Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Galactic Armada Rewrite #74

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f43ce21
ci: run i18helpers and extract source po
avivace Nov 2, 2023
fba619f
ci: move po extraction step
avivace Nov 7, 2023
ec2d4c2
initial commit
LaroldsJubilantJunkyard Nov 25, 2023
84640e5
getting the new game state management working
LaroldsJubilantJunkyard Nov 25, 2023
c2ca18e
working on title screen section
LaroldsJubilantJunkyard Nov 26, 2023
e823060
adding drawing text page
LaroldsJubilantJunkyard Nov 28, 2023
a4fff6a
started on objects
LaroldsJubilantJunkyard Nov 29, 2023
cc1f212
exporting game state functions
LaroldsJubilantJunkyard Dec 2, 2023
7cd2f39
removing testing code
LaroldsJubilantJunkyard Dec 2, 2023
74c76b3
fixing cp a problems with and a.
LaroldsJubilantJunkyard Dec 3, 2023
064b9b4
moving object init
LaroldsJubilantJunkyard Dec 3, 2023
be66027
finally have player rendering with new object pool system
LaroldsJubilantJunkyard Dec 3, 2023
8c654c6
bullets working
LaroldsJubilantJunkyard Dec 3, 2023
8d45da5
enemies spawning again
LaroldsJubilantJunkyard Dec 3, 2023
f4d2548
got bullet/enemy collision working
LaroldsJubilantJunkyard Dec 5, 2023
80d0ea7
enemies spawning again
LaroldsJubilantJunkyard Dec 5, 2023
257b9d0
removing drawlives function
LaroldsJubilantJunkyard Dec 5, 2023
939120c
added damaging and flashing
LaroldsJubilantJunkyard Dec 5, 2023
2287d1f
removing non working code snippets
LaroldsJubilantJunkyard Dec 7, 2023
3d72f44
updating backgrounds
LaroldsJubilantJunkyard Dec 10, 2023
6621833
commit of modified files for rebase
LaroldsJubilantJunkyard Dec 10, 2023
de6ea93
ci: run i18helpers and extract source po
avivace Nov 2, 2023
1941d8d
ci: move po extraction step
avivace Nov 7, 2023
4fb7973
adding all modified files for rebase
LaroldsJubilantJunkyard Dec 10, 2023
405c5a6
ci: run i18helpers and extract source po
avivace Nov 2, 2023
5a216be
ci: move po extraction step
avivace Nov 7, 2023
31f613c
initial commit
LaroldsJubilantJunkyard Nov 25, 2023
883192f
getting the new game state management working
LaroldsJubilantJunkyard Nov 25, 2023
71cc80c
working on title screen section
LaroldsJubilantJunkyard Nov 26, 2023
6a86197
adding drawing text page
LaroldsJubilantJunkyard Nov 28, 2023
1e2bc3c
started on objects
LaroldsJubilantJunkyard Nov 29, 2023
160e260
exporting game state functions
LaroldsJubilantJunkyard Dec 2, 2023
a1b3c14
removing testing code
LaroldsJubilantJunkyard Dec 2, 2023
0ba55ec
fixing cp a problems with and a.
LaroldsJubilantJunkyard Dec 3, 2023
4a21420
moving object init
LaroldsJubilantJunkyard Dec 3, 2023
639c818
finally have player rendering with new object pool system
LaroldsJubilantJunkyard Dec 3, 2023
5f0bd3a
bullets working
LaroldsJubilantJunkyard Dec 3, 2023
c6350b7
enemies spawning again
LaroldsJubilantJunkyard Dec 3, 2023
f3add10
got bullet/enemy collision working
LaroldsJubilantJunkyard Dec 5, 2023
21f9a9e
enemies spawning again
LaroldsJubilantJunkyard Dec 5, 2023
f70bdac
removing drawlives function
LaroldsJubilantJunkyard Dec 5, 2023
6acc70e
added damaging and flashing
LaroldsJubilantJunkyard Dec 5, 2023
557a83f
removing non working code snippets
LaroldsJubilantJunkyard Dec 7, 2023
45bf34e
updating backgrounds
LaroldsJubilantJunkyard Dec 10, 2023
2d1df1a
commit of modified files for rebase
LaroldsJubilantJunkyard Dec 10, 2023
4d91d8c
removing broken snippet and obsolete text
LaroldsJubilantJunkyard Dec 11, 2023
00b8ed2
updating github action
LaroldsJubilantJunkyard Dec 11, 2023
cf5d877
Merge remote-tracking branch 'origin/feature/galactic-armada-rewrite'
LaroldsJubilantJunkyard Dec 11, 2023
8f759a1
fixing github action again
LaroldsJubilantJunkyard Dec 11, 2023
53758f0
game loop restored
LaroldsJubilantJunkyard Dec 15, 2023
fdc11d4
adding the star field background to gameplay
LaroldsJubilantJunkyard Dec 16, 2023
c1d93b8
started on collision detection between objects
LaroldsJubilantJunkyard Dec 16, 2023
d581660
object collision done
LaroldsJubilantJunkyard Dec 16, 2023
82de7ea
finishing the hud
LaroldsJubilantJunkyard Dec 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ jobs:
git branch -v
git add -A
git commit -am 'Update build'
git push -v
git push -v
240 changes: 120 additions & 120 deletions galactic-armada/Makefile
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
# You can set the name of the .gb ROM file here
PROJECTNAME = GalacticArmada
SRCDIR = src
LIBDIR = libs
OBJDIR = obj
DSTDIR = dist
RESDIR = $(SRCDIR)/resources
ASMDIR = $(SRCDIR)/main
RESSPRITES = $(RESDIR)/sprites
RESBACKGROUNDS = $(RESDIR)/backgrounds
GENDIR = $(SRCDIR)/generated
GENSPRITES = $(GENDIR)/sprites
GENBACKGROUNDS = $(GENDIR)/backgrounds
BINS = $(DSTDIR)/$(PROJECTNAME).gb

# Tools
RGBDS ?=
ASM := $(RGBDS)rgbasm
GFX := $(RGBDS)rgbgfx
LINK := $(RGBDS)rgblink
FIX := $(RGBDS)rgbfix

# Tool flags
ASMFLAGS := -L
FIXFLAGS := -v -p 0xFF

# https://stackoverflow.com/a/18258352
# Make does not offer a recursive wild card function, so here's one:
rwildcard = $(foreach d,\
$(wildcard $(1:=/*)), \
$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d) \
)

# https://stackoverflow.com/a/16151140
# This makes it so every entry in a space-delimited list appears only once
unique = $(if $1,\
$(firstword $1) $(call unique,$(filter-out $(firstword $1),$1)) \
)

# Collect ASM sources from ASMDIR and LIBDIR.
ASMSOURCES_COLLECTED = \
$(call rwildcard,$(ASMDIR),*.asm) $(call rwildcard,$(LIBDIR),*.asm)

OBJS = $(patsubst %.asm,$(OBJDIR)/%.o,$(notdir $(ASMSOURCES_COLLECTED)))

all: $(BINS)

# ANCHOR: generate-graphics
NEEDED_GRAPHICS = \
$(GENSPRITES)/player-ship.2bpp \
$(GENSPRITES)/enemy-ship.2bpp \
$(GENSPRITES)/bullet.2bpp \
$(GENBACKGROUNDS)/text-font.2bpp \
$(GENBACKGROUNDS)/star-field.tilemap \
$(GENBACKGROUNDS)/title-screen.tilemap

# Generate sprites, ensuring the containing directories have been created.
$(GENSPRITES)/%.2bpp: $(RESSPRITES)/%.png | $(GENSPRITES)
$(GFX) -c "#FFFFFF,#cfcfcf,#686868,#000000;" --columns -o $@ $<

# Generate background tile set, ensuring the containing directories have been created.
$(GENBACKGROUNDS)/%.2bpp: $(RESBACKGROUNDS)/%.png | $(GENBACKGROUNDS)
$(GFX) -c "#FFFFFF,#cbcbcb,#414141,#000000;" -o $@ $<

# Generate background tile map *and* tile set, ensuring the containing directories
# have been created.
$(GENBACKGROUNDS)/%.tilemap: $(RESBACKGROUNDS)/%.png | $(GENBACKGROUNDS)
$(GFX) -c "#FFFFFF,#cbcbcb,#414141,#000000;" \
--tilemap $@ \
--unique-tiles \
-o $(GENBACKGROUNDS)/$*.2bpp \
$<
# ANCHOR_END: generate-graphics

compile.bat: Makefile
@echo "REM Automatically generated from Makefile" > compile.bat
@make -sn | sed y/\\/\\\\/\\\\\\\^/ | grep -v make >> compile.bat


# ANCHOR: generate-objects
# Extract directories from collected ASM sources and append "%.asm" to each one,
# creating a wildcard-rule.
ASMSOURCES_DIRS = $(patsubst %,%%.asm,\
$(call unique,$(dir $(ASMSOURCES_COLLECTED))) \
)

# This is a Makefile "macro".
# It defines a %.o target from a corresponding %.asm, ensuring the
# "prepare" step has ran and the graphics are already generated.
define object-from-asm
$(OBJDIR)/%.o: $1 | $(OBJDIR) $(NEEDED_GRAPHICS)
$$(ASM) $$(ASMFLAGS) -o $$@ $$<
endef

# Run the macro for each directory listed in ASMSOURCES_DIRS, thereby
# creating the appropriate targets.
$(foreach i, $(ASMSOURCES_DIRS), $(eval $(call object-from-asm,$i)))
# ANCHOR_END: generate-objects

# Link and build the final ROM.
$(BINS): $(OBJS) | $(DSTDIR)
$(LINK) -o $@ $^
$(FIX) $(FIXFLAGS) $@
# Ensure directories for generated files exist.
define ensure-directory
$1:
mkdir -p $$@
endef

PREPARE_DIRECTORIES = \
$(OBJDIR) $(GENSPRITES) $(GENBACKGROUNDS) $(DSTDIR)

$(foreach i, $(PREPARE_DIRECTORIES), $(eval $(call ensure-directory,$i)))

# Clean up generated directories.
clean:
rm -rfv $(PREPARE_DIRECTORIES)
# Declare these targets as "not actually files".
.PHONY: clean all

# You can set the name of the .gb ROM file here
PROJECTNAME = GalacticArmada
SRCDIR = src
LIBDIR = libs
OBJDIR = obj
DSTDIR = dist
RESDIR = $(SRCDIR)/resources
ASMDIR = $(SRCDIR)/main
RESSPRITES = $(RESDIR)/sprites
RESBACKGROUNDS = $(RESDIR)/backgrounds
GENDIR = $(SRCDIR)/generated
GENSPRITES = $(GENDIR)/sprites
GENBACKGROUNDS = $(GENDIR)/backgrounds
BINS = $(DSTDIR)/$(PROJECTNAME).gb
# Tools
RGBDS ?=
ASM := $(RGBDS)rgbasm
GFX := $(RGBDS)rgbgfx
LINK := $(RGBDS)rgblink
FIX := $(RGBDS)rgbfix
# Tool flags
ASMFLAGS := -L
FIXFLAGS := -v -p 0xFF
# https://stackoverflow.com/a/18258352
# Make does not offer a recursive wild card function, so here's one:
rwildcard = $(foreach d,\
$(wildcard $(1:=/*)), \
$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d) \
)
# https://stackoverflow.com/a/16151140
# This makes it so every entry in a space-delimited list appears only once
unique = $(if $1,\
$(firstword $1) $(call unique,$(filter-out $(firstword $1),$1)) \
)
# Collect ASM sources from ASMDIR and LIBDIR.
ASMSOURCES_COLLECTED = \
$(call rwildcard,$(ASMDIR),*.asm) $(call rwildcard,$(LIBDIR),*.asm)
OBJS = $(patsubst %.asm,$(OBJDIR)/%.o,$(notdir $(ASMSOURCES_COLLECTED)))
all: $(BINS)
# ANCHOR: generate-graphics
NEEDED_GRAPHICS = \
$(GENSPRITES)/player-ship.2bpp \
$(GENSPRITES)/enemy-ship.2bpp \
$(GENSPRITES)/bullet.2bpp \
$(GENBACKGROUNDS)/text-font.2bpp \
$(GENBACKGROUNDS)/star-field.tilemap \
$(GENBACKGROUNDS)/title-screen.tilemap
# Generate sprites, ensuring the containing directories have been created.
$(GENSPRITES)/%.2bpp: $(RESSPRITES)/%.png | $(GENSPRITES)
$(GFX) -c "#FFFFFF,#cfcfcf,#686868,#000000;" --columns -o $@ $<
# Generate background tile set, ensuring the containing directories have been created.
$(GENBACKGROUNDS)/%.2bpp: $(RESBACKGROUNDS)/%.png | $(GENBACKGROUNDS)
$(GFX) -c "#FFFFFF,#cbcbcb,#414141,#000000;" -o $@ $<
# Generate background tile map *and* tile set, ensuring the containing directories
# have been created.
$(GENBACKGROUNDS)/%.tilemap: $(RESBACKGROUNDS)/%.png | $(GENBACKGROUNDS)
$(GFX) -c "#FFFFFF,#cbcbcb,#414141,#000000;" \
--tilemap $@ \
--unique-tiles \
-o $(GENBACKGROUNDS)/$*.2bpp \
$<
# ANCHOR_END: generate-graphics
compile.bat: Makefile
@echo "REM Automatically generated from Makefile" > compile.bat
@make -sn | sed y/\\/\\\\/\\\\\\\^/ | grep -v make >> compile.bat
# ANCHOR: generate-objects
# Extract directories from collected ASM sources and append "%.asm" to each one,
# creating a wildcard-rule.
ASMSOURCES_DIRS = $(patsubst %,%%.asm,\
$(call unique,$(dir $(ASMSOURCES_COLLECTED))) \
)
# This is a Makefile "macro".
# It defines a %.o target from a corresponding %.asm, ensuring the
# "prepare" step has ran and the graphics are already generated.
define object-from-asm
$(OBJDIR)/%.o: $1 | $(OBJDIR) $(NEEDED_GRAPHICS)
$$(ASM) $$(ASMFLAGS) -o $$@ $$<
endef
# Run the macro for each directory listed in ASMSOURCES_DIRS, thereby
# creating the appropriate targets.
$(foreach i, $(ASMSOURCES_DIRS), $(eval $(call object-from-asm,$i)))
# ANCHOR_END: generate-objects
# Link and build the final ROM.
$(BINS): $(OBJS) | $(DSTDIR)
$(LINK) -n dist/GalacticArmada.sym -m dist/GalacticArmada.map -o $@ $^
$(FIX) $(FIXFLAGS) $@
# Ensure directories for generated files exist.
define ensure-directory
$1:
mkdir -p $$@
endef
PREPARE_DIRECTORIES = \
$(OBJDIR) $(GENSPRITES) $(GENBACKGROUNDS) $(DSTDIR)
$(foreach i, $(PREPARE_DIRECTORIES), $(eval $(call ensure-directory,$i)))
# Clean up generated directories.
clean:
rm -rfv $(PREPARE_DIRECTORIES)
# Declare these targets as "not actually files".
.PHONY: clean all
93 changes: 49 additions & 44 deletions galactic-armada/libs/input.asm
Original file line number Diff line number Diff line change
@@ -1,45 +1,50 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; It's straight from: https://gbdev.io/gb-asm-tutorial/part2/input.html
; In their words (paraphrased): reading player input for gameboy is NOT a trivial task
; So it's best to use some tested code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

include "src/main/utils/hardware.inc"

SECTION "Input", ROM0

Input::
; Poll half the controller
ld a, P1F_GET_BTN
call .onenibble
ld b, a ; B7-4 = 1; B3-0 = unpressed buttons

; Poll the other half
ld a, P1F_GET_DPAD
call .onenibble
swap a ; A3-0 = unpressed directions; A7-4 = 1
xor a, b ; A = pressed buttons + directions
ld b, a ; B = pressed buttons + directions

; And release the controller
ld a, P1F_GET_NONE
ldh [rP1], a

; Combine with previous wCurKeys to make wNewKeys
ld a, [wCurKeys]
xor a, b ; A = keys that changed state
and a, b ; A = keys that changed to pressed
ld [wNewKeys], a
ld a, b
ld [wCurKeys], a
ret

.onenibble
ldh [rP1], a ; switch the key matrix
call .knownret ; burn 10 cycles calling a known ret
ldh a, [rP1] ; ignore value while waiting for the key matrix to settle
ldh a, [rP1]
ldh a, [rP1] ; this read counts
or a, $F0 ; A7-4 = 1; A3-0 = unpressed keys
.knownret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; It's straight from: https://gbdev.io/gb-asm-tutorial/part2/input.html
; In their words (paraphrased): reading player input for gameboy is NOT a trivial task
; So it's best to use some tested code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

include "src/main/includes/hardware.inc"

SECTION "Input", ROM0

Input::

; Save th previous state
ld a, [wCurKeys]
ld [wLastKeys], a

; Poll half the controller
ld a, P1F_GET_BTN
call .onenibble
ld b, a ; B7-4 = 1; B3-0 = unpressed buttons

; Poll the other half
ld a, P1F_GET_DPAD
call .onenibble
swap a ; A3-0 = unpressed directions; A7-4 = 1
xor a, b ; A = pressed buttons + directions
ld b, a ; B = pressed buttons + directions

; And release the controller
ld a, P1F_GET_NONE
ldh [rP1], a

; Combine with previous wCurKeys to make wNewKeys
ld a, [wCurKeys]
xor a, b ; A = keys that changed state
and a, b ; A = keys that changed to pressed
ld [wNewKeys], a
ld a, b
ld [wCurKeys], a
ret

.onenibble
ldh [rP1], a ; switch the key matrix
call .knownret ; burn 10 cycles calling a known ret
ldh a, [rP1] ; ignore value while waiting for the key matrix to settle
ldh a, [rP1]
ldh a, [rP1] ; this read counts
or a, $F0 ; A7-4 = 1; A3-0 = unpressed keys
.knownret
ret
Loading
Loading