-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCTEST.ASM
More file actions
230 lines (204 loc) · 5.78 KB
/
CTEST.ASM
File metadata and controls
230 lines (204 loc) · 5.78 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
;;Chris Busch
#include "ti-85.h"
;;;;;;
;;text memory
;;;;;;
xspot =$80DF ;x : current row
yspot =$80E0 ;y : current col
coordp =$80E1 ;p : previous row
coordq =$80E2 ;q : previous col
dummy1 =$80E3 ;local variable
score =$80E4
row1 =$80E5 ;checker is stored here
oldxy =$80E6 ;labels from "row2" to
oldxy_ =$80E7 ;"row8" are not necessary
pix =$80E8 ;just to remind that
pix_ =$80E9 ;memory has been reserved.
sprxy =$80F0
sprxy_ =$80F1 ;what_ shows reservation only
randvar =$80F2
;----------------------------------------------------------------------------
; Title
;----------------------------------------------------------------------------
.org 0
.db "Crunch v0.1"
;----------------------------------------------------------------------------
; macro section
;----------------------------------------------------------------------------
;;;;;#include "gamemacs.h"
;----------------------------------------------------------------------------
; Program start
;----------------------------------------------------------------------------
main:
ROM_CALL(CLEARLCD)
set 3,(IY+5) ;white on black.
ld HL,$0003
ld (CURSOR_ROW),HL
ld HL,$0000
ld (CURSOR_COL),HL
ld HL,(PROGRAM_ADDR)
ld DE,Title
add HL,DE
ROM_CALL(D_ZT_STR)
res 3,(IY+5) ;black on white.
wait4enter:
call GET_KEY
;;add rand seeder
ld a,(randvar)
add a,13
ld (randvar),a
cp K_ENTER
jr nz, wait4enter
;;;;;;;;;;;;initsprite
ld hl,VIDEO_MEM
ld (sprxy),hl ;sprxy=videomem
ld (oldxy),hl ;oldxy=sprxy
ld HL,(PROGRAM_ADDR)
ld DE,picture
add HL,DE
ld (pix),hl ;pix=picture
drawloop:
; ld hl,(oldxy)
; push hl
; CALL_(erasespr)
; ld hl,(sprxy)
; push hl
; ld hl,(pix)
; push hl
; CALL_(drawspr)
ld ix,(oldxy)
CALL_(erasespr)
ld hl,(sprxy)
ld ix,(pix)
CALL_(drawspr)
gameloop:
;;;;;;start keyboard handling
call GET_KEY
cp K_NOKEY
jr z, nokey
cp K_EXIT
jr z, quit
;;;;;;probably movement
;;;;;;do premovement stuff here
ld hl,(sprxy) ;oldxy=sprxy
ld (oldxy),hl
;;;;;;check movement
movement: ;;;;;;;;; ASSUME a=getkey
cp K_UP
jr z, keyup
cp K_DOWN
jr z, keydown
cp K_LEFT
jr z, keyleft
cp K_RIGHT
jr z, keyright
cp K_SECOND
jr z, keyrandom
nokey:
jr gameloop
keyup:
;;hlydec(sprxy)
ld hl,(sprxy) ;hl=sprxy
ld bc,$FF80
add hl,bc ;hl-=16*8
ld a,h ;if( h<$FC ) {
cp $FC ; goto gameloop
jr C,gameloop ;}
ld (sprxy),hl ;sprxy=hl
jr drawloop
keydown:
;;hlyinc(sprxy)
ld hl,(sprxy) ;hl=sprxy
ld bc,16*8
add hl,bc ;hl+=16*8
ld a,h ;if( h<$FC ) {
cp $FC ; goto gameloop
jr C,gameloop ;}
ld (sprxy),hl ;sprxy=hl
jr drawloop
keyleft:
;;hlxdec(sprxy)
ld hl,(sprxy) ;hl=sprxy
ld a,l ;if( l&0xF==0) {
and $0F ;
cp 0 ; goto gameloop
jr z,gameloop ;}
dec hl ;hl--
ld (sprxy),hl ;sprxy=hl
jr drawloop
keyright:
;;hlxinc(sprxy)
ld hl,(sprxy) ;hl=sprxy
ld a,l ;if( l&0x0F==0x0F) {
and $0F ;
cp $0F ; goto gameloop
jr z,gameloop ;}
inc hl ;hl--
ld (sprxy),hl ;sprxy=hl
jr drawloop
quit:
ret ;end game
keyrandom:
CALL_(rand)
and $03
inc a
jr movement
;;;;;;;;;functions
#include "rand.asm"
#define putline(offset) ld a,(IX+offset)
#defcont \ ld (hl),a
#defcont \ add hl,bc
;;drawspr
;;draw(XY,picture)
;;calling: push XY \ push picture \ call putsprite
;;destroys: bc,ix,hl,a
drawspr:
; pop bc ;save (sp)
; pop ix ;IX=start address for bitmap
; pop hl ;hl=start address for pixel puts
; push bc ;restore (sp)
ld bc,16 ;bc=16
putline(0)
putline(1)
putline(2)
putline(3)
putline(4)
putline(5)
putline(6)
putline(7)
ret
;;end drawspr
;;erasespr
;;erasespr(XY)
;;calling: push XY \ call erasespr
;;destroys: bc,ix
erasespr:
; pop bc ;save (sp)
; pop ix ;IX=start address for pixel puts
; push bc ;restore (sp)
ld (ix+16*0),0
ld (ix+16*1),0
ld (ix+16*2),0
ld (ix+16*3),0
ld (ix+16*4),0
ld (ix+16*5),0
ld (ix+16*6),0
ld (ix+16*7),0
ret
;;end erasesprite
;----------------------------------------------------------------------------
; data section
;----------------------------------------------------------------------------
;;sprite definition
;;struct sprite {
;; void* vidmem
;; void*
;;}
sprvidmem = 0 ;sprite video memory location
sprpic = 2 ;sprite picture info
sprsize = 10
Title: .db " Crunch v0.0 "
.db "(C)1995 Chris Busch"
.db " <hit enter> ",0
picture: .db $FF,$C3,$c3,$db,$db,$c3,$c3,$FF
.END