X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/1ef9903729b6d0785ae56e2422120b030f3ef1f6..ba3bf9e0fe404be7e29910dad474dd4580550c05:/worm.z80 diff --git a/worm.z80 b/worm.z80 index d5b88d1..b4b4373 100644 --- a/worm.z80 +++ b/worm.z80 @@ -1,5 +1,5 @@ ; Title : Worm -; Version : 89% +; Version : 90% ; Release Date : april 2000??? ; Filename : worm.86p (4kb) ; Author(s) : Shiar @@ -16,10 +16,9 @@ ;----------- TO-DO ----------- ;----------------------------- -; 89% = DONE +; 90% = DONE ; 3% * linkplay -; 1% * titlescreen ; 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) @@ -37,6 +36,8 @@ ;----------------------------- ;----------------------------- +#define buffer ;use display buffer (otherwise write directly to screen) + #define cal call #define psh push #define dnz djnz @@ -68,7 +69,7 @@ _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl _mm_ldir = $52ED ;24bit ldir _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1 _RAM_PAGE_7 = $47F3 -_PTEMP_END = $D29A +_PTEMP_END = $D29A ;end of VAT _load_ram_ahl = $462F ;ahl->page+hl _writeb_inc_ahl = $5567 ;ld (ahl),c @@ -76,26 +77,37 @@ _writeb_inc_ahl = $5567 ;ld (ahl),c ;------- data storage ------- ;----------------------------- -leveldata = $EA00 ;size< $400 -ScrBuffer = $8100 ;size=$2000 (32x256) - ;->mod$800 -templevels = $BC00 ;size= 3*$10 -DispBuffer = $BC00 ;size= $390 (16x57) -SinCosTable = $B500 ;size= $100 (4x64) - -worm1 = $B400 -worm2 = $B41E -worm3 = $B43C -worm4 = $B45A -ball1 = $B478 - -resbit = 2 ;and%11111011 -worm1p = $B000 ;%10110000 -$B3FF -worm2p = $B800 ;%10111000 -$BBFF -worm3p = $F000 ;%11110000 -$F3FF -worm4p = $A800 ;$E800=%11101000 ;$D748+$1000+ - -WormVersion = 088 +;--- permanent + +ScrBuffer = $8820 ;-A7FF (20*FF=1FE0) +worm2p = $A800 ;-ABFF (400) %10101O00 +worm1 = $AC00 ;-AC1D (31d) +worm2 = $AC1F ;-AC3B (1F) +worm3 = $AC3E ;-AC59 (1F) +worm4 = $AC5D ;-AC77 (1F) +balls = $AC7C ;-ACFF (3x43d) +SinCosTable = $AD00 ;-AE00 (4x40) + ;free $AE01 ;-AFFF (1FF) +worm1p = $B000 ;-B7FF (800) %1011O000 +worm3p = $B800 ;-BBFF (400) %10111O00 + ;free $BF91 ;-BFFF (6F) + + ;program $D748 ;-E7FF (106D+4A) + ;free $E800 ;-EFFF (800) +worm4p = $F000 ;-F3FF (400) %11110O00 +leveldata = $F400 ;-FA70 (<=671) + +peaspos = $AE01 + +;--- temporary + +templevels = $BC00 ;(3*strings) @init +namelength = $BC00 ;(1) @menu +#ifdef buffer +DispBuffer = $BC00 ;(10x57d) @game +#else +DispBuffer = $FC70 +#endif ;----------------------------- ;------- program start ------- @@ -103,6 +115,8 @@ WormVersion = 088 .org _asm_exec_ram +WormVersion = 090 + start: nop jp Start @@ -111,7 +125,7 @@ start: .dw WormIcon WormMsg: - .db "WORM by SHIAR -- pre-beta 89%",0 + .db "WORM by SHIAR -- pre-beta 90%",0 WormIcon: .db 9,2 .db %10010110,%01101111 @@ -124,20 +138,19 @@ WormIcon: .db %11101111,%00001111 .db %11000011,%10000000 -levelhead = '8' -levelhead2 = '9' ;worm levels header = "89" +levelhead = 'w' +levelhead2 = 90 ;worm levels header = "90" Start: ld (SpSave),sp cal _runindicoff cal _flushallmenus - cal _clrLCD cal _RAM_PAGE_7 ld hl,$BFFF ;VAT start ld bc,templevels searchloop: - ld de,(_PTEMP_END+1) + ld de,(_PTEMP_END+1) ;VAT end or a ;nc sbc hl,de ;hl" + ld hl,$0004 + ld (_curRow),hl pop hl ld a,(hl) cp 255 @@ -342,8 +359,23 @@ NegativeSineWave: ld (curlevel),a DisplayMenu: cal _clrWindow - ld hl,txtWelcome - cal _puts + ld de,$FC42 ;(10,2) + ld hl,wtPicture + ld a,16 ;height +disptitleloop: + ld bc,8 ;width + ldir + ex de,hl + ld bc,8 ;next line + add hl,bc + ex de,hl + dec a + jr nz,disptitleloop + + ld hl,txtMenu + ld de,$0D5A + ld (_penCol),de + cal _vputs ;by Shiar ld de,$0207 ld (_curRow),de cal _puts ;--- @@ -496,12 +528,17 @@ menudraw: changeworms: cal _clrWindow + ld hl,txtName + cal _puts ;"Enter name player " ld a,(Gametype) cp 2 ld a,1 jr c,wormnrname ld a,(nrworms) wormnrname: + add a,'0' + cal _putc + sub '0' add a,a ;2x ld e,a add a,a ;4x @@ -518,6 +555,9 @@ wormnrname: jp DisplayMenu entername: + ld h,1 + ld l,h + ld (_curRow),hl ld (namelength),a enternameloop: ld a,'_' @@ -578,16 +618,14 @@ waitnokeypressed: jr nz,waitnokeypressed ret -namelength: - .db 0 chartable: - .db 0,"!<>^",0,0,0,0 + .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 "yuqlgb7#" ;0..xvar .db 0,"-pkfa6'" ;on..alpha - .db "54321.",0,0 ;F5..more + .db "54321*",0,0 ;F5..more ;--proc @@ -727,30 +765,25 @@ GameOver: ld (worm2+score+1),hl ld (worm3+score+1),hl ld (worm4+score+1),hl - ld hl,worm1set+4 - ld de,worm1+lives -;&&&>* - cal _MOV5B ;9xld(de),(hl) - cal _mov9b - ld hl,worm2set+4 - ld de,worm2+lives - cal _MOV5B - cal _mov9b - ld hl,worm3set+4 - ld de,worm3+lives - cal _MOV5B - cal _mov9b - ld hl,worm4set+4 - ld de,worm4+lives - cal _MOV5B - cal _mov9b + ld hl,worm1set + ld de,worm1+head + ld a,4 ;4x (all worms) +createwormsloop: + ld bc,19 + ldir ;copy 19 bytes + ex de,hl + ld bc,head + add hl,bc + ex de,hl ;de=wormX+head + dec a ;loop + jr nz,createwormsloop ld a,(Gametype) cp 1 ;=peaworm jr nz,worminitdone - ld (worm1+lives),a ;&&&<* + ld (worm1+lives),a worminitdone: - pop hl + pop hl ;begin of current level StartLevel: ld de,Left @@ -811,35 +844,12 @@ setsprite: add a,c ld c,a ld b,0 - ld de,ball1 + ld de,balls ldir toobad_noballs: -#ifdef 0 - ld a,(gameCar) - and _datahunt - jr z,nohunter - ld a,huntersize - ld (worm2+grow),a -nohunter: -#endif - ex de,hl ld (thislevel),de - psh de - ld hl,worm1set - ld de,worm1+head - cal _MOV4B - ld hl,worm2set - ld de,worm2+head - cal _MOV4B - ld hl,worm3set - ld de,worm3+head - cal _MOV4B - ld hl,worm4set - ld de,worm4+head - cal _MOV4B - pop de ld hl,worm1 ld a,(gameCar) @@ -991,6 +1001,16 @@ 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 @@ -1074,7 +1094,10 @@ Delay: jr nz,Delay NoDelay: - cal handlethoseneatlittleballs + ld a,0 +nrballs =$-1 + or a + cal nz,handlethoseneatlittleballs ld ix,worm1 ld a,(nrworms) @@ -1112,8 +1135,7 @@ CheckExit: WormDead: ld a,2 ld (flashtime),a - ld a,respawndelay - ld (ix+delay),a + ld (ix+delay),respawndelay thislevel =$+1 ld de,0 @@ -1306,6 +1328,8 @@ ExitNoStats: jp _clrWindow loadhiscoreposinahl: + ld a,(Level) + ld b,a ld a,(Gametype) or a externalhiscoresavepos: @@ -1314,7 +1338,9 @@ hiscrposa =$-1 ld hl,0 hiscrposhl =$-2 ret z ;(Gametype)=0 - cal _INC_PTR_AHL +addlevelposition: + cal _AHL_PLUS_2_PG3 + dnz addlevelposition ret ;----------------------------- @@ -1371,6 +1397,7 @@ inputcall: respawncheck: cp respawndelay-1 jr nz,unnamedlabel + cal saverespawncounter removeworm: ld h,(ix+tail+1) ld l,(ix+tail) @@ -1382,7 +1409,7 @@ removewormloop: inc hl ld b,(hl) inc hl - res resbit,h + cal resbit psh hl cal res4pixels pop hl @@ -1401,7 +1428,8 @@ safewormsizedone: ;de=ix+head ld (ix+tail+1),d - ld (ix+tail),e + ld (ix+tail),e ;head=tail/size=0 + ret unnamedlabel: cp 1 @@ -1414,7 +1442,7 @@ respawndue: cp l ;changed? ret z saverespawncounter: - ld (ix+delay),h + ld (ix+delay),a ret ;------- handle worm --------- @@ -1437,6 +1465,18 @@ donediddelydone: ld e,(ix+pos2) ld d,(ix+pos2+1) + psh hl + ld hl,previouspos + ld (hl),c + inc hl + ld (hl),b + inc hl + inc hl + ld (hl),e + inc hl + ld (hl),d + pop hl + ;-------- move worm ---------- Wormmove: @@ -1495,27 +1535,19 @@ GotFour: Hitworm: ld a,(gameCar) ld h,a - and _datafood - jp z,WormDead + and _datadie + cal z,checkhitotherworm + ld a,h + and _datamultpeas ;&&bit + jr nz,multiple_peas ld a,h - and _datahunt - cal nz,checkhitotherworm + and _datafood + jp z,WormDead ;no food ld hl,0 PeaY =$-2 PeaX =$-1 - ld a,(sprsize) - inc a - ld d,a - ld a,b - sub h - inc a - cp d ;=(sprsize)+1 - jp nc,WormDead - ld a,c - sub l - inc a - cp d + cal chkpeahit jp nc,WormDead cal DrawPea ;remove pea ld a,(ix+grow) @@ -1529,10 +1561,10 @@ peagrowth =$-1 ld de,10 cal IncScore pop af - jr nz,still_alive_not_dead + jp nz,Drawworm ;continue ld a,(gameCar) and _datafoodl - jr z,still_alive_not_dead + jp z,Drawworm ld a,(Gametype) or a jp nz,Exit ;stack restored @@ -1547,20 +1579,66 @@ peagrowth =$-1 cal _HLTIMES10 ex de,hl cal IncScore ;score+(40*level) + cal removeworm pop hl ; << call pop hl ; << call pop hl ; << levelp new jp StartLevel +chkpeahit: ;hl=peapos + ld a,(sprsize) + inc a + ld d,a + ld a,b + sub h + inc a + cp d ;=(sprsize)+1 + ret nc ;nc=no pea + ld a,c + sub l + inc a + cp d + ret ;c=pea + +flagcaptured: + psh hl + ld de,30 + cal IncScore + pop hl + cal WormDead +DrawAllPeas: + ld hl,(peaspos) + cal DrawPea + ld hl,(peaspos+3) + jp DrawPea + +multiple_peas: + ld hl,(peaspos) + ld a,(ix+reserv) + ld e,a ;push a + and %01 + jr nz,corrrectpea + ld hl,(peaspos+3) +corrrectpea: + cal chkpeahit + jp nc,WormDead + 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 + psh af ;safe z-flag + cal DrawPea ;remove + pop af + jr z,flagcaptured + jr Drawworm + ;----------------------------- -checkhitotherworm: - .db $dd,$7d ;ld a,lx - cp worm2&255 - ret nz -ThisIsJustASillyUselessLabel: - ld hl,(worm1+tail) - ld de,(worm1+head) nextotherwormbit: ld a,c sub (hl) @@ -1572,13 +1650,14 @@ nextotherwormbit: sub (hl) inc a cp 4 - jr c,otherwormHIT ;yes + ret c ;nz ;yes nothit1: inc hl - res resbit,h + cal resbit +ChkWorm: cal _cphlde jr nz,nextotherwormbit - ret + ret ;z checkhitlapline: ld a,63 @@ -1601,29 +1680,43 @@ nolap: ld (ix+reserv),a ret -otherwormHIT: - psh ix - ld de,10 - cal IncScore +checkhitotherworm: + .db $dd,$7d ;ld a,lx + cp worm2&255 + psh ix + jr nz,chkworm2 ; ret nz ld ix,worm1 - cal WormDead - pop ix - pop bc -still_alive_not_dead: + jr chkworm +chkworm2: + ld ix,worm2 + +chkworm: + ld h,(ix+tail+1) + ld l,(ix+tail) + ld e,(ix+head) + ld d,(ix+head+1) + cal ChkWorm + pop ix + ret z ;not hit + pop bc ;call +previouspos =$+1 + ld bc,0 + ld de,0 + ld (ix+pos),c + ld (ix+pos+1),b + ld (ix+pos2),e + ld (ix+pos2+1),d + ret ;-------- draw worm ---------- Drawworm: - ld a,(gameCar) - and _datahunt - cal nz,HuntingTimeScore - ld c,(ix+pos) ld b,(ix+pos+1) - ld a,(gameCar) - and _datalaps - cal nz,checkhitlapline + ld a,(Gametype) + cp gamerace + cal z,checkhitlapline ld l,(ix+head) ld h,(ix+head+1) @@ -1631,7 +1724,7 @@ Drawworm: inc hl ld (hl),b inc hl - res resbit,h + cal resbit ld (ix+head),l ld (ix+head+1),h @@ -1650,7 +1743,7 @@ removetail: inc hl ld b,(hl) inc hl - res resbit,h + cal resbit ld (ix+tail),l ld (ix+tail+1),h @@ -1673,13 +1766,8 @@ ResPixel: ;----------------------------- handlethoseneatlittleballs: - ld a,0 -nrballs =$-1 - or a - ret z - - ld hl,ball1 - ld b,a + ld hl,balls + ld b,a ;a=(nrballs) handleballs psh bc psh hl @@ -1772,6 +1860,12 @@ checkballhit: ;----------- procs ----------- ;----------------------------- +resbit: + ld a,h + and (ix+storepos) + ld h,a + ret + randompos: ld b,a Random: ;(2..b+2) @@ -1823,8 +1917,7 @@ DrawPea: ;hl=(PeaY) ld c,l ld de,peasprite spritepos =$-2 - cal PutSprite ;||-ed - ret + jp PutSprite ;||-ed ;----------- score ----------- @@ -1838,14 +1931,6 @@ divideagain: ;3x pop hl ret -HuntingTimeScore: - .db $dd,$7d ;ld a,lx - cp worm2&255 - ret z ;=worm#2 - dec (ix+reserv) - ret nz - ld hl,10 - IncScore: ld h,(ix+score+1) ld l,(ix+score) @@ -2029,10 +2114,10 @@ NotMaxYScroll: jr nc,NotMinXScroll xor a NotMinXScroll: - cp 128 + cp 128 FieldWidth = $-1 - jr c,NotMaxXScroll - ld a,(FieldWidth) + jr c,NotMaxXScroll + ld a,(FieldWidth) NotMaxXScroll: psh af ; >> 3 and %11111000 @@ -2050,7 +2135,7 @@ NotMaxXScroll: inc c CopyScreen: add hl,bc - ld b,57 + ld b,57 CopyScreenLoop: psh bc ; >> 4 ld bc,16 @@ -2105,10 +2190,12 @@ Bit7: AfterShiftDelay: halt AfterShift: +#ifdef buffer ld hl,DispBuffer ld de,$fc00+$70 ld bc,1024-$70 ldir +#endif pop de ; << 1 pop bc ; << 0k ret @@ -2583,6 +2670,41 @@ LevelDefM: ;---------- data ------------- ;----------------------------- +wtPicture: +.db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000 +.db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000 +.db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000 +.db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000 +.db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000 +.db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000 +.db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000 +.db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100 +.db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100 +.db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100 +.db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100 +.db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001100 +.db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00001100 +.db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00011100 +.db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00011000 +.db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00011000 + +txtMenu: .db "by Shiar",0 + .db "Have fun!",0 ;4th menu item + .db "Level 00",0 ;3rd + .db "Worms: 0",0 ;2nd +txtGame: .db "Singleplayer",0 ;0 (1st) +txtGame2: .db "Peaworm ",0 ;1 (next 1st) + .db "Deathmatch",0 ;2 + .db "Foodmatch ",0 ;3 + .db "LinkMatch",0 ;4 + .db "Race ",0 ;5 + .db "CTF ",0 ;6 + .db "Domination",0 ;7 +txtLevsel: .db $CF," Select levels: ",5,0 +txtName: .db "Enter name player ",0 +txtWaiting: .db "Waiting...",0 +txtReceive: .db "Receiving..." ;,0 + TrigPrecalc: .db 0, 3, 6, 9, 12, 15, 18, 21 .db 24, 27, 30, 33, 36, 39, 42, 45 @@ -2594,23 +2716,6 @@ TrigPrecalc: .db 124,125,125,126,126,126,126,126 .db 127 -txtWelcome: .db "Welcome to Worm!! ", - .db "by Shiar",0 - .db "Have fun!",0 ;4th menu item - .db "Level 00",0 ;3rd - .db "Worms: 0",0 ;2nd -txtGame: .db "Singleplayer",0 ;0 (1st) -txtGame2: .db "Peaworm ",0 ;1 - .db "Deathmatch",0 ;2 - .db "Foodmatch ",0 ;3 - .db "LinkMatch",0 ;4 (>options) - .db "Hunting ",0 ;5 - .db "Race ",0 ;6 - .db "CTF ",0 ;7 - .db "Domination",0 ;(>=8) -txtWaiting: .db "Waiting...",0 -txtReceive: .db "Receiving...",0 - txtLevel: .db "Level ",0 txtWorms: .db "Worms: 0",0 ;follows txtLevel txtDied: .db "Died ",0 @@ -2623,43 +2728,52 @@ txtGO: .db "----- GAME OVER -----",0 gamesdata: -_datalink = %00000001 -_datalivel = %00000010 ;ix+lives=0 limit +_datalink = %00000001 ;linkplay +_datalivel = %00000010 ;lives=0 limit _datafoodl = %00000100 ;left=0 limit _datanextl = %00001000 ;next level if left=0 _datasingl = %00001000 ;singleplayer=1 _datafood = %00010000 ;food present -_datahunt = %00100000 -_datalaps = %01000000 ;give lap score +_________ = %00100000 ; +_datadie = %01000000 ;worm dies on impact _datascore = %10000000 ;score>=100 limit +_datamultpeas = %00100000 + +gamesingle = 0 +datasingle: .db %01011110 +gamepeas = 1 +datapeas: .db %01011010 +gamedeathm = 2 +datadeathm: .db %01000010 +gamefoodm = 3 +datafoodm: .db %11010000 +gamelinkm = 4 +datalinkm: .db %01000011 +gamerace = 5 +datarace: .db %10000000 +gamectf = 6 +datactf: .db %11100000 +gamedomin = 7 +datadomin: .db %01000000 ;==(8 modes) -datasingle: .db %00011110 -datapeas: .db %00011010 -datadeathm: .db %00000010 -datafoodm: .db %10010000 -datalinkm: .db %00000011 -datahuntin: .db %10100000 -datarace: .db %11000000 -datactf: .db %00000000 ;==(8 modes) -;datadomin: .db %00000000 datalevels: .dw LevelDef, LevelDef .dw LevelDefM,LevelDefM .dw LevelDefM,LevelDefM .dw LevelDefM,LevelDefM -nrlevels: .db 1,1,1,1,1,1,1,1 +nrlevels: .db 2,2,2,2,2,2,2,2 worm1set: .dw worm1p,worm1p - .db 3,0,%01111110,%10,%100 ;< > -worm1name: .db "Left ",0 + .db %11110111,3,%00,%01111110,%10,%100 ;< > +worm1name: .db "worm #01",0 worm2set: .dw worm2p,worm2p - .db 3,0,%00111111,%10000,%1000 ;f1 f2 -worm2name: .db "Right ",0 + .db %11111011,3,%11,%00111111,%10000,%1000 ;f1 f2 +worm2name: .db "worm #02",0 worm3set: .dw worm3p,worm3p - .db 3,0,%01011111,%10,%100 ;sto , -worm3name: .db "Top ",0 + .db %11111011,3,0,%01011111,%10,%100 ;sto , +worm3name: .db "worm #03",0 worm4set: .dw worm4p,worm4p - .db 3,0,%01111101,%10,%1 ;enter + -worm4name: .db "Bottom ",0 + .db %11111011,3,0,%01111101,%10,%1 ;enter + +worm4name: .db "worm #04",0 hipeaworm: .dw 0 end: @@ -2679,21 +2793,22 @@ grow = 6 ;level died = 8 ;game score = 9 ;game delay = 11 ;game - -head = 12 ;level -tail = 14 ;level -lives = 16 ;game -reserv = 17 ;loop + ;19B @game +head = 12 ;4B (head=tail) +tail = 14 ;also@next level +storepos = 16 +lives = 17 +reserv = 18 ;loop ;race:lap - ;hunt:time -input = 18 ;& -left = 19 ;& -right = 20 ;& -name = 21 ;game -wormsize = 30 - -respawndelay = 40 -maxnamelength = 9 + ;ctf:pea +input = 19 +left = 20 +right = 21 +name = 22 +wormsize = 31 + +respawndelay = 30 +maxnamelength = 8+1 ;----------------------------- ;----------- end -------------