|
|
1.1 root 1: /*
2: Hatari - stMemory.c
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.
6:
7: ST Memory access functions - take care of endian swaps.
8: */
9:
10: #include <SDL_endian.h>
11:
12: #include "main.h"
13: #include "decode.h"
14: #include "m68000.h"
15: #include "memAlloc.h"
16: #include "../cpu/maccess.h"
17:
18:
19: /*-----------------------------------------------------------------------*/
20: /*
21: Clear section of ST's memory space.
22: */
23: void STMemory_Clear(unsigned long StartAddress, unsigned long EndAddress)
24: {
25: Memory_Clear((void *)((unsigned long)STRam+StartAddress),EndAddress-StartAddress);
26: }
27:
28:
29: /*-----------------------------------------------------------------------*/
30: /*
31: Swap 16-bit integer to/from 68000/PC format.
32: */
33: unsigned short STMemory_Swap68000Int(unsigned short var)
34: {
35: return SDL_SwapBE16(var);
36: }
37:
38: /*-----------------------------------------------------------------------*/
39: /*
40: Swap 32-bit integer to/from 68000/PC format.
41: */
42: unsigned long STMemory_Swap68000Long(unsigned long var)
43: {
44: return SDL_SwapBE32(var);
45: }
46:
47:
48: /*-----------------------------------------------------------------------*/
49: /*
50: Write 32-bit word into ST memory space, NOTE - value will be convert to 68000 endian
51: */
52: void STMemory_WriteLong(unsigned long Address, unsigned long Var)
53: {
54: uae_u32 *pLongWord;
55:
56: Address &= 0xffffff;
57: pLongWord = (uae_u32 *)((unsigned long)STRam+Address);
58: do_put_mem_long(pLongWord, Var);
59: }
60:
61: /*-----------------------------------------------------------------------*/
62: /*
63: Write 16-bit word into ST memory space.
64: NOTE - value will be convert to 68000 endian.
65: */
66: void STMemory_WriteWord(unsigned long Address, unsigned short Var)
67: {
68: uae_u16 *pShortWord;
69:
70: Address &= 0xffffff;
71: pShortWord = (uae_u16 *)((unsigned long)STRam+Address);
72: do_put_mem_word(pShortWord, Var);
73: }
74:
75: /*-----------------------------------------------------------------------*/
76: /*
77: Write 8-bit byte into ST memory space.
78: */
79: void STMemory_WriteByte(unsigned long Address, unsigned char Var)
80: {
81: unsigned char *pChar;
82:
83: Address &= 0xffffff;
84: pChar = (unsigned char *)((unsigned long)STRam+Address);
85: *pChar = Var;
86: }
87:
88:
89: /*-----------------------------------------------------------------------*/
90: /*
91: Read 32-bit word from ST memory space.
92: NOTE - value will be converted to PC endian.
93: */
94: unsigned long STMemory_ReadLong(unsigned long Address)
95: {
96: uae_u32 *pLongWord;
97:
98: Address &= 0xffffff;
99: pLongWord = (uae_u32 *)((unsigned long)STRam+Address);
100: return(do_get_mem_long(pLongWord));
101: }
102:
103: /*-----------------------------------------------------------------------*/
104: /*
105: Read 16-bit word from ST memory space.
106: NOTE - value will be converted to PC endian.
107: */
108: unsigned short STMemory_ReadWord(unsigned long Address)
109: {
110: uae_u16 *pShortWord;
111:
112: Address &= 0xffffff;
113: pShortWord = (uae_u16 *)((unsigned long)STRam+Address);
114: return(do_get_mem_word(pShortWord));
115: }
116:
117: /*-----------------------------------------------------------------------*/
118: /*
119: Read 8-bit byte from ST memory space
120: */
121: unsigned char STMemory_ReadByte(unsigned long Address)
122: {
123: unsigned char *pChar;
124:
125: Address &= 0xffffff;
126: pChar = (unsigned char *)((unsigned long)STRam+Address);
127: return( *pChar );
128: }
129:
130:
131: /*-----------------------------------------------------------------------*/
132: /*
133: Write 32-bit word into PC memory space.
134: NOTE - value will be convert to 68000 endian.
135: */
136: void STMemory_WriteLong_PCSpace(void *pAddress, unsigned long Var)
137: {
138: do_put_mem_long(pAddress, Var);
139: }
140:
141: /*-----------------------------------------------------------------------*/
142: /*
143: Write 16-bit word into PC memory space.
144: NOTE - value will be convert to 68000 endian.
145: */
146: void STMemory_WriteWord_PCSpace(void *pAddress, unsigned short Var)
147: {
148: do_put_mem_word(pAddress, Var);
149: }
150:
151:
152: /*-----------------------------------------------------------------------*/
153: /*
154: Read 32-bit word from PC memory space.
155: NOTE - value will be convert to PC endian.
156: */
157: unsigned long STMemory_ReadLong_PCSpace(void *pAddress)
158: {
159: return(do_get_mem_long(pAddress));
160: }
161:
162: /*-----------------------------------------------------------------------*/
163: /*
164: Read 16-bit word from PC memory space.
165: NOTE - value will be convert to PC endian.
166: */
167: unsigned short int STMemory_ReadWord_PCSpace(void *pAddress)
168: {
169: return(do_get_mem_word(pAddress));
170: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.