2 ; Version : 95% (0.95.B09)
3 ; Release Date : OOHHhhh... soon?!?
4 ; Filename : wormy.86p (5kb)
6 ; Email Address : wormy@shiar.org
7 ; Web Page : www.shiar.org
8 ; Description : ruling Nibbles-like game 1-4 players
9 ; Where to get this game : www.shiar.org (home of Wormy)
10 ; Other games by author(s) : Nemesis beta
11 ; Additional Credits to : Matthew Shepcar (wrote original Peaworm, end'98)
12 ; Jonah Cohen (helped writing worm)
14 ;-----------------------------
15 ;----------- TO-DO -----------
16 ;-----------------------------
20 ; [* internal levels ]
21 ; [ * check levels/gametype ]
22 ; [ * enough hiscore saves! ]
23 ; [* complete readme ]
24 ; 1% * misc (pollish, bugs, &&&)
25 ; 1% * long length save (level#6)
28 ; 1% * transmit game/level data
29 ; Xfirst packet loss?? or vti onlyXXXXX
30 ; X1/3 worms over linkXXXX
31 ; Xsend new peas' positionsXXXXX
33 ;100% = bugs fixed + levels done
38 ;-----------------------------
39 ;-----------------------------
40 ;------- W O R M Y ---------
41 ;-----------------------------
42 ;-----------------------------
44 #define buffer ;use display buffer (otherwise write directly to screen)
45 #define readymask ;"greys" out the field before starting a level
46 #define coolzgfx ;nice graphics for game over screen
48 ;#define readytext ;displays "prepare" before level starts
49 ;#define invincible ;worms cannot die =)
50 ;#define optdie ;in race games worms don't die when they run into each other
57 #include "ti86asm.inc"
59 _SHRACC = $4383 ;4x srl a
60 _SHLACC = $438B ;4x sll a
61 _divHLby10 = $4044 ;hl=hl/10
62 _divAby10 = $4DAF ;a=a/10
63 _HLTIMES10 = $41BF ;hl=hl*10
64 _cphlde = $403C ;cp hl,de
65 _clrWindow = $4A86 ;clear screen
66 _asapvar = $D6FC ;own name (worm)
67 _MOV4B = $429B ;4x ld (de),(hl)
68 _MOV5B = $4297 ;5x ld (de),(hl)
69 _mov9b = $4283 ;9x ld (de),(hl)
70 _ldHLind = $4010 ;ld hl,(hl)
71 _swapt_ = $45F3 ;ex_ahl_bde
72 _Get_Word_ahl = $521D ;ld de,(ahl)
73 _Set_Word_ahl = $5221 ;ld (ahl),de
74 _INC_PTR_AHL = $4637 ;ahl=ahl+1
75 _AHL_PLUS_2_PG3 = $4C3F ;ahl=ahl+2
76 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl
77 _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
78 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
79 _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl
80 _mm_ldir = $52ED ;24bit ldir
81 _MM_LDIR_SET_SIZE = $524D ;_SET_MM_NUM_BYTES + _mm_ldir
82 _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1
83 _RAM_PAGE_7 = $47F3 ;"""" 7
84 _PTEMP_END = $D29A ;end of VAT
85 _load_ram_ahl = $462F ;ahl->page+hl
86 _writeb_inc_ahl = $5567 ;ld (ahl++),c
87 _jforce = $409C ;TI-OS stack restored
88 _EXLP = $4493 ;swap (hl),(de) b times
89 _GETB_AHL = $46C3 ;a=(ahl) \ hl=ahl
91 ;-----------------------------
92 ;------- data storage -------
93 ;-----------------------------
97 ScrBuffer = $8820 ;-A7FF (20*FF=1FE0)
98 worm2p = $A800 ;-ABFF (400) %10101O00
99 worm1 = $AC00 ;-AC1D (31d)
100 worm2 = $AC1F ;-AC3B (1F)
101 worm3 = $AC3E ;-AC59 (1F)
102 worm4 = $AC5D ;-AC77 (1F)
103 balls = $AC7C ;-ACFF (3x43d)
104 SinCosTable = $AD00 ;-AE00 (4*40)
105 ;free $AE01 ;-AFFF (1FF)
106 worm1p = $B000 ;-B7FF (800) %1011O000
107 worm3p = $B800 ;-BBFF (400) %10111O00
108 ;free $BF91 ;-BFFF (6F)
109 ;program $D748 ;-EFFF (186D+4A)
110 worm4p = $F000 ;-F3FF (400) %11110O00
111 leveldata = $F400 ;-FA70 (<=671)
113 turn10 = $AE01 ; (1) (counter)
114 peaspos = $AE02 ;-AE05 (4) (peas)
116 ;MEM|8---9---A---B---C---D---E---F---|
117 ; |..[------]||[]|......[-----]|[].|
118 ; | SCREEN 2* 13 PRGM 4LV |
122 namelength = $BC00 ;(1) @menu
123 datalink = $BC00 ;(8) @init
125 DispBuffer = $BC00 ;(10x57d) @game
130 ;-----------------------------
131 ;------- program start -------
132 ;-----------------------------
148 .db "WORMY by SHIAR -- beta 95%",0
151 .db %00000000,%00111100
152 .db %00000000,%01010010
153 .db %00000000,%01100001
154 .db %01100011,%10011001
155 .db %10010100,%01101001
156 .db %10011001,%00011001
157 .db %01000010,%11000001
158 .db %00111100,%00111110
161 levelhead2 = 95 ;wormy levels header = "95"
192 ld bc,int_end-int_handler
199 ld hl,$BFFF ;VAT start
202 ld de,(_PTEMP_END+1) ;VAT end
232 ex de,hl ;ld ahl,(hl)
233 cal _AHL_PLUS_2_PG3 ;string id
234 cal _Get_Word_ahl ;ld de,(ahl)
238 jr nz,_searchnext ;not worm
242 inc ix ;save level's ahl
255 cal _Get_Word_ahl ;ld de,(ahl++)
257 ld a,e ;set new level
282 cal _vputs ;"< SELECT LEVELS >"
302 cp 49 ;bottom of screen
310 ld l,(ix+2) ;ahl=(ix)
311 cal _load_ram_ahl ;hl=ahl
315 readylevelfile: ;selected level at ahl
318 add a,3 ;sellev+3 (#0==-3)
334 cal _GETB_AHL ;ld a,(ahl)
339 cal _INC_PTR_AHL ;ahl++
341 jr nz,skiptitle ;goto #0-terminator
367 cal _load_ram_ahl ;hl=ahl
368 ld de,$FFA0 ;desc.text
373 cp d ;de>$FFFF (offscreen)
374 jr nz,levdescclearloop
378 ld ix,templevels-6 ;reset 2 1st page
380 ld b,-2 ;level selected
386 pop bc ;GET_KEY destr. b
404 or a ;levelfile on page 0 (=internal)
406 cal skiptitle ;skip description
409 ld (leveldataSize),de
414 ld (hilvlposa),a ;singleplayer levels
419 cal _SET_ABS_SRC_ADDR ;levelsstart
422 cal _SET_ABS_DEST_ADDR ;store in mem.
425 cal _MM_LDIR_SET_SIZE
427 cal _LOAD_ABS_SRC_ADDR ;->ahl
434 ldi ;(de),(hl)\inc hl
439 res 2,(iy+13) ;appAutoScroll
447 ld (hl),1 ;def=level#1
451 ;-----------------------------
452 ;----- build trig tables -----
453 ;-----------------------------
478 ;-----------------------------
479 ;---------- menu -------------
480 ;-----------------------------
482 DisplayMenu: ;---draw menu---
489 ld hl,$FC00+$010 ;(*,01)
491 ld hl,$FC00+$160 ;(*,22)
493 ld hl,$FC00+$3E0 ;(*,62)
498 dec a ;will be inced @changegame
501 ld hl,changegame ;dispmenusets ;mainMenu
502 psh hl ;jump here after ret
505 ;Mode|Level|Limit|Worms|worm #|controls
506 ; jr dispmenucommon ;cal
509 ld de,$FD80 ;begin pos
533 hr: ;draw horizontal line at hl
542 ;Back|Lives|Limit|Speed|Rotation|Growth
557 inc hl \ inc hl \ inc hl
575 inc a ;-1=None; 0..98->1..99
590 cal cshowA0 ;turn speed
597 ld a,(hl) ;(scorelimit)
602 jr z,optionMenu ;do not display 0 behind 'None'
614 jp z,dispmainmenu ;mainMenu
658 cal loadgamecar ;a=(hl)
661 jr nc,optionMenu ;>99
665 jp dispomenusets ;optionMenu
668 sub 1 ;dec does not set cf
676 jr nc,optionMenu ;>99
679 jr _dispomenusets ;optionMenu
682 sub 1 ;dec does not set cf
689 ld a,(hl) ;(scorelimit)
696 jr nc,_optionMenu ;>98
700 jr _dispomenusets ;optionMenu
706 jr z,_optionMenu ;<-1
713 inc hl ;=saves 2 bytes :P
722 jr nc,_optionMenu ;>25
725 jr _dispomenusets ;optionMenu
740 jr nc,_optionMenu ;>98
743 jr _dispomenusets ;optionMenu
749 jr z,__optionMenu ;<-1
761 dec a ;2nd item: level
763 sub 3 ;5th item: wormname
767 jp LetsGetThisPartyOn ;otherwise
798 jr nc,mainMenu ;may not become >(nrworms)
802 jr _dispmenusets ;mainMenu
815 ; jr z,bchangecurworm
820 jr nz,changedcurworm ;save >0
825 ld a,(hl) ;hl=nrworms
828 jr nc,mainMenu ;may not be >4
831 jr _dispmenusets ;mainMenu
835 ld a,(hl) ;hl=nrworms
839 ld a,(hl) ;hl=nrworms
842 jr nc,changednrworms ;save >=2
851 jr _mainMenu ;don't change for singleplayer
856 dec hl ;inced earlier
858 ld a,1 ;change LS-bit (=link)
862 jr dispmenusets ;mainMenu
869 jr dispmenusets ;mainMenu
882 jr dispmenusets ;mainMenu
885 inc hl ;hl=loadgamecar+2
887 ld a,(hl) ;(curlevel)
889 cp (hl) ;max level for sel.game
895 jr dispmenusets ;mainMenu
898 ld a,(hl) ;(curlevel)
903 getnrlevels: ;for current gametype at hl
930 cal getcustomkey ;left
931 cal getcustomkey ;right
934 ;---display current settings---
944 add hl,de ;hl=posGame+(Gametype)
945 ld a,(hl) ;str.offset
949 ld (CURtxtGame),hl ;save for g/o
950 cal _vputs ;Singleplayer
999 ld hl,$363E ;controls
1005 ;--- handle menukeys ---
1013 pop bc ;GET_KEY destr. b
1023 menupos: ;highlight #b
1036 add hl,hl ;$FD20+item*96
1066 ;--- change name ---
1069 getwormname: ;of (curworm)
1097 ld hl,$FF07 ;begin pos
1130 dec (hl) ;(namelength)
1145 .db 0,".<>!",0,0,0,0 ;down,L,R,up
1146 .db 0,"XTOJE0",0 ;enter..clear
1147 .db " WSNID9",0 ;(-)..custom
1148 .db "ZVRMHC8",0 ;dot..del
1149 .db "YUQLGB7#" ;0..xvar
1150 .db $D9,"-PKFA6'" ;on..alpha
1151 .db "54321*",0,$D0 ;F5..more
1155 ld (ix+8),0 ;end mark
1158 ;-----------------------------
1159 ;------- procs-n-stuff -------
1160 ;-----------------------------
1164 halt ;save them batteries! yeah!
1168 ld hl,$FD97 ;begin pos
1169 ld a,35 ;nr of lines
1171 ld de,7 ;bytes to add
1173 ld c,9 ;bytes to clear
1178 jr nz,clroldsetsloop
1181 jr nz,clroldsettings
1184 hlatlevel: ;d must be 0
1186 ld a,(Gametype) ;8bytes -> 7bytes
1191 add a,24+1 ;go to datalevels
1193 sbc hl,de ;datalevels
1194 cal _ldHLind ;ld hl,(hl)
1195 pop de ;de=loadgamecar
1197 ld a,(de) ;(curlevel)
1201 dec d ;levels to skip
1205 ret ;hl=begin of correct level
1207 skiplvltitle: ;zf=singleplayer
1209 or a ;null-terminator
1214 skiplevel: ;@hl - destr:ab - alter:hl
1223 ld b,(hl) ;spritesize
1231 pop af ;cp (Gametype),0
1233 inc b ;multiplayer lvl
1235 inc b ;skip other 3 worms (9 bytes)
1269 ;build: c=(gameCar)=(hl-1)
1270 ; a=(wormbeglives)=(hl)
1276 add a,a ;8 bytes per mode
1288 ;-----------------------------
1289 ;-------- start game ---------
1290 ;-----------------------------
1294 ld (CheckExit),a ;set exit state
1299 ex (sp),hl ;pop \ psh leveldata
1300 psh hl ;psh loadgamecar
1304 jp nc,StartLevel ;&&&jr
1306 ;--------- link ------------
1321 jp DisplayMenu ;return to menu
1331 ;name/keys: wormy#1 = link = 0 + link (name1)
1332 ; 2 = worm #1 = #1 + local(name1)
1333 ; 3 = link = 0 + link (name2)
1334 ; 4 = worm #2 = #2 + local(name2)
1337 ldi ;keys worm#2 = worm#1
1340 ldi ;keys worm#4 = worm#2
1343 ld (worm1+left),a ;worm 1...
1344 ld (worm3+left),a ;and worm 3 via link
1384 ;name/keys: wormy#1 = worm #1 = ok
1385 ; 2 = link = 0 + link (name1)
1386 ; 3 = worm #2 = #2 + local(name2)
1387 ; 4 = link = 0 + link (name2)
1390 ldi ;keys worm#3 = worm#2
1393 ld (worm2+left),a ;worm 2+4..
1394 ld (worm4+left),a ;..over link
1413 ;-------- load level ---------
1432 ld (turnright),a ;more efficient
1436 cal _HLTIMES10 ;hl=10*(hl)
1442 ld a,4 ;4x (all worms)
1452 ld (hl),b ;score+1=0
1459 ex de,hl ;de=wormX+head
1463 jr nz,createwormsloop
1467 pop hl ;begin of current level
1474 dec (hl) ;curlevel-- (not beyond last lvl)
1477 ;show end msg or smtn
1479 psh bc ;where to go afterwards
1480 inc hl ;location of ending-code
1481 jp (hl) ;go there ("call")
1494 ld a,(hl) ;speed from level
1498 ld (de),a ;custom speed
1517 ld b,0 ;bc=sprite size
1518 add hl,bc ;hl=behind sprite
1525 setsprite: ;de=@sprite ;a=sprsize
1549 pop af ;cp (Gametype),0
1557 ld a,SinCosTable/256
1568 ld bc,(worm2-worm1)-5
1578 ;-------- draw level ---------
1605 add hl,hl ;32=scr.width
1612 ld bc,63 ;first 2 rows
1614 ldir ;draw upper border
1616 ld (hl),%11000000 ;first left border
1621 inc hl ;clear rest of line
1661 cp gamerace ;or gamectf
1662 jr c,levelhasbeensetup
1664 ld c,2 ;ld bc,2 (2 bytes)
1665 jr z,loadextralevelstuff ;cp gamerace
1666 ld c,4 ;ld bc,4 (2nd flag in ctf)
1667 loadextralevelstuff:
1676 ;--------- prepare -----------
1679 psh hl ; >> levelp new
1706 ld hl,4+(txtposReady*256)
1729 ;-----------------------------
1730 ;----------- LOOP ------------
1731 ;-----------------------------
1734 ld bc,(worm1+pos) ;camera worm #1
1736 or a ;if #1 not over link
1738 ld bc,(worm2+pos) ;otherwise view from #2
1740 cal DisplayField ;display piece of level
1755 jr nz,screeninvertloop
1768 ld (handledworm),a ;reset
1786 jr nz,nodispupdate ;just once every 10 turns
1787 ld (hl),10 ;reset counter
1788 cal forceshowstats ;update score
1793 jr nz,noctfpeas2draw
1796 cal tryDrawPea ;pea#1
1799 cal tryDrawPea ;pea#2
1806 cal nz,handlethoseneatlittleballs
1819 inc (hl) ;0..nrworms-1
1822 ;-----------------------------
1823 ;---------- keys -------------
1824 ;-----------------------------
1839 rla ;=$17 (c=EXIT-key)
1850 ld (ix+delay),respawndelay
1869 ld (ix+pos2+1),a ;x2
1876 cp gamectf ;ctf no death penalty
1879 ret nz ;HandleWorm done
1881 or a ;0=no live limit
1882 ret z ;don't end game
1885 jr z,anyworm ;quit at any worm's death
1886 ld a,(nrworms) ;timematch: all worms must've died
1888 ld hl,worm1+lives-(worm2-worm1)
1890 xor a ;check for 0 lives
1892 add hl,de ;next worm
1894 ret nz ;any >0: don't exit
1897 ld a,$A7 ;exit@end of turn
1898 ld (CheckExit),a ;set exit state
1907 out (7),a ;both wires low = game over signal
1916 cal menuinvloop ;invert
1918 cal hr ;menuinvloop w/ b=16
1928 cal menuinvloop ;invert
1930 cal hr ;menuinvloop w/ b=16
1949 cal _vputs ;Died Score
1964 jr c,nonewwinner ;h<d
1965 jr nz,newwinner ;h>d
1968 jr nc,nonewwinner ;l<e
1979 cpl ;high value (>$FB)
1984 ld a,(hl) ;less deaths
1991 ;---display worms---
2003 cp (hl) ;input=0 = link
2020 ld a,(hl) ;worm+died
2027 jr nz,nodmwinner ;deathmatch?
2028 ld a,0 ;winner's deaths
2030 cp (hl) ;equals this worm?
2031 scf ;jr nz,notwinner
2034 jr c,notwinner ;no singleplayer winners
2036 cal _ldHLind ;ld hl,(hl)
2039 cal _cphlde ;==highest score..
2054 dnz displayWormStats
2057 or a ;singleplayer (0) only
2058 jr nz,hilevelcheckdone
2063 jr c,hilevelcheckdone
2064 ld (hl),a ;save local
2069 hilvlposhl =$-2 ;save external
2070 cal _writeb_inc_ahl ;ld (ahl),c
2075 jr z,hiscorecheckdone ;no SP
2077 cal loadhiscoreposinahl
2078 cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile)
2081 cal _SET_ABS_DEST_ADDR ;to local
2083 cal _MM_LDIR_SET_SIZE ;get old score+name
2086 ld de,(highsave) ;de=prev. hiscore
2087 ld hl,(worm1+score) ;hl=worm1's score
2088 cal _cphlde ;sub hl,de
2089 jr c,NotNewHigh ;new<old
2090 jr z,NotNewHigh ;new<=old
2092 ld (highsave),hl ;store new hiscore
2093 ld de,highsave+2 ;to
2094 ld hl,worm1+name ;from
2096 ldir ;store new hiname
2097 cal loadhiscoreposinahl
2098 cal _SET_ABS_DEST_ADDR ;to ahl
2101 cal _SET_ABS_SRC_ADDR ;from local
2103 cal _MM_LDIR_SET_SIZE ;save new
2131 ;x123456789012345678901
2132 ;>>>>>> GAME OVER <<<<<
2137 ;6Worm#02 @ 05 00120
2144 rst 20h ;_ABS_MOV10TOOP1
2146 ld hl,savestart-_asm_exec_ram+4
2150 cal _SET_ABS_DEST_ADDR
2154 cal _SET_ABS_SRC_ADDR
2155 ld hl,saveend-savestart
2156 cal _MM_LDIR_SET_SIZE
2164 loadhiscoreposinahl:
2165 ld hl,0 ;for peaworm and singleplayer
2171 ld a,(nrlevels+1) ;skip peaworm slots if tron mode
2175 ld b,a ;levels to skip (including 1 for singleplayer)
2176 ld de,5 ;to add per level
2178 add hl,de ;one word+3 bytes for name
2179 dnz addlevelposition
2186 adc a,0 ;ahl=saveloc
2195 jp _putc ;..then put *
2197 ;-----------------------------
2198 ;----------- worm ------------
2199 ;-----------------------------
2204 cal saverespawncounter
2210 jr DoesWormTailEqualsWormHead ;chk4 size=0
2221 DoesWormTailEqualsWormHead:
2223 jr nz,removewormloop
2227 jr nz,safewormsizedone
2235 ld (ix+tail),e ;head=tail/size=0
2241 jr nz,saverespawncounter
2265 ld a,%01111111 ;default
2268 dnz bitmask ;a/8 times
2269 out (1),a ;send bitmask
2270 in a,(1) ;input keys
2275 dnz keybit ;check match (cf set)
2278 inkeys: ;use jp not call!
2297 jr z,inlink ;input by link
2298 cal inkeys ;input by keys
2302 ld c,l ;send our keys
2309 ;-----------------------------
2310 ;------- handle worm ---------
2311 ;-----------------------------
2362 ;-------- move worm ----------
2390 notmoveY: ;bc=newpos
2397 pop hl ; << pos (old)
2415 ;--------- worm hit ----------
2422 cal z,checkhitotherworm
2425 and _datamultpeas ;&&bit
2429 jp z,WormDead ;no food
2436 cal DrawPea ;remove pea
2448 jp nz,Drawworm ;continue
2454 jp nz,Exit ;stack restored
2465 cal _IncScore ;score+(40*level)
2472 chkpeahit: ;bc=ownpos;hl=peapos (destr:ad)
2488 ld hl,(peaspos) ;1st pea
2491 and %01 ;ourpea (0|1)
2493 ld hl,(peaspos+2) ;2nd pea ;&&&ex de,hl?
2498 ld a,e ;peek a (that's x86asm for pop\push ;)
2499 bit 1,a ;%10 = carrying flag?
2500 jp z,WormDead ;if not just die
2505 pop af ;which flag? (=and %1)
2506 ld hl,drawctfpea1 ;restore #1
2507 jr z,nottheotherflag
2508 ld hl,drawctfpea2 ;restore #2
2510 ld (hl),3 ;draw delay 3 turns
2516 hitflag: ;correct pea hit
2518 xor %11 ;invert flag taken + ownflag
2520 and %10 ;just returned?
2524 jr nz,Drawworm ;flag taken, continue game
2526 ld e,20 ;flag captured+returned
2530 ld (drawctfpea1),a ;redraw..
2531 ld (drawctfpea2),a ;..both flags
2534 ;-----------------------------
2553 jr nz,nextotherwormbit
2563 ld a,(peaspos+1) ;yline
2566 jr nc,checklap ;y>yline -> a=1
2567 xor a ;y<yline -> a=0
2570 ret z ;same as before
2571 ld (ix+reserv),a ;1st time
2574 and 1 ;group 0 (1,3) or 1 (2,4)
2576 ret z ;(group 0 and y<yline) or (group 1 and y>yline)
2585 .db $dd,$7d ;ld a,lx
2588 jr nz,chkworm2 ; ret nz
2614 ;-------- draw worm ----------
2622 cal z,checkhitlapline
2628 ret z ;keep tail in "Tron"
2671 ;-----------------------------
2672 ;---------- ball -------------
2673 ;-----------------------------
2675 handlethoseneatlittleballs:
2721 bit 1,d ;1=up; 0=down
2751 letsmovetheotherway:
2766 ;-----------------------------
2767 ;----------- procs -----------
2768 ;-----------------------------
2772 ld a,%10000000 ;all key-masks
2775 inc a ;cp %11111111 (no keys pressed)
2776 jr nz,releasekeys ;keep waitin
2777 cal GET_KEY ;clear buffer
2799 CheckPea: ;@hl; destr:abcde
2812 ret nz ;nz=pixel found
2821 tryDrawPea: ;hl=peapos;bc=dopea
2830 dec (hl) ;hl=appeartime
2831 ex de,hl ;hl=peaspos
2841 jr z,receivenewpeaoverlink
2842 ld c,l ;send pea's pos
2845 jp Qsend ;&&&possible jr
2846 receivenewpeaoverlink:
2864 cal sendnewpeaoverlink
2873 PutSprite: ;||@(b,c)
2874 ;by SHIAR only ix saved
2911 ;----------- score -----------
2914 ;piece of crap checking whether you've already won in timematch
2926 jr z,nneexxtt ;yourself
2928 ret nz ;someone else still alive
2933 jr c,nneexxtt_ ;you>him
2946 dnz chktimematchover
2962 add hl,de ;increase score
2965 jr z,scorecommon ;hl/1000 not increased
2974 jr c,showstats ;<0=0
2977 IncScore: ;inc score by e
2979 _IncScore ; inc by de
2983 or a ;if singleplayer...
2985 add hl,de ;score+=de
2988 ld (ix+score),l ;save
2993 jr z,showstats ;de=0=no limit
3000 jr nz,timematchscore ;no disp for timematches
3001 ld hl,$FC00 ;&&&only necessary in deathmatch
3023 shownameloop: ;1st 3 chars
3052 showstat: ;(multiplayer)
3063 showA: ;small w/o leading 0 (&&&combine w/ cshowA0??)
3082 showstatsS: ;(singleplayer)
3117 showA0: ;big w/ leading 0
3129 cshowA0: ;small w/ leading 0
3164 ;-----------------------------
3282 ld (ShiftRightCounter),a
3284 ld (ShiftRightChunk),a
3298 ShiftRightCounter = $-1
3320 ld (ShiftLeftCounter),a
3322 ld (ShiftLeftChunk),a
3324 jr nc,ShiftLeftSameByte
3343 ShiftLeftCounter = $-1
3354 jr nz,ShiftRowsRight
3388 ;----------- draw ------------
3402 CheckPixel: ;at bc in d
3409 ;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes)
3410 ;(b,c) to hl:a; "destroyes" ahl
3412 FindPixel: ;(b,c) to hl:a
3475 drawcircle: ;(d,e),h ;de=x,y; h=z
3486 ex (sp),hl ;push zz \ pop x,y
3487 cal circledraw ;(x-xx,y+yy)-(x+xx,y+yy)
3488 ;(x-xx,y-yy)-(x+xx,y-yy)
3489 cal circledraw ;(x-yy,y+xx)-(x+yy,y+xx)
3490 ;(x-yy,y-xx)-(x+yy,y-xx)
3492 ex (sp),hl ;push x,y \ pop zz
3495 dec a ;-256<h<0 = $FF**
3497 jr z,circlenext ;jump if zz<0
3501 add a,a ;a=2yy-2 ;nc
3503 sbc hl,de ;zz=zz-2yy+2
3511 add hl,de ;zz=zz+2xx+3
3520 circledraw: ;destr:de
3525 add hl,bc ;h=x+xx; l=y+yy
3527 cal drawline ;(h-b,l+c)-(h+b,l+c)
3533 cal drawline ;(h-b,l-c)-(h+b,l-c)
3534 ld a,b ;swap xx and yy
3540 drawbox: ;(d,e)-(h,l)
3565 drawline: ;(d,e)-(h,l)
3666 ;..and last but not least..:
3667 ;-----------------------------
3668 ;----------- link ------------
3669 ;-----------------------------
3676 out (7),a ;raise both wires = link ok
3679 checklink: ;load wires in A and check for timeout
3680 dec de ;decrease timer
3683 jr z,linktimeout ;timeout if de==0
3686 out (1),a ;select keys
3696 ld a,0 ;losses so far
3698 inc a ;and this is another one
3700 pop de ;return from link
3701 cp lossout ;quit if too many errors
3702 ret c ;otherwise just continue
3708 Qsend: ;--- try to send 8 bits in C; CF=error --- destr:abcde ---
3711 jr z,linkerr ;both wires low = exit signal
3712 ld b,8 ;bits to send
3715 rl c ;bit to send in cf
3716 ld a,D0LD1H ;0: lower white
3718 ld a,D0HD1L ;1: lower red
3720 out (7),a ;lower one (send bit)
3722 cal checklink ;other calc must lower other wire
3724 cal linkok ;raise one, ok to raise other (out (7),D0HD1H)
3727 cp %11 ;both raised (by other calc)
3730 dnz sendloop ;repeat for all bits
3732 ld (linklosses),a ;reset number of losses
3737 Crecv: ;--- receive 8 bits into A/C --- destr:abCde ---
3739 ret nc ;return if all went ok
3740 jr Crecv ;and try again
3742 Qrecv: ;--- receive 8 bits into A/C; CF=error --- destr:abCde ---
3744 jr z,linkerr ;both low = error, quit
3745 ld b,8 ;bits to receive
3749 cal linktest ;checklink
3751 jr z,recvwait ;both high = nothing sent (yet)
3753 rra ;received bit in cf
3755 jr c,received ;lower white wire as well
3756 ld a,D0HD1L ;lower red
3759 out (7),a ;both wires low
3762 jr z,recvwaitack ;same wire will be raised again by other calc
3763 cal linkok ;raise both
3765 dnz recvloop ;repeat for all bits
3767 ld (linklosses),a ;reset number of losses
3771 ;-----------------------------
3772 ;---------- levels -----------
3773 ;-----------------------------
3777 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
3778 .db 0,2,63 ;start d, y, x
3779 .db 128,57 ;field width (128-255), height (57-255)
3780 .db 0 ;no additional lines, boxes
3788 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3792 .db "Fast Fun :))",0
3794 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3795 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3801 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3806 LevelDefT: ;tron=no delay
3807 .db "Empty Tron Level",0
3809 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3810 .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
3815 .db "Round and Round",0
3817 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3818 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
3826 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3827 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
3832 ;-----------------------------
3833 ;---------- data -------------
3834 ;-----------------------------
3837 .db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000
3838 .db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000
3839 .db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000
3840 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000
3841 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000
3842 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000
3843 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000
3844 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000
3845 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000
3846 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000
3847 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000
3848 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000
3849 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011
3850 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100
3851 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101
3852 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011
3855 .db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000
3856 .db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000
3857 .db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000
3858 .db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100
3859 .db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010
3860 .db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010
3861 .db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100
3863 ;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000
3865 txtMenu: .db "Mode",0 ;1st menu item
3871 posMenu: .dw $2418,$231E,$2824,$1F2A,$1730,$1936
3872 txtMenuR: .db "controls",0
3873 txtoMenu: .db "Back",0 ;1st menu item
3879 posoMenu: .dw $2618,$251E,$2524,$222A,$1A30,$1C36
3880 txtGame: .db "Singleplayer",0
3881 txtGame1: .db "Peaworm",0
3882 txtGame2: .db "Tron",0
3883 txtGame3: .db "Deathmatch",0
3884 txtGame4: .db "Foodmatch",0
3885 txtGame5: .db "Timematch",0
3886 txtGame6: .db "Race",0
3887 txtGame7: .db "CTF" ;,0
3890 .db txtGame1-txtGame
3891 .db txtGame2-txtGame
3892 .db txtGame3-txtGame
3893 .db txtGame4-txtGame
3894 .db txtGame5-txtGame
3895 .db txtGame6-txtGame
3896 .db txtGame7-txtGame
3898 txtNone: .db "None",0
3899 txtDef: .db "Default",0
3902 txtKeyleft: .db ":left",0
3903 txtKeyright:.db "/right",0
3905 txtLevsel: .db $CF," SELECT LEVELS ",5,0
3906 txtWaiting: .db "Waiting...",0
3907 txtReceive: .db "Receiving..." ;,0
3910 .db 0, 3, 6, 9, 12, 15, 18, 21
3911 .db 24, 27, 30, 33, 36, 39, 42, 45
3912 .db 48, 51, 54, 57, 59, 62, 65, 67
3913 .db 70, 73, 75, 78, 80, 82, 85, 87
3914 .db 89, 91, 94, 96, 98,100,102,103
3915 .db 105,107,108,110,112,113,114,116
3916 .db 117,118,119,120,121,122,123,123
3917 .db 124,125,125,126,126,126,126,126
3920 txtLevel: .db "Level ",0
3921 txtWorms: .db "Worms: 0",0 ;follows txtLevel
3922 txtName: .db "Name",0
3923 txtWinner: .db "Wins " ;follows txtName
3924 txtDied: .db "Died " ;follows txtWinner
3925 txtScore: .db "Score",0 ;follows txtDied
3926 txtLeft: .db " left",0 ;follows txtScore
3927 txthiscore:.db "HiScore:",0
3929 txtReady: .db "Prepare!",0
3933 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0
3936 datalevels: .dw LevelDef, LevelDefM
3937 .dw LevelDefT,LevelDefM
3938 .dw LevelDefM,LevelDefM
3939 .dw LevelDefR,LevelDefC
3940 nrlevels: .db 0,3,1,3,3,3,3,1 ;=defaults
3942 _datalink = %0000001 ;linkplay
3943 _datafoodl = %0000010 ;left=0 limit
3944 _datasingl = %0000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel)
3945 _datamultpeas = %0001000 ;multiple peas=1
3946 _datatime = %0010000 ;time incs score (timematch)
3947 _datafood = %0100000 ;food present
3948 _datadie = %1000000 ;worm dies on impact
3949 ;reserved %10000000 ;for future use
3951 savestart: ; �game info (see above)
3952 ; | �lives (0=unlimited)
3953 ; | | �nrworms (can be altered by user)
3954 ; | | | �level (reset to 1 at startup)
3955 ; | | | | �speed/delay (-1=def)
3956 ; | | | | | �grow speed (-1=none; 0=continuous)
3957 ; | | | | | | �turn speed (8=def)
3958 ; | | | | | | | �score limit (0=none)
3959 gamesingle = 0 ;used | | | | | | | |
3960 datasingle: .db %1100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives)
3962 datapeas: .db %1100100,1,1,1,-1,-1, 8, 0 ;Peaworm (SP; 1 live)
3964 datatron: .db %1010100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
3965 gamedeathm = 3 ;used
3966 datadeathm: .db %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth)
3968 datafoodm: .db %1100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
3970 datatimem: .db %1010000,1,2,1,-1, 0, 8, 0 ;Timematch (tron, 100 score)
3972 datarace: .db %0000000,0,2,1,-1,-1, 8,10 ;Race (100 score, no collision)
3974 datactf: .db %1001000,0,4,1,-1,-1, 8,10 ;CTF (100 score)
3976 worm1set: .dw worm1p,worm1p
3977 .db %11110111,1,-01,K_RIGHT,K_LEFT
3978 worm1name: .db "WORMY ",0
3979 worm2set: .dw worm2p,worm2p
3980 .db %11111011,0,-01,K_F2,K_F1
3981 worm2name: .db "VIPER ",0
3982 worm3set: .dw worm3p,worm3p
3983 .db %11111011,1,-01,K_COMMA,K_STO
3984 worm3name: .db "NIBBLER ",0
3985 worm4set: .dw worm4p,worm4p
3986 .db %11111011,0,-01,K_PLUS,K_ENTER
3987 worm4name: .db "JIM ",0
3996 Gametype: .db 0 ;last gamemode
4010 head = 13 ;4B (head=tail)
4011 tail = 15 ;also@next level
4013 reserv = 18 ;loop (race:lap|ctf:pea)
4014 input = 19 ;---currently unused afaik---
4024 ;bla space (reserved for internal levels)
4025 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4026 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4027 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4028 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4029 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4030 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4031 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4032 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4033 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4034 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4035 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4036 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4037 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4038 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4039 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4040 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4041 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4042 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4043 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4044 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4045 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4046 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4047 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4048 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4049 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4050 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4051 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4052 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4053 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4054 .db " wormy@shiar.org",0
4057 defspriteimg: .db %01100000
4063 .db "Internal Levels",0
4064 .db "by SHIAR -- still t"
4065 .db "o be added...." ;,0
4067 .db 0,deflevels/256,deflevels&255
4070 ;-----------------------------
4071 ;----------- end -------------
4072 ;-----------------------------