| 1 | /* Mednafen - Multi-system Emulator |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | */ |
| 17 | |
| 18 | #include "../mednafen.h"cxx . . $ `<file>/mednafen/mednafen.h`/ |
| 19 | #include <math.h> |
| 20 | #include "pcecd_drive.h"cxx . . $ `<file>/mednafen/pce_fast/pcecd_drive.h`/ |
| 21 | #include "../cdrom/cdromif.h"cxx . . $ `<file>/mednafen/cdrom/cdromif.h`/ |
| 22 | #include "../cdrom/SimpleFIFO.h"cxx . . $ `<file>/mednafen/cdrom/SimpleFIFO.h`/ |
| 23 | #include "../msvc_compat.h"cxx . . $ `<file>/mednafen/msvc_compat.h`/ |
| 24 | |
| 25 | static inline void SCSIDBGcxx . . $ SCSIDBG(326aeb464d16410c).(const char *format, ...) |
| 26 | { |
| 27 | //printf("SCSI: " format "\n", ## __VA_ARGS__); |
| 28 | } |
| 29 | //#define SCSIDBG(format, ...) { } |
| 30 | |
| 31 | using namespace CDUtility; |
| 32 | |
| 33 | static uint32cxx . . $ uint32# CD_DATA_TRANSFER_RATEcxx . . $ CD_DATA_TRANSFER_RATE.; |
| 34 | static uint32cxx . . $ uint32# System_Clockcxx . . $ System_Clock.; |
| 35 | static void (*CDIRQCallbackcxx . . $ CDIRQCallback.)(int); |
| 36 | static void (*CDStuffSubchannelscxx . . $ CDStuffSubchannels.)(uint8cxx . . $ uint8#, int); |
| 37 | static Blip_Buffercxx . . $ Blip_Buffer# *sbufcxx . . $ sbuf.[2]; |
| 38 | static CDIFcxx . . $ CDIF# *Cur_CDIFcxx . . $ Cur_CDIF.; |
| 39 | |
| 40 | // Internal operation to the SCSI CD unit. Only pass 1 or 0 to these macros! |
| 41 | #define SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(mask, set) { cd_bus.signals &= ~mask; if(set) cd_bus.signals |= mask; } |
| 42 | |
| 43 | #define SetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:43:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_BSY_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:23:9`!, set) |
| 44 | #define SetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:44:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_IO_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:19:9`!, set) |
| 45 | #define SetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:45:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_CD_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:20:9`!, set) |
| 46 | #define SetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:46:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_MSG_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:21:9`!, set) |
| 47 | |
| 48 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(bool set) |
| 49 | { |
| 50 | if(set && !REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`!) |
| 51 | CDIRQCallbackcxx . . $ CDIRQCallback.(PCECD_Drive_IRQ_MAGICAL_REQcxx . . $ PCECD_Drive_IRQ_MAGICAL_REQ.); |
| 52 | |
| 53 | SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_REQ_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:22:9`!, set); |
| 54 | } |
| 55 | |
| 56 | #define SetkingACKcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:56:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_kingACK_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:27:9`!, set) |
| 57 | #define SetkingRSTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:57:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_kingRST_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:26:9`!, set) |
| 58 | #define SetkingSELcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:58:9`!(set) SetIOPcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:41:9`!(PCECD_Drive_kingSEL_maskcxx . . $ `mednafen/pce_fast/pcecd_drive.h:28:9`!, set) |
| 59 | |
| 60 | |
| 61 | enumcxx . . $ $anonymous_type_9dc09b8b7c986d6d_0# |
| 62 | { |
| 63 | QMode_Zerocxx . . $ QMode_Zero. = 0, |
| 64 | QMode_Timecxx . . $ QMode_Time. = 1, |
| 65 | QMode_MCNcxx . . $ QMode_MCN. = 2, // Media Catalog Number |
| 66 | QMode_ISRCcxx . . $ QMode_ISRC. = 3 // International Standard Recording Code |
| 67 | }; |
| 68 | |
| 69 | typedef structcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1# |
| 70 | { |
| 71 | bool last_RST_signalcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#last_RST_signal.; |
| 72 | |
| 73 | // The pending message to send(in the message phase) |
| 74 | uint8cxx . . $ uint8# message_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_pending.; |
| 75 | |
| 76 | bool status_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#status_sent., message_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_sent.; |
| 77 | |
| 78 | // Pending error codes |
| 79 | uint8cxx . . $ uint8# key_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#key_pending., asc_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#asc_pending., ascq_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#ascq_pending., fru_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#fru_pending.; |
| 80 | |
| 81 | uint8cxx . . $ uint8# command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[256]; |
| 82 | uint8cxx . . $ uint8# command_buffer_poscxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer_pos.; |
| 83 | uint8cxx . . $ uint8# command_size_leftcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_size_left.; |
| 84 | |
| 85 | // FALSE if not all pending data is in the FIFO, TRUE if it is. |
| 86 | // Used for multiple sector CD reads. |
| 87 | bool data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done.; |
| 88 | |
| 89 | bool TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen.; |
| 90 | bool DiscChangedcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#DiscChanged.; |
| 91 | |
| 92 | uint8cxx . . $ uint8# SubQBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf.[4][0xC]; // One for each of the 4 most recent q-Modes. |
| 93 | uint8cxx . . $ uint8# SubQBuf_Lastcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf_Last.[0xC]; // The most recent q subchannel data, regardless of q-mode. |
| 94 | |
| 95 | uint8cxx . . $ uint8# SubPWBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubPWBuf.[96]; |
| 96 | |
| 97 | } pcecd_drive_tcxx . . $ pcecd_drive_t#; |
| 98 | |
| 99 | typedef Blip_Synthcxx . . $ Blip_Synth# < blip_good_qualitycxx . . $ blip_good_quality., 1> CDSynthcxx . . $ CDSynth#; |
| 100 | |
| 101 | enumcxx . . $ $anonymous_type_9dc09b8b7c986d6d_2# |
| 102 | { |
| 103 | CDDASTATUS_PAUSEDcxx . . $ CDDASTATUS_PAUSED. = -1, |
| 104 | CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED. = 0, |
| 105 | CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING. = 1, |
| 106 | }; |
| 107 | |
| 108 | enumcxx . . $ $anonymous_type_9dc09b8b7c986d6d_3# |
| 109 | { |
| 110 | PLAYMODE_SILENTcxx . . $ PLAYMODE_SILENT. = 0x00, |
| 111 | PLAYMODE_NORMALcxx . . $ PLAYMODE_NORMAL., |
| 112 | PLAYMODE_INTERRUPTcxx . . $ PLAYMODE_INTERRUPT., |
| 113 | PLAYMODE_LOOPcxx . . $ PLAYMODE_LOOP., |
| 114 | }; |
| 115 | |
| 116 | typedef structcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4# |
| 117 | { |
| 118 | int32cxx . . $ int32# CDDADivAcccxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADivAcc.; |
| 119 | uint32cxx . . $ uint32# scan_sec_endcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#scan_sec_end.; |
| 120 | |
| 121 | uint8cxx . . $ uint8# PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode.; |
| 122 | CDSynthcxx . . $ CDSynth# CDDASynthcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASynth.; |
| 123 | int32cxx . . $ int32# CDDAVolumecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAVolume.; |
| 124 | int16cxx . . $ int16# last_samplecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#last_sample.[2]; |
| 125 | int16cxx . . $ int16# CDDASectorBuffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASectorBuffer.[1176]; |
| 126 | uint32cxx . . $ uint32# CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos.; |
| 127 | |
| 128 | int8cxx . . $ int8# CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus.; |
| 129 | uint8cxx . . $ uint8# ScanModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#ScanMode.; |
| 130 | int32cxx . . $ int32# CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv.; |
| 131 | int CDDATimeDivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDATimeDiv.; |
| 132 | } cdda_tcxx . . $ cdda_t#; |
| 133 | |
| 134 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void MakeSensecxx . . $ MakeSense(330792055c7de067).(uint8cxx . . $ uint8# target[18], uint8cxx . . $ uint8# key, uint8cxx . . $ uint8# asc, uint8cxx . . $ uint8# ascq, uint8cxx . . $ uint8# fru) |
| 135 | { |
| 136 | memset(target, 0, 18); |
| 137 | |
| 138 | target[0] = 0x70; // Current errors and sense data is not SCSI compliant |
| 139 | target[2] = key; |
| 140 | target[7] = 0x0A; |
| 141 | target[12] = asc; // Additional Sense Code |
| 142 | target[13] = ascq; // Additional Sense Code Qualifier |
| 143 | target[14] = fru; // Field Replaceable Unit code |
| 144 | } |
| 145 | |
| 146 | static void (*SCSILogcxx . . $ SCSILog.)(const char *, const char *format, ...); |
| 147 | |
| 148 | static pcecd_drive_timestamp_tcxx . . $ pcecd_drive_timestamp_t# lasttscxx . . $ lastts.; |
| 149 | static int64cxx . . $ int64# monotonic_timestampcxx . . $ monotonic_timestamp.; |
| 150 | static int64cxx . . $ int64# pce_lastsapsp_timestampcxx . . $ pce_lastsapsp_timestamp.; |
| 151 | |
| 152 | static pcecd_drive_tcxx . . $ pcecd_drive_t# cdcxx . . $ cd.; |
| 153 | pcecd_drive_bus_tcxx . . $ pcecd_drive_bus_t# cd_buscxx . . $ cd_bus.; |
| 154 | static cdda_tcxx . . $ cdda_t# cddacxx . . $ cdda.; |
| 155 | |
| 156 | static SimpleFIFOcxx . . $ SimpleFIFO#<uint8cxx . . $ uint8#> dincxx . . $ din.(2048); |
| 157 | |
| 158 | static CDUtilitycxx . . $ CDUtility/::TOCcxx . . $ CDUtility/TOC# toccxx . . $ toc.; |
| 159 | |
| 160 | static uint32cxx . . $ uint32# read_sec_startcxx . . $ read_sec_start.; |
| 161 | static uint32cxx . . $ uint32# read_seccxx . . $ read_sec.; |
| 162 | static uint32cxx . . $ uint32# read_sec_endcxx . . $ read_sec_end.; |
| 163 | |
| 164 | static int32cxx . . $ int32# CDReadTimercxx . . $ CDReadTimer.; |
| 165 | static uint32cxx . . $ uint32# SectorAddrcxx . . $ SectorAddr.; |
| 166 | static uint32cxx . . $ uint32# SectorCountcxx . . $ SectorCount.; |
| 167 | |
| 168 | |
| 169 | enumcxx . . $ $anonymous_type_9dc09b8b7c986d6d_5# |
| 170 | { |
| 171 | PHASE_BUS_FREEcxx . . $ PHASE_BUS_FREE. = 0, |
| 172 | PHASE_COMMANDcxx . . $ PHASE_COMMAND., |
| 173 | PHASE_DATA_INcxx . . $ PHASE_DATA_IN., |
| 174 | PHASE_STATUScxx . . $ PHASE_STATUS., |
| 175 | PHASE_MESSAGE_INcxx . . $ PHASE_MESSAGE_IN., |
| 176 | }; |
| 177 | |
| 178 | static unsigned int CurrentPhasecxx . . $ CurrentPhase.; |
| 179 | static void ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(const unsigned int new_phase); |
| 180 | |
| 181 | static void VirtualResetcxx . . $ VirtualReset(49f6e7a06ebc5aa8).(void) |
| 182 | { |
| 183 | dincxx . . $ din..Flushcxx . . $ SimpleFIFO#Flush(49f6e7a06ebc5aa8).(); |
| 184 | |
| 185 | cddacxx . . $ cdda..CDDADivAcccxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADivAcc. = (int64cxx . . $ int64#)System_Clockcxx . . $ System_Clock. * 65536 / 44100; |
| 186 | CDReadTimercxx . . $ CDReadTimer. = 0; |
| 187 | |
| 188 | pce_lastsapsp_timestampcxx . . $ pce_lastsapsp_timestamp. = monotonic_timestampcxx . . $ monotonic_timestamp.; |
| 189 | |
| 190 | SectorAddrcxx . . $ SectorAddr. = SectorCountcxx . . $ SectorCount. = 0; |
| 191 | read_sec_startcxx . . $ read_sec_start. = read_seccxx . . $ read_sec. = 0; |
| 192 | read_sec_endcxx . . $ read_sec_end. = ~0; |
| 193 | |
| 194 | cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_SILENTcxx . . $ PLAYMODE_SILENT.; |
| 195 | cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. = 0; |
| 196 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 197 | cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. = 0; |
| 198 | |
| 199 | cddacxx . . $ cdda..ScanModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#ScanMode. = 0; |
| 200 | cddacxx . . $ cdda..scan_sec_endcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#scan_sec_end. = 0; |
| 201 | |
| 202 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_BUS_FREEcxx . . $ PHASE_BUS_FREE.); |
| 203 | } |
| 204 | |
| 205 | void PCECD_Drive_Powercxx . . $ PCECD_Drive_Power(d4f767463ce0a6b3).(pcecd_drive_timestamp_tcxx . . $ pcecd_drive_timestamp_t# system_timestamp) |
| 206 | { |
| 207 | memset(&cdcxx . . $ cd., 0, sizeof(pcecd_drive_tcxx . . $ pcecd_drive_t#)); |
| 208 | memset(&cd_buscxx . . $ cd_bus., 0, sizeof(pcecd_drive_bus_tcxx . . $ pcecd_drive_bus_t#)); |
| 209 | |
| 210 | monotonic_timestampcxx . . $ monotonic_timestamp. = system_timestamp; |
| 211 | |
| 212 | cdcxx . . $ cd..DiscChangedcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#DiscChanged. = false; |
| 213 | |
| 214 | if(Cur_CDIFcxx . . $ Cur_CDIF. && !cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen.) |
| 215 | Cur_CDIFcxx . . $ Cur_CDIF.->ReadTOCcxx . . $ CDIF#ReadTOC(421bcafe44c737e9).(&toccxx . . $ toc.); |
| 216 | |
| 217 | CurrentPhasecxx . . $ CurrentPhase. = PHASE_BUS_FREEcxx . . $ PHASE_BUS_FREE.; |
| 218 | |
| 219 | VirtualResetcxx . . $ VirtualReset(49f6e7a06ebc5aa8).(); |
| 220 | } |
| 221 | |
| 222 | |
| 223 | void PCECD_Drive_SetDBcxx . . $ PCECD_Drive_SetDB(ac50b47256ae7414).(uint8cxx . . $ uint8# data) |
| 224 | { |
| 225 | cd_buscxx . . $ cd_bus..DBcxx . . $ pcecd_drive_bus_t#DB. = data; |
| 226 | //printf("Set DB: %02x\n", data); |
| 227 | } |
| 228 | |
| 229 | void PCECD_Drive_SetACKcxx . . $ PCECD_Drive_SetACK(b45ddcbc8423892c).(bool set) |
| 230 | { |
| 231 | SetkingACKcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:56:9`!(set); |
| 232 | //printf("Set ACK: %d\n", set); |
| 233 | } |
| 234 | |
| 235 | void PCECD_Drive_SetSELcxx . . $ PCECD_Drive_SetSEL(b45ddcbc8423892c).(bool set) |
| 236 | { |
| 237 | SetkingSELcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:58:9`!(set); |
| 238 | //printf("Set SEL: %d\n", set); |
| 239 | } |
| 240 | |
| 241 | void PCECD_Drive_SetRSTcxx . . $ PCECD_Drive_SetRST(b45ddcbc8423892c).(bool set) |
| 242 | { |
| 243 | SetkingRSTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:57:9`!(set); |
| 244 | //printf("Set RST: %d\n", set); |
| 245 | } |
| 246 | |
| 247 | static void GenSubQFromSubPWcxx . . $ GenSubQFromSubPW(49f6e7a06ebc5aa8).(void) |
| 248 | { |
| 249 | uint8cxx . . $ uint8# SubQBuf[0xC]; |
| 250 | |
| 251 | subq_deinterleavecxx . . $ CDUtility/subq_deinterleave(b1fdb6ced7ea43e9).(cdcxx . . $ cd..SubPWBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubPWBuf., SubQBuf); |
| 252 | |
| 253 | //printf("Real %d/ SubQ %d - ", read_sec, BCD_to_U8(SubQBuf[7]) * 75 * 60 + BCD_to_U8(SubQBuf[8]) * 75 + BCD_to_U8(SubQBuf[9]) - 150); |
| 254 | // Debug code, remove me. |
| 255 | //for(int i = 0; i < 0xC; i++) |
| 256 | // printf("%02x ", SubQBuf[i]); |
| 257 | //printf("\n"); |
| 258 | |
| 259 | if(!subq_check_checksumcxx . . $ CDUtility/subq_check_checksum(190063cf6fb4afb1).(SubQBuf)) |
| 260 | { |
| 261 | SCSIDBGcxx . . $ SCSIDBG(326aeb464d16410c).("SubQ checksum error!"); |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | memcpy(cdcxx . . $ cd..SubQBuf_Lastcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf_Last., SubQBuf, 0xC); |
| 266 | |
| 267 | uint8cxx . . $ uint8# adr = SubQBuf[0] & 0xF; |
| 268 | |
| 269 | if(adr <= 0x3) |
| 270 | memcpy(cdcxx . . $ cd..SubQBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf.[adr], SubQBuf, 0xC); |
| 271 | |
| 272 | //if(adr == 0x02) |
| 273 | //for(int i = 0; i < 12; i++) |
| 274 | // printf("%02x\n", cd.SubQBuf[0x2][i]); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | |
| 279 | #define STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`! 0 |
| 280 | #define STATUS_CHECK_CONDITIONcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:280:9`! 1 |
| 281 | |
| 282 | #define SENSEKEY_NO_SENSEcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:282:9`! 0x0 |
| 283 | #define SENSEKEY_NOT_READYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:283:9`! 0x2 |
| 284 | #define SENSEKEY_MEDIUM_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:284:9`! 0x3 |
| 285 | #define SENSEKEY_HARDWARE_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:285:9`! 0x4 |
| 286 | #define SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`! 0x5 |
| 287 | #define SENSEKEY_UNIT_ATTENTIONcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:287:9`! 0x6 |
| 288 | #define SENSEKEY_ABORTED_COMMANDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:288:9`! 0xB |
| 289 | |
| 290 | #define ASC_MEDIUM_NOT_PRESENTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:290:9`! 0x3A |
| 291 | |
| 292 | |
| 293 | // NEC sub-errors(ASC), no ASCQ. |
| 294 | #define NSE_NO_DISCcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:294:9`! 0x0B // Used with SENSEKEY_NOT_READY - This condition occurs when tray is closed with no disc present. |
| 295 | #define NSE_TRAY_OPENcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:295:9`! 0x0D // Used with SENSEKEY_NOT_READY |
| 296 | #define NSE_SEEK_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:296:9`! 0x15 |
| 297 | #define NSE_HEADER_READ_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:297:9`! 0x16 // Used with SENSEKEY_MEDIUM_ERROR |
| 298 | #define NSE_NOT_AUDIO_TRACKcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:298:9`! 0x1C // Used with SENSEKEY_MEDIUM_ERROR |
| 299 | #define NSE_NOT_DATA_TRACKcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:299:9`! 0x1D // Used with SENSEKEY_MEDIUM_ERROR |
| 300 | #define NSE_INVALID_COMMANDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:300:9`! 0x20 |
| 301 | #define NSE_INVALID_ADDRESScxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:301:9`! 0x21 |
| 302 | #define NSE_INVALID_PARAMETERcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:302:9`! 0x22 |
| 303 | #define NSE_END_OF_VOLUMEcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:303:9`! 0x25 |
| 304 | #define NSE_INVALID_REQUEST_IN_CDBcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:304:9`! 0x27 |
| 305 | #define NSE_DISC_CHANGEDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:305:9`! 0x28 // Used with SENSEKEY_UNIT_ATTENTION |
| 306 | #define NSE_AUDIO_NOT_PLAYINGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:306:9`! 0x2C |
| 307 | |
| 308 | // ASC, ASCQ pair |
| 309 | #define AP_UNRECOVERED_READ_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:309:9`! 0x11, 0x00 |
| 310 | #define AP_LEC_UNCORRECTABLE_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:310:9`! 0x11, 0x05 |
| 311 | #define AP_CIRC_UNRECOVERED_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:311:9`! 0x11, 0x06 |
| 312 | |
| 313 | #define AP_UNKNOWN_MEDIUM_FORMATcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:313:9`! 0x30, 0x01 |
| 314 | #define AP_INCOMPAT_MEDIUM_FORMATcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:314:9`! 0x30, 0x02 |
| 315 | |
| 316 | static void ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(const unsigned int new_phase) |
| 317 | { |
| 318 | //printf("New phase: %d %lld\n", new_phase, monotonic_timestamp); |
| 319 | switch(new_phase) |
| 320 | { |
| 321 | case PHASE_BUS_FREEcxx . . $ PHASE_BUS_FREE.: |
| 322 | SetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:43:9`!(false); |
| 323 | SetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:46:9`!(false); |
| 324 | SetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:45:9`!(false); |
| 325 | SetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:44:9`!(false); |
| 326 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(false); |
| 327 | |
| 328 | CDIRQCallbackcxx . . $ CDIRQCallback.(0x8000 | PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.); |
| 329 | break; |
| 330 | |
| 331 | case PHASE_DATA_INcxx . . $ PHASE_DATA_IN.: // Us to them |
| 332 | SetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:43:9`!(true); |
| 333 | SetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:46:9`!(false); |
| 334 | SetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:45:9`!(false); |
| 335 | SetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:44:9`!(true); |
| 336 | //SetREQ(true); |
| 337 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(false); |
| 338 | break; |
| 339 | |
| 340 | case PHASE_STATUScxx . . $ PHASE_STATUS.: // Us to them |
| 341 | SetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:43:9`!(true); |
| 342 | SetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:46:9`!(false); |
| 343 | SetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:45:9`!(true); |
| 344 | SetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:44:9`!(true); |
| 345 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(true); |
| 346 | break; |
| 347 | |
| 348 | case PHASE_MESSAGE_INcxx . . $ PHASE_MESSAGE_IN.: // Us to them |
| 349 | SetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:43:9`!(true); |
| 350 | SetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:46:9`!(true); |
| 351 | SetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:45:9`!(true); |
| 352 | SetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:44:9`!(true); |
| 353 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(true); |
| 354 | break; |
| 355 | |
| 356 | case PHASE_COMMANDcxx . . $ PHASE_COMMAND.: // Them to us |
| 357 | SetBSYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:43:9`!(true); |
| 358 | SetMSGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:46:9`!(false); |
| 359 | SetCDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:45:9`!(true); |
| 360 | SetIOcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:44:9`!(false); |
| 361 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(true); |
| 362 | break; |
| 363 | } |
| 364 | CurrentPhasecxx . . $ CurrentPhase. = new_phase; |
| 365 | } |
| 366 | |
| 367 | static void SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(uint8cxx . . $ uint8# status, uint8cxx . . $ uint8# message) |
| 368 | { |
| 369 | // This should never ever happen, but that doesn't mean it won't. ;) |
| 370 | if(dincxx . . $ din..CanReadcxx . . $ SimpleFIFO#CanRead(db52760e79bf9054).()) |
| 371 | { |
| 372 | printf("BUG: %d bytes still in SCSI CD FIFO\n", dincxx . . $ din..CanReadcxx . . $ SimpleFIFO#CanRead(db52760e79bf9054).()); |
| 373 | dincxx . . $ din..Flushcxx . . $ SimpleFIFO#Flush(49f6e7a06ebc5aa8).(); |
| 374 | } |
| 375 | |
| 376 | cdcxx . . $ cd..message_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_pending. = message; |
| 377 | |
| 378 | cdcxx . . $ cd..status_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#status_sent. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 379 | cdcxx . . $ cd..message_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_sent. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 380 | |
| 381 | |
| 382 | if(status == STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!) |
| 383 | cd_buscxx . . $ cd_bus..DBcxx . . $ pcecd_drive_bus_t#DB. = 0x00; |
| 384 | else |
| 385 | cd_buscxx . . $ cd_bus..DBcxx . . $ pcecd_drive_bus_t#DB. = 0x01; |
| 386 | |
| 387 | |
| 388 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_STATUScxx . . $ PHASE_STATUS.); |
| 389 | } |
| 390 | |
| 391 | static void DoSimpleDataIncxx . . $ DoSimpleDataIn(c3975586d4b99d3b).(const uint8cxx . . $ uint8# *data_in, uint32cxx . . $ uint32# len) |
| 392 | { |
| 393 | dincxx . . $ din..Writecxx . . $ SimpleFIFO#Write(9c56d35a43b4e338).(data_in, len); |
| 394 | |
| 395 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = true; |
| 396 | |
| 397 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_DATA_INcxx . . $ PHASE_DATA_IN.); |
| 398 | } |
| 399 | |
| 400 | void PCECD_Drive_SetDisccxx . . $ PCECD_Drive_SetDisc(d51decba753f8c21).(bool tray_open, CDIFcxx . . $ CDIF# *cdif, bool no_emu_side_effects) |
| 401 | { |
| 402 | Cur_CDIFcxx . . $ Cur_CDIF. = cdif; |
| 403 | |
| 404 | // Closing the tray. |
| 405 | if(cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen. && !tray_open) |
| 406 | { |
| 407 | cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen. = false; |
| 408 | |
| 409 | if(cdif) |
| 410 | { |
| 411 | cdif->ReadTOCcxx . . $ CDIF#ReadTOC(421bcafe44c737e9).(&toccxx . . $ toc.); |
| 412 | |
| 413 | if(!no_emu_side_effects) |
| 414 | { |
| 415 | memset(cdcxx . . $ cd..SubQBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf., 0, sizeof(cdcxx . . $ cd..SubQBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf.)); |
| 416 | memset(cdcxx . . $ cd..SubQBuf_Lastcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf_Last., 0, sizeof(cdcxx . . $ cd..SubQBuf_Lastcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf_Last.)); |
| 417 | cdcxx . . $ cd..DiscChangedcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#DiscChanged. = true; |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | else if(!cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen. && tray_open) // Opening the tray |
| 422 | { |
| 423 | cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen. = true; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | static void CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(int key, int asc = 0, int ascq = 0) |
| 428 | { |
| 429 | printf("CC Error: %02x %02x %02x\n", key, asc, ascq); |
| 430 | |
| 431 | cdcxx . . $ cd..key_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#key_pending. = key; |
| 432 | cdcxx . . $ cd..asc_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#asc_pending. = asc; |
| 433 | cdcxx . . $ cd..ascq_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#ascq_pending. = ascq; |
| 434 | cdcxx . . $ cd..fru_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#fru_pending. = 0x00; |
| 435 | |
| 436 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_CHECK_CONDITIONcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:280:9`!, 0x00); |
| 437 | } |
| 438 | |
| 439 | static bool ValidateRawDataSectorcxx . . $ ValidateRawDataSector(f3e7299796ab6c6f).(uint8cxx . . $ uint8# *data, const uint32cxx . . $ uint32# lba) |
| 440 | { |
| 441 | if(!edc_lec_check_and_correctcxx . . $ CDUtility/edc_lec_check_and_correct(ecc5f6bcf4eac26).(data, false)) |
| 442 | { |
| 443 | MDFN_DispMessagecxx . . $ MDFN_DispMessage(326aeb464d16410c).(_cxx . . $ `mednafen/mednafen.h:9:9`!("Uncorrectable data at sector %u"), lba); |
| 444 | MDFN_PrintErrorcxx . . $ MDFN_PrintError(326aeb464d16410c).(_cxx . . $ `mednafen/mednafen.h:9:9`!("Uncorrectable data at sector %u"), lba); |
| 445 | |
| 446 | dincxx . . $ din..Flushcxx . . $ SimpleFIFO#Flush(49f6e7a06ebc5aa8).(); |
| 447 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = false; |
| 448 | |
| 449 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_MEDIUM_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:284:9`!, AP_LEC_UNCORRECTABLE_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:310:9`!); |
| 450 | return(false); |
| 451 | } |
| 452 | |
| 453 | return(true); |
| 454 | } |
| 455 | |
| 456 | static void DoREADBasecxx . . $ DoREADBase(b4d55b1286ff73e8).(uint32cxx . . $ uint32# sa, uint32cxx . . $ uint32# sc) |
| 457 | { |
| 458 | if(sa > toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba.) // Another one of those off-by-one PC-FX CD bugs. |
| 459 | { |
| 460 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`!, NSE_END_OF_VOLUMEcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:303:9`!); |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | // Case for READ(10) and READ(12) where sc == 0, and sa == toc.tracks[100].lba |
| 465 | if(!sc && sa == toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba.) |
| 466 | { |
| 467 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_MEDIUM_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:284:9`!, NSE_HEADER_READ_ERRORcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:297:9`!); |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | if(SCSILogcxx . . $ SCSILog.) |
| 472 | { |
| 473 | int Track = toccxx . . $ toc..FindTrackByLBAcxx . . $ CDUtility/TOC#FindTrackByLBA(4c679297bf94b9eb).(sa); |
| 474 | uint32cxx . . $ uint32# Offset = sa - toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[Track].lbacxx . . $ CDUtility/TOC_Track#lba.; //Cur_CDIF->GetTrackStartPositionLBA(Track); |
| 475 | SCSILogcxx . . $ SCSILog.("SCSI", "Read: start=0x%08x(track=%d, offs=0x%08x), cnt=0x%08x", sa, Track, Offset, sc); |
| 476 | } |
| 477 | |
| 478 | SectorAddrcxx . . $ SectorAddr. = sa; |
| 479 | SectorCountcxx . . $ SectorCount. = sc; |
| 480 | if(SectorCountcxx . . $ SectorCount.) |
| 481 | { |
| 482 | Cur_CDIFcxx . . $ Cur_CDIF.->HintReadSectorcxx . . $ CDIF#HintReadSector(cb2f890c2fdad230).(sa); //, sa + sc); |
| 483 | |
| 484 | CDReadTimercxx . . $ CDReadTimer. = (uint64cxx . . $ uint64#)3 * 2048 * System_Clockcxx . . $ System_Clock. / CD_DATA_TRANSFER_RATEcxx . . $ CD_DATA_TRANSFER_RATE.; |
| 485 | } |
| 486 | else |
| 487 | { |
| 488 | CDReadTimercxx . . $ CDReadTimer. = 0; |
| 489 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 490 | } |
| 491 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 492 | } |
| 493 | |
| 494 | // |
| 495 | // |
| 496 | // |
| 497 | static void DoTESTUNITREADYcxx . . $ DoTESTUNITREADY(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 498 | { |
| 499 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 500 | } |
| 501 | |
| 502 | static void DoREQUESTSENSEcxx . . $ DoREQUESTSENSE(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 503 | { |
| 504 | uint8cxx . . $ uint8# data_in[18]; |
| 505 | |
| 506 | MakeSensecxx . . $ MakeSense(330792055c7de067).(data_in, cdcxx . . $ cd..key_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#key_pending., cdcxx . . $ cd..asc_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#asc_pending., cdcxx . . $ cd..ascq_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#ascq_pending., cdcxx . . $ cd..fru_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#fru_pending.); |
| 507 | |
| 508 | DoSimpleDataIncxx . . $ DoSimpleDataIn(c3975586d4b99d3b).(data_in, 18); |
| 509 | |
| 510 | cdcxx . . $ cd..key_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#key_pending. = 0; |
| 511 | cdcxx . . $ cd..asc_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#asc_pending. = 0; |
| 512 | cdcxx . . $ cd..ascq_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#ascq_pending. = 0; |
| 513 | cdcxx . . $ cd..fru_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#fru_pending. = 0; |
| 514 | } |
| 515 | |
| 516 | /******************************************************** |
| 517 | * * |
| 518 | * SCSI Command 0x08 - READ(6) * |
| 519 | * * |
| 520 | ********************************************************/ |
| 521 | static void DoREAD6cxx . . $ DoREAD6(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 522 | { |
| 523 | uint32cxx . . $ uint32# sa = ((cdb[1] & 0x1F) << 16) | (cdb[2] << 8) | (cdb[3] << 0); |
| 524 | uint32cxx . . $ uint32# sc = cdb[4]; |
| 525 | |
| 526 | // TODO: confirm real PCE does this(PC-FX does at least). |
| 527 | if(!sc) |
| 528 | { |
| 529 | SCSIDBGcxx . . $ SCSIDBG(326aeb464d16410c).("READ(6) with count == 0.\n"); |
| 530 | sc = 256; |
| 531 | } |
| 532 | |
| 533 | DoREADBasecxx . . $ DoREADBase(b4d55b1286ff73e8).(sa, sc); |
| 534 | } |
| 535 | |
| 536 | /******************************************************** |
| 537 | * * |
| 538 | * PC Engine CD Command 0xD8 - SAPSP * |
| 539 | * * |
| 540 | ********************************************************/ |
| 541 | static void DoNEC_PCE_SAPSPcxx . . $ DoNEC_PCE_SAPSP(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 542 | { |
| 543 | uint32cxx . . $ uint32# new_read_sec_start; |
| 544 | |
| 545 | //printf("Set audio start: %02x %02x %02x %02x %02x %02x %02x\n", cdb[9], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6]); |
| 546 | switch (cdb[9] & 0xc0) |
| 547 | { |
| 548 | default: SCSIDBGcxx . . $ SCSIDBG(326aeb464d16410c).("Unknown SAPSP 9: %02x\n", cdb[9]); |
| 549 | case 0x00: |
| 550 | new_read_sec_start = (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; |
| 551 | break; |
| 552 | |
| 553 | case 0x40: |
| 554 | new_read_sec_start = AMSF_to_LBAcxx . . $ CDUtility/AMSF_to_LBA(61bf41d5caea65af).(BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[2]), BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[3]), BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[4])); |
| 555 | break; |
| 556 | |
| 557 | case 0x80: |
| 558 | { |
| 559 | int track = BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[2]); |
| 560 | |
| 561 | if(!track) |
| 562 | track = 1; |
| 563 | else if(track >= toccxx . . $ toc..last_trackcxx . . $ CDUtility/TOC#last_track. + 1) |
| 564 | track = 100; |
| 565 | new_read_sec_start = toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[track].lbacxx . . $ CDUtility/TOC_Track#lba.; |
| 566 | } |
| 567 | break; |
| 568 | } |
| 569 | |
| 570 | //printf("%lld\n", (long long)(monotonic_timestamp - pce_lastsapsp_timestamp) * 1000 / System_Clock); |
| 571 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. == CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING. && new_read_sec_start == read_sec_startcxx . . $ read_sec_start. && ((int64cxx . . $ int64#)(monotonic_timestampcxx . . $ monotonic_timestamp. - pce_lastsapsp_timestampcxx . . $ pce_lastsapsp_timestamp.) * 1000 / System_Clockcxx . . $ System_Clock.) < 190) |
| 572 | { |
| 573 | pce_lastsapsp_timestampcxx . . $ pce_lastsapsp_timestamp. = monotonic_timestampcxx . . $ monotonic_timestamp.; |
| 574 | |
| 575 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 576 | CDIRQCallbackcxx . . $ CDIRQCallback.(PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.); |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | pce_lastsapsp_timestampcxx . . $ pce_lastsapsp_timestamp. = monotonic_timestampcxx . . $ monotonic_timestamp.; |
| 581 | |
| 582 | read_seccxx . . $ read_sec. = read_sec_startcxx . . $ read_sec_start. = new_read_sec_start; |
| 583 | read_sec_endcxx . . $ read_sec_end. = toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba.; |
| 584 | |
| 585 | |
| 586 | cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. = 588; |
| 587 | |
| 588 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_PAUSEDcxx . . $ CDDASTATUS_PAUSED.; |
| 589 | cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_SILENTcxx . . $ PLAYMODE_SILENT.; |
| 590 | |
| 591 | if(cdb[1]) |
| 592 | { |
| 593 | cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_NORMALcxx . . $ PLAYMODE_NORMAL.; |
| 594 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.; |
| 595 | } |
| 596 | |
| 597 | if(read_seccxx . . $ read_sec. < toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba.) |
| 598 | Cur_CDIFcxx . . $ Cur_CDIF.->HintReadSectorcxx . . $ CDIF#HintReadSector(cb2f890c2fdad230).(read_seccxx . . $ read_sec.); |
| 599 | |
| 600 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 601 | CDIRQCallbackcxx . . $ CDIRQCallback.(PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.); |
| 602 | } |
| 603 | |
| 604 | |
| 605 | |
| 606 | /******************************************************** |
| 607 | * * |
| 608 | * PC Engine CD Command 0xD9 - SAPEP * |
| 609 | * * |
| 610 | ********************************************************/ |
| 611 | static void DoNEC_PCE_SAPEPcxx . . $ DoNEC_PCE_SAPEP(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 612 | { |
| 613 | uint32cxx . . $ uint32# new_read_sec_end; |
| 614 | |
| 615 | //printf("Set audio end: %02x %02x %02x %02x %02x %02x %02x\n", cdb[9], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6]); |
| 616 | |
| 617 | switch (cdb[9] & 0xc0) |
| 618 | { |
| 619 | default: SCSIDBGcxx . . $ SCSIDBG(326aeb464d16410c).("Unknown SAPEP 9: %02x\n", cdb[9]); |
| 620 | |
| 621 | case 0x00: |
| 622 | new_read_sec_end = (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; |
| 623 | break; |
| 624 | |
| 625 | case 0x40: |
| 626 | new_read_sec_end = BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[4]) + 75 * (BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[3]) + 60 * BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[2])); |
| 627 | new_read_sec_end -= 150; |
| 628 | break; |
| 629 | |
| 630 | case 0x80: |
| 631 | { |
| 632 | int track = BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[2]); |
| 633 | |
| 634 | if(!track) |
| 635 | track = 1; |
| 636 | else if(track >= toccxx . . $ toc..last_trackcxx . . $ CDUtility/TOC#last_track. + 1) |
| 637 | track = 100; |
| 638 | new_read_sec_end = toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[track].lbacxx . . $ CDUtility/TOC_Track#lba.; |
| 639 | } |
| 640 | break; |
| 641 | } |
| 642 | |
| 643 | read_sec_endcxx . . $ read_sec_end. = new_read_sec_end; |
| 644 | |
| 645 | switch(cdb[1]) // PCE CD(TODO: Confirm these, and check the mode mask): |
| 646 | { |
| 647 | default: |
| 648 | case 0x03: cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_NORMALcxx . . $ PLAYMODE_NORMAL.; |
| 649 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.; |
| 650 | break; |
| 651 | |
| 652 | case 0x02: cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_INTERRUPTcxx . . $ PLAYMODE_INTERRUPT.; |
| 653 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.; |
| 654 | break; |
| 655 | |
| 656 | case 0x01: cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_LOOPcxx . . $ PLAYMODE_LOOP.; |
| 657 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.; |
| 658 | break; |
| 659 | |
| 660 | case 0x00: cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. = PLAYMODE_SILENTcxx . . $ PLAYMODE_SILENT.; |
| 661 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 662 | break; |
| 663 | } |
| 664 | |
| 665 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 666 | } |
| 667 | |
| 668 | |
| 669 | |
| 670 | /******************************************************** |
| 671 | * * |
| 672 | * PC Engine CD Command 0xDA - Pause * |
| 673 | * * |
| 674 | ********************************************************/ |
| 675 | static void DoNEC_PCE_PAUSEcxx . . $ DoNEC_PCE_PAUSE(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 676 | { |
| 677 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. != CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.) // Hmm, should we give an error if it tries to pause and it's already paused? |
| 678 | { |
| 679 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_PAUSEDcxx . . $ CDDASTATUS_PAUSED.; |
| 680 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 681 | } |
| 682 | else // Definitely give an error if it tries to pause when no track is playing! |
| 683 | { |
| 684 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`!, NSE_AUDIO_NOT_PLAYINGcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:306:9`!); |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | |
| 689 | |
| 690 | /******************************************************** |
| 691 | * * |
| 692 | * PC Engine CD Command 0xDD - Read Subchannel Q * |
| 693 | * * |
| 694 | ********************************************************/ |
| 695 | static void DoNEC_PCE_READSUBQcxx . . $ DoNEC_PCE_READSUBQ(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 696 | { |
| 697 | uint8cxx . . $ uint8# *SubQBuf = cdcxx . . $ cd..SubQBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf.[QMode_Timecxx . . $ QMode_Time.]; |
| 698 | uint8cxx . . $ uint8# data_in[8192]; |
| 699 | |
| 700 | memset(data_in, 0x00, 10); |
| 701 | |
| 702 | data_in[2] = SubQBuf[1]; // Track |
| 703 | data_in[3] = SubQBuf[2]; // Index |
| 704 | data_in[4] = SubQBuf[3]; // M(rel) |
| 705 | data_in[5] = SubQBuf[4]; // S(rel) |
| 706 | data_in[6] = SubQBuf[5]; // F(rel) |
| 707 | data_in[7] = SubQBuf[7]; // M(abs) |
| 708 | data_in[8] = SubQBuf[8]; // S(abs) |
| 709 | data_in[9] = SubQBuf[9]; // F(abs) |
| 710 | |
| 711 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. == CDDASTATUS_PAUSEDcxx . . $ CDDASTATUS_PAUSED.) |
| 712 | data_in[0] = 2; // Pause |
| 713 | else if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. == CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.) |
| 714 | data_in[0] = 0; // Playing |
| 715 | else |
| 716 | data_in[0] = 3; // Stopped |
| 717 | |
| 718 | DoSimpleDataIncxx . . $ DoSimpleDataIn(c3975586d4b99d3b).(data_in, 10); |
| 719 | } |
| 720 | |
| 721 | |
| 722 | |
| 723 | /******************************************************** |
| 724 | * * |
| 725 | * PC Engine CD Command 0xDE - Get Directory Info * |
| 726 | * * |
| 727 | ********************************************************/ |
| 728 | static void DoNEC_PCE_GETDIRINFOcxx . . $ DoNEC_PCE_GETDIRINFO(28caea9380bfac8a).(const uint8cxx . . $ uint8# *cdb) |
| 729 | { |
| 730 | // Problems: |
| 731 | // Returned data lengths on real PCE are not confirmed. |
| 732 | // Mode 0x03 behavior not tested on real PCE |
| 733 | |
| 734 | uint8cxx . . $ uint8# data_in[2048]; |
| 735 | uint32cxx . . $ uint32# data_in_size = 0; |
| 736 | |
| 737 | memset(data_in, 0, sizeof(data_in)); |
| 738 | |
| 739 | switch(cdb[1]) |
| 740 | { |
| 741 | default: MDFN_DispMessagecxx . . $ MDFN_DispMessage(326aeb464d16410c).("Unknown GETDIRINFO Mode: %02x", cdb[1]); |
| 742 | printf("Unknown GETDIRINFO Mode: %02x", cdb[1]); |
| 743 | case 0x0: |
| 744 | data_in[0] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(toccxx . . $ toc..first_trackcxx . . $ CDUtility/TOC#first_track.); |
| 745 | data_in[1] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(toccxx . . $ toc..last_trackcxx . . $ CDUtility/TOC#last_track.); |
| 746 | |
| 747 | data_in_size = 2; |
| 748 | break; |
| 749 | |
| 750 | case 0x1: |
| 751 | { |
| 752 | uint8cxx . . $ uint8# m, s, f; |
| 753 | |
| 754 | LBA_to_AMSFcxx . . $ CDUtility/LBA_to_AMSF(e84e8f147c6dbba1).(toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba., &m, &s, &f); |
| 755 | |
| 756 | data_in[0] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(m); |
| 757 | data_in[1] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(s); |
| 758 | data_in[2] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(f); |
| 759 | |
| 760 | data_in_size = 3; |
| 761 | } |
| 762 | break; |
| 763 | |
| 764 | case 0x2: |
| 765 | { |
| 766 | uint8cxx . . $ uint8# m, s, f; |
| 767 | int track = BCD_to_U8cxx . . $ CDUtility/BCD_to_U8(50106d451684defa).(cdb[2]); |
| 768 | |
| 769 | if(!track) |
| 770 | track = 1; |
| 771 | else if(cdb[2] == 0xAA) |
| 772 | { |
| 773 | track = 100; |
| 774 | } |
| 775 | else if(track > 99) |
| 776 | { |
| 777 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`!, NSE_INVALID_PARAMETERcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:302:9`!); |
| 778 | return; |
| 779 | } |
| 780 | |
| 781 | LBA_to_AMSFcxx . . $ CDUtility/LBA_to_AMSF(e84e8f147c6dbba1).(toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[track].lbacxx . . $ CDUtility/TOC_Track#lba., &m, &s, &f); |
| 782 | |
| 783 | data_in[0] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(m); |
| 784 | data_in[1] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(s); |
| 785 | data_in[2] = U8_to_BCDcxx . . $ CDUtility/U8_to_BCD(50106d451684defa).(f); |
| 786 | data_in[3] = toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[track].controlcxx . . $ CDUtility/TOC_Track#control.; |
| 787 | data_in_size = 4; |
| 788 | } |
| 789 | break; |
| 790 | } |
| 791 | |
| 792 | DoSimpleDataIncxx . . $ DoSimpleDataIn(c3975586d4b99d3b).(data_in, data_in_size); |
| 793 | } |
| 794 | |
| 795 | #define SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`! 0x01 |
| 796 | |
| 797 | typedef structcxx . . $ $anonymous_type_9dc09b8b7c986d6d_6# |
| 798 | { |
| 799 | uint8cxx . . $ uint8# cmdcxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#cmd.; |
| 800 | uint8cxx . . $ uint8# flagscxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#flags.; |
| 801 | void (*funccxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#func.)(const uint8cxx . . $ uint8# *cdb); |
| 802 | const char *pretty_namecxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#pretty_name.; |
| 803 | const char *format_stringcxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#format_string.; |
| 804 | } SCSICHcxx . . $ SCSICH#; |
| 805 | |
| 806 | static const uint8cxx . . $ uint8# RequiredCDBLencxx . . $ RequiredCDBLen.[16] = |
| 807 | { |
| 808 | 6, // 0x0n |
| 809 | 6, // 0x1n |
| 810 | 10, // 0x2n |
| 811 | 10, // 0x3n |
| 812 | 10, // 0x4n |
| 813 | 10, // 0x5n |
| 814 | 10, // 0x6n |
| 815 | 10, // 0x7n |
| 816 | 10, // 0x8n |
| 817 | 10, // 0x9n |
| 818 | 12, // 0xAn |
| 819 | 12, // 0xBn |
| 820 | 10, // 0xCn |
| 821 | 10, // 0xDn |
| 822 | 10, // 0xEn |
| 823 | 10, // 0xFn |
| 824 | }; |
| 825 | |
| 826 | static SCSICHcxx . . $ SCSICH# PCECommandDefscxx . . $ PCECommandDefs.[] = |
| 827 | { |
| 828 | { 0x00, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoTESTUNITREADYcxx . . $ DoTESTUNITREADY(28caea9380bfac8a)., "Test Unit Ready" }, |
| 829 | { 0x03, 0, DoREQUESTSENSEcxx . . $ DoREQUESTSENSE(28caea9380bfac8a)., "Request Sense" }, |
| 830 | { 0x08, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoREAD6cxx . . $ DoREAD6(28caea9380bfac8a)., "Read(6)" }, |
| 831 | |
| 832 | { 0xD8, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoNEC_PCE_SAPSPcxx . . $ DoNEC_PCE_SAPSP(28caea9380bfac8a)., "Set Audio Playback Start Position" }, |
| 833 | { 0xD9, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoNEC_PCE_SAPEPcxx . . $ DoNEC_PCE_SAPEP(28caea9380bfac8a)., "Set Audio Playback End Position" }, |
| 834 | { 0xDA, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoNEC_PCE_PAUSEcxx . . $ DoNEC_PCE_PAUSE(28caea9380bfac8a)., "Pause" }, |
| 835 | { 0xDD, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoNEC_PCE_READSUBQcxx . . $ DoNEC_PCE_READSUBQ(28caea9380bfac8a)., "Read Subchannel Q" }, |
| 836 | { 0xDE, SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!, DoNEC_PCE_GETDIRINFOcxx . . $ DoNEC_PCE_GETDIRINFO(28caea9380bfac8a)., "Get Dir Info" }, |
| 837 | |
| 838 | { 0xFF, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 839 | }; |
| 840 | |
| 841 | void PCECD_Drive_ResetTScxx . . $ PCECD_Drive_ResetTS(49f6e7a06ebc5aa8).(void) |
| 842 | { |
| 843 | lasttscxx . . $ lastts. = 0; |
| 844 | } |
| 845 | |
| 846 | void PCECD_Drive_GetCDDAValuescxx . . $ PCECD_Drive_GetCDDAValues(a68af88c52dba8c4).(int16cxx . . $ int16# &left, int16cxx . . $ int16# &right) |
| 847 | { |
| 848 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus.) |
| 849 | { |
| 850 | left = cddacxx . . $ cdda..CDDASectorBuffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASectorBuffer.[cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. * 2]; |
| 851 | right = cddacxx . . $ cdda..CDDASectorBuffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASectorBuffer.[cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. * 2 + 1]; |
| 852 | } |
| 853 | else |
| 854 | left = right = 0; |
| 855 | } |
| 856 | |
| 857 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void RunCDDAcxx . . $ RunCDDA(3d89109e85ced1be).(uint32cxx . . $ uint32# system_timestamp, int32cxx . . $ int32# run_time) |
| 858 | { |
| 859 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. == CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.) |
| 860 | { |
| 861 | int32cxx . . $ int32# sample[2]; |
| 862 | |
| 863 | cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. -= run_time << 16; |
| 864 | |
| 865 | while(cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. <= 0) |
| 866 | { |
| 867 | const uint32cxx . . $ uint32# synthtime = ((system_timestamp + (cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. >> 16))) / cddacxx . . $ cdda..CDDATimeDivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDATimeDiv.; |
| 868 | |
| 869 | cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. += cddacxx . . $ cdda..CDDADivAcccxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADivAcc.; |
| 870 | |
| 871 | //MDFN_DispMessage("%d %d %d\n", read_sec_start, read_sec, read_sec_end); |
| 872 | |
| 873 | if(cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. == 588) |
| 874 | { |
| 875 | if(read_seccxx . . $ read_sec. >= read_sec_endcxx . . $ read_sec_end.) |
| 876 | { |
| 877 | switch(cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode.) |
| 878 | { |
| 879 | case PLAYMODE_SILENTcxx . . $ PLAYMODE_SILENT.: |
| 880 | case PLAYMODE_NORMALcxx . . $ PLAYMODE_NORMAL.: |
| 881 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 882 | break; |
| 883 | |
| 884 | case PLAYMODE_INTERRUPTcxx . . $ PLAYMODE_INTERRUPT.: |
| 885 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 886 | CDIRQCallbackcxx . . $ CDIRQCallback.(PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.); |
| 887 | break; |
| 888 | |
| 889 | case PLAYMODE_LOOPcxx . . $ PLAYMODE_LOOP.: |
| 890 | read_seccxx . . $ read_sec. = read_sec_startcxx . . $ read_sec_start.; |
| 891 | break; |
| 892 | } |
| 893 | |
| 894 | // If CDDA playback is stopped, break out of our while(CDDADiv ...) loop and don't play any more sound! |
| 895 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. == CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.) |
| 896 | break; |
| 897 | } |
| 898 | |
| 899 | // Don't play past the user area of the disc. |
| 900 | if(read_seccxx . . $ read_sec. >= toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba.) |
| 901 | { |
| 902 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 903 | break; |
| 904 | } |
| 905 | |
| 906 | if(cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen.) |
| 907 | { |
| 908 | cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. = CDDASTATUS_STOPPEDcxx . . $ CDDASTATUS_STOPPED.; |
| 909 | |
| 910 | #if 0 |
| 911 | cd.data_transfer_done = FALSE; |
| 912 | cd.key_pending = SENSEKEY_NOT_READY; |
| 913 | cd.asc_pending = ASC_MEDIUM_NOT_PRESENT; |
| 914 | cd.ascq_pending = 0x00; |
| 915 | cd.fru_pending = 0x00; |
| 916 | SendStatusAndMessage(STATUS_CHECK_CONDITION, 0x00); |
| 917 | #endif |
| 918 | |
| 919 | break; |
| 920 | } |
| 921 | |
| 922 | |
| 923 | cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. = 0; |
| 924 | |
| 925 | { |
| 926 | uint8cxx . . $ uint8# tmpbuf[2352 + 96]; |
| 927 | |
| 928 | Cur_CDIFcxx . . $ Cur_CDIF.->ReadRawSectorcxx . . $ CDIF#ReadRawSector(f3e7299796ab6c6f).(tmpbuf, read_seccxx . . $ read_sec.); //, read_sec_end, read_sec_start); |
| 929 | |
| 930 | for(int i = 0; i < 588 * 2; i++) |
| 931 | cddacxx . . $ cdda..CDDASectorBuffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASectorBuffer.[i] = MDFN_de16lsb(&tmpbuf[i * 2]); |
| 932 | |
| 933 | memcpy(cdcxx . . $ cd..SubPWBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubPWBuf., tmpbuf + 2352, 96); |
| 934 | } |
| 935 | GenSubQFromSubPWcxx . . $ GenSubQFromSubPW(49f6e7a06ebc5aa8).(); |
| 936 | read_seccxx . . $ read_sec.++; |
| 937 | } // End if(CDDAReadPos == 588) |
| 938 | |
| 939 | // If the last valid sub-Q data decoded indicate that the corresponding sector is a data sector, don't output the |
| 940 | // current sector as audio. |
| 941 | sample[0] = sample[1] = 0; |
| 942 | |
| 943 | if(!(cdcxx . . $ cd..SubQBuf_Lastcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubQBuf_Last.[0] & 0x40) && cddacxx . . $ cdda..PlayModecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#PlayMode. != PLAYMODE_SILENTcxx . . $ PLAYMODE_SILENT.) |
| 944 | { |
| 945 | sample[0] = (cddacxx . . $ cdda..CDDASectorBuffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASectorBuffer.[cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. * 2 + 0] * cddacxx . . $ cdda..CDDAVolumecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAVolume.) >> 16; |
| 946 | sample[1] = (cddacxx . . $ cdda..CDDASectorBuffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASectorBuffer.[cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. * 2 + 1] * cddacxx . . $ cdda..CDDAVolumecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAVolume.) >> 16; |
| 947 | } |
| 948 | |
| 949 | if(!(cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. % 6)) |
| 950 | { |
| 951 | int subindex = cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos. / 6 - 2; |
| 952 | |
| 953 | if(subindex >= 0) |
| 954 | CDStuffSubchannelscxx . . $ CDStuffSubchannels.(cdcxx . . $ cd..SubPWBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubPWBuf.[subindex], subindex); |
| 955 | else // The system-specific emulation code should handle what value the sync bytes are. |
| 956 | CDStuffSubchannelscxx . . $ CDStuffSubchannels.(0x00, subindex); |
| 957 | } |
| 958 | |
| 959 | if(sbufcxx . . $ sbuf.[0] && sbufcxx . . $ sbuf.[1]) |
| 960 | { |
| 961 | cddacxx . . $ cdda..CDDASynthcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASynth..offset_inlinecxx . . $ Blip_Synth#offset_inline(90077ce6337795eb).(synthtime, sample[0] - cddacxx . . $ cdda..last_samplecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#last_sample.[0], sbufcxx . . $ sbuf.[0]); |
| 962 | cddacxx . . $ cdda..CDDASynthcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASynth..offset_inlinecxx . . $ Blip_Synth#offset_inline(90077ce6337795eb).(synthtime, sample[1] - cddacxx . . $ cdda..last_samplecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#last_sample.[1], sbufcxx . . $ sbuf.[1]); |
| 963 | } |
| 964 | |
| 965 | cddacxx . . $ cdda..last_samplecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#last_sample.[0] = sample[0]; |
| 966 | cddacxx . . $ cdda..last_samplecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#last_sample.[1] = sample[1]; |
| 967 | |
| 968 | cddacxx . . $ cdda..CDDAReadPoscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAReadPos.++; |
| 969 | } |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | static INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void RunCDReadcxx . . $ RunCDRead(3d89109e85ced1be).(uint32cxx . . $ uint32# system_timestamp, int32cxx . . $ int32# run_time) |
| 974 | { |
| 975 | if(CDReadTimercxx . . $ CDReadTimer. > 0) |
| 976 | { |
| 977 | CDReadTimercxx . . $ CDReadTimer. -= run_time; |
| 978 | |
| 979 | if(CDReadTimercxx . . $ CDReadTimer. <= 0) |
| 980 | { |
| 981 | if(dincxx . . $ din..CanWritecxx . . $ SimpleFIFO#CanWrite(db52760e79bf9054).() < 2048) |
| 982 | { |
| 983 | //printf("Carp: %d %d %d\n", din.CanWrite(), SectorCount, CDReadTimer); |
| 984 | //CDReadTimer = (cd.data_in_size - cd.data_in_pos) * 10; |
| 985 | |
| 986 | CDReadTimercxx . . $ CDReadTimer. += (uint64cxx . . $ uint64#) 1 * 2048 * System_Clockcxx . . $ System_Clock. / CD_DATA_TRANSFER_RATEcxx . . $ CD_DATA_TRANSFER_RATE.; |
| 987 | |
| 988 | //CDReadTimer += (uint64) 1 * 128 * System_Clock / CD_DATA_TRANSFER_RATE; |
| 989 | } |
| 990 | else |
| 991 | { |
| 992 | uint8cxx . . $ uint8# tmp_read_buf[2352 + 96]; |
| 993 | |
| 994 | if(cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen.) |
| 995 | { |
| 996 | dincxx . . $ din..Flushcxx . . $ SimpleFIFO#Flush(49f6e7a06ebc5aa8).(); |
| 997 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 998 | |
| 999 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_NOT_READYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:283:9`!, NSE_TRAY_OPENcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:295:9`!); |
| 1000 | } |
| 1001 | else if(SectorAddrcxx . . $ SectorAddr. >= toccxx . . $ toc..trackscxx . . $ CDUtility/TOC#tracks.[100].lbacxx . . $ CDUtility/TOC_Track#lba.) |
| 1002 | { |
| 1003 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`!, NSE_END_OF_VOLUMEcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:303:9`!); |
| 1004 | } |
| 1005 | else if(!Cur_CDIFcxx . . $ Cur_CDIF.->ReadRawSectorcxx . . $ CDIF#ReadRawSector(f3e7299796ab6c6f).(tmp_read_buf, SectorAddrcxx . . $ SectorAddr.)) //, SectorAddr + SectorCount)) |
| 1006 | { |
| 1007 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 1008 | |
| 1009 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`!); |
| 1010 | } |
| 1011 | else if(ValidateRawDataSectorcxx . . $ ValidateRawDataSector(f3e7299796ab6c6f).(tmp_read_buf, SectorAddrcxx . . $ SectorAddr.)) |
| 1012 | { |
| 1013 | memcpy(cdcxx . . $ cd..SubPWBufcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#SubPWBuf., tmp_read_buf + 2352, 96); |
| 1014 | |
| 1015 | if(tmp_read_buf[12 + 3] == 0x2) |
| 1016 | dincxx . . $ din..Writecxx . . $ SimpleFIFO#Write(9c56d35a43b4e338).(tmp_read_buf + 24, 2048); |
| 1017 | else |
| 1018 | dincxx . . $ din..Writecxx . . $ SimpleFIFO#Write(9c56d35a43b4e338).(tmp_read_buf + 16, 2048); |
| 1019 | |
| 1020 | GenSubQFromSubPWcxx . . $ GenSubQFromSubPW(49f6e7a06ebc5aa8).(); |
| 1021 | |
| 1022 | CDIRQCallbackcxx . . $ CDIRQCallback.(PCECD_Drive_IRQ_DATA_TRANSFER_READYcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_READY.); |
| 1023 | |
| 1024 | SectorAddrcxx . . $ SectorAddr.++; |
| 1025 | SectorCountcxx . . $ SectorCount.--; |
| 1026 | |
| 1027 | if(CurrentPhasecxx . . $ CurrentPhase. != PHASE_DATA_INcxx . . $ PHASE_DATA_IN.) |
| 1028 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_DATA_INcxx . . $ PHASE_DATA_IN.); |
| 1029 | |
| 1030 | if(SectorCountcxx . . $ SectorCount.) |
| 1031 | { |
| 1032 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 1033 | CDReadTimercxx . . $ CDReadTimer. += (uint64cxx . . $ uint64#) 1 * 2048 * System_Clockcxx . . $ System_Clock. / CD_DATA_TRANSFER_RATEcxx . . $ CD_DATA_TRANSFER_RATE.; |
| 1034 | } |
| 1035 | else |
| 1036 | { |
| 1037 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!; |
| 1038 | } |
| 1039 | } |
| 1040 | } // end else to if(!Cur_CDIF->ReadSector |
| 1041 | |
| 1042 | } |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | |
| 1047 | uint32cxx . . $ uint32# PCECD_Drive_Runcxx . . $ PCECD_Drive_Run(46cc46841198e427).(pcecd_drive_timestamp_tcxx . . $ pcecd_drive_timestamp_t# system_timestamp) |
| 1048 | { |
| 1049 | int32cxx . . $ int32# run_time = system_timestamp - lasttscxx . . $ lastts.; |
| 1050 | |
| 1051 | if(system_timestamp < lasttscxx . . $ lastts.) |
| 1052 | { |
| 1053 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Meow: %d %d\n", system_timestamp, lasttscxx . . $ lastts.); |
| 1054 | assertcxx . . $ `/usr/include/assert.h:102:11`!(system_timestamp >= lastts); |
| 1055 | } |
| 1056 | |
| 1057 | monotonic_timestampcxx . . $ monotonic_timestamp. += run_time; |
| 1058 | |
| 1059 | lasttscxx . . $ lastts. = system_timestamp; |
| 1060 | |
| 1061 | RunCDReadcxx . . $ RunCDRead(3d89109e85ced1be).(system_timestamp, run_time); |
| 1062 | RunCDDAcxx . . $ RunCDDA(3d89109e85ced1be).(system_timestamp, run_time); |
| 1063 | |
| 1064 | bool ResetNeeded = false; |
| 1065 | |
| 1066 | if(RST_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:32:9`! && !cdcxx . . $ cd..last_RST_signalcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#last_RST_signal.) |
| 1067 | ResetNeeded = true; |
| 1068 | |
| 1069 | cdcxx . . $ cd..last_RST_signalcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#last_RST_signal. = RST_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:32:9`!; |
| 1070 | |
| 1071 | if(ResetNeeded) |
| 1072 | { |
| 1073 | //puts("RST"); |
| 1074 | VirtualResetcxx . . $ VirtualReset(49f6e7a06ebc5aa8).(); |
| 1075 | } |
| 1076 | else switch(CurrentPhasecxx . . $ CurrentPhase.) |
| 1077 | { |
| 1078 | case PHASE_BUS_FREEcxx . . $ PHASE_BUS_FREE.: |
| 1079 | if(SEL_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:34:9`!) |
| 1080 | { |
| 1081 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_COMMANDcxx . . $ PHASE_COMMAND.); |
| 1082 | } |
| 1083 | break; |
| 1084 | |
| 1085 | case PHASE_COMMANDcxx . . $ PHASE_COMMAND.: |
| 1086 | if(REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`!) // Data bus is valid nowww |
| 1087 | { |
| 1088 | //printf("Command Phase Byte I->T: %02x, %d\n", cd_bus.DB, cd.command_buffer_pos); |
| 1089 | cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[cdcxx . . $ cd..command_buffer_poscxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer_pos.++] = cd_buscxx . . $ cd_bus..DBcxx . . $ pcecd_drive_bus_t#DB.; |
| 1090 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!); |
| 1091 | } |
| 1092 | |
| 1093 | if(!REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && !ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`! && cdcxx . . $ cd..command_buffer_poscxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer_pos.) // Received at least one byte, what should we do? |
| 1094 | { |
| 1095 | if(cdcxx . . $ cd..command_buffer_poscxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer_pos. == RequiredCDBLencxx . . $ RequiredCDBLen.[cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[0] >> 4]) |
| 1096 | { |
| 1097 | const SCSICHcxx . . $ SCSICH#* cmd_info_ptr = PCECommandDefscxx . . $ PCECommandDefs.; |
| 1098 | |
| 1099 | while(cmd_info_ptr->pretty_namecxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#pretty_name. && cmd_info_ptr->cmdcxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#cmd. != cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[0]) |
| 1100 | cmd_info_ptr++; |
| 1101 | |
| 1102 | if(SCSILogcxx . . $ SCSILog.) |
| 1103 | { |
| 1104 | char log_buffer[1024]; |
| 1105 | int lb_pos; |
| 1106 | |
| 1107 | log_buffer[0] = 0; |
| 1108 | |
| 1109 | lb_pos = snprintf(log_buffer, 1024, "Command: %02x, %s ", cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[0], cmd_info_ptr->pretty_namecxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#pretty_name. ? cmd_info_ptr->pretty_namecxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#pretty_name. : "!!BAD COMMAND!!"); |
| 1110 | |
| 1111 | for(int i = 0; i < RequiredCDBLencxx . . $ RequiredCDBLen.[cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[0] >> 4]; i++) |
| 1112 | lb_pos += snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[i]); |
| 1113 | |
| 1114 | SCSILogcxx . . $ SCSILog.("SCSI", "%s", log_buffer); |
| 1115 | //puts(log_buffer); |
| 1116 | } |
| 1117 | |
| 1118 | |
| 1119 | if(cmd_info_ptr->pretty_namecxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#pretty_name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) // Command not found! |
| 1120 | { |
| 1121 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_ILLEGAL_REQUESTcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:286:9`!, NSE_INVALID_COMMANDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:300:9`!); |
| 1122 | |
| 1123 | SCSIDBGcxx . . $ SCSIDBG(326aeb464d16410c).("Bad Command: %02x\n", cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[0]); |
| 1124 | |
| 1125 | if(SCSILogcxx . . $ SCSILog.) |
| 1126 | SCSILogcxx . . $ SCSILog.("SCSI", "Bad Command: %02x", cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.[0]); |
| 1127 | |
| 1128 | cdcxx . . $ cd..command_buffer_poscxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer_pos. = 0; |
| 1129 | } |
| 1130 | else |
| 1131 | { |
| 1132 | if(cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen. && (cmd_info_ptr->flagscxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#flags. & SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!)) |
| 1133 | { |
| 1134 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_NOT_READYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:283:9`!, NSE_TRAY_OPENcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:295:9`!); |
| 1135 | } |
| 1136 | else if(!Cur_CDIFcxx . . $ Cur_CDIF. && (cmd_info_ptr->flagscxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#flags. & SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!)) |
| 1137 | { |
| 1138 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_NOT_READYcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:283:9`!, NSE_NO_DISCcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:294:9`!); |
| 1139 | } |
| 1140 | else if(cdcxx . . $ cd..DiscChangedcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#DiscChanged. && (cmd_info_ptr->flagscxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#flags. & SCF_REQUIRES_MEDIUMcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:795:9`!)) |
| 1141 | { |
| 1142 | CommandCCErrorcxx . . $ CommandCCError(b1146eedae1e1d0b).(SENSEKEY_UNIT_ATTENTIONcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:287:9`!, NSE_DISC_CHANGEDcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:305:9`!); |
| 1143 | cdcxx . . $ cd..DiscChangedcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#DiscChanged. = false; |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | cmd_info_ptr->funccxx . . $ $anonymous_type_9dc09b8b7c986d6d_6#func.(cdcxx . . $ cd..command_buffercxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer.); |
| 1148 | } |
| 1149 | |
| 1150 | cdcxx . . $ cd..command_buffer_poscxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#command_buffer_pos. = 0; |
| 1151 | } |
| 1152 | } // end if(cd.command_buffer_pos == RequiredCDBLen[cd.command_buffer[0] >> 4]) |
| 1153 | else // Otherwise, get more data for the command! |
| 1154 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!); |
| 1155 | } |
| 1156 | break; |
| 1157 | |
| 1158 | case PHASE_STATUScxx . . $ PHASE_STATUS.: |
| 1159 | if(REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`!) |
| 1160 | { |
| 1161 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!); |
| 1162 | cdcxx . . $ cd..status_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#status_sent. = TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!; |
| 1163 | } |
| 1164 | |
| 1165 | if(!REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && !ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`! && cdcxx . . $ cd..status_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#status_sent.) |
| 1166 | { |
| 1167 | // Status sent, so get ready to send the message! |
| 1168 | cdcxx . . $ cd..status_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#status_sent. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 1169 | cd_buscxx . . $ cd_bus..DBcxx . . $ pcecd_drive_bus_t#DB. = cdcxx . . $ cd..message_pendingcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_pending.; |
| 1170 | |
| 1171 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_MESSAGE_INcxx . . $ PHASE_MESSAGE_IN.); |
| 1172 | } |
| 1173 | break; |
| 1174 | |
| 1175 | case PHASE_DATA_INcxx . . $ PHASE_DATA_IN.: |
| 1176 | if(!REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && !ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`!) |
| 1177 | { |
| 1178 | //puts("REQ and ACK false"); |
| 1179 | if(dincxx . . $ din..CanReadcxx . . $ SimpleFIFO#CanRead(db52760e79bf9054).() == 0) // aaand we're done! |
| 1180 | { |
| 1181 | CDIRQCallbackcxx . . $ CDIRQCallback.(0x8000 | PCECD_Drive_IRQ_DATA_TRANSFER_READYcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_READY.); |
| 1182 | |
| 1183 | if(cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done.) |
| 1184 | { |
| 1185 | SendStatusAndMessagecxx . . $ SendStatusAndMessage(8fbe6856f5410d23).(STATUS_GOODcxx . . $ `mednafen/pce_fast/pcecd_drive.cpp:279:9`!, 0x00); |
| 1186 | cdcxx . . $ cd..data_transfer_donecxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#data_transfer_done. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 1187 | CDIRQCallbackcxx . . $ CDIRQCallback.(PCECD_Drive_IRQ_DATA_TRANSFER_DONEcxx . . $ PCECD_Drive_IRQ_DATA_TRANSFER_DONE.); |
| 1188 | } |
| 1189 | } |
| 1190 | else |
| 1191 | { |
| 1192 | cd_buscxx . . $ cd_bus..DBcxx . . $ pcecd_drive_bus_t#DB. = dincxx . . $ din..ReadBytecxx . . $ SimpleFIFO#ReadByte(389f4deb06b45b4e).(); |
| 1193 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!); |
| 1194 | } |
| 1195 | } |
| 1196 | if(REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`!) |
| 1197 | { |
| 1198 | //puts("REQ and ACK true"); |
| 1199 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!); |
| 1200 | } |
| 1201 | break; |
| 1202 | |
| 1203 | case PHASE_MESSAGE_INcxx . . $ PHASE_MESSAGE_IN.: |
| 1204 | if(REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`!) |
| 1205 | { |
| 1206 | SetREQcxx . . $ SetREQ(b45ddcbc8423892c).(FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!); |
| 1207 | cdcxx . . $ cd..message_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_sent. = TRUEcxx . . $ `mednafen/mednafen-types.h:113:9`!; |
| 1208 | } |
| 1209 | |
| 1210 | if(!REQ_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:35:9`! && !ACK_signalcxx . . $ `mednafen/pce_fast/pcecd_drive.h:31:9`! && cdcxx . . $ cd..message_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_sent.) |
| 1211 | { |
| 1212 | cdcxx . . $ cd..message_sentcxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#message_sent. = FALSEcxx . . $ `mednafen/mednafen-types.h:109:9`!; |
| 1213 | ChangePhasecxx . . $ ChangePhase(cb2f890c2fdad230).(PHASE_BUS_FREEcxx . . $ PHASE_BUS_FREE.); |
| 1214 | } |
| 1215 | break; |
| 1216 | } |
| 1217 | |
| 1218 | int32cxx . . $ int32# next_time = 0x7fffffff; |
| 1219 | |
| 1220 | if(CDReadTimercxx . . $ CDReadTimer. > 0 && CDReadTimercxx . . $ CDReadTimer. < next_time) |
| 1221 | next_time = CDReadTimercxx . . $ CDReadTimer.; |
| 1222 | |
| 1223 | if(cddacxx . . $ cdda..CDDAStatuscxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAStatus. == CDDASTATUS_PLAYINGcxx . . $ CDDASTATUS_PLAYING.) |
| 1224 | { |
| 1225 | int32cxx . . $ int32# cdda_div_sexytime = (cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. + 0xFFFF) >> 16; |
| 1226 | if(cdda_div_sexytime > 0 && cdda_div_sexytime < next_time) |
| 1227 | next_time = cdda_div_sexytime; |
| 1228 | } |
| 1229 | |
| 1230 | assertcxx . . $ `/usr/include/assert.h:102:11`!(next_time >= 0); |
| 1231 | |
| 1232 | return(next_time); |
| 1233 | } |
| 1234 | |
| 1235 | void PCECD_Drive_SetLogcxx . . $ PCECD_Drive_SetLog(efb5058ca3d6aa1e).(void (*logfunc)(const char *, const char *, ...)) |
| 1236 | { |
| 1237 | SCSILogcxx . . $ SCSILog. = logfunc; |
| 1238 | } |
| 1239 | |
| 1240 | void PCECD_Drive_SetTransferRatecxx . . $ PCECD_Drive_SetTransferRate(cb2f890c2fdad230).(uint32cxx . . $ uint32# TransferRate) |
| 1241 | { |
| 1242 | CD_DATA_TRANSFER_RATEcxx . . $ CD_DATA_TRANSFER_RATE. = TransferRate; |
| 1243 | } |
| 1244 | |
| 1245 | void PCECD_Drive_Closecxx . . $ PCECD_Drive_Close(49f6e7a06ebc5aa8).(void) |
| 1246 | { |
| 1247 | |
| 1248 | } |
| 1249 | |
| 1250 | void PCECD_Drive_Initcxx . . $ PCECD_Drive_Init(4ffa26e4fe0e05f9).(int cdda_time_div, Blip_Buffercxx . . $ Blip_Buffer# *leftbuf, Blip_Buffercxx . . $ Blip_Buffer# *rightbuf, uint32cxx . . $ uint32# TransferRate, uint32cxx . . $ uint32# SystemClock, void (*IRQFunc)(int), void (*SSCFunc)(uint8cxx . . $ uint8#, int)) |
| 1251 | { |
| 1252 | Cur_CDIFcxx . . $ Cur_CDIF. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1253 | cdcxx . . $ cd..TrayOpencxx . . $ $anonymous_type_9dc09b8b7c986d6d_1#TrayOpen. = false; |
| 1254 | |
| 1255 | monotonic_timestampcxx . . $ monotonic_timestamp. = 0; |
| 1256 | lasttscxx . . $ lastts. = 0; |
| 1257 | |
| 1258 | SCSILogcxx . . $ SCSILog. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1259 | |
| 1260 | //din = new SimpleFIFO<uint8>(2048); |
| 1261 | |
| 1262 | cddacxx . . $ cdda..CDDATimeDivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDATimeDiv. = cdda_time_div; |
| 1263 | |
| 1264 | cddacxx . . $ cdda..CDDAVolumecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAVolume. = 65536; |
| 1265 | cddacxx . . $ cdda..CDDASynthcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASynth..volumecxx . . $ Blip_Synth#volume(ba8836b59fb42830).(1.0f / 65536); |
| 1266 | cddacxx . . $ cdda..CDDASynthcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDASynth..treble_eqcxx . . $ Blip_Synth#treble_eq(a728e5f0d25ddc61).(0cxx . . $ blip_eq_t#blip_eq_t(ba8836b59fb42830).); |
| 1267 | sbufcxx . . $ sbuf.[0] = leftbuf; |
| 1268 | sbufcxx . . $ sbuf.[1] = rightbuf; |
| 1269 | |
| 1270 | CD_DATA_TRANSFER_RATEcxx . . $ CD_DATA_TRANSFER_RATE. = TransferRate; |
| 1271 | System_Clockcxx . . $ System_Clock. = SystemClock; |
| 1272 | CDIRQCallbackcxx . . $ CDIRQCallback. = IRQFunc; |
| 1273 | CDStuffSubchannelscxx . . $ CDStuffSubchannels. = SSCFunc; |
| 1274 | } |
| 1275 | |
| 1276 | void PCECD_Drive_SetCDDAVolumecxx . . $ PCECD_Drive_SetCDDAVolume(cb2f890c2fdad230).(unsigned vol) |
| 1277 | { |
| 1278 | cddacxx . . $ cdda..CDDAVolumecxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDAVolume. = vol; |
| 1279 | } |
| 1280 | |
| 1281 | int PCECD_Drive_StateActioncxx . . $ PCECD_Drive_StateAction(68129732609e585a).(StateMemcxx . . $ StateMem# * sm, int load, int data_only, const char *sname) |
| 1282 | { |
| 1283 | SFORMATcxx . . $ SFORMAT# StateRegs[] = |
| 1284 | { |
| 1285 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd_bus.DB, "DB"), |
| 1286 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd_bus.signals, "Signals"), |
| 1287 | SFVARcxx . . $ `mednafen/state.h:70:9`!(CurrentPhase), |
| 1288 | |
| 1289 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.last_RST_signal, "last_RST"), |
| 1290 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.message_pending, "message_pending"), |
| 1291 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.status_sent, "status_sent"), |
| 1292 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.message_sent, "message_sent"), |
| 1293 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.key_pending, "key_pending"), |
| 1294 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.asc_pending, "asc_pending"), |
| 1295 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.ascq_pending, "ascq_pending"), |
| 1296 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.fru_pending, "fru_pending"), |
| 1297 | |
| 1298 | SFARRAYNcxx . . $ `mednafen/state.h:72:9`!(cd.command_buffer, 256, "command_buffer"), |
| 1299 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.command_buffer_pos, "command_buffer_pos"), |
| 1300 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.command_size_left, "command_size_left"), |
| 1301 | |
| 1302 | // Don't save the FIFO's write position, it will be reconstructed from read_pos and in_count |
| 1303 | SFARRAYNcxx . . $ `mednafen/state.h:72:9`!(&din.data[0], din.data.size(), "din_fifo"), |
| 1304 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(din.read_pos, "din_read_pos"), |
| 1305 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(din.in_count, "din_in_count"), |
| 1306 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.data_transfer_done, "data_transfer_done"), |
| 1307 | |
| 1308 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.TrayOpen, "TrayOpen"), |
| 1309 | SFVARNcxx . . $ `mednafen/state.h:69:9`!(cd.DiscChanged, "DiscChanged"), |
| 1310 | |
| 1311 | SFVARcxx . . $ `mednafen/state.h:70:9`!(cdda.PlayMode), |
| 1312 | SFARRAY16cxx . . $ `mednafen/state.h:79:9`!(cdda.CDDASectorBuffer, 1176), |
| 1313 | SFVARcxx . . $ `mednafen/state.h:70:9`!(cdda.CDDAReadPos), |
| 1314 | SFVARcxx . . $ `mednafen/state.h:70:9`!(cdda.CDDAStatus), |
| 1315 | SFVARcxx . . $ `mednafen/state.h:70:9`!(cdda.CDDADiv), |
| 1316 | SFVARcxx . . $ `mednafen/state.h:70:9`!(read_sec_start), |
| 1317 | SFVARcxx . . $ `mednafen/state.h:70:9`!(read_sec), |
| 1318 | SFVARcxx . . $ `mednafen/state.h:70:9`!(read_sec_end), |
| 1319 | |
| 1320 | SFVARcxx . . $ `mednafen/state.h:70:9`!(CDReadTimer), |
| 1321 | SFVARcxx . . $ `mednafen/state.h:70:9`!(SectorAddr), |
| 1322 | SFVARcxx . . $ `mednafen/state.h:70:9`!(SectorCount), |
| 1323 | |
| 1324 | SFVARcxx . . $ `mednafen/state.h:70:9`!(cdda.ScanMode), |
| 1325 | SFVARcxx . . $ `mednafen/state.h:70:9`!(cdda.scan_sec_end), |
| 1326 | |
| 1327 | SFARRAYNcxx . . $ `mednafen/state.h:72:9`!(&cd.SubQBuf[0][0], sizeof(cd.SubQBuf), "SubQBufs"), |
| 1328 | SFARRAYNcxx . . $ `mednafen/state.h:72:9`!(cd.SubQBuf_Last, sizeof(cd.SubQBuf_Last), "SubQBufLast"), |
| 1329 | SFARRAYNcxx . . $ `mednafen/state.h:72:9`!(cd.SubPWBuf, sizeof(cd.SubPWBuf), "SubPWBuf"), |
| 1330 | |
| 1331 | SFVARcxx . . $ `mednafen/state.h:70:9`!(monotonic_timestamp), |
| 1332 | SFVARcxx . . $ `mednafen/state.h:70:9`!(pce_lastsapsp_timestamp), |
| 1333 | |
| 1334 | SFENDcxx . . $ `mednafen/state.h:94:9`! |
| 1335 | }; |
| 1336 | |
| 1337 | int ret = MDFNSS_StateActioncxx . . $ MDFNSS_StateAction(3f628545d3b0df83).(sm, load, data_only, StateRegs, sname); |
| 1338 | |
| 1339 | if(load) |
| 1340 | { |
| 1341 | dincxx . . $ din..in_countcxx . . $ SimpleFIFO#in_count. &= dincxx . . $ din..sizecxx . . $ SimpleFIFO#size. - 1; |
| 1342 | dincxx . . $ din..read_poscxx . . $ SimpleFIFO#read_pos. &= dincxx . . $ din..sizecxx . . $ SimpleFIFO#size. - 1; |
| 1343 | dincxx . . $ din..write_poscxx . . $ SimpleFIFO#write_pos. = (dincxx . . $ din..read_poscxx . . $ SimpleFIFO#read_pos. + dincxx . . $ din..in_countcxx . . $ SimpleFIFO#in_count.) & (dincxx . . $ din..sizecxx . . $ SimpleFIFO#size. - 1); |
| 1344 | |
| 1345 | if(cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. <= 0) |
| 1346 | cddacxx . . $ cdda..CDDADivcxx . . $ $anonymous_type_9dc09b8b7c986d6d_4#CDDADiv. = 1; |
| 1347 | //printf("%d %d %d\n", din.in_count, din.read_pos, din.write_pos); |
| 1348 | } |
| 1349 | |
| 1350 | return (ret); |
| 1351 | } |