Skip to content

Commit

Permalink
Bug Fix for Goal Scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
davemoore22 committed Jul 1, 2023
1 parent 5ce3bd0 commit bb7c22e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 19 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
game-over.png
hockey.bin
.vscode/settings.json
title-screen.png
in-game.png
hockey.dsk
hockey.cdt
*.png
rasmoutput.bin
4 changes: 4 additions & 0 deletions data.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ time_game_over:
sound_ball:
DEFB 1, 0, 0, 30, 0, 0
DEFB 7, 10, 0

sound_goal:
DEFB 2, 0, 0, 0, 0, 15
DEFB 5, 15, 0
53 changes: 40 additions & 13 deletions game.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1003,34 +1003,36 @@ check_for_goal:
.lt_2:
ld a, (game_state + BALL_Y); Check if inside goalposts on right
cp 6
ret p
cp 18
jp m, .p1_scored
cp 5
ret m
cp 17
jp m, .p2_scored
ret

.gt_39:
ld a, (game_state + BALL_Y); Check if inside goalposts on P1_LEFT
cp 6
ret p
cp 18
jp m, .p2_scored
cp 5
ret m
cp 17
jp m, .p1_scored
ret

.p1_scored:
ld a, (game_state + BALL_X)
ld a, (game_state + P1_SCORE)
inc a
ld (game_state + P1_SCORE), a
call play_goal_sound
call reset_pb
ld a, #FF
ret

.p2_scored:
ld a, (game_state + BALL_X)

ld a, (game_state + P2_SCORE)
inc a
ld (game_state + P2_SCORE), a
call play_goal_sound
call reset_pb
ld a, #FF
ret
Expand All @@ -1046,7 +1048,32 @@ check_for_goal:
;###############################################################################

play_ball_sound:
ld hl, sound_ball
call SOUND_QUEUE
ld hl, sound_ball
call SOUND_QUEUE
ret
;###############################################################################
;
; Play the Goal Sound
;
; Corrupts: AF, BC, DE, HL
;
; https://tinyurl.com/2uu9h7ea
;
;###############################################################################

play_goal_sound:
ld b, 15 ; Reset Noise Level
.loop:
ld hl, sound_goal + 5
ld (hl), b
push bc
ld hl, sound_goal
call SOUND_QUEUE
pop bc
call MC_WAIT_FLYBACK
djnz .loop
ld b, 0
ld hl, sound_goal
call SOUND_QUEUE
ret
Binary file added hockey.bin
Binary file not shown.
Binary file added hockey.cdt
Binary file not shown.
Binary file added hockey.dsk
Binary file not shown.

0 comments on commit bb7c22e

Please sign in to comment.