Skip to content

Commit

Permalink
Merge pull request #53 from algosup/fix-bugs-to-restore-the-backgroun…
Browse files Browse the repository at this point in the history
…d-buffer

Fix bugs to restore the background buffer
  • Loading branch information
leo-chartier authored Dec 8, 2023
2 parents 679805e + 88c2c1e commit caa516c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/keyboard.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readKeyboard:

; Read last key in buffer:
.keepReadingBuffer:
int3
mov ah, 00h
int 16h
mov bx, ax
Expand Down
26 changes: 21 additions & 5 deletions src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ section .text
call BuildBackgroundBuffer
call MazeToBGbuffer
call DisplayMaze
call UpdateScreen
call FirstDisplayPacMan
call FirstDisplayGhosts
call UpdateScreen

; Display the period
mov eax, PERIOD
Expand All @@ -27,17 +27,22 @@ section .text
rdtsc
mov [timestamp_of_next_frame], eax

;mov cx, 0
;push cx

;-----------------------------------------------------------------------------------------
;THE GAME LOOP
gameloop:
;-------------------------------------------------
;clear all
call waitLoop
call ClearPinky
call ClearPinky
call ClearBlinky
call ClearInky
call ClearClyde
call ClearPacMan
call ClearPacMan
;call DisplayMaze

call readKeyboard

Expand All @@ -53,13 +58,24 @@ section .text
call Display_Clyde

call UpdateScreen
;pop cx
;inc cx
;cmp cx, 10
;je DebugExit
;push cx


;-------------------------------------------------
; GOTO GAME LOOP
jmp gameloop
;-----------------------------------------------------------------------------------------

DebugExit:
;reset the keyboard buffer and then wait for a keypress :
mov ax, 0C01h ;
int 21h

exit:
mov ax, 3h
int 10h
Expand Down
9 changes: 6 additions & 3 deletions src/sprites.asm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ section .text
ret

ClearSprite:
push es
push ds
mov cx, SCREEN_WIDTH
mul cx
add bx, ax
Expand All @@ -148,12 +150,13 @@ section .text
.eachLine:
mov cx, SPRITE_SIZE ; set the counter for 8 pixel per line
rep movsb ; to mov the source from adress ds:si into the target from adress es:di byte per byte, 8 time (8 bits)
add di, SCREEN_WIDTH - SPRITE_SIZE ; increment the position register to the next line
add di, SCREEN_WIDTH - SPRITE_SIZE
add si, SCREEN_WIDTH - SPRITE_SIZE ; increment the position register to the next line
dec dx ; decrementatin de dx, when it reach 0, the flag is 0 too cause of the dec propreties
jnz .eachLine ; while the flag != 0, it continues

push cs
pop ds
pop ds
pop es
ret


Expand Down

0 comments on commit caa516c

Please sign in to comment.