; Title : Wormy ; Version : 93% ; Release Date : summer 2001 ; Filename : wormy.86p (5kb) ; Author(s) : Shiar ; Email Address : shiar0@hotmail.com ; ICQ UIN : #43840958 ; 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 ----------- ;----------------------------- ; 93% = DONE ; [* internal levels ] ; [ * check levels/gametype ] ; [ * enough hiscore saves! ] ; [* complete readme ] ; 1% * misc (pollish, bugs, &&&) ; * LINK ; * fix first packet loss ; 1% * transmit game/level data ; 1% * get g/o signal (l&l) working ; 2% * send new peas' positions ; * CTF ; 1% * fix pea XOR problem in ctf ; 1% * fix wormstop in race ;100% = bugs fixed + levels done ;----------------------------- ;----------------------------- ;--------- W O R M --------- ;----------------------------- ;----------------------------- #define buffer ;use display buffer (otherwise write directly to screen) #define readymask ;"greys" out the field before starting a level ;#define hlines ;horizontal-line routine for more speed drawing boxes ;^^(doesn't work properly)^^ ;#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 (4x40) ;free $AE01 ;-AFFF (1FF) worm1p = $B000 ;-B7FF (800) %1011O000 worm3p = $B800 ;-BBFF (400) %10111O00 ;free $BF91 ;-BFFF (6F) ;program $D748 ;-E7FF (106D+4A) ;free $E800 ;-EFFF (800) worm4p = $F000 ;-F3FF (400) %11110O00 leveldata = $F400 ;-FA70 (<=671) turn10 = $AE01 peaspos = $AE02 ;--- temporary namelength = $BC00 ;(1) @menu #ifdef buffer DispBuffer = $BC00 ;(10x57d) @game #else DispBuffer = $FC70 #endif ;----------------------------- ;------- program start ------- ;----------------------------- .org _asm_exec_ram wormVhost = 093 wormVclient = 193 start: nop jp Start .dw 1 .dw WormTxt .dw WormIcon WormTxt: .db "WORMY by SHIAR -- beta 93%",0 WormIcon: .db 8,2 .db %00110000,%00111100 .db %01110000,%00111110 .db %11100000,%00000111 .db %11000011,%11000011 .db %11000111,%11100011 .db %11101110,%01100111 .db %01111100,%01111110 .db %00111000,%00111100 levelhead = 'w' levelhead2 = 94 ;wormy levels header = "93" 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,$0601 ;x=1 ld (_penCol),hl pop hl dispnextlevel: ld a,(hl) inc a ;cp 255 jr z,_levselect ld a,(hl) ;ade=(hl) displevel: inc hl ld d,(hl) inc hl ld e,(hl) inc hl psh hl ex de,hl ;ahl=ade=(hl) cal _load_ram_ahl ;hl=ahl ld b,(hl) ;b=title size cal _vputs ld hl,_penCol ld (hl),$01 ;x=1 inc hl ld a,(hl) add a,6 ld (hl),a ;y+6 ld hl,availevels inc (hl) pop hl jr dispnextlevel levup: cal menupos dec b ;up ld a,b cp -4 jr nz,levselected inc b ;undo jr levselected levdown: cal menupos inc b ;down ld a,b cp -3 availevels =$-1 jr nz,levselected dec b ;back up levselected: jp menupos _levselect: ld b,-3 ;level selected cal menupos levselect: halt \ halt psh bc cal GET_KEY pop bc ;GET_KEY destr. b cp K_UP cal z,levup dec a ;K_DOWN cal z,levdown cp K_SECOND-1 jr z,loadlevel cp K_EXIT-1 jp z,ExitNoStats cp K_ENTER-1 jr nz,levselect ; jr z,loadlevel loadlevel: 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 ld hl,templevels-3 add hl,de ld a,(hl) ;ade=(hl) or a ;levelfile on page 0 (=internal) jr z,levelloaded inc hl ld d,(hl) inc hl ld e,(hl) ex de,hl ;ahl=ade skiptitle: ld b,a ;psh ahl psh hl cal _GETB_AHL ;ld a,(ahl) pop hl or a ld a,b ;pop ahl psh af cal _INC_PTR_AHL ;ahl++ pop af ;cp 0 jr nz,skiptitle ;goto #0-terminator 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 ; >> 1 ld bc,65 ldir dec hl ld b,63 MirrorSineWave: dec hl ld a,(hl) ld (de),a inc de dnz MirrorSineWave pop hl ; << 0k 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+$160 cal hr ld hl,$FC00+$3E0 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 de,$FD80 ;begin pos ld b,36*16/3 xor a clroldmenuloop: ld (de),a inc de ld (de),a inc de ld (de),a inc de dnz clroldmenuloop ld b,6 dispmenuloop: ld d,(ix) inc ix ld e,(ix) 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 ;--- 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 cshowA ;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 cshowA 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 cshowA 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 cshowA ;turn speed dispturndone: ld hl,$243E ld (_penCol),hl pop hl ;loadgamecar inc hl ld a,(hl) ;(scorelimit) or a psh af cal cshowA ;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 cp K_LEFT jr z,seloleft cp 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 99 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 cp K_LEFT jr z,selleft cp 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 _dispmenusets: 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 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: halt \ halt psh hl cal GET_KEY 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 inc hl psh 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; hl++ inc hl ld a,(hl) ;(curlevel) cal cshowA 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: halt \ halt cal GET_KEY 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: halt cal GET_KEY 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 ;--proc 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 skiplevel: ;@hl - destr:ab - alter:hl 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 ld a,(Gametype) cp gamesingle 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: ld a,(hl) inc hl or a 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 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 pop hl ;loadgamecar psh hl 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 jr z,levelsskipped cal skiplevel jr skiplevelloop levelsskipped: psh hl ;1st level ld a,(gameCar) rra ;and _datalink jr nc,GameOver 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 ld a,$18 jr multiplayer client: ld hl,txtReceive cal _puts ld a,$E6 multiplayer: ; cal linkok ; ld a,D0LD1L ; out (7),a ld (SwapPos),a ld a,2 ld (nrworms),a ;----------------------------- ;--------- game over --------- ;----------------------------- GameOver: ld hl,worm1set ld de,worm1 ld a,4 ;4x (all worms) createwormsloop: ex de,hl ld bc,died 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 StartLevel: cal _clrWindow pop hl ;begin of current level ld de,Left ld a,(hl) inc a ;=255? jp nz,nextlevel 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") nextlevel: ldi ld a,0 customspeed =$-1 inc a ;$FF=def jr z,defspeed dec a ld (hl),a ;store new speed defspeed: ld de,Speed ldi 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 ld a,(Gametype) cp gamesingle 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 ld a,2 ld (flashtime),a ;-------- draw level --------- 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 ld (hl),%11111111 ldir inc hl ld (hl),%11000000 inc hl ld b,31 ClearLine: ld (hl),c inc hl dnz ClearLine psh hl ; >> 3 ld a,(FieldWidth) add a,126 psh af ; >> 4 and %11111000 rra rra rra ld l,a ld h,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 gamectf jr nz,noctf ld de,peaspos ld bc,4 ldir psh hl cal DrawAllPeas pop hl noctf: cal drawstuff ;----------------------------- psh hl ; >> levelp new cal forceshowstats ld a,(gameCar) and _datafood jr z,nofood cal NewPea nofood: ld bc,(worm1+pos) cal DisplayField #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,0 gameCar =$-1 rra ;and _datalink jr nc,initfinished ;no link xor a SwapPos: ;$18 xx -> $E6 xx ; jr xx -> and xx jr sethost setclient: ld (worm1+left),a ;worm 1... ld (worm3+left),a ;and worm 3 via link cal Qrecv ld a,c ld (worm2+name+0),a cal Qrecv ld a,c ld (worm2+name+1),a cal Qrecv ld a,c ld (worm2+name+2),a cal Qrecv ld a,c ld (worm2+name+3),a cal Qrecv ld a,c ld (worm2+name+4),a jr initfinished sethost: ld (worm2+left),a ;worm 2+4.. ld (worm4+left),a ;..over link ld c,'T' cal Qsend ld c,'e' cal Qsend ld c,'s' cal Qsend ld c,'t' cal Qsend ld c,0 cal Qsend initfinished: 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: drawctfpea1: jr drawctfpea2 ld bc,drawctfpea1 ld hl,(peaspos) cal tryDrawPea drawctfpea2: jr noctfpeas2draw ld bc,drawctfpea2 ld hl,(peaspos+2) cal tryDrawPea 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) ;1..nrworms dnz handleworms ;----------------------------- ;---------- keys ------------- ;----------------------------- HandleKeys: ld a,%10111111 out (1),a in a,(1) rla ;MORE? jr c,CheckExit ld bc,$0103 out (c),b halt ;pause/off ld b,11 out (c),b CheckExit: rla ;=$17 (c=EXIT-key) ;or$A7 (c=0) jp c,GameLoop jr Exit 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 cal 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) ;livematch: 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 Exit: cal releasekeys ld sp,0 ;pop all SpSave = $-2 ld a,D0LD1L out (7),a ;both wires low = game over signal cal _clrWindow 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 l,$74 ; ld b,8 ; cal menuinvloop ld hl,_curRow inc (hl) 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 showA pop hl psh hl ld a,10 ld (_curCol),a ld a,(Gametype) cp gamedeathm jr nz,nodmwinner ;deathmatch? ld a,0 ;winner's deaths dmwinner =$-1 cp (hl) ;equals this worm? jr nz,notwinner jr 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.. jr nz,notwinner iswinner: ld a,'*' cal _putc ;..then put * 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 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: halt halt cal GET_KEY 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) addlevelposition: inc hl inc hl ;add one word per level inc hl inc hl inc hl ;plus 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 ;----------------------------- ;----------- 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 de,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 de,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 StartLevel 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),$E6 ;and nn ret 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 de,20 ;flag captured+returned cal IncScore pop hl ld a,$E6 ;and nn ld (drawctfpea1),a ;redraw.. ld (drawctfpea2),a ;..both flags jr Drawworm DrawAllPeas: ld hl,(peaspos) cal DrawPea ld hl,(peaspos+2) jp DrawPea ;----------------------------- 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,63 sub b jr z,nextlaphalf inc a ret nz nextlaphalf: ld a,c and 32 ;y>=32? jr nz,nolap cp (ix+reserv) jr z,nolap psh bc ld de,20 cal IncScore pop bc xor a nolap: ld (ix+reserv),a 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 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 psh bc cal CheckPea pop bc ret nz ;unsuccesful ld a,$18 ;jr ld (bc),a jr DrawPea 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 ld (PeaY),hl cal CheckPea jr nz,NewPea 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 ----------- _divHLby1000: psh hl ld b,3 divideagain: ;3x cal _divHLby10 dnz divideagain ld a,l ;a=hl/1000 pop hl ret IncScore: ld h,(ix+score+1) ld l,(ix+score) cal _divHLby1000 ld c,a add hl,de 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 scorecommon: ld (ix+score+1),h ld (ix+score),l 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 ret nz ;no disp for timematches 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) add a,'0' __vputmap: psh ix cal _vputmap pop ix ret showstatsS: ;(singleplayer) ld hl,txtLevel cal __vputs ld a,0 Level =$-1 cp 10 jr c,tilllevel9 ld l,a ld h,0 cal _divHLby10 psh af ld a,l add a,'0' cal __vputmap pop af tilllevel9: add a,'0' cal __vputmap 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 cshowA ld hl,txtLeft __vputs: psh ix cal _vputs pop ix ret showLevel: ld hl,txtLevel cal _puts ld a,(Level) showA: 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 cshowA: 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 jp z,drawline dec a ;2 = fatline jp z,drawfatline dec a ;3 = box jp z,drawbox dec a ;4 = circle jp z,drawcircle dec a ;5 = hline #ifdef hlines jp z,drawhline #else jp z,drawline #endif drawbox: ;(d,e)-(h,l) ld b,l ;Delta-y #ifdef hlines boxloop: cal drawhline inc e dnz boxloop ret drawhline: ;(d,e)-(h,e) psh bc ld b,d ld c,e psh hl cal FindPixel ld c,a ;starting mask ld a,h sub b ld b,a inc b ;1+x2-x1 hlineloop: ld a,(hl) or c ld (hl),a rrc c ;mask >> jr nc,hlinenext inc hl ;next byte hlinenext: dnz hlineloop pop hl pop bc ret #else ld l,e boxloop: cal drawline inc l inc e dnz boxloop ret #endif 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 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 ;----------------------------- ;----------- link ------------ ;----------------------------- linkok: ld a,D0HD1H out (7),a ;raise both wires = link ok ret timeout = $8000 lossout = 20 checklink: ;load wires in A and check for timeout dec de ;decrease timer ld a,d or e jr nz,linkfine ;ok if de>0 ;de==0 = timeout 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 linkfine: in a,(7) and %11 ret ;-------------- ;---- SEND ---- ;-------------- Csend: ld b,32 csendwait: nop dnz csendwait cal Qsend jr c,Csend ret Qsend: ;try to send 8 bits in C; CF=error --- destr:abcde nop \ nop in a,(7) and %11 ;both wires low = exit signal jr z,linkerr ;error otherwise 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 ld a,D0HD1H ;raise one, ok to raise other out (7),a 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:abcdehl --- 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 --- in a,(7) and %11 jr z,linkerr ;both low = error, quit ld b,8 ;bits to receive recvloop: ld de,timeout recvwait: cal checklink cp %11 jr z,recvwait ;both high = nothing sent (yet) 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 ld a,D0HD1H out (7),a ;raise both recvfinish: dnz recvloop ;repeat for all bits xor a ;nc=no error ld (linklosses),a ;reset number of losses ret ;----------------------------- ;---------- levels ----------- ;----------------------------- 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 ret LevelDefM: .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 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 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 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 LevelDefC: ;ctf .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 10,10,50,50 .db 0 ;----------------------------- ;---------- data ------------- ;----------------------------- wdPicture = 16 wtPicture: .db %00000000,%00000000,%00000111,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00000000,%00000000,%00000000,%00000000,%00000000 .db %00000000,%00000000,%00001111,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111000,%00000000,%00000000,%00000110,%01111011,%00100000 .db %00000000,%00000000,%00011100,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00011100,%00001110,%00000000,%00001001,%00010011,%01000000 .db %00000000,%00000000,%00011000,%00011111,%00000000,%01111111,%11000000,%00111100,%00011110,%01111000,%00001100,%00011111,%00000000,%10100111,%00110000,%10000000 .db %00000000,%00000000,%00111000,%00111111,%10000000,%11111111,%11100000,%11111110,%00111111,%11111100,%00001100,%00111011,%00000000,%10100001,%00001001,%01100000 .db %00000000,%00000000,%00110000,%01110001,%11000001,%11000000,%01110001,%11100110,%01110011,%11001110,%00001100,%00110001,%10000000,%01001110,%01110010,%01100000 .db %00000000,%00000000,%00110000,%01100000,%11000001,%10000000,%00111001,%10000000,%01100111,%11100110,%00001110,%01110001,%10000000,%00000000,%00000000,%00000000 .db %00000000,%00000000,%00110000,%01100000,%11000001,%10110000,%00011011,%10000000,%11101110,%01110111,%00001110,%01110001,%10000000,%00000000,%00000000,%00000000 .db %00000000,%00000000,%00110000,%01110001,%11000001,%10110000,%00011011,%00000000,%11001100,%00110011,%00000111,%11100001,%10000000,%00000000,%00000000,%00000000 .db %00000000,%00000000,%00110000,%00110001,%10000001,%10110000,%00011011,%00000000,%11001100,%00110011,%00000011,%11000011,%10000000,%00000000,%00000000,%00000000 .db %00000000,%00000000,%00111000,%00111011,%10000011,%10110000,%00011011,%00000000,%11001110,%01110011,%00000000,%00000011,%00110101,%01001001,%10000000,%00000000 .db %00000000,%00000000,%00011000,%00011111,%00000011,%00110000,%00011011,%00000000,%11000111,%11100011,%10000000,%00000011,%01000101,%00010101,%01000011,%01100011 .db %00000000,%00000000,%00011100,%00001110,%00000111,%00111000,%00111011,%10000000,%11000011,%11000001,%10000000,%00000111,%01100101,%01010101,%01000101,%01010100 .db %00000000,%00000000,%00001110,%00111111,%10001110,%00011100,%01110001,%10000000,%11100000,%00000001,%11100000,%00001110,%00110111,%01011101,%10010101,%01100101 .db %00000000,%00000000,%00000111,%11111011,%11111100,%00001111,%11100001,%11000000,%01100000,%00000000,%11111111,%11111100,%00010101,%01010101,%01000101,%01010101 .db %00000000,%00000000,%00000011,%11100000,%11111000,%00000111,%11000000,%11000000,%01100000,%00000000,%00111111,%11111000,%01100101,%01010101,%01000110,%01010011 txtMenu: .db "Mode",0 ;1st menu item .db "Level",0 ;2nd .db "Link",0 ;... .db "Worms",0 .db "worm #",0 .db 0 posMenu: .dw $2418,$231E,$2824,$1F2A,$1730,$1936 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: .dw $2618,$251E,$2524,$222A,$1A30,$1C36 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 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 txtReady: .db "Prepare!",0 txtposReady = 7 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0 datalevels: .dw LevelDef, LevelDefM .dw LevelDefT,LevelDefM .dw LevelDefM,LevelDefM .dw LevelDefM,LevelDefC nrlevels: .db 1,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, 9 ;CTF (90 score) worm1set: .dw worm1p,worm1p .db %11110111,%00,-01,K_RIGHT,K_LEFT worm1name: .db "WORMY ",0 worm2set: .dw worm2p,worm2p .db %11111011,%01,-01,K_F2,K_F1 worm2name: .db "VIPER ",0 worm3set: .dw worm3p,worm3p .db %11111011,%00,-01,K_COMMA,K_STO worm3name: .db "NIBBLER ",0 worm4set: .dw worm4p,worm4p .db %11111011,%01,-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 left = 20 right = 21 name = 22 wormsize = 31 startdelay = 30 respawndelay = 30 maxnamelength = 8+1 .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 " shiar0@hotmail.com",0 defspritesz = 4 defspriteimg: .db %01100000 .db %11110000 .db %11110000 .db %01100000 deflevels: .db "Internal Levels" ;,0 .db 0,deflevels/256,deflevels&255 templevels: ;----------------------------- ;----------- end ------------- ;----------------------------- .end .end