-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathequipment.asm
2456 lines (1566 loc) · 55.8 KB
/
equipment.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ==============================================================================
; *$6DD2A-$6DD31 JUMP LOCATION
Messaging_Equipment:
{
; Module E submodule 1 (Item submenu)
PHB : PHK : PLB
JSR Equipment_Local
PLB
RTL
}
; start of namespace
namespace "Equipment_"
; ==============================================================================
; *$6DD32-$6DD35 LONG
UpdateEquippedItemLong:
{
JSR UpdateHUD_updateEquippedItem
RTL
}
; ==============================================================================
; *$6DD36-$6DD59 LOCAL
Local:
{
; Appears to be a simple debug frame counter (8-bit) for this submodule
; Of course, it loops back every 256 frames
INC $0206
LDA $0200
JSL UseImplicitRegIndexedLocalJumpTable
dw ClearTilemap ; $DD5A = $6DD5A*
dw Init ; $DDAB = $6DDAB*
dw BringMenuDown ; $DE59 = $6DE59*
dw ChooseNextMode ; $DE6E = $6DE6E*
dw NormalMenu ; $DF15 = $6DF15*
dw UpdateHUD ; $DFA9 = $6DFA9*
dw CloseMenu ; $DFBA = $6DFBA*
dw GotoBottleMenu ; $DFFB = $6DFFB*
dw InitBottleMenu ; $E002 = $6E002*
dw ExpandBottleMenu ; $E08C = $6E08C*
dw BottleMenu ; $E0DF = $6E0DF*
dw EraseBottleMenu ; $E2FD = $6E2FD*
dw RestoreNormalMenu ; $E346 = $6E346*
}
; ==============================================================================
; *$6DD5A-$6DDAA JUMP LOCATION
ClearTilemap:
{
; This routine sets up a DMA transfer from
; $7E1000 to $6800 (word address) in VRAM
; Basically clears out
; Also plays the menu coming down sound, then moves to the next step
REP #$20
LDX.b #$00
; value of a transparent tile
LDA.b #$207F
.clearVramBuffer
STA $1000, X : STA $1080, X
STA $1100, X : STA $1180, X
STA $1200, X : STA $1280, X
STA $1300, X : STA $1380, X
STA $1400, X : STA $1480, X
STA $1500, X : STA $1580, X
STA $1600, X : STA $1680, X
STA $1700, X : STA $1780, X
INX #2 : CPX.b #$80
BNE .clearVramBuffer
SEP #$20
; play sound effect for opening item menu
LDA.b #$11 : STA $012F
; tell NMI to update tilemap
LDA.b #$01 : STA $17
; the region of tilemap to update is word address $6800 (this value 0x22 indexes into a table in NMI)
LDA.b #$22 : STA $0116
; move to next step of the submodule
INC $0200
RTS
}
; ==============================================================================
; *$6DDAB-$6DE58 JUMP LOCATION
Init:
{
; Module 0x0E.0x01.0x01
JSR CheckEquippedItem ; $6E399 IN ROM; Handles which item to equip (if none is equipped)
LDA.b #$01
JSR GetPaletteMask ; $00[2] = 0xFFFF
JSR DrawYButtonItems
LDA.b #$01
JSR GetPaletteMask
JSR DrawUknownBox ; $6E647 IN ROM; Construct a portion of the menu.
LDA.b #$01
JSR GetPaletteMask
JSR DrawAbilityText
JSR DrawAbilityIcons
JSR DrawProgressIcons
JSR DrawMoonPearl
JSR UnfinishedRoutine
LDA.b #$01
JSR GetPaletteMask
JSR DrawEquipment
JSR DrawShield
JSR DrawArmor
JSR DrawMapAndBigKey
JSR DrawCompass
LDX.b #$12
LDA $7EF340
; check if we have any equippable items available
.itemCheck
ORA $7EF341, X : DEX
BPL .itemCheck
CMP.b #$00
BEQ .noEquipableItems
LDA $7EF35C : ORA $7EF35D : ORA $7EF35E : ORA $7EF35F
BNE .haveBottleItems
BRA .haveNoBottles
.haveBottleItems
LDA $7EF34F
; There is a difference between having bottled items and having
; at least one bottle to put them in. $7EF34F acts as a flag for that.
BNE .hasBottleFlag
TAY
INY
LDA $7EF35C
BNE .selectThisBottle
INY
LDA $7EF35D
BNE .selectThisBottle
INY
LDA $7EF35E
BNE .selectThisBottle
INY
.selectThisBottle
TYA
.haveNoBottles
STA $7EF34F
.hasBottleFlag
JSR DoWeHaveThisItem
BCS .weHaveIt
JSR TryEquipNextItem
.weHaveIt
JSR DrawSelectedYButtonItem
; Does the player have a bottle equipped currently?
LDA $0202 : CMP.b #$10
BNE .equippedItemIsntBottle
LDA.b #$01
JSR GetPaletteMask
JSR DrawBottleMenu
.equippedItemIsntBottle
.noEquipableItems
; Start a timer
LDA.b #$10 : STA $0207
; Make NMI update BG3 tilemap
LDA.b #$01 : STA $17
; update vram address $6800 (word)
LDA.b #$22 : STA $0116
; move on to next step of the submodule
INC $0200
RTS
}
; ==============================================================================
; *$6DE59-$6DE6D JUMP LOCATION
BringMenuDown:
{
REP #$20
LDA $EA : SUB.w #$0008 : STA $EA : CMP.w #$FF18
SEP #$20
BNE .notDoneScrolling
INC $0200
.notDoneScrolling
RTS
}
; ==============================================================================
; *$6DE6E-$6DEAF JUMP LOCATION
ChooseNextMode:
{
; Makes a determination whether to go to the normal menu handling mode
; or the bottle submenu handling mode.
; there's also mode 0x05... which appears to be hidden at this point.
LDX.b #$12
LDA $7EF340
.haveAnyEquippable
ORA $7EF341, X : DEX : BPL .haveAnyEquippable
CMP.b #$00 : BEQ .haveNone
; Tell NMI to update BG3 tilemap next from by writing to address $6800 (word) in vram
LDA.b #$01 : STA $17
LDA.b #$22 : STA $0116
JSR DoWeHaveThisItem : BCS .weHaveIt
JSR TryEquipNextItem
.weHaveIt
JSR DrawSelectedYButtonItem
; Move to the next step of the submodule
LDA.b #$04 : STA $0200
LDA $0202 : CMP.b #$10 : BNE .notOnBottleMenu
; switch to the step of this submodule that handles when the
; bottle submenu is up
LDA.b #$0A : STA $0200
.notOnBottleMenu
RTS
.haveNone
; BYSTudlr
LDA $F4 : BEQ .noButtonPress
LDA.b #$05 : STA $0200
RTS
.noButtonPress
RTS
}
; ==============================================================================
; *$6DEB0-$6DEBC LOCAL
DoWeHaveThisItem:
{
LDX $0202
; Check to see if we have this item...
LDA $7EF33F, X
BNE .haveThisItem
CLC
RTS
.haveThisItem
SEC
RTS
}
; ==============================================================================
; *$6DEBD-$6DECA LOCAL
GoToPrevItem:
{
LDA $0202 : DEC A : CMP.b #$01 : BCS .dontReset
LDA.b #$14
.dontReset
STA $0202
RTS
}
; ==============================================================================
; *$6DECB-$6DED8 LOCAL
GotoNextItem:
{
; Load our currently equipped item, and move to the next one
; If we reach our limit (21), set it back to the bow and arrow slot.
LDA $0202 : INC A : CMP.b #$15 : BCC .dontReset
LDA.b #$01
.dontReset
; Otherwise try to equip the item in the next slot
STA $0202
RTS
}
; ==============================================================================
; *$6DED9-$6DEE1 LOCAL
TryEquipPrevItem:
{
.keepLooking
JSR GoToPrevItem
JSR DoWeHaveThisItem : BCC .keepLooking
RTS
}
; ==============================================================================
; *$6DEE2-$6DEEA JUMP LOCATION
TryEquipNextItem:
{
.keepLooking
JSR GoToNextItem
JSR DoWeHaveThisItem : BCC .keepLooking
RTS
}
; ==============================================================================
; *$6DEEB-$6DEFF LOCAL
TryEquipItemAbove:
{
.keepLooking
JSR GoToPrevItem
JSR GoToPrevItem
JSR GoToPrevItem
JSR GoToPrevItem
JSR GoToPrevItem
JSR DoWeHaveThisItem : BCC .keepLooking
RTS
}
; ==============================================================================
; *$6DF00-$6DF14 LOCAL
TryEquipItemBelow:
{
.keepLooking
JSR GoToNextItem
JSR GoToNextItem
JSR GoToNextItem
JSR GoToNextItem
JSR GoToNextItem
JSR DoWeHaveThisItem : BCC .keepLooking
RTS
}
; ==============================================================================
; *$6DF15-$6DFA8 JUMP LOCATION
NormalMenu:
{
INC $0207
; BYSTudlr
LDA $F0 : BNE .inputReceived
; Reset the ability to select a new item
STZ $BD
.inputReceived
; check if the start button was pressed this frame
LDA $F4 : AND.b #$10 : BEQ .dontLeaveMenu
; bring the menu back up and play the vvvvoooop sound as it comes up.
LDA.b #$05 : STA $0200
LDA.b #$12 : STA $012F
RTS
.dontLeaveMenu
; After selecting a new item, you have to release all of the BYSTudlr inputs
; before you can select a new item. Notice how $BD gets set back low if you
; aren't holding any of those buttons.
LDA $BD : BNE .didntChange
LDA $0202 : STA $00
; Joypad 2.... interesting. It's checking the R button.
LDA $F7 : AND.b #$10 : BEQ .dontBeAJackass
; Apparently pressing R on Joypad 2 (if it's enabled) deletes your currently selected item.
; Imagine playing the game with your friend constantly trying to delete your items
; Lots of punching would ensue.
LDX $0202
LDA.b #$00 : STA $7EF33F, X
; unlike .movingOut, Anthony's Song.
BRA .movingOn
.dontBeAJackass
; BYSTudlr says that we're checking if the up direction is pressed!!!!!! RAWWWWWWWRRRHHGHGH!!!!!
; BYSTudrl sounds like a name, like Baiyst Yudler, a German superbrute that hacks roms by breaking them in two!!!!
; And then he breaks them into many other numbers bigger than two!!!!!
LDA $F4 : AND.b #$08 : BEQ .notPressingUp
JSR TryEquipItemAbove
BRA .movingOn
.notPressingUp
; Don't piss off BYSTudlr - he likes playing Mr. Potato Head.
; The problem is he skips the potato part and goes straight for the head.
; (In spite of this, I find most of his work quite artistic and tasteful.)
LDA $F4 : AND.b #$04 : BEQ .notPressingDown
JSR TryEquipItemBelow
BRA .movingOut
.notPressingDown
; BYSTudlr is not going to pump you up, girly man. His sensibilities are far more refined than that.
LDA $F4 : AND.b #$02 : BEQ .notPressingLeft
JSR TryEquipPrevItem
BRA .movingOn
.notPressingLeft
; When BYSTudlr gets really hungry he makes chicken soup.
; Recipe (translated from German): Fill bathtub with chicken broth. Put chickens in tub. Eat.
LDA $F4 : AND.b #$01 : BEQ .notPressingRight
JSR TryEquipNextItem
.notPressingRight
LDA $F4 : STA $BD
; check if the currently equipped item changed
LDA $0202 : CMP.b $00 : BEQ .didntChange
; Reset a timer and play a sound effect
LDA.b #$10 : STA $0207
LDA.b #$20 : STA $012F
.didntChange
LDA.b #$01
JSR GetPaletteMask
JSR DrawYButtonItems
JSR DrawSelectedYButtonItem
; check if we ended up selecting a bottle this frame
LDA $0202 : CMP.b #$10 : BNE .didntSelectBottle
; switch to the bottle submenu handler
LDA.b #$07 : STA $0200
.didntSelectBottle
; Tell NMI to update BG3 tilemap next from by writing to address $6800 (word) in vram
LDA.b #$01 : STA $17
LDA.b #$22 : STA $0116
RTS
}
; ==============================================================================
; *$6DFA9-$6DFB9 LOCAL
UpdateHUD:
{
; Move on to next step.
INC $0200
JSR HUD.Rebuild.updateOnly
; *$6DFAF ALTERNATE ENTRY POINT
.updateEquippedItem
; Using the item selected in the item menu,
; set a value that tells us what item to use during actual
; gameplay. (Y button items, btw)
LDX $0202
LDA $0DFA15, X : STA $0303
RTS
}
; ==============================================================================
; *$6DFBA-$6DFFA JUMP LOCATION
CloseMenu:
{
.scroll_up_additional_8_pixels
REP #$20
; Scroll the menu back up so it's off screen (8 pixels at a time)
LDA $EA : ADD.w #$0008 : STA $EA : SEP #$20 : BNE .notDoneScrolling
JSR HUD.Rebuild
; reset submodule and subsubmodule indices
STZ $0200
STZ $11
; Go back to the module we came from
LDA $010C : STA $10
; Why this is checked, I dunno. notice the huge whopping STZ $11 up above? Yeah, I thought so.
LDA $11 : BEQ .noSpecialSubmode
; This seems random and out of place. There's not even a check to make sure we're indoors.
; Unless that LDA $11 up above was meant to be LDA $1B
JSL RestoreTorchBackground
.noSpecialSubmode
LDA $0303
CMP.b #$05 : BEQ .fireRod
CMP.b #$06 : BEQ .iceRod
LDA.b #$02 : STA $034B
STZ $020B
BRA .return
.fireRod
.iceRod
; Okay, so contrary to what I thought this did previously in the
; abstract, it actually positions the HUD up by 8 pixels higher than
; it would normally be if you select one of the rods and this variable
; $020B is also set. That's it.
LDA $020B : BNE .scroll_up_additional_8_pixels
STZ $034B
.notDoneScrolling
.return
RTS
}
; ==============================================================================
; *$6DFFB-$6E001 JUMP LOCATION
GotoBottleMenu:
{
STZ $0205
INC $0200
RTS
}
; ==============================================================================
; *$6E002-$6E04F JUMP LOCATION
InitBottleMenu:
{
REP #$30
LDA $0205 : AND.w #$00FF : ASL #6 : TAX
LDA.w #$207F
STA $12EA, X : STA $12EC, X : STA $12EE, X : STA $12F0, X
STA $12F2, X : STA $12F4, X : STA $12F6, X : STA $12F8, X
STA $12FA, X : STA $12FC, X
SEP #$30
INC $0205
LDA $0205 : CMP.b #$13 : BNE .notDoneErasing
INC $0200
LDA.b #$11 : STA $0205
.notDoneErasing
; Tell NMI to update BG3 tilemap next from by writing to address $6800 (word) in vram
LDA.b #$01 : STA $17
LDA.b #$22 : STA $0116
RTS
}
; ==============================================================================
; $6E050-$6E08B DATA
{
dw $28FB, $28F9, $28F9, $28F9, $28F9
dw $28F9, $28F9, $28F9, $28F9, $68FB
; $6E064
dw $28FC, $24F5, $24F5, $24F5, $24F5
dw $24F5, $24F5, $24F5, $24F5, $68FC
; $6E078
dw $A8FB, $A8F9, $A8F9, $A8F9, $A8F9
dw $A8F9, $A8F9, $A8F9, $A8F9, $E8FB
}
; ==============================================================================
; *$6E08C-$6E0DE JUMP LOCATION
ExpandBottleMenu:
{
; each frame of this causes the bottle menu frame
; to expand upward by by one tile
REP #$30
LDA $0205 : AND.w #$00FF : ASL #6 : TAX : PHX
LDY.w #$0012
.drawBottleMenuTop
LDA $E050, Y : STA $12FC, X
DEX #2 : DEY #2 : BPL .drawBottleMenuTop
PLX
LDY.w #$0012
; each subsequent frame, this will overwrite the top of the menu
; from the previous frame until fully expanded
.eraseOldTop
LDA $E064, Y : STA $133C, X
DEX #2
DEY #2 : BPL .eraseOldTop
LDX.w #$0012
; probably only really needs to be done during the first frame of this
; step of the submodule
.drawBottleMenuBottom
LDA $E078, X : STA $176A, X
DEX #2 : BPL .drawBottleMenuBottom
SEP #$30
DEC $0205 : LDA $0205 : BPL .notDoneDrawing
INC $0200
.notDoneDrawing
; Tell NMI to update BG3 tilemap next from by writing to address $6800 (word) in vram
LDA.b #$01 : STA $17
LDA.b #$22 : STA $0116
RTS
}
; ==============================================================================
; *$6E0DF-$6E176 JUMP LOCATION
BottleMenu:
{
INC $0207
; Check if the start button was pressed this frame
LDA $F4 : AND.b #$10 : BEQ .dontCloseMenu
; close the item menu and play the vvvoooop sound as it goes up
LDA.b #$12 : STA $012F
LDA.b #$05 : STA $0200
BRA .lookAtUpDownInput
.dontCloseMenu
LDA $F4 : AND.b #$03 : BEQ .noLeftRightInput
LDA $F4 : AND.b #$02 : BEQ .noLeftInput
JSR TryEquipPrevItem
BRA .movingOn
.noLeftInput
LDA $F4 : AND.b #$01 : BEQ .noRightInput
JSR TryEquipNextItem
.noRightInput
.movingOn
; play sound effect and start a timer to keep
; us from switching items for 16 frames.
LDA.b #$10 : STA $0207
LDA.b #$20 : STA $012F
LDA.b #$01
JSR GetPaletteMask
JSR DrawYButtonItems
JSR DrawSelectedYButtonItem
; Since left or right was pressed, we're exiting the bottle menu
; and going back to the normal menu.
INC $0200
STZ $0205
RTS
.noLeftRightInput
.lookAtUpDownInput
JSR UpdateBottleMenu
LDA $F4 : AND.b #$0C : BNE .haveUpDownInput
; there's no input, so nothing happens.
RTS
.haveUpDownInput
LDA $7EF34F : DEC A : STA $00 : STA $02
LDA $F4 : AND.b #$08 : BEQ .haveUpInput
.selectPrevBottle
LDA $00 : DEC A : AND.b #$03 : STA $00 : TAX
LDA $7EF35C, X : BEQ .selectPrevBottle
BRA .bottleIsSelected
.haveUpInput
.selectNextBottle
LDA $00 : INC A : AND.b #$03 : STA $00 : TAX
LDA $7EF35C, X : BEQ .selectNextBottle
.bottleIsSelected
LDA $00 : CMP $02 : BEQ .sameBottleWhoCares
; record which bottle was just selected
INC A : STA $7EF34F
; If it's not the same bottle we play the
; obligatory item switch sound effect
LDA.b #$10 : STA $0207
LDA.b #$20 : STA $012F
.sameBottleWhoCares
RTS
}
; ==============================================================================
; $6E177-$6E17E DATA
; ==============================================================================
; *$6E17F-$6E2FC LOCAL
UpdateBottleMenu:
{
REP #$30
LDX.w #$0000
LDY.w #$0007
LDA.w #$24F5
.erase
STA $132C, X : STA $136C, X
STA $13AC, X : STA $13EC, X
STA $142C, X : STA $146C, X
STA $14AC, X : STA $14EC, X
STA $152C, X : STA $156C, X
STA $15AC, X : STA $15EC, X
STA $162C, X : STA $166C, X
STA $16AC, X : STA $16EC, X
STA $172C, X
INX #2
DEY : BPL .erase
; Draw the 4 bottle icons (if we don't have that bottle it just draws blanks)
LDA.w #$1372 : STA $00
LDA $7EF35C : AND.w #$00FF : STA $02
LDA.w #$F751 : STA $04
JSR DrawItem
LDA.w #$1472 : STA $00
LDA $7EF35D : AND.w #$00FF : STA $02
LDA.w #$F751 : STA $04
JSR DrawItem
LDA.w #$1572 : STA $00
LDA $7EF35E : AND.w #$00FF : STA $02
LDA.w #$F751 : STA $04
JSR DrawItem
LDA.w #$1672 : STA $00
LDA $7EF35F : AND.w #$00FF : STA $02
LDA.w #$F751 : STA $04
JSR DrawItem
LDA.w #$1408 : STA $00
LDA $7EF34F : AND.w #$00FF : TAX : BNE .haveBottleEquipped
LDA.w #$0000
BRA .drawEquippedBottle
.haveBottleEquipped
LDA $7EF35B, X : AND.w #$00FF
.drawEquippedBottle
STA $02
LDA.w #$F751 : STA $04
JSR DrawItem
LDA $0202 : AND.w #$00FF : DEC A : ASL A : TAX
LDY $FAD5, X
LDA $0000, Y : STA $11B2
LDA $0002, Y : STA $11B4
LDA $0040, Y : STA $11F2
LDA $0042, Y : STA $11F4
LDA $7EF34F : DEC A : AND.w #$00FF : ASL A : TAY
LDA $E177, Y : TAY
LDA $0207 : AND.w #$0010 : BEQ .return
LDA.w #$3C61 : STA $12AA, Y
ORA.w #$4000 : STA $12AC, Y
LDA.w #$3C70 : STA $12E8, Y
ORA.w #$4000 : STA $12EE, Y
LDA.w #$BC70 : STA $1328, Y
ORA.w #$4000 : STA $132E, Y
LDA.w #$BC61 : STA $136A, Y
ORA.w #$4000 : STA $136C, Y
LDA.w #$3C60 : STA $12A8, Y
ORA.w #$4000 : STA $12AE, Y
ORA.w #$8000 : STA $136E, Y
EOR.w #$4000 : STA $1368, Y
LDA $7EF34F : AND.w #$00FF : BEQ .noSelectedBottle
TAX
LDA $7EF35B, X : AND.w #$00FF : DEC A : ASL #5 : TAX
LDY.w #$0000
.writeBottleDescription
LDA $F449, X : STA $122C, Y
LDA $F459, X : STA $126C, Y
INX #2
INY #2 : CPY.w #$0010
BCC .writeBottleDescription
.return
.noSelectedBottle
SEP #$30