| 1 | /* Mednafen - Multi-system Emulator |
| 2 | * |
| 3 | * Copyright notice for this file: |
| 4 | * Copyright (C) 2004 Ki |
| 5 | * Copyright (C) 2007-2011 Mednafen Team |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | PCE_FAST(less accurate, faster, etc.) fork from PCE module "pcecd.cpp". |
| 24 | */ |
| 25 | |
| 26 | #include "../mednafen.h"cxx . . $ `<file>/mednafen/mednafen.h`/ |
| 27 | #include "../cdrom/cdromif.h"cxx . . $ `<file>/mednafen/cdrom/cdromif.h`/ |
| 28 | #include "pcecd_drive.h"cxx . . $ `<file>/mednafen/pce_fast/pcecd_drive.h`/ |
| 29 | #include "../okiadpcm.h"cxx . . $ `<file>/mednafen/okiadpcm.h`/ |
| 30 | |
| 31 | #include "pcecd.h"cxx . . $ `<file>/mednafen/pce_fast/pcecd.h`/ |
| 32 | #include "../cdrom/SimpleFIFO.h"cxx . . $ `<file>/mednafen/cdrom/SimpleFIFO.h`/ |
| 33 | |
| 34 | //#define PCECD_DEBUG |
| 35 | |
| 36 | static unsigned int OC_Multipliercxx . . $ OC_Multiplier.; |
| 37 | |
| 38 | static void (*IRQCBcxx . . $ IRQCB.)(bool asserted); |
| 39 | |
| 40 | static float CDDAVolumeSettingcxx . . $ CDDAVolumeSetting.; // User setting! |
| 41 | |
| 42 | static bool bBRAMEnabledcxx . . $ bBRAMEnabled.; |
| 43 | static uint8cxx . . $ uint8# _Portcxx . . $ _Port.[15]; |
| 44 | static uint8cxx . . $ uint8# ACKStatuscxx . . $ ACKStatus.; |
| 45 | |
| 46 | static SimpleFIFOcxx . . $ SimpleFIFO#<uint8cxx . . $ uint8#> SubChannelFIFOcxx . . $ SubChannelFIFO.(16); |
| 47 | |
| 48 | static Blip_Buffercxx . . $ Blip_Buffer# *sbufcxx . . $ sbuf.[2]; |
| 49 | static int16cxx . . $ int16# RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[2]; |
| 50 | |
| 51 | static int32cxx . . $ int32# ClearACKDelaycxx . . $ ClearACKDelay.; |
| 52 | |
| 53 | static int32cxx . . $ int32# lasttscxx . . $ lastts.; |
| 54 | static int32cxx . . $ int32# pcecd_drive_necxx . . $ pcecd_drive_ne. = 0; |
| 55 | |
| 56 | // ADPCM variables and whatnot |
| 57 | static inline void ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).(const char *format, ...) |
| 58 | { |
| 59 | /*printf("[Half=%d, End=%d, Playing=%d] "x, ADPCM.HalfReached, ADPCM.EndReached, ADPCM.Playing, ## __VA_ARGS__);*/ |
| 60 | } |
| 61 | |
| 62 | typedef Blip_Synthcxx . . $ Blip_Synth#<blip_good_qualitycxx . . $ blip_good_quality., 16384> ADSynthcxx . . $ ADSynth#; |
| 63 | static ADSynthcxx . . $ ADSynth# ADPCMSynthcxx . . $ ADPCMSynth.; |
| 64 | static OKIADPCM_Decodercxx . . $ OKIADPCM_Decoder#<OKIADPCM_MSM5205cxx . . $ OKIADPCM_MSM5205.> MSM5205cxx . . $ MSM5205.; |
| 65 | |
| 66 | static bool ADPCMLPcxx . . $ ADPCMLP.; |
| 67 | typedef structcxx . . $ $anonymous_type_14e2bb641e7b656b_0# |
| 68 | { |
| 69 | uint8cxx . . $ uint8# *RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM.; // = NULL; //0x10000; |
| 70 | uint16cxx . . $ uint16# Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.; |
| 71 | uint16cxx . . $ uint16# ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr.; |
| 72 | uint16cxx . . $ uint16# WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr.; |
| 73 | uint16cxx . . $ uint16# LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount.; |
| 74 | |
| 75 | bool HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached.; |
| 76 | bool EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached.; |
| 77 | bool Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing.; |
| 78 | |
| 79 | uint8cxx . . $ uint8# LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd.; |
| 80 | uint32cxx . . $ uint32# SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq.; |
| 81 | uint32cxx . . $ uint32# LPF_SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LPF_SampleFreq.; |
| 82 | |
| 83 | uint8cxx . . $ uint8# PlayBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayBuffer.; |
| 84 | uint8cxx . . $ uint8# ReadBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadBuffer.; |
| 85 | int32cxx . . $ int32# ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending.; |
| 86 | int32cxx . . $ int32# WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending.; |
| 87 | uint8cxx . . $ uint8# WritePendingValuecxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePendingValue.; |
| 88 | |
| 89 | uint32cxx . . $ uint32# PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble.; |
| 90 | |
| 91 | |
| 92 | int64cxx . . $ int64# bigdivacccxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdivacc.; |
| 93 | int64cxx . . $ int64# bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv.; |
| 94 | int32cxx . . $ int32# last_pcmcxx . . $ $anonymous_type_14e2bb641e7b656b_0#last_pcm.; |
| 95 | } ADPCM_tcxx . . $ ADPCM_t#; |
| 96 | |
| 97 | static ADPCM_tcxx . . $ ADPCM_t# ADPCMcxx . . $ ADPCM.; |
| 98 | |
| 99 | typedef structcxx . . $ $anonymous_type_14e2bb641e7b656b_1# |
| 100 | { |
| 101 | uint8cxx . . $ uint8# Commandcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Command.; |
| 102 | int32cxx . . $ int32# Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume.; |
| 103 | |
| 104 | int32cxx . . $ int32# CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter.; |
| 105 | uint32cxx . . $ uint32# CountValuecxx . . $ $anonymous_type_14e2bb641e7b656b_1#CountValue.; // What to reload CycleCounter with when it expires. |
| 106 | bool Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked.; |
| 107 | } FADE_tcxx . . $ FADE_t#; |
| 108 | |
| 109 | static FADE_tcxx . . $ FADE_t# Fadercxx . . $ Fader.; |
| 110 | static int32cxx . . $ int32# ADPCMFadeVolumecxx . . $ ADPCMFadeVolume., CDDAFadeVolumecxx . . $ CDDAFadeVolume.; |
| 111 | |
| 112 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void Fader_SyncWhichcxx . . $ Fader_SyncWhich(49f6e7a06ebc5aa8).(void) |
| 113 | { |
| 114 | if(Fadercxx . . $ Fader..Commandcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Command. & 0x2) // ADPCM fade |
| 115 | { |
| 116 | ADPCMFadeVolumecxx . . $ ADPCMFadeVolume. = Fadercxx . . $ Fader..Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume.; |
| 117 | CDDAFadeVolumecxx . . $ CDDAFadeVolume. = 65536; |
| 118 | } |
| 119 | else // CD-DA Fade |
| 120 | { |
| 121 | CDDAFadeVolumecxx . . $ CDDAFadeVolume. = Fadercxx . . $ Fader..Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume.; |
| 122 | ADPCMFadeVolumecxx . . $ ADPCMFadeVolume. = 65536; |
| 123 | } |
| 124 | |
| 125 | ADPCMFadeVolumecxx . . $ ADPCMFadeVolume. >>= 6; |
| 126 | PCECD_Drive_SetCDDAVolumecxx . . $ PCECD_Drive_SetCDDAVolume(cb2f890c2fdad230).(0.50f * CDDAFadeVolumecxx . . $ CDDAFadeVolume. * CDDAVolumeSettingcxx . . $ CDDAVolumeSetting.); |
| 127 | } |
| 128 | |
| 129 | static void RedoLPFcxx . . $ RedoLPF(d4f767463ce0a6b3).(int f) |
| 130 | { |
| 131 | if(sbufcxx . . $ sbuf.[0] && sbufcxx . . $ sbuf.[1]) |
| 132 | { |
| 133 | if(ADPCMLPcxx . . $ ADPCMLP.) |
| 134 | { |
| 135 | if(f >= 14) |
| 136 | { |
| 137 | int rolloff = (int)((((double)32087.5 / (16 - f)) / 2) * 0.70); |
| 138 | ADPCMSynthcxx . . $ ADPCMSynth..treble_eqcxx . . $ Blip_Synth#treble_eq(a728e5f0d25ddc61).( blip_eq_tcxx . . $ blip_eq_t#blip_eq_t(4fde810f210164e8).(-1000, rolloff, sbufcxx . . $ sbuf.[0]->sample_ratecxx . . $ Blip_Buffer#sample_rate(57a65ae535d7db84).())); |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | int rolloff = (int)((((double)32087.5 / (16 - f)) / 2) * 0.80); |
| 143 | ADPCMSynthcxx . . $ ADPCMSynth..treble_eqcxx . . $ Blip_Synth#treble_eq(a728e5f0d25ddc61).( blip_eq_tcxx . . $ blip_eq_t#blip_eq_t(4fde810f210164e8).(-1000, rolloff, sbufcxx . . $ sbuf.[0]->sample_ratecxx . . $ Blip_Buffer#sample_rate(57a65ae535d7db84).())); |
| 144 | } |
| 145 | } |
| 146 | else |
| 147 | ADPCMSynthcxx . . $ ADPCMSynth..treble_eqcxx . . $ Blip_Synth#treble_eq(a728e5f0d25ddc61).(-cxx . . $ blip_eq_t#blip_eq_t(ba8836b59fb42830).8.0); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! int32cxx . . $ int32# ADPCM_ClocksToNextEventcxx . . $ ADPCM_ClocksToNextEvent(b126dc7c1de90089).(void) |
| 152 | { |
| 153 | int32cxx . . $ int32# ret = (ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. + 65535) >> 16; |
| 154 | |
| 155 | if(ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. && ret > ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending.) |
| 156 | ret = ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending.; |
| 157 | |
| 158 | if(ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. && ret > ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending.) |
| 159 | ret = ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending.; |
| 160 | |
| 161 | return(ret); |
| 162 | } |
| 163 | |
| 164 | static int32cxx . . $ int32# CalcNextEventcxx . . $ CalcNextEvent(7864480464b09eea).(int32cxx . . $ int32# base) |
| 165 | { |
| 166 | int32cxx . . $ int32# next_event = base; |
| 167 | int32cxx . . $ int32# ADPCM_ctne = ADPCM_ClocksToNextEventcxx . . $ ADPCM_ClocksToNextEvent(b126dc7c1de90089).(); |
| 168 | |
| 169 | if(next_event > ADPCM_ctne) |
| 170 | next_event = ADPCM_ctne; |
| 171 | |
| 172 | if(ClearACKDelaycxx . . $ ClearACKDelay. > 0 && next_event > ClearACKDelaycxx . . $ ClearACKDelay.) |
| 173 | next_event = ClearACKDelaycxx . . $ ClearACKDelay.; |
| 174 | |
| 175 | if(next_event > pcecd_drive_necxx . . $ pcecd_drive_ne.) |
| 176 | next_event = pcecd_drive_necxx . . $ pcecd_drive_ne.; |
| 177 | |
| 178 | if(Fadercxx . . $ Fader..Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked. && next_event > Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter.) |
| 179 | next_event = Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter.; |
| 180 | |
| 181 | return(next_event); |
| 182 | } |
| 183 | |
| 184 | static void update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).() |
| 185 | { |
| 186 | uint8cxx . . $ uint8# irq = _Portcxx . . $ _Port.[2] & _Portcxx . . $ _Port.[0x3] & (0x4|0x8|0x10|0x20|0x40); |
| 187 | |
| 188 | IRQCBcxx . . $ IRQCB.((bool)irq); |
| 189 | } |
| 190 | |
| 191 | static void StuffSubchannelcxx . . $ StuffSubchannel(d5cb1b1d97598ec6).(uint8cxx . . $ uint8# meow, int subindex) |
| 192 | { |
| 193 | uint8cxx . . $ uint8# tmp_data = meow & 0x7F; |
| 194 | |
| 195 | if(subindex == -2) |
| 196 | tmp_data = 0x00; |
| 197 | else if(subindex == -1) |
| 198 | tmp_data = 0x80; |
| 199 | |
| 200 | if(SubChannelFIFOcxx . . $ SubChannelFIFO..CanWritecxx . . $ SimpleFIFO#CanWrite(db52760e79bf9054).()) |
| 201 | SubChannelFIFOcxx . . $ SubChannelFIFO..Writecxx . . $ SimpleFIFO#Write(9c56d35a43b4e338).(&tmp_data, 1); |
| 202 | |
| 203 | _Portcxx . . $ _Port.[0x3] |= 0x10; |
| 204 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 205 | } |
| 206 | |
| 207 | static void CDIRQcxx . . $ CDIRQ(d4f767463ce0a6b3).(int type) |
| 208 | { |
| 209 | #ifdef PCECD_DEBUG |
| 210 | if(type != 0x8000 || _Port[0x3] & 0x60) |
| 211 | printf("CDIRQ: %d\n", type); |
| 212 | #endif |
| 213 | if(type & 0x8000) |
| 214 | { |
| 215 | type &= 0x7FFF; |
| 216 | if(type == PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.) |
| 217 | _Portcxx . . $ _Port.[0x3] &= ~0x20; |
| 218 | else if(type == PCECD_Drive_IRQ_DATA_TRANSFER_READYcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_READY.) |
| 219 | _Portcxx . . $ _Port.[0x3] &= ~0x40; |
| 220 | } |
| 221 | else if(type == PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.) |
| 222 | { |
| 223 | _Portcxx . . $ _Port.[0x3] |= 0x20; |
| 224 | } |
| 225 | else if(type == PCECD_Drive_IRQ_DATA_TRANSFER_READYcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_READY.) |
| 226 | { |
| 227 | _Portcxx . . $ _Port.[0x3] |= 0x40; |
| 228 | } |
| 229 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 230 | } |
| 231 | |
| 232 | static void UpdateADPCMIRQStatecxx . . $ UpdateADPCMIRQState(49f6e7a06ebc5aa8).(void) |
| 233 | { |
| 234 | _Portcxx . . $ _Port.[0x3] &= ~0xC; |
| 235 | |
| 236 | _Portcxx . . $ _Port.[0x3] |= ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. ? 0x4 : 0x0; |
| 237 | _Portcxx . . $ _Port.[0x3] |= ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached. ? 0x8 : 0x0; |
| 238 | |
| 239 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 240 | } |
| 241 | |
| 242 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! uint8cxx . . $ uint8# read_1808cxx . . $ read_1808(bc0fba5608a0bfe7).(int32cxx . . $ int32# timestamp) |
| 243 | { |
| 244 | uint8cxx . . $ uint8# ret = PCECD_Drive_GetDBcxx . . $ `mednafen/pce_fast/pcecd_drive.h:41:9`!(); |
| 245 | |
| 246 | if(PCECD_Drive_GetREQcxx . . $ `mednafen/pce_fast/pcecd_drive.h:46:9`!() && !PCECD_Drive_GetACKcxx . . $ `mednafen/pce_fast/pcecd_drive.h:49:9`!() && !PCECD_Drive_GetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.h:44:9`!()) |
| 247 | { |
| 248 | if(PCECD_Drive_GetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.h:43:9`!()) |
| 249 | { |
| 250 | PCECD_Drive_SetACKcxx . . $ PCECD_Drive_SetACK(b45ddcbc8423892c).(TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!); |
| 251 | ACKStatuscxx . . $ ACKStatus. = TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!; |
| 252 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 253 | ClearACKDelaycxx . . $ ClearACKDelay. = 15 * 3; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return(ret); |
| 258 | } |
| 259 | |
| 260 | bool PCECD_SetSettingscxx . . $ PCECD_SetSettings(d3cabfadec164be7).(const PCECD_Settingscxx . . $ PCECD_Settings# *settings) |
| 261 | { |
| 262 | if(settings) |
| 263 | { |
| 264 | assertcxx . . $ `/usr/include/assert.h:102:11`!(settings->CDDA_Volume <= 2.0); |
| 265 | assertcxx . . $ `/usr/include/assert.h:102:11`!(settings->ADPCM_Volume <= 2.0); |
| 266 | } |
| 267 | |
| 268 | CDDAVolumeSettingcxx . . $ CDDAVolumeSetting. = settings ? settings->CDDA_Volumecxx . . $ $anonymous_type_f432417630a7227e_0#CDDA_Volume. : 1.0; |
| 269 | Fader_SyncWhichcxx . . $ Fader_SyncWhich(49f6e7a06ebc5aa8).(); |
| 270 | |
| 271 | ADPCMSynthcxx . . $ ADPCMSynth..volumecxx . . $ Blip_Synth#volume(ba8836b59fb42830).(0.42735f * (settings ? settings->ADPCM_Volumecxx . . $ $anonymous_type_f432417630a7227e_0#ADPCM_Volume. : 1.0)); |
| 272 | ADPCMLPcxx . . $ ADPCMLP. = settings ? settings->ADPCM_LPFcxx . . $ $anonymous_type_f432417630a7227e_0#ADPCM_LPF. : 0; |
| 273 | |
| 274 | PCECD_Drive_SetTransferRatecxx . . $ PCECD_Drive_SetTransferRate(cb2f890c2fdad230).(126000 * (settings ? settings->CD_Speedcxx . . $ $anonymous_type_f432417630a7227e_0#CD_Speed. : 1)); |
| 275 | |
| 276 | return true; |
| 277 | } |
| 278 | |
| 279 | bool PCECD_Initcxx . . $ PCECD_Init(55ea6bcbc11777af).(const PCECD_Settingscxx . . $ PCECD_Settings# *settings, void (*irqcb)(bool), double master_clock, unsigned int ocm, Blip_Buffercxx . . $ Blip_Buffer# *soundbuf_l, Blip_Buffercxx . . $ Blip_Buffer# *soundbuf_r) |
| 280 | { |
| 281 | lasttscxx . . $ lastts. = 0; |
| 282 | |
| 283 | OC_Multipliercxx . . $ OC_Multiplier. = ocm; |
| 284 | |
| 285 | IRQCBcxx . . $ IRQCB. = irqcb; |
| 286 | |
| 287 | sbufcxx . . $ sbuf.[0] = soundbuf_l; |
| 288 | sbufcxx . . $ sbuf.[1] = soundbuf_r; |
| 289 | |
| 290 | // Warning: magic number 126000 in PCECD_SetSettings() too |
| 291 | PCECD_Drive_Initcxx . . $ PCECD_Drive_Init(4ffa26e4fe0e05f9).(3 * OC_Multipliercxx . . $ OC_Multiplier., sbufcxx . . $ sbuf.[0], sbufcxx . . $ sbuf.[1], 126000 * (settings ? settings->CD_Speedcxx . . $ $anonymous_type_f432417630a7227e_0#CD_Speed. : 1), master_clock * OC_Multipliercxx . . $ OC_Multiplier., CDIRQcxx . . $ CDIRQ(d4f767463ce0a6b3)., StuffSubchannelcxx . . $ StuffSubchannel(d5cb1b1d97598ec6).); |
| 292 | |
| 293 | if(!(ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM. = (uint8cxx . . $ uint8# *)malloccxx . . $ malloc(9f008b2a9698428b).(0x10000))) |
| 294 | { |
| 295 | return(0); |
| 296 | } |
| 297 | |
| 298 | PCECD_SetSettingscxx . . $ PCECD_SetSettings(d3cabfadec164be7).(settings); |
| 299 | |
| 300 | ADPCMcxx . . $ ADPCM..bigdivacccxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdivacc. = (int64cxx . . $ int64#)((double)master_clock * OC_Multipliercxx . . $ OC_Multiplier. * 65536 / 32087.5); |
| 301 | |
| 302 | return(TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!); |
| 303 | } |
| 304 | |
| 305 | |
| 306 | void PCECD_Closecxx . . $ PCECD_Close(49f6e7a06ebc5aa8).(void) |
| 307 | { |
| 308 | if(ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM.) |
| 309 | freecxx . . $ free(bd21765a0afc8e3c).(ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM.); |
| 310 | ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 311 | PCECD_Drive_Closecxx . . $ PCECD_Drive_Close(49f6e7a06ebc5aa8).(); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | void PCECD_Powercxx . . $ PCECD_Power(cb2f890c2fdad230).(uint32cxx . . $ uint32# timestamp) |
| 316 | { |
| 317 | if((int32cxx . . $ int32#)timestamp != lasttscxx . . $ lastts.) |
| 318 | (void)PCECD_Runcxx . . $ PCECD_Run(cb2f890c2fdad230).(timestamp); |
| 319 | |
| 320 | IRQCBcxx . . $ IRQCB.(0); |
| 321 | |
| 322 | PCECD_Drive_Powercxx . . $ PCECD_Drive_Power(d4f767463ce0a6b3).(timestamp); |
| 323 | pcecd_drive_necxx . . $ pcecd_drive_ne. = 0x7fffffff; |
| 324 | |
| 325 | bBRAMEnabledcxx . . $ bBRAMEnabled. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 326 | memset(_Portcxx . . $ _Port., 0, sizeof(_Portcxx . . $ _Port.)); |
| 327 | ACKStatuscxx . . $ ACKStatus. = 0; |
| 328 | ClearACKDelaycxx . . $ ClearACKDelay. = 0; |
| 329 | |
| 330 | memset(ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM., 0x00, 65536); |
| 331 | |
| 332 | ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. = ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. = 0; |
| 333 | ADPCMcxx . . $ ADPCM..ReadBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadBuffer. = 0; |
| 334 | ADPCMcxx . . $ ADPCM..PlayBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayBuffer. = 0; |
| 335 | |
| 336 | ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. = 0; |
| 337 | MSM5205cxx . . $ MSM5205..SetSamplecxx . . $ OKIADPCM_Decoder#SetSample(ed53e3bbd3fa2f69).(0x800); |
| 338 | MSM5205cxx . . $ MSM5205..SetSSIcxx . . $ OKIADPCM_Decoder#SetSSI(ac50b47256ae7414).(0); |
| 339 | |
| 340 | ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq. = 0; |
| 341 | ADPCMcxx . . $ ADPCM..LPF_SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LPF_SampleFreq. = 0; |
| 342 | ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. = ADPCMcxx . . $ ADPCM..bigdivacccxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdivacc. * (16 - ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq.); |
| 343 | RedoLPFcxx . . $ RedoLPF(d4f767463ce0a6b3).(ADPCMcxx . . $ ADPCM..LPF_SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LPF_SampleFreq.); |
| 344 | |
| 345 | ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. = 0; |
| 346 | ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. = 0; |
| 347 | ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr. = 0; |
| 348 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. = 0; |
| 349 | ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. = 0; |
| 350 | |
| 351 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = false; |
| 352 | ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached. = false; |
| 353 | ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. = false; |
| 354 | ADPCMcxx . . $ ADPCM..PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble. = 0; |
| 355 | |
| 356 | UpdateADPCMIRQStatecxx . . $ UpdateADPCMIRQState(49f6e7a06ebc5aa8).(); |
| 357 | |
| 358 | Fadercxx . . $ Fader..Commandcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Command. = 0x00; |
| 359 | Fadercxx . . $ Fader..Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume. = 0; |
| 360 | Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter. = 0; |
| 361 | Fadercxx . . $ Fader..CountValuecxx . . $ $anonymous_type_14e2bb641e7b656b_1#CountValue. = 0; |
| 362 | Fadercxx . . $ Fader..Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 363 | } |
| 364 | |
| 365 | bool PCECD_IsBRAMEnabledcxx . . $ PCECD_IsBRAMEnabled(c9857a73d68e59ba).(void) |
| 366 | { |
| 367 | return bBRAMEnabledcxx . . $ bBRAMEnabled.; |
| 368 | } |
| 369 | |
| 370 | uint8cxx . . $ uint8# PCECD_Readcxx . . $ PCECD_Read(e77b674d7ec06db6).(uint32cxx . . $ uint32# timestamp, uint32cxx . . $ uint32# A) |
| 371 | { |
| 372 | uint8cxx . . $ uint8# ret = 0; |
| 373 | |
| 374 | if((A & 0x18c0) == 0x18c0) |
| 375 | { |
| 376 | switch (A & 0x18cf) |
| 377 | { |
| 378 | case 0x18c1: ret = 0xaa; break; |
| 379 | case 0x18c2: ret = 0x55; break; |
| 380 | case 0x18c3: ret = 0x00; break; |
| 381 | case 0x18c5: ret = 0xaa; break; |
| 382 | case 0x18c6: ret = 0x55; break; |
| 383 | case 0x18c7: ret = 0x03; break; |
| 384 | } |
| 385 | } |
| 386 | else |
| 387 | { |
| 388 | PCECD_Runcxx . . $ PCECD_Run(cb2f890c2fdad230).(timestamp); |
| 389 | |
| 390 | switch(A & 0xf) |
| 391 | { |
| 392 | case 0x0: |
| 393 | ret = 0; |
| 394 | ret |= PCECD_Drive_GetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.h:42:9`!() ? 0x80 : 0x00; |
| 395 | ret |= PCECD_Drive_GetREQcxx . . $ `mednafen/pce_fast/pcecd_drive.h:46:9`!() ? 0x40 : 0x00; |
| 396 | ret |= PCECD_Drive_GetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.h:45:9`!() ? 0x20 : 0x00; |
| 397 | ret |= PCECD_Drive_GetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.h:44:9`!() ? 0x10 : 0x00; |
| 398 | ret |= PCECD_Drive_GetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.h:43:9`!() ? 0x08 : 0x00; |
| 399 | break; |
| 400 | |
| 401 | case 0x1: ret = PCECD_Drive_GetDBcxx . . $ `mednafen/pce_fast/pcecd_drive.h:41:9`!(); |
| 402 | break; |
| 403 | |
| 404 | case 0x2: ret = _Portcxx . . $ _Port.[2]; |
| 405 | break; |
| 406 | |
| 407 | case 0x3: bBRAMEnabledcxx . . $ bBRAMEnabled. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 408 | |
| 409 | /* switch left/right of digitized cd playback */ |
| 410 | ret = _Portcxx . . $ _Port.[0x3]; |
| 411 | _Portcxx . . $ _Port.[0x3] ^= 2; |
| 412 | break; |
| 413 | |
| 414 | case 0x4: ret = _Portcxx . . $ _Port.[4]; |
| 415 | break; |
| 416 | |
| 417 | case 0x5: if(_Portcxx . . $ _Port.[0x3] & 0x2) |
| 418 | ret = RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[1] & 0xff; // Right |
| 419 | else |
| 420 | ret = RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[0] & 0xff; // Left |
| 421 | break; |
| 422 | |
| 423 | case 0x6: if(_Portcxx . . $ _Port.[0x3] & 0x2) |
| 424 | ret = ((uint16cxx . . $ uint16#)RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[1]) >> 8; // Right |
| 425 | else |
| 426 | ret = ((uint16cxx . . $ uint16#)RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[0]) >> 8; // Left |
| 427 | break; |
| 428 | |
| 429 | case 0x7: |
| 430 | if(SubChannelFIFOcxx . . $ SubChannelFIFO..CanReadcxx . . $ SimpleFIFO#CanRead(db52760e79bf9054).() > 0) |
| 431 | ret = SubChannelFIFOcxx . . $ SubChannelFIFO..ReadBytecxx . . $ SimpleFIFO#ReadByte(389f4deb06b45b4e).(); |
| 432 | else |
| 433 | ret = 0x00; // Not sure if it's 0, 0xFF, the last byte read, or something else. |
| 434 | |
| 435 | if(SubChannelFIFOcxx . . $ SubChannelFIFO..CanReadcxx . . $ SimpleFIFO#CanRead(db52760e79bf9054).() == 0) |
| 436 | { |
| 437 | _Portcxx . . $ _Port.[0x3] &= ~0x10; |
| 438 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 439 | } |
| 440 | break; |
| 441 | |
| 442 | case 0x8: |
| 443 | ret = read_1808cxx . . $ read_1808(bc0fba5608a0bfe7).(timestamp); |
| 444 | break; |
| 445 | |
| 446 | case 0xa: |
| 447 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("ReadBuffer\n"); |
| 448 | ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. = 19 * 3; //24 * 3; |
| 449 | ret = ADPCMcxx . . $ ADPCM..ReadBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadBuffer.; |
| 450 | break; |
| 451 | |
| 452 | case 0xb: |
| 453 | ret = _Portcxx . . $ _Port.[0xb]; |
| 454 | break; |
| 455 | |
| 456 | case 0xc: |
| 457 | //printf("ADPCM Status Read: %d\n", timestamp); |
| 458 | ret = 0x00; |
| 459 | |
| 460 | ret |= (ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached.) ? 0x01 : 0x00; |
| 461 | ret |= (ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing.) ? 0x08 : 0x00; |
| 462 | ret |= (ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. > 0) ? 0x04 : 0x00; |
| 463 | ret |= (ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. > 0) ? 0x80 : 0x00; |
| 464 | break; |
| 465 | |
| 466 | case 0xd: |
| 467 | ret = ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd.; |
| 468 | break; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | #ifdef PCECD_DEBUG |
| 473 | printf("Read: %04x %02x, %d\n", A, ret, timestamp); |
| 474 | #endif |
| 475 | |
| 476 | return(ret); |
| 477 | } |
| 478 | |
| 479 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void Fader_Runcxx . . $ Fader_Run(d4f767463ce0a6b3).(const int32cxx . . $ int32# clocks) |
| 480 | { |
| 481 | if(Fadercxx . . $ Fader..Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked.) |
| 482 | { |
| 483 | Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter. -= clocks; |
| 484 | while(Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter. <= 0) |
| 485 | { |
| 486 | if(Fadercxx . . $ Fader..Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume.) |
| 487 | Fadercxx . . $ Fader..Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume.--; |
| 488 | |
| 489 | Fader_SyncWhichcxx . . $ Fader_SyncWhich(49f6e7a06ebc5aa8).(); |
| 490 | |
| 491 | Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter. += Fadercxx . . $ Fader..CountValuecxx . . $ $anonymous_type_14e2bb641e7b656b_1#CountValue.; |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | |
| 497 | void PCECD_Writecxx . . $ PCECD_Write(10e3fdc6547212ea).(uint32cxx . . $ uint32# timestamp, uint32cxx . . $ uint32# physAddr, uint8cxx . . $ uint8# data) |
| 498 | { |
| 499 | const uint8cxx . . $ uint8# V = data; |
| 500 | |
| 501 | #ifdef PCECD_DEBUG |
| 502 | printf("Write: (PC=%04x, t=%6d) %04x %02x; MSG: %d, REQ: %d, ACK: %d, CD: %d, IO: %d, BSY: %d, SEL: %d\n", HuCPU.PC, timestamp, physAddr, data, PCECD_Drive_GetMSG(), PCECD_Drive_GetREQ(), PCECD_Drive_GetACK(), PCECD_Drive_GetCD(), PCECD_Drive_GetIO(), PCECD_Drive_GetBSY(), PCECD_Drive_GetSEL()); |
| 503 | #endif |
| 504 | |
| 505 | PCECD_Runcxx . . $ PCECD_Run(cb2f890c2fdad230).(timestamp); |
| 506 | |
| 507 | switch (physAddr & 0xf) |
| 508 | { |
| 509 | case 0x0: |
| 510 | PCECD_Drive_SetSELcxx . . $ PCECD_Drive_SetSEL(b45ddcbc8423892c).(1); |
| 511 | PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 512 | PCECD_Drive_SetSELcxx . . $ PCECD_Drive_SetSEL(b45ddcbc8423892c).(0); |
| 513 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 514 | |
| 515 | /* reset irq status */ |
| 516 | _Portcxx . . $ _Port.[0x3] &= ~(0x20 | 0x40); // TODO: Confirm writing this register really reset these bits. |
| 517 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 518 | break; |
| 519 | |
| 520 | case 0x1: // $1801 |
| 521 | _Portcxx . . $ _Port.[1] = data; |
| 522 | PCECD_Drive_SetDBcxx . . $ PCECD_Drive_SetDB(ac50b47256ae7414).(data); |
| 523 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 524 | break; |
| 525 | |
| 526 | case 0x2: // $1802 |
| 527 | #ifdef PCECD_DEBUG |
| 528 | if(!(_Port[0x3] & _Port[2] & 0x40) && (_Port[0x3] & data & 0x40)) |
| 529 | puts("IRQ on waah 0x40"); |
| 530 | if(!(_Port[0x3] & _Port[2] & 0x20) && (_Port[0x3] & data & 0x20)) |
| 531 | puts("IRQ on waah 0x20"); |
| 532 | #endif |
| 533 | |
| 534 | PCECD_Drive_SetACKcxx . . $ PCECD_Drive_SetACK(b45ddcbc8423892c).(data & 0x80); |
| 535 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 536 | _Portcxx . . $ _Port.[2] = data; |
| 537 | ACKStatuscxx . . $ ACKStatus. = (bool)(data & 0x80); |
| 538 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 539 | break; |
| 540 | |
| 541 | case 0x3: // read only |
| 542 | break; |
| 543 | |
| 544 | case 0x4: |
| 545 | PCECD_Drive_SetRSTcxx . . $ PCECD_Drive_SetRST(b45ddcbc8423892c).(data & 0x2); |
| 546 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 547 | if(data & 0x2) |
| 548 | { |
| 549 | _Portcxx . . $ _Port.[0x3] &= ~0x70; |
| 550 | update_irq_statecxx . . $ update_irq_state(49f6e7a06ebc5aa8).(); |
| 551 | } |
| 552 | _Portcxx . . $ _Port.[4] = data; |
| 553 | break; |
| 554 | |
| 555 | case 0x5: |
| 556 | case 0x6: |
| 557 | { |
| 558 | int16cxx . . $ int16# left, right; |
| 559 | PCECD_Drive_GetCDDAValuescxx . . $ PCECD_Drive_GetCDDAValues(a68af88c52dba8c4).(left, right); |
| 560 | RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[0] = ((int64cxx . . $ int64#)abscxx . . $ abs(a1851578aea3f541).(left) * CDDAFadeVolumecxx . . $ CDDAFadeVolume.) >> 16; |
| 561 | RawPCMVolumeCachecxx . . $ RawPCMVolumeCache.[1] = ((int64cxx . . $ int64#)abscxx . . $ abs(a1851578aea3f541).(right) * CDDAFadeVolumecxx . . $ CDDAFadeVolume.) >> 16; |
| 562 | } |
| 563 | break; |
| 564 | |
| 565 | case 0x7: // $1807: D7=1 enables backup ram |
| 566 | if (data & 0x80) |
| 567 | { |
| 568 | bBRAMEnabledcxx . . $ bBRAMEnabled. = TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!; |
| 569 | } |
| 570 | break; |
| 571 | |
| 572 | case 0x8: // Set ADPCM address low |
| 573 | if(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x80) |
| 574 | break; |
| 575 | |
| 576 | ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. &= 0xFF00; |
| 577 | ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. |= V; |
| 578 | |
| 579 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("SAL: %02x, %d\n", V, timestamp); |
| 580 | |
| 581 | // Length appears to be constantly latched when D4 is set(tested on a real system) |
| 582 | if(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x10) |
| 583 | { |
| 584 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Set length(crazy way L): %04x\n", ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.); |
| 585 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. = ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.; |
| 586 | } |
| 587 | break; |
| 588 | |
| 589 | case 0x9: // Set ADPCM address high |
| 590 | if(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x80) |
| 591 | break; |
| 592 | |
| 593 | ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. &= 0x00FF; |
| 594 | ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. |= V << 8; |
| 595 | |
| 596 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("SAH: %02x, %d\n", V, timestamp); |
| 597 | |
| 598 | // Length appears to be constantly latched when D4 is set(tested on a real system) |
| 599 | if(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x10) |
| 600 | { |
| 601 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Set length(crazy way H): %04x\n", ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.); |
| 602 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. = ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.; |
| 603 | } |
| 604 | break; |
| 605 | |
| 606 | case 0xa: |
| 607 | //ADPCM_DEBUG("Write: %02x, %d\n", V, timestamp); |
| 608 | ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. = 3 * 11; |
| 609 | ADPCMcxx . . $ ADPCM..WritePendingValuecxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePendingValue. = data; |
| 610 | break; |
| 611 | |
| 612 | case 0xb: // adpcm dma |
| 613 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("DMA: %02x\n", V); |
| 614 | _Portcxx . . $ _Port.[0xb] = data; |
| 615 | break; |
| 616 | |
| 617 | case 0xc: // read-only |
| 618 | break; |
| 619 | |
| 620 | case 0xd: |
| 621 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Write180D: %02x\n", V); |
| 622 | if(data & 0x80) |
| 623 | { |
| 624 | ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. = 0; |
| 625 | ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. = 0; |
| 626 | ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr. = 0; |
| 627 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. = 0; |
| 628 | ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. = 0; |
| 629 | |
| 630 | ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. = false; |
| 631 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = false; |
| 632 | ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached. = false; |
| 633 | |
| 634 | ADPCMcxx . . $ ADPCM..PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble. = 0; |
| 635 | |
| 636 | UpdateADPCMIRQStatecxx . . $ UpdateADPCMIRQState(49f6e7a06ebc5aa8).(); |
| 637 | |
| 638 | MSM5205cxx . . $ MSM5205..SetSamplecxx . . $ OKIADPCM_Decoder#SetSample(ed53e3bbd3fa2f69).(0x800); |
| 639 | MSM5205cxx . . $ MSM5205..SetSSIcxx . . $ OKIADPCM_Decoder#SetSSI(ac50b47256ae7414).(0); |
| 640 | break; |
| 641 | } |
| 642 | |
| 643 | if(ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. && !(data & 0x20)) |
| 644 | ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. = false; |
| 645 | |
| 646 | if(!ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. && (data & 0x20)) |
| 647 | { |
| 648 | ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. = ADPCMcxx . . $ ADPCM..bigdivacccxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdivacc. * (16 - ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq.); |
| 649 | ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. = true; |
| 650 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = false; // Not sure about this. |
| 651 | ADPCMcxx . . $ ADPCM..PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble. = 0; |
| 652 | MSM5205cxx . . $ MSM5205..SetSamplecxx . . $ OKIADPCM_Decoder#SetSample(ed53e3bbd3fa2f69).(0x800); |
| 653 | MSM5205cxx . . $ MSM5205..SetSSIcxx . . $ OKIADPCM_Decoder#SetSSI(ac50b47256ae7414).(0); |
| 654 | } |
| 655 | |
| 656 | // Length appears to be constantly latched when D4 is set(tested on a real system) |
| 657 | if(data & 0x10) |
| 658 | { |
| 659 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Set length: %04x\n", ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.); |
| 660 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. = ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.; |
| 661 | ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached. = false; |
| 662 | } |
| 663 | |
| 664 | // D2 and D3 control read address |
| 665 | if(!(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x8) && (data & 0x08)) |
| 666 | { |
| 667 | if(data & 0x4) |
| 668 | ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. = ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.; |
| 669 | else |
| 670 | ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. = (ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr. - 1) & 0xFFFF; |
| 671 | |
| 672 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Set ReadAddr: %04x, %06x\n", ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr., ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr.); |
| 673 | } |
| 674 | |
| 675 | // D0 and D1 control write address |
| 676 | if(!(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x2) && (data & 0x2)) |
| 677 | { |
| 678 | ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr. = ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr.; |
| 679 | if(!(data & 0x1)) |
| 680 | ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr. = (ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr. - 1) & 0xFFFF; |
| 681 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Set WriteAddr: %04x, %06x\n", ADPCMcxx . . $ ADPCM..Addrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Addr., ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr.); |
| 682 | } |
| 683 | ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. = data; |
| 684 | UpdateADPCMIRQStatecxx . . $ UpdateADPCMIRQState(49f6e7a06ebc5aa8).(); |
| 685 | break; |
| 686 | |
| 687 | case 0xe: // Set ADPCM playback rate |
| 688 | { |
| 689 | uint8cxx . . $ uint8# freq = V & 0x0F; |
| 690 | |
| 691 | ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq. = freq; |
| 692 | |
| 693 | ADPCM_DEBUGcxx . . $ ADPCM_DEBUG(326aeb464d16410c).("Freq: %02x\n", freq); |
| 694 | } |
| 695 | break; |
| 696 | |
| 697 | case 0xf: |
| 698 | Fadercxx . . $ Fader..Commandcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Command. = V; |
| 699 | |
| 700 | #ifdef PCECD_DEBUG |
| 701 | printf("Fade: %02x\n", data); |
| 702 | #endif |
| 703 | |
| 704 | // Cancel fade |
| 705 | if(!(V & 0x8)) |
| 706 | { |
| 707 | Fadercxx . . $ Fader..Volumecxx . . $ $anonymous_type_14e2bb641e7b656b_1#Volume. = 65536; |
| 708 | Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter. = 0; |
| 709 | Fadercxx . . $ Fader..CountValuecxx . . $ $anonymous_type_14e2bb641e7b656b_1#CountValue. = 0; |
| 710 | Fadercxx . . $ Fader..Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 711 | } |
| 712 | else |
| 713 | { |
| 714 | Fadercxx . . $ Fader..CountValuecxx . . $ $anonymous_type_14e2bb641e7b656b_1#CountValue. = OC_Multipliercxx . . $ OC_Multiplier. * 3 * ((V & 0x4) ? 273 : 655); // 2.500s : 6.000s; |
| 715 | |
| 716 | if(!Fadercxx . . $ Fader..Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked.) |
| 717 | Fadercxx . . $ Fader..CycleCountercxx . . $ $anonymous_type_14e2bb641e7b656b_1#CycleCounter. = Fadercxx . . $ Fader..CountValuecxx . . $ $anonymous_type_14e2bb641e7b656b_1#CountValue.; |
| 718 | |
| 719 | Fadercxx . . $ Fader..Clockedcxx . . $ $anonymous_type_14e2bb641e7b656b_1#Clocked. = TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!; |
| 720 | } |
| 721 | Fader_SyncWhichcxx . . $ Fader_SyncWhich(49f6e7a06ebc5aa8).(); |
| 722 | break; |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void ADPCM_PB_Runcxx . . $ ADPCM_PB_Run(3e454b8ccf442868).(int32cxx . . $ int32# basetime, int32cxx . . $ int32# run_time) |
| 727 | { |
| 728 | ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. -= run_time * 65536; |
| 729 | |
| 730 | while(ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. <= 0) |
| 731 | { |
| 732 | ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. += ADPCMcxx . . $ ADPCM..bigdivacccxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdivacc. * (16 - ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq.); |
| 733 | |
| 734 | if(ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. && !ADPCMcxx . . $ ADPCM..PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble.) // Do playback sample buffer fetch. |
| 735 | { |
| 736 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = (ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. < 32768); |
| 737 | if(!ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. && !(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x10)) |
| 738 | { |
| 739 | if(ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached.) |
| 740 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = false; |
| 741 | |
| 742 | ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached. = true; |
| 743 | |
| 744 | if(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x40) |
| 745 | ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. = false; |
| 746 | } |
| 747 | |
| 748 | ADPCMcxx . . $ ADPCM..PlayBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayBuffer. = ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM.[ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr.]; |
| 749 | ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. = (ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. + 1) & 0xFFFF; |
| 750 | |
| 751 | if(ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. && !(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x10)) |
| 752 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount.--; |
| 753 | } |
| 754 | |
| 755 | if(ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing.) |
| 756 | { |
| 757 | int32cxx . . $ int32# pcm; |
| 758 | uint8cxx . . $ uint8# nibble; |
| 759 | |
| 760 | nibble = (ADPCMcxx . . $ ADPCM..PlayBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayBuffer. >> (ADPCMcxx . . $ ADPCM..PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble. ^ 4)) & 0x0F; |
| 761 | pcm = MSM5205cxx . . $ MSM5205..Decodecxx . . $ OKIADPCM_Decoder#Decode(3706112bcd2aff3a).(nibble) - 2048; |
| 762 | |
| 763 | ADPCMcxx . . $ ADPCM..PlayNibblecxx . . $ $anonymous_type_14e2bb641e7b656b_0#PlayNibble. ^= 4; |
| 764 | |
| 765 | pcm = (pcm * ADPCMFadeVolumecxx . . $ ADPCMFadeVolume.) >> 8; |
| 766 | uint32cxx . . $ uint32# synthtime = ((basetime + (ADPCMcxx . . $ ADPCM..bigdivcxx . . $ $anonymous_type_14e2bb641e7b656b_0#bigdiv. >> 16))) / (3 * OC_Multipliercxx . . $ OC_Multiplier.); |
| 767 | |
| 768 | if(sbufcxx . . $ sbuf.[0] && sbufcxx . . $ sbuf.[1]) |
| 769 | { |
| 770 | ADPCMSynthcxx . . $ ADPCMSynth..offsetcxx . . $ Blip_Synth#offset(90077ce6337795eb).(synthtime, pcm - ADPCMcxx . . $ ADPCM..last_pcmcxx . . $ $anonymous_type_14e2bb641e7b656b_0#last_pcm., sbufcxx . . $ sbuf.[0]); |
| 771 | ADPCMSynthcxx . . $ ADPCMSynth..offsetcxx . . $ Blip_Synth#offset(90077ce6337795eb).(synthtime, pcm - ADPCMcxx . . $ ADPCM..last_pcmcxx . . $ $anonymous_type_14e2bb641e7b656b_0#last_pcm., sbufcxx . . $ sbuf.[1]); |
| 772 | } |
| 773 | ADPCMcxx . . $ ADPCM..last_pcmcxx . . $ $anonymous_type_14e2bb641e7b656b_0#last_pcm. = pcm; |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void ADPCM_Runcxx . . $ ADPCM_Run(3e454b8ccf442868).(const int32cxx . . $ int32# clocks, const int32cxx . . $ int32# timestamp) |
| 779 | { |
| 780 | //printf("ADPCM Run: %d\n", clocks); |
| 781 | ADPCM_PB_Runcxx . . $ ADPCM_PB_Run(3e454b8ccf442868).(timestamp, clocks); |
| 782 | |
| 783 | if(ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending.) |
| 784 | { |
| 785 | ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. -= clocks; |
| 786 | if(ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. <= 0) |
| 787 | { |
| 788 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = (ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. < 32768); |
| 789 | if(!(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x10) && ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. < 0xFFFF) |
| 790 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount.++; |
| 791 | |
| 792 | ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM.[ADPCMcxx . . $ ADPCM..WriteAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WriteAddr.++] = ADPCMcxx . . $ ADPCM..WritePendingValuecxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePendingValue.; |
| 793 | ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. = 0; |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | if(!ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending.) |
| 798 | { |
| 799 | if(_Portcxx . . $ _Port.[0xb] & 0x3) |
| 800 | { |
| 801 | // Run PCECD_Drive before we examine the signals. |
| 802 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(timestamp); |
| 803 | |
| 804 | if(!PCECD_Drive_GetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.h:44:9`!() && PCECD_Drive_GetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.h:43:9`!() && PCECD_Drive_GetREQcxx . . $ `mednafen/pce_fast/pcecd_drive.h:46:9`!() && !PCECD_Drive_GetACKcxx . . $ `mednafen/pce_fast/pcecd_drive.h:49:9`!()) |
| 805 | { |
| 806 | ADPCMcxx . . $ ADPCM..WritePendingValuecxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePendingValue. = read_1808cxx . . $ read_1808(bc0fba5608a0bfe7).(timestamp); |
| 807 | ADPCMcxx . . $ ADPCM..WritePendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#WritePending. = 10 * 3; |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | if(ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending.) |
| 813 | { |
| 814 | ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. -= clocks; |
| 815 | if(ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. <= 0) |
| 816 | { |
| 817 | ADPCMcxx . . $ ADPCM..ReadBuffercxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadBuffer. = ADPCMcxx . . $ ADPCM..RAMcxx . . $ $anonymous_type_14e2bb641e7b656b_0#RAM.[ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr.]; |
| 818 | ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. = (ADPCMcxx . . $ ADPCM..ReadAddrcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadAddr. + 1) & 0xFFFF; |
| 819 | ADPCMcxx . . $ ADPCM..ReadPendingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#ReadPending. = 0; |
| 820 | |
| 821 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = (ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount. < 32768); |
| 822 | if(!(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x10)) |
| 823 | { |
| 824 | if(ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount.) |
| 825 | ADPCMcxx . . $ ADPCM..LengthCountcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LengthCount.--; |
| 826 | else |
| 827 | { |
| 828 | ADPCMcxx . . $ ADPCM..EndReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#EndReached. = true; |
| 829 | ADPCMcxx . . $ ADPCM..HalfReachedcxx . . $ $anonymous_type_14e2bb641e7b656b_0#HalfReached. = false; |
| 830 | |
| 831 | if(ADPCMcxx . . $ ADPCM..LastCmdcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LastCmd. & 0x40) |
| 832 | ADPCMcxx . . $ ADPCM..Playingcxx . . $ $anonymous_type_14e2bb641e7b656b_0#Playing. = false; |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | UpdateADPCMIRQStatecxx . . $ UpdateADPCMIRQState(49f6e7a06ebc5aa8).(); |
| 839 | } |
| 840 | |
| 841 | void PCECD_Runcxx . . $ PCECD_Run(cb2f890c2fdad230).(uint32cxx . . $ uint32# in_timestamp) |
| 842 | { |
| 843 | int32cxx . . $ int32# clocks = in_timestamp - lasttscxx . . $ lastts.; |
| 844 | int32cxx . . $ int32# running_ts = lasttscxx . . $ lastts.; |
| 845 | |
| 846 | //printf("Run Begin: Clocks=%d(%d - %d), cl=%d\n", clocks, in_timestamp, lastts, CalcNextEvent); |
| 847 | //fflush(stdout); |
| 848 | |
| 849 | while(clocks > 0) |
| 850 | { |
| 851 | int32cxx . . $ int32# chunk_clocks = CalcNextEventcxx . . $ CalcNextEvent(7864480464b09eea).(clocks); |
| 852 | |
| 853 | running_ts += chunk_clocks; |
| 854 | |
| 855 | if(ClearACKDelaycxx . . $ ClearACKDelay. > 0) |
| 856 | { |
| 857 | ClearACKDelaycxx . . $ ClearACKDelay. -= chunk_clocks; |
| 858 | if(ClearACKDelaycxx . . $ ClearACKDelay. <= 0) |
| 859 | { |
| 860 | ACKStatuscxx . . $ ACKStatus. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 861 | PCECD_Drive_SetACKcxx . . $ PCECD_Drive_SetACK(b45ddcbc8423892c).(FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!); |
| 862 | PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(running_ts); |
| 863 | if(PCECD_Drive_GetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.h:44:9`!()) |
| 864 | { |
| 865 | _Portcxx . . $ _Port.[0xb] &= ~1; |
| 866 | #ifdef PCECD_DEBUG |
| 867 | puts("DMA End"); |
| 868 | #endif |
| 869 | } |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | Fader_Runcxx . . $ Fader_Run(d4f767463ce0a6b3).(chunk_clocks); |
| 874 | |
| 875 | ADPCM_Runcxx . . $ ADPCM_Run(3e454b8ccf442868).(chunk_clocks, running_ts); |
| 876 | pcecd_drive_necxx . . $ pcecd_drive_ne. = PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(running_ts); |
| 877 | |
| 878 | clocks -= chunk_clocks; |
| 879 | } |
| 880 | |
| 881 | lasttscxx . . $ lastts. = in_timestamp; |
| 882 | } |
| 883 | |
| 884 | void PCECD_ResetTScxx . . $ PCECD_ResetTS(49f6e7a06ebc5aa8).(void) |
| 885 | { |
| 886 | if(ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq. != ADPCMcxx . . $ ADPCM..LPF_SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LPF_SampleFreq.) |
| 887 | { |
| 888 | ADPCMcxx . . $ ADPCM..LPF_SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LPF_SampleFreq. = ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq.; |
| 889 | RedoLPFcxx . . $ RedoLPF(d4f767463ce0a6b3).(ADPCMcxx . . $ ADPCM..LPF_SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#LPF_SampleFreq.); |
| 890 | } |
| 891 | PCECD_Drive_ResetTScxx . . $ PCECD_Drive_ResetTS(49f6e7a06ebc5aa8).(); |
| 892 | lasttscxx . . $ lastts. = 0; |
| 893 | } |
| 894 | |
| 895 | static int ADPCM_StateActioncxx . . $ ADPCM_StateAction(a45b884b8cf568d5).(StateMemcxx . . $ StateMem# *sm, int load, int data_only) |
| 896 | { |
| 897 | uint32cxx . . $ uint32# ad_sample = MSM5205cxx . . $ MSM5205..GetSamplecxx . . $ OKIADPCM_Decoder#GetSample(32a7769d58713265).(); |
| 898 | int32cxx . . $ int32# ad_ref_index = MSM5205cxx . . $ MSM5205..GetSSIcxx . . $ OKIADPCM_Decoder#GetSSI(7c4be072098b358f).(); |
| 899 | |
| 900 | SFORMATcxx . . $ SFORMAT# StateRegs[] = |
| 901 | { |
| 902 | SFARRAYcxx . . $ `mednafen/state.h:73:9`!(ADPCM.RAM, 0x10000), |
| 903 | |
| 904 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.bigdiv), |
| 905 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.Addr), |
| 906 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.ReadAddr), |
| 907 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.WriteAddr), |
| 908 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.LengthCount), |
| 909 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.LastCmd), |
| 910 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.SampleFreq), |
| 911 | |
| 912 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.ReadPending), |
| 913 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.ReadBuffer), |
| 914 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.PlayBuffer), |
| 915 | |
| 916 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.WritePending), |
| 917 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.WritePendingValue), |
| 918 | |
| 919 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.HalfReached), |
| 920 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.EndReached), |
| 921 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.Playing), |
| 922 | |
| 923 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ADPCM.PlayNibble), |
| 924 | |
| 925 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ad_sample), |
| 926 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ad_ref_index), |
| 927 | SFENDcxx . . $ `mednafen/state.h:94:9`! |
| 928 | }; |
| 929 | |
| 930 | int ret = MDFNSS_StateActioncxx . . $ MDFNSS_StateAction(3f628545d3b0df83).(sm, load, data_only, StateRegs, "APCM"); |
| 931 | if(load) |
| 932 | { |
| 933 | MSM5205cxx . . $ MSM5205..SetSamplecxx . . $ OKIADPCM_Decoder#SetSample(ed53e3bbd3fa2f69).(ad_sample); |
| 934 | MSM5205cxx . . $ MSM5205..SetSSIcxx . . $ OKIADPCM_Decoder#SetSSI(ac50b47256ae7414).(ad_ref_index); |
| 935 | RedoLPFcxx . . $ RedoLPF(d4f767463ce0a6b3).(ADPCMcxx . . $ ADPCM..SampleFreqcxx . . $ $anonymous_type_14e2bb641e7b656b_0#SampleFreq.); |
| 936 | } |
| 937 | return(ret); |
| 938 | } |
| 939 | |
| 940 | int PCECD_StateActioncxx . . $ PCECD_StateAction(a45b884b8cf568d5).(StateMemcxx . . $ StateMem# *sm, int load, int data_only) |
| 941 | { |
| 942 | SFORMATcxx . . $ SFORMAT# StateRegs[] = |
| 943 | { |
| 944 | SFVARcxx . . $ `mednafen/state.h:70:9`!(bBRAMEnabled), |
| 945 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ACKStatus), |
| 946 | SFVARcxx . . $ `mednafen/state.h:70:9`!(ClearACKDelay), |
| 947 | SFARRAY16cxx . . $ `mednafen/state.h:79:9`!(RawPCMVolumeCache, 2), |
| 948 | SFARRAYcxx . . $ `mednafen/state.h:73:9`!(_Port, sizeof(_Port)), |
| 949 | |
| 950 | SFVARcxx . . $ `mednafen/state.h:70:9`!(Fader.Command), |
| 951 | SFVARcxx . . $ `mednafen/state.h:70:9`!(Fader.Volume), |
| 952 | SFVARcxx . . $ `mednafen/state.h:70:9`!(Fader.CycleCounter), |
| 953 | SFVARcxx . . $ `mednafen/state.h:70:9`!(Fader.CountValue), |
| 954 | SFVARcxx . . $ `mednafen/state.h:70:9`!(Fader.Clocked), |
| 955 | |
| 956 | SFARRAYcxx . . $ `mednafen/state.h:73:9`!(&SubChannelFIFO.data[0], SubChannelFIFO.data.size()), |
| 957 | SFVARcxx . . $ `mednafen/state.h:70:9`!(SubChannelFIFO.read_pos), |
| 958 | SFVARcxx . . $ `mednafen/state.h:70:9`!(SubChannelFIFO.write_pos), |
| 959 | SFVARcxx . . $ `mednafen/state.h:70:9`!(SubChannelFIFO.in_count), |
| 960 | |
| 961 | SFENDcxx . . $ `mednafen/state.h:94:9`! |
| 962 | }; |
| 963 | |
| 964 | int ret = MDFNSS_StateActioncxx . . $ MDFNSS_StateAction(3f628545d3b0df83).(sm, load, data_only, StateRegs, "PECD"); |
| 965 | ret &= PCECD_Drive_StateActioncxx . . $ PCECD_Drive_StateAction(68129732609e585a).(sm, load, data_only, "CDRM"); |
| 966 | ret &= ADPCM_StateActioncxx . . $ ADPCM_StateAction(a45b884b8cf568d5).(sm, load, data_only); |
| 967 | |
| 968 | if(load) |
| 969 | { |
| 970 | Fader_SyncWhichcxx . . $ Fader_SyncWhich(49f6e7a06ebc5aa8).(); |
| 971 | //PCECD_Drive_SetDB(_Port[1]); |
| 972 | PCECD_Drive_SetACKcxx . . $ PCECD_Drive_SetACK(b45ddcbc8423892c).(ACKStatuscxx . . $ ACKStatus.); |
| 973 | PCECD_Drive_SetRSTcxx . . $ PCECD_Drive_SetRST(b45ddcbc8423892c).(_Portcxx . . $ _Port.[4] & 0x2); |
| 974 | |
| 975 | SubChannelFIFOcxx . . $ SubChannelFIFO..read_poscxx . . $ SimpleFIFO#read_pos. %= SubChannelFIFOcxx . . $ SubChannelFIFO..sizecxx . . $ SimpleFIFO#size.; |
| 976 | SubChannelFIFOcxx . . $ SubChannelFIFO..write_poscxx . . $ SimpleFIFO#write_pos. %= SubChannelFIFOcxx . . $ SubChannelFIFO..sizecxx . . $ SimpleFIFO#size.; |
| 977 | } |
| 978 | return(ret); |
| 979 | } |