More platforms, fixed graphics when switching floors

This commit is contained in:
Smallhacker
2018-01-04 23:35:28 -05:00
parent 3dde5bcbbd
commit c5b97deda1
3 changed files with 101 additions and 45 deletions

View File

@@ -1943,11 +1943,23 @@ org $02C2F3 ; <- Bank02.asm:10391 (JSL Dungeon_LoadRoom)
;================================================================================ ;================================================================================
;================================================================================ ;================================================================================
; Hook for graphicsoverride.asm ; Hooks into the "Reloading all graphics" routine
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
org $00E64D ; <- Bank00.asm:5656 (STZ $00 : STX $01 : STA $02) org $00E64D ; <- Bank00.asm:5656 (STZ $00 : STX $01 : STA $02)
JML BgGraphicsLoading JML BgGraphicsLoading
BgGraphicsLoadingCancel: BgGraphicsLoadingCancel:
RTS : NOP RTS : NOP
BgGraphicsLoadingResume: BgGraphicsLoadingResume:
;================================================================================ ;================================================================================
;================================================================================
; Hook when updating the floor tileset in dungeons (such as between floors)
;--------------------------------------------------------------------------------
org $00DF62 ; <- Bank00.asm:4672 (LDX.w #$0000 : LDY.w #$0040)
JML ReloadingFloors
NOP : NOP
ReloadingFloorsResume:
org $00DF6E ; <- A few instructions later, right after JSR Do3To4High16Bit
ReloadingFloorsCancel:
;================================================================================

View File

@@ -1,18 +1,24 @@
ShouldOverrideFileLoad:
; Y = Graphics file being loaded
CPY #$0A ; 0A = Ice/Mire floor file
BNE .no
LDA $040C ; Dungeon number
CMP #$12 ; Ice Palace
BEQ .yes
.no
CLC : RTS
.yes
SEC : RTS
BgGraphicsLoading: BgGraphicsLoading:
; Instructions overwritten ; Instructions overwritten
STZ $00 STZ $00
STX $01 STX $01
STA $02 STA $02
; Y = Graphics file being loaded JSR ShouldOverrideFileLoad
CPY #$0A ; 0A = Ice/Mire floor file BCS .useSpecialIcePalaceFile
BNE .useDefaultGraphics
LDA $040C ; Dungeon number
CMP #$12 ; Ice Palace
BEQ .useSpecialIcePalaceFile
.useDefaultGraphics
JML BgGraphicsLoadingResume JML BgGraphicsLoadingResume
.useSpecialIcePalaceFile .useSpecialIcePalaceFile
@@ -43,5 +49,35 @@ BgGraphicsLoading:
SEP #$20 SEP #$20
JML BgGraphicsLoadingCancel JML BgGraphicsLoadingCancel
ReloadingFloors:
SEP #$30 ; 8 AXY
LDA $7EC2F8 ; Floor file that has been decompressed
TAY
JSR ShouldOverrideFileLoad
REP #$30 ; 16 AXY
BCS .replaceWithSpecialIcePalaceFile
; Instructions overwritten by hook
LDX.w #$0000
LDY.w #$0040
JML ReloadingFloorsResume
.replaceWithSpecialIcePalaceFile
; Block move our hardcoded graphics into the output buffer
LDX.w #IcePalaceFloorGfx ; Source
LDY.w #$0000 ; Target
LDA.w #$0800 ; Length
PHB
MVN $7F, IcePalaceFloorGfx>>16
PLB
; Pretend that we ran the original routine
LDX.w #$0800
LDA.w #$6600
STA $03
JML ReloadingFloorsCancel
IcePalaceFloorGfx: IcePalaceFloorGfx:
incbin ice_palace_floor.bin incbin ice_palace_floor.bin

View File

@@ -7,7 +7,9 @@ LoadRoomHook:
JSL $00879c ; UseImplicitRegIndexedLocalJumpTable JSL $00879c ; UseImplicitRegIndexedLocalJumpTable
; Callback routines: ; Callback routines:
dl NoCallback ; 00 dl NoCallback ; 00
dl IcePalace1 ; 01 dl IcePalaceBombosSE ; 01
dl IcePalaceBombosSW ; 02
dl IcePalaceBombosNE ; 03
NoCallback: NoCallback:
RTL RTL
@@ -25,42 +27,48 @@ macro writeTile()
INX #2 INX #2
endmacro endmacro
!IP_BORDER = #$08D0 !BOMBOS_BORDER = #$08D0
!IP_ICON_1 = #$0CCA !BOMBOS_ICON_1 = #$0CCA
!IP_ICON_2 = #$0CCB !BOMBOS_ICON_2 = #$0CCB
!IP_ICON_3 = #$0CDA !BOMBOS_ICON_3 = #$0CDA
!IP_ICON_4 = #$0CDB !BOMBOS_ICON_4 = #$0CDB
macro DrawBombosPlatform(roomX, roomY, quadX, quadY)
!IP1_X = 14
!IP1_Y = 18
IcePalace1:
REP #$30 ; 16 AXY REP #$30 ; 16 AXY
%setTilePointer(!IP1_X, !IP1_Y, 1, 1) %setTilePointer(<roomX>, <roomY>, <quadX>, <quadY>)
LDA.w !IP_BORDER LDA.w !BOMBOS_BORDER
%writeTile() %writeTile()
%writeTile() %writeTile()
%writeTile() %writeTile()
%writeTile() %writeTile()
%setTilePointer(!IP1_X, !IP1_Y+1, 1, 1) %setTilePointer(<roomX>, <roomY>+1, <quadX>, <quadY>)
%writeTile() %writeTile()
LDA.w !IP_ICON_1 : %writeTile() LDA.w !BOMBOS_ICON_1 : %writeTile()
LDA.w !IP_ICON_2 : %writeTile() LDA.w !BOMBOS_ICON_2 : %writeTile()
LDA.w !IP_BORDER : %writeTile() LDA.w !BOMBOS_BORDER : %writeTile()
%setTilePointer(!IP1_X, !IP1_Y+2, 1, 1) %setTilePointer(<roomX>, <roomY>+2, <quadX>, <quadY>)
%writeTile() %writeTile()
LDA.w !IP_ICON_3 : %writeTile() LDA.w !BOMBOS_ICON_3 : %writeTile()
LDA.w !IP_ICON_4 : %writeTile() LDA.w !BOMBOS_ICON_4 : %writeTile()
LDA.w !IP_BORDER : %writeTile() LDA.w !BOMBOS_BORDER : %writeTile()
%setTilePointer(!IP1_X, !IP1_Y+3, 1, 1) %setTilePointer(<roomX>, <roomY>+3, <quadX>, <quadY>)
%writeTile() %writeTile()
%writeTile() %writeTile()
%writeTile() %writeTile()
%writeTile() %writeTile()
SEP #$30 ; 8 AXY SEP #$30 ; 8 AXY
endMacro
IcePalaceBombosSE:
%DrawBombosPlatform(14, 18, 1, 1)
RTL
IcePalaceBombosSW:
%DrawBombosPlatform(14, 18, 0, 1)
RTL
IcePalaceBombosNE:
%DrawBombosPlatform(14, 18, 1, 0)
RTL RTL
RoomCallbackTable: RoomCallbackTable:
@@ -71,13 +79,13 @@ RoomCallbackTable:
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 04x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 04x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 05x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 05x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 06x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 06x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 07x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $02, $00 ; 07x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 08x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 08x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 09x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 09x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Ax db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Ax
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Bx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Bx
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Cx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Cx
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Dx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $00 ; 0Dx
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Ex db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Ex
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Fx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Fx
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Fx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Fx