diff options
| author | Tharo <17233964+Thar0@users.noreply.github.com> | 2021-02-14 00:49:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-13 19:49:40 -0500 |
| commit | f9d96d9f73ac090245a518ec04f3fa0e50655d1e (patch) | |
| tree | 9dc905fce276cbfb07a05fc2bf0883bcedddcf23 /src/libultra_boot_O2 | |
| parent | d615ec4f31563b939f8c0dce1c20c79e137c2043 (diff) | |
Fix most compiler warnings in the boot and code segments (#674)
* Less warnings in boot & code segments
* few more warnings gone
* Ran formatter
* z_view warning gone
* -> 1
* f31 -> 31
* Remove function casts
* Few more small improvements
* Separate declaration and assignment in func_80091738 and Item_Give
Co-authored-by: Thar0 <maximilianc64@gmail.com>
Diffstat (limited to 'src/libultra_boot_O2')
24 files changed, 126 insertions, 132 deletions
diff --git a/src/libultra_boot_O2/_Ldtob.c b/src/libultra_boot_O2/_Ldtob.c index 68a9c5404..f7a6d1208 100644 --- a/src/libultra_boot_O2/_Ldtob.c +++ b/src/libultra_boot_O2/_Ldtob.c @@ -42,9 +42,9 @@ const f64 D_800122E0[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 1 void _Ldtob(_Pft* args, u8 type) { u8 buff[BUFF_LEN]; - u8* ptr; + u8* ptr = buff; u32 sp70; - f64 val; + f64 val = args->v.ld; /* maybe struct? */ s16 err; s16 nsig; @@ -60,14 +60,10 @@ void _Ldtob(_Pft* args, u8 type) { u8 drop; s32 n2; - ptr = buff; - val = args->v.ld; if (args->prec < 0) { args->prec = 6; - } else { - if (args->prec == 0 && (type == 'g' || type == 'G')) { - args->prec = 1; - } + } else if (args->prec == 0 && (type == 'g' || type == 'G')) { + args->prec = 1; } err = _Ldunscale(&exp, (_Pft*)args); if (err > 0) { @@ -90,18 +86,16 @@ void _Ldtob(_Pft* args, u8 type) { val *= D_800122E0[i]; } } - } else { - if (exp > 0) { - factor = 1; - exp &= ~3; + } else if (exp > 0) { + factor = 1; + exp &= ~3; - for (n = exp, i = 0; n > 0; n >>= 1, i++) { - if ((n & 1) != 0) { - factor *= D_800122E0[i]; - } + for (n = exp, i = 0; n > 0; n >>= 1, i++) { + if ((n & 1) != 0) { + factor *= D_800122E0[i]; } - val /= factor; } + val /= factor; } gen = ((type == 'f') ? exp + 10 : 6) + args->prec; if (gen > 0x13) { @@ -157,27 +151,28 @@ void _Ldtob(_Pft* args, u8 type) { } s16 _Ldunscale(s16* pex, _Pft* px) { - u16* ps = (u16*)px; s16 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); + return FINITE; } if (0 > xchar) { return NAN; } else { *pex = 0; - return (0); + return 0; } } void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp) { u8 point = '.'; + if (nsig <= 0) { nsig = 1, diff --git a/src/libultra_boot_O2/_Litob.c b/src/libultra_boot_O2/_Litob.c index 0f9452124..2f8152a10 100644 --- a/src/libultra_boot_O2/_Litob.c +++ b/src/libultra_boot_O2/_Litob.c @@ -7,20 +7,20 @@ u8 D_8000AF84[] = "0123456789ABCDEF"; void _Litob(_Pft* args, u8 type) { u8 buff[BUFF_LEN]; - const u8* num_map; + const u8* numMap; s32 base; - s32 buff_ind; + s32 idx; u64 num; lldiv_t quotrem; if (type == 'X') { - num_map = D_8000AF84; + numMap = D_8000AF84; } else { - num_map = D_8000AF70; + numMap = D_8000AF70; } base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16); - buff_ind = BUFF_LEN; + idx = BUFF_LEN; num = args->v.ll; if ((type == 'd' || type == 'i') && args->v.ll < 0) { @@ -28,29 +28,29 @@ void _Litob(_Pft* args, u8 type) { } if (num != 0 || args->prec != 0) { - buff[--buff_ind] = num_map[num % base]; + buff[--idx] = numMap[num % base]; } args->v.ll = num / base; - while (args->v.ll > 0 && buff_ind > 0) { + while (args->v.ll > 0 && idx > 0) { quotrem = lldiv(args->v.ll, base); args->v.ll = quotrem.quot; - buff[--buff_ind] = num_map[quotrem.rem]; + buff[--idx] = numMap[quotrem.rem]; } - args->n1 = BUFF_LEN - buff_ind; + args->n1 = BUFF_LEN - idx; - memcpy(args->s, buff + buff_ind, args->n1); + memcpy(args->s, buff + idx, args->n1); if (args->n1 < args->prec) { args->nz0 = args->prec - args->n1; } if (args->prec < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { - buff_ind = args->width - args->n0 - args->nz0 - args->n1; - if (buff_ind > 0) { - args->nz0 += buff_ind; + idx = args->width - args->n0 - args->nz0 - args->n1; + if (idx > 0) { + args->nz0 += idx; } } } diff --git a/src/libultra_boot_O2/_Printf.c b/src/libultra_boot_O2/_Printf.c index e8fa2c696..c9ac6c524 100644 --- a/src/libultra_boot_O2/_Printf.c +++ b/src/libultra_boot_O2/_Printf.c @@ -4,6 +4,7 @@ for (i = 0; *a >= '0' && *a <= '9'; a++) \ if (i < 999) \ i = *a + i * 10 - '0'; + #define _PROUT(fmt, _size) \ if (_size > 0) { \ arg = (void*)pfn(arg, fmt, _size); \ @@ -30,20 +31,19 @@ char zeroes[] = "00000000000000000000000000000000"; void _Putfld(_Pft*, va_list*, u8, u8*); -s32 _Printf(char* (*pfn)(char*, const char*, size_t), char* arg, const char* fmt, va_list ap) { +s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap) { _Pft x; x.nchar = 0; - while (1) { - const u8* s; - u8 c; - u8* t; - static const u8 fchar[] = " +-#0"; + while (true) { + static const char fchar[] = " +-#0"; static const u32 fbit[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0 }; + const u8* s = (u8*)fmt; + u8 c; + const char* t; u8 ac[0x20]; - s = (u8*)fmt; while ((c = *s) != 0 && c != '%') { s++; } @@ -105,7 +105,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->n0 = px->nz0 = px->n1 = px->nz1 = px->n2 = px->nz2 = 0; switch (code) { - case 'c': ac[px->n0++] = va_arg(*pap, u32); break; @@ -136,7 +135,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { _Litob(px, code); break; - case 'x': case 'X': case 'u': @@ -165,7 +163,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->s = (char*)&ac[px->n0]; _Litob(px, code); break; - case 'e': case 'f': case 'g': @@ -186,7 +183,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->s = (char*)&ac[px->n0]; _Ldtob(px, code); break; - case 'n': if (px->qual == 'h') { *(va_arg(*pap, u16*)) = px->nchar; @@ -200,11 +196,10 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { break; case 'p': - px->v.ll = (s64)va_arg(*pap, void*); + px->v.ll = va_arg(*pap, void*); px->s = (char*)&ac[px->n0]; _Litob(px, 'x'); break; - case 's': px->s = va_arg(*pap, char*); px->n1 = strlen(px->s); @@ -212,11 +207,9 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->n1 = px->prec; } break; - case '%': ac[px->n0++] = '%'; break; - default: ac[px->n0++] = code; break; diff --git a/src/libultra_boot_O2/__osDevMgrMain.c b/src/libultra_boot_O2/__osDevMgrMain.c index e481c33fb..0612bbee1 100644 --- a/src/libultra_boot_O2/__osDevMgrMain.c +++ b/src/libultra_boot_O2/__osDevMgrMain.c @@ -5,14 +5,13 @@ void __osDevMgrMain(void* arg) { OSIoMesg* ioMesg; OSMesg sp70; OSMesg sp6C; - OSMgrArgs* arg0; + OSMgrArgs* arg0 = (OSMgrArgs*)arg; __OSTranxInfo* transfer; __OSBlockInfo* block; s32 phi_s2; s32 phi_s0; u32 sp54; - arg0 = (OSMgrArgs*)arg; ioMesg = NULL; while (true) { diff --git a/src/libultra_boot_O2/__osPiRawStartDma.c b/src/libultra_boot_O2/__osPiRawStartDma.c index d323a66b3..8fda51351 100644 --- a/src/libultra_boot_O2/__osPiRawStartDma.c +++ b/src/libultra_boot_O2/__osPiRawStartDma.c @@ -1,8 +1,8 @@ #include "global.h" s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size) { - register s32 status; - status = HW_REG(PI_STATUS_REG, u32); + register s32 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); } diff --git a/src/libultra_boot_O2/__osSiDeviceBusy.c b/src/libultra_boot_O2/__osSiDeviceBusy.c index ec2462f83..789815312 100644 --- a/src/libultra_boot_O2/__osSiDeviceBusy.c +++ b/src/libultra_boot_O2/__osSiDeviceBusy.c @@ -1,8 +1,8 @@ #include "global.h" -s32 __osSiDeviceBusy() { - register u32 status; - status = HW_REG(SI_STATUS_REG, u32); +s32 __osSiDeviceBusy(void) { + register u32 status = HW_REG(SI_STATUS_REG, u32); + if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { return true; } else { diff --git a/src/libultra_boot_O2/__osViGetCurrentContext.c b/src/libultra_boot_O2/__osViGetCurrentContext.c index f83a2d0ee..1e3c6ffa3 100644 --- a/src/libultra_boot_O2/__osViGetCurrentContext.c +++ b/src/libultra_boot_O2/__osViGetCurrentContext.c @@ -1,5 +1,5 @@ #include "global.h" -OSViContext* __osViGetCurrentContext() { +OSViContext* __osViGetCurrentContext(void) { return __osViCurr; } diff --git a/src/libultra_boot_O2/__osViInit.c b/src/libultra_boot_O2/__osViInit.c index 43f2abb02..91d5759b7 100644 --- a/src/libultra_boot_O2/__osViInit.c +++ b/src/libultra_boot_O2/__osViInit.c @@ -4,7 +4,7 @@ OSViContext vi[2] = { 0 }; OSViContext* __osViCurr = &vi[0]; OSViContext* __osViNext = &vi[1]; -void __osViInit() { +void __osViInit(void) { bzero(vi, sizeof(vi)); __osViCurr = &vi[0]; __osViNext = &vi[1]; diff --git a/src/libultra_boot_O2/__osViSwapContext.c b/src/libultra_boot_O2/__osViSwapContext.c index 8f202d17c..aeadb75af 100644 --- a/src/libultra_boot_O2/__osViSwapContext.c +++ b/src/libultra_boot_O2/__osViSwapContext.c @@ -1,8 +1,8 @@ #include "global.h" -void __osViSwapContext() { - register OSViMode* s0; - register OSViContext* s1; +void __osViSwapContext(void) { + register OSViMode* viMode; + register OSViContext* viNext; u32 origin; u32 hStart; u32 vstart; @@ -11,52 +11,52 @@ void __osViSwapContext() { register u32 s2; field = 0; - s1 = __osViNext; - s0 = s1->modep; + viNext = __osViNext; + viMode = viNext->modep; field = HW_REG(VI_V_CURRENT_LINE_REG, u32) & 1; - s2 = osVirtualToPhysical(s1->buffer); - origin = (s0->fldRegs[field].origin) + s2; - if (s1->state & 2) { - s1->x.scale |= s0->comRegs.xScale & ~0xfff; + s2 = osVirtualToPhysical(viNext->buffer); + origin = (viMode->fldRegs[field].origin) + s2; + if (viNext->state & 2) { + viNext->x.scale |= viMode->comRegs.xScale & ~0xfff; } else { - s1->x.scale = s0->comRegs.xScale; + viNext->x.scale = viMode->comRegs.xScale; } - if (s1->state & 4) { - sp34 = (u32)(s0->fldRegs[field].yScale & 0xfff); - s1->y.scale = s1->y.factor * sp34; - s1->y.scale |= s0->fldRegs[field].yScale & ~0xfff; + if (viNext->state & 4) { + sp34 = (u32)(viMode->fldRegs[field].yScale & 0xfff); + viNext->y.scale = viNext->y.factor * sp34; + viNext->y.scale |= viMode->fldRegs[field].yScale & ~0xfff; } else { - s1->y.scale = s0->fldRegs[field].yScale; + viNext->y.scale = viMode->fldRegs[field].yScale; } - vstart = (s0->fldRegs[field].vStart - (__additional_scanline << 0x10)) + __additional_scanline; - hStart = s0->comRegs.hStart; + vstart = (viMode->fldRegs[field].vStart - (__additional_scanline << 0x10)) + __additional_scanline; + hStart = viMode->comRegs.hStart; - if (s1->state & 0x20) { + if (viNext->state & 0x20) { hStart = 0; } - if (s1->state & 0x40) { - s1->y.scale = 0; - origin = osVirtualToPhysical(s1->buffer); + if (viNext->state & 0x40) { + viNext->y.scale = 0; + origin = osVirtualToPhysical(viNext->buffer); } - if (s1->state & 0x80) { - s1->y.scale = (s1->y.offset << 0x10) & 0x3ff0000; - origin = osVirtualToPhysical(s1->buffer); + if (viNext->state & 0x80) { + viNext->y.scale = (viNext->y.offset << 0x10) & 0x3ff0000; + origin = osVirtualToPhysical(viNext->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_WIDTH_REG, u32) = viMode->comRegs.width; + HW_REG(VI_BURST_REG, u32) = viMode->comRegs.burst; + HW_REG(VI_V_SYNC_REG, u32) = viMode->comRegs.vSync; + HW_REG(VI_H_SYNC_REG, u32) = viMode->comRegs.hSync; + HW_REG(VI_LEAP_REG, u32) = viMode->comRegs.leap; HW_REG(VI_H_START_REG, u32) = hStart; HW_REG(VI_V_START_REG, u32) = 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->x.scale; - HW_REG(VI_Y_SCALE_REG, u32) = s1->y.scale; - HW_REG(VI_CONTROL_REG, u32) = s1->features; + HW_REG(VI_V_BURST_REG, u32) = viMode->fldRegs[field].vBurst; + HW_REG(VI_INTR_REG, u32) = viMode->fldRegs[field].vIntr; + HW_REG(VI_X_SCALE_REG, u32) = viNext->x.scale; + HW_REG(VI_Y_SCALE_REG, u32) = viNext->y.scale; + HW_REG(VI_CONTROL_REG, u32) = viNext->features; __osViNext = __osViCurr; - __osViCurr = s1; + __osViCurr = viNext; *__osViNext = *__osViCurr; } diff --git a/src/libultra_boot_O2/osCartRomInit.c b/src/libultra_boot_O2/osCartRomInit.c index a46e0e09b..ff5dc8292 100644 --- a/src/libultra_boot_O2/osCartRomInit.c +++ b/src/libultra_boot_O2/osCartRomInit.c @@ -2,7 +2,7 @@ OSPiHandle __CartRomHandle; -OSPiHandle* osCartRomInit() { +OSPiHandle* osCartRomInit(void) { register u32 a; register s32 status; register u32 prevInt; diff --git a/src/libultra_boot_O2/osDriveRomInit.c b/src/libultra_boot_O2/osDriveRomInit.c index 83b3c9fc6..af478f0e9 100644 --- a/src/libultra_boot_O2/osDriveRomInit.c +++ b/src/libultra_boot_O2/osDriveRomInit.c @@ -2,7 +2,7 @@ OSPiHandle __DriveRomHandle; -OSPiHandle* osDriveRomInit() { +OSPiHandle* osDriveRomInit(void) { register s32 status; register u32 a; register s32 prevInt; diff --git a/src/libultra_boot_O2/osEPiStartDma.c b/src/libultra_boot_O2/osEPiStartDma.c index f1dccc833..7547fb695 100644 --- a/src/libultra_boot_O2/osEPiStartDma.c +++ b/src/libultra_boot_O2/osEPiStartDma.c @@ -3,6 +3,7 @@ s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) { s32 ret; + if (!__osPiDevMgr.initialized) { return -1; } @@ -15,9 +16,9 @@ s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) { } if (mb->hdr.pri == 1) { - ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, 0); + ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); } else { - ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, 0); + ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); } return ret; diff --git a/src/libultra_boot_O2/osPiGetCmdQueue.c b/src/libultra_boot_O2/osPiGetCmdQueue.c index a4454ec82..f0e32ae20 100644 --- a/src/libultra_boot_O2/osPiGetCmdQueue.c +++ b/src/libultra_boot_O2/osPiGetCmdQueue.c @@ -1,7 +1,7 @@ #include "global.h" #include "ultra64/internal.h" -OSMesgQueue* osPiGetCmdQueue() { +OSMesgQueue* osPiGetCmdQueue(void) { if (!__osPiDevMgr.initialized) { return NULL; } diff --git a/src/libultra_boot_O2/osViBlack.c b/src/libultra_boot_O2/osViBlack.c index 3e877a387..657168866 100644 --- a/src/libultra_boot_O2/osViBlack.c +++ b/src/libultra_boot_O2/osViBlack.c @@ -2,11 +2,12 @@ // TODO: name magic constants void osViBlack(u8 active) { - register u32 int_disabled = __osDisableInt(); + register u32 prevInt = __osDisableInt(); + if (active) { __osViNext->state |= 0x20; } else { __osViNext->state &= ~0x20; } - __osRestoreInt(int_disabled); + __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O2/osViGetNextFramebuffer.c b/src/libultra_boot_O2/osViGetNextFramebuffer.c index 86f8549ab..aaf44ce4a 100644 --- a/src/libultra_boot_O2/osViGetNextFramebuffer.c +++ b/src/libultra_boot_O2/osViGetNextFramebuffer.c @@ -1,8 +1,9 @@ #include "global.h" -void* osViGetNextFramebuffer() { +void* osViGetNextFramebuffer(void) { s32 prevInt = __osDisableInt(); void* buff = __osViNext->buffer; + __osRestoreInt(prevInt); return buff; } diff --git a/src/libultra_boot_O2/osViSetMode.c b/src/libultra_boot_O2/osViSetMode.c index db3e7fc2a..621b7ca4a 100644 --- a/src/libultra_boot_O2/osViSetMode.c +++ b/src/libultra_boot_O2/osViSetMode.c @@ -1,9 +1,11 @@ #include "global.h" void osViSetMode(OSViMode* mode) { - register u32 int_disabled = __osDisableInt(); + register u32 prevInt = __osDisableInt(); + __osViNext->modep = mode; __osViNext->state = 1; __osViNext->features = __osViNext->modep->comRegs.ctrl; - __osRestoreInt(int_disabled); + + __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O2/osViSetSpecialFeatures.c b/src/libultra_boot_O2/osViSetSpecialFeatures.c index 63e8ab5f3..e5bd21029 100644 --- a/src/libultra_boot_O2/osViSetSpecialFeatures.c +++ b/src/libultra_boot_O2/osViSetSpecialFeatures.c @@ -1,7 +1,8 @@ #include "global.h" void osViSetSpecialFeatures(u32 func) { - register u32 int_disabled = __osDisableInt(); + register u32 prevInt = __osDisableInt(); + if (func & OS_VI_GAMMA_ON) { __osViNext->features |= OS_VI_GAMMA; } @@ -32,5 +33,6 @@ void osViSetSpecialFeatures(u32 func) { __osViNext->features |= __osViNext->modep->comRegs.ctrl & (OS_VI_UNK200 | OS_VI_UNK100); } __osViNext->state |= 8; - __osRestoreInt(int_disabled); + + __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O2/osViSetXScale.c b/src/libultra_boot_O2/osViSetXScale.c index e6a9ec6bb..21b4f7aea 100644 --- a/src/libultra_boot_O2/osViSetXScale.c +++ b/src/libultra_boot_O2/osViSetXScale.c @@ -2,16 +2,13 @@ void osViSetXScale(f32 value) { register u32 nomValue; - register u32 saveMask; - - saveMask = __osDisableInt(); + register u32 prevInt = __osDisableInt(); __osViNext->x.factor = value; - __osViNext->state |= 0x2; nomValue = __osViNext->modep->comRegs.xScale & 0xfff; __osViNext->x.scale = (u32)(__osViNext->x.factor * nomValue) & 0xFFF; - __osRestoreInt(saveMask); + __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O2/osViSetYScale.c b/src/libultra_boot_O2/osViSetYScale.c index cde3b56b0..29128af76 100644 --- a/src/libultra_boot_O2/osViSetYScale.c +++ b/src/libultra_boot_O2/osViSetYScale.c @@ -1,10 +1,10 @@ #include "global.h" void osViSetYScale(f32 scale) { - register s32 prevInt; + register s32 prevInt = __osDisableInt(); - prevInt = __osDisableInt(); __osViNext->y.factor = scale; __osViNext->state |= 4; + __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O2/osViSwapBuffer.c b/src/libultra_boot_O2/osViSwapBuffer.c index 13995291d..b7ab9f917 100644 --- a/src/libultra_boot_O2/osViSwapBuffer.c +++ b/src/libultra_boot_O2/osViSwapBuffer.c @@ -1,8 +1,10 @@ #include "global.h" void osViSwapBuffer(void* vaddr) { - u32 int_disabled = __osDisableInt(); + u32 prevInt = __osDisableInt(); + __osViNext->buffer = vaddr; __osViNext->state |= 0x10; // TODO: figure out what this flag means - __osRestoreInt(int_disabled); + + __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O2/pimgr.c b/src/libultra_boot_O2/pimgr.c index 4239f8f78..32c36e695 100644 --- a/src/libultra_boot_O2/pimgr.c +++ b/src/libultra_boot_O2/pimgr.c @@ -18,7 +18,7 @@ OSPiHandle* __osCurrentHandle[] = { }; void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) { - u32 int_disabled; + u32 prevInt; OSPri newPri; OSPri currentPri; @@ -36,7 +36,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC newPri = currentPri; osSetThreadPri(NULL, pri); } - int_disabled = __osDisableInt(); + prevInt = __osDisableInt(); __osPiDevMgr.initialized = true; __osPiDevMgr.cmdQueue = cmdQ; @@ -49,7 +49,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC osCreateThread(&piThread, 0, __osDevMgrMain, (void*)&__osPiDevMgr, piStackThread + sizeof(piStackThread), pri); osStartThread(&piThread); - __osRestoreInt(int_disabled); + __osRestoreInt(prevInt); if (newPri != -1) { osSetThreadPri(NULL, newPri); diff --git a/src/libultra_boot_O2/sprintf.c b/src/libultra_boot_O2/sprintf.c index 96698b79e..386d9fa14 100644 --- a/src/libultra_boot_O2/sprintf.c +++ b/src/libultra_boot_O2/sprintf.c @@ -1,11 +1,11 @@ #include "global.h" -char* proutSprintf(char* dst, const char* fmt, size_t size) { - return (char*)memcpy(dst, fmt, size) + size; +void* proutSprintf(void* dst, const char* fmt, u32 size) { + return (void*)((u32)memcpy(dst, fmt, size) + size); } s32 vsprintf(char* dst, const char* fmt, va_list args) { - s32 ret = _Printf(&proutSprintf, dst, fmt, args); + s32 ret = _Printf(proutSprintf, dst, fmt, args); if (ret > -1) { dst[ret] = 0; } @@ -17,7 +17,7 @@ s32 sprintf(char* dst, const char* fmt, ...) { va_list args; va_start(args, fmt); - ret = _Printf(&proutSprintf, dst, fmt, args); + ret = _Printf(proutSprintf, dst, fmt, args); if (ret > -1) { dst[ret] = 0; } diff --git a/src/libultra_boot_O2/string.c b/src/libultra_boot_O2/string.c index cea07c253..bf059094f 100644 --- a/src/libultra_boot_O2/string.c +++ b/src/libultra_boot_O2/string.c @@ -1,7 +1,8 @@ #include "global.h" -const u8* strchr(const u8* str, s32 ch) { +const char* strchr(const char* str, s32 ch) { u8 c = ch; + while (*str != c) { if (*str == 0) { return NULL; @@ -11,17 +12,19 @@ const u8* strchr(const u8* str, s32 ch) { return str; } -size_t strlen(const u8* str) { - const u8* ptr = str; +u32 strlen(const char* str) { + const char* ptr = str; + while (*ptr) { ptr++; } return ptr - str; } -void* memcpy(void* dst, const void* src, size_t size) { +void* memcpy(void* dst, const void* src, u32 size) { u8* _dst = dst; const u8* _src = src; + while (size > 0) { *_dst++ = *_src++; size--; diff --git a/src/libultra_boot_O2/vimgr.c b/src/libultra_boot_O2/vimgr.c index 5525ec74f..c195bbf4c 100644 --- a/src/libultra_boot_O2/vimgr.c +++ b/src/libultra_boot_O2/vimgr.c @@ -22,9 +22,10 @@ u32 __additional_scanline = 0; void viMgrMain(void*); void osCreateViManager(OSPri pri) { - u32 int_disabled; + u32 prevInt; OSPri newPri; OSPri currentPri; + if (!__osViDevMgr.initialized) { __osTimerServicesInit(); __additional_scanline = 0; @@ -44,7 +45,7 @@ void osCreateViManager(OSPri pri) { osSetThreadPri(NULL, pri); } - int_disabled = __osDisableInt(); + prevInt = __osDisableInt(); __osViDevMgr.initialized = true; __osViDevMgr.mgrThread = &viThread; __osViDevMgr.cmdQueue = &viEventQueue; @@ -56,7 +57,7 @@ void osCreateViManager(OSPri pri) { osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, viThreadStack + sizeof(viThreadStack), pri); __osViInit(); osStartThread(&viThread); - __osRestoreInt(int_disabled); + __osRestoreInt(prevInt); if (newPri != -1) { osSetThreadPri(NULL, newPri); } @@ -68,9 +69,8 @@ void viMgrMain(void* vargs) { static u16 viRetrace; u32 addTime; viMesgStruct* mesg; - u32 temp; // always 0 + u32 temp = 0; // always 0 - temp = 0; mesg = NULL; viRetrace = __osViGetCurrentContext()->retraceCount; if (viRetrace == 0) { @@ -79,7 +79,7 @@ void viMgrMain(void* vargs) { args = (OSMgrArgs*)vargs; - while (1) { + while (true) { osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK); switch (mesg->unk00) { case 13: @@ -107,9 +107,7 @@ void viMgrMain(void* vargs) { __osBaseCounter = osGetCount(); addTime = __osBaseCounter - addTime; __osCurrentTime = __osCurrentTime + addTime; - break; - case 14: __osTimerInterrupt(); break; |
