Skip to content

Commit a4816d2

Browse files
committed
add donut chr compression and ((noinline)) some funcs
1 parent 3c054ea commit a4816d2

File tree

13 files changed

+419
-56
lines changed

13 files changed

+419
-56
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ew windows
22
.vscode
33

4+
src/chr/dnt/*.bin
5+
46
*.nes
57
*.mlb
68
*.bak

makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ TMPDIR ?= $(TMPDIR_PREFIX)
6767
CFG ?= link.ld
6868

6969
CFLAGS = -flto -Os -ffast-math -fnonreentrant -std=gnu23 -Wall -Wextra
70-
LDFLAGS = -mreserve-zp=9 -T $(CFG)
70+
LDFLAGS = -mreserve-zp=27 -T $(CFG)
7171

7272
ifneq ($(findstring build,$(MAKECMDGOALS)),)
7373
ifeq ($(LEVELSET),)
@@ -79,7 +79,7 @@ endif
7979

8080

8181
# optimize for code size (the ideal method)
82-
build: $(TMPDIR) $(OUTDIR) $(OUTDIR)/$(NAME).nes
82+
build: CHR $(TMPDIR) $(OUTDIR) $(OUTDIR)/$(NAME).nes
8383

8484

8585

@@ -97,6 +97,9 @@ main:
9797

9898
#target: dependencies
9999

100+
CHR:
101+
python3 src/chr/donut.py src/chr/uncompressed/ src/chr/dnt -f
102+
100103
$(OUTDIR):
101104
$(call mkdir,$(OUTDIR))
102105

@@ -109,10 +112,13 @@ $(TMPDIR)/music.o: src/famistudio/music_0_bank*.dmc src/famistudio/*.s src/famis
109112
# compile all of the music assets into one giant object file
110113
$(CA65) src/famistudio/music_assets.s -o $@
111114

112-
$(TMPDIR)/assets.o: src/chr/uncompressed/*.chr src/assets.c src/assets.h
115+
$(TMPDIR)/donut.o: src/chr/*.s
116+
$(CA65) src/chr/donut.s -o $@
117+
118+
$(TMPDIR)/assets.o: src/chr/dnt/*.bin src/assets.c src/assets.h
113119
$(CC) -c src/assets.c $(CFLAGS) -o $@
114120

115-
$(OUTDIR)/$(NAME).nes: $(OUTDIR) $(TMPDIR)/music.o $(TMPDIR)/assets.o src/*.h src/*.c src/gamestates/*.c $(CFG)
121+
$(OUTDIR)/$(NAME).nes: $(OUTDIR) $(TMPDIR)/music.o $(TMPDIR)/assets.o $(TMPDIR)/donut.o src/*.h src/*.c src/gamestates/*.c $(CFG)
116122
$(CC) src/main.c $(TMPDIR)/*.o $(CFLAGS) $(LDFLAGS) -o $@
117123

118124

src/assets.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
11
#include "assets.h"
22

33
file(chr_menu_global, chr_bank_0) = {
4-
#embed "./chr/uncompressed/Menu_Global.chr" // 0.50 kb
4+
#embed "./chr/dnt/Menu_Global.bin"
55
};
66
file(chr_font, chr_bank_0) = {
7-
#embed "./chr/uncompressed/Font.chr" // 1.50 kb
7+
#embed "./chr/dnt/Font.bin"
88
};
99
file(chr_logo, chr_bank_0) = {
10-
#embed "./chr/uncompressed/Logo.chr" // 1.00 kb
10+
#embed "./chr/dnt/Logo.bin"
1111
};
1212
file(chr_famidash, chr_bank_0) = {
13-
#embed "./chr/uncompressed/Famidash.chr" // 1.00 kb
13+
#embed "./chr/dnt/Famidash.bin"
1414
};
1515

1616

1717
file(chr_tiles_global, chr_bank_1) = {
18-
#embed "./chr/uncompressed/General.chr" // 1.00 kb
18+
#embed "./chr/dnt/General.bin"
1919
};
2020
file(chr_tiles_grid, chr_bank_1) = {
21-
#embed "./chr/uncompressed/Grid.chr" // 1.00 kb
21+
#embed "./chr/dnt/Grid.bin"
2222
};
2323
file(chr_tiles_cross, chr_bank_1) = {
24-
#embed "./chr/uncompressed/Cross.chr" // 0.25 kb
24+
#embed "./chr/dnt/Cross.bin"
2525
};
2626
file(chr_tiles_brick, chr_bank_1) = {
27-
#embed "./chr/uncompressed/Brick.chr" // 0.25 kb
27+
#embed "./chr/dnt/Brick.bin"
2828
};
2929
file(chr_tiles_black, chr_bank_1) = {
30-
#embed "./chr/uncompressed/Black.chr" // 0.25 kb
30+
#embed "./chr/dnt/Black.bin"
3131
};
3232

33-
//embed(); // 1.00 kb
34-
//embed(, ); // 0.25 kb
35-
//embed(, ); // 0.25 kb
36-
//embed(, ); // 0.25 kb
37-
//embed(, ); // 0.25 kb
3833

3934

4035

scripts/donut.py renamed to src/chr/donut.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ def main(argv=None):
494494
ratio = 0
495495
else:
496496
ratio = float('NaN')
497+
output_file.write(b'\xff')
497498
print("{} :{:>6.1%} ({} => {} bytes, {})".format(input_file.file_name, ratio, r, w, output_file.file_name), file=sys.stderr)
498499
total_input_bytes += r
499500
total_output_bytes += w

0 commit comments

Comments
 (0)