From: Matthew Shepcar Date: Wed, 30 Dec 1998 21:49:48 +0000 (+0100) Subject: wonderworm (3 levels (lines), greyscale, vertical scrolling) X-Git-Url: http://git.shiar.nl/wormy.git/commitdiff_plain/fdf8f011d4a41fb2932efc938a282f263e164f46 wonderworm (3 levels (lines), greyscale, vertical scrolling) --- diff --git a/line.asm b/line.asm new file mode 100644 index 0000000..0c9cbfa --- /dev/null +++ b/line.asm @@ -0,0 +1,95 @@ +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/m.bat b/m.bat new file mode 100644 index 0000000..4205220 --- /dev/null +++ b/m.bat @@ -0,0 +1,14 @@ +@echo off +copy *.asm ..\asm86 +cd..\asm86 +tasm -80 -b worm.asm worm +if errorlevel 1 goto asmerr +prgm86 worm +copy worm.86p ..\worm +cd..\ti8xemu2 +copy blank.86 default.86 +addvar86 ..\worm\worm.86p +copy default.86 worm.bin +ti8xemu 86 /grey /speed 10 +:asmerr +cd..\worm diff --git a/worm.asm b/worm.asm index 85ffafb..0abad60 100644 --- a/worm.asm +++ b/worm.asm @@ -1,7 +1,7 @@ -; -- Peaworm v0.9 -- +; -WonderWorm--v0.9- ; by Matthew Shepcar -; 28th December 1998 +; 30th December 1998 #include asm86.h #include ti86asm.inc @@ -9,63 +9,201 @@ .org _asm_exec_ram - nop - jp Start + nop + jp Start .dw 0,WormMsg Start: call _runindicoff call _clrLCD + call BuildTrigTables + + ld hl,0FC00h + ld de,GreyBuf + ld bc,400h + ldir + + ld hl,IHandler + ld bc,IHandlerEnd-IHandler + ld de,0BCBCh + ldir + ld hl,0BD00h + ld (hl),d + ld de,0BD01h + ld a,d + ld bc,256 + ldir + ld i,a + im 2 + ld a,r ld (Seed),a - ld hl,0FC70h + ld hl,0 + ld (Score),hl + ld a,1 + ld (Level),a + ld a,3 + ld (Lives),a + ld hl,Levels + +StartLevel: + ld a,(hl) + ld (Left),a + inc hl + ld a,(hl) + ld (Speed),a + inc hl + ld a,25 +NextLife: + ld (GrowAmt),a push hl - ld de,0FC71h + ld d,(hl) + inc hl + ld e,(hl) + inc hl + ld a,(hl) + inc hl + ld (Heading),a + push de + ld a,(hl) + inc hl + sub 57 + ld (FieldHeight),a + add a,57-5 + push hl + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + ex de,hl + + ld hl,ScrBuffer + push hl + push de + ld de,ScrBuffer+1 ld bc,31 ld (hl),-1 ldir inc hl ld (hl),192 - ld l,9*16+15 + inc hl + ld b,14 +ClearLine: + ld (hl),c + inc hl + djnz ClearLine ld (hl),3 inc hl ex de,hl - ld bc,52*16 + pop bc ldir pop hl ld c,32 ldir + pop hl - ld (_penCol),de - ld hl,WormMsg + ld a,(hl) + inc hl + or a + jr z,NoLines +DrawLines: + push af + ld d,(hl) + inc hl + ld e,(hl) + inc hl + ld a,(hl) + inc hl + push hl + ld l,(hl) + ld h,a + call Line + inc d + inc h + call Line + inc e + inc l + call Line + dec d + dec h + call Line + pop hl + inc hl + pop af + dec a + jr nz,DrawLines +NoLines: + push hl + + ld hl,ScrBuffer + ld de,ScrBuffer+BufSize + ld bc,BufSize + ldir + + ld hl,0 + ld (_penCol),hl + ld hl,LivesMsg call _vputs - ld a,48 + ld a,(Lives) + add a,'0' + call _vputmap + + ld a,40 ld (_penCol),a - call _vputs - ld a,91 + call _vputs ;scoremsg + ld a,100 ld (_penCol),a call _vputs - ld a,(hl) + ld a,(Left) call PutNum - call BuildTrigTables + call PutScore call NewPea - ld a,25 - ld (GrowAmt),a + + xor a + call DisplayField + ld hl,LevelMsg + ld a,7 + call DispMsg + ld a,(Level) + add a,'0' + call _putc + res 3,(iy+5) + + xor a +ReadyDelay: + halt + dec a + jr nz,ReadyDelay + ld hl,(HeadPos) ld (TailPos),hl - xor a - ld (Heading),a - ld (Eaten),a - ld bc,0400Ah - ld d,a - ld e,a + pop hl + pop bc + push hl + ld de,0 GameLoop: - ld a,8 + + ld a,c + sub 29 + jr nc,NotMinScroll + xor a +NotMinScroll: + cp 43 +FieldHeight =$-1 + jr c,NotMaxScroll + ld a,(FieldHeight) +NotMaxScroll: + call DisplayField + + ld a,5 +Speed =$-1 Delay: halt dec a @@ -157,13 +295,13 @@ GotFour: rl d jr nc,WormNotCrashed ld hl,0 -PeaX =$-2 -PeaY =$-1 +PeaY =$-2 +PeaX =$-1 ld a,b sub h inc a cp 4 - jr nc,WormDead + jp nc,WormDead ld a,c sub l inc a @@ -176,16 +314,30 @@ GrowAmt =$-1 add a,15 ld (GrowAmt),a call NewPea - ld a,70 + ld de,10 + call IncScore + ld a,119 ld (_penCol),a - ld hl,Eaten + ld hl,Left + dec (hl) + jr nz,NotNextLevel + ld hl,Level inc (hl) + pop bc + pop de + pop hl + pop de + jp StartLevel + +NotNextLevel: ld a,(hl) call PutNum pop bc WormNotCrashed: push bc + ld a,3 +WormCol =$-1 call SetPixel inc b call SetPixel @@ -194,6 +346,9 @@ WormNotCrashed: dec b call SetPixel +; xor 2 +; ld (WormCol),a + ld hl,GrowAmt dec (hl) jr nz,GrowWorm @@ -224,6 +379,7 @@ GrowWorm: jr c,NotPaused call _getky WaitUnpause: + halt call _getky or a jr z,WaitUnpause @@ -236,6 +392,19 @@ NotPaused: push hl WormDead: pop de + pop hl + ld hl,(HeadPos) + ld de,(TailPos) + sbc hl,de + ld a,l + rr h + rra + ld hl,Lives + dec (hl) + pop hl + jp nz,NextLife + +#if 0 ld a,(Eaten) ld hl,HiScore cp (hl) @@ -252,6 +421,11 @@ WormDead: ld a,(HiScore) ld (hl),a NotNewHigh: +#endif + + im 1 + ld a,03Ch + out (0),a call _clrScrn call _homeup jp _getky @@ -260,17 +434,20 @@ NewPea: call Random ld a,h and 7Fh - cp 7Bh + cp 77h jr nc,NewPea - add a,2 + add a,3 ld h,a + ld a,(FieldHeight) + add a,57-12 + ld b,a ld a,l - and 3Fh - cp 30h + and 7Fh + cp b jr nc,NewPea - add a,12 + add a,5 ld l,a - ld (PeaX),hl + ld (PeaY),hl ld d,2 push hl call CheckPea @@ -313,13 +490,13 @@ Seed =$-2 ld a,7921 & 255 ld bc,1000h+(7921/256) domult16: - add hl,hl - rla + add hl,hl + rla rl c - jr nc,noadd16 - add hl,de + jr nc,noadd16 + add hl,de noadd16: - djnz domult16 + djnz domult16 inc hl ld (Seed),hl ;seed=(seed*7921+1) MOD 65536 ld a,h @@ -328,20 +505,57 @@ noadd16: ResPixel: call FindPixel cpl + ld d,a + and (hl) + ld (hl),a + ld a,d + ld de,BufSize + add hl,de and (hl) ld (hl),a ret SetPixel: + push bc + push af + push af call FindPixel + pop de + ld e,a + rr d + jr c,SetGrey1 + cpl + and (hl) + ld (hl),a +SetGrey1: + or (hl) + ld (hl),a + ld bc,BufSize + add hl,bc + ld a,e + rr d + jr c,SetGrey2 + cpl + and (hl) + ld (hl),a +SetGrey2: or (hl) ld (hl),a + pop af + pop bc ret CheckPixel: push de call FindPixel + push af + and (hl) + ld de,BufSize + add hl,de + ld e,a + pop af and (hl) + or e pop de ret z dec d @@ -369,13 +583,36 @@ FindPixel: or b ld l,a ld a,(de) - dec h - dec h - dec h - dec h + ld de,ScrBuffer + add hl,de pop bc ret +IncScore: + ld hl,(Score) + add hl,de + ld (Score),hl +PutScore: + ld hl,-1 + ld (_curRow),hl + ld a,63 + ld (_penCol),a + ld hl,(Score) + xor a + call 4A33h + dec hl + ld b,5 +DoPutScore: + ld a,(hl) + inc hl + cp 32 + jr nz,NotZeroDigit + ld a,'0' +NotZeroDigit: + call _vputmap + djnz DoPutScore + ret + PutNum: ld l,a ld h,0 @@ -391,15 +628,103 @@ PutDigit: offsets_table: .db 128,64,32,16,8,4,2,1 +IHandler: + exx + ex af,af' + in a,(3) + bit 1,a + jr z,notvbl + ld hl,GreyCounter + inc (hl) + ld a,(hl) + cp 3 + ld a,3Ch + jr nz,notpage1 + ld (hl),0 + ld a,(GreyBuf/256)-0C0h +notpage1: + out (0),a +notvbl: + jp 3Ah +IHandlerEnd: +GreyCounter .db 0 + +DisplayField: + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push bc + push de + ld de,ScrBuffer + add hl,de + ld de,0FC70h + ld bc,00390h + ldir + ld de,BufSize-390h + add hl,de + ld de,GreyBuf+70h + ld bc,00390h + ldir + pop de + pop bc + ret + +DispMsg: + push hl + ld h,a + ld l,4 + ld (_curRow),hl + ld hl,0FDE0h + ld de,0FDE1h + ld (hl),-1 + ld bc,0BFh + ldir + pop hl + set 3,(iy+5) + jp _puts + + +Levels: + .db 5,7 ;5 peas, speed 7 + .db 64,4,0 ;x,y,d + .db 57 ;field height + .db 0 ;no additional lines + + .db 8,6 + .db 4,14,40h + .db 57 + .db 1 + .db 28,28,100,28 + + .db 99,5 + .db 4,14,40h + .db 100 + .db 2 + .db 28,28,28,72 + .db 100,28,100,72 + #include trigtab.asm +#include line.asm -WormMsg .db "Peaworm!",0 -PeasMsg .db "Eaten: 00",0 -HiMsg .db "Hiscore: ",0 +WormMsg .db "Wonderworm!",0 +LevelMsg .db "Level ",0 +LivesMsg .db "Lives: ",0 +ScoreMsg .db "Score: ",0 +LeftMsg .db "Food: ",0 HiScore .db 0 Varname .db 4,"worm" -Eaten =$ -SinCosTable =09000h +Left =$ +Lives =$+1 +Level =$+2 +Score =$+3 + +SinCosTable =09E00h +ScrBuffer =8200h +BufSize =0A00h +GreyBuf =0F400h .end