From 122654c1ef9d99af8210ce95dee4eb4d1bc04b67 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 15 May 2025 16:27:36 +0200 Subject: Define the notion of a level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is for now just a variable that will be set during initialization, and that it can be influenced through the `LEVEL` make variable. Both the level and the level "kind" notions are used tracking, at least, which kind of enemy wave we have to send. Signed-off-by: Miquel Sabaté Solà --- Makefile | 7 +++++++ include/globals.s | 8 ++++++++ src/jetpac.s | 13 +++++++++++++ 3 files changed, 28 insertions(+) diff --git a/Makefile b/Makefile index a00dc6b..91bd0dd 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,10 @@ endif RUBY ?= ruby HAS_RUBY := $(shell command -v $(RUBY) >/dev/null 2>&1 && echo true || echo false) +## +# Variables for building the game. +LEVEL ?= 0 + .PHONY: all all: clean deps build @@ -54,6 +58,7 @@ build: gen-values build-full build-partial build-pal build-full: $(Q) rm -f config/generated.s $(Q) echo "HZ = 60" >> config/generated.s + $(Q) echo "LEVEL = $(LEVEL)" >> config/generated.s $(E) " CC jetpac (NTSC)" $(Q) $(CC65) $(CCOPTS) src/jetpac.s -C config/nrom.cfg -o "out/Jetpac (NTSC).nes" @@ -63,6 +68,7 @@ build-partial: $(Q) rm -f config/generated.s $(Q) echo "PARTIAL = 1" >> config/generated.s $(Q) echo "HZ = 60" >> config/generated.s + $(Q) echo "LEVEL = $(LEVEL)" >> config/generated.s $(E) " CC jetpac (partial)" $(Q) $(CC65) $(CCOPTS) src/jetpac.s -C config/nrom.cfg -o "out/Jetpac (DEV).nes" @@ -72,6 +78,7 @@ build-pal: $(Q) rm -f config/generated.s $(Q) echo "PAL = 1" >> config/generated.s $(Q) echo "HZ = 50" >> config/generated.s + $(Q) echo "LEVEL = $(LEVEL)" >> config/generated.s $(E) " CC jetpac (PAL)" $(Q) $(CC65) $(CCOPTS) src/jetpac.s -C config/nrom.cfg -o "out/Jetpac (PAL).nes" diff --git a/include/globals.s b/include/globals.s index 395df61..531c812 100644 --- a/include/globals.s +++ b/include/globals.s @@ -34,4 +34,12 @@ ;; | 2 | title over | We are transitioning from title to game | ;; | 1-0 | game | 0: title; 1: game; 2: game over, 3: game over (coin) | zp_flags = $20 + + ;; Current level of the game. + zp_level = $24 + + ;; The level "kind". Note that `zp_level` can go on forever, but the level + ;; "kind" repeats every 8 waves. Hence, this is just a cached version of + ;; masking `zp_level`. + zp_level_kind = $25 .endscope diff --git a/src/jetpac.s b/src/jetpac.s index 0c75bf4..ada5d1f 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -58,6 +58,19 @@ sta Joypad::zp_buttons1 sta Joypad::zp_buttons2 + ;; Initialize the level. We allow the build system to pass its own value for + ;; this in `LEVEL`, just in case we want to debug the enemy of a specific + ;; level. + .ifdef LEVEL + lda #LEVEL + sta Globals::zp_level + and #%00000111 + sta Globals::zp_level_kind + .else + sta Globals::zp_level + sta Globals::zp_level_kind + .endif + ;; Initialize the assets for the game. jsr Assets::init -- cgit v1.2.3