X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/711d2428b9a29f7c412e208f87f109b9671424a3..c19230bff97b89344d6e9fcec28a5a1df95a2bea:/wormy.z80 diff --git a/wormy.z80 b/wormy.z80 index b7db1ce..d6b21fb 100644 --- a/wormy.z80 +++ b/wormy.z80 @@ -109,7 +109,8 @@ worm3p = $B800 ;-BBFF (400) %10111O00 worm4p = $F000 ;-F3FF (400) %11110O00 leveldata = $F400 ;-FA70 (<=671) -peaspos = $AE01 +turn10 = $AE01 +peaspos = $AE02 ;--- temporary @@ -496,11 +497,7 @@ dispmenuloop: hr: ;draw horizontal line at hl ld b,16 -hrloop: - ld (hl),-1 - inc hl - dnz hrloop - ret + jp menuinvloop ;--- menu loop --- @@ -751,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 @@ -776,7 +773,7 @@ selleft: dec a jr z,bchangelevel dec a -; jr z,bchangelives + jr z,bchangelink dec a jr z,bchangenrworms ; dec a @@ -789,11 +786,8 @@ 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 @@ -801,14 +795,37 @@ changednrworms: ld (hl),a _dispmenusets: 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 @@ -899,9 +916,9 @@ dispmenusets: ld hl,$243E ld (_penCol),hl rr c ;(gameCar) - ld hl,txtYes - jr c,displink ld hl,txtNo + jr nc,displink + ld hl,txtYes displink: cal _vputs @@ -926,7 +943,7 @@ curworm =$-1 cal _vputs ld hl,$363E ;controls ld (_penCol),hl - ld hl,txtMenu6 + ld hl,txtMenuR cal _vputs jp mainMenu @@ -1123,7 +1140,7 @@ skipsprite: inc b inc b ;skip 6 ld a,c - cp _datasp + cp _datasingle jr z,skipworms inc b ;multiplayer lvl inc b @@ -1160,7 +1177,7 @@ skipobjects: loadgamecar: ;in: (Gametype) -;out: Gametype+1=hl +;out: hl=dataTYPE ;build: c=(gameCar)=(hl-1) ; a=(wormbeglives)=(hl) ;destr: acdehl @@ -1237,8 +1254,8 @@ levelsskipped: psh hl ;1st level ld a,(gameCar) - and _datalink - jr z,GameOver + rra ;and _datalink + jr nc,GameOver linkmatch: cal _clrWindow @@ -1266,8 +1283,8 @@ client: ld a,$E6 multiplayer: ; cal linkok - ld a,D0LD1L - out (7),a +; ld a,D0LD1L +; out (7),a ld (SwapPos),a ld a,2 ld (nrworms),a @@ -1381,8 +1398,8 @@ 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 @@ -1406,6 +1423,11 @@ worminit: pop bc ;<0 dnz worminit + inc a ;ld a,1 + ld (turn10),a + ld a,2 + ld (flashtime),a + ;-------- draw level --------- ld a,(de) @@ -1503,7 +1525,7 @@ noctf: ;----------------------------- psh hl ; >> levelp new - cal showstats + cal forceshowstats ld a,(gameCar) and _datafood jr z,nofood @@ -1547,8 +1569,8 @@ maskline: ld a,0 gameCar =$-1 - and _datalink - jr z,initfinished ;no link + rra ;and _datalink + jr nc,initfinished ;no link xor a SwapPos: ;$18 xx -> $E6 xx ; jr xx -> and xx @@ -1556,19 +1578,19 @@ SwapPos: ;$18 xx -> $E6 xx setclient: ld (worm1+left),a ;worm 1... ld (worm3+left),a ;and worm 3 via link - cal Crecv + cal Qrecv ld a,c ld (worm2+name+0),a - cal Crecv + cal Qrecv ld a,c ld (worm2+name+1),a - cal Crecv + cal Qrecv ld a,c ld (worm2+name+2),a - cal Crecv + cal Qrecv ld a,c ld (worm2+name+3),a - cal Crecv + cal Qrecv ld a,c ld (worm2+name+4),a jr initfinished @@ -1618,7 +1640,7 @@ screeninvertloop: ld (hl),a inc hl xor a - cp h + cp h ;end at >$FFFF jr nz,screeninvertloop noflash: @@ -1645,6 +1667,17 @@ 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: + + ld a,0 nrballs =$-1 or a @@ -1723,10 +1756,10 @@ handledworm =$-2 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 @@ -1743,6 +1776,7 @@ anyworm: #endif Exit: + cal releasekeys ld sp,0 ;pop all SpSave = $-2 ld a,D0LD1L @@ -1754,11 +1788,9 @@ SpSave = $-2 ld b,16*8 cal menuinvloop ;invert inc h ;$FD80 - ld b,16 - cal menuinvloop ;
+ cal hr ;menuinvloop w/ b=16 ld hl,$FCE0 - ld b,16 - cal menuinvloop ;
+ cal hr ; ld l,$74 ; ld b,8 ; cal menuinvloop @@ -1775,25 +1807,65 @@ CURtxtGame =$-2 ld (_penCol),de ld hl,txtName cal _vputs ;Name - ld a,$4F + 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 + psh hl ld bc,left-died add hl,bc ;+left xor a cp (hl) ;input=0 = link jr nz,NoLinkIndic - ld a,8 + ld a,9 ld (_curCol),a ld a,$DC ;-O cal _putc @@ -1803,23 +1875,47 @@ 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,16 + 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) - cal showHL ;worm+score - + 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 @@ -1877,7 +1973,6 @@ NotNewHigh: ;de=current hiscore cal showHL hiscorecheckdone: - cal releasekeys waitkey: halt halt @@ -2053,8 +2148,8 @@ inputcall: jr z,inlink ;input by link cal inkeys ;input by keys ld a,(gameCar) - and _datalink - ret z ;no link + rra ;and _datalink + ret nc ;no link ld c,l ;send our keys jp Qsend inlink: @@ -2083,12 +2178,12 @@ turn =$-1 inc (ix+grow) nogrow: - ld a,(Gametype) - cp gametron - jr nz,notron + ld a,(gameCar) + and _datatime + jr z,notimescore ld de,1 cal IncScore -notron: +notimescore: ld l,(ix+heading) cal inputcall @@ -2640,10 +2735,10 @@ scorelimit =$-2 jp nc,Exit showstats: - ld a,(Gametype) - cp gametron - ret z -showstatsEven4tron: + ld a,(gameCar) + and _datatime + ret nz ;no disp for timematches +forceshowstats: psh ix ld h,0 ld l,h @@ -2652,34 +2747,51 @@ showstatsEven4tron: ld b,a ld ix,worm1 ld a,(gameCar) - and _datanextl + 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 + add ix,de ;next ld hl,_penCol ld a,(hl) - add a,10 + add a,4 ;div ld (hl),a pop bc dnz showstatloop pop ix ret -showstat: +showstat: ;(multiplayer) ld a,(Gametype) - cp gametron - jr z,showscore - ld a,(wormbeglives) - or a ;0=death limit - jr nz,showlives + cp gamedeathm + jr z,showlives showscore: ld h,(ix+score+1) ld l,(ix+score) cal _D_HL_DECI - jr __vputs + jr __vputs showlives: ld a,(ix+lives) add a,'0' @@ -2689,7 +2801,7 @@ __vputmap: pop ix ret -showstatsS: +showstatsS: ;(singleplayer) ld hl,txtLevel cal __vputs ld a,0 @@ -3416,6 +3528,7 @@ csendwait: 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 @@ -3555,8 +3668,9 @@ txtMenu: .db "Mode",0 ;1st menu item .db "Link",0 ;... .db "Worms",0 .db "worm #",0 -txtMenu6: .db "controls",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 ;... @@ -3571,8 +3685,8 @@ txtGame3: .db "Deathmatch",0 txtGame4: .db "Foodmatch",0 txtGame5: .db "Timematch",0 txtGame6: .db "Race",0 -txtGame7: .db "CTF",0 -; .db "Domination",0 ;8 +txtGame7: .db "CTF" ;,0 + posGame: .db 0,txtGame1-txtGame .db txtGame2-txtGame .db txtGame3-txtGame @@ -3606,7 +3720,8 @@ TrigPrecalc: txtLevel: .db "Level ",0 txtWorms: .db "Worms: 0",0 ;follows txtLevel txtName: .db "Name",0 -txtDied: .db "Died " ;follows txtName +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 @@ -3614,47 +3729,46 @@ txtReady: .db "Prepare!",0 txtposReady = 7 txtGO: .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0 -_datalink = %0000001 ;linkplay - -_datafoodl = %0000010 ;left=0 limit -_datanextl = %0000100 ;next level if left=0 -_datasingl = %0000100 ;singleplayer=1 (=hiscore+keep_length) -_datamultpeas = %0001000 ;multiple peas=1 -_datatime = %0010000 ;time incs score -_datafood = %0100000 ;food present -_datadie = %1000000 ;worm dies on impact -_datasp = %1100110 - datalevels: .dw LevelDef, LevelDefM .dw LevelDefT,LevelDefM .dw LevelDefM,LevelDefM .dw LevelDefM,LevelDefC nrlevels: .db 1,3,1,3,3,3,3,1 ;=defaults -savestart: ; Úgame info - ; | Úlives +_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 (set to 1 at startup) - ; | | | | Úspeed (-1=def) - ; | | | | | Úgrow speed (-1=none) - ; | | | | | | Úturn speed - ; | | | | | | | Úscore limit -gamesingle = 0 ; | | | | | | | | + ; | | | Ú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 -datadeathm: .db %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth) +gamedeathm = 3 ;used +datadeathm: .db %1000001,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,-1, 8,10 ;Timematch (1 live, 100 score) -gamerace = 6 +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 +gamectf = 7 ;used datactf: .db %1001000,0,4,1,-1,-1, 8, 9 ;CTF (90 score) +_datasingle = %1100110 ;(datasingle) usable like gamesingle worm1set: .dw worm1p,worm1p .db %11110111,%00,-01,K_RIGHT,K_LEFT