Revert some changes as they were not tested or are not required
[pcsx_rearmed.git] / libpcsxcore / cdrom.h
CommitLineData
ef79bbde
P
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
24extern "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
66425c25 44#define MIN_VALUE(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
45#define MAX_VALUE(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
46
ef79bbde
P
47typedef struct {
48 unsigned char OCUP;
49 unsigned char Reg1Mode;
50 unsigned char Reg2;
51 unsigned char CmdProcess;
52 unsigned char Ctrl;
53 unsigned char Stat;
54
55 unsigned char StatP;
56
fffad32e 57 unsigned char Transfer[DATA_SIZE];
58 struct {
59 unsigned char Track;
60 unsigned char Index;
61 unsigned char Relative[3];
62 unsigned char Absolute[3];
63 } subq;
64 unsigned char TrackChanged;
639651a4 65 boolean m_locationChanged;
66 unsigned char pad1[2];
c69642c8 67 unsigned int freeze_ver;
ef79bbde
P
68
69 unsigned char Prev[4];
70 unsigned char Param[8];
df656dde 71 unsigned char Result[16];
ef79bbde
P
72
73 unsigned char ParamC;
74 unsigned char ParamP;
75 unsigned char ResultC;
76 unsigned char ResultP;
77 unsigned char ResultReady;
78 unsigned char Cmd;
79 unsigned char Readed;
55b8460a 80 unsigned char SetlocPending;
ef79bbde
P
81 u32 Reading;
82
83 unsigned char ResultTN[6];
84 unsigned char ResultTD[4];
df656dde 85 unsigned char SetSectorPlay[4];
55b8460a 86 unsigned char SetSectorEnd[4];
87 unsigned char SetSector[4];
ef79bbde
P
88 unsigned char Track;
89 boolean Play, Muted;
90 int CurTrack;
91 int Mode, File, Channel;
92 int Reset;
6087d7e7 93 int NoErr;
ef79bbde
P
94 int FirstSector;
95
96 xa_decode_t Xa;
97
98 int Init;
99
e4268a49 100 u16 Irq;
101 u8 IrqRepeated;
ef79bbde
P
102 u32 eCycle;
103
39df67df 104 u8 Seeked;
df656dde 105
80f91a20 106 u8 DriveState;
df656dde 107 u8 FastForward;
108 u8 FastBackward;
109 u8 pad;
110
53598a71 111 u8 AttenuatorLeftToLeft, AttenuatorLeftToRight;
112 u8 AttenuatorRightToRight, AttenuatorRightToLeft;
113 u8 AttenuatorLeftToLeftT, AttenuatorLeftToRightT;
114 u8 AttenuatorRightToRightT, AttenuatorRightToLeftT;
ef79bbde
P
115} cdrStruct;
116
117extern cdrStruct cdr;
118
119void cdrReset();
53598a71 120void cdrAttenuate(s16 *buf, int samples, int stereo);
121
ef79bbde
P
122void cdrInterrupt();
123void cdrReadInterrupt();
df656dde 124void cdrRepplayInterrupt();
125void cdrLidSeekInterrupt();
126void cdrPlayInterrupt();
9f8b032d 127void cdrDmaInterrupt();
1df403c5 128void LidInterrupt();
ef79bbde
P
129unsigned char cdrRead0(void);
130unsigned char cdrRead1(void);
131unsigned char cdrRead2(void);
132unsigned char cdrRead3(void);
133void cdrWrite0(unsigned char rt);
134void cdrWrite1(unsigned char rt);
135void cdrWrite2(unsigned char rt);
136void cdrWrite3(unsigned char rt);
496d88d4 137int cdrFreeze(void *f, int Mode);
ef79bbde
P
138
139#ifdef __cplusplus
140}
141#endif
142#endif