b762738c14a2aae35ade533e82e865fff21559dd
[pcsx_rearmed.git] / libpcsxcore / cdrom.h
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 ABS_CD(x) ((x >= 0) ? x : -x)
38 #define MIN_VALUE(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
39 #define MAX_VALUE(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
40
41 #define CD_FRAMESIZE_RAW                2352
42 #define DATA_SIZE                               (CD_FRAMESIZE_RAW - 12)
43
44 /* CD_FRAMESIZE_RAW aligned to a cache line for DMA buffers
45  * (assuming a cache line of max. 64 bytes) */
46 #define CD_FRAMESIZE_RAW_ALIGNED        2368
47
48 #define SUB_FRAMESIZE                   96
49
50 #define MSF2SECT(m, s, f)               (((m) * 60 + (s) - 2) * 75 + (f))
51
52 static inline void lba2msf(unsigned int lba, u8 *m, u8 *s, u8 *f) {
53         *m = lba / 75 / 60;
54         lba = lba - *m * 75 * 60;
55         *s = lba / 75;
56         lba = lba - *s * 75;
57         *f = lba;
58 }
59
60 void cdrReset();
61
62 void cdrInterrupt(void);
63 void cdrPlayReadInterrupt(void);
64 void cdrLidSeekInterrupt(void);
65 void cdrDmaInterrupt(void);
66 void LidInterrupt(void);
67 unsigned char cdrRead0(void);
68 unsigned char cdrRead1(void);
69 unsigned char cdrRead2(void);
70 unsigned char cdrRead3(void);
71 void cdrWrite0(unsigned char rt);
72 void cdrWrite1(unsigned char rt);
73 void cdrWrite2(unsigned char rt);
74 void cdrWrite3(unsigned char rt);
75 int cdrFreeze(void *f, int Mode);
76
77 #ifdef __cplusplus
78 }
79 #endif
80 #endif