mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-22 10:39:20 +01:00
Rename sc64 finalize to minify
Fix ability to make without parameters
This commit is contained in:
parent
b5a9fa31fe
commit
5485aef989
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
@ -44,6 +44,7 @@ jobs:
|
|||||||
- name: Build N64FlashcartMenu ROM
|
- name: Build N64FlashcartMenu ROM
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
|
mkdir output
|
||||||
# TODO: split this to use params for each flashcart type.
|
# TODO: split this to use params for each flashcart type.
|
||||||
make -j all
|
make -j all
|
||||||
|
|
||||||
@ -52,9 +53,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: N64FlashcartMenu
|
name: N64FlashcartMenu
|
||||||
path: |
|
path: |
|
||||||
./build/N64FlashcartMenu.z64
|
./output/N64FlashcartMenu.z64
|
||||||
|
./build/N64FlashcartMenu.elf
|
||||||
|
|
||||||
finalize-sc64-menu:
|
minify-sc64-menu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
|
|
||||||
@ -74,12 +76,11 @@ jobs:
|
|||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: N64FlashcartMenu
|
name: N64FlashcartMenu
|
||||||
path: ./build
|
path: ./
|
||||||
|
|
||||||
- name: Finalize rom
|
- name: Finalize rom
|
||||||
run: |
|
run: |
|
||||||
cd ./build
|
python ./tools/sc64/minify.py ./build/N64FlashcartMenu.elf ./output/N64FlashcartMenu.z64 ./output/sc64menu.n64
|
||||||
python ../tools/sc64/finalize.py N64FlashcartMenu.z64
|
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
@ -87,13 +88,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: SC64-Menu
|
name: SC64-Menu
|
||||||
path: |
|
path: |
|
||||||
./build/sc64menu.n64
|
./output/sc64menu.n64
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|
||||||
|
|
||||||
# release-sc64-menu:
|
# release-sc64-menu:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# needs: finalize-sc64-menu
|
# needs: minify-sc64-menu
|
||||||
|
|
||||||
# steps:
|
# steps:
|
||||||
# - name: Generate release
|
# - name: Generate release
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
/.vscode
|
/.vscode
|
||||||
/build
|
/build
|
||||||
|
/output
|
||||||
tools/sc64/sc64.exe
|
tools/sc64/sc64.exe
|
||||||
|
9
Makefile
9
Makefile
@ -1,9 +1,10 @@
|
|||||||
# .DEFAULT_GOAL := mytarget
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
EXE_NAME = N64FlashcartMenu
|
EXE_NAME = N64FlashcartMenu
|
||||||
|
|
||||||
SOURCE_DIR = src
|
SOURCE_DIR = src
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
|
OUTPUT_DIR = output
|
||||||
|
|
||||||
include $(N64_INST)/include/n64.mk
|
include $(N64_INST)/include/n64.mk
|
||||||
|
|
||||||
@ -32,12 +33,14 @@ $(BUILD_DIR)/$(EXE_NAME).elf: $(OBJS)
|
|||||||
$(EXE_NAME).z64: N64_ROM_TITLE=$(EXE_NAME)
|
$(EXE_NAME).z64: N64_ROM_TITLE=$(EXE_NAME)
|
||||||
|
|
||||||
all: $(EXE_NAME).z64
|
all: $(EXE_NAME).z64
|
||||||
$(shell mv $(EXE_NAME).z64 $(BUILD_DIR))
|
$(shell mkdir $(OUTPUT_DIR))
|
||||||
$(shell cd $(BUILD_DIR)/ && python3 ../tools/sc64/finalize.py ./$(EXE_NAME).z64)
|
$(shell mv $(EXE_NAME).z64 $(OUTPUT_DIR))
|
||||||
|
$(shell python3 ./tools/sc64/minify.py $(BUILD_DIR)/$(EXE_NAME).elf $(OUTPUT_DIR)/N64FlashcartMenu.z64 $(OUTPUT_DIR)/sc64menu.n64)
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(shell rm -rf ./$(BUILD_DIR))
|
$(shell rm -rf ./$(BUILD_DIR))
|
||||||
|
$(shell rm -rf ./$(OUTPUT_DIR))
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
# run:
|
# run:
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
if (len(sys.argv) != 2):
|
|
||||||
print(f'Usage: python {sys.argv[0]} input')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
ALIGN = 512
|
|
||||||
STRIP_BYTE = b'\x00'
|
|
||||||
|
|
||||||
input_file = sys.argv[1]
|
|
||||||
sc64_output = 'sc64menu.n64'
|
|
||||||
|
|
||||||
try:
|
|
||||||
bin_data = b''
|
|
||||||
|
|
||||||
with open(input_file, 'rb') as f:
|
|
||||||
bin_data = f.read()
|
|
||||||
|
|
||||||
bin_data = bin_data.strip(STRIP_BYTE)
|
|
||||||
modulo = len(bin_data) % ALIGN
|
|
||||||
if (modulo > 0):
|
|
||||||
bin_data += STRIP_BYTE * (ALIGN - modulo)
|
|
||||||
|
|
||||||
with open(sc64_output, 'wb') as f:
|
|
||||||
f.write(bin_data)
|
|
||||||
|
|
||||||
except FileNotFoundError as e:
|
|
||||||
print(f'Couldn\'t open file: {e}')
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
sys.exit(3)
|
|
39
tools/sc64/minify.py
Normal file
39
tools/sc64/minify.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
|
||||||
|
def get_rom_end(elf):
|
||||||
|
p1 = Popen(f'readelf -s {elf}'.split(), stdout=PIPE)
|
||||||
|
p2 = Popen('grep -m 1 __rom_end'.split(), stdin=p1.stdout, stdout=PIPE)
|
||||||
|
stdout, _ = p2.communicate()
|
||||||
|
rom_end = int(stdout.decode('UTF-8').split()[1], 16)
|
||||||
|
rom_end &= 0x1FFFFFFF
|
||||||
|
rom_end -= 0x400
|
||||||
|
rom_end += 0x1000
|
||||||
|
return rom_end
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if (len(sys.argv) != 4):
|
||||||
|
print(f'Usage: python {sys.argv[0]} elf input output')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
elf_file = sys.argv[1]
|
||||||
|
input_file = sys.argv[2]
|
||||||
|
output_file = sys.argv[3]
|
||||||
|
|
||||||
|
ALIGN = 512
|
||||||
|
|
||||||
|
rom_end = get_rom_end(elf_file)
|
||||||
|
modulo = rom_end % ALIGN
|
||||||
|
if (modulo > 0):
|
||||||
|
rom_end += (ALIGN - modulo)
|
||||||
|
|
||||||
|
minified_data = b''
|
||||||
|
with open(input_file, 'rb') as f:
|
||||||
|
minified_data = f.read(rom_end)
|
||||||
|
|
||||||
|
with open(output_file, 'wb') as f:
|
||||||
|
f.write(minified_data)
|
Loading…
Reference in New Issue
Block a user