mirror of
https://github.com/YohannDR/mzm.git
synced 2024-11-26 22:40:42 +00:00
Add first version of extractor
This commit is contained in:
parent
a5593bb34c
commit
04396acc1c
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
/src/**/*.s
|
||||
/data/*
|
||||
!/data/data.txt
|
||||
|
||||
*.gba
|
||||
*.elf
|
||||
@ -14,7 +13,6 @@
|
||||
*.deps.json
|
||||
*.runtimeconfig.json
|
||||
|
||||
data/*.c
|
||||
include/**/*.s
|
||||
tools/*.txt
|
||||
.vscode
|
10
Makefile
10
Makefile
@ -32,6 +32,8 @@ SHA1SUM = sha1sum
|
||||
TAIL = tail
|
||||
|
||||
GBAFIX = tools/gbafix/gbafix
|
||||
PYTHON = python3
|
||||
EXTRACTOR = tools/extractor.py
|
||||
|
||||
# Flags
|
||||
ASFLAGS = -mcpu=arm7tdmi
|
||||
@ -56,10 +58,6 @@ endif
|
||||
.PHONY: all
|
||||
all: $(TARGET)
|
||||
|
||||
.PHONY: extract
|
||||
extract:
|
||||
$(MSG) MZM-Extractor -a
|
||||
|
||||
.PHONY: check
|
||||
check: all
|
||||
$(MSG) SHA1SUM $(SHA1FILE)
|
||||
@ -96,7 +94,6 @@ help:
|
||||
@echo ' dump: dump the ROMs'
|
||||
@echo ' diff: compare the ROM with the original'
|
||||
@echo ' clean: remove the ROM and intermediate files'
|
||||
@echo ' extract: extract data as files using the MZM-Extractor (https://github.com/YohannDR/MZM-Extractor)'
|
||||
@echo ' help: show this message'
|
||||
@echo ''
|
||||
@echo 'Flags:'
|
||||
@ -124,6 +121,9 @@ $(ELF) $(MAP): $(OBJ) linker.ld
|
||||
$(MSG) CC $@
|
||||
$Q$(CPP) $(CPPFLAGS) $< | $(CC) -o $@ $(CFLAGS) && printf '\t.align 2, 0 @ dont insert nops\n' >> $@
|
||||
|
||||
%.c:
|
||||
$(MSG) Extractor $@
|
||||
$Q$(PYTHON) $(EXTRACTOR)
|
||||
|
||||
src/sram/%.s: CFLAGS = -O1 -mthumb-interwork -fhex-asm
|
||||
src/sram/%.s: src/sram/%.c
|
||||
|
1
database.txt
Normal file
1
database.txt
Normal file
@ -0,0 +1 @@
|
||||
Sprites/MorphBall.gfx;672;0x2b28a8
|
35
tools/extractor.py
Normal file
35
tools/extractor.py
Normal file
@ -0,0 +1,35 @@
|
||||
from array import array
|
||||
from io import BufferedReader
|
||||
import os
|
||||
import shutil
|
||||
|
||||
DATA_PATH = "../data/"
|
||||
subDirs: array = [
|
||||
"Sprites/"
|
||||
]
|
||||
|
||||
shutil.rmtree(DATA_PATH, ignore_errors=False, onerror=None)
|
||||
|
||||
if not os.path.exists(DATA_PATH):
|
||||
# Create directories
|
||||
os.mkdir(DATA_PATH)
|
||||
for dir in subDirs:
|
||||
os.mkdir(DATA_PATH.__add__(dir))
|
||||
|
||||
|
||||
rom: BufferedReader = open("../mzm_us_baserom.gba", "rb")
|
||||
db: BufferedReader = open("../database.txt", "r")
|
||||
|
||||
line: str = db.readline()
|
||||
while line != '':
|
||||
# Formatted as follows : name;size;address
|
||||
info: array = line.split(";")
|
||||
rom.seek(int(info[2], 16))
|
||||
data = rom.read(int(info[1]))
|
||||
|
||||
output: BufferedReader = open("../data/".__add__(info[0]), "wb")
|
||||
output.write(bytearray(data))
|
||||
output.close()
|
||||
line = db.readline()
|
||||
|
||||
rom.close()
|
Loading…
Reference in New Issue
Block a user