-
Notifications
You must be signed in to change notification settings - Fork 53
/
roomloading.asm
165 lines (150 loc) · 5.58 KB
/
roomloading.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
LoadRoomHook:
JSL.l IndoorTileTransitionCounter
.noStats
JSL Dungeon_LoadRoom
REP #$10 ; 16 bit XY
LDX.b RoomIndex ; Room ID
LDA.l RoomCallbackTable, X
SEP #$10 ; 8 bit XY
JSL JumpTableLong
; Callback routines:
dl NoCallback ; 00
dl IcePalaceBombosSE ; 01
dl IcePalaceBombosSW ; 02
dl IcePalaceBombosNE ; 03
dl CastleEastEntrance ; 04
dl CastleWestEntrance ; 05
NoCallback:
RTL
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
macro writeTileAt(roomX, roomY, quadX, quadY)
STA.l <quadY>*32+<roomY>*2+<quadX>*32+<roomX>*2+$7E2000
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:
LDA.l AllowSwordlessMedallionUse : CMP.b #$01 : BEQ + : RTL : +
%DrawBombosPlatform(14, 18, 1, 1)
RTL
IcePalaceBombosSW:
LDA.l AllowSwordlessMedallionUse : CMP.b #$01 : BEQ + : RTL : +
%DrawBombosPlatform(14, 18, 0, 1)
RTL
IcePalaceBombosNE:
LDA.l AllowSwordlessMedallionUse : CMP.b #$01 : BEQ + : RTL : +
%DrawBombosPlatform(14, 18, 1, 0)
RTL
CastleEastEntrance:
LDA.l ProgressIndicator : CMP.b #$02 : !BLT + : RTL : + ; only apply in rain states (0 or 1)
LDA.l BlockCastleDoorsInRain : BNE + : RTL : +
REP #$20 ; 16 A
LDA.w #$08e1 ; square peg
%writeTileAt(11,21,0,1)
%writeTileAt(11,26,0,1)
%writeTileAt(20,21,0,1)
%writeTileAt(20,26,0,1)
INC ;horizontal rail
%writeTileAt(12,21,0,1)
%writeTileAt(13,21,0,1)
%writeTileAt(14,21,0,1)
%writeTileAt(15,21,0,1)
%writeTileAt(16,21,0,1)
%writeTileAt(17,21,0,1)
%writeTileAt(18,21,0,1)
%writeTileAt(19,21,0,1)
INC ;vertical rail
%writeTileAt(11,22,0,1)
%writeTileAt(11,23,0,1)
%writeTileAt(11,24,0,1)
%writeTileAt(11,25,0,1)
%writeTileAt(20,22,0,1)
%writeTileAt(20,23,0,1)
%writeTileAt(20,24,0,1)
%writeTileAt(20,25,0,1)
SEP #$20 ; 8 A
RTL
CastleWestEntrance:
LDA.l ProgressIndicator : CMP.b #$02 : !BLT + : RTL : + ; only apply in rain states (0 or 1)
LDA.l BlockCastleDoorsInRain : BNE + : RTL : +
REP #$20 ; 16 A
LDA.w #$08e1 ; square peg
%writeTileAt(11,21,1,1)
%writeTileAt(11,26,1,1)
%writeTileAt(20,21,1,1)
%writeTileAt(20,26,1,1)
INC ;horizontal rail
%writeTileAt(12,21,1,1)
%writeTileAt(13,21,1,1)
%writeTileAt(14,21,1,1)
%writeTileAt(15,21,1,1)
%writeTileAt(16,21,1,1)
%writeTileAt(17,21,1,1)
%writeTileAt(18,21,1,1)
%writeTileAt(19,21,1,1)
INC ;vertical rail
%writeTileAt(11,22,1,1)
%writeTileAt(11,23,1,1)
%writeTileAt(11,24,1,1)
%writeTileAt(11,25,1,1)
%writeTileAt(20,22,1,1)
%writeTileAt(20,23,1,1)
%writeTileAt(20,24,1,1)
%writeTileAt(20,25,1,1)
SEP #$20 ; 8 A
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 $05, $00, $04, $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