Skip to content

Commit 7652ec5

Browse files
committed
Initial Revision
Manic Miner for Apple II
1 parent ca737f4 commit 7652ec5

30 files changed

+11375
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode/*
2+
!.vscode/settings.json
3+
!.vscode/tasks.json
4+
!.vscode/launch.json
5+
!.vscode/extensions.json
6+
*.code-workspace
7+
/obj/
8+
/Makefile.options
9+
/mminer.dsk
10+
/mminer.apple2*

Makefile

Lines changed: 349 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,349 @@
1+
###############################################################################
2+
### Generic Makefile for cc65 projects - full version with abstract options ###
3+
### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" Łogiewa ###
4+
###############################################################################
5+
6+
###############################################################################
7+
### In order to override defaults - values can be assigned to the variables ###
8+
###############################################################################
9+
10+
# Space or comma separated list of cc65 supported target platforms to build for.
11+
# Default: c64 (lowercase!)
12+
TARGETS := apple2
13+
14+
# Name of the final, single-file executable.
15+
# Default: name of the current dir with target name appended
16+
PROGRAM := mminer
17+
18+
# Path(s) to additional libraries required for linking the program
19+
# Use only if you don't want to place copies of the libraries in SRCDIR
20+
# Default: none
21+
LIBS :=
22+
23+
# Custom linker configuration file
24+
# Use only if you don't want to place it in SRCDIR
25+
# Default: none
26+
CONFIG :=
27+
28+
# Additional C compiler flags and options.
29+
# Default: none
30+
CFLAGS =
31+
32+
# Additional assembler flags and options.
33+
# Default: none
34+
ASFLAGS =
35+
36+
# Additional linker flags and options.
37+
# Default: none
38+
LDFLAGS =
39+
ifeq ($(PROGRAM),)
40+
NAME := $(notdir $(CURDIR))
41+
else
42+
NAME := $(PROGRAM)
43+
endif
44+
$(NAME).apple2: LDFLAGS +=
45+
46+
# Path to the directory containing C and ASM sources.
47+
# Default: src
48+
SRCDIR :=
49+
50+
# Path to the directory where object files are to be stored (inside respective target subdirectories).
51+
# Default: obj
52+
OBJDIR :=
53+
54+
# Command used to run the emulator.
55+
# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload
56+
EMUCMD :=
57+
58+
# On Windows machines VICE emulators may not be available in the PATH by default.
59+
# In such case, please set the variable below to point to directory containing
60+
# VICE emulators.
61+
#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\"
62+
VICE_HOME :=
63+
#APPLEWIN_HOME := c:\users\swessels\apps\applewin
64+
65+
# Optional commands used before starting the emulation process, and after finishing it.
66+
# Default: none
67+
# Examples
68+
#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate"
69+
#PREEMUCMD := osascript -e "tell application \"X11\" to activate"
70+
#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false"
71+
#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate"
72+
#PREEMUCMD := sed "s/^al \([[0-9A-F]\+\)\ \./\1 /g" $(NAME).apple2.lbl > $(APPLEWIN_HOME)\A2_USER1.SYM
73+
POSTEMUCMD :=
74+
75+
76+
# Options state file name. You should not need to change this, but for those
77+
# rare cases when you feel you really need to name it differently - here you are
78+
STATEFILE := Makefile.options
79+
80+
###################################################################################
81+
#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! ####
82+
###################################################################################
83+
84+
###################################################################################
85+
### Mapping abstract options to the actual compiler, assembler and linker flags ###
86+
### Predefined compiler, assembler and linker flags, used with abstract options ###
87+
### valid for 2.14.x. Consult the documentation of your cc65 version before use ###
88+
###################################################################################
89+
90+
# Compiler flags used to tell the compiler to optimise for SPEED
91+
define _optspeed_
92+
CFLAGS += -Oris
93+
endef
94+
95+
# Compiler flags used to tell the compiler to optimise for SIZE
96+
define _optsize_
97+
CFLAGS += -Or
98+
endef
99+
100+
# Compiler and assembler flags for generating listings
101+
define _listing_
102+
CFLAGS += --listing $$(@:.o=.lst)
103+
ASFLAGS += --listing $$(@:.o=.lst)
104+
REMOVES += $(addsuffix .lst,$(basename $(OBJECTS)))
105+
endef
106+
107+
# Linker flags for generating map file
108+
define _mapfile_
109+
LDFLAGS += --mapfile $$@.map
110+
REMOVES += $(PROGRAM).map
111+
endef
112+
113+
# Linker flags for generating VICE label file
114+
define _labelfile_
115+
ASFLAGS += --debug-info
116+
LDFLAGS += -Ln $$@.lbl
117+
REMOVES += $(PROGRAM).lbl
118+
endef
119+
120+
# Linker flags for generating a debug file
121+
define _debugfile_
122+
LDFLAGS += -Wl --dbgfile,$$@.dbg
123+
REMOVES += $(PROGRAM).dbg
124+
endef
125+
126+
###############################################################################
127+
### Defaults to be used if nothing defined in the editable sections above ###
128+
###############################################################################
129+
130+
# Presume the C64 target like the cl65 compile & link utility does.
131+
# Set TARGETS to override.
132+
ifeq ($(TARGETS),)
133+
TARGETS := c64
134+
endif
135+
136+
# Presume we're in a project directory so name the program like the current
137+
# directory. Set PROGRAM to override.
138+
ifeq ($(PROGRAM),)
139+
PROGRAM := $(notdir $(CURDIR))
140+
endif
141+
142+
# Presume the C and asm source files to be located in the subdirectory 'src'.
143+
# Set SRCDIR to override.
144+
ifeq ($(SRCDIR),)
145+
SRCDIR := src
146+
endif
147+
148+
# Presume the object and dependency files to be located in the subdirectory
149+
# 'obj' (which will be created). Set OBJDIR to override.
150+
ifeq ($(OBJDIR),)
151+
OBJDIR := obj
152+
endif
153+
TARGETOBJDIR := $(OBJDIR)/$(TARGETS)
154+
155+
# Default emulator commands and options for particular targets.
156+
# Set EMUCMD to override.
157+
c64_EMUCMD := $(VICE_HOME)x64 -kernal kernal -VICIIdsize -autoload
158+
c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload
159+
vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload
160+
pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload
161+
plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload
162+
# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option
163+
c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload
164+
cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload
165+
cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload
166+
atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run
167+
cx16_EMUCMD := x16emu -run -prg
168+
apple2_EMUCMD := $(APPLEWIN_HOME)\AppleWin.exe -d1 $(CURDIR)\$(NAME).dsk
169+
170+
ifeq ($(EMUCMD),)
171+
EMUCMD = $($(CC65TARGET)_EMUCMD)
172+
endif
173+
174+
###############################################################################
175+
### The magic begins ###
176+
###############################################################################
177+
178+
# The "Native Win32" GNU Make contains quite some workarounds to get along with
179+
# cmd.exe as shell. However it does not provide means to determine that it does
180+
# actually activate those workarounds. Especially $(SHELL) does NOT contain the
181+
# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to
182+
# execute the command 'echo' without any parameters. Only cmd.exe will return a
183+
# non-empty string - saying 'ECHO is on/off'.
184+
#
185+
# Many "Native Win32" programs accept '/' as directory delimiter just fine. How-
186+
# ever the internal commands of cmd.exe generally require '\' to be used.
187+
#
188+
# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a
189+
# '-p' to create parent directories as needed.
190+
#
191+
# cmd.exe has an internal command 'del' that reports a syntax error if executed
192+
# without any file so make sure to call it only if there's an actual argument.
193+
ifeq ($(shell echo),)
194+
MKDIR = mkdir -p $1
195+
RMDIR = rmdir $1
196+
RMFILES = $(RM) $1
197+
else
198+
MKDIR = mkdir $(subst /,\,$1)
199+
RMDIR = rmdir $(subst /,\,$1)
200+
RMFILES = $(if $1,del /f $(subst /,\,$1))
201+
endif
202+
COMMA := ,
203+
SPACE := $(N/A) $(N/A)
204+
define NEWLINE
205+
206+
207+
endef
208+
# Note: Do not remove any of the two empty lines above !
209+
210+
TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS))
211+
212+
ifeq ($(words $(TARGETLIST)),1)
213+
214+
# Set PROGRAM to something like 'myprog.c64'.
215+
override PROGRAM := $(PROGRAM).$(TARGETLIST)
216+
217+
# Set SOURCES to something like 'src/foo.c src/bar.s'.
218+
# Use of assembler files with names ending differently than .s is deprecated!
219+
SOURCES := $(wildcard $(SRCDIR)/*.c)
220+
SOURCES += $(wildcard $(SRCDIR)/*.s)
221+
SOURCES += $(wildcard $(SRCDIR)/*.asm)
222+
SOURCES += $(wildcard $(SRCDIR)/*.a65)
223+
224+
# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'.
225+
# Use of assembler files with names ending differently than .s is deprecated!
226+
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.c)
227+
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.s)
228+
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.asm)
229+
SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.a65)
230+
231+
# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'.
232+
OBJECTS := $(addsuffix .o,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES)))))
233+
234+
# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'.
235+
DEPENDS := $(OBJECTS:.o=.d)
236+
237+
# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'.
238+
LIBS += $(wildcard $(SRCDIR)/*.lib)
239+
LIBS += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.lib)
240+
241+
# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'.
242+
CONFIG += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.cfg)
243+
CONFIG += $(wildcard $(SRCDIR)/*.cfg)
244+
245+
# Select CONFIG file to use. Target specific configs have higher priority.
246+
ifneq ($(word 2,$(CONFIG)),)
247+
CONFIG := $(firstword $(CONFIG))
248+
$(info Using config file $(CONFIG) for linking)
249+
endif
250+
251+
.SUFFIXES:
252+
.PHONY: all test clean zap love
253+
254+
all: $(PROGRAM)
255+
256+
-include $(DEPENDS)
257+
-include $(STATEFILE)
258+
259+
# If OPTIONS are given on the command line then save them to STATEFILE
260+
# if (and only if) they have actually changed. But if OPTIONS are not
261+
# given on the command line then load them from STATEFILE. Have object
262+
# files depend on STATEFILE only if it actually exists.
263+
ifeq ($(origin OPTIONS),command line)
264+
ifneq ($(OPTIONS),$(_OPTIONS_))
265+
ifeq ($(OPTIONS),)
266+
$(info Removing OPTIONS)
267+
$(shell $(RM) $(STATEFILE))
268+
$(eval $(STATEFILE):)
269+
else
270+
$(info Saving OPTIONS=$(OPTIONS))
271+
$(shell echo _OPTIONS_=$(OPTIONS) > $(STATEFILE))
272+
endif
273+
$(eval $(OBJECTS): $(STATEFILE))
274+
endif
275+
else
276+
ifeq ($(origin _OPTIONS_),file)
277+
$(info Using saved OPTIONS=$(_OPTIONS_))
278+
OPTIONS = $(_OPTIONS_)
279+
$(eval $(OBJECTS): $(STATEFILE))
280+
endif
281+
endif
282+
283+
# Transform the abstract OPTIONS to the actual cc65 options.
284+
$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_)))
285+
286+
# Strip potential variant suffix from the actual cc65 target.
287+
CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST)))
288+
289+
# The remaining targets.
290+
$(TARGETOBJDIR):
291+
$(call MKDIR,$@)
292+
293+
vpath %.c $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
294+
295+
$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR)
296+
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $<
297+
298+
vpath %.s $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
299+
300+
$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR)
301+
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
302+
303+
vpath %.asm $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
304+
305+
$(TARGETOBJDIR)/%.o: %.asm | $(TARGETOBJDIR)
306+
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
307+
308+
vpath %.a65 $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
309+
310+
$(TARGETOBJDIR)/%.o: %.a65 | $(TARGETOBJDIR)
311+
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
312+
313+
$(PROGRAM): $(CONFIG) $(OBJECTS) $(LIBS)
314+
cl65 -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^)
315+
316+
test: $(PROGRAM)
317+
$(PREEMUCMD)
318+
$(EMUCMD)
319+
$(POSTEMUCMD)
320+
321+
clean:
322+
$(call RMFILES,$(OBJECTS))
323+
$(call RMFILES,$(DEPENDS))
324+
$(call RMFILES,$(REMOVES))
325+
$(call RMFILES,$(PROGRAM))
326+
327+
else # $(words $(TARGETLIST)),1
328+
329+
all test clean:
330+
$(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE))
331+
332+
endif # $(words $(TARGETLIST)),1
333+
334+
OBJDIRLIST := $(wildcard $(OBJDIR)/*)
335+
336+
zap:
337+
$(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.o $o/*.d $o/*.lst)$(NEWLINE))
338+
$(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE))
339+
-$(call RMDIR,$(OBJDIR))
340+
-$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE))
341+
342+
love:
343+
@echo "Not war, eh?"
344+
345+
###################################################################
346+
### Place your additional targets in the additional Makefiles ###
347+
### in the same directory - their names have to end with ".mk"! ###
348+
###################################################################
349+
-include *.mk

Makefile-dsk.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
DSK = $(NAME).dsk
2+
3+
# For this one, see https://applecommander.github.io/
4+
AC ?= ac.jar
5+
6+
# Unix or Windows
7+
ifeq ($(shell echo),)
8+
CP = cp $1
9+
else
10+
CP = copy $(subst /,\,$1)
11+
endif
12+
13+
REMOVES += $(DSK)
14+
15+
.PHONY: dsk
16+
dsk: $(DSK)
17+
18+
$(DSK): $(NAME).apple2
19+
$(call CP, apple2/template.dsk $@)
20+
java -jar $(AC) -p $@ $(NAME).system sys < $(NAME).apple2.loader
21+
java -jar $(AC) -as $@ $(NAME) bin < $(NAME).apple2

0 commit comments

Comments
 (0)