You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Fix UNF by moving it's code to engine segment
Additionally update UNF code to latest master
This commit is contained in:
@@ -25,6 +25,8 @@ To build with UNF, run make with ``UNF=1``.
|
||||
|
||||
Further instructions can be found at the [official repository](https://github.com/buu342/N64-UNFLoader)
|
||||
|
||||
**NOTE: Closing the UNFLoader window will result in your game eventually hanging due to lacking a USB device to send messages to, so beware of that**
|
||||
|
||||
## Multi-Save support
|
||||
|
||||
The repository supports SRAM in addition to EEPROM. The standard save data functions are #ifdef'd to accommedate this.
|
||||
|
||||
8
sm64.ld
8
sm64.ld
@@ -132,7 +132,6 @@ SECTIONS
|
||||
|
||||
BUILD_DIR/src/boot*.o(.text);
|
||||
BUILD_DIR/src/hvqm*.o(.text);
|
||||
BUILD_DIR/src/usb*.o(.text);
|
||||
BUILD_DIR/src/audio*.o(.text);
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(.text);
|
||||
@@ -148,7 +147,6 @@ SECTIONS
|
||||
|
||||
/* data */
|
||||
BUILD_DIR/src/boot*.o(.*data*);
|
||||
BUILD_DIR/src/usb*.o(.*data*);
|
||||
BUILD_DIR/src/audio*.o(.*data*);
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(.*data*);
|
||||
@@ -163,7 +161,6 @@ SECTIONS
|
||||
|
||||
/* rodata */
|
||||
BUILD_DIR/src/boot*.o(.rodata*);
|
||||
BUILD_DIR/src/usb*.o(.rodata*);
|
||||
BUILD_DIR/src/audio*.o(.rodata*);
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(.*rodata*);
|
||||
@@ -181,7 +178,6 @@ SECTIONS
|
||||
{
|
||||
BUILD_DIR/src/boot*.o(.*bss*);
|
||||
BUILD_DIR/src/hvqm*.o(.*bss*);
|
||||
BUILD_DIR/src/usb*.o(.*bss*);
|
||||
BUILD_DIR/src/audio*.o(.*bss*);
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(COMMON);
|
||||
@@ -206,19 +202,23 @@ SECTIONS
|
||||
{
|
||||
BUILD_DIR/src/game*.o(.text);
|
||||
BUILD_DIR/src/engine*.o(.text);
|
||||
BUILD_DIR/src/usb*.o(.text);
|
||||
/* data */
|
||||
BUILD_DIR/src/game*.o(.*data*);
|
||||
BUILD_DIR/src/engine*.o(.data*);
|
||||
BUILD_DIR/src/engine*.o(.sdata*);
|
||||
BUILD_DIR/src/usb*.o(.*data*);
|
||||
/* rodata */
|
||||
BUILD_DIR/src/game*.o(.rodata*);
|
||||
BUILD_DIR/src/engine*.o(.rodata*);
|
||||
BUILD_DIR/src/usb*.o(.rodata*);
|
||||
}
|
||||
END_SEG(engine)
|
||||
BEGIN_NOLOAD(engine)
|
||||
{
|
||||
BUILD_DIR/src/game*.o(.*bss*);
|
||||
BUILD_DIR/src/engine*.o(.bss*);
|
||||
BUILD_DIR/src/usb*.o(.*bss*);
|
||||
. = ALIGN(0x40);
|
||||
}
|
||||
END_NOLOAD(engine)
|
||||
|
||||
@@ -319,6 +319,10 @@ void thread3_main(UNUSED void *arg) {
|
||||
crash_screen_init();
|
||||
#endif
|
||||
|
||||
#ifdef UNF
|
||||
debug_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
osSyncPrintf("Super Mario 64\n");
|
||||
osSyncPrintf("Built by: %s\n", __username__);
|
||||
@@ -462,9 +466,6 @@ void thread1_idle(UNUSED void *arg) {
|
||||
osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON);
|
||||
osViSetSpecialFeatures(OS_VI_GAMMA_OFF);
|
||||
osCreatePiManager(OS_PRIORITY_PIMGR, &gPIMesgQueue, gPIMesgBuf, ARRAY_COUNT(gPIMesgBuf));
|
||||
#ifdef UNF
|
||||
debug_initialize();
|
||||
#endif
|
||||
create_thread(&gMainThread, 3, thread3_main, NULL, gThread3Stack + 0x2000, 100);
|
||||
osStartThread(&gMainThread);
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
#if defined(RNC1) || defined(RNC2)
|
||||
#include <rnc.h>
|
||||
#endif
|
||||
#ifdef UNF
|
||||
#include "usb/usb.h"
|
||||
#include "usb/debug.h"
|
||||
#endif
|
||||
|
||||
|
||||
// round up to the next multiple
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
#ifdef HVQM
|
||||
#include <hvqm/hvqm.h>
|
||||
#endif
|
||||
#ifdef UNF
|
||||
#include "usb/usb.h"
|
||||
#include "usb/debug.h"
|
||||
#endif
|
||||
#ifdef SRAM
|
||||
#include "sram.h"
|
||||
#endif
|
||||
|
||||
@@ -449,7 +449,11 @@ https://github.com/buu342/N64-UNFLoader
|
||||
==============================*/
|
||||
|
||||
void _debug_assert(const char* expression, const char* file, int line)
|
||||
{
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
volatile char crash;
|
||||
|
||||
// Set the assert data
|
||||
assert_expr = expression;
|
||||
assert_line = line;
|
||||
@@ -460,8 +464,9 @@ https://github.com/buu342/N64-UNFLoader
|
||||
debug_printf("Assertion failed in file '%s', line %d.\n", assert_file, assert_line);
|
||||
#endif
|
||||
|
||||
// Intentionally cause a null pointer exception
|
||||
*((char*)(NULL)) = 0;
|
||||
// Intentionally cause a TLB exception on load/instruction fetch
|
||||
crash = *(volatile char *)1;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -385,20 +385,7 @@ static void usb_findcart()
|
||||
|
||||
// Check if we have an EverDrive
|
||||
if (buff == ED7_VERSION || buff == ED3_VERSION)
|
||||
{
|
||||
// Initialize the PI
|
||||
IO_WRITE(PI_STATUS_REG, 3);
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, 0x40);
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, 0x12);
|
||||
IO_WRITE(PI_BSD_DOM1_PGS_REG, 0x07);
|
||||
IO_WRITE(PI_BSD_DOM1_RLS_REG, 0x03);
|
||||
IO_WRITE(PI_BSD_DOM2_LAT_REG, 0x05);
|
||||
IO_WRITE(PI_BSD_DOM2_PWD_REG, 0x0C);
|
||||
IO_WRITE(PI_BSD_DOM2_PGS_REG, 0x0D);
|
||||
IO_WRITE(PI_BSD_DOM2_RLS_REG, 0x02);
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, 0x04);
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, 0x0C);
|
||||
|
||||
{
|
||||
// Set the USB mode
|
||||
usb_everdrive_writereg(ED_REG_SYSCFG, 0);
|
||||
usb_everdrive_writereg(ED_REG_USBCFG, ED_USBMODE_RDNOP);
|
||||
@@ -453,7 +440,7 @@ void usb_write(int datatype, const void* data, int size)
|
||||
@return The data header, or 0
|
||||
==============================*/
|
||||
|
||||
u32 usb_poll()
|
||||
unsigned long usb_poll()
|
||||
{
|
||||
// If no debug cart exists, stop
|
||||
if (usb_cart == CART_NONE)
|
||||
@@ -604,7 +591,7 @@ static s8 usb_64drive_wait()
|
||||
#endif
|
||||
|
||||
// Took too long, abort
|
||||
if((timeout++) > 1000000)
|
||||
if((timeout++) > 10000)
|
||||
return -1;
|
||||
}
|
||||
while((ret >> 8) & D64_CI_BUSY);
|
||||
@@ -642,9 +629,10 @@ static void usb_64drive_setwritable(u8 enable)
|
||||
Waits for the 64Drive's USB to be idle
|
||||
==============================*/
|
||||
|
||||
static void usb_64drive_waitidle()
|
||||
static int usb_64drive_waitidle()
|
||||
{
|
||||
u32 status __attribute__((aligned(8)));
|
||||
u32 timeout = 0;
|
||||
do
|
||||
{
|
||||
#ifdef LIBDRAGON
|
||||
@@ -657,8 +645,11 @@ static void usb_64drive_waitidle()
|
||||
#endif
|
||||
#endif
|
||||
status = (status >> 4) & D64_USB_BUSY;
|
||||
if (timeout++ > 128)
|
||||
return 0;
|
||||
}
|
||||
while(status != D64_USB_IDLE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -724,7 +715,8 @@ static void usb_64drive_write(int datatype, const void* data, int size)
|
||||
int read = 0;
|
||||
|
||||
// Spin until the write buffer is free and then set the cartridge to write mode
|
||||
usb_64drive_waitidle();
|
||||
if (!usb_64drive_waitidle())
|
||||
return;
|
||||
usb_64drive_setwritable(TRUE);
|
||||
|
||||
// Write data to SDRAM until we've finished
|
||||
@@ -749,7 +741,11 @@ static void usb_64drive_write(int datatype, const void* data, int size)
|
||||
}
|
||||
|
||||
// Spin until the write buffer is free
|
||||
usb_64drive_waitidle();
|
||||
if (!usb_64drive_waitidle())
|
||||
{
|
||||
usb_64drive_setwritable(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up DMA transfer between RDRAM and the PI
|
||||
#ifdef LIBDRAGON
|
||||
@@ -1062,7 +1058,8 @@ static void usb_everdrive_writedata(void* buff, u32 pi_address, u32 len)
|
||||
|
||||
static void usb_everdrive_writereg(u64 reg, u32 value)
|
||||
{
|
||||
usb_everdrive_writedata(&value, ED_GET_REGADD(reg), sizeof(u32));
|
||||
u32 val __attribute__((aligned(8))) = value;
|
||||
usb_everdrive_writedata(&val, ED_GET_REGADD(reg), sizeof(u32));
|
||||
}
|
||||
|
||||
|
||||
@@ -1073,12 +1070,15 @@ static void usb_everdrive_writereg(u64 reg, u32 value)
|
||||
|
||||
static void usb_everdrive_usbbusy()
|
||||
{
|
||||
u32 timeout = 0;
|
||||
u32 val __attribute__((aligned(8)));
|
||||
do
|
||||
do
|
||||
{
|
||||
usb_everdrive_readreg(ED_REG_USBCFG, &val);
|
||||
}
|
||||
while ((val & ED_USBSTAT_ACT) != 0);
|
||||
if (timeout++ != 8192)
|
||||
continue;
|
||||
usb_everdrive_writereg(ED_REG_USBCFG, ED_USBMODE_RDNOP);
|
||||
} while ((val & ED_USBSTAT_ACT) != 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1690,4 +1690,4 @@ static void usb_sc64_read(void)
|
||||
// Invalidate cache
|
||||
osInvalDCache(usb_buffer, BUFFER_SIZE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
@return The data header, or 0
|
||||
==============================*/
|
||||
|
||||
extern unsigned int usb_poll();
|
||||
extern unsigned long usb_poll();
|
||||
|
||||
|
||||
/*==============================
|
||||
|
||||
Reference in New Issue
Block a user