|
|
1.1 root 1: /*
1.1.1.2 root 2: Hatari - stMemory.h
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
1.1 root 6: */
7:
1.1.1.2 root 8: #ifndef HATARI_STMEMORY_H
9: #define HATARI_STMEMORY_H
10:
1.1.1.9 ! root 11: #include "main.h"
1.1.1.3 root 12: #include "sysdeps.h"
13: #include "maccess.h"
14:
1.1.1.7 root 15: #if ENABLE_SMALL_MEM
16: extern Uint8 *STRam;
17: extern uae_u8 *ROMmemory;
18: # define RomMem (ROMmemory-0xe00000)
19: #else
1.1.1.3 root 20: extern Uint8 STRam[16*1024*1024];
1.1.1.7 root 21: #define RomMem STRam
22: #endif /* ENABLE_SMALL_MEM */
1.1.1.3 root 23:
1.1.1.7 root 24: extern Uint32 STRamEnd;
1.1.1.3 root 25:
26: /* Offset ST address to PC pointer: */
1.1.1.8 root 27: #if ENABLE_SMALL_MEM
28: # define STRAM_ADDR(Var) \
29: (((Var)>= 0xe00000) \
30: ? ((unsigned long)RomMem+((Uint32)(Var) & 0x00ffffff)) \
31: : ((unsigned long)STRam+((Uint32)(Var) & 0x00ffffff)))
32: #else
33: # define STRAM_ADDR(Var) ((unsigned long)STRam+((Uint32)(Var) & 0x00ffffff))
34: #endif
1.1.1.3 root 35:
36: /*-----------------------------------------------------------------------*/
37: /*
38: Write 32-bit word into ST memory space.
39: NOTE - value will be convert to 68000 endian
40: */
41: static inline void STMemory_WriteLong(Uint32 Address, Uint32 Var)
42: {
1.1.1.4 root 43: Address &= 0xffffff;
1.1.1.7 root 44: #if ENABLE_SMALL_MEM
45: if (Address >= 0xe00000)
46: do_put_mem_long(&ROMmemory[Address-0xe00000], Var);
47: else
48: do_put_mem_long(&STRam[Address], Var);
49: #else
1.1.1.4 root 50: do_put_mem_long(&STRam[Address], Var);
1.1.1.7 root 51: #endif
1.1.1.3 root 52: }
53:
54: /*-----------------------------------------------------------------------*/
55: /*
56: Write 16-bit word into ST memory space.
57: NOTE - value will be convert to 68000 endian.
58: */
59: static inline void STMemory_WriteWord(Uint32 Address, Uint16 Var)
60: {
1.1.1.4 root 61: Address &= 0xffffff;
1.1.1.7 root 62: #if ENABLE_SMALL_MEM
63: if (Address >= 0xe00000)
64: do_put_mem_word(&ROMmemory[Address-0xe00000], Var);
65: else
66: do_put_mem_word(&STRam[Address], Var);
67: #else
1.1.1.4 root 68: do_put_mem_word(&STRam[Address], Var);
1.1.1.7 root 69: #endif
1.1.1.3 root 70: }
71:
72: /*-----------------------------------------------------------------------*/
73: /*
74: Write 8-bit byte into ST memory space.
75: */
76: static inline void STMemory_WriteByte(Uint32 Address, Uint8 Var)
77: {
1.1.1.4 root 78: Address &= 0xffffff;
1.1.1.7 root 79: #if ENABLE_SMALL_MEM
80: if (Address >= 0xe00000)
81: ROMmemory[Address-0xe00000] = Var;
82: else
83: STRam[Address] = Var;
84: #else
1.1.1.4 root 85: STRam[Address] = Var;
1.1.1.7 root 86: #endif
1.1.1.3 root 87: }
88:
89:
90: /*-----------------------------------------------------------------------*/
91: /*
92: Read 32-bit word from ST memory space.
93: NOTE - value will be converted to PC endian.
94: */
95: static inline Uint32 STMemory_ReadLong(Uint32 Address)
96: {
1.1.1.4 root 97: Address &= 0xffffff;
1.1.1.7 root 98: #if ENABLE_SMALL_MEM
99: if (Address >= 0xe00000)
100: return do_get_mem_long(&ROMmemory[Address-0xe00000]);
101: else
102: return do_get_mem_long(&STRam[Address]);
103: #else
1.1.1.4 root 104: return do_get_mem_long(&STRam[Address]);
1.1.1.7 root 105: #endif
1.1.1.3 root 106: }
107:
108: /*-----------------------------------------------------------------------*/
109: /*
110: Read 16-bit word from ST memory space.
111: NOTE - value will be converted to PC endian.
112: */
113: static inline Uint16 STMemory_ReadWord(Uint32 Address)
114: {
1.1.1.4 root 115: Address &= 0xffffff;
1.1.1.7 root 116: #if ENABLE_SMALL_MEM
117: if (Address >= 0xe00000)
118: return do_get_mem_word(&ROMmemory[Address-0xe00000]);
119: else
120: return do_get_mem_word(&STRam[Address]);
121: #else
1.1.1.4 root 122: return do_get_mem_word(&STRam[Address]);
1.1.1.7 root 123: #endif
1.1.1.3 root 124: }
125:
126: /*-----------------------------------------------------------------------*/
127: /*
128: Read 8-bit byte from ST memory space
129: */
130: static inline Uint8 STMemory_ReadByte(Uint32 Address)
131: {
1.1.1.4 root 132: Address &= 0xffffff;
1.1.1.7 root 133: #if ENABLE_SMALL_MEM
134: if (Address >= 0xe00000)
135: return ROMmemory[Address-0xe00000];
136: else
137: return STRam[Address];
138: #else
1.1.1.4 root 139: return STRam[Address];
1.1.1.7 root 140: #endif
1.1.1.3 root 141: }
142:
143:
1.1.1.5 root 144: extern void STMemory_Clear(Uint32 StartAddress, Uint32 EndAddress);
1.1.1.6 root 145: extern void STMemory_SetDefaultConfig(void);
1.1.1.2 root 146:
147: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.