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 : http://shiar.nl
24 ; License: : GNU General Public License version 3
25 ; Description : perfect Nibbles game with free movement, nine game
26 ; modes, for 1-4 players, many levels and editor
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 ;_______________________________________________________________________________
32 ;--- notes ---------------------------------------------------------------------
34 ; * Game README is wormy.txt
35 ; * All code under the GPL version 3
36 ; * You may alter and redistribute (parts of) this code
37 ; but only under the same license; credits would be appreciated
38 ; * I'm not responsible for any damage this might cause, yada yada...
39 ; * Although I've commented & labeled quite some stuff, due to
40 ; crazy optimizations and weird coding, it may be harder to
41 ; understand than the average blob of code. This is probably _not_
42 ; the best source to learn z80 from. w00t the Shyer Way (tm).
43 ; * Email me. If you've got suggestions|patches|questions: tell me.
44 ; * Don't scroll down if you get scared easily.
46 ;--- index ---------------------------------------------------------------------
48 ; * TO_DO : future features
50 ; * STORAGE : permanent; temporary; layout
51 ; * PROG_START : search levels
53 ; * MORE_INIT : trig tables
54 ; * MAIN_MENU : draw menu; options menu; main menu; display
55 ; current settings; handle menukeys; change name
57 ; * START_GAME : link; client; set/send worms; host; load game;
61 ; * GAME_OVER : who won?; display worms; quit
63 ; * WORM_ALIVE : move worm; draw worm
65 ; * WORMY_HIT : multifood; ctf; main; foodmatch|SP; take pea;
70 ; * DRAW : pixel; findpixel; objects; circle; box;
72 ; * LINK! : multiple bytes; foo; send; recv; common
74 ; * DATA : graphics; menus; text; foo; game settings
77 ;_______________________________________________________________________________
78 ; _______ _____ ______ _____
80 ; | |_____| ____ |_____/ |_____|
81 ;_______________________________________________________________________________
84 ; X [34] freeze when no space left to place pea (break after 10k tries)
85 ; X [34] wow another bit of code 'reniced' (easter egg or something :)
86 ; X [34] two more jp to jr
87 ; X [34] highly improved randomizer (values >127 were rare)
88 ; X [36] replace 'left' at the change-control prompt
89 ; X [36] ED: fixed immediate exit at level preview when using enter key
90 ; X [36] bouncies drawn after placing peas (causing overwrites)
91 ; X [36] FIX: skip string length bytes when running from yas
92 ; X [36] ED: pointer to ending message realigned
93 ; X [36] LVL: end messages fixed in affected episodes
95 ; * scorebar last digit (at 128-3) not displayed by _vputs :(
96 ; * save last played level (in levelfile prolly)
97 ; * automatically start players in multiplayer games after certain time
98 ; * muliplayer bonuses/powerups (shrink, lives, stun, inverse, etc.)
99 ; * levels with random pixels appearing during game
100 ; * no borders (move players from one side to another)
101 ; * hiding levels crashes?? (ishell 2.01 rom 1.6)
102 ; * use selected player on main menu as first player in singleplayer games
105 ;--- future features -----------------------------------------------------------
107 ;just a maybe-list; NO guarantees!
109 ; * correct team winners
110 ; * level compression
111 ; * ubersized bouncies (sprites)
112 ; * arrow to offscreen peas
116 ; * pause in linkplay
117 ; * coop (DON'T COUNT ON IT)
119 ;_______________________________________________________________________________
120 ; _/_/_____ __ _ _______ _ _ ______ _______
121 ; _/_/ | | \ | | | | | | \ |______
122 ; / / __|__ | \_| |_____ |_____ |_____| |_____/ |______
123 ;_______________________________________________________________________________
126 #include "ti86asm.inc"
132 _SHRACC = $4383 ;4x srl a
133 _SHLACC = $438B ;4x sll a
134 _divHLby10 = $4044 ;hl=hl/10
135 _divAby10 = $4DAF ;a=a/10
136 _HLTIMES10 = $41BF ;hl=hl*10
137 _cphlde = $403C ;cp hl,de
138 _clrWindow = $4A86 ;clear screen
139 _asapvar = $D6FC ;own name (worm)
140 _MOV4B = $429B ;4x ld (de),(hl)
141 _MOV5B = $4297 ;5x ld (de),(hl)
142 _mov9b = $4283 ;9x ld (de),(hl)
143 _ldHLind = $4010 ;ld hl,(hl)
144 _swapt_ = $45F3 ;ex ahl,bde (doesn't work?)
145 _Get_Word_ahl = $521D ;ld de,(ahl)
146 _Set_Word_ahl = $5221 ;ld (ahl),de
147 _INC_PTR_AHL = $4637 ;inc ahl
148 _AHL_PLUS_2_PG3 = $4C3F ;add ahl,2
149 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl
150 _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
151 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
152 _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl
153 _mm_ldir = $52ED ;24bit ldir
154 _MM_LDIR_SET_SIZE = $524D ;_SET_MM_NUM_BYTES + _mm_ldir
155 _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1
156 _RAM_PAGE_7 = $47F3 ;"""" 7
157 _PTEMP_END = $D29A ;end of VAT
158 _load_ram_ahl = $462F ;ahl->page+hl
159 _writeb_inc_ahl = $5567 ;ld (ahl++),c
160 _jforce = $409C ;TI-OS stack restored
161 _EXLP = $4493 ;swap (hl),(de) b times
162 _GETB_AHL = $46C3 ;a=(ahl) \ hl=ahl
165 #define id2 ;yas2 level identifier - this'll add (65) bytes
166 #define buffer ;use display buffer, otherwise write directly to screen (11)
167 #define readymask ;"greys" out the field before starting a level (20)
168 ;#define readytext ;-displays "prepare" before level starts (42)
169 #define coolzgfx ;nice graphics for game over screen (98)
170 #define spprotect ;options not changable for singleplayer modes
171 ;#define intlevels ;-internal levels
172 ;-to become invincible, define the magic word :D
175 levelhead2 = 97 ;wormy levels header = "0"
177 ;_______________________________________________________________________________
178 ; _______ _______ _____ ______ _______ ______ _______
179 ; |______ | | | |_____/ |_____| | ____ |______
180 ; ______| | |_____| | \_ | | |_____| |______
181 ;_______________________________________________________________________________
183 ;--- permanent -----------------------------------------------------------------
185 ScrBuffer = $8420 ;-A3FF (20*FF=1FE0)
186 worm4p = $A400 ;-A5FF (200) %101001O0
187 ;free = $A600 ;-A7FF (200)
188 worm2p = $A800 ;-ABFF (400) %10101O00
189 SinCosTable = $AC00 ;-AD00 (4*40)
190 worm1 = $AD01 ;-AD1E (1E)
191 worm2 = $AD1F ;-AD3C (1E)
192 worm3 = $AD3D ;-AD5A (1E)
193 worm4 = $AD5B ;-AD78 (1E)
194 balls = $AD79 ;-AE00 (<=3x2D) (bb<=45)
195 turn10 = $AE01 ;-AE01 (1) (counter)
196 peaspos = $AE02 ;-AF05 (4-104) (peas)
197 ;free = $AF06 ;-AFFF (F9)
198 worm1p = $B000 ;-B7FF (800) %1011O000
199 worm3p = $B800 ;-BBFF (400) %10111O00
200 ;buffer = $BC00 ;-BF90 (390)
201 ;free = $BF91 ;-BFFF (6F)
202 ;program = $D748 ;-EFFF (186D+4A) ;6327
203 leveldata = $F080 ;-F9FF (<=97F)
205 datalevels = $FA00 ;-FA11 (12) (>=$C000)
206 nrlevels = $FA12 ;-FA1B (A) (<$FA70)
207 defspr = $F078 ;-F07F (8)
210 ;MEM|8---9---A---B---C---D---E---F---| ;there's something wrong
211 ; |..[------]||[]|......[-----]|[].| ;if you still understand < OUTDATED <
212 ; | SCREEN 2* 13 PRGM 4LV | ;after looking at this
214 ;--- temporary -----------------------------------------------------------------
216 namelength = $BC00 ;(1) @menu
217 datalink = $BC00 ;(8) @init
219 DispBuffer = $BC00 ;(10x57d) @game
223 linklevel = $AECC ;(<=134) @game+init
224 lefttotalb = $BF91 ;(1) @game
225 drawctfpea1 = peaspos+4
226 drawctfpea2 = peaspos+6
228 ;--- layout --------------------------------------------------------------------
241 tail = 15 ; │also@next level
243 reserv = 18 ; │loop (race:lap|ctf:pea)
248 wormsize = 30 ;^mark^
250 ;_______________________________________________________________________________
251 ; _____ ______ _____ ______ _______ _______ _______ ______ _______
252 ; |_____] |_____/ | | | ____ |______ | |_____| |_____/ |
253 ; | | \_ |_____| |_____| _____ ______| | | | | \_ |
254 ;_______________________________________________________________________________
256 .org %1101011101001000
258 start: ;turn back NOW!
259 nop ;and so it begins...
288 .db 8,2 ;Rkaydees' icon:
289 .db %00000000,%00111100 ; XX
290 .db %00000000,%01010010 ; XXX
291 .db %00000000,%01100001 ; XX
292 .db %01100011,%10011001 ; XX
293 .db %10010100,%01101001 ; XX
294 .db %10011001,%00011001 ; XX
295 .db %01000010,%11000001 ; X XX
296 .db %00111100,%00111110 ; XXXX
304 .db "wor" ;description
305 .dw yasexec ;execution routine
306 .dw yascomment-yasdetect
307 .dw yasdetect-$-1 ;detection routine
308 .dw yasicon-yascomment
309 .dw yascomment-$-1 ;comment routine
310 .dw yasdataend-yasicon
311 .dw yasicon-$-1 ;icon routine
316 cal _AHL_PLUS_2_PG3 ;skip past length bytes
317 cal skiptitle ;title (plus size+header <- all non-0)
318 ; cal skiptitle ;description
321 cal _AHL_PLUS_2_PG3 ;skip past length bytes
323 ld hl,levelhead+(levelhead2*256)
333 ld hl,$F400+levelicon-yasicon
338 .db %00011100 ;..XXX... ...XXX..
339 .db %00011110 ;.X...X.. ...XXXX.
340 .db %00000011 ;.X..X... ......XX
341 .db %10000001 ;X..X..XX X......X
342 .db %01011011 ;X..X..XX .X.XX.XX
343 .db %01101110 ;X...XXX. .XX.XXX.
357 ;--- search levels -------------------------------------------------------------
364 ld hl,$BFFF ;VAT start
367 ld de,(_PTEMP_END+1) ;VAT end
394 ex de,hl ;ld ahl,(hl)
395 cal _AHL_PLUS_2_PG3 ;string id
396 cal _Get_Word_ahl ;ld de,(ahl)
400 jr nz,_searchnext ;not worm
404 ld (ix+1),h ;save level's ahl
414 cal _Get_Word_ahl ;ld de,(ahl++)
416 ld a,e ;set new level
428 ;_______________________________________________________________________________
429 ; _______ _ _ _______ _______ _______ _______ _______
430 ; | |______ \ / |______ |______ | |______ | |
431 ; |_____ |______ \/ _____ ______| |______ |_____ |______ |_____ |
432 ;_______________________________________________________________________________
444 jp z,ExitNoStats ;->no lvls
446 jr z,loadlevel1 ;->1 lvl
447 levelselectmenu: ;load next page
455 cal _vputs ;"< SELECT LEVELS >"
459 ld hl,$FC00+$380 ;(*,56)
469 cal _load_ram_ahl ;hl=ahl
482 cp 49 ;bottom of screen
492 readylevelfile: ;selected level at ahl
493 ; ld hl,templevels-3/0
495 add a,3 ;sellev+3 (#0==-3)
511 cal _GETB_AHL ;ld a,(ahl)
516 cal _INC_PTR_AHL ;ahl++
518 jr nz,skiptitle ;goto #0-terminator
544 cal _load_ram_ahl ;hl=ahl
545 ld de,$FFA0 ;desc.text
550 cp d ;de>$FFFF (offscreen)
551 jr nz,levdescclearloop
553 jr levselectmenuloop+1
556 ld ix,templevels-6 ;reset 2 1st page
561 ld b,-2 ;level selected
567 pop bc ;GET_KEY destr. b
580 jr nz,levselectmenuloop
586 or a ;levelfile on page 0 (=internal)
589 cal skiptitle ;skip description
592 ld (leveldataSize),de
597 ld (hilvlposa),a ;singleplayer levels
602 cal _SET_ABS_SRC_ADDR ;levelsstart
605 cal _SET_ABS_DEST_ADDR ;store in mem.
608 cal _MM_LDIR_SET_SIZE
610 cal _LOAD_ABS_SRC_ADDR ;->ahl
617 ldi ;(de),(hl)\inc hl
622 ;_______________________________________________________________________________
623 ; _______ _____ ______ _______ _____ __ _ _____ _______
624 ; | | | | | |_____/ |______ | | \ | | |
625 ; | | | |_____| | \_ |______ _____ __|__ | \_| __|__ |
626 ;_______________________________________________________________________________
628 ; cal _runindicoff ;this is after level selection (run from yas1 or restart)
629 ; cal _flushallmenus ;so this stuff should already be done earlier or by yas
646 ld bc,int_end-int_handler
650 im 2 ;...it *does* work ;)
652 res 2,(iy+13) ;appAutoScroll
660 ld (hl),1 ;def=level#1
664 ;--- trig tables ---------------------------------------------------------------
666 ld hl,trigtable ;I believe this
667 ld de,SinCosTable ;is one of the few
668 psh de ;pieces of original
669 ld bc,65 ;Peaworm code still
689 ;_______________________________________________________________________________
690 ; _______ _______ _____ __ _ _______ _______ __ _ _ _
691 ; | | | |_____| | | \ | | | | |______ | \ | | |
692 ; | | | | | __|__ | \_| _____ | | | |______ | \_| |_____|
693 ;_______________________________________________________________________________
695 ;--- draw menu -----------------------------------------------------------------
703 optimize__w00t: ;may look like crap, but actually saves 3 bytes!
715 ld hl,$FC00+$010 ;(*,01)
717 ld hl,$FC00+$160 ;(*,22)
719 ld hl,$FC00+$3E0 ;(*,62)
723 dec a ;will be inced @changegame
725 ld hl,changegame ;dispmenusets ;mainMenu
726 psh hl ;jump here after ret
729 ;Mode|Level|Link|Worms|worm #|controls
730 ; jr dispmenucommon ;cal
735 ld de,$FD80 ;begin pos
742 jr nz,clroldmenuloop+2
757 hr: ;draw horizontal line at hl
759 ; jp menuinvloop ;shorter but not good for pausescreen
766 ;--- options menu --------------------------------------------------------------
771 ;Back|Lives|Limit|Speed|Rotation|Growth
778 jp nz,LetsGetThisPartyOn ;SP -> start game
791 inc hl \ inc hl \ inc hl
809 inc a ;-1=None; 0..98->1..99
824 cal cshowA ;turn speed
831 ld a,(hl) ;(scorelimit)
836 jr z,optionMenu ;do not display 0 behind 'None'
839 jr nz,optionMenu ;in multifood limit == #peas
851 jp z,dispmainmenu ;mainMenu
895 cal loadgamecar ;a=(hl)
898 jr nc,optionMenu ;>99
902 jp dispomenusets ;optionMenu
905 sub 1 ;dec does not set cf
913 jr nc,optionMenu ;>99
916 jr _dispomenusets ;optionMenu
919 sub 1 ;dec does not set cf
926 ld a,(hl) ;(scorelimit)
933 jr nc,_optionMenu ;>98
937 jr _dispomenusets ;optionMenu
943 jr z,_optionMenu ;<-1
950 inc hl ;=saves 2 bytes :P
959 jr nc,_optionMenu ;>25
962 jr _dispomenusets ;optionMenu
977 jr nc,_optionMenu ;>98
980 jr _dispomenusets ;optionMenu
986 jr z,__optionMenu ;<-1
989 ;--- main menu -----------------------------------------------------------------
998 dec a ;2nd item: level
1000 sub 3 ;5th item: wormname
1002 dec a ;6th: controls
1004 jp LetsGetThisPartyOn ;otherwise
1008 ld a,(hl) ;hl=nrworms
1011 jr nc,mainMenu ;may not be >4+2
1014 jr _dispmenusets ;mainMenu
1042 ; jr z,changecurworm
1048 jr nc,mainMenu ;may not become >4
1050 jr _dispmenusets ;mainMenu
1063 ; jr z,bchangecurworm
1069 jr nz,_dispmenusets ;save >0
1076 ld a,(hl) ;hl=nrworms
1079 jr nc,changednrworms ;save >=2
1087 jr _mainMenu ;don't change for singleplayer
1092 dec hl ;inced earlier
1094 ld a,1 ;change LS-bit (=link)
1098 jr dispmenusets ;mainMenu
1105 jr dispmenusets ;mainMenu
1123 jr dispmenusets ;mainMenu
1126 inc hl ;hl=loadgamecar+2
1128 ld a,(hl) ;(curlevel)
1130 cp (hl) ;max level for sel.game
1136 jr dispmenusets ;mainMenu
1139 ld a,(hl) ;(curlevel)
1144 getnrlevels: ;for current gametype at hl
1164 jr z,waitcustomkey ;ignore
1171 cal getcustomkey ;left
1174 cal getcustomkey ;right
1177 ;--- display current settings --------------------------------------------------
1184 cal _vputs ;Singleplayer or smtn
1240 ld hl,$363E ;controls
1246 ;--- handle menukeys -----------------------------------------------------------
1254 pop bc ;GET_KEY destr. b
1264 menupos: ;highlight #b
1277 add hl,hl ;$FD20+item*96
1307 ;--- change name ---------------------------------------------------------------
1309 getwormname: ;of (curworm)
1337 ld hl,$FF07 ;begin pos
1344 ld (ix),a ;clroldcustom -> a=0
1370 dec (hl) ;(namelength)
1384 .db ".<>!" ;down|L|R|up|-|-|-|-|[enter]
1385 .db "w00t!" ;(makes code look way better)
1386 .db "XTOJE0",'w' ;+|-|*|/|^|clear|- w
1387 .db " WSNID9",$F8 ;(-)|3|6|9|)|tan|custom|- o
1388 .db "ZVRMHC8",$A7 ;.|2|5|8|(|cos|prgm|[del] o
1389 .db "YUQLGB7#",$C2 ;0|1|4|7|ee|sin|table|xvar|[on] t
1390 .db "-PKFA6'" ;sto|,|x2|ln|log|graph|alpha
1391 .db "54321*",$AE,$D0 ;F5|F4|F3|F2|F1|2nd|[exit]|more
1395 ld (ix+8),d ;end mark
1398 ;_______________________________________________________________________________
1399 ; _______ _____ _______ _______ _____ ______ _____ _______ _______
1400 ; | | | | |______ | |_____] |_____/ | | | |______
1401 ; | | | __|__ ______| |_____ _____ | | \_ |_____| |_____ ______|
1402 ;_______________________________________________________________________________
1406 halt ;save them batteries! yeah!
1409 clrold: ;destr:acdehl (acd=0)
1410 ld hl,$FD97 ;begin pos
1411 ld a,35 ;nr of lines
1413 ld de,7 ;bytes to add
1415 ld c,9 ;bytes to clear
1420 jr nz,clroldsetsloop
1423 jr nz,clroldsettings
1426 hlatlevel: ;d must be 0
1433 cal _ldHLind ;ld hl,(hl)
1434 ex (sp),hl ;hl=loadgamecar
1437 ld a,(hl) ;(curlevel)
1442 dec c ;levels to skip
1446 ret ;hl=begin of correct level
1448 skiplvltitle: ;zf=singleplayer
1450 or a ;null-terminator
1455 skiplevel: ;@hl; de=2 - destr:ab - alter:hl
1462 ld b,(hl) ;spritesize
1470 pop af ;cp (gametype),0
1472 inc b ;multiplayer lvl
1474 inc b ;skip other 3 worms (9 bytes)
1479 sub gamerace ;a=(gametype)
1498 ;build: c=(gamecar)=(hl-1)
1499 ; a=(wormbeglives)=(hl)
1505 add a,a ;8 bytes per mode
1517 ;_______________________________________________________________________________
1518 ; _______ _______ _______ ______ _______ ______ _______ _______ _______
1519 ; |______ | |_____| |_____/ | | ____ |_____| | | | |______
1520 ; ______| | | | | \_ | _____ |_____| | | | | | |______
1521 ;_______________________________________________________________________________
1525 ld (CheckExit),a ;set exit state
1530 ld a,4 ;4x (all worms)
1540 ld (hl),b ;+score+1=0
1543 ld (hl),c ;+wdelay=2
1548 ex de,hl ;de=wormX+head
1549 ldir ;+head=+tail (2)
1552 ld c,wormsize-tail ;=bc
1555 jr nz,createwormsloop
1557 OhMyGodItsALabel: ;pj34r my coding skillz
1561 ex (sp),hl ;pop \ psh leveldata
1562 psh hl ;psh loadgamecar
1567 ;--- link ----------------------------------------------------------------------
1583 ;--- client --------------------------------------------------------------------
1587 ; cal _puts ;shouldnt be necessary since this part always seems to work afaik
1589 ;name/keys: wormy#1 = worm #1 = ok
1590 ; 2 = link = 0 + link (name1)
1591 ; 3 = worm #2 = #2 + local(name2)
1592 ; 4 = link = 0 + link (name2)
1593 ld e,worm3+wleft&255
1597 ld l,worm2+wleft&255
1598 cal linkworm ;worm2+4 over link
1606 cal recvstuff ;game setup
1607 ld hl,gametype ;+gamecar
1609 cal recvstuff ;transmit game
1612 cal recvstuff ;level
1614 cal loadtxtgame ;set CURtxtGame
1621 jp DisplayMenu ;return to menu
1623 ;--- set/send worms ------------------------------------------------------------
1627 moveworm: ;hl=wormN+wleft
1630 ldir ;keys+name worm(de) = worm(hl)
1632 linkworm: ;hl=wormN+wleft
1633 ld (hl),0 ;worm1|2+wleft
1638 ld bc,worm3-worm1-11 ;+2
1640 ld (hl),b ;worm3|4+wleft
1645 sendworm: ;hl=wormN+name
1649 add hl,bc ;worm(N+2)+name
1653 ;--- host ----------------------------------------------------------------------
1661 ;name/keys: wormy#1 = link = 0 + link (name1)
1662 ; 2 = worm #1 = #1 + local(name1)
1663 ; 3 = link = 0 + link (name2)
1664 ; 4 = worm #2 = #2 + local(name2)
1665 ld e,worm4+wleft&255
1667 ld e,worm2+wleft&255
1670 ld l,worm1+wleft&255
1671 cal linkworm ;worm1+3 over link
1679 cal sendstuff ;setup
1680 ld hl,gametype ;+gamecar
1685 cal sendstuff ;level
1687 ;--- load level ----------------------------------------------------------------
1694 ld b,$11 ;=ignore (ld)
1699 ld b,$CD ;=continue (call)
1703 ld (doteam),a ;do team score (CD) or not (11)
1715 ld (turnright),a ;more efficient
1727 cal _HLTIMES10 ;hl=10*(hl)
1732 pop hl ;begin of current level
1739 dec (hl) ;curlevel-- (not beyond last lvl)
1742 ;show end msg or smtn
1744 psh bc ;where to go afterwards
1745 inc hl ;location of ending-code
1746 jp (hl) ;go there ("call")
1757 rlc (hl) ;bit 7 of (hl)...
1758 rra ;...to bit 7 of (gamecar)
1759 rrc (hl) ;restore (hl)
1762 and 127 ;actual #peas
1780 ld a,(hl) ;speed from level
1784 ld (de),a ;custom speed
1798 ld b,0 ;bc=sprite size
1799 add hl,bc ;hl=behind sprite
1803 ld a,42 ;always overwritten
1810 setsprite: ;de=@sprite ;a=sprsize
1834 pop af ;cp (gametype),0
1842 ld a,SinCosTable/256
1859 ld bc,(worm2-worm1)-7
1868 ;--- draw level ----------------------------------------------------------------
1896 ld bc,63 ;first 2 rows
1898 ldir ;draw upper border
1900 ld (hl),%11000000 ;first left border
1905 inc hl ;clear rest of line
1945 cp gamerace ;or gamectf
1946 jr c,levelhasbeensetup
1948 ld c,2 ;ld bc,2 (2 bytes)
1949 jr z,loadextralevelstuff ;cp gamerace
1950 ld c,4 ;ld bc,4 (2nd flag in ctf)
1951 loadextralevelstuff:
1960 ;--- prepare -------------------------------------------------------------------
1963 psh hl ; >> levelp new
1965 cal handlethoseneatlittleballs
1969 cal c,multnewpea ;a=0
1978 ld de,57*256+%10101010
1999 ld hl,4+(txtposReady*256)
2013 ;_______________________________________________________________________________
2014 ; ______ _______ _______ _______ _____ _____ _____
2015 ; | ____ |_____| | | | |______ | | | | | |_____]
2016 ; |_____| | | | | | |______ _____ |_____ |_____| |_____| |
2017 ;_______________________________________________________________________________
2020 ld bc,(worm1+pos) ;camera worm #1
2022 or a ;if #1 not over link
2024 ld bc,(worm2+pos) ;otherwise view from #2
2026 cal DisplayField ;display piece of level
2041 jr nz,screeninvertloop
2054 ld (handledworm),a ;reset
2072 jr nz,nodispupdate ;just once every 10 turns
2073 ld (hl),10 ;reset counter
2074 cal forceshowstats ;update score
2079 jr nz,noctfpeas2draw
2082 cal tryDrawPea ;pea#1
2085 cal tryDrawPea ;pea#2
2088 cal handlethoseneatlittleballs
2101 inc (hl) ;0..nrworms-1
2104 ;_______________________________________________________________________________
2105 ; _ _ _______ __ __ _______
2106 ; |____/ |______ \_/ |______
2107 ; | \_ |______ | ______|
2108 ;_______________________________________________________________________________
2117 rla ;=$17 (c=EXIT-key)
2122 ;--- pause menu ----------------------------------------------------------------
2127 ;Resume|Turn Off|Contrast|Exit||
2130 ld hl,$FC00+$170 ;(*,23)
2132 ld hl,$FC00+$310 ;(*,49)
2203 ;_______________________________________________________________________________
2204 ; ______ _______ _______ _______ _____ _ _ _______ ______
2205 ; | ____ |_____| | | | |______ | | \ / |______ |_____/
2206 ; |_____| | | | | | |______ _____ |_____| \/ |______ | \_
2207 ;_______________________________________________________________________________
2214 out (7),a ;both wires low = game over signal
2223 cal menuinvloop ;invert
2225 cal hr ;menuinvloop w/ b=16
2235 cal menuinvloop ;invert
2237 cal hr ;menuinvloop w/ b=16
2256 cal _vputs ;Died Score
2260 ;--- who won? ------------------------------------------------------------------
2273 jr c,nonewwinner ;h<d
2274 jr nz,newwinner ;h>d
2277 jr nc,nonewwinner ;l<e
2288 cpl ;high value (>$FB)
2293 ld a,(hl) ;less deaths
2300 ;--- display worms -------------------------------------------------------------
2302 ;x123456789012345678901
2303 ;>>>>>> GAME OVER <<<<<
2308 ;6Worm#02 @ 05 00120
2322 cp (hl) ;wleft=0 = link
2339 ld a,(hl) ;worm+died
2346 jr nz,nodmwinner ;deathmatch?
2347 ld a,0 ;winner's deaths
2349 cp (hl) ;equals this worm?
2350 scf ;jr nz,notwinner
2353 jr c,notwinner ;no singleplayer winners
2355 cal _ldHLind ;ld hl,(hl)
2358 cal _cphlde ;==highest score..
2374 dnz displayWormStats
2378 or a ;singleplayer (0) only
2379 jr nz,hilevelcheckdone
2384 jr c,hilevelcheckdone
2385 ld (hl),a ;save local
2390 hilvlposhl =$-2 ;save external
2391 cal _writeb_inc_ahl ;ld (ahl),c
2397 jr z,hiscorecheckdone ;no SP
2399 cal loadhiscoreposinahl ;cf=0 (and)
2400 cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile)
2403 ;Be Root to fix a Unix problem
2405 ;ReBoot to fix a Windows problem
2406 cal _SET_ABS_DEST_ADDR ;to local
2407 ;W00t W00t to fix an assembly problem
2408 cal mmldir5 ;get old score+name
2409 ld de,(savestr) ;de=prev. hiscore
2410 ld hl,(worm1+score) ;hl=worm1's score
2411 cal _cphlde ;sub hl,de
2412 jr c,NotNewHigh ;new<old
2413 jr z,NotNewHigh ;new<=old
2415 ld (savestr),hl ;store new hiscore
2417 ld hl,worm1+name ;from
2419 ldir ;store new hiname
2420 cal loadhiscoreposinahl ;cf=0 (jr c)
2421 cal _SET_ABS_DEST_ADDR ;to ahl
2424 cal _SET_ABS_SRC_ADDR ;from local
2425 cal mmldir5 ;save new score+name
2459 loadhiscoreposinahl:
2466 ld a,(nrlevels+1) ;skip peaworm slots if tron mode
2470 ld b,a ;levels to skip (including 1 for singleplayer)
2471 ld de,5 ;to add per level
2473 add hl,de ;one word+3 bytes for name
2474 dnz addlevelposition
2481 adc a,0 ;ahl=saveloc
2483 savestr: ;hiscore (01ABC) _D_HL_DECI (01234)
2490 jp _putc ;..then put *
2492 ;--- quit ----------------------------------------------------------------------
2497 rst 20h ;_ABS_MOV10TOOP1
2499 ld hl,savestart-_asm_exec_ram+4
2503 cal _SET_ABS_DEST_ADDR
2507 cal _SET_ABS_SRC_ADDR
2508 ld hl,saveend-savestart
2509 cal _MM_LDIR_SET_SIZE
2517 ;_______________________________________________________________________________
2518 ; _ _ _ _____ ______ _______ _______ _______ _ _ _______ _______
2519 ; | | | | | |_____/ | | | |______ | | | |______ |______
2520 ; |__|__| |_____| | \_ | | | _____ ______| | |_____| | |
2521 ;_______________________________________________________________________________
2526 cal saverespawncounter
2532 jr DoesWormTailEqualsWormHead ;chk4 size=0
2536 jr nz,DoesWormTailEqualsWormHead
2537 inc (ix+grow+1) ;+256
2538 DoesWormTailEqualsWormHead:
2540 jr nz,removewormloop ;head=tail/size=0
2545 ld (ix+grow+1),a ;=0
2558 jr nz,saverespawncounter
2565 ld (ix+wdelay),a ;=0
2582 ld a,%01111111 ;default
2585 dnz bitmask ;a/8 times
2586 out (1),a ;send bitmask
2587 in a,(1) ;input keys
2592 dnz keybit ;check match (cf set)
2595 inkeys: ;use jp not call!
2614 jr z,inlink ;input by link
2615 cal inkeys ;input by keys
2619 ld c,l ;send our keys
2626 ;_______________________________________________________________________________
2627 ; _ _ _ _____ ______ _______ _______ _____ _ _ _______
2628 ; | | | | | |_____/ | | | |_____| | | \ / |______
2629 ; |__|__| |_____| | \_ | | | _____ | | |_____ __|__ \/ |______
2630 ;_______________________________________________________________________________
2669 ;--- move worm -----------------------------------------------------------------
2697 notmoveY: ;bc=newpos
2710 add a,h ;pixels moved |Dx|+|Dy|
2711 ld d,4 ;same pos = 4of4 bytes drawn
2713 xor 3 ;1 pixel = 2of4 blank; 2 pixels = 3of4 blank
2714 ld d,a ;#pixels that should be drawn
2716 cal chk4pixels ;d-=pixels at b,c
2717 rl d ;<0 meaning there were >d pixels
2718 cal c,hitworm ;so that wasn't us
2720 ;--- draw worm -----------------------------------------------------------------
2728 cal z,checkhitlapline
2734 ret z ;keep tail in "Tron"
2763 cal savetailpos ;ld (ix+tail),hl
2767 jr set4pixels ;redraw new last bit
2779 cal res4pixels ;rm last bit
2797 ;_______________________________________________________________________________
2798 ; ______ _____ _ _ __ _ _______ __ __ ______ _______
2799 ; |_____] | | | | | \ | | \_/ |_____] |_____| | |
2800 ; |_____] |_____| |_____| | \_| |_____ | |_____] | | |_____ |_____
2801 ;_______________________________________________________________________________
2803 handlethoseneatlittleballs:
2807 ret z ;no bouncies to handle
2853 bit 1,d ;1=up; 0=down
2883 letsmovetheotherway:
2898 ;_______________________________________________________________________________
2899 ; _ _ _ _____ ______ _______ __ __ _ _ _____ _______
2900 ; | | | | | |_____/ | | | \_/ |_____| | |
2901 ; |__|__| |_____| | \_ | | | | _____ | | __|__ |
2902 ;_______________________________________________________________________________
2904 ;--- multifood -----------------------------------------------------------------
2924 jr nz,chkmultpealoop
2933 ;--- ctf -----------------------------------------------------------------------
2936 ld hl,(peaspos) ;1st pea
2939 and %01 ;ourpea (0|1)
2941 ld hl,(peaspos+2) ;2nd pea
2946 ld a,e ;peek a (that's x86asm for pop\push ;)
2947 bit 1,a ;%1O = carrying flag?
2948 jr z,_wormdead ;if not just die
2950 ld hl,drawctfpea1 ;restore #1
2951 jr nz,nottheotherflag
2952 inc hl ;ld hl,drawctfpea2
2955 ld (hl),3 ;draw delay 3 turns
2959 hitflag: ;correct pea hit
2961 xor %11 ;invert flag taken + ownflag
2963 and %10 ;just returned?
2964 psh bc ;safe position
2969 ret nz ;flag taken: continue game ;drawworm
2970 ld e,20 ;flag captured+returned
2975 ld (drawctfpea1),a ;redraw..
2976 ld (drawctfpea2),a ;..both flags
2979 ;--- main ----------------------------------------------------------------------
2988 jr c,_wormdead ;no food
2990 ;--- foodmatch|SP --------------------------------------------------------------
2998 ;--- take pea ------------------------------------------------------------------
3004 cal DrawPea ;remove pea
3005 ld a,(ix+grow) ;grow
3013 dec (hl) ;dec left _before_ display
3018 ld c,(ix+pos) ;same position
3019 ld b,(ix+pos+1) ;we'll just leave pos2 - doubt anybody will care|notice..
3020 ret nz ;(Left)>0 ;drawworm
3023 jp nz,Exit ;stack restored
3034 cal _IncScore ;score+(40*level)
3036 pop hl ;<<call hitworm
3037 pop hl ;<<call HandleWorm
3038 pop hl ;<<$some other call
3042 chkpeahit: ;bc=ownpos;hl=peapos (destr:ad)
3057 ;--- misc ----------------------------------------------------------------------
3060 ld a,(peaspos) ;63 usually
3063 inc a ;(more checkin' since wormies just have those _huge_ heads ;)
3065 nextlaphalf: ;x==62|63; a=0
3066 ld a,(peaspos+1) ;yline
3069 jr nc,checklap ;y>yline -> a=1
3070 xor a ;y<yline -> a=0
3073 ret z ;same as before
3074 ld (ix+reserv),a ;1st time
3077 and 1 ;group 0 (1,3) or 1 (2,4)
3079 ret z ;(group 0 and y<yline) or (group 1 and y>yline)
3086 ;_______________________________________________________________________________
3087 ; _____ ______ _____ _______ _______
3088 ; |_____] |_____/ | | | |______
3089 ; | | \_ |_____| |_____ ______|
3090 ;_______________________________________________________________________________
3092 releasekeys: ;---------->promise me you'll never let go...
3093 halt ;-------------------->i won't let go....
3094 ld a,%10000000 ;all key-masks
3096 in a,(1) ;--------------->i'll never let go.....
3097 inc a ;cp %11111111 (no keys pressed)
3098 jr nz,releasekeys ;keep waitin
3099 cal GET_KEY ;clear buffer
3100 ret ;--------------------->*die* (we are VICTORIOUS! muha)
3106 scf ;not just even values:
3123 add hl,hl ;32=scr.width
3128 cal _MM_LDIR_SET_SIZE
3141 ld (ix+wdelay),rspawndelay
3160 ld (ix+pos2+1),a ;x2
3162 ld a,(handledworm) ;who are we? (1-4)
3163 cpl ;invert (just bit 0 actually)
3164 and 1 ;group 1 (1,3) or 0 (2,4)
3165 ld (ix+reserv),a ;reset halflap|flags to starting settings
3171 and _datadecs ;ctf and race no death penalty
3174 ret nz ;HandleWorm done
3176 or a ;0=no live limit
3177 ret z ;don't end game
3180 jr z,anyworm ;quit at any worm's death
3181 ld a,(nrworms) ;timematch: all worms must've died
3183 ld hl,worm1+lives-(worm2-worm1)
3185 xor a ;check for 0 lives
3187 add hl,de ;next worm
3189 ret nz ;any >0: don't exit
3192 ld a,$A7 ;exit@end of turn
3193 ld (CheckExit),a ;set exit state
3196 loadtxtgame: ;in:d=0; out:hl=txtGame+(gametype); destr:ade
3200 add hl,de ;hl=posGame+(gametype)
3201 ld a,(hl) ;str.offset
3205 ld (CURtxtGame),hl ;save for g/o
3208 CheckPea: ;@hl; destr:abcde
3221 ret nz ;nz=pixel found
3230 tryDrawPea: ;hl=peapos;bc=dopea
3239 dec (hl) ;hl=appeartime
3240 ex de,hl ;hl=peaspos
3262 ld de,$293A ;counter :)
3267 jp z,Exit ;break after 10554 tries to prevent freeze when field filled
3280 cal sendnewpeaoverlink
3290 PutSprite: ;||@(b,c)
3291 ;by SHIAR only ix saved
3328 ;_______________________________________________________________________________
3329 ; _______ _______ _____ ______ _______
3330 ; |______ | | | |_____/ |______
3331 ; ______| |_____ |_____| | \_ |______
3332 ;_______________________________________________________________________________
3363 jr nc,showstats ;<0=0
3369 add hl,de ;increase score
3372 jr z,scorecommon ;hl/1000 not increased
3377 ;piece of crap checking whether you've already won in timematch
3389 jr z,nneexxtt ;yourself
3391 ret nz ;someone else still alive
3396 jr c,nneexxtt_ ;you>him
3409 dnz chktimematchover
3412 IncScore: ;inc score by e
3414 _IncScore ; inc by de
3417 or a ;if singleplayer...
3419 add hl,de ;score+=de
3422 ld (ix+score),l ;save
3424 cal addteamscore ;cal=CD | ld de,*=11
3429 jr z,showstats ;de=0=no limit
3436 jr nz,timematchscore ;no disp for timematches
3454 shownameloop: ;1st 3 chars
3475 cal nz,showlives ;lives when initlives>0
3477 cal __vputmap ;small div
3480 cal nz,showscore ;score in !dm
3497 cshowA: ;small w/ leading 0; 0='none'
3505 cshowA00: ;small w/ leading 0
3522 showstatsS: ;(singleplayer)
3539 cal cshowA0 ;showlives
3562 showA0: ;big w/ leading 0
3583 ex de,hl ;ld hl,savestr
3591 ;_______________________________________________________________________________
3592 ; ______ _____ _______ _____ _______ __ __
3593 ; | \ | |______ |_____] | |_____| \_/
3594 ; |_____/ __|__ ______| | |_____ | | |
3595 ;_______________________________________________________________________________
3597 DisplayField: ;all done by Jonah Cohen iirc. (-scrolling is scary-)
3598 ld a,c ;not the fastest routine outthere, but it does get the job done.
3599 sub 29 ;if something doesn't work, I probably _did_ alter it ;)
3707 ld (ShiftRightCounter),a
3709 ld (ShiftRightChunk),a
3723 ShiftRightCounter = $-1
3745 ld (ShiftLeftCounter),a
3747 ld (ShiftLeftChunk),a
3749 jr nc,ShiftLeftSameByte
3768 ShiftLeftCounter = $-1
3779 jr nz,ShiftRowsRight
3813 ;_______________________________________________________________________________
3814 ; ______ ______ _______ _ _ _
3815 ; | \ |_____/ |_____| | | |
3816 ; |_____/ | \_ | | |__|__|
3817 ;_______________________________________________________________________________
3819 ;--- pixel ---------------------------------------------------------------------
3831 CheckPixel: ;at bc in d
3838 ;--- findpixel -----------------------------------------------------------------
3840 ;Based on Snake86's findpixel
3841 ;160-262 cycles; 31 bytes
3842 FindPixel: ;(b,c) to hl:a
3870 ;--- objects -------------------------------------------------------------------
3902 ;--- circle --------------------------------------------------------------------
3904 ;IMHO, one weery nice routine. Oh lemme be proud just *once*.
3905 ;Not perfect since it uses a screwy lineroutine to draw stuff
3906 ;but, just _look_ at it. Ain't it grand? Z80 at its best.
3907 ;Nice comments, also. So here we go: Shiar's Circle Routine:
3908 ;(using the Bresenham method)
3910 drawcircle: ;(d,e),h ;de=x,y; h=z
3921 ex (sp),hl ;push zz \ pop x,y
3922 cal circledraw ;(x-xx,y+yy)-(x+xx,y+yy)
3923 ;(x-xx,y-yy)-(x+xx,y-yy)
3924 cal circledraw ;(x-yy,y+xx)-(x+yy,y+xx)
3925 ;(x-yy,y-xx)-(x+yy,y-xx)
3927 ex (sp),hl ;push x,y \ pop zz
3930 dec a ;-256<h<0 = $FF**
3932 jr z,circlenext ;jump if zz<0
3936 add a,a ;a=2yy-2 ;nc
3938 sbc hl,de ;zz=zz-2yy+2
3946 add hl,de ;zz=zz+2xx+3
3955 circledraw: ;destr:de
3960 xor a ;left of screen -> x=0
3962 add hl,bc ;h=x+xx; l=y+yy
3964 cal drawline ;(h-b,l+c)-(h+b,l+c)
3969 xor a ;above screen -> y=0
3972 cal drawline ;(h-b,l-c)-(h+b,l-c)
3973 ld a,b ;swap xx and yy
3979 ;--- box -----------------------------------------------------------------------
3981 drawbox: ;(d,e)-(h,l)
3991 ;--- fatline -------------------------------------------------------------------
4005 ;--- line ----------------------------------------------------------------------
4007 ;A lot like Scabby's line routine in Wonderworm (dunno whether he wrote it
4008 ;himself tho.) I did make a few optimizations and commented the thing.
4009 ;A nice routine (also Bresenham), but for Wormy not perfect since really
4010 ;large lines (>128 pixels in length or something) won't be flawless.
4012 drawline: ;(d,e)-(h,l)
4018 jr c,lineXincs ;if x>xx
4020 lineXincs: ;deltax=|deltax|
4024 cal FindPixel ; (ahl=x+y)
4026 ld c,a ;c=mask (always)
4029 ld b,a ;b=deltax (always>0)
4031 jr nz,lineexists ;deltax!=0
4033 jr nz,lineexists ;deltay!=0
4035 jr DoneLine ;line is 1 pixel
4038 ld de,32 ;go down (def)
4039 jr nc,lineYincs ;cf = deltay<0
4042 lineYincs: ;lets assume y incs as well
4044 jr nc,SteepLine ;deltay<deltax?
4045 ld (line2sm+1),a ;a=deltay
4049 ld (line1sm+1),a ;a=-deltax
4051 add a,h ;a=deltay-deltax/2
4055 psh af ;init z=2dy-dx
4069 dnz linedrawxloop ;|deltax| times
4083 ld (line3sm+1),a ;=-deltay
4087 ld (line4sm+1),a ;=deltax
4088 add a,h ;a=deltax-deltay/2
4092 psh af ;init z=2dx-dy
4106 dnz linedrawyloop ;|deltay| times
4110 ;..and last but not least..:
4111 ;_______________________________________________________________________________
4113 ; | | | \ | |____/ /
4114 ; |_____ __|__ | \_| | \_ .
4115 ;_______________________________________________________________________________
4120 ;--- multiple bytes ------------------------------------------------------------
4145 ;--- foo -----------------------------------------------------------------------
4147 receivenewpeaoverlink:
4159 jr z,receivenewpeaoverlink
4160 ld c,l ;send pea's pos
4163 ; jr Qsend ;that's why it's here
4165 ;--- send ----------------------------------------------------------------------
4167 Qsend: ;--- try to send 8 bits in C; CF=error --- destr:abcde ---
4170 jr z,linkerr ;both wires low = exit signal
4171 ld b,8 ;bits to send
4174 rl c ;bit to send in cf
4175 ld a,D0LD1H ;0: lower white
4177 ld a,D0HD1L ;1: lower red
4179 out (7),a ;lower one (send bit)
4181 cal checklink ;other calc must lower other wire
4183 cal linkok ;raise one, ok to raise other (out (7),D0HD1H)
4186 cp %11 ;both raised (by other calc)
4189 dnz sendloop ;repeat for all bits
4191 ld (linklosses),a ;reset number of losses
4194 ;--- recv ----------------------------------------------------------------------
4196 Crecv: ;--- receive 8 bits into A/C --- destr:abCde ---
4198 ret nc ;return if all went ok
4199 jr Crecv ;and try again
4201 Qrecv: ;--- receive 8 bits into A/C; CF=error --- destr:abCde ---
4203 jr z,linkerr ;both low = error, quit
4204 ld b,8 ;bits to receive
4208 cal linktest ;checklink
4210 jr z,recvwait ;both high = nothing sent (yet)
4212 rra ;received bit in cf
4214 jr c,received ;lower white wire as well
4215 ld a,D0HD1L ;lower red
4218 out (7),a ;both wires low
4221 jr z,recvwaitack ;same wire will be raised again by other calc
4222 cal linkok ;raise both
4224 dnz recvloop ;repeat for all bits
4226 ld (linklosses),a ;reset number of losses
4229 ;--- common --------------------------------------------------------------------
4233 out (7),a ;raise both wires = link ok
4236 checklink: ;load wires in A and check for timeout
4237 dec de ;decrease timer
4240 jr z,linktimeout ;timeout if de==0
4243 out (1),a ;select keys
4246 jr z,linkerr ;break!
4253 ld a,0 ;losses so far
4255 inc a ;and this is another one
4257 pop de ;return from link
4258 cp lossout ;quit if too many errors
4259 ret c ;otherwise just continue
4264 ;_______________________________________________________________________________
4265 ; _____ __ _ _______ _______ _ _ _______ _______
4266 ; | | \ | | | |______ \ / |______ | |______
4267 ; __|__ | \_| | _____ |_____ |______ \/ |______ |_____ ______|
4268 ;_______________________________________________________________________________
4271 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
4272 .db 0,2,63 ;start d, y, x
4273 .db 128,57 ;field width (128-255), height (57-255)
4274 .db 0 ;no additional lines, boxes
4282 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
4286 .db "Fast Fun :))",0
4288 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4289 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
4295 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
4300 LevelDefT: ;tron=no delay
4301 .db "Empty Tron Level",0
4303 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4304 .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
4309 .db "Round and Round",0
4311 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4312 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
4320 .db %1110000,%10001000,%10001000,%10001000,%1110000,0
4321 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
4328 ;_______________________________________________________________________________
4329 ; ______ _______ _______ _______
4330 ; | \ |_____| | |_____|
4332 ;_______________________________________________________________________________
4334 ;--- graphics ------------------------------------------------------------------
4337 ; %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
4338 .db %00011110, %00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000
4339 .db %00111110, %00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000
4340 .db %01110000, %00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000
4341 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000
4342 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000
4343 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000
4344 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000
4345 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000
4346 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000
4347 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000
4348 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000
4349 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000
4350 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011
4351 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100
4352 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101
4353 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011
4357 .db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000
4358 .db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000
4359 .db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000
4360 .db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100
4361 .db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010
4362 .db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010
4363 .db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100
4364 ;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000
4366 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0
4369 ;--- menus ---------------------------------------------------------------------
4371 txtMenu: .db "Mode",0 ;1st menu item
4377 .dw $2418,$231E,$2824,$1F2A,$1730
4378 txtteamed: .db " vs 2",0 ;4th tail
4379 txtMenuR: .db "controls",0 ;6th
4381 txtoMenu: .db "Back",0 ;1st menu item
4388 .dw $2618,$251E,$2524,$222A,$1A30,$1C36
4390 txtpMenu: .db "Resume",0 ;1st menu item
4391 .db "Turn Off",0 ;2nd
4392 .db "Contrast",$CF,5,0 ;...
4395 .dw $3418,$331E,$2F24,$3A2A
4397 ;--- text ----------------------------------------------------------------------
4399 txtGame: .db "Singleplayer",0
4400 txtGame1: .db "Peaworm",0
4401 txtGame2: .db "Tron",0
4402 txtGame3: .db "Deathmatch",0
4403 txtGame4: .db "Foodmatch",0
4404 txtGame5: .db "Multifoodmatch",0
4405 txtGame6: .db "Timematch",0
4406 txtGame7: .db "Race",0
4407 txtGame8: .db "CTF";,0
4409 .db txtGame1-txtGame
4410 .db txtGame2-txtGame
4411 .db txtGame3-txtGame
4412 .db txtGame4-txtGame
4413 .db txtGame5-txtGame
4414 .db txtGame6-txtGame
4415 .db txtGame7-txtGame
4416 .db txtGame8-txtGame
4418 txtNone: .db "None",0
4419 txtDef: .db "Default",0
4422 txtKleft: .db ":left",0
4423 txtKright: .db "right",0
4425 txtLevsel: .db $CF," SELECT LEVELS ",5,0
4426 txtWaitn: .db "Waiting";"...",0
4427 txtReceiv: .db "...",0
4430 txtReady: .db "Prepare!",0
4433 txtLevel: .db "Level ",0
4434 txtWorms: .db "Worms: 0",0 ;follows txtLevel
4435 txtName: .db "Name",0
4436 txtWinner: .db "Wins",$D8 ;follows txtName
4437 txtDied: .db "Died",$D8 ;follows txtWinner
4438 txtScore: .db "Score",0 ;follows txtDied
4439 txtLeft: .db " left",0 ;follows txtScore
4440 txthiscore:.db "HiScore:";,0
4442 ;--- foo -----------------------------------------------------------------------
4444 trigtable: .db 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45
4445 .db 48, 51, 54, 57, 59, 62, 65, 67, 70, 73, 75, 78, 80, 82, 85, 87
4446 .db 89, 91, 94, 96, 98,100,102,103,105,107,108,110,112,113,114,116
4447 .db 117,118,119,120,121,122,123,123,124,125,125,126,126,126,126,126
4451 datalevels:.dw LevelDef,LevelDefM,LevelDefT,LevelDefM,LevelDefM
4452 .dw LevelDefM,LevelDefM,LevelDefR,LevelDefC
4453 nrlevels: .db 2,3,1,3,3,3,3,3,1,0
4455 .db 0,0,"SHI",0,0,"SHI",0,0,"SHI",0,0,"SHI",0,0,"SHI"
4460 ;--- game settings -------------------------------------------------------------
4464 worm1set: .dw worm1p
4465 .db %11110111,1,K_RIGHT,K_LEFT
4466 worm1name: .db "WORMY ",0 ;15 bytes
4467 worm2set: .dw worm2p
4468 .db %11111011,0,K_F2,K_F1
4469 worm2name: .db "VIPER ",0
4470 worm3set: .dw worm3p
4471 .db %11111011,1,K_COMMA,K_STO
4472 worm3name: .db "NIBBLER ",0
4473 worm4set: .dw worm4p
4474 .db %11111101,0,K_PLUS,K_ENTER
4475 worm4name: .db "JIM ",0
4477 _datalink = %00000001 ;linkplay (1!)
4478 _datafoodl = %00000010 ;left=0 limit
4479 _datasingl = %00000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel)
4480 _dataPctf = %00001000 ;ctf peas=1
4482 _datatime = %00010000 ;time incs score (timematch)
4483 _datadecs = %00100000 ;decrease score on death=1
4484 _datafood = %01000000 ;food present=0 (6!)
4485 _dataPmult = %10000000 ;multiple peas=1 (no _datafood) (7!)
4487 ; ┌game info (see above)
4488 ; │ ┌lives (0=unlimited)
4489 ; │ │ ┌nrworms (can be altered by user)
4490 ; │ │ │ ┌level (reset to 1 at startup)
4491 ; │ │ │ │ ┌speed/delay (-1=def)
4492 ; │ │ │ │ │ ┌grow speed (-1=none; 0=continuous)
4493 ; │ │ │ │ │ │ ┌turn speed (8=def)
4494 ; │ │ │ │ │ │ │ ┌score limit (0=none)
4495 gamesingle = 0 ; │ │ │ │ │ │ │ │
4496 datasingle:.db %00100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives)
4498 datapeas: .db %00100100,1,1,1,-1,126,8, 0 ;Peaworm (SP; 1 live, 127 growth)
4500 datatron: .db %01110100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
4502 datadeathm:.db %01100000,3,2,1,-1,42, 8, 0 ;Deathmatch (3 lives, 50 growth)
4504 datafoodm: .db %00100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
4506 datamfoodm:.db %11100010,0,2,1,-1,-1, 8,10 ;MuchFoodmatch (10 peas)
4508 datatimem: .db %01110000,1,2,1,-1, 0, 8, 0 ;Timematch (1 live, cont.growth)
4510 datarace: .db %01000000,0,2,1,-1,-1, 8,10 ;Race (100 score)
4512 datactf: .db %01001000,0,6,1,-1,-1, 8,10 ;CTF (100 score)
4514 gametype: .db 0 ;last gamemode
4515 gamecar: ;made before needed (not saved)
4526 defspr: .db %01100000
4531 deflevels: .db "Internal Levels",0
4534 .db 0,deflevels/256,deflevels&255
4538 ;_______________________________________________________________________________
4539 ; _______ _ _ _______ _______ . _______ _______
4540 ; | |_____| |_____| | ' |______ |_____| | |
4541 ; | | | | | | ______| _____ | | |_____ |_____
4542 ;_______________________________________________________________________________