| 1 | /* Cygne |
| 2 | * |
| 3 | * Copyright notice for this file: |
| 4 | * Copyright (C) 2002 Dox [email protected] |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #include <stdlib.h> |
| 21 | #include <math.h> |
| 22 | |
| 23 | #include <time.h> |
| 24 | |
| 25 | #include "wswan.h"cxx . . $ `<file>/mednafen/wswan/wswan.h`/ |
| 26 | #include "gfx.h"cxx . . $ `<file>/mednafen/wswan/gfx.h`/ |
| 27 | #include "interrupt.h"cxx . . $ `<file>/mednafen/wswan/interrupt.h`/ |
| 28 | #include "wswan-memory.h"cxx . . $ `<file>/mednafen/wswan/wswan-memory.h`/ |
| 29 | #include "sound.h"cxx . . $ `<file>/mednafen/wswan/sound.h`/ |
| 30 | #include "eeprom.h"cxx . . $ `<file>/mednafen/wswan/eeprom.h`/ |
| 31 | #include "rtc.h"cxx . . $ `<file>/mednafen/wswan/rtc.h`/ |
| 32 | #include "v30mz.h"cxx . . $ `<file>/mednafen/wswan/v30mz.h`/ |
| 33 | #include "../mempatcher.h"cxx . . $ `<file>/mednafen/mempatcher.h`/ |
| 34 | #include "../settings.h"cxx . . $ `<file>/mednafen/settings.h`/ |
| 35 | #include "../state_inline.h"cxx . . $ `<file>/mednafen/state_inline.h`/ |
| 36 | |
| 37 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! SkipSLcxx . . $ SkipSL.; // Skip save and load |
| 38 | |
| 39 | uint32cxx . . $ uint32# wsRAMSizecxx . . $ wsRAMSize.; |
| 40 | uint8cxx . . $ uint8# wsRAMcxx . . $ wsRAM.[65536]; |
| 41 | uint8cxx . . $ uint8# *wsSRAMcxx . . $ wsSRAM. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 42 | |
| 43 | uint8cxx . . $ uint8# *wsCartROMcxx . . $ wsCartROM.; |
| 44 | static uint32cxx . . $ uint32# sram_sizecxx . . $ sram_size.; |
| 45 | uint32cxx . . $ uint32# eeprom_sizecxx . . $ eeprom_size.; |
| 46 | |
| 47 | static uint8cxx . . $ uint8# ButtonWhichcxx . . $ ButtonWhich., ButtonReadLatchcxx . . $ ButtonReadLatch.; |
| 48 | |
| 49 | static uint32cxx . . $ uint32# DMASourcecxx . . $ DMASource.; |
| 50 | static uint16cxx . . $ uint16# DMADestcxx . . $ DMADest.; |
| 51 | static uint16cxx . . $ uint16# DMALengthcxx . . $ DMALength.; |
| 52 | static uint8cxx . . $ uint8# DMAControlcxx . . $ DMAControl.; |
| 53 | |
| 54 | static uint32cxx . . $ uint32# SoundDMASourcecxx . . $ SoundDMASource., SoundDMASourceSavedcxx . . $ SoundDMASourceSaved.; |
| 55 | static uint32cxx . . $ uint32# SoundDMALengthcxx . . $ SoundDMALength., SoundDMALengthSavedcxx . . $ SoundDMALengthSaved.; |
| 56 | static uint8cxx . . $ uint8# SoundDMAControlcxx . . $ SoundDMAControl.; |
| 57 | static uint8cxx . . $ uint8# SoundDMATimercxx . . $ SoundDMATimer.; |
| 58 | |
| 59 | static uint8cxx . . $ uint8# BankSelectorcxx . . $ BankSelector.[4]; |
| 60 | |
| 61 | static uint8cxx . . $ uint8# CommControlcxx . . $ CommControl., CommDatacxx . . $ CommData.; |
| 62 | |
| 63 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! languagecxx . . $ language.; |
| 64 | |
| 65 | extern uint16cxx . . $ uint16# WSButtonStatuscxx . . $ WSButtonStatus.; |
| 66 | |
| 67 | void WSwan_writemem20cxx . . $ WSwan_writemem20(cc289a6b3dfc48da).(uint32cxx . . $ uint32# A, uint8cxx . . $ uint8# V) |
| 68 | { |
| 69 | uint32cxx . . $ uint32# offset = A & 0xffff; |
| 70 | uint32cxx . . $ uint32# bank = (A>>16) & 0xF; |
| 71 | |
| 72 | if(!bank) /*RAM*/ |
| 73 | { |
| 74 | WSwan_SoundCheckRAMWritecxx . . $ WSwan_SoundCheckRAMWrite(cb2f890c2fdad230).(offset); |
| 75 | wsRAMcxx . . $ wsRAM.[offset] = V; |
| 76 | |
| 77 | WSWan_TCacheInvalidByAddrcxx . . $ WSWan_TCacheInvalidByAddr(cb2f890c2fdad230).(offset); |
| 78 | |
| 79 | if(offset>=0xfe00) /*WSC palettes*/ |
| 80 | WSwan_GfxWSCPaletteRAMWritecxx . . $ WSwan_GfxWSCPaletteRAMWrite(cc289a6b3dfc48da).(offset, V); |
| 81 | } |
| 82 | else if(bank == 1) /* SRAM */ |
| 83 | { |
| 84 | if(sram_sizecxx . . $ sram_size.) |
| 85 | wsSRAMcxx . . $ wsSRAM.[(offset | (BankSelectorcxx . . $ BankSelector.[1] << 16)) & (sram_sizecxx . . $ sram_size. - 1)] = V; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | uint8cxx . . $ uint8# WSwan_readmem20cxx . . $ WSwan_readmem20(32407b39b2dfce37).(uint32cxx . . $ uint32# A) |
| 90 | { |
| 91 | uint8cxx . . $ uint8# bank_num; |
| 92 | uint32cxx . . $ uint32# offset = A & 0xFFFF; |
| 93 | uint32cxx . . $ uint32# bank = (A >> 16) & 0xF; |
| 94 | |
| 95 | switch(bank) |
| 96 | { |
| 97 | case 0: |
| 98 | return wsRAMcxx . . $ wsRAM.[offset]; |
| 99 | case 1: |
| 100 | if(sram_sizecxx . . $ sram_size.) |
| 101 | return wsSRAMcxx . . $ wsSRAM.[(offset | (BankSelectorcxx . . $ BankSelector.[1] << 16)) & (sram_sizecxx . . $ sram_size. - 1)]; |
| 102 | return(0); |
| 103 | case 2: |
| 104 | case 3: |
| 105 | return wsCartROMcxx . . $ wsCartROM.[offset+((BankSelectorcxx . . $ BankSelector.[bank]&((rom_sizecxx . . $ rom_size.>>16)-1))<<16)]; |
| 106 | default: |
| 107 | break; |
| 108 | } |
| 109 | |
| 110 | bank_num = ((BankSelectorcxx . . $ BankSelector.[0] & 0xF) << 4) | (bank & 0xf); |
| 111 | bank_num &= (rom_sizecxx . . $ rom_size. >> 16) - 1; |
| 112 | |
| 113 | return(wsCartROMcxx . . $ wsCartROM.[(bank_num << 16) | offset]); |
| 114 | } |
| 115 | |
| 116 | static void ws_CheckDMAcxx . . $ ws_CheckDMA(49f6e7a06ebc5aa8).(void) |
| 117 | { |
| 118 | if(DMAControlcxx . . $ DMAControl. & 0x80) |
| 119 | { |
| 120 | while(DMALengthcxx . . $ DMALength.) |
| 121 | { |
| 122 | WSwan_writemem20cxx . . $ WSwan_writemem20(cc289a6b3dfc48da).(DMADestcxx . . $ DMADest., WSwan_readmem20cxx . . $ WSwan_readmem20(32407b39b2dfce37).(DMASourcecxx . . $ DMASource.)); |
| 123 | WSwan_writemem20cxx . . $ WSwan_writemem20(cc289a6b3dfc48da).(DMADestcxx . . $ DMADest.+1, WSwan_readmem20cxx . . $ WSwan_readmem20(32407b39b2dfce37).(DMASourcecxx . . $ DMASource.+1)); |
| 124 | |
| 125 | if(DMAControlcxx . . $ DMAControl. & 0x40) |
| 126 | { |
| 127 | DMASourcecxx . . $ DMASource. -= 2; |
| 128 | DMADestcxx . . $ DMADest. -= 2; |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | DMASourcecxx . . $ DMASource. += 2; |
| 133 | DMADestcxx . . $ DMADest. += 2; |
| 134 | } |
| 135 | DMASourcecxx . . $ DMASource. &= 0x000FFFFE; |
| 136 | DMALengthcxx . . $ DMALength. -= 2; |
| 137 | } |
| 138 | } |
| 139 | DMAControlcxx . . $ DMAControl. &= ~0x80; |
| 140 | } |
| 141 | |
| 142 | void WSwan_CheckSoundDMAcxx . . $ WSwan_CheckSoundDMA(49f6e7a06ebc5aa8).(void) |
| 143 | { |
| 144 | if(!(SoundDMAControlcxx . . $ SoundDMAControl. & 0x80)) |
| 145 | return; |
| 146 | |
| 147 | if(!SoundDMATimercxx . . $ SoundDMATimer.) |
| 148 | { |
| 149 | uint8cxx . . $ uint8# zebyte = WSwan_readmem20cxx . . $ WSwan_readmem20(32407b39b2dfce37).(SoundDMASourcecxx . . $ SoundDMASource.); |
| 150 | |
| 151 | if(SoundDMAControlcxx . . $ SoundDMAControl. & 0x10) |
| 152 | WSwan_SoundWritecxx . . $ WSwan_SoundWrite(cc289a6b3dfc48da).(0x95, zebyte); // Pick a port, any port?! |
| 153 | else |
| 154 | WSwan_SoundWritecxx . . $ WSwan_SoundWrite(cc289a6b3dfc48da).(0x89, zebyte); |
| 155 | |
| 156 | if(SoundDMAControlcxx . . $ SoundDMAControl. & 0x40) |
| 157 | SoundDMASourcecxx . . $ SoundDMASource.--; |
| 158 | else |
| 159 | SoundDMASourcecxx . . $ SoundDMASource.++; |
| 160 | SoundDMASourcecxx . . $ SoundDMASource. &= 0x000FFFFF; |
| 161 | |
| 162 | SoundDMALengthcxx . . $ SoundDMALength.--; |
| 163 | SoundDMALengthcxx . . $ SoundDMALength. &= 0x000FFFFF; |
| 164 | if(!SoundDMALengthcxx . . $ SoundDMALength.) |
| 165 | { |
| 166 | if(SoundDMAControlcxx . . $ SoundDMAControl. & 8) |
| 167 | { |
| 168 | SoundDMALengthcxx . . $ SoundDMALength. = SoundDMALengthSavedcxx . . $ SoundDMALengthSaved.; |
| 169 | SoundDMASourcecxx . . $ SoundDMASource. = SoundDMASourceSavedcxx . . $ SoundDMASourceSaved.; |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | SoundDMAControlcxx . . $ SoundDMAControl. &= ~0x80; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | switch(SoundDMAControlcxx . . $ SoundDMAControl. & 3) |
| 178 | { |
| 179 | case 0: SoundDMATimercxx . . $ SoundDMATimer. = 5; break; |
| 180 | case 1: SoundDMATimercxx . . $ SoundDMATimer. = 3; break; |
| 181 | case 2: SoundDMATimercxx . . $ SoundDMATimer. = 1; break; |
| 182 | case 3: SoundDMATimercxx . . $ SoundDMATimer. = 0; break; |
| 183 | } |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | SoundDMATimercxx . . $ SoundDMATimer.--; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | uint8cxx . . $ uint8# WSwan_readportcxx . . $ WSwan_readport(32407b39b2dfce37).(uint32cxx . . $ uint32# number) |
| 192 | { |
| 193 | number &= 0xFF; |
| 194 | |
| 195 | if((number >= 0x80 && number <= 0x9F) || (number == 0x6A) || (number == 0x6B)) |
| 196 | return(WSwan_SoundReadcxx . . $ WSwan_SoundRead(32407b39b2dfce37).(number)); |
| 197 | else if(number <= 0x3F || (number >= 0xA0 && number <= 0xAF) || (number == 0x60)) |
| 198 | return(WSwan_GfxReadcxx . . $ WSwan_GfxRead(32407b39b2dfce37).(number)); |
| 199 | else if((number >= 0xBA && number <= 0xBE) || (number >= 0xC4 && number <= 0xC8)) |
| 200 | return(WSwan_EEPROMReadcxx . . $ WSwan_EEPROMRead(32407b39b2dfce37).(number)); |
| 201 | else if(number >= 0xCA && number <= 0xCB) |
| 202 | return(WSwan_RTCReadcxx . . $ WSwan_RTCRead(32407b39b2dfce37).(number)); |
| 203 | else switch(number) |
| 204 | { |
| 205 | case 0x40: return(DMASourcecxx . . $ DMASource. >> 0); |
| 206 | case 0x41: return(DMASourcecxx . . $ DMASource. >> 8); |
| 207 | case 0x42: return(DMASourcecxx . . $ DMASource. >> 16); |
| 208 | |
| 209 | case 0x44: return(DMADestcxx . . $ DMADest. >> 0); |
| 210 | case 0x45: return(DMADestcxx . . $ DMADest. >> 8); |
| 211 | |
| 212 | case 0x46: return(DMALengthcxx . . $ DMALength. >> 0); |
| 213 | case 0x47: return(DMALengthcxx . . $ DMALength. >> 8); |
| 214 | |
| 215 | case 0x48: return(DMAControlcxx . . $ DMAControl.); |
| 216 | |
| 217 | case 0xB0: |
| 218 | case 0xB2: |
| 219 | case 0xB6: return(WSwan_InterruptReadcxx . . $ WSwan_InterruptRead(32407b39b2dfce37).(number)); |
| 220 | |
| 221 | case 0xC0: return(BankSelectorcxx . . $ BankSelector.[0] | 0x20); |
| 222 | case 0xC1: return(BankSelectorcxx . . $ BankSelector.[1]); |
| 223 | case 0xC2: return(BankSelectorcxx . . $ BankSelector.[2]); |
| 224 | case 0xC3: return(BankSelectorcxx . . $ BankSelector.[3]); |
| 225 | |
| 226 | case 0x4a: return(SoundDMASourcecxx . . $ SoundDMASource. >> 0); |
| 227 | case 0x4b: return(SoundDMASourcecxx . . $ SoundDMASource. >> 8); |
| 228 | case 0x4c: return(SoundDMASourcecxx . . $ SoundDMASource. >> 16); |
| 229 | case 0x4e: return(SoundDMALengthcxx . . $ SoundDMALength. >> 0); |
| 230 | case 0x4f: return(SoundDMALengthcxx . . $ SoundDMALength. >> 8); |
| 231 | case 0x50: return(SoundDMALengthcxx . . $ SoundDMALength. >> 16); |
| 232 | case 0x52: return(SoundDMAControlcxx . . $ SoundDMAControl.); |
| 233 | |
| 234 | case 0xB1: return(CommDatacxx . . $ CommData.); |
| 235 | |
| 236 | case 0xb3: |
| 237 | { |
| 238 | uint8cxx . . $ uint8# ret = CommControlcxx . . $ CommControl. & 0xf0; |
| 239 | |
| 240 | if(CommControlcxx . . $ CommControl. & 0x80) |
| 241 | ret |= 0x4; // Send complete |
| 242 | |
| 243 | return(ret); |
| 244 | } |
| 245 | case 0xb5: |
| 246 | { |
| 247 | uint8cxx . . $ uint8# ret = (ButtonWhichcxx . . $ ButtonWhich. << 4) | ButtonReadLatchcxx . . $ ButtonReadLatch.; |
| 248 | return(ret); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | if(number >= 0xC8) |
| 253 | return(0xD0 | languagecxx . . $ language.); |
| 254 | |
| 255 | return(0); |
| 256 | } |
| 257 | |
| 258 | void WSwan_writeportcxx . . $ WSwan_writeport(cc289a6b3dfc48da).(uint32cxx . . $ uint32# IOPort, uint8cxx . . $ uint8# V) |
| 259 | { |
| 260 | IOPort &= 0xFF; |
| 261 | |
| 262 | if((IOPort >= 0x80 && IOPort <= 0x9F) || (IOPort == 0x6A) || (IOPort == 0x6B)) |
| 263 | WSwan_SoundWritecxx . . $ WSwan_SoundWrite(cc289a6b3dfc48da).(IOPort, V); |
| 264 | else if((IOPort >= 0x00 && IOPort <= 0x3F) || (IOPort >= 0xA0 && IOPort <= 0xAF) || (IOPort == 0x60)) |
| 265 | WSwan_GfxWritecxx . . $ WSwan_GfxWrite(cc289a6b3dfc48da).(IOPort, V); |
| 266 | else if((IOPort >= 0xBA && IOPort <= 0xBE) || (IOPort >= 0xC4 && IOPort <= 0xC8)) |
| 267 | WSwan_EEPROMWritecxx . . $ WSwan_EEPROMWrite(cc289a6b3dfc48da).(IOPort, V); |
| 268 | else if(IOPort >= 0xCA && IOPort <= 0xCB) |
| 269 | WSwan_RTCWritecxx . . $ WSwan_RTCWrite(cc289a6b3dfc48da).(IOPort, V); |
| 270 | else switch(IOPort) |
| 271 | { |
| 272 | case 0x40: DMASourcecxx . . $ DMASource. &= 0xFFFF00; DMASourcecxx . . $ DMASource. |= (V << 0) & ~1; break; |
| 273 | case 0x41: DMASourcecxx . . $ DMASource. &= 0xFF00FF; DMASourcecxx . . $ DMASource. |= (V << 8); break; |
| 274 | case 0x42: DMASourcecxx . . $ DMASource. &= 0x00FFFF; DMASourcecxx . . $ DMASource. |= ((V & 0x0F) << 16); break; |
| 275 | |
| 276 | case 0x44: DMADestcxx . . $ DMADest. &= 0xFF00; DMADestcxx . . $ DMADest. |= (V << 0) & ~1; break; |
| 277 | case 0x45: DMADestcxx . . $ DMADest. &= 0x00FF; DMADestcxx . . $ DMADest. |= (V << 8); break; |
| 278 | |
| 279 | case 0x46: DMALengthcxx . . $ DMALength. &= 0xFF00; DMALengthcxx . . $ DMALength. |= (V << 0) & ~1; break; |
| 280 | case 0x47: DMALengthcxx . . $ DMALength. &= 0x00FF; DMALengthcxx . . $ DMALength. |= (V << 8); break; |
| 281 | |
| 282 | case 0x48: DMAControlcxx . . $ DMAControl. = V & ~0x3F; |
| 283 | ws_CheckDMAcxx . . $ ws_CheckDMA(49f6e7a06ebc5aa8).(); |
| 284 | break; |
| 285 | |
| 286 | case 0x4a: SoundDMASourcecxx . . $ SoundDMASource. &= 0xFFFF00; SoundDMASourcecxx . . $ SoundDMASource. |= (V << 0); SoundDMASourceSavedcxx . . $ SoundDMASourceSaved. = SoundDMASourcecxx . . $ SoundDMASource.; break; |
| 287 | case 0x4b: SoundDMASourcecxx . . $ SoundDMASource. &= 0xFF00FF; SoundDMASourcecxx . . $ SoundDMASource. |= (V << 8); SoundDMASourceSavedcxx . . $ SoundDMASourceSaved. = SoundDMASourcecxx . . $ SoundDMASource.; break; |
| 288 | case 0x4c: SoundDMASourcecxx . . $ SoundDMASource. &= 0x00FFFF; SoundDMASourcecxx . . $ SoundDMASource. |= ((V & 0xF) << 16); SoundDMASourceSavedcxx . . $ SoundDMASourceSaved. = SoundDMASourcecxx . . $ SoundDMASource.; break; |
| 289 | //case 0x4d: break; // Unused? |
| 290 | case 0x4e: SoundDMALengthcxx . . $ SoundDMALength. &= 0xFFFF00; SoundDMALengthcxx . . $ SoundDMALength. |= (V << 0); SoundDMALengthSavedcxx . . $ SoundDMALengthSaved. = SoundDMALengthcxx . . $ SoundDMALength.; break; |
| 291 | case 0x4f: SoundDMALengthcxx . . $ SoundDMALength. &= 0xFF00FF; SoundDMALengthcxx . . $ SoundDMALength. |= (V << 8); SoundDMALengthSavedcxx . . $ SoundDMALengthSaved. = SoundDMALengthcxx . . $ SoundDMALength.; break; |
| 292 | case 0x50: SoundDMALengthcxx . . $ SoundDMALength. &= 0x00FFFF; SoundDMALengthcxx . . $ SoundDMALength. |= ((V & 0xF) << 16); SoundDMALengthSavedcxx . . $ SoundDMALengthSaved. = SoundDMALengthcxx . . $ SoundDMALength.; break; |
| 293 | //case 0x51: break; // Unused? |
| 294 | case 0x52: SoundDMAControlcxx . . $ SoundDMAControl. = V & ~0x20; |
| 295 | break; |
| 296 | |
| 297 | case 0xB0: |
| 298 | case 0xB2: |
| 299 | case 0xB6: WSwan_InterruptWritecxx . . $ WSwan_InterruptWrite(cc289a6b3dfc48da).(IOPort, V); break; |
| 300 | |
| 301 | case 0xB1: CommDatacxx . . $ CommData. = V; break; |
| 302 | case 0xB3: CommControlcxx . . $ CommControl. = V & 0xF0; break; |
| 303 | |
| 304 | case 0xb5: ButtonWhichcxx . . $ ButtonWhich. = V >> 4; |
| 305 | ButtonReadLatchcxx . . $ ButtonReadLatch. = 0; |
| 306 | |
| 307 | if(ButtonWhichcxx . . $ ButtonWhich. & 0x4) /*buttons*/ |
| 308 | ButtonReadLatchcxx . . $ ButtonReadLatch. |= ((WSButtonStatuscxx . . $ WSButtonStatus. >> 8) << 1) & 0xF; |
| 309 | |
| 310 | if(ButtonWhichcxx . . $ ButtonWhich. & 0x2) /* H/X cursors */ |
| 311 | ButtonReadLatchcxx . . $ ButtonReadLatch. |= WSButtonStatuscxx . . $ WSButtonStatus. & 0xF; |
| 312 | |
| 313 | if(ButtonWhichcxx . . $ ButtonWhich. & 0x1) /* V/Y cursors */ |
| 314 | ButtonReadLatchcxx . . $ ButtonReadLatch. |= (WSButtonStatuscxx . . $ WSButtonStatus. >> 4) & 0xF; |
| 315 | break; |
| 316 | |
| 317 | case 0xC0: BankSelectorcxx . . $ BankSelector.[0] = V & 0xF; break; |
| 318 | case 0xC1: BankSelectorcxx . . $ BankSelector.[1] = V; break; |
| 319 | case 0xC2: BankSelectorcxx . . $ BankSelector.[2] = V; break; |
| 320 | case 0xC3: BankSelectorcxx . . $ BankSelector.[3] = V; break; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | void WSwan_MemoryKillcxx . . $ WSwan_MemoryKill(49f6e7a06ebc5aa8).(void) |
| 325 | { |
| 326 | if(wsSRAMcxx . . $ wsSRAM.) |
| 327 | freecxx . . $ free(5d22bdacc48458e8).(wsSRAMcxx . . $ wsSRAM.); |
| 328 | wsSRAMcxx . . $ wsSRAM. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 329 | } |
| 330 | |
| 331 | void WSwan_MemoryInitcxx . . $ WSwan_MemoryInit(83c327a91a6f0fc7).(boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! lang, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! IsWSC, uint32cxx . . $ uint32# ssize, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! SkipSaveLoad) |
| 332 | { |
| 333 | const uint16cxx . . $ uint16# byear = MDFN_GetSettingUIcxx . . $ MDFN_GetSettingUI(751346f8406fd082).("wswan.byear"); |
| 334 | const uint8cxx . . $ uint8# bmonth = MDFN_GetSettingUIcxx . . $ MDFN_GetSettingUI(751346f8406fd082).("wswan.bmonth"); |
| 335 | const uint8cxx . . $ uint8# bday = MDFN_GetSettingUIcxx . . $ MDFN_GetSettingUI(751346f8406fd082).("wswan.bday"); |
| 336 | const uint8cxx . . $ uint8# sex = MDFN_GetSettingIcxx . . $ MDFN_GetSettingI(3c95bd14d5d5d286).("wswan.sex"); |
| 337 | const uint8cxx . . $ uint8# blood = MDFN_GetSettingIcxx . . $ MDFN_GetSettingI(3c95bd14d5d5d286).("wswan.blood"); |
| 338 | |
| 339 | languagecxx . . $ language. = lang; |
| 340 | SkipSLcxx . . $ SkipSL. = SkipSaveLoad; |
| 341 | |
| 342 | wsRAMSizecxx . . $ wsRAMSize. = 65536; |
| 343 | sram_sizecxx . . $ sram_size. = ssize; |
| 344 | |
| 345 | // WSwan_EEPROMInit() will also clear wsEEPROM |
| 346 | WSwan_EEPROMInitcxx . . $ WSwan_EEPROMInit(3e1aae3d42b5adca).(MDFN_GetSettingScxx . . $ MDFN_GetSettingS(fb58d2e09a2a1ce6).("wswan.name"), byear, bmonth, bday, sex, blood); |
| 347 | |
| 348 | if(sram_sizecxx . . $ sram_size.) |
| 349 | { |
| 350 | wsSRAMcxx . . $ wsSRAM. = (uint8cxx . . $ uint8#*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sram_sizecxx . . $ sram_size.); |
| 351 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(wsSRAMcxx . . $ wsSRAM., 0, sram_sizecxx . . $ sram_size.); |
| 352 | } |
| 353 | |
| 354 | MDFNMP_AddRAMcxx . . $ MDFNMP_AddRAM(f9255d7bf06fcbb).(wsRAMSizecxx . . $ wsRAMSize., 0x00000, wsRAMcxx . . $ wsRAM.); |
| 355 | |
| 356 | if(sram_sizecxx . . $ sram_size.) |
| 357 | MDFNMP_AddRAMcxx . . $ MDFNMP_AddRAM(f9255d7bf06fcbb).(sram_sizecxx . . $ sram_size., 0x10000, wsSRAMcxx . . $ wsSRAM.); |
| 358 | } |
| 359 | |
| 360 | void WSwan_MemoryResetcxx . . $ WSwan_MemoryReset(49f6e7a06ebc5aa8).(void) |
| 361 | { |
| 362 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(wsRAMcxx . . $ wsRAM., 0, 65536); |
| 363 | |
| 364 | wsRAMcxx . . $ wsRAM.[0x75AC] = 0x41; |
| 365 | wsRAMcxx . . $ wsRAM.[0x75AD] = 0x5F; |
| 366 | wsRAMcxx . . $ wsRAM.[0x75AE] = 0x43; |
| 367 | wsRAMcxx . . $ wsRAM.[0x75AF] = 0x31; |
| 368 | wsRAMcxx . . $ wsRAM.[0x75B0] = 0x6E; |
| 369 | wsRAMcxx . . $ wsRAM.[0x75B1] = 0x5F; |
| 370 | wsRAMcxx . . $ wsRAM.[0x75B2] = 0x63; |
| 371 | wsRAMcxx . . $ wsRAM.[0x75B3] = 0x31; |
| 372 | |
| 373 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(BankSelectorcxx . . $ BankSelector., 0, sizeof(BankSelectorcxx . . $ BankSelector.)); |
| 374 | ButtonWhichcxx . . $ ButtonWhich. = 0; |
| 375 | ButtonReadLatchcxx . . $ ButtonReadLatch. = 0; |
| 376 | DMASourcecxx . . $ DMASource. = 0; |
| 377 | DMADestcxx . . $ DMADest. = 0; |
| 378 | DMALengthcxx . . $ DMALength. = 0; |
| 379 | DMAControlcxx . . $ DMAControl. = 0; |
| 380 | |
| 381 | SoundDMASourcecxx . . $ SoundDMASource. = SoundDMASourceSavedcxx . . $ SoundDMASourceSaved. = 0; |
| 382 | SoundDMALengthcxx . . $ SoundDMALength. = SoundDMALengthSavedcxx . . $ SoundDMALengthSaved. = 0; |
| 383 | SoundDMAControlcxx . . $ SoundDMAControl. = 0; |
| 384 | SoundDMATimercxx . . $ SoundDMATimer. = 0; |
| 385 | |
| 386 | CommControlcxx . . $ CommControl. = 0; |
| 387 | CommDatacxx . . $ CommData. = 0; |
| 388 | } |
| 389 | |
| 390 | int WSwan_MemoryStateActioncxx . . $ WSwan_MemoryStateAction(a45b884b8cf568d5).(StateMemcxx . . $ StateMem# *sm, int load, int data_only) |
| 391 | { |
| 392 | SFORMATcxx . . $ SFORMAT# StateRegs[] = |
| 393 | { |
| 394 | SFARRAYNcxx . . $ `mednafen/state_inline.h:8:9`!(wsRAM, 65536, "RAM"), |
| 395 | SFARRAYNcxx . . $ `mednafen/state_inline.h:8:9`!(sram_size ? wsSRAM : NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, sram_size, "SRAM"), |
| 396 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(ButtonWhich), |
| 397 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(ButtonReadLatch), |
| 398 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(WSButtonStatus), |
| 399 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(DMASource), |
| 400 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(DMADest), |
| 401 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(DMALength), |
| 402 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(DMAControl), |
| 403 | |
| 404 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SoundDMASource), |
| 405 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SoundDMASourceSaved), |
| 406 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SoundDMALength), |
| 407 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SoundDMALengthSaved), |
| 408 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SoundDMAControl), |
| 409 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SoundDMATimer), |
| 410 | |
| 411 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(CommControl), |
| 412 | SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(CommData), |
| 413 | |
| 414 | SFARRAYcxx . . $ `mednafen/state_inline.h:9:9`!(BankSelector, 4), |
| 415 | |
| 416 | SFENDcxx . . $ `mednafen/state_inline.h:20:9`! |
| 417 | }; |
| 418 | |
| 419 | if(!MDFNSS_StateActioncxx . . $ MDFNSS_StateAction(3f628545d3b0df83).(sm, load, data_only, StateRegs, "MEMR", falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!)) |
| 420 | return(0); |
| 421 | |
| 422 | if(load) |
| 423 | { |
| 424 | uint32cxx . . $ uint32# A; |
| 425 | for(A = 0xfe00; A <= 0xFFFF; A++) |
| 426 | WSwan_GfxWSCPaletteRAMWritecxx . . $ WSwan_GfxWSCPaletteRAMWrite(cc289a6b3dfc48da).(A, wsRAMcxx . . $ wsRAM.[A]); |
| 427 | } |
| 428 | return(1); |
| 429 | } |