X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/ce0bf2b9f5148725977f1cc2dbeccb59249e54d6..c23eda222bb4317abd8f9fd9e197aa6118c503c3:/worm.z80 diff --git a/worm.z80 b/worm.z80 index e254d01..22e6fec 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,11 +16,12 @@ ;----------- 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) ; 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) @@ -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,8 @@ _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 +_EXLP = $4493 ;swap (hl),(de) b times ;----------------------------- ;------- data storage ------- @@ -115,7 +122,7 @@ DispBuffer = $FC70 .org _asm_exec_ram -WormVersion = 090 +WormVersion = 091 start: nop @@ -125,7 +132,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 +146,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 +388,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 +411,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 +430,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 +477,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 +566,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 +593,7 @@ wormnrname: entername: ld h,1 - ld l,h + ld l,h ;) ld (_curRow),hl ld (namelength),a enternameloop: @@ -620,12 +657,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 +693,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 +711,7 @@ skiplines: ;boxes add a,a inc a ld b,a ;4x(hl)+1 + skiplb inc hl dnz skiplb @@ -729,22 +778,61 @@ host: cal _puts cal receive cp WormVersion - jp nz,LinkBreak +; jp nz,linkiniterror cal send + jr c,linkiniterror +; cal sendname +; cal receivename + + ld a,$18 jr multiplayer +linkiniterror: + pop hl + jp DisplayMenu + +sendname: + ld hl,worm1+name + ld b,maxnamelength +sendnameloop: + ld a,(hl) + inc hl + psh bc + psh hl + cal send + pop hl + pop bc +; dnz sendnameloop + ret +receivename: + ld hl,worm2+name + ld b,maxnamelength +recvnameloop: + psh bc + psh hl + cal receive + pop hl + pop bc + ld (hl),a + inc hl +; dnz recvnameloop + ret + client: ld hl,txtReceive cal _puts - cal ReceiveByte - jp c,LinkBreak + cal Qreceive + jp c,linkiniterror cp WormVersion - jp nz,LinkBreak +; jp nz,linkiniterror + +; cal receivename +; cal sendname - ld hl,SwapPos - ld (hl),$f6 + ld a,$f6 multiplayer: + ld (SwapPos),a ld a,2 ld (nrworms),a @@ -754,29 +842,25 @@ multiplayer: GameOver: cal _clrLCD - ld hl,0 - ld (worm1+died),hl -;+died=0 \ +score1=0 - ld (worm2+died),hl - ld (worm3+died),hl - ld (worm4+died),hl - inc h - ld (worm1+score+1),hl -;+score2=0 \ +delay=1 - ld (worm2+score+1),hl - ld (worm3+score+1),hl - ld (worm4+score+1),hl ld hl,worm1set - ld de,worm1+head + ld de,worm1 ld a,4 ;4x (all worms) createwormsloop: - ld bc,19 - ldir ;copy 19 bytes ex de,hl - ld bc,head + ld bc,died add hl,bc - ex de,hl ;de=wormX+head - dec a ;loop + ld (hl),0 ;died=0 + inc hl + ld (hl),0 ;score=0 + inc hl + ld (hl),0 ;score+1=0 + inc hl + ld (hl),2 ;delay=2 + inc hl + ex de,hl ;de=wormX+head + ld bc,19 + ldir ;copy 19 bytes + dec a ;loop jr nz,createwormsloop ld a,(Gametype) @@ -793,10 +877,7 @@ StartLevel: jp nz,nextlevel psh hl - ld b,150 -waitsomemore: - halt - dnz waitsomemore + cal releasekeys cal _clrWindow pop hl ;show end msg or smtn @@ -850,7 +931,9 @@ setsprite: toobad_noballs: ex de,hl +#ifndef invincible ld (thislevel),de +#endif ld hl,worm1 ld a,(gameCar) @@ -950,9 +1033,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 @@ -1002,16 +1097,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+2),hl - cal DrawPea -noctf: ld a,(gameCar) and _datafood jr z,nofood @@ -1019,6 +1104,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 @@ -1030,36 +1136,38 @@ nofood: ld hl,txtReady cal _puts res 3,(iy+5) +#endif ld a,0 gameCar =$-1 and _datalink - jr z,SwapPos ;no link + jr z,initfinished ;no link + xor a - ld (worm2+input),a + ld (worm2+input),a ;worm 2 via link ld (worm2+left),a - ld (Speed),a - + ld (Speed),a ;max.speed SwapPos: ;$18 xx -> $F6 xx + ; jr xx -> or xx jr initfinished inc a - ld (worm2+left),a - ld hl,(worm1+pos) - ld de,(worm2+pos) - ld (worm2+pos),hl - ld (worm1+pos),de - ld a,(worm1+heading) - ld b,a - ld a,(worm2+heading) - ld (worm1+heading),a - ld a,b - ld (worm2+heading),a + ld (worm2+left),a ;1 + ld hl,worm1 + ld de,worm2 + ld b,4 ;+heading +pos + cal _EXLP ;swap positions +;&&& over link + ld hl,worm1+name + ld de,worm2+name + ld b,maxnamelength + cal _EXLP ;swap positions initfinished: - ld b,0 + ld b,startdelay ReadyDelay: halt dnz ReadyDelay + cal releasekeys ;----------------------------- ;----------- LOOP ------------ @@ -1134,6 +1242,9 @@ CheckExit: jr Exit WormDead: +#ifdef invincible + jp stopworm +#else ld a,2 ld (flashtime),a ld (ix+delay),respawndelay @@ -1162,10 +1273,13 @@ 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 SpSave = $-2 + ld a,D0HD1H + out (7),a cal _clrWindow ld hl,txtGO cal _puts @@ -1193,13 +1307,13 @@ displayWormStats: ld bc,input-died add hl,bc ;+input xor a - cp (hl) + cp (hl) ;input=0 = link jr nz,NoLinkIndic - ld b,7 + ld b,7 ;{DOWN} inc hl ;+left cp (hl) jr z,hostLinkIndic - dec b + dec b ;{UP} hostLinkIndic: ld a,8 ld (_curCol),a @@ -1219,9 +1333,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 @@ -1241,7 +1355,6 @@ NoLinkIndic: checkhilevel: ld hl,nrlevels ld a,(Level) - inc a cp (hl) jr c,hilevelcheckdone ld (hl),a ;save local @@ -1288,13 +1401,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 @@ -1324,6 +1440,7 @@ ExitNoStats: cal _SET_MM_NUM_BYTES cal _mm_ldir + cal releasekeys res 4,(iy+9) set 2,(iy+13) jp _clrWindow @@ -1348,53 +1465,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 @@ -1439,11 +1509,65 @@ unnamedlabel: respawndue: ld l,a cal inputcall + ld (sendbyte),a ld a,h ;previous cp l ;changed? ret z + ld (ix+delay),a ;=0 + ret saverespawncounter: ld (ix+delay),a + jr inputcall +; ld a,(ix+input) +; or a +; jr z,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 + psh hl + cal send + cal receive + pop hl + ld l,a + ret +receivefirst: + psh af + psh hl + cal receive + pop hl + ld l,a + pop af + psh hl + cal send + pop hl ret ;------- handle worm --------- @@ -1451,10 +1575,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 @@ -1584,6 +1708,7 @@ peagrowth =$-1 pop hl ; << call pop hl ; << call pop hl ; << levelp new + ld (ix+delay),2 jp StartLevel chkpeahit: ;hl=peapos @@ -1890,6 +2015,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) @@ -2563,289 +2698,110 @@ boxloop: ;----------- link ------------ ;----------------------------- -#ifdef 0 TIMEOUT = $1000 -receive: - cal GET_KEY - cp K_EXIT - jp z,LinkBreak - in a,(7) - and %11 - cp %11 - jr z,receive - cal Qreceive - jr c,receive - ret - -Qreceive: - ld b,8 - jr ReceiveCont -receiveloop: - ld de,TIMEOUT -WaitRecBit: - cal CheckLink - jr z,LinkFailed - cp %11 - jr z,WaitRecBit -ReceiveCont: - sub 2 - ld a,2 - ld d,D0LD1H - jr c,ReceiveLow - rra - ld d,D0HD1L -ReceiveLow: - rr c - ld (AckBit),a - ld a,d - out (7),a - ld de,TIMEOUT -WaitAckRec: - cal CheckLink - cp 0 -AckBit =$-1 - jr nz,WaitAckRec - ld a,D0HD1H - out (7),a - ld d,4 -WaitReadyRec: - dec d - jr z,ReadyRec - in a,(7) - cp %11 - jr nz,WaitReadyRec -ReadyRec: - dnz receiveloop - jr LinkSuccess - -send: - ld b,9 - ld c,a - jr SendAcked -SendBits: - rr c - ld a,D0LD1H - jr nc,SendLow - ld a,D0HD1L -SendLow: - out (7),a - ld de,TIMEOUT -WaitAckSend: - cal CheckLink - jr nz,WaitAckSend -SendAcked: - ld a,D0HD1H - out (7),a - ld de,TIMEOUT -WaitReadySend: - cal CheckLink - cp %11 - jr nz,WaitReadySend - dnz SendBits -LinkSuccess: - ld a,c ;pop a - ret - -LinkFailed: - scf - ld a,c - ret -LinkBreak: - ld a,D0HD1H - out (7),a - jp Exit - -CheckLink: +checklink: pop hl dec de - ld a,d - or e - jr z,LinkFailed + ld a,d + or e + jr z,LinkFailed 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 + jp z,Exit in a,(7) and %11 jp (hl) -#endif -LinkBreak: - pop hl - ld a,D0HD1H +;-------------- +;---- SEND ---- 8 bits in a +;-------------- destr:bcdehl +send: + ld c,a + ld b,8+1 ;bits to send + jr checksend +sendloop: + rr 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) + ld de,TIMEOUT +waitacksend: + cal checklink ;other calc must lower other whire + jr nz,waitacksend +checksend: + ld a,D0HD1H ;ok to raise both out (7),a - jp DisplayMenu - + ld de,TIMEOUT +finishsend: + cal checklink + cp %11 ;both raised (by other calc) + jr nz,finishsend + dnz sendloop ;repeat for all bits + .db $F6 ;or NN ;nc +LinkFailed: + scf ;c=error + ret +;-------------- +;---- RECV ---- 8 bits to a +;-------------- destr:bcdehl receive: - cal GET_KEY - cp K_EXIT - jp z,LinkBreak - cal TryReceiveByte + halt ;&&& + ld de,TIMEOUT + cal checklink + jr z,receive + cp %11 + jr z,receive + cal Qreceive jr c,receive ret - -LINKPORT =7 -TIMEOUT =$1000 -LINKMASK =3 - -LinkPrep: - ex (sp),hl - push bc - push de -; ld b,(iy+12h) -; push bc - set 2,(iy+12h) - ld b,8 - jp (hl) - -TryReceiveByte: - in a,(LINKPORT) - and LINKMASK - cp LINKMASK - scf - ret z -ReceiveByteCont: - call LinkPrep - jr ReceiveCont -ReceiveByte: - call LinkPrep -ReceiveBits: - ld de,TIMEOUT +Qreceive: + ld b,8 ;bits to receive +receiveloop: + ld de,TIMEOUT WaitRecBit: - call CheckLink - jr z,LinkFailed - cp LINKMASK - jr z,WaitRecBit -ReceiveCont: - sub LINKMASK/3*2 - ld a,LINKMASK/3*2 - ld d,D0LD1H - jr c,ReceiveLow - rra - ld d,D0HD1L -ReceiveLow: - rr c - ld (AckBit),a - ld a,d - out (LINKPORT),a - ld de,TIMEOUT -WaitAckRec: - call CheckLink - cp 0 + cal checklink + jr z,LinkFailed ;both low = error + cp %11 + jr z,WaitRecBit ;both on = nothing sent +recvbit: + rra ;received bit in cf + ld a,%10 + ld d,D0LD1H + jr c,savebit ;lower white as well + rra ;ld a,%01 + ld d,D0HD1L ;lower red +savebit: + rr c ;save bit + ld (AckBit),a + ld a,d + out (7),a ;lower other (both low) + ld de,TIMEOUT +waitackrecv: + cal checklink +; jr z,waitackrecv ;wait for one to go high + cp 0 AckBit =$-1 - jr nz,WaitAckRec - ld a,D0HD1H - out (LINKPORT),a - ld d,4 -WaitReadyRec: - dec d - jr z,ReadyRec - in a,(LINKPORT) - cp LINKMASK - jr nz,WaitReadyRec -ReadyRec: - djnz ReceiveBits - jr LinkSuccess - -send: -SendByte: - call LinkPrep - ld c,a - - inc b - jr SendAcked - -SendBits: - rr c - ld a,D0LD1H - jr nc,SendLow - ld a,D0HD1L -SendLow: - out (LINKPORT),a - ld de,TIMEOUT -WaitAckSend: - call CheckLink - jr nz,WaitAckSend -SendAcked: - ld a,D0HD1H - out (LINKPORT),a - ld de,TIMEOUT -WaitReadySend: - call CheckLink - cp LINKMASK - jr nz,WaitReadySend - djnz SendBits -LinkSuccess: - or 0 -.org $-1 -LinkFailed: - scf - ld a,c - res 2,(iy+12h) - pop de - pop bc - pop hl - ret - -CheckLink: - pop hl - dec de - ld a,d - or e - jr z,LinkFailed - ld a,0BFh - call _readkeypad - bit 6,a - jr z,LinkFailed - in a,(LINKPORT) - and LINKMASK - jp (hl) - -_readkeypad: - out (1),a - in a,(1) - push af - ld a,255 - out (1),a - pop af - ret - - -TEST_2: - ld b,8 -T2delay: - halt - dnz T2delay - in a,(7) - and %11 - ld b,a - ld a,'1' - rr b - jr c,T2no1 - ld a,'-' -T2no1: - cal _putc - ld a,'2' - rr b - jr c,T2no2 - ld a,'-' -T2no2: - cal _putc - cal GET_KEY - cp K_EXIT - jp z,DisplayMenu - jr TEST_2 - + jr nz,waitackrecv + ld a,D0HD1H + out (7),a ;raise both + dnz receiveloop ;repeat for all bits + or a ;nc + ld a,c ;a=byte received + ret ;----------------------------- ;---------- levels ----------- @@ -2890,8 +2846,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 @@ -3006,6 +2962,7 @@ right = 21 name = 22 wormsize = 31 +startdelay = 30 respawndelay = 30 maxnamelength = 8+1