]> wirehaze git hosting - lifeboot.git/blobdiff - lifeboot.asm

wirehaze git hosting

remove delay and add iteration limit
[lifeboot.git] / lifeboot.asm
index e44a671b9c8e4644491e1422377419354509cad0..9b03696aa827eb2e63b7d2d3c609533fa85b1807 100644 (file)
@@ -6,15 +6,15 @@ org 7c00h
 ; settings --------------------------------------------------------------------
 
 %define DEAD ' '            ; char to represent a dead cell
-%define ALIVE '#'           ; char to represent an alive cell
+%define ALIVE '.'           ; char to represent an alive cell
 %define PRINT_COLOR 07h     ; grey on black
-%define WAIT_DELAY 02h      ; 0.131072 seconds
+%define ITER_LIM 500        ; reset the simulation after ITER_LIM iterations
 
 ; constants -------------------------------------------------------------------
 
 %define COLS 80
 %define ROWS 25
-%define VGAPGSZ (COLS * ROWS * 2 + 96)  ; why 96 ??????
+%define VGAPGSZ 1000h
 
 ; memory layout ---------------------------------------------------------------
 
@@ -26,6 +26,7 @@ org 7c00h
 
 %define xss DAT             ; xs() state (word)
 %define currvgapg DAT + 2   ; current vga page near pointer (word)
+%define iter DAT + 4        ; current iteration # (word)
 
 ; =============================================================================
 
@@ -71,6 +72,7 @@ mov word [currvgapg], 0
 start:
 
 call init_grid
+mov word [iter], 1
 
 ; apply game of life's rules to determine the next state ----------------------
 
@@ -78,40 +80,20 @@ next_state:
 
 call vsync_wait
 call write_next_vga_page
-call wait_keypress
+
+call vsync_wait
 call flip_vga_page
 
-jmp next_state
+inc word [iter]
+cmp word [iter], ITER_LIM
+jle next_state
+
+jmp start                   ; reset
 
 ; =============================================================================
 
 ; functions -------------------------------------------------------------------
 
-; delay() - suspend program execution temporarily -----------------------------
-
-; clobbers ah, cx, dx
-
-delay:
-
-mov cx, WAIT_DELAY          ; cx:dx = interval in microseconds
-mov dx, 0
-
-mov ah, 86h
-int 15h                     ; wait
-
-ret
-
-; wait_keypress() - wait for any keypress -------------------------------------
-
-; clobbers: ax
-
-wait_keypress:
-
-mov ah, 00h         ; read key press
-int 16h             ; keyboard services
-
-ret
-
 ; vsync_wait() - wait for display to enter the next VBlank cycle --------------
 
 ; clobbers ax, dx
@@ -190,8 +172,6 @@ ret
 
 flip_vga_page:
 
-call vsync_wait
-
 xor word [currvgapg], VGAPGSZ   ; flip currvgapg
 setnz al                        ; al = !(currvgapg == 0)