7 Commits

Author SHA1 Message Date
PoliEcho 82e55b3e1e Merge branch 'master' of https://git.pupes.org/PoliEcho/asm-game-of-life
build_test / build (push) Successful in 2m11s
2025-07-14 20:57:01 +02:00
PoliEcho 6d3279f850 add tty workaround 2025-07-14 20:55:41 +02:00
PoliEcho 1820d4fdf8 Update README.md
build_test / build (push) Successful in 1m58s
2025-07-13 22:18:00 +00:00
PoliEcho 81367baa99 Update README.md
build_test / build (push) Successful in 1m48s
2025-07-13 22:16:01 +00:00
PoliEcho 33b6a82a42 Update README.md
build_test / build (push) Successful in 2m2s
2025-07-13 22:12:02 +00:00
PoliEcho 755f9b9f06 Update README.md
build_test / build (push) Successful in 1m54s
2025-07-13 22:03:09 +00:00
PoliEcho c3563fcda1 Update README.md
build_test / build (push) Successful in 2m18s
2025-07-13 21:57:45 +00:00
2 changed files with 48 additions and 4 deletions
+18 -2
View File
@@ -11,9 +11,25 @@
> make
## Download
#### TODO: add releases link
[releases](https://git.pupes.org/PoliEcho/asm-game-of-life/releases)
## Build
```shell
make
```
```
## Controls
| key | action |
|--------|-------------------------|
| arrows | move cursor |
| ENTER | invert cell |
| j/k | change simulation speed |
| p | start/stop simulation |
| q | quit |
## Warning
delays in TTY may be broken
## Notes
if screen does not clear properly after loading just move the cursor around a bit
+30 -2
View File
@@ -12,6 +12,8 @@ section .bss
extern gameboard_ptr
extern simulation_running
extern running_in_tty
section .data
cursor_rows: dw 1
cursor_cols: dw 1
@@ -49,6 +51,7 @@ global handle_user_input
handle_user_input:; main loop of the program
push r12
push r13
push r14
lea r12, [multipurpuse_buf]
@@ -72,12 +75,26 @@ handle_user_input:; main loop of the program
movss xmm0, [speed_multiplier]
movss xmm1, [simulation_speed]
mulss xmm0, xmm1; callculate sleep lenght
cvttss2si rdx, xmm0; truncate and copy to rdx
cvttss2si rdx, xmm0; truncate and copy to rdx
mov r14, rdx
syscall
mov sil, [running_in_tty]
test sil, sil
jz .skip_tty_mul
push rax
mov rax, 2500; magic number
xor rdx,rdx
mul r14
mov r14, rax
pop rax
.skip_tty_mul:
test rax, rax; SYS_POLL returns 0 when no change happens within timeout
jz .no_input
.repeat_read:
xor rax, rax
mov qword [r12], rax; zeroout the buffer
@@ -88,8 +105,18 @@ handle_user_input:; main loop of the program
syscall; read user input
cmp rax, EAGAIN
je .no_input
jne .handle_input
mov al, [running_in_tty]
test al, al
jz .no_input
; this runs only if running in tty
test r14, r14
jz .no_input; timeout
dec r14
jmp .repeat_read
.handle_input:
mov rax, [r12]
cmp eax, 0x00415B1B; check if input is more than left arrow
@@ -237,6 +264,7 @@ handle_user_input:; main loop of the program
jmp .main_loop
.function_exit:
pop r14
pop r13
pop r12
ret