X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/daa6847068e3ae9b0201187f7f619feb27229385..b2288323cde0474b43669f9c5805fa92191c75d6:/worm.asm diff --git a/worm.asm b/worm.asm index 6c84154..d8f61e0 100644 --- a/worm.asm +++ b/worm.asm @@ -16,22 +16,18 @@ ;----------- TO-DO ----------- ;----------------------------- -; Shiar 4.II.00 +; Shiar 3.III.00 ;Feel like doing something? (name indicates who's working on it) -; * linkplay TESTING! (+faster) +; * linkplay ; * singleplay ending ; * titlescreen ; * make linkplay available for all gametypes (not just deathmatch) ; * two worms collide with heads -> both should die -; * bouncing balls :) ; * 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 -; * AI worms? ;1)* sprites for picks instead of blocks -; * fix linedraw procedure -; * save hiscore ;1) Working on a new pickup-system allowing more than one "food" and different pickup-handling @@ -247,12 +243,14 @@ LetsGetThisPartyOn: ld hl,gamesdata add hl,de - or a - jr nz,notsingle - inc a + ld a,(hl) + push af + and _datasingl + jr z,notsingle + ld a,1 ld (nrworms),a notsingle: - ld a,(hl) + pop af ld (gameCar),a push af @@ -344,26 +342,39 @@ GameOver: pop de StartLevel: - ld a,(de) - ld (Left),a - inc de - ld a,(de) - ld (Speed),a - inc de - ld a,(de) + ex de,hl + ld de,Left + ldi + ld de,Speed + ldi + ld a,(hl) ld (worm1+grow),a ld (worm2+grow),a ld (worm3+grow),a ld (worm4+grow),a - inc de + ld (beginsize),a + inc hl + + ld a,(hl) + inc hl + ld (nrballs),a + or a + jr z,toobad_noballs + ld de,ballpos + ldi + ldi +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 push de ld hl,worm1set @@ -622,6 +633,8 @@ Delay: jr nz,Delay NoDelay: + call handlethatneatlittleball + ld ix,worm1 ld a,(nrworms) ld b,a @@ -660,7 +673,9 @@ WormDead: ld h,(ix+tail+1) ld l,(ix+tail) - push hl + ld d,(ix+head+1) + ld e,(ix+head) + jr DoesWormTailEqualsWormHead ;chk4 size=0 removewormloop: ld c,(hl) inc hl @@ -670,31 +685,22 @@ removewormloop: push hl call res4pixels pop hl - ld a,(ix+head) - cp l - jr nz,removewormloop - ld a,(ix+head+1) - cp h + inc (ix+grow) +DoesWormTailEqualsWormHead: + call _cphlde jr nz,removewormloop - ;hl=ix+head - pop de ;ix+tail ld a,(gameCar) - and _datamulti + and _datasingl jr nz,safewormsizedone -; or a - sbc hl,de - ld a,l - rr h - rra - inc a + ld a,0 +beginsize =$-1 ld (ix+grow),a safewormsizedone: - ld h,(ix+head+1) - ld l,(ix+head) - ld (ix+tail+1),h - ld (ix+tail),l + ;de=ix+head + ld (ix+tail+1),d + ld (ix+tail),e ld a,50 ld (ix+delay),a @@ -792,6 +798,29 @@ NoLinkIndic: pop bc djnz displayWormStats + ld a,(gameCar) + and _datasingl + jr z,hiscorecheckdone +checkhiscore: + ld de,(worm1+score) +HiScore =$+1 + ld hl,0 + ld a,e + cp l + jr c,NotNewHigh + ld a,d + cp h + jr c,NotNewHigh + ld (HiScore),de + ex de,hl ;disp.new hiscore +NotNewHigh: + ex de,hl + ld hl,txthiscore + call _puts + ex de,hl + call showHL +hiscorecheckdone: + waitkey: halt halt @@ -812,14 +841,6 @@ waitkey: ;8Snaky @ 00 04820 ExitNoStats: -; ld a,(Eaten) - xor a - ld hl,HiScore - cp (hl) - jr c,NotNewHigh - ld (hl),a -NotNewHigh: - ld hl,_asapvar rst 20h ;_ABS_MOV10TOOP1 rst 10h ;_FINDSYM @@ -829,7 +850,7 @@ NotNewHigh: adc a,0 call _SET_ABS_DEST_ADDR - xor a + xor a ld hl,start call _SET_ABS_SRC_ADDR ld hl,end-start @@ -955,14 +976,7 @@ notmoveY: ;bc=newpos xor 3 ld d,a GotFour: - call CheckPixel - inc b - call CheckPixel - inc c - call CheckPixel - dec b - call CheckPixel - dec c + call chk4pixels rl d jp nc,Drawworm @@ -1101,13 +1115,7 @@ Drawworm: ld (ix+head),l ld (ix+head+1),h - call SetPixel - inc b - call SetPixel - inc c - call SetPixel - dec b - call SetPixel + call set4pixels ld a,(ix+grow) dec a @@ -1133,7 +1141,59 @@ res4pixels: inc c call ResPixel dec b - jp ResPixel +ResPixel: + call FindPixel + cpl + and (hl) + ld (hl),a + ret + +;----------------------------- +;---------- ball ------------- +;----------------------------- + +handlethatneatlittleball: + ld a,0 +nrballs =$-1 + or a + ret z +ballpos =$+1 + ld bc,$0503 + call res4pixels + dec c + ld e,b +ballxmove: + inc b ;=%000100 dec=%000101 + call checkballhit + jr z,ballxdone + ld b,e + ld hl,ballxmove + call letsmovetheotherway +ballxdone: + ld e,c +ballymove: + inc c ;=%001100 dec=%001101 + call checkballhit + jr z,balldone + ld c,e + ld hl,ballymove + call letsmovetheotherway +balldone: + ld (ballpos),bc + jp set4pixels + +letsmovetheotherway: + ld a,1 + xor (hl) + ld (hl),a + ret + +checkballhit: + ld d,0 + call chk4pixels + xor a + cp d + ret ;----------------------------- ;----------- procs ----------- @@ -1144,8 +1204,8 @@ NewPea: ld hl,0 ld de,12345 Seed =$-2 - ld a,7921 & 255 - ld bc,1000h+(7921/256) + ld a,7921&255 + ld bc,$1000+(7921/256) domult16: add hl,hl rla @@ -1155,12 +1215,12 @@ domult16: noadd16: djnz domult16 inc hl - ld (Seed),hl ;seed=(seed*7921+1) MOD 65536 + ld (Seed),hl ;seed=(seed*7921+1)\65536 ld a,(FieldWidth) add a,123 cp h - jr c,NewPea + jr c,NewPea inc h inc h ld a,(FieldHeight) @@ -1208,19 +1268,29 @@ DrawPeaPixel: ;-------- pixelprocs --------- -ResPixel: ;at bc - call FindPixel - cpl - and (hl) - ld (hl),a - ret - +set4pixels: + call SetPixel + inc b + call SetPixel + inc c + call SetPixel + dec b SetPixel: ;at bc call FindPixel or (hl) ld (hl),a ret +chk4pixels: ;&& + call CheckPixel + inc b + call CheckPixel + inc c + call CheckPixel + dec b + call CheckPixel + dec c + ret CheckPixel: ;at bc in d call FindPixel and (hl) @@ -1228,67 +1298,34 @@ CheckPixel: ;at bc in d dec d ret -;------------------------------------------------------ -; CLEM's FIND_PIXEL -; by Clem -; -; 131 cycles 28 bytes (b,c) to hl:a destroyes: none -;------------------------------------------------------ +;CLEM's FIND_PIXEL (131 cycles; 28 bytes) +; (b,c) to hl:a; destroyes: -) FindPixel: - ld h,ScrBuffer/$800 - ld a,c - add a,a - add a,a - ld l,a ;hl=$3f00+4*y - ld a,b - rra - add hl,hl - rra - add hl,hl ;hl=$fc00+16*y - add hl,hl - rra ;a=x/8 - or l - ld l,a - ld a,b - and 7 - cpl - rlca - rlca - rlca - ld (FP_Bit),a - xor a -FP_Bit =$+1 - set 0,a - ret - -;FindPixel: ;bc to ahl + de gone - push de - push bc - ld a,b - and 7 - add a,offsets_table & 255 - ld e,a - ld d,offsets_table/256 - ld h,0 - ld l,c - add hl,hl ;2y - add hl,hl ;4y - add hl,hl ;8y - add hl,hl ;16y - add hl,hl ;32y + ld h,ScrBuffer/$800 + ld a,c + add a,a + add a,a + ld l,a ;hl=4*y + offset/8 ld a,b - and %11111000 - rra rra + add hl,hl rra + add hl,hl + add hl,hl ;hl=32*y + offset + rra ;a=x/8 or l ld l,a - ld a,(de) - ld de,ScrBuffer - add hl,de - pop bc - pop de + ld a,b + and 7 + cpl + rlca + rlca + rlca + ld (FP_Bit),a + xor a +FP_Bit =$+1 + set 0,a ret ;----------- score ----------- @@ -1333,9 +1370,7 @@ showstats: jr nz,showstatsS showstatloop: push bc -; push ix call showstat -; pop ix ld de,worm2-worm1 add ix,de ld hl,_penCol @@ -1389,6 +1424,10 @@ tilllevel9: ld a,123 ld (_penCol),a call showlives + ld a,(gameCar) + and _datafoodl + pop ix + ret z showleft: ld a,31 ld (_penCol),a @@ -1402,7 +1441,6 @@ Left =$-1 add a,'0' call __vputmap ld hl,txtLeft - pop ix __vputs: push ix call _vputs @@ -1448,9 +1486,6 @@ savestr: ;----------------------------- -offsets_table: - .db 128,64,32,16,8,4,2,1 - DisplayField: ld a,c sub 29 @@ -1686,10 +1721,10 @@ Line: ;draw line from de to hl (doptions) - .db "Hunting ",0 ;4 - .db "Race ",0 ;5 - .db "CTF ",0 ;6 - .db "Domination",0 ;7 +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 WormVersion = 092 -WormMsg: .db "WORM by SHIAR -- test version",0 -txtLevel: .db "Level ",0 -txtWorms: .db "Worms: 0",0 ;follows txtLevel -txtDied: .db "Died ",0 -txtScore: .db "Score",0 ;follows txtDied -txtLeft: .db " left",0 ;follows txtScore -txtReady: .db "Prepare!",0 +WormMsg: .db "WORM by SHIAR -- test version",0 +txtLevel: .db "Level ",0 +txtWorms: .db "Worms: 0",0 ;follows txtLevel +txtDied: .db "Died ",0 +txtScore: .db "Score",0 ;follows txtDied +txtLeft: .db " left",0 ;follows txtScore +txthiscore:.db "HiScore:",0 +txtReady: .db "Prepare!",0 txtposReady = 7 -txtGO: .db "----- GAME OVER -----",0 -HiScore: .db 0 +txtGO: .db "----- GAME OVER -----",0 gamesdata: _datalink = %00000001 -_datamulti = %00000010 +_datasingl = %00001000 ;singleplayer=1 _datalivel = %00000010 ;ix+lives=0 limit _datafoodl = %00000100 ;left=0 limit _datanextl = %00001000 ;next level if left=0 @@ -2239,13 +2282,15 @@ _datascore = %10000000 ;score>=100 limit datasingle: .db %00011110 .dw LevelsS +datapeas: .db %00011010 + .dw LevelsS datadeathm: .db %00000010 .dw LevelsDM2 datafoodm: .db %10010000 .dw LevelsDM datalinkm: .db %00000011 .dw LevelsDM -datahuntin: .db %00110100 +datahuntin: .db %10100000 .dw LevelsH datarace: .db %11000000 .dw LevelsR @@ -2256,7 +2301,7 @@ datadomin: .db %00000000 setdata = 18 -resbit = 2 ;and%11111011 +resbit = 2 ;and%11111011 worm1set: .dw $B000,$B000 ;%10110000 .db 3,0,%01111110,%10,%100 ;< > .db "Worm #1",0