-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.asm
141 lines (120 loc) · 2.64 KB
/
main.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
device ZXSPECTRUM128
SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION
org #4000
incbin "screen.scr"
org #7000
start:
di
ld sp, stack_top
call Memory.init
call Midi.init
call im2On
ei
xor a : out (#fe), a
ld b,#ff
1 halt
djnz 1b
call Attr.init
ld a, 7 : call Memory.setPage
ei
call Effects.eff2
menu:
call Attr.drawRectangle
ld hl, txt_0, de, #030C : call Attr.printAttr
ld hl, txt_1, de, #0E02 : call Attr.printAttr
ld b, 150
1 halt
push bc
ld bc, #f7fe : in a, (c)
pop bc
ld e,a
and 1 : jr z, .start
ld a, e
and 2 : jr z, .start
ld a,e
and 4 : jr z, .kj_start
djnz 1b
call Attr.drawRectangle
ld hl, txt_2, de, #030C : call Attr.printAttr
ld hl, txt_3, de, #0E02 : call Attr.printAttr
ld b, 150
1 halt
push bc
ld bc, #f7fe : in a, (c)
pop bc
ld e,a
and 1 : jr z, .start
ld a, e
and 2 : jr z, .start
ld a,e
and 4 : jr z, .kj_start
djnz 1b
call Attr.drawRectangle
ld hl, txt_4, de, #030C : call Attr.printAttr
ld hl, txt_5, de, #0E02 : call Attr.printAttr
ld b, 150
1 halt
push bc
ld bc, #f7fe : in a, (c)
pop bc
ld e,a
and 1 : jr z, .start
ld a, e
and 2 : jr z, .start
ld a,e
and 4 : jr z, .kj_start
djnz 1b
jp menu
.kj_start
ld a, 1 : ld (kj), a
.start
call Effects.eff2
call restoreLevel
call Text.drawUI
call Text.updateUI
call Snake.reborn.fill
ei
.loop
dup 10
halt
edup
call Snake.hideTail
call Snake.moveSnake
call Snake.checkBounds
call Snake.drawSnake
jr .loop
include "modules/memory.asm"
include "modules/im2.asm"
include "modules/attr.asm"
include "modules/qaop.asm"
include "modules/kjoy.asm"
include "modules/text.asm"
include "modules/effects.asm"
include "snake.asm"
include "levels.asm"
txt_0 db "1", 0
txt_1 db "QAOP", 0
txt_2 db "2", 0
txt_3 db "OPQA", 0
txt_4 db "3", 0
txt_5 db "KJOY", 0
buff:
display "Code ends: ", $
display "Code section left bytes: ", #bd00 - $
assert $ < $bd00
stack_top equ $bdbb
;; There're only two pages on ZX Spectrum 128 that fast on every model
;; It's page 2 and page 0
;; So we'll use page 0 for playing our midi music
page 0
org #c000
include "modules/ay-midi.asm"
include "modules/int-player.asm"
DISPLAY "Max song size: ", #ffff - $
song:
incbin "mus/sugar.nmf"
db 0, 0
DISPLAY "PAGE 0 Bytes free: ", #ffff - $
;; End of page 0 contents
savesna "snake.sna",start
savetap "spasnake.tap", start