1 /* 2 * Sega Master System 3 * 4 * $Id: sms.h,v 1.5 2017-01-03 02:23:05 aralbrec Exp $ 5 */ 6 7 #ifndef __SMS_H__ 8 #define __SMS_H__ 9 10 #include <sys/compiler.h> 11 12 #include <compress/aplib.h> 13 14 #define VDP_REG_FLAGS0 0x80 15 // Screen sync off 16 #define VDP_REG_FLAGS0_SYNC 0x01 17 // Normal or enable stretch screen 18 #define VDP_REG_FLAGS0_STRETCH 0x02 19 // Causes graphics change (related to screen addr?) 20 #define VDP_REG_FLAGS0_CHANGE 0x04 21 // Shift sprites left by 1 character 22 #define VDP_REG_FLAGS0_SHIFT 0x08 23 // Horizontal interupts enable 24 #define VDP_REG_FLAGS0_HINT 0x10 25 // Display extra column on LHS of screen 26 #define VDP_REG_FLAGS0_LHS 0x20 27 // Top 2 rows of screen horizontal non-scrolling 28 #define VDP_REG_FLAGS0_LOCKTOP 0x40 29 // Right side of screen vertical non-scrolling 30 #define VDP_REG_FLAGS0_LOCKRIGHT 0x80 31 32 33 #define VDP_REG_FLAGS1 0x81 34 // Double sized pixels in sprites 35 #define VDP_REG_FLAGS1_DOUBLE 0x01 36 // 8x16 sprites 37 #define VDP_REG_FLAGS1_8x16 0x02 38 // 0? 39 #define VDP_REG_FLAGS1_BIT2 0x04 40 // Stretch screen by 6 rows 41 #define VDP_REG_FLAGS1_STRETCH6 0x08 42 // Stretch screen by 4 rows 43 #define VDP_REG_FLAGS1_STRETCH4 0x10 44 // Vertical interrupts enable 45 #define VDP_REG_FLAGS1_VINT 0x20 46 // Screen enable 47 #define VDP_REG_FLAGS1_SCREEN 0x40 48 // 0? 49 #define VDP_REG_FLAGS1_BIT7 0x80 50 51 #define VDP_REG_HINT_COUNTER 0x8A 52 53 // Bkg tile appears in front of the sprites 54 #define BKG_ATTR_PRIO 0x1000 55 // Bkg tile uses sprite palette 56 #define BKG_ATTR_SPRPAL 0x0800 57 // Bkg tile is vertically flipped 58 #define BKG_ATTR_VFLIP 0x0400 59 // Bkg tile is horizontally flipped 60 #define BKG_ATTR_HFLIP 0x0200 61 // Bkg tile uses the second tileset 62 #define BKG_ATTR_2NDTILESET 0x0100 63 64 #define __SMS_JOY_UP 0x01 65 #define __SMS_JOY_DOWN 0x02 66 #define __SMS_JOY_LEFT 0x04 67 #define __SMS_JOY_RIGHT 0x08 68 #define __SMS_JOY_FIREA 0x10 69 #define __SMS_JOY_FIREB 0x20 70 71 #ifndef JOY_UP 72 // JOY_UP is defined in games.h using standard z88dk bits 73 #define JOY_UP __SMS_JOY_UP 74 #define JOY_DOWN __SMS_JOY_DOWN 75 #define JOY_LEFT __SMS_JOY_LEFT 76 #define JOY_RIGHT __SMS_JOY_RIGHT 77 #define JOY_FIREA __SMS_JOY_FIREA 78 #define JOY_FIREB __SMS_JOY_FIREB 79 #endif 80 81 82 typedef char INT8; 83 typedef unsigned char UINT8; 84 typedef int INT16; 85 typedef unsigned int UINT16; 86 typedef long INT32; 87 typedef unsigned long UINT32; 88 89 typedef INT8 BYTE; 90 typedef UINT8 UBYTE; 91 typedef INT16 WORD; 92 typedef UINT16 UWORD; 93 typedef INT32 LWORD; 94 typedef UINT32 ULWORD; 95 typedef INT32 DWORD; 96 typedef UINT32 UDWORD; 97 98 #ifndef NULL 99 #define NULL 0 100 #endif 101 102 #ifndef FALSE 103 #define FALSE 0 104 #define TRUE 1 105 #endif 106 107 /* Useful definition for fixed point values */ 108 typedef union _fixed { 109 struct { 110 UBYTE l; 111 UBYTE h; 112 } b; 113 UWORD w; 114 } fixed; 115 116 extern void __LIB__ clear_vram(); 117 // Load a 6 bit palette - for both gamegear and sms 118 extern void __LIB__ load_palette(unsigned char *data, int index, int count) __smallc; 119 // Load a 12 bit palette - gamegear only 120 extern void __LIB__ load_palette_gamegear(unsigned int *data, int index, int count) __smallc; 121 extern void __LIB__ load_tiles(unsigned char *data, int index, int count, int bpp) __smallc; 122 extern void __LIB__ set_bkg_map(unsigned int *data, int x, int y, int w, int h) __smallc; 123 extern void __LIB__ scroll_bkg(int x, int y) __smallc; 124 extern int __LIB__ get_vcount(); 125 extern int __LIB__ wait_vblank_noint(); 126 extern void __LIB__ set_sprite(int n, int x, int y, int tile) __smallc; 127 128 // Following two methods return __SMS_JOY_XX 129 extern int __LIB__ read_joypad1(); 130 extern int __LIB__ read_joypad2(); 131 132 #ifndef gotoxy 133 // gotoxy is defined in conio.h, so avoid the clash 134 #define gotoxy(x,y) gotoxy_sms(x,y) 135 #endif 136 extern void __LIB__ gotoxy_sms(int x, int y) __smallc; 137 extern unsigned char standard_font[]; /* Actually data *not* a function */ 138 139 extern void __LIB__ set_vdp_reg(int reg, int value) __smallc; 140 extern void __LIB__ add_raster_int(void *ptr); 141 extern void __LIB__ add_pause_int(void *ptr); 142 extern void __LIB__ set_sound_freq(int channel, int freq) __smallc; 143 extern void __LIB__ set_sound_volume(int channel, int volume) __smallc; 144 145 146 147 extern unsigned char pause_flag; 148 149 #endif 150