★ PROGRAMMER'S GUIDE ★ VDP1 library
Area name | Number of blocks |
|---|---|
VRAM area reference switch command | 1 |
System command area | 4x2 |
User command area | COMMAND_MAX × 2 |
Gouraud shading table area | (GOUR_TBL_MAX + 3) / 4 × 2 |
Color look-up 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. If you do not want to prioritize the drawing, you can specify it in the 2D work area definition and SPR_2OpenCommand ().
#include <machine.h> #define _SPR2_ / * Using 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 gouro tables * / #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); / * Initialize 2D sprite display * / 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 * / for (;;) { SPR_2SetChar (...); / * Character dataset to VRAM * / } SPR_2FrameChgIntr (0xffff); / * Set frame change interval * / / * Set to indefinite mode * / for (;;) { ------------- / * Scroll dataset * / SPR_2OpenCommand (SPR_2DRAW_PRTY_OFF); / * Open command write * / SPR_2SysClip (0, & xy); / * System clip area command * / SPR_2LocalCoord (0, & xy); / * Local coordinate command * / SPR_2Polygon (...); / * Various sprite commands * / SPR_2NormSpr (...); / *. .. .. SPR_2CloseCommand (); / * Command write close * / SCL_DisplayFrame (); / * Wait 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 * / -------- }
★ PROGRAMMER'S GUIDE ★ VDP1 library