-
Notifications
You must be signed in to change notification settings - Fork 53
/
bookofmudora.asm
101 lines (98 loc) · 3.15 KB
/
bookofmudora.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
;================================================================================
; Randomize Book of Mudora
;--------------------------------------------------------------------------------
LoadLibraryItemGFX:
%GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues)
JSL.l AttemptItemSubstitution
JSL.l ResolveLootIDLong
STA.w SpriteID, X
JSL.l PrepDynamicTile_loot_resolved
RTL
;--------------------------------------------------------------------------------
DrawLibraryItemGFX:
PHA
LDA.w SpriteID, X
JSL.l DrawDynamicTile
PLA
RTL
;--------------------------------------------------------------------------------
SetLibraryItem:
LDY.w SpriteID, X
JSL.l ItemSet_Library ; contains thing we wrote over
RTL
;--------------------------------------------------------------------------------
;0x0087 - Hera Room w/key
;================================================================================
; Randomize Bonk Keys
;--------------------------------------------------------------------------------
LoadBonkItemGFX:
LDA.b #$08 : STA.w SpriteOAMProp, X ; thing we wrote over
LoadBonkItemGFX_inner:
LDA.b #$00 : STA.l RedrawFlag
JSR LoadBonkItem
JSL.l AttemptItemSubstitution
JSL.l ResolveLootIDLong
STA.w SpriteItemType, X
STA.w SpriteID, X
JSL.l PrepDynamicTile
PHA : PHX
LDA.w SpriteID,X : TAX
LDA.l SpriteProperties_standing_width,X : BNE +
LDA.b #$00 : STA.l SpriteOAM : STA.l SpriteOAM+8
+
PLX : PLA
RTL
;--------------------------------------------------------------------------------
DrawBonkItemGFX:
PHA
LDA.l RedrawFlag : BEQ .skipInit
JSL.l LoadBonkItemGFX_inner
BRA .done ; don't draw on the init frame
.skipInit
LDA.w SpriteID,X
JSL.l DrawDynamicTileNoShadow
.done
PLA
RTL
;--------------------------------------------------------------------------------
GiveBonkItem:
JSR LoadBonkItem
JSR.w AbsorbKeyCheck : BCC .notKey
.key
PHY : LDY.b #$24 : JSL.l AddInventory : PLY ; do inventory processing for a small key
LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys
LDA.b #$2F : JSL.l Sound_SetSfx3PanLong
LDA.b #$01 : STA.l UpdateHUDFlag
RTL
.notKey
PHY : TAY : JSL.l Link_ReceiveItem : PLY
RTL
;--------------------------------------------------------------------------------
LoadBonkItem:
LDA.b RoomIndex ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte
CMP.b #115 : BNE + ; Desert Bonk Key
LDA.l BonkKey_Desert
BRA ++
+ : CMP.b #140 : BNE + ; GTower Bonk Key
LDA.l BonkKey_GTower
BRA ++
+
LDA.b #$24 ; default to small key
++
RTS
;--------------------------------------------------------------------------------
AbsorbKeyCheck:
PHA
CMP.b #$24 : BEQ .key
CMP.b #$A0 : BCC .not_key
CMP.b #$B0 : BCS .not_key
AND.b #$0F : ASL
CMP.w DungeonID : BNE .not_key
.key
PLA
SEC
RTS
.not_key
PLA
CLC
RTS