;dead.asm (all vbi code)

   lda deadtype
   bne *+5
   jmp dead1
   cmp #2
   bne *+5
   jmp dead3

;tail and skeleton head
dead2
   lda fishd
   beq :rt01
:lf01
   lda #low [skeldata1+2]
   sta :selfmod1
   lda #high [skeldata1+2]
   sta :selfmod1+1
   lda #low fishdata2
   sta :selfmod2
   lda #high fishdata2
   sta :selfmod2+1
   lda #%00001111
   sta :tmp2vbi
   lda #12
   sta COLPM0
   lda #198-32
   sta COLPM1
   jmp :lfrt01
:rt01
   lda #low [skeldata2+2]
   sta :selfmod2
   lda #high [skeldata2+2]
   sta :selfmod2+1
   lda #low fishdata1
   sta :selfmod1
   lda #high fishdata1
   sta :selfmod1+1
   lda #%11110000
   sta :tmp2vbi
   lda #12
   sta COLPM1
   lda #198-32
   sta COLPM0
:lfrt01
   lda :tmpvbi
   and #16 ;ignore trigger status
   tax
:lpdf2
:selfmod1 equ *+1
   lda fishdata1,x
   sta play0,y
:selfmod2 equ *+1
   lda fishdata2,x
   sta play1,y
   lda fishdata3,x
   and :tmp2vbi
   sta play2,y
   iny
   inx
   dec :cntr
   bne :lpdf2
;set fish colors
;   lda #198-32
;   sta COLPM0
;   sta COLPM1
   lda #202-32
   sta COLPM2
   lda #1
   sta SIZEP2
   jmp :donefish

dead1
   lda :tmpvbi
   and #16 ;ignore trigger status
   tax
:lpd2skel
   lda skeldata1,x
   sta play0,y
   lda skeldata2,x
   sta play1,y
   lda #0
   sta play2,y
   iny
   inx
   dec :cntr
   bne :lpd2skel
;set skeleton colors
   lda #12
   sta COLPM0
   sta COLPM1
   lda #1
   sta SIZEP2
   jmp :donefish

dead3
   lda :tmpvbi
   and #16 ;ignore trigger status
   clc
   adc #15
   tax
   lda random
   and #3
   sta :tmp2vbi   
   tya
   cpy #83
   bcs :lpdf3
   clc
   adc :tmp2vbi
   tay
   sty ofishy
:lpdf3
   lda fishdata1,x
   sta play0,y
   lda fishdata2,x
   sta play1,y
   lda fishdata3,x
   sta play2,y
   iny
   dex
   dec :cntr
   bne :lpdf3
;set fish colors
   lda #198-32
   sta COLPM0
   sta COLPM1
   lda #202-32
   sta COLPM2
   lda #1
   sta SIZEP2
   jmp :donefish

