1 //
2 // MEMORY.H: Header file
3 //
4 // All Jaguar related memory and I/O locations are contained in this file
5 //
6 
7 #ifndef __MEMORY_H__
8 #define __MEMORY_H__
9 
10 #include <stdint.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 extern uint8_t jagMemSpace[];
17 
18 extern uint8_t * jaguarMainRAM;
19 extern uint8_t * jaguarMainROM;
20 extern uint8_t * gpuRAM;
21 extern uint8_t * dspRAM;
22 
23 extern uint32_t * butch, * dscntrl;
24 extern uint16_t * ds_data;
25 extern uint32_t * i2cntrl, * sbcntrl, * subdata, * subdatb, * sb_time, * fifo_data, * i2sdat2, * unknown;
26 
27 extern uint16_t * memcon1, * memcon2, * hc, * vc, * lph, * lpv;
28 extern uint64_t * obData;
29 extern uint32_t * olp;
30 extern uint16_t * obf, * vmode, * bord1, * bord2, * hp, * hbb, * hbe, * hs,
31 	* hvs, * hdb1, * hdb2, * hde, * vp, * vbb, * vbe, * vs, * vdb, * vde,
32 	* veb, * vee, * vi, * pit0, * pit1, * heq;
33 extern uint32_t * bg;
34 extern uint16_t * int1, * int2;
35 extern uint8_t * clut, * lbuf;
36 extern uint32_t * g_flags, * g_mtxc, * g_mtxa, * g_end, * g_pc, * g_ctrl,
37 	* g_hidata, * g_divctrl;
38 extern uint32_t g_remain;
39 extern uint32_t * a1_base, * a1_flags, * a1_clip, * a1_pixel, * a1_step,
40 	* a1_fstep, * a1_fpixel, * a1_inc, * a1_finc, * a2_base, * a2_flags,
41 	* a2_mask, * a2_pixel, * a2_step, * b_cmd, * b_count;
42 extern uint64_t * b_srcd, * b_dstd, * b_dstz, * b_srcz1, * b_srcz2, * b_patd;
43 extern uint32_t * b_iinc, * b_zinc, * b_stop, * b_i3, * b_i2, * b_i1, * b_i0, * b_z3,
44 	* b_z2, * b_z1, * b_z0;
45 extern uint16_t * jpit1, * jpit2, * jpit3, * jpit4, * clk1, * clk2, * clk3, * j_int,
46 	* asidata, * asictrl;
47 extern uint16_t asistat;
48 extern uint16_t * asiclk, * joystick, * joybuts;
49 extern uint32_t * d_flags, * d_mtxc, * d_mtxa, * d_end, * d_pc, * d_ctrl,
50 	* d_mod, * d_divctrl;
51 extern uint32_t d_remain;
52 extern uint32_t * d_machi;
53 extern uint16_t * ltxd, lrxd, * rtxd, rrxd;
54 extern uint8_t * sclk, sstat;
55 extern uint32_t * smode;
56 
57 // Read/write tracing enumeration
58 
59 enum { UNKNOWN, JAGUAR, DSP, GPU, TOM, JERRY, M68K, BLITTER, OP, DEBUG };
60 extern const char * whoName[10];
61 
62 // BIOS identification enum
63 
64 // Some handy macros to help converting native endian to big endian (jaguar native)
65 // & vice versa
66 
67 #define SET64(r, a, v) 	r[(a)] = ((v) & 0xFF00000000000000) >> 56, r[(a)+1] = ((v) & 0x00FF000000000000) >> 48, \
68 						r[(a)+2] = ((v) & 0x0000FF0000000000) >> 40, r[(a)+3] = ((v) & 0x000000FF00000000) >> 32, \
69 						r[(a)+4] = ((v) & 0xFF000000) >> 24, r[(a)+5] = ((v) & 0x00FF0000) >> 16, \
70 						r[(a)+6] = ((v) & 0x0000FF00) >> 8, r[(a)+7] = (v) & 0x000000FF
71 #define GET64(r, a)		(((uint64_t)r[(a)] << 56) | ((uint64_t)r[(a)+1] << 48) | \
72 						((uint64_t)r[(a)+2] << 40) | ((uint64_t)r[(a)+3] << 32) | \
73 						((uint64_t)r[(a)+4] << 24) | ((uint64_t)r[(a)+5] << 16) | \
74 						((uint64_t)r[(a)+6] << 8) | (uint64_t)r[(a)+7])
75 #define SET32(r, a, v)	r[(a)] = ((v) & 0xFF000000) >> 24, r[(a)+1] = ((v) & 0x00FF0000) >> 16, \
76 						r[(a)+2] = ((v) & 0x0000FF00) >> 8, r[(a)+3] = (v) & 0x000000FF
77 #define GET32(r, a)		((r[(a)] << 24) | (r[(a)+1] << 16) | (r[(a)+2] << 8) | r[(a)+3])
78 #define SET16(r, a, v)	r[(a)] = ((v) & 0xFF00) >> 8, r[(a)+1] = (v) & 0xFF
79 #define GET16(r, a)		((r[(a)] << 8) | r[(a)+1])
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif	// __MEMORY_H__
86