CutterCross
Active member
Sort of an extension to what I was doing with attribute table loads. Experimenting with collision table compression, saw the collision table loads were inefficient for full-screen loads, made a more efficient version. Again, instead of the original's row-column system, this streams each collision nibble one by one.
This loads the same set of collision bytes to BOTH collision tables, so this is really only applicable as-is to non-scrolling games. If you're so inclined, you can modify it so that it only loads to one collision table based on what PPU nametable you're on. And of course this is mostly just for full-screen collision table loads, so arg3 should be set to #240.
New doLoadCollisionTable.asm:
New LoadCollisionData macro:
This loads the same set of collision bytes to BOTH collision tables, so this is really only applicable as-is to non-scrolling games. If you're so inclined, you can modify it so that it only loads to one collision table based on what PPU nametable you're on. And of course this is mostly just for full-screen collision table loads, so arg3 should be set to #240.
New doLoadCollisionTable.asm:
Code:
;;;; CC Collision Table Load ;;;;
doLoadCollisionTable:
;;; currently, arg0_hold has the bank data
;;; arg1_hold has the screen index, if it is needed.
;;; arg2_hold has screen bits.
;;; bit 0 = overworld (0) underworld (1)
;;; bit 1 = metaTable (0) 8x8 table (1)
;arg0 = screen bank
;arg3_hold = number of collisions to load
;arg4_hold = collision table offset
SwitchBank arg0_hold
LDA arg4_hold
TAX
LSR
TAY
LDA arg4_hold
AND #$01
BNE +
LDA #%11110000
JMP ++
+
LDA #%00001111
++
STA arg4_hold ;; Now used to determine if collision is on even or odd column
loop_LoadCollisionTable:
LDA (temp16),y
AND arg4_hold
STA arg5_hold
LDA arg4_hold
CMP #%11110000
BNE +
LDA arg5_hold
LSR
LSR
LSR
LSR
STA arg5_hold
+
;;;; loading to 1st collision table
LDA arg5_hold
STA collisionTable,x
;;;; loading to 2nd collision table
STA collisionTable2,x
doneLoadingThisCollision:
LDA arg4_hold
EOR #$FF
STA arg4_hold
CMP #%11110000
BNE +
INY
+
INX
DEC arg3_hold
BNE loop_LoadCollisionTable
doneWithLoadingCollisions:
ReturnBank
RTS
New LoadCollisionData macro:
Code:
MACRO LoadCollisionData arg0, arg1, arg2, arg3, arg4
;arg0 = screen bank
;arg1 = screen index
;arg2 = load screen bits
;;; bit 0 = overworld (0) underworld (1)
;;; bit 1 = metaTable (0) 8x8 table (1)
;arg3 = number of collisions to load
;arg4 = collision table offset
LDA arg0
STA arg0_hold
LDA arg1
STA arg1_hold
LDA arg2
STA arg2_hold
LDA arg3
STA arg3_hold
LDA arg4
STA arg4_hold
SwitchBank #$16
LDY arg1
LDA arg2
AND #%00000001
BEQ loadFromMap1table
;;;load from map 2 table
LDA CollisionTables_Map2_Lo,y
STA temp16
LDA CollisionTables_Map2_Hi,y
STA temp16+1
LDA arg0_hold
CLC
ADC #$08
STA arg0_hold
JMP GotColTablePointer
loadFromMap1table:
LDA CollisionTables_Map1_Lo,y
STA temp16
LDA CollisionTables_Map1_Hi,y
STA temp16+1
GotColTablePointer:
;;now (temp16) holds the address of the nametable to be loaded.
ReturnBank
JSR doLoadCollisionTable
ENDM