3 ; Release Date : summer 2001
4 ; Filename : wormy.86p (5kb)
6 ; Email Address : shiar0@hotmail.com
8 ; Web Page : www.shiar.org
9 ; Description : ruling Nibbles-like game 1-4 players
10 ; Where to get this game : www.shiar.org (home of Wormy)
11 ; Other games by author(s) : Nemesis beta
12 ; Additional Credits to : Matthew Shepcar (wrote original Peaworm, end'98)
13 ; Jonah Cohen (helped writing worm)
15 ;-----------------------------
16 ;----------- TO-DO -----------
17 ;-----------------------------
21 ; [* internal levels ]
22 ; [ * check levels/gametype ]
23 ; [ * enough hiscore saves! ]
24 ; [* complete readme ]
25 ; 1% * misc (pollish, bugs, &&&)
27 ; * fix first packet loss
28 ; 1% * transmit game/level data
29 ;;;1% * get g/o signal (l&l) working
30 ; 2% * send new peas' positions
32 ;100% = bugs fixed + levels done
34 ;-----------------------------
35 ;-----------------------------
36 ;--------- W O R M ---------
37 ;-----------------------------
38 ;-----------------------------
40 #define buffer ;use display buffer (otherwise write directly to screen)
41 #define readymask ;"greys" out the field before starting a level
42 #define coolzgfx ;nice graphics for game over screen
44 ;#define readytext ;displays "prepare" before level starts
45 ;#define invincible ;worms cannot die =)
46 ;#define optdie ;in race games worms don't die when they run into each other
54 #include "ti86asm.inc"
56 _SHRACC = $4383 ;4x srl a
57 _SHLACC = $438B ;4x sll a
58 _divHLby10 = $4044 ;hl=hl/10
59 _divAby10 = $4DAF ;a=a/10
60 _HLTIMES10 = $41BF ;hl=hl*10
61 _cphlde = $403C ;cp hl,de
62 _clrWindow = $4A86 ;clear screen
63 _asapvar = $D6FC ;own name (worm)
64 _MOV4B = $429B ;4x ld (de),(hl)
65 _MOV5B = $4297 ;5x ld (de),(hl)
66 _mov9b = $4283 ;9x ld (de),(hl)
67 _ldHLind = $4010 ;ld hl,(hl)
68 _swapt_ = $45F3 ;ex_ahl_bde
69 _Get_Word_ahl = $521D ;ld de,(ahl)
70 _Set_Word_ahl = $5221 ;ld (ahl),de
71 _INC_PTR_AHL = $4637 ;ahl=ahl+1
72 _AHL_PLUS_2_PG3 = $4C3F ;ahl=ahl+2
73 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl
74 _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
75 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
76 _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl
77 _mm_ldir = $52ED ;24bit ldir
78 _MM_LDIR_SET_SIZE = $524D ;_SET_MM_NUM_BYTES + _mm_ldir
79 _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1
80 _RAM_PAGE_7 = $47F3 ;"""" 7
81 _PTEMP_END = $D29A ;end of VAT
82 _load_ram_ahl = $462F ;ahl->page+hl
83 _writeb_inc_ahl = $5567 ;ld (ahl++),c
84 _jforce = $409C ;TI-OS stack restored
85 _EXLP = $4493 ;swap (hl),(de) b times
86 _GETB_AHL = $46C3 ;a=(ahl) \ hl=ahl
88 ;-----------------------------
89 ;------- data storage -------
90 ;-----------------------------
94 ScrBuffer = $8820 ;-A7FF (20*FF=1FE0)
95 worm2p = $A800 ;-ABFF (400) %10101O00
96 worm1 = $AC00 ;-AC1D (31d)
97 worm2 = $AC1F ;-AC3B (1F)
98 worm3 = $AC3E ;-AC59 (1F)
99 worm4 = $AC5D ;-AC77 (1F)
100 balls = $AC7C ;-ACFF (3x43d)
101 SinCosTable = $AD00 ;-AE00 (4*40)
102 ;free $AE01 ;-AFFF (1FF)
103 worm1p = $B000 ;-B7FF (800) %1011O000
104 worm3p = $B800 ;-BBFF (400) %10111O00
105 ;free $BF91 ;-BFFF (6F)
106 ;program $D748 ;-EFFF (186D+4A)
107 worm4p = $F000 ;-F3FF (400) %11110O00
108 leveldata = $F400 ;-FA70 (<=671)
110 turn10 = $AE01 ; (1) (counter)
111 peaspos = $AE02 ;-AE05 (4) (peas)
113 ;MEM|8---9---A---B---C---D---E---F---|
114 ; |..[------]||[]|......[-----]|[].|
115 ; | SCREEN 2* 13 PRGM 4LV |
119 namelength = $BC00 ;(1) @menu
121 DispBuffer = $BC00 ;(10x57d) @game
126 ;-----------------------------
127 ;------- program start -------
128 ;-----------------------------
143 .db "WORMY by SHIAR -- beta 95%",0
146 .db %00000000,%00111100
147 .db %00000000,%01010010
148 .db %00000000,%01100001
149 .db %01100011,%10011001
150 .db %10010100,%01101001
151 .db %10011001,%00011001
152 .db %01000010,%11000001
153 .db %00111100,%00111110
156 levelhead2 = 95 ;wormy levels header = "95"
187 ld bc,int_end-int_handler
194 ld hl,$BFFF ;VAT start
197 ld de,(_PTEMP_END+1) ;VAT end
227 ex de,hl ;ld ahl,(hl)
228 cal _AHL_PLUS_2_PG3 ;string id
229 cal _Get_Word_ahl ;ld de,(ahl)
233 jr nz,_searchnext ;not worm
237 inc ix ;save level's ahl
250 cal _Get_Word_ahl ;ld de,(ahl++)
252 ld a,e ;set new level
277 cal _vputs ;"< SELECT LEVELS >"
295 ld l,(ix+2) ;ahl=(ix)
296 cal _load_ram_ahl ;hl=ahl
297 ld b,(hl) ;b=title size
307 cp 49 ;bottom of screen
331 ld ix,templevels-6 ;reset 2 1st page
333 ld b,-2 ;level selected
340 pop bc ;GET_KEY destr. b
359 add a,3 ;sellev+3 (#0==-3)
367 or a ;levelfile on page 0 (=internal)
378 cal _GETB_AHL ;ld a,(ahl)
383 cal _INC_PTR_AHL ;ahl++
385 jr nz,skiptitle ;goto #0-terminator
388 ld (leveldataSize),de
393 ld (hilvlposa),a ;singleplayer levels
398 cal _SET_ABS_SRC_ADDR ;levelsstart
401 cal _SET_ABS_DEST_ADDR ;store in mem.
404 cal _MM_LDIR_SET_SIZE
406 cal _LOAD_ABS_SRC_ADDR ;->ahl
413 ldi ;(de),(hl)\inc hl
418 res 2,(iy+13) ;appAutoScroll
426 ld (hl),1 ;def=level#1
430 ;-----------------------------
431 ;----- build trig tables -----
432 ;-----------------------------
457 ;-----------------------------
458 ;---------- menu -------------
459 ;-----------------------------
461 DisplayMenu: ;---draw menu---
468 ld hl,$FC00+$010 ;(*,01)
470 ld hl,$FC00+$160 ;(*,22)
472 ld hl,$FC00+$3E0 ;(*,62)
477 dec a ;will be inced @changegame
480 ld hl,changegame ;dispmenusets ;mainMenu
481 psh hl ;jump here after ret
484 ;Mode|Level|Limit|Worms|worm #|controls
485 ; jr dispmenucommon ;cal
488 ld de,$FD80 ;begin pos
512 hr: ;draw horizontal line at hl
521 ;Back|Lives|Limit|Speed|Rotation|Growth
536 inc hl \ inc hl \ inc hl
554 inc a ;-1=None; 0..98->1..99
569 cal cshowA0 ;turn speed
576 ld a,(hl) ;(scorelimit)
581 jr z,optionMenu ;do not display 0 behind 'None'
593 jp z,dispmainmenu ;mainMenu
637 cal loadgamecar ;a=(hl)
640 jr nc,optionMenu ;>99
644 jp dispomenusets ;optionMenu
647 sub 1 ;dec does not set cf
655 jr nc,optionMenu ;>99
658 jr _dispomenusets ;optionMenu
661 sub 1 ;dec does not set cf
668 ld a,(hl) ;(scorelimit)
675 jr nc,_optionMenu ;>98
679 jr _dispomenusets ;optionMenu
685 jr z,_optionMenu ;<-1
692 inc hl ;=saves 2 bytes :P
701 jr nc,_optionMenu ;>25
704 jr _dispomenusets ;optionMenu
719 jr nc,_optionMenu ;>98
722 jr _dispomenusets ;optionMenu
728 jr z,__optionMenu ;<-1
740 dec a ;2nd item: level
742 sub 3 ;5th item: wormname
746 jp LetsGetThisPartyOn ;otherwise
777 jr nc,mainMenu ;may not become >(nrworms)
781 jr _dispmenusets ;mainMenu
794 ; jr z,bchangecurworm
799 jr nz,changedcurworm ;save >0
804 ld a,(hl) ;hl=nrworms
807 jr nc,mainMenu ;may not be >4
810 jr _dispmenusets ;mainMenu
814 ld a,(hl) ;hl=nrworms
818 ld a,(hl) ;hl=nrworms
821 jr nc,changednrworms ;save >=2
830 jr _mainMenu ;don't change for singleplayer
835 dec hl ;inced earlier
837 ld a,1 ;change LS-bit (=link)
841 jr dispmenusets ;mainMenu
848 jr dispmenusets ;mainMenu
861 jr dispmenusets ;mainMenu
864 inc hl ;hl=loadgamecar+2
866 ld a,(hl) ;(curlevel)
868 cp (hl) ;max level for sel.game
874 jr dispmenusets ;mainMenu
877 ld a,(hl) ;(curlevel)
882 getnrlevels: ;for current gametype at hl
909 cal getcustomkey ;left
910 cal getcustomkey ;right
913 ;---display current settings---
923 add hl,de ;hl=posGame+(Gametype)
924 ld a,(hl) ;str.offset
928 ld (CURtxtGame),hl ;save for g/o
929 cal _vputs ;Singleplayer
978 ld hl,$363E ;controls
984 ;--- handle menukeys ---
992 pop bc ;GET_KEY destr. b
1002 menupos: ;highlight #b
1015 add hl,hl ;$FD20+item*96
1045 ;--- change name ---
1048 getwormname: ;of (curworm)
1076 ld hl,$FF07 ;begin pos
1109 dec (hl) ;(namelength)
1124 .db 0,".<>!",0,0,0,0 ;down,L,R,up
1125 .db 0,"XTOJE0",0 ;enter..clear
1126 .db " WSNID9",0 ;(-)..custom
1127 .db "ZVRMHC8",0 ;dot..del
1128 .db "YUQLGB7#" ;0..xvar
1129 .db $D9,"-PKFA6'" ;on..alpha
1130 .db "54321*",0,$D0 ;F5..more
1134 ld (ix+8),0 ;end mark
1141 halt ;save them batteries! yeah!
1145 ld hl,$FD97 ;begin pos
1146 ld a,35 ;nr of lines
1148 ld de,7 ;bytes to add
1150 ld c,9 ;bytes to clear
1155 jr nz,clroldsetsloop
1158 jr nz,clroldsettings
1161 hlatlevel: ;d must be 0
1163 ld a,(Gametype) ;8bytes -> 7bytes
1168 add a,24+1 ;go to datalevels
1170 sbc hl,de ;datalevels
1171 cal _ldHLind ;ld hl,(hl)
1172 pop de ;de=loadgamecar
1174 ld a,(de) ;(curlevel)
1178 dec d ;levels to skip
1182 ret ;hl=begin of correct level
1184 skiplvltitle: ;zf=singleplayer
1186 or a ;null-terminator
1191 skiplevel: ;@hl - destr:ab - alter:hl
1200 ld b,(hl) ;spritesize
1208 pop af ;cp (Gametype),0
1210 inc b ;multiplayer lvl
1212 inc b ;skip other 3 worms (9 bytes)
1246 ;build: c=(gameCar)=(hl-1)
1247 ; a=(wormbeglives)=(hl)
1253 add a,a ;8 bytes per mode
1265 ;-----------------------------
1266 ;-------- start game ---------
1267 ;-----------------------------
1271 ld (CheckExit),a ;set exit state
1289 ld (turnright),a ;more efficient
1293 cal _HLTIMES10 ;hl=10*(hl)
1317 jp DisplayMenu ;return to menu
1336 ;-----------------------------
1337 ;--------- game over ---------
1338 ;-----------------------------
1343 ld a,4 ;4x (all worms)
1353 ld (hl),b ;score+1=0
1360 ex de,hl ;de=wormX+head
1364 jr nz,createwormsloop
1368 pop hl ;begin of current level
1375 dec (hl) ;curlevel-- (not beyond last lvl)
1378 ;show end msg or smtn
1380 psh bc ;where to go afterwards
1381 inc hl ;location of ending-code
1382 jp (hl) ;go there ("call")
1395 ld a,(hl) ;speed from level
1399 ld (de),a ;custom speed
1418 ld b,0 ;bc=sprite size
1419 add hl,bc ;hl=behind sprite
1426 setsprite: ;de=@sprite ;a=sprsize
1450 pop af ;cp (Gametype),0
1458 ld a,SinCosTable/256
1469 ld bc,(worm2-worm1)-5
1479 ;-------- draw level ---------
1505 add hl,hl ;32=scr.width
1512 ld bc,63 ;first 2 rows
1514 ldir ;draw upper border
1516 ld (hl),%11000000 ;first left border
1521 inc hl ;clear rest of line
1561 cp gamerace ;or gamectf
1562 jr c,levelhasbeensetup
1564 ld c,2 ;ld bc,2 (2 bytes)
1565 jr z,loadextralevelstuff ;cp gamerace
1566 ld c,4 ;ld bc,4 (2nd flag in ctf)
1567 loadextralevelstuff:
1576 ;-----------------------------
1578 psh hl ; >> levelp new
1613 ld hl,4+(txtposReady*256)
1624 jr nc,initfinished ;no link
1626 SwapPos: ;$18 xx -> $E6 xx
1630 ld (worm1+left),a ;worm 1...
1631 ld (worm3+left),a ;and worm 3 via link
1662 ld (worm2+left),a ;worm 2+4..
1663 ld (worm4+left),a ;..over link
1678 ;-----------------------------
1679 ;----------- LOOP ------------
1680 ;-----------------------------
1683 ld bc,(worm1+pos) ;camera worm #1
1685 or a ;if #1 not over link
1687 ld bc,(worm2+pos) ;otherwise view from #2
1689 cal DisplayField ;display piece of level
1704 jr nz,screeninvertloop
1717 ld (handledworm),a ;reset
1735 jr nz,nodispupdate ;just once every 10 turns
1736 ld (hl),10 ;reset counter
1737 cal forceshowstats ;update score
1742 jr nz,noctfpeas2draw
1745 cal tryDrawPea ;pea#1
1748 cal tryDrawPea ;pea#2
1755 cal nz,handlethoseneatlittleballs
1768 inc (hl) ;0..nrworms-1
1771 ;-----------------------------
1772 ;---------- keys -------------
1773 ;-----------------------------
1788 rla ;=$17 (c=EXIT-key)
1799 ld (ix+delay),respawndelay
1818 ld (ix+pos2+1),a ;x2
1825 cp gamectf ;ctf no death penalty
1828 ret nz ;HandleWorm done
1830 or a ;0=no live limit
1831 ret z ;don't end game
1834 jr z,anyworm ;quit at any worm's death
1835 ld a,(nrworms) ;timematch: all worms must've died
1837 ld hl,worm1+lives-(worm2-worm1)
1839 xor a ;check for 0 lives
1841 add hl,de ;next worm
1843 ret nz ;any >0: don't exit
1846 ld a,$A7 ;exit@end of turn
1847 ld (CheckExit),a ;set exit state
1856 out (7),a ;both wires low = game over signal
1865 cal menuinvloop ;invert
1867 cal hr ;menuinvloop w/ b=16
1877 cal menuinvloop ;invert
1879 cal hr ;menuinvloop w/ b=16
1898 cal _vputs ;Died Score
1913 jr c,nonewwinner ;h<d
1914 jr nz,newwinner ;h>d
1917 jr nc,nonewwinner ;l<e
1928 cpl ;high value (>$FB)
1933 ld a,(hl) ;less deaths
1940 ;---display worms---
1952 cp (hl) ;input=0 = link
1969 ld a,(hl) ;worm+died
1976 jr nz,nodmwinner ;deathmatch?
1977 ld a,0 ;winner's deaths
1979 cp (hl) ;equals this worm?
1980 scf ;jr nz,notwinner
1983 jr c,notwinner ;no singleplayer winners
1985 cal _ldHLind ;ld hl,(hl)
1988 cal _cphlde ;==highest score..
2003 dnz displayWormStats
2006 or a ;singleplayer (0) only
2007 jr nz,hilevelcheckdone
2012 jr c,hilevelcheckdone
2013 ld (hl),a ;save local
2018 hilvlposhl =$-2 ;save external
2019 cal _writeb_inc_ahl ;ld (ahl),c
2024 jr z,hiscorecheckdone ;no SP
2026 cal loadhiscoreposinahl
2027 cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile)
2030 cal _SET_ABS_DEST_ADDR ;to local
2032 cal _MM_LDIR_SET_SIZE ;get old score+name
2035 ld de,(highsave) ;de=prev. hiscore
2036 ld hl,(worm1+score) ;hl=worm1's score
2037 cal _cphlde ;sub hl,de
2038 jr c,NotNewHigh ;new<old
2039 jr z,NotNewHigh ;new<=old
2041 ld (highsave),hl ;store new hiscore
2042 ld de,highsave+2 ;to
2043 ld hl,worm1+name ;from
2045 ldir ;store new hiname
2046 cal loadhiscoreposinahl
2047 cal _SET_ABS_DEST_ADDR ;to ahl
2050 cal _SET_ABS_SRC_ADDR ;from local
2052 cal _MM_LDIR_SET_SIZE ;save new
2080 ;x123456789012345678901
2081 ;>>>>>> GAME OVER <<<<<
2086 ;6Worm#02 @ 05 00120
2093 rst 20h ;_ABS_MOV10TOOP1
2095 ld hl,savestart-_asm_exec_ram+4
2099 cal _SET_ABS_DEST_ADDR
2103 cal _SET_ABS_SRC_ADDR
2104 ld hl,saveend-savestart
2105 cal _MM_LDIR_SET_SIZE
2113 loadhiscoreposinahl:
2114 ld hl,0 ;for peaworm and singleplayer
2120 ld a,(nrlevels+1) ;skip peaworm slots if tron mode
2124 ld b,a ;levels to skip (including 1 for singleplayer)
2125 ld de,5 ;to add per level
2127 add hl,de ;one word+3 bytes for name
2128 dnz addlevelposition
2135 adc a,0 ;ahl=saveloc
2144 jp _putc ;..then put *
2146 ;-----------------------------
2147 ;----------- worm ------------
2148 ;-----------------------------
2153 cal saverespawncounter
2159 jr DoesWormTailEqualsWormHead ;chk4 size=0
2170 DoesWormTailEqualsWormHead:
2172 jr nz,removewormloop
2176 jr nz,safewormsizedone
2184 ld (ix+tail),e ;head=tail/size=0
2190 jr nz,saverespawncounter
2214 ld a,%01111111 ;default
2217 dnz bitmask ;a/8 times
2218 out (1),a ;send bitmask
2219 in a,(1) ;input keys
2224 dnz keybit ;check match (cf set)
2227 inkeys: ;use jp not call!
2246 jr z,inlink ;input by link
2247 cal inkeys ;input by keys
2251 ld c,l ;send our keys
2258 ;------- handle worm ---------
2309 ;-------- move worm ----------
2337 notmoveY: ;bc=newpos
2344 pop hl ; << pos (old)
2362 ;--------- worm hit ----------
2369 cal z,checkhitotherworm
2372 and _datamultpeas ;&&bit
2376 jp z,WormDead ;no food
2383 cal DrawPea ;remove pea
2395 jp nz,Drawworm ;continue
2401 jp nz,Exit ;stack restored
2412 cal _IncScore ;score+(40*level)
2419 chkpeahit: ;bc=ownpos;hl=peapos (destr:ad)
2435 ld hl,(peaspos) ;1st pea
2438 and %01 ;ourpea (0|1)
2440 ld hl,(peaspos+2) ;2nd pea ;&&&ex de,hl?
2445 ld a,e ;peek a (that's x86asm for pop\push ;)
2446 bit 1,a ;%10 = carrying flag?
2447 jp z,WormDead ;if not just die
2452 pop af ;which flag? (=and %1)
2453 ld hl,drawctfpea1 ;restore #1
2454 jr z,nottheotherflag
2455 ld hl,drawctfpea2 ;restore #2
2457 ld (hl),3 ;draw delay 3 turns
2463 hitflag: ;correct pea hit
2465 xor %11 ;invert flag taken + ownflag
2467 and %10 ;just returned?
2471 jr nz,Drawworm ;flag taken, continue game
2473 ld e,20 ;flag captured+returned
2477 ld (drawctfpea1),a ;redraw..
2478 ld (drawctfpea2),a ;..both flags
2481 ;-----------------------------
2500 jr nz,nextotherwormbit
2510 ld a,(peaspos+1) ;yline
2513 jr nc,checklap ;y>yline -> a=1
2514 xor a ;y<yline -> a=0
2517 ret z ;same as before
2518 ld (ix+reserv),a ;1st time
2521 and 1 ;group 0 (1,3) or 1 (2,4)
2523 ret z ;(group 0 and y<yline) or (group 1 and y>yline)
2532 .db $dd,$7d ;ld a,lx
2535 jr nz,chkworm2 ; ret nz
2561 ;-------- draw worm ----------
2569 cal z,checkhitlapline
2575 ret z ;keep tail in "Tron"
2618 ;-----------------------------
2619 ;---------- ball -------------
2620 ;-----------------------------
2622 handlethoseneatlittleballs:
2668 bit 1,d ;1=up; 0=down
2698 letsmovetheotherway:
2713 ;-----------------------------
2714 ;----------- procs -----------
2715 ;-----------------------------
2719 ld a,%10000000 ;all key-masks
2722 inc a ;cp %11111111 (no keys pressed)
2723 jr nz,releasekeys ;keep waitin
2724 cal GET_KEY ;clear buffer
2746 CheckPea: ;@hl; destr:abcde
2759 ret nz ;nz=pixel found
2768 tryDrawPea: ;hl=peapos;bc=dopea
2777 dec (hl) ;hl=appeartime
2778 ex de,hl ;hl=peaspos
2801 PutSprite: ;||@(b,c)
2802 ;by SHIAR only ix saved
2839 ;----------- score -----------
2841 timematchscore: ;piece of crap checking whether you've already won in timematch
2851 jr z,nneexxtt ;yourself
2853 ret nz ;someone else still alive
2858 jr c,nneexxtt_ ;you>him
2871 dnz chktimematchover
2887 add hl,de ;increase score
2890 jr z,scorecommon ;hl/1000 not increased
2899 jr c,showstats ;<0=0
2902 IncScore: ;inc score by e
2904 _IncScore ; inc by de
2908 or a ;if singleplayer...
2910 add hl,de ;score+=de
2913 ld (ix+score),l ;save
2918 jr z,showstats ;de=0=no limit
2925 jr nz,timematchscore ;no disp for timematches
2926 ld hl,$FC00 ;&&&only necessary in deathmatch
2948 shownameloop: ;1st 3 chars
2977 showstat: ;(multiplayer)
2988 showA: ;small w/o leading 0 (&&&combine w/ cshowA0??)
3007 showstatsS: ;(singleplayer)
3042 showA0: ;big w/ leading 0
3054 cshowA0: ;small w/ leading 0
3089 ;-----------------------------
3207 ld (ShiftRightCounter),a
3209 ld (ShiftRightChunk),a
3223 ShiftRightCounter = $-1
3245 ld (ShiftLeftCounter),a
3247 ld (ShiftLeftChunk),a
3249 jr nc,ShiftLeftSameByte
3268 ShiftLeftCounter = $-1
3279 jr nz,ShiftRowsRight
3313 ;----------- draw ------------
3327 CheckPixel: ;at bc in d
3334 ;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes)
3335 ;(b,c) to hl:a; "destroyes" ahl
3337 FindPixel: ;(b,c) to hl:a
3400 drawcircle: ;(d,e),h ;de=x,y; h=z
3411 ex (sp),hl ;push zz \ pop x,y
3412 cal circledraw ;(x-xx,y+yy)-(x+xx,y+yy)
3413 ;(x-xx,y-yy)-(x+xx,y-yy)
3414 cal circledraw ;(x-yy,y+xx)-(x+yy,y+xx)
3415 ;(x-yy,y-xx)-(x+yy,y-xx)
3417 ex (sp),hl ;push x,y \ pop zz
3420 dec a ;-256<h<0 = $FF**
3422 jr z,circlenext ;jump if zz<0
3426 add a,a ;a=2yy-2 ;nc
3428 sbc hl,de ;zz=zz-2yy+2
3436 add hl,de ;zz=zz+2xx+3
3445 circledraw: ;destr:de
3450 add hl,bc ;h=x+xx; l=y+yy
3452 cal drawline ;(h-b,l+c)-(h+b,l+c)
3458 cal drawline ;(h-b,l-c)-(h+b,l-c)
3459 ld a,b ;swap xx and yy
3465 drawbox: ;(d,e)-(h,l)
3490 drawline: ;(d,e)-(h,l)
3591 ;-----------------------------
3592 ;----------- link ------------
3593 ;-----------------------------
3597 out (7),a ;raise both wires = link ok
3603 checklink: ;load wires in A and check for timeout
3604 dec de ;decrease timer
3607 jr nz,linkfine ;ok if de>0
3610 ld a,0 ;losses so far
3612 inc a ;and this is another one
3614 pop de ;return from link
3615 cp lossout ;quit if too many errors
3616 ret c ;otherwise just continue
3635 Qsend: ;try to send 8 bits in C; CF=error --- destr:abcde
3638 and %11 ;both wires low = exit signal
3639 jr z,linkerr ;error otherwise
3640 ld b,8 ;bits to send
3643 rl c ;bit to send in cf
3644 ld a,D0LD1H ;0: lower white
3646 ld a,D0HD1L ;1: lower red
3648 out (7),a ;lower one (send bit)
3650 cal checklink ;other calc must lower other wire
3652 ld a,D0HD1H ;raise one, ok to raise other
3656 cp %11 ;both raised (by other calc)
3659 dnz sendloop ;repeat for all bits
3661 ld (linklosses),a ;reset number of losses
3666 Crecv: ;--- receive 8 bits into A/C --- destr:abcdehl ---
3668 ret nc ;return if all went ok
3669 jr Crecv ;and try again
3671 Qrecv: ;--- receive 8 bits into A/C; CF=error --- destr:abcde ---
3674 jr z,linkerr ;both low = error, quit
3675 ld b,8 ;bits to receive
3681 jr z,recvwait ;both high = nothing sent (yet)
3682 rra ;received bit in cf
3684 jr c,received ;lower white wire as well
3685 ld a,D0HD1L ;lower red
3688 out (7),a ;both wires low
3691 jr z,recvwaitack ;same wire will be raised again by other calc
3693 out (7),a ;raise both
3695 dnz recvloop ;repeat for all bits
3697 ld (linklosses),a ;reset number of losses
3701 ;-----------------------------
3702 ;---------- levels -----------
3703 ;-----------------------------
3706 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
3707 .db 0,2,63 ;start d, y, x
3708 .db 128,57 ;field width (128-255), height (57-255)
3709 .db 0 ;no additional lines, boxes
3717 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3721 .db "Fast Fun :))",0
3723 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3724 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3730 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3735 LevelDefT: ;tron=no delay
3736 .db "Empty Tron Level",0
3738 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3739 .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
3744 .db "Round and Round",0
3746 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3747 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
3755 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3756 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
3761 ;-----------------------------
3762 ;---------- data -------------
3763 ;-----------------------------
3766 .db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000
3767 .db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000
3768 .db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000
3769 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000
3770 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000
3771 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000
3772 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000
3773 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000
3774 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000
3775 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000
3776 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000
3777 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000
3778 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011
3779 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100
3780 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101
3781 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011
3784 .db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000
3785 .db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000
3786 .db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000
3787 .db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100
3788 .db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010
3789 .db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010
3790 .db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100
3792 ;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000
3794 txtMenu: .db "Mode",0 ;1st menu item
3800 posMenu: .dw $2418,$231E,$2824,$1F2A,$1730,$1936
3801 txtMenuR: .db "controls",0
3802 txtoMenu: .db "Back",0 ;1st menu item
3808 posoMenu: .dw $2618,$251E,$2524,$222A,$1A30,$1C36
3809 txtGame: .db "Singleplayer",0
3810 txtGame1: .db "Peaworm",0
3811 txtGame2: .db "Tron",0
3812 txtGame3: .db "Deathmatch",0
3813 txtGame4: .db "Foodmatch",0
3814 txtGame5: .db "Timematch",0
3815 txtGame6: .db "Race",0
3816 txtGame7: .db "CTF" ;,0
3819 .db txtGame1-txtGame
3820 .db txtGame2-txtGame
3821 .db txtGame3-txtGame
3822 .db txtGame4-txtGame
3823 .db txtGame5-txtGame
3824 .db txtGame6-txtGame
3825 .db txtGame7-txtGame
3827 txtNone: .db "None",0
3828 txtDef: .db "Default",0
3831 txtKeyleft: .db ":left",0
3832 txtKeyright:.db "/right",0
3834 txtLevsel: .db $CF," SELECT LEVELS ",5,0
3835 txtWaiting: .db "Waiting...",0
3836 txtReceive: .db "Receiving..." ;,0
3839 .db 0, 3, 6, 9, 12, 15, 18, 21
3840 .db 24, 27, 30, 33, 36, 39, 42, 45
3841 .db 48, 51, 54, 57, 59, 62, 65, 67
3842 .db 70, 73, 75, 78, 80, 82, 85, 87
3843 .db 89, 91, 94, 96, 98,100,102,103
3844 .db 105,107,108,110,112,113,114,116
3845 .db 117,118,119,120,121,122,123,123
3846 .db 124,125,125,126,126,126,126,126
3849 txtLevel: .db "Level ",0
3850 txtWorms: .db "Worms: 0",0 ;follows txtLevel
3851 txtName: .db "Name",0
3852 txtWinner: .db "Wins " ;follows txtName
3853 txtDied: .db "Died " ;follows txtWinner
3854 txtScore: .db "Score",0 ;follows txtDied
3855 txtLeft: .db " left",0 ;follows txtScore
3856 txthiscore:.db "HiScore:",0
3858 txtReady: .db "Prepare!",0
3862 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0
3865 datalevels: .dw LevelDef, LevelDefM
3866 .dw LevelDefT,LevelDefM
3867 .dw LevelDefM,LevelDefM
3868 .dw LevelDefR,LevelDefC
3869 nrlevels: .db 1,3,1,3,3,3,3,1 ;=defaults
3871 _datalink = %0000001 ;linkplay
3872 _datafoodl = %0000010 ;left=0 limit
3873 _datasingl = %0000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel)
3874 _datamultpeas = %0001000 ;multiple peas=1
3875 _datatime = %0010000 ;time incs score (timematch)
3876 _datafood = %0100000 ;food present
3877 _datadie = %1000000 ;worm dies on impact
3878 ;reserved %10000000 ;for future use
3880 savestart: ; �game info (see above)
3881 ; | �lives (0=unlimited)
3882 ; | | �nrworms (can be altered by user)
3883 ; | | | �level (reset to 1 at startup)
3884 ; | | | | �speed/delay (-1=def)
3885 ; | | | | | �grow speed (-1=none; 0=continuous)
3886 ; | | | | | | �turn speed (8=def)
3887 ; | | | | | | | �score limit (0=none)
3888 gamesingle = 0 ;used | | | | | | | |
3889 datasingle: .db %1100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives)
3891 datapeas: .db %1100100,1,1,1,-1,-1, 8, 0 ;Peaworm (SP; 1 live)
3893 datatron: .db %1010100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
3894 gamedeathm = 3 ;used
3895 datadeathm: .db %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth)
3897 datafoodm: .db %1100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
3899 datatimem: .db %1010000,1,2,1,-1, 0, 8, 0 ;Timematch (tron, 100 score)
3901 datarace: .db %0000000,0,2,1,-1,-1, 8,10 ;Race (100 score, no collision)
3903 datactf: .db %1001000,0,4,1,-1,-1, 8,10 ;CTF (100 score)
3905 worm1set: .dw worm1p,worm1p
3906 .db %11110111,1,-01,K_RIGHT,K_LEFT
3907 worm1name: .db "WORMY ",0
3908 worm2set: .dw worm2p,worm2p
3909 .db %11111011,0,-01,K_F2,K_F1
3910 worm2name: .db "VIPER ",0
3911 worm3set: .dw worm3p,worm3p
3912 .db %11111011,1,-01,K_COMMA,K_STO
3913 worm3name: .db "NIBBLER ",0
3914 worm4set: .dw worm4p,worm4p
3915 .db %11111011,0,-01,K_PLUS,K_ENTER
3916 worm4name: .db "JIM ",0
3925 Gametype: .db 0 ;last gamemode
3939 head = 13 ;4B (head=tail)
3940 tail = 15 ;also@next level
3942 reserv = 18 ;loop (race:lap|ctf:pea)
3953 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3954 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3955 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3956 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3957 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3958 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3959 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3960 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3961 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3962 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3963 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3964 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3965 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3966 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3967 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3968 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3969 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3970 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3971 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3972 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3973 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3974 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3975 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3976 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3977 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3978 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3979 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3980 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3981 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
3982 .db " wormy@shiar.org",0
3985 defspriteimg: .db %01100000
3991 .db "Internal Levels" ;,0
3993 .db 0,deflevels/256,deflevels&255
3996 ;-----------------------------
3997 ;----------- end -------------
3998 ;-----------------------------