Skip to content

Commit

Permalink
Fault OK (#35)
Browse files Browse the repository at this point in the history
* Fault OK

* Small cleanups

* typo

* PR

* Splat ext to extract font

* Format

* newline

* small cleanups
  • Loading branch information
hensldm authored Dec 9, 2023
1 parent 8d9b289 commit e2bf753
Show file tree
Hide file tree
Showing 14 changed files with 975 additions and 32 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ SPLAT_YAML ?= $(TARGET).$(VERSION).yaml



IINC := -Iinclude -Ibin/$(VERSION) -I.
IINC := -Iinclude -I.
IINC += -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ilib/ultralib/include/ido

ifeq ($(KEEP_MDEBUG),0)
Expand Down Expand Up @@ -169,11 +169,11 @@ endif

#### Files ####

$(shell mkdir -p asm bin linker_scripts/$(VERSION)/auto)
$(shell mkdir -p asm assets linker_scripts/$(VERSION)/auto)

SRC_DIRS := $(shell find src -type d)
ASM_DIRS := $(shell find asm/$(VERSION) -type d -not -path "asm/$(VERSION)/nonmatchings/*")
BIN_DIRS := $(shell find bin -type d)
BIN_DIRS := $(shell find assets -type d)

C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
S_FILES := $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(wildcard $(dir)/*.s))
Expand All @@ -195,6 +195,7 @@ $(shell mkdir -p $(BUILD_DIR)/linker_scripts/$(VERSION) $(BUILD_DIR)/linker_scri
build/src/main/O2/%.o: OPTFLAGS := -O2

# per-file flags
build/src/main/fault.o: CFLAGS += -trapuv

# cc & asm-processor
build/src/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) --
Expand All @@ -211,18 +212,18 @@ ifneq ($(COMPARE),0)
endif

clean:
$(RM) -r $(BUILD_DIR)/asm $(BUILD_DIR)/bin $(BUILD_DIR)/src $(ROM) $(ELF)
$(RM) -r $(BUILD_DIR)/asm $(BUILD_DIR)/assets $(BUILD_DIR)/src $(ROM) $(ELF)

distclean: clean
$(RM) -r $(BUILD_DIR) asm/ bin/ .splat/
$(RM) -r $(BUILD_DIR) asm/ assets/ .splat/
$(RM) -r linker_scripts/$(VERSION)/auto $(LD_SCRIPT)
$(MAKE) -C tools distclean

setup:
$(MAKE) -C tools

extract:
$(RM) -r asm/$(VERSION) bin/$(VERSION)
$(RM) -r asm/$(VERSION) assets/$(VERSION)
$(CAT) yamls/$(VERSION)/header.yaml yamls/$(VERSION)/makerom.yaml yamls/$(VERSION)/main.yaml > $(SPLAT_YAML)
$(SPLAT) $(SPLAT_FLAGS) $(SPLAT_YAML)

Expand Down
1 change: 0 additions & 1 deletion checksum.md5

This file was deleted.

34 changes: 34 additions & 0 deletions include/alignment.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef ALIGNMENT_H
#define ALIGNMENT_H

#include "attributes.h"

#define ALIGN8(val) (((val) + 7) & ~7)
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
#define ALIGN32(val) (((val) + 0x1F) & ~0x1F)
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
#define ALIGN256(val) (((val) + 0xFF) & ~0xFF)

#ifndef ALIGNED
#define ALIGNED(x) __attribute__ ((aligned (x)))
#endif

#ifdef __sgi /* IDO compiler */
#define UNALIGNED __unaligned
#else
#define UNALIGNED
#endif

#ifdef __sgi /* IDO compiler */
#define ALIGNOF(x) __builtin_alignof(x)
#elif (__STDC_VERSION__ >= 201112L) /* C11 */
#define ALIGNOF(x) _Alignof(x)
#else /* __GNUC__ */
#define ALIGNOF(x) __alignof__(x)
#endif

#define ALIGN_MASK(n) (~((n) - 1))

#define ALIGNOF_MASK(x) ALIGN_MASK(ALIGNOF(x))

#endif
10 changes: 10 additions & 0 deletions include/fault.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef FAULT_H
#define FAULT_H

#include "ultra64.h"

void Fault_SetFramebuffer(u16* fb, u16 width, u16 depth);
void Fault_Init(void);
void Fault_HungUp(const char* file, s32 line);

#endif
27 changes: 27 additions & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@
#include "unk.h"
#include "ys64math.h"

struct Input;

typedef struct MallocRecord {
/* 0x00 */ UNK_TYPE allocP;
/* 0x04 */ UNK_TYPE requestSize;
/* 0x08 */ UNK_TYPE totalFree;
/* 0x0C */ UNK_TYPE totalAlloc;
/* 0x10 */ UNK_TYPE blockCnt;
} MallocRecord; // size >= 0x14

extern MallocRecord mallocRecord;

extern UNK_TYPE D_800DA83C;
extern UNK_TYPE D_8010DF40;

typedef struct Y511F0UnkStruct {
/* 0x0 */ uintptr_t unk0;
/* 0x4 */ s16 unk4;
/* 0x8 */ uintptr_t unk8;
/* 0xC */ uintptr_t unkC;
} Y511F0UnkStruct; // size = 0x10

extern Y511F0UnkStruct D_800DA840[];

// 740F0
void func_80074C88(UNK_PTR, struct Input*, s32);

// malloc
void* func_80064DD0(u32 size);

Expand Down
8 changes: 8 additions & 0 deletions include/sleep.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef SLEEP_H
#define SLEEP_H

#include "ultra64.h"

void csleep(OSTime t);

#endif
12 changes: 12 additions & 0 deletions include/stack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef STACK_H
#define STACK_H

#include "alignment.h"

#define STACK(stack, size) \
u64 stack[ALIGN8(size) / sizeof(u64)]

#define STACK_TOP(stack) \
((u8*)(stack) + sizeof(stack))

#endif
9 changes: 9 additions & 0 deletions include/ys64thread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef YS64_THREAD_H
#define YS64_THREAD_H

#define Y_THREAD_ID_FAULT 2

#define Y_PRIORITY_FAULT OS_PRIORITY_APPMAX


#endif
14 changes: 14 additions & 0 deletions linker_scripts/us/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ entrypoint = 0x80000400;

bootproc = 0x8006743C;

Fault_SetFramebuffer = 0x80071250; // type:func
Fault_Init = 0x8007127C; // type:func
Fault_HungUp = 0x80071380; // type:func

ViMode_Init = 0x8007EA54;

gfxprint_setup = 0x8007EF00; // type:func
Expand Down Expand Up @@ -92,6 +96,16 @@ aprintf = 0x80082174;
csleep = 0x800821A0;

// data
mallocRecord = 0x800A65AC; // type:MallocRecord size:0x14

fault_exit = 0x800A8000;
fault_msg_id = 0x800A8004;
fault_display_enable = 0x800A8008;
sFaultFont = 0x800A800C; // type:u32
sExceptionNames = 0x800A840C; // size:0x48
sFpExceptionNames = 0x800A8454; // size:0x18
sFaultFontColor = 0x800A846C; // type:u16 size:0x2

gfxprint_moji_tlut = 0x800A9A60;
gfxprint_rainbow_tlut = 0x800A9AE0;
gfxprint_font = 0x800A9B08;
Expand Down
Loading

0 comments on commit e2bf753

Please sign in to comment.