From c37537d56c77c727a0feff6a60bac35cc5d2ca51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20de=20Keyn?= <146000855+benoitdekeyn-algosup@users.noreply.github.com> Date: Fri, 8 Dec 2023 01:43:29 +0100 Subject: [PATCH 1/4] fixed the restoring brutally now, it works, but instead of clearing the sprites one by one, I just redisplay the maze at each beginning of the gameloop --- src/keyboard.asm | 2 +- src/main.asm | 32 ++++++++++++++++++++++++-------- src/sprites.asm | 1 + 3 files changed, 26 insertions(+), 9 deletions(-) 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..2a011ca 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 ClearBlinky - call ClearInky - call ClearClyde - call ClearPacMan + + ;call ClearPinky + ;call ClearBlinky + ;call ClearInky + ;call ClearClyde + ;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..d9245d4 100644 --- a/src/sprites.asm +++ b/src/sprites.asm @@ -131,6 +131,7 @@ section .text ret ClearSprite: + mov cx, SCREEN_WIDTH mul cx add bx, ax From 77a36414deb03d4a2233f55b1c9861d792cf1a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20de=20Keyn?= <146000855+benoitdekeyn-algosup@users.noreply.github.com> Date: Fri, 8 Dec 2023 01:50:12 +0100 Subject: [PATCH 2/4] ok definetly fixed it well while restoring the bloc of 16x16 pixels from the background buffer to the screen buffer, to go to the next line, I increment 'di' (destination offset) by the screen width, but I forgot to increment 'si' (source offset) too. --- src/main.asm | 12 ++++++------ src/sprites.asm | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main.asm b/src/main.asm index 2a011ca..dca9bc8 100644 --- a/src/main.asm +++ b/src/main.asm @@ -37,12 +37,12 @@ section .text call waitLoop - ;call ClearPinky - ;call ClearBlinky - ;call ClearInky - ;call ClearClyde - ;call ClearPacMan - call DisplayMaze + call ClearPinky + call ClearBlinky + call ClearInky + call ClearClyde + call ClearPacMan + ;call DisplayMaze call readKeyboard diff --git a/src/sprites.asm b/src/sprites.asm index d9245d4..bf1330c 100644 --- a/src/sprites.asm +++ b/src/sprites.asm @@ -131,7 +131,8 @@ section .text ret ClearSprite: - + push es + push ds mov cx, SCREEN_WIDTH mul cx add bx, ax @@ -149,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 From ea97ac011817354bf95dcace59379de642e4ff48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20de=20Keyn?= <146000855+benoitdekeyn-algosup@users.noreply.github.com> Date: Fri, 8 Dec 2023 01:56:57 +0100 Subject: [PATCH 3/4] just verified that it works with the different velocities too --- src/Initialization.asm | 6 +++--- src/initialization.asm | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Initialization.asm b/src/Initialization.asm index afb8de0..bb4dd1f 100644 --- a/src/Initialization.asm +++ b/src/Initialization.asm @@ -174,14 +174,14 @@ section .text mov word [frameOf_Pinky_eyes], EYES_UP call Display_Pinky mov word [x_PinkyVelocity], 0 - mov word [y_PinkyVelocity], -1 + mov word [y_PinkyVelocity], -2 ;blinky mov word [x_BlinkyPosition], 160 mov word [y_BlinkyPosition], 84 mov word [frameOf_Blinky], BLINKY_1 mov word [frameOf_Blinky_eyes], EYES_RIGHT call Display_Blinky - mov word [x_BlinkyVelocity], 1 + mov word [x_BlinkyVelocity], 5 mov word [y_BlinkyVelocity], 0 ;inky mov word [x_InkyPosition], 144 @@ -190,7 +190,7 @@ section .text mov word [frameOf_Inky_eyes], EYES_DOWN call Display_Inky mov word [x_InkyVelocity], 0 - mov word [y_InkyVelocity], 1 + mov word [y_InkyVelocity], 3 ;clyde mov word [x_ClydePosition], 176 mov word [y_ClydePosition], 108 diff --git a/src/initialization.asm b/src/initialization.asm index afb8de0..bb4dd1f 100644 --- a/src/initialization.asm +++ b/src/initialization.asm @@ -174,14 +174,14 @@ section .text mov word [frameOf_Pinky_eyes], EYES_UP call Display_Pinky mov word [x_PinkyVelocity], 0 - mov word [y_PinkyVelocity], -1 + mov word [y_PinkyVelocity], -2 ;blinky mov word [x_BlinkyPosition], 160 mov word [y_BlinkyPosition], 84 mov word [frameOf_Blinky], BLINKY_1 mov word [frameOf_Blinky_eyes], EYES_RIGHT call Display_Blinky - mov word [x_BlinkyVelocity], 1 + mov word [x_BlinkyVelocity], 5 mov word [y_BlinkyVelocity], 0 ;inky mov word [x_InkyPosition], 144 @@ -190,7 +190,7 @@ section .text mov word [frameOf_Inky_eyes], EYES_DOWN call Display_Inky mov word [x_InkyVelocity], 0 - mov word [y_InkyVelocity], 1 + mov word [y_InkyVelocity], 3 ;clyde mov word [x_ClydePosition], 176 mov word [y_ClydePosition], 108 From 88c2c1e38cd044874f46822b4a09e833d3f70b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20de=20Keyn?= <146000855+benoitdekeyn-algosup@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:06:43 +0100 Subject: [PATCH 4/4] removed the velocity changes --- src/Initialization.asm | 6 +++--- src/initialization.asm | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Initialization.asm b/src/Initialization.asm index bb4dd1f..afb8de0 100644 --- a/src/Initialization.asm +++ b/src/Initialization.asm @@ -174,14 +174,14 @@ section .text mov word [frameOf_Pinky_eyes], EYES_UP call Display_Pinky mov word [x_PinkyVelocity], 0 - mov word [y_PinkyVelocity], -2 + mov word [y_PinkyVelocity], -1 ;blinky mov word [x_BlinkyPosition], 160 mov word [y_BlinkyPosition], 84 mov word [frameOf_Blinky], BLINKY_1 mov word [frameOf_Blinky_eyes], EYES_RIGHT call Display_Blinky - mov word [x_BlinkyVelocity], 5 + mov word [x_BlinkyVelocity], 1 mov word [y_BlinkyVelocity], 0 ;inky mov word [x_InkyPosition], 144 @@ -190,7 +190,7 @@ section .text mov word [frameOf_Inky_eyes], EYES_DOWN call Display_Inky mov word [x_InkyVelocity], 0 - mov word [y_InkyVelocity], 3 + mov word [y_InkyVelocity], 1 ;clyde mov word [x_ClydePosition], 176 mov word [y_ClydePosition], 108 diff --git a/src/initialization.asm b/src/initialization.asm index bb4dd1f..afb8de0 100644 --- a/src/initialization.asm +++ b/src/initialization.asm @@ -174,14 +174,14 @@ section .text mov word [frameOf_Pinky_eyes], EYES_UP call Display_Pinky mov word [x_PinkyVelocity], 0 - mov word [y_PinkyVelocity], -2 + mov word [y_PinkyVelocity], -1 ;blinky mov word [x_BlinkyPosition], 160 mov word [y_BlinkyPosition], 84 mov word [frameOf_Blinky], BLINKY_1 mov word [frameOf_Blinky_eyes], EYES_RIGHT call Display_Blinky - mov word [x_BlinkyVelocity], 5 + mov word [x_BlinkyVelocity], 1 mov word [y_BlinkyVelocity], 0 ;inky mov word [x_InkyPosition], 144 @@ -190,7 +190,7 @@ section .text mov word [frameOf_Inky_eyes], EYES_DOWN call Display_Inky mov word [x_InkyVelocity], 0 - mov word [y_InkyVelocity], 3 + mov word [y_InkyVelocity], 1 ;clyde mov word [x_ClydePosition], 176 mov word [y_ClydePosition], 108