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