X-Git-Url: http://git.shiar.net/wormy.git/blobdiff_plain/8fff5ad3c104f2936efec10bd4278491321865a1..daa6847068e3ae9b0201187f7f619feb27229385:/worm.asm?ds=inline diff --git a/worm.asm b/worm.asm index 8d0bab1..6c84154 100644 --- a/worm.asm +++ b/worm.asm @@ -1,7 +1,7 @@ ; Title : Worm ; Version : 0.92 ; Release Date : soon (I hope) -; Filename : worm.86p +; Filename : worm.86p (3404) ; Author(s) : Shiar ; Email Address : shiar@mailroom.com ; ICQ UIN : #43840958 @@ -16,7 +16,7 @@ ;----------- TO-DO ----------- ;----------------------------- -; Shiar 23.I .00 +; Shiar 4.II.00 ;Feel like doing something? (name indicates who's working on it) ; * linkplay TESTING! (+faster) @@ -26,7 +26,6 @@ ; * 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? @@ -34,7 +33,7 @@ ; * fix linedraw procedure ; * save hiscore -;1) Shiar: working on a new pickup-system allowing more than one "food" and different pickup-handling +;1) Working on a new pickup-system allowing more than one "food" and different pickup-handling #include "TI86.inc" @@ -63,9 +62,9 @@ WormIcon: .db %11000011,%10000000 Start: - ld (SpSave),sp + ld (SpSave),sp call _runIndicOff -; call _flushAllMenus + call _flushAllMenus call _clrLCD res 2,(iy+13) ;appAutoScroll @@ -76,25 +75,25 @@ Start: ;----- build trig tables ----- ;----------------------------- - ld hl,TrigPrecalc - ld de,SinCosTable + ld hl,TrigPrecalc + ld de,SinCosTable push de ; >> 1 - ld bc,65 + ld bc,65 ldir dec hl - ld b,63 + ld b,63 MirrorSineWave: dec hl - ld a,(hl) - ld (de),a + ld a,(hl) + ld (de),a inc de djnz MirrorSineWave pop hl ; << 0k - ld b,128+64 + ld b,128+64 NegativeSineWave: xor a sub (hl) - ld (de),a + ld (de),a inc hl inc de djnz NegativeSineWave @@ -126,7 +125,7 @@ select: ld a,b or a jr nz,gooptionsMenu - jp ThePartyIsOn + jp LetsGetThisPartyOn notselect cp K_EXIT jp z,ExitNoStats @@ -238,7 +237,7 @@ notup: ;-------- start game --------- ;----------------------------- -ThePartyIsOn: +LetsGetThisPartyOn: ld hl,Gametype ld a,(hl) add a,a @@ -258,7 +257,7 @@ notsingle: push af and _datascore - ld de,$FF64 + ld de,$FF64 ;virt.infinate jr z,setscorelimit ld d,0 ;de=100 setscorelimit: @@ -273,8 +272,14 @@ setscorelimit: linkmatch: call _clrWindow + + +; in a,(7) +; and %11 +; cp %11 ld a,WormVersion - call SendByte +; jr nz,host + call send jr c,host client: @@ -306,22 +311,19 @@ multiplayer: GameOver: call _clrLCD - 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 (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 hl,0 + ld (worm1+died),hl +;+died=0 \ +score1=0 + ld (worm2+died),hl + ld (worm3+died),hl + ld (worm4+died),hl + inc h + ld (worm1+score+1),hl +;+score2=0 \ +delay=1 + ld (worm2+score+1),hl + ld (worm3+score+1),hl + ld (worm4+score+1),hl + ld a,l ld (Level),a ld hl,worm1set+4 ld de,worm1+lives @@ -355,6 +357,13 @@ StartLevel: ld (worm4+grow),a inc de + ld a,(gameCar) + and _datahunt + jr z,nohunter + ld a,huntersize + ld (worm2+grow),a +nohunter: + ld (thislevel),de push de ld hl,worm1set @@ -587,6 +596,22 @@ GameLoop: ld bc,(worm1+pos) call DisplayField + ld a,1 +flashtime =$-1 + dec a + jr z,noflash + ld (flashtime),a + ld hl,$fc00+(16*7) +screeninvertloop: + ld a,(hl) + cpl + ld (hl),a + inc hl + xor a + cp h + jr nz,screeninvertloop +noflash: + ld a,0 Speed =$-1 or a @@ -630,6 +655,9 @@ NotPaused: jr Exit ;&& WormDead: + ld a,2 + ld (flashtime),a + ld h,(ix+tail+1) ld l,(ix+tail) push hl @@ -651,18 +679,17 @@ removewormloop: ;hl=ix+head pop de ;ix+tail - or a + ld a,(gameCar) + and _datamulti + jr nz,safewormsizedone +; or a sbc hl,de ld a,l rr h rra inc a ld (ix+grow),a - - push ix - ld de,10 - call DecScore - pop ix +safewormsizedone: ld h,(ix+head+1) ld l,(ix+head) @@ -684,6 +711,10 @@ thislevel =$+1 inc (ix+died) dec (ix+lives) + push af + ld de,10 + call DecScore + pop af ret nz ;HandleWorm done ld a,(gameCar) and _datalivel @@ -751,7 +782,7 @@ NoLinkIndic: ld a,16 ld (_curCol),a - inc hl + inc hl ;worm+score call _ldHLind ;ld hl,(hl) call showHL ;worm+score @@ -967,22 +998,19 @@ PeaX =$-1 ld hl,Left dec (hl) push af - push ix ld de,10 call IncScore - pop ix pop af - jr nz,NotNextLevel + jr nz,still_alive_not_dead ld a,(gameCar) and _datafoodl - jr z,NotNextLevel + jr z,still_alive_not_dead 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) @@ -996,17 +1024,17 @@ checkhitotherworm: .db $dd,$7d ;ld a,lx cp worm2&255 ret nz - - ld hl,worm1+tail - ld d,20 +ThisIsJustASillyUselessLabel: + ld hl,(worm1+tail) + ld de,(worm1+head) nextotherwormbit: - ld a,b + ld a,c sub (hl) inc hl inc a cp 4 jr nc,nothit1 ;no - ld a,c + ld a,b sub (hl) inc a cp 4 @@ -1014,19 +1042,9 @@ nextotherwormbit: 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 + call _cphlde jr nz,nextotherwormbit ret -otherwormHIT: - jp Exit checkhitlapline: ld a,63 @@ -1036,26 +1054,36 @@ checkhitlapline: ret nz nextlaphalf: ld a,c - and 32 ;>=32? + and 32 ;y>=32? jr nz,nolap cp (ix+reserv) jr z,nolap - push ix push bc ld de,20 call IncScore pop bc - pop ix xor a nolap: ld (ix+reserv),a ret -NotNextLevel: +otherwormHIT: + push ix + ld de,10 + call IncScore + ld ix,worm1 + call WormDead + pop ix + pop bc +still_alive_not_dead: ;-------- draw worm ---------- Drawworm: + ld a,(gameCar) + and _datahunt + call nz,HuntingTimeScore + ld c,(ix+pos) ld b,(ix+pos+1) @@ -1200,7 +1228,41 @@ CheckPixel: ;at bc in d dec d ret -FindPixel: ;bc to ahl + de gone +;------------------------------------------------------ +; CLEM's FIND_PIXEL +; by Clem +; +; 131 cycles 28 bytes (b,c) to hl:a destroyes: none +;------------------------------------------------------ + +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 @@ -1210,11 +1272,11 @@ FindPixel: ;bc to ahl + de gone 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 + add hl,hl ;2y + add hl,hl ;4y + add hl,hl ;8y + add hl,hl ;16y + add hl,hl ;32y ld a,b and %11111000 rra @@ -1231,17 +1293,25 @@ FindPixel: ;bc to ahl + de gone ;----------- score ----------- -DecScore: +HuntingTimeScore: + .db $dd,$7d ;ld a,lx + cp worm2&255 + ret z ;=worm#2 + dec (ix+reserv) + ret nz + ld de,10 + +IncScore: ld h,(ix+score+1) ld l,(ix+score) - or a - sbc hl,de - ret c + add hl,de jr scorecommon -IncScore: +DecScore: ;&&& ld h,(ix+score+1) ld l,(ix+score) - add hl,de + or a + sbc hl,de + ret c scorecommon: ld (ix+score+1),h ld (ix+score),l @@ -1251,8 +1321,9 @@ scorelimit =$-2 jp nc,Exit showstats: - xor a - sbc hl,hl + push ix + ld h,0 + ld l,h ld (_penCol),hl ld a,(nrworms) ld b,a @@ -1262,9 +1333,9 @@ showstats: jr nz,showstatsS showstatloop: push bc - push ix +; push ix call showstat - pop ix +; pop ix ld de,worm2-worm1 add ix,de ld hl,_penCol @@ -1273,6 +1344,7 @@ showstatloop: ld (hl),a pop bc djnz showstatloop + pop ix ret showstat: @@ -1283,16 +1355,19 @@ showscore: ld h,(ix+score+1) ld l,(ix+score) call _D_HL_DECI - jp _vputs + jr __vputs showlives: ld a,(ix+lives) add a,'0' - jp _vputmap +__vputmap: + push ix + call _vputmap + pop ix + ret showstatsS: - push ix ld hl,txtLevel - call _vputs + call __vputs ld a,(Level) cp 10 jr c,tilllevel9 @@ -1302,12 +1377,11 @@ showstatsS: push af ld a,l add a,'0' - call _vputmap + call __vputmap pop af tilllevel9: add a,'0' - call _vputmap - pop ix + call __vputmap ld a,98 ld (_penCol),a @@ -1323,12 +1397,17 @@ Left =$-1 push af call _divAby10 add a,'0' - call _vputmap + call __vputmap pop af add a,'0' - call _vputmap + call __vputmap ld hl,txtLeft - jp _vputs + pop ix +__vputs: + push ix + call _vputs + pop ix + ret showLevel: ld hl,txtLevel @@ -1736,6 +1815,8 @@ boxloopx: ;----------------------------- ;----------- link ------------ ;----------------------------- +#ifdef 0 +TIMEOUT = $1200 send: push af ;ld b,a @@ -1769,6 +1850,7 @@ ReceiveByteCont: ReceiveByte: call LinkPrep ReceiveBits: + ld de,TIMEOUT WaitRecBit: call checklink jr z,LinkFailed @@ -1786,6 +1868,7 @@ ReceiveLow: ld (AckBit),a ld a,d out (7),a + ld de,TIMEOUT WaitAckRec: call checklink cp 0 @@ -1818,12 +1901,14 @@ sendbit: ld a,D0hD1l sendselected: out (7),a + ld de,TIMEOUT waitacknowledge: call checklink jr nz,waitacknowledge SendAcked: ld a,D0hD1h out (7),a + ld de,TIMEOUT waitsendready: call checklink cp %11 @@ -1845,6 +1930,11 @@ linkerror: jp Exit checklink: + pop hl + dec de + ld a,d + or e + jr z,LinkFailed ld a,$BF ;key call _readkeypad bit 6,a @@ -1852,6 +1942,7 @@ checklink: in a,(7) and %11 + jp (hl) ret _readkeypad: @@ -1862,6 +1953,97 @@ _readkeypad: out (1),a pop af ret +#endif + +send: +SendByte: + in a,(7) + and %11 + jr z,nolink + ld b,8 +sendloop: + ld de,$8000 + rl c + ld a,%11010100 + jr nc,sendbit + ld a,%11101000 +sendbit: + out (7),a +sendwait1: + call checklink + in a,(7) + and %11 + jr nz,sendwait1 + ld a,%11000000 + out (7),a +sendwait2: + call checklink + in a,(7) + and %11 + cp %11 + jr nz,sendwait2 + djnz sendloop + xor a + ret +timeout: + scf + ret + + +receive: + in a,(7) + and %11 + jr z,nolink + cp %11 + jr z,receive + ld b,8 +receiveloop: + ld de,$8000 +receivewait1: + call checklink + in a,(7) + and %11 + cp %11 + jr z,receivewait1 + rra + rl c + rra + ld a,%11010100 + jr nc,receivebit + ld a,%11101000 +receivebit: + out (7),a +receivewait2: + call checklink + in a,(7) + and %11 + jr z,receivewait2 + ld a,%11000000 + out (7),a + djnz receiveloop + xor a + ret + +checklink: + dec de + ld a,d + or e + jr z,timeout + ld a,$BF ;key + call _readkeypad + bit 6,a + jr z,timeout + ret +_readkeypad: + out (1),a + in a,(1) + push af + ld a,%11111111 + out (1),a + pop af + ret +nolink: + jp Exit ;----------------------------- ;---------- levels ----------- @@ -1894,11 +2076,24 @@ LevelsR: .db 1 .db 8,29,32,20 +LevelsH: + + .db 8,5,5 +huntersize = 31 + .db $40,28,2,$C0,28,125, $00,2,63,$80,54,63 + .db 128,57 + .db 0 + .db 4 + .db 4,19,16,14 + .db 4,19,80,14 + .db 4,19,16,34 + .db 4,19,80,34 + NUM_LEVELS = 9 LevelsS: - .db 5,4,15 ;5 peas, speed 5 + .db 5,4,15 ;peas,speed,begin_size .db 0,2,63 ;d,y,x .db 128,57 ;field width, height .db 0 ;no additional lines @@ -2033,6 +2228,7 @@ HiScore: .db 0 gamesdata: _datalink = %00000001 +_datamulti = %00000010 _datalivel = %00000010 ;ix+lives=0 limit _datafoodl = %00000100 ;left=0 limit _datanextl = %00001000 ;next level if left=0 @@ -2050,7 +2246,7 @@ datafoodm: .db %10010000 datalinkm: .db %00000011 .dw LevelsDM datahuntin: .db %00110100 - .dw LevelsDM + .dw LevelsH datarace: .db %11000000 .dw LevelsR datactf: .db %00000000 @@ -2061,16 +2257,16 @@ datadomin: .db %00000000 setdata = 18 resbit = 2 ;and%11111011 -worm1set: .dw $B000,$B000 ;10110000 +worm1set: .dw $B000,$B000 ;%10110000 .db 3,0,%01111110,%10,%100 ;< > .db "Worm #1",0 -worm2set: .dw $B800,$B800 ;10111000 +worm2set: .dw $B800,$B800 ;%10111000 .db 3,0,%00111111,%10000,%1000 ;f1 f2 .db "Worm #2",0 -worm3set: .dw $E800,$E800 ;11101000 ;$D748+$1000+ +worm3set: .dw $E800,$E800 ;%11101000 ;$D748+$1000+ .db 3,0,%01011111,%10,%100 ;sto , .db "Worm #3",0 -worm4set: .dw $F000,$F000 ;11110000 +worm4set: .dw $F000,$F000 ;%11110000 .db 3,0,%01111101,%10,%1 ;enter + .db "Worm #4",0 worm1 = $B400 @@ -2084,14 +2280,15 @@ pos = 2 ;level* pos2 = 4 ;level grow = 6 ;level died = 8 ;game -delay = 9 ;game -score = 10 ;game +score = 9 ;game +delay = 11 ;game head = 12 ;level tail = 14 ;level lives = 16 ;game reserv = 17 ;loop - ;race=lap + ;race:lap + ;hunt:time input = 18 ;& left = 19 ;& right = 20 ;& @@ -2100,11 +2297,11 @@ name = 21 ;game Level =$+1 DispBuffer =$+2 ;912 bytes -ScrBuffer = $8200 ;32x256 bytes -SinCosTable = $A200 +ScrBuffer = $8000 ;-$A1FF (32x256) +SinCosTable = $A200 ;-$A300 (4x64) ;----------------------------- ;----------- end ------------- ;----------------------------- -.end +.end \ No newline at end of file