In this chapter, we will explain the recognition method and actual operation of Sega Saturn's data input device using Sega Saturn's representative input device, Sega Saturn PAD.
The Sega Saturn PAD has four direction keys, ABCXYZ buttons, LR button and start button on the top of the controller as input devices.
We will explain how the data input using each input device of these controllers is judged inside the Sega Saturn, along with sample programs.
The data input device mainly used on the Sega Saturn is the control PAD that comes with the main unit, called the Sega Saturn PAD.
Sega Saturn PAD is an input device consisting of direction keys, start button, ABC button, XYZ button, and LR button arranged to point in four directions.
Figure 9-1 Example of input device (Sega Saturn PAD)
Attribute | Name | Input configuration | remarks |
---|---|---|---|
Digital | Sega Saturn PAD | Directional key, start, 8 button | Sega Saturn standard pad |
sega saturn mouse | XY movement amount, start, 3 buttons | The amount of mouse movement is stored as an absolute value. | |
megadora 3 button pad | Directional key, start, 3 button | Can be connected with Sega Tap | |
megadora 6 button pad | Directional key, start, 6 button | Can be connected with Sega Tap | |
analog | analog joystick (Mission Stick) | Direction lever, start, 8 buttons | The amount of movement is the absolute value of the unsigned A/D output. |
Special | sega saturn keyboard | Compatible with IBM keyboards | |
Auxiliary equipment | Sega Saturn 6P Multitap | Number of connections: 6 | |
sega tap | Number of connections 4 | Used to connect Megadora PAD |
Sega Saturn PAD is processed as a set of bits as shown below.
bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 | |
---|---|---|---|---|---|---|---|---|
Peripheral ID | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
1st DATA | → | ← | ↓ | ↑ | Start | A | C | B |
2nd DATA | R | X | Y | Z | L | 1 | 1 | 1 |
Figure 9-2 Sega Saturn PAD input status bit array (16bit display)
Figure 9-3 Changes in input status bit string (Sega Saturn PAD)
● Definition contents of PerDigital structure ● typedef struct{ /* digital device */ Uint8 id; /* Peripheral ID */ Uint16 data; /* Current peripheral data */ Uint16 push /* Data of the pressed switch */ Uint16 pull /* Released switch data */ }PerDigital;
data: 16-bit peripheral data (indicates the current bit state) push: 16-bit peripheral data (bits change only at the moment the input is executed) pull: 16-bit peripheral data (bits change only at the moment the input is released) id: 8-bit data string indicating the device peripheral ID
Note
For details on peripherals, please refer to “HARDWEAR MANUAL vol.1” and the header file “sl_def.h” included with the system.
● Pat assignment ● #define PER_DGT_KR (1<< 15) /* Direction key (→) */ #define PER_DGT_KL (1<< 14) /* Direction key (←) */ #define PER_DGT_KD (1<< 13) /* Direction key (↓) */ #define PER_DGT_KU (1<< 12) /* Direction key (↑) */ #define PER_DGT_ST (1<< 11) /* Start button */ #define PER_DGT_TA (1<< 10) /* A button */ #define PER_DGT_TC (1<< 9) /* C button */ #define PER_DGT_TB (1<< 8) /* B button */ #define PER_DGT_TR (1<< 7) /* R trigger */ #define PER_DGT_TX (1<< 6) /* X button */ #define PER_DGT_TY (1<< 5) /* Y button */ #define PER_DGT_TZ (1<< 4) /* Z button */ #define PER_DGT_TL (1<< 3) /* L trigger */
Figure 9-6 Pad assignment contents (for PER_DGT_TA)
/*------------------------------------------------ ----------------------*/ /* Pad Control */ /*------------------------------------------------ ----------------------*/ #include "sgl.h" #include "sega_sys.h" #define NBG1_CEL_ADR ( VDP2_VRAM_B1 + 0x02000 ) #define NBG1_MAP_ADR ( VDP2_VRAM_B1 + 0x12000 ) #define NBG1_COL_ADR ( VDP2_COLRAM + 0x00200 ) #define BACK_COL_ADR ( VDP2_VRAM_A1 + 0x1fffe ) #define PAD_NUM 13 static Uint16 pad_asign[] = { PER_DGT_KU, PER_DGT_KD, PER_DGT_KR, PER_DGT_KL, PER_DGT_TA, PER_DGT_TB, PER_DGT_TC, PER_DGT_ST, PER_DGT_TX, PER_DGT_TY, PER_DGT_TZ, PER_DGT_TR, PER_DGT_TL, }; extern pad_cel[]; extern pad_map[]; extern pad_pal[]; extern TEXTURE tex_spr[]; extern PICTURE pic_spr[]; extern FIXED stat[][XYZS]; extern SPR_ATTR attr[]; extern ANGLE angz[]; static void set_sprite(PICTURE *pcptr , Uint32 NbPicture) { TEXTURE *txptr; for(; NbPicture--> 0; pcptr++){ txptr = tex_spr + pcptr-> texno; slDMACopy((void *)pcptr-> pcsrc, (void *)(SpriteVRAM + ((txptr-> (CGadr)<< 3)), (Uint32)((txptr-> Hsize * txptr-> Vsize * 4)>> (pcptr-> cmode))); } } static void disp_sprite() { static Sint32 i; Uint16 data; if(!Per_Connect1) return; data = Smpc_Peripheral[0].data; for(i=0;i< PAD_NUM;i++){ if((data & pad_asign[i])==0){ slDispSprite((FIXED *)stat[i], (SPR_ATTR *)(&attr[i].texno),(ANGLE)angz[i]); } } } void ss_main(void) { slInitSystem(TV_320x224,tex_spr,1); slTVOff(); set_sprite(pic_spr,1); slPrint("Sample program 9.1" , slLocate(9,2)); slColRAMMode(CRM16_1024); slBack1ColSet((void *)BACK_COL_ADR , 0); slCharNbg1(COL_TYPE_256 , CHAR_SIZE_1x1); slPageNbg1((void *)NBG1_CEL_ADR , 0 , PNB_1WORD|CN_12BIT); slPlaneNbg1(PL_SIZE_1x1); slMapNbg1((void *)NBG1_MAP_ADR , (void *)NBG1_MAP_ADR , (void *)NBG1_MAP_ADR , (void *)NBG1_MAP_ADR); Cel2VRAM(pad_cel , (void *)NBG1_CEL_ADR , 483*64); Map2VRAM(pad_map, (void *)NBG1_MAP_ADR, 32, 19, 1, 256); Pal2CRAM(pad_pal , (void *)NBG1_COL_ADR , 256); slScrPosNbg1(toFIXED(-32.0) , toFIXED(-36.0)); slScrAutoDisp(NBG0ON | NBG1ON); slTVOn(); while(1) { disp_sprite(); slSynch(); } }
Forwarding destination | ||||
---|---|---|---|---|
increment | Decrement | fixed | ||
Rotation Sending Former | increment | Sinc_Dinc_Byte | Sinc_Ddec_Byte | Sinc_Dfix_Byte |
Decrement | Sdec_Dinc_Byte | Ban | Sdec_Dfix_Byte | |
fixed | Sfix_Dinc_Byte | Sfix_Ddec_Byte | Ban |
functional type | Function name | Parameter | function |
---|---|---|---|
void | slDispSprite | FIXED *pos,ATTR *atrb,ANGLE Zrot | Sprite display by specifying position, scale, and display angle |
void | slPutSprite | FIXED *pos,ATTR *atrb,ANGLE Zrot | Sprite display according to perspective transformation |
void | slSetSprite | SPRITE *parms,FIXED Zpos | Set in the buffer for transferring sprite data to hardware |
void | slDMACopy | void *src,void *dst,Uint32 cnt | DMA transfer of only C from A to B (same bus transfer possible) |
void | slDMAWait | void | Wait until DMA transfer is completed |
void | slDMAXCopy | void *src,void *dst,Uint32 cnt,Uint16 mode | DMA transfer from A to B with C only in transfer mode D (same bus transfer possible) |