Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 galactic-armada/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ $(foreach i, $(ASMSOURCES_DIRS), $(eval $(call object-from-asm,$i)))

# Link and build the final ROM.
$(BINS): $(OBJS) | $(DSTDIR)
$(LINK) -o $@ $^
$(LINK) -n $(DSTDIR)/$(PROJECTNAME).sym -o $@ $^
$(FIX) $(FIXFLAGS) $@
# Ensure directories for generated files exist.
define ensure-directory
Expand Down
2 changes: 1 addition & 1 deletion galactic-armada/src/main/GalacticArmada.asm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ EntryPoint:

; from: https://github.com/eievui5/gb-sprobj-lib
; The library is relatively simple to get set up. First, put the following in your initialization code:
; Initilize Sprite Object Library.
; Initialize Sprite Object Library.
call InitSprObjLibWrapper

; Turn the LCD off
Expand Down
22 changes: 19 additions & 3 deletions galactic-armada/src/main/states/gameplay/gameplay-state.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SECTION "GameplayVariables", WRAM0

wScore:: ds 6
wLives:: db
wUpdateHud:: db

SECTION "GameplayState", ROM0

Expand All @@ -26,15 +27,13 @@ InitGameplayState::
ld [wScore+3], a
ld [wScore+4], a
ld [wScore+5], a
ld [wUpdateHud], a

call InitializeBackground
call InitializePlayer
call InitializeBullets
call InitializeEnemies

; Initiate STAT interrupts
call InitStatInterrupts

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand All @@ -60,6 +59,9 @@ InitGameplayState::
ld a, 7
ld [rWX], a

; Initiate STAT interrupts
call InitStatInterrupts

; Turn the LCD on
ld a, LCDCF_ON | LCDCF_BGON|LCDCF_OBJON | LCDCF_OBJ16 | LCDCF_WINON | LCDCF_WIN9C00|LCDCF_BG9800
ld [rLCDC], a
Expand Down Expand Up @@ -120,6 +122,20 @@ UpdateGameplayState::
call WaitForOneVBlank
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Check if we need to redraw the hud
; Doing it here to make sure it's in a VBlank window
ld a, [wUpdateHud]
and a
jp z, SkipHudRedraw

call DrawLives
call DrawScore

xor a
ld [wUpdateHud], a

SkipHudRedraw:

jp UpdateGameplayState

EndGameplay:
Expand Down
3 changes: 3 additions & 0 deletions galactic-armada/src/main/states/gameplay/hud.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SECTION "GameplayHUD", ROM0
; ANCHOR: hud-increase-score
IncreaseScore::

ld a, 1
ld [wUpdateHud], a; Tell gameplay-state to update hud

; We have 6 digits, start with the right-most digit (the last byte)
ld c, 0
ld hl, wScore+5
Expand Down
30 changes: 16 additions & 14 deletions galactic-armada/src/main/states/gameplay/objects/bullets.asm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ InitializeBullets::
xor a
ld [wSpawnBullet], a

; Copy the bullet tile data intto vram
; Copy the bullet tile data into vram
ld de, bulletTileData
ld hl, BULLET_TILES_START
ld bc, bulletTileDataEnd - bulletTileData
Expand All @@ -52,10 +52,12 @@ InitializeBullets::

ld b, a
ld hl, wBullets
ld [hl], a

InitializeBullets_Loop:

; Set as inactive
ld [hl], 0

; Increase the address
ld a, l
add PER_BULLET_BYTES_COUNT
Expand All @@ -64,7 +66,7 @@ InitializeBullets_Loop:
adc 0
ld h, a

; Increase how many bullets we have initailized
; Increase how many bullets we have initialized
ld a, b
inc a
ld b, a
Expand All @@ -78,7 +80,7 @@ InitializeBullets_Loop:
; ANCHOR: bullets-update-start
UpdateBullets::

; Make sure we have SOME active enemies
; Make sure we have SOME active bullets
ld a, [wSpawnBullet]
ld b, a
ld a, [wActiveBulletCounter]
Expand Down Expand Up @@ -113,7 +115,7 @@ UpdateBullets_Loop:
cp MAX_BULLET_COUNT
ret nc

; Increase the bullet data our address is pointingtwo
; Increase the bullet data our address is pointing to
ld a, l
add PER_BULLET_BYTES_COUNT
ld l, a
Expand All @@ -126,13 +128,13 @@ UpdateBullets_Loop:
UpdateBullets_PerBullet:

; The first byte is if the bullet is active
; If it's NOT zero, it's active, go to the normal update section
; If it's NOT zero, it's active, go to the normal update section
ld a, [hl]
and a
jp nz, UpdateBullets_PerBullet_Normal

; Do we need to spawn a bullet?
; If we dont, loop to the next enemy
; If we don't, loop to the next bullet
ld a, [wSpawnBullet]
and a
jp z, UpdateBullets_Loop
Expand All @@ -150,7 +152,7 @@ UpdateBullets_PerBullet_SpawnDeactivatedBullet:

push hl

; Set the current bullet as active
; Set the current bullet as active
ld a, 1
ld [hli], a

Expand All @@ -161,7 +163,7 @@ UpdateBullets_PerBullet_SpawnDeactivatedBullet:
ld d, a

; Descale the player's x position
; the result will only be in the low byt
; the result will only be in the low byte
srl d
rr b
srl d
Expand Down Expand Up @@ -220,7 +222,7 @@ UpdateBullets_PerBullet_Normal:

; See if our non scaled low byte is above 160
ld a, c
cp 178
cp 160
; If it's below 160, deactivate
jp nc, UpdateBullets_DeActivateIfOutOfBounds

Expand All @@ -233,8 +235,8 @@ UpdateBullets_PerBullet_Normal:
;; Drawing a metasprite
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Save the address of the metasprite into the 'wMetaspriteAddress' variable
; Our DrawMetasprites functoin uses that variable
; Save the address of the metasprite into the 'wMetaspriteAddress' variable
; Our DrawMetasprites function uses that variable
ld a, LOW(bulletMetasprite)
ld [wMetaspriteAddress], a
ld a, HIGH(bulletMetasprite)
Expand All @@ -248,7 +250,7 @@ UpdateBullets_PerBullet_Normal:
ld a, c
ld [wMetaspriteY], a

; Actually call the 'DrawMetasprites function
; Actually call the 'DrawMetasprites' function
call DrawMetasprites

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -278,7 +280,7 @@ UpdateBullets_DeActivateIfOutOfBounds:
; ANCHOR: fire-bullets
FireNextBullet::

; Make sure we don't have the max amount of enmies
; Make sure we don't have the max amount of bullets
ld a, [wActiveBulletCounter]
cp MAX_BULLET_COUNT
ret nc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ CheckCurrentEnemyAgainstBullets_PerBullet_Y_Overlap:
srl c
rr b

; preserve our first byte addresss
; preserve our first byte address
pop hl
push hl

Expand Down Expand Up @@ -178,7 +178,7 @@ CheckCurrentEnemyAgainstBullets_PerBullet_Y_Overlap:
; ANCHOR: enemy-bullet-collision-per-bullet-collision
CheckCurrentEnemyAgainstBullets_PerBullet_Collision:

; set the active byte and x value to 0 for bullets
; set the active byte and x value to 0 for bullets
xor a
ld [hli], a
ld [hl], a
Expand All @@ -188,13 +188,12 @@ CheckCurrentEnemyAgainstBullets_PerBullet_Collision:
ld a, [wUpdateEnemiesCurrentEnemyAddress+1]
ld h, a

; set the active byte and x value to 0 for enemies
; set the active byte and x value to 0 for enemies
xor a
ld [hli], a
ld [hl], a

call IncreaseScore
call DrawScore

; Decrease how many active enemies their are
ld a, [wActiveEnemyCounter]
Expand Down
21 changes: 10 additions & 11 deletions galactic-armada/src/main/states/gameplay/objects/enemies.asm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ UpdateEnemies::
; ANCHOR: enemies-update-loop
UpdateEnemies_Loop:

; Check our coutner, if it's zero
; Check our counter, if it's zero
; Stop the function
ld a, [wUpdateEnemiesCounter]
inc a
Expand All @@ -112,7 +112,7 @@ UpdateEnemies_Loop:
cp MAX_ENEMY_COUNT
ret nc

; Increase the enemy data our address is pointingtwo
; Increase the enemy data our address is pointing to
ld a, l
add PER_ENEMY_BYTES_COUNT
ld l, a
Expand Down Expand Up @@ -170,7 +170,7 @@ UpdateEnemies_SpawnNewEnemy:
; ANCHOR: enemies-update-per-enemy2
UpdateEnemies_PerEnemy_Update:

; Save our first bytye
; Save our first byte
push hl

; Get our move speed in e
Expand Down Expand Up @@ -204,7 +204,7 @@ UpdateEnemies_PerEnemy_Update:

pop hl

; Descale the y psoition
; Descale the y position
srl d
rr c
srl d
Expand Down Expand Up @@ -238,7 +238,6 @@ UpdateEnemies_PerEnemy_CheckPlayerCollision:
push hl

call DamagePlayer
call DrawLives

pop hl

Expand Down Expand Up @@ -276,11 +275,11 @@ UpdateEnemies_NoCollisionWithPlayer::
; ANCHOR: draw-enemy-metasprites

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; call the 'DrawMetasprites function. setup variables and call
; call the 'DrawMetasprites' function. setup variables and call
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Save the address of the metasprite into the 'wMetaspriteAddress' variable
; Our DrawMetasprites functoin uses that variable
; Our DrawMetasprites function uses that variable
ld a, LOW(enemyShipMetasprite)
ld [wMetaspriteAddress+0], a
ld a, HIGH(enemyShipMetasprite)
Expand All @@ -294,7 +293,7 @@ UpdateEnemies_NoCollisionWithPlayer::
ld a, [wCurrentEnemyY]
ld [wMetaspriteY], a

; Actually call the 'DrawMetasprites function
; Actually call the 'DrawMetasprites' function
call DrawMetasprites

; ANCHOR_END: draw-enemy-metasprites
Expand All @@ -313,12 +312,12 @@ UpdateEnemies_NoCollisionWithPlayer::
; ANCHOR: enemies-spawn
TryToSpawnEnemies::

; Increase our spwncounter
; Increase our spawn counter
ld a, [wSpawnCounter]
inc a
ld [wSpawnCounter], a

; Check our spawn acounter
; Check our spawn a counter
; Stop if it's below a given value
ld a, [wSpawnCounter]
cp ENEMY_SPAWN_DELAY_MAX
Expand All @@ -330,7 +329,7 @@ TryToSpawnEnemies::
cp 0
ret nz

; Make sure we don't have the max amount of enmies
; Make sure we don't have the max amount of enemies
ld a, [wActiveEnemyCounter]
cp MAX_ENEMY_COUNT
ret nc
Expand Down
9 changes: 5 additions & 4 deletions galactic-armada/src/main/states/gameplay/objects/player.asm
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ UpdatePlayer_UpdateSprite:
rr c

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Drawing the palyer metasprite
; Drawing the player metasprite
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; Save the address of the metasprite into the 'wMetaspriteAddress' variable
; Our DrawMetasprites functoin uses that variable
; Our DrawMetasprites function uses that variable
ld a, LOW(playerTestMetaSprite)
ld [wMetaspriteAddress+0], a
ld a, HIGH(playerTestMetaSprite)
Expand All @@ -190,7 +190,7 @@ UpdatePlayer_UpdateSprite:
ld a, c
ld [wMetaspriteY], a

; Actually call the 'DrawMetasprites function
; Actually call the 'DrawMetasprites' function
call DrawMetasprites;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -212,7 +212,8 @@ TryShoot:
; ANCHOR: player-damage
DamagePlayer::


ld a, 1
ld [wUpdateHud], a; Tell gameplay-state to update hud

xor a
ld [mPlayerFlash], a
Expand Down
6 changes: 3 additions & 3 deletions galactic-armada/src/main/states/story/story-state.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ InitStoryState::

; ANCHOR: story-screen-data
Story:
.Line1 db "the galatic empire", 255
.Line1 db "the galactic empire", 255
.Line2 db "rules the galaxy", 255
.Line3 db "with an iron", 255
.Line4 db "fist.", 255
Expand Down Expand Up @@ -55,7 +55,7 @@ UpdateStoryState::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Save the passed value into the variable: mWaitKey
; The WaitForKeyFunction always checks against this vriable
; The WaitForKeyFunction always checks against this variable
ld a, PADF_A
ld [mWaitKey], a

Expand Down Expand Up @@ -92,7 +92,7 @@ UpdateStoryState::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Save the passed value into the variable: mWaitKey
; The WaitForKeyFunction always checks against this vriable
; The WaitForKeyFunction always checks against this variable
ld a, PADF_A
ld [mWaitKey], a

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ UpdateTitleScreenState::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Save the passed value into the variable: mWaitKey
; The WaitForKeyFunction always checks against this vriable
; The WaitForKeyFunction always checks against this variable
ld a, PADF_A
ld [mWaitKey], a

Expand Down
Loading