forked from CaitSith2/z3randomizer
-
Notifications
You must be signed in to change notification settings - Fork 4
/
bookofmudora.asm
103 lines (99 loc) · 3.45 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
102
103
;================================================================================
; Randomize Book of Mudora
;--------------------------------------------------------------------------------
LoadLibraryItemGFX:
%GetPossiblyEncryptedPlayerID(LibraryItem_Player) : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID
%GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues)
STA $0E80, X ; Store item type
JSL.l PrepDynamicTile
RTL
;--------------------------------------------------------------------------------
DrawLibraryItemGFX:
PHA
LDA $0E80, X ; Retrieve stored item type
JSL.l DrawDynamicTile
PLA
RTL
;--------------------------------------------------------------------------------
SetLibraryItem:
PHA
LDY $0E80, X ; Retrieve stored item type
PLA
JSL.l ItemSet_Library ; contains thing we wrote over
RTL
;--------------------------------------------------------------------------------
;0x0087 - Hera Room w/key
;================================================================================
; Randomize Bonk Keys
;--------------------------------------------------------------------------------
!REDRAW = "$7F5000"
!BONK_ITEM_ROOM = "$7F5400"
!BONK_ITEM_PLAYER_ROOM = "$7F5401"
!BONK_ITEM = "$7F5402"
!BONK_ITEM_PLAYER = "$7F5403"
;--------------------------------------------------------------------------------
LoadBonkItemGFX:
LDA.b #$08 : STA $0F50, X ; thing we wrote over
LoadBonkItemGFX_inner:
LDA.b #$00 : STA !REDRAW
JSR LoadBonkItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID
JSR LoadBonkItem
JSL.l PrepDynamicTile
RTL
;--------------------------------------------------------------------------------
DrawBonkItemGFX:
PHA
LDA !REDRAW : BEQ .skipInit ; skip init if already ready
JSL.l LoadBonkItemGFX_inner
BRA .done ; don't draw on the init frame
.skipInit
JSR LoadBonkItem
JSL.l DrawDynamicTileNoShadow
.done
PLA
RTL
;--------------------------------------------------------------------------------
GiveBonkItem:
JSR LoadBonkItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID
JSR LoadBonkItem
CMP #$24 : BNE .notKey
.key
PHY : LDY.b #$24 : JSL.l AddInventory : PLY ; do inventory processing for a small key
LDA $7EF36F : INC A : STA $7EF36F
LDA.b #$2F : JSL.l Sound_SetSfx3PanLong
JSL CountBonkItem
RTL
.notKey
PHY : TAY : JSL.l Link_ReceiveItem : PLY
JSL CountBonkItem
RTL
;--------------------------------------------------------------------------------
LoadBonkItem:
LDA $A0 ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte
CMP !BONK_ITEM_ROOM : BNE + : LDA !BONK_ITEM : BRA ++
+ : STA !BONK_ITEM_ROOM
CMP #115 : BNE + ; Desert Bonk Key
%GetPossiblyEncryptedItem(BonkKey_Desert, HeartPieceIndoorValues) : STA !BONK_ITEM
BRA ++
+ : CMP #140 : BNE + ; GTower Bonk Key
%GetPossiblyEncryptedItem(BonkKey_GTower, HeartPieceIndoorValues) : STA !BONK_ITEM
BRA ++
+
LDA.b #$24 : STA !BONK_ITEM ; default to small key
++
RTS
;--------------------------------------------------------------------------------
LoadBonkItem_Player:
LDA $A0 ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte
CMP !BONK_ITEM_PLAYER_ROOM : BNE + : LDA !BONK_ITEM_PLAYER : BRA ++
+ : STA !BONK_ITEM_PLAYER_ROOM
CMP #115 : BNE + ; Desert Bonk Key
%GetPossiblyEncryptedPlayerID(BonkKey_Desert_Player) : STA !BONK_ITEM_PLAYER
BRA ++
+ : CMP #140 : BNE + ; GTower Bonk Key
%GetPossiblyEncryptedPlayerID(BonkKey_GTower_Player) : STA !BONK_ITEM_PLAYER
BRA ++
+
LDA.b #$00 : STA !BONK_ITEM_PLAYER
++
RTS