Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial work on shifting, 1 #91

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified calcprogress.py
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern void _bcopy(void *, void *, u32);

// 3FB0.s
extern void func_80003B30(void *, s32, s32, s32); // types unknown
extern void func_80004200();

// 5580.s
extern void func_80004CC0(OSThread *, s32, s32);
Expand Down
28 changes: 25 additions & 3 deletions include/fragments.h → include/sections.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _FRAGMENTS_H_
#define _FRAGMENTS_H_
#ifndef _SECTIONS_H_
#define _SECTIONS_H_

// fragment 1
extern u8 fragment1_TEXT_START[];
Expand Down Expand Up @@ -386,4 +386,26 @@ extern u8 fragment77_TEXT_START[];
extern u8 fragment77_ROM_START[];
extern u8 fragment77_ROM_END[];

#endif // _FRAGMENTS_H_
// Asset externs

extern u8 _3B96B0_ROM_START[];
extern u8 _3BA190_ROM_START[];
extern u8 _3CB130_ROM_START[];
extern u8 _45B580_ROM_START[];
extern u8 _4A21C0_ROM_START[];
extern u8 _4BD6B0_ROM_START[];
extern u8 _4BE810_ROM_START[];
extern u8 _4D1330_ROM_START[];
extern u8 _4EB0C0_ROM_START[];
extern u8 _5046B0_ROM_START[];
extern u8 _52ABA0_ROM_START[];
extern u8 _52F6D0_ROM_START[];
extern u8 _533B20_ROM_START[];
extern u8 _56E7D0_ROM_START[];
extern u8 _5C7A70_ROM_START[];
extern u8 _5C7AD0_ROM_START[];
extern u8 _5F6790_ROM_START[];
extern u8 _5F92A0_ROM_START[];
extern u8 _5FFC30_ROM_START[];

#endif // _SECTIONS_H_
2 changes: 2 additions & 0 deletions include/ultra64.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
#include "functions.h"
#include "variables.h"

#include "sections.h"

#endif
92 changes: 84 additions & 8 deletions splat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,31 @@ segments:
- [0x23C270, c, fragments/29/fragment29_code]
- [0x23D3C0, data, fragments/29/fragment29_data]
- [0x23D430, bin, fragments/29/fragment29_reloc]

- name: fragment29_misc_1
type: code
bss_size: 0x0
start: 0x23D500
vram: 0x88910000 # unk VRAM, shuts linker up
subsegments:
- [0x23D500, bin, fragments/29/fragment29_unk_bin_1] # PERS-SZP file, pokeball, c buttons etc textures

- name: fragment29_misc_2
type: code
bss_size: 0x0
start: 0x23FB60
vram: 0x88920000 # unk VRAM, shuts linker up
subsegments:
- [0x23FB60, bin, fragments/29/fragment29_unk_bin_2] # PERS-SZP file, pokeball, c buttons etc textures

- name: fragment29_misc_3
type: code
bss_size: 0x0
start: 0x24F430
vram: 0x88920000 # unk VRAM, shuts linker up
subsegments:
- [0x24F430, bin, fragments/29/fragment29_unk_bin_3] # PERS-SZP file, pokeball, c buttons etc textures

- name: fragment30
type: code
bss_size: 0x0
Expand Down Expand Up @@ -880,6 +903,13 @@ segments:
- [0x25ECF0, data, fragments/33/fragment33_data]
- [0x25F020, rodata, fragments/33/fragment33_rodata]
- [0x25F070, bin, fragments/33/fragment33_reloc]

- name: fragment33_misc
type: code
bss_size: 0x0
start: 0x25F440
vram: 0x81310000 # unk vram, shuts linker up
subsegments:
- [0x25F440, bin, fragments/33/fragment33_unk_bin_1] # PRES-JPEG, transfer machine background

# alternative pokemon textures pointer loader
Expand Down Expand Up @@ -1408,12 +1438,58 @@ segments:
- [0x3B9640, c, fragments/77/fragment77_code]
- [0x3B96A0, bin, fragments/77/fragment77_reloc]

# Rest of the ROM
- name: assets
type: code
bss_size: 0x0
start: 0x3B96B0
vram: 0x80000000 # unknown vram
subsegments:
- [0x3B96B0, bin]
- [0x3B96B0, bin]
- [0x3BA190, bin]
- [0x3CB130, bin]
- [0x45B580, bin]
- [0x4A21C0, bin]
- [0x4BD6B0, bin]
- [0x4BE810, bin]
- [0x4D1330, bin]
- [0x4EB0C0, bin]
- [0x5046B0, bin]
- [0x52ABA0, bin]
- [0x52F6D0, bin]
- [0x533B20, bin]
- [0x56E7D0, bin]
- [0x5C7A70, bin]
- [0x5C7AD0, bin]
- [0x5F6790, bin]
- [0x5F92A0, bin]
- [0x5FFC30, bin]
- [0x613110, bin]
- [0x6230D0, bin]
- [0x66E1D0, bin]
- [0x66F540, bin]
- [0x66FD80, bin]
- [0x675FA0, bin]
- [0x696350, bin]
- [0x69D090, bin]
- [0x6A9750, bin]
- [0x6AE1D0, bin]
- [0x6B0FB0, bin]
- [0x6B4F00, bin]
- [0x6C1AB0, bin]
- [0x6C4CE0, bin]
- [0x6C4E50, bin]
- [0x6CA730, bin]
- [0x6E2FC0, bin]
- [0x6E8910, bin]
- [0x6EB340, bin]
- [0x6EC4D0, bin]
- [0x6ECE80, bin]
- [0x701E50, bin]
- [0x70D3A0, bin]
- [0x7820E0, bin]
- [0x783760, bin]
- [0x798CD0, bin]
- [0x7994B0, bin]
- [0x79AFB0, bin]
- [0x79B8F0, bin] # not a file, just so it doesnt complain
- [0x7C0000]

# rest of ROM.. part 2. This area and beyond NEEDS to be hard-aligned to this address.
# for the ROM to be shiftable, we need a way to fix this area beyond here to this address and for the prior area
# to be filled with FFs instead of being binned. TODO: Make it shift
- [0x7C0000, bin]
- [0x2000000]
13 changes: 11 additions & 2 deletions src/29BA0.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#include "common.h"
#include <ultra64.h>
#include "memory.h"

#pragma GLOBAL_ASM("asm/nonmatchings/29BA0/func_80028FA0.s")

#pragma GLOBAL_ASM("asm/nonmatchings/29BA0/func_80029008.s")
s32 func_80029008(s32 arg0, s32 romStart, s32 romEnd, s32 arg3, s32 arg4) {
s32 result;
s32 (*func)(s32, s32);

func = func_80004454(arg0, romStart, romEnd);
result = func(arg3, arg4);
main_pool_try_free(func);
return result;
}

#pragma GLOBAL_ASM("asm/nonmatchings/29BA0/func_80029048.s")

Expand Down
111 changes: 106 additions & 5 deletions src/3FB0.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "common.h"
#include <ultra64.h>
#include "memory.h"

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_800033B0.s")

Expand Down Expand Up @@ -32,7 +33,43 @@

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80003D64.s")

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80003DC4.s")
void* func_80003DC4(uintptr_t romStart, uintptr_t romEnd, s32 arg2, s32 arg3) {
u32* addr;
u32* newaddr;
u32* ret;
s32 pad;
int side;

side = (arg2 == 0) ? MEMORY_POOL_RIGHT : MEMORY_POOL_LEFT;

addr = main_pool_alloc(0x18, side);
if (addr != NULL) {
func_80003B30(addr, romStart, romStart + 0x18, arg3);
// is PERS-SZP?
if ((addr[0] == 'PERS') && (addr[1] == '-SZP')) {
newaddr = main_pool_alloc(ALIGN16(romEnd - romStart), side);
if (newaddr != NULL) {
func_80003B30(newaddr, romStart, romEnd, arg3);
ret = func_80003D18(newaddr, newaddr, arg2);
}
// is PRESJPEG?
} else if ((addr[0] == 'PRES') && (addr[1] == 'JPEG')) {
newaddr = main_pool_alloc(ALIGN16(romEnd - romStart), side);
if (newaddr != NULL) {
func_80003B30(newaddr, romStart, romEnd, arg3);
ret = func_80003C80(newaddr, newaddr, arg2);
}
} else {
newaddr = main_pool_alloc(ALIGN16(romEnd - romStart), arg2);
ret = newaddr;
if (newaddr != NULL) {
func_80003B30(ret, romStart, romEnd, arg3);
}
}
main_pool_try_free(addr);
}
return ret;
}

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80003F54.s")

Expand All @@ -44,19 +81,83 @@

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80004200.s")

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80004258.s")
s32 func_80004258(s32 id, s32 arg1, s32 arg2, s32 arg3) {
s32 vaddr = func_80003DC4(arg1, arg2, arg3, 0);

if ((vaddr != 0) && (id > 0)) {
Memmap_SetSegmentMap(id, vaddr, main_pool_get_block_dist(vaddr));
main_pool_set_func(vaddr, id + 0x82000000, &func_80004200);
}
return vaddr;
}

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_800042E0.s")

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80004364.s")

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_800043BC.s")

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80004454.s")
void *func_80004454(s32 arg0, uintptr_t romStart, uintptr_t romEnd) {
void *addr = func_80003DC4(romStart, romEnd, 0, 0);

if (addr != NULL) {
func_800043BC(arg0, addr);
}
return addr;
}

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_800044A8.s")

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_800044F4.s")
void* func_800044F4(uintptr_t romStart, uintptr_t romEnd, s32 arg2, s32 arg3) {
u32* ret;
unsigned long sp28_2;
unsigned long sp28;
u16* newaddr;

ret = NULL;
switch (arg2) {
case 0:
newaddr = func_80003DC4(romStart, romEnd, 0, 0);
ret = newaddr;
if (newaddr != NULL) {
newaddr[0] |= 1;
}
break;
case 1:
newaddr = func_80003DC4(romStart, romStart + 0x20, 0, 0);
ret = newaddr;
if (newaddr != NULL) {
sp28_2 = (ret[3] * 0x10) + 0x10;
main_pool_try_free(ret);
newaddr = func_80003DC4(romStart, romStart + sp28_2, 0, 0);
ret = newaddr;
if (newaddr != NULL) {
*newaddr |= 2;
if (arg3 == 1) {
*newaddr |= 4;
}
}
}
break;
case 2:
newaddr = func_80003DC4(romStart, romStart + 0x20, 1, 0);
ret = newaddr;
if (newaddr != NULL) {
sp28 = (ret[3] * 0x10) + 0x10;
main_pool_try_free(ret);
newaddr = func_80003DC4(romStart, romStart + sp28, 1, 0);
ret = newaddr;
if ((newaddr != NULL) && (arg3 == 1)) {
*newaddr |= 4;
}
}
break;
}
if (ret != NULL) {
ret[1] = romStart;
}
return ret;
}

#pragma GLOBAL_ASM("asm/nonmatchings/3FB0/func_80004660.s")

Expand Down
8 changes: 2 additions & 6 deletions src/E1C0.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ultra64.h>
#include <PR/os_internal_reg.h>
#include "dp_intro.h"
#include "fragments.h"
#include "sections.h"
#include "memory.h"
#include "dp_intro.h"
#include "util.h"
Expand Down Expand Up @@ -32,10 +32,6 @@ extern char D_800AA668;

extern u8 D_81200000[];

// ROM offsets
extern u8 D_3BA190[];
extern u8 D_3CB130[];

// from fragment 1
void func_81206D9C(void);
void func_81206E64(void);
Expand Down Expand Up @@ -90,7 +86,7 @@ void func_8000D738(struct UnkInputStruct8000D738* arg0) {
D_800AA664 = main_pool_alloc(0x21E0, 0);
func_80004454(((u32)((u32)&fragment1_TEXT_START & 0x0FF00000) >> 0x14) - 0x10, &fragment1_ROM_START,
&fragment1_ROM_END);
temp_v0 = func_800044F4(&D_3BA190, &D_3CB130, 1, 1);
temp_v0 = func_800044F4(&_3BA190_ROM_START, &_3CB130_ROM_START, 1, 1);
D_800AA660->unk21FC = func_8000484C(temp_v0, 0);
D_800AA660->unk2200 = func_8000484C(temp_v0, 1);
D_800AA660->unk2204 = *arg0;
Expand Down
Empty file modified tools/m2ctx.py
100644 → 100755
Empty file.
Loading
Loading