Get HVQM working

This commit is contained in:
CrashOveride95
2020-12-09 09:05:40 -05:00
parent 5e042fd82c
commit 7f4cefdc36
8 changed files with 772 additions and 70 deletions

View File

@@ -5,8 +5,6 @@
#include "sm64.h"
#if defined(TARGET_N64) && (defined(VERSION_EU) || defined(VERSION_SH))
#include "printf.h"
u8 gCrashScreenCharToGlyph[128] = {
@@ -118,11 +116,7 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) {
if (size > 0) {
ptr = buf;
#ifdef VERSION_SH
while (size > 0) {
#else
while (*ptr) {
#endif
glyph = gCrashScreenCharToGlyph[*ptr & 0x7f];
@@ -130,10 +124,6 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) {
crash_screen_draw_glyph(x, y, glyph);
}
#ifdef VERSION_SH
size--;
#endif
ptr++;
x += 6;
}
@@ -191,16 +181,10 @@ void draw_crash_screen(OSThread *thread) {
cause = 17;
}
#ifdef VERSION_SH
osWritebackDCacheAll();
#endif
crash_screen_draw_rect(25, 20, 270, 25);
crash_screen_print(30, 25, "THREAD:%d (%s)", thread->id, gCauseDesc[cause]);
crash_screen_print(30, 35, "PC:%08XH SR:%08XH VA:%08XH", tc->pc, tc->sr, tc->badvaddr);
#ifdef VERSION_EU
osWritebackDCacheAll();
#endif
crash_screen_sleep(2000);
crash_screen_draw_rect(25, 45, 270, 185);
crash_screen_print(30, 50, "AT:%08XH V0:%08XH V1:%08XH", (u32) tc->at, (u32) tc->v0,
@@ -223,9 +207,7 @@ void draw_crash_screen(OSThread *thread) {
(u32) tc->sp);
crash_screen_print(30, 140, "S8:%08XH RA:%08XH", (u32) tc->s8, (u32) tc->ra);
crash_screen_print_fpcsr(tc->fpcsr);
#ifdef VERSION_EU
osWritebackDCacheAll();
#endif
crash_screen_print_float_reg(30, 170, 0, &tc->fp0.f.f_even);
crash_screen_print_float_reg(120, 170, 2, &tc->fp2.f.f_even);
crash_screen_print_float_reg(210, 170, 4, &tc->fp4.f.f_even);
@@ -242,9 +224,7 @@ void draw_crash_screen(OSThread *thread) {
crash_screen_print_float_reg(120, 210, 26, &tc->fp26.f.f_even);
crash_screen_print_float_reg(210, 210, 28, &tc->fp28.f.f_even);
crash_screen_print_float_reg(30, 220, 30, &tc->fp30.f.f_even);
#ifdef VERSION_EU
osWritebackDCacheAll();
#endif
osViBlack(FALSE);
osViSwapBuffer(gCrashScreen.framebuffer);
}
@@ -279,37 +259,20 @@ void thread2_crash_screen(UNUSED void *arg) {
}
void crash_screen_set_framebuffer(u16 *framebuffer, u16 width, u16 height) {
#ifdef VERSION_EU
gCrashScreen.framebuffer = framebuffer;
#else
gCrashScreen.framebuffer = (u16 *)((uintptr_t)framebuffer | 0xa0000000);
#endif
gCrashScreen.width = width;
gCrashScreen.height = height;
}
void crash_screen_init(void) {
#ifdef VERSION_EU
gCrashScreen.framebuffer = (u16 *) (osMemSize | 0x80000000) - SCREEN_WIDTH * SCREEN_HEIGHT;
#else
gCrashScreen.framebuffer = (u16 *) (osMemSize | 0xA0000000) - SCREEN_WIDTH * SCREEN_HEIGHT;
#endif
gCrashScreen.width = SCREEN_WIDTH;
#ifdef VERSION_EU
gCrashScreen.height = SCREEN_HEIGHT;
#else
gCrashScreen.height = 0x10;
#endif
osCreateMesgQueue(&gCrashScreen.mesgQueue, &gCrashScreen.mesg, 1);
osCreateThread(&gCrashScreen.thread, 2, thread2_crash_screen, NULL,
(u8 *) gCrashScreen.stack + sizeof(gCrashScreen.stack),
#ifdef VERSION_EU
OS_PRIORITY_APPMAX
#else
OS_PRIORITY_RMON
#endif
);
osStartThread(&gCrashScreen.thread);
}
#endif

View File

@@ -59,6 +59,10 @@ struct DemoInput *gCurrDemoInput = NULL; // demo input sequence
u16 gDemoInputListID = 0;
struct DemoInput gRecordedDemoInput = { 0 }; // possibly removed in EU. TODO: Check
#include "include/timekeeper.inc.c"
#include "include/hvqm.inc.c"
/**
* Initializes the Reality Display Processor (RDP).
* This function initializes settings such as texture filtering mode,
@@ -606,6 +610,7 @@ void thread5_game_loop(UNUSED void *arg) {
#if ENABLE_RUMBLE
create_thread_6();
#endif
createHvqmThread();
save_file_load_all();
set_vblank_handler(2, &gGameVblankHandler, &gGameVblankQueue, (OSMesg) 1);
@@ -647,11 +652,9 @@ void thread5_game_loop(UNUSED void *arg) {
// amount of free space remaining.
print_text_fmt_int(180, 20, "BUF %d", gGfxPoolEnd - (u8 *) gDisplayListHead);
}
#if 0
if (gPlayer1Controller->buttonPressed & L_TRIG) {
osStartThread(&hvqmThread);
osRecvMesg(&gDmaMesgQueue, NULL, OS_MESG_BLOCK);
}
#endif
}
}

View File

@@ -328,11 +328,13 @@ void handle_dp_complete(void) {
sCurrentDisplaySPTask->state = SPTASK_STATE_FINISHED_DP;
sCurrentDisplaySPTask = NULL;
}
extern void crash_screen_init(void);
void thread3_main(UNUSED void *arg) {
setup_mesg_queues();
alloc_pool();
load_engine_code_segment();
crash_screen_init();
create_thread(&gSoundThread, 4, thread4_sound, NULL, gThread4Stack + 0x2000, 20);
osStartThread(&gSoundThread);
@@ -340,7 +342,6 @@ void thread3_main(UNUSED void *arg) {
create_thread(&gGameLoopThread, 5, thread5_game_loop, NULL, gThread5Stack + 0x2000, 10);
osStartThread(&gGameLoopThread);
//createHvqmThread();
while (TRUE) {
OSMesg msg;
@@ -458,10 +459,7 @@ void thread1_idle(UNUSED void *arg) {
}
void main_func(void) {
UNUSED u8 pad[64]; // needed to pad the stack
osInitialize();
stub_main_1();
create_thread(&gIdleThread, 1, thread1_idle, NULL, gIdleThreadStack + 0x800, 100);
osStartThread(&gIdleThread);
}

View File

@@ -26,7 +26,6 @@ extern OSThread gIdleThread;
extern OSThread gMainThread;
extern OSThread gGameLoopThread;
extern OSThread gSoundThread;
extern OSThread hvqmThread;
#if ENABLE_RUMBLE
extern OSThread gRumblePakThread;