; Title : Wormy ; Version : 96% (0.96.C14) ; Release Date : UUHHhhh... soon?!? ; Filename : wormy.86p (5kb) ; Author(s) : Shiar ; Email Address : wormy@shiar.org ; Web Page : www.shiar.org ; Description : ruling Nibbles-like game 1-4 players ; Where to get this game : www.shiar.org (home of Wormy) ; Other games by author(s) : Nemesis beta ; Additional Credits to : Matthew Shepcar (wrote original Peaworm, end'98) ; Jonah Cohen (helped writing worm) ;----------------------------- ;----------- TO-DO ----------- ;----------------------------- ; 96% = DONE ; [* internal levels ] ; [ * check levels/gametype ] ; [ * enough hiscore saves! ] ; [* complete readme ] ; 1% * misc (pollish, bugs, &&&) ; 1% * long length save (level#6) ; * mem at worm #4 ; * LINK ; 1% * transmit game/level data ; Xfirst packet loss?? or vti onlyXXXXX ; X1/3 worms over linkXXXX ; Xsend new peas' positionsXXXXX ;100% = bugs fixed + levels done ; MAYBE: sound ; NO: coop ;----------------------------- ;----------------------------- ;------- W O R M Y --------- ;----------------------------- ;----------------------------- #define buffer ;use display buffer (otherwise write directly to screen) #define readymask ;"greys" out the field before starting a level #define coolzgfx ;nice graphics for game over screen ;#define readytext ;displays "prepare" before level starts ;#define invincible ;worms cannot die =) ;#define optdie ;in race games worms don't die when they run into each other #define cal call #define psh push #define dnz djnz #include "asm86.h" #include "ti86asm.inc" _SHRACC = $4383 ;4x srl a _SHLACC = $438B ;4x sll a _divHLby10 = $4044 ;hl=hl/10 _divAby10 = $4DAF ;a=a/10 _HLTIMES10 = $41BF ;hl=hl*10 _cphlde = $403C ;cp hl,de _clrWindow = $4A86 ;clear screen _asapvar = $D6FC ;own name (worm) _MOV4B = $429B ;4x ld (de),(hl) _MOV5B = $4297 ;5x ld (de),(hl) _mov9b = $4283 ;9x ld (de),(hl) _ldHLind = $4010 ;ld hl,(hl) _swapt_ = $45F3 ;ex_ahl_bde _Get_Word_ahl = $521D ;ld de,(ahl) _Set_Word_ahl = $5221 ;ld (ahl),de _INC_PTR_AHL = $4637 ;ahl=ahl+1 _AHL_PLUS_2_PG3 = $4C3F ;ahl=ahl+2 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl _mm_ldir = $52ED ;24bit ldir _MM_LDIR_SET_SIZE = $524D ;_SET_MM_NUM_BYTES + _mm_ldir _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1 _RAM_PAGE_7 = $47F3 ;"""" 7 _PTEMP_END = $D29A ;end of VAT _load_ram_ahl = $462F ;ahl->page+hl _writeb_inc_ahl = $5567 ;ld (ahl++),c _jforce = $409C ;TI-OS stack restored _EXLP = $4493 ;swap (hl),(de) b times _GETB_AHL = $46C3 ;a=(ahl) \ hl=ahl ;----------------------------- ;------- data storage ------- ;----------------------------- ;--- permanent ScrBuffer = $8820 ;-A7FF (20*FF=1FE0) worm2p = $A800 ;-ABFF (400) %10101O00 worm1 = $AC00 ;-AC1D (31d) worm2 = $AC1F ;-AC3B (1F) worm3 = $AC3E ;-AC59 (1F) worm4 = $AC5D ;-AC77 (1F) balls = $AC7C ;-ACFF (3x43d) SinCosTable = $AD00 ;-AE00 (4*40) ;free $AE01 ;-AFFF (1FF) worm1p = $B000 ;-B7FF (800) %1011O000 worm3p = $B800 ;-BBFF (400) %10111O00 ;free $BF91 ;-BFFF (6F) ;program $D748 ;-EFFF (186D+4A) worm4p = $F000 ;-F3FF (400) %11110O00 leveldata = $F400 ;-FA70 (<=671) turn10 = $AE01 ; (1) (counter) peaspos = $AE02 ;-AE05 (4) (peas) ;MEM|8---9---A---B---C---D---E---F---| ; |..[------]||[]|......[-----]|[].| ; | SCREEN 2* 13 PRGM 4LV | ;--- temporary namelength = $BC00 ;(1) @menu datalink = $BC00 ;(8) @init #ifdef buffer DispBuffer = $BC00 ;(10x57d) @game #else DispBuffer = $FC70 #endif ;----------------------------- ;------- program start ------- ;----------------------------- .org _asm_exec_ram wormVhost = 095 wormVclient = 195 start: nop jp Start .db 1 nop .dw WormTxt .dw WormIcon WormTxt: .db "WORMY by SHIAR -- 96% C14",0 WormIcon: .db 8,2 .db %00000000,%00111100 .db %00000000,%01010010 .db %00000000,%01100001 .db %01100011,%10011001 .db %10010100,%01101001 .db %10011001,%00011001 .db %01000010,%11000001 .db %00111100,%00111110 levelhead = 'w' levelhead2 = 95 ;wormy levels header = "95" int_handler: ex af,af' in a,($03) bit 3,a jp z,$0039 res 0,a out ($03),a jp $0039 int_end: Start: ld (SpSave),sp cal _runindicoff cal _flushallmenus im 1 ld a,$D4 ld h,a ld l,0 ;ld hl,$D400 ld d,a ld e,1 ;ld de,$D401 ld b,e ld c,l ;ld bc,$0100 dec a ;ld a,$D3 ld (hl),a ldir ld hl,int_handler ld d,a ld e,a ;ld de,$D3D3 ld bc,int_end-int_handler ldir inc a ;ld a,$D4 ld i,a im 2 cal _RAM_PAGE_7 ld hl,$BFFF ;VAT start ld ix,templevels searchloop: ld de,(_PTEMP_END+1) ;VAT end or a ;nc sbc hl,de ;hl" ld hl,$FC00+(2*16) ld b,16*9 cal menuinvloop ld hl,$FC00+(56*16) cal hr ld hl,$0601 ;x=1 ld (_penCol),hl dispnextlevel: ld a,(ix+3) ld b,a inc a ;cp 255 jr z,__levselect displevel: ld hl,_penCol ld (hl),$01 ;x=1 inc hl ld a,(hl) add a,6 ld (hl),a ;y+6 cp 49 ;bottom of screen jr nc,_levselect ld de,3 add ix,de ld hl,availevels inc (hl) ld a,b ;(ix+0) ld h,(ix+1) ld l,(ix+2) ;ahl=(ix) cal _load_ram_ahl ;hl=ahl cal _vputs jr dispnextlevel readylevelfile: ;selected level at ahl ; ld hl,templevels-3 ld a,b add a,3 ;sellev+3 (#0==-3) ld e,a add a,a ;*2 add a,e ;*3 ld e,a ld d,0 ;de=sellev*3 add hl,de ld a,(hl) ;ade=(hl) inc hl ld d,(hl) inc hl ld e,(hl) ex de,hl ;ahl=ade skiptitle: ld d,a ;psh ahl psh hl cal _GETB_AHL ;ld a,(ahl) pop hl or a ld a,d ;pop ahl psh af cal _INC_PTR_AHL ;ahl++ pop af ;cp 0 jr nz,skiptitle ;goto #0-terminator ret levup: cal menupos dec b ;up ld a,b cp -3 jr nz,levselect inc b ;undo jr levselect levdown: cal menupos inc b ;down ld a,b cp -2 availevels =$-1 jr nz,levselect dec b ;back up levselect: cal menupos ld hl,$3900 ld (_penCol),hl pop hl psh hl cal readylevelfile cal _load_ram_ahl ;hl=ahl ld de,$FFA0 ;desc.text xor a levdescclearloop: ld (de),a ;empty inc de cp d ;de>$FFFF (offscreen) jr nz,levdescclearloop cal _vputs jr levselectmenu+1 __levselect: ld ix,templevels-6 ;reset 2 1st page _levselect: ld b,-2 ;level selected jr levselect levselectmenu: psh hl psh bc cal ubergetkey pop bc ;GET_KEY destr. b dec a ;cp K_DOWN jr z,levdown sub K_UP-1 jr z,levup pop hl inc a ;cp K_RIGHT jp z,levelselectmenu cp K_ENTER-K_RIGHT jr z,loadlevel sub K_EXIT-K_RIGHT jp z,ExitNoStats inc a ;cp K_SECOND jr nz,levselectmenu ; jr z,loadlevel loadlevel: cal readylevelfile or a ;levelfile on page 0 (=internal) jr z,levelloaded cal skiptitle ;skip description cal _Get_Word_ahl ld (leveldataSize),de ld d,8 ;counter ld bc,datalevels cal loadgametype ld (hilvlposa),a ;singleplayer levels ld (hilvlposhl),hl ld d,4 cal loadgametype cal _SET_ABS_SRC_ADDR ;levelsstart xor a ld hl,leveldata cal _SET_ABS_DEST_ADDR ;store in mem. ld hl,0 leveldataSize =$-2 cal _MM_LDIR_SET_SIZE cal _LOAD_ABS_SRC_ADDR ;->ahl ld (hiscrposa),a ld (hiscrposhl),hl cal _RAM_PAGE_1 ld hl,leveldata ld de,defsprsize ldi ;(de),(hl)\inc hl ld (defsprite),hl levelloaded: cal _RAM_PAGE_1 res 2,(iy+13) ;appAutoScroll ld a,r ld (Seed),a ld hl,datasingle+3 ld b,8 ld de,8 setdeflevels: ld (hl),1 ;def=level#1 add hl,de ;next dnz setdeflevels ;----------------------------- ;----- build trig tables ----- ;----------------------------- ld hl,TrigPrecalc ld de,SinCosTable psh de ld bc,65 ldir dec hl ld b,63 MirrorSineWave: dec hl ld a,(hl) ld (de),a inc de dnz MirrorSineWave pop hl ;SinCosTable ld b,128+64 NegativeSineWave: xor a sub (hl) ld (de),a inc hl inc de dnz NegativeSineWave ;----------------------------- ;---------- menu ------------- ;----------------------------- DisplayMenu: ;---draw menu--- cal linkok cal _clrWindow ld de,$FC40 ;(0,4) ld hl,wtPicture ld bc,16*16 ldir ld hl,$FC00+$010 ;(*,01) cal hr ld hl,$FC00+$160 ;(*,22) cal hr ld hl,$FC00+$3E0 ;(*,62) cal hr dispmainmenu: ld hl,Gametype ld a,(hl) dec a ;will be inced @changegame and 7 ld (hl),a ld hl,changegame ;dispmenusets ;mainMenu psh hl ;jump here after ret ld hl,txtMenu ld ix,posMenu ;Mode|Level|Limit|Worms|worm #|controls ; jr dispmenucommon ;cal dispmenucommon_: ld b,36*16/4 dispmenucommon: ld de,$FD80 ;begin pos xor a clroldmenuloop: ld (de),a inc de ld (de),a inc de ld (de),a inc de ld (de),a inc de dnz clroldmenuloop ld b,(ix) dispmenuloop: ld d,(ix+1) inc ix ld e,(ix+1) inc ix ld (_penCol),de cal _vputs dnz dispmenuloop ; ld b,0 ;b=menu# ret ;hr: ;draw horizontal line at hl ; ld b,16 ; jp menuinvloop hr: ld b,16 hrloop: ld (hl),-1 inc hl dnz hrloop ret ;--- menu loop --- dispoptionmenu: ld hl,txtoMenu ld ix,posoMenu ;Back|Lives|Limit|Speed|Rotation|Growth cal dispmenucommon_ dispomenusets: cal clrold ld hl,$1E3E ld (_penCol),hl cal loadgamecar psh hl cal cshowA0 ;lives ld hl,$2A3E ld (_penCol),hl pop hl ;loadgamecar inc hl \ inc hl \ inc hl psh hl ld a,(hl) ;(Speed) inc a ;1..99 jr nz,dispspeed ld hl,txtDef cal _vputs jr dispspeeddone dispspeed: cal cshowA0 dispspeeddone: ld hl,$363E ld (_penCol),hl pop hl ;loadgamecar inc hl psh hl ld a,(hl) ;(growth) inc a ;-1=None; 0..98->1..99 cal cshowA0 ld hl,$303E ld (_penCol),hl pop hl ;loadgamecar inc hl psh hl ld a,(hl) cp 8 jr nz,dispturn ld hl,txtDef cal _vputs jr dispturndone dispturn: cal cshowA0 ;turn speed dispturndone: ld hl,$243E ld (_penCol),hl pop hl ;loadgamecar inc hl ld a,(hl) ;(scorelimit) or a psh af cal cshowA0 ;limit pop af ;a==0? jr z,optionMenu ;do not display 0 behind 'None' ld a,'0' cal _vputmap ;x10 optionMenu: cal menupos cal menucall jr nz,notoselect oselect: cal menupos ld a,b or a ;1st item? jp z,dispmainmenu ;mainMenu jr optionMenu notoselect cp K_EXIT jp z,dispmainmenu psh af cal menupos cal loadgamecar inc hl pop af sub K_LEFT jr z,seloleft dec a ;K_RIGHT ld a,b jr nz,optionMenu seloright: dec a jr z,changelives dec a jr z,changelimit dec a jr z,changespeed dec a jr z,changeturn dec a jr z,changegrowth seloleft: ld a,b dec a jr z,bchangelives dec a jr z,bchangelimit dec a jr z,bchangespeed dec a jr z,bchangeturn dec a jr z,bchangegrowth _optionMenu: jr optionMenu changelives: cal loadgamecar ;a=(hl) inc a cp 100 jr nc,optionMenu ;>99 changedlives: ld (hl),a _dispomenusets: jp dispomenusets ;optionMenu bchangelives: cal loadgamecar sub 1 ;dec does not set cf jr c,optionMenu ;<0 jr changedlives changelimit: cal changelimitInit inc a cp 100 jr nc,optionMenu ;>99 changedlimit: ld (hl),a jr _dispomenusets ;optionMenu bchangelimit: cal changelimitInit sub 1 ;dec does not set cf jr c,optionMenu ;<0 jr changedlimit changelimitInit: cal loadgamecar ld de,6 add hl,de ld a,(hl) ;(scorelimit) ret changespeed: cal changespeedInit inc a cp 20 jr nc,_optionMenu ;>98 changedspeed: dec hl ;(Speed) ld (hl),a jr _dispomenusets ;optionMenu bchangespeed: cal changespeedInit dec a cp -2 __optionMenu: ;w/ zf jr z,_optionMenu ;<-1 jr changedspeed changespeedInit: cal loadgamecar ld de,3 add hl,de ld a,(hl) ;(Speed) inc hl ;=saves 2 bytes :P ret changeturn: cal changespeedInit inc hl ;(turnspeed) ld a,(hl) inc a cp 26 jr nc,_optionMenu ;>25 changedturn: ld (hl),a jr _dispomenusets ;optionMenu bchangeturn: cal changespeedInit inc hl ld a,(hl) dec a cp 3 jr c,_optionMenu ;<3 jr changedturn changegrowth: cal changespeedInit ld a,(hl) inc a cp 99 jr nc,_optionMenu ;>98 changedgrowth: ld (hl),a jr _dispomenusets ;optionMenu bchangegrowth: cal changespeedInit ld a,(hl) dec a cp -2 jr z,__optionMenu ;<-1 jr changedgrowth ;--- mainMenu: cal menupos cal menucall jr nz,notselect select: ;2nd/enter cal menupos ld a,b dec a ;2nd item: level jp z,dispoptionmenu sub 3 ;5th item: wormname jp z,changeworms dec a ;6th: controls jp z,changekeys jp LetsGetThisPartyOn ;otherwise notselect cp K_EXIT jp z,ExitNoStats psh af cal menupos cal loadgamecar inc hl pop af sub K_LEFT jr z,selleft dec a ;K_RIGHT ld a,b jr nz,mainMenu selright: or a jr z,changegame dec a jr z,changelevel dec a jr z,changelink dec a jr z,changenrworms ; dec a ; jr z,changecurworm changecurworm: ; hl=nrworms ld a,(curworm) cp (hl) jr nc,mainMenu ;may not become >(nrworms) inc a changedcurworm: ld (curworm),a jr _dispmenusets ;mainMenu selleft: ld a,b or a jr z,bchangegame dec a jr z,bchangelevel dec a jr z,bchangelink dec a jr z,bchangenrworms ; dec a ; jr z,bchangecurworm bchangecurworm: ld a,(curworm) dec a ;0-3 jr nz,changedcurworm ;save >0 jr mainMenu changenrworms: cal change4spOnly ld a,(hl) ;hl=nrworms inc a cp 5 jr nc,mainMenu ;may not be >4 changednrworms: ld (hl),a jr _dispmenusets ;mainMenu changenrwormsInit: ld a,(Gametype) cp 3 ld a,(hl) ;hl=nrworms ret bchangenrworms: cal change4spOnly ld a,(hl) ;hl=nrworms dec a ;0-3 cp 2 jr nc,changednrworms ;save >=2 _mainMenu: jr mainMenu change4spOnly: ld a,(Gametype) cp 3 ret nc pop hl ;cal jr _mainMenu ;don't change for singleplayer changelink: bchangelink: cal change4spOnly dec hl ;inced earlier dec hl ;gameCar ld a,1 ;change LS-bit (=link) xor (hl) ;0=1; 1=0 ld (hl),a _dispmenusets: jr dispmenusets ;mainMenu changegame: ld a,(Gametype) inc a cal changedgame jr z,changegame jr dispmenusets ;mainMenu changedgame: and 7 ;mod 8 ld (Gametype),a cal getnrlevels xor a cp (hl) ret bchangegame: ld a,(Gametype) dec a cal changedgame jr z,bchangegame jr dispmenusets ;mainMenu changelevel: inc hl ;hl=loadgamecar+2 psh hl ld a,(hl) ;(curlevel) cal getnrlevels cp (hl) ;max level for sel.game pop hl jr z,_mainMenu inc a changedlevel: ld (hl),a jr dispmenusets ;mainMenu bchangelevel: inc hl ld a,(hl) ;(curlevel) dec a jr nz,changedlevel jr _mainMenu getnrlevels: ;for current gametype at hl ld hl,Gametype ld d,0 ld e,(hl) ld hl,nrlevels add hl,de ret getcustomkey: cal _vputs dec ix waitcustomkey: psh hl cal ubergetkey pop hl or a jr z,waitcustomkey cp K_EXIT ret z cp K_MORE jr z,waitcustomkey ld (ix),a ret changekeys: cal getwormname ld hl,txtKeyleft cal getcustomkey ;left cal getcustomkey ;right ; jr dispmenusets ;---display current settings--- dispmenusets: cal clrold ld de,$183E ld (_penCol),de ld d,0 ld a,(Gametype) ld e,a ld hl,posGame add hl,de ;hl=posGame+(Gametype) ld a,(hl) ;str.offset ld e,a ;^d=0^ ld hl,txtGame add hl,de ;txtGameX ld (CURtxtGame),hl ;save for g/o cal _vputs ;Singleplayer ld hl,$2A3E ;worms ld (_penCol),hl cal loadgamecar psh hl inc hl ld a,(hl) add a,'0' cal _vputmap ld hl,$243E ld (_penCol),hl rr c ;(gameCar) ld hl,txtNo jr nc,displink ld hl,txtYes displink: cal _vputs ld hl,$1E3E ;level ld (_penCol),hl pop hl ;loadgamecar psh bc ld d,0 cal hlatlevel ld a,(Gametype) or a ;gamesingle jr nz,displvlname ld a,(Level) cal cshowA0 jr lvldisped displvlname: cal _vputs lvldisped: pop bc ld hl,$3032 ld (_penCol),hl ld a,1 curworm =$-1 add a,'0' cal _vputmap ld hl,$303E ld (_penCol),hl cal getwormname psh ix ;wormNname pop hl ;ld hl,ix cal _vputs ld hl,$363E ;controls ld (_penCol),hl ld hl,txtMenuR cal _vputs jp mainMenu ;--- handle menukeys --- menucall: psh bc menuwaitkey: cal ubergetkey or a jr z,menuwaitkey pop bc ;GET_KEY destr. b cp K_UP cal z,menuup cp K_DOWN cal z,menudown cp K_ENTER ret z cp K_SECOND ret ;z=select menupos: ;highlight #b ld c,b ;psh b ld a,b add a,3 add a,a add a,a sub b add a,a add a,a add a,a ;*24 ld h,$FC/4 ld l,a add hl,hl add hl,hl ;$FD20+item*96 ld b,16*7 menuinvloop: ld a,(hl) cpl ld (hl),a inc hl dnz menuinvloop ld b,c ;pop b ret ;a=-1 menudown: cal menupos inc b jr menuupdown menuup: cal menupos dec b menuupdown: ld a,b cp 6 jr nz,menunewchk xor a ;6=0 menunewchk: inc b jr nz,menunewok ld a,5 ;-1=5 menunewok: ld b,a jr menupos ;--- change name --- ; of worm#(curworm) getwormname: ;of (curworm) ld a,(curworm) add a,a ;2x ld e,a add a,a ;4x add a,a ;8x add a,a ;16x add a,e ;18x ld e,a ld d,0 ;de=a ld ix,worm1name-18 add ix,de ret changeworms: cal getwormname psh ix pop hl ;ld hl,ix psh hl ld b,8 emptyname: ld (hl),' ' inc hl dnz emptyname ld a,maxnamelength ld (namelength),a enternameloop: ld hl,$FF07 ;begin pos ld a,6 ;nr of lines cal clroldcustom ld hl,$303E ld (_penCol),hl pop hl psh hl ld (ix),0 cal __vputs ld (ix),' ' ld a,'_' cal __vputmap nokeypressed: cal ubergetkey or a jr z,nokeypressed ld hl,namelength cp K_DEL jr nz,continue backspace: ld a,(hl) cp maxnamelength jr nc,nokeypressed inc (hl) dec ix jr enternameloop continue: cp K_ENTER jr z,nameentered cp K_EXIT jr z,nameentered dec (hl) ;(namelength) jr z,nameentered ld hl,chartable ld e,a ld d,0 add hl,de ld a,(hl) or a jr z,nokeypressed ld (ix),a inc ix cal releasekeys jr enternameloop chartable: .db 0,".<>!",0,0,0,0 ;down,L,R,up .db 0,"XTOJE0",0 ;enter..clear .db " WSNID9",0 ;(-)..custom .db "ZVRMHC8",0 ;dot..del .db "YUQLGB7#" ;0..xvar .db $D9,"-PKFA6'" ;on..alpha .db "54321*",0,$D0 ;F5..more nameentered: pop ix ;stringbegin ld (ix+8),0 ;end mark jp DisplayMenu ;----------------------------- ;------- procs-n-stuff ------- ;----------------------------- ubergetkey: halt ;woo hoo halt ;save them batteries! yeah! jp GET_KEY clrold: ld hl,$FD97 ;begin pos ld a,35 ;nr of lines clroldcustom: ld de,7 ;bytes to add clroldsettings: ld c,9 ;bytes to clear clroldsetsloop: ld (hl),d ;=0 inc hl dec c jr nz,clroldsetsloop add hl,de dec a jr nz,clroldsettings ret hlatlevel: ;d must be 0 psh hl ;loadgamecar ld a,(Gametype) ;8bytes -> 7bytes ld e,a add a,a ;nc add a,e add a,a ;8->2bytes add a,24+1 ;go to datalevels ld e,a ;=de sbc hl,de ;datalevels cal _ldHLind ;ld hl,(hl) pop de ;de=loadgamecar inc de \ inc de ld a,(de) ;(curlevel) ld (Level),a ld d,a ;begin level skiplevelloop: dec d ;levels to skip ret z cal skiplevel jr skiplevelloop ret ;hl=begin of correct level skiplvltitle: ;zf=singleplayer ld a,(hl) or a ;null-terminator inc hl jr nz,skiplvltitle ret skiplevel: ;@hl - destr:ab - alter:hl ld a,(Gametype) or a ;gamesingle psh af cal nz,skiplvltitle inc hl inc hl inc hl inc hl ;skip 4 ld b,(hl) ;spritesize inc b skipsprite: inc hl dnz skipsprite ld b,(hl) ;balls inc b inc b ;skip 6 pop af ;cp (Gametype),0 jr z,skipworms inc b ;multiplayer lvl inc b inc b ;skip other 3 worms (9 bytes) skipworms: ld a,b add a,a add a,b ld b,a ;3x(balls+2) skipballs: inc hl dnz skipballs skipflags: ld a,(Gametype) cp gamectf jr nz,noflagstoskip inc hl inc hl inc hl inc hl noflagstoskip: skipobjects: xor a or (hl) inc hl ;nf ret z ;0=end inc hl inc hl inc hl inc hl jr skipobjects loadgamecar: ;in: (Gametype) ;out: hl=dataTYPE ;build: c=(gameCar)=(hl-1) ; a=(wormbeglives)=(hl) ;destr: acdehl ld hl,datasingle ld a,(Gametype) add a,a add a,a add a,a ;8 bytes per mode ld e,a ld d,0 add hl,de ld a,(hl) ld (gameCar),a ld c,a inc hl ld a,(hl) ld (wormbeglives),a ret ;----------------------------- ;-------- start game --------- ;----------------------------- LetsGetThisPartyOn: ld a,$17 ;no exit ld (CheckExit),a ;set exit state cal loadgamecar psh hl cal hlatlevel ex (sp),hl ;pop \ psh leveldata psh hl ;psh loadgamecar ld a,0 gameCar =$-1 rra ;and _datalink jp nc,StartLevel ;&&&jr ;--------- link ------------ linkmatch: cal _clrWindow ld c,wormVhost cal Qsend ld hl,txtWaiting cal _puts cal Crecv ld a,c cp wormVclient jr z,client cp wormVhost jr z,host pop hl ;error jp DisplayMenu ;return to menu host: ld c,wormVclient cal Qsend jr sethost client: ld hl,txtReceive cal _puts setclient: ;name/keys: wormy#1 = link = 0 + link (name1) ; 2 = worm #1 = #1 + local(name1) ; 3 = link = 0 + link (name2) ; 4 = worm #2 = #2 + local(name2) ld de,worm2+left ld hl,worm1+left ldi ;keys worm#2 = worm#1 ldi ;+right ld de,worm4+left ldi ;keys worm#4 = worm#2 ldi xor a ld (worm1+left),a ;worm 1... ld (worm3+left),a ;and worm 3 via link ld hl,worm1+name ld b,9 cal recvstuff ld hl,worm2+name ld b,9 cal sendstuff pop hl pop de psh de psh hl ld b,168 cal sendstuff ex de,hl ld b,8 cal sendstuff jr StartLevel sendstuff: psh de sendstuffloop: psh bc ld c,(hl) inc hl cal Qsend pop bc dnz sendstuffloop pop de ret recvstuff: psh de recvstuffloop: psh bc cal Qrecv ld (hl),c inc hl pop bc dnz recvstuffloop pop de ret sethost: ;name/keys: wormy#1 = worm #1 = ok ; 2 = link = 0 + link (name1) ; 3 = worm #2 = #2 + local(name2) ; 4 = link = 0 + link (name2) ld de,worm3+left ld hl,worm2+left ldi ;keys worm#3 = worm#2 ldi ;+right xor a ld (worm2+left),a ;worm 2+4.. ld (worm4+left),a ;..over link ld hl,worm1+name ld b,9 cal sendstuff ld hl,worm2+name ld b,9 cal recvstuff pop hl pop de ld hl,templevels ld de,datalink psh de psh hl ld b,168 cal recvstuff ex de,hl ld b,8 cal recvstuff ;-------- load level --------- StartLevel: pop hl ;loadgamecar ld a,(hl) ld (wormbeglives),a inc hl ;nrworms ld a,(hl) ld (nrworms),a inc hl ;level inc hl ld a,(hl) ld (customspeed),a inc hl ld a,(hl) ld (growspeed),a inc hl ld a,(hl) ld (turnleft),a ld (turnright),a ;more efficient inc hl ld l,(hl) ld h,0 cal _HLTIMES10 ;hl=10*(hl) ld (scorelimit),hl setupworms: ld hl,worm1set ld de,worm1 ld a,4 ;4x (all worms) createwormsloop: ex de,hl ld bc,died ;8 add hl,bc ; ld b,0 ld (hl),b ;died=0 inc hl ld (hl),b ;score=0 inc hl ld (hl),b ;score+1=0 inc hl ld (hl),2 ;delay=2 inc hl ld (hl),3 ;lives=x wormbeglives =$-1 inc hl ex de,hl ;de=wormX+head ld bc,18 ldir ;copy 18 bytes dec a ;loop jr nz,createwormsloop Nextlevel: cal _clrWindow pop hl ;begin of current level ld a,(hl) inc a ;=255? jp nz,donextlevel psh hl ld hl,Level dec (hl) ;curlevel-- (not beyond last lvl) cal releasekeys pop hl ;show end msg or smtn ld bc,Exit psh bc ;where to go afterwards inc hl ;location of ending-code jp (hl) ;go there ("call") donextlevel: ld a,(Gametype) or a ;gamesingle psh af cal nz,skiplvltitle ld de,Left ldi ld de,Speed ld a,0 customspeed =$-1 inc a ;$FF=def jr nz,setspeed ld a,(hl) ;speed from level inc a setspeed: dec a ld (de),a ;custom speed inc hl ld de,peagrowth ldi ld a,(hl) ld (worm1+grow),a ld (worm2+grow),a ld (worm3+grow),a ld (worm4+grow),a ld (beginsize),a inc hl ld a,(hl) inc hl or a jr z,defaultsprite ld d,h ld e,l ;ld de,hl ld c,a ld b,0 ;bc=sprite size add hl,bc ;hl=behind sprite jr setsprite defaultsprite: ld a,defspritesz defsprsize =$-1 defsprite =$+1 ld de,defspriteimg setsprite: ;de=@sprite ;a=sprsize ld (sprsize),a ld (spritepos),de ld a,(hl) inc hl ld (nrballs),a or a jr z,toobad_noballs ld c,a add a,a add a,c ld c,a ld b,0 ld de,balls ldir toobad_noballs: ex de,hl #ifndef invincible ld (thislevel),de #endif ld hl,worm1 pop af ;cp (Gametype),0 ld b,1 jr z,worminit ld b,4 worminit: psh bc ;>1 ex de,hl ldi ;d ld a,SinCosTable/256 ld (de),a inc de ldi ;y ldi ;x ex de,hl xor a ld (hl),a ;y2 inc hl ld (hl),a ;x2 ld bc,(worm2-worm1)-5 add hl,bc pop bc ;<0 dnz worminit inc a ;ld a,1 ld (turn10),a inc a ;ld a,2 ld (flashtime),a ;-------- draw level --------- initlevel: ld a,(de) inc de sub 128 jr nc,setfieldx xor a ;fieldx<128 setfieldx: ld (FieldWidth),a ld a,(de) inc de ld l,a sub 57 jr nc,setfieldy xor a ;fieldy<57 setfieldy: ld (FieldHeight),a psh de ; >> levelp ld a,l ;pop sub 5 ld l,a ld h,0 add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl ;32=scr.width ex de,hl ld hl,ScrBuffer psh hl ; >> 1 psh de ; >> 2 ld de,ScrBuffer+1 ld bc,63 ;first 2 rows ld (hl),%11111111 ldir ;draw upper border inc hl ld (hl),%11000000 ;first left border inc hl ld b,31 ClearLine: ld (hl),c ;=0 inc hl ;clear rest of line dnz ClearLine psh hl ; >> 3 ld a,(FieldWidth) add a,126 psh af ; >> 4 and %11111000 rra rra rra ld l,a ld h,c ;0 add hl,de pop af ; << 3 and %00000111 ld b,a ; ld c,0 ld a,%11000000 jr z,NoVertShift VertShift: rra rr c dnz VertShift NoVertShift: ld (hl),a inc hl ld (hl),c ex de,hl pop de ; << 2 pop bc ; << 1 ldir pop hl ; << 0k ld c,64 ldir pop hl ; << levelp ld a,(Gametype) cp gamerace ;or gamectf jr c,levelhasbeensetup ld de,peaspos ld c,2 ;ld bc,2 (2 bytes) jr z,loadextralevelstuff ;cp gamerace ld c,4 ;ld bc,4 (2nd flag in ctf) loadextralevelstuff: ldir ld a,1 ;draw delay ld (drawctfpea1),a ld (drawctfpea2),a levelhasbeensetup: cal drawstuff ;--------- prepare ----------- leveldone: psh hl ; >> levelp new cal forceshowstats #ifdef readymask ld hl,$FC70 ld d,%10101010 ld c,56 maskloop: ld a,d xor %11111111 ld d,a ld b,$10 maskline: ld a,(hl) or d ld (hl),a inc hl dnz maskline dec c jr nz,maskloop #endif #ifdef readytext ld hl,$FDE0 ld de,$FDE1 ld (hl),%11111111 ld bc,$BF ldir ld hl,4+(txtposReady*256) ld (_curRow),hl set 3,(iy+5) ld hl,txtReady cal _puts res 3,(iy+5) #endif ld a,(gameCar) and _datafood jr z,nofood ld ix,worm1 cal NewPea nofood: ld bc,(worm1+pos) cal DisplayField ld b,startdelay ReadyDelay: halt dnz ReadyDelay cal releasekeys ;----------------------------- ;----------- LOOP ------------ ;----------------------------- GameLoop: ld bc,(worm1+pos) ;camera worm #1 ld a,(worm1+left) or a ;if #1 not over link jr nz,showfield ld bc,(worm2+pos) ;otherwise view from #2 showfield: cal DisplayField ;display piece of level ld a,1 flashtime =$-1 dec a jr z,noflash ld (flashtime),a ld hl,$fc00+(16*7) screeninvertloop: ld a,(hl) cpl ld (hl),a inc hl xor a cp h ;end at >$FFFF jr nz,screeninvertloop noflash: ld a,0 Speed =$-1 or a jr z,NoDelay Delay: halt dec a jr nz,Delay NoDelay: ld (handledworm),a ;reset ld hl,turn ld a,(hl) inc a ;-1 jr z,nextturnok dec (hl) dec a ;0 (now <0) jr nz,nextturnok growspeed =$+1 ld (hl),$FF nextturnok: ld a,(gameCar) and _datatime jr z,nodispupdate ld hl,turn10 dec (hl) jr nz,nodispupdate ;just once every 10 turns ld (hl),10 ;reset counter cal forceshowstats ;update score nodispupdate: ld a,(Gametype) cp gamectf jr nz,noctfpeas2draw ld de,drawctfpea1 ld hl,(peaspos) cal tryDrawPea ;pea#1 ld de,drawctfpea2 ld hl,(peaspos+2) cal tryDrawPea ;pea#2 noctfpeas2draw: ld a,0 nrballs =$-1 or a cal nz,handlethoseneatlittleballs ld ix,worm1 ld a,1 nrworms =$-1 ld b,a handleworms: psh bc cal HandleWorm ld bc,worm2-worm1 add ix,bc pop bc ld hl,handledworm inc (hl) ;0..nrworms-1 dnz handleworms ;----------------------------- ;---------- keys ------------- ;----------------------------- HandleKeys: ld a,%10111111 out (1),a in a,(1) rla ;MORE? jr nc,disppausemenu CheckExit: rla ;=$17 (c=EXIT-key) ;or$A7 (c=0) jp c,GameLoop jp Exit ;jr? ;------- pause menu ------- disppausemenu: ld hl,txtpMenu ld ix,pospMenu ;Resume|Turn Off|Contrast|Exit|| ld b,25*16/4 cal dispmenucommon ld hl,$FC00+$170 ;(*,23) cal hr ld hl,$FC00+$310 ;(*,49) cal hr cal menupos pauseMenu: psh bc pmenuwaitkey: cal ubergetkey or a jr z,pmenuwaitkey pop bc ;GET_KEY ld d,b ;c=new b cp K_UP jr nz,pmenunotup dec d pmenunotup: cp K_DOWN jr nz,pmenunotdown inc d pmenunotdown: psh af cal menupos ld a,d ;new pos and 3 ;0-3 ld b,a cal menupos pop af cp K_ENTER jr z,pselect cp K_SECOND jr nz,notpselect pselect: ld a,b or a ;1: continue jr z,donepausing dec a ;2: off jr z,turnoff dec a ;3: contrast jr z,pauseMenu jr Exit ;4: exit notpselect cp K_EXIT jr z,donepausing ld hl,CONTRAST sub K_LEFT jr z,contrastdown dec a ;K_RIGHT jr nz,pauseMenu contrastup: inc (hl) jr setcontrast contrastdown: dec (hl) setcontrast: ld a,(hl) out (2),a jr pauseMenu turnoff: ld bc,$0103 out (c),b halt ;pause/off ld b,11 out (c),b ld b,1 jr pauseMenu donepausing: cal releasekeys jp GameLoop Exit: cal releasekeys ld sp,0 ;pop all SpSave = $-2 ld a,D0LD1L out (7),a ;both wires low = game over signal cal _clrWindow #ifdef coolzgfx ld de,$FC30 ;(0,1) ld hl,wtWormy ld bc,16*7 ldir ld hl,$FC10 ld b,16*11 cal menuinvloop ;invert ld hl,$FD80 cal hr ;menuinvloop w/ b=16 ld hl,$FCE0 cal hr ld hl,_curRow ld (hl),2 #else ld hl,txtGO cal _puts ld hl,$FC00 ld b,16*8 cal menuinvloop ;invert inc h ;$FD80 cal hr ;menuinvloop w/ b=16 ld hl,$FCE0 cal hr ld hl,_curRow inc (hl) #endif ld hl,txtGame CURtxtGame =$-2 cal _puts ld a,$0D ;$0D02 ld (_curCol),a cal showLevel ld de,$1901 ld (_penCol),de ld hl,txtName cal _vputs ;Name ld a,$3D ld (_penCol),a cal _vputs ;Died Score ld de,$0004 ld (_curRow),de findwinner: ld hl,(worm1+score) ld (winnerscore),hl ld b,3 ;(nrworms)-1 ld hl,worm2+score findwinnerloop: psh hl cal _ldHLind ld de,(winnerscore) ld a,h cp d jr c,nonewwinner ;hd ld a,e cp l jr nc,nonewwinner ;l$FB) ld hl,worm1+died finddmwinner: cp (hl) jr c,nonewdmwinner ld a,(hl) ;less deaths nonewdmwinner: ld de,worm2-worm1 add hl,de dnz finddmwinner ld (dmwinner),a ;---display worms--- ld a,(nrworms) ld b,a ld hl,worm1+died displayWormStats: psh bc psh hl ld bc,left-died add hl,bc ;+left xor a cp (hl) ;input=0 = link jr nz,NoLinkIndic ld a,9 ld (_curCol),a ld a,$DC ;-O cal _putc xor a ld (_curCol),a NoLinkIndic: inc hl inc hl ;+name cal _puts pop hl psh hl ld a,13 ld (_curCol),a ld a,(hl) ;worm+died cal showA0 pop hl psh hl ld a,(Gametype) cp gamedeathm jr nz,nodmwinner ;deathmatch? ld a,0 ;winner's deaths dmwinner =$-1 cp (hl) ;equals this worm? scf ;jr nz,notwinner cal z,iswinner nodmwinner: jr c,notwinner ;no singleplayer winners inc hl ;worm+score cal _ldHLind ;ld hl,(hl) ld de,0 winnerscore =$-2 cal _cphlde ;==highest score.. cal z,iswinner notwinner: ld a,16 ld (_curCol),a pop hl psh hl inc hl ;worm+score cal _ldHLind cal showHL pop hl ld bc,worm2-worm1 add hl,bc pop bc dnz displayWormStats ld a,(Gametype) or a ;singleplayer (0) only jr nz,hilevelcheckdone checkhilevel: ld hl,nrlevels ld a,(Level) cp (hl) jr c,hilevelcheckdone ld (hl),a ;save local ld c,a ld a,0 hilvlposa =$-1 ld hl,nrlevels hilvlposhl =$-2 ;save external cal _writeb_inc_ahl ;ld (ahl),c hilevelcheckdone: ld a,(gameCar) and _datasingl jr z,hiscorecheckdone ;no SP checkhiscore: cal loadhiscoreposinahl cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile) xor a ld hl,highsave cal _SET_ABS_DEST_ADDR ;to local ld hl,5 ;5 bytes cal _MM_LDIR_SET_SIZE ;get old score+name cal _RAM_PAGE_1 ld de,(highsave) ;de=prev. hiscore ld hl,(worm1+score) ;hl=worm1's score cal _cphlde ;sub hl,de jr c,NotNewHigh ;newOld ld (highsave),hl ;store new hiscore ld de,highsave+2 ;to ld hl,worm1+name ;from ld bc,3 ;3 chars ldir ;store new hiname cal loadhiscoreposinahl cal _SET_ABS_DEST_ADDR ;to ahl xor a ld hl,highsave cal _SET_ABS_SRC_ADDR ;from local ld hl,5 cal _MM_LDIR_SET_SIZE ;save new cal _RAM_PAGE_1 ld hl,_curRow dec (hl) cal iswinner NotNewHigh: ld hl,$3149 ld (_penCol),hl ld hl,txthiscore cal _vputs ld hl,$0C07 ld (_curRow),hl ld hl,highsave+2 cal _puts ld hl,(highsave) cal showHL hiscorecheckdone: waitkey: cal ubergetkey cp K_ENTER jp z,DisplayMenu cp K_SECOND jp z,DisplayMenu cp K_EXIT jr nz,waitkey ;x123456789012345678901 ;>>>>>> GAME OVER <<<<< ;2Multiplayer ;3Level 01 ;4 Died Score: ;5NameName 03 00070 ;6Worm#02 @ 05 00120 ;7Worm#03 15 00030 ;8Snaky @ 00 04820 ExitNoStats: cal linkok ld hl,_asapvar rst 20h ;_ABS_MOV10TOOP1 rst 10h ;_FINDSYM ld hl,savestart-_asm_exec_ram+4 xor a add hl,de adc a,b ;ahl=bde+4 cal _SET_ABS_DEST_ADDR xor a ld hl,savestart cal _SET_ABS_SRC_ADDR ld hl,saveend-savestart cal _MM_LDIR_SET_SIZE cal releasekeys res 4,(iy+9) set 2,(iy+13) im 1 ;remove keyfix jp _clrWindow loadhiscoreposinahl: ld hl,0 ;for peaworm and singleplayer ld a,(Gametype) or a ;Singleplayer? jr z,hi__ dec a ;peaworm? jr z,hi_ ld a,(nrlevels+1) ;skip peaworm slots if tron mode hi_: ld bc,(Level) add a,c ld b,a ;levels to skip (including 1 for singleplayer) ld de,5 ;to add per level addlevelposition: add hl,de ;one word+3 bytes for name dnz addlevelposition hi__: xor a ;ahl=0(+hl) ld bc,defhiscrpos hiscrposhl =$-2 add hl,bc hiscrposa =$+1 adc a,0 ;ahl=saveloc ret highsave: .db 0,0,"WOR ",0 iswinner: ld a,10 ld (_curCol),a ld a,'*' jp _putc ;..then put * ;----------------------------- ;----------- worm ------------ ;----------------------------- respawncheck: cp respawndelay-1 jr nz,unnamedlabel cal saverespawncounter removeworm: ld h,(ix+tail+1) ;& ld l,(ix+tail) ld d,(ix+head+1) ld e,(ix+head) jr DoesWormTailEqualsWormHead ;chk4 size=0 removewormloop: ld c,(hl) inc hl ld b,(hl) inc hl cal resbit psh hl cal res4pixels pop hl inc (ix+grow) DoesWormTailEqualsWormHead: cal _cphlde jr nz,removewormloop ld a,(gameCar) and _datasingl jr nz,safewormsizedone ld a,0 beginsize =$-1 ld (ix+grow),a safewormsizedone: ;de=ix+head ld (ix+tail+1),d ld (ix+tail),e ;head=tail/size=0 ret unnamedlabel: cp 1 ld h,a jr nz,saverespawncounter respawndue: ld l,a cal inputcall ld a,h ;previous cp l ;changed? ret z ld (ix+delay),a ;=0 ret saverespawncounter: ld (ix+delay),a jr inputcall chkkey: ;key=a dec a ld b,a srl b srl b srl b ;b=a/8 and 7 ;a=a\8 ld c,a ;push keybit ld a,-1 out (1),a inc b ld a,%01111111 ;default bitmask: rlca ;rotate left dnz bitmask ;a/8 times out (1),a ;send bitmask in a,(1) ;input keys ld b,c ;pop keybit inc b keybit: rra dnz keybit ;check match (cf set) ret inkeys: ;use jp not call! cal chkkey jr nc,notright ld a,l add a,8 turnright =$-1 ld l,a notright: ld a,(ix+right) cal chkkey ret nc ld a,l sub 8 turnleft =$-1 ld l,a ret inputcall: ld a,(ix+left) or a jr z,inlink ;input by link cal inkeys ;input by keys ld a,(gameCar) rra ;and _datalink ret nc ;no link ld c,l ;send our keys jp Qsend inlink: cal Qrecv ;Crecv ld l,c ret ;----------------------------- ;------- handle worm --------- ;----------------------------- HandleWorm: xor a cp (ix+lives) jr nz,alive ld a,(wormbeglives) or a ret nz ;live limit alive: ld a,(ix+delay) dec a jp nz,respawncheck xor a cp 0 turn =$-1 jr nz,nogrow inc (ix+grow) nogrow: ld a,(gameCar) and _datatime jr z,notimescore ld e,1 cal IncScore notimescore: ld l,(ix+heading) cal inputcall donediddelydone: ld (ix+heading),l ld h,(ix+heading+1) ld c,(ix+pos) ld b,(ix+pos+1) ld e,(ix+pos2) ld d,(ix+pos2+1) psh hl ld hl,previouspos ld (hl),c inc hl ld (hl),b inc hl inc hl ld (hl),e inc hl ld (hl),d pop hl ;-------- move worm ---------- Wormmove: psh bc ; >> pos ld a,(hl) add a,a add a,d ld d,a bit 7,(hl) jr z,notnegX dec b notnegX: jr nc,notmoveX inc b notmoveX: ld a,l add a,$40 ld l,a ld a,(hl) add a,a add a,e ld e,a bit 7,(hl) jr z,notnegY dec c notnegY: jr nc,notmoveY inc c notmoveY: ;bc=newpos ld (ix+pos2),e ld (ix+pos2+1),d ld (ix+pos),c ld (ix+pos+1),b ;-check- pop hl ; << pos (old) ld a,h sub b and 1 ld h,a ld a,l sub c and 1 add a,h ld d,4 jr z,GotFour xor 3 ld d,a GotFour: cal chk4pixels rl d jp nc,Drawworm ;--------- worm hit ---------- Hitworm: ld a,(gameCar) ld h,a #ifdef optdie and _datadie cal z,checkhitotherworm ld a,h #endif and _datamultpeas ;&&bit jr nz,chkctfpeas ld a,h and _datafood jp z,WormDead ;no food ld hl,0 PeaY =$-2 PeaX =$-1 cal chkpeahit jp nc,WormDead cal DrawPea ;remove pea ld a,(ix+grow) add a,15 peagrowth =$-1 ld (ix+grow),a cal NewPea ld hl,Left dec (hl) psh af ld e,10 cal IncScore pop af jp nz,Drawworm ;continue ld a,(gameCar) and _datafoodl jp z,Drawworm ld a,(Gametype) or a jp nz,Exit ;stack restored ld hl,Level ld a,(hl) inc (hl) ld l,a ;hl=Level ld h,0 add hl,hl add hl,hl cal _HLTIMES10 ex de,hl cal _IncScore ;score+(40*level) cal removeworm pop hl ; << call pop hl ; << call ld (ix+delay),2 jp Nextlevel chkpeahit: ;bc=ownpos;hl=peapos (destr:ad) ld a,(sprsize) inc a ld d,a ld a,b sub h inc a cp d ;=(sprsize)+1 ret nc ;nc=no pea ld a,c sub l inc a cp d ret ;c=pea chkctfpeas: ld hl,(peaspos) ;1st pea ld a,(ix+reserv) ld e,a ;push a and %01 ;ourpea (0|1) jr z,sel_otherpea ld hl,(peaspos+2) ;2nd pea ;&&&ex de,hl? sel_otherpea: cal chkpeahit jr c,hitflag ;no peas hit: ld a,e ;peek a (that's x86asm for pop\push ;) bit 1,a ;%10 = carrying flag? jp z,WormDead ;if not just die xor %11 ;drop flag ld (ix+reserv),a psh af cal WormDead pop af ;which flag? (=and %1) ld hl,drawctfpea1 ;restore #1 jr z,nottheotherflag ld hl,drawctfpea2 ;restore #2 nottheotherflag: ld (hl),3 ;draw delay 3 turns ret drawctfpea1: .db 0 drawctfpea2: .db 0 hitflag: ;correct pea hit ld a,e ;pop a xor %11 ;invert flag taken + ownflag ld (ix+reserv),a and %10 ;just returned? psh af ;safe z-flag cal DrawPea ;remove pop af jr nz,Drawworm ;flag taken, continue game psh hl ld e,20 ;flag captured+returned cal IncScore pop hl ld a,3 ;draw delay ld (drawctfpea1),a ;redraw.. ld (drawctfpea2),a ;..both flags jr Drawworm ;----------------------------- nextotherwormbit: ld a,c sub (hl) inc hl inc a cp 4 jr nc,nothit1 ;no ld a,b sub (hl) inc a cp 4 ret c ;nz ;yes nothit1: inc hl cal resbit ChkWorm: cal _cphlde jr nz,nextotherwormbit ret ;z checkhitlapline: ld a,(peaspos) ;63 sub b ;x==63 jr z,nextlaphalf inc a ret nz nextlaphalf: ld a,(peaspos+1) ;yline cp c ;ypos ld a,1 jr nc,checklap ;y>yline -> a=1 xor a ;y a=0 checklap: cp (ix+reserv) ret z ;same as before ld (ix+reserv),a ;1st time ld e,a ld a,(handledworm) and 1 ;group 0 (1,3) or 1 (2,4) xor e ret z ;(group 0 and yyline) psh bc ld e,20 cal IncScore ;lap! pop bc ret #ifdef optdie checkhitotherworm: .db $dd,$7d ;ld a,lx cp worm2&255 psh ix jr nz,chkworm2 ; ret nz ld ix,worm1 jr chkworm chkworm2: ld ix,worm2 chkworm: ld h,(ix+tail+1) ld l,(ix+tail) ld e,(ix+head) ld d,(ix+head+1) cal ChkWorm pop ix ret z ;not hit pop bc ;call #endif stopworm: ld bc,0 previouspos =$-2 ld de,0 ld (ix+pos),c ld (ix+pos+1),b ld (ix+pos2),e ld (ix+pos2+1),d ret ;-------- draw worm ---------- Drawworm: ld c,(ix+pos) ld b,(ix+pos+1) ld a,(Gametype) cp gamerace cal z,checkhitlapline cal set4pixels dec c ld a,(growspeed) or a ;0=tron ret z ;keep tail in "Tron" ld l,(ix+head) ld h,(ix+head+1) ld (hl),c inc hl ld (hl),b inc hl cal resbit ld (ix+head),l ld (ix+head+1),h ld a,(ix+grow) dec a jr z,removetail ld (ix+grow),a ret removetail: ld l,(ix+tail) ld h,(ix+tail+1) ld c,(hl) inc hl ld b,(hl) inc hl cal resbit ld (ix+tail),l ld (ix+tail+1),h res4pixels: cal ResPixel inc b cal ResPixel inc c cal ResPixel dec b ResPixel: cal FindPixel cpl and (hl) ld (hl),a ret ;----------------------------- ;---------- ball ------------- ;----------------------------- handlethoseneatlittleballs: ld hl,balls ld b,a ;a=(nrballs) handleballs psh bc psh hl ld c,(hl) inc hl ld b,(hl) inc hl ld d,(hl) cal handleball dec c pop hl ld (hl),c inc hl ld (hl),b inc hl ld (hl),d inc hl pop bc dnz handleballs ret handleball: cal res4pixels dec c ballxmove: bit 0,d ;1=L; 0=R jr z,ballright ballleft: dec b cal checkballhit jr z,ballymove inc b ;undo res 0,d ;go right jr ballymove ballright: inc b cal checkballhit jr z,ballymove dec b ;back set 0,d ;>left ballymove: bit 1,d ;1=up; 0=down jr z,balldown ballup: dec c cal checkballhit jr z,balldone inc c res 1,d ;go down jr balldone balldown: inc c cal checkballhit jr z,balldone dec c set 1,d ;up balldone: set4pixels: ;@(b,c) cal SetPixel inc b cal SetPixel inc c cal SetPixel dec b SetPixel: ;at bc cal FindPixel or (hl) ld (hl),a ret letsmovetheotherway: ld a,1 xor (hl) ld (hl),a ret checkballhit: psh de ld d,0 cal chk4pixels xor a cp d pop de ret ;----------------------------- ;----------- procs ----------- ;----------------------------- releasekeys: halt ld a,%10000000 ;all key-masks out (1),a in a,(1) inc a ;cp %11111111 (no keys pressed) jr nz,releasekeys ;keep waitin cal GET_KEY ;clear buffer ret resbit: ld a,h and (ix+storepos) ld h,a ret randompos: ld b,a Random: ;(2..b+2) ld a,r Seed =$+1 add a,0 ld (Seed),a and %01111110 cp b jr nc,Random add a,2 ret WormDead: #ifdef invincible jp stopworm #else ld a,2 ld (flashtime),a ld (ix+delay),respawndelay thislevel =$+1 ld hl,0 ld de,0 handledworm =$-2 add hl,de add hl,de add hl,de ld a,(hl) inc hl ld (ix+heading),a ld a,(hl) ld (ix+pos),a ;y inc hl ld a,(hl) ld (ix+pos+1),a ;x xor a ld (ix+pos2),a ;y2 ld (ix+pos2+1),a ;x2 inc (ix+died) dec (ix+lives) psh af ld de,10 ld a,(Gametype) cp gamectf ;ctf no death penalty cal nz,DecScore pop af ret nz ;HandleWorm done ld a,(wormbeglives) or a ;0=no live limit ret z ;don't end game ld a,(gameCar) and _datatime jr z,anyworm ;quit at any worm's death ld a,(nrworms) ;timematch: all worms must've died ld b,a ;# of worms ld hl,worm1+lives-(worm2-worm1) ld de,worm2-worm1 xor a ;check for 0 lives checklives: add hl,de ;next worm cp (hl) ;lives==0? ret nz ;any >0: don't exit dnz checklives anyworm: ld a,$A7 ;exit@end of turn ld (CheckExit),a ;set exit state ret ;finish turn #endif CheckPea: ;@hl; destr:abcde ld c,l ld a,(sprsize) ld e,a chkloopy: ld b,h ld a,(sprsize) ld d,a chkloopx: psh hl cal FindPixel and (hl) pop hl ret nz ;nz=pixel found inc b dec d jr nz,chkloopx inc c dec e jr nz,chkloopy ret ;z=empty space tryDrawPea: ;hl=peapos;bc=dopea ld a,(de) or a ;0=drawn ret z psh de cal CheckPea pop de ret nz ;unsuccesful ex de,hl dec (hl) ;hl=appeartime ex de,hl ;hl=peaspos jr z,DrawPea ret sendnewpeaoverlink: ld a,(gameCar) rra ;and _datalink ret nc ;no link ld a,(ix+left) or a jr z,receivenewpeaoverlink ld c,l ;send pea's pos cal Qsend ld c,h jp Qsend ;&&&possible jr receivenewpeaoverlink: cal Qrecv ;Crecv ld l,c cal Qrecv ;Crecv ld h,c ret NewPea: ld a,(FieldWidth) add a,127-4 cal randompos ld h,a ld a,(FieldHeight) add a,56-4 cal randompos ld l,a cal CheckPea jr nz,NewPea cal sendnewpeaoverlink ld (PeaY),hl DrawPea: ;hl=(PeaY) ld b,h ld c,l ld de,0 spritepos =$-2 ; jp PutSprite PutSprite: ;||@(b,c) ;by SHIAR only ix saved cal FindPixel ld (beginbit),a ld a,0 sprsize =$-1 ld b,a ;rows sprloopy: psh bc ;rows psh hl ld a,(de) ld c,a inc de ld a,(sprsize) ld b,a ;width beginbit =$+1 ld a,1 sprloopx: sla c ;draw? jr nc,sprnodraw psh af xor (hl) ld (hl),a pop af sprnodraw: rrca ;next bit jp nc,nextbitok inc hl ;next byte nextbitok: dnz sprloopx pop hl ld bc,32 ;next line add hl,bc pop bc dnz sprloopy ret ;----------- score ----------- timematchscore: ;piece of crap checking whether you've already won in timematch ld a,(nrworms) ld b,a ;# of worms dec a ret z ;singleplayer ld hl,worm1+lives ld de,worm2-worm1 ld a,(handledworm) ld c,a ;wormcounter chktimematchover: xor a cp c jr z,nneexxtt ;yourself cp (hl) ret nz ;someone else still alive dec hl ;+delay dec hl ;+score+1 ld a,(hl) cp (ix+score+1) jr c,nneexxtt_ ;you>him ret nz ;not highest dec hl ;+score ld a,(hl) cp (ix+score) ret nc ;you<=him inc hl nneexxtt_: inc hl inc hl nneexxtt: dec c add hl,de dnz chktimematchover jp anyworm ;g/o _divHLby1000: psh hl ld b,3 divideagain: ;3x cal _divHLby10 dnz divideagain ld a,l ;a=hl/1000 pop hl ret extralives: cal _divHLby1000 ld c,a add hl,de ;increase score cal _divHLby1000 cp c jr z,scorecommon ;hl/1000 not increased inc (ix+lives) jr scorecommon DecScore: ;&&& ld h,(ix+score+1) ld l,(ix+score) or a sbc hl,de jr c,showstats ;<0=0 jr scorecommon IncScore: ;inc score by e ld d,0 _IncScore ; inc by de ld h,(ix+score+1) ld l,(ix+score) ld a,(Gametype) or a ;if singleplayer... jr z,extralives add hl,de ;score+=de scorecommon: ld (ix+score+1),h ld (ix+score),l ;save ld de,0 scorelimit =$-2 ld a,d or e jr z,showstats ;de=0=no limit cal _cphlde jp nc,Exit showstats: ld a,(gameCar) and _datatime jr nz,timematchscore ;no disp for timematches ld hl,$FC00 ;&&&only necessary in deathmatch ld b,6*16-1 clearstats: ld (hl),a ;=0 inc hl dnz clearstats forceshowstats: psh ix ld h,0 ld l,h ld (_penCol),hl ld a,(nrworms) ld b,a ld ix,worm1 ld a,(gameCar) and _datasingl jr nz,showstatsS showstatloop: psh bc #ifdef longnames ld b,3 psh ix shownameloop: ;1st 3 chars ld a,(ix+name) or a jr z,nameshown cal __vputmap inc ix dnz shownameloop nameshown: ld a,':' cal _vputmap pop ix #else ld a,(ix+name) cal __vputmap ld a,':' cal __vputmap #endif cal showstat ld de,worm2-worm1 add ix,de ;next ld hl,_penCol ld a,(hl) add a,4 ;div ld (hl),a pop bc dnz showstatloop pop ix ret showstat: ;(multiplayer) ld a,(Gametype) cp gamedeathm jr z,showlives showscore: ld h,(ix+score+1) ld l,(ix+score) cal _D_HL_DECI jr __vputs showlives: ld a,(ix+lives) showA: ;small w/o leading 0 (&&&combine w/ cshowA0??) cp 10 jr c,showleastsign ld l,a ld h,0 cal _divHLby10 psh af ld a,l add a,'0' cal __vputmap pop af showleastsign: add a,'0' __vputmap: psh ix cal _vputmap pop ix ret showstatsS: ;(singleplayer) ld hl,txtLevel cal __vputs ld a,0 Level =$-1 cal showA ld a,98 ld (_penCol),a cal showscore ld a,123 ld (_penCol),a cal showlives ld a,(gameCar) and _datafoodl pop ix ret z showleft: ld a,31 ld (_penCol),a ld a,0 Left =$-1 cal cshowA0 ld hl,txtLeft __vputs: psh ix cal _vputs pop ix ret showLevel: ld hl,txtLevel cal _puts ld a,(Level) showA0: ;big w/ leading 0 ld l,a ld h,0 cal _divHLby10 psh af ld a,l add a,'0' cal _putc pop af add a,'0' jp _putc cshowA0: ;small w/ leading 0 or a jr nz,cshowavalue ld hl,txtNone jp _vputs cshowavalue: ld l,a ld h,0 cal _divHLby10 psh af ld a,l add a,'0' cal __vputmap pop af add a,'0' jp __vputmap showHL: cal _D_HL_DECI jp _puts _D_HL_DECI: ld de,savestr+4 ld b,5 ldhld: cal _divHLby10 add a,'0' ld (de),a dec de dnz ldhld ld hl,savestr ret savestr: .db "00000",0 ;----------------------------- DisplayField: ld a,c sub 29 jr nc,NotMinYScroll xor a NotMinYScroll: cp 43 FieldHeight =$-1 jr c,NotMaxYScroll ld a,(FieldHeight) NotMaxYScroll: ld l,a ld h,0 add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl psh bc ; >> 1 psh de ; >> 2 ld de,ScrBuffer add hl,de ld a,b sub 64 jr nc,NotMinXScroll xor a NotMinXScroll: cp 128 FieldWidth = $-1 jr c,NotMaxXScroll ld a,(FieldWidth) NotMaxXScroll: psh af ; >> 3 and %11111000 rra rra rra ld c,a ld b,0 ld de,DispBuffer pop af ; << 2 and %00000111 psh af ; >> 3 cp 6 jr c,CopyScreen inc c CopyScreen: add hl,bc ld b,57 CopyScreenLoop: psh bc ; >> 4 ld bc,16 ldir ld c,16 add hl,bc pop bc ; << 3 dnz CopyScreenLoop pop af ; << 2 ld c,$b7 ;or a Bit0: jr nz,Bit1 halt halt jr AfterShiftDelay Bit1: dec a jr nz,Bit2 cal ShiftRight1 jr AfterShiftDelay Bit2: dec a jr nz,Bit3 ld a,2 cal ShiftRight jr AfterShiftDelay Bit3: dec a jr nz,Bit4 cal Chunk cal ShiftLeft1 jr AfterShift Bit4: dec a jr nz,Bit5 cal Chunk jr AfterShiftDelay Bit5: dec a jr nz,Bit6 cal Chunk cal ShiftRight1 jr AfterShift Bit6: dec a jr nz,Bit7 ld a,2 cal ShiftLeft jr AfterShift Bit7: cal ShiftLeft AfterShiftDelay: halt AfterShift: #ifdef buffer ld hl,DispBuffer ld de,$fc00+$70 ld bc,1024-$70 ldir #endif pop de ; << 1 pop bc ; << 0k ret ShiftRight1: ld a,1 ShiftRight: ld (ShiftRightCounter),a ld a,c ld (ShiftRightChunk),a ld c,16 add hl,bc ld b,57 ShiftRightLoop: psh bc ld bc,-32 add hl,bc ex de,hl ld a,(de) ShiftRightChunk: or a cal c,_SHLACC ld c,0 ShiftRightCounter = $-1 ShiftRowsLeft: psh hl rla ld b,16 ShiftRowLeft: dec hl rl (hl) dnz ShiftRowLeft pop hl dec c jr nz,ShiftRowsLeft ld bc,-16 add hl,bc ex de,hl pop bc dnz ShiftRightLoop ret ShiftLeft1: ld a,1 ShiftLeft: ld (ShiftLeftCounter),a ld a,c ld (ShiftLeftChunk),a rla jr nc,ShiftLeftSameByte dec hl ShiftLeftSameByte: ex de,hl ld bc,-16 add hl,bc NewSprite: ex de,hl ld b,57 ShiftLeftLoop: psh bc ; >> 1 ld bc,-32 add hl,bc ex de,hl ld a,(de) ShiftLeftChunk: or a cal c,_SHRACC ld c,0 ShiftLeftCounter = $-1 ShiftRowsRight: psh hl ; >> 2 rra ld b,16 ShiftRowRight: rr (hl) inc hl dnz ShiftRowRight pop hl ; << 1 dec c jr nz,ShiftRowsRight ld bc,-16 add hl,bc ex de,hl pop bc ; << 0k dnz ShiftLeftLoop ret Chunk: psh hl ; >> 1 psh de ; >> 2 ld c,16 add hl,bc ld b,57 ChunkScreen: psh bc ; >> 3 ld bc,-32 add hl,bc ex de,hl ld a,(de) cal _SHRACC ld b,16 ChunkRow: dec hl rld dnz ChunkRow ex de,hl pop bc ; << 2 dnz ChunkScreen pop de ; << 1 pop hl ; << 0k ld c,$37 ;scf ret ;----------- draw ------------ ;--- pixel --- chk4pixels: ;&& cal CheckPixel inc b cal CheckPixel inc c cal CheckPixel dec b cal CheckPixel dec c ret CheckPixel: ;at bc in d cal FindPixel and (hl) ret z dec d ret ;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes) ;(b,c) to hl:a; "destroyes" ahl FindPixel: ;(b,c) to hl:a ld h,0 ld l,c ;hl=y add hl,hl add hl,hl ld a,b ;a=x rra add hl,hl rra add hl,hl add hl,hl ;hl=32*y rra ;a=x/8 or l ld l,a ld a,b and 7 cpl rlca rlca rlca ld (FP_Bit),a xor a FP_Bit =$+1 set 0,a psh de ;&&& ld de,ScrBuffer add hl,de pop de ret ;--- objects --- drawstuff: ld a,(hl) inc hl or a ;0 = ret z ;no more ld d,(hl) inc hl ld e,(hl) inc hl ld b,(hl) inc hl psh hl ld l,(hl) ld h,b cal drawsmtn pop hl inc hl jr drawstuff drawsmtn: dec a ;1 = line jr z,drawline dec a ;2 = fatline jr z,drawfatline dec a ;3 = box jr z,drawbox ; dec a ;4 = circle ; jp z,drawcircle drawcircle: ;(d,e),h ;de=x,y; h=z ld c,h ;c=yy=z ld a,h neg ld l,a ;l=-z xor a ld b,a ;b=xx=0 dec a ;-$00** ld h,a ;hl=zz=-z circloop: psh de ;x,y ex (sp),hl ;push zz \ pop x,y cal circledraw ;(x-xx,y+yy)-(x+xx,y+yy) ;(x-xx,y-yy)-(x+xx,y-yy) cal circledraw ;(x-yy,y+xx)-(x+yy,y+xx) ;(x-yy,y-xx)-(x+yy,y-xx) ex (sp),hl ;push x,y \ pop zz xor a ld d,a ;d=0 dec a ;-256=yy inc b ;xx++ jr circloop circledraw: ;destr:de psh hl ld a,h ;hl=x,y sub b ;bc=xx,yy ld d,a ;d=x-xx add hl,bc ;h=x+xx; l=y+yy ld e,l ;e=y+yy cal drawline ;(h-b,l+c)-(h+b,l+c) ld a,l sub c ;a=y again sub c ld l,a ;l=y-yy ld e,l ;e=l=y-yy cal drawline ;(h-b,l-c)-(h+b,l-c) ld a,b ;swap xx and yy ld b,c ld c,a ;ex b,c pop hl ret drawbox: ;(d,e)-(h,l) ld b,l ;Delta-y ld l,e boxloop: cal drawline inc l inc e dnz boxloop ret drawfatline: cal drawline inc d inc h cal drawline inc e inc l cal drawline dec d dec h ; jp drawline ;LINE (d,e)-(h,l) ;destroyes a drawline: ;(d,e)-(h,l) psh bc ;destr: a psh hl psh de ld a,d cp h jr c,lineOrdered ex de,hl lineOrdered: ld b,d ld c,e psh hl psh bc cal FindPixel pop bc pop de connectedLine: psh hl ld h,c ld c,a ld a,d sub b ld b,a ld a,e jr nz,LineNotPoint cp h jr nz,LineNotPoint pop hl jr DoneLine LineNotPoint: sub h ld de,32 jr nc,LinePositiveY neg ld de,-32 LinePositiveY: cp b jr nc,SteepLine add a,a ld (line2sm+1),a ld h,a xor a sub b add a,a ld (line1sm+1),a ld a,h sub b pop hl LineLoopGentle: psh af ld a,(hl) or c ld (hl),a rrc c jr nc,$+3 inc hl pop af jp m,line2sm line1sm: add a,0 add hl,de line2sm: add a,0 dnz LineLoopGentle DoneLine: ld a,(hl) or c ld (hl),a pop de pop hl pop bc ret SteepLine: ld h,a neg add a,a ld (line3sm+1),a ld a,b add a,a ld (line4sm+1),a sub h ld b,h pop hl LineLoopSteep: psh af ld a,(hl) or c ld (hl),a add hl,de pop af jp m,line4sm line3sm: add a,0 rrc c jr nc,$+3 inc hl line4sm: add a,0 dnz LineLoopSteep jr DoneLine ;..and last but not least..: ;----------------------------- ;----------- link ------------ ;----------------------------- timeout = $8000 lossout = 20 linkok: ld a,D0HD1H out (7),a ;raise both wires = link ok ret checklink: ;load wires in A and check for timeout dec de ;decrease timer ld a,d or e jr z,linktimeout ;timeout if de==0 linktest: ld a,$BF out (1),a ;select keys in a,(1) ;input bit 6,a ;exit key jp z,Exit ;break! linkfine: in a,(7) and %11 ret linktimeout: ;de==0 cal linkok ld a,0 ;losses so far linklosses =$-1 inc a ;and this is another one ld (linklosses),a pop de ;return from link cp lossout ;quit if too many errors ret c ;otherwise just continue linkerr: jp Exit ;---- SEND ---- Qsend: ;--- try to send 8 bits in C; CF=error --- destr:abcde --- nop \ nop cal linkfine jr z,linkerr ;both wires low = exit signal ld b,8 ;bits to send sendloop: ld de,timeout rl c ;bit to send in cf ld a,D0LD1H ;0: lower white jr nc,sendbit ld a,D0HD1L ;1: lower red sendbit: out (7),a ;lower one (send bit) sendwaitack: cal checklink ;other calc must lower other wire jr nz,sendwaitack cal linkok ;raise one, ok to raise other (out (7),D0HD1H) sendfinish: cal checklink cp %11 ;both raised (by other calc) jr nz,sendfinish ; nop \ nop dnz sendloop ;repeat for all bits xor a ;nc... ld (linklosses),a ;reset number of losses ret ;=ok ;---- RECV ---- Crecv: ;--- receive 8 bits into A/C --- destr:abCde --- cal Qrecv ret nc ;return if all went ok jr Crecv ;and try again Qrecv: ;--- receive 8 bits into A/C; CF=error --- destr:abCde --- cal linkfine jr z,linkerr ;both low = error, quit ld b,8 ;bits to receive recvloop: ; ld de,timeout recvwait: cal linktest ;checklink cp %11 jr z,recvwait ;both high = nothing sent (yet) ld de,timeout rra ;received bit in cf ld a,D0LD1H jr c,received ;lower white wire as well ld a,D0HD1L ;lower red received: rl c ;save bit in c out (7),a ;both wires low recvwaitack: cal checklink jr z,recvwaitack ;same wire will be raised again by other calc cal linkok ;raise both recvfinish: dnz recvloop ;repeat for all bits xor a ;nc=no error ld (linklosses),a ;reset number of losses ret ;----------------------------- ;---------- levels ----------- ;----------------------------- ;&&&&& 99% LevelDef: .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls .db 0,2,63 ;start d, y, x .db 128,57 ;field width (128-255), height (57-255) .db 0 ;no additional lines, boxes .db 255 ;last level ret ;ending code LevelDefM: .db "Empty Arena",0 .db 8,4,15,15,0,0 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64 .db 128,57 .db 0 .db "Fast Fun :))",0 .db 8,0,18,12,5 .db %1110000,%10001000,%10001000,%10001000,%1110000,0 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64 .db 128,57 .db 0 .db "Two Circles",0 .db 8,5,18,12,0,0 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64 .db 128,57 .db 4,40,26,20,0 .db 4,90,40,11,0,0 LevelDefT: ;tron=no delay .db "Empty Tron Level",0 .db 8,4,18,12,5 .db %1110000,%10001000,%10001000,%10001000,%1110000,0 .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64 .db 128,57 .db 0 LevelDefR: ;race .db "Round and Round",0 .db 8,4,18,12,5 .db %1110000,%10001000,%10001000,%10001000,%1110000,0 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125 .db 128,57 .db 63,27 .db 4,63,27,10,0,0 LevelDefC: ;ctf .db "Default CTF",0 .db 8,4,18,12,5 .db %1110000,%10001000,%10001000,%10001000,%1110000,0 .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125 .db 128,57 .db 27,8,27,116 .db 0 ;----------------------------- ;---------- data ------------- ;----------------------------- wtPicture: ;title .db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000 .db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000 .db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011 wtWormy: ;g/o .db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000 .db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000 .db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000 .db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100 .db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010 .db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010 .db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100 ;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000 txtMenu: .db "Mode",0 ;1st menu item .db "Level",0 ;2nd .db "Link",0 ;... .db "Worms",0 .db "worm #",0 posMenu: .db 5 .dw $2418,$231E,$2824,$1F2A,$1730 txtMenuR: .db "controls",0 txtoMenu: .db "Back",0 ;1st menu item .db "Lives",0 ;2nd .db "Limit",0 ;... .db "Speed",0 .db "Rotation",0 .db "Growth",0 posoMenu: .db 6 .dw $2618,$251E,$2524,$222A,$1A30,$1C36 txtpMenu: .db "Resume",0 ;1st menu item .db "Turn Off",0 ;2nd .db "Contrast",$CF,5,0 ;... .db "Exit",0 pospMenu: .db 4 .dw $3418,$331E,$2F24,$3A2A txtGame: .db "Singleplayer",0 txtGame1: .db "Peaworm",0 txtGame2: .db "Tron",0 txtGame3: .db "Deathmatch",0 txtGame4: .db "Foodmatch",0 txtGame5: .db "Timematch",0 txtGame6: .db "Race",0 txtGame7: .db "CTF" ;,0 posGame: .db 0 .db txtGame1-txtGame .db txtGame2-txtGame .db txtGame3-txtGame .db txtGame4-txtGame .db txtGame5-txtGame .db txtGame6-txtGame .db txtGame7-txtGame txtNone: .db "None",0 txtDef: .db "Default",0 txtYes: .db "Yes",0 txtNo: .db "No",0 txtKeyleft: .db ":left",0 txtKeyright:.db "/right",0 posLevsel = $0320 txtLevsel: .db $CF," SELECT LEVELS ",5,0 txtWaiting: .db "Waiting...",0 txtReceive: .db "Receiving..." ;,0 TrigPrecalc: .db 0, 3, 6, 9, 12, 15, 18, 21 .db 24, 27, 30, 33, 36, 39, 42, 45 .db 48, 51, 54, 57, 59, 62, 65, 67 .db 70, 73, 75, 78, 80, 82, 85, 87 .db 89, 91, 94, 96, 98,100,102,103 .db 105,107,108,110,112,113,114,116 .db 117,118,119,120,121,122,123,123 .db 124,125,125,126,126,126,126,126 .db 127 txtLevel: .db "Level ",0 txtWorms: .db "Worms: 0",0 ;follows txtLevel txtName: .db "Name",0 txtWinner: .db "Wins " ;follows txtName txtDied: .db "Died " ;follows txtWinner txtScore: .db "Score",0 ;follows txtDied txtLeft: .db " left",0 ;follows txtScore txthiscore:.db "HiScore:",0 #ifdef readytext txtReady: .db "Prepare!",0 txtposReady = 7 #endif #ifndef coolzgfx txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0 #endif datalevels: .dw LevelDef, LevelDefM .dw LevelDefT,LevelDefM .dw LevelDefM,LevelDefM .dw LevelDefR,LevelDefC nrlevels: .db 0,3,1,3,3,3,3,1 ;=defaults _datalink = %0000001 ;linkplay _datafoodl = %0000010 ;left=0 limit _datasingl = %0000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel) _datamultpeas = %0001000 ;multiple peas=1 _datatime = %0010000 ;time incs score (timematch) _datafood = %0100000 ;food present _datadie = %1000000 ;worm dies on impact ;reserved %10000000 ;for future use savestart: ; Úgame info (see above) ; | Úlives (0=unlimited) ; | | Únrworms (can be altered by user) ; | | | Úlevel (reset to 1 at startup) ; | | | | Úspeed/delay (-1=def) ; | | | | | Úgrow speed (-1=none; 0=continuous) ; | | | | | | Úturn speed (8=def) ; | | | | | | | Úscore limit (0=none) gamesingle = 0 ;used | | | | | | | | datasingle: .db %1100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives) gamepeas = 1 datapeas: .db %1100100,1,1,1,-1,-1, 8, 0 ;Peaworm (SP; 1 live) gametron = 2 datatron: .db %1010100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth) gamedeathm = 3 ;used datadeathm: .db %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth) gamefoodm = 4 datafoodm: .db %1100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score) gametimem = 5 datatimem: .db %1010000,1,2,1,-1, 0, 8, 0 ;Timematch (tron, 100 score) gamerace = 6 ;used datarace: .db %0000000,0,2,1,-1,-1, 8,10 ;Race (100 score, no collision) gamectf = 7 ;used datactf: .db %1001000,0,4,1,-1,-1, 8,10 ;CTF (100 score) worm1set: .dw worm1p,worm1p .db %11110111,1,-01,K_RIGHT,K_LEFT worm1name: .db "WORMY ",0 worm2set: .dw worm2p,worm2p .db %11111011,0,-01,K_F2,K_F1 worm2name: .db "VIPER ",0 worm3set: .dw worm3p,worm3p .db %11111011,1,-01,K_COMMA,K_STO worm3name: .db "NIBBLER ",0 worm4set: .dw worm4p,worm4p .db %11111011,0,-01,K_PLUS,K_ENTER worm4name: .db "JIM ",0 defhiscrpos: .db 0,0,"SHI" .db 0,0,"SHI" .db 0,0,"SHI" .db 0,0,"SHI" .db 0,0,"SHI" Gametype: .db 0 ;last gamemode saveend: ;set: heading = 0 ;level* pos = 2 ;level* pos2 = 4 ;level grow = 6 ;level died = 8 ;game score = 9 ;game delay = 11 ;game ;19B @game lives = 12 head = 13 ;4B (head=tail) tail = 15 ;also@next level storepos = 17 reserv = 18 ;loop (race:lap|ctf:pea) input = 19 ;---currently unused afaik--- left = 20 right = 21 name = 22 wormsize = 31 startdelay = 30 respawndelay = 30 maxnamelength = 8+1 ;bla space (reserved for internal levels) .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db "WWW.SHIAR.ORG WWW.SHIAR.ORG " .db " wormy@shiar.org",0 defspritesz = 4 defspriteimg: .db %01100000 .db %11110000 .db %11110000 .db %01100000 deflevels: .db "Internal Levels",0 .db "by SHIAR -- still t" .db "o be added...." ;,0 .db 0,deflevels/256,deflevels&255 templevels: ;----------------------------- ;----------- end ------------- ;----------------------------- .end .end