home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / JAGUAR / JAG_SRC / SOURCE / CORE.H < prev    next >
C/C++ Source or Header  |  2001-08-18  |  16KB  |  445 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. // Jagulator: Atari Jaguar Console Emulation Project (core.h)
  3. // -----------------------------------------------------------------------------
  4. // Jagulator is the Copyright (c) RealityMan 1998-2001 and is provided "as is" 
  5. // without any expressed or implied warranty. I have no Trademarks, Legal or 
  6. // otherwise. Atari, Jaguar and the Atari Logo are copyright Hasbro Inc. All 
  7. // other Copyrights and Trademarks are acknowledged. This project is in no way 
  8. // linked to Atari/Hasbro or other associated Atari companies.                
  9. //
  10. // 07-07-2001 GH: New Source, Rewritten for Release 1.5.0
  11. // 00-00-0000 GH: All Previous Source Considered as Development Code Only
  12.  
  13. #ifndef CORE_H
  14. #define CORE_H
  15.  
  16. ////////////////////////////////////////////////////////////////////////////////
  17. // Required Include Files
  18.  
  19. #include <windows.h>
  20. #include <commctrl.h>
  21. #include <gl/gl.h>
  22. #include <gl/glu.h>
  23. #include <stdio.h>
  24. #include "resource.h"
  25. #include "version.h"
  26. #include "starcpu.h"
  27. #include "jaguar.h"
  28.  
  29. ////////////////////////////////////////////////////////////////////////////////
  30. // Debug Definitions
  31.  
  32. #define RELEASE                        // Include Release Specific Code
  33.  
  34. //#define DBGMEM                         // Include Memory Access Debug Code
  35. //#define DBGBLT                         // Include Blitter Debug Code
  36. //#define DBGCLR                         // Include Color/CLUT Debug Code
  37.  
  38. ////////////////////////////////////////////////////////////////////////////////
  39. // Macro Definitions
  40.  
  41. #define DEBUG                          // Debug Mode Enabled
  42.  
  43. #define LINELEN                    81  // Console Line Length
  44. #define LINES                    1024  // Max Console Lines
  45. #define MAXSTRING                1024  // Max String Length
  46.  
  47. #define HISTORY                    64  // Command History
  48.  
  49. #define RED                  "\x1\x4"  // Colors for Console (VGA Color Numbers)
  50. #define GRAY                 "\x1\x8"
  51. #define NORMAL               "\x1\x7"
  52. #define PUR                  "\x1\x5"
  53. #define YEL                  "\x1\xe"
  54. #define YELLOW               "\x1\xe"
  55. #define WHITE                "\x1\xf"
  56. #define CYAN                 "\x1\x3"
  57. #define BLUE                 "\x1\x9"
  58. #define BROWN                "\x1\x6"
  59. #define GREEN                "\x1\x2"
  60. #define DBLUE                "\x1\x1"
  61.  
  62. #define WIN_CONS                    0  // Console Window Numbers         
  63.  
  64. #define VIEW_CONS               0x040  // Changed Bitmask (For view_changed)
  65. #define VIEW_CLEAR              0x100
  66. #define VIEW_RESIZE             0x200
  67. #define VIEW_ALL          (VIEW_CONS)
  68.  
  69. #define KEY_ESC                    27  // Console Keys
  70. #define KEY_ENTER                  13
  71. #define KEY_BKSPACE                 8
  72. #define KEY_DEL                 0x1f0
  73. #define KEY_F1                  0x101
  74. #define KEY_F2                  0x102
  75. #define KEY_F3                  0x103
  76. #define KEY_F4                  0x104
  77. #define KEY_F5                  0x105
  78. #define KEY_F6                  0x106
  79. #define KEY_F7                  0x107
  80. #define KEY_F8                  0x108
  81. #define KEY_F9                  0x109
  82. #define KEY_F10                 0x10A
  83. #define KEY_F11                 0x10B
  84. #define KEY_F12                 0x10C
  85. #define KEY_LEFT                0x120
  86. #define KEY_RIGHT               0x121
  87. #define KEY_UP                  0x122
  88. #define KEY_DOWN                0x123
  89. #define KEY_PGUP                0x124
  90. #define KEY_PGDN                0x125
  91. #define KEY_HOME                0x126
  92. #define KEY_END                 0x127
  93. #define KEY_RELEASE            0x1000
  94.  
  95. #define IFIS(x,str) if(!stricmp(x,str))   
  96. #define IS(x,str)   !stricmp(x,str)
  97.  
  98. ////////////////////////////////////////////////////////////////////////////////
  99. // Data Types
  100.  
  101.    typedef signed int         sdword;  // 32-Bit
  102.    typedef unsigned int       dword;   // 32-Bit
  103.    typedef signed short       sword;   // 16-Bit
  104.    typedef unsigned short     word;    // 16-Bit
  105.    typedef signed char        sbyte;   // 8-Bit
  106.    typedef unsigned char      byte;    // 8-Bit
  107.  
  108.    typedef struct {
  109.        dword        hi, lo;
  110.    } phrase;                           // 64-Bit
  111.  
  112.    typedef struct _tag_cfgdata         // Configuration File Information
  113.    {
  114.       // [default]
  115.       char rootpath[MAX_PATH];         // Executable Path (Ends in \)
  116.       char rompath[MAX_PATH];          // Default Path for Rom Search
  117.       char bootpath[MAX_PATH];         // Default Path for Boot Rom
  118.       
  119.       // [audio]
  120.       int  sound;                      // Enable/Disable Audio
  121.  
  122.       // [video]
  123.       int  graphics;                   // Enable/Disable Video
  124.       int  hres;                       // Width of Graphics Display
  125.       int  vres;                       // Height of Graphics Display
  126.       int  fullscreen;                 // Enable/Disable Fullscreen Mode
  127.       int  frameskip;                  // Frameskip Level
  128.  
  129.    } CFGDATA;
  130.  
  131.    extern CFGDATA cfg;                 // External Decleration
  132.  
  133.    typedef struct _tag_con             // Console Line Data
  134.    {
  135.       char linedata[LINES][LINELEN];
  136.       char *line[LINES];               // 0 = bottommost
  137.       int writepos;
  138.    } Con;
  139.  
  140.    extern Con console;                 // External Decleration
  141.  
  142.    typedef struct _tag_view            // Console View Information
  143.    {
  144.       int changed;                     // Bitmask for What to Update 
  145.       int active;                      // Active Window: 0 = Console
  146.       int consolerow;                  // 0=Bottom of Console,>0=Scroll Upward
  147.       int consolecursor;               // X-Cursor Position for Console
  148.       int consrows;                    // Number of Rows in Console (Read Only)
  149.    } View;
  150.  
  151.    extern View view;                   // External Decleration
  152.  
  153.    typedef struct _tag_win             // Console Window Information
  154.    {
  155.       int y, sy;
  156.    } Win;
  157.  
  158. ////////////////////////////////////////////////////////////////////////////////
  159. // Globals
  160.  
  161.    extern HWND hwndMain;               // Handle to the Main App Window
  162.    extern HWND hwndStatus;             // Handle to Status Bar
  163.    extern char eeprom[];               // Cartridge Hi-Score Eeprom Image
  164.  
  165. ////////////////////////////////////////////////////////////////////////////////
  166. // Emulator States
  167.  
  168.    typedef struct _tag_state           // Main Emulator State
  169.    {
  170.       byte ram[0x400000];              // Main and Shadow RAM Memory
  171.       byte game[0x600000];             // Cartridge ROM Image
  172.       byte boot[0x20000];              // Boot EEPROM
  173.       byte tom[0x10000];               // TOM 
  174.       byte jerry[0x10000];             // JERRY
  175.  
  176.       int    frameopen;                // Frame Currently Being Processed
  177.       int    opened;                   // Display Opened Flag
  178.       int    readytogo;                // Emulation Can Begin
  179.       int    emulating;                // Emulation is Executing
  180.  
  181.       GLclampf br, bg, bb;             // Background Red, Green, Blue
  182.  
  183.    } STATE;
  184.  
  185.    extern STATE st;                    // External Decleration
  186.  
  187.    typedef struct _tag_gpu_state       // GPU State Information
  188.    {
  189.       // Main GPU Processor
  190.       sdword arb[32];                  // GPU Active Register Bank
  191.       sdword srb[32];                  // GPU Secondary Register Bank
  192.       dword  acc;                      // Accumulator
  193.       //dword  pc;                       // Program Counter
  194.       //dword  src;                      // Source Register
  195.       //dword  dst;                      // Destination Register
  196.       //BOOL   z;                        // Zero Flag
  197.       //BOOL   n;                        // Negative Flag
  198.       //BOOL   c;                        // Carry Flag
  199.       dword  ctrl;                     // GPU Control Word    (0xF02114 RW)
  200.       BOOL   div16;                    // 16.16 Division Flag (0xF0211C WO)
  201.       dword  divrem;                   // Division Remainder  (0xF0211C RO)
  202.  
  203.       // Processor Activity Flags
  204.       BOOL   gpuActive;                // GPU Active Flag
  205.       BOOL   objActive;                // Object Processor Active Flag
  206.       BOOL   step;                     // GPU Single Step Flag
  207.       BOOL   stepgo;                   // GPU Single Step Go Flag
  208.  
  209.       // Object List
  210.       dword  olp;                      // Object List Pointer
  211.       BOOL   olista;                   // Object List Active
  212.  
  213.       // Graphics
  214.       dword  vmode;                    // Video Mode
  215.       dword  cmode;                    // Color Mode
  216.       dword  frame;                    // Current Frame Number
  217.       int    frameopen;                // Frame Currently Being Processed
  218.       int    opened;                   // Display Opened Flag
  219.  
  220.       // Multi-Threading
  221.       HANDLE hGPUThread;               // GPU Thread Handle
  222.       DWORD  GPUTid;                   // GPU Thread ID
  223.  
  224.    } GPUSTATE;
  225.  
  226.    extern GPUSTATE gst;                // External Decleration
  227.  
  228.    typedef struct _tag_dsp_state       // DSP State Information
  229.    {
  230.       // Main DSP Processor
  231.       sdword arb[32];                  // DSP Active Register Bank
  232.       sdword srb[32];                  // DSP Secondary Register Bank
  233.       dword  acc;                      // Accumulator
  234.       dword  pc;                       // Program Counter
  235.       dword  src;                      // Source Register
  236.       dword  dest;                     // Destination Register
  237.       BOOL   z;                        // Zero Flag
  238.       BOOL   n;                        // Negative Flag
  239.       BOOL   c;                        // Carry Flag
  240.       BOOL   div16;                    // 16.16 Division Flag
  241.       dword  divrem;                   // Division Remainder
  242.       BOOL   bswitched;                // Register Banks Switched
  243.  
  244.       // Multi-Threading
  245.       HANDLE hDSPThread;               // DSP Thread Handle
  246.       DWORD DSPTid;                    // DSP Thread ID
  247.  
  248.       // Processor Activity Flags
  249.       BOOL dspActive;                  // DSP Active Flag
  250.  
  251.    } DSPSTATE;
  252.  
  253.    extern DSPSTATE dst;                // External Decleration
  254.  
  255.    typedef struct _tag_blt_state       // Blitter State
  256.    {
  257.       dword  a1base;                   // A1 Base Register
  258.       dword  a1flags;                  // A1 Flags Register
  259.       dword  a1clip;                   // A1 Clipping Size
  260.       dword  a1pixel;                  // A1 Pixel Pointer
  261.       dword  a1step;                   // A1 Step Value
  262.       dword  a1fstep;                  // A1 Step Fraction Value
  263.       dword  a1fpixel;                 // A1 Pixel Pointer Fraction
  264.       dword  a1inc;                    // A1 Increment
  265.       dword  a1finc;                   // A1 Increment Fraction
  266.       dword  a2base;                   // A2 Base Register
  267.       dword  a2flags;                  // A2 Flags Register
  268.       dword  a2mask;                   // A2 Window Mask
  269.       dword  a2pixel;                  // A2 Pixel Pointer
  270.       dword  a2step;                   // A2 Step Value
  271.       dword  bcmd;                     // Blitter Command Register
  272.       dword  bcount;                   // Counters Register
  273.       phrase bpatd;                    // Pattern Data Register
  274.  
  275.       // Multi-Threading
  276.       HANDLE hBLTThread;               // DSP Thread Handle
  277.       DWORD BLTTid;                    // DSP Thread ID
  278.  
  279.       // Processor Activity Flags
  280.       BOOL   bltInactive;              // Blitter Inactive Flag
  281.  
  282.    } BLTSTATE;
  283.  
  284.    extern BLTSTATE blt;                // External Decleration
  285.  
  286. ////////////////////////////////////////////////////////////////////////////////
  287. // RISC Defines
  288.  
  289. #define ADD             0
  290. #define ADDC            1
  291. #define ADDQ            2
  292. #define ADDQT           3
  293. #define SUB             4
  294. #define SUBC            5
  295. #define SUBQ            6
  296. #define SUBQT           7
  297. #define NEG             8
  298. #define AND             9
  299. #define OR              10
  300. #define XOR             11
  301. #define NOT             12
  302. #define BTST            13
  303. #define BSET            14
  304. #define BCLR            15
  305. #define MULT            16
  306. #define IMULT           17
  307. #define IMULTN          18
  308. #define RESMAC          19
  309. #define IMACN           20
  310. #define DIV             21
  311. #define ABS             22
  312. #define SH              23
  313. #define SHLQ            24
  314. #define SHRQ            25
  315. #define SHA             26
  316. #define SHARQ           27
  317. #define ROR             28
  318. #define RORQ            29
  319. #define CMP             30
  320. #define CMPQ            31
  321. #define SAT8            32
  322. #define SAT16           33
  323. #define SUBQMOD         32
  324. #define SAT16S          33
  325. #define MOVE            34
  326. #define MOVEQ           35
  327. #define MOVETA          36
  328. #define MOVEFA          37
  329. #define MOVEI           38
  330. #define LOADB           39
  331. #define LOADW           40
  332. #define LOAD            41
  333. #define LOADP           42
  334. #define SAT32S          42
  335. #define LOAD_14I        43
  336. #define LOAD_15I        44
  337. #define STOREB          45
  338. #define STOREW          46
  339. #define STORE           47
  340. #define STOREP          48
  341. #define MIRROR          48
  342. #define STORE_14I       49
  343. #define STORE_15I       50
  344. #define MOVE_PC         51
  345. #define JUMP            52
  346. #define JR              53
  347. #define MMULT           54
  348. #define MTOI            55
  349. #define NORMI           56
  350. #define NOP             57
  351. #define LOAD_14R        58
  352. #define LOAD_15R        59
  353. #define STORE_14R       60
  354. #define STORE_15R       61
  355. #define SAT24           62
  356. #define PACK_UNPACK     63
  357. #define ADDQMOD         63
  358.  
  359. ////////////////////////////////////////////////////////////////////////////////
  360. // Prototypes
  361.  
  362.    // debugui.c
  363.    extern void print( char *, ... );   
  364.    extern void con_gotoxy( int, int );
  365.    extern void flushdisplay( void );
  366.    extern void view_changed( int );
  367.    extern void conkey( int );
  368.    extern void con_cursorxy( int, int, int );
  369.    extern void view_writeconsole( char * );
  370.    extern void exitnow( void );
  371.    extern void error( char *, ... );
  372.    extern void view_open( void );
  373.    extern void debugui( void );
  374.    extern void view_close( void );
  375.  
  376.    // cmd.c
  377.    extern void command_fkey( int );    
  378.    extern void command( char * );
  379.  
  380.    // main.c
  381.    extern void main_thread( void );    
  382.  
  383.    // mem.c
  384.    extern unsigned mem_tomreadw( unsigned );
  385.    extern void mem_tomwritew( unsigned, unsigned );
  386.    extern unsigned mem_jryreadw( unsigned );
  387.    extern void mem_jrywritew( unsigned, unsigned );
  388.    extern unsigned mem_readword( unsigned );
  389.    extern unsigned mem_readbyte( unsigned );
  390.    extern void mem_writebyte( unsigned, unsigned );
  391.    extern void mem_writeword( unsigned, unsigned );
  392.  
  393.    // video.c
  394.    extern void v_getglinfo( void );    
  395.    extern int v_init( int, int );
  396.    extern void v_deinit( void );
  397.    extern void obj_opendisplay( void );
  398.    extern void obj_framestart( void );
  399.    extern void obj_frameend( void );
  400.  
  401.    // boot.c
  402.    dword boot_load( void );
  403.    extern void boot( char * );
  404.    extern void bootaddr( char *, int );
  405.    extern void bootcd( void );
  406.  
  407.    // disarisc.c
  408.    void gpudebug_disassemble( int ) ;
  409.    void dspdebug_disassemble( int ) ;
  410.  
  411.    // cpudebug.h 
  412.    extern void cpudebug_hexdump( void ); 
  413.    extern void cpudebug_disassemble( int );
  414.    extern void cpudebug_registerdump( void );
  415.  
  416.    // gpu.c
  417.    extern DWORD gpu_exec( LPVOID );
  418.    extern dword gpc;                          // Program Counter
  419.  
  420.    // dsp.c
  421.    extern DWORD ExecDSP( LPVOID );
  422.  
  423.    // color.c
  424.    extern void color_ccry( unsigned, unsigned );
  425.    extern void color_crgb( unsigned, unsigned );
  426.    extern dword rgb16_rgb32( dword, int );
  427.    extern dword cry16_rgb32( dword, int );
  428.  
  429.    // blitter.c
  430.    extern void exec_blitter( void );
  431.  
  432.    // object.c
  433.    extern void object_exec( void );
  434.  
  435.    // cpu.c
  436.    extern dword cpu_exec( void );
  437.  
  438.    // jagulator.c
  439.    extern HANDLE hInst;                // Global Application Instance
  440.    extern char sbbuf[];                // Status Bar String Buffer
  441.  
  442. #endif // CORE_H
  443.  
  444.  
  445.