-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPresentationEngine.cpp
371 lines (347 loc) · 10.1 KB
/
PresentationEngine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
#include "basetypes.h"
#include "byteswap.h"
#include "Bios.h"
#include "mpe.h"
#include "NuonEnvironment.h"
extern NuonEnvironment nuonEnv;
extern void NullBiosHandler(MPE &mpe);
void API_EnterPE(MPE &mpe)
{
}
void API_NDK(MPE &mpe)
{
}
void API_DVD(MPE &mpe)
{
}
void API_FindDiskType(MPE &mpe)
{
//Ballistic routine wont exit loop until FindDiskType returns non-zero
mpe.regs[0] = -1;
}
void API_IsPresenting(MPE &mpe)
{
//Return "not presenting" for now
mpe.regs[0] = 0;
}
void API_GetFieldCounter(MPE &mpe)
{
const uint32 fieldCounter = SwapBytes(*((uint32 *)&nuonEnv.systemBusDRAM[VIDEO_FIELD_COUNTER_ADDRESS & SYSTEM_BUS_VALID_MEMORY_MASK]));
mpe.regs[0] = fieldCounter;
}
void API_IsNDK(MPE &mpe)
{
mpe.regs[0] = 0;
}
void API_IsDVD(MPE &mpe)
{
mpe.regs[0] = 1;
}
void API_StepOneFrame(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_AUDIOStreamSelect(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_ForwardSpeed(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_PresentVOB(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_StartCellStill(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_CellStillDone(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_PresentCell(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_CellReadDone(MPE &mpe)
{
//mpe.regs[0] = 1;
}
void API_ProgramChange(MPE &mpe)
{
mpe.regs[0] = 0;
}
void API_SetAngle(MPE &mpe)
{
//mpe.regs[0] = 1;
}
NuonBiosHandler SVC_API_Table[] = {
API_EnterPE, //_API_EnterPE
API_NDK, //_API_NDK
API_DVD, //_API_DVD
NullBiosHandler, //_API_VCD
NullBiosHandler, //_API_CDA
NullBiosHandler, //_API_VLM
NullBiosHandler, //_API_SVR
NullBiosHandler, //_API_DVD_AUDIO
NullBiosHandler, //_API_GetCGMS
NullBiosHandler, //_API_SetCGMS
NullBiosHandler, //_API_Eject
NullBiosHandler, //_API_Retract
API_IsNDK, //_API_IsNDK
API_IsDVD, //_API_IsDVD
NullBiosHandler, //_API_IsDVD_AUDIO
NullBiosHandler, //_API_IsVCD
NullBiosHandler, //_API_IsCDA
NullBiosHandler, //_API_IsVLM
NullBiosHandler, //_API_IsSVR
NullBiosHandler, //_API_JoyReset
NullBiosHandler, //_API_JoyPoll
NullBiosHandler, //_API_IsSet
NullBiosHandler, //_API_WasSet
NullBiosHandler, //_API_WasReleased
NullBiosHandler, //_API_JoyData
NullBiosHandler, //_API_JoyXData
NullBiosHandler, //_API_JoyYData
NullBiosHandler, //_API_STC
NullBiosHandler, //_API_GetMsClk
NullBiosHandler, //_API_SetMsClk
NullBiosHandler, //_API_WaitMs
API_GetFieldCounter, //_API_GetFieldCounter
NullBiosHandler, //_API_HostGetChar
NullBiosHandler, //_API_HostPutChar
NullBiosHandler, //_API_HostPeekChar
NullBiosHandler, //_API_HostQuery
NullBiosHandler, //_API_HostPeek
NullBiosHandler, //_API_HostWrite
NullBiosHandler, //_API_TryHostSend
NullBiosHandler, //_API_EchoEnable
NullBiosHandler, //_API_EchoDisable
API_FindDiskType, //_API_FindDiskType
NullBiosHandler, //_API_DriveReset
NullBiosHandler, //_API_TitleKey
NullBiosHandler, //_API_SearchDisk
NullBiosHandler, //_API_DMA_Read32
NullBiosHandler, //_API_DVD_IFO_Read
NullBiosHandler, //_API_DVD_SetEndOfDat
NullBiosHandler, //_API_DVD_SetEndOfLay
NullBiosHandler, //_API_DVD_DiskIsOpposite
NullBiosHandler, //_API_DVD_DiskIsParallel
NullBiosHandler, //_API_CSS_ReadKeyA
NullBiosHandler, //_API_CSS_ReadKeyB
NullBiosHandler, //_API_StopDrive
NullBiosHandler, //_API_DVD_ReadPSNsToC
NullBiosHandler, //_API_DiskType
NullBiosHandler, //_API_DVD_IsDiskOpposite
NullBiosHandler, //_API_DVD_DriveSetDisabled
NullBiosHandler, //_API_ReadPSNs
NullBiosHandler, //_API_FastReadPSNs
NullBiosHandler, //_API_ReadCPR_MAI
NullBiosHandler, //_API_StartReadPSNs
NullBiosHandler, //_API_ReadPSNsDone
NullBiosHandler, //_API_ResetReadPSNs
NullBiosHandler, //_API_TrickType
NullBiosHandler, //_API_I2C_StartMaster
NullBiosHandler, //_API_I2C_StartMaster
NullBiosHandler, //_API_I2C_StartMaster
NullBiosHandler, //_API_I2C_MasterWrite
NullBiosHandler, //_API_I2C_MasterReadD
NullBiosHandler, //_API_I2C_MasterWrite
NullBiosHandler, //_API_I2C_MasterReset
NullBiosHandler, //_API_FindVMG_Key
NullBiosHandler, //_API_VMG
NullBiosHandler, //_API_FindTitleKey
NullBiosHandler, //_API_VTSN
NullBiosHandler, //_API_RLBN_To_PSN
NullBiosHandler, //_API_LSN_To_PSN
NullBiosHandler, //_API_FindUDFFile
NullBiosHandler, //_API_FirstLSN
NullBiosHandler, //_API_FirstDataSector
NullBiosHandler, //_API_DVD_Mount
NullBiosHandler, //_API_DVD_UnMount
NullBiosHandler, //_API_HasDVDVideo
NullBiosHandler, //_API_HasDVDAudio
NullBiosHandler, //_API_SelectDVDVideo
NullBiosHandler, //_API_SelectDVDAudio
NullBiosHandler, //_API_FindDiskKey
NullBiosHandler, //_API_SetDiskKey
NullBiosHandler, //_API_SetTitleKey
NullBiosHandler, //_API_SetEndOfDataSec
NullBiosHandler, //_API_SetEndOfLayer0S
NullBiosHandler, //_API_DVD_TempRead
NullBiosHandler, //_API_DVD_ReadBlock
NullBiosHandler, //_API_DVD_ReadBlocks
NullBiosHandler, //_API_FP_Ready
NullBiosHandler, //_API_FP_Send
NullBiosHandler, //_API_HaveIRInput
NullBiosHandler, //_API_IR_Receiver
NullBiosHandler, //_API_PollIRController
NullBiosHandler, //_API_FlashErase
NullBiosHandler, //_API_HaveFlash
NullBiosHandler, //_API_FlashBusy
NullBiosHandler, //_API_FlashRead
NullBiosHandler, //_API_FlashWrite
NullBiosHandler, //_API_FetchNVData
NullBiosHandler, //_API_StoreNVData
NullBiosHandler, //_API_Start
NullBiosHandler, //_API_GetControlEvent
NullBiosHandler, //_API_TranslateEvent
NullBiosHandler, //_API_FLDisplay
NullBiosHandler, //_API_MemScratch
NullBiosHandler, //_API_StackInfoAddres
NullBiosHandler, //_API_CommXmit
NullBiosHandler, //_API_DVD_IFO_ReadBlock
NullBiosHandler, //_API_IsTrayOut
NullBiosHandler, //_API_DVD_ReMount
NullBiosHandler, //_API_LoadPE
NullBiosHandler, //_API_SetPowerState
NullBiosHandler, //_API_DVD_DriveIsTray
NullBiosHandler, //_API_CancelAPS
NullBiosHandler, //_API_TVSystem
NullBiosHandler, //_API_IsTrayEmpty
NullBiosHandler, //_API_ReadPSNsOK
NullBiosHandler, //_API_SetDiskType
NullBiosHandler, //_API_GetTitleKey
NullBiosHandler, //_API_FlashSectorSize
NullBiosHandler, //_API_GetError
};
NuonBiosHandler DVD_API_Table[] = {
API_StepOneFrame, //_API_StepOneFrame
API_AUDIOStreamSelect, //_API_AUDIOStreamSelect
NullBiosHandler, //_API_SetSPPalette
NullBiosHandler, //_API_SPStreamSelection
NullBiosHandler, //_API_VideoAttributes
NullBiosHandler, //_API_ChangeAngle
NullBiosHandler, //_API_Speed
NullBiosHandler, //_API_Rate
API_ForwardSpeed, //_API_ForwardSpeed
NullBiosHandler, //_API_BackwardSpeed
NullBiosHandler, //_API_IsForward
NullBiosHandler, //_API_IsReverse
NullBiosHandler, //_API_PauseOn
NullBiosHandler, //_API_PauseOff
NullBiosHandler, //_API_Paused
NullBiosHandler, //_API_ReleaseVOBU_Still
NullBiosHandler, //_API_StillOff
NullBiosHandler, //_API_StopDVD
NullBiosHandler, //_API_SetButton
API_PresentCell, //_API_PresentCell
API_CellReadDone, //_API_CellReadDone
API_StartCellStill, //_API_StartCellStill
API_CellStillDone, //_API_CellStillDone
NullBiosHandler, //_API_VOBU_UOP_CTL
API_IsPresenting, //_API_IsPresenting
NullBiosHandler, //_API_InVOBU_Still
NullBiosHandler, //_API_GetVOBU_Count
NullBiosHandler, //_API_FetchNAVPACK
NullBiosHandler, //_API_PTM
NullBiosHandler, //_API_S_PTM
NullBiosHandler, //_API_E_PTM
NullBiosHandler, //_API_ELTM
NullBiosHandler, //_API_GetVOBU_EA
NullBiosHandler, //_API_SetVOBU_Count
NullBiosHandler, //_API_HideButton
API_ProgramChange, //_API_ProgramChange
API_SetAngle, //_API_SetAngle
NullBiosHandler, //_API_ButtonDisplayMode
NullBiosHandler, //_API_NAVPACKADR
NullBiosHandler, //_API_GetNavPackAdr
NullBiosHandler, //_API_GetButtonCMD
NullBiosHandler, //_API_Button
NullBiosHandler, //_API_ButtonActivate
NullBiosHandler, //_API_SelectAndActivate
NullBiosHandler, //_API_UpperButton
NullBiosHandler, //_API_LowerButton
NullBiosHandler, //_API_LeftButton
NullBiosHandler, //_API_RightButton
NullBiosHandler, //_API_NumberOfButtons
NullBiosHandler, //_API_AutoActionButton
NullBiosHandler, //_API_ButtonSelect
NullBiosHandler, //_API_ButtonGroup
NullBiosHandler, //_API_AllowFOSL
NullBiosHandler, //_API_FreezeDisplayMode
NullBiosHandler, //_API_SlowDisplayMode
NullBiosHandler, //_API_TrickDisplayMode
NullBiosHandler, //_API_VOBU_Jump
NullBiosHandler, //_API_GetAngle
NullBiosHandler, //_API_AllowFSTA
NullBiosHandler, //_API_GetAudioStreamNumber
NullBiosHandler, //_API_GetSPStreamNumber
API_PresentVOB, //_API_PresentVOB
NullBiosHandler, //_API_SetScreenFit
NullBiosHandler, //_API_VOBU_HasVideo
NullBiosHandler, //_API_SetAudioStreamNumber
NullBiosHandler, //_API_CSS
NullBiosHandler, //_API_PresentStream
NullBiosHandler, //_API_CancelProcessed
NullBiosHandler, //_API_DisplayProcessed
NullBiosHandler, //_API_DisplayingFrame
NullBiosHandler, //_API_PresentDualStreams
NullBiosHandler, //_API_GetNonVideoNavP
NullBiosHandler, //_API_SetPECompatLevel
NullBiosHandler //_API_ButtonOffsetNo
};
void InitDVDJumpTable()
{
for(uint32 i = 0; i < 1024; i++)
{
PatchJumptable(DVD_JUMPTABLE_START + (i << 3UL), ROM_PE_BASE + (i << 3));
}
}
void CallPEHandler(MPE &mpe, const uint32 address)
{
if(((address & 0x8FFFFFFFUL) < SVC_API_JUMPTABLE_START) || ((address & 0x8FFFFFFFUL) >= PTR_API_JUMPTABLE_START))
{
return;
}
else
{
const uint32 offset = (address >> 3) & 0x7F;
NuonBiosHandler* table;
switch((address >> 10) & 0x7)
{
case 0:
table = SVC_API_Table;
break;
case 1:
//table = Audio_API_Table;
return;
break;
case 2:
//table = CDA_API_Table;
return;
break;
case 3:
table = DVD_API_Table;
break;
case 4:
//offset &= 0x3F;
//table = DVDA_API_Table;
//if((address & 0x200)
//{
// table = NTC_API_Table;
//}
return;
break;
case 5:
//table = SVR_API_Table;
return;
break;
case 6:
//table = VCD_API_Table;
return;
break;
case 7:
//table = VIDEO_API_Table;
return;
break;
default:
assert(false);
return;
break;
}
table[offset](mpe);
}
}