1 2 // automatically generated by m4 from headers in proto subdir 3 4 5 #ifndef __BIFROST2_H__ 6 #define __BIFROST2_H__ 7 8 #include <arch.h> 9 #include <intrinsic.h> 10 11 /* ---------------------------------------------------------------- 12 * Z88DK INTERFACE LIBRARY FOR THE BIFROST*2 ENGINE - by Einar Saukas 13 * 14 * If you use this interface library, you must load afterwards the 15 * BIFROST*2 ENGINE and a multicolor tile set. For a detailed sample 16 * see file "bifrost2dem.c". 17 * ---------------------------------------------------------------- 18 */ 19 20 // ---------------------------------------------------------------- 21 // Constants 22 // ---------------------------------------------------------------- 23 24 extern unsigned char BIFROST2_tilemap[81]; 25 26 #define BIFROST2_STATIC 128 27 #define BIFROST2_DISABLED 255 28 29 // ---------------------------------------------------------------- 30 // Install BIFROST*2 ENGINE 31 // ---------------------------------------------------------------- 32 33 extern void BIFROST2_install(void); 34 35 36 // ---------------------------------------------------------------- 37 // Location of BIFROST*2 ISR hook 38 // ---------------------------------------------------------------- 39 40 extern unsigned char BIFROST2_ISR_HOOK[3]; 41 42 // ---------------------------------------------------------------- 43 // Location of BIFROST*2 hole 44 // ---------------------------------------------------------------- 45 46 #define BIFROST2_HOLE_SIZE __BIFROST2_HOLE_SIZE 47 48 #if BIFROST2_HOLE_SIZE > 0 49 extern unsigned char BIFROST2_HOLE[BIFROST2_HOLE_SIZE]; 50 #endif 51 52 // ---------------------------------------------------------------- 53 // Activate multicolor rendering with BIFROST*2 ENGINE 54 // ---------------------------------------------------------------- 55 56 extern void BIFROST2_start(void) __preserves_regs(b,c,d,e); 57 58 59 // ---------------------------------------------------------------- 60 // Deactivate multicolor rendering with BIFROST*2 ENGINE 61 // ---------------------------------------------------------------- 62 63 extern void BIFROST2_stop(void) __preserves_regs(b,c,d,e); 64 65 66 // ---------------------------------------------------------------- 67 // Execute HALT (wait for next frame). 68 // 69 // If an interrupt occurs while certain routines (BIFROST2_drawTileH, 70 // BIFROST2_showTilePosH, BIFROST2_showNextTile, BIFROST2_fillTileAttrH) 71 // are under execution, the program may crash. 72 // 73 // Routine BIFROST2_halt can be used to avoid these problems. 74 // Immediately after calling it, your program will have some time 75 // to execute a few other routines without any interruption. 76 // ---------------------------------------------------------------- 77 78 #define BIFROST2_halt() intrinsic_halt() 79 80 // ---------------------------------------------------------------- 81 // Place a multicolor tile index into the tile map. Add value 82 // BIFROST2_STATIC for static tile, otherwise it will be animated 83 // 84 // Parameters: 85 // px: tile vertical position (0-10) 86 // py: tile horizontal position (0-9) 87 // tile: tile index (0-255) 88 // 89 // Obs: Also available as inline macro (for constant parameters) 90 // ---------------------------------------------------------------- 91 92 extern void BIFROST2_setTile(unsigned char px,unsigned char py,unsigned char tile) __preserves_regs(b,d); 93 extern void BIFROST2_setTile_callee(unsigned char px,unsigned char py,unsigned char tile) __preserves_regs(b) __z88dk_callee; 94 #define BIFROST2_setTile(a,b,c) BIFROST2_setTile_callee(a,b,c) 95 96 97 98 #define M_BIFROST2_SETTILE(px, py, tile) BIFROST2_tilemap[(px)*10+(py)] = (tile) 99 100 // ---------------------------------------------------------------- 101 // Obtain a multicolor tile index from the tile map 102 // 103 // Parameters: 104 // px: tile vertical position (0-10) 105 // py: tile horizontal position (0-9) 106 // 107 // Returns: 108 // Tile index currently stored in this position 109 // 110 // Obs: Also available as inline macro (for constant parameters) 111 // ---------------------------------------------------------------- 112 113 extern unsigned char BIFROST2_getTile(unsigned char px,unsigned char py) __preserves_regs(b,d,e); 114 extern unsigned char BIFROST2_getTile_callee(unsigned char px,unsigned char py) __preserves_regs(b,d,e) __z88dk_callee; 115 #define BIFROST2_getTile(a,b) BIFROST2_getTile_callee(a,b) 116 117 118 119 #define M_BIFROST2_GETTILE(px, py) BIFROST2_tilemap[(px)*10+(py)] 120 121 // ---------------------------------------------------------------- 122 // Convert multicolor tile index into the equivalent animation group 123 // 124 // Parameters: 125 // tile: tile index (0-255) 126 // 127 // Returns: 128 // Animation group for animated tile, otherwise the same tile index 129 // ---------------------------------------------------------------- 130 131 extern unsigned char BIFROST2_getAnimGroup(unsigned char tile) __preserves_regs(b,c,d,e); 132 extern unsigned char BIFROST2_getAnimGroup_fastcall(unsigned char tile) __preserves_regs(b,c,d,e,h) __z88dk_fastcall; 133 #define BIFROST2_getAnimGroup(a) BIFROST2_getAnimGroup_fastcall(a) 134 135 136 137 // ---------------------------------------------------------------- 138 // Locate memory address that stores the multicolor attribute of a 139 // certain screen position inside the multicolor area 140 // 141 // Parameters: 142 // lin: pixel line (0-192) 143 // col: char column (1-20) 144 // 145 // Returns: 146 // Memory address of the multicolor attribute 147 // ---------------------------------------------------------------- 148 149 extern unsigned char *BIFROST2_findAttrH(unsigned char lin,unsigned char col) __preserves_regs(b); 150 extern unsigned char *BIFROST2_findAttrH_callee(unsigned char lin,unsigned char col) __preserves_regs(b) __z88dk_callee; 151 #define BIFROST2_findAttrH(a,b) BIFROST2_findAttrH_callee(a,b) 152 153 154 155 // ---------------------------------------------------------------- 156 // Reconfigure BIFROST*2 ENGINE to read tile images from another address 157 // 158 // Parameters: 159 // addr: New tile images address 160 // ---------------------------------------------------------------- 161 162 extern unsigned char BIFROST2_TILE_IMAGES[]; 163 #define BIFROST2_resetTileImages(addr) intrinsic_store16(_BIFROST2_TILE_IMAGES,addr) 164 165 // ---------------------------------------------------------------- 166 // Reconfigure BIFROST*2 ENGINE to use 2 frames per animation group 167 // ---------------------------------------------------------------- 168 169 extern void BIFROST2_resetAnim2Frames(void) __preserves_regs(b,c,d,e); 170 171 172 // ---------------------------------------------------------------- 173 // Reconfigure BIFROST*2 ENGINE to use 4 frames per animation group 174 // ---------------------------------------------------------------- 175 176 extern void BIFROST2_resetAnim4Frames(void) __preserves_regs(b,c,d,e); 177 178 179 // ---------------------------------------------------------------- 180 // Advanced conversions 181 // ---------------------------------------------------------------- 182 183 #define PX2LIN(px) (((px)+1)<<4) 184 #define PX2ROW(px) (((px)<<1)+1) 185 186 #define ROW2LIN(row) (((row)+1)<<3) 187 #define ROW2PX_UP(row) ((row)>>1) 188 #define ROW2PX_DOWN(row) (((row)-1)>>1) 189 190 #define LIN2ROW_UP(lin) (((lin)>>3)-1) 191 #define LIN2ROW_DOWN(lin) (((lin)-1)>>3) 192 #define LIN2PX_UP(lin) (((lin)>>4)-1) 193 #define LIN2PX_DOWN(lin) (((lin)-1)>>4) 194 195 #define PY2COL(py) (((py)<<1)+1) 196 #define COL2PY_LEFT(col) (((col)-1)>>1) 197 #define COL2PY_RIGHT(col) ((col)>>1) 198 199 // ---------------------------------------------------------------- 200 // Instantly draw a multicolor tile at the specified screen position 201 // 202 // Parameters: 203 // lin: pixel line (0-192) 204 // col: char column (0-20) 205 // tile: tile index (0-255) 206 // 207 // WARNING: If this routine is under execution when interrupt 208 // occurs, program may crash!!! (see BIFROST2_halt) 209 // ---------------------------------------------------------------- 210 211 extern void BIFROST2_drawTileH(unsigned char lin,unsigned char col,unsigned char tile); 212 extern void BIFROST2_drawTileH_callee(unsigned char lin,unsigned char col,unsigned char tile) __z88dk_callee; 213 #define BIFROST2_drawTileH(a,b,c) BIFROST2_drawTileH_callee(a,b,c) 214 215 216 217 // ---------------------------------------------------------------- 218 // Instantly show/animate the multicolor tile currently stored in 219 // the specified tile map position 220 // 221 // Parameters: 222 // lin: pixel line (16,32,48..176) 223 // col: char column (1,3,5..19) 224 // 225 // WARNING: If this routine is under execution when interrupt 226 // occurs, program may crash!!! (see BIFROST2_halt) 227 // ---------------------------------------------------------------- 228 229 extern void BIFROST2_showTilePosH(unsigned char lin,unsigned char col); 230 extern void BIFROST2_showTilePosH_callee(unsigned char lin,unsigned char col) __z88dk_callee; 231 #define BIFROST2_showTilePosH(a,b) BIFROST2_showTilePosH_callee(a,b) 232 233 234 235 // ---------------------------------------------------------------- 236 // Instantly show/animate the next multicolor tile currently stored 237 // in the tile map position, according to a pre-established drawing 238 // order 239 // 240 // WARNING: If this routine is under execution when interrupt 241 // occurs, program may crash!!! (see BIFROST2_halt) 242 // ---------------------------------------------------------------- 243 244 extern void BIFROST2_showNextTile(void); 245 246 247 // ---------------------------------------------------------------- 248 // Instantly show/animate the next two multicolor tiles currently 249 // stored in the tile map position, according to a pre-established 250 // drawing order 251 // 252 // WARNING: If this routine is under execution when interrupt 253 // occurs, program may crash!!! (see BIFROST2_halt) 254 // ---------------------------------------------------------------- 255 256 extern void BIFROST2_showNext2Tiles(void); 257 258 259 // ---------------------------------------------------------------- 260 // Instantly change the attributes in a tile area (16x16 pixels) to 261 // the specified value (use the same INK and PAPER values to "erase" 262 // a tile) 263 // 264 // Parameters: 265 // lin: pixel line (0-192) 266 // col: char column (0-20) 267 // attr: attribute value (0-255), INK+8*PAPER+64*BRIGHT+128*FLASH 268 // 269 // WARNING: If this routine is under execution when interrupt 270 // occurs, program may crash!!! (see BIFROST2_halt) 271 // ---------------------------------------------------------------- 272 273 extern void BIFROST2_fillTileAttrH(unsigned char lin,unsigned char col,unsigned char attr) __preserves_regs(b); 274 extern void BIFROST2_fillTileAttrH_callee(unsigned char lin,unsigned char col,unsigned char attr) __preserves_regs(b) __z88dk_callee; 275 #define BIFROST2_fillTileAttrH(a,b,c) BIFROST2_fillTileAttrH_callee(a,b,c) 276 277 278 279 #endif 280