Extract memory card icons (#166)

Extract the memory card icons out of DRA.BIN and SEL.BIN.


![image](https://user-images.githubusercontent.com/6128729/227794798-4dd071f9-512b-4c72-8f5d-fcbf7a615519.png)

I also took the opportunity to extract `g_MemcardPortMask` into its own
source file `save_mgr_pre.c`. Unfortunately this is required to keep the
original data order. This suggests that most likely the icon palette and
bitmap were baked into the original `save_mgr.c` as byte arrays. I
decided to take a different approach and extracted them as PNGs for
better moddability.

I had to spin-off Splat into a new fork due to some breaking changes on
0.18.0.
This commit is contained in:
Luciano Ciccariello 2023-12-12 07:12:13 +00:00 committed by GitHub
parent e9d7eb0e2c
commit e9bed91931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 403 additions and 182 deletions

2
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "tools/n64splat"]
path = tools/n64splat
url = https://github.com/ethteck/splat.git
url = https://github.com/Xeeynamo/splat.git
[submodule "tools/asm-differ"]
path = tools/asm-differ
url = https://github.com/simonlindholm/asm-differ.git

View File

@ -64,6 +64,7 @@ GO := $(HOME)/go/bin/go
GOPATH := $(HOME)/go
SOTNDISK := $(GOPATH)/bin/sotn-disk
GFXSTAGE := $(PYTHON) $(TOOLS_DIR)/gfxstage.py
PNG2S := $(PYTHON) $(TOOLS_DIR)/png2s.py
ICONV := iconv --from-code=UTF-8 --to-code=Shift-JIS
define list_src_files

View File

@ -49,3 +49,21 @@ $(BUILD_DIR)/weapon.ld: $(CONFIG_DIR)/splat.$(VERSION).weapon.yaml $(PSX_BASE_SY
cat $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.$(VERSION).weapon.txt $(CONFIG_DIR)/symbols.$(VERSION).weapon.txt.in > $(CONFIG_DIR)/generated.symbols.$(VERSION).weapon.txt
$(SPLAT) $<
rm $(CONFIG_DIR)/generated.symbols.$(VERSION).weapon.txt
$(BUILD_DIR)/assets/dra/memcard_%.png.o: assets/dra/memcard_%.png
mkdir -p $(dir $@)
$(PNG2S) $< \
$(BUILD_DIR)/assets/dra/memcard_$*.png.s g_saveIcon$* \
$(BUILD_DIR)/assets/dra/memcard_$*.pal.s g_saveIconPal$*
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/assets/dra/memcard_$*.png.o $(BUILD_DIR)/assets/dra/memcard_$*.png.s
rm $(BUILD_DIR)/assets/dra/memcard_$*.png.s
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/assets/dra/memcard_$*.pal.o $(BUILD_DIR)/assets/dra/memcard_$*.pal.s
rm $(BUILD_DIR)/assets/dra/memcard_$*.pal.s
$(BUILD_DIR)/assets/st/sel/memcard_%.png.o: assets/st/sel/memcard_%.png
mkdir -p $(dir $@)
$(PNG2S) $< \
$(BUILD_DIR)/assets/st/sel/memcard_$*.png.s g_saveIcon$* \
$(BUILD_DIR)/assets/st/sel/memcard_$*.pal.s g_saveIconPal$*
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/assets/st/sel/memcard_$*.png.o $(BUILD_DIR)/assets/st/sel/memcard_$*.png.s
rm $(BUILD_DIR)/assets/st/sel/memcard_$*.png.s
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/assets/st/sel/memcard_$*.pal.o $(BUILD_DIR)/assets/st/sel/memcard_$*.pal.s
rm $(BUILD_DIR)/assets/st/sel/memcard_$*.pal.s

View File

@ -34,7 +34,39 @@ segments:
- [0x160, .data, play]
- [0x240, .data, loading]
- [0x248, .data, 47BB8]
- [0x510, data]
- [0x510, .data, save_mgr_pre]
- [0x518, palette, memcard_0]
- [0x538, palette, memcard_1]
- [0x558, palette, memcard_2]
- [0x578, palette, memcard_3]
- [0x598, palette, memcard_4]
- [0x5B8, palette, memcard_5]
- [0x5D8, palette, memcard_6]
- [0x5F8, palette, memcard_7]
- [0x618, palette, memcard_8]
- [0x638, palette, memcard_9]
- [0x658, palette, memcard_10]
- [0x678, palette, memcard_11]
- [0x698, palette, memcard_12]
- [0x6B8, palette, memcard_13]
- [0x6D8, palette, memcard_14]
- [0x6F8, palette, memcard_15]
- [0x718, ci4, memcard_0, 16, 48]
- [0x898, ci4, memcard_1, 16, 48]
- [0xA18, ci4, memcard_2, 16, 48]
- [0xB98, ci4, memcard_3, 16, 48]
- [0xD18, ci4, memcard_4, 16, 48]
- [0xE98, ci4, memcard_5, 16, 48]
- [0x1018, ci4, memcard_6, 16, 48]
- [0x1198, ci4, memcard_7, 16, 48]
- [0x1318, ci4, memcard_8, 16, 48]
- [0x1498, ci4, memcard_9, 16, 48]
- [0x1618, ci4, memcard_10, 16, 48]
- [0x1798, ci4, memcard_11, 16, 48]
- [0x1918, ci4, memcard_12, 16, 48]
- [0x1A98, ci4, memcard_13, 16, 48]
- [0x1C18, ci4, memcard_14, 16, 48]
- [0x1D98, ci4, memcard_15, 16, 48]
- [0x1F18, .data, save_mgr]
- [0x2178, data]
- [0x2CF4, .data, menu] # array of strings

View File

@ -34,7 +34,39 @@ segments:
- [0x160, .data, play]
- [0x240, .data, loading]
- [0x248, .data, 47BB8]
- [0x510, data]
- [0x510, .data, save_mgr_pre]
- [0x518, palette, memcard_0]
- [0x538, palette, memcard_1]
- [0x558, palette, memcard_2]
- [0x578, palette, memcard_3]
- [0x598, palette, memcard_4]
- [0x5B8, palette, memcard_5]
- [0x5D8, palette, memcard_6]
- [0x5F8, palette, memcard_7]
- [0x618, palette, memcard_8]
- [0x638, palette, memcard_9]
- [0x658, palette, memcard_10]
- [0x678, palette, memcard_11]
- [0x698, palette, memcard_12]
- [0x6B8, palette, memcard_13]
- [0x6D8, palette, memcard_14]
- [0x6F8, palette, memcard_15]
- [0x718, ci4, memcard_0, 16, 48]
- [0x898, ci4, memcard_1, 16, 48]
- [0xA18, ci4, memcard_2, 16, 48]
- [0xB98, ci4, memcard_3, 16, 48]
- [0xD18, ci4, memcard_4, 16, 48]
- [0xE98, ci4, memcard_5, 16, 48]
- [0x1018, ci4, memcard_6, 16, 48]
- [0x1198, ci4, memcard_7, 16, 48]
- [0x1318, ci4, memcard_8, 16, 48]
- [0x1498, ci4, memcard_9, 16, 48]
- [0x1618, ci4, memcard_10, 16, 48]
- [0x1798, ci4, memcard_11, 16, 48]
- [0x1918, ci4, memcard_12, 16, 48]
- [0x1A98, ci4, memcard_13, 16, 48]
- [0x1C18, ci4, memcard_14, 16, 48]
- [0x1D98, ci4, memcard_15, 16, 48]
- [0x1F18, .data, save_mgr]
- [0x21B8, data]
- [0x2BC0, data]

View File

@ -31,6 +31,39 @@ segments:
subsegments:
- [0x0, .data, 2C048]
- [0x3A8, data]
- [0x8DC, .data, save_mgr_pre]
- [0x8E4, palette, memcard_0]
- [0x904, palette, memcard_1]
- [0x924, palette, memcard_2]
- [0x944, palette, memcard_3]
- [0x964, palette, memcard_4]
- [0x984, palette, memcard_5]
- [0x9A4, palette, memcard_6]
- [0x9C4, palette, memcard_7]
- [0x9E4, palette, memcard_8]
- [0xA04, palette, memcard_9]
- [0xA24, palette, memcard_10]
- [0xA44, palette, memcard_11]
- [0xA64, palette, memcard_12]
- [0xA84, palette, memcard_13]
- [0xAA4, palette, memcard_14]
- [0xAC4, palette, memcard_15]
- [0xAE4, ci4, memcard_0, 16, 48]
- [0xC64, ci4, memcard_1, 16, 48]
- [0xDE4, ci4, memcard_2, 16, 48]
- [0xF64, ci4, memcard_3, 16, 48]
- [0x10E4, ci4, memcard_4, 16, 48]
- [0x1264, ci4, memcard_5, 16, 48]
- [0x13E4, ci4, memcard_6, 16, 48]
- [0x1564, ci4, memcard_7, 16, 48]
- [0x16E4, ci4, memcard_8, 16, 48]
- [0x1864, ci4, memcard_9, 16, 48]
- [0x19E4, ci4, memcard_10, 16, 48]
- [0x1B64, ci4, memcard_11, 16, 48]
- [0x1CE4, ci4, memcard_12, 16, 48]
- [0x1E64, ci4, memcard_13, 16, 48]
- [0x1FE4, ci4, memcard_14, 16, 48]
- [0x2164, ci4, memcard_15, 16, 48]
- [0x22E4, .data, save_mgr]
- [0x2584, data]
- [0xD5D4, .data, D5D4]

View File

@ -24,7 +24,7 @@ options:
- ".bss"
segments:
- name: f_000
type: ci4
type: grey4
start: 0x00000
vram: 0
width: 256
@ -42,7 +42,7 @@ segments:
- [0x050D4, c, w_000]
- [0x05700, sbss, w_000] # empty
- name: f_001
type: ci4
type: grey4
start: 0x07000
vram: 0
width: 256
@ -59,7 +59,7 @@ segments:
- [0x0C014, c, w_001]
- [0x0D430, sbss, w_001]
- name: f_002
type: ci4
type: grey4
start: 0x0E000
vram: 0
width: 256
@ -76,7 +76,7 @@ segments:
- [0x12BDC, c, w_002]
- [0x13200, sbss, w_002]
- name: f_003
type: ci4
type: grey4
start: 0x15000
vram: 0
width: 256
@ -93,7 +93,7 @@ segments:
- [0x19C40, c, w_003]
- [0x1A26C, sbss, w_003]
- name: f_004
type: ci4
type: grey4
start: 0x1C000
vram: 0
width: 256
@ -110,7 +110,7 @@ segments:
- [0x2131C, c, w_004]
- [0x2196C, sbss, w_004]
- name: f_005
type: ci4
type: grey4
start: 0x23000
vram: 0
width: 256
@ -127,7 +127,7 @@ segments:
- [0x2831C, c, w_005]
- [0x28998, sbss, w_005]
- name: f_006
type: ci4
type: grey4
start: 0x2A000
vram: 0
width: 256
@ -144,7 +144,7 @@ segments:
- [0x2EC54, c, w_006]
- [0x2F9B8, sbss, w_006]
- name: f_007
type: ci4
type: grey4
start: 0x31000
vram: 0
width: 256
@ -161,7 +161,7 @@ segments:
- [0x35CA0, c, w_007]
- [0x36918, sbss, w_007]
- name: f_008
type: ci4
type: grey4
start: 0x38000
vram: 0
width: 256
@ -178,7 +178,7 @@ segments:
- [0x3CB4C, c, w_008]
- [0x3DF78, sbss, w_008]
- name: f_009
type: ci4
type: grey4
start: 0x3F000
vram: 0
width: 256
@ -195,7 +195,7 @@ segments:
- [0x43B4C, c, w_009]
- [0x450F0, sbss, w_009]
- name: f_010
type: ci4
type: grey4
start: 0x46000
vram: 0
width: 256
@ -212,7 +212,7 @@ segments:
- [0x4ACC0, c, w_010]
- [0x4CC1C, sbss, w_010]
- name: f_011
type: ci4
type: grey4
start: 0x4D000
vram: 0
width: 256
@ -229,7 +229,7 @@ segments:
- [0x51CDC, c, w_011]
- [0x53810, sbss, w_011]
- name: f_012
type: ci4
type: grey4
start: 0x54000
vram: 0
width: 256
@ -246,7 +246,7 @@ segments:
- [0x58ACC, c, w_012]
- [0x59B28, sbss, w_012]
- name: f_013
type: ci4
type: grey4
start: 0x5B000
vram: 0
width: 256
@ -263,7 +263,7 @@ segments:
- [0x5F62C, c, w_013]
- [0x60C10, sbss, w_013]
- name: f_014
type: ci4
type: grey4
start: 0x62000
vram: 0
width: 256
@ -280,7 +280,7 @@ segments:
- [0x665BC, c, w_014]
- [0x67584, sbss, w_014]
- name: f_015
type: ci4
type: grey4
start: 0x69000
vram: 0
width: 256
@ -297,7 +297,7 @@ segments:
- [0x6D7E4, c, w_015]
- [0x6EFC8, sbss, w_015]
- name: f_016
type: ci4
type: grey4
start: 0x70000
vram: 0
width: 256
@ -314,7 +314,7 @@ segments:
- [0x7460C, c, w_016]
- [0x75D74, sbss, w_016]
- name: f_017
type: ci4
type: grey4
start: 0x77000
vram: 0
width: 256
@ -331,7 +331,7 @@ segments:
- [0x7B3AC, c, w_017]
- [0x7C0F4, sbss, w_017]
- name: f_018
type: ci4
type: grey4
start: 0x7E000
vram: 0
width: 256
@ -348,7 +348,7 @@ segments:
- [0x82740, c, w_018]
- [0x831B4, sbss, w_018]
- name: f_019
type: ci4
type: grey4
start: 0x85000
vram: 0
width: 256
@ -365,7 +365,7 @@ segments:
- [0x89554, c, w_019]
- [0x89DB4, sbss, w_019]
- name: f_020
type: ci4
type: grey4
start: 0x8C000
vram: 0
width: 256
@ -382,7 +382,7 @@ segments:
- [0x90BC8, c, w_020]
- [0x92238, sbss, w_020]
- name: f_021
type: ci4
type: grey4
start: 0x93000
vram: 0
width: 256
@ -399,7 +399,7 @@ segments:
- [0x977B4, c, w_021]
- [0x98B78, sbss, w_021]
- name: f_022
type: ci4
type: grey4
start: 0x9A000
vram: 0
width: 256
@ -416,7 +416,7 @@ segments:
- [0x9E814, c, w_022]
- [0x9EF80, sbss, w_022]
- name: f_023
type: ci4
type: grey4
start: 0xA1000
vram: 0
width: 256
@ -433,7 +433,7 @@ segments:
- [0xA5D80, c, w_023]
- [0xA797C, sbss, w_023]
- name: f_024
type: ci4
type: grey4
start: 0xA8000
vram: 0
width: 256
@ -450,7 +450,7 @@ segments:
- [0xACDE0, c, w_024]
- [0xAEBF4, sbss, w_024]
- name: f_025
type: ci4
type: grey4
start: 0xAF000
vram: 0
width: 256
@ -467,7 +467,7 @@ segments:
- [0xB3B74, c, w_025]
- [0xB5918, sbss, w_025]
- name: f_026
type: ci4
type: grey4
start: 0xB6000
vram: 0
width: 256
@ -484,7 +484,7 @@ segments:
- [0xBAB9C, c, w_026]
- [0xBCC3C, sbss, w_026]
- name: f_027
type: ci4
type: grey4
start: 0xBD000
vram: 0
width: 256
@ -501,7 +501,7 @@ segments:
- [0xC1D54, c, w_027]
- [0xC36EC, sbss, w_027]
- name: f_028
type: ci4
type: grey4
start: 0xC4000
vram: 0
width: 256
@ -518,7 +518,7 @@ segments:
- [0xC8BF4, c, w_028]
- [0xCA954, sbss, w_028]
- name: f_029
type: ci4
type: grey4
start: 0xCB000
vram: 0
width: 256
@ -536,7 +536,7 @@ segments:
- [0xCFDD8, c, w_029]
- [0xD19A0, sbss, w_029]
- name: f_030
type: ci4
type: grey4
start: 0xD2000
vram: 0
width: 256
@ -553,7 +553,7 @@ segments:
- [0xD66DC, c, w_030]
- [0xD8C44, sbss, w_030]
- name: f_031
type: ci4
type: grey4
start: 0xD9000
vram: 0
width: 256
@ -570,7 +570,7 @@ segments:
- [0xDD918, c, w_031]
- [0xDDF88, sbss, w_031]
- name: f_032
type: ci4
type: grey4
start: 0xE0000
vram: 0
width: 256
@ -587,7 +587,7 @@ segments:
- [0xE4924, c, w_032]
- [0xE5020, sbss, w_032]
- name: f_033
type: ci4
type: grey4
start: 0xE7000
vram: 0
width: 256
@ -604,7 +604,7 @@ segments:
- [0xEBC58, c, w_033]
- [0xEC2C8, sbss, w_033]
- name: f_034
type: ci4
type: grey4
start: 0xEE000
vram: 0
width: 256
@ -621,7 +621,7 @@ segments:
- [0xF2950, c, w_034]
- [0xF33F0, sbss, w_034]
- name: f_035
type: ci4
type: grey4
start: 0xF5000
vram: 0
width: 256
@ -638,7 +638,7 @@ segments:
- [0xF954C, c, w_035]
- [0xF9B78, sbss, w_035]
- name: f_036
type: ci4
type: grey4
start: 0xFC000
vram: 0
width: 256
@ -655,7 +655,7 @@ segments:
- [0x10055C, c, w_036]
- [0x100B88, sbss, w_036]
- name: f_037
type: ci4
type: grey4
start: 0x103000
vram: 0
width: 256
@ -672,7 +672,7 @@ segments:
- [0x1077C4, c, w_037]
- [0x108BE4, sbss, w_037]
- name: f_038
type: ci4
type: grey4
start: 0x10A000
vram: 0
width: 256
@ -689,7 +689,7 @@ segments:
- [0x10EDEC, c, w_038]
- [0x10F844, sbss, w_038]
- name: f_039
type: ci4
type: grey4
start: 0x111000
vram: 0
width: 256
@ -706,7 +706,7 @@ segments:
- [0x115DEC, c, w_039]
- [0x116A28, sbss, w_039]
- name: f_040
type: ci4
type: grey4
start: 0x118000
vram: 0
width: 256
@ -723,7 +723,7 @@ segments:
- [0x11C874, c, w_040]
- [0x11D540, sbss, w_040]
- name: f_041
type: ci4
type: grey4
start: 0x11F000
vram: 0
width: 256
@ -740,7 +740,7 @@ segments:
- [0x123574, c, w_041]
- [0x124200, sbss, w_041]
- name: f_042
type: ci4
type: grey4
start: 0x126000
vram: 0
width: 256
@ -757,7 +757,7 @@ segments:
- [0x12A764, c, w_042]
- [0x12B5EC, sbss, w_042]
- name: f_043
type: ci4
type: grey4
start: 0x12D000
vram: 0
width: 256
@ -774,7 +774,7 @@ segments:
- [0x13205C, c, w_043]
- [0x132D74, sbss, w_043]
- name: f_044
type: ci4
type: grey4
start: 0x134000
vram: 0
width: 256
@ -791,7 +791,7 @@ segments:
- [0x1382C0, c, w_044]
- [0x138F24, sbss, w_044]
- name: f_045
type: ci4
type: grey4
start: 0x13B000
vram: 0
width: 256
@ -808,7 +808,7 @@ segments:
- [0x13F378, c, w_045]
- [0x1403B8, sbss, w_045]
- name: f_046
type: ci4
type: grey4
start: 0x142000
vram: 0
width: 256
@ -825,7 +825,7 @@ segments:
- [0x146C64, c, w_046]
- [0x147EC0, sbss, w_046]
- name: f_047
type: ci4
type: grey4
start: 0x149000
vram: 0
width: 256
@ -842,7 +842,7 @@ segments:
- [0x14D568, c, w_047]
- [0x14E6A4, sbss, w_047]
- name: f_048
type: ci4
type: grey4
start: 0x150000
vram: 0
width: 256
@ -859,7 +859,7 @@ segments:
- [0x155050, c, w_048]
- [0x1563B4, sbss, w_048]
- name: f_049
type: ci4
type: grey4
start: 0x157000
vram: 0
width: 256
@ -876,7 +876,7 @@ segments:
- [0x15C14C, c, w_049]
- [0x15D8CC, sbss, w_049]
- name: f_050
type: ci4
type: grey4
start: 0x15E000
vram: 0
width: 256
@ -893,7 +893,7 @@ segments:
- [0x163080, c, w_050]
- [0x164BF8, sbss, w_050]
- name: f_051
type: ci4
type: grey4
start: 0x165000
vram: 0
width: 256
@ -910,7 +910,7 @@ segments:
- [0x169ED4, c, w_051]
- [0x16B0E0, sbss, w_051]
- name: f_052
type: ci4
type: grey4
start: 0x16C000
vram: 0
width: 256
@ -927,7 +927,7 @@ segments:
- [0x170CB0, c, w_052]
- [0x172B84, sbss, w_052]
- name: f_053
type: ci4
type: grey4
start: 0x173000
vram: 0
width: 256
@ -944,7 +944,7 @@ segments:
- [0x178280, c, w_053]
- [0x179894, sbss, w_053]
- name: f_054
type: ci4
type: grey4
start: 0x17A000
vram: 0
width: 256
@ -961,7 +961,7 @@ segments:
- [0x17EF0C, c, w_054]
- [0x17F8F8, sbss, w_054]
- name: f_055
type: ci4
type: grey4
start: 0x181000
vram: 0
width: 256
@ -978,7 +978,7 @@ segments:
- [0x1861A0, c, w_055]
- [0x186C2C, sbss, w_055]
- name: f_056
type: ci4
type: grey4
start: 0x188000
vram: 0
width: 256
@ -995,7 +995,7 @@ segments:
- [0x18D060, c, w_056]
- [0x18E0B8, sbss, w_056]
- name: f_057
type: ci4
type: grey4
start: 0x18F000
vram: 0
width: 256
@ -1012,7 +1012,7 @@ segments:
- [0x1940B4, c, w_057]
- [0x1946E0, sbss, w_057]
- name: f_058
type: ci4
type: grey4
start: 0x196000
vram: 0
width: 256

View File

@ -1,21 +1,3 @@
g_UnkMemcardPort = 0x800A0510;
g_saveIconPalette = 0x800A0518;
g_saveIcon0 = 0x800A0718;
g_saveIcon1 = 0x800A0898;
g_saveIcon2 = 0x800A0A18;
g_saveIcon3 = 0x800A0B98;
g_saveIcon4 = 0x800A0D18;
g_saveIcon5 = 0x800A0E98;
g_saveIcon6 = 0x800A1018;
g_saveIcon7 = 0x800A1198;
g_saveIcon8 = 0x800A1318;
g_saveIcon9 = 0x800A1498;
g_saveIcon10 = 0x800A1618;
g_saveIcon11 = 0x800A1798;
g_saveIcon12 = 0x800A1918;
g_saveIcon13 = 0x800A1A98;
g_saveIcon14 = 0x800A1C18;
g_saveIcon15 = 0x800A1D98;
D_800A21B8 = 0x800A2178;
D_800A2438 = 0x800A23F8;
D_800A243C = 0x800A23FC;

View File

@ -1,21 +1,3 @@
g_UnkMemcardPort = 0x800A0510;
g_saveIconPalette = 0x800A0518;
g_saveIcon0 = 0x800A0718;
g_saveIcon1 = 0x800A0898;
g_saveIcon2 = 0x800A0A18;
g_saveIcon3 = 0x800A0B98;
g_saveIcon4 = 0x800A0D18;
g_saveIcon5 = 0x800A0E98;
g_saveIcon6 = 0x800A1018;
g_saveIcon7 = 0x800A1198;
g_saveIcon8 = 0x800A1318;
g_saveIcon9 = 0x800A1498;
g_saveIcon10 = 0x800A1618;
g_saveIcon11 = 0x800A1798;
g_saveIcon12 = 0x800A1918;
g_saveIcon13 = 0x800A1A98;
g_saveIcon14 = 0x800A1C18;
g_saveIcon15 = 0x800A1D98;
c_chPlaystationButtons = 0x800A2D70;
c_chShoulderButtons = 0x800A2D74;
MenuContextData = 0x800A2E00;

View File

@ -1,24 +1,6 @@
g_SpriteBanks = 0x8018059C;
g_Cluts = 0x8018070C;
g_EntityGfxs = 0x80180760;
g_UnkMemcardPort = 0x801808DC;
g_saveIconPalette = 0x801808E4;
g_saveIcon0 = 0x80180AE4;
g_saveIcon1 = 0x80180C64;
g_saveIcon2 = 0x80180DE4;
g_saveIcon3 = 0x80180F64;
g_saveIcon4 = 0x801810E4;
g_saveIcon5 = 0x80181264;
g_saveIcon6 = 0x801813E4;
g_saveIcon7 = 0x80181564;
g_saveIcon8 = 0x801816E4;
g_saveIcon9 = 0x80181864;
g_saveIcon10 = 0x801819E4;
g_saveIcon11 = 0x80181B64;
g_saveIcon12 = 0x80181CE4;
g_saveIcon13 = 0x80181E64;
g_saveIcon14 = 0x80181FE4;
g_saveIcon15 = 0x80182164;
g_StreamWidth = 0x8018B2FC;
g_StreamHeight = 0x8018B300;
PrintFileSelectPlaceName = 0x801AD134;

View File

@ -26,5 +26,8 @@ typedef struct {
extern MemcardInfo g_MemcardInfo[2];
extern s32 g_MemcardBlockRead;
extern s32 g_MemcardPortMask[];
extern u16 g_saveIconPal0[0x10][0x10];
extern u8* g_saveIconTexture[0x10];
#endif

View File

@ -372,9 +372,6 @@ extern u16 g_ButtonMask[];
extern u8 g_StageSelectOrder[];
extern u16 D_800A04CC[];
extern u32 D_800A04F8;
extern s32 g_UnkMemcardPort[];
extern u16 g_saveIconPalette[0x10][0x10];
extern u8* g_saveIconTexture[0x10];
extern s16 D_800A21B8[0x20];
extern s32 D_800A2438;
extern u8 D_800A243C[];

2
src/dra/save_mgr_pre.c Normal file
View File

@ -0,0 +1,2 @@
#include "dra.h"
#include "../save_mgr_pre.h"

View File

@ -279,13 +279,13 @@ s32 func_800E9880(s32 nPort, s32 nCard) {
break;
case 3:
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
memcard->unk258 = -1;
g_MemcardStep = 4;
break;
case 4:
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
memcard->unk258 = 2;
_clear_event_x();
_card_clear(channel);
@ -294,7 +294,7 @@ s32 func_800E9880(s32 nPort, s32 nCard) {
break;
case 2:
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
memcard->unk258 = -3;
g_MemcardStep = 4;
break;
@ -319,19 +319,19 @@ s32 func_800E9880(s32 nPort, s32 nCard) {
break;
case 3:
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
memcard->unk258 = -1;
g_MemcardStep++;
break;
case 4:
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
memcard->unk258 = -2;
g_MemcardStep++;
break;
case 2:
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
memcard->unk258 = -3;
g_MemcardStep++;
break;
@ -481,7 +481,7 @@ s32 MemcardFormat(s32 nPort, s32 nCard) {
char savePath[0x8];
s32 ret;
D_8006C3AC &= g_UnkMemcardPort[nPort];
D_8006C3AC &= g_MemcardPortMask[nPort];
sprintf(savePath, "bu%1d%1d:", nPort, nCard);
_clear_event_x();
format(savePath);
@ -499,9 +499,9 @@ s32 MemcardFormat(s32 nPort, s32 nCard) {
void GetSavePalette(u16* dst, s32 palIdx) {
s32 i;
u16* src = g_saveIconPalette[0];
u16* src = g_saveIconPal0[0];
src = g_saveIconPalette[palIdx];
src = g_saveIconPal0[palIdx];
for (i = 0; i < COLORS_PER_PAL; i++) {
*dst++ = *src++;
}

3
src/save_mgr_pre.h Normal file
View File

@ -0,0 +1,3 @@
#include "memcard.h"
s32 g_MemcardPortMask[] = {-2, -3};

View File

@ -1,4 +1,5 @@
#include "sel.h"
#include "memcard.h"
typedef enum {
Tips_Generic,

View File

@ -0,0 +1,2 @@
#include "sel.h"
#include "../../save_mgr_pre.h"

View File

@ -122,9 +122,6 @@ extern u8 D_80180564[];
extern u8 D_80180578[];
extern u8 D_80180580[];
extern const char* D_801808D0[];
extern s32 g_UnkMemcardPort[2];
extern u16 g_saveIconPalette[0x10][0x10];
extern u8* g_saveIconTexture[];
extern s8 D_801823A0[]; // on-screen keyboard
extern RECT D_80182584;
extern RECT D_8018258C;

@ -1 +1 @@
Subproject commit 63d16cf283597284200f9a7093bb94b5877c4365
Subproject commit e60277d6966edcfec1b06253c18e4344fef441a8

93
tools/png2s.py Executable file
View File

@ -0,0 +1,93 @@
#!/usr/bin/python3
import argparse
import png
def convert(in_file, out_file_bitmap, name_bitmap, out_file_pal, name_pal, is_append):
def encode_pal(dst, idx, palette):
for i in range(0, len(palette)):
color = palette[i]
r = color[0]
g = color[1]
b = color[2]
a = 0x8000 if color[3] >= 64 else 0x0000
c = (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | a
dst[idx + i * 2 + 0] = c & 0xFF
dst[idx + i * 2 + 1] = (c >> 8) & 0xFF
def encode_bitmap(data):
out = bytearray(int(len(data) / 2))
for i in range(0, len(out)):
out[i] = data[i * 2 + 0]
out[i] |= data[i * 2 + 1] << 4
return out
mode = "a" if is_append else "w"
img = png.Reader(in_file).read()
data = encode_bitmap(bytearray().join(img[2]))
info = img[3]
if info["planes"] != 1:
return f"'{in_file}' must be an indexed image"
palette = info["palette"]
if len(palette) > 16:
return f"'{in_file}' palette must be of 16 colors or less but found {len(palette)} colors instead"
with open(out_file_bitmap, mode) as f_out:
f_out.write(f".section .data\n")
f_out.write(f".global {name_bitmap}\n")
f_out.write(f"{name_bitmap}:\n")
for x in data:
f_out.write(f".byte 0x{x:02X}\n")
f_out.write("\n")
pal_data = bytearray(0x10 * 2)
encode_pal(pal_data, 0, palette)
with open(out_file_pal, mode) as f_out:
f_out.write(f".section .data\n")
f_out.write(f".global {name_pal}\n")
f_out.write(f"{name_pal}:\n")
f_out.write(f".short 0x{pal_data[0x01]:02X}{pal_data[0x00]:02X}\n")
f_out.write(f".short 0x{pal_data[0x03]:02X}{pal_data[0x02]:02X}\n")
f_out.write(f".short 0x{pal_data[0x05]:02X}{pal_data[0x04]:02X}\n")
f_out.write(f".short 0x{pal_data[0x07]:02X}{pal_data[0x06]:02X}\n")
f_out.write(f".short 0x{pal_data[0x09]:02X}{pal_data[0x08]:02X}\n")
f_out.write(f".short 0x{pal_data[0x0B]:02X}{pal_data[0x0A]:02X}\n")
f_out.write(f".short 0x{pal_data[0x0D]:02X}{pal_data[0x0C]:02X}\n")
f_out.write(f".short 0x{pal_data[0x0F]:02X}{pal_data[0x0E]:02X}\n")
f_out.write(f".short 0x{pal_data[0x11]:02X}{pal_data[0x10]:02X}\n")
f_out.write(f".short 0x{pal_data[0x13]:02X}{pal_data[0x12]:02X}\n")
f_out.write(f".short 0x{pal_data[0x15]:02X}{pal_data[0x14]:02X}\n")
f_out.write(f".short 0x{pal_data[0x17]:02X}{pal_data[0x16]:02X}\n")
f_out.write(f".short 0x{pal_data[0x19]:02X}{pal_data[0x18]:02X}\n")
f_out.write(f".short 0x{pal_data[0x1B]:02X}{pal_data[0x1A]:02X}\n")
f_out.write(f".short 0x{pal_data[0x1D]:02X}{pal_data[0x1C]:02X}\n")
f_out.write(f".short 0x{pal_data[0x1F]:02X}{pal_data[0x1E]:02X}\n")
f_out.write("\n")
return None
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="convert a PNG to an assemblable GNU-friendly data file"
)
parser.add_argument("input")
parser.add_argument("output_bmp")
parser.add_argument("name_bmp")
parser.add_argument("output_pal")
parser.add_argument("name_pal")
args = parser.parse_args()
err = convert(
args.input,
args.output_bmp,
args.name_bmp,
args.output_pal,
args.name_pal,
False,
)
if err:
raise Exception(err)

View File

@ -1,54 +1,7 @@
import n64img.image
from typing import List, Tuple
from segtypes.n64.img import N64SegImg
from segtypes.n64.ci4 import N64SegCi4
def generate_grey_palette() -> List[Tuple[int, int, int, int]]:
def generate_grey_color(intensity: int) -> Tuple[int, int, int, int]:
return intensity, intensity, intensity, 255
return [
generate_grey_color(0x00),
generate_grey_color(0x11),
generate_grey_color(0x22),
generate_grey_color(0x33),
generate_grey_color(0x44),
generate_grey_color(0x55),
generate_grey_color(0x66),
generate_grey_color(0x77),
generate_grey_color(0x88),
generate_grey_color(0x99),
generate_grey_color(0xAA),
generate_grey_color(0xBB),
generate_grey_color(0xCC),
generate_grey_color(0xDD),
generate_grey_color(0xEE),
generate_grey_color(0xFF),
]
class PSXSegCi4(N64SegImg):
class PSXSegCi4(N64SegCi4):
def __init__(self, *args, **kwargs):
kwargs["img_cls"] = n64img.image.CI4
super().__init__(*args, **kwargs)
def flip_endian(self, src):
dst = bytearray(src)
for i in range(0, len(dst)):
ch = dst[i]
dst[i] = (ch >> 4) | ((ch & 0xF) << 4)
return dst
def split(self, rom_bytes):
path = self.out_path()
path.parent.mkdir(parents=True, exist_ok=True)
assert isinstance(self.rom_start, int)
assert isinstance(self.rom_end, int)
self.n64img.palette = generate_grey_palette()
self.n64img.data = self.flip_endian(rom_bytes[self.rom_start : self.rom_end])
self.n64img.write(path)
self.log(f"Wrote {self.name} to {path}")
self.n64img.little_endian = True

48
tools/splat_ext/grey4.py Normal file
View File

@ -0,0 +1,48 @@
import n64img.image
from typing import List, Tuple
from segtypes.n64.img import N64SegImg
def generate_grey_palette() -> List[Tuple[int, int, int, int]]:
def generate_grey_color(intensity: int) -> Tuple[int, int, int, int]:
return intensity, intensity, intensity, 255
return [
generate_grey_color(0x00),
generate_grey_color(0x11),
generate_grey_color(0x22),
generate_grey_color(0x33),
generate_grey_color(0x44),
generate_grey_color(0x55),
generate_grey_color(0x66),
generate_grey_color(0x77),
generate_grey_color(0x88),
generate_grey_color(0x99),
generate_grey_color(0xAA),
generate_grey_color(0xBB),
generate_grey_color(0xCC),
generate_grey_color(0xDD),
generate_grey_color(0xEE),
generate_grey_color(0xFF),
]
class PSXSegGrey4(N64SegImg):
def __init__(self, *args, **kwargs):
kwargs["img_cls"] = n64img.image.CI4
super().__init__(*args, **kwargs)
def split(self, rom_bytes):
path = self.out_path()
path.parent.mkdir(parents=True, exist_ok=True)
assert isinstance(self.rom_start, int)
assert isinstance(self.rom_end, int)
self.n64img.palette = generate_grey_palette()
self.n64img.data = rom_bytes[self.rom_start : self.rom_end]
self.n64img.little_endian = True
self.n64img.write(path)
self.log(f"Wrote {self.name} to {path}")

9
tools/splat_ext/i4.py Normal file
View File

@ -0,0 +1,9 @@
import n64img.image
from segtypes.n64.i4 import N64SegI4
class PSXSegI4(N64SegI4):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.n64img.little_endian = True

View File

@ -0,0 +1,42 @@
from itertools import zip_longest
from math import ceil
from typing import List, Tuple
from segtypes.n64.palette import N64SegPalette
# ABBBBBGG GGGRRRRR
def unpack_color(data):
s = int.from_bytes(data[0:2], byteorder="little")
r = s & 0x1F
g = (s >> 5) & 0x1F
b = (s >> 10) & 0x1F
a = (s >> 15) * 0xFF
r = ceil(0xFF * (r / 31))
g = ceil(0xFF * (g / 31))
b = ceil(0xFF * (b / 31))
return r, g, b, a
def iter_in_groups(iterable, n, fillvalue=None):
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)
class PSXSegPalette(N64SegPalette):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def parse_palette(self, rom_bytes) -> List[Tuple[int, int, int, int]]:
assert isinstance(self.rom_start, int)
assert isinstance(self.rom_end, int)
data = rom_bytes[self.rom_start : self.rom_end]
palette = []
for a, b in iter_in_groups(data, 2):
palette.append(unpack_color([a, b]))
return palette

View File

@ -0,0 +1,9 @@
import n64img.image
from segtypes.n64.rgba16 import N64SegRgba16
class PSXSegRgba16(N64SegRgba16):
def __init__(self, *args, **kwargs):
kwargs["img_cls"] = n64img.image.RGBA16
super().__init__(*args, **kwargs)