From c5e404f1dd05c005de747e7fbb198ce1ceee9af8 Mon Sep 17 00:00:00 2001 From: PoliEcho Date: Wed, 9 Jul 2025 21:33:36 +0200 Subject: [PATCH] FINALY fix inicializing gameboard --- src/drawing.asm | 8 ++------ src/str.asm | 7 ++++--- src/symbols.asm | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/drawing.asm b/src/drawing.asm index 0247b3b..f5dfb06 100644 --- a/src/drawing.asm +++ b/src/drawing.asm @@ -43,7 +43,7 @@ init_gameboard: mov rsi, 0x20; set rsi to SPACE character mov rdx, [gameboard_size] push rdx - add rdx, ESC_chars_compensation_Len+2; I dont know how this work but it works so i wont touch it + add rdx, ESC_chars_compensation_Len; I dont know how this work but it works so i wont touch it call memory_set @@ -51,14 +51,10 @@ init_gameboard: pop rdi add rdi, rdx; get pointer to last char on screen push rdi - add rdi, 9; I dont know how this work but it works so i wont touch it - push rdi + add rdi, ESC_chars_compensation_Len lea rsi, [reset] call string_copy - pop rax - mov byte [rax+resetLen], 0; I dont know how this work but it works so i wont touch it - pop rdi xor rax, rax mov ax, [term_cols] diff --git a/src/str.asm b/src/str.asm index b1ee4de..6f83b2c 100644 --- a/src/str.asm +++ b/src/str.asm @@ -88,7 +88,7 @@ memory_set:; takes destination in rdi, byte in sil and lenght in rdx cmp rdx, 16 jnl .write_16_or_more_bytes - mov cl, dl + mov rcx, rdx jmp .write_less_than_16_bytes .write_16_or_more_bytes: mov rax, rdi; move destination to rax @@ -101,10 +101,11 @@ memory_set:; takes destination in rdi, byte in sil and lenght in rdx mov cl, 16 sub cl, al; now offset to first higher 16 byte alligned address is stored in r8 - - mov rax, r11 + movzx rcx, cl; remove ani posible garbage + .write_less_than_16_bytes: + mov rax, r11 sub rdx, rcx; we will write these bytes now rep stosb diff --git a/src/symbols.asm b/src/symbols.asm index 317c5f2..f184145 100644 --- a/src/symbols.asm +++ b/src/symbols.asm @@ -9,4 +9,4 @@ TIOCGWINSZ equ 0x5413 ASCII_ZERO equ 48 ESC_CHAR equ 27 -ESC_chars_compensation_Len equ 13; i have to compensate for escape sequences that dont get printed why 11 exactly, I dont know +ESC_chars_compensation_Len equ 9; i have to compensate for escape sequences that dont get printed why 11 exactly, I dont know