1 ;___▄███________________________________________________________▄▄▄▄____________
4 ;▐██ ▄███▄ ▄▄████▄▄ ▄████ ▄██▄ ▄██▄ ▐██ █████
5 ;██▌ ███████ ▄██████████ ███████ ████████████▄ ██ ███ ███
6 ;██ ██▀ ▀██ ▐██▀▀ ▀███ ███▀ ██▌ ██▀ ████ ▀██ ██▌ ▐██▌ ▐██
7 ;██ ██ ██ ██ ▄ ██▌ ▐██▌ ▐██ ██████ ██▌ ███ ███ ██
8 ;██ ██ ██ ██ ██ ▐██ ███ ██▌ ███▀ ▐██ ▀██ ███ ▐███ ██
9 ;██ ██▌ ▐██ ██ ██ ██ ██▌ ██▌▐██▌ ██▌ ██ ██████▀ ██
10 ;██ ▐██ ██▌ ▐██ ██ ██ ██ ██ ▐██ ██▌ ██▌ ▀███▀ ▐██
11 ;██▌ ██▄ ▄██ ██▌ ██ ██ ██▌ ██ ▐██▌ ▐██▌ ██▌ ██▌
12 ;▐██ █████ ▐██ ██▌ ▐██ ██▌ ██ ▀██▄▄██▀ ███ ▐██
13 ; ███ ███ ██▌ ▐██ ██▌ ███ ██▌ ▀████▀ ▐██ ███
14 ; ███▄ ▄█████▄ ▄███ ██▌ ███ ▐██▌ ██▌ ███▄▄ ▄███
15 ; ███████▀ ▀███████ ▐██▄▄███▌ ███ ▐██ ██████████████▌
16 ; ▀███▀ ▀██▀▀ ▀█████▀ ██ ██▌ ▀█████████▀
17 ;_______________________________________________________________________________
19 ; Version : 100% (1.00.36)
20 ; Release Date : 2002 March 6
22 ; Email Address : wormy@shiar.org
23 ; Web Page : www.shiar.org
24 ; Description : perfect Nibbles game with free movement, nine game
25 ; modes, for 1-4 players, many levels and editor
26 ; Where to get this game : wormy.shiar.org
27 ; Other games by author(s) : Nemesis beta
28 ; Additional Credits to : Matthew Shepcar : wrote original Peaworm, end'98
29 ; Jonah Cohen : helped writing worm
30 ; Files : wormy.txt (9283) : ed15e942a99b40e5a584c597cb13df46
31 ; wormy.z80 (100k) : 977109a7d25f3227fe817edbcc36ad9a
32 ; wormy.86g (8914) : fbff7c36687c1e7e3113c29069021718
33 ;_______________________________________________________________________________
35 ;--- notes ---------------------------------------------------------------------
37 ; * Game README is wormy.txt
38 ; * Use for LEARNING practises ONLY!
39 ; * Don't _ever_ release altered code w/o permission!
40 ; * Give me credits when you use any of this stuff
41 ; * I'm not responsible for any damage this might cause, yada yada...
42 ; * Although I've commented & labeled quite some stuff, due to
43 ; crazy optimizations and weird coding, it may be harder to
44 ; understand than the average blob of code. This is probably _not_
45 ; the best source to learn z80 from. w00t the Shyer Way (tm).
46 ; * Email me. If you've got suggestions|patches|questions: tell me.
47 ; * Don't scroll down if you get scared easily.
49 ;--- index ---------------------------------------------------------------------
51 ; * TO_DO : future features
53 ; * STORAGE : permanent; temporary; layout
54 ; * PROG_START : search levels
56 ; * MORE_INIT : trig tables
57 ; * MAIN_MENU : draw menu; options menu; main menu; display
58 ; current settings; handle menukeys; change name
60 ; * START_GAME : link; client; set/send worms; host; load game;
64 ; * GAME_OVER : who won?; display worms; quit
66 ; * WORM_ALIVE : move worm; draw worm
68 ; * WORMY_HIT : multifood; ctf; main; foodmatch|SP; take pea;
73 ; * DRAW : pixel; findpixel; objects; circle; box;
75 ; * LINK! : multiple bytes; foo; send; recv; common
77 ; * DATA : graphics; menus; text; foo; game settings
80 ;_______________________________________________________________________________
81 ; _______ _____ ______ _____
83 ; | |_____| ____ |_____/ |_____|
84 ;_______________________________________________________________________________
87 ; X [34] freeze when no space left to place pea (break after 10k tries)
88 ; X [34] wow another bit of code 'reniced' (easter egg or something :)
89 ; X [34] two more jp to jr
90 ; X [34] highly improved randomizer (values >127 were rare)
91 ; X [36] replace 'left' at the change-control prompt
92 ; X [36] ED: fixed immediate exit at level preview when using enter key
93 ; X [36] bouncies drawn after placing peas (causing overwrites)
94 ; X [36] FIX: skip string length bytes when running from yas
95 ; X [36] ED: pointer to ending message realigned
96 ; X [36] LVL: end messages fixed in affected episodes
98 ; * scorebar last digit (at 128-3) not displayed by _vputs :(
99 ; * save last played level (in levelfile prolly)
100 ; * automatically start players in multiplayer games after certain time
101 ; * muliplayer bonuses/powerups (shrink, lives, stun, inverse, etc.)
102 ; * levels with random pixels appearing during game
103 ; * no borders (move players from one side to another)
104 ; * hiding levels crashes?? (ishell 2.01 rom 1.6)
105 ; * use selected player on main menu as first player in singleplayer games
108 ;--- future features -----------------------------------------------------------
110 ;just a maybe-list; NO guarantees!
112 ; * correct team winners
113 ; * level compression
114 ; * ubersized bouncies (sprites)
115 ; * arrow to offscreen peas
119 ; * pause in linkplay
120 ; * coop (DON'T COUNT ON IT)
122 ;_______________________________________________________________________________
123 ; _/_/_____ __ _ _______ _ _ ______ _______
124 ; _/_/ | | \ | | | | | | \ |______
125 ; / / __|__ | \_| |_____ |_____ |_____| |_____/ |______
126 ;_______________________________________________________________________________
129 #include "ti86asm.inc"
135 _SHRACC = $4383 ;4x srl a
136 _SHLACC = $438B ;4x sll a
137 _divHLby10 = $4044 ;hl=hl/10
138 _divAby10 = $4DAF ;a=a/10
139 _HLTIMES10 = $41BF ;hl=hl*10
140 _cphlde = $403C ;cp hl,de
141 _clrWindow = $4A86 ;clear screen
142 _asapvar = $D6FC ;own name (worm)
143 _MOV4B = $429B ;4x ld (de),(hl)
144 _MOV5B = $4297 ;5x ld (de),(hl)
145 _mov9b = $4283 ;9x ld (de),(hl)
146 _ldHLind = $4010 ;ld hl,(hl)
147 _swapt_ = $45F3 ;ex ahl,bde (doesn't work?)
148 _Get_Word_ahl = $521D ;ld de,(ahl)
149 _Set_Word_ahl = $5221 ;ld (ahl),de
150 _INC_PTR_AHL = $4637 ;inc ahl
151 _AHL_PLUS_2_PG3 = $4C3F ;add ahl,2
152 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl
153 _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
154 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
155 _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl
156 _mm_ldir = $52ED ;24bit ldir
157 _MM_LDIR_SET_SIZE = $524D ;_SET_MM_NUM_BYTES + _mm_ldir
158 _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1
159 _RAM_PAGE_7 = $47F3 ;"""" 7
160 _PTEMP_END = $D29A ;end of VAT
161 _load_ram_ahl = $462F ;ahl->page+hl
162 _writeb_inc_ahl = $5567 ;ld (ahl++),c
163 _jforce = $409C ;TI-OS stack restored
164 _EXLP = $4493 ;swap (hl),(de) b times
165 _GETB_AHL = $46C3 ;a=(ahl) \ hl=ahl
168 #define id2 ;yas2 level identifier - this'll add (65) bytes
169 #define buffer ;use display buffer, otherwise write directly to screen (11)
170 #define readymask ;"greys" out the field before starting a level (20)
171 ;#define readytext ;-displays "prepare" before level starts (42)
172 #define coolzgfx ;nice graphics for game over screen (98)
173 #define spprotect ;options not changable for singleplayer modes
174 ;#define intlevels ;-internal levels
175 ;-to become invincible, define the magic word :D
178 levelhead2 = 97 ;wormy levels header = "0"
180 ;_______________________________________________________________________________
181 ; _______ _______ _____ ______ _______ ______ _______
182 ; |______ | | | |_____/ |_____| | ____ |______
183 ; ______| | |_____| | \_ | | |_____| |______
184 ;_______________________________________________________________________________
186 ;--- permanent -----------------------------------------------------------------
188 ScrBuffer = $8420 ;-A3FF (20*FF=1FE0)
189 worm4p = $A400 ;-A5FF (200) %101001O0
190 ;free = $A600 ;-A7FF (200)
191 worm2p = $A800 ;-ABFF (400) %10101O00
192 SinCosTable = $AC00 ;-AD00 (4*40)
193 worm1 = $AD01 ;-AD1E (1E)
194 worm2 = $AD1F ;-AD3C (1E)
195 worm3 = $AD3D ;-AD5A (1E)
196 worm4 = $AD5B ;-AD78 (1E)
197 balls = $AD79 ;-AE00 (<=3x2D) (bb<=45)
198 turn10 = $AE01 ;-AE01 (1) (counter)
199 peaspos = $AE02 ;-AF05 (4-104) (peas)
200 ;free = $AF06 ;-AFFF (F9)
201 worm1p = $B000 ;-B7FF (800) %1011O000
202 worm3p = $B800 ;-BBFF (400) %10111O00
203 ;buffer = $BC00 ;-BF90 (390)
204 ;free = $BF91 ;-BFFF (6F)
205 ;program = $D748 ;-EFFF (186D+4A) ;6327
206 leveldata = $F080 ;-F9FF (<=97F)
208 datalevels = $FA00 ;-FA11 (12) (>=$C000)
209 nrlevels = $FA12 ;-FA1B (A) (<$FA70)
210 defspr = $F078 ;-F07F (8)
213 ;MEM|8---9---A---B---C---D---E---F---| ;there's something wrong
214 ; |..[------]||[]|......[-----]|[].| ;if you still understand < OUTDATED <
215 ; | SCREEN 2* 13 PRGM 4LV | ;after looking at this
217 ;--- temporary -----------------------------------------------------------------
219 namelength = $BC00 ;(1) @menu
220 datalink = $BC00 ;(8) @init
222 DispBuffer = $BC00 ;(10x57d) @game
226 linklevel = $AECC ;(<=134) @game+init
227 lefttotalb = $BF91 ;(1) @game
228 drawctfpea1 = peaspos+4
229 drawctfpea2 = peaspos+6
231 ;--- layout --------------------------------------------------------------------
244 tail = 15 ; │also@next level
246 reserv = 18 ; │loop (race:lap|ctf:pea)
251 wormsize = 30 ;^mark^
253 ;_______________________________________________________________________________
254 ; _____ ______ _____ ______ _______ _______ _______ ______ _______
255 ; |_____] |_____/ | | | ____ |______ | |_____| |_____/ |
256 ; | | \_ |_____| |_____| _____ ______| | | | | \_ |
257 ;_______________________________________________________________________________
259 .org %1101011101001000
261 start: ;turn back NOW!
262 nop ;and so it begins...
291 .db 8,2 ;Rkaydees' icon:
292 .db %00000000,%00111100 ; XX
293 .db %00000000,%01010010 ; XXX
294 .db %00000000,%01100001 ; XX
295 .db %01100011,%10011001 ; XX
296 .db %10010100,%01101001 ; XX
297 .db %10011001,%00011001 ; XX
298 .db %01000010,%11000001 ; X XX
299 .db %00111100,%00111110 ; XXXX
307 .db "wor" ;description
308 .dw yasexec ;execution routine
309 .dw yascomment-yasdetect
310 .dw yasdetect-$-1 ;detection routine
311 .dw yasicon-yascomment
312 .dw yascomment-$-1 ;comment routine
313 .dw yasdataend-yasicon
314 .dw yasicon-$-1 ;icon routine
319 cal _AHL_PLUS_2_PG3 ;skip past length bytes
320 cal skiptitle ;title (plus size+header <- all non-0)
321 ; cal skiptitle ;description
324 cal _AHL_PLUS_2_PG3 ;skip past length bytes
326 ld hl,levelhead+(levelhead2*256)
336 ld hl,$F400+levelicon-yasicon
341 .db %00011100 ;..XXX... ...XXX..
342 .db %00011110 ;.X...X.. ...XXXX.
343 .db %00000011 ;.X..X... ......XX
344 .db %10000001 ;X..X..XX X......X
345 .db %01011011 ;X..X..XX .X.XX.XX
346 .db %01101110 ;X...XXX. .XX.XXX.
360 ;--- search levels -------------------------------------------------------------
367 ld hl,$BFFF ;VAT start
370 ld de,(_PTEMP_END+1) ;VAT end
397 ex de,hl ;ld ahl,(hl)
398 cal _AHL_PLUS_2_PG3 ;string id
399 cal _Get_Word_ahl ;ld de,(ahl)
403 jr nz,_searchnext ;not worm
407 ld (ix+1),h ;save level's ahl
417 cal _Get_Word_ahl ;ld de,(ahl++)
419 ld a,e ;set new level
431 ;_______________________________________________________________________________
432 ; _______ _ _ _______ _______ _______ _______ _______
433 ; | |______ \ / |______ |______ | |______ | |
434 ; |_____ |______ \/ _____ ______| |______ |_____ |______ |_____ |
435 ;_______________________________________________________________________________
447 jp z,ExitNoStats ;->no lvls
449 jr z,loadlevel1 ;->1 lvl
450 levelselectmenu: ;load next page
458 cal _vputs ;"< SELECT LEVELS >"
462 ld hl,$FC00+$380 ;(*,56)
472 cal _load_ram_ahl ;hl=ahl
485 cp 49 ;bottom of screen
495 readylevelfile: ;selected level at ahl
496 ; ld hl,templevels-3/0
498 add a,3 ;sellev+3 (#0==-3)
514 cal _GETB_AHL ;ld a,(ahl)
519 cal _INC_PTR_AHL ;ahl++
521 jr nz,skiptitle ;goto #0-terminator
547 cal _load_ram_ahl ;hl=ahl
548 ld de,$FFA0 ;desc.text
553 cp d ;de>$FFFF (offscreen)
554 jr nz,levdescclearloop
556 jr levselectmenuloop+1
559 ld ix,templevels-6 ;reset 2 1st page
564 ld b,-2 ;level selected
570 pop bc ;GET_KEY destr. b
583 jr nz,levselectmenuloop
589 or a ;levelfile on page 0 (=internal)
592 cal skiptitle ;skip description
595 ld (leveldataSize),de
600 ld (hilvlposa),a ;singleplayer levels
605 cal _SET_ABS_SRC_ADDR ;levelsstart
608 cal _SET_ABS_DEST_ADDR ;store in mem.
611 cal _MM_LDIR_SET_SIZE
613 cal _LOAD_ABS_SRC_ADDR ;->ahl
620 ldi ;(de),(hl)\inc hl
625 ;_______________________________________________________________________________
626 ; _______ _____ ______ _______ _____ __ _ _____ _______
627 ; | | | | | |_____/ |______ | | \ | | |
628 ; | | | |_____| | \_ |______ _____ __|__ | \_| __|__ |
629 ;_______________________________________________________________________________
631 ; cal _runindicoff ;this is after level selection (run from yas1 or restart)
632 ; cal _flushallmenus ;so this stuff should already be done earlier or by yas
649 ld bc,int_end-int_handler
653 im 2 ;...it *does* work ;)
655 res 2,(iy+13) ;appAutoScroll
663 ld (hl),1 ;def=level#1
667 ;--- trig tables ---------------------------------------------------------------
669 ld hl,trigtable ;I believe this
670 ld de,SinCosTable ;is one of the few
671 psh de ;pieces of original
672 ld bc,65 ;Peaworm code still
692 ;_______________________________________________________________________________
693 ; _______ _______ _____ __ _ _______ _______ __ _ _ _
694 ; | | | |_____| | | \ | | | | |______ | \ | | |
695 ; | | | | | __|__ | \_| _____ | | | |______ | \_| |_____|
696 ;_______________________________________________________________________________
698 ;--- draw menu -----------------------------------------------------------------
706 optimize__w00t: ;may look like crap, but actually saves 3 bytes!
718 ld hl,$FC00+$010 ;(*,01)
720 ld hl,$FC00+$160 ;(*,22)
722 ld hl,$FC00+$3E0 ;(*,62)
726 dec a ;will be inced @changegame
728 ld hl,changegame ;dispmenusets ;mainMenu
729 psh hl ;jump here after ret
732 ;Mode|Level|Link|Worms|worm #|controls
733 ; jr dispmenucommon ;cal
738 ld de,$FD80 ;begin pos
745 jr nz,clroldmenuloop+2
760 hr: ;draw horizontal line at hl
762 ; jp menuinvloop ;shorter but not good for pausescreen
769 ;--- options menu --------------------------------------------------------------
774 ;Back|Lives|Limit|Speed|Rotation|Growth
781 jp nz,LetsGetThisPartyOn ;SP -> start game
794 inc hl \ inc hl \ inc hl
812 inc a ;-1=None; 0..98->1..99
827 cal cshowA ;turn speed
834 ld a,(hl) ;(scorelimit)
839 jr z,optionMenu ;do not display 0 behind 'None'
842 jr nz,optionMenu ;in multifood limit == #peas
854 jp z,dispmainmenu ;mainMenu
898 cal loadgamecar ;a=(hl)
901 jr nc,optionMenu ;>99
905 jp dispomenusets ;optionMenu
908 sub 1 ;dec does not set cf
916 jr nc,optionMenu ;>99
919 jr _dispomenusets ;optionMenu
922 sub 1 ;dec does not set cf
929 ld a,(hl) ;(scorelimit)
936 jr nc,_optionMenu ;>98
940 jr _dispomenusets ;optionMenu
946 jr z,_optionMenu ;<-1
953 inc hl ;=saves 2 bytes :P
962 jr nc,_optionMenu ;>25
965 jr _dispomenusets ;optionMenu
980 jr nc,_optionMenu ;>98
983 jr _dispomenusets ;optionMenu
989 jr z,__optionMenu ;<-1
992 ;--- main menu -----------------------------------------------------------------
1001 dec a ;2nd item: level
1003 sub 3 ;5th item: wormname
1005 dec a ;6th: controls
1007 jp LetsGetThisPartyOn ;otherwise
1011 ld a,(hl) ;hl=nrworms
1014 jr nc,mainMenu ;may not be >4+2
1017 jr _dispmenusets ;mainMenu
1045 ; jr z,changecurworm
1051 jr nc,mainMenu ;may not become >4
1053 jr _dispmenusets ;mainMenu
1066 ; jr z,bchangecurworm
1072 jr nz,_dispmenusets ;save >0
1079 ld a,(hl) ;hl=nrworms
1082 jr nc,changednrworms ;save >=2
1090 jr _mainMenu ;don't change for singleplayer
1095 dec hl ;inced earlier
1097 ld a,1 ;change LS-bit (=link)
1101 jr dispmenusets ;mainMenu
1108 jr dispmenusets ;mainMenu
1126 jr dispmenusets ;mainMenu
1129 inc hl ;hl=loadgamecar+2
1131 ld a,(hl) ;(curlevel)
1133 cp (hl) ;max level for sel.game
1139 jr dispmenusets ;mainMenu
1142 ld a,(hl) ;(curlevel)
1147 getnrlevels: ;for current gametype at hl
1167 jr z,waitcustomkey ;ignore
1174 cal getcustomkey ;left
1177 cal getcustomkey ;right
1180 ;--- display current settings --------------------------------------------------
1187 cal _vputs ;Singleplayer or smtn
1243 ld hl,$363E ;controls
1249 ;--- handle menukeys -----------------------------------------------------------
1257 pop bc ;GET_KEY destr. b
1267 menupos: ;highlight #b
1280 add hl,hl ;$FD20+item*96
1310 ;--- change name ---------------------------------------------------------------
1312 getwormname: ;of (curworm)
1340 ld hl,$FF07 ;begin pos
1347 ld (ix),a ;clroldcustom -> a=0
1373 dec (hl) ;(namelength)
1387 .db ".<>!" ;down|L|R|up|-|-|-|-|[enter]
1388 .db "w00t!" ;(makes code look way better)
1389 .db "XTOJE0",'w' ;+|-|*|/|^|clear|- w
1390 .db " WSNID9",$F8 ;(-)|3|6|9|)|tan|custom|- o
1391 .db "ZVRMHC8",$A7 ;.|2|5|8|(|cos|prgm|[del] o
1392 .db "YUQLGB7#",$C2 ;0|1|4|7|ee|sin|table|xvar|[on] t
1393 .db "-PKFA6'" ;sto|,|x2|ln|log|graph|alpha
1394 .db "54321*",$AE,$D0 ;F5|F4|F3|F2|F1|2nd|[exit]|more
1398 ld (ix+8),d ;end mark
1401 ;_______________________________________________________________________________
1402 ; _______ _____ _______ _______ _____ ______ _____ _______ _______
1403 ; | | | | |______ | |_____] |_____/ | | | |______
1404 ; | | | __|__ ______| |_____ _____ | | \_ |_____| |_____ ______|
1405 ;_______________________________________________________________________________
1409 halt ;save them batteries! yeah!
1412 clrold: ;destr:acdehl (acd=0)
1413 ld hl,$FD97 ;begin pos
1414 ld a,35 ;nr of lines
1416 ld de,7 ;bytes to add
1418 ld c,9 ;bytes to clear
1423 jr nz,clroldsetsloop
1426 jr nz,clroldsettings
1429 hlatlevel: ;d must be 0
1436 cal _ldHLind ;ld hl,(hl)
1437 ex (sp),hl ;hl=loadgamecar
1440 ld a,(hl) ;(curlevel)
1445 dec c ;levels to skip
1449 ret ;hl=begin of correct level
1451 skiplvltitle: ;zf=singleplayer
1453 or a ;null-terminator
1458 skiplevel: ;@hl; de=2 - destr:ab - alter:hl
1465 ld b,(hl) ;spritesize
1473 pop af ;cp (gametype),0
1475 inc b ;multiplayer lvl
1477 inc b ;skip other 3 worms (9 bytes)
1482 sub gamerace ;a=(gametype)
1501 ;build: c=(gamecar)=(hl-1)
1502 ; a=(wormbeglives)=(hl)
1508 add a,a ;8 bytes per mode
1520 ;_______________________________________________________________________________
1521 ; _______ _______ _______ ______ _______ ______ _______ _______ _______
1522 ; |______ | |_____| |_____/ | | ____ |_____| | | | |______
1523 ; ______| | | | | \_ | _____ |_____| | | | | | |______
1524 ;_______________________________________________________________________________
1528 ld (CheckExit),a ;set exit state
1533 ld a,4 ;4x (all worms)
1543 ld (hl),b ;+score+1=0
1546 ld (hl),c ;+wdelay=2
1551 ex de,hl ;de=wormX+head
1552 ldir ;+head=+tail (2)
1555 ld c,wormsize-tail ;=bc
1558 jr nz,createwormsloop
1560 OhMyGodItsALabel: ;pj34r my coding skillz
1564 ex (sp),hl ;pop \ psh leveldata
1565 psh hl ;psh loadgamecar
1570 ;--- link ----------------------------------------------------------------------
1586 ;--- client --------------------------------------------------------------------
1590 ; cal _puts ;shouldnt be necessary since this part always seems to work afaik
1592 ;name/keys: wormy#1 = worm #1 = ok
1593 ; 2 = link = 0 + link (name1)
1594 ; 3 = worm #2 = #2 + local(name2)
1595 ; 4 = link = 0 + link (name2)
1596 ld e,worm3+wleft&255
1600 ld l,worm2+wleft&255
1601 cal linkworm ;worm2+4 over link
1609 cal recvstuff ;game setup
1610 ld hl,gametype ;+gamecar
1612 cal recvstuff ;transmit game
1615 cal recvstuff ;level
1617 cal loadtxtgame ;set CURtxtGame
1624 jp DisplayMenu ;return to menu
1626 ;--- set/send worms ------------------------------------------------------------
1630 moveworm: ;hl=wormN+wleft
1633 ldir ;keys+name worm(de) = worm(hl)
1635 linkworm: ;hl=wormN+wleft
1636 ld (hl),0 ;worm1|2+wleft
1641 ld bc,worm3-worm1-11 ;+2
1643 ld (hl),b ;worm3|4+wleft
1648 sendworm: ;hl=wormN+name
1652 add hl,bc ;worm(N+2)+name
1656 ;--- host ----------------------------------------------------------------------
1664 ;name/keys: wormy#1 = link = 0 + link (name1)
1665 ; 2 = worm #1 = #1 + local(name1)
1666 ; 3 = link = 0 + link (name2)
1667 ; 4 = worm #2 = #2 + local(name2)
1668 ld e,worm4+wleft&255
1670 ld e,worm2+wleft&255
1673 ld l,worm1+wleft&255
1674 cal linkworm ;worm1+3 over link
1682 cal sendstuff ;setup
1683 ld hl,gametype ;+gamecar
1688 cal sendstuff ;level
1690 ;--- load level ----------------------------------------------------------------
1697 ld b,$11 ;=ignore (ld)
1702 ld b,$CD ;=continue (call)
1706 ld (doteam),a ;do team score (CD) or not (11)
1718 ld (turnright),a ;more efficient
1730 cal _HLTIMES10 ;hl=10*(hl)
1735 pop hl ;begin of current level
1742 dec (hl) ;curlevel-- (not beyond last lvl)
1745 ;show end msg or smtn
1747 psh bc ;where to go afterwards
1748 inc hl ;location of ending-code
1749 jp (hl) ;go there ("call")
1760 rlc (hl) ;bit 7 of (hl)...
1761 rra ;...to bit 7 of (gamecar)
1762 rrc (hl) ;restore (hl)
1765 and 127 ;actual #peas
1783 ld a,(hl) ;speed from level
1787 ld (de),a ;custom speed
1801 ld b,0 ;bc=sprite size
1802 add hl,bc ;hl=behind sprite
1806 ld a,42 ;always overwritten
1813 setsprite: ;de=@sprite ;a=sprsize
1837 pop af ;cp (gametype),0
1845 ld a,SinCosTable/256
1862 ld bc,(worm2-worm1)-7
1871 ;--- draw level ----------------------------------------------------------------
1899 ld bc,63 ;first 2 rows
1901 ldir ;draw upper border
1903 ld (hl),%11000000 ;first left border
1908 inc hl ;clear rest of line
1948 cp gamerace ;or gamectf
1949 jr c,levelhasbeensetup
1951 ld c,2 ;ld bc,2 (2 bytes)
1952 jr z,loadextralevelstuff ;cp gamerace
1953 ld c,4 ;ld bc,4 (2nd flag in ctf)
1954 loadextralevelstuff:
1963 ;--- prepare -------------------------------------------------------------------
1966 psh hl ; >> levelp new
1968 cal handlethoseneatlittleballs
1972 cal c,multnewpea ;a=0
1981 ld de,57*256+%10101010
2002 ld hl,4+(txtposReady*256)
2016 ;_______________________________________________________________________________
2017 ; ______ _______ _______ _______ _____ _____ _____
2018 ; | ____ |_____| | | | |______ | | | | | |_____]
2019 ; |_____| | | | | | |______ _____ |_____ |_____| |_____| |
2020 ;_______________________________________________________________________________
2023 ld bc,(worm1+pos) ;camera worm #1
2025 or a ;if #1 not over link
2027 ld bc,(worm2+pos) ;otherwise view from #2
2029 cal DisplayField ;display piece of level
2044 jr nz,screeninvertloop
2057 ld (handledworm),a ;reset
2075 jr nz,nodispupdate ;just once every 10 turns
2076 ld (hl),10 ;reset counter
2077 cal forceshowstats ;update score
2082 jr nz,noctfpeas2draw
2085 cal tryDrawPea ;pea#1
2088 cal tryDrawPea ;pea#2
2091 cal handlethoseneatlittleballs
2104 inc (hl) ;0..nrworms-1
2107 ;_______________________________________________________________________________
2108 ; _ _ _______ __ __ _______
2109 ; |____/ |______ \_/ |______
2110 ; | \_ |______ | ______|
2111 ;_______________________________________________________________________________
2120 rla ;=$17 (c=EXIT-key)
2125 ;--- pause menu ----------------------------------------------------------------
2130 ;Resume|Turn Off|Contrast|Exit||
2133 ld hl,$FC00+$170 ;(*,23)
2135 ld hl,$FC00+$310 ;(*,49)
2206 ;_______________________________________________________________________________
2207 ; ______ _______ _______ _______ _____ _ _ _______ ______
2208 ; | ____ |_____| | | | |______ | | \ / |______ |_____/
2209 ; |_____| | | | | | |______ _____ |_____| \/ |______ | \_
2210 ;_______________________________________________________________________________
2217 out (7),a ;both wires low = game over signal
2226 cal menuinvloop ;invert
2228 cal hr ;menuinvloop w/ b=16
2238 cal menuinvloop ;invert
2240 cal hr ;menuinvloop w/ b=16
2259 cal _vputs ;Died Score
2263 ;--- who won? ------------------------------------------------------------------
2276 jr c,nonewwinner ;h<d
2277 jr nz,newwinner ;h>d
2280 jr nc,nonewwinner ;l<e
2291 cpl ;high value (>$FB)
2296 ld a,(hl) ;less deaths
2303 ;--- display worms -------------------------------------------------------------
2305 ;x123456789012345678901
2306 ;>>>>>> GAME OVER <<<<<
2311 ;6Worm#02 @ 05 00120
2325 cp (hl) ;wleft=0 = link
2342 ld a,(hl) ;worm+died
2349 jr nz,nodmwinner ;deathmatch?
2350 ld a,0 ;winner's deaths
2352 cp (hl) ;equals this worm?
2353 scf ;jr nz,notwinner
2356 jr c,notwinner ;no singleplayer winners
2358 cal _ldHLind ;ld hl,(hl)
2361 cal _cphlde ;==highest score..
2377 dnz displayWormStats
2381 or a ;singleplayer (0) only
2382 jr nz,hilevelcheckdone
2387 jr c,hilevelcheckdone
2388 ld (hl),a ;save local
2393 hilvlposhl =$-2 ;save external
2394 cal _writeb_inc_ahl ;ld (ahl),c
2400 jr z,hiscorecheckdone ;no SP
2402 cal loadhiscoreposinahl ;cf=0 (and)
2403 cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile)
2406 ;Be Root to fix a Unix problem
2408 ;ReBoot to fix a Windows problem
2409 cal _SET_ABS_DEST_ADDR ;to local
2410 ;W00t W00t to fix an assembly problem
2411 cal mmldir5 ;get old score+name
2412 ld de,(savestr) ;de=prev. hiscore
2413 ld hl,(worm1+score) ;hl=worm1's score
2414 cal _cphlde ;sub hl,de
2415 jr c,NotNewHigh ;new<old
2416 jr z,NotNewHigh ;new<=old
2418 ld (savestr),hl ;store new hiscore
2420 ld hl,worm1+name ;from
2422 ldir ;store new hiname
2423 cal loadhiscoreposinahl ;cf=0 (jr c)
2424 cal _SET_ABS_DEST_ADDR ;to ahl
2427 cal _SET_ABS_SRC_ADDR ;from local
2428 cal mmldir5 ;save new score+name
2462 loadhiscoreposinahl:
2469 ld a,(nrlevels+1) ;skip peaworm slots if tron mode
2473 ld b,a ;levels to skip (including 1 for singleplayer)
2474 ld de,5 ;to add per level
2476 add hl,de ;one word+3 bytes for name
2477 dnz addlevelposition
2484 adc a,0 ;ahl=saveloc
2486 savestr: ;hiscore (01ABC) _D_HL_DECI (01234)
2493 jp _putc ;..then put *
2495 ;--- quit ----------------------------------------------------------------------
2500 rst 20h ;_ABS_MOV10TOOP1
2502 ld hl,savestart-_asm_exec_ram+4
2506 cal _SET_ABS_DEST_ADDR
2510 cal _SET_ABS_SRC_ADDR
2511 ld hl,saveend-savestart
2512 cal _MM_LDIR_SET_SIZE
2520 ;_______________________________________________________________________________
2521 ; _ _ _ _____ ______ _______ _______ _______ _ _ _______ _______
2522 ; | | | | | |_____/ | | | |______ | | | |______ |______
2523 ; |__|__| |_____| | \_ | | | _____ ______| | |_____| | |
2524 ;_______________________________________________________________________________
2529 cal saverespawncounter
2535 jr DoesWormTailEqualsWormHead ;chk4 size=0
2539 jr nz,DoesWormTailEqualsWormHead
2540 inc (ix+grow+1) ;+256
2541 DoesWormTailEqualsWormHead:
2543 jr nz,removewormloop ;head=tail/size=0
2548 ld (ix+grow+1),a ;=0
2561 jr nz,saverespawncounter
2568 ld (ix+wdelay),a ;=0
2585 ld a,%01111111 ;default
2588 dnz bitmask ;a/8 times
2589 out (1),a ;send bitmask
2590 in a,(1) ;input keys
2595 dnz keybit ;check match (cf set)
2598 inkeys: ;use jp not call!
2617 jr z,inlink ;input by link
2618 cal inkeys ;input by keys
2622 ld c,l ;send our keys
2629 ;_______________________________________________________________________________
2630 ; _ _ _ _____ ______ _______ _______ _____ _ _ _______
2631 ; | | | | | |_____/ | | | |_____| | | \ / |______
2632 ; |__|__| |_____| | \_ | | | _____ | | |_____ __|__ \/ |______
2633 ;_______________________________________________________________________________
2672 ;--- move worm -----------------------------------------------------------------
2700 notmoveY: ;bc=newpos
2713 add a,h ;pixels moved |Dx|+|Dy|
2714 ld d,4 ;same pos = 4of4 bytes drawn
2716 xor 3 ;1 pixel = 2of4 blank; 2 pixels = 3of4 blank
2717 ld d,a ;#pixels that should be drawn
2719 cal chk4pixels ;d-=pixels at b,c
2720 rl d ;<0 meaning there were >d pixels
2721 cal c,hitworm ;so that wasn't us
2723 ;--- draw worm -----------------------------------------------------------------
2731 cal z,checkhitlapline
2737 ret z ;keep tail in "Tron"
2766 cal savetailpos ;ld (ix+tail),hl
2770 jr set4pixels ;redraw new last bit
2782 cal res4pixels ;rm last bit
2800 ;_______________________________________________________________________________
2801 ; ______ _____ _ _ __ _ _______ __ __ ______ _______
2802 ; |_____] | | | | | \ | | \_/ |_____] |_____| | |
2803 ; |_____] |_____| |_____| | \_| |_____ | |_____] | | |_____ |_____
2804 ;_______________________________________________________________________________
2806 handlethoseneatlittleballs:
2810 ret z ;no bouncies to handle
2856 bit 1,d ;1=up; 0=down
2886 letsmovetheotherway:
2901 ;_______________________________________________________________________________
2902 ; _ _ _ _____ ______ _______ __ __ _ _ _____ _______
2903 ; | | | | | |_____/ | | | \_/ |_____| | |
2904 ; |__|__| |_____| | \_ | | | | _____ | | __|__ |
2905 ;_______________________________________________________________________________
2907 ;--- multifood -----------------------------------------------------------------
2927 jr nz,chkmultpealoop
2936 ;--- ctf -----------------------------------------------------------------------
2939 ld hl,(peaspos) ;1st pea
2942 and %01 ;ourpea (0|1)
2944 ld hl,(peaspos+2) ;2nd pea
2949 ld a,e ;peek a (that's x86asm for pop\push ;)
2950 bit 1,a ;%1O = carrying flag?
2951 jr z,_wormdead ;if not just die
2953 ld hl,drawctfpea1 ;restore #1
2954 jr nz,nottheotherflag
2955 inc hl ;ld hl,drawctfpea2
2958 ld (hl),3 ;draw delay 3 turns
2962 hitflag: ;correct pea hit
2964 xor %11 ;invert flag taken + ownflag
2966 and %10 ;just returned?
2967 psh bc ;safe position
2972 ret nz ;flag taken: continue game ;drawworm
2973 ld e,20 ;flag captured+returned
2978 ld (drawctfpea1),a ;redraw..
2979 ld (drawctfpea2),a ;..both flags
2982 ;--- main ----------------------------------------------------------------------
2991 jr c,_wormdead ;no food
2993 ;--- foodmatch|SP --------------------------------------------------------------
3001 ;--- take pea ------------------------------------------------------------------
3007 cal DrawPea ;remove pea
3008 ld a,(ix+grow) ;grow
3016 dec (hl) ;dec left _before_ display
3021 ld c,(ix+pos) ;same position
3022 ld b,(ix+pos+1) ;we'll just leave pos2 - doubt anybody will care|notice..
3023 ret nz ;(Left)>0 ;drawworm
3026 jp nz,Exit ;stack restored
3037 cal _IncScore ;score+(40*level)
3039 pop hl ;<<call hitworm
3040 pop hl ;<<call HandleWorm
3041 pop hl ;<<$some other call
3045 chkpeahit: ;bc=ownpos;hl=peapos (destr:ad)
3060 ;--- misc ----------------------------------------------------------------------
3063 ld a,(peaspos) ;63 usually
3066 inc a ;(more checkin' since wormies just have those _huge_ heads ;)
3068 nextlaphalf: ;x==62|63; a=0
3069 ld a,(peaspos+1) ;yline
3072 jr nc,checklap ;y>yline -> a=1
3073 xor a ;y<yline -> a=0
3076 ret z ;same as before
3077 ld (ix+reserv),a ;1st time
3080 and 1 ;group 0 (1,3) or 1 (2,4)
3082 ret z ;(group 0 and y<yline) or (group 1 and y>yline)
3089 ;_______________________________________________________________________________
3090 ; _____ ______ _____ _______ _______
3091 ; |_____] |_____/ | | | |______
3092 ; | | \_ |_____| |_____ ______|
3093 ;_______________________________________________________________________________
3095 releasekeys: ;---------->promise me you'll never let go...
3096 halt ;-------------------->i won't let go....
3097 ld a,%10000000 ;all key-masks
3099 in a,(1) ;--------------->i'll never let go.....
3100 inc a ;cp %11111111 (no keys pressed)
3101 jr nz,releasekeys ;keep waitin
3102 cal GET_KEY ;clear buffer
3103 ret ;--------------------->*die* (we are VICTORIOUS! muha)
3109 scf ;not just even values:
3126 add hl,hl ;32=scr.width
3131 cal _MM_LDIR_SET_SIZE
3144 ld (ix+wdelay),rspawndelay
3163 ld (ix+pos2+1),a ;x2
3165 ld a,(handledworm) ;who are we? (1-4)
3166 cpl ;invert (just bit 0 actually)
3167 and 1 ;group 1 (1,3) or 0 (2,4)
3168 ld (ix+reserv),a ;reset halflap|flags to starting settings
3174 and _datadecs ;ctf and race no death penalty
3177 ret nz ;HandleWorm done
3179 or a ;0=no live limit
3180 ret z ;don't end game
3183 jr z,anyworm ;quit at any worm's death
3184 ld a,(nrworms) ;timematch: all worms must've died
3186 ld hl,worm1+lives-(worm2-worm1)
3188 xor a ;check for 0 lives
3190 add hl,de ;next worm
3192 ret nz ;any >0: don't exit
3195 ld a,$A7 ;exit@end of turn
3196 ld (CheckExit),a ;set exit state
3199 loadtxtgame: ;in:d=0; out:hl=txtGame+(gametype); destr:ade
3203 add hl,de ;hl=posGame+(gametype)
3204 ld a,(hl) ;str.offset
3208 ld (CURtxtGame),hl ;save for g/o
3211 CheckPea: ;@hl; destr:abcde
3224 ret nz ;nz=pixel found
3233 tryDrawPea: ;hl=peapos;bc=dopea
3242 dec (hl) ;hl=appeartime
3243 ex de,hl ;hl=peaspos
3265 ld de,$293A ;counter :)
3270 jp z,Exit ;break after 10554 tries to prevent freeze when field filled
3283 cal sendnewpeaoverlink
3293 PutSprite: ;||@(b,c)
3294 ;by SHIAR only ix saved
3331 ;_______________________________________________________________________________
3332 ; _______ _______ _____ ______ _______
3333 ; |______ | | | |_____/ |______
3334 ; ______| |_____ |_____| | \_ |______
3335 ;_______________________________________________________________________________
3366 jr nc,showstats ;<0=0
3372 add hl,de ;increase score
3375 jr z,scorecommon ;hl/1000 not increased
3380 ;piece of crap checking whether you've already won in timematch
3392 jr z,nneexxtt ;yourself
3394 ret nz ;someone else still alive
3399 jr c,nneexxtt_ ;you>him
3412 dnz chktimematchover
3415 IncScore: ;inc score by e
3417 _IncScore ; inc by de
3420 or a ;if singleplayer...
3422 add hl,de ;score+=de
3425 ld (ix+score),l ;save
3427 cal addteamscore ;cal=CD | ld de,*=11
3432 jr z,showstats ;de=0=no limit
3439 jr nz,timematchscore ;no disp for timematches
3457 shownameloop: ;1st 3 chars
3478 cal nz,showlives ;lives when initlives>0
3480 cal __vputmap ;small div
3483 cal nz,showscore ;score in !dm
3500 cshowA: ;small w/ leading 0; 0='none'
3508 cshowA00: ;small w/ leading 0
3525 showstatsS: ;(singleplayer)
3542 cal cshowA0 ;showlives
3565 showA0: ;big w/ leading 0
3586 ex de,hl ;ld hl,savestr
3594 ;_______________________________________________________________________________
3595 ; ______ _____ _______ _____ _______ __ __
3596 ; | \ | |______ |_____] | |_____| \_/
3597 ; |_____/ __|__ ______| | |_____ | | |
3598 ;_______________________________________________________________________________
3600 DisplayField: ;all done by Jonah Cohen iirc. (-scrolling is scary-)
3601 ld a,c ;not the fastest routine outthere, but it does get the job done.
3602 sub 29 ;if something doesn't work, I probably _did_ alter it ;)
3710 ld (ShiftRightCounter),a
3712 ld (ShiftRightChunk),a
3726 ShiftRightCounter = $-1
3748 ld (ShiftLeftCounter),a
3750 ld (ShiftLeftChunk),a
3752 jr nc,ShiftLeftSameByte
3771 ShiftLeftCounter = $-1
3782 jr nz,ShiftRowsRight
3816 ;_______________________________________________________________________________
3817 ; ______ ______ _______ _ _ _
3818 ; | \ |_____/ |_____| | | |
3819 ; |_____/ | \_ | | |__|__|
3820 ;_______________________________________________________________________________
3822 ;--- pixel ---------------------------------------------------------------------
3834 CheckPixel: ;at bc in d
3841 ;--- findpixel -----------------------------------------------------------------
3843 ;Based on Snake86's findpixel
3844 ;160-262 cycles; 31 bytes
3845 FindPixel: ;(b,c) to hl:a
3873 ;--- objects -------------------------------------------------------------------
3905 ;--- circle --------------------------------------------------------------------
3907 ;IMHO, one weery nice routine. Oh lemme be proud just *once*.
3908 ;Not perfect since it uses a screwy lineroutine to draw stuff
3909 ;but, just _look_ at it. Ain't it grand? Z80 at its best.
3910 ;Nice comments, also. So here we go: Shiar's Circle Routine:
3911 ;(using the Bresenham method)
3913 drawcircle: ;(d,e),h ;de=x,y; h=z
3924 ex (sp),hl ;push zz \ pop x,y
3925 cal circledraw ;(x-xx,y+yy)-(x+xx,y+yy)
3926 ;(x-xx,y-yy)-(x+xx,y-yy)
3927 cal circledraw ;(x-yy,y+xx)-(x+yy,y+xx)
3928 ;(x-yy,y-xx)-(x+yy,y-xx)
3930 ex (sp),hl ;push x,y \ pop zz
3933 dec a ;-256<h<0 = $FF**
3935 jr z,circlenext ;jump if zz<0
3939 add a,a ;a=2yy-2 ;nc
3941 sbc hl,de ;zz=zz-2yy+2
3949 add hl,de ;zz=zz+2xx+3
3958 circledraw: ;destr:de
3963 xor a ;left of screen -> x=0
3965 add hl,bc ;h=x+xx; l=y+yy
3967 cal drawline ;(h-b,l+c)-(h+b,l+c)
3972 xor a ;above screen -> y=0
3975 cal drawline ;(h-b,l-c)-(h+b,l-c)
3976 ld a,b ;swap xx and yy
3982 ;--- box -----------------------------------------------------------------------
3984 drawbox: ;(d,e)-(h,l)
3994 ;--- fatline -------------------------------------------------------------------
4008 ;--- line ----------------------------------------------------------------------
4010 ;A lot like Scabby's line routine in Wonderworm (dunno whether he wrote it
4011 ;himself tho.) I did make a few optimizations and commented the thing.
4012 ;A nice routine (also Bresenham), but for Wormy not perfect since really
4013 ;large lines (>128 pixels in length or something) won't be flawless.
4015 drawline: ;(d,e)-(h,l)
4021 jr c,lineXincs ;if x>xx
4023 lineXincs: ;deltax=|deltax|
4027 cal FindPixel ; (ahl=x+y)
4029 ld c,a ;c=mask (always)
4032 ld b,a ;b=deltax (always>0)
4034 jr nz,lineexists ;deltax!=0
4036 jr nz,lineexists ;deltay!=0
4038 jr DoneLine ;line is 1 pixel
4041 ld de,32 ;go down (def)
4042 jr nc,lineYincs ;cf = deltay<0
4045 lineYincs: ;lets assume y incs as well
4047 jr nc,SteepLine ;deltay<deltax?
4048 ld (line2sm+1),a ;a=deltay
4052 ld (line1sm+1),a ;a=-deltax
4054 add a,h ;a=deltay-deltax/2
4058 psh af ;init z=2dy-dx
4072 dnz linedrawxloop ;|deltax| times
4086 ld (line3sm+1),a ;=-deltay
4090 ld (line4sm+1),a ;=deltax
4091 add a,h ;a=deltax-deltay/2
4095 psh af ;init z=2dx-dy
4109 dnz linedrawyloop ;|deltay| times
4113 ;..and last but not least..:
4114 ;_______________________________________________________________________________
4116 ; | | | \ | |____/ /
4117 ; |_____ __|__ | \_| | \_ .
4118 ;_______________________________________________________________________________
4123 ;--- multiple bytes ------------------------------------------------------------
4148 ;--- foo -----------------------------------------------------------------------
4150 receivenewpeaoverlink:
4162 jr z,receivenewpeaoverlink
4163 ld c,l ;send pea's pos
4166 ; jr Qsend ;that's why it's here
4168 ;--- send ----------------------------------------------------------------------
4170 Qsend: ;--- try to send 8 bits in C; CF=error --- destr:abcde ---
4173 jr z,linkerr ;both wires low = exit signal
4174 ld b,8 ;bits to send
4177 rl c ;bit to send in cf
4178 ld a,D0LD1H ;0: lower white
4180 ld a,D0HD1L ;1: lower red
4182 out (7),a ;lower one (send bit)
4184 cal checklink ;other calc must lower other wire
4186 cal linkok ;raise one, ok to raise other (out (7),D0HD1H)
4189 cp %11 ;both raised (by other calc)
4192 dnz sendloop ;repeat for all bits
4194 ld (linklosses),a ;reset number of losses
4197 ;--- recv ----------------------------------------------------------------------
4199 Crecv: ;--- receive 8 bits into A/C --- destr:abCde ---
4201 ret nc ;return if all went ok
4202 jr Crecv ;and try again
4204 Qrecv: ;--- receive 8 bits into A/C; CF=error --- destr:abCde ---
4206 jr z,linkerr ;both low = error, quit
4207 ld b,8 ;bits to receive
4211 cal linktest ;checklink
4213 jr z,recvwait ;both high = nothing sent (yet)
4215 rra ;received bit in cf
4217 jr c,received ;lower white wire as well
4218 ld a,D0HD1L ;lower red
4221 out (7),a ;both wires low
4224 jr z,recvwaitack ;same wire will be raised again by other calc
4225 cal linkok ;raise both
4227 dnz recvloop ;repeat for all bits
4229 ld (linklosses),a ;reset number of losses
4232 ;--- common --------------------------------------------------------------------
4236 out (7),a ;raise both wires = link ok
4239 checklink: ;load wires in A and check for timeout
4240 dec de ;decrease timer
4243 jr z,linktimeout ;timeout if de==0
4246 out (1),a ;select keys
4249 jr z,linkerr ;break!
4256 ld a,0 ;losses so far
4258 inc a ;and this is another one
4260 pop de ;return from link
4261 cp lossout ;quit if too many errors
4262 ret c ;otherwise just continue
4267 ;_______________________________________________________________________________
4268 ; _____ __ _ _______ _______ _ _ _______ _______
4269 ; | | \ | | | |______ \ / |______ | |______
4270 ; __|__ | \_| | _____ |_____ |______ \/ |______ |_____ ______|
4271 ;_______________________________________________________________________________
4274 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
4275 .db 0,2,63 ;start d, y, x
4276 .db 128,57 ;field width (128-255), height (57-255)
4277 .db 0 ;no additional lines, boxes
4285 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
4289 .db "Fast Fun :))",0
4291 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4292 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
4298 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
4303 LevelDefT: ;tron=no delay
4304 .db "Empty Tron Level",0
4306 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4307 .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
4312 .db "Round and Round",0
4314 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4315 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
4323 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4324 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
4331 ;_______________________________________________________________________________
4332 ; ______ _______ _______ _______
4333 ; | \ |_____| | |_____|
4335 ;_______________________________________________________________________________
4337 ;--- graphics ------------------------------------------------------------------
4340 ; %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
4341 .db %00011110, %00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000
4342 .db %00111110, %00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000
4343 .db %01110000, %00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000
4344 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000
4345 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000
4346 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000
4347 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000
4348 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000
4349 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000
4350 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000
4351 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000
4352 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000
4353 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011
4354 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100
4355 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101
4356 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011
4360 .db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000
4361 .db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000
4362 .db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000
4363 .db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100
4364 .db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010
4365 .db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010
4366 .db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100
4367 ;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000
4369 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0
4372 ;--- menus ---------------------------------------------------------------------
4374 txtMenu: .db "Mode",0 ;1st menu item
4380 .dw $2418,$231E,$2824,$1F2A,$1730
4381 txtteamed: .db " vs 2",0 ;4th tail
4382 txtMenuR: .db "controls",0 ;6th
4384 txtoMenu: .db "Back",0 ;1st menu item
4391 .dw $2618,$251E,$2524,$222A,$1A30,$1C36
4393 txtpMenu: .db "Resume",0 ;1st menu item
4394 .db "Turn Off",0 ;2nd
4395 .db "Contrast",$CF,5,0 ;...
4398 .dw $3418,$331E,$2F24,$3A2A
4400 ;--- text ----------------------------------------------------------------------
4402 txtGame: .db "Singleplayer",0
4403 txtGame1: .db "Peaworm",0
4404 txtGame2: .db "Tron",0
4405 txtGame3: .db "Deathmatch",0
4406 txtGame4: .db "Foodmatch",0
4407 txtGame5: .db "Multifoodmatch",0
4408 txtGame6: .db "Timematch",0
4409 txtGame7: .db "Race",0
4410 txtGame8: .db "CTF";,0
4412 .db txtGame1-txtGame
4413 .db txtGame2-txtGame
4414 .db txtGame3-txtGame
4415 .db txtGame4-txtGame
4416 .db txtGame5-txtGame
4417 .db txtGame6-txtGame
4418 .db txtGame7-txtGame
4419 .db txtGame8-txtGame
4421 txtNone: .db "None",0
4422 txtDef: .db "Default",0
4425 txtKleft: .db ":left",0
4426 txtKright: .db "right",0
4428 txtLevsel: .db $CF," SELECT LEVELS ",5,0
4429 txtWaitn: .db "Waiting";"...",0
4430 txtReceiv: .db "...",0
4433 txtReady: .db "Prepare!",0
4436 txtLevel: .db "Level ",0
4437 txtWorms: .db "Worms: 0",0 ;follows txtLevel
4438 txtName: .db "Name",0
4439 txtWinner: .db "Wins",$D8 ;follows txtName
4440 txtDied: .db "Died",$D8 ;follows txtWinner
4441 txtScore: .db "Score",0 ;follows txtDied
4442 txtLeft: .db " left",0 ;follows txtScore
4443 txthiscore:.db "HiScore:";,0
4445 ;--- foo -----------------------------------------------------------------------
4447 trigtable: .db 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45
4448 .db 48, 51, 54, 57, 59, 62, 65, 67, 70, 73, 75, 78, 80, 82, 85, 87
4449 .db 89, 91, 94, 96, 98,100,102,103,105,107,108,110,112,113,114,116
4450 .db 117,118,119,120,121,122,123,123,124,125,125,126,126,126,126,126
4454 datalevels:.dw LevelDef,LevelDefM,LevelDefT,LevelDefM,LevelDefM
4455 .dw LevelDefM,LevelDefM,LevelDefR,LevelDefC
4456 nrlevels: .db 2,3,1,3,3,3,3,3,1,0
4458 .db 0,0,"SHI",0,0,"SHI",0,0,"SHI",0,0,"SHI",0,0,"SHI"
4463 ;--- game settings -------------------------------------------------------------
4467 worm1set: .dw worm1p
4468 .db %11110111,1,K_RIGHT,K_LEFT
4469 worm1name: .db "WORMY ",0 ;15 bytes
4470 worm2set: .dw worm2p
4471 .db %11111011,0,K_F2,K_F1
4472 worm2name: .db "VIPER ",0
4473 worm3set: .dw worm3p
4474 .db %11111011,1,K_COMMA,K_STO
4475 worm3name: .db "NIBBLER ",0
4476 worm4set: .dw worm4p
4477 .db %11111101,0,K_PLUS,K_ENTER
4478 worm4name: .db "JIM ",0
4480 _datalink = %00000001 ;linkplay (1!)
4481 _datafoodl = %00000010 ;left=0 limit
4482 _datasingl = %00000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel)
4483 _dataPctf = %00001000 ;ctf peas=1
4485 _datatime = %00010000 ;time incs score (timematch)
4486 _datadecs = %00100000 ;decrease score on death=1
4487 _datafood = %01000000 ;food present=0 (6!)
4488 _dataPmult = %10000000 ;multiple peas=1 (no _datafood) (7!)
4490 ; ┌game info (see above)
4491 ; │ ┌lives (0=unlimited)
4492 ; │ │ ┌nrworms (can be altered by user)
4493 ; │ │ │ ┌level (reset to 1 at startup)
4494 ; │ │ │ │ ┌speed/delay (-1=def)
4495 ; │ │ │ │ │ ┌grow speed (-1=none; 0=continuous)
4496 ; │ │ │ │ │ │ ┌turn speed (8=def)
4497 ; │ │ │ │ │ │ │ ┌score limit (0=none)
4498 gamesingle = 0 ; │ │ │ │ │ │ │ │
4499 datasingle:.db %00100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives)
4501 datapeas: .db %00100100,1,1,1,-1,126,8, 0 ;Peaworm (SP; 1 live, 127 growth)
4503 datatron: .db %01110100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
4505 datadeathm:.db %01100000,3,2,1,-1,42, 8, 0 ;Deathmatch (3 lives, 50 growth)
4507 datafoodm: .db %00100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
4509 datamfoodm:.db %11100010,0,2,1,-1,-1, 8,10 ;MuchFoodmatch (10 peas)
4511 datatimem: .db %01110000,1,2,1,-1, 0, 8, 0 ;Timematch (1 live, cont.growth)
4513 datarace: .db %01000000,0,2,1,-1,-1, 8,10 ;Race (100 score)
4515 datactf: .db %01001000,0,6,1,-1,-1, 8,10 ;CTF (100 score)
4517 gametype: .db 0 ;last gamemode
4518 gamecar: ;made before needed (not saved)
4529 defspr: .db %01100000
4534 deflevels: .db "Internal Levels",0
4537 .db 0,deflevels/256,deflevels&255
4541 ;_______________________________________________________________________________
4542 ; _______ _ _ _______ _______ . _______ _______
4543 ; | |_____| |_____| | ' |______ |_____| | |
4544 ; | | | | | | ______| _____ | | |_____ |_____
4545 ;_______________________________________________________________________________