Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/yabause/src/cs2.h
2 views
1
/* Copyright 2003 Guillaume Duhamel
2
Copyright 2004-2006 Theo Berkau
3
4
This file is part of Yabause.
5
6
Yabause is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
11
Yabause is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with Yabause; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#ifndef CS2_H
22
#define CS2_H
23
24
#include "memory.h"
25
#include "cdbase.h"
26
#include "cs0.h"
27
28
#define MAX_BLOCKS 200
29
#define MAX_SELECTORS 24
30
#define MAX_FILES 256
31
32
typedef struct
33
{
34
s32 size;
35
u32 FAD;
36
u8 cn;
37
u8 fn;
38
u8 sm;
39
u8 ci;
40
u8 data[2352];
41
} block_struct;
42
43
typedef struct
44
{
45
u32 FAD;
46
u32 range;
47
u8 mode;
48
u8 chan;
49
u8 smmask;
50
u8 cimask;
51
u8 fid;
52
u8 smval;
53
u8 cival;
54
u8 condtrue;
55
u8 condfalse;
56
} filter_struct;
57
58
typedef struct
59
{
60
s32 size;
61
block_struct *block[MAX_BLOCKS];
62
u8 blocknum[MAX_BLOCKS];
63
u8 numblocks;
64
} partition_struct;
65
66
typedef struct
67
{
68
u16 groupid;
69
u16 userid;
70
u16 attributes;
71
u16 signature;
72
u8 filenumber;
73
u8 reserved[5];
74
} xarec_struct;
75
76
typedef struct
77
{
78
u8 recordsize;
79
u8 xarecordsize;
80
u32 lba;
81
u32 size;
82
u8 dateyear;
83
u8 datemonth;
84
u8 dateday;
85
u8 datehour;
86
u8 dateminute;
87
u8 datesecond;
88
u8 gmtoffset;
89
u8 flags;
90
u8 fileunitsize;
91
u8 interleavegapsize;
92
u16 volumesequencenumber;
93
u8 namelength;
94
char name[32];
95
xarec_struct xarecord;
96
} dirrec_struct;
97
98
typedef struct
99
{
100
u8 audcon;
101
u8 audlay;
102
u8 audbufdivnum;
103
u8 vidcon;
104
u8 vidlay;
105
u8 vidbufdivnum;
106
} mpegcon_struct;
107
108
typedef struct
109
{
110
u8 audstm;
111
u8 audstmid;
112
u8 audchannum;
113
u8 vidstm;
114
u8 vidstmid;
115
u8 vidchannum;
116
} mpegstm_struct;
117
118
typedef struct
119
{
120
u32 DTR;
121
u16 UNKNOWN;
122
u16 HIRQ;
123
u16 HIRQMASK; // Masks bits from HIRQ -only- when generating A-bus interrupts
124
u16 CR1;
125
u16 CR2;
126
u16 CR3;
127
u16 CR4;
128
u16 MPEGRGB;
129
} blockregs_struct;
130
131
typedef struct {
132
blockregs_struct reg;
133
u32 FAD;
134
u8 status;
135
136
// cd specific stats
137
u8 options;
138
u8 repcnt;
139
u8 ctrladdr;
140
u8 track;
141
u8 index;
142
143
// mpeg specific stats
144
u8 actionstatus;
145
u8 pictureinfo;
146
u8 mpegaudiostatus;
147
u16 mpegvideostatus;
148
u16 vcounter;
149
150
// authentication variables
151
u16 satauth;
152
u16 mpgauth;
153
154
// internal varaibles
155
u32 transfercount;
156
u32 cdwnum;
157
u32 TOC[102];
158
u32 playFAD;
159
u32 playendFAD;
160
unsigned int maxrepeat;
161
u32 getsectsize;
162
u32 putsectsize;
163
u32 calcsize;
164
s32 infotranstype;
165
s32 datatranstype;
166
int isonesectorstored;
167
int isdiskchanged;
168
int isbufferfull;
169
int speed1x;
170
int isaudio;
171
u8 transfileinfo[12];
172
u8 lastbuffer;
173
174
filter_struct filter[MAX_SELECTORS];
175
filter_struct *outconcddev;
176
filter_struct *outconmpegfb;
177
filter_struct *outconmpegbuf;
178
filter_struct *outconmpegrom;
179
filter_struct *outconhost;
180
u8 outconcddevnum;
181
u8 outconmpegfbnum;
182
u8 outconmpegbufnum;
183
u8 outconmpegromnum;
184
u8 outconhostnum;
185
186
partition_struct partition[MAX_SELECTORS];
187
188
partition_struct *datatranspartition;
189
u8 datatranspartitionnum;
190
s32 datatransoffset;
191
u32 datanumsecttrans;
192
u16 datatranssectpos;
193
u16 datasectstotrans;
194
195
u32 blockfreespace;
196
block_struct block[MAX_BLOCKS];
197
block_struct workblock;
198
199
u32 curdirsect;
200
u32 curdirsize;
201
u32 curdirfidoffset;
202
dirrec_struct fileinfo[MAX_FILES];
203
u32 numfiles;
204
205
const char *mpegpath;
206
207
u32 mpegintmask;
208
209
mpegcon_struct mpegcon[2];
210
mpegstm_struct mpegstm[2];
211
212
int _command;
213
u32 _periodiccycles; // microseconds * 3
214
u32 _periodictiming; // microseconds * 3
215
u32 _commandtiming;
216
CDInterface * cdi;
217
218
int carttype;
219
int playtype;
220
} Cs2;
221
222
typedef struct {
223
char system[17];
224
char company[17];
225
char itemnum[11];
226
char version[7];
227
char date[11];
228
char cdinfo[9];
229
char region[11];
230
char peripheral[17];
231
char gamename[113];
232
u32 ipsize;
233
u32 msh2stack;
234
u32 ssh2stack;
235
u32 firstprogaddr;
236
u32 firstprogsize;
237
} ip_struct;
238
239
extern Cs2 * Cs2Area;
240
extern ip_struct * cdip;
241
242
int Cs2Init(int, int, const char *, const char *, const char *);
243
int Cs2ChangeCDCore(int coreid, const char *cdpath);
244
void Cs2DeInit(void);
245
246
u8 FASTCALL Cs2ReadByte(u32);
247
u16 FASTCALL Cs2ReadWord(u32);
248
u32 FASTCALL Cs2ReadLong(u32);
249
void FASTCALL Cs2WriteByte(u32, u8);
250
void FASTCALL Cs2WriteWord(u32, u16);
251
void FASTCALL Cs2WriteLong(u32, u32);
252
253
void FASTCALL Cs2RapidCopyT1(void *dest, u32 count);
254
void FASTCALL Cs2RapidCopyT2(void *dest, u32 count);
255
256
void Cs2Exec(u32);
257
int Cs2GetTimeToNextSector(void);
258
void Cs2Execute(void);
259
void Cs2Reset(void);
260
void Cs2SetTiming(int);
261
void Cs2Command(void);
262
void Cs2SetCommandTiming(u8 cmd);
263
264
// command name command code
265
void Cs2GetStatus(void); // 0x00
266
void Cs2GetHardwareInfo(void); // 0x01
267
void Cs2GetToc(void); // 0x02
268
void Cs2GetSessionInfo(void); // 0x03
269
void Cs2InitializeCDSystem(void); // 0x04
270
// Open Tray // 0x05
271
void Cs2EndDataTransfer(void); // 0x06
272
void Cs2PlayDisc(void); // 0x10
273
void Cs2SeekDisc(void); // 0x11
274
// Scan Disc // 0x12
275
void Cs2GetSubcodeQRW(void); // 0x20
276
void Cs2SetCDDeviceConnection(void); // 0x30
277
// get CD Device Connection // 0x31
278
void Cs2GetLastBufferDestination(void); // 0x32
279
void Cs2SetFilterRange(void); // 0x40
280
// get Filter Range // 0x41
281
void Cs2SetFilterSubheaderConditions(void);// 0x42
282
void Cs2GetFilterSubheaderConditions(void);// 0x43
283
void Cs2SetFilterMode(void); // 0x44
284
void Cs2GetFilterMode(void); // 0x45
285
void Cs2SetFilterConnection(void); // 0x46
286
// Get Filter Connection // 0x47
287
void Cs2ResetSelector(void); // 0x48
288
void Cs2GetBufferSize(void); // 0x50
289
void Cs2GetSectorNumber(void); // 0x51
290
void Cs2CalculateActualSize(void); // 0x52
291
void Cs2GetActualSize(void); // 0x53
292
void Cs2GetSectorInfo(void); // 0x54
293
void Cs2SetSectorLength(void); // 0x60
294
void Cs2GetSectorData(void); // 0x61
295
void Cs2DeleteSectorData(void); // 0x62
296
void Cs2GetThenDeleteSectorData(void); // 0x63
297
void Cs2PutSectorData(void); // 0x64
298
// Copy Sector Data // 0x65
299
// Move Sector Data // 0x66
300
void Cs2GetCopyError(void); // 0x67
301
void Cs2ChangeDirectory(void); // 0x70
302
void Cs2ReadDirectory(void); // 0x71
303
void Cs2GetFileSystemScope(void); // 0x72
304
void Cs2GetFileInfo(void); // 0x73
305
void Cs2ReadFile(void); // 0x74
306
void Cs2AbortFile(void); // 0x75
307
void Cs2MpegGetStatus(void); // 0x90
308
void Cs2MpegGetInterrupt(void); // 0x91
309
void Cs2MpegSetInterruptMask(void); // 0x92
310
void Cs2MpegInit(void); // 0x93
311
void Cs2MpegSetMode(void); // 0x94
312
void Cs2MpegPlay(void); // 0x95
313
void Cs2MpegSetDecodingMethod(void); // 0x96
314
// MPEG Out Decoding Sync // 0x97
315
// MPEG Get Timecode // 0x98
316
// MPEG Get Pts // 0x99
317
void Cs2MpegSetConnection(void); // 0x9A
318
void Cs2MpegGetConnection(void); // 0x9B
319
// MPEG Change Connection // 0x9C
320
void Cs2MpegSetStream(void); // 0x9D
321
void Cs2MpegGetStream(void); // 0x9E
322
// MPEG Get Picture Size // 0x9F
323
void Cs2MpegDisplay(void); // 0xA0
324
void Cs2MpegSetWindow(void); // 0xA1
325
void Cs2MpegSetBorderColor(void); // 0xA2
326
void Cs2MpegSetFade(void); // 0xA3
327
void Cs2MpegSetVideoEffects(void); // 0xA4
328
// MPEG Get Image // 0xA5
329
// MPEG Set Image // 0xA6
330
// MPEG Read Image // 0xA7
331
// MPEG Write Image // 0xA8
332
// MPEG Read Sector // 0xA9
333
// MPEG Write Sector // 0xAA
334
// MPEG Get LSI // 0xAE
335
void Cs2MpegSetLSI(void); // 0xAF
336
void Cs2CmdE0(void); // 0xE0
337
void Cs2CmdE1(void); // 0xE1
338
void Cs2CmdE2(void); // 0xE2
339
340
u8 Cs2FADToTrack(u32 val);
341
u32 Cs2TrackToFAD(u16 trackandindex);
342
void Cs2SetupDefaultPlayStats(u8 track_number, int writeFAD);
343
block_struct * Cs2AllocateBlock(u8 * blocknum);
344
void Cs2FreeBlock(block_struct * blk);
345
void Cs2SortBlocks(partition_struct * part);
346
partition_struct * Cs2GetPartition(filter_struct * curfilter);
347
partition_struct * Cs2FilterData(filter_struct * curfilter, int isaudio);
348
int Cs2CopyDirRecord(u8 * buffer, dirrec_struct * dirrec);
349
int Cs2ReadFileSystem(filter_struct * curfilter, u32 fid, int isoffset);
350
void Cs2SetupFileInfoTransfer(u32 fid);
351
partition_struct * Cs2ReadUnFilteredSector(u32 rufsFAD);
352
//partition_struct * Cs2ReadFilteredSector(u32 rfsFAD);
353
int Cs2ReadFilteredSector(u32 rfsFAD, partition_struct **partition);
354
u8 Cs2GetIP(int autoregion);
355
u8 Cs2GetRegionID(void);
356
int Cs2SaveState(FILE *);
357
int Cs2LoadState(FILE *, int, int);
358
359
#endif
360
361