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