Area name | Number of blocks |
---|---|
VRAM area reference switch command | 1 |
System command area | 4×2 |
User command area | COMMAND_MAX×2 |
gouraud shading table area | (GOUR_TBL_MAX+3)/4×2 |
color lookup table area | LOOKUP_TBL_MAX |
block pool area | All remaining blocks |
SPR_2LocalCoord() | SPR_2SysClip() | SPR_2UserClip() | SPR_2line() |
SPR_2polyLine() | SPR_2Polygon() | SPR_2NormSpr() | SPR_2ScaleSpr() |
SPR_2DistSpr() | SPR_2Cmd() |
The number of blocks for this drawing order management is specified in advance in the 2D work area definition. Prioritize drawing
If you do not want to do this, you can specify it in the 2D work area definition and SPR_2OpenCommand().
#include< machine.h> #define _SPR2_ /* Use sprite display extension library */ #include "sega_spr.h" #include "sega_scl.h" #include "sega_int.h"#define COMMAND_MAX 512 /* Maximum number of commands */ #define GOUR_TBL_MAX 512 /* Maximum number of GOUR_TBL_MAX */ #define LOOKUP_TBL_MAX 512 /* Maximum number of lookup tables */ #define CHAR_MAX 100 /* Maximum number of characters */ #define DRAW_PRTY_MAX 256 /* Maximum number of drawing priority blocks */ SPR_2DefineWork(work2d, COMMAND_MAX, GOUR_TBL_MAX, LOOKUP_TBL_MAX, CHAR_MAX, DRAW_PRTY_MAX) /* 2D work area definition */ extern void vbStart(void); /* V-BLANK IN interrupt routine */ extern void vbEnd(void); /* V-BLANK OUT interrupt routine */ main() { 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_2Initial(&work2d); /* 2D sprite display initialization */ 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 */ for(;;){ SPR_2SetChar(...); /* Set character data to VRAM */ } SPR_2FrameChgIntr(0xffff); /* Frame change interval */ /* Set to indeterminate mode */ for(;;){ ------------- /* Scroll data set */ SPR_2OpenCommand(SPR_2DRAW_PRTY_OFF); /* Open for command writing */ SPR_2SysClip(0,&xy); /* System clip area command */ SPR_2LocalCoord(0,&xy); /* Local coordinate command */ SPR_2Polygon(...); /* Various sprite commands */ SPR_2NormSpr(...); /* . . . SPR_2CloseCommand(); /* Close command write */ SCL_DisplayFrame(); /* Wait 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 */ -------- }