|
|
1.1 ! root 1: /* ! 2: Hatari - main.h ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at ! 5: your option any later version. Read the file gpl.txt for details. ! 6: */ ! 7: ! 8: #ifndef HATARI_MAIN_H ! 9: #define HATARI_MAIN_H ! 10: ! 11: typedef int BOOL; ! 12: #ifndef bool ! 13: typedef int bool; ! 14: #endif /* bool */ ! 15: ! 16: #ifndef MIN ! 17: # define MIN(a,b) ((a)<(b) ? (a) : (b)) ! 18: #endif ! 19: #ifndef MAX ! 20: # define MAX(a,b) ((a)>(b) ? (a) : (b)) ! 21: #endif ! 22: ! 23: #define PROG_NAME "Frontier: Elite 2" /* Name, version for window title */ ! 24: ! 25: #define MAX_FILENAME_LENGTH 256 ! 26: #define MAX_STRING_LENGTH 512 ! 27: ! 28: #include <stdio.h> ! 29: #include <stdlib.h> ! 30: #include <string.h> ! 31: #include <math.h> ! 32: #include <time.h> ! 33: #include <assert.h> ! 34: ! 35: ! 36: #ifndef FALSE ! 37: #define FALSE 0 ! 38: #define TRUE (!0) ! 39: #endif ! 40: ! 41: #define CALL_VAR(func) { ((void(*)(void))func)(); } ! 42: ! 43: /* VM Memory size */ ! 44: #define MEMORY_SIZE (2*1024*1024) ! 45: ! 46: /* 68000 operand sizes */ ! 47: #define SIZE_BYTE 1 ! 48: #define SIZE_WORD 2 ! 49: #define SIZE_LONG 4 ! 50: ! 51: /* 68000 Register defines */ ! 52: enum { ! 53: REG_D0, /* D0.. */ ! 54: REG_D1, ! 55: REG_D2, ! 56: REG_D3, ! 57: REG_D4, ! 58: REG_D5, ! 59: REG_D6, ! 60: REG_D7, /* ..D7 */ ! 61: REG_A0, /* A0.. */ ! 62: REG_A1, ! 63: REG_A2, ! 64: REG_A3, ! 65: REG_A4, ! 66: REG_A5, ! 67: REG_A6, ! 68: REG_A7, /* ..A7(also SP) */ ! 69: }; ! 70: ! 71: /* PC Condition code's */ ! 72: #define PC_CARRY 0x0001 /* Bit 0 */ ! 73: #define PC_AUX 0x0010 /* Bit 4 */ ! 74: #define PC_ZERO 0x0040 /* Bit 6 */ ! 75: #define PC_NEG 0x0080 /* Bit 7 */ ! 76: #define PC_OVERFLOW 0x0800 /* Bit 11 */ ! 77: ! 78: /* 68000 Condition code's */ ! 79: #define SR_AUX 0x0010 ! 80: #define SR_NEG 0x0008 ! 81: #define SR_ZERO 0x0004 ! 82: #define SR_OVERFLOW 0x0002 ! 83: #define SR_CARRY 0x0001 ! 84: ! 85: #define SR_CLEAR_AUX 0xffef ! 86: #define SR_CLEAR_NEG 0xfff7 ! 87: #define SR_CLEAR_ZERO 0xfffb ! 88: #define SR_CLEAR_OVERFLOW 0xfffd ! 89: #define SR_CLEAR_CARRY 0xfffe ! 90: ! 91: #define SR_CCODE_MASK (SR_AUX|SR_NEG|SR_ZERO|SR_OVERFLOW|SR_CARRY) ! 92: #define SR_MASK 0xFFE0 ! 93: ! 94: #define SR_TRACEMODE 0x8000 ! 95: #define SR_SUPERMODE 0x2000 ! 96: #define SR_IPL 0x0700 ! 97: ! 98: #define SR_CLEAR_IPL 0xf8ff ! 99: #define SR_CLEAR_TRACEMODE 0x7fff ! 100: #define SR_CLEAR_SUPERMODE 0xdfff ! 101: ! 102: /* Emuation condition codes, ordered so can do 'xor al,al' to set XNZVC -0000 */ ! 103: #define EMU_X 0x0100 ! 104: #define EMU_N 0x0080 ! 105: #define EMU_Z 0x0040 ! 106: #define EMU_V 0x0020 ! 107: #define EMU_C 0x0010 ! 108: ! 109: #define EMU_CLEAR_X 0xfeff ! 110: #define EMU_CLEAR_N 0xff7f ! 111: #define EMU_CLEAR_Z 0xffbf ! 112: #define EMU_CLEAR_V 0xffdf ! 113: #define EMU_CLEAR_C 0xffef ! 114: ! 115: /* Exception vectors */ ! 116: #define EXCEPTION_BUSERROR 0x00000008 ! 117: #define EXCEPTION_ADDRERROR 0x0000000c ! 118: #define EXCEPTION_ILLEGALINS 0x00000010 ! 119: #define EXCEPTION_DIVZERO 0x00000014 ! 120: #define EXCEPTION_CHK 0x00000018 ! 121: #define EXCEPTION_TRAPV 0x0000001c ! 122: #define EXCEPTION_TRACE 0x00000024 ! 123: #define EXCEPTION_LINE_A 0x00000028 ! 124: #define EXCEPTION_LINE_F 0x0000002c ! 125: #define EXCEPTION_HBLANK 0x00000068 ! 126: #define EXCEPTION_VBLANK 0x00000070 ! 127: #define EXCEPTION_INPUT 0x00000074 ! 128: #define EXCEPTION_TRAP0 0x00000080 ! 129: #define EXCEPTION_TRAP1 0x00000084 ! 130: #define EXCEPTION_TRAP2 0x00000088 ! 131: #define EXCEPTION_TRAP13 0x000000B4 ! 132: #define EXCEPTION_TRAP14 0x000000B8 ! 133: ! 134: /* Find IPL - don't forget to call MakeSR() before you use it! */ ! 135: #define FIND_IPL ((SR>>8)&0x7) ! 136: ! 137: /* Size of 68000 instructions */ ! 138: #define MAX_68000_INSTRUCTION_SIZE 10 /* Longest 68000 instruction is 10 bytes(6+4) */ ! 139: #define MIN_68000_INSTRUCTION_SIZE 2 /* Smallest 68000 instruction is 2 bytes(ie NOP) */ ! 140: ! 141: /* ! 142: All the following processor timings are based on a bog standard 8MHz 68000 as found in all standard ST's ! 143: ! 144: Clock cycles per line (50Hz) : 512 ! 145: NOPs per scan line (50Hz) : 128 ! 146: Scan lines per VBL (50Hz) : 313 (64 at top,200 screen,49 bottom) ! 147: ! 148: Clock cycles per line (60Hz) : 508 ! 149: NOPs per scan line (60Hz) : 127 ! 150: Scan lines per VBL (60Hz) : 263 ! 151: ! 152: Clock cycles per VBL (50Hz) : 160256 ! 153: NOPs per VBL (50Hz) : 40064 ! 154: ! 155: Pixels per clock cycle (low res) : 1 ! 156: Pixels per clock cycle (med res) : 2 ! 157: Pixels per clock cycle (high res) : 4 ! 158: Pixels per NOP (low res) : 4 ! 159: Pixels per NOP (med res) : 8 ! 160: Pixels per NOP (high res) : 16 ! 161: */ ! 162: #define SCREEN_HEIGHT_HBL 200 /* This is usually the height of the screen */ ! 163: ! 164: #define SCREENBYTES_LINE 320 ! 165: ! 166: #define SCREEN_START_CYCLE 96 /* Cycle first normal pixel appears on */ ! 167: #define SCANLINES_PER_FRAME 313 /* Number of scan lines per frame */ ! 168: #define CYCLES_PER_LINE 512 /* Cycles per horiztonal line scan */ ! 169: #define CYCLES_PER_FRAME (SCANLINES_PER_FRAME*CYCLES_PER_LINE) /* Cycles per VBL @ 50fps = 160256 */ ! 170: #define CYCLES_PER_SEC (CYCLES_PER_FRAME*50) /* Cycles per second */ ! 171: #define CYCLES_ENDLINE (64+320+88+40) /* DE(Display Enable) */ ! 172: #define CYCLES_HBL (CYCLES_PER_LINE+96) /* Cycles for first HBL - very inaccurate on ST */ ! 173: #define CYCLES_DEBUGGER 3000 /* Check debugger every 'x' cycles */ ! 174: ! 175: /* Illegal Opcode used to call C code from 68k emu */ ! 176: #define HOSTCALL_OPCODE 10 /* Free op-code to initialize system (connected drives etc.) */ ! 177: #define HCALL_OPCODE 11 ! 178: ! 179: #define PRG_HEADER_SIZE 0x1c /* Size of header at start of ST .prg files */ ! 180: ! 181: ! 182: extern BOOL bQuitProgram; ! 183: extern BOOL bEmulationActive; ! 184: extern char szName[]; ! 185: extern char szBootDiscImage[MAX_FILENAME_LENGTH]; ! 186: extern char szWorkingDir[MAX_FILENAME_LENGTH]; ! 187: extern char szCurrentDir[MAX_FILENAME_LENGTH]; ! 188: ! 189: extern void Main_SysError(char *Error,char *Title); ! 190: extern int Main_Message(char *lpText, char *lpCaption /*, unsigned int uType*/); ! 191: extern void Main_PauseEmulation(void); ! 192: extern void Main_UnPauseEmulation(void); ! 193: extern void Main_EventHandler(); ! 194: ! 195: #endif /* ifndef HATARI_MAIN_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.