1 /* 2 * Headerfile for Amstrad CPC specific functions 3 * 4 * $Id: cpc.h - fall 2107 - $ 5 */ 6 7 #ifndef __CPC_H__ 8 #define __CPC_H__ 9 10 #include <sys/compiler.h> 11 #include <sys/types.h> 12 13 /////////////////////////////////////////// 14 // DIAGNOSTICS AND HARDWARE IDENTIFICATION 15 /////////////////////////////////////////// 16 17 // FDC detection (0-none, 1-Amstrad, 2-Vortex) 18 extern int __LIB__ cpc_fdc(void); 19 20 // CPC model detection (0-464, 1-664, 2-6128) 21 extern int __LIB__ cpc_model(void); 22 23 24 /////////////////////////////////////////// 25 // KEYBOARD FUNCTIONS 26 /////////////////////////////////////////// 27 28 extern char __LIB__ cpc_AnyKeyPressed(void); 29 extern char __LIB__ cpc_TestKey(int key) __z88dk_fastcall; 30 extern char __LIB__ cpc_TestKeyF(int key) __z88dk_fastcall; 31 extern void __LIB__ cpc_DeleteKeys(void); 32 extern char __LIB__ cpc_RedefineKey(int key) __z88dk_fastcall; 33 extern void __LIB__ cpc_ScanKeyboard(void); 34 35 extern void __LIB__ cpc_AssignKey(int key, int value) __smallc ; 36 extern void __LIB__ cpc_AssignKey_callee(int key, int value) __smallc __z88dk_callee; 37 #define cpc_AssignKey(a,b) cpc_AssignKey_callee(a,b) 38 39 /////////////////////////////////////////// 40 // VIDEO RELATED FUNCTIONS 41 /////////////////////////////////////////// 42 43 // Set video mode via Firmware 44 extern int __LIB__ cpc_setmode(int) __z88dk_fastcall; 45 extern int __LIB__ cpc_SetModo(int) __z88dk_fastcall; 46 47 // Switch video mode directly 48 extern int __LIB__ cpc_SetMode(int) __z88dk_fastcall; 49 50 // Set CPC color for a specified pen (set color in a palette element) 51 extern void __LIB__ cpc_set_palette(int pen, int color) __smallc ; 52 extern void __LIB__ cpc_set_palette_callee(int pen, int color) __smallc __z88dk_callee; 53 extern void __LIB__ cpc_SetInk(int pen, int color) __smallc ; 54 extern void __LIB__ cpc_SetInk_callee(int pen, int color) __smallc __z88dk_callee; 55 #define cpc_SetInk(a,b) cpc_SetInk_callee(a,b) 56 #define cpc_set_palette(a,b) cpc_set_palette_callee(a,b) 57 58 // Set CPC color 59 extern void __LIB__ cpc_SetColour(int pos, int color) __smallc ; 60 extern void __LIB__ cpc_SetColour_callee(int pos, int color) __smallc __z88dk_callee; 61 #define cpc_SetColour(a,b) cpc_SetColour_callee(a,b) 62 63 // Set Border Color 64 extern void __LIB__ cpc_SetBorder(int color) __z88dk_fastcall; 65 66 67 extern unsigned int __LIB__ cpc_GetScrAddress(int x, int y) __smallc ; 68 extern unsigned int __LIB__ cpc_GetScrAddress_callee(int x, int y) __smallc __z88dk_callee; 69 #define cpc_GetScrAddress(a,b) cpc_GetScrAddress_callee(a,b) 70 71 72 73 // Print to direct screen address (fully coloured font) 74 extern void __LIB__ cpc_PrintGphStr(char *text, unsigned int address) __smallc ; 75 extern void __LIB__ cpc_PrintGphStr_callee(char *text, unsigned int address) __smallc __z88dk_callee; 76 #define cpc_PrintGphStr(a,b) cpc_PrintGphStr_callee(a,b) 77 78 // Print to direct screen address, specify pen color 79 extern void __LIB__ cpc_PrintGphStrStd(int pen, char *text, unsigned int address) __smallc ; 80 extern void __LIB__ cpc_PrintGphStrStd_callee(int pen, char *text, unsigned int address) __smallc __z88dk_callee; 81 #define cpc_PrintGphStrStd(a,b,c) cpc_PrintGphStrStd_callee(a,b,c) 82 83 // Print to direct screen address (mode 1) 84 extern void __LIB__ cpc_PrintGphStrM1(char *text, unsigned int address) __smallc ; 85 extern void __LIB__ cpc_PrintGphStrM1_callee(char *text, unsigned int address) __smallc __z88dk_callee; 86 #define cpc_PrintGphStrM1(a,b) cpc_PrintGphStrM1_callee(a,b) 87 88 89 90 // Print to direct screen address, double height (fully coloured font) 91 extern void __LIB__ cpc_PrintGphStr2X(char *text, unsigned int address) __smallc ; 92 extern void __LIB__ cpc_PrintGphStr2X_callee(char *text, unsigned int address) __smallc __z88dk_callee; 93 #define cpc_PrintGphStr2X(a,b) cpc_PrintGphStr2X_callee(a,b) 94 95 // Print to direct screen address, double height (mode 1) 96 extern void __LIB__ cpc_PrintGphStrM12X(char *text, unsigned int address) __smallc ; 97 extern void __LIB__ cpc_PrintGphStrM12X_callee(char *text, unsigned int address) __smallc __z88dk_callee; 98 #define cpc_PrintGphStrM12X(a,b) cpc_PrintGphStrM12X_callee(a,b) 99 100 101 102 // Print at x,y (fully coloured font) 103 extern void __LIB__ cpc_PrintGphStrXY(char *text, int x, int y) __smallc ; 104 extern void __LIB__ cpc_PrintGphStrXY_callee(char *text, int x, int y) __smallc __z88dk_callee; 105 #define cpc_PrintGphStrXY(a,b,c) cpc_PrintGphStrXY_callee(a,b,c) 106 107 // Print at x,y in double height (for fully coloured font) 108 extern void __LIB__ cpc_PrintGphStrXY2X(char *text, int x, int y) __smallc ; 109 extern void __LIB__ cpc_PrintGphStrXY2X_callee(char *text, int x, int y) __smallc __z88dk_callee; 110 #define cpc_PrintGphStrXY2X(a,b,c) cpc_PrintGphStrXY2X_callee(a,b,c) 111 112 // Print at x,y, specify pen color 113 extern void __LIB__ cpc_PrintGphStrStdXY(int pen, char *text, int x, int y) __smallc ; 114 extern void __LIB__ cpc_PrintGphStrStdXY_callee(int pen, char *text, int x, int y) __smallc __z88dk_callee; 115 #define cpc_PrintGphStrStdXY(a,b,c,d) cpc_PrintGphStrStdXY_callee(a,b,c,d) 116 117 // Print at x,y (mode 1) 118 extern void __LIB__ cpc_PrintGphStrXYM1(char *text, int x, int y) __smallc ; 119 extern void __LIB__ cpc_PrintGphStrXYM1_callee(char *text, int x, int y) __smallc __z88dk_callee; 120 #define cpc_PrintGphStrXYM1(a,b,c) cpc_PrintGphStrXYM1_callee(a,b,c) 121 122 // Print at x,y (mode 1) 123 extern void __LIB__ cpc_PrintGphStrXYM12X(char *text, int x, int y) __smallc ; 124 extern void __LIB__ cpc_PrintGphStrXYM12X_callee(char *text, int x, int y) __smallc __z88dk_callee; 125 #define cpc_PrintGphStrXYM12X(a,b,c) cpc_PrintGphStrXYM12X_callee(a,b,c) 126 127 128 129 // Set font colors (for fully coloured font) 130 extern void __LIB__ cpc_SetInkGphStr(int color, int valor) __smallc ; 131 extern void __LIB__ cpc_SetInkGphStr_callee(int color, int valor) __smallc __z88dk_callee; 132 #define cpc_SetInkGphStr(a,b) cpc_SetInkGphStr_callee(a,b) 133 134 // Set font colors (for mode 1 font) 135 extern void __LIB__ cpc_SetInkGphStrM1(int color, int valor) __smallc ; 136 extern void __LIB__ cpc_SetInkGphStrM1_callee(int color, int valor) __smallc __z88dk_callee; 137 #define cpc_SetInkGphStrM1(a,b) cpc_SetInkGphStrM1_callee(a,b) 138 139 // Rotate left region 140 extern void __LIB__ cpc_RLI(unsigned int pos, int w, int h) __smallc ; 141 extern void __LIB__ cpc_RLI_callee(unsigned int pos, int w, int h) __smallc __z88dk_callee; 142 #define cpc_RLI(a,b,c) cpc_RLI_callee(a,b,c) 143 144 // Rotate left region 145 extern void __LIB__ cpc_RRI(unsigned int pos, int w, int h) __smallc ; 146 extern void __LIB__ cpc_RRI_callee(unsigned int pos, int w, int h) __smallc __z88dk_callee; 147 #define cpc_RRI(a,b,c) cpc_RRI_callee(a,b,c) 148 149 // Clear Screen 150 extern void __LIB__ cpc_ClrScr(void); 151 152 // Print String using firmware 153 extern char __LIB__ cpc_PrintStr(char *text) __z88dk_fastcall; 154 155 156 /////////////////////////////////////////// 157 // SPRITES 158 /////////////////////////////////////////// 159 160 extern void __LIB__ cpc_PutSp(char *sprite, int height, int width, unsigned int address) __smallc ; 161 extern void __LIB__ cpc_PutSp_callee(char *sprite, int height, int width, unsigned int address) __smallc __z88dk_callee; 162 #define cpc_PutSp(a,b,c,d) cpc_PutSp_callee(a,b,c,d) 163 164 extern void __LIB__ cpc_PutSpXOR(char *sprite, int height, int width, unsigned int address) __smallc ; 165 extern void __LIB__ cpc_PutSpXOR_callee(char *sprite, int height, int width, unsigned int address) __smallc __z88dk_callee; 166 #define cpc_PutSpXOR(a,b,c,d) cpc_PutSpXOR_callee(a,b,c,d) 167 168 extern void __LIB__ cpc_PutSpTr(char *sprite, int height, int width, unsigned int address) __smallc ; 169 extern void __LIB__ cpc_PutSpTr_callee(char *sprite, int height, int width, unsigned int address) __smallc __z88dk_callee; 170 #define cpc_PutSpTr(a,b,c,d) cpc_PutSpTr_callee(a,b,c,d) 171 172 extern void __LIB__ cpc_PutMaskSp(char *sprite, int height, int width, unsigned int address) __smallc ; 173 extern void __LIB__ cpc_PutMaskSp_callee(char *sprite, int height, int width, unsigned int address) __smallc __z88dk_callee; 174 #define cpc_PutMaskSp(a,b,c,d) cpc_PutMaskSp_callee(a,b,c,d) 175 176 extern void __LIB__ cpc_GetSp(char *sprite, int height, int width, unsigned int address) __smallc ; 177 extern void __LIB__ cpc_GetSp_callee(char *sprite, int height, int width, unsigned int address) __smallc __z88dk_callee; 178 #define cpc_GetSp(a,b,c,d) cpc_GetSp_callee(a,b,c,d) 179 180 181 /* 182 // minimun sprite structure 183 struct sprite { 184 int sp0; //2 bytes 01 185 int sp1; //2 bytes 23 186 int coord0; //2 bytes 45 current superbuffer address 187 int coord1; //2 bytes 67 old superbuffer address 188 unsigned char cx, cy; //2 bytes 89 current coordinates 189 unsigned char ox, oy; //2 bytes 1011 old coordinates 190 unsigned char move1; 191 unsigned char move; // .. to know the movement direction of the sprite 192 }; 193 194 // Set Sprite position 195 extern void __LIB__ cpc_SpUpdX(struct sprite *sprite, int x) __smallc ; 196 extern void __LIB__ cpc_SpUpdX_callee(struct sprite *sprite, int x) __smallc __z88dk_callee; 197 #define cpc_SpUpdX(a,b) cpc_SpUpdX_callee(a,b) 198 extern void __LIB__ cpc_SpUpdY(struct sprite *sprite, int y) __smallc ; 199 extern void __LIB__ cpc_SpUpdY_callee(struct sprite *sprite, int y) __smallc __z88dk_callee; 200 #define cpc_SpUpdY(a,b) cpc_SpUpdY_callee(a,b) 201 202 // Tiles 203 extern char __LIB__ cpc_PutSpTileMap(struct sprite *sprite) __z88dk_fastcall; 204 extern char __LIB__ cpc_PutMaskSpriteTileMap2b(struct sprite *sprite) __z88dk_fastcall; 205 #define cpc_PutMaskSpTileMap2b(a) cpc_PutMaskSpriteTileMap2b(a) 206 extern void __LIB__ cpc_UpdateTileMap(int spritelist) __z88dk_fastcall; 207 extern void __LIB__ cpc_ShowTileMap(int x) __z88dk_fastcall; 208 extern void __LIB__ cpc_ShowTileMap2(void); 209 extern void __LIB__ cpc_ResetTouchedTiles(void); 210 extern void __LIB__ cpc_ShowTouchedTiles(void); 211 212 extern void __LIB__ cpc_SetTile(int x, int y, int byte) __smallc ; 213 extern void __LIB__ cpc_SetTile_callee(int x, int y, int byte) __smallc __z88dk_callee; 214 #define cpc_SetTile(a,b,c) cpc_SetTile_callee(a,b,c) 215 216 extern void __LIB__ cpc_PutTiles(int x, int y, int w, int h, char *buffer) __smallc ; 217 extern void __LIB__ cpc_PutTiles_callee(int x, int y, int w, int h, char *buffer) __smallc __z88dk_callee; 218 #define cpc_PutTiles(a,b,c,d,e) cpc_PutTiles_callee(a,b,c,d,e) 219 220 extern void __LIB__ cpc_GetTiles(int x, int y, int w, int h, char *buffer) __smallc ; 221 extern void __LIB__ cpc_GetTiles_callee(int x, int y, int w, int h, char *buffer) __smallc __z88dk_callee; 222 #define cpc_GetTiles(a,b,c,d,e) cpc_GetTiles_callee(a,b,c,d,e) 223 224 extern void __LIB__ cpc_SuperbufferAddress(struct sprite *sprite) __z88dk_fastcall; 225 226 // Test if there is collision between 2 sprites 227 extern void __LIB__ cpc_CollSp(struct sprite *sprite1, struct sprite *sprite2) __smallc ; 228 extern void __LIB__ cpc_CollSp_callee(struct sprite *sprite1, struct sprite *sprite2) __smallc __z88dk_callee; 229 #define cpc_CollSp(a,b) cpc_CollSp_callee(a,b) 230 231 // Update Screen 232 extern void __LIB__ cpc_UpdScr(void); 233 */ 234 235 236 /////////////////////////////////////////// 237 // MISC FUNCTIONS 238 /////////////////////////////////////////// 239 240 // (old way) Enable/Disable firmware: forcefully modify interrupts to jump to nothing 241 extern void __LIB__ cpc_DisableFirmware(void); 242 extern void __LIB__ cpc_EnableFirmware(void); 243 244 // Tiny ROM based console gets implementation 245 extern int __LIB__ cpc_gets(char *s); 246 247 // Copies a string to a CPC RSX compatible one 248 extern char __LIB__ *cpc_rsx_str(char *str) __z88dk_fastcall; // (malloc lib is required) 249 250 extern char __LIB__ *cpc_rsx_strcpy(char *, char *) __smallc ; 251 extern char __LIB__ *cpc_rsx_strcpy_callee(char *, char *) __smallc __z88dk_callee; 252 #define cpc_rsx_strcpy(a,b) cpc_rsx_strcpy_callee(a,b) 253 254 // Data decompression, PUcrunch format 255 extern void __LIB__ cpc_Uncrunch(char *, char *) __smallc ; 256 extern void __LIB__ cpc_Uncrunch_callee(char *, char *) __smallc __z88dk_callee; 257 #define cpc_Uncrunch(a,b) cpc_Uncrunch_callee(a,b) 258 259 // Data decompression, Exomizer 2 format 260 extern void __LIB__ cpc_UnExo(char *, char *) __smallc ; 261 extern void __LIB__ cpc_UnExo_callee(char *, char *) __smallc __z88dk_callee; 262 #define cpc_UnExo(a,b) cpc_UnExo_callee(a,b) 263 264 // Call RSX/Bar command 265 extern int __LIB__ cpc_rsx(char *cmd,...); 266 267 // RSX return error codes 268 #define RSX_NOT_FOUND -1 269 270 #define RSX_NOT_OPEN 0x0E // file not open as expected 271 #define RSX_HARD_EOF 0x0F // hard end of file 272 #define RSX_SOFT_EOF 0x1A // soft end of file 273 #define RSX_BAD_CMD 0x10 // bad command, usually wrong filename 274 #define RSX_FILE_EXIST 0x11 // file already exists 275 #define RSX_FILE_NOT_FOUND 0x12 // file doesn't exist 276 #define RSX_DIR_FULL 0x13 // directory is full 277 #define RSX_DISK_FULL 0x14 // disc is full 278 #define RSX_DISK_CHANGE 0x15 // disk has been changed with files open on it 279 #define RSX_READ_ONLY 0x16 // file is read-only 280 281 // RSX bitwise coded return error codes 282 #define RSX_HARD_ERR 64 283 #define RSX_HE_CRC 32 // data error - CRC err. on data or ID field 284 #define RSX_HE_OVERRUN 16 // overrun error 285 #define RSX_HE_NOTREADY 8 // drive not ready - no disk in drive 286 #define RSX_HE_NOSECTOR 4 // no data - can't find sector 287 #define RSX_HE_WPROTECT 2 // not writable - wr protected 288 #define RSX_HE_NOMARK 1 // address mark missing 289 290 291 // Hide/Show BIOS error messages 292 extern void __LIB__ bios_msg(int flag) __z88dk_fastcall; 293 294 #define MSG_ENABLE 0 295 #define MSG_DISABLE 255 296 297 #endif 298