PROGRAMMER'S GUIDEVDP1 library
■ | Advance
VDP1 library

1. VDP1 Basic Processing Guide


1.1 Purpose

1.2 Commentary

[Initial processing]

[V-BLANK interrupt processing function]

1.3 How to change the sprite execution environment

Slave SH and DSP are used for high-speed 3D and 2D processing, but depending on the application, you may want to avoid using them on the library side. In such a case, you can change the sprite execution environment by defining or commenting out the following #define defined at the beginning of sega_spr.h and rebuilding the sprite and scroll library.

/ * ------------------------------------------
 * Select 3D & Sprite Execute Environment
 * ---------------------------------------- * /
 #define SPR_SYNC_VB_OUT
 #define USE_SLAVE
 #define USE_DSP
 #define USE_INBETWEEN_OBJECT
 #define USE_DEBUG_INFO

A description of each #define is given below.

(1) SPR_SYNC_VB_OUT
If this is defined, the framebuffer switching wait of the sprite of SCL_DisplayFrame () will be V blankout, and the processing time of one field will be extended.
Scroll register writing is done with a V blank in without waiting for SCL_DisplayFrame ().
When commented out, the V blank-in will scroll and sprites will be synchronized as before.

(2) USE_SLAVE
If this is defined, the slave CPU will be used and parallel processing with the main CPU will be performed.
If commented out, the slave CPU will not be used.

(3) USE_DSP
If this is defined, the matrix composition of coordinate transformation will be performed by DSP, and parallel processing will be performed with the CPU side.
If you comment it out, the DSP will not be used.

(4) USE_INBETWEEN_OBJECT
If you define this, you can process the connecting polygons between objects. If you don't have inter-object connection polygons, commenting out this definition will give you a slight shape-up of your 3D library.

(5) USE_DEBUG_INFO
If this is defined, the number of polygons calculated by SPR_3DrawModel () and the number of drawing polygons will be set in the following variables.
This value is a cumulative value, so clear it if necessary on the application side.

extern int dbgComputePol; / * Number of calculated polygons * /
extern int dbgDrawPol; / * Number of drawing polygons * /

This variable is already defined in sega_spr.h.

1.4 Program description example

#include <machine.h>
#include "saga_spr.h"
#include "sega_scl.h"
#include "sega_int.h"

extern void vbStart (void); / * V-BLANK IN interrupt routine * /
extern void vbEnd (void); / * V-BLANK OUT interrupt routine * /
main ()

{
     Uint8 * vram; / * VRAM address storage area * /

     set_imask (0); / * Enable interrupts * /

     SCL_Vdp2Init (); / * Scroll and priority initialization * /
     SCL_SetPriority (SCL_SP0 | SCL_SP1 | SCL_SP2 | SCL_SP3 | SCL_SP4 |
                     SCL_SP5 | SCL_SP6 | SCL_SP7,7);
     SCL_SetSpriteMode (SCL_TYPE1, SCL_MIX, SCL_SP_WINDOW);
     SPR_Initial (& vram); / * Initialize sprites * /

     INT_ChgMsk (INT_MSK_NULL, INT_MSK_VBL_IN | INT_MSK_VBL_OUT);
                                    / * Disable V-BLANK interrupts * /
     INT_SetFunc (INT_SCU_VBLK_IN, & vbStart);     
                                    / * Registration of V-BLANK IN interrupt routine * /
     INT_SetFunc (INT_SCU_VBLK_OUT, & vbEnd);     
                                    / * Registration of V-BLANK OUT interrupt routine * /
     INT_ChgMsk (INT_MSK_VBL_IN | INT_MSK_VBL_OUT, INT_MSK_NULL);
                                    / * Enable V-BLANK interrupt * /

     SCL_SetFrameInterval (2); / * Set frame change interval * /
                                    / * Set to 2/60 seconds * /

     for (;;) {
           memcpy (vram, command, sizeof (command));
                                    / * Set sprite command in VRAM * /

              -------- / * Scroll dataset * /
           SCL_DisplayFrame (); / * Waiting for V-BLANK interrupt * /
                                    / * Sprite display and scrolling * /
     }
 }

−V Blank processing routine (source file different from the above main) −

#include <machine.h>
#include "sega_spr.h"
#include "sega_scl.h"

#pragma interrupt (VbStart)
#pragma interrupt (VbEnd)

void VbStart (void)
{
     SCL_VblankStart (); / * V blank start VDP interrupt processing * /

             -------- / * Other V blank start processing * /
}

void VbEnd (void)
{
     SCL_VblankEnd (); / * V blank end VDP interrupt processing * /
     -------- / * Other V blank end processing * /
}


■ | Advance
PROGRAMMER'S GUIDEVDP1 library
Copyright SEGA ENTERPRISES, LTD., 1997