Skip to content

Commit 29f2d50

Browse files
committed
build processes
adding makefile for setup on linux
1 parent ac375e6 commit 29f2d50

File tree

6 files changed

+113
-14
lines changed

6 files changed

+113
-14
lines changed

.dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ __pycache__
55

66
# Installed from source
77
bin/*
8-
!bin/*.bat
98
*.lnk
109
emu/*
1110
.vscode
11+
12+
build

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ bin/sneschk.py
1010
bin/snesbrr*
1111
bin/pmage*
1212
bin/*
13-
!bin/*.bat
1413
*.lnk
15-
emu/*
14+
emu/*
15+
build

Makefile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# For installing tools.
2+
3+
.PHONY: all
4+
5+
export SNESKIT := $(CURDIR)
6+
7+
#-----------------------------------------------------------------------------------------
8+
all: cc65/bin/ca65 bin/sneschk
9+
10+
#-----------------------------------------------------------------------------------------
11+
cc65/bin/ca65:
12+
git clone https://github.com/cc65/cc65.git
13+
cd cc65
14+
make
15+
16+
#-----------------------------------------------------------------------------------------
17+
# sneschk - from the local repo
18+
bin/sneschk: tool-src/sneschk/sneschk.py
19+
cp tool-src/sneschk/sneschk.py bin/sneschk
20+
chmod a+x bin/sneschk
21+
22+
#-----------------------------------------------------------------------------------------
23+
# SNESMOD smconv
24+
bin/smconv:
25+
mkdir -p build
26+
cd build
27+
git clone https://github.com/mukunda-/snesmod
28+
cd snesmod/smconv
29+
make sneskit_install
30+
31+
#-----------------------------------------------------------------------------------------
32+
# snesbrr
33+
bin/snesbrr:
34+
mkdir -p build
35+
cd build
36+
git clone https://github.com/mukunda-/snesbrr
37+
cd snesbrr
38+
make sneskit_install
39+
40+
#-----------------------------------------------------------------------------------------
41+
bin/bin2ca:
42+
cp tool-src/bin2ca/bin2ca.py bin/bin2ca
43+
chmod a+x bin/bin2ca
44+
45+
#-----------------------------------------------------------------------------------------
46+
clean:
47+
rm -rf cc65
48+
rm -f bin/sneschk bin/smconv bin/snesbrr bin/bin2ca

bin/sneschk.bat

-3
This file was deleted.

setup.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,27 @@ def install_snesbrr():
7979
if bin_exists("snesbrr"):
8080
print("*** snesbrr already installed. Skipping installation.")
8181
return
82-
run("mkdir -p build")
83-
run("cd build")
82+
os.makedirs("build", mode=0o755, exist_ok=True)
83+
os.chdir("build")
8484
run("git clone https://github.com/mukunda-/snesbrr")
85-
run("cd snesbrr")
85+
os.chdir("snesbrr")
8686
run("make sneskit_install")
87-
run("cd ../..")
87+
os.chdir("..")
88+
os.chdir("..")
8889

8990
#-----------------------------------------------------------------------------------------
9091
def install_snesmod():
9192
if bin_exists("smconv"):
9293
print("*** smconv already installed. Skipping installation.")
93-
run("mkdir -p build")
94-
run("cd build")
94+
os.makedirs("build", mode=0o755, exist_ok=True)
95+
os.chdir("build")
9596
run("git clone https://github.com/mukunda-/snesmod")
96-
run("cd snesmod/smconv")
97+
os.chdir("snesmod")
98+
os.chdir("smconv")
9799
run("make sneskit_install")
98-
run("cd ../..")
100+
os.chdir("..")
101+
os.chdir("..")
102+
os.chdir("..")
99103

100104
#-----------------------------------------------------------------------------------------
101105
install_cc65()

tool-src/bin2ca/bin2ca.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python3
2+
#*****************************************************************************************
3+
# SNESMOD
4+
# (C) 2025 Mukunda Johnson (mukunda.com)
5+
# Licensed under MIT
6+
#*****************************************************************************************
7+
import argparse
8+
9+
#-----------------------------------------------------------------------------------------
10+
def bin2ca():
11+
parser = argparse.ArgumentParser(prog="bin2ca.py", description='Convert binary files to assembly files for ca65.')
12+
parser.add_argument('input_file', type=str, help='The binary file to convert.')
13+
parser.add_argument('output_file', type=str, help='The output assembly file.')
14+
parser.add_argument('--label', type=str, help='A label to emit for the assembly file. LABEL and LABEL_end will be produced if this argument is given.')
15+
parser.add_argument('--segment', type=str, help='The segment to emit for the assembly file.')
16+
parser.add_argument('--bytesperline', type=int, default=64, help='The number of bytes to emit per line.')
17+
args = parser.parse_args()
18+
19+
with open(args.input_file, "rb") as f:
20+
data = f.read()
21+
22+
with open(args.output_file, "w") as f:
23+
f.write(f"""
24+
; bin2ca.py converted binary data
25+
; total size: {len(data)} bytes""".strip())
26+
f.write("\n\n")
27+
28+
if args.label:
29+
f.write(f"\t.global {args.label}, {args.label}_end\n")
30+
31+
if args.segment:
32+
f.write(f"\t.segment \"{args.segment}\"\n")
33+
34+
f.write("\n")
35+
36+
if args.label:
37+
f.write(f"{args.label}:\n")
38+
39+
bpl = args.bytesperline
40+
for i in range(0, len(data), bpl):
41+
f.write("\t.byte ")
42+
f.write(",".join([f"${byte:02x}" for byte in data[i:i+bpl]]))
43+
f.write("\n")
44+
45+
if args.label:
46+
f.write(f"{args.label}_end:\n")
47+
48+
if __name__ == "__main__":
49+
bin2ca()

0 commit comments

Comments
 (0)