Annotation of hatari/src/includes/main.h, revision 1.1.1.5

1.1       root        1: /*
                      2:   Hatari
                      3: */
                      4: 
                      5: #ifndef MAIN_H
                      6: #define MAIN_H
                      7: 
                      8: typedef int BOOL;
                      9: 
1.1.1.5 ! root       10: #define PROG_NAME      "Hatari v0.25" /* Name, version for window title */
        !            11: #define PROG_VERSION        "v0.25"
        !            12: #define VERSION_STRING      "0.25 "   /* Always 6 bytes(inc' NULL) */
1.1       root       13: #define VERSION_STRING_SIZE    6      /* Size of above(inc' NULL) */
                     14: 
                     15: //#define TOTALLY_FINAL_VERSION       /* Web release version... */
                     16: 
                     17: #define FINAL_VERSION                 /* Full-speed non-debug version for release */
                     18: //#define DEBUG_TO_FILE               /* Use debug.txt files */
                     19: #define FIND_PERFORMANCE
                     20: 
                     21: #ifndef FINAL_VERSION
                     22:   #define USE_DEBUGGER                /* Debugger version(non-release) */
                     23:   #define DEBUG_TO_FILE               /* Use debug.txt files */
                     24: #endif
                     25: 
                     26: #ifdef TOTALLY_FINAL_VERSION
                     27:   #undef DEBUG_TO_FILE                /* Don't use debug files for final release */
                     28:   #undef FIND_PERFORMANCE
                     29: #endif
                     30: 
                     31: #define MAX_FILENAME_LENGTH  256
                     32: #define MAX_STRING_LENGTH  512
                     33: 
                     34: 
                     35: #include <stdio.h>
                     36: #include <stdlib.h>
                     37: #include <string.h>
                     38: #include <math.h>
                     39: #include <time.h>
                     40: #include <assert.h>
                     41: 
                     42: 
                     43: #ifndef FALSE
                     44: #define FALSE 0
                     45: #define TRUE (!0)
                     46: #endif
                     47: 
                     48: #define CALL_VAR(func)  { ((void(*)(void))func)(); }
                     49: 
1.1.1.4   root       50: /* Binary conversion macro's */
1.1       root       51: #define BIN2(a,b) ((a<<1)+(b))
                     52: #define BIN3(a,b,c) ((a<<2)+(b<<1)+(c))
                     53: #define BIN4(a,b,c,d) ((a<<3)+(b<<2)+(c<<1)+(d))
                     54: #define BIN5(a,b,c,d,e) ((a<<4)+(b<<3)+(c<<2)+(d<<1)+(e))
                     55: #define BIN6(a,b,c,d,e,f) ((a<<5)+(b<<4)+(c<<3)+(d<<2)+(e<<1)+(f))
                     56: #define BIN7(a,b,c,d,e,f,g) ((a<<6)+(b<<5)+(c<<4)+(d<<3)+(e<<2)+(f<<1)+(g))
                     57: #define BIN8(a,b,c,d,e,f,g,h) ((a<<7)+(b<<6)+(c<<5)+(d<<4)+(e<<3)+(f<<2)+(g<<1)+(h))
                     58: #define BIN10(a,b,c,d,e,f,g,h,i,j) ((a<<9)+(b<<8)+(c<<7)+(d<<6)+(e<<5)+(f<<4)+(g<<3)+(h<<2)+(i<<1)+(j))
                     59: #define BIN12(a,b,c,d,e,f,g,h,i,j,k,l) ((a<<11)+(b<<10)+(c<<9)+(d<<8)+(e<<7)+(f<<6)+(g<<5)+(h<<4)+(i<<3)+(j<<2)+(k<<1)+(l))
                     60: #define BIN14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) ((a<<13)+(b<<12)+(c<<11)+(d<<10)+(e<<9)+(f<<8)+(g<<7)+(h<<6)+(i<<5)+(j<<4)+(k<<3)+(l<<2)+(m<<1)+(n))
                     61: #define BIN16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) ((a<<15)+(b<<14)+(c<<13)+(d<<12)+(e<<11)+(f<<10)+(g<<9)+(h<<8)+(i<<7)+(j<<6)+(k<<5)+(l<<4)+(m<<3)+(n<<2)+(o<<1)+(p))
                     62: 
1.1.1.4   root       63: /* 68000 operand sizes */
1.1       root       64: #define SIZE_BYTE  1
                     65: #define SIZE_WORD  2
                     66: #define SIZE_LONG  4
                     67: 
                     68: /* 68000 Register defines */
                     69: enum {
                     70:   REG_D0,    /* D0.. */
                     71:   REG_D1,
                     72:   REG_D2,
                     73:   REG_D3,
                     74:   REG_D4,
                     75:   REG_D5,
                     76:   REG_D6,
                     77:   REG_D7,    /* ..D7 */
                     78:   REG_A0,    /* A0.. */
                     79:   REG_A1,
                     80:   REG_A2,
                     81:   REG_A3,
                     82:   REG_A4,
                     83:   REG_A5,
                     84:   REG_A6,
                     85:   REG_A7,    /* ..A7(also SP) */
                     86: };
                     87: 
                     88: /* PC Condition code's */
1.1.1.4   root       89: #define PC_CARRY    0x0001  /* Bit 0 */
                     90: #define PC_AUX      0x0010  /* Bit 4 */
                     91: #define PC_ZERO     0x0040  /* Bit 6 */
                     92: #define PC_NEG      0x0080  /* Bit 7 */
                     93: #define PC_OVERFLOW 0x0800  /* Bit 11 */
1.1       root       94: 
                     95: /* 68000 Condition code's */
                     96: #define SR_AUX      0x0010
                     97: #define SR_NEG      0x0008
                     98: #define SR_ZERO      0x0004
                     99: #define SR_OVERFLOW    0x0002
                    100: #define SR_CARRY    0x0001
                    101: 
                    102: #define SR_CLEAR_AUX    0xffef
                    103: #define SR_CLEAR_NEG    0xfff7
                    104: #define SR_CLEAR_ZERO    0xfffb
                    105: #define SR_CLEAR_OVERFLOW  0xfffd
                    106: #define SR_CLEAR_CARRY    0xfffe
                    107: 
                    108: #define SR_CCODE_MASK    (SR_AUX|SR_NEG|SR_ZERO|SR_OVERFLOW|SR_CARRY)
                    109: #define SR_MASK      0xFFE0
                    110: 
                    111: #define SR_TRACEMODE    0x8000
                    112: #define SR_SUPERMODE    0x2000
                    113: #define SR_IPL      0x0700
                    114: 
                    115: #define SR_CLEAR_IPL    0xf8ff
                    116: #define SR_CLEAR_TRACEMODE  0x7fff
                    117: #define SR_CLEAR_SUPERMODE  0xdfff
                    118: 
                    119: /* Emuation condition codes, ordered so can do 'xor al,al' to set XNZVC -0000 */
                    120: #define  EMU_X    0x0100
                    121: #define  EMU_N    0x0080
                    122: #define  EMU_Z    0x0040
                    123: #define  EMU_V    0x0020
                    124: #define  EMU_C    0x0010
                    125: 
                    126: #define  EMU_CLEAR_X  0xfeff
                    127: #define  EMU_CLEAR_N  0xff7f
                    128: #define  EMU_CLEAR_Z  0xffbf
                    129: #define  EMU_CLEAR_V  0xffdf
                    130: #define  EMU_CLEAR_C  0xffef
                    131: 
                    132: /* Exception vectors */
                    133: #define  EXCEPTION_BUSERROR  0x00000008
                    134: #define  EXCEPTION_ADDRERROR  0x0000000c
                    135: #define EXCEPTION_ILLEGALINS  0x00000010
                    136: #define  EXCEPTION_DIVZERO  0x00000014
                    137: #define EXCEPTION_CHK    0x00000018
                    138: #define EXCEPTION_TRAPV    0x0000001c
                    139: #define EXCEPTION_TRACE    0x00000024
                    140: #define  EXCEPTION_LINE_A  0x00000028
                    141: #define  EXCEPTION_LINE_F  0x0000002c
                    142: #define  EXCEPTION_HBLANK  0x00000068
                    143: #define  EXCEPTION_VBLANK  0x00000070
                    144: #define EXCEPTION_TRAP0    0x00000080
                    145: #define EXCEPTION_TRAP1    0x00000084
                    146: #define EXCEPTION_TRAP2    0x00000088
                    147: #define EXCEPTION_TRAP13  0x000000B4
                    148: #define EXCEPTION_TRAP14  0x000000B8
                    149: 
                    150: /* Find IPL */
                    151: #define FIND_IPL    ((SR>>8)&0x7)
                    152: 
                    153: /* Size of 68000 instructions */
                    154: #define MAX_68000_INSTRUCTION_SIZE  10  /* Longest 68000 instruction is 10 bytes(6+4) */
                    155: #define MIN_68000_INSTRUCTION_SIZE  2   /* Smallest 68000 instruction is 2 bytes(ie NOP) */
                    156: 
                    157: /*
                    158:   All the following processor timings are based on a bog standard 8MHz 68000 as found in all standard ST's
                    159: 
                    160:   Clock cycles per line (50Hz)      : 512
                    161:   NOPs per scan line (50Hz)         : 128
                    162:   Scan lines per VBL (50Hz)         : 313(64 at top,200 screen,49 bottom)
                    163: 
                    164:   Clock cycles per line (60Hz)      : 508
                    165:   NOPs per scan line (60Hz)         : 127
                    166:   Scan lines per VBL (60Hz)         : 315
                    167: 
                    168:   Clock cycles per VBL              : 160256
                    169:   NOPs per VBL                      : 40064
                    170: 
                    171:   Pixels per clock cycle (low res)  : 1
                    172:   Pixels per clock cycle (med res)  : 2
                    173:   Pixels per clock cycle (high res) : 4
                    174:   Pixels per NOP (low res)          : 4
                    175:   Pixels per NOP (med res)          : 8
                    176:   Pixels per NOP (high res)         : 16
                    177: */
                    178: #define SCREEN_START_HBL  64            /* This is usually the first line of the displayed screen */
                    179: #define SCREEN_HEIGHT_HBL  200          /* This is usually the height of the screen */
                    180: #define FIRST_VISIBLE_HBL  (SCREEN_START_HBL-OVERSCAN_TOP)    /* Normal screen starts 64 lines in, top border is 28 lines */
                    181: #define  NUM_VISIBLE_LINES  (OVERSCAN_TOP+SCREEN_HEIGHT_HBL+OVERSCAN_BOTTOM)  /* Number of visible screen lines including top/bottom borders */
                    182: 
                    183: /* Assumes 32 pixels left+right */
                    184: #define SCREENBYTES_LEFT    16          /* Bytes for left border in ST screen */
                    185: #define SCREENBYTES_MIDDLE    160       /* Middle(320 pixels) */
                    186: #define SCREENBYTES_RIGHT    16         /* right border */
                    187: #define SCREENBYTES_LINE    (SCREENBYTES_LEFT+SCREENBYTES_MIDDLE+SCREENBYTES_RIGHT)
                    188: 
                    189: /* Overscan values */
                    190: #define OVERSCAN_LEFT      (SCREENBYTES_LEFT*2)    /* Number of pixels in each border */
                    191: #define OVERSCAN_RIGHT      (SCREENBYTES_RIGHT*2)
                    192: #define OVERSCAN_TOP      29
                    193: #define OVERSCAN_BOTTOM      38
                    194: #define OVERSCAN_MIDDLE      320        /* Number of pixels across screen(low res) */
                    195: 
                    196: #define SCREEN_START_CYCLE    96        /* Cycle first normal pixel appears on */
                    197: #define SCANLINES_PER_FRAME    313      /* Number of scan lines per frame */
                    198: #define CYCLES_PER_LINE      512        /* Cycles per horiztonal line scan */
                    199: #define CYCLES_PER_FRAME    (SCANLINES_PER_FRAME*CYCLES_PER_LINE)  /* Cycles per VBL @ 50fps = 160256 */
                    200: #define CYCLES_VBL_IN      (SCREEN_START_HBL*CYCLES_PER_LINE)  /*((28+64)*CYCLES_PER_LINE) */
                    201: #define CYCLES_PER_SEC      (CYCLES_PER_FRAME*50)    /* Cycles per second */
                    202: #define CYCLES_ENDLINE      (64+320+88+40)      /* DE(Display Enable) */
                    203: #define CYCLES_HBL      (CYCLES_PER_LINE+96)    /* Cycles for first HBL - very inaccurate on ST */
                    204: #define CYCLES_DEBUGGER      3000       /* Check debugger every 'x' cycles */
                    205: 
                    206: /* Illegal Opcode used to help emulation. eg. free entries are 8 to 15 inc' */
                    207: #define  GEMDOS_OPCODE        8  /* Free op-code to intercept GemDOS trap */
                    208: #define  RUNOLDGEMDOS_OPCODE  9  /* Free op-code to set PC to old GemDOS vector(if doesn't need to intercept) */
                    209: #define  CONDRV_OPCODE       10  /* Free op-code to intercept set up connected drives */
                    210: #define  TIMERD_OPCODE       11  /* Free op-code to prevent Timer D starting in GemDOS */
                    211: #define  VDI_OPCODE          12  /* Free op-code to call VDI handlers AFTER Trap#2 */
                    212: #define  LINEA_OPCODE        13  /* Free op-code to call handlers AFTER Line-A */
                    213: /* Other Opcodes */
                    214: #define RTS_OPCODE  BIN16(0,1,0,0,1,1,1,0,0,1,1,1,0,1,0,1)
                    215: #define NOP_OPCODE  BIN16(0,1,0,0,1,1,1,0,0,1,1,1,0,0,0,1)
                    216: #define BRAW_OPCODE  BIN16(0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0)
                    217: 
                    218: /* Handy invalid address for flags(24-bit address can never be this) */
                    219: #define BRK_DISABLED      0xffffffff
                    220: #define BRK_SINGLE_INSTRUCTION    0xfffffffe
                    221: #define  BRK_STOP      0xfffffffd
                    222: 
                    223: #define PRG_HEADER_SIZE    0x1c  /* Size of header at start of ST .prg files */
                    224: 
                    225: 
                    226: extern BOOL bQuitProgram;
1.1.1.2   root      227: extern BOOL bEnableDebug;
1.1       root      228: extern BOOL bEmulationActive;
                    229: extern char szName[];
                    230: extern char szBootDiscImage[MAX_FILENAME_LENGTH];
                    231: extern char szWorkingDir[MAX_FILENAME_LENGTH];
                    232: extern char szCurrentDir[MAX_FILENAME_LENGTH];
                    233: 
                    234: extern void Main_MemorySnapShot_Capture(BOOL bSave);
                    235: extern void Main_SysError(char *Error,char *Title);
                    236: extern int Main_Message(char *lpText, char *lpCaption /*, unsigned int uType*/);
                    237: extern void Main_PauseEmulation(void);
                    238: extern void Main_UnPauseEmulation(void);
                    239: extern void Main_EventHandler();
                    240: extern void Main_WaitVBLEvent(void);
                    241: extern BOOL Main_AlreadyWaitingVBLEvent(void);
1.1.1.2   root      242: /*extern void Main_SoundTimerFunc(void);*/
1.1       root      243: extern void Main_SetSpeedThreadTimer(int nMinMaxSpeed);
                    244: 
                    245: #endif /* ifndef MAIN_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.