summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2024-12-22 23:48:13 +0000
committerGitHub <noreply@github.com>2024-12-22 15:48:13 -0800
commit06b06ab50759d1b92fe0a3510453a11454d9409c (patch)
treec4a14c616087f4cf55b1900fd8b2380c71b598fb
parent187e75c4417f3a2b5373be4610adcf836dba93a1 (diff)
Check in makerom files (#1758)
* Check in makerom files * Fix disasm for asm files in src
-rw-r--r--Makefile3
-rw-r--r--include/PR/asm.h85
-rw-r--r--include/boot.h6
-rw-r--r--spec6
-rw-r--r--src/boot/boot_main.c3
-rw-r--r--src/makerom/entry.s34
-rw-r--r--src/makerom/ipl3.s2
-rw-r--r--src/makerom/rom_header.s15
-rwxr-xr-xtools/disasm/disasm.py12
9 files changed, 156 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 5caf087bd..38b60cb6d 100644
--- a/Makefile
+++ b/Makefile
@@ -315,7 +315,8 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG_EXTRACTED:.png=.inc.c),$(f:
ASSET_C_FILES_EXTRACTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.c)))
ASSET_C_FILES_COMMITTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.c)))
C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard $(dir)/*.c))
-S_FILES := $(shell grep -F "\$$(BUILD_DIR)/asm" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/') \
+S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s)) \
+ $(shell grep -F "\$$(BUILD_DIR)/asm" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/') \
$(shell grep -F "\$$(BUILD_DIR)/data" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/')
SCHEDULE_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.schl))
BASEROM_FILES := $(shell grep -F "\$$(BUILD_DIR)/baserom" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*//')
diff --git a/include/PR/asm.h b/include/PR/asm.h
new file mode 100644
index 000000000..d5058f5c1
--- /dev/null
+++ b/include/PR/asm.h
@@ -0,0 +1,85 @@
+#ifndef PR_ASM_H
+#define PR_ASM_H
+
+#ifdef __sgi
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#endif
+
+#ifndef _LANGUAGE_C
+
+#define LEAF(x) \
+ .balign 4 ;\
+ .globl x ;\
+ .type x, @function ;\
+ x: ;\
+ .ent x, 0 ;\
+ .frame $sp, 0, $ra
+
+#define XLEAF(x) \
+ .balign 4 ;\
+ .globl x ;\
+ .type x, @function ;\
+ x: ;\
+ .aent x, 0
+
+#define NESTED(x, fsize, ra) \
+ .globl x ;\
+ x: ;\
+ .ent x, 0 ;\
+ .frame $sp, fsize, ra
+
+#define XNESTED(x) \
+ .globl x ;\
+ x: ;\
+ .aent x, 0
+
+#define END(x) \
+ .size x, . - x ;\
+ .end x
+
+#define IMPORT(x, size) \
+ .extern x, size
+
+#define EXPORT(x) \
+ .globl x ;\
+ x:
+
+#define DATA(x) \
+ .balign 4 ;\
+ .globl x ;\
+ .type x, @object ;\
+ x:
+
+#define ENDDATA(x) \
+ .size x, . - x
+
+#endif
+
+/**
+ * Stack Alignment
+ */
+#if (_MIPS_SIM == _ABIO32)
+#define NARGSAVE 4 // space for 4 args must be allocated
+#define ALSZ (8-1)
+#define ALMASK ~(8-1)
+#elif (_MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64)
+#define NARGSAVE 0 // no caller responsibilities
+#define ALSZ (16-1)
+#define ALMASK ~(16-1)
+#endif
+
+#define FRAMESZ(size) (((size) + ALSZ) & ALMASK)
+
+/**
+ * Register Size
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2)
+#define SZREG 4
+#elif (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
+#define SZREG 8
+#endif
+
+#endif
diff --git a/include/boot.h b/include/boot.h
new file mode 100644
index 000000000..b0c1a50f0
--- /dev/null
+++ b/include/boot.h
@@ -0,0 +1,6 @@
+#ifndef BOOT_H
+#define BOOT_H
+
+#define BOOT_STACK_SIZE 0x400
+
+#endif
diff --git a/spec b/spec
index d5c82aa76..68430e396 100644
--- a/spec
+++ b/spec
@@ -12,9 +12,9 @@ endseg
beginseg
name "makerom"
address 0x8007F000
- include "$(BUILD_DIR)/asm/makerom/rom_header.o"
- include "$(BUILD_DIR)/asm/makerom/ipl3.o"
- include "$(BUILD_DIR)/asm/makerom/entry.o"
+ include "$(BUILD_DIR)/src/makerom/rom_header.o"
+ include "$(BUILD_DIR)/src/makerom/ipl3.o"
+ include "$(BUILD_DIR)/src/makerom/entry.o"
endseg
beginseg
diff --git a/src/boot/boot_main.c b/src/boot/boot_main.c
index 1ce87d3b0..df67fa38c 100644
--- a/src/boot/boot_main.c
+++ b/src/boot/boot_main.c
@@ -1,3 +1,4 @@
+#include "boot.h"
#include "carthandle.h"
#include "CIC6105.h"
#include "idle.h"
@@ -9,7 +10,7 @@ StackEntry sBootStackInfo;
OSThread sIdleThread;
STACK(sIdleStack, 0x400);
StackEntry sIdleStackInfo;
-STACK(sBootStack, 0x400);
+STACK(sBootStack, BOOT_STACK_SIZE);
void bootproc(void) {
StackCheck_Init(&sBootStackInfo, sBootStack, STACK_TOP(sBootStack), 0, -1, "boot");
diff --git a/src/makerom/entry.s b/src/makerom/entry.s
new file mode 100644
index 000000000..e28bc8b50
--- /dev/null
+++ b/src/makerom/entry.s
@@ -0,0 +1,34 @@
+#include "PR/asm.h"
+#include "boot.h"
+
+.set noreorder
+
+.section .text
+
+.balign 16
+
+LEAF(entrypoint)
+ // Clear boot segment .bss
+ la $t0, _bootSegmentBssStart
+#ifndef AVOID_UB
+ // UB: li only loads the lower 16 bits of _bootSegmentBssSize when it may be larger than this,
+ // so not all of bss may be cleared if it is too large
+ li $t1, _bootSegmentBssSize
+#else
+ la $t1, _bootSegmentBssSize
+#endif
+.clear_bss:
+ addi $t1, $t1, -8
+ sw $zero, 0($t0)
+ sw $zero, 4($t0)
+ bnez $t1, .clear_bss
+ addi $t0, $t0, 8
+ // Set up stack and enter program code
+ lui $t2, %hi(bootproc)
+ lui $sp, %hi(sBootStack + BOOT_STACK_SIZE)
+ addiu $t2, %lo(bootproc)
+ jr $t2
+ addiu $sp, %lo(sBootStack + BOOT_STACK_SIZE)
+END(entrypoint)
+
+.fill 0x60 - (. - entrypoint)
diff --git a/src/makerom/ipl3.s b/src/makerom/ipl3.s
new file mode 100644
index 000000000..22ae65250
--- /dev/null
+++ b/src/makerom/ipl3.s
@@ -0,0 +1,2 @@
+.text
+.incbin "extracted/n64-us/baserom/makerom", 0x40, 0xFC0
diff --git a/src/makerom/rom_header.s b/src/makerom/rom_header.s
new file mode 100644
index 000000000..22c209ae0
--- /dev/null
+++ b/src/makerom/rom_header.s
@@ -0,0 +1,15 @@
+#include "rom_header.h"
+
+/* 0x00 */ ENDIAN_IDENTIFIER
+/* 0x01 */ PI_DOMAIN_1_CFG(64, 18, 7, 3)
+/* 0x04 */ SYSTEM_CLOCK_RATE_SETTING(0xF)
+/* 0x08 */ ENTRYPOINT(entrypoint)
+/* 0x0C */ LIBULTRA_VERSION(2, 0, K)
+/* 0x10 */ CHECKSUM()
+/* 0x18 */ PADDING(8)
+/* 0x20 */ ROM_NAME("ZELDA MAJORA'S MASK")
+/* 0x34 */ PADDING(7)
+/* 0x3B */ MEDIUM(CARTRIDGE)
+/* 0x3C */ GAME_ID("ZS")
+/* 0x3E */ REGION(US)
+/* 0x3F */ GAME_REVISION(0)
diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py
index f4b5c3e18..1d6955652 100755
--- a/tools/disasm/disasm.py
+++ b/tools/disasm/disasm.py
@@ -118,9 +118,12 @@ def discard_decomped_files(files_spec, include_files):
.split("$(BUILD_DIR)/", 1)[1]
.replace(".o", ".c")[:-1]
)
- with open(root_path / last_line, "r") as f2:
- if "GLOBAL_ASM" in f2.read():
- include = True
+ if os.path.exists(root_path / last_line):
+ with open(root_path / last_line, "r") as f2:
+ if "GLOBAL_ASM" in f2.read():
+ include = True
+ else:
+ assert os.path.exists(root_path / last_line.replace(".c", ".s"))
include |= force_include
if include:
@@ -131,8 +134,7 @@ def discard_decomped_files(files_spec, include_files):
continue
if included:
f[4] = new_files
-
- new_spec.append(f)
+ new_spec.append(f)
return new_spec