X-Git-Url: http://git.shiar.net/wormy.git/blobdiff_plain/1be4b87255fd59f1f29438afb6a43a1c81e51d2b..ececf2878a429d97287102bc8315f05c8aa423f1:/wormy.z80?ds=sidebyside diff --git a/wormy.z80 b/wormy.z80 index a2c919b..6ed5a09 100644 --- a/wormy.z80 +++ b/wormy.z80 @@ -18,18 +18,19 @@ ; 93% = DONE -; * internal levels -; * check levels/gametype -; * enough hiscore saves! -; * complete readme +; [* internal levels ] +; [ * check levels/gametype ] +; [ * enough hiscore saves! ] +; [* complete readme ] ; 1% * misc (pollish, bugs, &&&) ; * LINK -; 2% * fix deaths linkplay and transmit game/level data -; 2% * make linkplay available for all gametypes (not just deathmatch) +; * 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 (+dom?) -; * fix wormstop -; 1% * domination?: take control points by running over them and hold them +; 1% * fix pea XOR problem in ctf +; 1% * fix wormstop in race ;100% = bugs fixed + levels done @@ -42,9 +43,10 @@ #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 @@ -53,12 +55,12 @@ #include "asm86.h" #include "ti86asm.inc" -_SHRACC = $4383 -_SHLACC = $438B +_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 +_cphlde = $403C ;cp hl,de _clrWindow = $4A86 ;clear screen _asapvar = $D6FC ;own name (worm) _MOV4B = $429B ;4x ld (de),(hl) @@ -75,11 +77,12 @@ _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 +_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 +_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 @@ -108,7 +111,8 @@ worm3p = $B800 ;-BBFF (400) %10111O00 worm4p = $F000 ;-F3FF (400) %11110O00 leveldata = $F400 ;-FA70 (<=671) -peaspos = $AE01 +turn10 = $AE01 +peaspos = $AE02 ;--- temporary @@ -138,19 +142,18 @@ start: WormTxt: .db "WORMY by SHIAR -- beta 93%",0 WormIcon: - .db 9,2 - .db %10010110,%01101111 - .db %10110101,%01001011 - .db %01110011,%01001001 - .db %00000011,%10000000 - .db %00000001,%11100000 - .db %00111000,%11111000 - .db %01111110,%00111111 - .db %11101111,%00001111 - .db %11000011,%10000000 + .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 = 93 ;wormy levels header = "93" +levelhead2 = 94 ;wormy levels header = "93" int_handler: ex af,af' @@ -244,20 +247,14 @@ _searchnext: loadgametype: psh de - inc bc - inc bc cal _Get_Word_ahl ;ld de,(ahl++) psh af - ld a,d - or e - jr z,defaultlevels ld a,e ;set new level ld (bc),a inc bc ld a,d ld (bc),a - dec bc -defaultlevels: + inc bc pop af pop de ;counter dec d ;8x @@ -339,7 +336,7 @@ levselect: cp K_SECOND-1 jr z,loadlevel cp K_EXIT-1 - ret z + jp z,ExitNoStats cp K_ENTER-1 jr nz,levselect ; jr z,loadlevel @@ -377,10 +374,11 @@ skiptitle: cal _Get_Word_ahl ld (leveldataSize),de + ld d,8 ;counter - ld bc,datalevels-2 + ld bc,datalevels cal loadgametype - ld (hilvlposa),a + ld (hilvlposa),a ;singleplayer levels ld (hilvlposhl),hl ld d,4 cal loadgametype @@ -391,8 +389,7 @@ skiptitle: cal _SET_ABS_DEST_ADDR ;store in mem. ld hl,0 leveldataSize =$-2 - cal _SET_MM_NUM_BYTES - cal _mm_ldir + cal _MM_LDIR_SET_SIZE cal _LOAD_ABS_SRC_ADDR ;->ahl ld (hiscrposa),a @@ -412,12 +409,10 @@ levelloaded: ld hl,datasingle+3 ld b,8 + ld de,8 setdeflevels: ld (hl),1 ;def=level#1 - inc hl - inc hl - inc hl - inc hl + add hl,de ;next dnz setdeflevels ;----------------------------- @@ -452,14 +447,42 @@ NegativeSineWave: ;----------------------------- 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) @@ -467,14 +490,232 @@ dispmenuloop: ld e,(ix) inc ix ld (_penCol),de - cal _vputs ;Mode \ Level \ Limit \ Worms \ worm # \ controls + cal _vputs dnz dispmenuloop +; ld b,0 ;b=menu# + ret - ld b,0 ;b=menu# - jr _dispmenusets ;mainMenu +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 @@ -482,11 +723,13 @@ mainMenu: select: ;2nd/enter cal menupos ld a,b - sub 4 ;4th item? + dec a ;2nd item: level + jp z,dispoptionmenu + sub 3 ;5th item: wormname jp z,changeworms - dec a ;5th? + dec a ;6th: controls jp z,changekeys - jp LetsGetThisPartyOn ;1/2/3/5 + jp LetsGetThisPartyOn ;otherwise notselect cp K_EXIT jp z,ExitNoStats @@ -505,9 +748,9 @@ selright: or a jr z,changegame dec a - jp z,changelevel ;&&&jr?? + jr z,changelevel dec a - jr z,changelives + jr z,changelink dec a jr z,changenrworms ; dec a @@ -530,7 +773,7 @@ selleft: dec a jr z,bchangelevel dec a - jr z,bchangelives + jr z,bchangelink dec a jr z,bchangenrworms ; dec a @@ -543,71 +786,71 @@ bchangecurworm: jr mainMenu changenrworms: - ld a,(Gametype) - cp 2 - jr c,mainMenu ;type 0/1 - ;hl=nrworms - ld a,(hl) + 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 + jr _dispmenusets ;mainMenu +changenrwormsInit: + ld a,(Gametype) + cp 3 + ld a,(hl) ;hl=nrworms + ret bchangenrworms: - ;hl=nrworms - ld a,(hl) + cal change4spOnly + ld a,(hl) ;hl=nrworms dec a ;0-3 - jr nz,changednrworms ;save >0 + 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,0 -Gametype =$-1 + ld a,(Gametype) inc a + cal changedgame + jr z,changegame + jr dispmenusets ;mainMenu changedgame: and 7 ;mod 8 ld (Gametype),a - jr dispmenusets ;mainMenu + cal getnrlevels + xor a + cp (hl) + ret bchangegame: ld a,(Gametype) dec a - jr changedgame - -changelives: - cal changelivesInit - inc a - cp 100 - jr nc,_mainMenu ;&& _? -changedlives: - ld (hl),a + cal changedgame + jr z,bchangegame jr dispmenusets ;mainMenu -bchangelives: - cal changelivesInit - dec a - jr z,_mainMenu - jr changedlives -changelivesInit: - cal loadgamecar ;c=(gameCar) -;a=(hl)=(Gametype+1)=(wormbeglives) - ld a,(Gametype) ;&&& - cp 3 - ld a,(hl) - ret nc ;change lives - pop hl ;restore stack - jr _mainMenu ;singleplayer (no limit) changelevel: inc hl ;hl=loadgamecar+2 psh hl ld a,(hl) ;(curlevel) - ld hl,Gametype - ld d,0 - ld e,(hl) - ld hl,nrlevels - add hl,de + cal getnrlevels cp (hl) ;max level for sel.game pop hl jr z,_mainMenu @@ -622,6 +865,14 @@ bchangelevel: 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 @@ -649,20 +900,7 @@ changekeys: ;---display current settings--- dispmenusets: - ld hl,$FD97 ;begin pos - ld de,7 ;bytes to add - ld a,35 ;nr of lines -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 - + cal clrold ld de,$183E ld (_penCol),de ld d,0 @@ -677,30 +915,24 @@ clroldsetsloop: ld (CURtxtGame),hl ;save for g/o cal _vputs ;Singleplayer - cal loadgamecar - psh hl - ld hl,$243E - ld (_penCol),hl - cal cshowA ;liveslimit - sub '0' ;original A - ld l,a - ld a,c - and _datascore - ld a,' ' - jr z,limitok - ld a,'0' -limitok: - cal _vputmap ;x10 - ld hl,$2A3E ;worms ld (_penCol),hl - pop hl ;cal loadgamecar + 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++ @@ -717,13 +949,13 @@ curworm =$-1 ld hl,$303E ld (_penCol),hl cal getwormname - ld hl,worm1name-18 - add hl,de + psh ix ;wormNname + pop hl ;ld hl,ix cal _vputs ld hl,$363E ;controls ld (_penCol),hl -; ld hl,txtMenu -; cal _vputs + ld hl,txtMenuR + cal _vputs jp mainMenu ;--- handle menukeys --- @@ -807,62 +1039,54 @@ getwormname: ;of (curworm) ret changeworms: - cal _clrWindow - ld hl,txtEName - cal _puts ;"Enter name player " - ld a,(curworm) - add a,'0' - cal _putc - cal getwormname + psh ix + pop hl ;ld hl,ix + psh hl + ld b,8 +emptyname: + ld (hl),' ' + inc hl + dnz emptyname ld a,maxnamelength - cal entername - ld (ix),0 ;end mark - jp DisplayMenu - -entername: - ld h,1 - ld l,h ;) - ld (_curRow),hl 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 _putc - ld hl,_curCol - dec (hl) + cal __vputmap nokeypressed: halt cal GET_KEY or a jr z,nokeypressed + ld hl,namelength cp K_DEL jr nz,continue backspace: - ld hl,namelength ld a,(hl) cp maxnamelength jr nc,nokeypressed inc (hl) - dec ix - ld a,' ' - ld (ix),a - cal _putc - ld hl,_curCol - dec (hl) - dec (hl) jr enternameloop continue: cp K_ENTER - ret z + jr z,nameentered cp K_EXIT - ret z - - ld hl,namelength - dec (hl) - ret z + jr z,nameentered + dec (hl) ;(namelength) + jr z,nameentered ld hl,chartable ld e,a ld d,0 @@ -870,14 +1094,11 @@ continue: ld a,(hl) or a jr z,nokeypressed - ld (ix),a - cal _putc inc ix cal releasekeys jr enternameloop - chartable: .db 0,".<>!",0,0,0,0 ;down,L,R,up .db 0,"XTOJE0",0 ;enter..clear @@ -887,8 +1108,30 @@ chartable: .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 @@ -902,8 +1145,8 @@ skipsprite: ld b,(hl) ;balls inc b inc b ;skip 6 - ld a,c - cp _datasp + ld a,(Gametype) + cp gamesingle jr z,skipworms inc b ;multiplayer lvl inc b @@ -940,7 +1183,7 @@ skipobjects: loadgamecar: ;in: (Gametype) -;out: Gametype+1=hl +;out: hl=dataTYPE ;build: c=(gameCar)=(hl-1) ; a=(wormbeglives)=(hl) ;destr: acdehl @@ -948,6 +1191,7 @@ loadgamecar: 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 @@ -968,30 +1212,39 @@ LetsGetThisPartyOn: ld (CheckExit),a ;set exit state cal loadgamecar - ld b,a ;psh a + psh hl + ld (wormbeglives),a inc hl ;nrworms ld a,(hl) ld (nrworms),a - ld l,b ;pop a - ld h,0 ;hl=a - cal _HLTIMES10 ;hl=10*(hl) - ld (scorelimit),hl ;set limit + 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 - cal loadgamecar ;nc + pop hl ;loadgamecar psh hl - ld a,(Gametype) ;4bytes -> 3bytes - add a,a ;3->2bytes + 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 - ld a,c ;(gameCar) - and _datascore - jr nz,scorelimitset - dec a ;ld a,$FF ;=no_limit - ld (scorelimit),a -scorelimitset: - cal _ldHLind ;ld hl,(hl) pop de ;de=loadgamecar inc de \ inc de @@ -1006,9 +1259,9 @@ skiplevelloop: levelsskipped: psh hl ;1st level - ld a,c - and _datalink - jr z,GameOver + ld a,(gameCar) + rra ;and _datalink + jr nc,GameOver linkmatch: cal _clrWindow @@ -1021,22 +1274,23 @@ linkmatch: cp wormVclient jr z,client cp wormVhost - jr nz,linkiniterror + jr z,host + pop hl ;error + jp DisplayMenu ;return to menu + host: ld c,wormVclient cal Qsend ld a,$18 jr multiplayer - -linkiniterror: - pop hl - jp DisplayMenu - 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 @@ -1046,9 +1300,6 @@ multiplayer: ;----------------------------- GameOver: - ld a,%11000000 - out (7),a ;link normal - cal _clrLCD ld hl,worm1set ld de,worm1 ld a,4 ;4x (all worms) @@ -1056,11 +1307,12 @@ createwormsloop: ex de,hl ld bc,died add hl,bc - ld (hl),0 ;died=0 + ld b,0 + ld (hl),b ;died=0 inc hl - ld (hl),0 ;score=0 + ld (hl),b ;score=0 inc hl - ld (hl),0 ;score+1=0 + ld (hl),b ;score+1=0 inc hl ld (hl),2 ;delay=2 inc hl @@ -1073,19 +1325,18 @@ wormbeglives =$-1 dec a ;loop jr nz,createwormsloop - pop hl ;begin of current level - 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) - psh hl cal releasekeys - cal _clrWindow pop hl ;show end msg or smtn ld bc,Exit @@ -1094,6 +1345,13 @@ StartLevel: 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 @@ -1145,32 +1403,36 @@ toobad_noballs: #endif ld hl,worm1 - ld a,(gameCar) - cp _datasp + ld a,(Gametype) + cp gamesingle ld b,1 jr z,worminit ld b,4 worminit: - psh bc ; >> 1 + psh bc ;>1 ex de,hl - ldi ;d + ldi ;d ld a,SinCosTable/256 ld (de),a inc de - ldi ;y - ldi ;x + ldi ;y + ldi ;x ex de,hl - xor a - ld (hl),a ;y2 + ld (hl),a ;y2 inc hl - ld (hl),a ;x2 + ld (hl),a ;x2 ld bc,(worm2-worm1)-5 add hl,bc - pop bc ; << 0k + pop bc ;<0 dnz worminit + inc a ;ld a,1 + ld (turn10),a + ld a,2 + ld (flashtime),a + ;-------- draw level --------- ld a,(de) @@ -1197,7 +1459,7 @@ setfieldy: add hl,hl add hl,hl add hl,hl - add hl,hl + add hl,hl ;32=scr.width ex de,hl ld hl,ScrBuffer @@ -1268,7 +1530,7 @@ noctf: ;----------------------------- psh hl ; >> levelp new - cal showstats + cal forceshowstats ld a,(gameCar) and _datafood jr z,nofood @@ -1312,18 +1574,44 @@ maskline: ld a,0 gameCar =$-1 - and _datalink - jr z,initfinished ;no link + rra ;and _datalink + jr nc,initfinished ;no link xor a - ld (Speed),a ;max.speed SwapPos: ;$18 xx -> $E6 xx ; jr xx -> and xx jr sethost setclient: - ld (worm1+left),a ;worm 1 via link + 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 via link + 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 @@ -1337,8 +1625,13 @@ ReadyDelay: ;----------------------------- GameLoop: - ld bc,(worm1+pos) - cal DisplayField + 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 @@ -1352,7 +1645,7 @@ screeninvertloop: ld (hl),a inc hl xor a - cp h + cp h ;end at >$FFFF jr nz,screeninvertloop noflash: @@ -1366,7 +1659,41 @@ Delay: jr nz,Delay NoDelay: - ld (handledworm),a ;=0 + 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 @@ -1428,10 +1755,13 @@ handledworm =$-2 inc hl ld (ix+heading),a ld a,(hl) - ld (ix+pos),a + ld (ix+pos),a ;y inc hl ld a,(hl) - ld (ix+pos+1),a + 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) @@ -1440,13 +1770,13 @@ handledworm =$-2 cal DecScore pop af ret nz ;HandleWorm done - ld a,(gameCar) - and _datalivel + ld a,(wormbeglives) + or a ;0=no live limit ret z ;don't end game - ld a,(Gametype) - cp gametron - jr nz,anyworm ;if not Tron, quit at any worm's death - ld a,(nrworms) + 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 @@ -1463,10 +1793,11 @@ anyworm: #endif Exit: + cal releasekeys ld sp,0 ;pop all SpSave = $-2 - ld a,D0HD1H - out (7),a + ld a,D0LD1L + out (7),a ;both wires low = game over signal cal _clrWindow ld hl,txtGO cal _puts @@ -1474,11 +1805,9 @@ SpSave = $-2 ld b,16*8 cal menuinvloop ;invert inc h ;$FD80 - ld b,16 - cal menuinvloop ;