mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-12-22 16:30:23 +00:00
throw out unused libultra sources
This commit is contained in:
parent
d48db1d9c6
commit
99f69eff1c
85 changed files with 16 additions and 4608 deletions
74
Makefile
74
Makefile
|
@ -354,73 +354,25 @@ LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c)
|
|||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
|
||||
CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
||||
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
|
||||
ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
|
||||
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \
|
||||
$(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))))
|
||||
|
||||
# We need to keep this for now
|
||||
# If we're not N64 use below
|
||||
ULTRA_C_FILES := \
|
||||
alBnkfNew.c \
|
||||
guLookAtRef.c \
|
||||
guMtxF2L.c \
|
||||
guNormalize.c \
|
||||
guOrthoF.c \
|
||||
guPerspectiveF.c \
|
||||
guRotateF.c \
|
||||
guScaleF.c \
|
||||
guTranslateF.c \
|
||||
ldiv.c
|
||||
|
||||
ULTRA_C_FILES_SKIP := \
|
||||
sqrtf.c \
|
||||
string.c \
|
||||
sprintf.c \
|
||||
_Printf.c \
|
||||
kdebugserver.c \
|
||||
osInitialize.c \
|
||||
func_802F7140.c \
|
||||
func_802F71F0.c \
|
||||
func_802F4A20.c \
|
||||
EU_D_802f4330.c \
|
||||
D_802F4380.c \
|
||||
osLeoDiskInit.c \
|
||||
osCreateThread.c \
|
||||
osDestroyThread.c \
|
||||
osStartThread.c \
|
||||
osSetThreadPri.c \
|
||||
osPiStartDma.c \
|
||||
osPiRawStartDma.c \
|
||||
osPiRawReadIo.c \
|
||||
osPiGetCmdQueue.c \
|
||||
osJamMesg.c \
|
||||
osSendMesg.c \
|
||||
osRecvMesg.c \
|
||||
osSetEventMesg.c \
|
||||
osTimer.c \
|
||||
osSetTimer.c \
|
||||
osSetTime.c \
|
||||
osCreateViManager.c \
|
||||
osViSetSpecialFeatures.c \
|
||||
osVirtualToPhysical.c \
|
||||
osViBlack.c \
|
||||
osViSetEvent.c \
|
||||
osViSetMode.c \
|
||||
osViSwapBuffer.c \
|
||||
osSpTaskLoadGo.c \
|
||||
osCreatePiManager.c \
|
||||
osGetTime.c \
|
||||
osEepromProbe.c \
|
||||
osEepromWrite.c \
|
||||
osEepromLongWrite.c \
|
||||
osEepromRead.c \
|
||||
osEepromLongRead.c \
|
||||
osContInit.c \
|
||||
osContStartReadData.c \
|
||||
osAiGetLength.c \
|
||||
osAiSetFrequency.c \
|
||||
osAiSetNextBuffer.c \
|
||||
__osViInit.c \
|
||||
__osSyncPutChars.c \
|
||||
__osAtomicDec.c \
|
||||
__osSiRawStartDma.c \
|
||||
__osViSwapContext.c \
|
||||
__osViGetCurrentContext.c \
|
||||
__osDevMgrMain.c
|
||||
|
||||
C_FILES := $(filter-out src/game/main.c,$(C_FILES))
|
||||
ULTRA_C_FILES := $(filter-out $(addprefix lib/src/,$(ULTRA_C_FILES_SKIP)),$(ULTRA_C_FILES))
|
||||
C_FILES := $(filter-out src/game/main.c,$(C_FILES))
|
||||
ULTRA_C_FILES := $(addprefix lib/src/,$(ULTRA_C_FILES))
|
||||
|
||||
# "If we're not N64, use the above"
|
||||
|
||||
|
|
|
@ -81,4 +81,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC
|
|||
OSMesgQueue *osPiGetCmdQueue(void);
|
||||
s32 osPiWriteIo(uintptr_t devAddr, u32 data);
|
||||
s32 osPiReadIo(uintptr_t devAddr, u32 *data);
|
||||
|
||||
s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size);
|
||||
s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size);
|
||||
#endif
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
#include "new_func.h"
|
||||
#include "macros.h"
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
u32 D_802F4380() {
|
||||
u32 sp3c;
|
||||
u32 sp38;
|
||||
u32 sp34;
|
||||
__OSTranxInfo *sp30;
|
||||
__OSBlockInfo *sp2c;
|
||||
u32 sp28;
|
||||
UNUSED __OSBlockInfo *sp24;
|
||||
if (!EU_D_80302090) {
|
||||
return 0;
|
||||
}
|
||||
sp30 = &__osDiskHandle->transferInfo;
|
||||
sp2c = &sp30->block[sp30->blockNum];
|
||||
sp38 = HW_REG(PI_STATUS_REG, u32);
|
||||
if (sp38 & PI_STATUS_BUSY) {
|
||||
HW_REG(PI_STATUS_REG, u32) = PI_STATUS_RESET_CONTROLLER | PI_STATUS_CLEAR_INTR;
|
||||
WAIT_ON_IOBUSY(sp38);
|
||||
sp3c = HW_REG(ASIC_STATUS, u32);
|
||||
if (sp3c & MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_IOBUSY(sp38);
|
||||
HW_REG(ASIC_BM_CTL, u32) = sp30->bmCtlShadow | MECHANIC_INTERRUPT_RESET;
|
||||
}
|
||||
sp30->unk10 = 75;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
WAIT_ON_IOBUSY(sp38);
|
||||
sp3c = HW_REG(ASIC_STATUS, u32);
|
||||
if (sp3c & MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_IOBUSY(sp38);
|
||||
HW_REG(ASIC_BM_CTL, u32) = sp30->bmCtlShadow | MECHANIC_INTERRUPT_RESET;
|
||||
sp30->unk10 = 0;
|
||||
return 0;
|
||||
}
|
||||
if (sp3c & BUFFER_MANAGER_ERROR) {
|
||||
sp30->unk10 = 3;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
if (sp30->cmdType == 1) {
|
||||
if ((sp3c & DATA_REQUEST) == 0) {
|
||||
if (sp30->sectorNum + 1 != sp30->transferMode * 85) {
|
||||
sp30->unk10 = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR;
|
||||
D_8030208C |= 0x00100401;
|
||||
sp30->unk10 = 0;
|
||||
func_802F4B08();
|
||||
return 1;
|
||||
}
|
||||
sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize);
|
||||
sp30->sectorNum += 1;
|
||||
osEPiRawStartDma(__osDiskHandle, 1, 0x05000400, sp2c->dramAddr, sp2c->sectorSize);
|
||||
return 1;
|
||||
}
|
||||
if (sp30->cmdType == 0) {
|
||||
if (sp30->transferMode == 3) {
|
||||
if ((s32)(sp2c->C1ErrNum + 17) < sp30->sectorNum) {
|
||||
sp30->unk10 = 0;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
if ((sp3c & DATA_REQUEST) == 0) {
|
||||
sp30->unk10 = 17;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize);
|
||||
}
|
||||
sp34 = HW_REG(ASIC_BM_STATUS, u32);
|
||||
if (((C1_SINGLE & sp34) && (C1_DOUBLE & sp34)) || (sp34 & MICRO_STATUS))
|
||||
{
|
||||
if (sp2c->C1ErrNum > 3) {
|
||||
if (sp30->transferMode != 3 || sp30->sectorNum > 0x52) {
|
||||
sp30->unk10 = 17;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
sp28 = sp2c->C1ErrNum;
|
||||
sp2c->C1ErrSector[sp28] = sp30->sectorNum + 1;
|
||||
}
|
||||
sp2c->C1ErrNum += 1;
|
||||
}
|
||||
if (sp3c & C2_TRANSFER) {
|
||||
if (sp30->sectorNum != 87) {
|
||||
sp30->unk10 = 6;
|
||||
func_802F4A20();
|
||||
}
|
||||
if (sp30->transferMode == 2 && sp30->blockNum == 0) {
|
||||
sp30->blockNum = 1;
|
||||
sp30->sectorNum = -1;
|
||||
sp30->block[1].dramAddr =
|
||||
(void *) ((u32) sp30->block[1].dramAddr - sp30->block[1].sectorSize);
|
||||
} else {
|
||||
HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR;
|
||||
D_8030208C |= 0x00100401;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, 0, 0x5000000, sp2c->C2Addr, sp2c->sectorSize * 4);
|
||||
sp30->unk10 = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sp30->sectorNum == -1 && sp30->transferMode == 2 && sp30->blockNum == 1) {
|
||||
sp24 = &sp30->block[0];
|
||||
if (sp30->block[0].C1ErrNum == 0) {
|
||||
if (((u32 *) sp30->block[0].C2Addr)[0] | ((u32 *) sp30->block[0].C2Addr)[1]
|
||||
| ((u32 *) sp30->block[0].C2Addr)[2] | ((u32 *) sp30->block[0].C2Addr)[3]) {
|
||||
sp30->unk10 = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sp30->unk10 = 0;
|
||||
func_802F4B08();
|
||||
}
|
||||
sp30->sectorNum += 1;
|
||||
if (sp3c & DATA_REQUEST) {
|
||||
if (sp30->sectorNum > 0x54) {
|
||||
sp30->unk10 = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, 0, 0x05000400, sp2c->dramAddr, sp2c->sectorSize);
|
||||
sp30->unk10 = 0;
|
||||
return 1;
|
||||
}
|
||||
if (sp30->sectorNum <= 0x54) {
|
||||
sp30->unk10 = 6;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
sp30->unk10 = 75;
|
||||
func_802F4A20();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
// an array of pointers to functions taking no arguments and returning u32...
|
||||
// this is only referenced in the exception handler and here. this function is called with a0=1 and
|
||||
// then the same memory address is loaded. it's definitely an array access though..
|
||||
extern u32 (*D_80334920[8])(void) ;
|
||||
|
||||
void EU_D_802f4330(u32 a0, u32 a1(void)) {
|
||||
register u32 int_disabled = __osDisableInt();
|
||||
D_80334920[a0] = a1;
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
typedef union {
|
||||
int i;
|
||||
float f;
|
||||
} fu;
|
||||
const fu NAN = { 0x7f810000 };
|
287
lib/src/_Ldtob.c
287
lib/src/_Ldtob.c
|
@ -1,287 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include <macros.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "printf.h"
|
||||
|
||||
#define BUFF_LEN 0x20
|
||||
|
||||
static s16 _Ldunscale(s16 *, printf_struct *);
|
||||
static void _Genld(printf_struct *, u8, u8 *, s16, s16);
|
||||
|
||||
const double D_80338670[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L };
|
||||
|
||||
/* float properties */
|
||||
#define _D0 0
|
||||
#define _DBIAS 0x3ff
|
||||
#define _DLONG 1
|
||||
#define _DOFF 4
|
||||
#define _FBIAS 0x7e
|
||||
#define _FOFF 7
|
||||
#define _FRND 1
|
||||
#define _LBIAS 0x3ffe
|
||||
#define _LOFF 15
|
||||
/* integer properties */
|
||||
#define _C2 1
|
||||
#define _CSIGN 1
|
||||
#define _ILONG 0
|
||||
#define _MBMAX 8
|
||||
#define NAN 2
|
||||
#define INF 1
|
||||
#define FINITE -1
|
||||
#define _DFRAC ((1 << _DOFF) - 1)
|
||||
#define _DMASK (0x7fff & ~_DFRAC)
|
||||
#define _DMAX ((1 << (15 - _DOFF)) - 1)
|
||||
#define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1))
|
||||
#define _DSIGN 0x8000
|
||||
#if _D0 == 3
|
||||
#define _D1 2 /* little-endian order */
|
||||
#define _D2 1
|
||||
#define _D3 0
|
||||
#else
|
||||
#define _D1 1 /* big-endian order */
|
||||
#define _D2 2
|
||||
#define _D3 3
|
||||
#endif
|
||||
|
||||
void _Ldtob(printf_struct *args, u8 type) {
|
||||
u8 buff[BUFF_LEN];
|
||||
u8 *ptr;
|
||||
UNUSED u32 sp70;
|
||||
f64 val;
|
||||
/* maybe struct? */
|
||||
s16 err;
|
||||
s16 nsig;
|
||||
s16 exp;
|
||||
|
||||
s32 i;
|
||||
s32 n;
|
||||
f64 factor;
|
||||
s32 gen;
|
||||
s32 j;
|
||||
s32 lo;
|
||||
ldiv_t qr;
|
||||
u8 drop;
|
||||
s32 n2;
|
||||
/* */
|
||||
UNUSED u8 unused[0x4];
|
||||
ptr = buff;
|
||||
val = args->value.f64;
|
||||
if (args->precision < 0) {
|
||||
args->precision = 6;
|
||||
} else {
|
||||
if (args->precision == 0 && (type == 'g' || type == 'G')) {
|
||||
args->precision = 1;
|
||||
}
|
||||
}
|
||||
err = _Ldunscale(&exp, args);
|
||||
if (err > 0) {
|
||||
memcpy(args->buff, err == 2 ? "NaN" : "Inf", args->part2_len = 3);
|
||||
return;
|
||||
}
|
||||
if (err == 0) {
|
||||
nsig = 0;
|
||||
exp = 0;
|
||||
} else {
|
||||
if (val < 0) {
|
||||
val = -val;
|
||||
}
|
||||
exp = exp * 30103 / 0x000186A0 - 4;
|
||||
if (exp < 0) {
|
||||
n = (3 - exp) & ~3;
|
||||
exp = -n;
|
||||
for (i = 0; n > 0; n >>= 1, i++) {
|
||||
if ((n & 1) != 0) {
|
||||
val *= D_80338670[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (exp > 0) {
|
||||
factor = 1;
|
||||
exp &= ~3;
|
||||
for (n = exp, i = 0; n > 0; n >>= 1, i++) {
|
||||
if ((n & 1) != 0) {
|
||||
factor *= D_80338670[i];
|
||||
}
|
||||
}
|
||||
val /= factor;
|
||||
}
|
||||
}
|
||||
gen = ((type == 'f') ? exp + 10 : 6) + args->precision;
|
||||
if (gen > 0x13) {
|
||||
gen = 0x13;
|
||||
}
|
||||
*ptr++ = '0';
|
||||
while (gen > 0 && 0 < val) {
|
||||
lo = val;
|
||||
if ((gen -= 8) > 0) {
|
||||
val = (val - lo) * 1.0e8;
|
||||
}
|
||||
ptr = ptr + 8;
|
||||
for (j = 8; lo > 0 && --j >= 0;) {
|
||||
qr = ldiv(lo, 10);
|
||||
*--ptr = qr.rem + '0';
|
||||
lo = qr.quot;
|
||||
}
|
||||
while (--j >= 0) {
|
||||
ptr--;
|
||||
*ptr = '0';
|
||||
}
|
||||
ptr += 8;
|
||||
}
|
||||
|
||||
gen = ptr - &buff[1];
|
||||
for (ptr = &buff[1], exp += 7; *ptr == '0'; ptr++) {
|
||||
--gen, --exp;
|
||||
}
|
||||
|
||||
nsig = ((type == 'f') ? exp + 1 : ((type == 'e' || type == 'E') ? 1 : 0)) + args->precision;
|
||||
if (gen < nsig) {
|
||||
nsig = gen;
|
||||
}
|
||||
if (nsig > 0) {
|
||||
if (nsig < gen && ptr[nsig] > '4') {
|
||||
drop = '9';
|
||||
} else {
|
||||
drop = '0';
|
||||
}
|
||||
|
||||
for (n2 = nsig; ptr[--n2] == drop;) {
|
||||
nsig--;
|
||||
}
|
||||
if (drop == '9') {
|
||||
ptr[n2]++;
|
||||
}
|
||||
if (n2 < 0) {
|
||||
--ptr, ++nsig, ++exp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_Genld(args, type, ptr, nsig, exp);
|
||||
}
|
||||
|
||||
static s16 _Ldunscale(s16 *pex, printf_struct *px) {
|
||||
|
||||
unsigned short *ps = (unsigned short *) px;
|
||||
short xchar = (ps[_D0] & _DMASK) >> _DOFF;
|
||||
if (xchar == _DMAX) { /* NaN or INF */
|
||||
*pex = 0;
|
||||
return (s16)(ps[_D0] & _DFRAC || ps[_D1] || ps[_D2] || ps[_D3] ? NAN : INF);
|
||||
} else if (0 < xchar) {
|
||||
ps[_D0] = (ps[_D0] & ~_DMASK) | (_DBIAS << _DOFF);
|
||||
*pex = xchar - (_DBIAS - 1);
|
||||
return (FINITE);
|
||||
}
|
||||
if (0 > xchar) {
|
||||
return NAN;
|
||||
} else {
|
||||
*pex = 0;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
static void _Genld(printf_struct *px, u8 code, u8 *p, s16 nsig, s16 xexp) {
|
||||
u8 point = '.';
|
||||
if (nsig <= 0) {
|
||||
nsig = 1,
|
||||
|
||||
p = (u8 *) "0";
|
||||
}
|
||||
|
||||
if (code == 'f'
|
||||
|| ((code == 'g' || code == 'G') && (-4 <= xexp) && (xexp < px->precision))) { /* 'f' format */
|
||||
++xexp; /* change to leading digit count */
|
||||
if (code != 'f') { /* fixup for 'g' */
|
||||
if (!(px->flags & FLAGS_HASH) && nsig < px->precision) {
|
||||
px->precision = nsig;
|
||||
}
|
||||
if ((px->precision -= xexp) < 0) {
|
||||
px->precision = 0;
|
||||
}
|
||||
}
|
||||
if (xexp <= 0) { /* digits only to right of point */
|
||||
px->buff[px->part2_len++] = '0';
|
||||
if (0 < px->precision || px->flags & FLAGS_HASH) {
|
||||
px->buff[px->part2_len++] = point;
|
||||
}
|
||||
if (px->precision < -xexp) {
|
||||
xexp = -px->precision;
|
||||
}
|
||||
px->num_mid_zeros = -xexp;
|
||||
px->precision += xexp;
|
||||
if (px->precision < nsig) {
|
||||
nsig = px->precision;
|
||||
}
|
||||
memcpy(&px->buff[px->part2_len], p, px->part3_len = nsig);
|
||||
px->num_trailing_zeros = px->precision - nsig;
|
||||
} else if (nsig < xexp) { /* zeros before point */
|
||||
memcpy(&px->buff[px->part2_len], p, nsig);
|
||||
px->part2_len += nsig;
|
||||
px->num_mid_zeros = xexp - nsig;
|
||||
if (0 < px->precision || px->flags & FLAGS_HASH) {
|
||||
px->buff[px->part2_len] = point, ++px->part3_len;
|
||||
}
|
||||
px->num_trailing_zeros = px->precision;
|
||||
} else { /* enough digits before point */
|
||||
memcpy(&px->buff[px->part2_len], p, xexp);
|
||||
px->part2_len += xexp;
|
||||
nsig -= xexp;
|
||||
if (0 < px->precision || px->flags & FLAGS_HASH) {
|
||||
px->buff[px->part2_len++] = point;
|
||||
}
|
||||
if (px->precision < nsig) {
|
||||
nsig = px->precision;
|
||||
}
|
||||
memcpy(&px->buff[px->part2_len], p + xexp, nsig);
|
||||
px->part2_len += nsig;
|
||||
px->num_mid_zeros = px->precision - nsig;
|
||||
}
|
||||
} else { /* 'e' format */
|
||||
if (code == 'g' || code == 'G') { /* fixup for 'g' */
|
||||
if (nsig < px->precision) {
|
||||
px->precision = nsig;
|
||||
}
|
||||
if (--px->precision < 0) {
|
||||
px->precision = 0;
|
||||
}
|
||||
code = code == 'g' ? 'e' : 'E';
|
||||
}
|
||||
px->buff[px->part2_len++] = *p++;
|
||||
if (0 < px->precision || px->flags & FLAGS_HASH) {
|
||||
px->buff[px->part2_len++] = point;
|
||||
}
|
||||
if (0 < px->precision) { /* put fraction digits */
|
||||
if (px->precision < --nsig) {
|
||||
nsig = px->precision;
|
||||
}
|
||||
memcpy(&px->buff[px->part2_len], p, nsig);
|
||||
px->part2_len += nsig;
|
||||
px->num_mid_zeros = px->precision - nsig;
|
||||
}
|
||||
p = (u8 *) &px->buff[px->part2_len]; /* put exponent */
|
||||
*p++ = code;
|
||||
if (0 <= xexp) {
|
||||
*p++ = '+';
|
||||
} else { /* negative exponent */
|
||||
*p++ = '-';
|
||||
xexp = -xexp;
|
||||
}
|
||||
if (100 <= xexp) { /* put oversize exponent */
|
||||
if (1000 <= xexp) {
|
||||
*p++ = xexp / 1000 + '0', xexp %= 1000;
|
||||
}
|
||||
*p++ = xexp / 100 + '0', xexp %= 100;
|
||||
}
|
||||
*p++ = xexp / 10 + '0', xexp %= 10;
|
||||
*p++ = xexp + '0';
|
||||
px->part3_len = p - (u8 *) &px->buff[px->part2_len];
|
||||
}
|
||||
if ((px->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { /* pad with leading zeros */
|
||||
int n =
|
||||
px->part1_len + px->part2_len + px->num_mid_zeros + px->part3_len + px->num_trailing_zeros;
|
||||
|
||||
if (n < px->width) {
|
||||
px->num_leading_zeros = px->width - n;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "printf.h"
|
||||
|
||||
#define BUFF_LEN 0x18
|
||||
|
||||
static u8 D_80334960[] = "0123456789abcdef";
|
||||
static u8 D_80334974[] = "0123456789ABCDEF";
|
||||
|
||||
void _Litob(printf_struct *args, u8 type) {
|
||||
u8 buff[BUFF_LEN];
|
||||
const u8 *num_map;
|
||||
s32 base;
|
||||
s32 buff_ind;
|
||||
u64 num;
|
||||
lldiv_t quotrem;
|
||||
|
||||
if (type == 'X') {
|
||||
num_map = D_80334974;
|
||||
} else {
|
||||
num_map = D_80334960;
|
||||
}
|
||||
|
||||
base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16);
|
||||
buff_ind = BUFF_LEN;
|
||||
num = args->value.s64;
|
||||
|
||||
if ((type == 'd' || type == 'i') && args->value.s64 < 0) {
|
||||
num = -num;
|
||||
}
|
||||
|
||||
if (num != 0 || args->precision != 0) {
|
||||
buff[--buff_ind] = num_map[num % base];
|
||||
}
|
||||
|
||||
args->value.s64 = num / base;
|
||||
|
||||
while (args->value.s64 > 0 && buff_ind > 0) {
|
||||
quotrem = lldiv(args->value.s64, base);
|
||||
args->value.s64 = quotrem.quot;
|
||||
buff[--buff_ind] = num_map[quotrem.rem];
|
||||
}
|
||||
|
||||
args->part2_len = BUFF_LEN - buff_ind;
|
||||
|
||||
memcpy(args->buff, buff + buff_ind, args->part2_len);
|
||||
|
||||
if (args->part2_len < args->precision) {
|
||||
args->num_leading_zeros = args->precision - args->part2_len;
|
||||
}
|
||||
|
||||
if (args->precision < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) {
|
||||
buff_ind = args->width - args->part1_len - args->num_leading_zeros - args->part2_len;
|
||||
if (buff_ind > 0) {
|
||||
args->num_leading_zeros += buff_ind;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "printf.h"
|
||||
|
||||
#define ATOI(i, a) \
|
||||
for (i = 0; *a >= '0' && *a <= '9'; a++) \
|
||||
if (i < 999) \
|
||||
i = *a + i * 10 - '0';
|
||||
#define _PROUT(dst, fmt, _size) \
|
||||
if (_size > 0) { \
|
||||
dst = prout(dst, fmt, _size); \
|
||||
if (dst != 0) \
|
||||
sp78.size += _size; \
|
||||
else \
|
||||
return sp78.size; \
|
||||
}
|
||||
#define _PAD(i, m, c, src, extracond) \
|
||||
if (extracond && m > 0) \
|
||||
for (i = m; i > 0; i -= c) { \
|
||||
if ((u32) i > 32) \
|
||||
c = 32; \
|
||||
else \
|
||||
c = i; \
|
||||
_PROUT(dst, src, c); \
|
||||
}
|
||||
|
||||
const char length_str[] = "hlL";
|
||||
const char flags_str[] = " +-#0";
|
||||
const u32 flags_arr[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0 };
|
||||
char _spaces[] = " ";
|
||||
char _zeroes[] = "00000000000000000000000000000000";
|
||||
|
||||
static void _Putfld(printf_struct *, va_list *, u8, u8 *);
|
||||
|
||||
s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char *fmt, va_list args) {
|
||||
printf_struct sp78;
|
||||
const u8 *fmt_ptr;
|
||||
u8 c;
|
||||
const char *flag_index;
|
||||
u8 sp4c[0x20]; // probably a buffer?
|
||||
s32 sp48, sp44, sp40, sp3c, sp38, sp34, sp30, sp2c, sp28, sp24;
|
||||
sp78.size = 0;
|
||||
while (1) {
|
||||
fmt_ptr = (u8 *) fmt;
|
||||
while ((c = *fmt_ptr++) > 0) {
|
||||
if (c == '%') {
|
||||
fmt_ptr--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_PROUT(dst, fmt, fmt_ptr - (u8 *) fmt);
|
||||
if (c == 0) {
|
||||
return sp78.size;
|
||||
}
|
||||
fmt = (char *) ++fmt_ptr;
|
||||
sp78.flags = 0;
|
||||
for (; (flag_index = strchr(flags_str, *fmt_ptr)) != NULL; fmt_ptr++) {
|
||||
sp78.flags |= flags_arr[flag_index - flags_str];
|
||||
}
|
||||
if (*fmt_ptr == '*') {
|
||||
sp78.width = va_arg(args, s32);
|
||||
if (sp78.width < 0) {
|
||||
sp78.width = -sp78.width;
|
||||
sp78.flags |= FLAGS_MINUS;
|
||||
}
|
||||
fmt_ptr++;
|
||||
} else {
|
||||
ATOI(sp78.width, fmt_ptr);
|
||||
}
|
||||
if (*fmt_ptr != '.') {
|
||||
sp78.precision = -1;
|
||||
} else {
|
||||
fmt_ptr++;
|
||||
if (*fmt_ptr == '*') {
|
||||
sp78.precision = va_arg(args, s32);
|
||||
fmt_ptr++;
|
||||
} else {
|
||||
ATOI(sp78.precision, fmt_ptr);
|
||||
}
|
||||
}
|
||||
if (strchr(length_str, *fmt_ptr) != NULL) {
|
||||
sp78.length = *fmt_ptr++;
|
||||
} else {
|
||||
sp78.length = 0;
|
||||
}
|
||||
|
||||
if (sp78.length == 'l' && *fmt_ptr == 'l') {
|
||||
sp78.length = 'L';
|
||||
fmt_ptr++;
|
||||
}
|
||||
_Putfld(&sp78, &args, *fmt_ptr, sp4c);
|
||||
sp78.width -= sp78.part1_len + sp78.num_leading_zeros + sp78.part2_len + sp78.num_mid_zeros
|
||||
+ sp78.part3_len + sp78.num_trailing_zeros;
|
||||
_PAD(sp44, sp78.width, sp48, _spaces, !(sp78.flags & FLAGS_MINUS));
|
||||
_PROUT(dst, (char *) sp4c, sp78.part1_len);
|
||||
_PAD(sp3c, sp78.num_leading_zeros, sp40, _zeroes, 1);
|
||||
_PROUT(dst, sp78.buff, sp78.part2_len);
|
||||
_PAD(sp34, sp78.num_mid_zeros, sp38, _zeroes, 1);
|
||||
_PROUT(dst, (char *) (&sp78.buff[sp78.part2_len]), sp78.part3_len)
|
||||
_PAD(sp2c, sp78.num_trailing_zeros, sp30, _zeroes, 1);
|
||||
_PAD(sp24, sp78.width, sp28, _spaces, sp78.flags & FLAGS_MINUS);
|
||||
fmt = (char *) fmt_ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
|
||||
a0->part1_len = a0->num_leading_zeros = a0->part2_len = a0->num_mid_zeros = a0->part3_len =
|
||||
a0->num_trailing_zeros = 0;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case 'c':
|
||||
buff[a0->part1_len++] = va_arg(*args, u32);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (a0->length == 'l') {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
} else if (a0->length == 'L') {
|
||||
a0->value.s64 = va_arg(*args, s64);
|
||||
} else {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
}
|
||||
|
||||
if (a0->length == 'h') {
|
||||
a0->value.s64 = (s16) a0->value.s64;
|
||||
}
|
||||
|
||||
if (a0->value.s64 < 0) {
|
||||
buff[a0->part1_len++] = '-';
|
||||
} else if (a0->flags & FLAGS_PLUS) {
|
||||
buff[a0->part1_len++] = '+';
|
||||
} else if (a0->flags & FLAGS_SPACE) {
|
||||
buff[a0->part1_len++] = ' ';
|
||||
}
|
||||
|
||||
a0->buff = (char *) &buff[a0->part1_len];
|
||||
|
||||
_Litob(a0, type);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'u':
|
||||
case 'o':
|
||||
if (a0->length == 'l') {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
} else if (a0->length == 'L') {
|
||||
a0->value.s64 = va_arg(*args, s64);
|
||||
} else {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
}
|
||||
|
||||
if (a0->length == 'h') {
|
||||
a0->value.s64 = (u16) a0->value.s64;
|
||||
} else if (a0->length == 0) {
|
||||
a0->value.s64 = (u32) a0->value.s64;
|
||||
}
|
||||
|
||||
if (a0->flags & FLAGS_HASH) {
|
||||
buff[a0->part1_len++] = '0';
|
||||
if (type == 'x' || type == 'X') {
|
||||
|
||||
buff[a0->part1_len++] = type;
|
||||
}
|
||||
}
|
||||
a0->buff = (char *) &buff[a0->part1_len];
|
||||
_Litob(a0, type);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'E':
|
||||
case 'G':
|
||||
//... okay?
|
||||
a0->value.f64 = a0->length == 'L' ? va_arg(*args, f64) : va_arg(*args, f64);
|
||||
|
||||
if (a0->value.u16 & 0x8000) {
|
||||
buff[a0->part1_len++] = '-';
|
||||
} else {
|
||||
if (a0->flags & FLAGS_PLUS) {
|
||||
buff[a0->part1_len++] = '+';
|
||||
} else if (a0->flags & FLAGS_SPACE) {
|
||||
buff[a0->part1_len++] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
a0->buff = (char *) &buff[a0->part1_len];
|
||||
_Ldtob(a0, type);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (a0->length == 'h') {
|
||||
*(va_arg(*args, u16 *)) = a0->size;
|
||||
} else if (a0->length == 'l') {
|
||||
*va_arg(*args, u32 *) = a0->size;
|
||||
} else if (a0->length == 'L') {
|
||||
*va_arg(*args, u64 *) = a0->size;
|
||||
} else {
|
||||
*va_arg(*args, u32 *) = a0->size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
a0->value.s64 = (intptr_t) va_arg(*args, void *);
|
||||
a0->buff = (char *) &buff[a0->part1_len];
|
||||
_Litob(a0, 'x');
|
||||
break;
|
||||
|
||||
case 's':
|
||||
a0->buff = va_arg(*args, char *);
|
||||
a0->part2_len = strlen(a0->buff);
|
||||
if (a0->precision >= 0 && a0->part2_len > a0->precision) {
|
||||
a0->part2_len = a0->precision;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%':
|
||||
buff[a0->part1_len++] = '%';
|
||||
break;
|
||||
|
||||
default:
|
||||
buff[a0->part1_len++] = type;
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
s32 __osAiDeviceBusy(void) {
|
||||
register s32 status = HW_REG(AI_STATUS_REG, u32);
|
||||
if ((status & AI_STATUS_AI_FULL) != 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
s32 __osAtomicDec(u32 *a0) {
|
||||
s32 sp1c;
|
||||
s32 sp18;
|
||||
sp1c = __osDisableInt();
|
||||
|
||||
if (*a0 != 0) {
|
||||
(*a0)--;
|
||||
sp18 = 1;
|
||||
} else {
|
||||
sp18 = 0;
|
||||
}
|
||||
|
||||
__osRestoreInt(sp1c);
|
||||
return sp18;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
// these don't feel like they belong here
|
||||
// but it makes the most logical since there was printf data before
|
||||
#ifndef AVOID_UB
|
||||
OSThread *D_80334890 = NULL;
|
||||
u32 D_80334894 = -1;
|
||||
OSThread *D_80334898 = (OSThread *) &D_80334890;
|
||||
OSThread *D_8033489C = (OSThread *) &D_80334890;
|
||||
OSThread *D_803348A0 = NULL;
|
||||
u32 D_803348A4 = 0; // UNKNOWN
|
||||
#else
|
||||
OSThread_ListHead D_80334890_fix = {NULL, -1, (OSThread *) &D_80334890_fix, (OSThread *) &D_80334890_fix, NULL, 0};
|
||||
#endif
|
||||
|
||||
void __osDequeueThread(OSThread **queue, OSThread *thread) {
|
||||
register OSThread **a2;
|
||||
register OSThread *a3;
|
||||
a2 = queue;
|
||||
a3 = *a2;
|
||||
while (a3 != NULL) {
|
||||
if (a3 == thread) {
|
||||
*a2 = thread->next;
|
||||
return;
|
||||
}
|
||||
a2 = &a3->next;
|
||||
a3 = *a2;
|
||||
}
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "macros.h"
|
||||
#if defined(VERSION_EU)
|
||||
#include "new_func.h"
|
||||
void __osDevMgrMain(void *args) {
|
||||
OSIoMesg *sp44;
|
||||
OSMesg sp40;
|
||||
OSMesg sp3c;
|
||||
s32 sp38;
|
||||
OSMgrArgs *sp34;
|
||||
UNUSED u32 sp30;
|
||||
u32 sp2c;
|
||||
__OSBlockInfo *sp28;
|
||||
__OSTranxInfo *sp24;
|
||||
sp30 = 0;
|
||||
sp2c = 0;
|
||||
sp44 = NULL;
|
||||
sp38 = 0;
|
||||
sp34 = (OSMgrArgs *) args;
|
||||
while (1) {
|
||||
osRecvMesg(sp34->unk08, (OSMesg) &sp44, OS_MESG_BLOCK);
|
||||
if (sp44->piHandle != NULL && sp44->piHandle->type == 2
|
||||
&& (sp44->piHandle->transferInfo.cmdType == 0
|
||||
|| sp44->piHandle->transferInfo.cmdType == 1)) {
|
||||
sp24 = &sp44->piHandle->transferInfo;
|
||||
sp28 = &sp24->block[sp24->blockNum];
|
||||
sp24->sectorNum = -1;
|
||||
if (sp24->transferMode != 3) {
|
||||
sp28->dramAddr = (void *) ((u32) sp28->dramAddr - sp28->sectorSize);
|
||||
}
|
||||
if (sp24->transferMode == 2 && sp44->piHandle->transferInfo.cmdType == 0)
|
||||
sp2c = 1;
|
||||
else
|
||||
sp2c = 0;
|
||||
osRecvMesg(sp34->unk10, &sp3c, OS_MESG_BLOCK);
|
||||
func_802F7140(0x00100401); // remove magic constant!
|
||||
func_802F71A0(sp44->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000));
|
||||
while (1) {
|
||||
osRecvMesg(sp34->unk0c, &sp40, OS_MESG_BLOCK);
|
||||
sp30 = osSendMesg(sp44->hdr.retQueue, sp44, OS_MESG_NOBLOCK);
|
||||
if (sp2c != 1 || sp44->piHandle->transferInfo.unk10 != 0)
|
||||
break;
|
||||
sp2c = 0;
|
||||
}
|
||||
osSendMesg(sp34->unk10, NULL, OS_MESG_NOBLOCK);
|
||||
if (sp44->piHandle->transferInfo.blockNum == 1)
|
||||
func_802F71F0();
|
||||
} else {
|
||||
switch (sp44->hdr.type) {
|
||||
case 11:
|
||||
osRecvMesg(sp34->unk10, &sp3c, OS_MESG_BLOCK);
|
||||
sp38 = sp34->dma_func(OS_READ, sp44->devAddr, sp44->dramAddr, sp44->size);
|
||||
break;
|
||||
case 12:
|
||||
osRecvMesg(sp34->unk10, &sp3c, OS_MESG_BLOCK);
|
||||
sp38 = sp34->dma_func(OS_WRITE, sp44->devAddr, sp44->dramAddr, sp44->size);
|
||||
break;
|
||||
case 15:
|
||||
osRecvMesg(sp34->unk10, &sp3c, OS_MESG_BLOCK);
|
||||
sp38 = sp34->edma_func(sp44->piHandle, OS_READ, sp44->devAddr, sp44->dramAddr,
|
||||
sp44->size);
|
||||
break;
|
||||
case 16:
|
||||
osRecvMesg(sp34->unk10, &sp3c, OS_MESG_BLOCK);
|
||||
sp38 = sp34->edma_func(sp44->piHandle, OS_WRITE, sp44->devAddr, sp44->dramAddr,
|
||||
sp44->size);
|
||||
break;
|
||||
case 10:
|
||||
osSendMesg(sp44->hdr.retQueue, sp44, OS_MESG_NOBLOCK);
|
||||
sp38 = -1;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
sp38 = -1;
|
||||
break;
|
||||
}
|
||||
if (sp38 == 0) {
|
||||
osRecvMesg(sp34->unk0c, &sp40, OS_MESG_BLOCK);
|
||||
sp30 = osSendMesg(sp44->hdr.retQueue, sp44, OS_MESG_NOBLOCK);
|
||||
osSendMesg(sp34->unk10, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void __osDevMgrMain(void *args) {
|
||||
OSIoMesg *sp34;
|
||||
OSMesg sp30;
|
||||
OSMesg sp2c;
|
||||
s32 sp28;
|
||||
OSMgrArgs *sp24;
|
||||
sp34 = NULL;
|
||||
sp28 = 0;
|
||||
sp24 = (OSMgrArgs *) args;
|
||||
while (1) {
|
||||
osRecvMesg(sp24->unk08, (OSMesg) &sp34, OS_MESG_BLOCK);
|
||||
switch (sp34->hdr.type) {
|
||||
case 11:
|
||||
osRecvMesg(sp24->unk10, &sp2c, OS_MESG_BLOCK);
|
||||
sp28 = sp24->dma_func(OS_READ, sp34->devAddr, sp34->dramAddr, sp34->size);
|
||||
break;
|
||||
case 12:
|
||||
osRecvMesg(sp24->unk10, &sp2c, OS_MESG_BLOCK);
|
||||
sp28 = sp24->dma_func(OS_WRITE, sp34->devAddr, sp34->dramAddr, sp34->size);
|
||||
break;
|
||||
case 10:
|
||||
osSendMesg(sp34->hdr.retQueue, sp34, OS_MESG_NOBLOCK);
|
||||
sp28 = -1;
|
||||
break;
|
||||
default:
|
||||
sp28 = -1;
|
||||
break;
|
||||
}
|
||||
if (sp28 == 0) {
|
||||
osRecvMesg(sp24->unk0c, &sp30, OS_MESG_BLOCK);
|
||||
osSendMesg(sp34->hdr.retQueue, sp34, OS_MESG_NOBLOCK);
|
||||
osSendMesg(sp24->unk10, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,5 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
OSThread *__osGetCurrFaultedThread() {
|
||||
return D_8033489C; // 80302efc
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
#define PIAccessQueueSize 2
|
||||
|
||||
OSMesg osPiMesgBuff[PIAccessQueueSize];
|
||||
OSMesgQueue gOsPiMessageQueue;
|
||||
u32 gOsPiAccessQueueCreated = 0;
|
||||
|
||||
void __osPiCreateAccessQueue(void) {
|
||||
gOsPiAccessQueueCreated = 1;
|
||||
osCreateMesgQueue(&gOsPiMessageQueue, &osPiMesgBuff[0], PIAccessQueueSize - 1);
|
||||
osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
void __osPiGetAccess(void) {
|
||||
OSMesg sp1c;
|
||||
if (!gOsPiAccessQueueCreated) {
|
||||
__osPiCreateAccessQueue();
|
||||
}
|
||||
osRecvMesg(&gOsPiMessageQueue, &sp1c, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void __osPiRelAccess(void) {
|
||||
osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#define SIAccessQueueSize 2
|
||||
OSMesg osSiMesgBuff[SIAccessQueueSize];
|
||||
OSMesgQueue gOsSiMessageQueue;
|
||||
|
||||
u32 gOsSiAccessQueueCreated = 0;
|
||||
void __osSiCreateAccessQueue() {
|
||||
gOsSiAccessQueueCreated = 1;
|
||||
osCreateMesgQueue(&gOsSiMessageQueue, &osSiMesgBuff[0], SIAccessQueueSize - 1);
|
||||
osSendMesg(&gOsSiMessageQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
void __osSiGetAccess(void) {
|
||||
OSMesg sp1c;
|
||||
if (!gOsSiAccessQueueCreated) {
|
||||
__osSiCreateAccessQueue();
|
||||
}
|
||||
osRecvMesg(&gOsSiMessageQueue, &sp1c, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void __osSiRelAccess(void) {
|
||||
osSendMesg(&gOsSiMessageQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
s32 __osSiDeviceBusy() {
|
||||
register u32 status;
|
||||
status = HW_REG(SI_STATUS_REG, u32);
|
||||
if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
s32 __osSiRawReadIo(void *a0, u32 *a1) {
|
||||
if (__osSiDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
*a1 = HW_REG((uintptr_t) a0, u32);
|
||||
return 0;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
s32 __osSiRawStartDma(s32 dir, void *addr) {
|
||||
if (__osSiDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dir == OS_WRITE) {
|
||||
osWritebackDCache(addr, 64);
|
||||
}
|
||||
|
||||
HW_REG(SI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(addr);
|
||||
|
||||
if (dir == OS_READ) {
|
||||
HW_REG(SI_PIF_ADDR_RD64B_REG, u32) = 0x1FC007C0;
|
||||
} else {
|
||||
HW_REG(SI_PIF_ADDR_WR64B_REG, u32) = 0x1FC007C0;
|
||||
}
|
||||
|
||||
if (dir == OS_READ) {
|
||||
osInvalDCache(addr, 64);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
s32 __osSiRawWriteIo(void *a0, u32 a1) {
|
||||
if (__osSiDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
HW_REG((uintptr_t) a0, u32) = a1;
|
||||
return 0;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
s32 __osSpDeviceBusy() {
|
||||
register u32 status = HW_REG(SP_STATUS_REG, u32);
|
||||
if (status & (SPSTATUS_IO_FULL | SPSTATUS_DMA_FULL | SPSTATUS_DMA_BUSY)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
u32 __osSpGetStatus() {
|
||||
return HW_REG(SP_STATUS_REG, u32);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size) {
|
||||
if (__osSpDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
HW_REG(SP_MEM_ADDR_REG, void *) = sp_ptr;
|
||||
HW_REG(SP_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_ptr);
|
||||
if (dir == 0) {
|
||||
HW_REG(SP_WR_LEN_REG, u32) = size - 1;
|
||||
} else {
|
||||
HW_REG(SP_RD_LEN_REG, u32) = size - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
s32 __osSpSetPc(void *pc) {
|
||||
register u32 status = HW_REG(SP_STATUS_REG, u32);
|
||||
if (!(status & SPSTATUS_HALT)) {
|
||||
return -1;
|
||||
} else {
|
||||
HW_REG(SP_PC_REG, void *) = pc;
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
void __osSpSetStatus(u32 status) {
|
||||
HW_REG(SP_STATUS_REG, u32) = status;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
typedef struct {
|
||||
u8 unk00 : 2;
|
||||
u8 pad : 4;
|
||||
u8 unk01 : 2;
|
||||
u8 unk2[3];
|
||||
} unkStruct;
|
||||
|
||||
u32 D_80334A40 = 0;
|
||||
u32 D_80334A44 = 1;
|
||||
|
||||
void __osSyncPutChars(s32 a0, s32 a1, u8 *a2) {
|
||||
unkStruct sp24;
|
||||
s32 sp20;
|
||||
u32 sp1c;
|
||||
sp24.unk00 = a0;
|
||||
sp24.unk01 = a1;
|
||||
|
||||
for (sp20 = 0; sp20 < a1; sp20++) {
|
||||
sp24.unk2[sp20] = a2[sp20];
|
||||
}
|
||||
|
||||
while (!__osAtomicDec(&D_80334A44)) {
|
||||
;
|
||||
}
|
||||
|
||||
sp1c = __osDisableInt();
|
||||
|
||||
*(u32 *) 0xC0000000 = *(u32 *) &sp24;
|
||||
while (!(__osGetCause() & 0x2000)) {
|
||||
;
|
||||
}
|
||||
*(u32 *) 0xC000000C = 0;
|
||||
D_80334A44++;
|
||||
|
||||
__osRestoreInt(sp1c);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSViContext *D_80334910;
|
||||
OSViContext *__osViGetCurrentContext() {
|
||||
return D_80334910;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#ifndef VERSION_JP
|
||||
extern u32 osTvType;
|
||||
#endif
|
||||
|
||||
OSViContext D_803348B0[2] = { 0 };
|
||||
OSViContext *D_80334910 = &D_803348B0[0];
|
||||
OSViContext *D_80334914 = &D_803348B0[1];
|
||||
#ifdef VERSION_EU
|
||||
u32 D_8033491C = 0x02E6D354;
|
||||
u32 D_80334918 = TV_TYPE_PAL;
|
||||
#else
|
||||
u32 D_80334918 = TV_TYPE_NTSC;
|
||||
u32 D_8033491C = 0x02E6D354;
|
||||
#endif
|
||||
|
||||
extern OSViMode D_80334990;
|
||||
extern OSViMode D_803349E0;
|
||||
#ifdef VERSION_EU
|
||||
extern OSViMode D_80302FD0;
|
||||
#endif
|
||||
|
||||
void __osViInit(void) {
|
||||
//#ifdef VERSION_JP
|
||||
#ifdef VERSION_US
|
||||
D_80334918 = osTvType;
|
||||
#endif
|
||||
bzero(D_803348B0, sizeof(D_803348B0));
|
||||
D_80334910 = &D_803348B0[0];
|
||||
D_80334914 = &D_803348B0[1];
|
||||
D_80334914->retraceCount = 1;
|
||||
D_80334910->retraceCount = 1;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
|
||||
if (osTvType == TV_TYPE_PAL) {
|
||||
D_80334914->unk08 = &D_80334990;
|
||||
D_8033491C = 0x02F5B2D2;
|
||||
} else if (osTvType == TV_TYPE_MPAL) {
|
||||
D_80334914->unk08 = &D_803349E0;
|
||||
D_8033491C = 0x02E6025C;
|
||||
} else {
|
||||
D_80334914->unk08 = &D_80302FD0;
|
||||
D_8033491C = 0x02E6D354;
|
||||
}
|
||||
|
||||
#else
|
||||
#ifdef VERSION_JP
|
||||
if (D_80334918 != TV_TYPE_PAL)
|
||||
#else
|
||||
if (D_80334918 == TV_TYPE_NTSC)
|
||||
#endif
|
||||
{
|
||||
D_80334914->unk08 = &D_80334990;
|
||||
D_8033491C = 0x02E6D354;
|
||||
} else {
|
||||
D_80334914->unk08 = &D_803349E0;
|
||||
#ifdef VERSION_JP
|
||||
D_8033491C = 0x02F5B2D2;
|
||||
#else
|
||||
D_8033491C = 0x02E6025C;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
D_80334914->unk00 = 32;
|
||||
D_80334914->features = D_80334914->unk08->comRegs.ctrl;
|
||||
#ifndef VERSION_JP
|
||||
while (HW_REG(VI_CURRENT_REG, u32) > 0xa) {
|
||||
;
|
||||
}
|
||||
HW_REG(VI_STATUS_REG, u32) = 0;
|
||||
#endif
|
||||
__osViSwapContext();
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
extern OSViContext *D_80334914;
|
||||
extern OSViContext *D_80334910;
|
||||
void __osViSwapContext() {
|
||||
register OSViMode *s0;
|
||||
register OSViContext *s1;
|
||||
u32 origin;
|
||||
u32 hStart;
|
||||
u32 sp34;
|
||||
u32 field;
|
||||
register u32 s2;
|
||||
field = 0;
|
||||
s1 = D_80334914;
|
||||
s0 = s1->unk08;
|
||||
field = HW_REG(VI_V_CURRENT_LINE_REG, u32) & 1;
|
||||
s2 = osVirtualToPhysical(s1->buffer);
|
||||
origin = (s0->fldRegs[field].origin) + s2;
|
||||
if (s1->unk00 & 2) {
|
||||
s1->unk20 |= s0->comRegs.xScale & ~0xfff;
|
||||
} else {
|
||||
s1->unk20 = s0->comRegs.xScale;
|
||||
}
|
||||
if (s1->unk00 & 4) {
|
||||
sp34 = (u32)(s0->fldRegs[field].yScale & 0xfff);
|
||||
s1->unk2c = s1->unk24 * sp34;
|
||||
s1->unk2c |= s0->fldRegs[field].yScale & ~0xfff;
|
||||
} else {
|
||||
s1->unk2c = s0->fldRegs[field].yScale;
|
||||
}
|
||||
hStart = s0->comRegs.hStart;
|
||||
if (s1->unk00 & 0x20) {
|
||||
hStart = 0;
|
||||
}
|
||||
if (s1->unk00 & 0x40) {
|
||||
s1->unk2c = 0;
|
||||
origin = osVirtualToPhysical(s1->buffer);
|
||||
}
|
||||
if (s1->unk00 & 0x80) {
|
||||
s1->unk2c = (s1->unk28 << 0x10) & 0x3ff0000;
|
||||
origin = osVirtualToPhysical(s1->buffer);
|
||||
}
|
||||
HW_REG(VI_ORIGIN_REG, u32) = origin;
|
||||
HW_REG(VI_WIDTH_REG, u32) = s0->comRegs.width;
|
||||
HW_REG(VI_BURST_REG, u32) = s0->comRegs.burst;
|
||||
HW_REG(VI_V_SYNC_REG, u32) = s0->comRegs.vSync;
|
||||
HW_REG(VI_H_SYNC_REG, u32) = s0->comRegs.hSync;
|
||||
HW_REG(VI_LEAP_REG, u32) = s0->comRegs.leap;
|
||||
HW_REG(VI_H_START_REG, u32) = hStart;
|
||||
HW_REG(VI_V_START_REG, u32) = s0->fldRegs[field].vStart;
|
||||
HW_REG(VI_V_BURST_REG, u32) = s0->fldRegs[field].vBurst;
|
||||
HW_REG(VI_INTR_REG, u32) = s0->fldRegs[field].vIntr;
|
||||
HW_REG(VI_X_SCALE_REG, u32) = s1->unk20;
|
||||
HW_REG(VI_Y_SCALE_REG, u32) = s1->unk2c;
|
||||
HW_REG(VI_CONTROL_REG, u32) = s1->features;
|
||||
D_80334914 = D_80334910;
|
||||
D_80334910 = s1;
|
||||
*D_80334914 = *D_80334910;
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
#include "new_func.h"
|
||||
|
||||
void func_802F4A20(void) {
|
||||
__OSTranxInfo *sp1c;
|
||||
volatile u32 sp18;
|
||||
sp1c = &__osDiskHandle->transferInfo;
|
||||
WAIT_ON_IOBUSY(sp18);
|
||||
HW_REG(ASIC_BM_CTL, u32) = BUFFER_MANAGER_RESET | sp1c->bmCtlShadow; //should be unk10??
|
||||
WAIT_ON_IOBUSY(sp18);
|
||||
HW_REG(ASIC_BM_CTL, u32) = sp1c->bmCtlShadow;
|
||||
func_802F4B08();
|
||||
HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR;
|
||||
D_8030208C |= 0x00100401; //TODO: fix magic numbers
|
||||
}
|
||||
|
||||
typedef struct OSEventMessageStruct_0_s {
|
||||
OSMesgQueue *queue;
|
||||
OSMesg msg;
|
||||
} OSEventMessageStruct_0;
|
||||
|
||||
extern OSEventMessageStruct_0 D_80363830[16]; // should be OS_NUM_EVENTS + 1 I think
|
||||
|
||||
void func_802F4B08(void) {
|
||||
OSEventMessageStruct_0 *sp2c;
|
||||
OSMesgQueue *sp28;
|
||||
u32 sp24;
|
||||
register OSThread *s0;
|
||||
sp2c = &D_80363830[OS_EVENT_PI];
|
||||
sp28 = sp2c->queue;
|
||||
if (!sp28 || sp28->validCount >= sp28->msgCount)
|
||||
return;
|
||||
sp24 = (sp28->first + sp28->validCount) % sp28->msgCount;
|
||||
sp28->msg[sp24] = sp2c->msg;
|
||||
sp28->validCount += 1;
|
||||
if (sp28->mtqueue->next != NULL) {
|
||||
s0 = __osPopThread(&sp28->mtqueue);
|
||||
__osEnqueueThread(&D_80334898, s0);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "new_func.h"
|
||||
|
||||
void func_802F7140(u32 a0) {
|
||||
register u32 s0;
|
||||
s0 = __osDisableInt();
|
||||
D_8030208C &= ~(-0x402 & a0);
|
||||
__osRestoreInt(s0);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
|
||||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
//possibly osEpiWriteIo
|
||||
s32 func_802F71A0(OSPiHandle *a0, u32 a1, u32 a2) {
|
||||
register u32 a3 = HW_REG(PI_STATUS_REG, u32);
|
||||
while (a3 & PI_STATUS_ERROR)
|
||||
a3 = HW_REG(PI_STATUS_REG, u32);
|
||||
HW_REG(a0->baseAddress | a1, u32) = a2;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
/ 0B69A0 802F71A0 3C0EA460 / lui $t6, %hi(PI_STATUS_REG) # $t6, 0xa460
|
||||
/ 0B69A4 802F71A4 8DC70010 / lw $a3, %lo(PI_STATUS_REG)($t6)
|
||||
/ 0B69A8 802F71A8 27BDFFF8 / addiu $sp, $sp, -8
|
||||
/ 0B69AC 802F71AC 30EF0003 / andi $t7, $a3, 3
|
||||
|
||||
/ 0B69B0 802F71B0 11E00006 / beqz $t7, .L802F71CC
|
||||
/ 0B69B4 802F71B4 00000000 / nop
|
||||
.L802F71B8:
|
||||
/ 0B69B8 802F71B8 3C18A460 / lui $t8, %hi(PI_STATUS_REG) # $t8, 0xa460
|
||||
/ 0B69BC 802F71BC 8F070010 / lw $a3, %lo(PI_STATUS_REG)($t8)
|
||||
/ 0B69C0 802F71C0 30F90003 / andi $t9, $a3, 3
|
||||
/ 0B69C4 802F71C4 1720FFFC / bnez $t9, .L802F71B8
|
||||
/ 0B69C8 802F71C8 00000000 / nop
|
||||
.L802F71CC:
|
||||
/ 0B69CC 802F71CC 8C88000C / lw $t0, 0xc($a0)
|
||||
/ 0B69D0 802F71D0 3C01A000 / lui $at, 0xa000
|
||||
/ 0B69D4 802F71D4 27BD0008 / addiu $sp, $sp, 8
|
||||
/ 0B69D8 802F71D8 01054825 / or $t1, $t0, $a1
|
||||
/ 0B69DC 802F71DC 01215025 / or $t2, $t1, $at
|
||||
/ 0B69E0 802F71E0 AD460000 / sw $a2, ($t2)
|
||||
/ 0B69E4 802F71E4 03E00008 / jr $ra
|
||||
/ 0B69E8 802F71E8 00001025 / move $v0, $zero
|
||||
|
||||
/ 0B69EC 802F71EC 00000000 / nop */
|
|
@ -1,8 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void func_802F71F0(void) {
|
||||
register u32 s0 = __osDisableInt();
|
||||
D_803348A0->state = OS_STATE_RUNNABLE;
|
||||
__osEnqueueAndYield(&D_80334898);
|
||||
__osRestoreInt(s0);
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
typedef struct {
|
||||
u8 unk00 : 2;
|
||||
u8 pad : 4;
|
||||
u8 unk01 : 2;
|
||||
u8 unk2[3];
|
||||
} unkStruct;
|
||||
|
||||
extern u32 D_80334A44;
|
||||
|
||||
u32 D_80334A30 = 0;
|
||||
u32 D_80334A34 = 0;
|
||||
s32 D_80334A38 = 0;
|
||||
|
||||
extern u8 D_80365E40[0x1000];
|
||||
|
||||
OSThread gInterruptedThread;
|
||||
|
||||
void u32_to_string(u32 i, u8 *str) {
|
||||
str[0] = (i >> 0x18) & 0xff;
|
||||
str[1] = (i >> 0x10) & 0xff;
|
||||
str[2] = (i >> 0x8) & 0xff;
|
||||
str[3] = i & 0xff;
|
||||
}
|
||||
|
||||
u32 string_to_u32(u8 *str) {
|
||||
u32 i;
|
||||
i = (str[0] & 0xff) << 0x18;
|
||||
i |= (str[1] & 0xff) << 0x10;
|
||||
i |= (str[2] & 0xff) << 0x8;
|
||||
i |= (str[3] & 0xff);
|
||||
return i;
|
||||
}
|
||||
|
||||
void send_packet(u8 *a0, s32 a1) {
|
||||
unkStruct sp1c;
|
||||
s32 i;
|
||||
sp1c.unk00 = 2;
|
||||
for (sp1c.unk01 = a1, i = 0; i < a1; i++) {
|
||||
sp1c.unk2[i] = a0[i];
|
||||
}
|
||||
*(volatile u32 *) 0xc0000000 = *(u32 *) &sp1c;
|
||||
while (!(__osGetCause() & 0x2000)) {
|
||||
;
|
||||
}
|
||||
*(volatile u32 *) 0xc000000c = 0;
|
||||
}
|
||||
|
||||
void send(u8 *buff, s32 len) {
|
||||
s32 i;
|
||||
s32 end;
|
||||
s32 rem;
|
||||
if (!D_80334A44) {
|
||||
while (!(__osGetCause() & 0x2000)) {
|
||||
;
|
||||
}
|
||||
*(volatile u32 *) 0xc000000c = 0;
|
||||
D_80334A44 = 1;
|
||||
}
|
||||
i = 0;
|
||||
rem = len % 3;
|
||||
end = len - rem;
|
||||
for (; i < end; i += 3) {
|
||||
send_packet(&buff[i], 3);
|
||||
}
|
||||
if (rem > 0) {
|
||||
send_packet(&buff[end], rem);
|
||||
}
|
||||
}
|
||||
|
||||
void process_command_memory(void) {
|
||||
u32 sp1c;
|
||||
u32 sp18;
|
||||
sp1c = string_to_u32(&D_80365E40[1]);
|
||||
sp18 = string_to_u32(&D_80365E40[5]);
|
||||
send((u8 *) (uintptr_t) sp1c, sp18);
|
||||
}
|
||||
|
||||
void process_command_register(void) {
|
||||
send((u8 *) &gInterruptedThread.context, sizeof(__OSThreadContext));
|
||||
}
|
||||
|
||||
void kdebugserver(u32 a0) {
|
||||
u32 sp2c;
|
||||
unkStruct sp28;
|
||||
*(u32 *) &sp28 = a0;
|
||||
for (sp2c = 0; sp2c < sp28.unk01; sp2c++) {
|
||||
D_80365E40[D_80334A34] = sp28.unk2[sp2c];
|
||||
D_80334A34++;
|
||||
}
|
||||
D_80334A38 -= sp28.unk01;
|
||||
switch (D_80334A30) {
|
||||
case 0:
|
||||
switch (sp28.unk2[0]) {
|
||||
case 1:
|
||||
D_80334A30 = 1;
|
||||
D_80334A38 = 9 - sp28.unk01;
|
||||
break;
|
||||
case 2:
|
||||
process_command_register();
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
break;
|
||||
default:
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (D_80334A38 <= 0) {
|
||||
if (D_80365E40[0] == 1) {
|
||||
process_command_memory();
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
} else {
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
D_80334A30 = 0;
|
||||
D_80334A34 = 0;
|
||||
D_80334A38 = 0;
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
|
||||
// These unions are necessary to put the constants in .rodata rather than .data.
|
||||
// TODO: is it possible to remove them somehow?
|
||||
|
||||
typedef union {
|
||||
/* 0x0 */ double d;
|
||||
/* 0x0 */ struct
|
||||
{
|
||||
/* 0x0 */ unsigned int hi;
|
||||
/* 0x4 */ unsigned int lo;
|
||||
} word;
|
||||
} du;
|
||||
|
||||
typedef union {
|
||||
/* 0x0 */ float f;
|
||||
/* 0x0 */ unsigned int i;
|
||||
} fu;
|
||||
|
||||
static const du P[5] = {{1.0},
|
||||
{-0.16666659550427756},
|
||||
{0.008333066246082155},
|
||||
{-1.980960290193795E-4},
|
||||
{2.605780637968037E-6}};
|
||||
|
||||
static const du rpi = {0.3183098861837907};
|
||||
|
||||
static const du pihi = {
|
||||
3.1415926218032837};
|
||||
|
||||
static const du pilo = {
|
||||
3.178650954705639E-8};
|
||||
|
||||
static const fu zero = {0.0};
|
||||
extern const fu NAN;
|
||||
|
||||
#ifndef OSX_BUILD
|
||||
float cosf(float x)
|
||||
{
|
||||
double dx; // double x
|
||||
double xsq; // x squared
|
||||
double poly;
|
||||
double dn;
|
||||
float xabs;
|
||||
int n;
|
||||
double result;
|
||||
int ix; // int x
|
||||
int xpt;
|
||||
ix = *(int *)&x;
|
||||
xpt = (ix >> 22) & 0x1FF;
|
||||
|
||||
if (xpt < 310)
|
||||
{
|
||||
if (0 < x)
|
||||
xabs = x;
|
||||
else
|
||||
xabs = -x;
|
||||
dx = xabs;
|
||||
|
||||
dn = dx * rpi.d + .5;
|
||||
if (0 <= dn)
|
||||
{
|
||||
|
||||
n = dn + .5;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = dn - .5;
|
||||
}
|
||||
dn = n;
|
||||
|
||||
dx -= (dn - .5) * pihi.d;
|
||||
dx -= (dn - .5) * pilo.d;
|
||||
xsq = dx * dx;
|
||||
|
||||
poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d;
|
||||
|
||||
result = ((dx * xsq) * poly) + dx;
|
||||
|
||||
if ((n & 0x1) == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -(float)result;
|
||||
}
|
||||
}
|
||||
|
||||
if (x != x)
|
||||
{
|
||||
return NAN.f;
|
||||
}
|
||||
|
||||
return zero.f;
|
||||
}
|
||||
#endif // OSX_BUILD cannot use this
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
typedef signed long long int s64;
|
||||
typedef unsigned long long int u64;
|
||||
s64 __d_to_ll(double d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
s64 __f_to_ll(float f)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
u64 __d_to_ull(double d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
u64 __f_to_ull(float f)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
double __ll_to_d(s64 s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
float __ll_to_f(s64 s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
double __ull_to_d(u64 u)
|
||||
{
|
||||
return u;
|
||||
}
|
||||
float __ull_to_f(u64 u)
|
||||
{
|
||||
return u;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1)
|
||||
{
|
||||
return a0 >> a1;
|
||||
}
|
||||
unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1)
|
||||
{
|
||||
return a0 % a1;
|
||||
}
|
||||
unsigned long long __ull_div(unsigned long long a0, unsigned long long a1)
|
||||
{
|
||||
return a0 / a1;
|
||||
}
|
||||
|
||||
unsigned long long __ll_lshift(unsigned long long a0, unsigned long long a1)
|
||||
{
|
||||
return a0 << a1;
|
||||
}
|
||||
|
||||
long long __ll_rem(unsigned long long a0, long long a1)
|
||||
{
|
||||
return a0 % a1;
|
||||
}
|
||||
|
||||
long long __ll_div(long long a0, long long a1)
|
||||
{
|
||||
return a0 / a1;
|
||||
}
|
||||
|
||||
unsigned long long __ll_mul(unsigned long long a0, unsigned long long a1)
|
||||
{
|
||||
return a0 * a1;
|
||||
}
|
||||
|
||||
void __ull_divremi(unsigned long long *div, unsigned long long *rem, unsigned long long a2, unsigned short a3)
|
||||
{
|
||||
*div = a2 / a3;
|
||||
*rem = a2 % a3;
|
||||
}
|
||||
long long __ll_mod(long long a0, long long a1)
|
||||
{
|
||||
long long tmp = a0 % a1;
|
||||
if ((tmp < 0 && a1 > 0) || (tmp > 0 && a1 < 0))
|
||||
{
|
||||
|
||||
tmp += a1;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
long long __ll_rshift(long long a0, long long a1)
|
||||
{
|
||||
return a0 >> a1;
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
|
||||
// These unions are necessary to put the constants in .rodata rather than .data.
|
||||
// TODO: is it possible to remove them somehow?
|
||||
|
||||
typedef union {
|
||||
/* 0x0 */ double d;
|
||||
/* 0x0 */ struct
|
||||
{
|
||||
/* 0x0 */ unsigned int hi;
|
||||
/* 0x4 */ unsigned int lo;
|
||||
} word;
|
||||
} du;
|
||||
|
||||
typedef union {
|
||||
/* 0x0 */ float f;
|
||||
/* 0x0 */ unsigned int i;
|
||||
} fu;
|
||||
|
||||
static const du P[5] = {{1.0},
|
||||
{-0.16666659550427756},
|
||||
{0.008333066246082155},
|
||||
{-1.980960290193795E-4},
|
||||
{2.605780637968037E-6}};
|
||||
|
||||
static const du rpi = {0.3183098861837907};
|
||||
|
||||
static const du pihi = {
|
||||
3.1415926218032837};
|
||||
|
||||
static const du pilo = {
|
||||
3.178650954705639E-8};
|
||||
|
||||
static const fu zero = {0.0};
|
||||
extern const fu NAN;
|
||||
|
||||
float sinf(float x)
|
||||
{
|
||||
double dx; // double x
|
||||
double xsq; // x squared
|
||||
double poly;
|
||||
double dn;
|
||||
int n;
|
||||
double result;
|
||||
int ix; // int x
|
||||
int xpt;
|
||||
|
||||
ix = *(int *)&x;
|
||||
xpt = (ix >> 22) & 0x1FF;
|
||||
|
||||
if (xpt < 255)
|
||||
{
|
||||
dx = x;
|
||||
if (xpt >= 230)
|
||||
{
|
||||
xsq = dx * dx;
|
||||
|
||||
poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d;
|
||||
|
||||
result = ((dx * xsq) * poly) + dx;
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
if (xpt < 310)
|
||||
{
|
||||
dx = x;
|
||||
|
||||
dn = dx * rpi.d;
|
||||
|
||||
if (dn >= 0)
|
||||
{
|
||||
n = dn + 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = dn - 0.5;
|
||||
}
|
||||
|
||||
dn = n;
|
||||
|
||||
dx -= dn * pihi.d;
|
||||
dx -= dn * pilo.d;
|
||||
|
||||
xsq = dx * dx;
|
||||
|
||||
poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d;
|
||||
|
||||
result = ((dx * xsq) * poly) + dx;
|
||||
|
||||
if ((n & 0x1) == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -(float)result;
|
||||
}
|
||||
}
|
||||
|
||||
if (x != x)
|
||||
{
|
||||
return NAN.f;
|
||||
}
|
||||
|
||||
return zero.f;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osAi.h"
|
||||
#include "hardware.h"
|
||||
|
||||
u32 osAiGetLength() {
|
||||
return HW_REG(AI_LEN_REG, u32);
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osAi.h"
|
||||
#include "hardware.h"
|
||||
|
||||
extern s32 D_8033491C;
|
||||
|
||||
s32 osAiSetFrequency(u32 freq) {
|
||||
register u32 a1;
|
||||
register s32 a2;
|
||||
register float ftmp;
|
||||
ftmp = D_8033491C / (float) freq + .5f;
|
||||
|
||||
a1 = ftmp;
|
||||
|
||||
if (a1 < 0x84) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
a2 = (a1 / 66) & 0xff;
|
||||
if (a2 > 16) {
|
||||
a2 = 16;
|
||||
}
|
||||
|
||||
HW_REG(AI_DACRATE_REG, u32) = a1 - 1;
|
||||
HW_REG(AI_BITRATE_REG, u32) = a2 - 1;
|
||||
HW_REG(AI_CONTROL_REG, u32) = 1; // enable dma
|
||||
return D_8033491C / (s32) a1;
|
||||
}
|
||||
|
||||
// put some extra jr $ra's down there please
|
||||
static void filler1(void) {
|
||||
}
|
||||
static void filler2(void) {
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osAi.h"
|
||||
#include "hardware.h"
|
||||
|
||||
u8 D_80334820 = 0;
|
||||
|
||||
/**
|
||||
* It is worth noting that a previous hardware bug has been fixed by a software
|
||||
* patch in osAiSetNextBuffer. This bug occurred when the address of the end of the
|
||||
* buffer specified by osAiSetNextBuffer was at a specific value. This value
|
||||
* occurred when the following was true:
|
||||
*
|
||||
* (vaddr + nbytes) & 0x00003FFF == 0x00002000
|
||||
*
|
||||
* (when the buffer ends with address of lower 14 bits 0x2000) In this case, the
|
||||
* DMA transfer does not complete successfully. This can cause clicks and pops in
|
||||
* the audio output. This bug no longer requires special handling by the application
|
||||
* because it is now patched by osAiSetNextBuffer.
|
||||
*/
|
||||
|
||||
s32 osAiSetNextBuffer(void *buff, u32 len) {
|
||||
u8 *sp1c = buff;
|
||||
if (D_80334820 != 0) {
|
||||
sp1c -= 0x2000;
|
||||
}
|
||||
|
||||
if ((((uintptr_t) buff + len) & 0x3fff) == 0x2000) {
|
||||
D_80334820 = 1;
|
||||
} else {
|
||||
D_80334820 = 0;
|
||||
}
|
||||
|
||||
if (__osAiDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
HW_REG(AI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(sp1c);
|
||||
HW_REG(AI_LEN_REG, u32) = len;
|
||||
return 0;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
|
||||
void __osPackRequestData(u8);
|
||||
void __osContGetInitData(u8 *, OSContStatus *);
|
||||
|
||||
u32 _osContInitialized = 0; // probably initialized
|
||||
|
||||
extern u64 osClockRate;
|
||||
|
||||
// these probably belong in EEPROMlongread or something
|
||||
u8 _osLastSentSiCmd;
|
||||
u8 _osContNumControllers;
|
||||
OSTimer D_80365D28;
|
||||
OSMesgQueue _osContMesgQueue;
|
||||
OSMesg _osContMesgBuff[4];
|
||||
s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) {
|
||||
OSMesg mesg;
|
||||
u32 ret = 0;
|
||||
OSTime currentTime;
|
||||
OSTimer timer;
|
||||
OSMesgQueue timerMesgQueue;
|
||||
|
||||
if (_osContInitialized) {
|
||||
return 0;
|
||||
}
|
||||
_osContInitialized = 1;
|
||||
currentTime = osGetTime();
|
||||
if (500000 * osClockRate / 1000000 > currentTime) {
|
||||
osCreateMesgQueue(&timerMesgQueue, &mesg, 1);
|
||||
osSetTimer(&timer, 500000 * osClockRate / 1000000 - currentTime, 0, &timerMesgQueue, &mesg);
|
||||
osRecvMesg(&timerMesgQueue, &mesg, OS_MESG_BLOCK);
|
||||
}
|
||||
_osContNumControllers = 4; // TODO: figure out what it means
|
||||
#ifdef VERSION_EU
|
||||
__osPackRequestData(0);
|
||||
#else
|
||||
__osPackRequestData(255);
|
||||
#endif
|
||||
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
|
||||
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
|
||||
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
|
||||
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
|
||||
__osContGetInitData(bitpattern, status);
|
||||
#ifdef VERSION_EU
|
||||
_osLastSentSiCmd = 0;
|
||||
#else
|
||||
_osLastSentSiCmd = 255;
|
||||
#endif
|
||||
__osSiCreateAccessQueue();
|
||||
osCreateMesgQueue(&_osContMesgQueue, _osContMesgBuff, 1);
|
||||
return ret;
|
||||
}
|
||||
void __osContGetInitData(u8 *bitpattern, OSContStatus *status) {
|
||||
OSContPackedRequest *cmdBufPtr;
|
||||
OSContPackedRequest response;
|
||||
s32 i;
|
||||
u8 sp7;
|
||||
|
||||
sp7 = 0;
|
||||
cmdBufPtr = &(_osContCmdBuf[0].request);
|
||||
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) {
|
||||
response = *(OSContPackedRequest *) cmdBufPtr;
|
||||
status->errnum = (response.rxLen & 0xc0) >> 4;
|
||||
if (status->errnum == 0) {
|
||||
status->type = response.data2 << 8 | response.data1;
|
||||
status->status = response.data3;
|
||||
|
||||
sp7 |= 1 << i;
|
||||
}
|
||||
}
|
||||
*bitpattern = sp7;
|
||||
}
|
||||
void __osPackRequestData(u8 command) {
|
||||
OSContPackedRequest *cmdBufPtr;
|
||||
OSContPackedRequest request;
|
||||
s32 i;
|
||||
|
||||
// some kind of weird zeroing code
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
*((u32 *) &_osContCmdBuf + i) = 0;
|
||||
}
|
||||
|
||||
_osContPifCtrl = 1;
|
||||
cmdBufPtr = &_osContCmdBuf[0].request;
|
||||
request.padOrEnd = 255;
|
||||
request.txLen = 1;
|
||||
request.rxLen = 3;
|
||||
request.command = command;
|
||||
request.data1 = 255;
|
||||
request.data2 = 255;
|
||||
request.data3 = 255;
|
||||
request.data4 = 255;
|
||||
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
*cmdBufPtr++ = request;
|
||||
}
|
||||
cmdBufPtr->padOrEnd = 254;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include <macros.h>
|
||||
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 OSContPackedStruct _osContCmdBuf[7];
|
||||
UNUSED static u32 unused; // padding between these two variables
|
||||
u32 _osContPifCtrl;
|
||||
#else
|
||||
// Reordered gcc vars above will disturb the aliasing done to access all 8 members of this array, hence AVOID_UB.
|
||||
ALIGNED8 OSContPackedStruct _osContCmdBuf[8];
|
||||
#endif
|
||||
|
||||
extern u8 _osLastSentSiCmd;
|
||||
extern u8 _osContNumControllers;
|
||||
|
||||
void __osPackReadData(void);
|
||||
s32 osContStartReadData(OSMesgQueue *mesg) {
|
||||
s32 ret = 0;
|
||||
s32 i;
|
||||
__osSiGetAccess();
|
||||
if (_osLastSentSiCmd != 1) {
|
||||
__osPackReadData();
|
||||
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
|
||||
osRecvMesg(mesg, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
*((u32 *) &_osContCmdBuf + i) = 255;
|
||||
}
|
||||
|
||||
_osContPifCtrl = 0;
|
||||
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
|
||||
_osLastSentSiCmd = 1;
|
||||
__osSiRelAccess();
|
||||
return ret;
|
||||
}
|
||||
void osContGetReadData(OSContPad *pad) {
|
||||
OSContPackedRead *cmdBufPtr;
|
||||
OSContPackedRead response;
|
||||
s32 i;
|
||||
cmdBufPtr = &_osContCmdBuf[0].read;
|
||||
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) {
|
||||
response = *cmdBufPtr;
|
||||
pad->errnum = (response.rxLen & 0xc0) >> 4;
|
||||
if (pad->errnum == 0) {
|
||||
pad->button = response.button;
|
||||
pad->stick_x = response.rawStickX;
|
||||
pad->stick_y = response.rawStickY;
|
||||
}
|
||||
};
|
||||
}
|
||||
void __osPackReadData() {
|
||||
OSContPackedRead *cmdBufPtr;
|
||||
OSContPackedRead request;
|
||||
s32 i;
|
||||
cmdBufPtr = &_osContCmdBuf[0].read;
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
*((u32 *) &_osContCmdBuf + i) = 0;
|
||||
}
|
||||
|
||||
_osContPifCtrl = 1;
|
||||
request.padOrEnd = 255;
|
||||
request.txLen = 1;
|
||||
request.rxLen = 4;
|
||||
request.command = 1;
|
||||
request.button = 65535;
|
||||
request.rawStickX = -1;
|
||||
request.rawStickY = -1;
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
*cmdBufPtr++ = request;
|
||||
}
|
||||
cmdBufPtr->padOrEnd = 254;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msgBuf, s32 count) {
|
||||
mq->mtqueue = (OSThread *) &D_80334890; //?
|
||||
mq->fullqueue = (OSThread *) &D_80334890;
|
||||
mq->validCount = 0;
|
||||
mq->first = 0;
|
||||
mq->msgCount = count;
|
||||
mq->msg = msgBuf;
|
||||
return;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
#define OS_PI_MGR_MESG_BUFF_SIZE 1
|
||||
|
||||
OSMgrArgs piMgrArgs = { 0 };
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
OSPiHandle *D_80302DFC = NULL;
|
||||
#endif
|
||||
OSThread piMgrThread;
|
||||
u32 piMgrStack[0x400]; // stack bottom
|
||||
OSMesgQueue __osPiMesgQueue;
|
||||
OSMesg piMgrMesgBuff[OS_PI_MGR_MESG_BUFF_SIZE + 1];
|
||||
|
||||
extern u32 gOsPiAccessQueueCreated;
|
||||
extern OSMesgQueue gOsPiMessageQueue;
|
||||
void __osDevMgrMain(void *);
|
||||
|
||||
void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt) {
|
||||
u32 int_disabled;
|
||||
OSPri newPri;
|
||||
OSPri currentPri;
|
||||
|
||||
if (!piMgrArgs.initialized) {
|
||||
osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt);
|
||||
osCreateMesgQueue(&__osPiMesgQueue, &piMgrMesgBuff[0], OS_PI_MGR_MESG_BUFF_SIZE);
|
||||
if (!gOsPiAccessQueueCreated) {
|
||||
__osPiCreateAccessQueue();
|
||||
} // what is this constant geez
|
||||
osSetEventMesg(OS_EVENT_PI, &__osPiMesgQueue, (void *) 0x22222222);
|
||||
newPri = -1;
|
||||
currentPri = osGetThreadPri(NULL);
|
||||
if (currentPri < pri) {
|
||||
newPri = currentPri;
|
||||
osSetThreadPri(NULL, pri);
|
||||
}
|
||||
int_disabled = __osDisableInt();
|
||||
piMgrArgs.initialized = TRUE;
|
||||
piMgrArgs.mgrThread = &piMgrThread;
|
||||
piMgrArgs.unk08 = cmdQ;
|
||||
piMgrArgs.unk0c = &__osPiMesgQueue;
|
||||
piMgrArgs.unk10 = &gOsPiMessageQueue;
|
||||
piMgrArgs.dma_func = osPiRawStartDma;
|
||||
#ifdef VERSION_EU
|
||||
piMgrArgs.edma_func = osEPiRawStartDma;
|
||||
#endif
|
||||
osCreateThread(&piMgrThread, 0, __osDevMgrMain, (void *) &piMgrArgs, &piMgrStack[0x400], pri);
|
||||
osStartThread(&piMgrThread);
|
||||
__osRestoreInt(int_disabled);
|
||||
if (newPri != -1) {
|
||||
osSetThreadPri(NULL, newPri);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void __osCleanupThread(void);
|
||||
|
||||
// Don't warn about pointer->u64 cast
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
|
||||
|
||||
void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri pri) {
|
||||
register u32 int_disabled;
|
||||
u32 tmp;
|
||||
thread->id = id;
|
||||
thread->priority = pri;
|
||||
thread->next = NULL;
|
||||
thread->queue = NULL;
|
||||
thread->context.pc = (u32) entry;
|
||||
thread->context.a0 = (u64) arg;
|
||||
thread->context.sp = (u64) sp - 16;
|
||||
thread->context.ra = (u64) __osCleanupThread;
|
||||
tmp = OS_IM_ALL;
|
||||
thread->context.sr = 65283;
|
||||
thread->context.rcp = (tmp & 0x3f0000) >> 16;
|
||||
thread->context.fpcsr = (u32) 0x01000800;
|
||||
thread->fp = 0;
|
||||
thread->state = OS_STATE_STOPPED;
|
||||
thread->flags = 0;
|
||||
int_disabled = __osDisableInt();
|
||||
thread->tlnext = D_8033489C;
|
||||
|
||||
D_8033489C = thread;
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
|
@ -1,108 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
#define OS_VI_MANAGER_MESSAGE_BUFF_SIZE 5
|
||||
|
||||
static OSMgrArgs viMgrMainArgs = { 0 };
|
||||
static OSThread viMgrThread;
|
||||
static u32 viMgrStack[0x400]; // stack bottom
|
||||
static OSMesgQueue __osViMesgQueue;
|
||||
static OSMesg viMgrMesgBuff[OS_VI_MANAGER_MESSAGE_BUFF_SIZE];
|
||||
|
||||
static OSIoMesg viEventViMesg;
|
||||
static OSIoMesg viEventCounterMesg;
|
||||
|
||||
extern void __osTimerServicesInit(void);
|
||||
extern void __osTimerInterrupt(void);
|
||||
extern OSTime _osCurrentTime;
|
||||
extern u32 D_80365DA8;
|
||||
extern u32 __osViIntrCount;
|
||||
void viMgrMain(void *);
|
||||
|
||||
void osCreateViManager(OSPri pri) {
|
||||
u32 int_disabled;
|
||||
OSPri newPri;
|
||||
OSPri currentPri;
|
||||
if (!viMgrMainArgs.initialized) {
|
||||
__osTimerServicesInit();
|
||||
osCreateMesgQueue(&__osViMesgQueue, &viMgrMesgBuff[0], OS_VI_MANAGER_MESSAGE_BUFF_SIZE);
|
||||
viEventViMesg.hdr.type = 13;
|
||||
viEventViMesg.hdr.pri = 0;
|
||||
viEventViMesg.hdr.retQueue = 0;
|
||||
viEventCounterMesg.hdr.type = 14;
|
||||
viEventCounterMesg.hdr.pri = 0;
|
||||
viEventCounterMesg.hdr.retQueue = 0;
|
||||
osSetEventMesg(OS_EVENT_VI, &__osViMesgQueue, &viEventViMesg);
|
||||
osSetEventMesg(OS_EVENT_COUNTER, &__osViMesgQueue, &viEventCounterMesg);
|
||||
newPri = -1;
|
||||
currentPri = osGetThreadPri(NULL);
|
||||
if (currentPri < pri) {
|
||||
newPri = currentPri;
|
||||
osSetThreadPri(NULL, pri);
|
||||
}
|
||||
int_disabled = __osDisableInt();
|
||||
viMgrMainArgs.initialized = TRUE;
|
||||
viMgrMainArgs.mgrThread = &viMgrThread;
|
||||
viMgrMainArgs.unk08 = &__osViMesgQueue;
|
||||
viMgrMainArgs.unk0c = &__osViMesgQueue;
|
||||
viMgrMainArgs.unk10 = NULL;
|
||||
viMgrMainArgs.dma_func = NULL;
|
||||
#ifdef VERSION_EU
|
||||
viMgrMainArgs.edma_func = NULL;
|
||||
#endif
|
||||
|
||||
osCreateThread(&viMgrThread, 0, viMgrMain, (void *) &viMgrMainArgs, &viMgrStack[0x400], pri);
|
||||
__osViInit();
|
||||
osStartThread(&viMgrThread);
|
||||
__osRestoreInt(int_disabled);
|
||||
if (newPri != -1) {
|
||||
osSetThreadPri(NULL, newPri);
|
||||
}
|
||||
}
|
||||
}
|
||||
void viMgrMain(void *vargs) {
|
||||
static u16 retrace;
|
||||
OSViContext *context;
|
||||
OSMgrArgs *args;
|
||||
OSMesg mesg;
|
||||
u32 sp28; // always 0
|
||||
u32 sp24; // time related
|
||||
mesg = NULL;
|
||||
sp28 = FALSE;
|
||||
context = __osViGetCurrentContext();
|
||||
|
||||
if ((retrace = context->retraceCount) == 0) {
|
||||
retrace = 1;
|
||||
}
|
||||
|
||||
args = (OSMgrArgs *) vargs;
|
||||
|
||||
while (1) {
|
||||
osRecvMesg(args->unk0c, &mesg, OS_MESG_BLOCK);
|
||||
switch (*(u16 *) mesg) {
|
||||
case 13:
|
||||
__osViSwapContext();
|
||||
if (!--retrace) {
|
||||
context = __osViGetCurrentContext();
|
||||
if (context->mq != NULL) {
|
||||
osSendMesg(context->mq, context->msg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
retrace = context->retraceCount;
|
||||
}
|
||||
__osViIntrCount++;
|
||||
if (sp28) {
|
||||
sp24 = osGetCount();
|
||||
_osCurrentTime = sp24;
|
||||
sp28 = 0;
|
||||
}
|
||||
sp24 = D_80365DA8;
|
||||
D_80365DA8 = osGetCount();
|
||||
sp24 = D_80365DA8 - sp24;
|
||||
_osCurrentTime = _osCurrentTime + sp24;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
__osTimerInterrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void osDestroyThread(OSThread *thread) {
|
||||
register s32 int_disabled;
|
||||
register OSThread *s1;
|
||||
register OSThread *s2;
|
||||
|
||||
int_disabled = __osDisableInt();
|
||||
|
||||
if (thread == NULL) {
|
||||
thread = D_803348A0;
|
||||
} else if (thread->state != OS_STATE_STOPPED) {
|
||||
__osDequeueThread(thread->queue, thread);
|
||||
}
|
||||
|
||||
if (D_8033489C == thread) {
|
||||
D_8033489C = D_8033489C->tlnext;
|
||||
} else {
|
||||
s1 = D_8033489C;
|
||||
s2 = s1->tlnext;
|
||||
while (s2 != NULL) {
|
||||
if (s2 == thread) {
|
||||
s1->tlnext = thread->tlnext;
|
||||
break;
|
||||
} else {
|
||||
s1 = s2;
|
||||
s2 = s1->tlnext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thread == D_803348A0) {
|
||||
__osDispatchThread();
|
||||
}
|
||||
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
#include "new_func.h"
|
||||
|
||||
s32 osEPiRawStartDma(OSPiHandle *arg0, s32 dir, u32 cart_addr, void *dram_addr, u32 size) {
|
||||
register int status;
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
while (status & PI_STATUS_ERROR)
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
HW_REG(PI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_addr);
|
||||
HW_REG(PI_CART_ADDR_REG, void *) = (void *) (((uintptr_t) arg0->baseAddress | cart_addr) & 0x1fffffff);
|
||||
|
||||
switch (dir) {
|
||||
case OS_READ:
|
||||
HW_REG(PI_WR_LEN_REG, u32) = size - 1;
|
||||
break;
|
||||
case OS_WRITE:
|
||||
HW_REG(PI_RD_LEN_REG, u32) = size - 1;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern u64 osClockRate;
|
||||
extern u8 D_80365D20;
|
||||
extern u8 _osContNumControllers;
|
||||
extern OSTimer D_80365D28; // not sure what this is yet
|
||||
extern OSMesgQueue _osContMesgQueue;
|
||||
extern OSMesg _osContMesgBuff[4];
|
||||
|
||||
s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
|
||||
s32 status = 0;
|
||||
if (address > 0x40) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (nbytes > 0) {
|
||||
status = osEepromRead(mq, address, buffer);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
nbytes -= 8;
|
||||
address += 1;
|
||||
buffer += 8;
|
||||
osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff);
|
||||
osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
return status;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern u64 osClockRate;
|
||||
extern u8 D_80365D20;
|
||||
extern u8 _osContNumControllers;
|
||||
extern OSTimer D_80365D28;
|
||||
extern OSMesgQueue _osContMesgQueue;
|
||||
extern OSMesg _osContMesgBuff[4];
|
||||
// exactly the same as osEepromLongRead except for osEepromWrite call
|
||||
|
||||
s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
|
||||
s32 result = 0;
|
||||
if (address > 0x40) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (nbytes > 0) {
|
||||
result = osEepromWrite(mq, address, buffer);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
nbytes -= 8;
|
||||
address += 1;
|
||||
buffer += 8;
|
||||
osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff);
|
||||
osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
// TODO: merge with osEepromWrite
|
||||
typedef struct {
|
||||
u16 unk00;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
} unkStruct;
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *, unkStruct *);
|
||||
s32 osEepromProbe(OSMesgQueue *mq) {
|
||||
s32 status = 0;
|
||||
unkStruct sp18;
|
||||
|
||||
__osSiGetAccess();
|
||||
status = __osEepStatus(mq, &sp18);
|
||||
if (status == 0 && (sp18.unk00 & 0x8000) != 0) {
|
||||
status = 1;
|
||||
} else {
|
||||
status = 0;
|
||||
}
|
||||
__osSiRelAccess();
|
||||
return status;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern u8 _osLastSentSiCmd;
|
||||
|
||||
typedef struct {
|
||||
u16 unk00;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
} unkStruct;
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
u8 unk04;
|
||||
u8 unk05;
|
||||
u8 unk06;
|
||||
u8 unk07;
|
||||
} unkStruct3;
|
||||
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
unkStruct3 unk04;
|
||||
} unkStruct2;
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *, unkStruct *);
|
||||
s32 __osPackEepReadData(u8);
|
||||
|
||||
s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
s32 sp34;
|
||||
s32 sp30;
|
||||
u8 *sp2c;
|
||||
unkStruct sp28;
|
||||
unkStruct2 sp20;
|
||||
sp34 = 0;
|
||||
sp30 = 0;
|
||||
sp2c = (u8 *) &D_80365E00;
|
||||
if (address > 0x40) {
|
||||
return -1;
|
||||
}
|
||||
__osSiGetAccess();
|
||||
sp34 = __osEepStatus(mq, &sp28);
|
||||
if (sp34 != 0 || sp28.unk00 != 0x8000) {
|
||||
|
||||
return 8;
|
||||
}
|
||||
while (sp28.unk02 & 0x80) {
|
||||
__osEepStatus(mq, &sp28);
|
||||
}
|
||||
__osPackEepReadData(address);
|
||||
sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
(D_80365E00)[sp30] = 255;
|
||||
}
|
||||
D_80365E3C = 0;
|
||||
sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
_osLastSentSiCmd = 4;
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
sp2c++;
|
||||
}
|
||||
sp20 = *(unkStruct2 *) sp2c;
|
||||
sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
if (sp34 == 0) {
|
||||
for (sp30 = 0; sp30 < 8; sp30++) {
|
||||
*buffer++ = ((u8 *) &sp20.unk04)[sp30];
|
||||
}
|
||||
}
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
}
|
||||
|
||||
s32 __osPackEepReadData(u8 address) {
|
||||
u8 *sp14;
|
||||
unkStruct2 sp8;
|
||||
s32 sp4;
|
||||
sp14 = (u8 *) &D_80365E00;
|
||||
for (sp4 = 0; sp4 < 0x10; sp4++) {
|
||||
D_80365E00[sp4] = 255;
|
||||
}
|
||||
D_80365E3C = 1;
|
||||
sp8.unk00 = 2;
|
||||
sp8.unk01 = 8;
|
||||
sp8.unk02 = 4;
|
||||
sp8.unk03 = address;
|
||||
for (sp4 = 0; sp4 < 8; sp4++) {
|
||||
((u8 *) &sp8.unk04)[sp4] = 0;
|
||||
}
|
||||
for (sp4 = 0; sp4 < 4; sp4++) {
|
||||
*sp14++ = 0;
|
||||
}
|
||||
*(unkStruct2 *) sp14 = sp8;
|
||||
sp14 += 0xc;
|
||||
*sp14 = 254;
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 u32 D_80365E00[15];
|
||||
u32 D_80365E3C;
|
||||
#else
|
||||
// Certain code accesses the 16th element (D_80365E3C) in this array, making a seperate
|
||||
// definition UB when gcc rearranges those.
|
||||
ALIGNED8 u32 D_80365E00[16];
|
||||
#endif
|
||||
extern u8 _osLastSentSiCmd;
|
||||
|
||||
typedef struct {
|
||||
u16 unk00;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
} unkStruct;
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
u8 unk04;
|
||||
u8 unk05;
|
||||
u8 unk06;
|
||||
u8 unk07;
|
||||
} unkStruct3;
|
||||
|
||||
typedef struct {
|
||||
u8 unk00;
|
||||
u8 unk01;
|
||||
u8 unk02;
|
||||
u8 unk03;
|
||||
unkStruct3 unk04;
|
||||
} unkStruct2;
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *, unkStruct *);
|
||||
s32 __osPackEepWriteData(u8, u8 *);
|
||||
|
||||
s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
s32 sp34;
|
||||
s32 sp30;
|
||||
u8 *sp2c;
|
||||
unkStruct2 sp20;
|
||||
unkStruct sp1c;
|
||||
sp34 = 0;
|
||||
sp2c = (u8 *) &D_80365E00;
|
||||
|
||||
if (address > 0x40) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
__osSiGetAccess();
|
||||
sp34 = __osEepStatus(mq, &sp1c);
|
||||
|
||||
if (sp34 != 0 || sp1c.unk00 != 0x8000) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
while (sp1c.unk02 & 0x80) {
|
||||
__osEepStatus(mq, &sp1c);
|
||||
}
|
||||
|
||||
__osPackEepWriteData(address, buffer);
|
||||
|
||||
sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
for (sp30 = 0; sp30 < 0x10; sp30++) {
|
||||
(D_80365E00)[sp30] = 255;
|
||||
}
|
||||
|
||||
D_80365E3C = 0;
|
||||
sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
_osLastSentSiCmd = 5;
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
sp2c++;
|
||||
}
|
||||
|
||||
sp20 = *(unkStruct2 *) sp2c;
|
||||
sp34 = (sp20.unk01 & 0xc0) >> 4;
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
}
|
||||
|
||||
s32 __osPackEepWriteData(u8 address, u8 *buffer) {
|
||||
u8 *sp14;
|
||||
unkStruct2 sp8;
|
||||
s32 sp4;
|
||||
sp14 = (u8 *) &D_80365E00;
|
||||
for (sp4 = 0; sp4 < 0x10; sp4++) {
|
||||
D_80365E00[sp4] = 255;
|
||||
}
|
||||
D_80365E3C = 1;
|
||||
sp8.unk00 = 10;
|
||||
sp8.unk01 = 1;
|
||||
sp8.unk02 = 5;
|
||||
sp8.unk03 = address;
|
||||
for (sp4 = 0; sp4 < 8; sp4++) {
|
||||
((u8 *) &sp8.unk04)[sp4] = *buffer++;
|
||||
}
|
||||
for (sp4 = 0; sp4 < 4; sp4++) {
|
||||
*sp14++ = 0;
|
||||
}
|
||||
*(unkStruct2 *) sp14 = sp8;
|
||||
sp14 += 0xc;
|
||||
*sp14 = 254;
|
||||
}
|
||||
|
||||
s32 __osEepStatus(OSMesgQueue *a0, unkStruct *a1) {
|
||||
u32 sp2c = 0;
|
||||
s32 sp28;
|
||||
u8 *sp24 = (u8 *) D_80365E00;
|
||||
unkStruct3 sp1c;
|
||||
|
||||
for (sp28 = 0; sp28 < 0x10; sp28++) {
|
||||
D_80365E00[sp28] = 0;
|
||||
}
|
||||
|
||||
D_80365E3C = 1;
|
||||
sp24 = (u8 *) D_80365E00;
|
||||
for (sp28 = 0; sp28 < 4; sp28++) {
|
||||
*sp24++ = 0;
|
||||
}
|
||||
|
||||
sp1c.unk00 = 255;
|
||||
sp1c.unk01 = 1;
|
||||
sp1c.unk02 = 3;
|
||||
sp1c.unk03 = 0;
|
||||
sp1c.unk04 = 255;
|
||||
sp1c.unk05 = 255;
|
||||
sp1c.unk06 = 255;
|
||||
sp1c.unk07 = 255;
|
||||
*(unkStruct3 *) sp24 = sp1c;
|
||||
|
||||
sp24 += 8;
|
||||
sp24[0] = 254;
|
||||
|
||||
sp2c = __osSiRawStartDma(OS_WRITE, D_80365E00);
|
||||
osRecvMesg(a0, NULL, OS_MESG_BLOCK);
|
||||
|
||||
_osLastSentSiCmd = 5;
|
||||
|
||||
sp2c = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
osRecvMesg(a0, NULL, OS_MESG_BLOCK);
|
||||
|
||||
if (sp2c != 0) {
|
||||
return sp2c;
|
||||
}
|
||||
|
||||
sp24 = (u8 *) D_80365E00;
|
||||
for (sp28 = 0; sp28 < 4; sp28++) {
|
||||
*sp24++ = 0;
|
||||
}
|
||||
|
||||
sp1c = *(unkStruct3 *) sp24;
|
||||
a1->unk03 = (sp1c.unk02 & 0xc0) >> 4;
|
||||
a1->unk00 = (sp1c.unk05 << 8) | sp1c.unk04;
|
||||
a1->unk02 = sp1c.unk06;
|
||||
if (a1->unk03 != 0) {
|
||||
return a1->unk03;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
OSPri osGetThreadPri(OSThread *thread) {
|
||||
if (thread == NULL) {
|
||||
thread = D_803348A0;
|
||||
}
|
||||
return thread->priority;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern OSTime _osCurrentTime;
|
||||
extern u32 D_80365DA8;
|
||||
|
||||
OSTime osGetTime() {
|
||||
u32 sp34;
|
||||
u32 sp30;
|
||||
OSTime sp28;
|
||||
register u32 int_disabled;
|
||||
int_disabled = __osDisableInt();
|
||||
sp34 = osGetCount();
|
||||
sp30 = sp34 - D_80365DA8;
|
||||
sp28 = _osCurrentTime;
|
||||
__osRestoreInt(int_disabled);
|
||||
return sp28 + sp30;
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
#include <macros.h>
|
||||
|
||||
#define PIF_ADDR_START (void *) 0x1FC007FC
|
||||
|
||||
typedef struct {
|
||||
u32 instr00;
|
||||
u32 instr01;
|
||||
u32 instr02;
|
||||
u32 instr03;
|
||||
} exceptionPreamble;
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
extern u32 EU_D_802f4330(u32, void (*));
|
||||
extern void D_802F4380();
|
||||
|
||||
#endif
|
||||
u32 D_80365CD0; // maybe initialized?
|
||||
u64 osClockRate = 62500000;
|
||||
u32 D_80334808 = 0;
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
u32 EU_D_80336C40;
|
||||
u32 EU_D_80336C44;
|
||||
|
||||
u32 D_8030208C = OS_IM_ALL;
|
||||
u32 EU_D_80302090 = 0;
|
||||
u8 EU_unusedZeroes[8] = { 0 };
|
||||
#endif
|
||||
|
||||
#define EXCEPTION_TLB_MISS 0x80000000
|
||||
#define EXCEPTION_XTLB_MISS 0x80000080
|
||||
#define EXCEPTION_CACHE_ERROR 0x80000100
|
||||
#define EXCEPTION_GENERAL 0x80000180
|
||||
|
||||
extern u32 osResetType;
|
||||
extern exceptionPreamble __osExceptionPreamble;
|
||||
|
||||
void osInitialize(void) {
|
||||
u32 sp34;
|
||||
u32 sp30 = 0;
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
UNUSED u32 eu_sp34;
|
||||
UNUSED u32 eu_sp30;
|
||||
#endif
|
||||
UNUSED u32 sp2c;
|
||||
D_80365CD0 = TRUE;
|
||||
__osSetSR(__osGetSR() | 0x20000000);
|
||||
__osSetFpcCsr(0x01000800);
|
||||
while (__osSiRawReadIo(PIF_ADDR_START, &sp34)) {
|
||||
;
|
||||
}
|
||||
while (__osSiRawWriteIo(PIF_ADDR_START, sp34 | 8)) {
|
||||
;
|
||||
}
|
||||
*(exceptionPreamble *) EXCEPTION_TLB_MISS = __osExceptionPreamble;
|
||||
*(exceptionPreamble *) EXCEPTION_XTLB_MISS = __osExceptionPreamble;
|
||||
*(exceptionPreamble *) EXCEPTION_CACHE_ERROR = __osExceptionPreamble;
|
||||
*(exceptionPreamble *) EXCEPTION_GENERAL = __osExceptionPreamble;
|
||||
osWritebackDCache((void *) 0x80000000,
|
||||
EXCEPTION_GENERAL + sizeof(exceptionPreamble) - EXCEPTION_TLB_MISS);
|
||||
osInvalICache((void *) 0x80000000,
|
||||
EXCEPTION_GENERAL + sizeof(exceptionPreamble) - EXCEPTION_TLB_MISS);
|
||||
osMapTLBRdb();
|
||||
osPiRawReadIo(4, &sp30);
|
||||
sp30 &= ~0xf;
|
||||
if (sp30) {
|
||||
osClockRate = sp30;
|
||||
}
|
||||
osClockRate = osClockRate * 3 / 4;
|
||||
if (osResetType == RESET_TYPE_COLD_RESET) {
|
||||
bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer));
|
||||
}
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
eu_sp30 = HW_REG(PI_STATUS_REG, u32);
|
||||
while (eu_sp30 & PI_STATUS_ERROR) {
|
||||
eu_sp30 = HW_REG(PI_STATUS_REG, u32);
|
||||
};
|
||||
if (!((eu_sp34 = HW_REG(ASIC_STATUS, u32)) & _64DD_PRESENT_MASK)) {
|
||||
EU_D_80302090 = 1;
|
||||
EU_D_802f4330(1, D_802F4380);
|
||||
} else {
|
||||
EU_D_80302090 = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) {
|
||||
register s32 int_disabled;
|
||||
int_disabled = __osDisableInt();
|
||||
while (mq->validCount >= mq->msgCount) {
|
||||
if (flag == OS_MESG_BLOCK) {
|
||||
D_803348A0->state = OS_STATE_WAITING;
|
||||
__osEnqueueAndYield(&mq->fullqueue);
|
||||
} else {
|
||||
__osRestoreInt(int_disabled);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount;
|
||||
mq->msg[mq->first] = msg;
|
||||
mq->validCount++;
|
||||
if (mq->mtqueue->next != NULL) {
|
||||
osStartThread(__osPopThread(&mq->mtqueue));
|
||||
}
|
||||
__osRestoreInt(int_disabled);
|
||||
return 0;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
// this file must include some globally referenced data because it is not called anywhere
|
||||
// data, comes shortly before _Ldtob I think, before crash_screen
|
||||
|
||||
extern OSPiHandle *D_80302DFC;
|
||||
// bss
|
||||
OSPiHandle LeoDiskHandle;
|
||||
OSPiHandle *__osDiskHandle;
|
||||
|
||||
// some kind of piHandle init function, maybe osDriveRomInit or osCartRomInit
|
||||
OSPiHandle *osLeoDiskInit(void) {
|
||||
s32 sp1c;
|
||||
LeoDiskHandle.type = 2;
|
||||
LeoDiskHandle.baseAddress = (0xa0000000 | 0x05000000);
|
||||
LeoDiskHandle.latency = 3;
|
||||
LeoDiskHandle.pulse = 6;
|
||||
LeoDiskHandle.pageSize = 6;
|
||||
LeoDiskHandle.relDuration = 2;
|
||||
HW_REG(PI_BSD_DOM2_LAT_REG, u32) = LeoDiskHandle.latency;
|
||||
HW_REG(PI_BSD_DOM2_PWD_REG, u32) = LeoDiskHandle.pulse;
|
||||
HW_REG(PI_BSD_DOM2_PGS_REG, u32) = LeoDiskHandle.pageSize;
|
||||
HW_REG(PI_BSD_DOM2_RLS_REG, u32) = LeoDiskHandle.relDuration;
|
||||
bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo));
|
||||
sp1c = __osDisableInt();
|
||||
LeoDiskHandle.next = D_80302DFC;
|
||||
D_80302DFC = &LeoDiskHandle;
|
||||
__osDiskHandle = &LeoDiskHandle;
|
||||
__osRestoreInt(sp1c);
|
||||
return &LeoDiskHandle;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern OSMgrArgs piMgrArgs;
|
||||
|
||||
OSMesgQueue *osPiGetCmdQueue(void) {
|
||||
if (!piMgrArgs.initialized) {
|
||||
return NULL;
|
||||
}
|
||||
return piMgrArgs.unk08;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
extern u32 osRomBase;
|
||||
|
||||
s32 osPiRawReadIo(u32 a0, u32 *a1) {
|
||||
register int status;
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
}
|
||||
*a1 = HW_REG(osRomBase | a0, u32);
|
||||
return 0;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
|
||||
extern u32 osRomBase; // TODO: figure out why this is like this
|
||||
|
||||
s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size) {
|
||||
register int status;
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
}
|
||||
|
||||
HW_REG(PI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_addr);
|
||||
|
||||
HW_REG(PI_CART_ADDR_REG, void *) = (void *) (((uintptr_t) osRomBase | cart_addr) & 0x1fffffff);
|
||||
|
||||
switch (dir) {
|
||||
case 0:
|
||||
HW_REG(PI_WR_LEN_REG, u32) = size - 1;
|
||||
break;
|
||||
case 1:
|
||||
HW_REG(PI_RD_LEN_REG, u32) = size - 1;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
/*s32 osPiRawStartDma_2(s32 dir, u32 cart_addr, void *dram_addr, size_t size) {
|
||||
register int status;
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
}
|
||||
|
||||
HW_REG(PI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_addr);
|
||||
|
||||
HW_REG(PI_CART_ADDR_REG, void *) = (void *) (((uintptr_t) osRomBase | cart_addr) & 0x1fffffff);
|
||||
|
||||
switch (dir) {
|
||||
case 0:
|
||||
HW_REG(PI_WR_LEN_REG, u32) = size - 1;
|
||||
break;
|
||||
case 1:
|
||||
HW_REG(PI_RD_LEN_REG, u32) = size - 1;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
#endif
|
|
@ -1,37 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern OSMgrArgs piMgrArgs;
|
||||
|
||||
s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
|
||||
size_t nbytes, OSMesgQueue *mq) {
|
||||
register s32 result;
|
||||
register OSMesgQueue *cmdQueue;
|
||||
if (!piMgrArgs.initialized) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO: name magic constants
|
||||
if (direction == OS_READ) {
|
||||
mb->hdr.type = 11;
|
||||
} else {
|
||||
mb->hdr.type = 12;
|
||||
}
|
||||
|
||||
mb->hdr.pri = priority;
|
||||
mb->hdr.retQueue = mq;
|
||||
mb->dramAddr = vAddr;
|
||||
mb->devAddr = devAddr;
|
||||
mb->size = nbytes;
|
||||
#ifdef VERSION_EU
|
||||
mb->piHandle = NULL;
|
||||
#endif
|
||||
|
||||
if (priority == OS_MESG_PRI_HIGH) {
|
||||
cmdQueue = osPiGetCmdQueue();
|
||||
result = osJamMesg(cmdQueue, mb, OS_MESG_NOBLOCK);
|
||||
} else {
|
||||
cmdQueue = osPiGetCmdQueue();
|
||||
result = osSendMesg(cmdQueue, mb, OS_MESG_NOBLOCK);
|
||||
}
|
||||
return result;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flag) {
|
||||
register u32 int_disabled;
|
||||
register OSThread *thread;
|
||||
int_disabled = __osDisableInt();
|
||||
|
||||
while (!mq->validCount) {
|
||||
if (!flag) {
|
||||
__osRestoreInt(int_disabled);
|
||||
return -1;
|
||||
}
|
||||
D_803348A0->state = OS_STATE_WAITING;
|
||||
__osEnqueueAndYield(&mq->mtqueue);
|
||||
}
|
||||
|
||||
if (msg != NULL) {
|
||||
*msg = *(mq->first + mq->msg);
|
||||
}
|
||||
|
||||
mq->first = (mq->first + 1) % mq->msgCount;
|
||||
mq->validCount--;
|
||||
|
||||
if (mq->fullqueue->next != NULL) {
|
||||
thread = __osPopThread(&mq->fullqueue);
|
||||
osStartThread(thread);
|
||||
}
|
||||
|
||||
__osRestoreInt(int_disabled);
|
||||
return 0;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) {
|
||||
register u32 int_disabled;
|
||||
register s32 index;
|
||||
register OSThread *s2;
|
||||
int_disabled = __osDisableInt();
|
||||
|
||||
while (mq->validCount >= mq->msgCount) {
|
||||
if (flag == OS_MESG_BLOCK) {
|
||||
D_803348A0->state = 8;
|
||||
__osEnqueueAndYield(&mq->fullqueue);
|
||||
} else {
|
||||
__osRestoreInt(int_disabled);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
index = (mq->first + mq->validCount) % mq->msgCount;
|
||||
mq->msg[index] = msg;
|
||||
mq->validCount++;
|
||||
|
||||
if (mq->mtqueue->next != NULL) {
|
||||
s2 = __osPopThread(&mq->mtqueue);
|
||||
osStartThread(s2);
|
||||
}
|
||||
|
||||
__osRestoreInt(int_disabled);
|
||||
return 0;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
typedef struct OSEventMessageStruct_0_s {
|
||||
OSMesgQueue *queue;
|
||||
OSMesg msg;
|
||||
} OSEventMessageStruct_0;
|
||||
|
||||
OSEventMessageStruct_0 D_80363830[16];
|
||||
|
||||
void osSetEventMesg(OSEvent e, OSMesgQueue *mq, OSMesg msg) {
|
||||
register u32 int_disabled;
|
||||
OSEventMessageStruct_0 *msgs;
|
||||
int_disabled = __osDisableInt();
|
||||
msgs = D_80363830 + e;
|
||||
msgs->queue = mq;
|
||||
msgs->msg = msg;
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void osSetThreadPri(OSThread *thread, OSPri pri) {
|
||||
register u32 int_disabled = __osDisableInt();
|
||||
if (thread == NULL) {
|
||||
thread = D_803348A0;
|
||||
}
|
||||
|
||||
if (thread->priority != pri) {
|
||||
thread->priority = pri;
|
||||
if (thread != D_803348A0) {
|
||||
if (thread->state != OS_STATE_STOPPED) {
|
||||
__osDequeueThread(thread->queue, thread);
|
||||
__osEnqueueThread(thread->queue, thread);
|
||||
}
|
||||
}
|
||||
if (D_803348A0->priority < D_80334898->priority) {
|
||||
D_803348A0->state = OS_STATE_RUNNABLE;
|
||||
__osEnqueueAndYield(&D_80334898);
|
||||
}
|
||||
}
|
||||
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
extern OSTime _osCurrentTime;
|
||||
|
||||
void osSetTime(OSTime time) {
|
||||
_osCurrentTime = time;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSTimer *D_80334830;
|
||||
extern u64 __osInsertTimer(OSTimer *);
|
||||
|
||||
u32 osSetTimer(OSTimer *a0, OSTime a1, u64 a2, OSMesgQueue *a3, OSMesg a4) {
|
||||
u64 sp18;
|
||||
a0->next = NULL;
|
||||
a0->prev = NULL;
|
||||
a0->interval = a2;
|
||||
if (a1 != 0) {
|
||||
a0->remaining = a1;
|
||||
} else {
|
||||
a0->remaining = a2;
|
||||
}
|
||||
a0->mq = a3;
|
||||
a0->msg = a4;
|
||||
sp18 = __osInsertTimer(a0);
|
||||
if (D_80334830->next == a0) {
|
||||
__osSetTimerIntr(sp18);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "hardware.h"
|
||||
#include <macros.h>
|
||||
|
||||
#define _osVirtualToPhysical(ptr) \
|
||||
if (ptr != NULL) { \
|
||||
ptr = (void *) osVirtualToPhysical(ptr); \
|
||||
}
|
||||
|
||||
OSTask D_803638B0;
|
||||
OSTask *_VirtualToPhysicalTask(OSTask *task) {
|
||||
OSTask *physicalTask;
|
||||
physicalTask = &D_803638B0;
|
||||
bcopy(task, physicalTask, sizeof(OSTask));
|
||||
_osVirtualToPhysical(physicalTask->t.ucode);
|
||||
_osVirtualToPhysical(physicalTask->t.ucode_data);
|
||||
_osVirtualToPhysical(physicalTask->t.dram_stack);
|
||||
_osVirtualToPhysical(physicalTask->t.output_buff);
|
||||
_osVirtualToPhysical(physicalTask->t.output_buff_size);
|
||||
_osVirtualToPhysical(physicalTask->t.data_ptr);
|
||||
_osVirtualToPhysical(physicalTask->t.yield_data_ptr);
|
||||
return physicalTask;
|
||||
}
|
||||
void osSpTaskLoad(OSTask *task) {
|
||||
OSTask *physicalTask;
|
||||
physicalTask = _VirtualToPhysicalTask(task);
|
||||
if (physicalTask->t.flags & M_TASK_FLAG0) {
|
||||
physicalTask->t.ucode_data = physicalTask->t.yield_data_ptr;
|
||||
physicalTask->t.ucode_data_size = physicalTask->t.yield_data_size;
|
||||
task->t.flags &= ~M_TASK_FLAG0;
|
||||
}
|
||||
osWritebackDCache(physicalTask, sizeof(OSTask));
|
||||
__osSpSetStatus(SPSTATUS_CLEAR_SIGNAL0 | SPSTATUS_CLEAR_SIGNAL1 | SPSTATUS_CLEAR_SIGNAL2
|
||||
| SPSTATUS_SET_INTR_ON_BREAK);
|
||||
while (__osSpSetPc((void *) SP_IMEM_START) == -1) {
|
||||
;
|
||||
}
|
||||
while (__osSpRawStartDma(1, (void *) (SP_IMEM_START - sizeof(*physicalTask)), physicalTask,
|
||||
sizeof(OSTask))
|
||||
== -1) {
|
||||
;
|
||||
}
|
||||
while (__osSpDeviceBusy()) {
|
||||
;
|
||||
}
|
||||
while (__osSpRawStartDma(1, (void *) SP_IMEM_START, physicalTask->t.ucode_boot,
|
||||
physicalTask->t.ucode_boot_size)
|
||||
== -1) {
|
||||
;
|
||||
}
|
||||
}
|
||||
void osSpTaskStartGo(UNUSED OSTask *task) {
|
||||
while (__osSpDeviceBusy()) {
|
||||
;
|
||||
}
|
||||
__osSpSetStatus(SPSTATUS_SET_INTR_ON_BREAK | SPSTATUS_CLEAR_SSTEP | SPSTATUS_CLEAR_BROKE
|
||||
| SPSTATUS_CLEAR_HALT);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void osSpTaskYield(void) {
|
||||
__osSpSetStatus(SPSTATUS_SET_SIGNAL0);
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
#include "libultra_internal.h"
|
||||
|
||||
OSYieldResult osSpTaskYielded(OSTask *task) {
|
||||
s32 status;
|
||||
u32 int_disabledult;
|
||||
status = __osSpGetStatus();
|
||||
if (status & SPSTATUS_SIGNAL1_SET) {
|
||||
int_disabledult = 1;
|
||||
} else {
|
||||
int_disabledult = 0;
|
||||
}
|
||||
if (status & SPSTATUS_SIGNAL0_SET) {
|
||||
task->t.flags |= int_disabledult;
|
||||
task->t.flags &= ~(M_TASK_FLAG1);
|
||||
}
|
||||
return int_disabledult;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void osStartThread(OSThread *thread) {
|
||||
register u32 int_disabled;
|
||||
register uintptr_t state;
|
||||
int_disabled = __osDisableInt();
|
||||
state = thread->state;
|
||||
|
||||
if (state != OS_STATE_STOPPED) {
|
||||
if (state == OS_STATE_WAITING) {
|
||||
do {
|
||||
} while (0);
|
||||
thread->state = OS_STATE_RUNNABLE;
|
||||
__osEnqueueThread(&D_80334898, thread);
|
||||
}
|
||||
} else {
|
||||
if (thread->queue == NULL || thread->queue == &D_80334898) {
|
||||
thread->state = OS_STATE_RUNNABLE;
|
||||
|
||||
__osEnqueueThread(&D_80334898, thread);
|
||||
} else {
|
||||
thread->state = OS_STATE_WAITING;
|
||||
__osEnqueueThread(thread->queue, thread);
|
||||
state = (uintptr_t) __osPopThread(thread->queue);
|
||||
__osEnqueueThread(&D_80334898, (OSThread *) state);
|
||||
}
|
||||
}
|
||||
if (D_803348A0 == NULL) {
|
||||
__osDispatchThread();
|
||||
} else {
|
||||
if (D_803348A0->priority < D_80334898->priority) {
|
||||
D_803348A0->state = OS_STATE_RUNNABLE;
|
||||
__osEnqueueAndYield(&D_80334898);
|
||||
}
|
||||
}
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
|
||||
// TODO: document
|
||||
OSTimer D_80365D80;
|
||||
OSTimer *D_80334830 = &D_80365D80;
|
||||
OSTime _osCurrentTime;
|
||||
u32 D_80365DA8;
|
||||
u32 __osViIntrCount;
|
||||
u32 D_80365DB0;
|
||||
|
||||
void __osTimerServicesInit(void) {
|
||||
_osCurrentTime = 0;
|
||||
D_80365DA8 = 0;
|
||||
__osViIntrCount = 0;
|
||||
D_80334830->prev = D_80334830;
|
||||
D_80334830->next = D_80334830->prev;
|
||||
D_80334830->remaining = 0;
|
||||
D_80334830->interval = D_80334830->remaining;
|
||||
D_80334830->mq = NULL;
|
||||
D_80334830->msg = NULL;
|
||||
}
|
||||
|
||||
void __osTimerInterrupt(void) {
|
||||
OSTimer *sp24;
|
||||
u32 sp20;
|
||||
u32 sp1c;
|
||||
if (D_80334830->next == D_80334830) {
|
||||
return;
|
||||
}
|
||||
while (1) {
|
||||
sp24 = D_80334830->next;
|
||||
if (sp24 == D_80334830) {
|
||||
__osSetCompare(0);
|
||||
D_80365DB0 = 0;
|
||||
break;
|
||||
}
|
||||
sp20 = osGetCount();
|
||||
sp1c = sp20 - D_80365DB0;
|
||||
D_80365DB0 = sp20;
|
||||
if (sp1c < sp24->remaining) {
|
||||
sp24->remaining -= sp1c;
|
||||
__osSetTimerIntr(sp24->remaining);
|
||||
return;
|
||||
} else {
|
||||
sp24->prev->next = sp24->next;
|
||||
sp24->next->prev = sp24->prev;
|
||||
sp24->next = NULL;
|
||||
sp24->prev = NULL;
|
||||
if (sp24->mq != NULL) {
|
||||
osSendMesg(sp24->mq, sp24->msg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
if (sp24->interval != 0) {
|
||||
sp24->remaining = sp24->interval;
|
||||
__osInsertTimer(sp24);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __osSetTimerIntr(u64 a0) {
|
||||
u64 tmp;
|
||||
s32 intDisabled = __osDisableInt();
|
||||
D_80365DB0 = osGetCount();
|
||||
tmp = a0 + D_80365DB0;
|
||||
__osSetCompare(tmp);
|
||||
__osRestoreInt(intDisabled);
|
||||
}
|
||||
|
||||
u64 __osInsertTimer(OSTimer *a0) {
|
||||
OSTimer *sp34;
|
||||
u64 sp28;
|
||||
s32 intDisabled;
|
||||
intDisabled = __osDisableInt();
|
||||
for (sp34 = D_80334830->next, sp28 = a0->remaining; sp34 != D_80334830 && sp28 > sp34->remaining;
|
||||
sp28 -= sp34->remaining, sp34 = sp34->next) {
|
||||
;
|
||||
}
|
||||
a0->remaining = sp28;
|
||||
if (sp34 != D_80334830) {
|
||||
sp34->remaining -= sp28;
|
||||
}
|
||||
a0->next = sp34;
|
||||
a0->prev = sp34->prev;
|
||||
sp34->prev->next = a0;
|
||||
sp34->prev = a0;
|
||||
__osRestoreInt(intDisabled);
|
||||
return sp28;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSViContext *D_80334914;
|
||||
// TODO: name magic constants
|
||||
void osViBlack(u8 active) {
|
||||
register u32 int_disabled = __osDisableInt();
|
||||
if (active) {
|
||||
D_80334914->unk00 |= 0x20;
|
||||
} else {
|
||||
D_80334914->unk00 &= ~0x20;
|
||||
}
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#ifdef VERSION_EU
|
||||
OSViMode D_80334990 = {
|
||||
/*type*/ 16,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 625,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 } }
|
||||
};
|
||||
OSViMode D_803349E0 = {
|
||||
/*type*/ 30, //osViModePalLan1
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 265233,
|
||||
/*leap*/ 202968090,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } }
|
||||
};
|
||||
OSViMode D_80302FD0 = {
|
||||
/*type*/ 2,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } }
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
OSViMode D_80334990 = {
|
||||
/*type*/ 2,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } }
|
||||
};
|
||||
OSViMode D_803349E0 = {
|
||||
/*type*/ 16,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 625,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 } }
|
||||
};
|
||||
#endif
|
|
@ -1,10 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSViContext *D_80334914;
|
||||
void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount) {
|
||||
|
||||
register u32 int_disabled = __osDisableInt();
|
||||
(D_80334914)->mq = mq;
|
||||
(D_80334914)->msg = msg;
|
||||
(D_80334914)->retraceCount = retraceCount;
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSViContext *D_80334914;
|
||||
void osViSetMode(OSViMode *mode) {
|
||||
register u32 int_disabled = __osDisableInt();
|
||||
D_80334914->unk08 = mode;
|
||||
D_80334914->unk00 = 1;
|
||||
D_80334914->features = D_80334914->unk08->comRegs.ctrl;
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSViContext *D_80334914;
|
||||
void osViSetSpecialFeatures(u32 func) {
|
||||
register u32 int_disabled = __osDisableInt();
|
||||
if (func & OS_VI_GAMMA_ON) {
|
||||
D_80334914->features |= OS_VI_GAMMA;
|
||||
}
|
||||
if (func & OS_VI_GAMMA_OFF) {
|
||||
D_80334914->features &= ~OS_VI_GAMMA;
|
||||
}
|
||||
if (func & OS_VI_GAMMA_DITHER_ON) {
|
||||
D_80334914->features |= OS_VI_GAMMA_DITHER;
|
||||
}
|
||||
if (func & OS_VI_GAMMA_DITHER_OFF) {
|
||||
|
||||
D_80334914->features &= ~OS_VI_GAMMA_DITHER;
|
||||
}
|
||||
if (func & OS_VI_DIVOT_ON) {
|
||||
|
||||
D_80334914->features |= OS_VI_DIVOT;
|
||||
}
|
||||
if (func & OS_VI_DIVOT_OFF) {
|
||||
|
||||
D_80334914->features &= ~OS_VI_DIVOT;
|
||||
}
|
||||
if (func & OS_VI_DITHER_FILTER_ON) {
|
||||
D_80334914->features |= OS_VI_DITHER_FILTER;
|
||||
D_80334914->features &= ~(OS_VI_UNK200 | OS_VI_UNK100);
|
||||
}
|
||||
if (func & OS_VI_DITHER_FILTER_OFF) {
|
||||
D_80334914->features &= ~OS_VI_DITHER_FILTER;
|
||||
D_80334914->features |= D_80334914->unk08->comRegs.ctrl & (OS_VI_UNK200 | OS_VI_UNK100);
|
||||
}
|
||||
D_80334914->unk00 |= 8;
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
extern OSViContext *D_80334914;
|
||||
void osViSwapBuffer(void *vaddr) {
|
||||
u32 int_disabled = __osDisableInt();
|
||||
D_80334914->buffer = vaddr;
|
||||
D_80334914->unk00 |= 0x10; // TODO: figure out what this flag means
|
||||
__osRestoreInt(int_disabled);
|
||||
}
|
|
@ -1,975 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
OSViMode osViModeTable[] = {
|
||||
/*osViModeNtscLpn1*/
|
||||
{ /*type*/ 0,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12814,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLpf1*/
|
||||
{ /*type*/ 1,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLan1*/
|
||||
{ /*type*/ 2,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLaf1*/
|
||||
{ /*type*/ 3,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLpn2*/
|
||||
{ /*type*/ 4,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 13071,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLpf2*/
|
||||
{ /*type*/ 5,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12879,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLan2*/
|
||||
{ /*type*/ 6,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12319,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscLaf2*/
|
||||
{ /*type*/ 7,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12383,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscHpn1*/
|
||||
{ /*type*/ 8,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscHpf1*/
|
||||
{ /*type*/ 9,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscHan1*/
|
||||
{ /*type*/ 10,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscHaf1*/
|
||||
{ /*type*/ 11,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscHpn2*/
|
||||
{ /*type*/ 12,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 13135,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 5120,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModeNtscHpf2*/
|
||||
{ /*type*/ 13,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12879,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 65348153,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3093,
|
||||
/*leap*/ 202705941,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 5120,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
|
||||
#if !defined(VERSION_US)
|
||||
/*osViModePalLpn1*/
|
||||
{ /*type*/ 14,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12814,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 625,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLpf1*/
|
||||
{ /*type*/ 15,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLan1*/
|
||||
{ /*type*/ 16,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 625,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLaf1*/
|
||||
{ /*type*/ 17,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLpn2*/
|
||||
{ /*type*/ 18,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 13071,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 625,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLpf2*/
|
||||
{ /*type*/ 19,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12879,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLan2*/
|
||||
{ /*type*/ 20,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12319,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 625,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLaf2*/
|
||||
{ /*type*/ 21,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12383,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpn1*/
|
||||
{ /*type*/ 22,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpf1*/
|
||||
{ /*type*/ 23,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHan1*/
|
||||
{ /*type*/ 24,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHaf1*/
|
||||
{ /*type*/ 25,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpn2*/
|
||||
{ /*type*/ 26,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 13135,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 5120,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpf2*/
|
||||
{ /*type*/ 27,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12879,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 67380026,
|
||||
/*vSync*/ 624,
|
||||
/*hSync*/ 1379433,
|
||||
/*leap*/ 208604270,
|
||||
/*hStart*/ 8389376,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 6095415,
|
||||
/*vBurst*/ 590443,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 5120,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 6226489,
|
||||
/*vBurst*/ 852585,
|
||||
/*vIntr*/ 2 } } },
|
||||
#endif
|
||||
#if !defined(VERSION_JP)
|
||||
/*osViModePalLpn1*/
|
||||
{ /*type*/ 28,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12814,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 265233,
|
||||
/*leap*/ 202968090,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLpf1*/
|
||||
{ /*type*/ 29,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLan1*/
|
||||
{ /*type*/ 30,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12574,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 265233,
|
||||
/*leap*/ 202968090,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLaf1*/
|
||||
{ /*type*/ 31,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 640,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 640,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLpn2*/
|
||||
{ /*type*/ 32,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 13071,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 265233,
|
||||
/*leap*/ 202968090,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLpf2*/
|
||||
{ /*type*/ 33,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12879,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLan2*/
|
||||
{ /*type*/ 34,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12319,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 525,
|
||||
/*hSync*/ 265233,
|
||||
/*leap*/ 202968090,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalLaf2*/
|
||||
{ /*type*/ 35,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12383,
|
||||
/*width*/ 320,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 512,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 16778240,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 1280,
|
||||
/*yScale*/ 50332672,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpn1*/
|
||||
{ /*type*/ 36,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpf1*/
|
||||
{ /*type*/ 37,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12878,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHan1*/
|
||||
{ /*type*/ 38,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHaf1*/
|
||||
{ /*type*/ 39,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12382,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 1280,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpn2*/
|
||||
{ /*type*/ 40,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 13135,
|
||||
/*width*/ 1280,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 2560,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 5120,
|
||||
/*yScale*/ 1024,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } },
|
||||
/*osViModePalHpf2*/
|
||||
{ /*type*/ 41,
|
||||
/*comRegs*/
|
||||
{ /*ctrl*/ 12879,
|
||||
/*width*/ 640,
|
||||
/*burst*/ 73735737,
|
||||
/*vSync*/ 524,
|
||||
/*hSync*/ 3088,
|
||||
/*leap*/ 203164700,
|
||||
/*hStart*/ 7078636,
|
||||
/*xScale*/ 1024,
|
||||
/*vCurrent*/ 0 },
|
||||
/*fldRegs*/
|
||||
{ { /*origin*/ 2560,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2294269,
|
||||
/*vBurst*/ 721410,
|
||||
/*vIntr*/ 2 },
|
||||
{ /*origin*/ 5120,
|
||||
/*yScale*/ 33556480,
|
||||
/*vStart*/ 2425343,
|
||||
/*vBurst*/ 918020,
|
||||
/*vIntr*/ 2 } } }
|
||||
#endif
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
uintptr_t osVirtualToPhysical(void *addr) {
|
||||
if ((uintptr_t) addr >= 0x80000000 && (uintptr_t) addr < 0xa0000000) {
|
||||
return ((uintptr_t) addr & 0x1fffffff);
|
||||
} else if ((uintptr_t) addr >= 0xa0000000 && (uintptr_t) addr < 0xc0000000) {
|
||||
return ((uintptr_t) addr & 0x1fffffff);
|
||||
} else {
|
||||
return __osProbeTLB(addr);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
/* 00 */ s64 s64;
|
||||
u64 u64;
|
||||
f64 f64;
|
||||
u32 u32;
|
||||
u16 u16;
|
||||
} value;
|
||||
/* 08 */ char *buff;
|
||||
/* 0c */ s32 part1_len;
|
||||
/* 10 */ s32 num_leading_zeros;
|
||||
/* 14 */ s32 part2_len;
|
||||
/* 18 */ s32 num_mid_zeros;
|
||||
/* 1c */ s32 part3_len;
|
||||
/* 20 */ s32 num_trailing_zeros;
|
||||
/* 24 */ s32 precision;
|
||||
/* 28 */ s32 width;
|
||||
/* 2c */ u32 size;
|
||||
/* 30 */ u32 flags;
|
||||
/* 34 */ u8 length;
|
||||
} printf_struct;
|
||||
|
||||
#define FLAGS_SPACE 1
|
||||
#define FLAGS_PLUS 2
|
||||
#define FLAGS_MINUS 4
|
||||
#define FLAGS_HASH 8
|
||||
#define FLAGS_ZERO 16
|
||||
s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char *fmt, va_list args);
|
||||
void _Litob(printf_struct *args, u8 type);
|
||||
void _Ldtob(printf_struct *args, u8 type);
|
||||
#endif
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include "libultra_internal.h"
|
||||
#include "printf.h"
|
||||
#include <string.h>
|
||||
char *proutSprintf(char *dst, const char *src, size_t count);
|
||||
int sprintf(char *dst, const char *fmt, ...) {
|
||||
s32 written;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
written = _Printf(proutSprintf, dst, fmt, args);
|
||||
if (written >= 0) {
|
||||
dst[written] = 0;
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
char *proutSprintf(char *dst, const char *src, size_t count) {
|
||||
return (char *) memcpy((u8 *) dst, (u8 *) src, count) + count;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include <string.h>
|
||||
|
||||
void *memcpy(void *dst, const void *src, size_t size) {
|
||||
u8 *_dst = dst;
|
||||
const u8 *_src = src;
|
||||
while (size > 0) {
|
||||
*_dst++ = *_src++;
|
||||
size--;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
size_t strlen(const char *str) {
|
||||
const u8 *ptr = (const u8 *) str;
|
||||
while (*ptr) {
|
||||
ptr++;
|
||||
}
|
||||
return (const char *) ptr - str;
|
||||
}
|
||||
|
||||
char *strchr(const char *str, s32 ch) {
|
||||
u8 c = ch;
|
||||
while (*(u8 *)str != c) {
|
||||
if (*(u8 *)str == 0) {
|
||||
return NULL;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
return (char *) str;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
|
||||
// only referenced in kdebugserver...
|
||||
#ifdef VERSION_EU
|
||||
u8 D_80365E40[0x1000];
|
||||
#else
|
||||
u8 D_80365E40[0x100];
|
||||
#endif
|
Loading…
Reference in a new issue