From: Mischa Poslawsky Date: Sun, 7 May 2000 11:34:28 +0000 (+0200) Subject: worm 0.91.0507: improve key handling, mask game field before start X-Git-Url: http://git.shiar.nl/wormy.git/commitdiff_plain/7ec10d8466fbe267a3d0a8fe8fbfaed79adbf07f worm 0.91.0507: improve key handling, mask game field before start --- diff --git a/worm.z80 b/worm.z80 index e254d01..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,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,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 @@ -729,18 +777,22 @@ host: cal _puts cal receive cp WormVersion - jp nz,LinkBreak + jp nz,linkiniterror cal send jr multiplayer +linkiniterror: + pop hl + jp DisplayMenu + client: ld hl,txtReceive cal _puts - cal ReceiveByte - jp c,LinkBreak + cal Qreceive + jp c,linkiniterror cp WormVersion - jp nz,LinkBreak + jp nz,linkiniterror ld hl,SwapPos ld (hl),$f6 @@ -850,7 +902,9 @@ setsprite: toobad_noballs: ex de,hl +#ifndef invincible ld (thislevel),de +#endif ld hl,worm1 ld a,(gameCar) @@ -950,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 @@ -1002,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+2),hl - cal DrawPea -noctf: ld a,(gameCar) and _datafood jr z,nofood @@ -1019,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 @@ -1030,6 +1107,7 @@ nofood: ld hl,txtReady cal _puts res 3,(iy+5) +#endif ld a,0 gameCar =$-1 @@ -1056,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 ------------ @@ -1134,6 +1213,9 @@ CheckExit: jr Exit WormDead: +#ifdef invincible + jp stopworm +#else ld a,2 ld (flashtime),a ld (ix+delay),respawndelay @@ -1162,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 @@ -1193,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 @@ -1219,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 @@ -1241,7 +1324,6 @@ NoLinkIndic: checkhilevel: ld hl,nrlevels ld a,(Level) - inc a cp (hl) jr c,hilevelcheckdone ld (hl),a ;save local @@ -1288,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 @@ -1324,6 +1409,7 @@ ExitNoStats: cal _SET_MM_NUM_BYTES cal _mm_ldir + cal releasekeys res 4,(iy+9) set 2,(iy+13) jp _clrWindow @@ -1348,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 @@ -1430,6 +1469,7 @@ safewormsizedone: ;de=ix+head ld (ix+tail+1),d ld (ix+tail),e ;head=tail/size=0 + jr norespawn ret unnamedlabel: @@ -1444,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 --------- @@ -1451,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 @@ -1890,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) @@ -2563,9 +2660,15 @@ boxloop: ;----------- link ------------ ;----------------------------- -#ifdef 0 TIMEOUT = $1000 +LinkBreak: + pop hl + ld a,D0HD1H + out (7),a + jp Exit + + receive: cal GET_KEY cp K_EXIT @@ -2574,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: @@ -2589,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: @@ -2617,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 @@ -2642,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 @@ -2665,187 +2768,18 @@ 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) -#endif - -LinkBreak: - pop hl - ld a,D0HD1H - out (7),a - jp DisplayMenu - - -receive: - cal GET_KEY - cp K_EXIT - jp z,LinkBreak - cal TryReceiveByte - 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 -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 -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 - ;----------------------------- ;---------- levels ----------- @@ -2890,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 @@ -3006,6 +2940,7 @@ right = 21 name = 22 wormsize = 31 +startdelay = 30 respawndelay = 30 maxnamelength = 8+1 diff --git a/wormlvl.z80 b/wormlvl.z80 index 57e2d55..7ad6a49 100644 --- a/wormlvl.z80 +++ b/wormlvl.z80 @@ -8,7 +8,7 @@ .org $F3E3-16 - .db 'w',90 + .db 'w',91 .db 16,"Worm LevelPack I" .dw hiscore-single @@ -24,8 +24,8 @@ levelsdata: .dw ctf .dw domination - .db 2,3,4,2 - .db 2,2,2,2 + .db 1,2,3,1 + .db 1,1,2,1 ;---------- LEVELS ---------- @@ -194,7 +194,6 @@ deathmatch: foodmatch: -ctf: domination: .db 8,5,18,15,0,0 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64 @@ -219,9 +218,24 @@ race: .db 52,10,74,37 +ctf: + .db 8,5,18,15,0,0 + .db $20,2,2,$A0,54,125, $20,2,7,$A0,54,120 + .db 128,57 + .db 9,117,46,10 + .db 0,0 + + .db 8,5,18,15,0,0 + .db $60,54,2,$E0,2,125, $60,49,2,$E0,7,125 + .db 128,57 + .db 9,10,46,117 + .db 0,1 + .db 20,14,107,31 + + hiscore: .dw 0 - .dw 1,2 + .dw 0,0 .end