Skip to content

Commit 2d4f34e

Browse files
authored
Updated part 3 code to run correctly. Spelling fixes (#180)
1 parent fd3e129 commit 2d4f34e

File tree

18 files changed

+81
-62
lines changed

18 files changed

+81
-62
lines changed

galactic-armada/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ $(foreach i, $(ASMSOURCES_DIRS), $(eval $(call object-from-asm,$i)))
9898

9999
# Link and build the final ROM.
100100
$(BINS): $(OBJS) | $(DSTDIR)
101-
$(LINK) -o $@ $^
101+
$(LINK) -n $(DSTDIR)/$(PROJECTNAME).sym -o $@ $^
102102
$(FIX) $(FIXFLAGS) $@
103103
# Ensure directories for generated files exist.
104104
define ensure-directory

galactic-armada/src/main/GalacticArmada.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ EntryPoint:
2929

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

3535
; Turn the LCD off

galactic-armada/src/main/states/gameplay/gameplay-state.asm

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SECTION "GameplayVariables", WRAM0
66

77
wScore:: ds 6
88
wLives:: db
9+
wUpdateHud:: db
910

1011
SECTION "GameplayState", ROM0
1112

@@ -26,15 +27,13 @@ InitGameplayState::
2627
ld [wScore+3], a
2728
ld [wScore+4], a
2829
ld [wScore+5], a
30+
ld [wUpdateHud], a
2931

3032
call InitializeBackground
3133
call InitializePlayer
3234
call InitializeBullets
3335
call InitializeEnemies
3436

35-
; Initiate STAT interrupts
36-
call InitStatInterrupts
37-
3837
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3938
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4039

@@ -60,6 +59,9 @@ InitGameplayState::
6059
ld a, 7
6160
ld [rWX], a
6261

62+
; Initiate STAT interrupts
63+
call InitStatInterrupts
64+
6365
; Turn the LCD on
6466
ld a, LCDCF_ON | LCDCF_BGON|LCDCF_OBJON | LCDCF_OBJ16 | LCDCF_WINON | LCDCF_WIN9C00|LCDCF_BG9800
6567
ld [rLCDC], a
@@ -120,6 +122,20 @@ UpdateGameplayState::
120122
call WaitForOneVBlank
121123
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122124
125+
; Check if we need to redraw the hud
126+
; Doing it here to make sure it's in a VBlank window
127+
ld a, [wUpdateHud]
128+
and a
129+
jp z, SkipHudRedraw
130+
131+
call DrawLives
132+
call DrawScore
133+
134+
xor a
135+
ld [wUpdateHud], a
136+
137+
SkipHudRedraw:
138+
123139
jp UpdateGameplayState
124140

125141
EndGameplay:

galactic-armada/src/main/states/gameplay/hud.asm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ SECTION "GameplayHUD", ROM0
66
; ANCHOR: hud-increase-score
77
IncreaseScore::
88

9+
ld a, 1
10+
ld [wUpdateHud], a; Tell gameplay-state to update hud
11+
912
; We have 6 digits, start with the right-most digit (the last byte)
1013
ld c, 0
1114
ld hl, wScore+5

galactic-armada/src/main/states/gameplay/objects/bullets.asm

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ InitializeBullets::
4040
xor a
4141
ld [wSpawnBullet], a
4242

43-
; Copy the bullet tile data intto vram
43+
; Copy the bullet tile data into vram
4444
ld de, bulletTileData
4545
ld hl, BULLET_TILES_START
4646
ld bc, bulletTileDataEnd - bulletTileData
@@ -52,10 +52,12 @@ InitializeBullets::
5252

5353
ld b, a
5454
ld hl, wBullets
55-
ld [hl], a
5655

5756
InitializeBullets_Loop:
5857

58+
; Set as inactive
59+
ld [hl], 0
60+
5961
; Increase the address
6062
ld a, l
6163
add PER_BULLET_BYTES_COUNT
@@ -64,7 +66,7 @@ InitializeBullets_Loop:
6466
adc 0
6567
ld h, a
6668

67-
; Increase how many bullets we have initailized
69+
; Increase how many bullets we have initialized
6870
ld a, b
6971
inc a
7072
ld b, a
@@ -78,7 +80,7 @@ InitializeBullets_Loop:
7880
; ANCHOR: bullets-update-start
7981
UpdateBullets::
8082

81-
; Make sure we have SOME active enemies
83+
; Make sure we have SOME active bullets
8284
ld a, [wSpawnBullet]
8385
ld b, a
8486
ld a, [wActiveBulletCounter]
@@ -113,7 +115,7 @@ UpdateBullets_Loop:
113115
cp MAX_BULLET_COUNT
114116
ret nc
115117

116-
; Increase the bullet data our address is pointingtwo
118+
; Increase the bullet data our address is pointing to
117119
ld a, l
118120
add PER_BULLET_BYTES_COUNT
119121
ld l, a
@@ -126,13 +128,13 @@ UpdateBullets_Loop:
126128
UpdateBullets_PerBullet:
127129

128130
; The first byte is if the bullet is active
129-
; If it's NOT zero, it's active, go to the normal update section
131+
; If it's NOT zero, it's active, go to the normal update section
130132
ld a, [hl]
131133
and a
132134
jp nz, UpdateBullets_PerBullet_Normal
133135

134136
; Do we need to spawn a bullet?
135-
; If we dont, loop to the next enemy
137+
; If we don't, loop to the next bullet
136138
ld a, [wSpawnBullet]
137139
and a
138140
jp z, UpdateBullets_Loop
@@ -150,7 +152,7 @@ UpdateBullets_PerBullet_SpawnDeactivatedBullet:
150152

151153
push hl
152154

153-
; Set the current bullet as active
155+
; Set the current bullet as active
154156
ld a, 1
155157
ld [hli], a
156158

@@ -161,7 +163,7 @@ UpdateBullets_PerBullet_SpawnDeactivatedBullet:
161163
ld d, a
162164
163165
; Descale the player's x position
164-
; the result will only be in the low byt
166+
; the result will only be in the low byte
165167
srl d
166168
rr b
167169
srl d
@@ -220,7 +222,7 @@ UpdateBullets_PerBullet_Normal:
220222

221223
; See if our non scaled low byte is above 160
222224
ld a, c
223-
cp 178
225+
cp 160
224226
; If it's below 160, deactivate
225227
jp nc, UpdateBullets_DeActivateIfOutOfBounds
226228
@@ -233,8 +235,8 @@ UpdateBullets_PerBullet_Normal:
233235
;; Drawing a metasprite
234236
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
235237

236-
; Save the address of the metasprite into the 'wMetaspriteAddress' variable
237-
; Our DrawMetasprites functoin uses that variable
238+
; Save the address of the metasprite into the 'wMetaspriteAddress' variable
239+
; Our DrawMetasprites function uses that variable
238240
ld a, LOW(bulletMetasprite)
239241
ld [wMetaspriteAddress], a
240242
ld a, HIGH(bulletMetasprite)
@@ -248,7 +250,7 @@ UpdateBullets_PerBullet_Normal:
248250
ld a, c
249251
ld [wMetaspriteY], a
250252

251-
; Actually call the 'DrawMetasprites function
253+
; Actually call the 'DrawMetasprites' function
252254
call DrawMetasprites
253255
254256
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -278,7 +280,7 @@ UpdateBullets_DeActivateIfOutOfBounds:
278280
; ANCHOR: fire-bullets
279281
FireNextBullet::
280282

281-
; Make sure we don't have the max amount of enmies
283+
; Make sure we don't have the max amount of bullets
282284
ld a, [wActiveBulletCounter]
283285
cp MAX_BULLET_COUNT
284286
ret nc

galactic-armada/src/main/states/gameplay/objects/collision/enemy-bullet-collision.asm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ CheckCurrentEnemyAgainstBullets_PerBullet_Y_Overlap:
139139
srl c
140140
rr b
141141

142-
; preserve our first byte addresss
142+
; preserve our first byte address
143143
pop hl
144144
push hl
145145

@@ -178,7 +178,7 @@ CheckCurrentEnemyAgainstBullets_PerBullet_Y_Overlap:
178178
; ANCHOR: enemy-bullet-collision-per-bullet-collision
179179
CheckCurrentEnemyAgainstBullets_PerBullet_Collision:
180180

181-
; set the active byte and x value to 0 for bullets
181+
; set the active byte and x value to 0 for bullets
182182
xor a
183183
ld [hli], a
184184
ld [hl], a
@@ -188,13 +188,12 @@ CheckCurrentEnemyAgainstBullets_PerBullet_Collision:
188188
ld a, [wUpdateEnemiesCurrentEnemyAddress+1]
189189
ld h, a
190190

191-
; set the active byte and x value to 0 for enemies
191+
; set the active byte and x value to 0 for enemies
192192
xor a
193193
ld [hli], a
194194
ld [hl], a
195195
196196
call IncreaseScore
197-
call DrawScore
198197

199198
; Decrease how many active enemies their are
200199
ld a, [wActiveEnemyCounter]

galactic-armada/src/main/states/gameplay/objects/enemies.asm

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ UpdateEnemies::
102102
; ANCHOR: enemies-update-loop
103103
UpdateEnemies_Loop:
104104

105-
; Check our coutner, if it's zero
105+
; Check our counter, if it's zero
106106
; Stop the function
107107
ld a, [wUpdateEnemiesCounter]
108108
inc a
@@ -112,7 +112,7 @@ UpdateEnemies_Loop:
112112
cp MAX_ENEMY_COUNT
113113
ret nc
114114

115-
; Increase the enemy data our address is pointingtwo
115+
; Increase the enemy data our address is pointing to
116116
ld a, l
117117
add PER_ENEMY_BYTES_COUNT
118118
ld l, a
@@ -170,7 +170,7 @@ UpdateEnemies_SpawnNewEnemy:
170170
; ANCHOR: enemies-update-per-enemy2
171171
UpdateEnemies_PerEnemy_Update:
172172

173-
; Save our first bytye
173+
; Save our first byte
174174
push hl
175175

176176
; Get our move speed in e
@@ -204,7 +204,7 @@ UpdateEnemies_PerEnemy_Update:
204204

205205
pop hl
206206

207-
; Descale the y psoition
207+
; Descale the y position
208208
srl d
209209
rr c
210210
srl d
@@ -238,7 +238,6 @@ UpdateEnemies_PerEnemy_CheckPlayerCollision:
238238
push hl
239239

240240
call DamagePlayer
241-
call DrawLives
242241

243242
pop hl
244243
@@ -276,11 +275,11 @@ UpdateEnemies_NoCollisionWithPlayer::
276275
; ANCHOR: draw-enemy-metasprites
277276

278277
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
279-
; call the 'DrawMetasprites function. setup variables and call
278+
; call the 'DrawMetasprites' function. setup variables and call
280279
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
281280

282281
; Save the address of the metasprite into the 'wMetaspriteAddress' variable
283-
; Our DrawMetasprites functoin uses that variable
282+
; Our DrawMetasprites function uses that variable
284283
ld a, LOW(enemyShipMetasprite)
285284
ld [wMetaspriteAddress+0], a
286285
ld a, HIGH(enemyShipMetasprite)
@@ -294,7 +293,7 @@ UpdateEnemies_NoCollisionWithPlayer::
294293
ld a, [wCurrentEnemyY]
295294
ld [wMetaspriteY], a
296295

297-
; Actually call the 'DrawMetasprites function
296+
; Actually call the 'DrawMetasprites' function
298297
call DrawMetasprites
299298

300299
; ANCHOR_END: draw-enemy-metasprites
@@ -313,12 +312,12 @@ UpdateEnemies_NoCollisionWithPlayer::
313312
; ANCHOR: enemies-spawn
314313
TryToSpawnEnemies::
315314

316-
; Increase our spwncounter
315+
; Increase our spawn counter
317316
ld a, [wSpawnCounter]
318317
inc a
319318
ld [wSpawnCounter], a
320319

321-
; Check our spawn acounter
320+
; Check our spawn a counter
322321
; Stop if it's below a given value
323322
ld a, [wSpawnCounter]
324323
cp ENEMY_SPAWN_DELAY_MAX
@@ -330,7 +329,7 @@ TryToSpawnEnemies::
330329
cp 0
331330
ret nz
332331

333-
; Make sure we don't have the max amount of enmies
332+
; Make sure we don't have the max amount of enemies
334333
ld a, [wActiveEnemyCounter]
335334
cp MAX_ENEMY_COUNT
336335
ret nc

galactic-armada/src/main/states/gameplay/objects/player.asm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ UpdatePlayer_UpdateSprite:
170170
rr c
171171
172172
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
173-
; Drawing the palyer metasprite
173+
; Drawing the player metasprite
174174
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
175175

176176

177177
; Save the address of the metasprite into the 'wMetaspriteAddress' variable
178-
; Our DrawMetasprites functoin uses that variable
178+
; Our DrawMetasprites function uses that variable
179179
ld a, LOW(playerTestMetaSprite)
180180
ld [wMetaspriteAddress+0], a
181181
ld a, HIGH(playerTestMetaSprite)
@@ -190,7 +190,7 @@ UpdatePlayer_UpdateSprite:
190190
ld a, c
191191
ld [wMetaspriteY], a
192192

193-
; Actually call the 'DrawMetasprites function
193+
; Actually call the 'DrawMetasprites' function
194194
call DrawMetasprites;
195195

196196
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -212,7 +212,8 @@ TryShoot:
212212
; ANCHOR: player-damage
213213
DamagePlayer::
214214

215-
215+
ld a, 1
216+
ld [wUpdateHud], a; Tell gameplay-state to update hud
216217

217218
xor a
218219
ld [mPlayerFlash], a

galactic-armada/src/main/states/story/story-state.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ InitStoryState::
1515

1616
; ANCHOR: story-screen-data
1717
Story:
18-
.Line1 db "the galatic empire", 255
18+
.Line1 db "the galactic empire", 255
1919
.Line2 db "rules the galaxy", 255
2020
.Line3 db "with an iron", 255
2121
.Line4 db "fist.", 255
@@ -55,7 +55,7 @@ UpdateStoryState::
5555
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5656

5757
; Save the passed value into the variable: mWaitKey
58-
; The WaitForKeyFunction always checks against this vriable
58+
; The WaitForKeyFunction always checks against this variable
5959
ld a, PADF_A
6060
ld [mWaitKey], a
6161

@@ -92,7 +92,7 @@ UpdateStoryState::
9292
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9393

9494
; Save the passed value into the variable: mWaitKey
95-
; The WaitForKeyFunction always checks against this vriable
95+
; The WaitForKeyFunction always checks against this variable
9696
ld a, PADF_A
9797
ld [mWaitKey], a
9898

galactic-armada/src/main/states/title-screen/title-screen-state.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ UpdateTitleScreenState::
6262
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6363

6464
; Save the passed value into the variable: mWaitKey
65-
; The WaitForKeyFunction always checks against this vriable
65+
; The WaitForKeyFunction always checks against this variable
6666
ld a, PADF_A
6767
ld [mWaitKey], a
6868

0 commit comments

Comments
 (0)