1 2 #ifndef _SP1_H 3 #define _SP1_H 4 5 /////////////////////////////////////////////////////////// 6 // SPRITE PACK v3.0 // 7 // Sinclair Spectrum Version // 8 // aralbrec - April / May 2006 // 9 /////////////////////////////////////////////////////////// 10 // // 11 // See the wiki for documentation details // 12 // http://www.z88dk.org/wiki // 13 // // 14 /////////////////////////////////////////////////////////// 15 16 #include <rect.h> 17 #include <sys/types.h> 18 19 /////////////////////////////////////////////////////////// 20 // DATA STRUCTURES // 21 /////////////////////////////////////////////////////////// 22 23 struct sp1_Rect { 24 25 uchar row; 26 uchar col; 27 uchar width; 28 uchar height; 29 30 }; 31 32 struct sp1_update; 33 struct sp1_ss; 34 struct sp1_cs; 35 36 struct sp1_update { // "update structs" - 10 bytes - Every tile in the display area managed by SP1 is described by one of these 37 38 uchar nload; // +0 bit 7 = 1 for invalidated, bit 6 = 1 for removed, bits 5:0 = number of occluding sprites present + 1 39 uchar colour; // +1 background tile attribute 40 uint tile; // +2 background 16-bit tile code (if MSB != 0 taken as address of graphic, else lookup in tile array) 41 struct sp1_cs *slist; // +4 BIG ENDIAN ; list of sprites occupying this tile (MSB = 0 if none) points at struct sp1_cs.attr_mask 42 struct sp1_update *ulist; // +6 BIG ENDIAN ; next update struct in list of update structs queued for draw (MSB = 0 if none) 43 uchar *screen; // +8 address in display file where this tile is drawn 44 45 }; 46 47 struct sp1_ss { // "sprite structs" - 20 bytes - Every sprite is described by one of these 48 49 uchar row; // +0 current y tile-coordinate 50 uchar col; // +1 current x tile-coordinate 51 uchar width; // +2 width of sprite in tiles 52 uchar height; // +3 height of sprite in tiles 53 54 uchar vrot; // +4 bit 7 = 1 for 2-byte graphical definition else 1-byte, bits 2:0 = current vertical rotation (0..7) 55 uchar hrot; // +5 current horizontal rotation (0..7) 56 57 uchar *frame; // +6 current sprite frame address added to graphic pointers 58 59 uchar res0; // +8 "LD A,n" opcode 60 uchar e_hrot; // +9 effective horizontal rotation = MSB of rotation table to use 61 uchar res1; // +10 "LD BC,nn" opcode 62 uint e_offset; // +11 effective offset to add to graphic pointers, equals result of vertical rotation + frame addr 63 uchar res2; // +13 "EX DE,HL" opcode 64 uchar res3; // +14 "JP (HL)" opcode 65 66 struct sp1_cs *first; // +15 BIG ENDIAN ; first struct sp1_cs of this sprite 67 68 uchar xthresh; // +17 hrot must be at least this number of pixels for last column of sprite to be drawn (1 default) 69 uchar ythresh; // +18 vrot must be at least this number of pixels for last row of sprite to be drawn (1 default) 70 uchar nactive; // +19 number of struct sp1_cs cells on display (written by sp1_MoveSpr*) 71 72 }; 73 74 struct sp1_cs { // "char structs" - 24 bytes - Every sprite is broken into pieces fitting into a tile, each of which is described by one of these 75 76 struct sp1_cs *next_in_spr; // +0 BIG ENDIAN ; next sprite char within same sprite in row major order (MSB = 0 if none) 77 78 struct sp1_update *update; // +2 BIG ENDIAN ; tile this sprite char currently occupies (MSB = 0 if none) 79 80 uchar plane; // +4 plane sprite occupies, 0 = closest to viewer 81 uchar type; // +5 bit 7 = 1 occluding, bit 6 = 1 last column, bit 5 = 1 last row, bit 4 = 1 clear pixelbuffer 82 uchar attr_mask; // +6 attribute mask logically ANDed with underlying attribute, default = 0xff for transparent 83 uchar attr; // +7 sprite colour, logically ORed to form final colour, default = 0 for transparent 84 85 void *ss_draw; // +8 struct sp1_ss + 8 bytes ; points at code embedded in sprite struct sp1_ss 86 87 uchar res0; // +10 typically "LD HL,nn" opcode 88 uchar *def; // +11 graphic definition pointer 89 uchar res1; // +13 typically "LD IX,nn" opcode 90 uchar res2; // +14 91 uchar *l_def; // +15 graphic definition pointer for sprite character to left of this one 92 uchar res3; // +17 typically "CALL nn" opcode 93 void *draw; // +18 & draw function for this sprite char 94 95 struct sp1_cs *next_in_upd; // +20 BIG ENDIAN ; & sp1_cs.attr_mask of next sprite occupying the same tile (MSB = 0 if none) 96 struct sp1_cs *prev_in_upd; // +22 BIG ENDIAN ; & sp1_cs.next_in_upd of previous sprite occupying the same tile 97 98 }; 99 100 struct sp1_ap { // "attribute pairs" - 2 bytes - A struct to hold sprite attribute and mask pairs 101 102 uchar attr_mask; // +0 attribute mask logically ANDed with underlying attribute = 0xff for transparent 103 uchar attr; // +1 sprite colour, logically ORed to form final colour = 0 for transparent 104 105 }; 106 107 struct sp1_tp { // "tile pairs" - 3 bytes - A struct to hold background colour and tile pairs 108 109 uchar attr; // +0 colour 110 uint tile; // +1 tile code 111 112 }; 113 114 struct sp1_pss { // "print string struct" - 11 bytes - A struct holding print state information 115 116 struct sp1_Rect *bounds; // +0 rectangular boundary within which printing will be allowed 117 uchar flags; // +2 bit 0=invalidate?, 1=xwrap?, 2=yinc?, 3=ywrap? 118 uchar x; // +3 current x coordinate of cursor with respect to top left corner of bounds 119 uchar y; // +4 current y coordinate of cursor with respect to top left corner of bounds 120 uchar attr_mask; // +5 current attribute mask 121 uchar attr; // +6 current attribute 122 struct sp1_update *pos; // +7 RESERVED struct sp1_update associated with current cursor coordinates 123 void *visit; // +9 void (*visit)(struct sp1_update *) function, set to 0 for none 124 125 }; 126 127 /////////////////////////////////////////////////////////// 128 // SPRITES // 129 /////////////////////////////////////////////////////////// 130 131 // sprite type bits 132 133 #define SP1_TYPE_OCCLUDE 0x80 // background and sprites underneath will not be drawn 134 #define SP1_TYPE_BGNDCLR 0x10 // for occluding sprites, copy background tile into pixel buffer before draw 135 136 #define SP1_TYPE_2BYTE 0x40 // sprite graphic consists of (mask,graph) pairs, valid only in sp1_CreateSpr() 137 #define SP1_TYPE_1BYTE 0x00 // sprite graphic consists of graph only, valid only in sp1_CreateSpr() 138 139 // sprite attribute masks, logically AND together if necessary 140 // spectrum.h contains defines for INK and PAPER colours 141 142 #define SP1_AMASK_TRANS 0xff // attribute mask for a transparent-colour sprite 143 #define SP1_AMASK_INK 0xf8 // attribute mask for an ink-only sprite 144 #define SP1_AMASK_PAPER 0xc7 // attribute mask for a paper-only sprite 145 #define SP1_AMASK_NOFLASH 0x7f // attribute mask for no-flash 146 #define SP1_AMASK_NOBRIGHT 0xbf // attribute mask for no-bright 147 #define SP1_ATTR_TRANS 0x00 // attribute for a transparent-colour sprite 148 149 // prototype struct_sp1_ss and struct_sp1_cs that can be used to initialize empty structures 150 151 extern struct sp1_cs sp1_struct_cs_prototype; 152 extern struct sp1_ss sp1_struct_ss_prototype; 153 154 // draw functions for sprites with two-byte graphical definitions, ie (mask,graphic) pairs 155 156 extern void __LIB__ SP1_DRAW_MASK2(void); // masked sprite 2-byte definition (mask,graph) pairs ; sw rotation will use MASK2_NR if no rotation necessary 157 extern void __LIB__ SP1_DRAW_MASK2NR(void); // masked sprite 2-byte definition (mask,graph) pairs ; no rotation applied, graphic always drawn at exact tile boundary 158 extern void __LIB__ SP1_DRAW_MASK2LB(void); // masked sprite 2-byte definition (mask,graph) pairs ; sw rotation as MASK2 but for left boundary of sprite only 159 extern void __LIB__ SP1_DRAW_MASK2RB(void); // masked sprite 2-byte definition (mask,graph) pairs ; sw rotation as MASK2 but for right boundary of sprite only 160 161 extern void __LIB__ SP1_DRAW_LOAD2(void); // load sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation will use LOAD2_NR if no rotation necessary 162 extern void __LIB__ SP1_DRAW_LOAD2NR(void); // load sprite 2-byte definition (mask,graph) pairs mask ignored; no rotation applied, always drawn at exact tile boundary 163 extern void __LIB__ SP1_DRAW_LOAD2LB(void); // load sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as LOAD2 but for left boundary of sprite only 164 extern void __LIB__ SP1_DRAW_LOAD2RB(void); // load sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as LOAD2 but for right boundary of sprite only 165 166 extern void __LIB__ SP1_DRAW_OR2(void); // or sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation will use OR2_NR if no rotation necessary 167 extern void __LIB__ SP1_DRAW_OR2NR(void); // or sprite 2-byte definition (mask,graph) pairs mask ignored; no rotation applied, always drawn at exact tile boundary 168 extern void __LIB__ SP1_DRAW_OR2LB(void); // or sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as OR2 but for left boundary of sprite only 169 extern void __LIB__ SP1_DRAW_OR2RB(void); // or sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as OR2 but for right boundary of sprite only 170 171 extern void __LIB__ SP1_DRAW_XOR2(void); // xor sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation will use XOR2_NR if no rotation necessary 172 extern void __LIB__ SP1_DRAW_XOR2NR(void); // xor sprite 2-byte definition (mask,graph) pairs mask ignored; no rotation applied, always drawn at exact tile boundary 173 extern void __LIB__ SP1_DRAW_XOR2LB(void); // xor sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as XOR2 but for left boundary of sprite only 174 extern void __LIB__ SP1_DRAW_XOR2RB(void); // xor sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as XOR2 but for right boundary of sprite only 175 176 extern void __LIB__ SP1_DRAW_LOAD2LBIM(void); // load sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as LOAD2 but for left boundary of sprite w/ implied mask 177 extern void __LIB__ SP1_DRAW_LOAD2RBIM(void); // load sprite 2-byte definition (mask,graph) pairs mask ignored; sw rotation as LOAD2 but for right boundary of sprite w/ implied mask 178 179 // draw functions for sprites with one-byte graphical definitions, ie no mask just graphics 180 181 extern void __LIB__ SP1_DRAW_LOAD1(void); // load sprite 1-byte definition graph only no mask; sw rotation will use LOAD1_NR if no rotation necessary 182 extern void __LIB__ SP1_DRAW_LOAD1NR(void); // load sprite 1-byte definition graph only no mask; no rotation applied, always drawn at exact tile boundary 183 extern void __LIB__ SP1_DRAW_LOAD1LB(void); // load sprite 1-byte definition graph only no mask; sw rotation as LOAD1 but for left boundary of sprite only 184 extern void __LIB__ SP1_DRAW_LOAD1RB(void); // load sprite 1-byte definition graph only no mask; sw rotation as LOAD1 but for right boundary of sprite only 185 186 extern void __LIB__ SP1_DRAW_OR1(void); // or sprite 1-byte definition graph only no mask; sw rotation will use OR1_NR if no rotation necessary 187 extern void __LIB__ SP1_DRAW_OR1NR(void); // or sprite 1-byte definition graph only no mask; no rotation applied, always drawn at exact tile boundary 188 extern void __LIB__ SP1_DRAW_OR1LB(void); // or sprite 1-byte definition graph only no mask; sw rotation as OR1 but for left boundary of sprite only 189 extern void __LIB__ SP1_DRAW_OR1RB(void); // or sprite 1-byte definition graph only no mask; sw rotation as OR1 but for right boundary of sprite only 190 191 extern void __LIB__ SP1_DRAW_XOR1(void); // xor sprite 1-byte definition graph only no mask; sw rotation will use XOR1_NR if no rotation necessary 192 extern void __LIB__ SP1_DRAW_XOR1NR(void); // xor sprite 1-byte definition graph only no mask; no rotation applied, always drawn at exact tile boundary 193 extern void __LIB__ SP1_DRAW_XOR1LB(void); // xor sprite 1-byte definition graph only no mask; sw rotation as XOR1 but for left boundary of sprite only 194 extern void __LIB__ SP1_DRAW_XOR1RB(void); // xor sprite 1-byte definition graph only no mask; sw rotation as XOR1 but for right boundary of sprite only 195 196 extern void __LIB__ SP1_DRAW_LOAD1LBIM(void); // load sprite 1-byte definition graph only no mask; sw rotation as LOAD1 but for left boundary of sprite with implied mask 197 extern void __LIB__ SP1_DRAW_LOAD1RBIM(void); // load sprite 1-byte definition graph only no mask; sw rotation as LOAD1 but for right boundary of sprite with implied mask 198 199 // draw functions for sprites without graphics 200 201 extern void __LIB__ SP1_DRAW_ATTR(void); // pixels are not drawn, only attributes 202 203 204 // void *hook1 <-> void [ __FASTCALL__ ] (*hook1)(uint count, struct sp1_cs *c) // if __FASTCALL__ only struct sp1_cs* passed 205 // void *hook2 <-> void [ __FASTCALL__ ] (*hook2)(uint count, struct sp1_update *u) // if __FASTCALL__ only struct sp1_update* passed 206 // 207 // void *drawf <-> void (*drawf)(void) // sprite draw function containing draw code and data for struct_sp1_cs 208 209 extern struct sp1_ss __LIB__ *sp1_CreateSpr(void *drawf, uchar type, uchar height, int graphic, uchar plane); 210 extern uint __LIB__ sp1_AddColSpr(struct sp1_ss *s, void *drawf, uchar type, int graphic, uchar plane); 211 extern void __LIB__ sp1_ChangeSprType(struct sp1_cs *c, void *drawf); 212 extern void __FASTCALL__ __LIB__ sp1_DeleteSpr(struct sp1_ss *s); // only call after sprite is moved off screen 213 214 extern void __LIB__ sp1_MoveSprAbs(struct sp1_ss *s, struct sp1_Rect *clip, void *frame, uchar row, uchar col, uchar vrot, uchar hrot); 215 extern void __LIB__ sp1_MoveSprRel(struct sp1_ss *s, struct sp1_Rect *clip, void *frame, char rel_row, char rel_col, char rel_vrot, char rel_hrot); 216 extern void __LIB__ sp1_MoveSprPix(struct sp1_ss *s, struct sp1_Rect *clip, void *frame, uint x, uint y); 217 218 extern void __LIB__ sp1_IterateSprChar(struct sp1_ss *s, void *hook1); 219 extern void __LIB__ sp1_IterateUpdateSpr(struct sp1_ss *s, void *hook2); 220 221 extern void __LIB__ sp1_GetSprClrAddr(struct sp1_ss *s, uchar **sprdest); 222 extern void __LIB__ sp1_PutSprClr(uchar **sprdest, struct sp1_ap *src, uchar n); 223 extern void __LIB__ sp1_GetSprClr(uchar **sprsrc, struct sp1_ap *dest, uchar n); 224 225 extern void __LIB__ *sp1_PreShiftSpr(uchar flag, uchar height, uchar width, void *srcframe, void *destframe, uchar rshift); 226 227 // some functions for displaying independent struct_sp1_cs not connected with any sprites; useful as foreground elements 228 // if not using a no-rotate (NR) type sprite draw function, must manually init the sp1_cs.ldef member after calling sp1_InitCharStruct() 229 230 extern void __LIB__ sp1_InitCharStruct(struct sp1_cs *cs, void *drawf, uchar type, void *graphic, uchar plane); 231 extern void __LIB__ sp1_InsertCharStruct(struct sp1_update *u, struct sp1_cs *cs); 232 extern void __FASTCALL__ __LIB__ sp1_RemoveCharStruct(struct sp1_cs *cs); 233 234 235 /* CALLEE LINKAGE */ 236 237 extern struct sp1_ss __CALLEE__ __LIB__ *sp1_CreateSpr_callee(void *drawf, uchar type, uchar height, int graphic, uchar plane); 238 extern uint __CALLEE__ __LIB__ sp1_AddColSpr_callee(struct sp1_ss *s, void *drawf, uchar type, int graphic, uchar plane); 239 extern void __CALLEE__ __LIB__ sp1_MoveSprAbs_callee(struct sp1_ss *s, struct sp1_Rect *clip, void *frame, uchar row, uchar col, uchar vrot, uchar hrot); 240 extern void __CALLEE__ __LIB__ sp1_MoveSprRel_callee(struct sp1_ss *s, struct sp1_Rect *clip, void *frame, char rel_row, char rel_col, char rel_vrot, char rel_hrot); 241 extern void __CALLEE__ __LIB__ sp1_MoveSprPix_callee(struct sp1_ss *s, struct sp1_Rect *clip, void *frame, uint x, uint y); 242 extern void __CALLEE__ __LIB__ sp1_IterateSprChar_callee(struct sp1_ss *s, void *hook1); 243 extern void __CALLEE__ __LIB__ sp1_IterateUpdateSpr_callee(struct sp1_ss *s, void *hook2); 244 extern void __CALLEE__ __LIB__ sp1_ChangeSprType_callee(struct sp1_cs *c, void *drawf); 245 extern void __CALLEE__ __LIB__ sp1_GetSprClrAddr_callee(struct sp1_ss *s, uchar **sprdest); 246 extern void __CALLEE__ __LIB__ sp1_PutSprClr_callee(uchar **sprdest, struct sp1_ap *src, uchar n); 247 extern void __CALLEE__ __LIB__ sp1_GetSprClr_callee(uchar **sprsrc, struct sp1_ap *dest, uchar n); 248 extern void __CALLEE__ __LIB__ *sp1_PreShiftSpr_callee(uchar flag, uchar height, uchar width, void *srcframe, void *destframe, uchar rshift); 249 extern void __CALLEE__ __LIB__ sp1_InitCharStruct_callee(struct sp1_cs *cs, void *drawf, uchar type, void *graphic, uchar plane); 250 extern void __CALLEE__ __LIB__ sp1_InsertCharStruct_callee(struct sp1_update *u, struct sp1_cs *cs); 251 252 #define sp1_CreateSpr(a,b,c,d,e) sp1_CreateSpr_callee(a,b,c,d,e) 253 #define sp1_AddColSpr(a,b,c,d,e) sp1_AddColSpr_callee(a,b,c,d,e) 254 #define sp1_MoveSprAbs(a,b,c,d,e,f,g) sp1_MoveSprAbs_callee(a,b,c,d,e,f,g) 255 #define sp1_MoveSprRel(a,b,c,d,e,f,g) sp1_MoveSprRel_callee(a,b,c,d,e,f,g) 256 #define sp1_MoveSprPix(a,b,c,d,e) sp1_MoveSprPix_callee(a,b,c,d,e) 257 #define sp1_IterateSprChar(a,b) sp1_IterateSprChar_callee(a,b) 258 #define sp1_IterateUpdateSpr(a,b) sp1_IterateUpdateSpr_callee(a,b) 259 #define sp1_ChangeSprType(a,b) sp1_ChangeSprType_callee(a,b) 260 #define sp1_GetSprClrAddr(a,b) sp1_GetSprClrAddr_callee(a,b) 261 #define sp1_PutSprClr(a,b,c) sp1_PutSprClr_callee(a,b,c) 262 #define sp1_GetSprClr(a,b,c) sp1_GetSprClr_callee(a,b,c) 263 #define sp1_PreShiftSpr(a,b,c,d,e,f) sp1_PreShiftSpr_callee(a,b,c,d,e,f) 264 #define sp1_InitCharStruct(a,b,c,d,e) sp1_InitCharStruct_callee(a,b,c,d,e) 265 #define sp1_InsertCharStruct(a,b) sp1_InsertCharStruct_callee(a,b) 266 267 268 /////////////////////////////////////////////////////////// 269 // COLLISION DETECTION // 270 /////////////////////////////////////////////////////////// 271 272 // BEING REVIEWED FOR CHANGES - DON'T USE 273 274 // These are adapter functions for the rectangles library. 275 // You must link to the rectangles library during compilation 276 // if you use these functions "-lrect". 277 278 // Collision is detected for non-zero return values 279 // and carry flag set. 280 281 // Notice that each struct_sp1_ss begins with a struct_sp1_Rect, 282 // meaning a struct_sp1_ss can be used where struct_sp1_Rect 283 // appears below. 284 285 extern int __LIB__ sp1_IsPtInRect(uchar x, uchar y, struct sp1_Rect *r); 286 extern int __LIB__ sp1_IsPt8InRect(uint x, uint y, struct sp1_Rect *r); // point coords divided by 8 287 extern int __LIB__ sp1_IsRectInRect(struct sp1_Rect *r1, struct sp1_Rect *r2); 288 extern int __LIB__ sp1_IntersectRect(struct sp1_Rect *r1, struct sp1_Rect *r2, struct sp1_Rect *result); 289 290 // straight conversions from struct sp1_Rect to struct r_Rect8/16 291 292 extern void __LIB__ sp1_MakeRect8(struct sp1_Rect *s, struct r_Rect8 *r); 293 extern void __LIB__ sp1_MakeRect16(struct sp1_Rect *s, struct r_Rect16 *r); 294 295 // conversions from struct sp1_ss to struct r_Rect8/16 with character coordinates changed to pixel coordinates 296 // horizontal and vertical rotation also added to pixel coordinate origin 297 298 extern void __LIB__ sp1_MakeRect8Pix(struct sp1_ss *s, struct r_Rect8 *r); 299 extern void __LIB__ sp1_MakeRect16Pix(struct sp1_ss *s, struct r_Rect16 *r); 300 301 /////////////////////////////////////////////////////////// 302 // TILES // 303 /////////////////////////////////////////////////////////// 304 305 #define SP1_RFLAG_TILE 0x01 306 #define SP1_RFLAG_COLOUR 0x02 307 #define SP1_RFLAG_SPRITE 0x04 308 309 #define SP1_PSSFLAG_INVALIDATE 0x01 310 #define SP1_PSSFLAG_XWRAP 0x02 311 #define SP1_PSSFLAG_YINC 0x04 312 #define SP1_PSSFLAG_YWRAP 0x08 313 314 extern void __LIB__ *sp1_TileEntry(uchar c, void *def); 315 316 extern void __LIB__ sp1_PrintAt(uchar row, uchar col, uchar colour, uint tile); 317 extern void __LIB__ sp1_PrintAtInv(uchar row, uchar col, uchar colour, uint tile); 318 extern uint __LIB__ sp1_ScreenStr(uchar row, uchar col); 319 extern uchar __LIB__ sp1_ScreenAttr(uchar row, uchar col); 320 321 extern void __LIB__ sp1_PrintString(struct sp1_pss *ps, uchar *s); 322 extern void __LIB__ sp1_SetPrintPos(struct sp1_pss *ps, uchar row, uchar col); 323 324 extern void __LIB__ sp1_GetTiles(struct sp1_Rect *r, struct sp1_tp *dest); 325 extern void __LIB__ sp1_PutTiles(struct sp1_Rect *r, struct sp1_tp *src); 326 extern void __LIB__ sp1_PutTilesInv(struct sp1_Rect *r, struct sp1_tp *src); 327 328 extern void __LIB__ sp1_ClearRect(struct sp1_Rect *r, uchar colour, uchar tile, uchar rflag); 329 extern void __LIB__ sp1_ClearRectInv(struct sp1_Rect *r, uchar colour, uchar tile, uchar rflag); 330 331 /* CALLEE LINKAGE */ 332 333 extern void __CALLEE__ __LIB__ *sp1_TileEntry_callee(uchar c, void *def); 334 extern void __CALLEE__ __LIB__ sp1_PrintAt_callee(uchar row, uchar col, uchar colour, uint tile); 335 extern void __CALLEE__ __LIB__ sp1_PrintAtInv_callee(uchar row, uchar col, uchar colour, uint tile); 336 extern uint __CALLEE__ __LIB__ sp1_ScreenStr_callee(uchar row, uchar col); 337 extern uchar __CALLEE__ __LIB__ sp1_ScreenAttr_callee(uchar row, uchar col); 338 extern void __CALLEE__ __LIB__ sp1_PrintString_callee(struct sp1_pss *ps, uchar *s); 339 extern void __CALLEE__ __LIB__ sp1_SetPrintPos_callee(struct sp1_pss *ps, uchar row, uchar col); 340 extern void __CALLEE__ __LIB__ sp1_GetTiles_callee(struct sp1_Rect *r, struct sp1_tp *dest); 341 extern void __CALLEE__ __LIB__ sp1_PutTiles_callee(struct sp1_Rect *r, struct sp1_tp *src); 342 extern void __CALLEE__ __LIB__ sp1_PutTilesInv_callee(struct sp1_Rect *r, struct sp1_tp *src); 343 extern void __CALLEE__ __LIB__ sp1_ClearRect_callee(struct sp1_Rect *r, uchar colour, uchar tile, uchar rflag); 344 extern void __CALLEE__ __LIB__ sp1_ClearRectInv_callee(struct sp1_Rect *r, uchar colour, uchar tile, uchar rflag); 345 346 #define sp1_TileEntry(a,b) sp1_TileEntry_callee(a,b) 347 #define sp1_PrintAt(a,b,c,d) sp1_PrintAt_callee(a,b,c,d) 348 #define sp1_PrintAtInv(a,b,c,d) sp1_PrintAtInv_callee(a,b,c,d) 349 #define sp1_ScreenStr(a,b) sp1_ScreenStr_callee(a,b) 350 #define sp1_ScreenAttr(a,b) sp1_ScreenAttr_callee(a,b) 351 #define sp1_PrintString(a,b) sp1_PrintString_callee(a,b) 352 #define sp1_SetPrintPos(a,b,c) sp1_SetPrintPos_callee(a,b,c) 353 #define sp1_GetTiles(a,b) sp1_GetTiles_callee(a,b) 354 #define sp1_PutTiles(a,b) sp1_PutTiles_callee(a,b) 355 #define sp1_PutTilesInv(a,b) sp1_PutTilesInv_callee(a,b) 356 #define sp1_ClearRect(a,b,c,d) sp1_ClearRect_callee(a,b,c,d) 357 #define sp1_ClearRectInv(a,b,c,d) sp1_ClearRectInv_callee(a,b,c,d) 358 359 360 /////////////////////////////////////////////////////////// 361 // UPDATER // 362 /////////////////////////////////////////////////////////// 363 364 #define SP1_IFLAG_MAKE_ROTTBL 0x01 365 #define SP1_IFLAG_OVERWRITE_TILES 0x02 366 #define SP1_IFLAG_OVERWRITE_DFILE 0x04 367 368 // void *hook <-> void [ __FASTCALL__ ] (*hook)(struct sp1_update *u) 369 370 extern void __LIB__ sp1_Initialize(uchar iflag, uchar colour, uchar tile); 371 extern void __LIB__ sp1_UpdateNow(void); 372 373 extern struct sp1_update __LIB__ *sp1_GetUpdateStruct(uchar row, uchar col); 374 extern void __LIB__ sp1_IterateUpdateArr(struct sp1_update **ua, void *hook); // zero terminated array 375 extern void __LIB__ sp1_IterateUpdateRect(struct sp1_Rect *r, void *hook); 376 377 extern void __FASTCALL__ __LIB__ sp1_InvUpdateStruct(struct sp1_update *u); 378 extern void __FASTCALL__ __LIB__ sp1_ValUpdateStruct(struct sp1_update *u); 379 380 extern void __FASTCALL__ __LIB__ sp1_DrawUpdateStructIfInv(struct sp1_update *u); 381 extern void __FASTCALL__ __LIB__ sp1_DrawUpdateStructIfVal(struct sp1_update *u); 382 extern void __FASTCALL__ __LIB__ sp1_DrawUpdateStructIfNotRem(struct sp1_update *u); 383 extern void __FASTCALL__ __LIB__ sp1_DrawUpdateStructAlways(struct sp1_update *u); 384 385 extern void __FASTCALL__ __LIB__ sp1_RemoveUpdateStruct(struct sp1_update *u); 386 extern void __FASTCALL__ __LIB__ sp1_RestoreUpdateStruct(struct sp1_update *u); 387 388 extern void __FASTCALL__ __LIB__ sp1_Invalidate(struct sp1_Rect *r); 389 extern void __FASTCALL__ __LIB__ sp1_Validate(struct sp1_Rect *r); 390 391 /* CALLEE LINKAGE */ 392 393 extern void __CALLEE__ __LIB__ sp1_Initialize_callee(uchar iflag, uchar colour, uchar tile); 394 extern struct sp1_update __CALLEE__ __LIB__ *sp1_GetUpdateStruct_callee(uchar row, uchar col); 395 extern void __CALLEE__ __LIB__ sp1_IterateUpdateArr_callee(struct sp1_update **ua, void *hook); 396 extern void __CALLEE__ __LIB__ sp1_IterateUpdateRect_callee(struct sp1_Rect *r, void *hook); 397 398 399 #define sp1_Initialize(a,b,c) sp1_Initialize_callee(a,b,c) 400 #define sp1_GetUpdateStruct(a,b) sp1_GetUpdateStruct_callee(a,b) 401 #define sp1_IterateUpdateArr(a,b) sp1_IterateUpdateArr_callee(a,b) 402 #define sp1_IterateUpdateRect(a,b) sp1_IterateUpdateRect_callee(a,b) 403 404 405 #endif 406