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 up printing and begin GDB
This commit is contained in:
8
Makefile
8
Makefile
@@ -9,6 +9,7 @@ default: all
|
||||
DEFINES :=
|
||||
|
||||
SRC_DIRS :=
|
||||
USE_DEBUG := 0
|
||||
|
||||
#==============================================================================#
|
||||
# Build Options #
|
||||
@@ -170,6 +171,7 @@ $(eval $(call validate-option,UNF,0 1))
|
||||
ifeq ($(UNF),1)
|
||||
DEFINES += UNF=1
|
||||
SRC_DIRS += src/usb
|
||||
USE_DEBUG := 1
|
||||
endif
|
||||
|
||||
|
||||
@@ -181,6 +183,10 @@ ISVPRINT ?= 0
|
||||
$(eval $(call validate-option,ISVPRINT,0 1))
|
||||
ifeq ($(ISVPRINT),1)
|
||||
DEFINES += ISVPRINT=1
|
||||
USE_DEBUG := 1
|
||||
endif
|
||||
|
||||
ifeq ($(USE_DEBUG),1)
|
||||
ULTRALIB := ultra_d
|
||||
else
|
||||
ULTRALIB := ultra_rom
|
||||
@@ -738,7 +744,7 @@ $(ELF): $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) unde
|
||||
# Build ROM
|
||||
$(ROM): $(ELF)
|
||||
$(call print,Building ROM:,$<,$@)
|
||||
$(V)$(OBJCOPY) --pad-to=0x100000 --gap-fill=0xFF $< $@ -O binary
|
||||
$(V)$(OBJCOPY) --pad-to=0x800000 --gap-fill=0xFF $< $@ -O binary
|
||||
$(V)$(N64CKSUM) $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).objdump: $(ELF)
|
||||
|
||||
8
sm64.ld
8
sm64.ld
@@ -132,7 +132,7 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.text);
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.text);
|
||||
#if defined(ISVPRINT)
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(.text);
|
||||
#else
|
||||
*/libultra_rom.a:*.o(.text);
|
||||
@@ -158,7 +158,7 @@ SECTIONS
|
||||
#ifdef GZIP
|
||||
*/libz.a:*.o(.*data*);
|
||||
#endif
|
||||
#if defined(ISVPRINT)
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(.*data*);
|
||||
#else
|
||||
*/libultra_rom.a:*.o(.*data*);
|
||||
@@ -178,7 +178,7 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.rodata*);
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.rodata*);
|
||||
#if defined(ISVPRINT)
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(.*rodata*);
|
||||
#else
|
||||
*/libultra_rom.a:*.o(.*rodata*);
|
||||
@@ -208,7 +208,7 @@ SECTIONS
|
||||
BUILD_DIR/src/gzip*.o(.bss*);
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.*bss*);
|
||||
#if defined(ISVPRINT)
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
*/libultra_d.a:*.o(COMMON);
|
||||
*/libultra_d.a:*.o(.scommon);
|
||||
*/libultra_d.a:*.o(.*bss*);
|
||||
|
||||
@@ -216,8 +216,10 @@ void discard_bank(s32 bankId) {
|
||||
#else
|
||||
if (note->priority >= NOTE_PRIORITY_MIN) {
|
||||
#endif
|
||||
#if defined(VERSION_EU)
|
||||
eu_stubbed_printf_3("Kill Voice %d (ID %d) %d\n", note->waveId,
|
||||
bankId, note->priority);
|
||||
#endif
|
||||
eu_stubbed_printf_0("Warning: Running Sequence's data disappear!\n");
|
||||
note->parentLayer->enabled = FALSE; // is 0x48, should be 0x44
|
||||
note->parentLayer->finished = TRUE;
|
||||
@@ -760,7 +762,9 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
#ifdef VERSION_SH
|
||||
case 0:
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
eu_stubbed_printf_1("MEMORY:StayHeap OVERFLOW (REQ:%d)", arg1 * size);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1118,8 +1122,9 @@ void audio_reset_session(void) {
|
||||
#else
|
||||
struct SynthesisReverb *reverb;
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
eu_stubbed_printf_1("Heap Reconstruct Start %x\n", gAudioResetPresetIdToLoad);
|
||||
|
||||
#endif
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
decrease_reverb_gain();
|
||||
|
||||
@@ -1977,11 +1977,11 @@ void audio_init() {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
// Should probably contain the sizes of the data banks, but those aren't
|
||||
// easily accessible from here.
|
||||
eu_stubbed_printf_0("---------- Init Completed. ------------\n");
|
||||
eu_stubbed_printf_1(" Syndrv :[%6d]\n", 0); // gSoundDataADSR
|
||||
eu_stubbed_printf_1(" Seqdrv :[%6d]\n", 0); // gMusicData
|
||||
eu_stubbed_printf_1(" audiodata :[%6d]\n", 0); // gSoundDataRaw
|
||||
eu_stubbed_printf_0("---------------------------------------\n");
|
||||
osSyncPrintf("---------- Init Completed. ------------\n");
|
||||
osSyncPrintf(" Syndrv :[%6d]\n", gSoundDataADSR); // gSoundDataADSR
|
||||
osSyncPrintf(" Seqdrv :[%6d]\n", gMusicData); // gMusicData
|
||||
osSyncPrintf(" audiodata :[%6d]\n", gSoundDataRaw); // gSoundDataRaw
|
||||
osSyncPrintf("---------------------------------------\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,16 @@
|
||||
|
||||
#ifdef VERSION_EU
|
||||
|
||||
#if defined(ISVPRINT) || defined(UNF)
|
||||
#define stubbed_printf osSyncPrintf
|
||||
#else
|
||||
|
||||
#ifdef __sgi
|
||||
#define stubbed_printf
|
||||
#else
|
||||
#define stubbed_printf(...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SAMPLES_TO_OVERPRODUCE 0x10
|
||||
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x40
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
# This file is handwritten.
|
||||
|
||||
glabel decompress
|
||||
.if VERSION_SH == 1
|
||||
lw $a3, 8($a0)
|
||||
lw $t9, 0xc($a0)
|
||||
lw $t8, 4($a0)
|
||||
@@ -54,96 +53,4 @@ glabel decompress
|
||||
bne $a1, $t8, .L802772C0
|
||||
addi $a2, $a2, -1
|
||||
jr $ra
|
||||
nop
|
||||
.elseif VERSION_EU == 1
|
||||
lw $a3, 8($a0)
|
||||
lw $t9, 0xc($a0)
|
||||
lw $t8, 4($a0)
|
||||
add $a3, $a3, $a0
|
||||
add $t9, $t9, $a0
|
||||
move $a2, $zero
|
||||
addi $a0, $a0, 0x10
|
||||
add $t8, $t8, $a1
|
||||
.L8026ED80:
|
||||
bnezl $a2, .L8026ED98
|
||||
slt $t1, $t0, $zero
|
||||
lw $t0, ($a0)
|
||||
li $a2, 32
|
||||
addi $a0, $a0, 4
|
||||
slt $t1, $t0, $zero
|
||||
.L8026ED98:
|
||||
beql $t1, $zero, .L8026EDB8
|
||||
lhu $t2, ($a3)
|
||||
lb $t2, ($t9)
|
||||
addi $t9, $t9, 1
|
||||
addi $a1, $a1, 1
|
||||
b .L8026EDE4
|
||||
sb $t2, -1($a1)
|
||||
lhu $t2, ($a3)
|
||||
.L8026EDB8:
|
||||
addi $a3, $a3, 2
|
||||
srl $t3, $t2, 0xc
|
||||
andi $t2, $t2, 0xfff
|
||||
sub $t1, $a1, $t2
|
||||
addi $t3, $t3, 3
|
||||
.L8026EDCC:
|
||||
lb $t2, -1($t1)
|
||||
addi $t3, $t3, -1
|
||||
addi $t1, $t1, 1
|
||||
addi $a1, $a1, 1
|
||||
bnez $t3, .L8026EDCC
|
||||
sb $t2, -1($a1)
|
||||
.L8026EDE4:
|
||||
sll $t0, $t0, 1
|
||||
bne $a1, $t8, .L8026ED80
|
||||
addi $a2, $a2, -1
|
||||
jr $ra
|
||||
nop
|
||||
.else
|
||||
lw $t8, 4($a0)
|
||||
lw $a3, 8($a0)
|
||||
lw $t9, 0xc($a0)
|
||||
move $a2, $zero
|
||||
add $t8, $t8, $a1
|
||||
add $a3, $a3, $a0
|
||||
add $t9, $t9, $a0
|
||||
addi $a0, $a0, 0x10
|
||||
.L8027EF50:
|
||||
bnez $a2, .L8027EF64
|
||||
nop
|
||||
lw $t0, ($a0)
|
||||
li $a2, 32
|
||||
addi $a0, $a0, 4
|
||||
.L8027EF64:
|
||||
slt $t1, $t0, $zero
|
||||
beqz $t1, .L8027EF88
|
||||
nop
|
||||
lb $t2, ($t9)
|
||||
addi $t9, $t9, 1
|
||||
sb $t2, ($a1)
|
||||
addi $a1, $a1, 1
|
||||
b .L8027EFBC
|
||||
nop
|
||||
.L8027EF88:
|
||||
lhu $t2, ($a3)
|
||||
addi $a3, $a3, 2
|
||||
srl $t3, $t2, 0xc
|
||||
andi $t2, $t2, 0xfff
|
||||
sub $t1, $a1, $t2
|
||||
addi $t3, $t3, 3
|
||||
.L8027EFA0:
|
||||
lb $t2, -1($t1)
|
||||
addi $t3, $t3, -1
|
||||
addi $t1, $t1, 1
|
||||
sb $t2, ($a1)
|
||||
addi $a1, $a1, 1
|
||||
bnez $t3, .L8027EFA0
|
||||
nop
|
||||
.L8027EFBC:
|
||||
sll $t0, $t0, 1
|
||||
addi $a2, $a2, -1
|
||||
bne $a1, $t8, .L8027EF50
|
||||
nop
|
||||
jr $ra
|
||||
nop
|
||||
.endif
|
||||
nop
|
||||
@@ -236,9 +236,11 @@ void func_sh_8024CA04(void) {
|
||||
static void thread6_rumble_loop(UNUSED void *a0) {
|
||||
OSMesg msg;
|
||||
|
||||
osSyncPrintf("start motor thread\n");
|
||||
cancel_rumble();
|
||||
|
||||
sRumblePakThreadActive = TRUE;
|
||||
osSyncPrintf("go motor thread\n");
|
||||
|
||||
while (TRUE) {
|
||||
// Block until VI
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
#define DEBUG_MODE 1 // Enable/Disable debug mode
|
||||
#define DEBUG_INIT_MSG 1 // Print a message when debug mode has initialized
|
||||
#define USE_FAULTTHREAD 1 // Create a fault detection thread (libultra only)
|
||||
#define OVERWRITE_OSPRINT 0 // Replaces osSyncPrintf calls with debug_printf (libultra only)
|
||||
#define OVERWRITE_OSPRINT 1 // Replaces osSyncPrintf calls with debug_printf (libultra only)
|
||||
#define MAX_COMMANDS 25 // The max amount of user defined commands possible
|
||||
|
||||
#define osSyncPrintf debug_printf // Temporary until libultra_d is linked instead
|
||||
|
||||
// Fault thread definitions (libultra only)
|
||||
#define FAULT_THREAD_ID 13
|
||||
|
||||
933
src/usb/debugger.c
Normal file
933
src/usb/debugger.c
Normal file
File diff suppressed because it is too large
Load Diff
60
src/usb/debugger.h
Normal file
60
src/usb/debugger.h
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
#ifndef __DEBUGGER_H
|
||||
#define __DEBUGGER_H
|
||||
|
||||
#include <ultra64.h>
|
||||
#include "serial.h"
|
||||
|
||||
enum GDBBreakpointType {
|
||||
GDBBreakpointTypeNone,
|
||||
GDBBreakpointTypeTemporary,
|
||||
GDBBreakpointTypeUser,
|
||||
GDBBreakpointTypeUserUnapplied,
|
||||
};
|
||||
|
||||
struct GDBBreakpoint {
|
||||
u32 addr;
|
||||
u32 prevValue;
|
||||
enum GDBBreakpointType type;
|
||||
};
|
||||
|
||||
#define GDB_MAX_BREAK_POINTS 32
|
||||
|
||||
/**
|
||||
* Initializes the debugger
|
||||
* @param handler Pi Handler used for DMA, this is return value
|
||||
* of osCartRomInit
|
||||
* @param dmaMessageQ The message queue used to coordinate use of
|
||||
* the DMA. This should be the same message queue used for DMA
|
||||
* actions in the rest of your program
|
||||
* @param forThreads an array of threads you want the debugger to
|
||||
* watch connect to. If a thread isn't included in this array
|
||||
* it will be ignored by the debugger
|
||||
* @param forThreadsLen the length of the forThreads array
|
||||
*/
|
||||
enum GDBError gdbInitDebugger(OSPiHandle* handler, OSMesgQueue* dmaMessageQ, OSThread** forThreads, u32 forThreadsLen);
|
||||
enum GDBError gdbCheckForPacket();
|
||||
|
||||
/**
|
||||
* A hard coded breakpoint you can include in compiled code
|
||||
*/
|
||||
void gdbBreak();
|
||||
|
||||
/**
|
||||
* Gets the address of the current memory watch point
|
||||
*/
|
||||
void* getWatchPoint();
|
||||
/**
|
||||
* Sets a watch point. When a thread reads or writes to the given
|
||||
* address. It will pause in the debugger
|
||||
* @param addr The address to watch
|
||||
* @param read a non zero value signals that a thread will break when addr is read
|
||||
* @param write a non zero value signals that a thread will break when addr is written
|
||||
*/
|
||||
void gdbSetWatchPoint(void* addr, int read, int write);
|
||||
/**
|
||||
* Removes the current watch point this is the same as doing gdbSetWatchPoint(0, 0, 0)
|
||||
*/
|
||||
void gdbClearWatchPoint();
|
||||
|
||||
#endif
|
||||
519
src/usb/serial.c
Normal file
519
src/usb/serial.c
Normal file
File diff suppressed because it is too large
Load Diff
44
src/usb/serial.h
Normal file
44
src/usb/serial.h
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
#ifndef __SERIAL_H
|
||||
#define __SERIAL_H
|
||||
|
||||
#include <ultra64.h>
|
||||
|
||||
// #define USE_UNF_LOADER 1
|
||||
|
||||
enum GDBError {
|
||||
GDBErrorNone,
|
||||
GDBErrorUSBTimeout,
|
||||
GDBErrorUSBNoData,
|
||||
GDBErrorBadPacket,
|
||||
GDBErrorMessageTooLong,
|
||||
GDBErrorBadFooter,
|
||||
GDBErrorDMA,
|
||||
GDBErrorBufferTooSmall,
|
||||
};
|
||||
|
||||
enum GDBDataType {
|
||||
GDBDataTypeNone,
|
||||
GDBDataTypeText,
|
||||
GDBDataTypeRawBinary,
|
||||
GDBDataTypeScreenshot,
|
||||
GDBDataTypeGDB,
|
||||
};
|
||||
|
||||
enum GDBCartType {
|
||||
GDBCartTypeNone,
|
||||
GDBCartTypeX7,
|
||||
GDBCartTypeCen64,
|
||||
};
|
||||
|
||||
extern u8 (*gdbSerialCanRead)();
|
||||
|
||||
enum GDBError gdbSerialInit(OSPiHandle* handler, OSMesgQueue* dmaMessageQ);
|
||||
|
||||
enum GDBError gdbSendMessage(enum GDBDataType type, char* src, u32 len);
|
||||
|
||||
enum GDBError gdbPollHeader(enum GDBDataType* type, u32* len);
|
||||
enum GDBError gdbReadData(char* target, u32 len, u32* dataRead);
|
||||
enum GDBError gdbFinishRead();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user