-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·104 lines (81 loc) · 2.63 KB
/
Copy pathMakefile
File metadata and controls
executable file
·104 lines (81 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
###############################################################################
# (GNU make is required)
# Usage:
# To comple .c to .s : make x.s
# To comple to .nes : make x.nes
# To run emulator : make x.run
#
# cha-rom -> neschar.inc (ascii code)
# memory map -> map.h
###############################################################################
# 2014-12-19 : Initial vertion by T.Furukawa based on AISoC's Makefile
###############################################################################
ifndef SRCDIR
SRCDIR = .
endif
NESDIR = $(SRCDIR)/../nes
NESEXE = $(NESDIR)/debug/obj_dir/VNES
M65CDIR ?= /opt/cc65
M65C = $(M65CDIR)/bin/cc65
#M65ASM = $(M65CDIR)/bin/ca65 --include-dir $(M65CDIR)/asminc
M65ASM = $(M65CDIR)/bin/ca65
M65LD = $(M65CDIR)/bin/ld65
M65CFG = $(SRCDIR)/lib/nes.cfg
M65LIB = $(M65CDIR)/share/cc65/lib/nes.lib
EMULATOR = ./emulators/fceux-2.6.6-win64/fceux64.exe
READNES = ./emulators/ReadNES3.exe
INPUTS = $(wildcard *.c)
OUTPUTS = $(INPUTS:.c=.nes)
FILE = lib/ppu.h lib/apu.h lib/pad.h lib/map.h
VPATH = $(SRCDIR):$(SRCDIR)/lib
ifndef EDITOR
EDITOR = $(SRCDIR)/Terapad/TeraPad.exe
endif
MIRROR = 1
all: $(M65C) $(OUTPUTS)
$(M65C):
cd $(M65CDIR); make
$(NESEXE):
cd $(NESDIR); make sim
$(FILE):
clean:
rm -f *.s *.o *.nes *.hex *~ *.cha *.prg *.txt *.bin
dist-clean:clean
cd $(M65CDIR); make clean;
################################
# suffix rules
################################
.SUFFIXES: .c .hex .s .nes .run
%.s:$(M65C) %.c $(FILE)
$(M65C) $(CFLAGS) -Or -I./lib $*.c
%.o:$(M65C) %.s
$(M65ASM) $*.s
%.nes:%.s crt0.o
$(M65ASM) $*.s
$(M65LD) -o $*.nes -C $(M65CFG) $*.o crt0.o $(M65LIB)
crt0.o:$(M65C) crt0.s neschar.inc
$(M65ASM) -D__NES_MIRRORING__=$(MIRROR) -I$(SRCDIR) -I$(SRCDIR)/lib $(SRCDIR)/lib/crt0.s -o $@
%.rom:%.nes
$(READNES) $<
%.run:%.nes
$(EMULATOR) $<
game:game.nes
$(EMULATOR) $<
repair:
cp .game.c.bak game.c
cp .game.h.bak game.h
edit:game.c
$(EDITOR) $< &
%.cha:%.nes
( PRG_N=`od -v -An -t x1 $< |awk 'NR==1 {print strtonum("0x" $$5)*0x4000/0x10}'`; \
CHA_N=`od -v -An -t x1 $< |awk 'NR==1 {print strtonum("0x" $$6)*0x2000/0x10}'`; \
od -v -An -t x1 $< |awk "NR>$$PRG_N+1&&NR<=($$CHA_N+$$PRG_N+1)" > $@ ; )
%.prg:%.nes
( PRG_N=`od -v -An -t x1 $< |awk 'NR==1 {print strtonum("0x" $$5)*0x4000/0x10}'`; \
CHA_N=`od -v -An -t x1 $< |awk 'NR==1 {print strtonum("0x" $$6)*0x2000/0x10}'`; \
od -v -An -t x1 $< |awk "NR>1&&NR<=$$PRG_N+1" > $@ ; )
%.sim:%.prg %.cha %.nes $(NESEXE)
(cd $(NESDIR); make sim)
cp $*.prg prg.txt
cp $*.cha cha.txt
$(NESEXE) $*.nes