Skip to content

Commit 2a9556c

Browse files
authored
Add autobuild (#1)
* add autobuilds * track game libs * track thumb compatiblity files
1 parent 7aed8d8 commit 2a9556c

File tree

16 files changed

+95642
-40
lines changed

16 files changed

+95642
-40
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
container: ghcr.io/yanis002/st-build:main
10+
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
version: [eur]
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: recursive
25+
26+
- name: Git config
27+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
28+
29+
- name: Prepare
30+
run: |
31+
mv /extract/* ./extract
32+
mv /tools/armips/* ./tools/armips
33+
34+
- name: Build
35+
run: |
36+
COMPARE=0 make init
37+
make

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extract/eu
66
extract/jp
77
extract/us
88
build/
9-
libs/*.a
9+
libs/libgz.a
1010

1111
# workspace files
1212
*.nds

Makefile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ STGZ_DECOMP_DIR ?= resources/decomp
4747
# game region, only eur is supported atm
4848
REGION := eur
4949
50+
COMPARE ?= 1
51+
5052
### project tools ###
5153
5254
MAKE = make
@@ -70,14 +72,15 @@ DSROM := tools/dsrom
7072
7173
# armips setup
7274
ARMIPS_DIR := tools/armips
73-
ARMIPS ?= $(ARMIPS_DIR)/build/armips
75+
ARMIPS ?= $(ARMIPS_DIR)/out/armips
7476
7577
# main source/objects
7678
BUILD_DIR := build/$(REGION)
77-
ASM_FILES := $(wildcard src/*.s)
78-
C_FILES := $(wildcard src/*.c)
79-
CPP_FILES := $(wildcard src/*.cpp)
80-
OBJ := $(foreach f,$(ASM_FILES),$(BUILD_DIR)/$(f:.s=.o)) $(foreach f,$(C_FILES),$(BUILD_DIR)/$(f:.c=.o)) $(foreach f,$(CPP_FILES),$(BUILD_DIR)/$(f:.cpp=.o)) $(BUILD_DIR)/thumb-$(REGION).o
79+
ALL_FILES := $(shell find src/ -path "src/thumb" -prune -o -print)
80+
ASM_FILES := $(filter %.s, $(ALL_FILES))
81+
C_FILES := $(filter %.c, $(ALL_FILES))
82+
CPP_FILES := $(filter %.cpp, $(ALL_FILES))
83+
OBJ := $(foreach f,$(ASM_FILES),$(BUILD_DIR)/$(f:.s=.o)) $(foreach f,$(C_FILES),$(BUILD_DIR)/$(f:.c=.o)) $(foreach f,$(CPP_FILES),$(BUILD_DIR)/$(f:.cpp=.o)) $(BUILD_DIR)/src/thumb/thumb-$(REGION).o
8184
DEPS := $(foreach f,$(ASM_FILES),$(BUILD_DIR)/$(f:.s=.d)) $(foreach f,$(C_FILES),$(BUILD_DIR)/$(f:.c=.d)) $(foreach f,$(CPP_FILES),$(BUILD_DIR)/$(f:.cpp=.d))
8285
8386
# hooks source/objects
@@ -111,8 +114,10 @@ RESERVED_SIZE := 0x10
111114
RESERVED_ADDR := $(shell $(PYTHON) -c "print(f'0x{$(OVLGZ_ADDR) + $(OVLGZ_SIZE) - $(RESERVED_SIZE):08X}')")
112115
113116
# compiler settings
114-
CC := arm-none-eabi-gcc -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s -nostdlib -nodefaultlibs -nostartfiles
115-
WARNINGS := -Wall -Wno-multichar -Wno-unknown-pragmas
117+
CFLAGS_BASE := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s -nostdlib -nodefaultlibs -nostartfiles
118+
CC := arm-none-eabi-gcc $(CFLAGS_BASE)
119+
CXX := arm-none-eabi-g++ $(CFLAGS_BASE)
120+
WARNINGS := -Wall -Wno-multichar -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-unused-variable
116121
INCLUDES := -I include -I $(STGZ_DECOMP_DIR)/include -I $(STGZ_DECOMP_DIR)/libs/c/include
117122
CPP_DEFINES := -DGZ_OVL_ID=114 -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -DPACKAGE_NAME='$(PACKAGE_NAME)' -DPACKAGE_COMMIT_AUTHOR='$(PACKAGE_COMMIT_AUTHOR)' -DPACKAGE_AUTHOR='$(PACKAGE_AUTHOR)'
118123
CFLAGS := -Os -fno-short-enums -fomit-frame-pointer -ffast-math -fno-builtin -fshort-wchar -MMD -MP $(WARNINGS) $(INCLUDES) $(CPP_DEFINES)
@@ -136,8 +141,8 @@ HOOKS_GAME_BIN := $(HOOKS_GAME_ELF:.elf=.bin)
136141
HOOKS_GAME_MAP := $(HOOKS_GAME_ELF:.elf=.map)
137142
138143
# create output directories
139-
$(shell mkdir -p $(BUILD_DIR)/src)
140-
$(shell mkdir -p $(HOOKS_BUILD_DIR)/src)
144+
$(shell $(MKDIR) -p $(BUILD_DIR)/src/thumb)
145+
$(shell $(MKDIR) -p $(HOOKS_BUILD_DIR)/src)
141146
142147
### project settings ###
143148
@@ -197,9 +202,11 @@ extract:
197202
198203
hooks: overlay $(HOOKS_BIN) $(HOOKS_GAME_BIN)
199204
200-
init: venv libs
205+
init: venv
201206
$(call print_no_args,Verifying baserom checksum...)
207+
ifeq ($(COMPARE),1)
202208
$(V)sha1sum -c $(EXTRACT_DIR)/baserom_st_$(REGION).sha1
209+
endif
203210
$(V)$(DL_TOOL) dsrom v0.6.1
204211
ifeq ("$(wildcard $(ARMIPS_DIR))", "")
205212
$(error armips not found!)
@@ -212,7 +219,7 @@ endif
212219
213220
libs:
214221
$(call print_no_args,Generating game symbol library...)
215-
$(V)$(PYTHON) tools/gen_libs.py -m libst -d $(STGZ_DECOMP_DIR) -b build
222+
$(V)$(PYTHON) tools/gen_libs.py -m libst -d $(STGZ_DECOMP_DIR)
216223
$(call print_no_args,Success!)
217224
218225
overlay: $(BIN)
@@ -240,7 +247,7 @@ venv:
240247
241248
## process auto-generated thumb definitions (necessary to avoid crashes when calling thumb functions) ##
242249
243-
$(BUILD_DIR)/thumb-$(REGION).o: build/thumb-$(REGION).s
250+
$(BUILD_DIR)/src/thumb/thumb-$(REGION).o: src/thumb/thumb-$(REGION).s
244251
$(V)$(CC) $(CFLAGS) -fverbose-asm -Os -x assembler-with-cpp -fomit-frame-pointer -c "$<" -o "$@"
245252
246253
## process source files ##
@@ -255,15 +262,15 @@ $(BUILD_DIR)/src/%.o: src/%.c
255262
256263
$(BUILD_DIR)/src/%.o: src/%.cpp
257264
$(call print_two_args,Compiling:,$<,$@)
258-
$(V)$(CC) $(CPP_FLAGS) -c "$<" -o "$@"
265+
$(V)$(CXX) $(CPP_FLAGS) -c "$<" -o "$@"
259266
260267
$(HOOKS_BUILD_DIR)/src/%.o: hooks/src/%.c
261268
$(call print_two_args,Compiling hooks:,$<,$@)
262269
$(V)$(CC) $(CFLAGS) -DOVERLAY_0_SLOT_ADDR=$(OVERLAY_0_SLOT_ADDR) -c "$<" -o "$@"
263270
264271
$(HOOKS_BUILD_DIR)/src/%.o: hooks/src/%.cpp
265272
$(call print_two_args,Compiling hooks:,$<,$@)
266-
$(V)$(CC) $(CPP_FLAGS) -c "$<" -o "$@"
273+
$(V)$(CXX) $(CPP_FLAGS) -c "$<" -o "$@"
267274
268275
## process build artifacts ##
269276

hooks/src/game.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#include <System/OverlayManager.hpp>
22
#include <System/Random.hpp>
3-
#include <Unknown/UnkStruct_02049a2c.hpp>
3+
#include <Game/Game.hpp>
44
#include <Unknown/UnkStruct_02049b74.hpp>
55
#include <Unknown/UnkStruct_02049bd4.hpp>
66
#include <Unknown/UnkStruct_0204a110.hpp>
77
#include <Unknown/UnkStruct_0204e64c.hpp>
88
#include <Unknown/UnkStruct_027e0208.hpp>
99
#include <regs.h>
1010

11-
extern "C" void GZ_Main(int param1);
11+
extern "C" void GZ_Main();
1212

13-
class StartUpMain : public UnkStruct_02049a2c {
14-
void Run(unk32 param1);
13+
class StartUpMain : public Game {
14+
void Run();
1515
};
1616

1717
extern "C" void func_020196fc();
@@ -34,8 +34,8 @@ struct SomeSaveFileStruct {
3434
};
3535

3636
// shorter version of the main loop specifically for boot time, no idea if this affects things later though...
37-
void StartUpMain::Run(unk32 param1) {
38-
this->func_ov018_020c48a4(param1);
37+
void StartUpMain::Run() {
38+
this->func_ov018_020c48a4();
3939

4040
do {
4141
// initialization of the next game mode
@@ -76,5 +76,5 @@ void StartUpMain::Run(unk32 param1) {
7676
func_020132c8();
7777
} while (gOverlayManager.mLoadedOverlays[OverlaySlot_4] == OverlayIndex_StartUp);
7878

79-
GZ_Main(param1);
79+
GZ_Main();
8080
}

hooks/src/hooks.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
* Make sure to make it as small as possible!
66
*/
77

8-
extern void _ZN18UnkStruct_02049a2c19func_ov018_020c48f8Ev(void* ptr);
8+
extern void _ZN4Game19func_ov018_020c48f8Ev(void* ptr);
99
extern void FS_LoadOverlay(int param1, int overlayID);
1010
extern void GZ_Init();
11-
extern void main(int param1, int param2);
12-
extern void GZ_Main(int param1);
1311

1412
#ifndef __INTELLISENSE__
1513
#ifndef GZ_OVL_ID
@@ -28,7 +26,7 @@ extern void GZ_Main(int param1);
2826

2927
// init hook: replace the `func_ov018_020c48f8` call from `GameModeStartUp::vfunc_0C` so we can load and init the gz overlay
3028
void GZ_InitHook(void* ptr) {
31-
_ZN18UnkStruct_02049a2c19func_ov018_020c48f8Ev(ptr);
29+
_ZN4Game19func_ov018_020c48f8Ev(ptr);
3230

3331
// make sure overlay 0 has completed loading
3432
while (nOverlay0 != 0) {}

include/gz_game.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#pragma once
22

3-
#include <Unknown/UnkStruct_02049a2c.hpp>
3+
#include <Game/Game.hpp>
44

5-
// IMPORTANT: this should match `UnkStruct_02049a2c` exactly!
6-
class CustomGame : public UnkStruct_02049a2c {
5+
// IMPORTANT: this should match `Game` exactly!
6+
class CustomGame : public Game {
77
public:
8-
void Run(unk32 param1);
8+
void Run();
99
void ExecutePause();
1010
};

include/gz_settings.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "gz.hpp"
44

5-
#include <Unknown/UnkStruct_02049a2c.hpp>
5+
#include <Game/Game.hpp>
66
#include <System/OverlayManager.hpp>
77
#include <types.h>
88

0 commit comments

Comments
 (0)