annotate Plugins/Input/sexypsf/PsxMem.c @ 333:42cdc99e395a trunk

[svn] Now that the build system is ready, upload the plugin code.
author chainsaw
date Sun, 25 Dec 2005 13:11:21 -0800
parents
children e089ce1ba088
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
1 /* Pcsx - Pc Psx Emulator
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
2 * Copyright (C) 1999-2002 Pcsx Team
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
3 *
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
7 * (at your option) any later version.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
8 *
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
12 * GNU General Public License for more details.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
13 *
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
17 */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
18
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
19 #include <string.h>
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
20 #include <stdlib.h>
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
21
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
22 #include "PsxCommon.h"
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
23
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
24 void LoadPSXMem(u32 address, s32 length, char *data)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
25 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
26 //printf("%08x %08x\n",address,length);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
27 while(length>0)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
28 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
29 if(address&65535)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
30 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
31 u32 tmplen;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
32
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
33 //puts("Squishy");
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
34 tmplen=((65536-(address&65535))>length)?length:65536-(address&65535);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
35 if(psxMemLUT[address>>16])
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
36 memcpy((char *)(psxMemLUT[address>>16]+(address&65535)),data,tmplen);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
37 address+=tmplen;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
38 data+=tmplen;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
39 length-=tmplen;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
40 //printf("%08x %08x\n",address,tmplen);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
41 continue;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
42 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
43 if(psxMemLUT[address>>16])
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
44 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
45 memcpy((char *)(psxMemLUT[address>>16]),data,(length<65536)?length:65536);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
46 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
47 data+=65536;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
48 address+=65536;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
49 length-=65536;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
50 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
51 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
52
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
53 static int writeok;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
54 int psxMemInit() {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
55 int i;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
56
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
57 writeok=1;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
58
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
59 psxMemLUT = malloc(0x10000 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
60 memset(psxMemLUT, 0, 0x10000 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
61
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
62 psxM = (char*)malloc(0x00200000);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
63 psxP = (char*)malloc(0x00010000);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
64 psxH = (char*)malloc(0x00010000);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
65 psxR = (char*)malloc(0x00080000);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
66 if (psxMemLUT == NULL || psxM == NULL || psxP == NULL || psxH == NULL || psxR == NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
67 printf("Error allocating memory"); return -1;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
68 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
69
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
70 for (i=0; i<0x80; i++) psxMemLUT[i + 0x0000] = &psxM[(i & 0x1f) << 16];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
71
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
72 memcpy(psxMemLUT + 0x8000, psxMemLUT, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
73 memcpy(psxMemLUT + 0xa000, psxMemLUT, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
74
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
75 for (i=0; i<0x01; i++) psxMemLUT[i + 0x1f00] = (u32)&psxP[i << 16];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
76
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
77 for (i=0; i<0x01; i++) psxMemLUT[i + 0x1f80] = (u32)&psxH[i << 16];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
78
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
79 for (i=0; i<0x08; i++) psxMemLUT[i + 0xbfc0] = (u32)&psxR[i << 16];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
80
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
81 return 0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
82 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
83
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
84 void psxMemReset() {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
85 memset(psxM, 0, 0x00200000);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
86 memset(psxP, 0, 0x00010000);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
87 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
88
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
89 void psxMemShutdown() {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
90 free(psxM);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
91 free(psxP);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
92 free(psxH);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
93 free(psxR);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
94 free(psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
95 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
96
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
97 u8 psxMemRead8(u32 mem) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
98 char *p;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
99 u32 t;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
100
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
101 t = mem >> 16;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
102 if (t == 0x1f80) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
103 if (mem < 0x1f801000)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
104 return psxHu8(mem);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
105 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
106 return psxHwRead8(mem);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
107 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
108 p = (char *)(psxMemLUT[t]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
109 if (p != NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
110 return *(u8 *)(p + (mem & 0xffff));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
111 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
112 return 0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
113 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
114 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
115 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
116
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
117 u16 psxMemRead16(u32 mem) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
118 char *p;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
119 u32 t;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
120
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
121 t = mem >> 16;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
122 if (t == 0x1f80) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
123 if (mem < 0x1f801000)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
124 return BFLIP16(psxHu16(mem));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
125 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
126 return psxHwRead16(mem);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
127 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
128 p = (char *)(psxMemLUT[t]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
129 if (p != NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
130 return BFLIP16(*(u16 *)(p + (mem & 0xffff)));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
131 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
132 return 0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
133 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
134 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
135 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
136
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
137 u32 psxMemRead32(u32 mem) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
138 char *p;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
139 u32 t;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
140
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
141 t = mem >> 16;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
142 if (t == 0x1f80) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
143 if (mem < 0x1f801000)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
144 return BFLIP32(psxHu32(mem));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
145 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
146 return psxHwRead32(mem);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
147 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
148 p = (char *)(psxMemLUT[t]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
149 if (p != NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
150 return BFLIP32(*(u32 *)(p + (mem & 0xffff)));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
151 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
152 return 0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
153 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
154 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
155 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
156
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
157 void psxMemWrite8(u32 mem, u8 value) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
158 char *p;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
159 u32 t;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
160
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
161 t = mem >> 16;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
162 if (t == 0x1f80) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
163 if (mem < 0x1f801000)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
164 psxHu8(mem) = value;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
165 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
166 psxHwWrite8(mem, value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
167 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
168 p = (char *)(psxMemLUT[t]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
169 if (p != NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
170 *(u8 *)(p + (mem & 0xffff)) = value;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
171 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
172 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
173 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
174
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
175 void psxMemWrite16(u32 mem, u16 value) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
176 char *p;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
177 u32 t;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
178
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
179 t = mem >> 16;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
180 if (t == 0x1f80) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
181 if (mem < 0x1f801000)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
182 psxHu16(mem) = BFLIP16(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
183 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
184 psxHwWrite16(mem, value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
185 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
186 p = (char *)(psxMemLUT[t]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
187 if (p != NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
188 *(u16 *)(p + (mem & 0xffff)) = BFLIP16(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
189 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
190 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
191 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
192
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
193 void psxMemWrite32(u32 mem, u32 value) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
194 char *p;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
195 u32 t;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
196
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
197 // if ((mem&0x1fffff) == 0x71E18 || value == 0x48088800) SysPrintf("t2fix!!\n");
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
198 t = mem >> 16;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
199 if (t == 0x1f80) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
200 if (mem < 0x1f801000)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
201 psxHu32(mem) = BFLIP32(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
202 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
203 psxHwWrite32(mem, value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
204 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
205 p = (char *)(psxMemLUT[t]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
206 if (p != NULL) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
207 *(u32 *)(p + (mem & 0xffff)) = BFLIP32(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
208 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
209 if (mem != 0xfffe0130) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
210
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
211 } else {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
212 int i;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
213
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
214 switch (value) {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
215 case 0x800: case 0x804:
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
216 if (writeok == 0) break;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
217 writeok = 0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
218 memset(psxMemLUT + 0x0000, 0, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
219 memset(psxMemLUT + 0x8000, 0, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
220 memset(psxMemLUT + 0xa000, 0, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
221 break;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
222 case 0x1e988:
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
223 if (writeok == 1) break;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
224 writeok = 1;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
225 for (i=0; i<0x80; i++) psxMemLUT[i + 0x0000] = &psxM[(i & 0x1f) << 16];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
226 memcpy(psxMemLUT + 0x8000, psxMemLUT, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
227 memcpy(psxMemLUT + 0xa000, psxMemLUT, 0x80 * sizeof *psxMemLUT);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
228 break;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
229 default:
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
230 break;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
231 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
232 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
233 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
234 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
235 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
236