home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fujiology Archive
/
fujiology_archive_v1_0.iso
/
!FALCON
/
LINEOUT
/
DELTA.ZIP
/
DELTASRC.ZIP
/
DELTA.SRC
/
WATER.SO
< prev
next >
Wrap
Text File
|
2003-01-04
|
10KB
|
571 lines
; 2d textured water. Accurate. A screen for delta.
;======= OBJECT EQUATES ========
; Basin dimensions: must be small due to dsp mixer!
Water.BASIN_RAW_WIDTH: = 144
Water.BASIN_RAW_HEIGHT: = 82
Water.BASIN_TOTAL_WIDTH: = Water.BASIN_RAW_WIDTH+2
Water.BASIN_TOTAL_HEIGHT: = Water.BASIN_RAW_HEIGHT+2
;======= OBJECT TABLE ========
* Must be first in object!!
Water.table:
DC.L Water.mainLoop
DC.L Water.init
DC.L Water.setRes
DC.L Water.setCirclePisser
DC.L Water.setSinePisser
DC.L Water.setBigDrop
DC.L Water.setRainDrops
DC.L 0
;======= RESOLUTION SETTING ROUTINE ========
Water.setRes:
move.l frmcnt,d0
sub.l lastframecount,d0
beq.s .end
move.l #rts,vbl_gfx
move.w monitormode,d0
cmpi.w #vga60,d0
beq.s .vga60
cmpi.w #vga100,d0
beq.s .vga100
cmpi.w #rgb50,d0
beq.s .rgb50
* Unknown monitormode..
.end: rts
.vga60: bra.l vga60_16bit_160_200
.vga100:bra.l vga100_16bit_160_100
.rgb50: bra.l rgb50_16bit_320_100
;======= INIT SUBROUTINE ========
Water.init:
lea Water.flowTable,a1
lea Water.pal,a0
bsr.l Pal.makeGradientHc
moveq #0,d0
rts
Water.realtimeInit:
move.l #Water.setRes,vbl_gfx
; Requires Dsp.loadProgram function!
move.l #(Water.p56End-Water.p56)/3,d0
lea Water.p56,a0
bsr Dsp.loadProgram
move.l #$278AB156,random
move.l #Water.pissCircle,Water.dropRout
rts
;======= SCREENINIT SUBROUTINE ========
Water.initScreen:
IFEQ testmode
movea.l scr,a0
bsr.l CLEAR_320100TSCR
ENDC
rts
;======= MAINLOOP SUBROUTINE ========
Water.mainLoop:
move.w $468.w,.old468
move.l frmcnt,d0
sub.l lastframecount,d0
bne.s .end_realtime_init
move.l d0,-(sp)
bsr Water.realtimeInit
move.l (sp)+,d0
.end_realtime_init:
cmpi.l #3,d0
bhs.s .end_screeninit
bsr Water.initScreen
.end_screeninit:
IFNE 1
movea.l Water.dropRout,a0
jsr (a0)
ELSE
move.w $4bc.w,d0
andi.w #%0000001000000000,d0
beq.s .endfill
movea.l Water.frontAdr,a0
lea falconheight_dat,a1
move.w #Water.BASIN_RAW_HEIGHT-1,d7
moveq #0,d0
.yloop: move.w #Water.BASIN_RAW_WIDTH-1,d6
.xloop: move.b (a1)+,d0
lsr.b #4,d0
add.w d0,(a0)+
;lsr.b #1,d0
;move.w d0,(a0)+
dbra d6,.xloop
addq #4,a0
dbra d7,.yloop
.endfill:
ENDC
movea.l Water.paintRout,a0
jsr (a0)
IFEQ testmode
move.w .old468(pc),d0
moveq #2,d3
cmpi.w #vga100,monitormode
bne.s .wait
moveq #4,d3
.wait: move.w $0468.w,d2
sub.w d0,d2
cmp.w d3,d2
blt.s .wait
lea scr,a0
move.l (a0)+,d0
move.l (a0)+,d1
move.l (a0),-4(a0)
move.l d0,(a0)
move.l d1,-8(a0)
move.l d0,d1
lsr.w #8,d0
move.l d0,$ffff8200.w
move.b d1,$ffff820d.w
ENDC
rts
.old468:DC.W 0
;======= OBJECT SUBROUTINES ========
Water.setCirclePisser:
move.l #Water.pissCircle,Water.dropRout
rts
Water.setSinePisser:
move.l #Water.pissSine,Water.dropRout
rts
Water.setBigDrop:
move.l #Water.dropBigOne,Water.dropRout
rts
Water.setRainDrops:
move.l #Water.dropRain,Water.dropRout
rts
IFNE 0
INSTALL_PALETTEPAINTER:
move.l #PAINT_DSPWATER,Water.paintRout
rts
INSTALL_BACKDROPPAINTER:
move.l #PAINT_DSPOFFSETWATER,Water.paintRout
rts
ENDC
Water.pissCircle:
lea sine_tbl,a0
move.w $4bc.w,d0
add.w d0,d0
Do_SinModulo d0
Get_SinCos a0,d0,d1,d2
muls.w #(Water.BASIN_RAW_WIDTH*4)/5,d1
muls.w #(Water.BASIN_RAW_HEIGHT*2)/3,d2
swap d1
swap d2
addi.w #Water.BASIN_TOTAL_WIDTH/2,d1
addi.w #Water.BASIN_TOTAL_HEIGHT/2,d2
mulu.w #Water.BASIN_TOTAL_WIDTH,d2
ext.l d1
add.l d2,d1
IFNE 0
movea.l Water.frontAdr,a0
move.w #$00ff,(a0,d1.l*2)
ENDC
lea Water.dropletTable,a0
move.w #1,(a0)+
move.w d1,(a0)+
move.w #200,(a0)+
subq #6,a0
bsr SEND_DROPS
rts
Water.dropBigOne:
lea Water.dropletTable,a0
move.w $4bc.w,d0
andi.w #$0200,d0
beq.s .send_none
move.w #Water.BASIN_TOTAL_WIDTH*(Water.BASIN_RAW_HEIGHT/2)+Water.BASIN_TOTAL_WIDTH/2,d1
move.w #2000,d2
move.w #3,(a0)+
move.w d1,(a0)+
move.w d2,(a0)+
addq.w #1,d1
move.w d1,(a0)+
move.w d2,(a0)+
addq.w #1,d1
move.w d1,(a0)+
move.w d2,(a0)+
lea Water.dropletTable,a0
bsr SEND_DROPS
rts
.send_none:
move.w #0,(a0)
bsr SEND_DROPS
rts
Water.dropRain:
Calc_NextRandom
move.l #$0000ffff,d2
and.l d2,d0
and.l d2,d1
divu.w #Water.BASIN_RAW_WIDTH,d0
divu.w #Water.BASIN_RAW_HEIGHT,d1
swap d0
swap d1
mulu.w #Water.BASIN_TOTAL_WIDTH,d1
add.w d0,d1
lea Water.dropletTable,a0
move.w #1,(a0)+
move.w d1,(a0)+
move.w #200,(a0)+
subq #6,a0
bsr SEND_DROPS
rts
Water.pissSine:
lea sine_tbl,a0
move.w $4bc.w,d0
move.w d0,d3
mulu.w #3,d3
lsr.w #1,d3
add.w d0,d0
Do_SinModulo d0
Do_SinModulo d3
Get_Sin a0,d0,d1
Get_Sin a0,d3,d2
muls.w #(Water.BASIN_RAW_WIDTH*4)/5,d1
muls.w #(Water.BASIN_RAW_HEIGHT*2)/3,d2
swap d1
swap d2
addi.w #Water.BASIN_TOTAL_WIDTH/2,d1
addi.w #Water.BASIN_TOTAL_HEIGHT/2,d2
mulu.w #Water.BASIN_TOTAL_WIDTH,d2
ext.l d1
add.l d2,d1
IFNE 0
movea.l Water.frontAdr,a0
move.w #$00ff,(a0,d1.l*2)
ENDC
lea Water.dropletTable,a0
move.w #1,(a0)+
move.w d1,(a0)+
move.w #200,(a0)+
subq #6,a0
bsr SEND_DROPS
rts
Water.PaintPal:
movea.l scr,a0
lea 640*((100-Water.BASIN_RAW_HEIGHT)/2)(a0),a0
move.l #(160-Water.BASIN_RAW_WIDTH)*4,d5
move.l d5,d0
lsr.l #1,d0
adda.l d0,a0
lea $ffffa206.w,a1
moveq #Water.BASIN_RAW_HEIGHT-1,d7
lea Water.pal+256*4,a6
.wait_recvdsp:
btst #0,$ffffa202.w
beq.s .wait_recvdsp
.yloop: moveq #Water.BASIN_RAW_WIDTH/16-1,d6
.xloop: REPT 16
move.w (a1),d0
move.l (a6,d0.w),(a0)+
ENDR
dbra d6,.xloop
adda.l d5,a0
dbra d7,.yloop
rts
Water.paintDspOffsets:
movea.l scr,a0
lea $ffffa206.w,a1
moveq #Water.BASIN_RAW_HEIGHT-1,d7
lea Texture.16bTexture2+(256*70+60)*2,a6
move.w monitormode,d0
cmpi.w #vga60,d0
beq Water.paintVga60
cmpi.w #vga100,d0
beq Water.paintVga100
cmpi.w #rgb50,d0
beq Water.paintRgb50
* Unknown monitormode..
rts
Water.paintVga60:
move.l #160-Water.BASIN_RAW_WIDTH,d0
andi.w #$fffe,d0
adda.l d0,a0
lea 160*((100-Water.BASIN_RAW_HEIGHT)/2)*2(a0),a0
move.l #(160*2-Water.BASIN_RAW_WIDTH)*2,d5
lea 160*2(a0),a2
.wait_recvdsp:
btst #0,$ffffa202.w
beq.s .wait_recvdsp
.yloop: moveq #Water.BASIN_RAW_WIDTH/16-1,d6
.xloop:
REPT 16
move.w (a1),d0
move.w (a6,d0.w),(a0)+
move.w (a6,d0.w),(a2)+
addq #2,a6
ENDR
dbra d6,.xloop
lea (256-Water.BASIN_RAW_WIDTH)*2(a6),a6
adda.l d5,a0
adda.l d5,a2
dbra d7,.yloop
rts
Water.paintVga100:
move.l #160-Water.BASIN_RAW_WIDTH,d0
andi.w #$fffe,d0
adda.l d0,a0
lea 160*((100-Water.BASIN_RAW_HEIGHT)/2)*2(a0),a0
move.l #(160-Water.BASIN_RAW_WIDTH)*2,d5
.wait_recvdsp:
btst #0,$ffffa202.w
beq.s .wait_recvdsp
.yloop: moveq #Water.BASIN_RAW_WIDTH/16-1,d6
.xloop: REPT 16
move.w (a1),d0
move.w (a6,d0.w),(a0)+
addq #2,a6
ENDR
dbra d6,.xloop
lea (256-Water.BASIN_RAW_WIDTH)*2(a6),a6
adda.l d5,a0
dbra d7,.yloop
rts
Water.paintRgb50:
move.l #(160-Water.BASIN_RAW_WIDTH)*4,d5
move.l d5,d0
lsr.l #1,d0
adda.l d0,a0
lea 640*((100-Water.BASIN_RAW_HEIGHT)/2)(a0),a0
.wait_recvdsp:
btst #0,$ffffa202.w
beq.s .wait_recvdsp
.yloop: moveq #Water.BASIN_RAW_WIDTH/16-1,d6
.xloop: REPT 16
move.w (a1),d0
move.l (a6,d0.w*2),(a0)+
addq #2,a6
ENDR
dbra d6,.xloop
lea (256-Water.BASIN_RAW_WIDTH)*2(a6),a6
adda.l d5,a0
dbra d7,.yloop
rts
* INPUT: a0: droplet table
SEND_DROPS:
moveq #0,d7
move.w (a0)+,d7
.wait_dsp:
btst #1,$ffffa202.w
beq.s .wait_dsp
move.l d7,$ffffa204.w
subq.w #1,d7
bmi.s .end
moveq #0,d0
.loop:
move.w (a0)+,d0
.wait1_dsp:
btst #1,$ffffa202.w
beq.s .wait1_dsp
move.l d0,$ffffa204.w
move.w (a0)+,d0
.wait2_dsp:
btst #1,$ffffa202.w
beq.s .wait2_dsp
move.l d0,$ffffa204.w
dbra d7,.loop
.end: rts
IFNE 0
PLOT_WATER:
movea.l scr,a0
lea Water.pal+256*4,a6
movea.l Water.backAdr,a5
movea.l Water.frontAdr,a1
move.l a1,Water.backAdr
move.l a5,Water.frontAdr
addq #2,a1
addq #2,a5
lea -2(a1),a2
lea 2(a1),a3
lea (Water.BASIN_TOTAL_WIDTH-1)*2(a1),a4
lea (-Water.BASIN_TOTAL_WIDTH-1)*2(a1),a1
move.l #(160-Water.BASIN_RAW_WIDTH)*4,d5
moveq #Water.BASIN_RAW_HEIGHT-1,d7
.yloop: move.w #Water.BASIN_RAW_WIDTH-1,d6
.xloop: move.w (a1)+,d0
add.w (a1),d0
add.w 2(a1),d0
add.w (a2)+,d0
add.w (a3)+,d0
add.w (a4)+,d0
add.w (a4),d0
add.w 2(a4),d0
asr.w #2,d0
sub.w (a5),d0
move.w d0,d1
asr.w #5,d1
sub.w d1,d0
move.w d0,(a5)+
move.l (a6,d0.w*4),(a0)+
dbra d6,.xloop
addq #2*2,a1
addq #2*2,a2
addq #2*2,a3
addq #2*2,a4
addq #2*2,a5
adda.l d5,a0
dbra d7,.yloop
rts
ENDC
;======= OBJECT DATA ========
DATA
Water.p56:
INCBIN DSPWATER.P56
Water.p56End:
EVEN
IFNE 0
Water.frontAdr:
DC.L Water.buffer1
Water.backAdr:
DC.L Water.buffer2
ENDC
Water.flowTable:
DC.W 32 (.end-.start)/4
DC.W 4
.start: DC.L $00000000 ;DC.L $00000000
DC.L $0000001f ;DC.L $003f0000
DC.L $0000003f ;DC.L $007f0000
DC.L $0000005f ;DC.L $3fdf0000
DC.L $0000007f ;DC.L $7fff0000
DC.L $0000009f ;DC.L $dfff0000
DC.L $000000bf ;DC.L $ffff0000
DC.L $000000df ;DC.L $ffff003f
DC.L $000000ff ;DC.L $ffff007f
DC.L $001f00ff ;DC.L $ffff00bf
DC.L $003f00ff ;DC.L $ffff00ff
DC.L $005f00ff ;DC.L $ffff00ff
DC.L $007f00ff ;DC.L $ffff00ff
DC.L $009f00ff ;DC.L $ffff00ff
DC.L $00bf00ff ;DC.L $ffff00ff
DC.L $00df00ff ;DC.L $ffff00ff
DC.L $00ff00ff ;DC.L $ffff00ff
DC.L $1fff00ff
DC.L $3fff00ff
DC.L $5fff00ff
DC.L $7fff00ff
DC.L $9fff00ff
DC.L $bfff00ff
DC.L $dfff00ff
DC.L $ffff00ff
DC.L $ffdf00df
DC.L $ffbf00bf
DC.L $ff9f009f
DC.L $ff7f007f
DC.L $ff5f005f
DC.L $ff3f003f
DC.L $ff1f001f
DC.L $ff000000
.end:
Water.paintRout:
DC.L Water.paintDspOffsets
;======= OBJECT RESERVES ========
BSS
Water.pal:
DS.W 512
IFNE 0
DS.W Water.BASIN_TOTAL_WIDTH
Water.buffer1:
DS.W Water.BASIN_TOTAL_WIDTH*Water.BASIN_RAW_HEIGHT
DS.W Water.BASIN_TOTAL_WIDTH
Water.buffer2:
DS.W Water.BASIN_TOTAL_WIDTH*Water.BASIN_RAW_HEIGHT
DS.W Water.BASIN_TOTAL_WIDTH
ENDC
Water.dropletTable:
DS.W 1+16 ; 16 drops max each frame!
Water.dropRout:
DS.L 1
;======= END OF DEMO-EFFECT OBJECT ========