VI (Thanks HeartPiece) and CStaticAudio work

Former-commit-id: 4babadb501a53ed61876f37a6a60fba76de55e02
This commit is contained in:
Phillip Stephens 2023-10-19 19:10:34 -07:00
parent f49069d4e6
commit 392fa91842
11 changed files with 2347 additions and 69 deletions

View File

@ -15293,18 +15293,18 @@ fmult__Fii = .text:0x8036BB24; // type:function size:0xE0 scope:local
quan__FiPsi = .text:0x8036BC04; // type:function size:0x30 scope:local
SetVolume__18CStaticAudioPlayerFc = .text:0x8036BC34; // type:function size:0x28 scope:global
DecodeMonoAndMix__18CStaticAudioPlayerCFv = .text:0x8036BC5C; // type:function size:0x194 scope:global
Decode__18CStaticAudioPlayerFv = .text:0x8036BDF0; // type:function size:0x124 scope:global
DoMix__18CStaticAudioPlayer = .text:0x8036BF14; // type:function size:0xBC scope:global
Decode__18CStaticAudioPlayerFPUsPUsUi = .text:0x8036BDF0; // type:function size:0x124 scope:global
DoMix__18CStaticAudioPlayerFv = .text:0x8036BF14; // type:function size:0xBC scope:global
MixCallback__18CStaticAudioPlayerFv = .text:0x8036BFD0; // type:function size:0x24 scope:global
StopMixOut__18CStaticAudioPlayerFv = .text:0x8036BFF4; // type:function size:0x3C scope:global
StartMixOut__18CStaticAudioPlayerFv = .text:0x8036C030; // type:function size:0xD4 scope:global
IsReady__18CStaticAudioPlayer = .text:0x8036C104; // type:function size:0x54 scope:global
__dt__18CStaticAudioPlayer = .text:0x8036C158; // type:function size:0xB0 scope:global
fn_8036C208 = .text:0x8036C208; // type:function size:0xD0
__ct__18CStaticAudioPlayerFRCQ24rstl12basic_stringii = .text:0x8036C2D8; // type:function size:0x30C scope:global
fn_8036C5E4 = .text:0x8036C5E4; // type:function size:0x120
fn_8036C704 = .text:0x8036C704; // type:function size:0xD8
RunDMACallback__18CStaticAudioPlayerFv = .text:0x8036C7DC; // type:function size:0xA0 scope:global
IsReady__18CStaticAudioPlayerCFv = .text:0x8036C104; // type:function size:0x54 scope:global
__dt__18CStaticAudioPlayerFv = .text:0x8036C158; // type:function size:0xB0 scope:global
__dt__Q24rstl67vector<Q24rstl23auto_ptr<11CDvdRequest>,Q24rstl17rmemory_allocator>Fv = .text:0x8036C208; // type:function size:0xD0
__ct__18CStaticAudioPlayerFRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>ii = .text:0x8036C2D8; // type:function size:0x30C scope:global
reserve__Q24rstl67vector<Q24rstl23auto_ptr<11CDvdRequest>,Q24rstl17rmemory_allocator>Fi = .text:0x8036C5E4; // type:function size:0x120
CancelDMACallback__18CStaticAudioPlayerFPFv_v = .text:0x8036C704; // type:function size:0xD8
RunDMACallback__18CStaticAudioPlayerFPFv_v = .text:0x8036C7DC; // type:function size:0xA0 scope:global
fn_8036C87C = .text:0x8036C87C; // type:function size:0x74
fn_8036C8F0 = .text:0x8036C8F0; // type:function size:0xA4
__sinit_CStaticAudioPlayer_cpp = .text:0x8036C994; // type:function size:0x3C scope:local
@ -22084,7 +22084,7 @@ lbl_805A9690 = .sbss:0x805A9690; // type:object size:0x1 data:byte
lbl_805A9694 = .sbss:0x805A9694; // type:object size:0x1 data:byte
lbl_805A9698 = .sbss:0x805A9698; // type:object size:0x1 data:byte
lbl_805A969C = .sbss:0x805A969C; // type:object size:0x1 data:byte
lbl_805A96A0 = .sbss:0x805A96A0; // type:object size:0x8 data:4byte
sCurrentPlayer = .sbss:0x805A96A0; // type:object size:0x8 scope:local data:4byte
lbl_805A96A8 = .sbss:0x805A96A8; // type:object size:0x1 data:byte
lbl_805A96AC = .sbss:0x805A96AC; // type:object size:0x4 data:4byte
lbl_805A96B0 = .sbss:0x805A96B0; // type:object size:0x8 data:4byte
@ -22228,27 +22228,25 @@ PendingBits = .sbss:0x805A9948; // type:object size:0x4 scope:local data:4byte
SamplingCallback = .sbss:0x805A994C; // type:object size:0x4 scope:local data:4byte
recalibrated$396 = .sbss:0x805A9950; // type:object size:0x4 scope:local data:4byte
__PADSpec = .sbss:0x805A9954; // type:object size:0x4 scope:global data:4byte
lbl_805A9958 = .sbss:0x805A9958; // type:object size:0x4 data:4byte
IsInitialized = .sbss:0x805A9958; // type:object size:0x4 scope:local data:4byte
lbl_805A995C = .sbss:0x805A995C; // type:object size:0x4 data:4byte
lbl_805A9960 = .sbss:0x805A9960; // type:object size:0x4 data:4byte
lbl_805A9964 = .sbss:0x805A9964; // type:object size:0x8
lbl_805A996C = .sbss:0x805A996C; // type:object size:0x4 data:4byte
lbl_805A9970 = .sbss:0x805A9970; // type:object size:0x4 data:4byte
lbl_805A9974 = .sbss:0x805A9974; // type:object size:0x4 data:4byte
lbl_805A9978 = .sbss:0x805A9978; // type:object size:0x2 data:2byte
lbl_805A997A = .sbss:0x805A997A; // type:object size:0x2 data:2byte
lbl_805A997C = .sbss:0x805A997C; // type:object size:0x4 data:4byte
lbl_805A9980 = .sbss:0x805A9980; // type:object size:0x4 data:4byte
lbl_805A9984 = .sbss:0x805A9984; // type:object size:0x4 data:4byte
lbl_805A9988 = .sbss:0x805A9988; // type:object size:0x8 data:4byte
lbl_805A9990 = .sbss:0x805A9990; // type:object size:0x4 data:4byte
lbl_805A9994 = .sbss:0x805A9994; // type:object size:0x4 data:4byte
lbl_805A9998 = .sbss:0x805A9998; // type:object size:0x4 data:4byte
encoderType = .sbss:0x805A9974; // type:object size:0x4 data:4byte
displayOffsetH = .sbss:0x805A9978; // type:object size:0x2 data:2byte
displayOffsetV = .sbss:0x805A997A; // type:object size:0x2 data:2byte
changeMode = .sbss:0x805A997C; // type:object size:0x4 scope:local data:4byte
changed = .sbss:0x805A9980; // type:object size:0x8 scope:local data:8byte
shdwChangeMode = .sbss:0x805A9988; // type:object size:0x4 scope:local data:4byte
shdwChanged = .sbss:0x805A9990; // type:object size:0x8 scope:local data:8byte
CurrTiming = .sbss:0x805A9998; // type:object size:0x4 scope:local data:4byte
CurrTvMode = .sbss:0x805A999C; // type:object size:0x4 scope:local data:4byte
lbl_805A99A0 = .sbss:0x805A99A0; // type:object size:0x4 data:4byte
lbl_805A99A4 = .sbss:0x805A99A4; // type:object size:0x4 data:4byte
lbl_805A99A8 = .sbss:0x805A99A8; // type:object size:0x4 data:4byte
lbl_805A99AC = .sbss:0x805A99AC; // type:object size:0x4 data:4byte
NextBufAddr = .sbss:0x805A99A0; // type:object size:0x4 scope:local data:4byte
CurrBufAddr = .sbss:0x805A99A4; // type:object size:0x4 scope:local data:4byte
FBSet = .sbss:0x805A99A8; // type:object size:0x4 scope:local data:4byte
message$329 = .sbss:0x805A99AC; // type:object size:0x4 scope:local data:4byte
__global_destructor_chain = .sbss:0x805A99B0; // type:object size:0x4 scope:global data:4byte
__aborting = .sbss:0x805A99B8; // type:object size:0x4 scope:global data:4byte
__atexit_curr_func = .sbss:0x805A99BC; // type:object size:0x4 scope:local data:4byte

View File

@ -15308,18 +15308,18 @@ fmult__Fii = .text:0x8036BD00; // type:function size:0xE0 scope:local
quan__FiPsi = .text:0x8036BDE0; // type:function size:0x30 scope:local
SetVolume__18CStaticAudioPlayerFc = .text:0x8036BE10; // type:function size:0x28 scope:global
DecodeMonoAndMix__18CStaticAudioPlayerCFv = .text:0x8036BE38; // type:function size:0x194 scope:global
Decode__18CStaticAudioPlayerFv = .text:0x8036BFCC; // type:function size:0x124 scope:global
DoMix__18CStaticAudioPlayer = .text:0x8036C0F0; // type:function size:0xBC scope:global
Decode__18CStaticAudioPlayerFPUsPUsUi = .text:0x8036BFCC; // type:function size:0x124 scope:global
DoMix__18CStaticAudioPlayerFv = .text:0x8036C0F0; // type:function size:0xBC scope:global
MixCallback__18CStaticAudioPlayerFv = .text:0x8036C1AC; // type:function size:0x24 scope:global
StopMixOut__18CStaticAudioPlayerFv = .text:0x8036C1D0; // type:function size:0x3C scope:global
StartMixOut__18CStaticAudioPlayerFv = .text:0x8036C20C; // type:function size:0xD4 scope:global
IsReady__18CStaticAudioPlayer = .text:0x8036C2E0; // type:function size:0x54 scope:global
__dt__18CStaticAudioPlayer = .text:0x8036C334; // type:function size:0xB0 scope:global
fn_8036C208 = .text:0x8036C3E4; // type:function size:0xD0 scope:global
__ct__18CStaticAudioPlayerFRCQ24rstl12basic_stringii = .text:0x8036C4B4; // type:function size:0x30C scope:global
fn_8036C5E4 = .text:0x8036C7C0; // type:function size:0x120 scope:global
fn_8036C704 = .text:0x8036C8E0; // type:function size:0xD8 scope:global
RunDMACallback__18CStaticAudioPlayerFv = .text:0x8036C9B8; // type:function size:0xA0 scope:global
IsReady__18CStaticAudioPlayerCFv = .text:0x8036C2E0; // type:function size:0x54 scope:global
__dt__18CStaticAudioPlayerFv = .text:0x8036C334; // type:function size:0xB0 scope:global
__dt__Q24rstl67vector<Q24rstl23auto_ptr<11CDvdRequest>,Q24rstl17rmemory_allocator>Fv = .text:0x8036C3E4; // type:function size:0xD0 scope:global
__ct__18CStaticAudioPlayerFRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>ii = .text:0x8036C4B4; // type:function size:0x30C scope:global
reserve__Q24rstl67vector<Q24rstl23auto_ptr<11CDvdRequest>,Q24rstl17rmemory_allocator>Fi = .text:0x8036C7C0; // type:function size:0x120 scope:global
CancelDMACallback__18CStaticAudioPlayerFPFv_v = .text:0x8036C8E0; // type:function size:0xD8 scope:global
RunDMACallback__18CStaticAudioPlayerFPFv_v = .text:0x8036C9B8; // type:function size:0xA0 scope:global
fn_8036C87C = .text:0x8036CA58; // type:function size:0x74 scope:global
fn_8036C8F0 = .text:0x8036CACC; // type:function size:0xA4 scope:global
__sinit_CStaticAudioPlayer_cpp = .text:0x8036CB70; // type:function size:0x3C scope:global
@ -22130,7 +22130,7 @@ lbl_805A9690 = .sbss:0x805A9870; // type:object size:0x1 scope:global data:byte
lbl_805A9694 = .sbss:0x805A9874; // type:object size:0x1 scope:global data:byte
lbl_805A9698 = .sbss:0x805A9878; // type:object size:0x1 scope:global data:byte
lbl_805A969C = .sbss:0x805A987C; // type:object size:0x1 scope:global data:byte
lbl_805A96A0 = .sbss:0x805A9880; // type:object size:0x8 scope:global data:4byte
sCurrentPlayer = .sbss:0x805A9880; // type:object size:0x8 scope:global data:4byte
lbl_805A96A8 = .sbss:0x805A9888; // type:object size:0x1 scope:global data:byte
lbl_805A96AC = .sbss:0x805A988C; // type:object size:0x4 scope:global data:4byte
lbl_805A96B0 = .sbss:0x805A9890; // type:object size:0x8 scope:global data:4byte
@ -22281,15 +22281,15 @@ lbl_805A9964 = .sbss:0x805A9B44; // type:object size:0x8 scope:local
lbl_805A996C = .sbss:0x805A9B4C; // type:object size:0x4 scope:local data:4byte
lbl_805A9970 = .sbss:0x805A9B50; // type:object size:0x4 scope:local data:4byte
lbl_805A9974 = .sbss:0x805A9B54; // type:object size:0x4 scope:local data:4byte
lbl_805A9978 = .sbss:0x805A9B58; // type:object size:0x2 scope:local data:2byte
lbl_805A997A = .sbss:0x805A9B5A; // type:object size:0x2 scope:local data:2byte
displayOffsetH = .sbss:0x805A9B58; // type:object size:0x2 scope:local data:2byte
displayOffsetV = .sbss:0x805A9B5A; // type:object size:0x2 scope:local data:2byte
lbl_805A997C = .sbss:0x805A9B5C; // type:object size:0x4 scope:local data:4byte
lbl_805A9980 = .sbss:0x805A9B60; // type:object size:0x4 scope:local data:4byte
lbl_805A9984 = .sbss:0x805A9B64; // type:object size:0x4 scope:local data:4byte
lbl_805A9988 = .sbss:0x805A9B68; // type:object size:0x8 scope:local data:4byte
lbl_805A9990 = .sbss:0x805A9B70; // type:object size:0x4 scope:local data:4byte
lbl_805A9994 = .sbss:0x805A9B74; // type:object size:0x4 scope:local data:4byte
lbl_805A9998 = .sbss:0x805A9B78; // type:object size:0x4 scope:local data:4byte
CurrTiming = .sbss:0x805A9B78; // type:object size:0x4 scope:local data:4byte
CurrTvMode = .sbss:0x805A9B7C; // type:object size:0x4 scope:local data:4byte
lbl_805A99A0 = .sbss:0x805A9B80; // type:object size:0x4 scope:local data:4byte
lbl_805A99A4 = .sbss:0x805A9B84; // type:object size:0x4 scope:local data:4byte

View File

@ -0,0 +1,43 @@
#ifndef _CSTATICAUDIOPLAYER
#define _CSTATICAUDIOPLAYER
#include <Kyoto/Audio/g721.h>
#include <rstl/auto_ptr.hpp>
#include <rstl/string.hpp>
#include <rstl/vector.hpp>
class CDvdRequest;
typedef void (*FAudioCallback)();
class CStaticAudioPlayer {
public:
CStaticAudioPlayer(const rstl::string& filepath, const int w1, const int w2);
~CStaticAudioPlayer();
const bool IsReady() const;
void StartMixOut();
void StopMixOut();
static void MixCallback();
void DoMix();
static void RunDMACallback(FAudioCallback);
static void CancelDMACallback(FAudioCallback);
void Decode(ushort* bufIn, ushort* bufOut, uint numSamples);
private:
rstl::string x0_filepath;
int x10_rsfRem;
int x14_rsfLength;
int x18_curSamp;
int x1c_loopStartSamp;
int x20_loopEndSamp;
int x24_curBuf;
rstl::auto_ptr< uchar > x28_dmaLeft;
rstl::auto_ptr< uchar > x30_dmaRight;
rstl::vector< rstl::auto_ptr< CDvdRequest > > x38_dvdRequests;
rstl::vector< rstl::auto_ptr< uchar > > x48_buffers;
g72x_state x58_leftState;
g72x_state x8c_rightState;
ushort xc0_volume;
};
#endif // _CSTATICAUDIOPLAYER

View File

@ -3,6 +3,9 @@
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*AISCallback)(u32 count);
typedef void (*AIDCallback)();
@ -33,4 +36,8 @@ void AIInit(u8* stack);
BOOL AICheckInit();
void AIReset();
#ifdef __cplusplus
}
#endif
#endif // _DOLPHIN_AI

View File

@ -3,41 +3,12 @@
#include <dolphin/gx/GXEnum.h>
#include <dolphin/types.h>
#include <dolphin/vitypes.h>
#ifdef __cplusplus
extern "C" {
#endif
#define VI_TVMODE(format, interlace) (((format) << 2) + (interlace))
#define VI_INTERLACE 0
#define VI_NON_INTERLACE 1
#define VI_PROGRESSIVE 2
#define VI_NTSC 0
#define VI_PAL 1
#define VI_MPAL 2
#define VI_DEBUG 3
#define VI_DEBUG_PAL 4
#define VI_EURGB60 5
typedef enum {
VI_TVMODE_NTSC_INT = VI_TVMODE(VI_NTSC, VI_INTERLACE),
VI_TVMODE_NTSC_DS = VI_TVMODE(VI_NTSC, VI_NON_INTERLACE),
VI_TVMODE_NTSC_PROG = VI_TVMODE(VI_NTSC, VI_PROGRESSIVE),
VI_TVMODE_PAL_INT = VI_TVMODE(VI_PAL, VI_INTERLACE),
VI_TVMODE_PAL_DS = VI_TVMODE(VI_PAL, VI_NON_INTERLACE),
VI_TVMODE_EURGB60_INT = VI_TVMODE(VI_EURGB60, VI_INTERLACE),
VI_TVMODE_EURGB60_DS = VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE),
VI_TVMODE_MPAL_INT = VI_TVMODE(VI_MPAL, VI_INTERLACE),
VI_TVMODE_MPAL_DS = VI_TVMODE(VI_MPAL, VI_NON_INTERLACE),
VI_TVMODE_DEBUG_INT = VI_TVMODE(VI_DEBUG, VI_INTERLACE),
VI_TVMODE_DEBUG_PAL_INT = VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE),
VI_TVMODE_DEBUG_PAL_DS = VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE)
} VITVMode;
typedef enum { VI_XFBMODE_SF = 0, VI_XFBMODE_DF } VIXFBMode;
typedef struct _GXRenderModeObj {
/*0x00*/ VITVMode viTVmode;
/*0x04*/ u16 fbWidth;

View File

@ -8,15 +8,217 @@ extern "C" {
#endif
#ifdef __MWERKS__
vu16 __VIRegs[59] : 0xCC002000;
// offsets for __VIRegs[i]
#define VI_VERT_TIMING (0)
#define VI_DISP_CONFIG (1)
#define VI_HORIZ_TIMING_0L (2)
#define VI_HORIZ_TIMING_0U (3)
#define VI_HORIZ_TIMING_1L (4)
#define VI_HORIZ_TIMING_1U (5)
#define VI_VERT_TIMING_ODD (6)
#define VI_VERT_TIMING_ODD_U (7)
#define VI_VERT_TIMING_EVEN (8)
#define VI_VERT_TIMING_EVEN_U (9)
#define VI_BBI_ODD (10) // burst blanking interval
#define VI_BBI_ODD_U (11) // burst blanking interval
#define VI_BBI_EVEN (12) // burst blanking interval
#define VI_BBI_EVEN_U (13) // burst blanking interval
#define VI_TOP_FIELD_BASE_LEFT (14) // top in 2d, top of left pic in 3d
#define VI_TOP_FIELD_BASE_LEFT_U (15) // top in 2d, top of left pic in 3d
#define VI_TOP_FIELD_BASE_RIGHT (16) // top of right pic in 3d
#define VI_TOP_FIELD_BASE_RIGHT_U (17) // top of right pic in 3d
#define VI_BTTM_FIELD_BASE_LEFT (18) // bottom in 2d, bottom of left pic in 3d
#define VI_BTTM_FIELD_BASE_LEFT_U (19) // bottom in 2d, bottom of left pic in 3d
#define VI_BTTM_FIELD_BASE_RIGHT (20) // bottom of right pic in 3d
#define VI_BTTM_FIELD_BASE_RIGHT_U (21) // bottom of right pic in 3d
#define VI_VERT_COUNT (22) // vertical display position
#define VI_HORIZ_COUNT (23) // horizontal display position
#define VI_DISP_INT_0 (24) // display interrupt 0L
#define VI_DISP_INT_0U (25) // display interrupt 0U
#define VI_DISP_INT_1 (26) // display interrupt 1L
#define VI_DISP_INT_1U (27) // display interrupt 1U
#define VI_DISP_INT_2 (28) // display interrupt 2L
#define VI_DISP_INT_2U (29) // display interrupt 2U
#define VI_DISP_INT_3 (30) // display interrupt 3L
#define VI_DISP_INT_3U (31) // display interrupt 3U
#define VI_HSW (36) // horizontal scaling width
#define VI_HSR (37) // horizontal scaling register
#define VI_FCT_0 (38) // filter coefficient table 0L
#define VI_FCT_0U (39) // filter coefficient table 0U
#define VI_FCT_1 (40) // filter coefficient table 1L
#define VI_FCT_1U (41) // filter coefficient table 1U
#define VI_FCT_2 (42) // filter coefficient table 2L
#define VI_FCT_2U (43) // filter coefficient table 2U
#define VI_FCT_3 (44) // filter coefficient table 3L
#define VI_FCT_3U (45) // filter coefficient table 3U
#define VI_FCT_4 (46) // filter coefficient table 4L
#define VI_FCT_4U (47) // filter coefficient table 4U
#define VI_FCT_5 (48) // filter coefficient table 5L
#define VI_FCT_5U (49) // filter coefficient table 5U
#define VI_FCT_6 (50) // filter coefficient table 6L
#define VI_FCT_6U (51) // filter coefficient table 6U
#define VI_CLOCK_SEL (54) // clock select
#define VI_DTV_STAT (55) // DTV status
#define VI_WIDTH (56)
vu32 __PIRegs[12] : 0xCC003000;
// offsets for __PIRegs[i]
#define PI_INTRPT_SRC (0) // interrupt cause
#define PI_INTRPT_MASK (1) // interrupt mask
#define PI_FIFO_START (3) // FIFO base start
#define PI_FIFO_END (4) // FIFO base end
#define PI_FIFO_PTR (5) // FIFO current write pointer
#define PI_RESETCODE (9) // reset code, used by OSReset
// PI Interrupt causes.
#define PI_INTRPT_ERR (0x1) // GP runtime error
#define PI_INTRPT_RSW (0x2) // reset switch
#define PI_INTRPT_DVD (0x4) // DVD/DI interrupt
#define PI_INTRPT_SI (0x8) // serial/controller interrupt
#define PI_INTRPT_EXI (0x10) // external mem interrupt
#define PI_INTRPT_AI (0x20) // audio streaming interrupt
#define PI_INTRPT_DSP (0x40) // digital signal proc interrupt
#define PI_INTRPT_MEM (0x80) // memory interface interrupt
#define PI_INTRPT_VI (0x100) // video interface interrupt
#define PI_INTRPT_PE_TOKEN (0x200) // pixel engine token
#define PI_INTRPT_PE_FINISH (0x400) // pixel engine finish
#define PI_INTRPT_CP (0x800) // command FIFO
#define PI_INTRPT_DEBUG (0x1000) // external debugger
#define PI_INTRPT_HSP (0x2000) // high speed port
#define PI_INTRPT_RSWST (0x10000) // reset switch state (1 when pressed)
vu16 __MEMRegs[64] : 0xCC004000;
// offsets for __MEMRegs[i]
#define MEM_PROT_1 (0) // protected region 1
#define MEM_PROT_2 (2) // protected region 1
#define MEM_PROT_3 (4) // protected region 1
#define MEM_PROT_4 (6) // protected region 1
#define MEM_PROT_TYPE (8) // protection type
#define MEM_INTRPT_MASK (14) // interrupt mask
#define MEM_INTRPT_SRC (15) // interrupt cause
#define MEM_INTRPT_FLAG (16) // set when interrupt happens
#define MEM_INTRPT_ADDR_LO (17) // address that caused interrupt
#define MEM_INTRPT_ADDR_HI (18) // address that caused interrupt
#define MEM_UNK_FLAG (20) // unknown memory flag, set in __OSInitMemoryProtection
vu16 __DSPRegs[32] : 0xCC005000;
// offsets for __DSPRegs[i]
#define DSP_MAILBOX_IN_HI (0)
#define DSP_MAILBOX_IN_LO (1)
#define DSP_MAILBOX_OUT_HI (2)
#define DSP_MAILBOX_OUT_LO (3)
#define DSP_CONTROL_STATUS (5)
#define DSP_ARAM_SIZE (9)
#define DSP_ARAM_MODE (11)
#define DSP_ARAM_REFRESH (13)
#define DSP_ARAM_DMA_MM_HI (16) // Main mem address
#define DSP_ARAM_DMA_MM_LO (17)
#define DSP_ARAM_DMA_ARAM_HI (18) // ARAM address
#define DSP_ARAM_DMA_ARAM_LO (19)
#define DSP_ARAM_DMA_SIZE_HI (20) // DMA buffer size
#define DSP_ARAM_DMA_SIZE_LO (21)
#define DSP_DMA_START_HI (24) // DMA start address
#define DSP_DMA_START_LO (25)
#define DSP_DMA_CONTROL_LEN (27)
#define DSP_DMA_BYTES_LEFT (29)
vu32 __DIRegs[16] : 0xCC006000;
// offsets for __DIRegs[i]
#define DI_STATUS (0)
#define DI_COVER_STATUS (1) // cover status - 0=normal, 1=interrupt/open
#define DI_CMD_BUF_0 (2) // command buffer 0
#define DI_CMD_BUF_1 (3) // command buffer 1
#define DI_CMD_BUF_2 (4) // command buffer 2
#define DI_DMA_MEM_ADDR (5) // DMA address
#define DI_DMA_LENGTH (6) // transfer length address
#define DI_CONTROL (7)
#define DI_MM_BUF (8) // Main memory buffer
#define DI_CONFIG (9)
vu32 __SIRegs[64] : 0xCC006400;
// offsets for __SIRegs[i]
// Channel 0/Joy-channel 1
#define SI_CHAN_0_BUF (0) // output buffer
#define SI_CHAN_0_BTN_1 (1) // button 1
#define SI_CHAN_0_BTN_2 (2) // button 2
// Channel 1/Joy-channel 2
#define SI_CHAN_1_BUF (3) // output buffer
#define SI_CHAN_1_BTN_1 (4) // button 1
#define SI_CHAN_1_BTN_2 (5) // button 2
// Channel 2/Joy-channel 3
#define SI_CHAN_2_BUF (6) // output buffer
#define SI_CHAN_2_BTN_1 (7) // button 1
#define SI_CHAN_2_BTN_2 (8) // button 2
// Channel 3/Joy-channel 4
#define SI_CHAN_3_BUF (9) // output buffer
#define SI_CHAN_3_BTN_1 (10) // button 1
#define SI_CHAN_3_BTN_2 (11) // button 2
#define SI_POLL (12)
#define SI_CC_STAT (13) // communication control status
#define SI_STAT (14)
#define SI_EXI_LOCK (15) // exi clock lock
#define SI_IO_BUFFER (32) // start of buffer (32 to 63)
vu32 __EXIRegs[16] : 0xCC006800;
// offsets for __EXIRegs[i]
// Channel 0
#define EXI_CHAN_0_STAT (0) // parameters/status
#define EXI_CHAN_0_DMA_ADDR (1) // DMA start address
#define EXI_CHAN_0_LEN (2) // DMA transfer length
#define EXI_CHAN_0_CONTROL (3) // control register
#define EXI_CHAN_0_IMM (4) // immediate data
// Channel 1
#define EXI_CHAN_1_STAT (5) // parameters/status
#define EXI_CHAN_1_DMA_ADDR (6) // DMA start address
#define EXI_CHAN_1_LEN (7) // DMA transfer length
#define EXI_CHAN_1_CONTROL (8) // control register
#define EXI_CHAN_1_IMM (9) // immediate data
// Channel 2
#define EXI_CHAN_2_STAT (10) // parameters/status
#define EXI_CHAN_2_DMA_ADDR (11) // DMA start address
#define EXI_CHAN_2_LEN (12) // DMA transfer length
#define EXI_CHAN_2_CONTROL (13) // control register
#define EXI_CHAN_2_IMM (14) // immediate data
vu32 __AIRegs[8] : 0xCC006C00;
// offsets for __AIRegs[i]
#define AI_CONTROL (0) // control
#define AI_VOLUME (1) // volume
#define AI_SAMPLE_COUNTER (2) // number of stereo samples output
#define AI_INTRPT_TIMING (3) // interrupt timing
#else
#define __VIRegs ((vu16*)0xCC002000)
#define __PIRegs ((vu32*)0xCC003000)

View File

@ -9,7 +9,7 @@ extern "C" {
#endif
void VIInit(void);
void VIConfigure(GXRenderModeObj* rm);
void VIConfigure(const GXRenderModeObj* rm);
void VIFlush(void);
u32 VIGetTvFormat(void);
void VISetNextFrameBuffer(void* fb);

View File

@ -12,6 +12,7 @@ extern "C" {
u32 VIGetNextField(void);
VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback callback);
VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback callback);
void __VIGetCurrentPosition(s16* x, s16* y);
u32 VIGetDTVStatus(void);
#ifdef __cplusplus

View File

@ -7,8 +7,122 @@
extern "C" {
#endif
#define VI_INTERLACE 0
#define VI_NON_INTERLACE 1
#define VI_PROGRESSIVE 2
#define VI_3D 3
#define VI_NTSC 0
#define VI_PAL 1
#define VI_MPAL 2
#define VI_DEBUG 3
#define VI_DEBUG_PAL 4
#define VI_EURGB60 5
#define VI_GCA 6
#define VI_TVMODE(format, interlace) (((format) << 2) + (interlace))
typedef enum {
// NTSC
VI_TVMODE_NTSC_INT = VI_TVMODE(VI_NTSC, VI_INTERLACE),
VI_TVMODE_NTSC_DS = VI_TVMODE(VI_NTSC, VI_NON_INTERLACE),
VI_TVMODE_NTSC_PROG = VI_TVMODE(VI_NTSC, VI_PROGRESSIVE),
VI_TVMODE_NTSC_3D = VI_TVMODE(VI_NTSC, VI_3D),
// PAL
VI_TVMODE_PAL_INT = VI_TVMODE(VI_PAL, VI_INTERLACE),
VI_TVMODE_PAL_DS = VI_TVMODE(VI_PAL, VI_NON_INTERLACE),
// MPAL
VI_TVMODE_MPAL_INT = VI_TVMODE(VI_MPAL, VI_INTERLACE),
VI_TVMODE_MPAL_DS = VI_TVMODE(VI_MPAL, VI_NON_INTERLACE),
// Debug
VI_TVMODE_DEBUG_INT = VI_TVMODE(VI_DEBUG, VI_INTERLACE),
// Debug PAL
VI_TVMODE_DEBUG_PAL_INT = VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE),
VI_TVMODE_DEBUG_PAL_DS = VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE),
// EU RGB60
VI_TVMODE_EURGB60_INT = VI_TVMODE(VI_EURGB60, VI_INTERLACE),
VI_TVMODE_EURGB60_DS = VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE),
// GCA
VI_TVMODE_GCA_INT = VI_TVMODE(VI_GCA, VI_INTERLACE),
VI_TVMODE_GCA_DS = VI_TVMODE(VI_GCA, VI_NON_INTERLACE),
VI_TVMODE_GCA_PROG = VI_TVMODE(VI_GCA, VI_PROGRESSIVE),
} VITVMode;
typedef enum {
VI_XFBMODE_SF = 0,
VI_XFBMODE_DF = 1,
} VIXFBMode;
typedef void (*VIPositionCallback)(s16 x, s16 y);
typedef void (*VIRetraceCallback)(u32 retraceCount);
// Structure to use with timing in vi.c (size 0x28).
typedef struct VITimingInfo {
u8 equ; // _00
u16 acv; // _02
u16 prbOdd; // _04
u16 prbEven; // _06
u16 psbOdd; // _08
u16 psbEven; // _0A
u8 bs1; // _0C
u8 bs2; // _0D
u8 bs3; // _0E
u8 bs4; // _0F
u16 be1; // _10
u16 be2; // _12
u16 be3; // _14
u16 be4; // _16
u16 numHalfLines; // _18
u16 hlw; // _1A
u8 hsy; // _1C
u8 hcs; // _1D
u8 hce; // _1E
u8 hbe640; // _1F
u16 hbs640; // _20
u8 hbeCCIR656; // _24
u16 hbsCCIR656; // _26
} VITimingInfo;
// Structure to use with HorVer in vi.c (size 0x58).
typedef struct VIPositionInfo {
u16 dispPosX; // _00
u16 dispPosY; // _02
u16 dispSizeX; // _04
u16 dispSizeY; // _06
u16 adjDispPosX; // _08
u16 adjDispPosY; // _0A
u16 adjDispSizeY; // _0C
u16 adjPanPosY; // _0E
u16 adjPanSizeY; // _10
u16 fbSizeX; // _12
u16 fbSizeY; // _14
u16 panPosX; // _16
u16 panPosY; // _18
u16 panSizeX; // _1A
u16 panSizeY; // _1C
VIXFBMode xfbMode; // _20
u32 nonInter; // _24
u32 tv; // _28
u8 wordPerLine; // _2C
u8 std; // _2D
u8 wpl; // _2E
u32 bufAddr; // _30
u32 tfbb; // _34
u32 bfbb; // _38
u8 xof; // _3C
BOOL isBlack; // _40
BOOL is3D; // _44
u32 rbufAddr; // _48
u32 rtfbb; // _4C
u32 rbfbb; // _50
VITimingInfo* timing; // _54
} VIPositionInfo;
#ifdef __cplusplus
}
#endif

1835
src/Dolphin/vi.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,107 @@
#include <Kyoto/Alloc/CMemory.hpp>
#include <Kyoto/Audio/CStaticAudioPlayer.hpp>
#include <Kyoto/CDvdFile.hpp>
#include <Kyoto/CDvdRequest.hpp>
#include <dolphin/os.h>
#include <dolphin/ai.h>
extern "C" bool fn_8034A7A4();
extern "C" void fn_8036C8F0() {
bool b1 = fn_8034A7A4();
}
CStaticAudioPlayer* sCurrentPlayer = nullptr;
void CStaticAudioPlayer::RunDMACallback(FAudioCallback) {
}
void CStaticAudioPlayer::CancelDMACallback(FAudioCallback) {
}
CStaticAudioPlayer::CStaticAudioPlayer(const rstl::string& filepath, const int loopStart,
const int loopEnd)
: x0_filepath(filepath)
, x10_rsfRem(-1)
, x18_curSamp(0)
, x1c_loopStartSamp(loopStart & ~1)
, x20_loopEndSamp(loopEnd & ~1)
, x24_curBuf(0)
, x28_dmaLeft((uchar*)CMemory::Alloc(640, IAllocator::kHI_RoundUpLen))
, x30_dmaRight((uchar*)CMemory::Alloc(640, IAllocator::kHI_RoundUpLen))
, xc0_volume(32768) {
CDvdFile dvdFile(filepath.data());
x10_rsfRem = dvdFile.GetFileSize();
x14_rsfLength = x10_rsfRem;
int bufferCount = ((x10_rsfRem - 1) + 0x20000) / 0x20000;
x48_buffers.reserve(bufferCount);
x38_dvdRequests.reserve(bufferCount);
for (int i = x10_rsfRem; i > 0; i -= 0x20000) {
uint uVar1 = 0x20000;
if (i <= 0x20000) {
uVar1 = (i + 31) & ~31;
}
rstl::auto_ptr< uchar > buf((uchar*)CMemory::Alloc(uVar1, IAllocator::kHI_RoundUpLen));
x48_buffers.push_back(buf);
x38_dvdRequests.push_back(dvdFile.SyncRead(buf.get(), uVar1));
}
}
//#pragma push
#pragma inline_max_size(200)
CStaticAudioPlayer::~CStaticAudioPlayer() {
StopMixOut();
}
//#pragma pop
const bool CStaticAudioPlayer::IsReady() const {
return !x38_dvdRequests.empty() ? x38_dvdRequests.back()->IsComplete() : true;
}
void CStaticAudioPlayer::StartMixOut() {
if (sCurrentPlayer == this) {
return;
}
x38_dvdRequests.clear();
x18_curSamp = 0;
g72x_init_state(&x58_leftState);
g72x_init_state(&x8c_rightState);
sCurrentPlayer = this;
RunDMACallback(MixCallback);
}
void CStaticAudioPlayer::StopMixOut() {
if (sCurrentPlayer == this) {
CancelDMACallback(MixCallback);
sCurrentPlayer = NULL;
}
}
void CStaticAudioPlayer::MixCallback() {
sCurrentPlayer->DoMix();
}
void CStaticAudioPlayer::DoMix() {
u32 aiStart = OSCachedToPhysical(AIGetDMAStartAddr());
x24_curBuf ^= 1;
u32 buf = (u32)(x24_curBuf != 0 ? x30_dmaRight.get() : x28_dmaLeft.get());
AIInitDMA(buf, 0x280);
u32 cookie = OSEnableInterrupts();
if (aiStart != 0) {
DCInvalidateRange((void*)aiStart, 0x280);
}
Decode((ushort*)buf, (ushort*)aiStart, 160);
DCFlushRange((void*)buf, 0x280);
OSRestoreInterrupts(cookie);
}