]>
wirehaze git hosting - lifeboot.git/blob - lifeboot.asm
81185ddd29816e688d1c8ec713df5a4be2cd1fae
10 %
define DEAD
' ' ; char to represent a dead cell
11 %
define ALIVE
'#' ; char to represent an alive cell
12 %
define INIT_RATIO
4 ; dead / alive
13 %
define PRINT_COLOR
0x07 ; grey on black
15 %
define GRID
ORG + 512 ; current cell grid (80 * 25 bytes)
16 %
define NEXT_GRID GRID
+ COLS
* ROWS
; next cell grid (80 * 25 bytes)
17 %
define XSS NEXT_GRID
+ COLS
* ROWS
; xs() state
19 ; entry point -----------------------------------------------------------------
21 ; initialize segment registers
31 ; clear screen ----------------------------------------------------------------
43 mov ax, (PRINT_COLOR
<< 8) | DEAD
45 rep stosw ; fill cx words at es:di with ax
47 ; setup -----------------------------------------------------------------------
53 int 0x1a ; system time
54 mov [XSS
], dx ; cx:dx = number of clock ticks since midnight
56 ; functions -------------------------------------------------------------------
58 ; xs() - xorshift pseudorandom number generator -------------------------------
61 ; ax = updated state ([XSS])
68 shl dx, 1 ; dx = xss << 1
69 xor ax, dx ; ax = xss ^ (xss << 1)
72 shr dx, 3 ; dx = xss' >> 3
73 xor ax, dx ; ax = xss' ^ (xss' >> 3)
76 shl dx, 10 ; dx = xss'' << 10
77 xor ax, dx ; ax = xss'' ^ (xss'' << 10)
82 ; errors ----------------------------------------------------------------------
87 ; print the error message string in si and halt
88 ; note: we assume es = VGA_SEG and ds = 0
93 ; es:di = video memory
94 ; ds:si = error message
96 ; ah = color attribute
99 lodsb ; al = [ds:si], si += 1
100 or al, al ; on null terminator,
102 stosw ; [es:di] = ax, di += 2
106 cli ; disable interrupts
110 ; data ------------------------------------------------------------------------
116 times 510 - ($ - $$) db 0 ; fill remaining bytes with zeroes
117 dw 0xaa55 ; mbr magic byte