;z80 ;zx-spectrum ;assembler ; haiku (c) Gasman 2005 ; ripple.asm: water effect ripple_frame ystep1_init ld hl,0x1180 ld (ystep1 + 1),hl ystep2_init ld hl,0x1080 ld (ystep2 + 1),hl xstep1_init ld hl,0x1100 ld (xstep1 + 1),hl xstep2_init ld hl,0x1000 ld (xstep2 + 1),hl ysine1_init ld hl,0 ld (ysine1 + 1),hl ld bc,0x0240 ; increment for animation add hl,bc ld (ysine1_init + 1),hl ysine2_init ld hl,0 ld (ysine2 + 1),hl ld bc,0x0300 ; increment for animation add hl,bc ld (ysine2_init + 1),hl ld hl,(xsine1_init + 1) ld bc,0x01c0 ; increment for animation add hl,bc ld (xsine1_init + 1),hl ld hl,(xsine2_init + 1) ld bc,0xff00 ; increment for animation add hl,bc ld (xsine2_init + 1),hl ld b,16 ld hl,0x5a00 + 0xe0 ld b,8 ripple_line push bc push hl ex de,hl ; attribute address into de ysine1 ld hl,0 ystep1 ld bc,0 add hl,bc ld (ysine1 + 1),hl ld l,h ld h,sine / 0x100 ld a,(hl) ysine2 ld hl,0 ystep2 ld bc,0 add hl,bc ld (ysine2 + 1),hl ld l,h ld h,sine / 0x100 add a,(hl) srl a ld (yadd + 1),a xsine1_init ld hl,0 ld bc,(xstep1 + 1) sla c rl b sla c rl b sla c rl b sla c rl b sbc hl,bc ld (xsine1 + 1),hl xsine2_init ld hl,0 ld bc,(xstep2 + 1) sla c rl b sla c rl b sla c rl b sla c rl b sbc hl,bc ld (xsine2 + 1),hl ld b,32 ripple_char push bc xsine1 ld hl,0 xstep1 ld bc,0 add hl,bc ld (xsine1 + 1),hl ld l,h ld h,sine / 0x100 ld a,(hl) xsine2 ld hl,0 xstep2 ld bc,0 add hl,bc ld (xsine2 + 1),hl ld l,h ld h,sine / 0x100 add a,(hl) srl a yadd add a,0 ld h,rip_colours / 0x100 ld l,a ld a,(hl) ld (de),a inc e pop bc djnz ripple_char ; scale xsteps/ysteps for perspective ld hl,(xstep1 + 1) ld b,h ld c,l srl h rr l srl h rr l srl h rr l add hl,bc ld (xstep1 + 1),hl ld hl,(xstep2 + 1) ld b,h ld c,l srl h rr l srl h rr l srl h rr l add hl,bc ld (xstep2 + 1),hl ld hl,(ystep1 + 1) ld b,h ld c,l srl h rr l srl h rr l srl h rr l add hl,bc ld (ystep1 + 1),hl ld hl,(ystep2 + 1) ld b,h ld c,l srl h rr l srl h rr l srl h rr l add hl,bc ld (ystep2 + 1),hl pop hl ld de,0x10000 - 0x0020 add hl,de pop bc dec b jp nz,ripple_line ret