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