Japanese
PROGRAMMER'S GUIDEVDP1 library
■ | Go forward
VDP1 library

1.VDP1 basic processing guide


1.1 Purpose

1.2 Explanation

[Initial processing]

[V-BLANK interrupt processing function]

1.3 How to change the sprite execution environment

Slave SH and DSP are used to perform high-speed 3D and 2D processing, but depending on the application, you may not want to use them on the library side. In this 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 provided below.

(1) SPR_SYNC_VB_OUT
When this is defined, the frame buffer switching wait for the sprite in SCL_DisplayFrame() becomes V blanked out, increasing the processing time for one field.
Scroll register writing is performed at V blank-in without waiting for SCL_DisplayFrame().
If you comment out, scrolling and sprites will be synchronized using V blank in as usual.

(2) USE_SLAVE
Defining this will use the slave CPU to perform parallel processing with the main CPU.
If you comment it out, the slave CPU will not be used.

(3) USE_DSP
If this is defined, matrix synthesis of coordinate transformation will be performed on the DSP, and processing will be performed in parallel with the CPU side.
If commented out, DSP will not be used.

(4) USE_INBETWEEN_OBJECT
By defining this, you can process connection polygons between objects. If there are no connecting polygons between objects, you can slightly improve the shape of the 3D library by commenting out this definition.

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

extern int dbgComputePol; /* Number of calculation polygons */
extern int dbgDrawPol; /* Number of polygons to draw */

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 sprite */

     INT_ChgMsk(INT_MSK_NULL, INT_MSK_VBL_IN | INT_MSK_VBL_OUT);
                                    /* Disable V-BLANK interrupt */
     INT_SetFunc(INT_SCU_VBLK_IN, &vbStart);     
                                    /* Register V-BLANK IN interrupt routine */
     INT_SetFunc(INT_SCU_VBLK_OUT, &vbEnd);     
                                    /* Register 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 to VRAM */

              -------- /* Scroll data set */
           SCL_DisplayFrame(); /* Waiting for V-BLANK interrupt */
                                    /* Display sprite and perform scrolling */
     }
 }

−V blank processing routine (source file separate from the main above) −

#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 */
}


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