Work on various dolphin libs

This commit is contained in:
Tal Hayon
2023-01-27 18:38:26 +02:00
parent d17c122e4d
commit 09f3d66390
32 changed files with 312 additions and 893 deletions
+19 -32
View File
@@ -641,43 +641,30 @@ s32 CARDFreeBlocks(s32 chan, s32* byteNotUsed, s32* filesNotUsed) {
return __CARDPutControlBlock(card, CARD_RESULT_READY);
}
/* 80353E20-80353EB8 34E760 0098+00 0/0 7/7 0/0 .text __CARDSync */
#ifdef NONMATCHING
s32 __CARDSync(s32 chan) {
s32 CARDGetResultCode(s32 chan)
{
CARDControl* card;
s32 val;
BOOL enabled;
s32 result;
if (chan < 0 || chan >= 2) {
return CARD_RESULT_FATAL_ERROR;
}
card = &__CARDBlock[chan];
return card->result;
}
/* 80353E20-80353EB8 34E760 0098+00 0/0 7/7 0/0 .text __CARDSync */
s32 __CARDSync(s32 chan) {
CARDControl* block;
s32 result;
s32 enabled;
block = &__CARDBlock[chan];
enabled = OSDisableInterrupts();
for (;; ) {
if (chan < 0 || chan >= 2)
result = -0x80;
else
result = card->result;
val = result;
if (val != CARD_RESULT_BUSY){
break;
} else {
OSSleepThread(&card->threadQueue);
}
}
while ((result = CARDGetResultCode(chan)) == -1) {
OSSleepThread(&block->threadQueue);
}
OSRestoreInterrupts(enabled);
return val;
return result;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm s32 __CARDSync(s32 chan) {
nofralloc
#include "asm/dolphin/card/CARDBios/__CARDSync.s"
}
#pragma pop
#endif
/* 80353EB8-80353F08 34E7F8 0050+00 1/0 0/0 0/0 .text OnReset */
static s32 OnReset(s32 f) {
+1 -13
View File
@@ -642,8 +642,6 @@ static void UnlockedHandler(s32 chan, OSContext* context) {
}
/* 80344238-803445E8 33EB78 03B0+00 5/5 3/3 0/0 .text EXIGetID */
// Use of add. instead of add
#ifdef NONMATCHING
s32 EXIGetID(s32 chan, u32 dev, u32* id) {
EXIControl* exi = &Ecb[chan];
BOOL err;
@@ -651,7 +649,7 @@ s32 EXIGetID(s32 chan, u32 dev, u32* id) {
s32 startTime;
BOOL enabled;
if (exi == (EXIControl*)NULL && dev == 2 && IDSerialPort1[0] != 0) {
if (chan == 0 && dev == 2 && IDSerialPort1[0] != 0) {
*id = IDSerialPort1[0];
return 1;
}
@@ -706,16 +704,6 @@ s32 EXIGetID(s32 chan, u32 dev, u32* id) {
return err ? 0 : !0;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm s32 EXIGetID(s32 chan, u32 dev, u32* id) {
nofralloc
#include "asm/exi/EXIBios/EXIGetID.s"
}
#pragma pop
#endif
/* ############################################################################################## */
/* 803D10F0-803D1100 02E210 000F+01 0/0 0/0 0/0 .data @473 */
+111 -59
View File
@@ -4,6 +4,8 @@
//
#include "dolphin/gx/GXFrameBuf.h"
#include "dolphin/gx/GXInit.h"
#include "dolphin/gx/GX.h"
#include "dol2asm.h"
#include "dolphin/types.h"
@@ -26,73 +28,112 @@ extern u8 GXEurgb60Hz480IntDf[60 + 4 /* padding */];
// External References:
//
void __GetImageTileCount();
void __cvt_fp2unsigned();
extern void* __GXData;
//
// Declarations:
//
/* 8035CA04-8035CA80 357344 007C+00 0/0 2/2 0/0 .text GXSetDispCopySrc */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetDispCopySrc(u16 left, u16 top, u16 width, u16 height) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetDispCopySrc.s"
void GXSetDispCopySrc(u16 left, u16 top, u16 width, u16 height)
{
__GXData->field_0x1e0 = 0;
GX_BITFIELD_SET(__GXData->field_0x1e0, 22, 10, left);
GX_BITFIELD_SET(__GXData->field_0x1e0, 12, 10, top);
GX_BITFIELD_SET(__GXData->field_0x1e0, 0, 8, 73);
__GXData->field_0x1e4 = 0;
GX_BITFIELD_SET(__GXData->field_0x1e4, 22, 10, width - 1);
GX_BITFIELD_SET(__GXData->field_0x1e4, 12, 10, height - 1);
GX_BITFIELD_SET(__GXData->field_0x1e4, 0, 8, 74);
}
#pragma pop
/* 8035CA80-8035CAFC 3573C0 007C+00 0/0 9/9 0/0 .text GXSetTexCopySrc */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetTexCopySrc(u16 left, u16 top, u16 width, u16 height) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetTexCopySrc.s"
void GXSetTexCopySrc(u16 left, u16 top, u16 width, u16 height)
{
__GXData->field_0x1f0 = 0;
GX_BITFIELD_SET(__GXData->field_0x1f0, 22, 10, left);
GX_BITFIELD_SET(__GXData->field_0x1f0, 12, 10, top);
GX_BITFIELD_SET(__GXData->field_0x1f0, 0, 8, 0x49);
__GXData->field_0x1f4 = 0;
GX_BITFIELD_SET(__GXData->field_0x1f4, 22, 10, width - 1);
GX_BITFIELD_SET(__GXData->field_0x1f4, 12, 10, height - 1);
GX_BITFIELD_SET(__GXData->field_0x1f4, 0, 8, 0x4A);
}
#pragma pop
/* 8035CAFC-8035CB30 35743C 0034+00 0/0 2/2 0/0 .text GXSetDispCopyDst */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetDispCopyDst(u16 width, u16 height) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetDispCopyDst.s"
void GXSetDispCopyDst(u16 arg0, u16 arg1)
{
s32 val = (s32) ((arg0 << 1) & 0xFFFE) >> 5;
__GXData->field_0x1e8 = 0;
GX_BITFIELD_SET(__GXData->field_0x1e8, 22, 10, val);
GX_BITFIELD_SET(__GXData->field_0x1e8, 0, 8, 0x4D);
}
#pragma pop
/* 8035CB30-8035CC60 357470 0130+00 0/0 9/9 0/0 .text GXSetTexCopyDst */
#ifdef NONMATCHING
void GXSetTexCopyDst(u16 width, u16 height, s32 fmt, GXBool mipmap) {
s32 fmt2;
s32 arg3, arg4, arg5;
__GXData->field_0x200 = 0;
fmt2 = fmt & 0xf;
if ((s32)fmt == GX_TF_Z16) {
fmt2 = 0xb;
}
switch (fmt) {
case 0:
case 1:
case 2:
case 3:
case 0x26:
GX_BITFIELD_SET(__GXData->field_0x1fc, 15, 2, 3);
break;
default:
GX_BITFIELD_SET(__GXData->field_0x1fc, 15, 2, 2);
break;
}
__GXData->field_0x200 = (fmt & 0x10) == 0x10;
__GXData->field_0x1fc = __rlwimi(__GXData->field_0x1fc, fmt2, 0, 28, 28);
fmt2 &= 7;
__GetImageTileCount(fmt, width, height, &arg3, &arg4, &arg5);
__GXData->field_0x1f8 = 0;
GX_BITFIELD_SET(__GXData->field_0x1f8, 22, 10, arg3*arg5);
GX_BITFIELD_SET(__GXData->field_0x1f8, 0, 8, 0x4d);
GX_BITFIELD_SET(__GXData->field_0x1fc, 22, 1, mipmap);
GX_BITFIELD_SET(__GXData->field_0x1fc, 25, 3, fmt2);
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetTexCopyDst(u16 width, u16 height, GXTexFmt fmt, GXBool mipmap) {
asm void GXSetTexCopyDst(u16 width, u16 height, s32 fmt, GXBool mipmap) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetTexCopyDst.s"
}
#pragma pop
#endif
/* 8035CC60-8035CC84 3575A0 0024+00 0/0 1/1 0/0 .text GXSetDispCopyFrame2Field */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetDispCopyFrame2Field(GXCopyMode mode) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetDispCopyFrame2Field.s"
void GXSetDispCopyFrame2Field(GXCopyMode arg0)
{
GX_BITFIELD_SET(__GXData->field_0x1ec, 18, 2, arg0);
GX_BITFIELD_SET(__GXData->field_0x1fc, 18, 2, 0);
}
#pragma pop
#define INSERT_FIELD(reg, value, nbits, shift) \
(reg) = ((u32) (reg) & ~(((1 << (nbits)) - 1) << (shift))) | \
((u32) (value) << (shift));
/* 8035CC84-8035CCDC 3575C4 0058+00 0/0 2/2 0/0 .text GXSetCopyClamp */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetCopyClamp(GXFBClamp clamp) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetCopyClamp.s"
void GXSetCopyClamp(GXFBClamp clamp) {
u8 isTop = (clamp & GX_CLAMP_TOP) == GX_CLAMP_TOP;
u8 isBottom = (clamp & GX_CLAMP_BOTTOM) == GX_CLAMP_BOTTOM;
__GXData->field_0x1ec = __rlwimi(__GXData->field_0x1ec, isTop, 0, 31, 31);
__GXData->field_0x1ec = __rlwimi(__GXData->field_0x1ec, isBottom, 1, 30, 30);
__GXData->field_0x1fc = __rlwimi(__GXData->field_0x1fc, isTop, 0, 31, 31);
__GXData->field_0x1fc = __rlwimi(__GXData->field_0x1fc, isBottom, 1, 30, 30);
}
#pragma pop
/* ############################################################################################## */
/* 804565A8-804565B0 004BA8 0004+04 3/3 0/0 0/0 .sdata2 @179 */
@@ -137,14 +178,29 @@ asm u32 GXSetDispCopyYScale(f32 y_scale) {
#pragma pop
/* 8035D070-8035D0E8 3579B0 0078+00 0/0 2/2 0/0 .text GXSetCopyClear */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetCopyClear(GXColor color, u32 clear_z) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetCopyClear.s"
void GXSetCopyClear(GXColor color, u32 clear_z) {
u32 r6 = 0;
GX_BITFIELD_SET(r6, 24, 8, color.r);
GX_BITFIELD_SET(r6, 16, 8, color.a);
GX_BITFIELD_SET(r6, 0, 8, 0x4f);
GXFIFO.u8 = 0x61;
GXFIFO.u32 = r6;
r6 = 0;
GX_BITFIELD_SET(r6, 24, 8, color.b);
GX_BITFIELD_SET(r6, 16, 8, color.g);
GX_BITFIELD_SET(r6, 0, 8, 0x50);
GXFIFO.u8 = 0x61;
GXFIFO.u32 = r6;
r6 = 0;
GX_BITFIELD_SET(r6, 8, 24, clear_z);
GX_BITFIELD_SET(r6, 0, 8, 0x51);
GXFIFO.u8 = 0x61;
GXFIFO.u32 = r6;
__GXData->field_0x2 = 0;
}
#pragma pop
/* 8035D0E8-8035D2F0 357A28 0208+00 0/0 4/4 0/0 .text GXSetCopyFilter */
#pragma push
@@ -157,14 +213,10 @@ asm void GXSetCopyFilter(GXBool antialias, u8 pattern[12][2], GXBool vf, u8 vfil
#pragma pop
/* 8035D2F0-8035D304 357C30 0014+00 0/0 2/2 0/0 .text GXSetDispCopyGamma */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXSetDispCopyGamma(GXGamma gamma) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXSetDispCopyGamma.s"
void GXSetDispCopyGamma(GXGamma gamma)
{
GX_BITFIELD_SET(__GXData->field_0x1ec, 23, 2, gamma);
}
#pragma pop
/* 8035D304-8035D46C 357C44 0168+00 0/0 3/3 0/0 .text GXCopyDisp */
#pragma push
@@ -187,14 +239,14 @@ asm void GXCopyTex(void* dst, GXBool clear) {
#pragma pop
/* 8035D5F8-8035D630 357F38 0038+00 0/0 1/1 0/0 .text GXClearBoundingBox */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void GXClearBoundingBox(void) {
nofralloc
#include "asm/dolphin/gx/GXFrameBuf/GXClearBoundingBox.s"
void GXClearBoundingBox(void)
{
GXFIFO.u8 = GX_LOAD_BP_REG;
GXFIFO.u32 = 0x550003FF;
GXFIFO.u8 = GX_LOAD_BP_REG;
GXFIFO.u32 = 0x560003FF;
set_x2(GX_FALSE);
}
#pragma pop
/* ############################################################################################## */
/* 803D2448-803D2484 02F568 003C+00 0/0 2/1 0/0 .data GXNtsc480IntDf */
-1
View File
@@ -132,7 +132,6 @@ void GXSetCullMode(GXCullMode mode) {
GXCullMode mode2;
data = __GXData;
// Useless set
mode2 = (mode >> 1) & 1;
GX_BITFIELD_SET(mode2, 30, 1, mode);
+8 -21
View File
@@ -67,7 +67,7 @@ static GXFifoObj FifoObj;
static GXData gxData;
/* 80456580-80456584 -00001 0004+00 6/6 108/108 0/0 .sdata2 __GXData */
SECTION_SDATA2 extern GXData* __GXData = &gxData;
GXData* const __GXData = &gxData;
/* 8035921C-80359318 353B5C 00FC+00 1/1 0/0 0/0 .text __GXDefaultTexRegionCallback */
#pragma push
@@ -80,29 +80,16 @@ asm GXTexRegion* __GXDefaultTexRegionCallback(GXTexObj* obj, GXTexMapID mapID) {
#pragma pop
/* 80359318-8035933C 353C58 0024+00 1/1 0/0 0/0 .text __GXDefaultTlutRegionCallback */
// blr instead of b
#ifdef NONMATCHING
GXTlutRegion* __GXDefaultTlutRegionCallback(u32 tlut) {
GXTlutRegion* region;
if (tlut >= 20) {
region = NULL;
} else {
region = &__GXData->field_0x388[tlut];
}
return region;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm GXTlutRegion* __GXDefaultTlutRegionCallback(u32 tlut) {
nofralloc
#include "asm/dolphin/gx/GXInit/__GXDefaultTlutRegionCallback.s"
#pragma peephole off
GXTlutRegion* __GXDefaultTlutRegionCallback(u32 tlut) {
if (tlut >= 0x14) {
return NULL;
} else {
return &__GXData->field_0x388[tlut];
}
}
#pragma pop
#endif
/* 80451944-80451948 000E44 0004+00 1/1 0/0 0/0 .sbss resetFuncRegistered$145 */
/* static */ u8 resetFuncRegistered[4];
+1 -2
View File
@@ -11,7 +11,6 @@
// Forward References:
//
void __GetImageTileCount();
static void GXLoadTexObjPreLoaded();
void GXLoadTexObj();
void GXLoadTlut();
@@ -118,7 +117,7 @@ SECTION_DATA static void* lit_145[61] = {
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void __GetImageTileCount() {
asm void __GetImageTileCount(u32 arg0, s16 arg1, s16 arg2, s32* arg3, s32* arg4, s32* arg5) {
nofralloc
#include "asm/dolphin/gx/GXTexture/__GetImageTileCount.s"
}
+66
View File
@@ -36,6 +36,39 @@ SECTION_SDATA2 static f32 lit_105 = 0.5f;
SECTION_SDATA2 static f32 lit_106 = 0.01745329238474369f;
/* 80346F28-80346FF8 341868 00D0+00 0/0 6/6 0/0 .text C_MTXPerspective */
// Functions match but has issues with float constants
#ifdef NONMATCHING
void C_MTXPerspective(Mtx44 m, f32 fovY, f32 aspect, f32 n, f32 f)
{
f32 temp_f3;
f32 temp_f4;
fovY = 0.5F * fovY;
temp_f4 = 1.0F / tanf(0.017453292F * (fovY));
temp_f3 = 1.0F / (f - n);
m[0][0] = temp_f4 / aspect;
m[0][1] = 0.0F;
m[0][2] = 0.0F;
m[0][3] = 0.0F;
m[1][0] = 0.0F;
m[1][1] = temp_f4;
m[1][2] = 0.0F;
m[1][3] = 0.0F;
m[2][0] = 0.0F;
m[2][1] = 0.0F;
m[2][2] = -n * temp_f3;
m[2][3] = temp_f3 * -(f * n);
m[3][0] = 0.0F;
m[3][1] = 0.0F;
m[3][2] = -1.0F;
m[3][3] = 0.0F;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -44,8 +77,40 @@ asm void C_MTXPerspective(Mtx44 m, f32 fovy, f32 aspect, f32 near, f32 far) {
#include "asm/dolphin/mtx/mtx44/C_MTXPerspective.s"
}
#pragma pop
#endif
/* 80346FF8-80347090 341938 0098+00 0/0 11/11 2/2 .text C_MTXOrtho */
#ifdef NONMATCHING
void C_MTXOrtho(Mtx44 m, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f)
{
f32 temp_f8;
f32 temp_f10;
f32 temp_f4;
temp_f10 = 1.0F / (r - l);
m[0][0] = 2.0F * temp_f10;
m[0][1] = 0.0F;
m[0][2] = 0.0F;
m[0][3] = temp_f10 * -(r + l);
temp_f8 = 1.0F / (t - b);
m[1][0] = 0.0F;
m[1][1] = 2.0F * temp_f8;
m[1][2] = 0.0F;
m[1][3] = temp_f8 * -(t + b);
temp_f4 = 1.0F / (f - n);
m[2][0] = 0.0F;
m[2][1] = 0.0F;
m[2][2] = -1.0F * temp_f4;
m[2][3] = -f * temp_f4;
m[3][0] = 0.0F;
m[3][1] = 0.0F;
m[3][2] = 0.0F;
m[3][3] = 1.0F;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -54,3 +119,4 @@ asm void C_MTXOrtho(Mtx44 m, f32 top, f32 bottom, f32 left, f32 right, f32 near,
#include "asm/dolphin/mtx/mtx44/C_MTXOrtho.s"
}
#pragma pop
#endif
-18
View File
@@ -34,18 +34,10 @@ static XY XYPAL[12] = {
};
#pragma pop
/* 803D1330-803D1368 02E450 0033+05 0/1 0/0 0/0 .data @16 */
#pragma push
#pragma force_active on
SECTION_DATA static char lit_16[] = "SISetSamplingRate: unknown TV format. Use default.";
#pragma pop
/* 80451700-80451708 000C00 0004+04 2/2 0/0 0/0 .sbss SamplingRate */
static u32 SamplingRate;
/* 80346290-80346374 340BD0 00E4+00 1/1 1/1 0/0 .text SISetSamplingRate */
// needs compiler epilogue patch
#ifdef NONMATCHING
void SISetSamplingRate(u32 msec) {
XY* xy;
BOOL enabled;
@@ -77,16 +69,6 @@ void SISetSamplingRate(u32 msec) {
SISetXY((__VIRegs[54] & 1 ? 2u : 1u) * xy[msec].line, xy[msec].count);
OSRestoreInterrupts(enabled);
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void SISetSamplingRate(u32 msec) {
nofralloc
#include "asm/dolphin/si/SISamplingRate/SISetSamplingRate.s"
}
#pragma pop
#endif
/* 80346374-80346398 340CB4 0024+00 0/0 2/2 0/0 .text SIRefreshSamplingRate */
void SIRefreshSamplingRate() {
+3 -1
View File
@@ -14,6 +14,7 @@ LIBVI_A_CFLAGS := \
-fp hard \
-nodefaults \
-str reuse \
-inline auto \
-RTTI off \
-maxerrors 5 \
-enum int $(INCLUDES) \
@@ -35,10 +36,11 @@ $(BUILD_DIR)/libs/dolphin/vi/%.o: libs/dolphin/vi/%.c $(BUILD_DIR)/libs/dolphin/
@mkdir -p $(@D)
@echo building... $<
@$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c
@$(FRANK_CC) $(LIBVI_A_CFLAGS) -c -o $(@:.o=.po) $(basename $@).c
@$(DOLPHIN_LIB_CC) $(LIBVI_A_CFLAGS) $(DEPFLAGS) -c -o $(dir $@) $(basename $@).c
@if [ -z '$(DISABLE_DEPS)' ]; then tools/transform-dep.py '$(basename $@).d' '$(basename $@).d'; touch -c $@; fi
@echo Frank is fixing $@
@$(PYTHON) $(FRANK) $@ $@ $@
@$(PYTHON) $(FRANK) $@ $(@:.o=.po) $@
ifndef DISABLE_DEPS
LIBVI_A_D_FILES := $(LIBVI_A_O_FILES:.o=.d)
+90 -57
View File
@@ -14,15 +14,15 @@
void __VIRetraceHandler();
static void getTiming();
void __VIInit();
static void setFbbRegs();
static void setVerticalRegs();
static void setFbbRegs(void**, void**, void**, void**, void**);
static void setVerticalRegs(u16, u16, u8, u16, u16, u16, u16, u16, u32);
u32 VIGetRetraceCount();
static void GetCurrentDisplayPosition();
static void GetCurrentDisplayPosition(u32* x, u32* y);
static void getCurrentFieldEvenOdd();
void VIGetNextField();
u32 VIGetNextField();
void VIGetCurrentLine();
void VIGetTvFormat();
void VIGetDTVStatus();
u32 VIGetDTVStatus();
void __VIDisplayPositionToXY();
void __VIGetCurrentPosition();
@@ -46,19 +46,19 @@ static u8 regs[118 + 2 /* padding */];
static u8 IsInitialized[4];
/* 804517E4-804517E8 000CE4 0004+00 4/3 0/0 0/0 .sbss retraceCount */
static u8 retraceCount[4];
static u32 retraceCount;
/* 804517E8-804517EC 000CE8 0004+00 3/3 0/0 0/0 .sbss flushFlag */
static u8 flushFlag[4];
/* 804517EC-804517F4 000CEC 0008+00 3/3 0/0 0/0 .sbss retraceQueue */
static u8 retraceQueue[8];
static OSThreadQueue retraceQueue;
/* 804517F4-804517F8 000CF4 0004+00 3/3 0/0 0/0 .sbss PreCB */
static u8 PreCB[4];
static VIRetraceCallback PreCB;
/* 804517F8-804517FC 000CF8 0004+00 3/3 0/0 0/0 .sbss PostCB */
static u8 PostCB[4];
static VIRetraceCallback PostCB;
/* 804517FC-80451800 000CFC 0004+00 1/1 0/0 0/0 .sbss PositionCallback */
static u8 PositionCallback[4];
@@ -112,24 +112,22 @@ asm void __VIRetraceHandler() {
#pragma pop
/* 8034C1E0-8034C224 346B20 0044+00 0/0 4/4 0/0 .text VISetPreRetraceCallback */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback) {
nofralloc
#include "asm/dolphin/vi/vi/VISetPreRetraceCallback.s"
VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback cb) {
VIRetraceCallback prevCb = PreCB;
BOOL enable = OSDisableInterrupts();
PreCB = cb;
OSRestoreInterrupts(enable);
return prevCb;
}
#pragma pop
/* 8034C224-8034C268 346B64 0044+00 0/0 4/4 2/2 .text VISetPostRetraceCallback */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback) {
nofralloc
#include "asm/dolphin/vi/vi/VISetPostRetraceCallback.s"
VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback cb) {
VIRetraceCallback prevCb = PostCB;
BOOL enable = OSDisableInterrupts();
PostCB = cb;
OSRestoreInterrupts(enable);
return prevCb;
}
#pragma pop
/* ############################################################################################## */
/* 803D1760-803D17A4 02E880 0044+00 4/3 0/0 0/0 .data @1 */
@@ -247,7 +245,7 @@ SECTION_DATA static void* lit_101[31] = {
};
/* 80451838-8045183C 000D38 0004+00 2/2 0/0 0/0 .sbss FBSet */
static u8 FBSet[4];
static u32 FBSet;
/* 8045183C-80451840 000D3C 0004+00 1/1 0/0 0/0 .sbss timingExtra */
static u8 timingExtra[4];
@@ -296,20 +294,22 @@ asm void VIInit() {
#pragma pop
/* 8034C9C4-8034CA18 347304 0054+00 0/0 10/10 0/0 .text VIWaitForRetrace */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void VIWaitForRetrace() {
nofralloc
#include "asm/dolphin/vi/vi/VIWaitForRetrace.s"
void VIWaitForRetrace() {
BOOL enable = OSDisableInterrupts();
u32 startVal = retraceCount;
do {
OSSleepThread(&retraceQueue);
} while(startVal == retraceCount);
OSRestoreInterrupts(enable);
}
#pragma pop
/* 8034CA18-8034CCEC 347358 02D4+00 2/2 0/0 0/0 .text setFbbRegs */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm void setFbbRegs() {
static asm void setFbbRegs(void**, void**, void**, void**, void**) {
nofralloc
#include "asm/dolphin/vi/vi/setFbbRegs.s"
}
@@ -319,7 +319,7 @@ static asm void setFbbRegs() {
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm void setVerticalRegs() {
static asm void setVerticalRegs(u16 arg0, u16 arg1, u8 arg2, u16 arg3, u16 arg4, u16 arg5, u16 arg6, u16 arg7, u32 arg8) {
nofralloc
#include "asm/dolphin/vi/vi/setVerticalRegs.s"
}
@@ -395,14 +395,18 @@ asm void VIFlush() {
#pragma pop
/* 8034D7C4-8034D830 348104 006C+00 0/0 3/3 0/0 .text VISetNextFrameBuffer */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void VISetNextFrameBuffer(void*) {
nofralloc
#include "asm/dolphin/vi/vi/VISetNextFrameBuffer.s"
void VISetNextFrameBuffer(void* buffer) {
void** bufferArray = (void**)regs;
BOOL enable = OSDisableInterrupts();
bufferArray[72] = buffer;
FBSet = 1;
setFbbRegs(bufferArray + 60, bufferArray + 73,
bufferArray + 74, bufferArray + 79, bufferArray + 80
);
OSRestoreInterrupts(enable);
}
#pragma pop
/* 8034D830-8034D838 -00001 0008+00 0/0 0/0 0/0 .text VIGetNextFrameBuffer */
void* VIGetNextFrameBuffer() {
@@ -415,29 +419,59 @@ void* VIGetCurrentFrameBuffer() {
}
/* 8034D840-8034D8BC 348180 007C+00 0/0 7/7 0/0 .text VISetBlack */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void VISetBlack(BOOL) {
nofralloc
#include "asm/dolphin/vi/vi/VISetBlack.s"
void VISetBlack(BOOL isBlack) {
u8* ptr = regs;
u16* ptr2;
BOOL enable = OSDisableInterrupts();
((u32*)ptr)[76] = isBlack;
ptr2 = ((u16**)ptr)[81];
setVerticalRegs(
((u16*)ptr)[125],
((u16*)ptr)[123],
((u8*)ptr2)[0],
ptr2[1],
ptr2[2],
ptr2[3],
ptr2[4],
ptr2[5],
((u32*)ptr)[76]
);
OSRestoreInterrupts(enable);
}
#pragma pop
/* 8034D8BC-8034D8C4 -00001 0008+00 0/0 0/0 0/0 .text VIGetRetraceCount */
u32 VIGetRetraceCount() {
return *(u32*)(&retraceCount);
return retraceCount;
}
/* 8034D8C4-8034D900 348204 003C+00 1/1 0/0 0/0 .text GetCurrentDisplayPosition */
#ifdef NONMATCHING
void GetCurrentDisplayPosition(u32* x, u32* y) {
u32 val3;
u32 val4;
u32 val = __VIRegs[22] & 0x7FF;
do {
val4 = val;
val = __VIRegs[22] & 0x7FF;
val3 = __VIRegs[23] & 0x7FF;
} while (val4 != val);
*x = val3;
*y = val;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm void GetCurrentDisplayPosition() {
static asm void GetCurrentDisplayPosition(u32* x, u32* y) {
nofralloc
#include "asm/dolphin/vi/vi/GetCurrentDisplayPosition.s"
}
#pragma pop
#endif
/* 8034D900-8034D968 348240 0068+00 1/1 0/0 0/0 .text getCurrentFieldEvenOdd */
#pragma push
@@ -453,7 +487,7 @@ static asm void getCurrentFieldEvenOdd() {
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void VIGetNextField() {
asm u32 VIGetNextField() {
nofralloc
#include "asm/dolphin/vi/vi/VIGetNextField.s"
}
@@ -495,14 +529,13 @@ asm void VIGetTvFormat() {
#pragma pop
/* 8034DB04-8034DB40 348444 003C+00 0/0 2/2 0/0 .text VIGetDTVStatus */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void VIGetDTVStatus() {
nofralloc
#include "asm/dolphin/vi/vi/VIGetDTVStatus.s"
u32 VIGetDTVStatus() {
u32 val;
BOOL enable = OSDisableInterrupts();
val = __VIRegs[55] & 3;
OSRestoreInterrupts(enable);
return val & 1;
}
#pragma pop
/* 8034DB40-8034DD5C 348480 021C+00 1/1 0/0 0/0 .text __VIDisplayPositionToXY */
#pragma push