From rtrevino@cpocd5.intel.com Fri Nov  9 17:36:14 1990
From: rtrevino@cpocd5.intel.com (Roy Trevino)
Newsgroups: comp.sys.handhelds
Subject: syzygy v0.1 - source code
Date: 2 Nov 90 05:05:45 GMT
Organization: Intel Corp, Chandler, AZ


Several people have requested the source to syzygy, so here it is.
Actually it's the listing file.	 It would have been posted sooner,
but I wanted to add *some* comments at least, etc.  Hopefully whoever
sent mail to me will see it.  Anyways, I guess we can all expect to
see tons more chip-48 programs posted now, as there is so much interest
in source code!	 :-)  They are actually quite easy to write.

Roy

PS - has anyone used the shift instructions in chip48?	The documentation
does not correlate with the "opcodes".	How do they really work?

======================================================================

--> PASS 1
****** 0 error(s) detected in pass 1 ******
--> PASS 2
	   ;
	   ;	  SYZYGY is (c) copyright 1990 by Roy Trevino (RTT)
	   ;
	   ;	  Noncommercial distribution allowed, provided that this
	   ;	  copyright message is preserved, and any modified versions
	   ;	  are clearly marked as such.
	   ;
	   ;	  SYZYGY, via CHIP-48, makes use of undocumented low-level features
	   ;	  of the HP48SX calculator, and may or may not cause loss of data,
	   ;	  excessive battery drainage, and/or damage to the calculator
	   ;	  hardware.  The Author takes no responsibility whatsoever for
	   ;	  any damage caused by the use of this program.
	   ;
	   ;	  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
	   ;	  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
	   ;	  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
	   ;	  PURPOSE.
	   ;
	   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	   ;
	   ;  Register usage (primary usage, may be others):
	   ;
	   ;	v0 - scratch
	   ;	v1 - x position of head
	   ;	v2 - y position of head
	   ;	v3 - current direction of head
	   ;	v4 - pointer to segment table entry for head
	   ;	v5 - previous direction of head
	   ;	v6 - x position of tail
	   ;	v7 - y position of tail
	   ;	v8 - direction of tail
	   ;	v9 - pointer to segment table entry for tail
	   ;	va - count of points being added to length
	   ;	vb - x position of target
	   ;	vc - y position of target
	   ;	vd - flags if target is on or off
	   ;	ve - random on time for target
	   ;	vf - carry/borrow/collision detect
	   ;
==== 0003  up:	     equ     #3		      ; (9) key for up
==== 0006  down:     equ     #6		      ; (6) key for down
==== 0007  left:     equ     #7		      ; (1) key for left
==== 0008  right:    equ     #8		      ; (2) key for right

	   ;
	   ;  Start of a circular table to track each segment of the syzygy,
	   ;  which consists of a direction and a length.
	   ;
	   ;  The start of the table is at #800 instead of a label at the bottom
	   ;  of the program (ie.  base:  end) because it seems to run faster
	   ;  that way.
	   ;
==== 0800  base:     equ     #800	      ; base of segment table

0200	   copyright:			      ; copyright notice
0200 1212	     jp	     _start
0202 8d8d	     dw	     #8d8d	      ; ->
0204 20a9	     dw	     #20a9	      ; (c)
0206 3139	     dw	     #3139	      ; 19
0208 3930	     dw	     #3930	      ; 90
020a 2052	     dw	     #2052	      ;	 R
020c 5454	     dw	     #5454	      ; TT
020e 208e	     dw	     #208e	      ; <-
0210 8e00	     dw	     #8e00
0212	   start:
0212 24b6	     call    _drawbord
0214 24da	     call    _drawtitle
0216	   waitkp1:
0216 600f	     ld	     v0,#f	      ; wait for (+) (keep border)
0218 e0a1	     sknp    v0
021a 1224	     jp	     _starty
021c 600e	     ld	     v0,#e	      ; wait for (-) (borderless)
021e e0a1	     sknp    v0
0220 1228	     jp	     _startn
0222 1216	     jp	     _waitkp1
0224	   starty:
0224 24da	     call    _drawtitle	      ; erase title (keep border)
0226 122c	     jp	     _initgame
0228	   startn:
0228 00e0	     cls		      ; erase everything (borderless)
022a 122c	     jp	     _initgame
	   ;
	   ;  initialization routines
	   ;
022c	   initgame:
	   ;
	   ;  initial head position near middle of screen
	   ;
022c c11f	     rnd     v1,#1f	      ; x-pos = rnd(16,47)
022e 7110	     add     v1,#10
0230 c20f	     rnd     v2,#f	      ; y-pos = rnd(8,23)
0232 7208	     add     v2,#8
0234 c303	     rnd     v3,#3	      ; direction = rnd(0,3)
0236 8530	     ld	     v5,v3	      ; last head direction
	   ;
	   ;  compute initial tail position
	   ;
0238 8610	     ld	     v6,v1	      ; start out same as head
023a 8720	     ld	     v7,v2
023c 8830	     ld	     v8,v3	      ; tail direction

023e 4800	     sne     v8,#0	      ; up
0240 7701	     add     v7,#1
0242 4801	     sne     v8,#1	      ; down
0244 77ff	     add     v7,#ff
0246 4802	     sne     v8,#2	      ; left
0248 7601	     add     v6,#1
024a 4803	     sne     v8,#3	      ; right
024c 76ff	     add     v6,#ff
	   ;
	   ;  draw initial syzygy, save initial segment to table
	   ;
024e a54c	     ld	     i,_dot
0250 d121	     drw     v1,v2,#1	      ; draw head
0252 d671	     drw     v6,v7,#1	      ; draw tail

0254 64f0	     ld	     v4,#f0	      ; init ptr to head vector
0256 69f1	     ld	     v9,#f1	      ; init ptr to tail vector

0258 a800	     ld	     i,_base	      ; save direction
025a f41e	     add     i,v4
025c 8030	     ld	     v0,v3
025e f055	     ld	     [i],v0
0260 7401	     add     v4,#1	      ; increment head ptr
0262 a800	     ld	     i,_base	      ; save segment count
0264 f41e	     add     i,v4
0266 6001	     ld	     v0,#1
0268 f055	     ld	     [i],v0

	   ;
	   ;  compute coordinates and value of first target
	   ;	plus set up flag and time until target
	   ;
026a 2522	     call    _rndtarg


026c 6a00	     ld	     va,#0	      ; additional length

	   ;
	   ; initial addition to syzygy for test purposes
	   ;
026e 7a00	     add     va,#0
	   ;
	   ;  main loop begins here
	   ;
0270	   loop:

0270	   chktarg:
0270 f007	     ld	     v0,dt	      ; check if a target is due
0272 3000	     se	     v0,#0
0274 129c	     jp	     _endtarg
0276 3d00	     se	     vd,#0
0278 1294	     jp	     _targoff

027a 6000	     ld	     v0,#0	      ; draw target
027c f029	     ld	     f,v0
027e dbc5	     drw     vb,vc,#5

0280 3f01	     se	     vf,#1	      ; if on body, erase immediately
0282 128c	     jp	     _targon
0284 dbc5	     drw     vb,vc,#5
0286 2522	     call    _rndtarg	      ; set up new target
0288 f015	     ld	     dt,v0	      ; no delay though
028a 129c	     jp	     _endtarg	      ; process at least one move

028c	   targon:
028c fe15	     ld	     dt,ve	      ; set up on-time
028e 6d01	     ld	     vd,#1	      ; set flag to denote on
0290 6e00	     ld	     ve,#0	      ; number of points unless hit
0292 129c	     jp	     _endtarg

0294	   targoff:
0294 80e0	     ld	     v0,ve	      ; erase old target
0296 f029	     ld	     f,v0
0298 dbc5	     drw     vb,vc,#5

029a 2522	     call    _rndtarg	      ; set up new target
029c	   endtarg:


029c	   chkkeys:
029c 6003	     ld	     v0,_up	      ; check for user input
029e e0a1	     sknp    v0
02a0 6300	     ld	     v3,#0	      ; new direction

02a2 6006	     ld	     v0,_down
02a4 e0a1	     sknp    v0
02a6 6301	     ld	     v3,#1

02a8 6007	     ld	     v0,_left
02aa e0a1	     sknp    v0
02ac 6302	     ld	     v3,#2

02ae 6008	     ld	     v0,_right
02b0 e0a1	     sknp    v0
02b2 6303	     ld	     v3,#3
	   ;
	   ;  compute next head position
	   ;
02b4 4300	     sne     v3,#0	      ; up
02b6 72ff	     add     v2,#ff
02b8 4301	     sne     v3,#1	      ; down
02ba 7201	     add     v2,#1
02bc 4302	     sne     v3,#2	      ; left
02be 71ff	     add     v1,#ff
02c0 4303	     sne     v3,#3	      ; right
02c2 7101	     add     v1,#1
	   ;
	   ;  draw next head position
	   ;
02c4 a54c	     ld	     i,_dot
02c6 d121	     drw     v1,v2,#1
	   ;
	   ;  check for collision
	   ;
02c8	   chkcoll:
02c8 3f01	     se	     vf,#1
02ca 1324	     jp	     _chkhead
	   ;
	   ;  if collision is due to target, add points (else die)
	   ;	this also means no doubling back on self
	   ;
02cc 3d01	     se	     vd,#1	      ; check if target is even on
02ce 1388	     jp	     _endgame

02d0 603f	     ld	     v0,#3f	      ; mask off extra x and y bits
02d2 8102	     and     v1,v0
02d4 601f	     ld	     v0,#1f
02d6 8202	     and     v2,v0

02d8 80b0	     ld	     v0,vb	      ; check if < target on left
02da 8017	     subn    v0,v1
02dc 3f01	     se	     vf,#1
02de 1388	     jp	     _endgame

02e0 80b0	     ld	     v0,vb	      ; check if > target on right
02e2 7003	     add     v0,#3
02e4 8015	     sub     v0,v1
02e6 3f01	     se	     vf,#1
02e8 1388	     jp	     _endgame

02ea 80c0	     ld	     v0,vc	      ; check if < target on top
02ec 8027	     subn    v0,v2
02ee 3f01	     se	     vf,#1
02f0 1388	     jp	     _endgame

02f2 80c0	     ld	     v0,vc	      ; check if > target on bottom
02f4 7004	     add     v0,#4
02f6 8025	     sub     v0,v2
02f8 3f01	     se	     vf,#1
02fa 1388	     jp	     _endgame
	   ;
	   ;  if made it this far, add points, erase target, etc
	   ;
02fc 6004	     ld	     v0,#4	      ; beep (actually, a "bip")
02fe f018	     ld	     st,v0

0300 ce07	     rnd     ve,#7	      ; award rnd(2,9) points
0302 7e02	     add     ve,#2	      ;
0304 8ae4	     add     va,ve	      ; add points

0306 a54c	     ld	     i,_dot	      ; temporarily erase head
0308 d121	     drw     v1,v2,#1
030a 6000	     ld	     v0,#0	      ; erase target
030c f029	     ld	     f,v0
030e dbc5	     drw     vb,vc,#5
0310 80e0	     ld	     v0,ve	      ; draw points instead
0312 f029	     ld	     f,v0
0314 dbc5	     drw     vb,vc,#5

0316 6030	     ld	     v0,#30	      ; delay for a while
0318 f015	     ld	     dt,v0
031a	   targwait:
031a f007	     ld	     v0,dt
031c 3000	     se	     v0,#0
031e 131a	     jp	     _targwait

0320 a54c	     ld	     i,_dot
0322 d121	     drw     v1,v2,#1	      ; redraw head
	   ;
	   ;  if direction changed, create a new segment record
	   ;
0324	   chkhead:
0324 9350	     sne     v3,v5
0326 133e	     jp	     _conthead

0328 7401	     add     v4,#1	      ; new segment record
032a a800	     ld	     i,_base
032c f41e	     add     i,v4
032e 8030	     ld	     v0,v3	      ; save direction
0330 f055	     ld	     [i],v0
0332 7401	     add     v4,#1	      ; point to counter
0334 a800	     ld	     i,_base	      ; initialize segment count to 0
0336 f41e	     add     i,v4
0338 6000	     ld	     v0,#0
033a f055	     ld	     [i],v0

033c 8530	     ld	     v5,v3	      ; reset previous direction

033e	   conthead:
033e a800	     ld	     i,_base	      ; simply add to current record
0340 f41e	     add     i,v4
0342 f065	     ld	     v0,[i]
0344 7001	     add     v0,#1	      ; increment head count
0346 f055	     ld	     [i],v0
	   ;
	   ;  don't erase tail if adding points to length
	   ;
0348	   chkpts:
0348 4a00	     sne     va,#0
034a 1358	     jp	     _contpts	      ; if pts = 0, continue normally

034c 600c	     ld	     v0,#c	      ; delay just a little to compensate
034e	   delhead:
034e 70ff	     add     v0,#ff
0350 3000	     se	     v0,#0
0352 134e	     jp	     _delhead

0354 7aff	     add     va,#ff	      ; decrement and loop
0356 1270	     jp	     _loop

0358	   contpts:
	   ;
	   ;  erase last tail position
	   ;
0358 a54c	     ld	     i,_dot
035a d671	     drw     v6,v7,#1

	   ;
	   ;  compute next tail position
	   ;
035c 4800	     sne     v8,#0	      ; up
035e 77ff	     add     v7,#ff
0360 4801	     sne     v8,#1	      ; down
0362 7701	     add     v7,#1
0364 4802	     sne     v8,#2	      ; left
0366 76ff	     add     v6,#ff
0368 4803	     sne     v8,#3	      ; right
036a 7601	     add     v6,#1

036c	   chktail:
036c a800	     ld	     i,_base	      ; get tail segment record
036e f91e	     add     i,v9
0370 f065	     ld	     v0,[i]
0372 70ff	     add     v0,#ff	      ; decrement tail count
0374 f055	     ld	     [i],v0	      ; save
0376 3000	     se	     v0,#0	      ; if zero, get new record
0378 1270	     jp	     _loop

037a 7901	     add     v9,#1	      ; new segment record
037c a800	     ld	     i,_base	      ; get new direction
037e f91e	     add     i,v9
0380 f065	     ld	     v0,[i]
0382 8800	     ld	     v8,v0
0384 7901	     add     v9,#1	      ; point to new count
	   ;
	   ;  end of main loop
	   ;
0386 1270	     jp	     _loop
	   ;
	   ;  endgame routines
	   ;
0388	   endgame:
0388 600d	     ld	     v0,#d	      ; beep
038a f018	     ld	     st,v0

038c 600b	     ld	     v0,#b	      ; wait for (space) keypress
038e e09e  endkp:    skp     v0
0390 138e	     jp	     _endkp
	   ;
	   ;  finish up tail to count points: digits are in vd:vc:vb format
	   ;  note that it is theoretically possible to get 64*32=2048 points,
	   ;  while three digits will only hold 999.  Unlikely but possible.
	   ;
0392 6b01	     ld	     vb,#1	      ; one's digit
0394 6c00	     ld	     vc,#0	      ; ten's digit
0396 6d00	     ld	     vd,#0	      ; hundred's digit

0398	   endtail:
	   ;
	   ;  increment score
	   ;
0398 7b01	     add     vb,#1
039a 3b0a	     se	     vb,#a
039c 13aa	     jp	     _endtailcont
039e 6b00	     ld	     vb,#0
03a0 7c01	     add     vc,#1
03a2 3c0a	     se	     vc,#a
03a4 13aa	     jp	     _endtailcont
03a6 6c00	     ld	     vc,#0
03a8 7d01	     add     vd,#1
	   ;
	   ;  compute next tail position to add up score
	   ;
03aa	   endtailcont:
03aa a54c	     ld	     i,_dot	      ; erase last tail position
03ac d671	     drw     v6,v7,#1

03ae 4800	     sne     v8,#0	      ; up
03b0 77ff	     add     v7,#ff
03b2 4801	     sne     v8,#1	      ; down
03b4 7701	     add     v7,#1
03b6 4802	     sne     v8,#2	      ; left
03b8 76ff	     add     v6,#ff
03ba 4803	     sne     v8,#3	      ; right
03bc 7601	     add     v6,#1

03be a800	     ld	     i,_base	      ; get tail segment record
03c0 f91e	     add     i,v9
03c2 f065	     ld	     v0,[i]
03c4 70ff	     add     v0,#ff	      ; decrement tail count
03c6 f055	     ld	     [i],v0	      ; save
03c8 3000	     se	     v0,#0	      ; if zero, get new record
03ca 1398	     jp	     _endtail

03cc 9940	     sne     v9,v4	      ; done when pointers are equal
03ce 13de	     jp	     _drawscore

03d0 7901	     add     v9,#1	      ; new segment record
03d2 a800	     ld	     i,_base	      ; get new direction
03d4 f91e	     add     i,v9
03d6 f065	     ld	     v0,[i]
03d8 8800	     ld	     v8,v0
03da 7901	     add     v9,#1	      ; point to new count
03dc 1398	     jp	     _endtail
	   ;
	   ;  draw score
	   ;
03de	   drawscore:
03de 00e0	     cls
03e0 6611	     ld	     v6,#11	      ; draw border
03e2 6709	     ld	     v7,#9
03e4 682f	     ld	     v8,#2f
03e6 6917	     ld	     v9,#17
03e8 a552	     ld	     i,_vbar
03ea d67e	     drw     v6,v7,#e
03ec d87e	     drw     v8,v7,#e
03ee 77ff	     add     v7,#ff
03f0 a54e	     ld	     i,_hbar
03f2 d671	     drw     v6,v7,#1
03f4 d691	     drw     v6,v9,#1
03f6 7608	     add     v6,#8
03f8 d671	     drw     v6,v7,#1
03fa d691	     drw     v6,v9,#1
03fc 7608	     add     v6,#8
03fe d671	     drw     v6,v7,#1
0400 d691	     drw     v6,v9,#1
0402 7608	     add     v6,#8
0404 a550	     ld	     i,_hbar2
0406 d671	     drw     v6,v7,#1
0408 d691	     drw     v6,v9,#1

040a a59e	     ld	     i,_sc	      ; show score (not high score yet)
040c 6613	     ld	     v6,#13
040e 6711	     ld	     v7,#11
0410 249a	     call    _showscore
	   ;
	   ;  figure out if it's the high score, save it if it is
	   ;
0412	   checkhigh:
0412 a5ae	     ld	     i,_high	      ; recover old high score into v3v2v1
0414 f365	     ld	     v3,[i]

0416 93d0	     sne     v3,vd	      ; if =, check next digit
0418 1424	     jp	     _conthigh1
041a 8030	     ld	     v0,v3	      ; if borrow, it's a new high score!
041c 80d5	     sub     v0,vd
041e 3f01	     se	     vf,#1
0420 143a	     jp	     _savehigh
0422 1444	     jp	     _drawhigh
0424	   conthigh1:
0424 92c0	     sne     v2,vc	      ; etc. as above for other digits
0426 1432	     jp	     _conthigh2
0428 8020	     ld	     v0,v2
042a 80c5	     sub     v0,vc
042c 3f01	     se	     vf,#1
042e 143a	     jp	     _savehigh
0430 1444	     jp	     _drawhigh
0432	   conthigh2:
0432 8010	     ld	     v0,v1
0434 80b5	     sub     v0,vb
0436 3f00	     se	     vf,#0
0438 1444	     jp	     _drawhigh

043a	   savehigh:
043a a5ae	     ld	     i,_high
043c 83d0	     ld	     v3,vd	      ; save new high score
043e 82c0	     ld	     v2,vc
0440 81b0	     ld	     v1,vb
0442 f355	     ld	     [i],v3
	   ;
	   ;  draw the high score
	   ;
0444	   drawhigh:
0444 a5ae	     ld	     i,_high
0446 f365	     ld	     v3,[i]
0448 6613	     ld	     v6,#13
044a 77f9	     add     v7,#f9
044c 8d30	     ld	     vd,v3
044e 8c20	     ld	     vc,v2
0450 8b10	     ld	     vb,v1
0452 a5a4	     ld	     i,_hi
0454 249a	     call    _showscore
	   ;
	   ;  random memory wasting stuff goes here
	   ;
0456	   waitkp2:

0456 c13f	     rnd     v1,#3f	      ; get random position
0458 c21f	     rnd     v2,#1f

045a 600d	     ld	     v0,#d	      ; check left
045c 8015	     sub     v0,v1
045e 3f00	     se	     vf,#0
0460 147c	     jp	     _drawrand

0462 6030	     ld	     v0,#30	      ; check right
0464 8017	     subn    v0,v1
0466 3f00	     se	     vf,#0
0468 147c	     jp	     _drawrand

046a 6003	     ld	     v0,#3	      ; check top
046c 8025	     sub     v0,v2
046e 3f00	     se	     vf,#0
0470 147c	     jp	     _drawrand

0472 6018	     ld	     v0,#18	      ; check bottom
0474 8027	     subn    v0,v2
0476 3f00	     se	     vf,#0
0478 147c	     jp	     _drawrand
047a 1482	     jp	     _chkkp2

047c	   drawrand:
047c c30f	     rnd     v3,#0f	      ; draw random number
047e f329	     ld	     f,v3
0480 d125	     drw     v1,v2,#5

0482	   chkkp2:
0482 600f	     ld	     v0,#f	      ; check for keypress
0484 e0a1	     sknp    v0
0486 1490	     jp	     _conty
0488 600e	     ld	     v0,#e
048a e0a1	     sknp    v0
048c 1496	     jp	     _contn
048e 1456	     jp	     _waitkp2

0490 00e0  conty:    cls
0492 24b6	     call    _drawbord
0494 122c	     jp	     _initgame
0496 00e0  contn:    cls
0498 122c	     jp	     _initgame
	   ;
	   ;  function showscore:
	   ;	digits in vd:vc:vb, descriptor in i, initial coords in v6,v7
	   ;
049a	   showscore:
049a d675	     drw     v6,v7,#5
049c a5aa	     ld	     i,_col
049e 7602	     add     v6,#2
04a0 d674	     drw     v6,v7,#4
04a2 fd29	     ld	     f,vd
04a4 760a	     add     v6,#a
04a6 d675	     drw     v6,v7,#5
04a8 fc29	     ld	     f,vc
04aa 7605	     add     v6,#5
04ac d675	     drw     v6,v7,#5
04ae fb29	     ld	     f,vb
04b0 7605	     add     v6,#5
04b2 d675	     drw     v6,v7,#5

04b4 00ee	     ret
	   ;
	   ;  function drawbord:
	   ;	draw border, try to do it fast
	   ;
04b6	   drawbord:
04b6	   horiz:
04b6 a54e	     ld	     i,_hbar
04b8 6100	     ld	     v1,#0	      ; left
04ba 6200	     ld	     v2,#0	      ; right
04bc 661f	     ld	     v6,#1f	      ; lower
04be	   horiz1:
04be d121	     drw     v1,v2,#1	      ; draw x,0
04c0 d161	     drw     v1,v6,#1	      ; draw x,31
04c2 7108	     add     v1,#8
04c4 3140	     se	     v1,#40	      ; same as 0
04c6 14be	     jp	     _horiz1

04c8	   vert:
04c8 a552	     ld	     i,_vbar
04ca 6201	     ld	     v2,#1
04cc 653f	     ld	     v5,#3f
04ce d12f	     drw     v1,v2,#f
04d0 d52f	     drw     v5,v2,#f
04d2 720f	     add     v2,#f
04d4 d12f	     drw     v1,v2,#f
04d6 d52f	     drw     v5,v2,#f

04d8 00ee	     ret
	   ;
	   ;  function drawtitle:  draws game title
	   ;
04da	   drawtitle:
04da 610c	     ld	     v1,#c
04dc 6207	     ld	     v2,#7
04de a562	     ld	     i,_s
04e0 d12a	     drw     v1,v2,#a
04e2 a56c	     ld	     i,_y
04e4 7106	     add     v1,#6
04e6 d12a	     drw     v1,v2,#a
04e8 a576	     ld	     i,_z
04ea 7106	     add     v1,#6
04ec d12a	     drw     v1,v2,#a
04ee a56c	     ld	     i,_y
04f0 7106	     add     v1,#6
04f2 d12a	     drw     v1,v2,#a
04f4 a580	     ld	     i,_g
04f6 7106	     add     v1,#6
04f8 d12a	     drw     v1,v2,#a
04fa a56c	     ld	     i,_y
04fc 7106	     add     v1,#6
04fe d12a	     drw     v1,v2,#a

0500 610e	     ld	     v1,#e
0502 6218	     ld	     v2,#18
0504 a58a	     ld	     i,_v
0506 d123	     drw     v1,v2,#3
0508 a58e	     ld	     i,_vers
050a 7108	     add     v1,#8
050c 72ff	     add     v2,#ff
050e d124	     drw     v1,v2,#4
0510 7109	     add     v1,#9
0512 72fe	     add     v2,#fe
0514 a592	     ld	     i,_r
0516 d126	     drw     v1,v2,#6
0518 7106	     add     v1,#6
051a 7201	     add     v2,#1
051c a598	     ld	     i,_tt
051e d125	     drw     v1,v2,#5

0520 00ee	     ret
	   ;
	   ;  function rndtarg:
	   ;	returns coords as (vb,vc)
	   ;	0 in vd
	   ;	time until target in dt
	   ;	on-time value ve
	   ;
0522	   rndtarg:
	   ;
	   ; x-pos = rnd(1,59)
	   ;
0522 6dc5	     ld	     vd,#c5	      ; -#3b (-59d)
0524 cb3f  rndx:     rnd     vb,#3f	      ; rnd (0,63)
0526 8eb0	     ld	     ve,vb
0528 8ed4	     add     ve,vd	      ; check if > 58
052a 4f01	     sne     vf,#1
052c 1524	     jp	     _rndx	      ; try again if too big

052e 7b01	     add     vb,#1
	   ;
	   ; y-pos = rnd(1,26)
	   ;

0530 6de6	     ld	     vd,#e6	      ; -#1a (-26d)
0532 cc1f  rndy:     rnd     vc,#1f
0534 8ec0	     ld	     ve,vc
0536 8ed4	     add     ve,vd
0538 4f01	     sne     vf,#1
053a 1532	     jp	     _rndy

053c 7c01	     add     vc,#1

053e	   rndf:
053e 6d00	     ld	     vd,#0	      ; flag marking new target

0540	   rndd:
0540 ce3f	     rnd     ve,#3f	      ; random off delay (64 - 127)
0542 7e40	     add     ve,#40
0544 fe15	     ld	     dt,ve
0546 ce3f	     rnd     ve,#3f	      ; random on delay (64 - 127)
0548 7e40	     add     ve,#40
054a 00ee	     ret

054c 8000  dot:	     dw	     #8000	      ; dot for syzygy
054e ff00  hbar:     dw	     #ff00	      ; horizontal border segment
0550 fe00  hbar2:    dw	     #fe00
0552 8080  vbar:     dw	     #8080	      ; vertical border segment
0554 8080	     dw	     #8080
0556 8080	     dw	     #8080
0558 8080	     dw	     #8080
055a 8080	     dw	     #8080
055c 8080	     dw	     #8080
055e 8080	     dw	     #8080
0560 8080	     dw	     #8080
	   ;
	   ;  True memory wasting stuff goes here (but why not?)
	   ;
0562 1f10  s:	     dw	     #1f10	      ; s character
0564 1010	     dw	     #1010
0566 1f01	     dw	     #1f01
0568 0101	     dw	     #0101
056a 011f	     dw	     #011f
056c 1111  y:	     dw	     #1111	      ; y character
056e 1111	     dw	     #1111
0570 1f04	     dw	     #1f04
0572 0404	     dw	     #0404
0574 0404	     dw	     #0404
0576 1f01  z:	     dw	     #1f01	      ; z character
0578 0202	     dw	     #0202
057a 0404	     dw	     #0404
057c 0808	     dw	     #0808
057e 101f	     dw	     #101f
0580 1f11  g:	     dw	     #1f11	      ; g character
0582 1010	     dw	     #1010
0584 1013	     dw	     #1013
0586 1111	     dw	     #1111
0588 111f	     dw	     #111f
058a 0505  v:	     dw	     #0505	      ; v character for version
058c 0200	     dw	     #0200
058e 7151  vers:     dw	     #7151	      ; version number characters
0590 5175	     dw	     #5175
0592 0c12  r:	     dw	     #0c12	      ; R character for signature
0594 1e14	     dw	     #1e14
0596 1209	     dw	     #1209
0598 143e  tt:	     dw	     #143e	      ; tt characters for signature
059a 1515	     dw	     #1515
059c 2a00	     dw	     #2a00
059e 7744  sc:	     dw	     #7744	      ; sc characters for score
05a0 2414	     dw	     #2414
05a2 7700	     dw	     #7700
05a4 5752  hi:	     dw	     #5752	      ; hi character for high score
05a6 7252	     dw	     #7252
05a8 5700	     dw	     #5700
05aa 0001  col:	     dw	     #0001	      ; : character for scores
05ac 0001	     dw	     #0001
05ae 0000  high:     dw	     #0000	      ; high score storage
05b0 0000	     dw	     #0000
05b2		     end		      ; end at last
****** 0 error(s) detected in pass 2 ******

--> LABEL XRF

   label      value
------------ -------
up		 3h
down		 6h
left		 7h
right		 8h
base	       800h
copyright      200h
start	       212h
waitkp1	       216h
starty	       224h
startn	       228h
initgame       22ch
loop	       270h
chktarg	       270h
targon	       28ch
targoff	       294h
endtarg	       29ch
chkkeys	       29ch
chkcoll	       2c8h
targwait       31ah
chkhead	       324h
conthead       33eh
chkpts	       348h
delhead	       34eh
contpts	       358h
chktail	       36ch
endgame	       388h
endkp	       38eh
endtail	       398h
endtailcont    3aah
drawscore      3deh
checkhigh      412h
conthigh1      424h
conthigh2      432h
savehigh       43ah
drawhigh       444h
waitkp2	       456h
drawrand       47ch
chkkp2	       482h
conty	       490h
contn	       496h
showscore      49ah
drawbord       4b6h
horiz	       4b6h
horiz1	       4beh
vert	       4c8h
drawtitle      4dah
rndtarg	       522h
rndx	       524h
rndy	       532h
rndf	       53eh
rndd	       540h
dot	       54ch
hbar	       54eh
hbar2	       550h
vbar	       552h
s	       562h
y	       56ch
z	       576h
g	       580h
v	       58ah
vers	       58eh
r	       592h
tt	       598h
sc	       59eh
hi	       5a4h
col	       5aah
high	       5aeh

--
  --------------------------------------------------------------
  Roy Trevino                                        Intel Corp.
  E-mail: rtrevino@sedona.intel.com          Tel: (602) 554 2816
  UUCP:  decwrl!apple!oliveb!orc!inews!rtrevino@sedona.intel.com

