#include "crash82.inc" ;replace this with ion.inc if that's what you use .db "Willy Wonder Worm",0 ProgS: ld hl,GRAPH_MEM-328 ld de,TEMP_MEM ld bc,72 ldir ld hl,GRAPH_MEM-256 ld de,TEXT_MEM2 ld bc,128 ldir ld hl,GRAPH_MEM-128 ld de,TEXT_MEM ld bc,128 ldir call start ld de,GRAPH_MEM-328 ld hl,TEMP_MEM ld bc,72 ldir ld de,GRAPH_MEM-256 ld hl,TEXT_MEM2 ld bc,128 ldir ld de,GRAPH_MEM-128 ld hl,TEXT_MEM ld bc,128 ldir ret start: ld hl,GRAPH_MEM push hl ld (hl),0 ld de,GRAPH_MEM+1 ld bc,767 ldir pop hl ld bc,23 push bc call Fill ld hl,GRAPH_MEM+744 pop bc call Fill ld hl,history ld bc,767 call Fill DrawSides: ld hl,GRAPH_MEM+(2*12) ld de,11 ld b,60 dsloop: ld (hl),%11000000 add hl,de ld (hl),%00000011 inc hl djnz dsloop call BuildTrigTables ld hl,$1000 ld (X),hl ld (Y),hl xor a ld (direction),a ld (score),a ld hl,11 ld (length),hl call NewPizza main: ld b,6 wait: ld a,%01111100 out (1),a in a,(1) bit 6,a ret z bit 2,a call z,rights bit 1,a call z,lefts djnz wait ld hl,history+765 ld de,history+767 ld bc,766 lddr ;shift all history call MoveHead call CheckCrash ld hl,(length) add hl,hl ld de,history add hl,de ld c,(hl) inc hl ld b,(hl) ld a,b inc a jr z,DontErase call ClearPixels DontErase: ld a,(Y+1) ld c,a ld (history),a inc hl ld a,(X+1) ld b,a ld (history+1),a ld hl,(X) ld b,h ld hl,(Y) ld c,h call SetPixels ROM_CALL(DISP_GRAPH) ei halt jp main rights: ld hl,direction inc (hl) ret lefts: ld hl,direction dec (hl) ret ClearPixels: ld e,02 DE1: push bc ld d,02 DE2: call ClearPixel inc b dec d jr nz,DE2 pop bc inc c dec e jr nz,DE1 ret CheckCrash: ld a,(Y+1) ld hl,history cp (hl) jr nz,CheckIt ld a,(X+1) inc hl cp (hl) ret z CheckIt: ld e,2 ld a,(X+1) ld b,a ld a,(Y+1) ld c,a call CheckPixel inc b call CheckPixel inc c call CheckPixel dec b call CheckPixel bit 7,e ret z dead: ;check if hit pea ld a,(X+1) ld b,a ld a,(px) sub b add a,3 sub 7 jr nc,dead2 ld a,(Y+1) ld b,a ld a,(py) sub b add a,3 sub 7 jr nc,dead2 ;player hit pea ld a,(px) ;clear pea ld b,a ld a,(py) ld c,a call ClearPixels ld hl,(length) ;increase length ld bc,9 add hl,bc ld (length),hl ld a,(score) ;increase score inc a cp 33 jr z,dead2 goon: ld (score),a jr NewPizza dead2: pop hl ROM_CALL(CLEARLCD) ld a,(score) ld l,a ld h,0 ld b,2 ld de,ScoreText convertscoretotext: call UNPACK_HL add a,48 ld (de),a dec de djnz convertscoretotext ld hl,Done ld de,$0302 ld (CURSOR_ROW),de ROM_CALL(D_ZT_STR) OTH_PAUSE call GET_KEY cp 9 jr nz,OTH_PAUSE ret NewPizza: ld a,r srl a srl a cp 46 jr c,NP_flop ld d,a ld a,64 sub d NP_flop: add a,a ld b,a ld a,r srl a srl a ld c,a call CheckPixel jr nz,NewPizza inc b call CheckPixel jr nz,NewPizza inc c call CheckPixel jr nz,NewPizza dec b call CheckPixel jr nz,NewPizza ld hl,px ld (hl),b inc hl ld (hl),c jp SetPixels MoveHead: ld a,(direction) ld b,a ld a,64 sub b ld hl,SinCosTable add a,l ld l,a adc a,h sub l ld h,a ld c,(hl) ;get decimal call extendBC ld hl,(X) add hl,bc add hl,bc ld (X),hl ld a,(direction) ld hl,SinCosTable add a,l ld l,a adc a,h sub l ld h,a ld c,(hl) ;get decimal call extendBC ld hl,(Y) add hl,bc add hl,bc ld (Y),hl ret SetPixels: ld e,02 SP1: push bc ld d,02 SP2: call SetPixel inc b dec d jr nz,SP2 pop bc inc c dec e jr nz,SP1 ret SetPixel: ;draw 4 pixels push bc call FindPixel or (hl) ld (hl),a pop bc ret ClearPixel: push bc call FindPixel cpl and (hl) ld (hl),a pop bc ret CheckPixel: push bc call FindPixel and (hl) pop bc ret z dec e ret extendBC: ld b,0 bit 7,c ret z ld b,255 ret Fill: ld d,h ld e,l inc de ld (hl),$FF ldir ret FindPixel: push de ld a,c add a,a add a,a ld e,a ld d,0 ld l,a ld h,d ld a,b rr a add hl,de rr a add hl,de rr a add a,l ld l,a adc a,h sub l ld h,a ld a,b and 7 ld de,offsets add a,e ld e,a adc a,d sub e ld d,a ld a,(de) ld de,GRAPH_MEM add hl,de pop de ret offsets: .db 128,64,32,16,8,4,2,1 #include Trigtab.asm ;sine table data ;aliases! ;---------- history = APD_BUF SinCosTable = GRAPH_MEM-328 TEMP_MEM: .ds 72 X = OP1 Y = OP1+2 direction = OP1+4 length = OP1+5 score = OP1+7 ;byte py = OP1+10 px = OP1+9 level = OP1+11 Done: .db "Score: ",0,0,0 ScoreText = $ - 2 .end