home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ST-Computer Leser 2002 January
/
STC_CD_01_2002.iso
/
JAGUAR
/
JAG_SRC
/
SOURCE
/
JAGUAR.H
< prev
next >
Wrap
C/C++ Source or Header
|
2001-08-14
|
32KB
|
670 lines
////////////////////////////////////////////////////////////////////////////////
// Jagulator: Atari Jaguar Console Emulation Project (jaguar.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.
#ifndef JAGUAR_H
#define JAGUAR_H
////////////////////////////////////////////////////////////////////////////////
// Generic Defines
#define DRAM 0x000000 // Physical Start of RAM
#define USERRAM 0x004000 // Start of Available RAM
#define ENDRAM 0x200000 // End of RAM
#define INITSTACK (ENDRAM-4) // Recommended Stack Location
#define LEVEL0 0x100 // 68000 Level 0 Autovector
#define USER0 0x100 // Pseudonym
////////////////////////////////////////////////////////////////////////////////
// Masks for INT1 CPU Interrupt Control
#define C_VIDENA 0x0001 // Enable CPU Video Interrupts
#define C_GPUENA 0x0002 // Enable CPU GPU Interrupts
#define C_OPENA 0x0004 // Enable CPU OP Interrupts
#define C_PITENA 0x0008 // Enable CPU PIT Interrupts
#define C_JERENA 0x0010 // Enable CPU Jerry Interrupts
#define C_VIDCLR 0x0100 // Clear CPU Video Interrupts
#define C_GPUCLR 0x0200 // Clear CPU GPU Interrupts
#define C_OPCLR 0x0400 // Clear CPU OP Interrupts
#define C_PITCLR 0x0800 // Clear CPU PIT Interrupts
#define C_JERCLR 0x1000 // Clear CPU Jerry Interrupts
////////////////////////////////////////////////////////////////////////////////
// Jaguar Registers
#define BASE 0xF00000 // TOM Internal Register Base
#define MEMCON1 0xF00000
#define MEMCON2 0xF00002
#define HC 0xF00004 // Horizontal Count
#define VC 0xF00006 // Vertical Count
#define LPH 0xF00008 // Horizontal Lightpen
#define LPV 0xF0000A // Vertical LightPen
#define OB0 0xF00010 // Current Object Phrase
#define OB1 0xF00012
#define OB2 0xF00014
#define OB3 0xF00016
#define OLP 0xF00020 // Object List Pointer
#define OLPLO 0xF00020
#define OLPHI 0xF00022
#define ODP 0xF00024
#define OBF 0xF00026 // Object Processor Flag
#define VMODE 0xF00028 // Video Mode
#define BORD 0xF0002A
#define BORD1 0xF0002A // Border Color (Red & Green)
#define BORD2 0xF0002C // Border Color (Blue)
#define HP 0xF0002E
#define HBB 0xF00030
#define HBE 0xF00032
#define HS 0xF00034
#define HVS 0xF00036
#define HDB1 0xF00038 // Horizontal Display Begin One
#define HDB2 0xF0003A // Horizontal Display Begin Two
#define HDE 0xF0003C // Horizontal Display End
#define VP 0xF0003E
#define VBB 0xF00040
#define VBE 0xF00042
#define VS 0xF00044 // Vertical Sync
#define VDB 0xF00046 // Vertical Display Begin
#define VDE 0xF00048 // Vertical Display End
#define VEB 0xF0004A
#define VEE 0xF0004C
#define VI 0xF0004E // Vertical Interrupt
#define PIT 0xF00050
#define PIT0 0xF00050 // Programmable Interrupt Timer (Lo)
#define PIT1 0xF00052 // Programmable Interrupt Timer (Hi)
#define HEQ 0xF00054
#define BG 0xF00058 // Background Color
#define INT1 0xF000E0 // CPU Interrupt Control Register
#define INT2 0xF000E2 // CPU Interrupt Resume Register
#define CLUT 0xF00400 // Color Lookup Table
#define LBUFA 0xF00800 // Line Buffer A
#define LBUFB 0xF01000 // Line Buffer B
#define LBUFC 0xF01800 // Line Buffer Current
////////////////////////////////////////////////////////////////////////////////
// Object Processor Equates
#define O_MASK_TYPE 0x00000007 // Mask off Object Type Field
#define BITOBJ 0 // Bitmap Object Type
#define SCBITOBJ 1 // Scaled Bitmap Object Type
#define GPUOBJ 2 // GPU Interrupt Object Type
#define BRANCHOBJ 3 // Branch Object Type
#define STOPOBJ 4 // Stop Object Type
#define O_REFLECT 0x00002000 // OR with top LONG of BITMAP Object
#define O_RMW 0x00004000
#define O_TRANS 0x00008000
#define O_RELEASE 0x00010000
#define O_DEPTH1 (0<<12) // DEPTH Field for BITMAP Objects
#define O_DEPTH2 (1<<12)
#define O_DEPTH4 (2<<12)
#define O_DEPTH8 (3<<12)
#define O_DEPTH16 (4<<12)
#define O_DEPTH32 (5<<12)
#define O_NOGAP (1<<15) // Phrase GAP Between Image Phrases
#define O_1GAP (2<<15)
#define O_2GAP (3<<15)
#define O_3GAP (4<<15)
#define O_4GAP (5<<15)
#define O_5GAP (6<<15)
#define O_6GAP (7<<15)
#define O_BREQ 0 // CC Field of BRANCH Objects
#define O_BRGT 1
#define O_BRLT 2
#define O_BROP 3
#define O_BRHALF 4
#define O_STOPINTS 0x00000008 // Enable Interrupts in STOP Object
// Bitmap and Scaled Bitmap Defines
#define O_YPOS 0x00003FF8 // Y Position
#define O_HEIGHT 0x00FFC000 // Number of Data Lines in Object
#define O_LINK1 0xFF000000 // Part 1 of Next Object Address
#define O_LINK2 0x000007FF // Part 2 of Next Object Address
#define O_DATA 0xFFFFF800 // Address of Pixel Data
#define O_XPOS 0x00000FFF // X Position of First Pixel
#define O_DEPTH 0x00007000 // Bits Per Pixel
#define O_PITCH 0x00038000 // Space to be Skipped
#define O_DWIDTH 0x0FFC0000 // Data Width in Phrases
#define O_IWIDTH1 0xF0000000 // Part 1 of Image Width in Phrases
#define O_IWIDTH2 0x0000003F // Part 2 of Image Width in Phrases
#define O_INDEX 0x00001FC0 // Palette Address Element
#define O_FLAGS 0x0001E000 // Reflect, RMW, Trans, Release
#define O_1STPIX 0x007E0000 // First Pixel to be Displayed
#define O_HSCALE 0x000000FF // Horizontal Scaling
#define O_VSCALE 0x0000FF00 // Vertical Scaling
#define O_REMAIN 0x00FF0000 // Scaling Remainder
////////////////////////////////////////////////////////////////////////////////
// Video Initialisation Constants
#define NTSC_WIDTH 1409 // Width of Screen in Clocks
#define NTSC_HMID 823 // Middle of Screen in Clocks
#define NTSC_HEIGHT 241 // Height of Screen in Pixels
#define NTSC_VMID 266 // Middle of Screen in Half-Lines
#define PAL_WIDTH 1381 // Same as above for PAL
#define PAL_HMID 843
#define PAL_HEIGHT 287
#define PAL_VMID 322
////////////////////////////////////////////////////////////////////////////////
// The following mask will extract the PAL/NTSC flag bit from the
// CONFIG register. NTSC = Bit Set, PAL = Bit Clear
#define VIDTYPE 0x10
////////////////////////////////////////////////////////////////////////////////
// The following are Video Mode Register Masks
#define VIDEN 0x0001 // Enable Video Interrupts
#define CRY16 0x0000 // 16-bit CRY Mode
#define RGB24 0x0002 // 24-bit RGB Mode
#define DIRECT16 0x0004 // 16-bit Direct Mode
#define RGB16 0x0006 // 16-bit RGB Mode
#define GENLOCK 0x0008 // Not Supported on Jaguar Console
#define INCEN 0x0010 // Enable Encrustation
#define BINC 0x0020 // Select Local Border Color
#define CSYNC 0x0040 // Enable Composite Sync
#define BGEN 0x0080 // Clear Line Buffer to BG Register
#define VARMOD 0x0100 // Enable Variable Resolution mode
#define PWIDTH1 0x0000 // Pixel Dividers
#define PWIDTH2 0x0200
#define PWIDTH3 0x0400
#define PWIDTH4 0x0600
#define PWIDTH5 0x0800
#define PWIDTH6 0x0A00
#define PWIDTH7 0x0C00
#define PWIDTH8 0x0E00
#define G_FLAGS 0xF02100 // GPU Flags
#define G_MTXC 0xF02104 // GPU Matrix Control
#define G_MTXA 0xF02108 // GPU Matrix Address
#define G_END 0xF0210C // GPU Data Organization
#define G_PC 0xF02110 // GPU Program Counter
#define G_CTRL 0xF02114 // GPU Operation Control/Status
#define G_HIDATA 0xF02118 // GPU Bus Interface High Data
#define G_REMAIN 0xF0211C // GPU Division Remainder
#define G_DIVCTRL 0xF0211C // GPU Divider Control
#define G_RAM 0xF03000 // GPU Internal RAM
#define G_ENDRAM 0xF04000 // GPU End of Internal RAM
////////////////////////////////////////////////////////////////////////////////
// GPU Flags Register Equates
#define G_CPUENA 0x00000010 // CPU Interrupt Enable Bits
#define G_DSPENA 0x00000020 // DSP Interrupt Enable Bits
#define G_PITENA 0x00000040 // PIT Interrupt Enable Bits
#define G_OPENA 0x00000080 // Object Processor Interrupt Enable Bits
#define G_BLITENA 0x00000100 // Blitter Interrupt Enable Bits
#define G_CPUCLR 0x00000200 // CPU Interrupt Clear Bits
#define G_DSPCLR 0x00000400 // DSP Interrupt Clear Bits
#define G_PITCLR 0x00000800 // PIT Interrupt Clear Bits
#define G_OPCLR 0x00001000 // Object Processor Interrupt Clear Bits
#define G_BLITCLR 0x00002000 // Blitter Interrupt Clear Bits
////////////////////////////////////////////////////////////////////////////////
// GPU Control/Status Register
#define GPUGO 0x00000001 // Start and Stop the GPU
#define GPUINT0 0x00000004 // Generate a GPU Type 0 Interrupt
#define G_CPULAT 0x00000040 // Interrupt Latches
#define G_DSPLAT 0x00000080
#define G_PITLAT 0x00000100
#define G_OPLAT 0x00000200
#define G_BLITLAT 0x00000400
#define A1_BASE 0xF02200 // A1 Base Address
#define A1_FLAGS 0xF02204 // A1 Control Flags
#define A1_CLIP 0xF02208 // A1 Clipping Size
#define A1_PIXEL 0xF0220C // A1 Pixel Pointer
#define A1_STEP 0xF02210 // A1 Step (Integer Part)
#define A1_FSTEP 0xF02214 // A1 Step (Fractional Part)
#define A1_FPIXEL 0xF02218 // A1 Pixel Pointer (Fractional)
#define A1_INC 0xF0221C // A1 Increment (Integer Part)
#define A1_FINC 0xF02220 // A1 Increment (Fractional Part)
#define A2_BASE 0xF02224 // A2 Base Address
#define A2_FLAGS 0xF02228 // A2 Control Flags
#define A2_MASK 0xF0222C // A2 Address Mask
#define A2_PIXEL 0xF02230 // A2 PIXEL
#define A2_STEP 0xF02234 // A2 Step (Integer)
#define B_CMD 0xF02238 // Command
#define B_COUNT 0xF0223C // Counters
#define B_SRCD 0xF02240 // Source Data
#define B_DSTD 0xF02248 // Destination Data
#define B_DSTZ 0xF02250 // Destination Z
#define B_SRCZ1 0xF02258 // Source Z (Integer)
#define B_SRCZ2 0xF02260 // Source Z (Fractional)
#define B_PATD 0xF02268 // Pattern Data
#define B_PATD0 0xF02268
#define B_PATD1 0xF0226C
#define B_IINC 0xF02270 // Intensity Increment
#define B_ZINC 0xF02274 // Z Increment
#define B_STOP 0xF02278 // Collision Stop Control
#define B_I3 0xF0227C // Blitter Intensity 3
#define B_I2 0xF02280 // Blitter Intensity 2
#define B_I1 0xF02284 // Blitter Intensity 1
#define B_I0 0xF02288 // Blitter Intensity 0
#define B_Z3 0xF0228C // Blitter Z 3
#define B_Z2 0xF02290 // Blitter Z 2
#define B_Z1 0xF02294 // Blitter Z 1
#define B_Z0 0xF02298 // Blitter Z 0
////////////////////////////////////////////////////////////////////////////////
// BLITTER Command Register Defines
#define SRCEN 0x00000001 // d00: Source Data Read (Inner Loop)
#define SRCENZ 0x00000002 // d01: Source Z Read (Inner Loop)
#define SRCENX 0x00000004 // d02: Source Data Read (Realign)
#define DSTEN 0x00000008 // d03: Destination Data Read (Inner Loop)
#define DSTENZ 0x00000010 // d04: Destination Z Read (Inner Loop)
#define DSTWRZ 0x00000020 // d05: Destination Z Write (Inner Loop)
#define CLIP_A1 0x00000040 // d06: A1 Clipping Enable
#define UPDA1F 0x00000100 // d08: A1 Update Step Fraction
#define UPDA1 0x00000200 // d09: A1 Update Step
#define UPDA2 0x00000400 // d10: A2 Update Step
#define DSTA2 0x00000800 // d11: Reverse Usage of A1 and A2
#define GOURD 0x00001000 // d12: Enable Gouraud Shading
#define ZBUFF 0x00002000 // d13: Polygon Z Data Updates
#define TOPBEN 0x00004000 // d14: Intensity Carry into Byte
#define TOPNEN 0x00008000 // d15: Intensity Carry into Nibble
#define PATDSEL 0x00010000 // d16: Select Pattern Data
#define ADDDSEL 0x00020000 // d17: Diagnostic
// d18-d20: Z Comparator Inhibit
#define ZMODELT 0x00040000 // Source < Destination
#define ZMODEEQ 0x00080000 // Source = Destination
#define ZMODEGT 0x00100000 // Source > Destination
// d21-d24: Logic Function Control
#define LFU_NAN 0x00200000 // !Source & !Destination
#define LFU_NA 0x00400000 // !Source & Destination
#define LFU_AN 0x00800000 // Source & !Destination
#define LFU_A 0x01000000 // Source & Destination
#define CMPDST 0x02000000 // d25: Pixel Compare Pattern & Dest
#define BCOMPEN 0x04000000 // d26: Bit Compare Write Inhibit
#define DCOMPEN 0x08000000 // d27: Data Compare Write Inhibit
#define BKGWREN 0x10000000 // d28: Data Write Back
#define BUSHI 0x20000000 // d29 Blitter Priority
#define SRCSHADE 0x40000000 // d30: Shade Src Data w/IINC Value
////////////////////////////////////////////////////////////////////////////////
// The following are ALL 16 possible Logical Operations of the LFUs
#define LFU_ZERO 0x00000000 // All Zeros
#define LFU_NSAND 0x00200000 // NOT Source AND NOT Destination
#define LFU_NSAD 0x00400000 // NOT Source AND Destination
#define LFU_NOTS 0x00600000 // NOT Source
#define LFU_SAND 0x00800000 // Source AND NOT Destination
#define LFU_NOTD 0x00A00000 // NOT Destination
#define LFU_N_SXORD 0x00C00000 // NOT (Source XOR Destination)
#define LFU_NSORND 0x00E00000 // NOT Source OR NOT Destination
#define LFU_SAD 0x01000000 // Source AND Destination
#define LFU_SXORD 0x01200000 // Source XOR Destination
#define LFU_D 0x01400000 // Destination
#define LFU_NSORD 0x01600000 // NOT Source OR Destination
#define LFU_S 0x01800000 // Source
#define LFU_SORND 0x01A00000 // Source OR NOT Destination
#define LFU_SORD 0x01C00000 // Source OR Destination
#define LFU_ONE 0x01E00000 // All Ones
////////////////////////////////////////////////////////////////////////////////
// These are some Common Combinations with Less Boolean Names
#define LFU_REPLACE 0x01800000 // Source REPLACEs Destination
#define LFU_XOR 0x01200000 // Source XOR with Destination
#define LFU_CLEAR 0x00000000 // CLEAR Destination
////////////////////////////////////////////////////////////////////////////////
// BLITTER Flags (A1 or A2) Register Defines
// Pitch d00-d01: Distance Between Pixel Phrases
#define PITCH1 0x00000000 // 0 Phrase Gap
#define PITCH2 0x00000001 // 1 Phrase Gap
#define PITCH4 0x00000002 // 3 Phrase Gap
#define PITCH3 0x00000003 // 2 Phrase Gap
// Pixel d03-d05: bit depth (2^n)
#define PIXEL1 0x00000000 // n = 0
#define PIXEL2 0x00000008 // n = 1
#define PIXEL4 0x00000010 // n = 2
#define PIXEL8 0x00000018 // n = 3
#define PIXEL16 0x00000020 // n = 4
#define PIXEL32 0x00000028 // n = 5
// Z offset d06-d08: Offset from phrase of pixel data from its corresponding
// Z data phrases.
#define ZOFFS0 0x00000000 // Offset = 0 UNUSED
#define ZOFFS1 0x00000040 // Offset = 1
#define ZOFFS2 0x00000080 // Offset = 2
#define ZOFFS3 0x000000C0 // Offset = 3
#define ZOFFS4 0x00000100 // Offset = 4
#define ZOFFS5 0x00000140 // Offset = 5
#define ZOFFS6 0x00000180 // Offset = 6
#define ZOFFS7 0x000001C0 // Offset = 7 UNUSED
// Width d09-d14: Width used for Address Generation
// This is a 6-bit floating point value in pixels
// 4-bit unsigned exponent
// 2-bit mantissa with implied 3rd bit of 1
#define WID2 0x00000800 // 1.00 X 2^1 ( 4<<9)
#define WID4 0x00001000 // 1.00 X 2^2 ( 8<<9)
#define WID6 0x00001400 // 1.10 X 2^2 (10<<9)
#define WID8 0x00001800 // 1.00 x 2^3 (12<<9)
#define WID10 0x00001A00 // 1.01 X 2^3 (13<<9)
#define WID12 0x00001C00 // 1.10 X 2^3 (14<<9)
#define WID14 0x00001E00 // 1.11 X 2^3 (15<<9)
#define WID16 0x00002000 // 1.00 X 2^4 (16<<9)
#define WID20 0x00002200 // 1.01 X 2^4 (17<<9)
#define WID24 0x00002400 // 1.10 X 2^4 (18<<9)
#define WID28 0x00002600 // 1.11 X 2^4 (19<<9)
#define WID32 0x00002800 // 1.00 X 2^5 (20<<9)
#define WID40 0x00002A00 // 1.01 X 2^5 (21<<9)
#define WID48 0x00002C00 // 1.10 X 2^5 (22<<9)
#define WID56 0x00002E00 // 1.11 X 2^5 (23<<9)
#define WID64 0x00003000 // 1.00 X 2^6 (24<<9)
#define WID80 0x00003200 // 1.01 X 2^6 (25<<9)
#define WID96 0x00003400 // 1.10 X 2^6 (26<<9)
#define WID112 0x00003600 // 1.11 X 2^6 (27<<9)
#define WID128 0x00003800 // 1.00 X 2^7 (28<<9)
#define WID160 0x00003A00 // 1.01 X 2^7 (29<<9)
#define WID192 0x00003C00 // 1.10 X 2^7 (30<<9)
#define WID224 0x00003E00 // 1.11 X 2^7 (31<<9)
#define WID256 0x00004000 // 1.00 X 2^8 (32<<9)
#define WID320 0x00004200 // 1.01 X 2^8 (33<<9)
#define WID384 0x00004400 // 1.10 X 2^8 (34<<9)
#define WID448 0x00004600 // 1.11 X 2^8 (35<<9)
#define WID512 0x00004800 // 1.00 X 2^9 (36<<9)
#define WID640 0x00004A00 // 1.01 X 2^9 (37<<9)
#define WID768 0x00004C00 // 1.10 X 2^9 (38<<9)
#define WID896 0x00004E00 // 1.11 X 2^9 (39<<9)
#define WID1024 0x00005000 // 1.00 X 2^10 (40<<9)
#define WID1280 0x00005200 // 1.01 X 2^10 (41<<9)
#define WID1536 0x00005400 // 1.10 X 2^10 (42<<9)
#define WID1792 0x00005600 // 1.11 X 2^10 (43<<9)
#define WID2048 0x00005800 // 1.00 X 2^11 (44<<9)
#define WID2560 0x00005A00 // 1.01 X 2^11 (45<<9)
#define WID3072 0x00005C00 // 1.10 X 2^11 (46<<9)
#define WID3584 0x00005E00 // 1.11 X 2^11 (47<<9)
// X add control d16-d17: Controls the update of the X pointer on each pass
// round the inner loop
#define XADDPHR 0x00000000 // 00 - Add Phrase Width and Truncate
#define XADDPIX 0x00010000 // 01 - Add Pixel Size (Add 1)
#define XADD0 0x00020000 // 10 - Add Zero
#define XADDINC 0x00030000 // 11 - Add the Increment
// Y add control d18:
// Controls the update of the Y pointer within the inner loop.
// It is overridden by the X add control if they are in add increment.
#define YADD0 0x00000000 // 00 - Add Zero
#define YADD1 0x00040000 // 01 - Add 1
// X sign d19: Add or subtract pixel size if X add control = 01 (XADDPIX)
#define XSIGNADD 0x00000000 // 0 - Add Pixel Size
#define XSIGNSUB 0x00080000 // 1 - Subtract Pixel Size
// Y sign d20: Add or subtract pixel size if Y add control = 01 (YADD1)
#define YSIGNADD 0x00000000 // 0 - Add 1
#define YSIGNSUB 0x00100000 // 1 - Sub 1
////////////////////////////////////////////////////////////////////////////////
// Jerry Registers
#define JPIT1 0xF10000 // Timer 1 Pre-Scaler
#define JPIT2 0xF10002 // Timer 1 Divider
#define JPIT3 0xF10004 // Timer 2 Pre-Scaler
#define JPIT4 0xF10006 // Timer 2 Divider
#define J_INT 0xF10020 // Jerry Interrupt Control (to TOM)
#define CLK1 0xF10010
#define CLK2 0xF10012
#define CHRO_CLK 0xF10014
#define R_DAC 0xF1A148
#define L_I2S 0xF1A148 // Left I2S Serial
#define L_DAC 0xF1A14C
#define R_I2S 0xF1A14C // Right I2S Serial
#define SCLK 0xF1A150 // SSI Clock Frequency
#define SMODE 0xF1A154 // SSI Control
#define ASIDATA 0xF10030
#define ASICTRL 0xF10032
#define ASISTAT 0xF10032
#define ASICLK 0xF10034
#define JOYSTICK 0xF14000 // Joystick Register and Mute
#define JOYBUTS 0xF14002 // Joystick Register
#define CONFIG 0xF14002 // Also has NTSC/PAL
#define PADDLE 0xF15000
#define ANALOGJOY 0xF17C00
////////////////////////////////////////////////////////////////////////////////
// Jerry Interrupt Control Flags
#define J_EXTENA 0x0001 // Enable Jerry External Ints
#define J_DSPENA 0x0002 // Enable Jerry DSP Ints
#define J_TIM1ENA 0x0004 // Enable Jerry Timer 1 Ints
#define J_TIM2ENA 0x0008 // Enable Jerry Timer 2 Ints
#define J_ASYNENA 0x0010 // Enable Jerry Asynch Serial Ints
#define J_SYNENA 0x0020 // Enable Jerry Synch Serial Ints
#define J_EXTCLR 0x0100 // Clear Pending External Ints
#define J_DSPCLR 0x0200 // Clear Pending DSP Ints
#define J_TIM1CLR 0x0400 // Clear Pending Timer 1 Ints
#define J_TIM2CLR 0x0800 // Clear Pending Timer 2 Ints
#define J_ASYNCLR 0x1000 // Clear Pending Asynch Serial Ints
#define J_SYNCLR 0x2000 // Clear Pending Synch Serial Ints
////////////////////////////////////////////////////////////////////////////////
// Joystick Equates
// Bits when LONGword is formatted as below (from JOYTEST\JT_LOOP.S).
// Format: xxApxxBx RLDU147* xxCxxxox 2580369#
#define JOY_UP 20 // Joypad
#define JOY_DOWN 21
#define JOY_LEFT 22
#define JOY_RIGHT 23
#define FIRE_A 29 // Fire Buttons
#define FIRE_B 25
#define FIRE_C 13
#define OPTION 9
#define PAUSE 28
#define KEY_STAR 16 // Keypad
#define KEY_7 17
#define KEY_4 18
#define KEY_1 19
#define KEY_0 4
#define KEY_8 5
#define KEY_5 6
#define KEY_2 7
#define KEY_HASH 0
#define KEY_9 1
#define KEY_6 2
#define KEY_3 3
// AND Joyedge with this - Joypad was Pressed if Result is not 0
#define ANY_JOY 0x00F00000
// AND Joyedge with this - A,B C Option or Pause was Pressed if Result is not 0
#define ANY_FIRE 0x32002200
// AND Joyedge with this - 123456789*0# was Pressed if Result is not 0
#define ANY_KEY 0x000F00FF
////////////////////////////////////////////////////////////////////////////////
// ROM Tables Built into Jerry - 128 Samples Each
// 16 Bit Samples Sign Extended to 32
#define ROM_TABLE 0xF1D000 // Base of Tables
#define ROM_TRI 0xF1D000 // A Triangle Wave
#define ROM_SINE 0xF1D200 // Full Amplitude SINE
#define ROM_AMSIN 0xF1D400 // Linear (?) ramp SINE
#define ROM_12W 0xF1D600 // SINE(X)+SINE(2*X) : (was ROM_SINE12W)
#define ROM_CHIRP 0xF1D800 // Short Sweep
#define ROM_NTRI 0xF1DA00 // Triangle with NOISE
#define ROM_DELTA 0xF1DC00 // Positive Spike
#define ROM_NOISE 0xF1DE00 // Noise
////////////////////////////////////////////////////////////////////////////////
// JERRY Registers (DSP)
#define D_FLAGS 0xF1A100 // DSP Flags
#define D_MTXC 0xF1A104 // DSP Matrix Control
#define D_MTXA 0xF1A108 // DSP Matrix Address
#define D_END 0xF1A10C // DSP Data Organisation
#define D_PC 0xF1A110 // DSP Program Counter
#define D_CTRL 0xF1A114 // DSP Operation Control/Status
#define D_MOD 0xF1A118 // DSP Modulo Instruction Mask
#define MOD_MASK 0xF1A118 // Mask for ADDQ(SUBQ)MOD
#define D_REMAIN 0xF1A11C // DSP Division Remainder
#define D_DIVCTRL 0xF1A11C // DSP Divider Control
#define D_MACHI 0xF1A120 // DSP Hi Byte of MAC Operations
#define D_RAM 0xF1B000 // DSP Internal RAM
#define D_ENDRAM 0xF1D000
////////////////////////////////////////////////////////////////////////////////
// JERRY Flag Register Equates
#define D_CPUENA 0x00000010 // CPU Interrupt Enable Bit
#define D_I2SENA 0x00000020 // I2S Interrupt Enable Bit
#define D_TIM1ENA 0x00000040 // Timer 1 Interrupt Enable Bit
#define D_TIM2ENA 0x00000080 // Timer 2 Interrupt Enable Bit
#define D_EXT0ENA 0x00000100 // External Interrupt 0 Enable Bit
#define D_EXT1ENA 0x00010000 // External Interrupt 1 Enable Bit
#define D_CPUCLR 0x00000200 // CPU Interrupt Clear Bit
#define D_I2SCLR 0x00000400 // I2S Interrupt Clear Bit
#define D_TIM1CLR 0x00000800 // Timer 1 Interrupt Clear Bit
#define D_TIM2CLR 0x00001000 // Timer 2 Interrupt Clear Bit
#define D_EXT0CLR 0x00002000 // External Interrupt 0 Clear Bit
#define D_EXT1CLR 0x00020000 // External Interrupt 1 Clear Bit
////////////////////////////////////////////////////////////////////////////////
// JERRY Control/Status Register
#define DSPGO 0x00000001 // Start DSP
#define DSPINT0 0x00000004 // Generate a DSP Interrupt 0
#define D_CPULAT 0x00000040 // Interrupt Latches
#define D_I2SLAT 0x00000080
#define D_TIM1LAT 0x00000100
#define D_TIM2LAT 0x00000200
#define D_EXT1LAT 0x00000400
#define D_EXT2LAT 0x00010000
////////////////////////////////////////////////////////////////////////////////
// JERRY Modulo Instruction Masks
#define MODMASK2 0xFFFFFFFE // 2 Byte Circular Buffer
#define MODMASK4 0xFFFFFFFC // 4 Byte Circular Buffer
#define MODMASK8 0xFFFFFFF8 // 8 Byte Circular Buffer
#define MODMASK16 0xFFFFFFF0 // 16 Byte Circular Buffer
#define MODMASK32 0xFFFFFFE0 // 32 Byte Circular Buffer
#define MODMASK64 0xFFFFFFC0 // 64 Byte Circular Buffer
#define MODMASK128 0xFFFFFF80 // 128 Byte Circular Buffer
#define MODMASK256 0xFFFFFF00 // 256 Byte Circular Buffer
#define MODMASK512 0xFFFFFE00 // 512 Byte Circular Buffer
#define MODMASK1K 0xFFFFFC00 // 1k Circular Buffer
#define MODMASK2K 0xFFFFF800 // 2k Circular Buffer
#define MODMASK4K 0xFFFFF000 // 4k Circular Buffer
#define MODMASK8K 0xFFFFE000 // 8k Circular Buffer
#define MODMASK16K 0xFFFFC000 // 16k Circular Buffer
#define MODMASK32K 0xFFFF8000 // 32k Circular Buffer
#define MODMASK64K 0xFFFF0000 // 64k Circular Buffer
#define MODMASK128K 0xFFFE0000 // 128k Circular Buffer
#define MODMASK256K 0xFFFC0000 // 256k Circular Buffer
#define MODMASK512K 0xFFF80000 // 512k Circular Buffer
#define MODMASK1M 0xFFF00000 // 1M Circular Buffer
////////////////////////////////////////////////////////////////////////////////
// SHARED Equates for TOM (GPU) and JERRY (DSP)
// Control/Status Registers
#define RISCGO 0x00000001 // Start GPU or DSP
#define CPUINT 0x00000002 // Allow the GPU/DSP to interrupt CPU
#define FORCEINT0 0x00000004 // Cause an INT 0 on GPU or DSP
#define SINGLE_STEP 0x00000008 // Enter SINGLE_STEP mode
#define SINGLE_GO 0x00000010 // Execute one instruction
#define REGPAGE 0x00004000 // Register Bank Select
#define DMAEN 0x00008000 // Enable DMA LOAD and STORE
// Flags Register
#define ZERO_FLAG 0x00000001 // ALU Zero Flag
#define CARRY_FLAG 0x00000002 // ALU Carry Flag
#define NEGA_FLAG 0x00000004 // ALU Negative Flag
#define IMASK 0x00000008 // Interrupt Service Mask
// Matrix Control Register
#define MATRIX3 0x00000003 // Use for 3x1 Matrix
#define MATRIX4 0x00000004 // etc...
#define MATRIX5 0x00000005
#define MATRIX6 0x00000006
#define MATRIX7 0x00000007
#define MATRIX8 0x00000008
#define MATRIX9 0x00000009
#define MATRIX10 0x0000000A
#define MATRIX11 0x0000000B
#define MATRIX12 0x0000000C
#define MATRIX13 0x0000000D
#define MATRIX14 0x0000000E
#define MATRIX15 0x0000000F
#define MATROW 0x00000000 // Access Matrix by Row
#define MATCOL 0x00000010 // Access Matrix by Column
// Data Organisation Register
#define BIG_IO 0x00010001 // Make I/O Big-Endian
#define BIG_PIX 0x00020002 // Access Pixels in Big-Endian
#define BIG_INST 0x00040004 // Fetch Instructions in Big-Endian
#define BIG_END 0x00070007
// Divide Unit Control
#define DIV_OFFSET 0x00000001 // Divide 16.16 values if set
#endif // JAGUAR_H