2 ; Version : 96% (0.96.C14)
3 ; Release Date : UUHHhhh... 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 -- 96% C14",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
511 ld de,$FD80 ;begin pos
536 ;hr: ;draw horizontal line at hl
553 ;Back|Lives|Limit|Speed|Rotation|Growth
568 inc hl \ inc hl \ inc hl
586 inc a ;-1=None; 0..98->1..99
601 cal cshowA0 ;turn speed
608 ld a,(hl) ;(scorelimit)
613 jr z,optionMenu ;do not display 0 behind 'None'
625 jp z,dispmainmenu ;mainMenu
669 cal loadgamecar ;a=(hl)
672 jr nc,optionMenu ;>99
676 jp dispomenusets ;optionMenu
679 sub 1 ;dec does not set cf
687 jr nc,optionMenu ;>99
690 jr _dispomenusets ;optionMenu
693 sub 1 ;dec does not set cf
700 ld a,(hl) ;(scorelimit)
707 jr nc,_optionMenu ;>98
711 jr _dispomenusets ;optionMenu
717 jr z,_optionMenu ;<-1
724 inc hl ;=saves 2 bytes :P
733 jr nc,_optionMenu ;>25
736 jr _dispomenusets ;optionMenu
751 jr nc,_optionMenu ;>98
754 jr _dispomenusets ;optionMenu
760 jr z,__optionMenu ;<-1
772 dec a ;2nd item: level
774 sub 3 ;5th item: wormname
778 jp LetsGetThisPartyOn ;otherwise
809 jr nc,mainMenu ;may not become >(nrworms)
813 jr _dispmenusets ;mainMenu
826 ; jr z,bchangecurworm
831 jr nz,changedcurworm ;save >0
836 ld a,(hl) ;hl=nrworms
839 jr nc,mainMenu ;may not be >4
842 jr _dispmenusets ;mainMenu
846 ld a,(hl) ;hl=nrworms
850 ld a,(hl) ;hl=nrworms
853 jr nc,changednrworms ;save >=2
862 jr _mainMenu ;don't change for singleplayer
867 dec hl ;inced earlier
869 ld a,1 ;change LS-bit (=link)
873 jr dispmenusets ;mainMenu
880 jr dispmenusets ;mainMenu
893 jr dispmenusets ;mainMenu
896 inc hl ;hl=loadgamecar+2
898 ld a,(hl) ;(curlevel)
900 cp (hl) ;max level for sel.game
906 jr dispmenusets ;mainMenu
909 ld a,(hl) ;(curlevel)
914 getnrlevels: ;for current gametype at hl
941 cal getcustomkey ;left
942 cal getcustomkey ;right
945 ;---display current settings---
955 add hl,de ;hl=posGame+(Gametype)
956 ld a,(hl) ;str.offset
960 ld (CURtxtGame),hl ;save for g/o
961 cal _vputs ;Singleplayer
1010 ld hl,$363E ;controls
1016 ;--- handle menukeys ---
1024 pop bc ;GET_KEY destr. b
1034 menupos: ;highlight #b
1047 add hl,hl ;$FD20+item*96
1077 ;--- change name ---
1080 getwormname: ;of (curworm)
1108 ld hl,$FF07 ;begin pos
1141 dec (hl) ;(namelength)
1156 .db 0,".<>!",0,0,0,0 ;down,L,R,up
1157 .db 0,"XTOJE0",0 ;enter..clear
1158 .db " WSNID9",0 ;(-)..custom
1159 .db "ZVRMHC8",0 ;dot..del
1160 .db "YUQLGB7#" ;0..xvar
1161 .db $D9,"-PKFA6'" ;on..alpha
1162 .db "54321*",0,$D0 ;F5..more
1166 ld (ix+8),0 ;end mark
1169 ;-----------------------------
1170 ;------- procs-n-stuff -------
1171 ;-----------------------------
1175 halt ;save them batteries! yeah!
1179 ld hl,$FD97 ;begin pos
1180 ld a,35 ;nr of lines
1182 ld de,7 ;bytes to add
1184 ld c,9 ;bytes to clear
1189 jr nz,clroldsetsloop
1192 jr nz,clroldsettings
1195 hlatlevel: ;d must be 0
1197 ld a,(Gametype) ;8bytes -> 7bytes
1202 add a,24+1 ;go to datalevels
1204 sbc hl,de ;datalevels
1205 cal _ldHLind ;ld hl,(hl)
1206 pop de ;de=loadgamecar
1208 ld a,(de) ;(curlevel)
1212 dec d ;levels to skip
1216 ret ;hl=begin of correct level
1218 skiplvltitle: ;zf=singleplayer
1220 or a ;null-terminator
1225 skiplevel: ;@hl - destr:ab - alter:hl
1234 ld b,(hl) ;spritesize
1242 pop af ;cp (Gametype),0
1244 inc b ;multiplayer lvl
1246 inc b ;skip other 3 worms (9 bytes)
1280 ;build: c=(gameCar)=(hl-1)
1281 ; a=(wormbeglives)=(hl)
1287 add a,a ;8 bytes per mode
1299 ;-----------------------------
1300 ;-------- start game ---------
1301 ;-----------------------------
1305 ld (CheckExit),a ;set exit state
1310 ex (sp),hl ;pop \ psh leveldata
1311 psh hl ;psh loadgamecar
1315 jp nc,StartLevel ;&&&jr
1317 ;--------- link ------------
1332 jp DisplayMenu ;return to menu
1342 ;name/keys: wormy#1 = link = 0 + link (name1)
1343 ; 2 = worm #1 = #1 + local(name1)
1344 ; 3 = link = 0 + link (name2)
1345 ; 4 = worm #2 = #2 + local(name2)
1348 ldi ;keys worm#2 = worm#1
1351 ldi ;keys worm#4 = worm#2
1354 ld (worm1+left),a ;worm 1...
1355 ld (worm3+left),a ;and worm 3 via link
1395 ;name/keys: wormy#1 = worm #1 = ok
1396 ; 2 = link = 0 + link (name1)
1397 ; 3 = worm #2 = #2 + local(name2)
1398 ; 4 = link = 0 + link (name2)
1401 ldi ;keys worm#3 = worm#2
1404 ld (worm2+left),a ;worm 2+4..
1405 ld (worm4+left),a ;..over link
1424 ;-------- load level ---------
1443 ld (turnright),a ;more efficient
1447 cal _HLTIMES10 ;hl=10*(hl)
1453 ld a,4 ;4x (all worms)
1463 ld (hl),b ;score+1=0
1470 ex de,hl ;de=wormX+head
1474 jr nz,createwormsloop
1478 pop hl ;begin of current level
1485 dec (hl) ;curlevel-- (not beyond last lvl)
1488 ;show end msg or smtn
1490 psh bc ;where to go afterwards
1491 inc hl ;location of ending-code
1492 jp (hl) ;go there ("call")
1505 ld a,(hl) ;speed from level
1509 ld (de),a ;custom speed
1528 ld b,0 ;bc=sprite size
1529 add hl,bc ;hl=behind sprite
1536 setsprite: ;de=@sprite ;a=sprsize
1560 pop af ;cp (Gametype),0
1568 ld a,SinCosTable/256
1579 ld bc,(worm2-worm1)-5
1589 ;-------- draw level ---------
1616 add hl,hl ;32=scr.width
1623 ld bc,63 ;first 2 rows
1625 ldir ;draw upper border
1627 ld (hl),%11000000 ;first left border
1632 inc hl ;clear rest of line
1672 cp gamerace ;or gamectf
1673 jr c,levelhasbeensetup
1675 ld c,2 ;ld bc,2 (2 bytes)
1676 jr z,loadextralevelstuff ;cp gamerace
1677 ld c,4 ;ld bc,4 (2nd flag in ctf)
1678 loadextralevelstuff:
1687 ;--------- prepare -----------
1690 psh hl ; >> levelp new
1717 ld hl,4+(txtposReady*256)
1740 ;-----------------------------
1741 ;----------- LOOP ------------
1742 ;-----------------------------
1745 ld bc,(worm1+pos) ;camera worm #1
1747 or a ;if #1 not over link
1749 ld bc,(worm2+pos) ;otherwise view from #2
1751 cal DisplayField ;display piece of level
1766 jr nz,screeninvertloop
1779 ld (handledworm),a ;reset
1797 jr nz,nodispupdate ;just once every 10 turns
1798 ld (hl),10 ;reset counter
1799 cal forceshowstats ;update score
1804 jr nz,noctfpeas2draw
1807 cal tryDrawPea ;pea#1
1810 cal tryDrawPea ;pea#2
1817 cal nz,handlethoseneatlittleballs
1830 inc (hl) ;0..nrworms-1
1833 ;-----------------------------
1834 ;---------- keys -------------
1835 ;-----------------------------
1844 rla ;=$17 (c=EXIT-key)
1849 ;------- pause menu -------
1854 ;Resume|Turn Off|Contrast|Exit||
1857 ld hl,$FC00+$170 ;(*,23)
1859 ld hl,$FC00+$310 ;(*,49)
1935 out (7),a ;both wires low = game over signal
1944 cal menuinvloop ;invert
1946 cal hr ;menuinvloop w/ b=16
1956 cal menuinvloop ;invert
1958 cal hr ;menuinvloop w/ b=16
1977 cal _vputs ;Died Score
1992 jr c,nonewwinner ;h<d
1993 jr nz,newwinner ;h>d
1996 jr nc,nonewwinner ;l<e
2007 cpl ;high value (>$FB)
2012 ld a,(hl) ;less deaths
2019 ;---display worms---
2031 cp (hl) ;input=0 = link
2048 ld a,(hl) ;worm+died
2055 jr nz,nodmwinner ;deathmatch?
2056 ld a,0 ;winner's deaths
2058 cp (hl) ;equals this worm?
2059 scf ;jr nz,notwinner
2062 jr c,notwinner ;no singleplayer winners
2064 cal _ldHLind ;ld hl,(hl)
2067 cal _cphlde ;==highest score..
2082 dnz displayWormStats
2085 or a ;singleplayer (0) only
2086 jr nz,hilevelcheckdone
2091 jr c,hilevelcheckdone
2092 ld (hl),a ;save local
2097 hilvlposhl =$-2 ;save external
2098 cal _writeb_inc_ahl ;ld (ahl),c
2103 jr z,hiscorecheckdone ;no SP
2105 cal loadhiscoreposinahl
2106 cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile)
2109 cal _SET_ABS_DEST_ADDR ;to local
2111 cal _MM_LDIR_SET_SIZE ;get old score+name
2114 ld de,(highsave) ;de=prev. hiscore
2115 ld hl,(worm1+score) ;hl=worm1's score
2116 cal _cphlde ;sub hl,de
2117 jr c,NotNewHigh ;new<old
2118 jr z,NotNewHigh ;new<=old
2120 ld (highsave),hl ;store new hiscore
2121 ld de,highsave+2 ;to
2122 ld hl,worm1+name ;from
2124 ldir ;store new hiname
2125 cal loadhiscoreposinahl
2126 cal _SET_ABS_DEST_ADDR ;to ahl
2129 cal _SET_ABS_SRC_ADDR ;from local
2131 cal _MM_LDIR_SET_SIZE ;save new
2159 ;x123456789012345678901
2160 ;>>>>>> GAME OVER <<<<<
2165 ;6Worm#02 @ 05 00120
2172 rst 20h ;_ABS_MOV10TOOP1
2174 ld hl,savestart-_asm_exec_ram+4
2178 cal _SET_ABS_DEST_ADDR
2182 cal _SET_ABS_SRC_ADDR
2183 ld hl,saveend-savestart
2184 cal _MM_LDIR_SET_SIZE
2192 loadhiscoreposinahl:
2193 ld hl,0 ;for peaworm and singleplayer
2199 ld a,(nrlevels+1) ;skip peaworm slots if tron mode
2203 ld b,a ;levels to skip (including 1 for singleplayer)
2204 ld de,5 ;to add per level
2206 add hl,de ;one word+3 bytes for name
2207 dnz addlevelposition
2214 adc a,0 ;ahl=saveloc
2223 jp _putc ;..then put *
2225 ;-----------------------------
2226 ;----------- worm ------------
2227 ;-----------------------------
2232 cal saverespawncounter
2238 jr DoesWormTailEqualsWormHead ;chk4 size=0
2249 DoesWormTailEqualsWormHead:
2251 jr nz,removewormloop
2255 jr nz,safewormsizedone
2263 ld (ix+tail),e ;head=tail/size=0
2269 jr nz,saverespawncounter
2293 ld a,%01111111 ;default
2296 dnz bitmask ;a/8 times
2297 out (1),a ;send bitmask
2298 in a,(1) ;input keys
2303 dnz keybit ;check match (cf set)
2306 inkeys: ;use jp not call!
2325 jr z,inlink ;input by link
2326 cal inkeys ;input by keys
2330 ld c,l ;send our keys
2337 ;-----------------------------
2338 ;------- handle worm ---------
2339 ;-----------------------------
2390 ;-------- move worm ----------
2418 notmoveY: ;bc=newpos
2425 pop hl ; << pos (old)
2443 ;--------- worm hit ----------
2450 cal z,checkhitotherworm
2453 and _datamultpeas ;&&bit
2457 jp z,WormDead ;no food
2464 cal DrawPea ;remove pea
2476 jp nz,Drawworm ;continue
2482 jp nz,Exit ;stack restored
2493 cal _IncScore ;score+(40*level)
2500 chkpeahit: ;bc=ownpos;hl=peapos (destr:ad)
2516 ld hl,(peaspos) ;1st pea
2519 and %01 ;ourpea (0|1)
2521 ld hl,(peaspos+2) ;2nd pea ;&&&ex de,hl?
2526 ld a,e ;peek a (that's x86asm for pop\push ;)
2527 bit 1,a ;%10 = carrying flag?
2528 jp z,WormDead ;if not just die
2533 pop af ;which flag? (=and %1)
2534 ld hl,drawctfpea1 ;restore #1
2535 jr z,nottheotherflag
2536 ld hl,drawctfpea2 ;restore #2
2538 ld (hl),3 ;draw delay 3 turns
2544 hitflag: ;correct pea hit
2546 xor %11 ;invert flag taken + ownflag
2548 and %10 ;just returned?
2552 jr nz,Drawworm ;flag taken, continue game
2554 ld e,20 ;flag captured+returned
2558 ld (drawctfpea1),a ;redraw..
2559 ld (drawctfpea2),a ;..both flags
2562 ;-----------------------------
2581 jr nz,nextotherwormbit
2591 ld a,(peaspos+1) ;yline
2594 jr nc,checklap ;y>yline -> a=1
2595 xor a ;y<yline -> a=0
2598 ret z ;same as before
2599 ld (ix+reserv),a ;1st time
2602 and 1 ;group 0 (1,3) or 1 (2,4)
2604 ret z ;(group 0 and y<yline) or (group 1 and y>yline)
2613 .db $dd,$7d ;ld a,lx
2616 jr nz,chkworm2 ; ret nz
2642 ;-------- draw worm ----------
2650 cal z,checkhitlapline
2656 ret z ;keep tail in "Tron"
2699 ;-----------------------------
2700 ;---------- ball -------------
2701 ;-----------------------------
2703 handlethoseneatlittleballs:
2749 bit 1,d ;1=up; 0=down
2779 letsmovetheotherway:
2794 ;-----------------------------
2795 ;----------- procs -----------
2796 ;-----------------------------
2800 ld a,%10000000 ;all key-masks
2803 inc a ;cp %11111111 (no keys pressed)
2804 jr nz,releasekeys ;keep waitin
2805 cal GET_KEY ;clear buffer
2833 ld (ix+delay),respawndelay
2852 ld (ix+pos2+1),a ;x2
2859 cp gamectf ;ctf no death penalty
2862 ret nz ;HandleWorm done
2864 or a ;0=no live limit
2865 ret z ;don't end game
2868 jr z,anyworm ;quit at any worm's death
2869 ld a,(nrworms) ;timematch: all worms must've died
2871 ld hl,worm1+lives-(worm2-worm1)
2873 xor a ;check for 0 lives
2875 add hl,de ;next worm
2877 ret nz ;any >0: don't exit
2880 ld a,$A7 ;exit@end of turn
2881 ld (CheckExit),a ;set exit state
2885 CheckPea: ;@hl; destr:abcde
2898 ret nz ;nz=pixel found
2907 tryDrawPea: ;hl=peapos;bc=dopea
2916 dec (hl) ;hl=appeartime
2917 ex de,hl ;hl=peaspos
2927 jr z,receivenewpeaoverlink
2928 ld c,l ;send pea's pos
2931 jp Qsend ;&&&possible jr
2932 receivenewpeaoverlink:
2950 cal sendnewpeaoverlink
2959 PutSprite: ;||@(b,c)
2960 ;by SHIAR only ix saved
2997 ;----------- score -----------
3000 ;piece of crap checking whether you've already won in timematch
3012 jr z,nneexxtt ;yourself
3014 ret nz ;someone else still alive
3019 jr c,nneexxtt_ ;you>him
3032 dnz chktimematchover
3048 add hl,de ;increase score
3051 jr z,scorecommon ;hl/1000 not increased
3060 jr c,showstats ;<0=0
3063 IncScore: ;inc score by e
3065 _IncScore ; inc by de
3069 or a ;if singleplayer...
3071 add hl,de ;score+=de
3074 ld (ix+score),l ;save
3079 jr z,showstats ;de=0=no limit
3086 jr nz,timematchscore ;no disp for timematches
3087 ld hl,$FC00 ;&&&only necessary in deathmatch
3109 shownameloop: ;1st 3 chars
3138 showstat: ;(multiplayer)
3149 showA: ;small w/o leading 0 (&&&combine w/ cshowA0??)
3168 showstatsS: ;(singleplayer)
3203 showA0: ;big w/ leading 0
3215 cshowA0: ;small w/ leading 0
3250 ;-----------------------------
3368 ld (ShiftRightCounter),a
3370 ld (ShiftRightChunk),a
3384 ShiftRightCounter = $-1
3406 ld (ShiftLeftCounter),a
3408 ld (ShiftLeftChunk),a
3410 jr nc,ShiftLeftSameByte
3429 ShiftLeftCounter = $-1
3440 jr nz,ShiftRowsRight
3474 ;----------- draw ------------
3488 CheckPixel: ;at bc in d
3495 ;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes)
3496 ;(b,c) to hl:a; "destroyes" ahl
3498 FindPixel: ;(b,c) to hl:a
3561 drawcircle: ;(d,e),h ;de=x,y; h=z
3572 ex (sp),hl ;push zz \ pop x,y
3573 cal circledraw ;(x-xx,y+yy)-(x+xx,y+yy)
3574 ;(x-xx,y-yy)-(x+xx,y-yy)
3575 cal circledraw ;(x-yy,y+xx)-(x+yy,y+xx)
3576 ;(x-yy,y-xx)-(x+yy,y-xx)
3578 ex (sp),hl ;push x,y \ pop zz
3581 dec a ;-256<h<0 = $FF**
3583 jr z,circlenext ;jump if zz<0
3587 add a,a ;a=2yy-2 ;nc
3589 sbc hl,de ;zz=zz-2yy+2
3597 add hl,de ;zz=zz+2xx+3
3606 circledraw: ;destr:de
3611 add hl,bc ;h=x+xx; l=y+yy
3613 cal drawline ;(h-b,l+c)-(h+b,l+c)
3619 cal drawline ;(h-b,l-c)-(h+b,l-c)
3620 ld a,b ;swap xx and yy
3626 drawbox: ;(d,e)-(h,l)
3651 drawline: ;(d,e)-(h,l)
3752 ;..and last but not least..:
3753 ;-----------------------------
3754 ;----------- link ------------
3755 ;-----------------------------
3762 out (7),a ;raise both wires = link ok
3765 checklink: ;load wires in A and check for timeout
3766 dec de ;decrease timer
3769 jr z,linktimeout ;timeout if de==0
3772 out (1),a ;select keys
3782 ld a,0 ;losses so far
3784 inc a ;and this is another one
3786 pop de ;return from link
3787 cp lossout ;quit if too many errors
3788 ret c ;otherwise just continue
3794 Qsend: ;--- try to send 8 bits in C; CF=error --- destr:abcde ---
3797 jr z,linkerr ;both wires low = exit signal
3798 ld b,8 ;bits to send
3801 rl c ;bit to send in cf
3802 ld a,D0LD1H ;0: lower white
3804 ld a,D0HD1L ;1: lower red
3806 out (7),a ;lower one (send bit)
3808 cal checklink ;other calc must lower other wire
3810 cal linkok ;raise one, ok to raise other (out (7),D0HD1H)
3813 cp %11 ;both raised (by other calc)
3816 dnz sendloop ;repeat for all bits
3818 ld (linklosses),a ;reset number of losses
3823 Crecv: ;--- receive 8 bits into A/C --- destr:abCde ---
3825 ret nc ;return if all went ok
3826 jr Crecv ;and try again
3828 Qrecv: ;--- receive 8 bits into A/C; CF=error --- destr:abCde ---
3830 jr z,linkerr ;both low = error, quit
3831 ld b,8 ;bits to receive
3835 cal linktest ;checklink
3837 jr z,recvwait ;both high = nothing sent (yet)
3839 rra ;received bit in cf
3841 jr c,received ;lower white wire as well
3842 ld a,D0HD1L ;lower red
3845 out (7),a ;both wires low
3848 jr z,recvwaitack ;same wire will be raised again by other calc
3849 cal linkok ;raise both
3851 dnz recvloop ;repeat for all bits
3853 ld (linklosses),a ;reset number of losses
3857 ;-----------------------------
3858 ;---------- levels -----------
3859 ;-----------------------------
3863 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
3864 .db 0,2,63 ;start d, y, x
3865 .db 128,57 ;field width (128-255), height (57-255)
3866 .db 0 ;no additional lines, boxes
3874 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3878 .db "Fast Fun :))",0
3880 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3881 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3887 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
3892 LevelDefT: ;tron=no delay
3893 .db "Empty Tron Level",0
3895 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3896 .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
3901 .db "Round and Round",0
3903 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3904 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
3912 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
3913 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
3918 ;-----------------------------
3919 ;---------- data -------------
3920 ;-----------------------------
3923 .db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000
3924 .db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000
3925 .db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000
3926 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000
3927 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000
3928 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000
3929 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000
3930 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000
3931 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000
3932 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000
3933 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000
3934 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000
3935 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011
3936 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100
3937 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101
3938 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011
3941 .db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000
3942 .db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000
3943 .db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000
3944 .db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100
3945 .db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010
3946 .db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010
3947 .db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100
3949 ;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000
3951 txtMenu: .db "Mode",0 ;1st menu item
3957 .dw $2418,$231E,$2824,$1F2A,$1730
3958 txtMenuR: .db "controls",0
3959 txtoMenu: .db "Back",0 ;1st menu item
3966 .dw $2618,$251E,$2524,$222A,$1A30,$1C36
3967 txtpMenu: .db "Resume",0 ;1st menu item
3968 .db "Turn Off",0 ;2nd
3969 .db "Contrast",$CF,5,0 ;...
3972 .dw $3418,$331E,$2F24,$3A2A
3973 txtGame: .db "Singleplayer",0
3974 txtGame1: .db "Peaworm",0
3975 txtGame2: .db "Tron",0
3976 txtGame3: .db "Deathmatch",0
3977 txtGame4: .db "Foodmatch",0
3978 txtGame5: .db "Timematch",0
3979 txtGame6: .db "Race",0
3980 txtGame7: .db "CTF" ;,0
3983 .db txtGame1-txtGame
3984 .db txtGame2-txtGame
3985 .db txtGame3-txtGame
3986 .db txtGame4-txtGame
3987 .db txtGame5-txtGame
3988 .db txtGame6-txtGame
3989 .db txtGame7-txtGame
3991 txtNone: .db "None",0
3992 txtDef: .db "Default",0
3995 txtKeyleft: .db ":left",0
3996 txtKeyright:.db "/right",0
3998 txtLevsel: .db $CF," SELECT LEVELS ",5,0
3999 txtWaiting: .db "Waiting...",0
4000 txtReceive: .db "Receiving..." ;,0
4003 .db 0, 3, 6, 9, 12, 15, 18, 21
4004 .db 24, 27, 30, 33, 36, 39, 42, 45
4005 .db 48, 51, 54, 57, 59, 62, 65, 67
4006 .db 70, 73, 75, 78, 80, 82, 85, 87
4007 .db 89, 91, 94, 96, 98,100,102,103
4008 .db 105,107,108,110,112,113,114,116
4009 .db 117,118,119,120,121,122,123,123
4010 .db 124,125,125,126,126,126,126,126
4013 txtLevel: .db "Level ",0
4014 txtWorms: .db "Worms: 0",0 ;follows txtLevel
4015 txtName: .db "Name",0
4016 txtWinner: .db "Wins " ;follows txtName
4017 txtDied: .db "Died " ;follows txtWinner
4018 txtScore: .db "Score",0 ;follows txtDied
4019 txtLeft: .db " left",0 ;follows txtScore
4020 txthiscore:.db "HiScore:",0
4022 txtReady: .db "Prepare!",0
4026 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0
4029 datalevels: .dw LevelDef, LevelDefM
4030 .dw LevelDefT,LevelDefM
4031 .dw LevelDefM,LevelDefM
4032 .dw LevelDefR,LevelDefC
4033 nrlevels: .db 0,3,1,3,3,3,3,1 ;=defaults
4035 _datalink = %0000001 ;linkplay
4036 _datafoodl = %0000010 ;left=0 limit
4037 _datasingl = %0000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel)
4038 _datamultpeas = %0001000 ;multiple peas=1
4039 _datatime = %0010000 ;time incs score (timematch)
4040 _datafood = %0100000 ;food present
4041 _datadie = %1000000 ;worm dies on impact
4042 ;reserved %10000000 ;for future use
4044 savestart: ; �game info (see above)
4045 ; | �lives (0=unlimited)
4046 ; | | �nrworms (can be altered by user)
4047 ; | | | �level (reset to 1 at startup)
4048 ; | | | | �speed/delay (-1=def)
4049 ; | | | | | �grow speed (-1=none; 0=continuous)
4050 ; | | | | | | �turn speed (8=def)
4051 ; | | | | | | | �score limit (0=none)
4052 gamesingle = 0 ;used | | | | | | | |
4053 datasingle: .db %1100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives)
4055 datapeas: .db %1100100,1,1,1,-1,-1, 8, 0 ;Peaworm (SP; 1 live)
4057 datatron: .db %1010100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
4058 gamedeathm = 3 ;used
4059 datadeathm: .db %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth)
4061 datafoodm: .db %1100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
4063 datatimem: .db %1010000,1,2,1,-1, 0, 8, 0 ;Timematch (tron, 100 score)
4065 datarace: .db %0000000,0,2,1,-1,-1, 8,10 ;Race (100 score, no collision)
4067 datactf: .db %1001000,0,4,1,-1,-1, 8,10 ;CTF (100 score)
4069 worm1set: .dw worm1p,worm1p
4070 .db %11110111,1,-01,K_RIGHT,K_LEFT
4071 worm1name: .db "WORMY ",0
4072 worm2set: .dw worm2p,worm2p
4073 .db %11111011,0,-01,K_F2,K_F1
4074 worm2name: .db "VIPER ",0
4075 worm3set: .dw worm3p,worm3p
4076 .db %11111011,1,-01,K_COMMA,K_STO
4077 worm3name: .db "NIBBLER ",0
4078 worm4set: .dw worm4p,worm4p
4079 .db %11111011,0,-01,K_PLUS,K_ENTER
4080 worm4name: .db "JIM ",0
4089 Gametype: .db 0 ;last gamemode
4103 head = 13 ;4B (head=tail)
4104 tail = 15 ;also@next level
4106 reserv = 18 ;loop (race:lap|ctf:pea)
4107 input = 19 ;---currently unused afaik---
4117 ;bla space (reserved for internal levels)
4118 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4119 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4120 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4121 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4122 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4123 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4124 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4125 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4126 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4127 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4128 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4129 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4130 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4131 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4132 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4133 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4134 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4135 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4136 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4137 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4138 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4139 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4140 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4141 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4142 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4143 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4144 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4145 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4146 .db "WWW.SHIAR.ORG WWW.SHIAR.ORG "
4147 .db " wormy@shiar.org",0
4150 defspriteimg: .db %01100000
4156 .db "Internal Levels",0
4157 .db "by SHIAR -- still t"
4158 .db "o be added...." ;,0
4160 .db 0,deflevels/256,deflevels&255
4163 ;-----------------------------
4164 ;----------- end -------------
4165 ;-----------------------------