-
Notifications
You must be signed in to change notification settings - Fork 0
/
life.asm
89 lines (76 loc) · 1.31 KB
/
life.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
OUTPUT life.z80
ORG $8000
; Defines
ScreenWidth EQU 80
ScreenHeight EQU 25
ScreenSize EQU ScreenWidth*ScreenHeight
DeadChar EQU $20
AliveChar EQU $40
call printBoard
main:
call calcCells
call swapScreen
call printBoard
;call printBoardNeighbourCount
; loop
jp main
ret
printBoard:
call cls
ld de,boardTop
call printStr
call printNl
ld a,'|'
call printChr
ld de,0
ld b,0
printLoop:
ld hl,(currentGrid)
add hl,de
ld a,(hl)
cp 1
jp nz, printDeadCell
ld a,AliveChar
call printChr
jp printCharDone
printDeadCell:
ld a,DeadChar
call printChr
printCharDone:
inc de
inc b
ld hl,ScreenSize ; this is a constant
or a
sbc hl,de
add hl,de
jp z,printLoopDone
ld a,ScreenWidth
cp b
jp nz,printLoop
ld a,'|'
call printChr
call printNl
ld a,'|'
call printChr
ld b,0
jp printLoop
printLoopDone:
ld a,'|'
call printChr
call printNl
ld de,boardBottom
call printStr
ret
; This works, stop debugging it
swapScreen:
ld hl,(currentGrid)
ld de,(otherGrid)
ld (otherGrid),hl
ld (currentGrid),de
ret
include debugging.asm
include board2.asm
include utils.asm
include ansi.asm
include data.asm
end: