diff --git a/src/keyboard.asm b/src/keyboard.asm index d5be30f..98fe876 100644 --- a/src/keyboard.asm +++ b/src/keyboard.asm @@ -11,7 +11,7 @@ readKeyboard: ; Read last key in buffer: .keepReadingBuffer: - int3 + mov ah, 00h int 16h mov bx, ax diff --git a/src/main.asm b/src/main.asm index 9534769..dca9bc8 100644 --- a/src/main.asm +++ b/src/main.asm @@ -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 @@ -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 @@ -53,6 +58,12 @@ section .text call Display_Clyde call UpdateScreen + ;pop cx + ;inc cx + ;cmp cx, 10 + ;je DebugExit + ;push cx + ;------------------------------------------------- @@ -60,6 +71,11 @@ section .text jmp gameloop ;----------------------------------------------------------------------------------------- +DebugExit: +;reset the keyboard buffer and then wait for a keypress : +mov ax, 0C01h ; +int 21h + exit: mov ax, 3h int 10h diff --git a/src/sprites.asm b/src/sprites.asm index c75e291..bf1330c 100644 --- a/src/sprites.asm +++ b/src/sprites.asm @@ -131,6 +131,8 @@ section .text ret ClearSprite: + push es + push ds mov cx, SCREEN_WIDTH mul cx add bx, ax @@ -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