| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * |
| 3 | * * |
| 4 | * This program is free software; you can redistribute it and/or modify * |
| 5 | * it under the terms of the GNU General Public License as published by * |
| 6 | * the Free Software Foundation; either version 2 of the License, or * |
| 7 | * (at your option) any later version. * |
| 8 | * * |
| 9 | * This program is distributed in the hope that it will be useful, * |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 12 | * GNU General Public License for more details. * |
| 13 | * * |
| 14 | * You should have received a copy of the GNU General Public License * |
| 15 | * along with this program; if not, write to the * |
| 16 | * Free Software Foundation, Inc., * |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * |
| 18 | ***************************************************************************/ |
| 19 | |
| 20 | #ifndef __CDROM_H__ |
| 21 | #define __CDROM_H__ |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | #include "psxcommon.h" |
| 28 | #include "decode_xa.h" |
| 29 | #include "r3000a.h" |
| 30 | #include "plugins.h" |
| 31 | #include "psxmem.h" |
| 32 | #include "psxhw.h" |
| 33 | |
| 34 | #define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */ |
| 35 | #define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */ |
| 36 | |
| 37 | #define MSF2SECT(m, s, f) (((m) * 60 + (s) - 2) * 75 + (f)) |
| 38 | |
| 39 | #define CD_FRAMESIZE_RAW 2352 |
| 40 | #define DATA_SIZE (CD_FRAMESIZE_RAW - 12) |
| 41 | |
| 42 | #define SUB_FRAMESIZE 96 |
| 43 | |
| 44 | typedef struct { |
| 45 | unsigned char OCUP; |
| 46 | unsigned char Reg1Mode; |
| 47 | unsigned char Reg2; |
| 48 | unsigned char CmdProcess; |
| 49 | unsigned char Ctrl; |
| 50 | unsigned char Stat; |
| 51 | |
| 52 | unsigned char StatP; |
| 53 | |
| 54 | unsigned char Transfer[DATA_SIZE]; |
| 55 | struct { |
| 56 | unsigned char Track; |
| 57 | unsigned char Index; |
| 58 | unsigned char Relative[3]; |
| 59 | unsigned char Absolute[3]; |
| 60 | } subq; |
| 61 | unsigned char TrackChanged; |
| 62 | unsigned char pad1[3]; |
| 63 | unsigned int freeze_ver; |
| 64 | |
| 65 | unsigned char Prev[4]; |
| 66 | unsigned char Param[8]; |
| 67 | unsigned char Result[16]; |
| 68 | |
| 69 | unsigned char ParamC; |
| 70 | unsigned char ParamP; |
| 71 | unsigned char ResultC; |
| 72 | unsigned char ResultP; |
| 73 | unsigned char ResultReady; |
| 74 | unsigned char Cmd; |
| 75 | unsigned char Readed; |
| 76 | unsigned char SetlocPending; |
| 77 | u32 Reading; |
| 78 | |
| 79 | unsigned char ResultTN[6]; |
| 80 | unsigned char ResultTD[4]; |
| 81 | unsigned char SetSectorPlay[4]; |
| 82 | unsigned char SetSectorEnd[4]; |
| 83 | unsigned char SetSector[4]; |
| 84 | unsigned char Track; |
| 85 | boolean Play, Muted; |
| 86 | int CurTrack; |
| 87 | int Mode, File, Channel; |
| 88 | int Reset; |
| 89 | int RErr; |
| 90 | int FirstSector; |
| 91 | |
| 92 | xa_decode_t Xa; |
| 93 | |
| 94 | int Init; |
| 95 | |
| 96 | u16 Irq; |
| 97 | u8 IrqRepeated; |
| 98 | u32 eCycle; |
| 99 | |
| 100 | u8 Seeked; |
| 101 | |
| 102 | u8 DriveState; |
| 103 | u8 FastForward; |
| 104 | u8 FastBackward; |
| 105 | u8 pad; |
| 106 | |
| 107 | u8 AttenuatorLeftToLeft, AttenuatorLeftToRight; |
| 108 | u8 AttenuatorRightToRight, AttenuatorRightToLeft; |
| 109 | u8 AttenuatorLeftToLeftT, AttenuatorLeftToRightT; |
| 110 | u8 AttenuatorRightToRightT, AttenuatorRightToLeftT; |
| 111 | } cdrStruct; |
| 112 | |
| 113 | extern cdrStruct cdr; |
| 114 | |
| 115 | void cdrReset(); |
| 116 | void cdrAttenuate(s16 *buf, int samples, int stereo); |
| 117 | |
| 118 | void cdrInterrupt(); |
| 119 | void cdrReadInterrupt(); |
| 120 | void cdrRepplayInterrupt(); |
| 121 | void cdrLidSeekInterrupt(); |
| 122 | void cdrPlayInterrupt(); |
| 123 | void cdrDmaInterrupt(); |
| 124 | void LidInterrupt(); |
| 125 | unsigned char cdrRead0(void); |
| 126 | unsigned char cdrRead1(void); |
| 127 | unsigned char cdrRead2(void); |
| 128 | unsigned char cdrRead3(void); |
| 129 | void cdrWrite0(unsigned char rt); |
| 130 | void cdrWrite1(unsigned char rt); |
| 131 | void cdrWrite2(unsigned char rt); |
| 132 | void cdrWrite3(unsigned char rt); |
| 133 | int cdrFreeze(void *f, int Mode); |
| 134 | |
| 135 | #ifdef __cplusplus |
| 136 | } |
| 137 | #endif |
| 138 | #endif |