summaryrefslogtreecommitdiff
path: root/lib/ultralib/src/io
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ultralib/src/io')
-rw-r--r--lib/ultralib/src/io/aigetlen.c6
-rw-r--r--lib/ultralib/src/io/aigetstat.c2
-rw-r--r--lib/ultralib/src/io/aisetfreq.c17
-rw-r--r--lib/ultralib/src/io/aisetnextbuf.c14
-rw-r--r--lib/ultralib/src/io/cartrominit.c8
-rw-r--r--lib/ultralib/src/io/contchannelreset.c4
-rw-r--r--lib/ultralib/src/io/conteeplongread.c2
-rw-r--r--lib/ultralib/src/io/conteeplongwrite.c2
-rw-r--r--lib/ultralib/src/io/conteepprobe.c4
-rw-r--r--lib/ultralib/src/io/conteepread.c8
-rw-r--r--lib/ultralib/src/io/conteepwrite.c5
-rw-r--r--lib/ultralib/src/io/contpfs.c6
-rw-r--r--lib/ultralib/src/io/contquery.c11
-rw-r--r--lib/ultralib/src/io/contramread.c5
-rw-r--r--lib/ultralib/src/io/contramwrite.c5
-rw-r--r--lib/ultralib/src/io/contreaddata.c5
-rw-r--r--lib/ultralib/src/io/contreset.c4
-rw-r--r--lib/ultralib/src/io/controller.c16
-rw-r--r--lib/ultralib/src/io/controller.h289
-rw-r--r--lib/ultralib/src/io/controller_gbpak.h8
-rw-r--r--lib/ultralib/src/io/controller_voice.h59
-rw-r--r--lib/ultralib/src/io/contsetch.c8
-rw-r--r--lib/ultralib/src/io/crc.c136
-rw-r--r--lib/ultralib/src/io/devmgr.c2
-rw-r--r--lib/ultralib/src/io/dpgetstat.c2
-rw-r--r--lib/ultralib/src/io/dpsetnextbuf.c2
-rw-r--r--lib/ultralib/src/io/driverominit.c6
-rw-r--r--lib/ultralib/src/io/epidma.c2
-rw-r--r--lib/ultralib/src/io/epigettype.c2
-rw-r--r--lib/ultralib/src/io/epilinkhandle.c2
-rw-r--r--lib/ultralib/src/io/epirawdma.c2
-rw-r--r--lib/ultralib/src/io/epirawread.c2
-rw-r--r--lib/ultralib/src/io/epirawwrite.c2
-rw-r--r--lib/ultralib/src/io/epiread.c2
-rw-r--r--lib/ultralib/src/io/epiwrite.c2
-rw-r--r--lib/ultralib/src/io/gbpakcheckconnector.c4
-rw-r--r--lib/ultralib/src/io/gbpakgetbank.c2
-rw-r--r--lib/ultralib/src/io/gbpakgetstatus.c2
-rw-r--r--lib/ultralib/src/io/gbpakinit.c8
-rw-r--r--lib/ultralib/src/io/gbpakpower.c4
-rw-r--r--lib/ultralib/src/io/gbpakreadid.c4
-rw-r--r--lib/ultralib/src/io/gbpakreadwrite.c2
-rw-r--r--lib/ultralib/src/io/gbpaksetbank.c2
-rw-r--r--lib/ultralib/src/io/leodiskinit.c6
-rw-r--r--lib/ultralib/src/io/leointerrupt.c10
-rw-r--r--lib/ultralib/src/io/motor.c16
-rw-r--r--lib/ultralib/src/io/pfsallocatefile.c5
-rw-r--r--lib/ultralib/src/io/pfschecker.c15
-rw-r--r--lib/ultralib/src/io/pfsdeletefile.c7
-rw-r--r--lib/ultralib/src/io/pfsfilestate.c5
-rw-r--r--lib/ultralib/src/io/pfsfreeblocks.c5
-rw-r--r--lib/ultralib/src/io/pfsgetlabel.c3
-rw-r--r--lib/ultralib/src/io/pfsgetstatus.c4
-rw-r--r--lib/ultralib/src/io/pfsinit.c4
-rw-r--r--lib/ultralib/src/io/pfsinitpak.c5
-rw-r--r--lib/ultralib/src/io/pfsisplug.c8
-rw-r--r--lib/ultralib/src/io/pfsnumfiles.c2
-rw-r--r--lib/ultralib/src/io/pfsreadwritefile.c20
-rw-r--r--lib/ultralib/src/io/pfsreformat.c5
-rw-r--r--lib/ultralib/src/io/pfsrepairid.c3
-rw-r--r--lib/ultralib/src/io/pfssearchfile.c3
-rw-r--r--lib/ultralib/src/io/pfsselectbank.c2
-rw-r--r--lib/ultralib/src/io/pfssetlabel.c3
-rw-r--r--lib/ultralib/src/io/pi.c4
-rw-r--r--lib/ultralib/src/io/piacs.c4
-rw-r--r--lib/ultralib/src/io/pidma.c2
-rw-r--r--lib/ultralib/src/io/pigetcmdq.c2
-rw-r--r--lib/ultralib/src/io/pigetstat.c4
-rw-r--r--lib/ultralib/src/io/pigettype.c2
-rw-r--r--lib/ultralib/src/io/piint.h197
-rw-r--r--lib/ultralib/src/io/pimgr.c30
-rw-r--r--lib/ultralib/src/io/pirawdma.c2
-rw-r--r--lib/ultralib/src/io/pirawread.c2
-rw-r--r--lib/ultralib/src/io/pirawwrite.c2
-rw-r--r--lib/ultralib/src/io/piread.c2
-rw-r--r--lib/ultralib/src/io/piwrite.c2
-rw-r--r--lib/ultralib/src/io/si.c4
-rw-r--r--lib/ultralib/src/io/siacs.c6
-rw-r--r--lib/ultralib/src/io/sigetstat.c4
-rw-r--r--lib/ultralib/src/io/siint.h15
-rw-r--r--lib/ultralib/src/io/sirawdma.c12
-rw-r--r--lib/ultralib/src/io/sirawread.c2
-rw-r--r--lib/ultralib/src/io/sirawwrite.c2
-rw-r--r--lib/ultralib/src/io/sp.c4
-rw-r--r--lib/ultralib/src/io/spgetstat.c2
-rw-r--r--lib/ultralib/src/io/sprawdma.c2
-rw-r--r--lib/ultralib/src/io/sprawread.c2
-rw-r--r--lib/ultralib/src/io/sprawwrite.c2
-rw-r--r--lib/ultralib/src/io/sptask.c4
-rw-r--r--lib/ultralib/src/io/vi.c6
-rw-r--r--lib/ultralib/src/io/viblack.c2
-rw-r--r--lib/ultralib/src/io/viextendvstart.c2
-rw-r--r--lib/ultralib/src/io/vifade.c2
-rw-r--r--lib/ultralib/src/io/vigetcurrcontext.c2
-rw-r--r--lib/ultralib/src/io/vigetcurrframebuf.c2
-rw-r--r--lib/ultralib/src/io/vigetmode.c2
-rw-r--r--lib/ultralib/src/io/vigetnextcontext.c2
-rw-r--r--lib/ultralib/src/io/vigetnextframebuf.c2
-rw-r--r--lib/ultralib/src/io/viint.h71
-rw-r--r--lib/ultralib/src/io/vimgr.c18
-rw-r--r--lib/ultralib/src/io/virepeatline.c2
-rw-r--r--lib/ultralib/src/io/visetevent.c2
-rw-r--r--lib/ultralib/src/io/visetmode.c2
-rw-r--r--lib/ultralib/src/io/visetspecial.c15
-rw-r--r--lib/ultralib/src/io/visetxscale.c2
-rw-r--r--lib/ultralib/src/io/visetyscale.c2
-rw-r--r--lib/ultralib/src/io/viswapbuf.c2
-rw-r--r--lib/ultralib/src/io/viswapcontext.c6
-rw-r--r--lib/ultralib/src/io/vitbl.c368
109 files changed, 587 insertions, 1052 deletions
diff --git a/lib/ultralib/src/io/aigetlen.c b/lib/ultralib/src/io/aigetlen.c
index 6b83682..aadf891 100644
--- a/lib/ultralib/src/io/aigetlen.c
+++ b/lib/ultralib/src/io/aigetlen.c
@@ -3,6 +3,12 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
+/**
+ * Returns the number of bytes remaining in a currently ongoing audio DMA.
+ *
+ * Note that audio DMA is double-buffered, a DMA can be queued while another is in-progress. This only returns
+ * information about the currently in-progress DMA.
+ */
u32 osAiGetLength(void) {
return IO_READ(AI_LEN_REG);
}
diff --git a/lib/ultralib/src/io/aigetstat.c b/lib/ultralib/src/io/aigetstat.c
index c7a3cf7..270b66e 100644
--- a/lib/ultralib/src/io/aigetstat.c
+++ b/lib/ultralib/src/io/aigetstat.c
@@ -3,6 +3,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 osAiGetStatus() {
+u32 osAiGetStatus(void) {
return IO_READ(AI_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/aisetfreq.c b/lib/ultralib/src/io/aisetfreq.c
index e41d6fa..2b0efca 100644
--- a/lib/ultralib/src/io/aisetfreq.c
+++ b/lib/ultralib/src/io/aisetfreq.c
@@ -1,12 +1,18 @@
#include "PR/rcp.h"
#include "PR/ultraerror.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: not sure if this should be here
extern s32 osViClock;
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
+/**
+ * Programs the operating frequency of the Audio DAC.
+ *
+ * @param frequency Target Playback frequency.
+ * @return The actual playback frequency, or -1 if the supplied frequency cannot be used.
+ */
s32 osAiSetFrequency(u32 frequency) {
register unsigned int dacRate;
register unsigned char bitRate;
@@ -31,15 +37,20 @@ s32 osAiSetFrequency(u32 frequency) {
}
#endif
+ // Calculate the DAC sample period ("dperiod") (dperiod + 1 = vid_clock / frequency)
f = osViClock / (float)frequency + .5f;
dacRate = f;
+ // Upcoming division by 66. If dacRate is smaller than 2 * 66 = 132, bitrate will be 1 and AI_BITRATE_REG will be
+ // programmed with 0, which results in no audio output. Return -1 to indicate an unusable frequency.
if (dacRate < AI_MIN_DAC_RATE) {
return -1;
}
+ // Calculate the largest "bitrate" (ABUS clock half period, "aclockhp") supported for this dacrate. These two
+ // quantities must satisfy (dperiod + 1) >= 66 * (aclockhp + 1), here this is taken as equality.
bitRate = dacRate / 66;
-
+ // Clamp to max value
if (bitRate > AI_MAX_BIT_RATE) {
bitRate = AI_MAX_BIT_RATE;
}
@@ -49,5 +60,7 @@ s32 osAiSetFrequency(u32 frequency) {
#if BUILD_VERSION < VERSION_J
IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON);
#endif
+ // Return the true playback frequency (frequency = vid_clock / (dperiod + 1)), which may differ from the target
+ // frequency.
return osViClock / (s32)dacRate;
}
diff --git a/lib/ultralib/src/io/aisetnextbuf.c b/lib/ultralib/src/io/aisetnextbuf.c
index 041b61d..78634a9 100644
--- a/lib/ultralib/src/io/aisetnextbuf.c
+++ b/lib/ultralib/src/io/aisetnextbuf.c
@@ -1,11 +1,20 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
+/**
+ * Submits an audio buffer to be consumed by the Audio DAC. The audio interface can queue a second DMA while another
+ * is in progress and automatically begin the next one as soon as the current DMA completes. If there is already a
+ * second DMA queued (DMA is full), -1 is returned to indicate the buffer could not be submitted.
+ *
+ * @param bufPtr Next audio buffer. Must be an 8-byte aligned KSEG0 (0x80XXXXXX) address.
+ * @param size Length of next audio buffer in bytes, maximum size 0x40000 bytes / 256 KiB. Should be a multiple of 8.
+ * @return 0 if the DMA was enqueued successfully, -1 if the DMA could not yet be queued.
+ */
s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
static u8 hdwrBugFlag = FALSE;
char* bptr;
@@ -41,6 +50,9 @@ s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
}
#if BUILD_VERSION < VERSION_J
+ //! @bug The __osAiDeviceBusy call should be above the hardware bug workaround to ensure that it was only
+ //! performed when a transfer was guaranteed to start. If this condition passes and this function returns without
+ //! submitting a buffer for DMA, the code above will lose track of when to apply the workaround.
if (__osAiDeviceBusy()) {
return -1;
}
diff --git a/lib/ultralib/src/io/cartrominit.c b/lib/ultralib/src/io/cartrominit.c
index 87aa8bb..7f2eb11 100644
--- a/lib/ultralib/src/io/cartrominit.c
+++ b/lib/ultralib/src/io/cartrominit.c
@@ -1,12 +1,12 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_version.h"
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/rcp.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
#if BUILD_VERSION >= VERSION_J
-OSPiHandle __CartRomHandle ALIGNED(8);
+OSPiHandle __CartRomHandle ALIGNED(0x8);
OSPiHandle* osCartRomInit(void) {
u32 value = 0;
u32 saveMask;
@@ -65,7 +65,7 @@ OSPiHandle* osCartRomInit(void) {
}
#else
-OSPiHandle CartRomHandle ALIGNED(8);
+OSPiHandle CartRomHandle ALIGNED(0x8);
OSPiHandle* osCartRomInit(void) {
u32 domain = 0;
u32 saveMask;
diff --git a/lib/ultralib/src/io/contchannelreset.c b/lib/ultralib/src/io/contchannelreset.c
index f6ed8a2..108a594 100644
--- a/lib/ultralib/src/io/contchannelreset.c
+++ b/lib/ultralib/src/io/contchannelreset.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 __osContChannelReset(OSMesgQueue* mq, int channel) {
s32 i;
diff --git a/lib/ultralib/src/io/conteeplongread.c b/lib/ultralib/src/io/conteeplongread.c
index d8d59f6..edebfc8 100644
--- a/lib/ultralib/src/io/conteeplongread.c
+++ b/lib/ultralib/src/io/conteeplongread.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osEepromLongRead(OSMesgQueue* mq, u8 address, u8* buffer, int length) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/conteeplongwrite.c b/lib/ultralib/src/io/conteeplongwrite.c
index c5668e1..8ecce25 100644
--- a/lib/ultralib/src/io/conteeplongwrite.c
+++ b/lib/ultralib/src/io/conteeplongwrite.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osEepromLongWrite(OSMesgQueue* mq, u8 address, u8* buffer, int length) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/conteepprobe.c b/lib/ultralib/src/io/conteepprobe.c
index b19dc49..ca09790 100644
--- a/lib/ultralib/src/io/conteepprobe.c
+++ b/lib/ultralib/src/io/conteepprobe.c
@@ -1,5 +1,5 @@
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 osEepromProbe(OSMesgQueue* mq) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/conteepread.c b/lib/ultralib/src/io/conteepread.c
index 2d334fa..502ab13 100644
--- a/lib/ultralib/src/io/conteepread.c
+++ b/lib/ultralib/src/io/conteepread.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
-OSPifRam __osEepPifRam ALIGNED(16);
+OSPifRam __osEepPifRam;
#if BUILD_VERSION >= VERSION_L
s32 __osEepromRead16K;
#endif
diff --git a/lib/ultralib/src/io/conteepwrite.c b/lib/ultralib/src/io/conteepwrite.c
index 7352430..9ebda24 100644
--- a/lib/ultralib/src/io/conteepwrite.c
+++ b/lib/ultralib/src/io/conteepwrite.c
@@ -1,7 +1,8 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
static void __osPackEepWriteData(u8 address, u8* buffer);
s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
diff --git a/lib/ultralib/src/io/contpfs.c b/lib/ultralib/src/io/contpfs.c
index c845a7d..8574de1 100644
--- a/lib/ultralib/src/io/contpfs.c
+++ b/lib/ultralib/src/io/contpfs.c
@@ -1,11 +1,11 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/os_version.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "PR/rmon.h"
#if BUILD_VERSION >= VERSION_J
-__OSInode __osPfsInodeCache ALIGNED(8);
+__OSInode __osPfsInodeCache ALIGNED(0x8);
s32 __osPfsInodeCacheChannel = -1;
u8 __osPfsInodeCacheBank = 250;
#endif
diff --git a/lib/ultralib/src/io/contquery.c b/lib/ultralib/src/io/contquery.c
index df038ce..d3c06fc 100644
--- a/lib/ultralib/src/io/contquery.c
+++ b/lib/ultralib/src/io/contquery.c
@@ -1,7 +1,11 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
+/**
+ * Starts to read the values for SI device status and type which are connected to the controller port and joyport
+ * connector.
+ */
s32 osContStartQuery(OSMesgQueue* mq) {
s32 ret = 0;
@@ -19,6 +23,9 @@ s32 osContStartQuery(OSMesgQueue* mq) {
return ret;
}
+/**
+ * Returns the values from osContStartQuery to status. Both functions must be paired for use.
+ */
void osContGetQuery(OSContStatus* data) {
u8 pattern;
__osContGetInitData(&pattern, data);
diff --git a/lib/ultralib/src/io/contramread.c b/lib/ultralib/src/io/contramread.c
index 9c399ee..99c8332 100644
--- a/lib/ultralib/src/io/contramread.c
+++ b/lib/ultralib/src/io/contramread.c
@@ -1,7 +1,8 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr))
diff --git a/lib/ultralib/src/io/contramwrite.c b/lib/ultralib/src/io/contramwrite.c
index a213049..0d79701 100644
--- a/lib/ultralib/src/io/contramwrite.c
+++ b/lib/ultralib/src/io/contramwrite.c
@@ -1,7 +1,8 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
extern s32 __osPfsLastChannel;
diff --git a/lib/ultralib/src/io/contreaddata.c b/lib/ultralib/src/io/contreaddata.c
index da0cac3..a2b1730 100644
--- a/lib/ultralib/src/io/contreaddata.c
+++ b/lib/ultralib/src/io/contreaddata.c
@@ -1,6 +1,7 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
static void __osPackReadData(void);
diff --git a/lib/ultralib/src/io/contreset.c b/lib/ultralib/src/io/contreset.c
index 140088a..c752f5b 100644
--- a/lib/ultralib/src/io/contreset.c
+++ b/lib/ultralib/src/io/contreset.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
void __osPackResetData(void);
diff --git a/lib/ultralib/src/io/controller.c b/lib/ultralib/src/io/controller.c
index 728c207..fd87b16 100644
--- a/lib/ultralib/src/io/controller.c
+++ b/lib/ultralib/src/io/controller.c
@@ -1,17 +1,17 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
-OSPifRam __osContPifRam ALIGNED(16);
+OSPifRam __osContPifRam;
u8 __osContLastCmd;
u8 __osMaxControllers;
OSTimer __osEepromTimer;
-OSMesgQueue __osEepromTimerQ ALIGNED(8);
+OSMesgQueue __osEepromTimerQ ALIGNED(0x8);
OSMesg __osEepromTimerMsg;
-s32 __osContinitialized = 0;
+s32 __osContinitialized = FALSE;
s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
OSMesg dummy;
@@ -20,11 +20,11 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
OSTimer mytimer;
OSMesgQueue timerMesgQueue;
- if (__osContinitialized != 0) {
+ if (__osContinitialized) {
return 0;
}
- __osContinitialized = 1;
+ __osContinitialized = TRUE;
t = osGetTime();
if (t < OS_USEC_TO_CYCLES(500000)) {
diff --git a/lib/ultralib/src/io/controller.h b/lib/ultralib/src/io/controller.h
deleted file mode 100644
index 5dac7f5..0000000
--- a/lib/ultralib/src/io/controller.h
+++ /dev/null
@@ -1,289 +0,0 @@
-#ifndef _CONTROLLER_H
-#define _CONTROLLER_H
-
-#include "PR/os_internal.h"
-#include "PR/os_version.h"
-#include "PR/rcp.h"
-
-//should go somewhere else but
-#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
-#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)
-
-typedef struct
-{
- /* 0x0 */ u32 ramarray[15];
- /* 0x3C */ u32 pifstatus;
-} OSPifRam;
-
-typedef struct
-{
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
- /* 0x4 */ u16 button;
- /* 0x6 */ s8 stick_x;
- /* 0x7 */ s8 stick_y;
-} __OSContReadFormat;
-
-typedef struct
-{
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
- /* 0x4 */ u8 typeh;
- /* 0x5 */ u8 typel;
- /* 0x6 */ u8 status;
- /* 0x7 */ u8 dummy1;
-} __OSContRequesFormat;
-
-typedef struct
-{
- /* 0x0 */ u8 txsize;
- /* 0x1 */ u8 rxsize;
- /* 0x2 */ u8 cmd;
- /* 0x3 */ u8 typeh;
- /* 0x4 */ u8 typel;
- /* 0x5 */ u8 status;
-} __OSContRequesFormatShort;
-
-typedef struct
-{
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
-#if BUILD_VERSION >= VERSION_J
- /* 0x4 */ u8 addrh;
- /* 0x5 */ u8 addrl;
-#else
- /* 0x4 */ u16 address;
-#endif
- /* 0x6 */ u8 data[BLOCKSIZE];
- /* 0x26 */ u8 datacrc;
-} __OSContRamReadFormat;
-
-typedef union {
- /* 0x0 */ struct
- {
- /* 0x0 */ u8 bank;
- /* 0x1 */ u8 page;
- } inode_t;
- /* 0x0 */ u16 ipage;
-} __OSInodeUnit;
-
-typedef struct
-{
- /* 0x0 */ u32 game_code;
- /* 0x4 */ u16 company_code;
- /* 0x6 */ __OSInodeUnit start_page;
- /* 0x8 */ u8 status;
- /* 0x9 */ s8 reserved;
- /* 0xA */ u16 data_sum;
- /* 0xC */ u8 ext_name[PFS_FILE_EXT_LEN];
- /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN];
-} __OSDir;
-
-typedef struct
-{
- /* 0x0 */ __OSInodeUnit inode_page[128];
-} __OSInode;
-
-typedef struct
-{
- /* 0x0 */ u32 repaired;
- /* 0x4 */ u32 random;
- /* 0x8 */ u64 serial_mid;
- /* 0x10 */ u64 serial_low;
- /* 0x18 */ u16 deviceid;
- /* 0x1A */ u8 banks;
- /* 0x1B */ u8 version;
- /* 0x1C */ u16 checksum;
- /* 0x1E */ u16 inverted_checksum;
-} __OSPackId;
-
-typedef struct
-{
- /* 0x0 */ u8 txsize;
- /* 0x1 */ u8 rxsize;
- /* 0x2 */ u8 cmd;
- /* 0x3 */ u8 address;
- /* 0x4 */ u8 data[EEPROM_BLOCK_SIZE];
-} __OSContEepromFormat;
-
-// Joybus commands
-//from: http://en64.shoutwiki.com/wiki/SI_Registers_Detailed#CONT_CMD_Usage
-#define CONT_CMD_REQUEST_STATUS 0
-#define CONT_CMD_READ_BUTTON 1
-#define CONT_CMD_READ_PAK 2
-#define CONT_CMD_WRITE_PAK 3
-#define CONT_CMD_READ_EEPROM 4
-#define CONT_CMD_WRITE_EEPROM 5
-#define CONT_CMD_READ36_VOICE 9
-#define CONT_CMD_WRITE20_VOICE 10
-#define CONT_CMD_READ2_VOICE 11
-#define CONT_CMD_WRITE4_VOICE 12
-#define CONT_CMD_SWRITE_VOICE 13
-#define CONT_CMD_CHANNEL_RESET 0xFD
-#define CONT_CMD_RESET 0xFF
-
-// Bytes transmitted for each joybus command
-#define CONT_CMD_REQUEST_STATUS_TX 1
-#define CONT_CMD_READ_BUTTON_TX 1
-#define CONT_CMD_READ_PAK_TX 3
-#define CONT_CMD_WRITE_PAK_TX 35
-#define CONT_CMD_READ_EEPROM_TX 2
-#define CONT_CMD_WRITE_EEPROM_TX 10
-#define CONT_CMD_READ36_VOICE_TX 3
-#define CONT_CMD_WRITE20_VOICE_TX 23
-#define CONT_CMD_READ2_VOICE_TX 3
-#define CONT_CMD_WRITE4_VOICE_TX 7
-#define CONT_CMD_SWRITE_VOICE_TX 3
-#define CONT_CMD_RESET_TX 1
-
-// Bytes received for each joybus command
-#define CONT_CMD_REQUEST_STATUS_RX 3
-#define CONT_CMD_READ_BUTTON_RX 4
-#define CONT_CMD_READ_PAK_RX 33
-#define CONT_CMD_WRITE_PAK_RX 1
-#define CONT_CMD_READ_EEPROM_RX 8
-#define CONT_CMD_WRITE_EEPROM_RX 1
-#define CONT_CMD_READ36_VOICE_RX 37
-#define CONT_CMD_WRITE20_VOICE_RX 1
-#define CONT_CMD_READ2_VOICE_RX 3
-#define CONT_CMD_WRITE4_VOICE_RX 1
-#define CONT_CMD_SWRITE_VOICE_RX 1
-#define CONT_CMD_RESET_RX 3
-
-#define CONT_CMD_NOP 0xff
-#define CONT_CMD_END 0xfe //indicates end of a command
-#define CONT_CMD_EXE 1 //set pif ram status byte to this to do a command
-
-#define DIR_STATUS_EMPTY 0
-#define DIR_STATUS_UNKNOWN 1
-#define DIR_STATUS_OCCUPIED 2
-
-// Controller accessory addresses
-// https://github.com/joeldipops/TransferBoy/blob/master/docs/TransferPakReference.md
-
-// Accesory detection
-#define CONT_ADDR_DETECT 0x8000
-// Rumble
-#define CONT_ADDR_RUMBLE 0xC000
-// Controller Pak
-// Transfer Pak
-#define CONT_ADDR_GB_POWER 0x8000 // Same as the detection address, but semantically different
-#define CONT_ADDR_GB_BANK 0xA000
-#define CONT_ADDR_GB_STATUS 0xB000
-
-// Addresses sent to controller accessories are in blocks, not bytes
-#define CONT_BLOCKS(x) ((x) / BLOCKSIZE)
-
-// Block addresses of the above
-#define CONT_BLOCK_DETECT CONT_BLOCKS(CONT_ADDR_DETECT)
-#define CONT_BLOCK_RUMBLE CONT_BLOCKS(CONT_ADDR_RUMBLE)
-#define CONT_BLOCK_GB_POWER CONT_BLOCKS(CONT_ADDR_GB_POWER)
-#define CONT_BLOCK_GB_BANK CONT_BLOCKS(CONT_ADDR_GB_BANK)
-#define CONT_BLOCK_GB_STATUS CONT_BLOCKS(CONT_ADDR_GB_STATUS)
-
-
-// Transfer pak
-
-#define GB_POWER_ON 0x84
-#define GB_POWER_OFF 0xFE
-
-
-typedef struct
-{
- /* 0x0 */ __OSInode inode;
- /* 0x100 */ u8 bank;
- /* 0x101 */ u8 map[PFS_INODE_DIST_MAP];
-} __OSInodeCache;
-
-extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *);
-u16 __osSumcalc(u8 *ptr, int length);
-s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum);
-s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid);
-s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp);
-s32 __osGetId(OSPfs *pfs);
-s32 __osCheckId(OSPfs *pfs);
-s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank);
-#if BUILD_VERSION >= VERSION_J
-s32 __osPfsSelectBank(OSPfs *pfs, u8 bank);
-#else
-s32 __osPfsSelectBank(OSPfs *pfs);
-#endif
-s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page);
-#if BUILD_VERSION >= VERSION_J
-s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u8 bank, __OSInodeUnit *last_page);
-#else
-s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag);
-#endif
-s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank);
-s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer);
-s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force);
-void __osContGetInitData(u8 *pattern, OSContStatus *data);
-void __osPackRequestData(u8 cmd);
-void __osPfsRequestData(u8 cmd);
-void __osPfsGetInitData(u8* pattern, OSContStatus* data);
-u8 __osContAddressCrc(u16 addr);
-u8 __osContDataCrc(u8 *data);
-s32 __osPfsGetStatus(OSMesgQueue *queue, int channel);
-
-extern u8 __osContLastCmd;
-extern OSTimer __osEepromTimer;
-extern OSMesg __osEepromTimerMsg;
-extern OSMesgQueue __osEepromTimerQ;
-extern OSPifRam __osEepPifRam;
-extern OSPifRam __osContPifRam;
-extern OSPifRam __osPfsPifRam;
-extern u8 __osMaxControllers;
-
-//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0
-#define ERRCK(fn) \
- ret = fn; \
- if (ret != 0) \
- return ret
-
-#if BUILD_VERSION >= VERSION_J
-
-#define SELECT_BANK(pfs, bank) \
- __osPfsSelectBank((pfs), (bank))
-
-#define SET_ACTIVEBANK_TO_ZERO() \
- if (pfs->activebank != 0) \
- { \
- ERRCK(__osPfsSelectBank(pfs, 0)); \
- } (void)0
-
-#else
-
-#define SELECT_BANK(pfs, bank) \
- (pfs->activebank = (bank), __osPfsSelectBank((pfs)))
-
-#define SET_ACTIVEBANK_TO_ZERO() \
- if (pfs->activebank != 0) \
- { \
- pfs->activebank = 0; \
- ERRCK(__osPfsSelectBank(pfs)); \
- } (void)0
-
-#endif
-
-#define PFS_CHECK_ID() \
- if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \
- return PFS_ERR_NEW_PACK
-
-#define PFS_CHECK_STATUS() \
- if ((pfs->status & PFS_INITIALIZED) == 0) \
- return PFS_ERR_INVALID
-
-#define PFS_GET_STATUS() \
- __osSiGetAccess(); \
- ret = __osPfsGetStatus(queue, channel); \
- __osSiRelAccess(); \
- if (ret != 0) \
- return ret
-
-#endif
diff --git a/lib/ultralib/src/io/controller_gbpak.h b/lib/ultralib/src/io/controller_gbpak.h
deleted file mode 100644
index db98bd4..0000000
--- a/lib/ultralib/src/io/controller_gbpak.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _CONTROLLER_GBPAK_H
-#define _CONTROLLER_GBPAK_H
-
-extern OSTimer __osGbpakTimer;
-extern OSMesg __osGbpakTimerMsg;
-extern OSMesgQueue __osGbpakTimerQ;
-
-#endif
diff --git a/lib/ultralib/src/io/controller_voice.h b/lib/ultralib/src/io/controller_voice.h
deleted file mode 100644
index 1b9dee6..0000000
--- a/lib/ultralib/src/io/controller_voice.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef CONTROLLER_VOICE_H
-#define CONTROLLER_VOICE_H
-
-#include "PR/ultratypes.h"
-
-typedef struct {
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
- /* 0x4 */ u8 addrh;
- /* 0x5 */ u8 addrl;
- /* 0x6 */ u8 data[2];
- /* 0x8 */ u8 datacrc;
-} __OSVoiceRead2Format;
-
-typedef struct {
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
- /* 0x4 */ u8 addrh;
- /* 0x5 */ u8 addrl;
- /* 0x6 */ u8 data[36];
- /* 0x2A */ u8 datacrc;
-} __OSVoiceRead36Format;
-
-typedef struct {
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
- /* 0x4 */ u8 addrh;
- /* 0x5 */ u8 addrl;
- /* 0x6 */ u8 data[4];
- /* 0xA */ u8 datacrc;
-} __OSVoiceWrite4Format;
-
-typedef struct {
- /* 0x0 */ u8 dummy;
- /* 0x1 */ u8 txsize;
- /* 0x2 */ u8 rxsize;
- /* 0x3 */ u8 cmd;
- /* 0x4 */ u8 addrh;
- /* 0x5 */ u8 addrl;
- /* 0x6 */ u8 data[20];
- /* 0x1A */ u8 datacrc;
-} __OSVoiceWrite20Format;
-
-typedef struct {
- /* 0x0 */ u8 txsize;
- /* 0x1 */ u8 rxsize;
- /* 0x2 */ u8 cmd;
- /* 0x3 */ u8 data;
- /* 0x4 */ u8 scrc;
- /* 0x5 */ u8 datacrc;
-} __OSVoiceSWriteFormat;
-
-#endif // CONTROLLER_VOICE_H
diff --git a/lib/ultralib/src/io/contsetch.c b/lib/ultralib/src/io/contsetch.c
index 0cababd..73a1ac1 100644
--- a/lib/ultralib/src/io/contsetch.c
+++ b/lib/ultralib/src/io/contsetch.c
@@ -1,7 +1,11 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
+/*
+ * This function specifies the number of devices for the functions to access when those functions access to multiple
+ * direct SI devices.
+ */
s32 osContSetCh(u8 ch) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/crc.c b/lib/ultralib/src/io/crc.c
index 3293b2d..bb6eb20 100644
--- a/lib/ultralib/src/io/crc.c
+++ b/lib/ultralib/src/io/crc.c
@@ -1,56 +1,154 @@
+/**
+ * File: crc.c
+ * Description: Functions to compute Cyclic Redundancy Check for specific addresses and data.
+ *
+ * CRC notes:
+ *
+ * General
+ * ===
+ * - CRC (Cyclic Redundancy Check) is a way of verifying that no errors were introduced in transmitted data.
+ * - It reads the entire message and generates a check number that is appended to it.
+ * - A CRC is specified by the length `n` of the check number and a number (called the generator) smaller than `1 << n`.
+ * - Different generators have different error-checking capabilities. The choice of a generator is a sophisticated
+ * mathematical problem.
+ *
+ * Mathematical basis
+ * ===
+ * - The algorithm is based on division of polynomials. The polynomials have coefficients in the field with two
+ * elements, 0 and 1, with addition given by XOR and multiplication by AND (it turns out this really is a field).
+ * Subtraction is the same as addition.
+ * - There is a one-to-one correspondence between binary polynomials and binary numbers: just evaluate the polynomial at
+ * 2, or write down an \f$ X^k \f$ corresponding to each `1 << k` the number is composed of.
+ * - The message bits `m{L}m{L-1}...m{1}m{0}` correspond to a polynomial \f$ m(X) = m_L X^L + m_{L-1} X^{L-1} + \dotsb +
+ * m_1 X^1 + m_0 X^0 \f$. We multiply this by \f$ X^n \f$ to make a space to insert the remainder at the end; this new
+ * polynomial will be the dividend.
+ * - The generator `p{n-1}p{n-2}...p{1}p{0}` corresponds to a polynomial \f$ p(X) = X^n + p_{n-1} X^{n-1} + \dotsb + p_1
+ * X^1 + p_0 X^0 \f$: the leading term is omitted in the binary description because it is always \f$ X^n \f$. The
+ * generator polynomial is the divisor.
+ * - The usual division algorithm is followed: we look along the dividend until we see a nonzero coefficient, then
+ * subtract an appropriate multiple of the divisor to cancel it out. We repeat this until we reach the end of the
+ * number.
+ * - Arithmetic in the field with two elements is particularly simple: subtraction is identical to addition, so also
+ * given by XOR, and the only multipliers required for subtracting the divisor are \f$ X^k \f$.
+ * - After applying the algorithm, the output is a polynomial \f$ R(X) \f$ so that we have
+ * \f[ m(X) X^n = Q(X) p(X) + R(X) \f]
+ * (\f$ R(X) \f$ is the *remainder after dividing by \f$ p(X) \f$*).
+ * - Therefore, \f$ m(X) X^n - R(X) \f$ is divisible by the generator polynomial. This means that if we append the
+ * binary number corresponding to \f$ R(X) \f$ to the message and rerun the algorithm, we will get 0 if no errors have
+ * been introduced.
+ *
+ *
+ * Implementation
+ * ===
+ * - We translate the binary polynomials to binary numbers by evaluating them at 2. The leading term in the generator
+ * polynomial is always \f$ X^n \f$, so we discard it to save space. In the binary field, subtraction is the same as
+ * addition, and given by XOR. Multiplication by \f$ X \f$ is given by shifting left.
+ * - Instead of fixing the message and moving the divisor polynomial right, we scan the message from the most
+ * significant digit, adding it to the end of the return value, (that is, for 1s, we shift and add 1, for 0s we just
+ * shift, effectively using the return value as a shift register).
+ * - When the return value has a 1 in the nth position (corresponding to the leading term in the generator polynomial),
+ * we binary-subtract (i.e. XOR) the return value with the generator polynomial's number.
+ * - This is repeated until we reach the end of the message.
+ * - Finally, to take into account the final multiplication by \f$ X^n \f$, we run another loop, which acts like we
+ * passed \f$ n \f$ more digits in the message that are all zero. Remember this gives us the extra space at the end for
+ * the check digits to be added.
+ *
+ *
+ * - To specify a CRC, at minimum we need the length of the check (i.e. the degree of the generator polynomial), \f$ n
+ * \f$, and the rest of the generator polynomial. This is usually expressed in the binary form, written as hex for
+ * compactness. Algorithms may also reverse or invert certain parts of the data or check to improve particular aspects
+ * of the algorithm, but the libultra functions use the simplest version.
+ *
+ *
+ * Resources
+ * ===
+ * - Wikipedia: [Cyclic redundancy check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check), and more specifically
+ * [Computation of cyclic redundancy checks](https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks)
+ * - Ben Eater has two videos on CRCs, the last two linked on [Error Detection | Ben Eater](https://eater.net/crc)
+ * - A page that specifically describes the same shift-register-style algorithms as libultra uses: [Understanding and
+ * implementing CRC (Cyclic Redundancy Check) calculation
+ * ](http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html)
+ */
#include "PR/os_internal.h"
#if BUILD_VERSION >= VERSION_J
+#define ADDRESS_CRC_MESSAGE_LENGTH 10
+#define ADDRESS_CRC_LENGTH 5
+#define ADDRESS_CRC_GENERATOR 0x15
+#define ADDRESS_CRC_MASK ((1 << ADDRESS_CRC_LENGTH) - 1)
+
+/**
+ * CRC-5 with the generating polynomial \f$ x^5 + x^4 + x^2 + 1 \f$, AKA 0x15 = 0b(1)1 0101.
+ * It only works on the bits from 0x7FF = 11 11111111, i.e. 10 bits.
+ *
+ * Usually used as __osContAddressCrc(addr) | (addr << 5) to add the CRC to the end. The overall length of 10 + 5 bits
+ * allows the address + CRC to fit into one s16.
+ *
+ * `addr` is the address of a block in the mempak, only valid up to 0x7FF.
+ */
u8 __osContAddressCrc(u16 addr) {
u32 temp = 0;
- u32 i = 0x400;
+ u32 i = (1 << ADDRESS_CRC_MESSAGE_LENGTH);
do {
+ // temp is used as a shift register for the CRC
temp <<= 1;
if ((u32)addr & i) {
- if (temp & 0x20) {
- temp ^= 0x14;
+ if (temp & (1 << ADDRESS_CRC_LENGTH)) {
+ // Same as temp++; temp ^= 0x15 since last bit always 0 after the shift
+ temp ^= ADDRESS_CRC_GENERATOR - 1;
} else {
++temp;
}
- } else if (temp & 0x20) {
- temp ^= 0x15;
+ } else if (temp & (1 << ADDRESS_CRC_LENGTH)) {
+ temp ^= ADDRESS_CRC_GENERATOR;
}
i >>= 1;
} while (i != 0);
- i = 5;
-
+ // Acts like 5 bits of 0s are appended to addr
+ i = ADDRESS_CRC_LENGTH;
do {
temp <<= 1;
- if (temp & 0x20) {
- temp ^= 0x15;
+ if (temp & (1 << ADDRESS_CRC_LENGTH)) {
+ temp ^= ADDRESS_CRC_GENERATOR;
}
} while (--i != 0);
- return temp & 0x1F;
+ // Discard the irrelevant bits above the actual remainder
+ return temp & ADDRESS_CRC_MASK;
}
+#define DATA_CRC_MESSAGE_BYTES 32
+#define DATA_CRC_LENGTH 8
+#define DATA_CRC_GENERATOR 0x85
+
+/**
+ * CRC-8 with generating polynomial \f$ x^8 + x^7 + x^2 + 1 \f$, AKA 0x85 = 0b(1) 1000 0101.
+ * Expects exactly 0x20 = 32 bytes of data.
+ */
u8 __osContDataCrc(u8* data) {
u32 temp = 0;
u32 i;
u32 j;
- for (i = 0x20; i; --i) {
- for (j = 0x80; j; j >>= 1) {
+ for (i = DATA_CRC_MESSAGE_BYTES; i; --i) {
+ // Loop over each bit in the byte starting with most significant
+ for (j = (1 << (DATA_CRC_LENGTH - 1)); j; j >>= 1) {
temp <<= 1;
if ((*data & j) != 0) {
- if ((temp & 0x100) != 0) {
- temp ^= 0x84;
+ if ((temp & (1 << DATA_CRC_LENGTH)) != 0) {
+ // Same as ret++; ret ^= 0x85 since last bit always 0 after the shift
+ temp ^= DATA_CRC_GENERATOR - 1;
} else {
++temp;
}
- } else if (temp & 0x100) {
- temp ^= 0x85;
+ } else if (temp & (1 << DATA_CRC_LENGTH)) {
+ temp ^= DATA_CRC_GENERATOR;
}
}
@@ -59,10 +157,10 @@ u8 __osContDataCrc(u8* data) {
do {
temp <<= 1;
- if (temp & 0x100) {
- temp ^= 0x85;
+ if (temp & (1 << DATA_CRC_LENGTH)) {
+ temp ^= DATA_CRC_GENERATOR;
}
- } while (++i < 8U);
+ } while (++i < DATA_CRC_LENGTH);
return temp;
}
diff --git a/lib/ultralib/src/io/devmgr.c b/lib/ultralib/src/io/devmgr.c
index 616dee5..70b26cc 100644
--- a/lib/ultralib/src/io/devmgr.c
+++ b/lib/ultralib/src/io/devmgr.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
void __osDevMgrMain(void* args) {
OSIoMesg* mb;
diff --git a/lib/ultralib/src/io/dpgetstat.c b/lib/ultralib/src/io/dpgetstat.c
index af3ccee..54dd3ac 100644
--- a/lib/ultralib/src/io/dpgetstat.c
+++ b/lib/ultralib/src/io/dpgetstat.c
@@ -4,6 +4,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 osDpGetStatus() {
+u32 osDpGetStatus(void) {
return IO_READ(DPC_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/dpsetnextbuf.c b/lib/ultralib/src/io/dpsetnextbuf.c
index 6314472..cbf3a6f 100644
--- a/lib/ultralib/src/io/dpsetnextbuf.c
+++ b/lib/ultralib/src/io/dpsetnextbuf.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/driverominit.c b/lib/ultralib/src/io/driverominit.c
index d73d349..d3e1bcf 100644
--- a/lib/ultralib/src/io/driverominit.c
+++ b/lib/ultralib/src/io/driverominit.c
@@ -1,10 +1,10 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
-OSPiHandle DriveRomHandle ALIGNED(8);
+OSPiHandle DriveRomHandle ALIGNED(0x8);
-OSPiHandle *osDriveRomInit() {
+OSPiHandle *osDriveRomInit(void) {
u32 saveMask;
if (DriveRomHandle.baseAddress == PHYS_TO_K1(PI_DOM1_ADDR1)) {
diff --git a/lib/ultralib/src/io/epidma.c b/lib/ultralib/src/io/epidma.c
index 06a9f69..77c6be6 100644
--- a/lib/ultralib/src/io/epidma.c
+++ b/lib/ultralib/src/io/epidma.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
diff --git a/lib/ultralib/src/io/epigettype.c b/lib/ultralib/src/io/epigettype.c
index c94012c..8487e68 100644
--- a/lib/ultralib/src/io/epigettype.c
+++ b/lib/ultralib/src/io/epigettype.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
s32 osEPiGetDeviceType(OSPiHandle* pihandle, OSPiInfo* info) {
info->type = pihandle->type;
diff --git a/lib/ultralib/src/io/epilinkhandle.c b/lib/ultralib/src/io/epilinkhandle.c
index 5f51854..2e9b1fa 100644
--- a/lib/ultralib/src/io/epilinkhandle.c
+++ b/lib/ultralib/src/io/epilinkhandle.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
s32 osEPiLinkHandle(OSPiHandle* EPiHandle) {
u32 saveMask = __osDisableInt();
diff --git a/lib/ultralib/src/io/epirawdma.c b/lib/ultralib/src/io/epirawdma.c
index 69a404d..b862353 100644
--- a/lib/ultralib/src/io/epirawdma.c
+++ b/lib/ultralib/src/io/epirawdma.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/epirawread.c b/lib/ultralib/src/io/epirawread.c
index 500a2ce..f6d446c 100644
--- a/lib/ultralib/src/io/epirawread.c
+++ b/lib/ultralib/src/io/epirawread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/epirawwrite.c b/lib/ultralib/src/io/epirawwrite.c
index 79fba31..9ab98a8 100644
--- a/lib/ultralib/src/io/epirawwrite.c
+++ b/lib/ultralib/src/io/epirawwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/epiread.c b/lib/ultralib/src/io/epiread.c
index 08cd0be..b2f346b 100644
--- a/lib/ultralib/src/io/epiread.c
+++ b/lib/ultralib/src/io/epiread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data) {
diff --git a/lib/ultralib/src/io/epiwrite.c b/lib/ultralib/src/io/epiwrite.c
index 42a239e..767caf5 100644
--- a/lib/ultralib/src/io/epiwrite.c
+++ b/lib/ultralib/src/io/epiwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data) {
diff --git a/lib/ultralib/src/io/gbpakcheckconnector.c b/lib/ultralib/src/io/gbpakcheckconnector.c
index 8eb3298..1d542bc 100644
--- a/lib/ultralib/src/io/gbpakcheckconnector.c
+++ b/lib/ultralib/src/io/gbpakcheckconnector.c
@@ -1,6 +1,6 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) {
s32 ret;
diff --git a/lib/ultralib/src/io/gbpakgetbank.c b/lib/ultralib/src/io/gbpakgetbank.c
index a2e5f38..e448688 100644
--- a/lib/ultralib/src/io/gbpakgetbank.c
+++ b/lib/ultralib/src/io/gbpakgetbank.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 __osGbpakGetBank(OSPfs* pfs, u8* bank) {
s32 ret;
diff --git a/lib/ultralib/src/io/gbpakgetstatus.c b/lib/ultralib/src/io/gbpakgetstatus.c
index d17d15c..76e7891 100644
--- a/lib/ultralib/src/io/gbpakgetstatus.c
+++ b/lib/ultralib/src/io/gbpakgetstatus.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osGbpakGetStatus(OSPfs* pfs, u8* status) {
s32 ret;
diff --git a/lib/ultralib/src/io/gbpakinit.c b/lib/ultralib/src/io/gbpakinit.c
index 102d962..e101c1e 100644
--- a/lib/ultralib/src/io/gbpakinit.c
+++ b/lib/ultralib/src/io/gbpakinit.c
@@ -1,10 +1,10 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "controller_gbpak.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/controller_gbpak.h"
OSTimer __osGbpakTimer;
-OSMesgQueue __osGbpakTimerQ ALIGNED(8);
+OSMesgQueue __osGbpakTimerQ ALIGNED(0x8);
OSMesg __osGbpakTimerMsg;
s32 osGbpakInit(OSMesgQueue* mq, OSPfs* pfs, int channel) {
diff --git a/lib/ultralib/src/io/gbpakpower.c b/lib/ultralib/src/io/gbpakpower.c
index 3d4a8f4..e2aa6f7 100644
--- a/lib/ultralib/src/io/gbpakpower.c
+++ b/lib/ultralib/src/io/gbpakpower.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "controller_gbpak.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/controller_gbpak.h"
s32 osGbpakPower(OSPfs* pfs, s32 flag) {
s32 i;
diff --git a/lib/ultralib/src/io/gbpakreadid.c b/lib/ultralib/src/io/gbpakreadid.c
index 3e2fa19..e88fc15 100644
--- a/lib/ultralib/src/io/gbpakreadid.c
+++ b/lib/ultralib/src/io/gbpakreadid.c
@@ -1,6 +1,6 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "os_version.h"
s32 osGbpakReadId(OSPfs* pfs, OSGbpakId* id, u8* status) {
diff --git a/lib/ultralib/src/io/gbpakreadwrite.c b/lib/ultralib/src/io/gbpakreadwrite.c
index a6d4b02..fe16ee2 100644
--- a/lib/ultralib/src/io/gbpakreadwrite.c
+++ b/lib/ultralib/src/io/gbpakreadwrite.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "os_version.h"
s32 __osGbpakSetBank(OSPfs* pfs, u8 bank);
diff --git a/lib/ultralib/src/io/gbpaksetbank.c b/lib/ultralib/src/io/gbpaksetbank.c
index 7a08646..efd2267 100644
--- a/lib/ultralib/src/io/gbpaksetbank.c
+++ b/lib/ultralib/src/io/gbpaksetbank.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 __osGbpakSetBank(OSPfs* pfs, u8 bank) {
int i;
diff --git a/lib/ultralib/src/io/leodiskinit.c b/lib/ultralib/src/io/leodiskinit.c
index e9f140b..cd74e77 100644
--- a/lib/ultralib/src/io/leodiskinit.c
+++ b/lib/ultralib/src/io/leodiskinit.c
@@ -2,12 +2,12 @@
#include "PR/os_internal.h"
#include "PR/os_libc.h"
#include "PR/rcp.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
-OSPiHandle LeoDiskHandle ALIGNED(8);
+OSPiHandle LeoDiskHandle ALIGNED(0x8);
OSPiHandle *__osDiskHandle;
-OSPiHandle *osLeoDiskInit() {
+OSPiHandle *osLeoDiskInit(void) {
u32 saveMask;
LeoDiskHandle.type = DEVICE_TYPE_64DD;
diff --git a/lib/ultralib/src/io/leointerrupt.c b/lib/ultralib/src/io/leointerrupt.c
index ad34e45..a94146e 100644
--- a/lib/ultralib/src/io/leointerrupt.c
+++ b/lib/ultralib/src/io/leointerrupt.c
@@ -1,17 +1,17 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
-#include "piint.h"
-#include "macros.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/piint.h"
+#include "PRinternal/macros.h"
extern OSPiHandle *__osDiskHandle;
-u8 leoDiskStack[OS_PIM_STACKSIZE] ALIGNED(16);
+u8 leoDiskStack[OS_PIM_STACKSIZE] ALIGNED(0x10);
static void __osLeoAbnormalResume(void);
static void __osLeoResume(void);
-s32 __osLeoInterrupt() {
+s32 __osLeoInterrupt(void) {
u32 stat = 0;
volatile u32 pi_stat;
u32 bm_stat;
diff --git a/lib/ultralib/src/io/motor.c b/lib/ultralib/src/io/motor.c
index 8028d69..b859aaf 100644
--- a/lib/ultralib/src/io/motor.c
+++ b/lib/ultralib/src/io/motor.c
@@ -1,11 +1,11 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/os_version.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#if BUILD_VERSION >= VERSION_J
-static OSPifRam __MotorDataBuf[MAXCONTROLLERS] ALIGNED(8);
+static OSPifRam __MotorDataBuf[MAXCONTROLLERS];
#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr))
@@ -134,10 +134,10 @@ s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, int channel) {
#else
-OSPifRam _MotorStopData[MAXCONTROLLERS] ALIGNED(8);
-OSPifRam _MotorStartData[MAXCONTROLLERS] ALIGNED(8);
-u8 _motorstopbuf[32] ALIGNED(8);
-u8 _motorstartbuf[32] ALIGNED(8);
+OSPifRam _MotorStopData[MAXCONTROLLERS] ALIGNED(0x8);
+OSPifRam _MotorStartData[MAXCONTROLLERS] ALIGNED(0x8);
+u8 _motorstopbuf[32] ALIGNED(0x8);
+u8 _motorstartbuf[32] ALIGNED(0x8);
u32 __osMotorinitialized[MAXCONTROLLERS] = {0, 0, 0, 0};
s32 osMotorStop(OSPfs *pfs) {
diff --git a/lib/ultralib/src/io/pfsallocatefile.c b/lib/ultralib/src/io/pfsallocatefile.c
index 24f6fe7..c31396e 100644
--- a/lib/ultralib/src/io/pfsallocatefile.c
+++ b/lib/ultralib/src/io/pfsallocatefile.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "PR/rmon.h"
#define ROUND_UP_DIVIDE(numerator, denominator) (((numerator) + (denominator)-1) / (denominator))
@@ -240,7 +241,7 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name
backup_inode.inode_page[old_last_page].inode_t.bank = bank;
backup_inode.inode_page[old_last_page].inode_t.page = start_page;
- ERRCK(__osPfsRWInode(pfs, &backup_inode, OS_WRITE, old_bank));
+ ERRCK(__osPfsRWInode(pfs, &backup_inode, PFS_WRITE, old_bank));
dir.start_page = fpage;
dir.company_code = company_code;
diff --git a/lib/ultralib/src/io/pfschecker.c b/lib/ultralib/src/io/pfschecker.c
index b736200..77b691a 100644
--- a/lib/ultralib/src/io/pfschecker.c
+++ b/lib/ultralib/src/io/pfschecker.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 corrupted_init(OSPfs* pfs, __OSInodeCache* cache);
s32 corrupted(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache);
@@ -55,7 +56,7 @@ s32 osPfsChecker(OSPfs* pfs) {
bank = next_page.inode_t.bank;
if (oldbank != bank) {
- ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
oldbank = bank;
}
@@ -90,7 +91,7 @@ s32 osPfsChecker(OSPfs* pfs) {
while (CHECK_IPAGE(next_page)) {
if (bank != next_page.inode_t.bank) {
bank = next_page.inode_t.bank;
- ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
}
@@ -142,7 +143,7 @@ s32 osPfsChecker(OSPfs* pfs) {
}
for (bank = 0; bank < pfs->banks; bank++) {
- ret = __osPfsRWInode(pfs, &tmp_inode, 0, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
@@ -164,7 +165,7 @@ s32 osPfsChecker(OSPfs* pfs) {
file_next_node[j] = checked_inode.inode_page[pp] = tmp_inode.inode_page[pp];
}
}
- ERRCK(__osPfsRWInode(pfs, &checked_inode, OS_WRITE, bank));
+ ERRCK(__osPfsRWInode(pfs, &checked_inode, PFS_WRITE, bank));
}
if (fixed) {
@@ -193,7 +194,7 @@ s32 corrupted_init(OSPfs* pfs, __OSInodeCache* cache) {
for (bank = 0; bank < pfs->banks; bank++) {
offset = bank > 0 ? 1 : pfs->inode_start_page;
- ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
@@ -234,7 +235,7 @@ s32 corrupted(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache) {
if (bank == fpage.inode_t.bank || cache->map[n] & (1 << (bank % PFS_BANK_LAPPED_BY))) {
if (bank != cache->bank) {
- ret = __osPfsRWInode(pfs, &cache->inode, 0, bank);
+ ret = __osPfsRWInode(pfs, &cache->inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
diff --git a/lib/ultralib/src/io/pfsdeletefile.c b/lib/ultralib/src/io/pfsdeletefile.c
index e013211..c8cc537 100644
--- a/lib/ultralib/src/io/pfsdeletefile.c
+++ b/lib/ultralib/src/io/pfsdeletefile.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name) {
s32 file_no;
@@ -38,13 +39,13 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name,
startpage = dir.start_page.inode_t.page;
for (bank = dir.start_page.inode_t.bank; bank < pfs->banks;) {
- ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank));
#if BUILD_VERSION >= VERSION_J
ERRCK(__osPfsReleasePages(pfs, &inode, startpage, bank, &last_page));
#else
ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, TRUE));
#endif
- ERRCK(__osPfsRWInode(pfs, &inode, OS_WRITE, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_WRITE, bank));
if (last_page.ipage == PFS_EOF) {
break;
diff --git a/lib/ultralib/src/io/pfsfilestate.c b/lib/ultralib/src/io/pfsfilestate.c
index 4f80020..78b9f4a 100644
--- a/lib/ultralib/src/io/pfsfilestate.c
+++ b/lib/ultralib/src/io/pfsfilestate.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) {
s32 ret;
@@ -72,7 +73,7 @@ s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) {
bank = dir.start_page.inode_t.bank;
while (bank < pfs->banks) {
- ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank));
next_page = inode.inode_page[start_page];
pages++;
diff --git a/lib/ultralib/src/io/pfsfreeblocks.c b/lib/ultralib/src/io/pfsfreeblocks.c
index 68a54c6..78c07c8 100644
--- a/lib/ultralib/src/io/pfsfreeblocks.c
+++ b/lib/ultralib/src/io/pfsfreeblocks.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) {
int j;
@@ -16,7 +17,7 @@ s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) {
PFS_CHECK_ID();
#endif
for (bank = 0; bank < pfs->banks; bank++) {
- ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank));
offset = ((bank > 0) ? 1 : pfs->inode_start_page);
for (j = offset; j < ARRLEN(inode.inode_page); j++) {
diff --git a/lib/ultralib/src/io/pfsgetlabel.c b/lib/ultralib/src/io/pfsgetlabel.c
index 0e4de49..adb1dcc 100644
--- a/lib/ultralib/src/io/pfsgetlabel.c
+++ b/lib/ultralib/src/io/pfsgetlabel.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsGetLabel(OSPfs* pfs, u8* label, int* len) {
int i;
diff --git a/lib/ultralib/src/io/pfsgetstatus.c b/lib/ultralib/src/io/pfsgetstatus.c
index 955412b..fa736e3 100644
--- a/lib/ultralib/src/io/pfsgetstatus.c
+++ b/lib/ultralib/src/io/pfsgetstatus.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#if BUILD_VERSION >= VERSION_J
void __osPfsRequestOneChannel(int channel, u8 cmd);
diff --git a/lib/ultralib/src/io/pfsinit.c b/lib/ultralib/src/io/pfsinit.c
index 5633c78..581cefc 100644
--- a/lib/ultralib/src/io/pfsinit.c
+++ b/lib/ultralib/src/io/pfsinit.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 osPfsInit(OSMesgQueue* queue, OSPfs* pfs, int channel) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/pfsinitpak.c b/lib/ultralib/src/io/pfsinitpak.c
index d3fde1f..65f2684 100644
--- a/lib/ultralib/src/io/pfsinitpak.c
+++ b/lib/ultralib/src/io/pfsinitpak.c
@@ -1,6 +1,7 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#if BUILD_VERSION >= VERSION_J
static s32 __osPfsCheckRamArea(OSPfs* pfs);
diff --git a/lib/ultralib/src/io/pfsisplug.c b/lib/ultralib/src/io/pfsisplug.c
index 9607907..0104030 100644
--- a/lib/ultralib/src/io/pfsisplug.c
+++ b/lib/ultralib/src/io/pfsisplug.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
-OSPifRam __osPfsPifRam ALIGNED(16);
+OSPifRam __osPfsPifRam;
s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/pfsnumfiles.c b/lib/ultralib/src/io/pfsnumfiles.c
index 7fa352e..d0af53b 100644
--- a/lib/ultralib/src/io/pfsnumfiles.c
+++ b/lib/ultralib/src/io/pfsnumfiles.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsNumFiles(OSPfs* pfs, s32* max_files, s32* files_used) {
int j;
diff --git a/lib/ultralib/src/io/pfsreadwritefile.c b/lib/ultralib/src/io/pfsreadwritefile.c
index 17afe54..ec35da3 100644
--- a/lib/ultralib/src/io/pfsreadwritefile.c
+++ b/lib/ultralib/src/io/pfsreadwritefile.c
@@ -1,20 +1,23 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
+
+#define CHECK_IPAGE(p) \
+ (((p).ipage >= pfs->inode_start_page) && ((p).inode_t.bank < pfs->banks) && ((p).inode_t.page >= 0x01) && \
+ ((p).inode_t.page < 0x80))
static s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page) {
s32 ret;
if (page->inode_t.bank != *bank) {
*bank = page->inode_t.bank;
- ERRCK(__osPfsRWInode(pfs, inode, 0, *bank));
+ ERRCK(__osPfsRWInode(pfs, inode, PFS_READ, *bank));
}
*page = inode->inode_page[page->inode_t.page];
- if (page->ipage < pfs->inode_start_page || page->inode_t.bank >= pfs->banks || page->inode_t.page <= 0 ||
- page->inode_t.page >= ARRLEN(inode->inode_page)) {
-
- if (page->ipage == 1) {
+ if (!CHECK_IPAGE(*page)) {
+ if (page->ipage == PFS_EOF) {
return PFS_ERR_INVALID;
}
@@ -54,9 +57,8 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in
return PFS_ERR_INVALID;
}
- if (dir.start_page.ipage < pfs->inode_start_page || dir.start_page.inode_t.bank >= pfs->banks ||
- dir.start_page.inode_t.page <= 0 || dir.start_page.inode_t.page >= ARRLEN(inode.inode_page)) {
- if ((dir.start_page.ipage == 1)) {
+ if (!CHECK_IPAGE(dir.start_page)) {
+ if ((dir.start_page.ipage == PFS_EOF)) {
return PFS_ERR_INVALID;
}
diff --git a/lib/ultralib/src/io/pfsreformat.c b/lib/ultralib/src/io/pfsreformat.c
index 687b456..e1768cf 100644
--- a/lib/ultralib/src/io/pfsreformat.c
+++ b/lib/ultralib/src/io/pfsreformat.c
@@ -1,6 +1,7 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 osPfsReFormat(OSPfs* pfs, OSMesgQueue* queue, int channel) {
int j;
diff --git a/lib/ultralib/src/io/pfsrepairid.c b/lib/ultralib/src/io/pfsrepairid.c
index 348f8b2..4ad6b0a 100644
--- a/lib/ultralib/src/io/pfsrepairid.c
+++ b/lib/ultralib/src/io/pfsrepairid.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#if BUILD_VERSION >= VERSION_J
diff --git a/lib/ultralib/src/io/pfssearchfile.c b/lib/ultralib/src/io/pfssearchfile.c
index 4fa3c57..ff76d16 100644
--- a/lib/ultralib/src/io/pfssearchfile.c
+++ b/lib/ultralib/src/io/pfssearchfile.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsFindFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, s32* file_no) {
s32 j;
diff --git a/lib/ultralib/src/io/pfsselectbank.c b/lib/ultralib/src/io/pfsselectbank.c
index 7e33b2d..70a8886 100644
--- a/lib/ultralib/src/io/pfsselectbank.c
+++ b/lib/ultralib/src/io/pfsselectbank.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#if BUILD_VERSION >= VERSION_J
s32 __osPfsSelectBank(OSPfs* pfs, u8 bank) {
diff --git a/lib/ultralib/src/io/pfssetlabel.c b/lib/ultralib/src/io/pfssetlabel.c
index 43308c7..ab6c6ea 100644
--- a/lib/ultralib/src/io/pfssetlabel.c
+++ b/lib/ultralib/src/io/pfssetlabel.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsSetLabel(OSPfs* pfs, u8* label) {
int i;
diff --git a/lib/ultralib/src/io/pi.c b/lib/ultralib/src/io/pi.c
index 3e67ddb..f2cc4b9 100644
--- a/lib/ultralib/src/io/pi.c
+++ b/lib/ultralib/src/io/pi.c
@@ -1,11 +1,11 @@
#include "PR/os_internal.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-int __osPiDeviceBusy() {
+int __osPiDeviceBusy(void) {
register u32 stat = IO_READ(PI_STATUS_REG);
if (stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
return TRUE;
diff --git a/lib/ultralib/src/io/piacs.c b/lib/ultralib/src/io/piacs.c
index c95147f..78974dd 100644
--- a/lib/ultralib/src/io/piacs.c
+++ b/lib/ultralib/src/io/piacs.c
@@ -1,10 +1,10 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#define PI_Q_BUF_LEN 1
u32 __osPiAccessQueueEnabled = 0;
static OSMesg piAccessBuf[PI_Q_BUF_LEN];
-OSMesgQueue __osPiAccessQueue ALIGNED(8);
+OSMesgQueue __osPiAccessQueue ALIGNED(0x8);
void __osPiCreateAccessQueue(void) {
__osPiAccessQueueEnabled = 1;
diff --git a/lib/ultralib/src/io/pidma.c b/lib/ultralib/src/io/pidma.c
index 0584e12..2464a6d 100644
--- a/lib/ultralib/src/io/pidma.c
+++ b/lib/ultralib/src/io/pidma.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
s32 osPiStartDma(OSIoMesg* mb, s32 priority, s32 direction, u32 devAddr, void* dramAddr, u32 size, OSMesgQueue* mq) {
register s32 ret;
diff --git a/lib/ultralib/src/io/pigetcmdq.c b/lib/ultralib/src/io/pigetcmdq.c
index 4724301..a4919d5 100644
--- a/lib/ultralib/src/io/pigetcmdq.c
+++ b/lib/ultralib/src/io/pigetcmdq.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
OSMesgQueue* osPiGetCmdQueue(void) {
if (!__osPiDevMgr.active) {
diff --git a/lib/ultralib/src/io/pigetstat.c b/lib/ultralib/src/io/pigetstat.c
index 43e9a27..a5ba497 100644
--- a/lib/ultralib/src/io/pigetstat.c
+++ b/lib/ultralib/src/io/pigetstat.c
@@ -1,9 +1,9 @@
#include "PR/os_internal.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 osPiGetStatus() {
+u32 osPiGetStatus(void) {
return IO_READ(PI_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/pigettype.c b/lib/ultralib/src/io/pigettype.c
index f918306..67fdc72 100644
--- a/lib/ultralib/src/io/pigettype.c
+++ b/lib/ultralib/src/io/pigettype.c
@@ -3,6 +3,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-s32 osPiGetDeviceType() {
+s32 osPiGetDeviceType(void) {
return osRomType;
}
diff --git a/lib/ultralib/src/io/piint.h b/lib/ultralib/src/io/piint.h
deleted file mode 100644
index 50a0858..0000000
--- a/lib/ultralib/src/io/piint.h
+++ /dev/null
@@ -1,197 +0,0 @@
-#ifndef _PIINT_H_
-#define _PIINT_H_
-
-#include "PR/os_internal.h"
-#include "PR/rcp.h"
-
-//https://github.com/LuigiBlood/64dd/wiki/Memory-Map
-
-#define LEO_BASE_REG 0x05000000
-
-#define LEO_CMD (LEO_BASE_REG + 0x508)
-#define LEO_STATUS (LEO_BASE_REG + 0x508)
-
-#define LEO_BM_CTL (LEO_BASE_REG + 0x510)
-#define LEO_BM_STATUS (LEO_BASE_REG + 0x510)
-
-#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518)
-#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518)
-
-#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) //C2 Sector Buffer
-#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) //Data Sector Buffer
-#define LEO_DATA (LEO_BASE_REG + 0x500) //Data
-#define LEO_MISC_REG (LEO_BASE_REG + 0x504) //Misc Register
-#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) //Current Track
-#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) //Sector Error Status
-#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) //Current Sector
-#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) //Hard Reset
-#define LEO_C1_S0 (LEO_BASE_REG + 0x524) //C1
-#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) //Sector Size (in bytes)
-#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) //C1
-#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) //Sectors per Block, Full Size
-#define LEO_C1_S4 (LEO_BASE_REG + 0x534) //C1
-#define LEO_C1_S6 (LEO_BASE_REG + 0x538) //C1
-#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) //Current Address?
-#define LEO_ID_REG (LEO_BASE_REG + 0x540) //ID
-#define LEO_TEST_REG (LEO_BASE_REG + 0x544) //Test Read
-#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) //Test Write
-#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) //Microsequencer RAM
-
-#define LEO_STATUS_PRESENCE_MASK 0xFFFF
-
-#define LEO_STATUS_DATA_REQUEST 0x40000000
-#define LEO_STATUS_C2_TRANSFER 0x10000000
-#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000
-#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000
-#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000
-#define LEO_STATUS_DISK_PRESENT 0x01000000
-#define LEO_STATUS_BUSY_STATE 0x00800000
-#define LEO_STATUS_RESET_STATE 0x00400000
-#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000
-#define LEO_STATUS_HEAD_RETRACTED 0x00080000
-#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000
-#define LEO_STATUS_MECHANIC_ERROR 0x00020000
-#define LEO_STATUS_DISK_CHANGE 0x00010000
-
-#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED)
-#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED)
-#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED)
-#define LEO_STATUS_MODE_ACTIVE 0
-
-#define LEO_CUR_TK_INDEX_LOCK 0x60000000
-
-#define LEO_BM_STATUS_RUNNING 0x80000000 //Running
-#define LEO_BM_STATUS_ERROR 0x04000000 //Error
-#define LEO_BM_STATUS_MICRO 0x02000000 //Micro Status?
-#define LEO_BM_STATUS_BLOCK 0x01000000 //Block Transfer
-#define LEO_BM_STATUS_C1CORRECTION 0x00800000 //C1 Correction
-#define LEO_BM_STATUS_C1DOUBLE 0x00400000 //C1 Double
-#define LEO_BM_STATUS_C1SINGLE 0x00200000 //C1 Single
-#define LEO_BM_STATUS_C1ERROR 0x00010000 //C1 Error
-
-#define LEO_BM_CTL_START 0x80000000 //Start Buffer Manager
-#define LEO_BM_CTL_MODE 0x40000000 //Buffer Manager Mode
-#define LEO_BM_CTL_IMASK 0x20000000 //BM Interrupt Mask
-#define LEO_BM_CTL_RESET 0x10000000 //Buffer Manager Reset
-#define LEO_BM_CTL_DISABLE_OR 0x08000000 //Disable OR Check?
-#define LEO_BM_CTL_DISABLE_C1 0x04000000 //Disable C1 Correction
-#define LEO_BM_CTL_BLOCK 0x02000000 //Block Transfer
-#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 //Mechanic Interrupt Reset
-
-#define LEO_BM_CTL_CONTROL_MASK 0xFF000000
-#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000
-#define LEO_BM_CTL_SECTOR_SHIFT 16
-
-#define LEO_CMD_TYPE_0 0 //TODO: name
-#define LEO_CMD_TYPE_1 1 //TODO: name
-#define LEO_CMD_TYPE_2 2 //TODO: name
-
-#define LEO_ERROR_GOOD 0
-#define LEO_ERROR_4 4 //maybe busy?
-#define LEO_ERROR_22 22 //
-#define LEO_ERROR_23 23 //unrecovered read error?
-#define LEO_ERROR_24 24 //no reference position found?
-#define LEO_ERROR_29 29 //
-
-extern OSDevMgr __osPiDevMgr;
-extern OSPiHandle *__osCurrentHandle[];
-extern OSPiHandle CartRomHandle;
-extern OSPiHandle LeoDiskHandle;
-extern OSMesgQueue __osPiAccessQueue;
-extern u32 __osPiAccessQueueEnabled;
-
-// These symbols were all renamed in 2.0J.
-#if BUILD_VERSION < VERSION_J
-#define __osEPiRawStartDma osEPiRawStartDma
-#define __osEPiRawReadIo osEPiRawReadIo
-#define __osEPiRawWriteIo osEPiRawWriteIo
-#define __osPiRawStartDma osPiRawStartDma
-#define __osPiRawWriteIo osPiRawWriteIo
-#define __osPiRawReadIo osPiRawReadIo
-#endif
-
-int __osPiDeviceBusy(void);
-void __osDevMgrMain(void *);
-void __osPiCreateAccessQueue(void);
-void __osPiRelAccess(void);
-void __osPiGetAccess(void);
-s32 __osPiRawStartDma(s32, u32 , void *, u32 );
-s32 __osPiRawWriteIo(u32, u32);
-s32 __osPiRawReadIo(u32, u32 *);
-s32 __osEPiRawWriteIo(OSPiHandle *, u32 , u32);
-s32 __osEPiRawReadIo(OSPiHandle *, u32 , u32 *);
-s32 __osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 );
-OSMesgQueue *osPiGetCmdQueue(void);
-
-#define WAIT_ON_IOBUSY(stat) \
- { \
- stat = IO_READ(PI_STATUS_REG); \
- while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \
- stat = IO_READ(PI_STATUS_REG); \
- } (void)0
-
-#define UPDATE_REG(pihandle, reg, var) \
- if (cHandle->var != pihandle->var) \
- IO_WRITE(reg, pihandle->var)
-
-#if BUILD_VERSION >= VERSION_J
-
-#define EPI_SYNC(pihandle, stat, domain) \
- \
- WAIT_ON_IOBUSY(stat); \
- \
- domain = pihandle->domain; \
- if (__osCurrentHandle[domain]->type != pihandle->type) \
- { \
- OSPiHandle *cHandle = __osCurrentHandle[domain]; \
- if (domain == PI_DOMAIN1) \
- { \
- UPDATE_REG(pihandle, PI_BSD_DOM1_LAT_REG, latency); \
- UPDATE_REG(pihandle, PI_BSD_DOM1_PGS_REG, pageSize); \
- UPDATE_REG(pihandle, PI_BSD_DOM1_RLS_REG, relDuration); \
- UPDATE_REG(pihandle, PI_BSD_DOM1_PWD_REG, pulse); \
- } \
- else \
- { \
- UPDATE_REG(pihandle, PI_BSD_DOM2_LAT_REG, latency); \
- UPDATE_REG(pihandle, PI_BSD_DOM2_PGS_REG, pageSize); \
- UPDATE_REG(pihandle, PI_BSD_DOM2_RLS_REG, relDuration); \
- UPDATE_REG(pihandle, PI_BSD_DOM2_PWD_REG, pulse); \
- } \
- cHandle->type = pihandle->type; \
- cHandle->latency = pihandle->latency; \
- cHandle->pageSize = pihandle->pageSize; \
- cHandle->relDuration = pihandle->relDuration; \
- cHandle->pulse = pihandle->pulse; \
- }(void)0
-
-#else
-
-#define EPI_SYNC(pihandle, stat, domain) \
- \
- WAIT_ON_IOBUSY(stat); \
- \
- domain = pihandle->domain; \
- if (__osCurrentHandle[domain] != pihandle) \
- { \
- OSPiHandle *cHandle = __osCurrentHandle[domain]; \
- if (domain == PI_DOMAIN1) \
- { \
- UPDATE_REG(pihandle, PI_BSD_DOM1_LAT_REG, latency); \
- UPDATE_REG(pihandle, PI_BSD_DOM1_PGS_REG, pageSize); \
- UPDATE_REG(pihandle, PI_BSD_DOM1_RLS_REG, relDuration); \
- UPDATE_REG(pihandle, PI_BSD_DOM1_PWD_REG, pulse); \
- } \
- else \
- { \
- UPDATE_REG(pihandle, PI_BSD_DOM2_LAT_REG, latency); \
- UPDATE_REG(pihandle, PI_BSD_DOM2_PGS_REG, pageSize); \
- UPDATE_REG(pihandle, PI_BSD_DOM2_RLS_REG, relDuration); \
- UPDATE_REG(pihandle, PI_BSD_DOM2_PWD_REG, pulse); \
- } \
- __osCurrentHandle[domain] = pihandle; \
- }(void)0
-
-#endif
-
-#endif
diff --git a/lib/ultralib/src/io/pimgr.c b/lib/ultralib/src/io/pimgr.c
index d98c6ad..e2c2bad 100644
--- a/lib/ultralib/src/io/pimgr.c
+++ b/lib/ultralib/src/io/pimgr.c
@@ -1,35 +1,35 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/rdb.h"
-static OSThread piThread ALIGNED(8);
-static char piThreadStack[OS_PIM_STACKSIZE] ALIGNED(16);
+static OSThread piThread ALIGNED(0x8);
+static STACK(piThreadStack, OS_PIM_STACKSIZE) ALIGNED(0x10);
#ifndef _FINALROM
-static OSThread ramromThread ALIGNED(8);
-static char ramromThreadStack[1024] ALIGNED(16);
-static OSMesgQueue getRamromQ ALIGNED(8);
+static OSThread ramromThread ALIGNED(0x8);
+static STACK(ramromThreadStack, 0x400) ALIGNED(0x10);
+static OSMesgQueue getRamromQ ALIGNED(0x8);
static OSMesg getRamromBuf[1];
-static OSMesgQueue freeRamromQ ALIGNED(8);
+static OSMesgQueue freeRamromQ ALIGNED(0x8);
static OSMesg freeRamromBuf[1];
static void ramromMain(void*);
#endif
-static OSMesgQueue piEventQueue ALIGNED(8);
+static OSMesgQueue piEventQueue ALIGNED(0x8);
static OSMesg piEventBuf[1];
OSDevMgr __osPiDevMgr = { 0 };
OSPiHandle* __osPiTable = NULL;
#if BUILD_VERSION >= VERSION_J
-OSPiHandle __Dom1SpeedParam ALIGNED(8);
-OSPiHandle __Dom2SpeedParam ALIGNED(8);
-OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &__Dom1SpeedParam, &__Dom2SpeedParam };
+OSPiHandle __Dom1SpeedParam ALIGNED(0x8);
+OSPiHandle __Dom2SpeedParam ALIGNED(0x8);
+OSPiHandle* __osCurrentHandle[2] ALIGNED(0x8) = { &__Dom1SpeedParam, &__Dom2SpeedParam };
#else
extern OSPiHandle CartRomHandle;
extern OSPiHandle LeoDiskHandle;
-OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &CartRomHandle, &LeoDiskHandle };
+OSPiHandle* __osCurrentHandle[2] ALIGNED(0x8) = { &CartRomHandle, &LeoDiskHandle };
#endif
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) {
@@ -71,11 +71,11 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC
__osPiDevMgr.acsQueue = &__osPiAccessQueue;
__osPiDevMgr.dma = __osPiRawStartDma;
__osPiDevMgr.edma = __osEPiRawStartDma;
- osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, &piThreadStack[OS_PIM_STACKSIZE], pri);
+ osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, STACK_START(piThreadStack), pri);
osStartThread(&piThread);
#ifndef _FINALROM
- osCreateThread(&ramromThread, 0, ramromMain, NULL, ramromThreadStack + 1024, (OSPri)pri - 1);
+ osCreateThread(&ramromThread, 0, ramromMain, NULL, STACK_START(ramromThreadStack), (OSPri)pri - 1);
osStartThread(&ramromThread);
#endif
__osRestoreInt(savedMask);
diff --git a/lib/ultralib/src/io/pirawdma.c b/lib/ultralib/src/io/pirawdma.c
index d5ea8c3..db77829 100644
--- a/lib/ultralib/src/io/pirawdma.c
+++ b/lib/ultralib/src/io/pirawdma.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/pirawread.c b/lib/ultralib/src/io/pirawread.c
index 95d7082..0040bb3 100644
--- a/lib/ultralib/src/io/pirawread.c
+++ b/lib/ultralib/src/io/pirawread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "assert.h"
#include "PR/ultraerror.h"
diff --git a/lib/ultralib/src/io/pirawwrite.c b/lib/ultralib/src/io/pirawwrite.c
index 92eba84..190f682 100644
--- a/lib/ultralib/src/io/pirawwrite.c
+++ b/lib/ultralib/src/io/pirawwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/piread.c b/lib/ultralib/src/io/piread.c
index 42bcf3e..7550307 100644
--- a/lib/ultralib/src/io/piread.c
+++ b/lib/ultralib/src/io/piread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osPiReadIo(u32 devAddr, u32* data) {
diff --git a/lib/ultralib/src/io/piwrite.c b/lib/ultralib/src/io/piwrite.c
index 75c00d1..7fe514f 100644
--- a/lib/ultralib/src/io/piwrite.c
+++ b/lib/ultralib/src/io/piwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osPiWriteIo(u32 devAddr, u32 data) {
diff --git a/lib/ultralib/src/io/si.c b/lib/ultralib/src/io/si.c
index 0188927..78794f5 100644
--- a/lib/ultralib/src/io/si.c
+++ b/lib/ultralib/src/io/si.c
@@ -1,10 +1,10 @@
#include "PR/os_internal.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-int __osSiDeviceBusy() {
+int __osSiDeviceBusy(void) {
register u32 stat = IO_READ(SI_STATUS_REG);
if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
diff --git a/lib/ultralib/src/io/siacs.c b/lib/ultralib/src/io/siacs.c
index 8ef5b3f..7ff12f1 100644
--- a/lib/ultralib/src/io/siacs.c
+++ b/lib/ultralib/src/io/siacs.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#define SI_Q_BUF_LEN 1
-static OSMesg siAccessBuf[SI_Q_BUF_LEN] ALIGNED(8);
-OSMesgQueue __osSiAccessQueue ALIGNED(8);
+static OSMesg siAccessBuf[SI_Q_BUF_LEN] ALIGNED(0x8);
+OSMesgQueue __osSiAccessQueue ALIGNED(0x8);
u32 __osSiAccessQueueEnabled = 0;
void __osSiCreateAccessQueue(void) {
diff --git a/lib/ultralib/src/io/sigetstat.c b/lib/ultralib/src/io/sigetstat.c
index 0225445..e21e50a 100644
--- a/lib/ultralib/src/io/sigetstat.c
+++ b/lib/ultralib/src/io/sigetstat.c
@@ -1,9 +1,9 @@
#include "PR/os_internal.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 __osSiGetStatus() {
+u32 __osSiGetStatus(void) {
return IO_READ(SI_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/siint.h b/lib/ultralib/src/io/siint.h
deleted file mode 100644
index 636a87f..0000000
--- a/lib/ultralib/src/io/siint.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _SIINT_H
-#define _SIINT_H
-
-#include "PR/os_internal.h"
-#include "PR/rcp.h"
-
-extern s32 __osEepromRead16K;
-extern u8 __osPfsInodeCacheBank;
-
-void __osSiGetAccess(void);
-void __osSiRelAccess(void);
-int __osSiDeviceBusy(void);
-void __osSiCreateAccessQueue(void);
-
-#endif
diff --git a/lib/ultralib/src/io/sirawdma.c b/lib/ultralib/src/io/sirawdma.c
index 5fb5f8a..ea2c228 100644
--- a/lib/ultralib/src/io/sirawdma.c
+++ b/lib/ultralib/src/io/sirawdma.c
@@ -1,8 +1,6 @@
#include "PR/os_internal.h"
#include "assert.h"
-#include "siint.h"
-
-
+#include "PRinternal/siint.h"
@@ -46,9 +44,11 @@
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
-#line 49
+#line 47
#endif
+#define PIF_RAM_SIZE (PIF_RAM_END + 1 - PIF_RAM_START)
+
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
@@ -66,7 +66,7 @@ s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
#endif
if (direction == OS_WRITE) {
- osWritebackDCache(dramAddr, 64);
+ osWritebackDCache(dramAddr, PIF_RAM_SIZE);
}
IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
@@ -78,7 +78,7 @@ s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
}
if (direction == OS_READ) {
- osInvalDCache(dramAddr, 64);
+ osInvalDCache(dramAddr, PIF_RAM_SIZE);
}
return 0;
diff --git a/lib/ultralib/src/io/sirawread.c b/lib/ultralib/src/io/sirawread.c
index 4ce8330..c182ff0 100644
--- a/lib/ultralib/src/io/sirawread.c
+++ b/lib/ultralib/src/io/sirawread.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "assert.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
diff --git a/lib/ultralib/src/io/sirawwrite.c b/lib/ultralib/src/io/sirawwrite.c
index 795d38a..ece13a5 100644
--- a/lib/ultralib/src/io/sirawwrite.c
+++ b/lib/ultralib/src/io/sirawwrite.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sp.c b/lib/ultralib/src/io/sp.c
index 3ad9076..98e7c40 100644
--- a/lib/ultralib/src/io/sp.c
+++ b/lib/ultralib/src/io/sp.c
@@ -1,12 +1,12 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-int __osSpDeviceBusy() {
+int __osSpDeviceBusy(void) {
register u32 stat = IO_READ(SP_STATUS_REG);
if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) {
diff --git a/lib/ultralib/src/io/spgetstat.c b/lib/ultralib/src/io/spgetstat.c
index 0cdfda6..8125b64 100644
--- a/lib/ultralib/src/io/spgetstat.c
+++ b/lib/ultralib/src/io/spgetstat.c
@@ -4,6 +4,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 __osSpGetStatus() {
+u32 __osSpGetStatus(void) {
return IO_READ(SP_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/sprawdma.c b/lib/ultralib/src/io/sprawdma.c
index 6d95a49..05d9b7a 100644
--- a/lib/ultralib/src/io/sprawdma.c
+++ b/lib/ultralib/src/io/sprawdma.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sprawread.c b/lib/ultralib/src/io/sprawread.c
index 5910a9e..180b440 100644
--- a/lib/ultralib/src/io/sprawread.c
+++ b/lib/ultralib/src/io/sprawread.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sprawwrite.c b/lib/ultralib/src/io/sprawwrite.c
index 9ce3ebf..c0f83cf 100644
--- a/lib/ultralib/src/io/sprawwrite.c
+++ b/lib/ultralib/src/io/sprawwrite.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sptask.c b/lib/ultralib/src/io/sptask.c
index 8fbfeb2..3c3ef15 100644
--- a/lib/ultralib/src/io/sptask.c
+++ b/lib/ultralib/src/io/sptask.c
@@ -2,7 +2,7 @@
#include "PR/ultraerror.h"
#include "PR/sptask.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#if BUILD_VERSION < VERSION_J
#ident "$Revision: 1.4 $"
@@ -11,7 +11,7 @@
#define _osVirtualToPhysical(ptr) \
if (ptr != NULL) { \
ptr = (void*)osVirtualToPhysical(ptr); \
- }
+ } (void)0
static OSTask tmp_task;
diff --git a/lib/ultralib/src/io/vi.c b/lib/ultralib/src/io/vi.c
index 246f01f..7023b70 100644
--- a/lib/ultralib/src/io/vi.c
+++ b/lib/ultralib/src/io/vi.c
@@ -1,13 +1,13 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/rcp.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-static __OSViContext vi[2] ALIGNED(8) = { 0 };
+static __OSViContext vi[2] ALIGNED(0x8) = { 0 };
__OSViContext* __osViCurr = &vi[0];
__OSViContext* __osViNext = &vi[1];
diff --git a/lib/ultralib/src/io/viblack.c b/lib/ultralib/src/io/viblack.c
index 30dd85c..f5fbf24 100644
--- a/lib/ultralib/src/io/viblack.c
+++ b/lib/ultralib/src/io/viblack.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/viextendvstart.c b/lib/ultralib/src/io/viextendvstart.c
index 7ee06d3..1624848 100644
--- a/lib/ultralib/src/io/viextendvstart.c
+++ b/lib/ultralib/src/io/viextendvstart.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
void osViExtendVStart(u32 value) {
#ifdef _DEBUG
diff --git a/lib/ultralib/src/io/vifade.c b/lib/ultralib/src/io/vifade.c
index 6766871..22be390 100644
--- a/lib/ultralib/src/io/vifade.c
+++ b/lib/ultralib/src/io/vifade.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/vigetcurrcontext.c b/lib/ultralib/src/io/vigetcurrcontext.c
index 7b1df9b..f33dc96 100644
--- a/lib/ultralib/src/io/vigetcurrcontext.c
+++ b/lib/ultralib/src/io/vigetcurrcontext.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/vigetcurrframebuf.c b/lib/ultralib/src/io/vigetcurrframebuf.c
index de36712..6c21e40 100644
--- a/lib/ultralib/src/io/vigetcurrframebuf.c
+++ b/lib/ultralib/src/io/vigetcurrframebuf.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
void* osViGetCurrentFramebuffer(void) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/vigetmode.c b/lib/ultralib/src/io/vigetmode.c
index 2507372..3bb492b 100644
--- a/lib/ultralib/src/io/vigetmode.c
+++ b/lib/ultralib/src/io/vigetmode.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
u32 osViGetCurrentMode(void) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/vigetnextcontext.c b/lib/ultralib/src/io/vigetnextcontext.c
index bb6012a..5f1c2e2 100644
--- a/lib/ultralib/src/io/vigetnextcontext.c
+++ b/lib/ultralib/src/io/vigetnextcontext.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
__OSViContext* __osViGetNextContext(void) {
return __osViNext;
diff --git a/lib/ultralib/src/io/vigetnextframebuf.c b/lib/ultralib/src/io/vigetnextframebuf.c
index 2985358..8d14809 100644
--- a/lib/ultralib/src/io/vigetnextframebuf.c
+++ b/lib/ultralib/src/io/vigetnextframebuf.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
void* osViGetNextFramebuffer(void) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/viint.h b/lib/ultralib/src/io/viint.h
deleted file mode 100644
index ffe0927..0000000
--- a/lib/ultralib/src/io/viint.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef _VIINT_H
-#define _VIINT_H
-#include "PR/os_internal.h"
-
-#define OS_TV_TYPE_PAL 0
-#define OS_TV_TYPE_NTSC 1
-#define OS_TV_TYPE_MPAL 2
-
-#define VI_STATE_MODE_UPDATED 0x01
-#define VI_STATE_XSCALE_UPDATED 0x02
-#define VI_STATE_YSCALE_UPDATED 0x04
-#define VI_STATE_CTRL_UPDATED 0x08 // related to control regs changing
-#define VI_STATE_BUFFER_UPDATED 0x10 // swap buffer
-#define VI_STATE_BLACK 0x20 // probably related to a black screen
-#define VI_STATE_REPEATLINE 0x40 // repeat line?
-#define VI_STATE_FADE 0x80 // fade
-
-#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */
-#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */
-#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */
-
-#define VI_SCALE_MASK 0xfff //see rcp scale_x/scale_y
-#define VI_2_10_FPART_MASK 0x3ff
-#define VI_SUBPIXEL_SH 0x10
-
-#define BURST(hsync_width, color_width, vsync_width, color_start) \
- (((u32)(hsync_width) & 0xFF) | (((u32)(color_width) & 0xFF) << 8) | (((u32)(vsync_width) & 0xF) << 16) | (((u32)(color_start) & 0xFFFF) << 20))
-#define WIDTH(v) (v)
-#define VSYNC(v) (v)
-#define HSYNC(duration, leap) (((u32)(leap) << 16) | ((u32)(duration) & 0xFFFF))
-#define LEAP(upper, lower) (((u32)(upper) << 16) | ((u32)(lower) & 0xFFFF))
-#define START(start, end) (((u32)(start) << 16) | ((u32)(end) & 0xFFFF))
-
-#define FTOFIX(val, i, f) ((u32)((val) * (f32)(1 << (f))) & ((1 << ((i) + (f))) - 1))
-
-#define F210(val) FTOFIX(val, 2, 10)
-#define SCALE(scaleup, off) (F210((1.0f / (f32)(scaleup))) | (F210((f32)(off)) << 16))
-
-#define VCURRENT(v) v //seemingly unused
-#define ORIGIN(v) v
-#define VINTR(v) v
-#define HSTART START
-
-typedef struct
-{
- /* 0x0 */ f32 factor;
- /* 0x4 */ u16 offset;
- /* 0x8 */ u32 scale;
-} __OSViScale;
-
-typedef struct
-{
- /* 0x0 */ u16 state;
- /* 0x2 */ u16 retraceCount;
- /* 0x4 */ void *framep;
- /* 0x8 */ OSViMode *modep;
- /* 0xC */ u32 control;
- /* 0x10 */ OSMesgQueue *msgq;
- /* 0x14 */ OSMesg msg;
- /* 0x18 */ __OSViScale x;
- /* 0x24 */ __OSViScale y;
-} __OSViContext; // 0x30 bytes
-
-void __osViSwapContext(void);
-extern __OSViContext *__osViCurr;
-extern __OSViContext *__osViNext;
-extern u32 __additional_scanline;
-__OSViContext *__osViGetCurrentContext(void);
-void __osViInit(void);
-extern OSDevMgr __osViDevMgr;
-#endif
diff --git a/lib/ultralib/src/io/vimgr.c b/lib/ultralib/src/io/vimgr.c
index 0fe51d5..3b434b8 100644
--- a/lib/ultralib/src/io/vimgr.c
+++ b/lib/ultralib/src/io/vimgr.c
@@ -1,20 +1,20 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "viint.h"
-#include "../os/osint.h"
+#include "PRinternal/viint.h"
+#include "PRinternal/osint.h"
OSDevMgr __osViDevMgr = { 0 };
#if BUILD_VERSION >= VERSION_J
u32 __additional_scanline = 0;
#endif
static OSThread viThread;
-static unsigned char viThreadStack[OS_VIM_STACKSIZE] ALIGNED(16);
-static OSMesgQueue viEventQueue ALIGNED(8);
-static OSMesg viEventBuf[5] ALIGNED(8);
-static OSIoMesg viRetraceMsg ALIGNED(8);
-static OSIoMesg viCounterMsg ALIGNED(8);
+static STACK(viThreadStack, OS_VIM_STACKSIZE) ALIGNED(0x10);
+static OSMesgQueue viEventQueue ALIGNED(0x8);
+static OSMesg viEventBuf[5] ALIGNED(0x8);
+static OSIoMesg viRetraceMsg ALIGNED(0x8);
+static OSIoMesg viCounterMsg ALIGNED(0x8);
static void viMgrMain(void* arg);
void osCreateViManager(OSPri pri) {
@@ -61,7 +61,7 @@ void osCreateViManager(OSPri pri) {
__osViDevMgr.acsQueue = NULL;
__osViDevMgr.dma = NULL;
__osViDevMgr.edma = NULL;
- osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, &viThreadStack[OS_VIM_STACKSIZE], pri);
+ osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, STACK_START(viThreadStack), pri);
__osViInit();
osStartThread(&viThread);
__osRestoreInt(savedMask);
diff --git a/lib/ultralib/src/io/virepeatline.c b/lib/ultralib/src/io/virepeatline.c
index 1bc4984..bc96773 100644
--- a/lib/ultralib/src/io/virepeatline.c
+++ b/lib/ultralib/src/io/virepeatline.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/visetevent.c b/lib/ultralib/src/io/visetevent.c
index f741a0e..b771403 100644
--- a/lib/ultralib/src/io/visetevent.c
+++ b/lib/ultralib/src/io/visetevent.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "assert.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
diff --git a/lib/ultralib/src/io/visetmode.c b/lib/ultralib/src/io/visetmode.c
index 5ab2094..114403e 100644
--- a/lib/ultralib/src/io/visetmode.c
+++ b/lib/ultralib/src/io/visetmode.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "assert.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
diff --git a/lib/ultralib/src/io/visetspecial.c b/lib/ultralib/src/io/visetspecial.c
index 0a288e5..24b4367 100644
--- a/lib/ultralib/src/io/visetspecial.c
+++ b/lib/ultralib/src/io/visetspecial.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
@@ -15,6 +15,19 @@
#define OS_VI_SPECIAL_MAX OS_VI_DITHER_FILTER_OFF
#endif
+/**
+ * Configures VI "special features" to be applied on the next context swap.
+ *
+ * "Special features" refer to the mode bits in the Video Interface control register that enable effects such as gamma
+ * correction, gamma dither, dither filtering, anti-aliasing filtering and divot filtering. Configuring the same
+ * setting ON and OFF in the same call will result in OFF taking precedence.
+ *
+ * Any unrecognized bits will be ignored. Note that this is very intentional as in early revisions of retail N64
+ * hardware setting bit 5 in the `features` field of OSViContext may cause physical damage to the console once it is
+ * fed to VI_CONTROL_REG on next context swap.
+ *
+ * @param func OS_VI_*_ON / OS_VI_*_OFF bits to enable or disable a setting.
+ */
void osViSetSpecialFeatures(u32 func) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/visetxscale.c b/lib/ultralib/src/io/visetxscale.c
index 6af6535..1baab29 100644
--- a/lib/ultralib/src/io/visetxscale.c
+++ b/lib/ultralib/src/io/visetxscale.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/visetyscale.c b/lib/ultralib/src/io/visetyscale.c
index c1c96f4..1202478 100644
--- a/lib/ultralib/src/io/visetyscale.c
+++ b/lib/ultralib/src/io/visetyscale.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/viswapbuf.c b/lib/ultralib/src/io/viswapbuf.c
index aa077cd..ec5016d 100644
--- a/lib/ultralib/src/io/viswapbuf.c
+++ b/lib/ultralib/src/io/viswapbuf.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "assert.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
diff --git a/lib/ultralib/src/io/viswapcontext.c b/lib/ultralib/src/io/viswapcontext.c
index 2f6d2c6..a19fd40 100644
--- a/lib/ultralib/src/io/viswapcontext.c
+++ b/lib/ultralib/src/io/viswapcontext.c
@@ -1,11 +1,11 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-void __osViSwapContext() {
+void __osViSwapContext(void) {
register OSViMode* vm;
register __OSViContext* vc;
u32 origin;
@@ -38,7 +38,7 @@ void __osViSwapContext() {
}
#if BUILD_VERSION >= VERSION_J
- vStart = (vm->fldRegs[field].vStart - (__additional_scanline << 0x10)) + __additional_scanline;
+ vStart = (vm->fldRegs[field].vStart - (__additional_scanline << VI_SUBPIXEL_SH)) + __additional_scanline;
#endif
hStart = vm->comRegs.hStart;
diff --git a/lib/ultralib/src/io/vitbl.c b/lib/ultralib/src/io/vitbl.c
index 476036e..a728c2c 100644
--- a/lib/ultralib/src/io/vitbl.c
+++ b/lib/ultralib/src/io/vitbl.c
@@ -1,6 +1,6 @@
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeTable[] = {
{ OS_VI_NTSC_LPN1, // type
@@ -100,15 +100,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -192,15 +192,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_NTSC_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(525), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(525), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -223,15 +224,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -316,15 +317,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -347,15 +348,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -533,15 +534,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -625,15 +626,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_PAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(625), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(625), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -656,15 +658,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -749,15 +751,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -780,15 +782,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -966,15 +968,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1058,15 +1060,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_MPAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(525), // vSync
- HSYNC(3089, 4), // hSync
- LEAP(3097, 3098), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(525), // vSync
+ HSYNC(3089, 4), // hSync
+ LEAP(3097, 3098), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1089,15 +1092,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1182,15 +1185,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1213,15 +1216,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1400,15 +1403,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1492,15 +1495,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_FPAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(625), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(625), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1523,15 +1527,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1616,15 +1620,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1647,15 +1651,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1735,6 +1739,6 @@ OSViMode osViModeTable[] = {
HSTART(47, 617), // vStart
BURST(105, 2, 13, 0), // vBurst
VINTR(2), // vIntr
- } } }
+ } } },
#endif
};