Japanese
PROGRAMMER'S GUIDEVDP1 library
BackForward
VDP1 library

2.VDP1 extended processing guide


2.1 Purpose

2.2 How to manage VRAM area

The VRAM area (512K bytes) is allocated and used as shown below.

[Description of each area]

[Allocation size of each area]
Allocate the size of each area as follows. One block is 32 bytes.

 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

COMMANND_MAX: Maximum number of commands
GOUR_TBL_MAX: Maximum number of Gouraud shading tables
LOOKUP_TBL_MAX: Maximum number of lookup tables

These values are defined using the VDP1 extended processing work area definition macro described later.

[Block allocation algorithm in block pool area]

●In case of acquisition
Searches for a free contiguous block area that satisfies the requested block size and allocates the smallest area.

●In case of release
If the specified block area is released and there is an adjacent free block, the free blocks are made continuous and combined into a large free block.

2.3 Draw order of sprite commands to the frame buffer

The drawing priority number when calling the sprite command setting routine below.
By specifying the number, you can set the drawing order for each command.

 SPR_2LocalCoord()
 SPR_2SysClip()
 SPR_2UserClip()
 SPR_2line()
 SPR_2polyLine()
 SPR_2Polygon()
 SPR_2NormSpr()
 SPR_2ScaleSpr()
 SPR_2DistSpr()
 SPR_2Cmd()

The drawing priority number indicates the drawing block number, and block number 0 is drawn first. Also, within the same block, commands are drawn in the order they are registered.

The drawing order setting operation is performed when calling the SPR_2CloseCommand() and SPR_2FlushDrawPrty() routines.
The control word jump specification and link specification word in the command are changed.

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().

2.4 Example of program description

An example of an actual program in C language is shown below.

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


BackForward
PROGRAMMER'S GUIDEVDP1 library
Copyright SEGA ENTERPRISES, LTD., 1997