;z80 ;zx-spectrum ;assembler ; haiku (c) Gasman 2005 ; fountain.asm: fountain plotter using the bob demo principle fountain ; clear backbuffers (16 x 96 x 8 = 12288) ld hl,bob_buffer ld de,bob_buffer+1 ld (hl),l ld bc,0x2fff ldir ld hl,0 ld (ell_trsin1 + 1),hl ld (ell_trsin2 + 1),hl xor a ld (ell_radius1 + 1),a ld (ell_sine + 1),a ld a,64 ld (ell_cosine + 1),a ld b,48 bob_cycle push bc ld b,8 bob_frame push bc ld a,(ell_radius1+1) ; increase radius linearly inc a jp z, no_ell_plot ; if radius is already too big, skip plotting ld (ell_radius1 + 1),a srl a ld (ell_radius2 + 1),a ; determine new y translation for ellipse ell_trsin1 ld hl,0 ld de,0x0100 add hl,de ld (ell_trsin1 + 1),hl ld l,h ld h,sine / 0x100 ld c,(hl) ell_trsin2 ld hl,0 ld de,0x0180 add hl,de ld (ell_trsin2 + 1),hl ld l,h ld h,sine / 0x100 ld a,(hl) add a,c ; result will be 0-ff ; find modulus and scale to 0-3f + delta ; (+ delta because ellipse will have negative points) jp p,ell_no_neg neg ell_no_neg srl a add a,0x08 ld (ell_ytrans + 1),a ; plot new ellipse ld b,16 ell_point push bc ell_sine ld hl,sine ld a,l add a,16 ld l,a ld (ell_sine + 1),hl ld a,(hl) sub 0x40 ; make a two's complement value ld d,a ell_radius1 ld e,0 call fmult add a,0x40 ; centre on 0x40 cp 0x80 ; check it's still in range jr nc,no_ell_dot ld c,a ; save x pos ell_cosine ld hl,sine + 64 ld a,l add a,16 ld l,a ld (ell_cosine + 1),hl ld a,(hl) sub 0x40 ; make a two's complement value ld d,a ell_radius2 ld e,0 call fmult ; scale value, output in A ell_ytrans add a,80 ; translate into place cp 0x60 ; check it's still in range jr nc,no_ell_dot ld l,a ld h,0 add hl,hl ; mult by 16 to get y address add hl,hl add hl,hl add hl,hl ld de,(bob_buff_addr + 1) add hl,de ld a,c srl a srl a srl a or l ld l,a ; merge x coord to get final address ld a,c and 0x07 ld d,screenbits / 0x100 ld e,a ld a,(de) or (hl) ld (hl),a no_ell_dot pop bc djnz ell_point ld a,(ell_sine + 1) fountain_spin1 nop ; inc a ld (ell_sine + 1),a ld a,(ell_cosine + 1) fountain_spin2 nop ; inc a ld (ell_cosine + 1),a no_ell_plot halt ld hl,ylo + 64 ld b,96 bob_line push bc ld e,(hl) inc h ld d,(hl) dec h inc l set 2,e push hl bob_buff_addr ld hl,bob_buffer rept 16 ldi endm ld (bob_buff_addr + 1),hl pop hl pop bc djnz bob_line pop bc dec b jp nz,bob_frame ld hl,bob_buffer ld (bob_buff_addr + 1),hl pop bc dec b jp nz,bob_cycle ret