Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (94 loc) · 3.82 KB
/
Copy pathMakefile
File metadata and controls
112 lines (94 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
CC65 = cc65
CA65 = ca65
LD65 = ld65
CL65 = cl65
NAME = menu
CFG = nes.cfg
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
# These ROM types shows:
# 1. Bit swaps on opcodes at startup and/or the entire ROM data.
# 2. If it jumps to another custom address ex. "JSR #$3000".
#
# Known ROM types:
# 1. SWAP_DATA_BITS_4_TO_5
# 2. SWAP_DATA_BITS_9_A_TO_0_1__SWAP_OPCODE_BITS_0_TO_1__STARTUP_CUSTOM_ADDR
# 3. NO_SWAP_DATA_BITS_01
# 4. G5_NO_SWAP_DATA_BITS_SWAP_OPCODE_BITS_6_7_1_2
ROM_TYPE = G5_NO_SWAP_DATA_BITS_SWAP_OPCODE_BITS_6_7_1_2
# Define bin Examples:
# ROMDUMP_INIT_TITLE = S29GL128P10TFI01_romdump_sup400in1_09082024
# ROMDUMP_INIT_EMULATOR_BIN = $(ROMDUMP_INIT_TITLE)_init_emulator_6E000.bin
# ROMDUMP_INIT_ORIGINAL_BIN = $(ROMDUMP_INIT_TITLE)_init_original_6E000.bin
ROMDUMP_INIT_TITLE = M36L0R7050T0_G5
ROMDUMP_INIT_EMULATOR_BIN = $(ROMDUMP_INIT_TITLE)_init_emulator_1_7CE20.bin
ROMDUMP_INIT_ORIGINAL_BIN = $(ROMDUMP_INIT_TITLE)_init_original_1_7CE20.bin
ROM_HANDHELD_OUTPUT_FOLDER = output_rom_handheld
NESHEADERFOLDER = nes_header
ROMDUMPFOLDER = romdump_init
.PHONY: default clean
all: $menu compile_to_handheld_rom
$menu: $(NAME).c
$(CC65) -Oir -Cl -t nes $(NAME).c -D$(ROM_TYPE)
$(CC65) -Oir -Cl -t nes appList.c
$(CC65) -Oir -Cl -t nes utilities.c -D$(ROM_TYPE)
$(CC65) -Oir -Cl -t nes debugging.c
$(CC65) -Oir -Cl -t nes handheld.c -D$(ROM_TYPE)
$(CA65) $(NAME).s
$(CA65) utilities.s
$(CA65) debugging.s
$(CA65) crt0.s
$(CA65) interrupt.s
$(CA65) handheld.s
ifeq ($(ROM_TYPE), G5_NO_SWAP_DATA_BITS_SWAP_OPCODE_BITS_6_7_1_2)
$(CA65) jumpToApp_G5.s
else
$(CA65) jumpToApp.s
endif
$(CA65) appList.s
ifeq ($(ROM_TYPE), G5_NO_SWAP_DATA_BITS_SWAP_OPCODE_BITS_6_7_1_2)
$(LD65) -C target.cfg crt0.o interrupt.o jumpToApp_G5.o appList.o $(NAME).o utilities.o debugging.o handheld.o nes.lib -o output.bin
else
$(LD65) -C target.cfg crt0.o interrupt.o jumpToApp.o appList.o $(NAME).o utilities.o debugging.o handheld.o nes.lib -o output.bin
endif
python buildCHR.py "fonts/powerpak_font.chr"
mkdir -p $(ROMDUMPFOLDER)
cat $(ROMDUMPFOLDER)/$(ROMDUMP_INIT_EMULATOR_BIN) output.bin apps.bin > output_final_emulator.bin
cat $(NESHEADERFOLDER)/nesHeader.bin output_final_emulator.bin > output_final_emulator.nes
compile_to_handheld_rom:
@echo "Compiling to Handheld ROM!"
ifeq ($(ROM_TYPE), NO_SWAP_DATA_BITS_01)
cat $(ROMDUMPFOLDER)/$(ROMDUMP_INIT_ORIGINAL_BIN) output.bin apps.bin > $(ROM_HANDHELD_OUTPUT_FOLDER)/output_final_handheld.bin
else ifeq ($(ROM_TYPE), SWAP_DATA_BITS_4_TO_5)
cat $(ROMDUMPFOLDER)/$(ROMDUMP_INIT_ORIGINAL_BIN) output.bin apps.bin > output_final_swapBits45.bin
else ifeq ($(ROM_TYPE), SWAP_DATA_BITS_9_A_TO_0_1__SWAP_OPCODE_BITS_0_TO_1__STARTUP_CUSTOM_ADDR)
# Combine emulator output first: Menu + Apps.
cat output.bin apps.bin > user.bin
# Then do the bit-swaps back to the original.
python sup_game_box_swap_bits.py user.bin O SWAP_DATA_BITS_9A_TO_12
# With the original bin (modified to jump to 0x88000) with swapped data and opcode bits, combine them finally:
cat $(ROMDUMPFOLDER)/$(ROMDUMP_INIT_ORIGINAL_BIN) $(ROM_HANDHELD_OUTPUT_FOLDER)/user_O.bin > $(ROM_HANDHELD_OUTPUT_FOLDER)/output_final_handheld.bin
else ifeq ($(ROM_TYPE), G5_NO_SWAP_DATA_BITS_SWAP_OPCODE_BITS_6_7_1_2)
cat $(ROMDUMPFOLDER)/$(ROMDUMP_INIT_ORIGINAL_BIN) output.bin apps.bin > $(ROM_HANDHELD_OUTPUT_FOLDER)/output_final_handheld.bin
endif
@echo "Done compiling to Handheld ROM! :D"
clean:
rm $(NAME).o
rm $(NAME).s
rm apps.bin
rm appList.s
rm crt0.o
rm interrupt.o
rm jumpToApp.o
rm appList.o
rm output.bin
rm output_final_emulator.bin
rm output_final_emulator.nes
rm $(ROM_HANDHELD_OUTPUT_FOLDER)/*.bin
rm appList.c
rm appList.h
rm debugging.o
rm debugging.s
rm utilities.o
rm utilities.s
rm handheld.o
rm handheld.s