X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/ba3bf9e0fe404be7e29910dad474dd4580550c05..7ec10d8466fbe267a3d0a8fe8fbfaed79adbf07f:/worm.z80 diff --git a/worm.z80 b/worm.z80 index b4b4373..a5cdab9 100644 --- a/worm.z80 +++ b/worm.z80 @@ -1,7 +1,7 @@ ; Title : Worm -; Version : 90% -; Release Date : april 2000??? -; Filename : worm.86p (4kb) +; Version : 91% +; Release Date : may 2000 +; Filename : worm.86p (5kb) ; Author(s) : Shiar ; Email Address : shiar@mailroom.com ; ICQ UIN : #43840958 @@ -16,13 +16,14 @@ ;----------- TO-DO ----------- ;----------------------------- -; 90% = DONE +; 91% = DONE -; 3% * linkplay +; 2% * fix deaths linkplay and transmit game/level data ; 2% * make linkplay available for all gametypes (not just deathmatch) -; * game types: -; 1% * ctf: take enemy flag (right-bottom) and return to your flag (left-top) -; 1% * domination?: take control points by running over them and hold them +; 1% * fix pea XOR problem in ctf (+dom?) +; * fix wormstop +; 1% * domination?: take control points by running over them and hold them +; * customizable keys ; * complete readme (+custom level info) ; 2% * ... (pollish, &&&) @@ -36,7 +37,11 @@ ;----------------------------- ;----------------------------- -#define buffer ;use display buffer (otherwise write directly to screen) +#define buffer ;use display buffer (otherwise write directly to screen) +#define readymask ;"grays" out the field before starting a level + +;#define readytext ;displays "prepare" before level starts +;#define invincible ;worms cannot die =) #define cal call #define psh push @@ -72,6 +77,7 @@ _RAM_PAGE_7 = $47F3 _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 ;----------------------------- ;------- data storage ------- @@ -115,7 +121,7 @@ DispBuffer = $FC70 .org _asm_exec_ram -WormVersion = 090 +WormVersion = 091 start: nop @@ -125,7 +131,7 @@ start: .dw WormIcon WormMsg: - .db "WORM by SHIAR -- pre-beta 90%",0 + .db "WORM by SHIAR -- pre-beta 91%",0 WormIcon: .db 9,2 .db %10010110,%01101111 @@ -139,7 +145,7 @@ WormIcon: .db %11000011,%10000000 levelhead = 'w' -levelhead2 = 90 ;worm levels header = "90" +levelhead2 = 91 ;worm levels header = "91" Start: ld (SpSave),sp @@ -381,10 +387,10 @@ disptitleloop: cal _puts ;--- dec e ;$0206 ld (_curRow),de - cal _puts ;Level + cal _puts ;Level <00> dec e ;$0205 ld (_curRow),de - cal _puts ;Worms: 2 + cal _puts ;Worms <2> dec e ;$0204 ld (_curRow),de ld hl,(CURtxtGame) @@ -404,6 +410,8 @@ select: notselect cp K_EXIT jp z,ExitNoStats + cp K_LEFT + jr z,selleft cp K_RIGHT ld a,b jr nz,mainMenu @@ -421,18 +429,32 @@ changelevel: ld hl,nrlevels add hl,de ld d,(hl) ;max level for sel.game +curlevel =$+1 ld a,1 -curlevel =$-1 inc a cp d jr c,changedlevel - ld a,1 + ld a,d changedlevel: ld (curlevel),a -dispcurlevel: - ld hl,$0806 +_dispcurlevel: + ld hl,$0906 ld (_curRow),hl cal showA +_mainMenu: + jr mainMenu + +selleft: + ld a,b + dec a + jr z,bchangenrworms + dec a + jr nz,mainMenu + +bchangelevel: + ld a,(curlevel) + dec a + jr nz,changedlevel jr mainMenu changegame: @@ -454,33 +476,42 @@ okilydokily: cal _puts ld (NEXTtxtGame),hl howmanyworms: + ld hl,nrworms ld a,(Gametype) cp 2 - ld a,1 - jr c,oneworm -nrworms =$+1 - ld a,2 -oneworm: - jr dispnrworms ;jr mainMenu + ld (hl),1 + jr c,dispnrworms + inc (hl) ;2 + jr dispnrworms ;mainMenu changenrworms: ld a,(Gametype) - cp 2 - jr c,mainMenu ;type 0/1 + cp 2 ;&& + jr c,_mainMenu ;type 0/1 ld hl,nrworms ld a,(hl) inc a cp 5 - jr c,changednrworms - ld a,1 + jr nc,dispcurlevel changednrworms: ld (hl),a dispnrworms: + ld a,(hl) ;hl=nrworms ld hl,$0905 ld (_curRow),hl - cal showA + add a,'0' + cal _putc +dispcurlevel ld a,(curlevel) - jr dispcurlevel ;mainMenu + jr _dispcurlevel ;mainMenu + +bchangenrworms: + ld hl,nrworms + ld a,(hl) + dec a + cp 2 ;2-4 + jr nc,changednrworms + jr dispcurlevel menucall: psh bc @@ -534,20 +565,25 @@ changeworms: cp 2 ld a,1 jr c,wormnrname - ld a,(nrworms) +nrworms =$+1 + ld a,1 wormnrname: add a,'0' cal _putc sub '0' + + ld d,a ;1x add a,a ;2x ld e,a add a,a ;4x add a,a ;8x add a,a ;16x add a,e ;18x + add a,d ;19x ld e,a - ld d,0 - ld ix,worm1name-18 + ld d,0 ;de=a + + ld ix,worm1name-19 add ix,de ld a,maxnamelength cal entername @@ -556,7 +592,7 @@ wormnrname: entername: ld h,1 - ld l,h + ld l,h ;) ld (_curRow),hl ld (namelength),a enternameloop: @@ -620,12 +656,12 @@ waitnokeypressed: 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 0,"-pkfa6'" ;on..alpha - .db "54321*",0,0 ;F5..more + .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 ;--proc @@ -656,6 +692,17 @@ skipworms: skipballs: inc hl dnz skipballs + +skipflags: + ld a,(Gametype) + cp gamectf + jr nz,noflagstoskip + inc hl + inc hl + inc hl + inc hl +noflagstoskip: + cal skiplines ;lines skiplines: ;boxes ld a,(hl) ;lines/boxes @@ -663,6 +710,7 @@ skiplines: ;boxes add a,a inc a ld b,a ;4x(hl)+1 + skiplb inc hl dnz skiplb @@ -722,27 +770,32 @@ linkmatch: cal _clrWindow ld a,WormVersion cal send - jr c,client ;2nd + jr nc,client ;2nd host: ld hl,txtWaiting cal _puts cal receive cp WormVersion - jp nz,LinkBreak + jp nz,linkiniterror cal send - ld hl,SwapPos - ld (hl),$f6 jr multiplayer +linkiniterror: + pop hl + jp DisplayMenu + client: ld hl,txtReceive cal _puts - cal receive + cal Qreceive + jp c,linkiniterror cp WormVersion - jp nz,LinkBreak + jp nz,linkiniterror + ld hl,SwapPos + ld (hl),$f6 multiplayer: ld a,2 ld (nrworms),a @@ -849,7 +902,9 @@ setsprite: toobad_noballs: ex de,hl +#ifndef invincible ld (thislevel),de +#endif ld hl,worm1 ld a,(gameCar) @@ -949,9 +1004,21 @@ NoVertShift: ld c,64 ldir -;-draw lines- 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: + +;-draw lines- + ld a,(hl) inc hl or a @@ -1001,16 +1068,6 @@ noboxes: psh hl ; >> levelp new cal showstats - ld a,(Gametype) - cp gamectf - jr nz,noctf - ld hl,$1010 - ld (peaspos),hl - cal DrawPea - ld hl,$2010 - ld (peaspos+3),hl - cal DrawPea -noctf: ld a,(gameCar) and _datafood jr z,nofood @@ -1018,6 +1075,27 @@ noctf: 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 @@ -1029,6 +1107,7 @@ nofood: ld hl,txtReady cal _puts res 3,(iy+5) +#endif ld a,0 gameCar =$-1 @@ -1055,10 +1134,11 @@ SwapPos: ;$18 xx -> $F6 xx ld (worm2+heading),a initfinished: - ld b,0 + ld b,startdelay ReadyDelay: halt dnz ReadyDelay + cal releasekeys ;----------------------------- ;----------- LOOP ------------ @@ -1133,6 +1213,9 @@ CheckExit: jr Exit WormDead: +#ifdef invincible + jp stopworm +#else ld a,2 ld (flashtime),a ld (ix+delay),respawndelay @@ -1161,6 +1244,7 @@ thislevel =$+1 ld a,$A7 ;exit@end of turn ld (CheckExit),a ;set exit state ret ;finish turn +#endif Exit: ld sp,0 ;pop all @@ -1192,7 +1276,7 @@ displayWormStats: ld bc,input-died add hl,bc ;+input xor a - cp (hl) + cp (hl) ;input=0 = link jr nz,NoLinkIndic ld b,7 inc hl ;+left @@ -1218,9 +1302,9 @@ NoLinkIndic: ld a,13 ld (_curCol),a ld a,(hl) ;worm+died - psh hl cal showA pop hl + psh hl ld a,16 ld (_curCol),a @@ -1240,7 +1324,6 @@ NoLinkIndic: checkhilevel: ld hl,nrlevels ld a,(Level) - inc a cp (hl) jr c,hilevelcheckdone ld (hl),a ;save local @@ -1287,13 +1370,16 @@ NotNewHigh: ;de=current hiscore cal showHL hiscorecheckdone: + cal releasekeys waitkey: halt halt cal GET_KEY cp K_ENTER jp z,DisplayMenu -; cp K_EXIT + cp K_SECOND + jp z,DisplayMenu + cp K_EXIT jr nz,waitkey ;x123456789012345678901 @@ -1323,6 +1409,7 @@ ExitNoStats: cal _SET_MM_NUM_BYTES cal _mm_ldir + cal releasekeys res 4,(iy+9) set 2,(iy+13) jp _clrWindow @@ -1347,53 +1434,6 @@ addlevelposition: ;----------- worm ------------ ;----------------------------- -inlink: - ld a,0 -sendbyte =$-1 - ld b,(ix+left) - dec b - jr z,receivefirst - cal send - cal receive - ld l,a - ret -receivefirst: - psh af - cal receive - ld l,a - pop af - psh hl - cal send - pop hl - ret - -inkeys: ;use jp not call! - out (1),a ;nop\nop - in a,(1) - ld b,a - and (ix+right) - jr z,notright - ld a,l - add a,8 - ld l,a -notright: - ld a,b - and (ix+left) - ret z - ld a,l - sub 8 - ld l,a - ret - -chkinput: - ld bc,donediddelydone - psh bc ;ret-dest. -inputcall: - ld a,(ix+input) - or a - jr nz,inkeys - jr inlink - respawncheck: cp respawndelay-1 jr nz,unnamedlabel @@ -1429,6 +1469,7 @@ safewormsizedone: ;de=ix+head ld (ix+tail+1),d ld (ix+tail),e ;head=tail/size=0 + jr norespawn ret unnamedlabel: @@ -1443,6 +1484,53 @@ respawndue: ret z saverespawncounter: ld (ix+delay),a +norespawn: + ld a,(gameCar) + and _datalink + jr nz,inlink + ret + +inkeys: ;use jp not call! + out (1),a ;nop\nop + in a,(1) + ld b,a + and (ix+right) + jr z,notright + ld a,l + add a,8 + ld l,a +notright: + ld a,b + and (ix+left) + ret z + ld a,l + sub 8 + ld l,a + ret + +inputcall: + ld a,(ix+input) + or a + jr nz,inkeys + +inlink: + ld a,0 +sendbyte =$-1 + ld b,(ix+left) + dec b + jr z,receivefirst + cal send + cal receive + ld l,a + ret +receivefirst: + psh af + cal receive + ld l,a + pop af + psh hl + cal send + pop hl ret ;------- handle worm --------- @@ -1450,10 +1538,10 @@ saverespawncounter: HandleWorm: ld a,(ix+delay) dec a - jr nz,respawncheck + jp nz,respawncheck ld l,(ix+heading) - jr chkinput + cal inputcall donediddelydone: ld a,l ld (sendbyte),a @@ -1605,37 +1693,65 @@ flagcaptured: ld de,30 cal IncScore pop hl +sillylabel: cal WormDead DrawAllPeas: ld hl,(peaspos) cal DrawPea - ld hl,(peaspos+3) + ld hl,(peaspos+2) jp DrawPea multiple_peas: - ld hl,(peaspos) + ld hl,(peaspos) ;1st pea + psh hl ld a,(ix+reserv) ld e,a ;push a and %01 - jr nz,corrrectpea - ld hl,(peaspos+3) -corrrectpea: + jr nz,sel_ownpea + ld hl,(peaspos+2) ;2nd pea +sel_ownpea: cal chkpeahit - jp nc,WormDead + pop hl ;(peapos) 1st pea + jp c,stopworm ;own pea hit + + ld a,e ;peek a (that x86 asm for pop\push ;) + and %01 + jr z,sel_otherpea + ld hl,(peaspos+2) ;2nd pea +sel_otherpea: + cal chkpeahit + jp c,hitflag + +;no peas hit + ld a,e + cal flagtoken + jp z,WormDead + ld b,a ;%10 + srl b ;%01 + add a,b ;%11 + ld (ix+reserv),a + cal DrawPea ;restore own flag + jr sillylabel ;inv both\die + +hitflag: ;correct pea hit ld a,e ;pop a xor %01 ;0=1;1=0 ld (ix+reserv),a - and %01 - add a,a - ld b,a - ld a,e - and %10 - cp b + cal flagtoken psh af ;safe z-flag cal DrawPea ;remove pop af jr z,flagcaptured - jr Drawworm + jr stopworm + +flagtoken: + and %01 ;current + add a,a ;<< for cp + ld b,a ;in b + ld a,e + and %10 ;own + cp b ;same? + ret ;Z=yes: no flag taken ;----------------------------- @@ -1699,8 +1815,9 @@ chkworm: pop ix ret z ;not hit pop bc ;call -previouspos =$+1 +stopworm: ld bc,0 +previouspos =$-2 ld de,0 ld (ix+pos),c ld (ix+pos+1),b @@ -1860,6 +1977,16 @@ checkballhit: ;----------- 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) @@ -2535,6 +2662,13 @@ boxloop: TIMEOUT = $1000 +LinkBreak: + pop hl + ld a,D0HD1H + out (7),a + jp Exit + + receive: cal GET_KEY cp K_EXIT @@ -2543,13 +2677,17 @@ receive: and %11 cp %11 jr z,receive - cal Qreceive + in a,(7) + and %11 + cp %11 + jr z,receive + ld b,8 + cal ReceiveCont jr c,receive ret Qreceive: ld b,8 - jr ReceiveCont receiveloop: ld de,TIMEOUT WaitRecBit: @@ -2558,16 +2696,16 @@ WaitRecBit: cp %11 jr z,WaitRecBit ReceiveCont: - sub 2 - ld a,2 + sub %10 + ld a,%10 ld d,D0LD1H jr c,ReceiveLow rra ld d,D0HD1L ReceiveLow: - rr c - ld (AckBit),a - ld a,d + rr c + ld (AckBit),a + ld a,d out (7),a ld de,TIMEOUT WaitAckRec: @@ -2586,13 +2724,15 @@ WaitReadyRec: jr nz,WaitReadyRec ReadyRec: dnz receiveloop - jr LinkSuccess + ld a,c + ret send: - ld b,9 ld c,a + ld b,8+1 jr SendAcked -SendBits: + +sendloop: rr c ld a,D0LD1H jr nc,SendLow @@ -2611,19 +2751,13 @@ WaitReadySend: cal CheckLink cp %11 jr nz,WaitReadySend - dnz SendBits + dnz sendloop LinkSuccess: - ld a,c ;pop a - ret - + .db $F6 ;or NN (skip scf) LinkFailed: scf - ld a,c + ld a,c ret -LinkBreak: - ld a,D0HD1H - out (7),a - jp Exit CheckLink: pop hl @@ -2634,19 +2768,19 @@ CheckLink: ld a,$BF out (1),a - nop \ nop +; nop \ nop in a,(1) psh af ld a,%11111111 out (1),a pop af bit 6,a + jr z,LinkFailed in a,(7) and %11 jp (hl) - ;----------------------------- ;---------- levels ----------- ;----------------------------- @@ -2690,8 +2824,8 @@ wtPicture: txtMenu: .db "by Shiar",0 .db "Have fun!",0 ;4th menu item - .db "Level 00",0 ;3rd - .db "Worms: 0",0 ;2nd + .db "Level ",$CF,"??",5,0 ;3rd + .db "Worms ",$CF,"?",5,0 ;2nd txtGame: .db "Singleplayer",0 ;0 (1st) txtGame2: .db "Peaworm ",0 ;1 (next 1st) .db "Deathmatch",0 ;2 @@ -2775,7 +2909,6 @@ worm4set: .dw worm4p,worm4p .db %11111011,3,0,%01111101,%10,%1 ;enter + worm4name: .db "worm #04",0 -hipeaworm: .dw 0 end: defsprsize = 4 @@ -2807,6 +2940,7 @@ right = 21 name = 22 wormsize = 31 +startdelay = 30 respawndelay = 30 maxnamelength = 8+1