|
|
1.1 root 1: /*
1.1.1.6 root 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.
1.1 root 6: */
7:
1.1.1.6 root 8: #ifndef HATARI_MAIN_H
9: #define HATARI_MAIN_H
1.1 root 10:
11: typedef int BOOL;
12:
1.1.1.8 ! root 13: #define PROG_NAME "Hatari v0.50" /* Name, version for window title */
! 14: #define PROG_VERSION "v0.50"
! 15: #define VERSION_STRING "0.50 " /* Always 6 bytes (inc' NULL) */
! 16: #define VERSION_STRING_SIZE 6 /* Size of above (inc' NULL) */
1.1 root 17:
18: //#define TOTALLY_FINAL_VERSION /* Web release version... */
19:
20: #define FINAL_VERSION /* Full-speed non-debug version for release */
21: //#define DEBUG_TO_FILE /* Use debug.txt files */
22:
23: #ifndef FINAL_VERSION
24: #define USE_DEBUGGER /* Debugger version(non-release) */
25: #define DEBUG_TO_FILE /* Use debug.txt files */
26: #endif
27:
28: #ifdef TOTALLY_FINAL_VERSION
29: #undef DEBUG_TO_FILE /* Don't use debug files for final release */
30: #endif
31:
32:
33: #include <stdio.h>
34: #include <stdlib.h>
35: #include <string.h>
36: #include <math.h>
37: #include <time.h>
38:
1.1.1.8 ! root 39: #include <SDL_types.h>
! 40:
! 41:
! 42: #define MAX_STRING_LENGTH 512
1.1 root 43:
44: #ifndef FALSE
45: #define FALSE 0
46: #define TRUE (!0)
47: #endif
48:
49: #define CALL_VAR(func) { ((void(*)(void))func)(); }
50:
51:
1.1.1.4 root 52: /* 68000 operand sizes */
1.1 root 53: #define SIZE_BYTE 1
54: #define SIZE_WORD 2
55: #define SIZE_LONG 4
56:
57: /* 68000 Register defines */
58: enum {
59: REG_D0, /* D0.. */
60: REG_D1,
61: REG_D2,
62: REG_D3,
63: REG_D4,
64: REG_D5,
65: REG_D6,
66: REG_D7, /* ..D7 */
67: REG_A0, /* A0.. */
68: REG_A1,
69: REG_A2,
70: REG_A3,
71: REG_A4,
72: REG_A5,
73: REG_A6,
1.1.1.8 ! root 74: REG_A7, /* ..A7 (also SP) */
1.1 root 75: };
76:
77: /* 68000 Condition code's */
78: #define SR_AUX 0x0010
79: #define SR_NEG 0x0008
80: #define SR_ZERO 0x0004
81: #define SR_OVERFLOW 0x0002
82: #define SR_CARRY 0x0001
83:
84: #define SR_CLEAR_AUX 0xffef
85: #define SR_CLEAR_NEG 0xfff7
86: #define SR_CLEAR_ZERO 0xfffb
87: #define SR_CLEAR_OVERFLOW 0xfffd
88: #define SR_CLEAR_CARRY 0xfffe
89:
90: #define SR_CCODE_MASK (SR_AUX|SR_NEG|SR_ZERO|SR_OVERFLOW|SR_CARRY)
91: #define SR_MASK 0xFFE0
92:
93: #define SR_TRACEMODE 0x8000
94: #define SR_SUPERMODE 0x2000
95: #define SR_IPL 0x0700
96:
97: #define SR_CLEAR_IPL 0xf8ff
98: #define SR_CLEAR_TRACEMODE 0x7fff
99: #define SR_CLEAR_SUPERMODE 0xdfff
100:
101: /* Exception vectors */
1.1.1.6 root 102: #define EXCEPTION_BUSERROR 0x00000008
1.1 root 103: #define EXCEPTION_ADDRERROR 0x0000000c
1.1.1.6 root 104: #define EXCEPTION_ILLEGALINS 0x00000010
105: #define EXCEPTION_DIVZERO 0x00000014
106: #define EXCEPTION_CHK 0x00000018
107: #define EXCEPTION_TRAPV 0x0000001c
108: #define EXCEPTION_TRACE 0x00000024
109: #define EXCEPTION_LINE_A 0x00000028
110: #define EXCEPTION_LINE_F 0x0000002c
111: #define EXCEPTION_HBLANK 0x00000068
112: #define EXCEPTION_VBLANK 0x00000070
113: #define EXCEPTION_TRAP0 0x00000080
114: #define EXCEPTION_TRAP1 0x00000084
115: #define EXCEPTION_TRAP2 0x00000088
116: #define EXCEPTION_TRAP13 0x000000B4
117: #define EXCEPTION_TRAP14 0x000000B8
1.1 root 118:
1.1.1.6 root 119: /* Find IPL - don't forget to call MakeSR() before you use it! */
1.1 root 120: #define FIND_IPL ((SR>>8)&0x7)
121:
122: /* Size of 68000 instructions */
123: #define MAX_68000_INSTRUCTION_SIZE 10 /* Longest 68000 instruction is 10 bytes(6+4) */
124: #define MIN_68000_INSTRUCTION_SIZE 2 /* Smallest 68000 instruction is 2 bytes(ie NOP) */
125:
126: /*
127: All the following processor timings are based on a bog standard 8MHz 68000 as found in all standard ST's
128:
129: Clock cycles per line (50Hz) : 512
130: NOPs per scan line (50Hz) : 128
1.1.1.7 root 131: Scan lines per VBL (50Hz) : 313 (64 at top,200 screen,49 bottom)
1.1 root 132:
133: Clock cycles per line (60Hz) : 508
134: NOPs per scan line (60Hz) : 127
1.1.1.7 root 135: Scan lines per VBL (60Hz) : 263
1.1 root 136:
1.1.1.7 root 137: Clock cycles per VBL (50Hz) : 160256
138: NOPs per VBL (50Hz) : 40064
1.1 root 139:
140: Pixels per clock cycle (low res) : 1
141: Pixels per clock cycle (med res) : 2
142: Pixels per clock cycle (high res) : 4
143: Pixels per NOP (low res) : 4
144: Pixels per NOP (med res) : 8
145: Pixels per NOP (high res) : 16
146: */
1.1.1.6 root 147: #define SCREEN_START_HBL 64 /* This is usually the first line of the displayed screen */
1.1 root 148: #define SCREEN_HEIGHT_HBL 200 /* This is usually the height of the screen */
149: #define FIRST_VISIBLE_HBL (SCREEN_START_HBL-OVERSCAN_TOP) /* Normal screen starts 64 lines in, top border is 28 lines */
1.1.1.6 root 150: #define NUM_VISIBLE_LINES (OVERSCAN_TOP+SCREEN_HEIGHT_HBL+OVERSCAN_BOTTOM) /* Number of visible screen lines including top/bottom borders */
1.1 root 151:
152: /* Assumes 32 pixels left+right */
153: #define SCREENBYTES_LEFT 16 /* Bytes for left border in ST screen */
1.1.1.6 root 154: #define SCREENBYTES_MIDDLE 160 /* Middle(320 pixels) */
155: #define SCREENBYTES_RIGHT 16 /* right border */
1.1 root 156: #define SCREENBYTES_LINE (SCREENBYTES_LEFT+SCREENBYTES_MIDDLE+SCREENBYTES_RIGHT)
157:
158: /* Overscan values */
1.1.1.6 root 159: #define OVERSCAN_LEFT (SCREENBYTES_LEFT*2) /* Number of pixels in each border */
1.1 root 160: #define OVERSCAN_RIGHT (SCREENBYTES_RIGHT*2)
1.1.1.6 root 161: #define OVERSCAN_TOP 29
162: #define OVERSCAN_BOTTOM 38
163: #define OVERSCAN_MIDDLE 320 /* Number of pixels across screen(low res) */
164:
165: #define SCREEN_START_CYCLE 96 /* Cycle first normal pixel appears on */
166: #define SCANLINES_PER_FRAME 313 /* Number of scan lines per frame */
167: #define CYCLES_PER_LINE 512 /* Cycles per horiztonal line scan */
1.1.1.7 root 168: #define CYCLES_VBL_IN (SCREEN_START_HBL*CYCLES_PER_LINE) /* ((28+64)*CYCLES_PER_LINE) */
1.1 root 169: #define CYCLES_PER_FRAME (SCANLINES_PER_FRAME*CYCLES_PER_LINE) /* Cycles per VBL @ 50fps = 160256 */
1.1.1.6 root 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 */
1.1 root 174:
175: /* Illegal Opcode used to help emulation. eg. free entries are 8 to 15 inc' */
176: #define GEMDOS_OPCODE 8 /* Free op-code to intercept GemDOS trap */
177: #define RUNOLDGEMDOS_OPCODE 9 /* Free op-code to set PC to old GemDOS vector(if doesn't need to intercept) */
1.1.1.7 root 178: #define SYSINIT_OPCODE 10 /* Free op-code to initialize system (connected drives etc.) */
1.1 root 179: #define VDI_OPCODE 12 /* Free op-code to call VDI handlers AFTER Trap#2 */
1.1.1.6 root 180:
1.1 root 181:
182: #define PRG_HEADER_SIZE 0x1c /* Size of header at start of ST .prg files */
183:
184:
185: extern BOOL bQuitProgram;
1.1.1.2 root 186: extern BOOL bEnableDebug;
1.1 root 187: extern BOOL bEmulationActive;
1.1.1.8 ! root 188: extern char szBootDiscImage[FILENAME_MAX];
! 189: extern char szWorkingDir[FILENAME_MAX];
! 190:
1.1 root 191:
192: extern void Main_MemorySnapShot_Capture(BOOL bSave);
193: extern void Main_SysError(char *Error,char *Title);
194: extern int Main_Message(char *lpText, char *lpCaption /*, unsigned int uType*/);
195: extern void Main_PauseEmulation(void);
196: extern void Main_UnPauseEmulation(void);
197: extern void Main_EventHandler();
198:
1.1.1.6 root 199: #endif /* ifndef HATARI_MAIN_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.