Skip to content

Commit

Permalink
Small fix to VBL handler in room game
Browse files Browse the repository at this point in the history
There's a flag that prevents most of the code in the VBL handler from
being executed twice at the same time. This patch makes the flag be
set right after testing if it is set or not. This isn't a real
problem right now because there's more than enough time to set the
flag after the test, but this way the code is easier to understand.
  • Loading branch information
AntonioND committed Jan 3, 2017
1 parent eafe997 commit 404353f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/room_game/room_game.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1053,20 +1053,21 @@ RoomGameVBLHandler:
ld a,b
ld [game_sprites_8x16],a


; Make sure that the following code isn't executed twice even if it doesn't
; finish in one frame.
ld a,[vbl_handler_working]
and a,a
ret nz ; already working

ld a,1
ld [vbl_handler_working],a ; flag as working

ld a,[rSVBK]
ld b,a
ld a,[rVBK]
ld c,a
push bc

ld a,1
ld [vbl_handler_working],a ; flag as working

; Allow another VBL (or STAT) interrupt to happen and update graphics. Since
; vbl_handler_working is set to 1, they will only update graphics and return
; before handling user input.
Expand Down

0 comments on commit 404353f

Please sign in to comment.