Merge pull request #16 from mmxbass/IcePalaceMedallions

Ice palace medallions
This commit is contained in:
Karkat
2018-01-04 23:44:58 -05:00
committed by GitHub
5 changed files with 217 additions and 0 deletions

View File

@@ -123,6 +123,8 @@ incsrc compasses.asm
incsrc doorframefixes.asm
;incsrc shopkeeper.asm
incsrc cuccostorm.asm
incsrc roomloading.asm
incsrc icepalacegraphics.asm
incsrc hashalphabet.asm ; <- TAKE OUT THE EXTRA ORGS IN HERE - THIS IS WHY WE COULDN'T ADD MORE FILES EARLIER
warnpc $A18000

View File

@@ -1925,3 +1925,41 @@ org $0298AD ; <- Bank02.asm:4495 (LDA $010E : CMP.b #$43)
JSL.l WalkDownIntoTavern
NOP #1
;================================================================================
;================================================================================
; Hooks for roomloading.asm
;--------------------------------------------------------------------------------
org $02895D ; <- Bank02.asm:1812 (JSL Dungeon_LoadRoom)
JSL LoadRoomHook
;--------------------------------------------------------------------------------
org $028BE7 ; <- Bank02.asm:2299 (JSL Dungeon_LoadRoom)
JSL LoadRoomHook
;--------------------------------------------------------------------------------
org $029309 ; <- Bank02.asm:3533 (JSL Dungeon_LoadRoom)
JSL LoadRoomHook
;--------------------------------------------------------------------------------
org $02C2F3 ; <- Bank02.asm:10391 (JSL Dungeon_LoadRoom)
JSL LoadRoomHook
;================================================================================
;================================================================================
; Hooks into the "Reloading all graphics" routine
;--------------------------------------------------------------------------------
org $00E64D ; <- Bank00.asm:5656 (STZ $00 : STX $01 : STA $02)
JML BgGraphicsLoading
BgGraphicsLoadingCancel:
RTS : NOP
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:
;================================================================================

BIN
ice_palace_floor.bin Normal file

Binary file not shown.

83
icepalacegraphics.asm Normal file
View File

@@ -0,0 +1,83 @@
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:
; Instructions overwritten
STZ $00
STX $01
STA $02
JSR ShouldOverrideFileLoad
BCS .useSpecialIcePalaceFile
JML BgGraphicsLoadingResume
.useSpecialIcePalaceFile
; We're loading the floor tiles in Ice Palace. Instead of the normal file,
; load another one that replaces the bridge tiles with the Bombos medallion
LDA $FFFFFF
LDA.b #IcePalaceFloorGfx>>16
STA $02
REP #$20
LDA.w #IcePalaceFloorGfx
STA $00
LDX.b #64*2 ; Tiles to load * 2
-
; Unrolled loop to upload half a tile
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
DEX
BNE -
SEP #$20
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:
incbin ice_palace_floor.bin

94
roomloading.asm Normal file
View File

@@ -0,0 +1,94 @@
LoadRoomHook:
JSL $01873A ; Dungeon_LoadRoom (Bank01.asm:726)
REP #$10 ; 16 bit XY
LDX $A0 ; Room ID
LDA RoomCallbackTable, X
SEP #$10 ; 8 bit XY
JSL $00879c ; UseImplicitRegIndexedLocalJumpTable
; Callback routines:
dl NoCallback ; 00
dl IcePalaceBombosSE ; 01
dl IcePalaceBombosSW ; 02
dl IcePalaceBombosNE ; 03
NoCallback:
RTL
!RL_TILE = 2
!RL_LINE = 128
macro setTilePointer(roomX, roomY, quadX, quadY)
; Left-to-right math. Should be equivalent to 0x7e2000+(roomX*2)+(roomY*128)+(quadX*64)+(quadY*4096)
LDX.w #<quadY>*32+<roomY>*2+<quadX>*32+<roomX>*2
endmacro
macro writeTile()
STA.l $7E2000,x
INX #2
endmacro
!BOMBOS_BORDER = #$08D0
!BOMBOS_ICON_1 = #$0CCA
!BOMBOS_ICON_2 = #$0CCB
!BOMBOS_ICON_3 = #$0CDA
!BOMBOS_ICON_4 = #$0CDB
macro DrawBombosPlatform(roomX, roomY, quadX, quadY)
REP #$30 ; 16 AXY
%setTilePointer(<roomX>, <roomY>, <quadX>, <quadY>)
LDA.w !BOMBOS_BORDER
%writeTile()
%writeTile()
%writeTile()
%writeTile()
%setTilePointer(<roomX>, <roomY>+1, <quadX>, <quadY>)
%writeTile()
LDA.w !BOMBOS_ICON_1 : %writeTile()
LDA.w !BOMBOS_ICON_2 : %writeTile()
LDA.w !BOMBOS_BORDER : %writeTile()
%setTilePointer(<roomX>, <roomY>+2, <quadX>, <quadY>)
%writeTile()
LDA.w !BOMBOS_ICON_3 : %writeTile()
LDA.w !BOMBOS_ICON_4 : %writeTile()
LDA.w !BOMBOS_BORDER : %writeTile()
%setTilePointer(<roomX>, <roomY>+3, <quadX>, <quadY>)
%writeTile()
%writeTile()
%writeTile()
%writeTile()
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
RoomCallbackTable:
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00 ; 00x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 01x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 02x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 03x
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 ; 06x
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 ; 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 ; 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, $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 ; 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 ; 10x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 11x
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 12x