From: Mischa Poslawsky Date: Fri, 28 Jan 2000 13:54:46 +0000 (+0100) Subject: worm 0.80.0128 X-Git-Url: http://git.shiar.nl/wormy.git/commitdiff_plain/8fff5ad3c104f2936efec10bd4278491321865a1 worm 0.80.0128 - boxes in levels - stats-bar (at top) remade, also in multiplayer games - begin-size of worms is map-dependant - stats-screen at game over - race mode - single file (integrate line.asm include) --- diff --git a/line.asm b/line.asm deleted file mode 100644 index 0c9cbfa..0000000 --- a/line.asm +++ /dev/null @@ -1,95 +0,0 @@ -Line: - push hl - push de - ld a,d - cp h - jr c,LineOrdered - ex de,hl -LineOrdered: - ld b,d - ld c,e - push hl - push bc - call FindPixel - pop bc - pop de -ConnectedLine: - push hl - ld h,c - ld c,a - ld a,d - sub b - ld b,a - ld a,e - jr nz,LineNotPoint - cp h - jr nz,LineNotPoint - pop hl - jr DoneLine -LineNotPoint: - sub h - ld de,16 - jr nc,LinePositiveY - neg - ld de,-16 -LinePositiveY: - cp b - jr nc,SteepLine - add a,a - ld (Line2sm+1),a - ld h,a - xor a - sub b - add a,a - ld (Line1sm+1),a - ld a,h - sub b - pop hl -LineLoopGentle: - push af - ld a,(hl) - or c - ld (hl),a - rrc c - jr nc,$+3 - inc hl - pop af - jp m,Line2sm -Line1sm add a,0 - add hl,de -Line2sm add a,0 - djnz LineLoopGentle -DoneLine: - ld a,(hl) - or c - ld (hl),a - pop de - pop hl - ret - -SteepLine: - ld h,a - neg - add a,a - ld (Line3sm+1),a - ld a,b - add a,a - ld (Line4sm+1),a - sub h - ld b,h - pop hl -LineLoopSteep: - push af - ld a,(hl) - or c - ld (hl),a - add hl,de - pop af - jp m,Line4sm -Line3sm add a,0 - rrc c - jr nc,$+3 - inc hl -Line4sm add a,0 - djnz LineLoopSteep - jr DoneLine diff --git a/worm.asm b/worm.asm index b71663d..8d0bab1 100644 --- a/worm.asm +++ b/worm.asm @@ -1,41 +1,76 @@ -; -WonderWorm--v0.9- -; by Matthew Shepcar 30.XII.98 -; modified by Jonah Cohen 19.XI .99 -; and Shiar 01.XII.99 +; Title : Worm +; Version : 0.92 +; Release Date : soon (I hope) +; Filename : worm.86p +; Author(s) : Shiar +; Email Address : shiar@mailroom.com +; ICQ UIN : #43840958 +; Web Page : www.games3.net/shiar +; Description : ruling multiplayer game for 86 (most like Nibbles) +; Where to get this game : games3.net/shiar (home of Worm) +; Other games by author(s) : Shiar: Nemesis beta +; Additional Credits to : Matthew Shepcar (wrote original Peaworm, end'98) +; Jonah Cohen (wrote some parts of worm) -;to-do: -; * picks not correctly removed -; * linkplay -; * hot pursuit + ctf -; * ending (+stats after multiplayer) +;----------------------------- +;----------- TO-DO ----------- +;----------------------------- + +; Shiar 23.I .00 + +;Feel like doing something? (name indicates who's working on it) +; * linkplay TESTING! (+faster) +; * singleplay ending +; * titlescreen +; * make linkplay available for all gametypes (not just deathmatch) +; * two worms collide with heads -> both should die +; * bouncing balls :) +; * game types: +; * hot pursuit/hunting/kodh: catch the other player and vv +;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) Shiar: working on a new pickup-system allowing more than one "food" and different pickup-handling #include "TI86.inc" +;----------------------------- +;------- program start ------- +;----------------------------- .org _asm_exec_ram - -_divHLby10 = $4044 -_getcsc = _getky -_clrWindow = $4a86 -_runIndicOff = _runindicoff -_flushAllMenus = _flushallmenus -_SHRACC = _shracc -_SHLACC = $438B - +start: nop jp Start - .dw 0,WormMsg + .dw 1 + .dw WormMsg + .dw WormIcon + +WormIcon: + .db 9,2 + .db %10010111,%01101111 + .db %10110101,%01001011 + .db %11110111,%01001001 + .db %00000011,%10000000 + .db %00000001,%11100000 + .db %00111000,%11111000 + .db %01111110,%00111111 + .db %11101111,%00001111 + .db %11000011,%10000000 Start: -; ld (SpSave),sp + ld (SpSave),sp call _runIndicOff - call _flushAllMenus +; call _flushAllMenus call _clrLCD + res 2,(iy+13) ;appAutoScroll ld a,r ld (Seed),a - xor a - ld (_asapvar+1),a ;----------------------------- ;----- build trig tables ----- @@ -69,106 +104,198 @@ NegativeSineWave: ;----------------------------- DisplayMenu: - call _clrLCD + ld a,2 + ld (nrworms),a +gomainMenu: + call _clrWindow ld hl,txtWelcome call _puts - ld hl,txtMenu - ld de,$0203 - ld b,4 -DispMenuLoop: - inc de + ld de,$0205 + ld (_curRow),de + call _puts ;txtOptions + dec e ;$0204 ld (_curRow),de + ld hl,(CURtxtGame) call _puts - djnz DispMenuLoop - ld hl,$0805 - ld (_curRow),hl + xor a +mainMenu: + call menucall + jr nz,notselect +select: + ld a,b + or a + jr nz,gooptionsMenu + jp ThePartyIsOn +notselect + cp K_EXIT + jp z,ExitNoStats + cp K_RIGHT + ld a,b + jr nz,mainMenu + or a + jr z,Variation + +gooptionsMenu: + call _clrWindow + ld hl,txtWelcome + call _puts + ld hl,txtLevel + ld de,$0205 + ld (_curRow),de + call _puts ;txtLevel + dec e ;$0204 + ld (_curRow),de + call _puts ;txtWorms + ld a,(nrworms) + add a,'0' + call _putc + xor a +optionsMenu: + call menucall + jr nz,notopselect +opselect: + ld a,b + or a + jr nz,changelevel +changeworms: + ld hl,nrworms + inc (hl) + ld a,4 + cp (hl) + jr nc,gooptionsMenu + ld (hl),2 + jr gooptionsMenu +changelevel: + jr optionsMenu + +notopselect: + cp K_EXIT + jr z,gomainMenu + ld a,b + jr optionsMenu + +Variation: + ld a,0 +Gametype =$-1 + ld hl,txtGame2 +NEXTtxtGame =$-2 + inc a + and 7 ;mod 8 + jr nz,okilydokily ld hl,txtGame +okilydokily: + ld (Gametype),a + ld de,$0204 + ld (_curRow),de + ld (CURtxtGame),hl call _puts + ld (NEXTtxtGame),hl + ld a,b + jp mainMenu - xor a -menudraw: - and 3 ;-1>>3; 4>>0 +menucall: push af - - ld h,0 - add a,4 - ld l,a + ld hl,$0004 + ld (_curRow),hl + ld a,' ' + call _putc + ld hl,$0005 ld (_curRow),hl - ld a,5 ;arrow call _putc - + pop af + push af ld h,0 - ld a,1 -Previous =$-1 add a,4 ld l,a ld (_curRow),hl - ld a,' ' + ld a,'*' call _putc - pop af - push af - ld (Previous),a -WKCP: + ld b,a +menukeys: halt \ halt - call GET_KEY - cp K_EXIT - jp z,Exit - cp K_ENTER - jr z,select - cp K_SECOND - jr z,select + call _getcsc + or a + jr z,menukeys cp K_UP jr nz,notup - pop af - dec a - jr menudraw +updown: + ld a,b + xor 1 + ld b,a + inc a ;nz + ret notup: cp K_DOWN - jr nz,WKCP - pop af + jr z,updown + cp K_ENTER + ret z + cp K_SECOND + ret ;z=select + +;----------------------------- +;-------- start game --------- +;----------------------------- + +ThePartyIsOn: + ld hl,Gametype + ld a,(hl) + add a,a + add a,(hl) + ld e,a + ld d,0 + ld hl,gamesdata + add hl,de + + or a + jr nz,notsingle inc a - jr menudraw + ld (nrworms),a +notsingle: + ld a,(hl) + ld (gameCar),a + push af -select: + and _datascore + ld de,$FF64 + jr z,setscorelimit + ld d,0 ;de=100 +setscorelimit: + ld (scorelimit),de + + inc hl + call _ldHLind pop af - ld b,a - or a ;1st - jr z,ThePartyIsOn - dec a ;2nd - jr z,Variation - dec a ;3rd - jp Exit + push hl + and _datalink + jr z,GameOver -Variation: - ld hl,$0805 - ld (_curRow),hl - ld a,0 -Gametype =$-1 - ld hl,txtGame2 -NEXTtxtGame =$-2 - inc a - and 3 - jr nz,okilydokily - ld hl,txtGame -okilydokily: - ld (Gametype),a +linkmatch: + call _clrWindow + ld a,WormVersion + call SendByte + jr c,host + +client: + ld hl,txtReceive call _puts - ld (NEXTtxtGame),hl - ld a,b - jr menudraw + call receive + cp WormVersion + ret nz + jr multiplayer -singleplayer: - inc a - ld (nrworms),a - ld de,LevelsS - jr GameOver +host: + ld hl,txtWaiting + call _puts + call receive + cp WormVersion + ret nz + call send + ld hl,SwapPos + ld (hl),$f6 -ThePartyIsOn: - ld a,(Gametype) - or a - jr z,singleplayer +multiplayer: ld a,2 ld (nrworms),a ld de,LevelsDM @@ -178,17 +305,41 @@ ThePartyIsOn: ;----------------------------- GameOver: - push de call _clrLCD - pop de - ld a,1 - ld (Level),a - ld hl,0 + xor a + ld (worm1+died),a + ld (worm2+died),a + ld (worm3+died),a + ld (worm4+died),a + ld h,a + ld l,a ld (worm1+score),hl ld (worm2+score),hl - ld a,3 - ld (worm1+lives),a - ld (worm2+lives),a + ld (worm3+score),hl + ld (worm4+score),hl + inc a + ld (worm1+delay),a + ld (worm2+delay),a + ld (worm3+delay),a + ld (worm4+delay),a + ld (Level),a + ld hl,worm1set+4 + ld de,worm1+lives + call _MOV5B ;9xld(de),(hl) + call _mov9b + ld hl,worm2set+4 + ld de,worm2+lives + call _MOV5B + call _mov9b + ld hl,worm3set+4 + ld de,worm3+lives + call _MOV5B + call _mov9b + ld hl,worm4set+4 + ld de,worm4+lives + call _MOV5B + call _mov9b + pop de StartLevel: ld a,(de) @@ -197,14 +348,35 @@ StartLevel: ld a,(de) ld (Speed),a inc de - ld a,15 + ld a,(de) ld (worm1+grow),a ld (worm2+grow),a -NextLife: - push de ; >> levelp old - ld b,2 - ld hl,worm1 + ld (worm3+grow),a + ld (worm4+grow),a + inc de + ld (thislevel),de + push de + ld hl,worm1set + ld de,worm1+head + call _MOV4B + ld hl,worm2set + ld de,worm2+head + call _MOV4B + ld hl,worm3set + ld de,worm3+head + call _MOV4B + ld hl,worm4set + ld de,worm4+head + call _MOV4B + pop de + + ld hl,worm1 + ld a,(gameCar) + and _datanextl + ld b,1 + jr nz,worminit + ld b,4 worminit: push bc ; >> 1 ld a,(de) @@ -229,18 +401,11 @@ worminit: inc hl ld (hl),a ;x2 - ld bc,20-5 + ld bc,(worm2-worm1)-5 add hl,bc pop bc ; << 0k djnz worminit - ld hl,Worm1 - ld (worm1+head),hl - ld (worm1+tail),hl - ld hl,Worm2 - ld (worm2+head),hl - ld (worm2+tail),hl - ;-------- draw level --------- ld a,(de) @@ -321,12 +486,7 @@ NoVertShift: jr z,NoLines DrawLines: push af ; >> 1 - ld d,(hl) - inc hl - ld e,(hl) - inc hl - ld a,(hl) - inc hl + call loaddrawdata push hl ; >> 2 ld l,(hl) ld h,a @@ -347,66 +507,73 @@ DrawLines: jr nz,DrawLines NoLines: + ld a,(hl) + inc hl + or a + jr z,noboxes +drawboxes: + push af + call loaddrawdata + push hl + ld l,(hl) + ld h,a + call drawbox + pop hl + inc hl + pop af + dec a + jr nz,drawboxes +noboxes: + ;----------------------------- push hl ; >> levelp new - - ld hl,0 - ld (_penCol),hl - ld hl,LivesMsg - call _vputs - ld a,(worm1+lives) - add a,'0' - call _vputmap - - ld a,40 - ld (_penCol),a - call _vputs ;scoremsg - ld a,100 - ld (_penCol),a - call _vputs - ld a,1 -Left =$-1 - call PutNum - ld ix,worm1 - call PutScore - + call showstats + ld a,(gameCar) + and _datafood + jr z,nofood call NewPea - - pop hl ; << levelp new - push hl ; >> levelp new + call DrawPea +nofood: ld bc,(worm1+pos) call DisplayField - ld hl,LevelMsg - ld a,7 - push hl ; >> 1 - ld h,a - ld l,4 - ld (_curRow),hl - ld hl,0FDE0h - ld de,0FDE1h - ld (hl),-1 - ld bc,0BFh + ld hl,$FDE0 + ld de,$FDE1 + ld (hl),%11111111 + ld bc,$BF ldir - pop hl ; << 0k + ld hl,4+(txtposReady*256) + ld (_curRow),hl set 3,(iy+5) + ld hl,txtReady call _puts - ld a,(Level) - cp 10 - jr c,LevelBelowTen - ld l,a - ld h,0 - call _divHLby10 - push af ; >> 1 - ld a,l - add a,'0' - call _putc - pop af ; << 0k -LevelBelowTen: - add a,'0' - call _putc res 3,(iy+5) + ld a,0 +gameCar =$-1 + and _datalink + jr z,SwapPos ;no link + xor a + ld (worm2+input),a + ld (worm2+left),a + ld (Speed),a + +SwapPos: ;$18 xx -> $F6 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 +initfinished: + ld b,0 ReadyDelay: halt @@ -431,11 +598,15 @@ Delay: NoDelay: ld ix,worm1 - call HandleWorm - ld ix,worm2 ld a,(nrworms) - cp 2 - call z,HandleWorm + ld b,a +handleworms: + push bc + call HandleWorm + ld bc,worm2-worm1 + add ix,bc + pop bc + djnz handleworms ;----------------------------- ;---------- keys ------------- @@ -456,66 +627,189 @@ HandleKeys: NotPaused: rla jp c,GameLoop -Exit2pop: - pop hl ; << levelp new -Exit1pop: - pop hl ; << levelp old - jr Exit - -Exit5pop: - pop hl - pop hl - pop hl - jr Exit2pop + jr Exit ;&& WormDead: - pop hl ; << call - pop hl ; << levelp new - ld hl,(worm1+head) - ld de,(worm1+tail) + ld h,(ix+tail+1) + ld l,(ix+tail) + push hl +removewormloop: + ld c,(hl) + inc hl + ld b,(hl) + inc hl + res resbit,h + push hl + call res4pixels + pop hl + ld a,(ix+head) + cp l + jr nz,removewormloop + ld a,(ix+head+1) + cp h + jr nz,removewormloop + + ;hl=ix+head + pop de ;ix+tail + or a sbc hl,de ld a,l rr h rra - ld (worm1+grow),a + inc a + ld (ix+grow),a - ld hl,(worm2+head) - ld de,(worm2+tail) - sbc hl,de - ld a,l - rr h - rra - ld (worm2+grow),a + push ix + ld de,10 + call DecScore + pop ix + + ld h,(ix+head+1) + ld l,(ix+head) + ld (ix+tail+1),h + ld (ix+tail),l + ld a,50 + ld (ix+delay),a + +thislevel =$+1 + ld de,0 + ld a,(de) + inc de + ld (ix+heading),a + ld a,(de) + ld (ix+pos),a + inc de + ld a,(de) + ld (ix+pos+1),a + + inc (ix+died) + dec (ix+lives) + ret nz ;HandleWorm done + ld a,(gameCar) + and _datalivel + ret z - ld a,(ix+lives) - dec a - ld (ix+lives),a - pop de ; << levelp old - jp nz,NextLife Exit: + ld sp,0 ;pop all +SpSave = $-2 + call _clrWindow + ld hl,txtGO + call _puts + ld hl,txtGame +CURtxtGame =$-2 + call _puts + ld de,0002 + ld (_curRow),de + call showLevel + ld de,$0B03 + ld (_curRow),de + ld hl,txtDied + call _puts + call _puts ;txtScore + xor a + ld (_curCol),a + + ld b,2 +nrworms =$-1 + ld hl,worm1+died +displayWormStats: + push bc + push hl + + ld bc,input-died + add hl,bc ;+input + xor a + cp (hl) + jr nz,NoLinkIndic + ld b,7 + inc hl ;+left + cp (hl) + jr z,hostLinkIndic + dec b +hostLinkIndic: + ld a,8 + ld (_curCol),a + ld a,b + call _putc + xor a + ld (_curCol),a + dec hl +NoLinkIndic: + inc hl + inc hl + inc hl ;+name + call _puts + + pop hl + push hl + ld a,13 + ld (_curCol),a + ld a,(hl) ;worm+died + push hl + call showA + pop hl + + ld a,16 + ld (_curCol),a + inc hl + call _ldHLind ;ld hl,(hl) + call showHL ;worm+score + + pop hl + ld bc,worm2-worm1 + add hl,bc + pop bc + djnz displayWormStats + +waitkey: + halt + halt + call _getcsc + cp K_ENTER + jp z,DisplayMenu +; cp K_EXIT + jr nz,waitkey + +;x123456789012345678901 +;1----- GAME OVER ----- +;2Multiplayer +;3Level 01 +;4 Died Score: +;5NameName 03 00070 +;6Worm#02 @ 05 00120 +;7Worm#03 15 00030 +;8Snaky @ 00 04820 + +ExitNoStats: +; ld a,(Eaten) + xor a + ld hl,HiScore + cp (hl) + jr c,NotNewHigh + ld (hl),a +NotNewHigh: -#if 0 - ld a,(Eaten) - ld hl,HiScore - cp (hl) - jr c,NotNewHigh - ld (hl),a - ld hl,_asapvar - rst 20h - rst 10h - call 460Bh - ld de,HiScore-_asm_exec_ram+2 + ld hl,_asapvar + rst 20h ;_ABS_MOV10TOOP1 + rst 10h ;_FINDSYM + call _swapt_ ;_ex_ahl_bde + ld de,4 add hl,de adc a,0 - call _load_ram_ahl - ld a,(HiScore) - ld (hl),a -NotNewHigh: -#endif + call _SET_ABS_DEST_ADDR + + xor a + ld hl,start + call _SET_ABS_SRC_ADDR + ld hl,end-start + call _SET_MM_NUM_BYTES + call _MM_LDIR + +; xor a +; ld (_asapvar+1),a res 4,(iy+9) -; ld sp,0 -SpSave = $-2 - jp _clrWindow + set 2,(iy+13) + jp _clrWindow ;----------------------------- ;----------- worm ------------ @@ -524,56 +818,53 @@ SpSave = $-2 inlink: ld a,0 sendbyte =$-1 - call SendByte - jr c,receivefirst + ld b,(ix+left) + dec b + jr z,receivefirst + call send call receive + ld l,a ret receivefirst: + push af call receive - ld a,(sendbyte) - call SendByte + ld l,a + pop af + push hl + call send + pop hl ret -receive: -receiveloop: - call GET_KEY - cp K_EXIT - jp z,Exit5pop - call TryReceiveByte - jr c,receiveloop - ld l,a - ret - -inkeys: +inkeys: ;use jp not call! out (1),a in a,(1) ld b,a and (ix+right) - jr z,NotRight + jr z,notright ld a,l add a,8 ld l,a -NotRight: +notright: ld a,b and (ix+left) - ret z + jr z,donediddelydone ld a,l sub 8 ld l,a - ret + jr donediddelydone ;------- handle worm --------- HandleWorm: + dec (ix+delay) + ret nz + inc (ix+delay) ld l,(ix+heading) ld a,(ix+input) or a - jr nz,keys + jr nz,inkeys call inlink - jr donelydone -keys: - call inkeys -donelydone: +donediddelydone: ld a,l ld (sendbyte),a ld (ix+heading),l @@ -593,30 +884,33 @@ Wormmove: add a,d ld d,a bit 7,(hl) - jr z,NotNegX + jr z,notnegX dec b -NotNegX: - jr nc,NotMoveX +notnegX: + jr nc,notmoveX inc b -NotMoveX: +notmoveX: ld a,l - add a,40h + add a,$40 ld l,a ld a,(hl) add a,a add a,e ld e,a bit 7,(hl) - jr z,NotNegY + jr z,notnegY dec c -NotNegY: - jr nc,NotMoveY +notnegY: + jr nc,notmoveY inc c -NotMoveY: ;bc=newpos +notmoveY: ;bc=newpos + ld (ix+pos2),e + ld (ix+pos2+1),d + ld (ix+pos),c + ld (ix+pos+1),b ;-check- pop hl ; << pos (old) - push de ; >> pos2 ld a,h sub b and 1 @@ -639,17 +933,19 @@ GotFour: call CheckPixel dec c rl d - pop de ; << pos2 - - ld (ix+pos2),e - ld (ix+pos2+1),d - ld (ix+pos),c - ld (ix+pos+1),b - jr nc,Drawworm + jp nc,Drawworm ;--------- worm hit ---------- Hitworm: + ld a,(gameCar) + ld h,a + and _datafood + jp z,WormDead + ld a,h + and _datahunt + call nz,checkhitotherworm + ld hl,0 PeaY =$-2 PeaX =$-1 @@ -661,43 +957,112 @@ PeaX =$-1 ld a,c sub l inc a - cp 4 - jp nc,WormDead - push bc ; >> 1 - call DrawPea - ld a,(ix+grow) - add a,15 - ld (ix+grow),a - call NewPea - ld de,10 + cp 4 + jp nc,WormDead + call DrawPea + ld a,(ix+grow) + add a,15 + ld (ix+grow),a + call NewPea + ld hl,Left + dec (hl) + push af + push ix + ld de,10 + call IncScore + pop ix + pop af + jr nz,NotNextLevel + ld a,(gameCar) + and _datafoodl + jr z,NotNextLevel + ld hl,Level + ld a,(hl) + inc (hl) + pop hl ; << call + pop hl ; << call + pop de ; << levelp new +; pop hl ; << levelp old + cp NUM_LEVELS + jp z,Exit + ld a,(gameCar) + and _datanextl + jp nz,StartLevel + jp Exit + +;----------------------------- + +checkhitotherworm: + .db $dd,$7d ;ld a,lx + cp worm2&255 + ret nz + + ld hl,worm1+tail + ld d,20 +nextotherwormbit: + ld a,b + sub (hl) + inc hl + inc a + cp 4 + jr nc,nothit1 ;no + ld a,c + sub (hl) + inc a + cp 4 + jr c,otherwormHIT ;yes +nothit1: + inc hl + res resbit,h + push bc + push de + push hl +; ld de,worm1+head +; call _cphlde + dec d + pop hl + pop de + pop bc + jr nz,nextotherwormbit + ret +otherwormHIT: + jp Exit + +checkhitlapline: + ld a,63 + sub b + jr z,nextlaphalf + inc a + ret nz +nextlaphalf: + ld a,c + and 32 ;>=32? + jr nz,nolap + cp (ix+reserv) + jr z,nolap + push ix + push bc + ld de,20 call IncScore - ld a,119 - ld (_penCol),a - ld hl,Left - dec (hl) - jr nz,NotNextLevel - ld hl,Level - ld a,(hl) - inc (hl) - pop bc ; << 0k - pop hl ; << call - pop de ; << levelp new - pop hl ; << levelp old - cp NUM_LEVELS - jp z,Exit - ld a,(Gametype) - or a - jp z,StartLevel - jp Exit + pop bc + pop ix + xor a +nolap: + ld (ix+reserv),a + ret NotNextLevel: - ld a,(hl) - call PutNum - pop bc ; << 0k ;-------- draw worm ---------- Drawworm: + ld c,(ix+pos) + ld b,(ix+pos+1) + + ld a,(gameCar) + and _datalaps + call nz,checkhitlapline + ld l,(ix+head) ld h,(ix+head+1) ld (hl),c @@ -733,6 +1098,7 @@ removetail: ld (ix+tail),l ld (ix+tail+1),h +res4pixels: call ResPixel inc b call ResPixel @@ -755,37 +1121,39 @@ Seed =$-2 domult16: add hl,hl rla - rl c - jr nc,noadd16 + rl c + jr nc,noadd16 add hl,de noadd16: djnz domult16 inc hl - ld (Seed),hl ;seed=(seed*7921+1) MOD 65536 - ld a,(FieldWidth) + ld (Seed),hl ;seed=(seed*7921+1) MOD 65536 + + ld a,(FieldWidth) add a,123 - cp h + cp h jr c,NewPea inc h inc h ld a,(FieldHeight) add a,51 - cp l - jr c,NewPea + cp l + jr c,NewPea inc l inc l - ld (PeaY),hl - ld d,2 - push hl ; >> 1 + ld (PeaY),hl + ld d,2 ;don't draw + push hl call CheckPea - pop hl ; << 0k + pop hl dec d - jr z,NewPea -DrawPea: - ld d,0 + jr z,NewPea + +DrawPea: ;hl=(PeaY) + ld d,0 ;draw CheckPea: - ld b,h - ld c,l + ld b,h + ld c,l call PeaPixel inc c call PeaPixel @@ -793,21 +1161,21 @@ CheckPea: call PeaPixel dec c PeaPixel: - push de ; >> 1 + push de call FindPixel - pop de ; << 0k - ld e,a - ld a,d - or a - ld a,e - jr z,DrawPeaPixel - and (hl) + pop de + ld e,a ;>> + ld a,d + or a + ld a,e ;<< + jr z,DrawPeaPixel ;d=0:draw + and (hl) ;pixel? ret z - ld d,1 + ld d,1 ;d=1:yes 2:no ret DrawPeaPixel: - xor (hl) - ld (hl),a + xor (hl) ;change pixel + ld (hl),a ret ;-------- pixelprocs --------- @@ -826,80 +1194,178 @@ SetPixel: ;at bc ret CheckPixel: ;at bc in d - push de ; >> 1 call FindPixel and (hl) - pop de ; << 0k ret z dec d ret FindPixel: ;bc to ahl + de gone - push de ; >> 1 - push bc ; >> 2 - ld a,b + 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 + ld e,a + ld d,offsets_table/256 + ld h,0 + ld l,c add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl - ld a,b + ld a,b and %11111000 rra rra rra - or l - ld l,a - ld a,(de) - ld de,ScrBuffer + or l + ld l,a + ld a,(de) + ld de,ScrBuffer add hl,de - pop bc ; << 1 - pop de ; << 0k + pop bc + pop de ret -;----------------------------- +;----------- score ----------- +DecScore: + ld h,(ix+score+1) + ld l,(ix+score) + or a + sbc hl,de + ret c + jr scorecommon IncScore: ld h,(ix+score+1) ld l,(ix+score) add hl,de +scorecommon: ld (ix+score+1),h ld (ix+score),l -PutScore: - ld de,_penCol - ld a,79 - ld (de),a - ld b,5 -DoPutScore: - push bc ; >> 1 - push de ; >> 2 - call _divHLby10 - call PutDigit - pop de ; << 1 - ld a,(de) - sub 8 - ld (de),a - pop bc ; << 0k - djnz DoPutScore + ld de,0 +scorelimit =$-2 + call _cphlde + jp nc,Exit + +showstats: + xor a + sbc hl,hl + ld (_penCol),hl + ld a,(nrworms) + ld b,a + ld ix,worm1 + ld a,(gameCar) + and _datanextl + jr nz,showstatsS +showstatloop: + push bc + push ix + call showstat + pop ix + ld de,worm2-worm1 + add ix,de + ld hl,_penCol + ld a,(hl) + add a,10 + ld (hl),a + pop bc + djnz showstatloop ret -PutNum: +showstat: + ld a,(gameCar) + and _datalivel + jr nz,showlives +showscore: + ld h,(ix+score+1) + ld l,(ix+score) + call _D_HL_DECI + jp _vputs +showlives: + ld a,(ix+lives) + add a,'0' + jp _vputmap + +showstatsS: + push ix + ld hl,txtLevel + call _vputs + ld a,(Level) + cp 10 + jr c,tilllevel9 ld l,a ld h,0 call _divHLby10 - push af ; >> 1 + push af ld a,l - call PutDigit - pop af ; << 0k -PutDigit: add a,'0' - jp _vputmap + call _vputmap + pop af +tilllevel9: + add a,'0' + call _vputmap + pop ix + + ld a,98 + ld (_penCol),a + call showscore + ld a,123 + ld (_penCol),a + call showlives +showleft: + ld a,31 + ld (_penCol),a + ld a,0 +Left =$-1 + push af + call _divAby10 + add a,'0' + call _vputmap + pop af + add a,'0' + call _vputmap + ld hl,txtLeft + jp _vputs + +showLevel: + ld hl,txtLevel + call _puts + ld a,(Level) +showA: + cp 10 + jr c,LevelBelowTen + ld l,a + ld h,0 + call _divHLby10 + push af + ld a,l + add a,'0' + call _putc + pop af +LevelBelowTen: + add a,'0' + jp _putc + +showHL: + call _D_HL_DECI + jp _puts + +_D_HL_DECI: + ld de,savestr+4 + ld b,5 +ldhld: + call _divHLby10 + add a,'0' + ld (de),a + dec de + djnz ldhld + ld hl,savestr + ret +savestr: + .db "00000",0 ;----------------------------- @@ -943,14 +1409,14 @@ NotMaxXScroll: rra rra rra - ld c,a - ld b,0 - ld de,DispBuffer + ld c,a + ld b,0 + ld de,DispBuffer pop af ; << 2 and %00000111 push af ; >> 3 - cp 6 - jr c,CopyScreen + cp 6 + jr c,CopyScreen inc c CopyScreen: add hl,bc @@ -964,12 +1430,12 @@ CopyScreenLoop: pop bc ; << 3 djnz CopyScreenLoop pop af ; << 2 - ld c,$b7 ;or a + ld c,$b7 ;or a Bit0: - jr nz,Bit1 + jr nz,Bit1 halt halt - jr AfterShiftDelay + jr AfterShiftDelay Bit1: dec a jr nz,Bit2 @@ -1027,7 +1493,7 @@ ShiftRight: add hl,bc ld b,57 ShiftRightLoop: - push bc ; >> 1 + push bc ld bc,-32 add hl,bc ex de,hl @@ -1038,20 +1504,20 @@ ShiftRightChunk: ld c,0 ShiftRightCounter = $-1 ShiftRowsLeft: - push hl ; >> 2 + push hl rla ld b,16 ShiftRowLeft: dec hl rl (hl) djnz ShiftRowLeft - pop hl ; << 1 + pop hl dec c jr nz,ShiftRowsLeft ld bc,-16 add hl,bc ex de,hl - pop bc ; << 0k + pop bc djnz ShiftRightLoop ret @@ -1068,6 +1534,7 @@ ShiftLeftSameByte: ex de,hl ld bc,-16 add hl,bc +NewSprite: ex de,hl ld b,57 ShiftLeftLoop: @@ -1102,157 +1569,299 @@ ShiftRowRight: Chunk: push hl ; >> 1 push de ; >> 2 - ld c,16 + ld c,16 add hl,bc - ld b,57 + ld b,57 ChunkScreen: push bc ; >> 3 - ld bc,-32 + ld bc,-32 add hl,bc - ex de,hl - ld a,(de) + ex de,hl + ld a,(de) call _SHRACC - ld b,16 + ld b,16 ChunkRow: dec hl rld djnz ChunkRow - ex de,hl + ex de,hl pop bc ; << 2 djnz ChunkScreen pop de ; << 1 pop hl ; << 0k - ld c,$37 ;scf + ld c,$37 ;scf + ret + +;----------- draw ------------ + +loaddrawdata: + ld d,(hl) + inc hl + ld e,(hl) + inc hl + ld a,(hl) + inc hl + ret + +Line: ;draw line from de to hl (doptions) + .db "Hunting ",0 ;4 + .db "Race ",0 ;5 + .db "CTF ",0 ;6 + .db "Domination",0 ;7 +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 +txtposReady = 7 +txtGO: .db "----- GAME OVER -----",0 +HiScore: .db 0 + +gamesdata: + +_datalink = %00000001 +_datalivel = %00000010 ;ix+lives=0 limit +_datafoodl = %00000100 ;left=0 limit +_datanextl = %00001000 ;next level if left=0 +_datafood = %00010000 ;food present +_datahunt = %00100000 +_datalaps = %01000000 ;give lap score +_datascore = %10000000 ;score>=100 limit + +datasingle: .db %00011110 + .dw LevelsS +datadeathm: .db %00000010 + .dw LevelsDM2 +datafoodm: .db %10010000 + .dw LevelsDM +datalinkm: .db %00000011 + .dw LevelsDM +datahuntin: .db %00110100 + .dw LevelsDM +datarace: .db %11000000 + .dw LevelsR +datactf: .db %00000000 + .dw LevelsDM +datadomin: .db %00000000 + .dw LevelsDM + + +setdata = 18 +resbit = 2 ;and%11111011 +worm1set: .dw $B000,$B000 ;10110000 + .db 3,0,%01111110,%10,%100 ;< > + .db "Worm #1",0 +worm2set: .dw $B800,$B800 ;10111000 + .db 3,0,%00111111,%10000,%1000 ;f1 f2 + .db "Worm #2",0 +worm3set: .dw $E800,$E800 ;11101000 ;$D748+$1000+ + .db 3,0,%01011111,%10,%100 ;sto , + .db "Worm #3",0 +worm4set: .dw $F000,$F000 ;11110000 + .db 3,0,%01111101,%10,%1 ;enter + + .db "Worm #4",0 +worm1 = $B400 +worm2 = $B430 +worm3 = $B460 +worm4 = $B490 +end: ;set: heading = 0 ;level* pos = 2 ;level* pos2 = 4 ;level -head = 6 ;level -tail = 8 ;level -grow = 10 ;level -lives = 13 ;game -score = 15 ;game -input = 17 ; -left = 18 ; -right = 19 ; - -Worm1 = $B000 -Worm2 = $B800 -resbit = 2 +grow = 6 ;level +died = 8 ;game +delay = 9 ;game +score = 10 ;game + +head = 12 ;level +tail = 14 ;level +lives = 16 ;game +reserv = 17 ;loop + ;race=lap +input = 18 ;& +left = 19 ;& +right = 20 ;& +name = 21 ;game Level =$+1 -DispBuffer =$+2 +DispBuffer =$+2 ;912 bytes ScrBuffer = $8200 ;32x256 bytes SinCosTable = $A200