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 >
Wrap
C/C++ Source or Header
|
2001-08-18
|
16KB
|
445 lines
////////////////////////////////////////////////////////////////////////////////
// Jagulator: Atari Jaguar Console Emulation Project (core.h)
// -----------------------------------------------------------------------------
// Jagulator is the Copyright (c) RealityMan 1998-2001 and is provided "as is"
// without any expressed or implied warranty. I have no Trademarks, Legal or
// otherwise. Atari, Jaguar and the Atari Logo are copyright Hasbro Inc. All
// other Copyrights and Trademarks are acknowledged. This project is in no way
// linked to Atari/Hasbro or other associated Atari companies.
//
// 07-07-2001 GH: New Source, Rewritten for Release 1.5.0
// 00-00-0000 GH: All Previous Source Considered as Development Code Only
#ifndef CORE_H
#define CORE_H
////////////////////////////////////////////////////////////////////////////////
// Required Include Files
#include <windows.h>
#include <commctrl.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <stdio.h>
#include "resource.h"
#include "version.h"
#include "starcpu.h"
#include "jaguar.h"
////////////////////////////////////////////////////////////////////////////////
// Debug Definitions
#define RELEASE // Include Release Specific Code
//#define DBGMEM // Include Memory Access Debug Code
//#define DBGBLT // Include Blitter Debug Code
//#define DBGCLR // Include Color/CLUT Debug Code
////////////////////////////////////////////////////////////////////////////////
// Macro Definitions
#define DEBUG // Debug Mode Enabled
#define LINELEN 81 // Console Line Length
#define LINES 1024 // Max Console Lines
#define MAXSTRING 1024 // Max String Length
#define HISTORY 64 // Command History
#define RED "\x1\x4" // Colors for Console (VGA Color Numbers)
#define GRAY "\x1\x8"
#define NORMAL "\x1\x7"
#define PUR "\x1\x5"
#define YEL "\x1\xe"
#define YELLOW "\x1\xe"
#define WHITE "\x1\xf"
#define CYAN "\x1\x3"
#define BLUE "\x1\x9"
#define BROWN "\x1\x6"
#define GREEN "\x1\x2"
#define DBLUE "\x1\x1"
#define WIN_CONS 0 // Console Window Numbers
#define VIEW_CONS 0x040 // Changed Bitmask (For view_changed)
#define VIEW_CLEAR 0x100
#define VIEW_RESIZE 0x200
#define VIEW_ALL (VIEW_CONS)
#define KEY_ESC 27 // Console Keys
#define KEY_ENTER 13
#define KEY_BKSPACE 8
#define KEY_DEL 0x1f0
#define KEY_F1 0x101
#define KEY_F2 0x102
#define KEY_F3 0x103
#define KEY_F4 0x104
#define KEY_F5 0x105
#define KEY_F6 0x106
#define KEY_F7 0x107
#define KEY_F8 0x108
#define KEY_F9 0x109
#define KEY_F10 0x10A
#define KEY_F11 0x10B
#define KEY_F12 0x10C
#define KEY_LEFT 0x120
#define KEY_RIGHT 0x121
#define KEY_UP 0x122
#define KEY_DOWN 0x123
#define KEY_PGUP 0x124
#define KEY_PGDN 0x125
#define KEY_HOME 0x126
#define KEY_END 0x127
#define KEY_RELEASE 0x1000
#define IFIS(x,str) if(!stricmp(x,str))
#define IS(x,str) !stricmp(x,str)
////////////////////////////////////////////////////////////////////////////////
// Data Types
typedef signed int sdword; // 32-Bit
typedef unsigned int dword; // 32-Bit
typedef signed short sword; // 16-Bit
typedef unsigned short word; // 16-Bit
typedef signed char sbyte; // 8-Bit
typedef unsigned char byte; // 8-Bit
typedef struct {
dword hi, lo;
} phrase; // 64-Bit
typedef struct _tag_cfgdata // Configuration File Information
{
// [default]
char rootpath[MAX_PATH]; // Executable Path (Ends in \)
char rompath[MAX_PATH]; // Default Path for Rom Search
char bootpath[MAX_PATH]; // Default Path for Boot Rom
// [audio]
int sound; // Enable/Disable Audio
// [video]
int graphics; // Enable/Disable Video
int hres; // Width of Graphics Display
int vres; // Height of Graphics Display
int fullscreen; // Enable/Disable Fullscreen Mode
int frameskip; // Frameskip Level
} CFGDATA;
extern CFGDATA cfg; // External Decleration
typedef struct _tag_con // Console Line Data
{
char linedata[LINES][LINELEN];
char *line[LINES]; // 0 = bottommost
int writepos;
} Con;
extern Con console; // External Decleration
typedef struct _tag_view // Console View Information
{
int changed; // Bitmask for What to Update
int active; // Active Window: 0 = Console
int consolerow; // 0=Bottom of Console,>0=Scroll Upward
int consolecursor; // X-Cursor Position for Console
int consrows; // Number of Rows in Console (Read Only)
} View;
extern View view; // External Decleration
typedef struct _tag_win // Console Window Information
{
int y, sy;
} Win;
////////////////////////////////////////////////////////////////////////////////
// Globals
extern HWND hwndMain; // Handle to the Main App Window
extern HWND hwndStatus; // Handle to Status Bar
extern char eeprom[]; // Cartridge Hi-Score Eeprom Image
////////////////////////////////////////////////////////////////////////////////
// Emulator States
typedef struct _tag_state // Main Emulator State
{
byte ram[0x400000]; // Main and Shadow RAM Memory
byte game[0x600000]; // Cartridge ROM Image
byte boot[0x20000]; // Boot EEPROM
byte tom[0x10000]; // TOM
byte jerry[0x10000]; // JERRY
int frameopen; // Frame Currently Being Processed
int opened; // Display Opened Flag
int readytogo; // Emulation Can Begin
int emulating; // Emulation is Executing
GLclampf br, bg, bb; // Background Red, Green, Blue
} STATE;
extern STATE st; // External Decleration
typedef struct _tag_gpu_state // GPU State Information
{
// Main GPU Processor
sdword arb[32]; // GPU Active Register Bank
sdword srb[32]; // GPU Secondary Register Bank
dword acc; // Accumulator
//dword pc; // Program Counter
//dword src; // Source Register
//dword dst; // Destination Register
//BOOL z; // Zero Flag
//BOOL n; // Negative Flag
//BOOL c; // Carry Flag
dword ctrl; // GPU Control Word (0xF02114 RW)
BOOL div16; // 16.16 Division Flag (0xF0211C WO)
dword divrem; // Division Remainder (0xF0211C RO)
// Processor Activity Flags
BOOL gpuActive; // GPU Active Flag
BOOL objActive; // Object Processor Active Flag
BOOL step; // GPU Single Step Flag
BOOL stepgo; // GPU Single Step Go Flag
// Object List
dword olp; // Object List Pointer
BOOL olista; // Object List Active
// Graphics
dword vmode; // Video Mode
dword cmode; // Color Mode
dword frame; // Current Frame Number
int frameopen; // Frame Currently Being Processed
int opened; // Display Opened Flag
// Multi-Threading
HANDLE hGPUThread; // GPU Thread Handle
DWORD GPUTid; // GPU Thread ID
} GPUSTATE;
extern GPUSTATE gst; // External Decleration
typedef struct _tag_dsp_state // DSP State Information
{
// Main DSP Processor
sdword arb[32]; // DSP Active Register Bank
sdword srb[32]; // DSP Secondary Register Bank
dword acc; // Accumulator
dword pc; // Program Counter
dword src; // Source Register
dword dest; // Destination Register
BOOL z; // Zero Flag
BOOL n; // Negative Flag
BOOL c; // Carry Flag
BOOL div16; // 16.16 Division Flag
dword divrem; // Division Remainder
BOOL bswitched; // Register Banks Switched
// Multi-Threading
HANDLE hDSPThread; // DSP Thread Handle
DWORD DSPTid; // DSP Thread ID
// Processor Activity Flags
BOOL dspActive; // DSP Active Flag
} DSPSTATE;
extern DSPSTATE dst; // External Decleration
typedef struct _tag_blt_state // Blitter State
{
dword a1base; // A1 Base Register
dword a1flags; // A1 Flags Register
dword a1clip; // A1 Clipping Size
dword a1pixel; // A1 Pixel Pointer
dword a1step; // A1 Step Value
dword a1fstep; // A1 Step Fraction Value
dword a1fpixel; // A1 Pixel Pointer Fraction
dword a1inc; // A1 Increment
dword a1finc; // A1 Increment Fraction
dword a2base; // A2 Base Register
dword a2flags; // A2 Flags Register
dword a2mask; // A2 Window Mask
dword a2pixel; // A2 Pixel Pointer
dword a2step; // A2 Step Value
dword bcmd; // Blitter Command Register
dword bcount; // Counters Register
phrase bpatd; // Pattern Data Register
// Multi-Threading
HANDLE hBLTThread; // DSP Thread Handle
DWORD BLTTid; // DSP Thread ID
// Processor Activity Flags
BOOL bltInactive; // Blitter Inactive Flag
} BLTSTATE;
extern BLTSTATE blt; // External Decleration
////////////////////////////////////////////////////////////////////////////////
// RISC Defines
#define ADD 0
#define ADDC 1
#define ADDQ 2
#define ADDQT 3
#define SUB 4
#define SUBC 5
#define SUBQ 6
#define SUBQT 7
#define NEG 8
#define AND 9
#define OR 10
#define XOR 11
#define NOT 12
#define BTST 13
#define BSET 14
#define BCLR 15
#define MULT 16
#define IMULT 17
#define IMULTN 18
#define RESMAC 19
#define IMACN 20
#define DIV 21
#define ABS 22
#define SH 23
#define SHLQ 24
#define SHRQ 25
#define SHA 26
#define SHARQ 27
#define ROR 28
#define RORQ 29
#define CMP 30
#define CMPQ 31
#define SAT8 32
#define SAT16 33
#define SUBQMOD 32
#define SAT16S 33
#define MOVE 34
#define MOVEQ 35
#define MOVETA 36
#define MOVEFA 37
#define MOVEI 38
#define LOADB 39
#define LOADW 40
#define LOAD 41
#define LOADP 42
#define SAT32S 42
#define LOAD_14I 43
#define LOAD_15I 44
#define STOREB 45
#define STOREW 46
#define STORE 47
#define STOREP 48
#define MIRROR 48
#define STORE_14I 49
#define STORE_15I 50
#define MOVE_PC 51
#define JUMP 52
#define JR 53
#define MMULT 54
#define MTOI 55
#define NORMI 56
#define NOP 57
#define LOAD_14R 58
#define LOAD_15R 59
#define STORE_14R 60
#define STORE_15R 61
#define SAT24 62
#define PACK_UNPACK 63
#define ADDQMOD 63
////////////////////////////////////////////////////////////////////////////////
// Prototypes
// debugui.c
extern void print( char *, ... );
extern void con_gotoxy( int, int );
extern void flushdisplay( void );
extern void view_changed( int );
extern void conkey( int );
extern void con_cursorxy( int, int, int );
extern void view_writeconsole( char * );
extern void exitnow( void );
extern void error( char *, ... );
extern void view_open( void );
extern void debugui( void );
extern void view_close( void );
// cmd.c
extern void command_fkey( int );
extern void command( char * );
// main.c
extern void main_thread( void );
// mem.c
extern unsigned mem_tomreadw( unsigned );
extern void mem_tomwritew( unsigned, unsigned );
extern unsigned mem_jryreadw( unsigned );
extern void mem_jrywritew( unsigned, unsigned );
extern unsigned mem_readword( unsigned );
extern unsigned mem_readbyte( unsigned );
extern void mem_writebyte( unsigned, unsigned );
extern void mem_writeword( unsigned, unsigned );
// video.c
extern void v_getglinfo( void );
extern int v_init( int, int );
extern void v_deinit( void );
extern void obj_opendisplay( void );
extern void obj_framestart( void );
extern void obj_frameend( void );
// boot.c
dword boot_load( void );
extern void boot( char * );
extern void bootaddr( char *, int );
extern void bootcd( void );
// disarisc.c
void gpudebug_disassemble( int ) ;
void dspdebug_disassemble( int ) ;
// cpudebug.h
extern void cpudebug_hexdump( void );
extern void cpudebug_disassemble( int );
extern void cpudebug_registerdump( void );
// gpu.c
extern DWORD gpu_exec( LPVOID );
extern dword gpc; // Program Counter
// dsp.c
extern DWORD ExecDSP( LPVOID );
// color.c
extern void color_ccry( unsigned, unsigned );
extern void color_crgb( unsigned, unsigned );
extern dword rgb16_rgb32( dword, int );
extern dword cry16_rgb32( dword, int );
// blitter.c
extern void exec_blitter( void );
// object.c
extern void object_exec( void );
// cpu.c
extern dword cpu_exec( void );
// jagulator.c
extern HANDLE hInst; // Global Application Instance
extern char sbbuf[]; // Status Bar String Buffer
#endif // CORE_H