Skip to content

Commit

Permalink
Merge pull request #60 from RevoSucks/data_rodata_work
Browse files Browse the repository at this point in the history
some data rodata work
  • Loading branch information
RevoSucks committed Aug 4, 2023
2 parents 9080839 + b29a25d commit 760153e
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ROM := $(TARGET).z64
ELF := $(BUILD_DIR)/$(TARGET).elf
LD_SCRIPT := $(TARGET).ld
LD_MAP := $(BUILD_DIR)/$(TARGET).map
ASM_DIRS := asm asm/os asm/libleo asm/libultra asm/libultra/os asm/libultra/io asm/libultra/gu asm/libultra/libc asm/libultra/al
ASM_DIRS := asm asm/os asm/libleo asm/libultra asm/libultra/os asm/libultra/io asm/libultra/gu asm/libultra/libc asm/libultra/al asm/data
DATA_DIRS := bin assets
SRC_DIRS := $(shell find src -type d)

Expand Down Expand Up @@ -314,7 +314,7 @@ $(BUILD_DIR)/src/libultra/libc/llcvt.c.o: src/libultra/libc/llcvt.c
@$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s)

$(BUILD_DIR)/%.s.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
iconv --from UTF-8 --to EUC-JP $^ | $(AS) $(ASFLAGS) -o $@

$(BUILD_DIR)/%.bin.o: %.bin
$(LD) -r -b binary -o $@ $<
Expand Down
12 changes: 6 additions & 6 deletions include/libleo/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ typedef struct {
} __LOCTime; // size = 0x6

/* libleo conversion tables */
extern const u8 LEOBYTE_TBL1[];
extern const u16 LEOBYTE_TBL2[];
extern const u8 LEOBYTE_TBL1[9];
extern const u16 LEOBYTE_TBL2[9];
extern const u16 LEOVZONE_TBL[][0x10];
extern const u16 LEOZONE_SCYL_TBL[];
extern const u16 LEOZONE_SCYL_TBL[16];
extern const u8 LEOVZONE_PZONEHD_TBL[][0x10];
extern const u16 LEOZONE_OUTERCYL_TBL[];
extern const u16 LEORAM_START_LBA[];
extern const s32 LEORAM_BYTE[];
extern const u16 LEOZONE_OUTERCYL_TBL[8];
extern const u16 LEORAM_START_LBA[7];
extern const s32 LEORAM_BYTE[7];

/* Memory Map */
#define LEO_BASE_REG 0x05000000
Expand Down
64 changes: 50 additions & 14 deletions splat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ segments:
- [0x50C20, asm]
- [0x50CC0, asm]
- [0x517A0, asm] # yay0 audio decoder
- [0x51850, asm]
- [0x518A0, asm]
- [0x51B20, asm]
- [0x51BC0, c, libleo/readwrite]
Expand Down Expand Up @@ -324,40 +325,75 @@ segments:

# .data is somewhere in here
- [0x6A1B0, .data, crash_screen]
- [0x6A3B0, bin, rom_data_6A3B0]
- [0x6A3B0, data, rom_data_6A3B0]
- [0x6A3D0, .data, gb_tower]
- [0x6A3E0, bin, rom_data_6A3E0]
- [0x6A3E0, data, rom_data_6A3E0]
- [0x7A180, .data, libleo/driverominit]
- [0x7A190, bin, rom_data_7A190]
- [0x7A190, data, rom_data_7A190]
- [0x7A2A0, .data, libultra/os/initialize]
- [0x7A2C0, .data, libultra/al/reverb]
- [0x7A2E0, bin, rom_data_7A2E0]
- [0x7A2E0, data, rom_data_7A2E0]
- [0x7B550, .data, libultra/gu/random]
- [0x7B560, .data, libultra/libc/xprintf]
- [0x7B5B0, .data, libultra/os/timerintr]
- [0x7B5C0, .data, libultra/al/drvrNew]
- [0x7B750, .data, libultra/al/env]
- [0x7B890, .data, libultra/io/vi]
- [0x7B900, bin, rom_data_7B900]
- [0x7B900, data, rom_data_7B900]
- [0x7B9F0, .data, libultra/io/gbpakreadid]
- [0x7BA40, .data, libultra/io/cartrominit]
- [0x7BA50, bin, rom_data_7BA50]
- [0x7BA50, data, rom_data_7BA50]
- [0x7BA60, .data, libultra/libc/xlitob]
- [0x7BA90, .data, libultra/io/vimgr]
- [0x7BAB0, .data, libultra/io/aisetnextbuf]
- [0x7BAC0, bin, rom_data_7BAC0]
- [0x7BAC0, data, rom_data_7BAC0]

# Start of .rodata
- [0x7BAC0, .rodata, rsp]
- [0x7BB10, bin, rom_rodata_7BB10]
- [0x7BB10, rodata, rom_rodata_7BB10]
- [0x7BB20, rodata, rom_rodata_7BB20]
- [0x7BB50, rodata, rom_rodata_7BB50]
- [0x7BBE0, .rodata, crash_screen]
- [0x7BFA0, bin, rom_rodata_7BFA0]
- [0x7BFA0, rodata, rom_rodata_7BFA0]
- [0x7BFC0, .rodata, gb_tower]
- [0x7C000, bin, rom_rodata_7C000]
- [0x7C000, rodata, rom_rodata_7C000]
- [0x7C180, rodata, rom_rodata_7C180]
- [0x7C190, rodata, rom_rodata_7C190]
- [0x7CCA0, rodata, rom_rodata_7CCA0]
- [0x7CD10, rodata, rom_rodata_7CD10]
- [0x7CD40, rodata, rom_rodata_7CD40]
- [0x7CEC0, rodata, rom_rodata_7CEC0]
- [0x7CFD0, rodata, rom_rodata_7CFD0]
- [0x7D030, rodata, rom_rodata_7D030]
- [0x7D040, rodata, rom_rodata_7D040]
- [0x7D0F0, rodata, rom_rodata_7D0F0]
- [0x7D110, rodata, rom_rodata_7D110]
- [0x7D1B0, rodata, rom_rodata_7D1B0]
- [0x7D230, rodata, rom_rodata_7D230]
- [0x7D340, rodata, rom_rodata_7D340]
- [0x7D3E0, rodata, rom_rodata_7D3E0]
- [0x7D880, rodata, rom_rodata_7D880]
- [0x7DF80, rodata, rom_rodata_7DF80]
- [0x7DFD0, rodata, rom_rodata_7DFD0]
- [0x7E0D0, rodata, rom_rodata_7E0D0]
- [0x7E0E0, rodata, rom_rodata_7E0E0]
- [0x7E110, rodata, rom_rodata_7E110]
- [0x7E2F0, rodata, rom_rodata_7E2F0]
- [0x7E560, rodata, rom_rodata_7E560]
- [0x7E5D0, rodata, rom_rodata_7E5D0]
- [0x7E600, rodata, rom_rodata_7E600]
- [0x7E630, .rodata, libleo/leofunc]
- [0x7E640, .rodata, libleo/leocmdex]
- [0x7E6F0, rodata, rom_rodata_7E6F0]
- [0x7E700, .rodata, libleo/leomecha]
- [0x7E770, .rodata, libleo/leo_tbl]
- [0x7E950, rodata, rom_rodata_7E950]
- [0x7ED50, .rodata, libleo/leoc2ecc]
- [0x7ED70, .rodata, libleo/leomseq_tbl]
- [0x7EDF0, .rodata, libleo/leotimer]
- [0x7EE10, bin, rom_rodata_7EE10]
- [0x7EE10, rodata, rom_rodata_7EE10]
- [0x7EE90, .rodata, libultra/gu/sinf]
- [0x7EEE0, bin, rom_rodata_7EEE0]
- [0x7EEE0, rodata, rom_rodata_7EEE0]
- [0x7EF30, .rodata, libultra/al/reverb]
- [0x7EF60, .rodata, libultra/gu/perspective]
- [0x7EF70, .rodata, libultra/io/devmgr]
Expand All @@ -369,11 +405,11 @@ segments:
- [0x7F0E0, .rodata, libultra/al/env]
- [0x7F130, .rodata, libultra/al/resample]
- [0x7F180, .rodata, libultra/gu/cosf]
- [0x7F1D0, bin, rom_rodata_7F1D0]
- [0x7F1D0, rodata, rom_rodata_7F1D0]
- [0x7F1E0, .rodata, libultra/libc/xldtob]
- [0x7F240, .rodata, libultra/libc/llcvt]
- [0x7F250, bin, F3DEX2_data] # F3DEX2 data
- [0x7F670, bin, rom_rodata_7F670]
- [0x7F670, bin, unk_bin_7F670]
- [0x7F980]

# .bss
Expand Down
7 changes: 4 additions & 3 deletions src/43520.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ void func_800491C0(s32 arg0);
void func_8004FD90(void);

extern s32 D_80078580;
extern s32 D_80078584;

void func_80042920(s32 arg0, s32 arg1) {
extern void* D_80078584;

void func_80042920(void *arg0, s32 arg1) {
if (D_80078580 == 0) {
D_80078580 = arg0;
if (D_80078584 == 0) {
if (D_80078584 == NULL) {
D_80078584 = arg0;
func_800491C0(arg1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/4F7F0.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct UnkStruct8004EBF0 {
};
void func_80047500(void*, u8, void*, void*);
struct UnkArray4* func_800495F8();
struct UnkArray4* D_80078584;
extern struct UnkArray4* D_80078584; // who did this? fix later

void func_8004EBF0(struct UnkStruct8004EBF0* arg0, f32 arg1) {
struct UnkArray4 *temp_v0;
Expand Down
100 changes: 100 additions & 0 deletions src/libleo/leo_tbl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include <ultra64.h>
#include <leo.h>
#include "libleo/internal.h"

// file of magic tables used for libleo.

// Firmware revision of libleo library.
const char LEOfirmware_rev[] = "B014A26";

const u8 LEOBYTE_TBL1[9] = {
0xE8,
0xD8,
0xD0,
0xC0,
0xB0,
0xA0,
0x90,
0x80,
0x70
};

const u16 LEOBYTE_TBL2[9] = {
0x4D08,
0x47B8,
0x4510,
0x3FC0,
0x3A70,
0x3520,
0x2FD0,
0x2A80,
0x2530
};

const u16 LEOVZONE_TBL[][0x10] = {
{ 0x0124, 0x0248, 0x035A, 0x047E, 0x05A2, 0x06B4, 0x07C6, 0x08D8, 0x09EA, 0x0AB6, 0x0B82, 0x0C94, 0x0DA6, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x06A2, 0x07C6, 0x08D8, 0x09EA, 0x0AFC, 0x0BC8, 0x0C94, 0x0DA6, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08C6, 0x09EA, 0x0AFC, 0x0C0E, 0x0CDA, 0x0DA6, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AEA, 0x0C0E, 0x0D20, 0x0DEC, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AD8, 0x0BEA, 0x0D0E, 0x0E32, 0x0EFE,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x0980, 0x0A92, 0x0BA4, 0x0CB6, 0x0DC8, 0x0EEC,
0x1010, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94,
0x0FB8, 0x10DC },
};

const u16 LEOZONE_SCYL_TBL[16] = {
0x0000,
0x009E,
0x013C,
0x01D1,
0x0266,
0x02FB,
0x0390,
0x0425,
0x0091,
0x012F,
0x01C4,
0x0259,
0x02EE,
0x0383,
0x0418,
0x048A
};

const u8 LEOVZONE_PZONEHD_TBL[][0x10] = {
{ 0x00, 0x01, 0x02, 0x09, 0x08, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A },
{ 0x00, 0x01, 0x02, 0x03, 0x0A, 0x09, 0x08, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x0B, 0x0A, 0x09, 0x08, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x06, 0x07, 0x0F, 0x0E, 0x0D },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x0F, 0x0E },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x0F },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 }
};

const u16 LEOZONE_OUTERCYL_TBL[8] = { 0x0000, 0x009E, 0x013C, 0x01D1, 0x0266, 0x02FB, 0x0390, 0x0425 };

const u16 LEORAM_START_LBA[7] = {
0x05A2,
0x07C6,
0x09EA,
0x0C0E,
0x0E32,
0x1010,
0x10DC
};

const s32 LEORAM_BYTE[7] = {
0x024A9DC0,
0x01C226C0,
0x01450F00,
0x00D35680,
0x006CFD40,
0x001DA240,
0x00000000
};
8 changes: 4 additions & 4 deletions src/libleo/leocmdex.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

extern u16 LEOrw_flags;

// D_8007DA40
const u8 leo_sys_form_lbas[] = {0, 1, 8, 9, 0, 0, 0, 0}; // EXTRA 0 IS A HACK

#pragma GLOBAL_ASM("asm/nonmatchings/libleo/leocmdex/leomain.s")

/*const LEOCmdRead leo_sys_read_cmd =
{
{LEO_COMMAND_READ,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00000000},
12,1,0,0
};
const u8 leo_sys_form_lbas[] = {0, 1, 8, 9};*/
};*/

extern LEOCmdRead leo_sys_read_cmd;
extern u8 leo_sys_form_lbas[];

u8 leoRead_system_area(void) {
LEOCmdRead temp_cmd;
Expand Down
12 changes: 3 additions & 9 deletions src/libleo/leofunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

const u8 LEO_ZERO_MESG[] = { 0 };

#ifdef NON_MATCHING
// https://decomp.me/scratch/dB2K5
void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size) {
u32 savedMask;
OSPri oldPri;
Expand Down Expand Up @@ -35,11 +33,10 @@ void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_
osCreateMesgQueue(&LEOdma_que, LEOdma_que_buf, ARRAY_COUNT(LEOdma_que_buf));
osCreateMesgQueue(&LEOblock_que, LEOblock_que_buf, ARRAY_COUNT(LEOblock_que_buf));
osCreateMesgQueue(&LEOpost_que, LEOpost_que_buf, ARRAY_COUNT(LEOpost_que_buf));
osCreateThread(&LEOcommandThread, 1, leomain, NULL, LEOcommandThreadStack + sizeof(LEOcommandThreadStack), compri);
osCreateThread(&LEOcommandThread, 1, leomain, NULL, LEOcommandThreadStack, compri);
osStartThread(&LEOcommandThread);
// LEOinterruptThreadStack reused the same memory address (D_80100638) as LEOcommand_que
// This won't compile
osCreateThread(&LEOinterruptThread, 1, leointerrupt, NULL, LEOinterruptThreadStack + sizeof(LEOinterruptThreadStack), intpri);
osCreateThread(&LEOinterruptThread, 1, leointerrupt, NULL,
LEOinterruptThreadStack, intpri);
osStartThread(&LEOinterruptThread);
osSetEventMesg(OS_EVENT_CART, &LEOevent_que, (OSMesg)0x30000);
osSendMesg(&LEOblock_que, NULL, 0);
Expand All @@ -49,9 +46,6 @@ void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_
osSetThreadPri(NULL, oldPri);
}
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/libleo/leofunc/leoInitialize.s")
#endif

void leoCommand(void* cmd_blk_addr) {
if (__leoResetCalled != 0) {
Expand Down
9 changes: 0 additions & 9 deletions src/libleo/leord_capa.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#include <ultra64.h>
#include "libleo/internal.h"

// static?
const u16 LEORAM_START_LBA[] = {
0x05A2, 0x07C6, 0x09EA, 0x0C0E, 0x0E32, 0x1010, 0x10DC,
};
// static?
const s32 LEORAM_BYTE[] = {
0x024A9DC0, 0x01C226C0, 0x01450F00, 0x00D35680, 0x006CFD40, 0x001DA240, 0x00000000,
};

void leoRd_capacity(void) {
if (LEOcur_command->header.control & LEO_CONTROL_WRT) {
LEOcur_command->data.readwrite.lba = LEORAM_START_LBA[LEOdisk_type] - 0x18;
Expand Down
17 changes: 0 additions & 17 deletions src/libleo/leoutil.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
#include <ultra64.h>
#include "libleo/internal.h"

const u16 LEOVZONE_TBL[][0x10] = {
{ 0x0124, 0x0248, 0x035A, 0x047E, 0x05A2, 0x06B4, 0x07C6, 0x08D8, 0x09EA, 0x0AB6, 0x0B82, 0x0C94, 0x0DA6, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x06A2, 0x07C6, 0x08D8, 0x09EA, 0x0AFC, 0x0BC8, 0x0C94, 0x0DA6, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08C6, 0x09EA, 0x0AFC, 0x0C0E, 0x0CDA, 0x0DA6, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AEA, 0x0C0E, 0x0D20, 0x0DEC, 0x0EB8,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AD8, 0x0BEA, 0x0D0E, 0x0E32, 0x0EFE,
0x0FCA, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x0980, 0x0A92, 0x0BA4, 0x0CB6, 0x0DC8, 0x0EEC,
0x1010, 0x10DC },
{ 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94,
0x0FB8, 0x10DC },
};

u16 leoLba_to_phys(u32 lba) {
u32 vzone;
u32 pzone;
Expand Down
1 change: 1 addition & 0 deletions undefined_syms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CartRomHandle = 0x80102430;
LeoDiskHandle = 0x801024A8;
piThreadStack = 0x801026D0;
LEOZONE_OUTERCYL_TBL = 0x8007DD08;
LEOinterruptThreadStack = 0x80100638;

0 comments on commit 760153e

Please sign in to comment.