;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; Here we will look at all of the tiles one by one, and if there is a monster block tile, we will convert it
CountObjects #%00001000
BEQ +noMoreMonsters
JMP +doSkipHurtingThisObject
+noMoreMonsters
MONSTER_BLOCK_TILE = #$07 ; the number collision type of your monster block.
LDX #$00
doCheckForMonsterBlockAfterMonsterDeath:
LDA currentNametable
AND #%00000001
BEQ +isEvenCt
LDA #$24
STA temp1 ;; high byte of thing
;;; is odd col table.
LDA collisionTable2,x
CMP #MONSTER_BLOCK_TILE
BEQ +isMonsterBlockTile
JMP +notMonsterBlockTile
+isMonsterBlockTile
;; is monster block table.
LDA #$00
STA collisionTable2,x
JSR getTileToChange_forMonBlock
JMP +doneWithTileUpdate
+isEvenCt
LDA #$20
STA temp1 ;; high byte of thing.
;;; is odd col table.
LDA collisionTable,x
CMP #MONSTER_BLOCK_TILE
BEQ +isMonsterBlockTile
JMP +notMonsterBlockTile
+isMonsterBlockTile
;; is monster block table.
LDA #$00
STA collisionTable,x
JSR getTileToChange_forMonBlock
JMP +doneWithTileUpdate
getTileToChange_forMonBlock:
TXA
STA temp
LSR
LSR
LSR
LSR
LSR
LSR
clc
ADC temp1
STA temp2 ;;;temp16+1
TXA
AND #%11110000
ASL
ASL
STA tempz
TXA
AND #%00001111
ASL
ORA tempz
STA temp3 ;temp16
;;; SET THE TILE NUMBER TO CHANGE TO.
LDA #$00 ;; the tile to change.
;;; this is in tiles, so if you wanted the second "metatile",
;;; use 2, not 1. If you wanted the tile in the next row,
;;; use #$20, not #$10. Etc.
STA tempA
CLC
ADC #$01
STA tempB
CLC
ADC #$0F
STA tempC
CLC
ADC #$01
STA tempD
LDY #$00
LDA temp2
STA scrollUpdateRam,y
INY
LDA temp3
STA scrollUpdateRam,y
INY
LDA tempA
STA scrollUpdateRam,y
INY
LDA temp2
STA scrollUpdateRam,y
INY
LDA temp3
CLC
ADC #$01
STA scrollUpdateRam,y
INY
LDA tempB
STA scrollUpdateRam,y
INY
LDA temp3
CLC
ADC #$20
STA temp3
LDA temp2
ADC #$00
STA temp2
LDA temp2
STA scrollUpdateRam,y
INY
LDA temp3
STA scrollUpdateRam,y
INY
LDA tempC
STA scrollUpdateRam,y
INY
LDA temp2
STA scrollUpdateRam,y
INY
LDA temp3
CLC
ADC #$01
STA scrollUpdateRam,y
INY
LDA tempD
STA scrollUpdateRam,y
INY
TYA
STA maxScrollOffsetCounter
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Turn on update screen on next frame.
LDA updateScreenData
ORA #%0000100
STA updateScreenData
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TriggerScreen screenType
RTS
+doneWithTileUpdate
JSR doWaitFrame
+notMonsterBlockTile
INX
CPX #240
BEQ +doSkipHurtingThisObject ;; done
JMP doCheckForMonsterBlockAfterMonsterDeath ;; last monster block.