@gaialabs/iog-baserom 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/baserom/auto-use-items/CellKeysAutoUse.patch.asm +30 -0
- package/baserom/auto-use-items/CrystalBallAutoUse.patch.asm +131 -0
- package/baserom/auto-use-items/DiamondBlockAutoUse.patch.asm +50 -0
- package/baserom/auto-use-items/ElevatorKeyAutoUse.patch.asm +26 -0
- package/baserom/auto-use-items/GorgonFlowerAutoUse.patch.asm +153 -0
- package/baserom/auto-use-items/HieroglyphPuzzle.patch.asm +1187 -0
- package/baserom/auto-use-items/HopeStatueAutoUse.patch.asm +99 -0
- package/baserom/auto-use-items/IncanStatueAutoUse.patch.asm +75 -0
- package/baserom/auto-use-items/ItemUseStub.patch.asm +24 -0
- package/baserom/auto-use-items/MagicPowerAutoUse.patch.asm +55 -0
- package/baserom/auto-use-items/MeatAutoUse.patch.asm +33 -0
- package/baserom/auto-use-items/MushroomDropAutoUse.patch.asm +100 -0
- package/baserom/auto-use-items/PalaceKeyAutoUse.patch.asm +52 -0
- package/baserom/auto-use-items/PrisonKeyAutoUse.patch.asm +84 -0
- package/baserom/auto-use-items/PurificationStoneAutoUse.patch.asm +49 -0
- package/baserom/auto-use-items/RamaStatueAutoUse.patch.asm +100 -0
- package/baserom/auto-use-items/TearpotAutoUse.patch.asm +41 -0
- package/baserom/{spritemaps → boot-logo}/spm_boot_logos.sprite.asm +10 -0
- package/baserom/collectible-system/RelicMenu.patch.asm +250 -0
- package/baserom/collectible-system/key_item_core.asm +445 -0
- package/baserom/{patches → equipped-icon}/EquippedIcon.patch.asm +41 -24
- package/baserom/equipped-icon/ItemSwapping.patch.asm +99 -0
- package/baserom/{palettes → equipped-icon}/pal_item_exprite2.pal +0 -0
- package/baserom/{spritemaps → equipped-icon}/spm_sc02_main_characters.sprite.asm +10 -0
- package/baserom/equipped-icon/spriteset_aura.asm +131 -0
- package/baserom/equipped-icon/spriteset_dark_friar.asm +277 -0
- package/baserom/equipped-icon/spriteset_darkgaia_projectile.asm +233 -0
- package/baserom/fixes-tweaks/BCDHex.patch.asm +60 -0
- package/baserom/fixes-tweaks/HudRedesign.patch.asm +108 -0
- package/baserom/fixes-tweaks/NeilsFatherFix.patch.asm +26 -0
- package/baserom/fixes-tweaks/PyramidPortalExit.patch.asm +41 -0
- package/baserom/fixes-tweaks/SceneTitles.patch.asm +84 -0
- package/baserom/fixes-tweaks/ThankfulFlower.patch.asm +28 -0
- package/baserom/fixes-tweaks/Utils.patch.asm +111 -0
- package/baserom/{spritemaps → fixes-tweaks}/spm_goldship_sprites.sprite.asm +11 -0
- package/baserom/fonts/EnhancedOverworldText.patch.asm +44 -0
- package/baserom/fonts/EnhancedPrologueText.patch.asm +252 -0
- package/baserom/{graphics → fonts}/gfx_fonts.bin +0 -0
- package/baserom/fonts/gfx_overworld_font.bin +0 -0
- package/baserom/inventory/EnhancedSlotActor.patch.asm +50 -0
- package/baserom/inventory/InventoryCounters.patch.asm +407 -0
- package/baserom/inventory/InventoryManagement.patch.asm +390 -0
- package/baserom/kara-run/gfx_castle_sprites.bin +0 -0
- package/baserom/new-game-plus/NGPEpilogueSwitch.patch.asm +52 -0
- package/baserom/{patches → new-game-plus}/NewGamePlus.patch.asm +42 -23
- package/baserom/oakton/map_fr30.map +0 -0
- package/baserom/oakton/map_fr30_effect.map +0 -0
- package/baserom/options-menu/EnhancedInvItemPicker.patch.asm +130 -0
- package/baserom/options-menu/MinimalHudOption.patch.asm +109 -0
- package/baserom/options-menu/OptionsMenu.patch.asm +218 -0
- package/baserom/options-menu/TextSpeedOption.patch.asm +108 -0
- package/baserom/options-menu/options_input_remap.asm +373 -0
- package/baserom/options-menu/options_menu_core.asm +1221 -0
- package/baserom/patches/APUWaitFixes.patch.asm +30 -17
- package/baserom/patches/AccentMap.patch.asm +16 -5
- package/baserom/patches/MusicTransitions.patch.asm +41 -24
- package/baserom/player-input/MergeInputFlags.patch.asm +146 -0
- package/baserom/player-input/PlayerInput.patch.asm +51 -0
- package/baserom/red-jewels/AnnSparkle.patch.asm +28 -0
- package/baserom/red-jewels/ChestFlaggedHiddenRedJewel.patch.asm +50 -0
- package/baserom/red-jewels/FishermanRedJewel.patch.asm +55 -0
- package/baserom/red-jewels/LanceSparkle.patch.asm +38 -0
- package/baserom/red-jewels/RedJewelSparkle.patch.asm +49 -0
- package/baserom/red-jewels/SnakePanicSparkle.patch.asm +45 -0
- package/baserom/red-jewels/SparkleAlways.patch.asm.example +19 -0
- package/baserom/red-jewels/StoneGirlSparkle.patch.asm +26 -0
- package/baserom/red-jewels/TrappedSlaveSparkle.patch.asm +63 -0
- package/baserom/red-jewels/generic_sparkle.asm +57 -0
- package/baserom/run-button/RunButtonCore.patch.asm +89 -0
- package/baserom/run-button/RunButtonOption.patch.asm +50 -0
- package/baserom/{patches/BitmapPatch.patch.asm → scene-load/BitmapLoad.patch.asm} +27 -12
- package/baserom/scene-load/Cop51Decompress.patch.asm +98 -0
- package/baserom/scene-load/ExpriteLoader.patch.asm +82 -0
- package/baserom/scene-load/MapNameLookup.patch.asm +27 -0
- package/baserom/scene-load/MenuBGLoad.patch.asm +70 -0
- package/baserom/scene-load/SFXTable.patch.asm +92 -0
- package/baserom/scene-load/SceneMetaLoad.patch.asm +68 -0
- package/baserom/scene-load/SpritemapLoad.patch.asm +61 -0
- package/baserom/scene-load/TilemapLoad.patch.asm +109 -0
- package/baserom/scene-load/TilesetLoad.patch.asm +41 -0
- package/baserom/set_overworld.set +0 -0
- package/baserom/seths-jewel/SethsJewelGoldShip.patch.asm +22 -0
- package/baserom/seths-jewel/SethsJewelIcon.patch.asm +22 -0
- package/baserom/seths-jewel/SethsJewelItem.patch.asm +62 -0
- package/baserom/seths-jewel/SethsJewelSprites.patch.asm +49 -0
- package/baserom/{patches → sky-delivery}/SouthCapeDeliveryman.patch.asm +12 -3
- package/baserom/sky-delivery/WatermiaDeliveryman.patch.asm +15 -0
- package/dist/index.cjs +10159 -964
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +10161 -967
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -8
- package/baserom/asm/spriteset_aura.asm +0 -122
- package/baserom/asm/spriteset_dark_friar.asm +0 -268
- package/baserom/asm/spriteset_will_projectile.asm +0 -224
- package/baserom/patches/Cop51Patch.patch.asm +0 -81
- package/baserom/patches/DPShop.asm.old +0 -328
- package/baserom/patches/DeathWarp.asm.old +0 -174
- package/baserom/patches/ExpandedHealthBars.old +0 -203
- package/baserom/patches/ExpriteLoader.patch.asm +0 -66
- package/baserom/patches/GemShop.asm.old +0 -345
- package/baserom/patches/InventoryCounters.patch.asm +0 -292
- package/baserom/patches/InventoryManagement.patch.asm +0 -324
- package/baserom/patches/InventoryScript.asm.old +0 -319
- package/baserom/patches/ItemDictionary.asm.old +0 -86
- package/baserom/patches/ItemRewards.asm.old +0 -49
- package/baserom/patches/ItemSwapping.patch.asm +0 -80
- package/baserom/patches/MapNameLookup.patch.asm +0 -13
- package/baserom/patches/MenuBGPatch.patch.asm +0 -54
- package/baserom/patches/NGPEpilogueSwitch.patch.asm +0 -44
- package/baserom/patches/PixelConverter.patch.asm.old +0 -60
- package/baserom/patches/QuickScripts.asm.old +0 -210
- package/baserom/patches/RunButton.patch.asm +0 -79
- package/baserom/patches/SFXTable.patch.asm +0 -73
- package/baserom/patches/SceneLoadPatch.patch.asm +0 -52
- package/baserom/patches/SpritemapPatch.patch.asm +0 -45
- package/baserom/patches/Teleporter.patch.asm.old +0 -203
- package/baserom/patches/TilemapPatch.patch.asm +0 -94
- package/baserom/patches/TilesetPatch.patch.asm +0 -27
- package/baserom/patches/Utils.patch.asm +0 -414
- package/baserom/patches/WatermiaDeliveryman.patch.asm +0 -2
- /package/baserom/{graphics → boot-logo}/gfx_boot_exprite.raw.bin +0 -0
- /package/baserom/{graphics → boot-logo}/gfx_boot_logos.bin +0 -0
- /package/baserom/{palettes → boot-logo}/pal_boot_logos.pal +0 -0
- /package/baserom/{palettes → equipped-icon}/fx_palette_198000.pal +0 -0
- /package/baserom/{graphics → equipped-icon}/gfx_item_exprite.raw.bin +0 -0
- /package/baserom/{graphics → equipped-icon}/misc_fx_1CD580.bin +0 -0
- /package/baserom/{palettes → equipped-icon}/pal_item_exprite.pal +0 -0
- /package/baserom/{palettes → equipped-icon}/pal_sc02_main_characters.pal +0 -0
- /package/baserom/{graphics → fonts}/gfx_credits_font.bin +0 -0
- /package/baserom/{graphics → inventory}/gfx_inventory_sprites.bin +0 -0
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
; ==============================================================================
|
|
2
|
+
; Options menu core - Optn. tab UI, button map editor, setting registry
|
|
3
|
+
; ==============================================================================
|
|
4
|
+
; What it does: Inventory Optn. tab (hover + full tab): left panel maps eight
|
|
5
|
+
; actions to physical buttons; right panel lists registered settings (24-byte
|
|
6
|
+
; records in InventoryOptionSetups, max 5 visible). Btn. Preset built-in.
|
|
7
|
+
; Vanilla behavior: No in-inventory options tab or save-backed button bytes UI.
|
|
8
|
+
; Hooks (overrides): None in this file (OptionsMenu.patch wires tab dispatch).
|
|
9
|
+
; Adds: TabHoverOptions, OptionsTab, OptionsDrawAll, Opt* helpers, registry
|
|
10
|
+
; anchors InventoryOptionSetups / OptionSettingPreset; other patches use
|
|
11
|
+
; OptionSettingPreset- chain inserts at file end for new settings.
|
|
12
|
+
; Depends on: options_input_remap, ConsoleStringRenderer, inventory actors,
|
|
13
|
+
; system_strings clears; assignment reads hardware $4218 not joypadRaw.
|
|
14
|
+
; State: Maps $0B34-$0B39; scratch $0BD0-$0BF6 (see !opt_* tags); packed
|
|
15
|
+
; options byte $0B3A (bits allocated per setting patches); displayModeFlags
|
|
16
|
+
; $09EC bit 0 for BG3 flush; bg1ConfigMode $0AE6 cleared for overlay.
|
|
17
|
+
; Hazards: COP requires X = actor slot; OptRenderString sets DBR to string bank
|
|
18
|
+
; for TBL temp reads (WRAM mirror); OptionsToggleMapping uses $@ for ROM table;
|
|
19
|
+
; handler RTS via OptCallHandler must restore X = D (actor id).
|
|
20
|
+
; ==============================================================================
|
|
21
|
+
|
|
22
|
+
?BANK 02
|
|
23
|
+
|
|
24
|
+
?INCLUDE 'options_input_remap'
|
|
25
|
+
?INCLUDE 'system_strings'
|
|
26
|
+
?INCLUDE 'inventory_spritemap'
|
|
27
|
+
?INCLUDE 'vblank_joypad'
|
|
28
|
+
?INCLUDE 'ConsoleStringRenderer'
|
|
29
|
+
|
|
30
|
+
!joypadHeld 0658
|
|
31
|
+
!joypadRaw 0660
|
|
32
|
+
!L_JOY1L 004218
|
|
33
|
+
!displayModeFlags 09EC
|
|
34
|
+
!bg1ConfigMode 0AE6
|
|
35
|
+
!inventoryTabIndex 0AFA
|
|
36
|
+
|
|
37
|
+
!btnMapA 0B34
|
|
38
|
+
!btnMapB 0B35
|
|
39
|
+
!btnMapX 0B36
|
|
40
|
+
!btnMapY 0B37
|
|
41
|
+
!btnMapL 0B38
|
|
42
|
+
!btnMapR 0B39
|
|
43
|
+
|
|
44
|
+
; WRAM scratch (inside $0BD0-$0BFB, the same scratch zone the debug menu uses).
|
|
45
|
+
; $0BD0-$0BDF 8 words: button display index per action row (TBL index into
|
|
46
|
+
; ButtonDisplayTable: 0 = blank, 1 = A, 2 = B, 3 = X, 4 = Y,
|
|
47
|
+
; 5 = L, 6 = R)
|
|
48
|
+
; $0BE0-$0BE9 5 words: setting temp values (see record +04)
|
|
49
|
+
; $0BEA-$0BEF 6 bytes: button map preview buffer (options_input_remap)
|
|
50
|
+
; $0BF0 byte offset of the currently selected record
|
|
51
|
+
; $0BF2 number of choices of the current setting (opt_count)
|
|
52
|
+
; $0BF4 bank byte of the string handed to OptRenderString
|
|
53
|
+
; $0BF6 Minimal HUD setting temp word (MinimalHudOption.patch.asm)
|
|
54
|
+
!opt_wram_base 0BD0
|
|
55
|
+
!opt_temp_preset 0BE8
|
|
56
|
+
!opt_map 0BEA
|
|
57
|
+
!opt_rec 0BF0
|
|
58
|
+
!opt_count 0BF2
|
|
59
|
+
!opt_str_bank 0BF4
|
|
60
|
+
|
|
61
|
+
; Record field offsets (see SETTING REGISTRY)
|
|
62
|
+
!ro_render 0000
|
|
63
|
+
!ro_desc 0003
|
|
64
|
+
!ro_temp 0006
|
|
65
|
+
!ro_store 0008
|
|
66
|
+
!ro_shift 000A
|
|
67
|
+
!ro_mask 000C
|
|
68
|
+
!ro_xor 000E
|
|
69
|
+
!ro_count 0010
|
|
70
|
+
!ro_load 0012
|
|
71
|
+
!ro_change 0014
|
|
72
|
+
!ro_commit 0016
|
|
73
|
+
!ro_stride 0018
|
|
74
|
+
|
|
75
|
+
---------------------------------------------
|
|
76
|
+
; Console strings for the options menu.
|
|
77
|
+
;
|
|
78
|
+
; LAYOUT: BG3 text is drawn over the BG1 status background (bg1ConfigMode=0).
|
|
79
|
+
; The upper content panel (rows 4-14) is cleared with consolestring_01E8E2
|
|
80
|
+
; before drawing, to remove any residual BG3 content from other tabs.
|
|
81
|
+
;
|
|
82
|
+
; POS coordinate reference (POS:lo,hi → offset (hi<<8)|lo, 64 bytes per tile row):
|
|
83
|
+
; Row 5, col 2 = $0104 → POS:04,1 (header line)
|
|
84
|
+
; Row 7, col 3 = $01C6 → POS:C6,1 (first action row)
|
|
85
|
+
; Row 22, col 11 = $0596 → POS:96,5 (description area)
|
|
86
|
+
; Settings start at row 5, col 19 (offset $0166) and advance 2 rows per setting.
|
|
87
|
+
optstr_pane |[PAL:0][POS:04,1]Button Mapping[N]--------------|
|
|
88
|
+
|
|
89
|
+
; Bottom-right description text
|
|
90
|
+
optstr_description |[PAL:0][POS:96,5]A to edit.[DBL]Assign buttons[DBL]to actions.|
|
|
91
|
+
|
|
92
|
+
; "Press a button..." prompt — replaces description during assignment mode
|
|
93
|
+
optstr_press_text |[PAL:0][POS:96,5]Press a[DBL]button...|
|
|
94
|
+
|
|
95
|
+
; Shown while a setting value is being edited
|
|
96
|
+
optstr_edit_hint |[PAL:0][POS:96,5]D-pad: change[DBL]A: confirm[DBL]B: cancel|
|
|
97
|
+
|
|
98
|
+
---------------------------------------------
|
|
99
|
+
; Button display table for TBL lookups.
|
|
100
|
+
; Index 0 = not assigned (space), 1-6 = physical button letter.
|
|
101
|
+
; Each entry is a pointer to a console string.
|
|
102
|
+
|
|
103
|
+
ButtonDisplayTable [
|
|
104
|
+
&btn_blank
|
|
105
|
+
&BtnNameA
|
|
106
|
+
&BtnNameB
|
|
107
|
+
&BtnNameX
|
|
108
|
+
&BtnNameY
|
|
109
|
+
&BtnNameL
|
|
110
|
+
&BtnNameR
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
---------------------------------------------
|
|
114
|
+
; Button name strings for TBL lookup via ButtonDisplayTable.
|
|
115
|
+
; Each is a 1-character console string used by optstr_rows_left.
|
|
116
|
+
|
|
117
|
+
btn_blank | |
|
|
118
|
+
BtnNameA |A|
|
|
119
|
+
BtnNameB |B|
|
|
120
|
+
BtnNameX |X|
|
|
121
|
+
BtnNameY |Y|
|
|
122
|
+
BtnNameL |L|
|
|
123
|
+
BtnNameR |R|
|
|
124
|
+
|
|
125
|
+
---------------------------------------------
|
|
126
|
+
; Action rows (left panel) rendered entirely through the ConsoleStringRenderer.
|
|
127
|
+
; Static action names are inline. One TBL lookup per row shows the
|
|
128
|
+
; assigned button letter, reading WRAM at $0BD0 + row*2.
|
|
129
|
+
;
|
|
130
|
+
; Row order matches ActionBitMasks: Confirm, Attack, Cancel, Use Item,
|
|
131
|
+
; Block, Block2, Run, Cycle Item.
|
|
132
|
+
|
|
133
|
+
optstr_rows_left |[PAL:0][POS:C6,1]\
|
|
134
|
+
Act/Confirm [TBL:@ButtonDisplayTable,BD0][N]\
|
|
135
|
+
Attack [TBL:@ButtonDisplayTable,BD2][N]\
|
|
136
|
+
Cancel [TBL:@ButtonDisplayTable,BD4][N]\
|
|
137
|
+
Use Item [TBL:@ButtonDisplayTable,BD6][N]\
|
|
138
|
+
Block [TBL:@ButtonDisplayTable,BD8][N]\
|
|
139
|
+
[PAL:14]Block2 [PAL:0][TBL:@ButtonDisplayTable,BDA][N]\
|
|
140
|
+
[PAL:14]Run [PAL:0][TBL:@ButtonDisplayTable,BDC][N]\
|
|
141
|
+
[PAL:14]Cycle Item [PAL:0][TBL:@ButtonDisplayTable,BDE]|
|
|
142
|
+
|
|
143
|
+
---------------------------------------------
|
|
144
|
+
; Btn. Preset — built-in setting (not persisted).
|
|
145
|
+
;
|
|
146
|
+
; Choices: Classic A, Classic B and, only while the live mapping matches
|
|
147
|
+
; neither, Custom. The record count is 2; OptPresetLoad raises opt_count to 3
|
|
148
|
+
; when the mapping is custom. Stepping previews the preset's buttons in the left
|
|
149
|
+
; panel; Confirm copies the preset into $0B34-$0B39, Cancel redraws from the
|
|
150
|
+
; untouched live mapping.
|
|
151
|
+
|
|
152
|
+
ButtonPresetOptions [
|
|
153
|
+
&preset_classic_a
|
|
154
|
+
&preset_classic_b
|
|
155
|
+
&preset_custom
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
preset_classic_a |Classic A|
|
|
159
|
+
preset_classic_b |Classic B|
|
|
160
|
+
preset_custom |Custom|
|
|
161
|
+
|
|
162
|
+
optstr_preset_render |[PAL:0]Btn. Preset[N] [PAL:14][TBL:@ButtonPresetOptions,BE8][PAL:0]|
|
|
163
|
+
optstr_preset_desc |[PAL:0][POS:96,5]Preset layouts for[DBL]all buttons.[DBL]A to choose.|
|
|
164
|
+
|
|
165
|
+
---------------------------------------------
|
|
166
|
+
; Setting registry (see header). Head word, then the records, then the
|
|
167
|
+
; delimiter. Btn. Preset is the built-in last record.
|
|
168
|
+
|
|
169
|
+
InventoryOptionSetups [
|
|
170
|
+
#$0018 ; record stride in bytes (records start after this word)
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
OptionSettingPreset [
|
|
174
|
+
@optstr_preset_render ;+00 render
|
|
175
|
+
@optstr_preset_desc ;+03 desc
|
|
176
|
+
#$0BE8 ;+06 temp
|
|
177
|
+
#$0000 ;+08 store (not persisted)
|
|
178
|
+
#$0000 ;+0A shift
|
|
179
|
+
#$0000 ;+0C mask
|
|
180
|
+
#$0000 ;+0E xor
|
|
181
|
+
#$0002 ;+10 count (OptPresetLoad adds Custom)
|
|
182
|
+
&OptPresetLoad ;+12 load
|
|
183
|
+
&OptPresetChange ;+14 change
|
|
184
|
+
&OptPresetCommit ;+16 commit
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
InventoryOptionSetupDelimiter #$FFFF
|
|
188
|
+
|
|
189
|
+
---------------------------------------------
|
|
190
|
+
; Cursor positions for SelectionCursorActor (X, Y pixel pairs) for the left
|
|
191
|
+
; panel. 8 rows at tile rows 7-14, spaced 8px (one tile row).
|
|
192
|
+
; X = 8px, one tile left of data column 3.
|
|
193
|
+
; Right panel cursors are computed (OptionsPositionCursor).
|
|
194
|
+
OptionsCursorPositions [
|
|
195
|
+
screen-pos < #$0008, #$0045 > ;00 row 7 Y=56
|
|
196
|
+
screen-pos < #$0008, #$004D > ;01 row 8 Y=64
|
|
197
|
+
screen-pos < #$0008, #$0055 > ;02 row 9 Y=72
|
|
198
|
+
screen-pos < #$0008, #$005D > ;03 row 10 Y=80
|
|
199
|
+
screen-pos < #$0008, #$0065 > ;04 row 11 Y=88
|
|
200
|
+
screen-pos < #$0008, #$006D > ;05 row 12 Y=96
|
|
201
|
+
screen-pos < #$0008, #$0075 > ;06 row 13 Y=104
|
|
202
|
+
screen-pos < #$0008, #$007D > ;07 row 14 Y=112
|
|
203
|
+
]
|
|
204
|
+
|
|
205
|
+
; Action bit masks (one byte per action, indexed by row 0-7)
|
|
206
|
+
ActionBitMasks [
|
|
207
|
+
#$80 ;00 Act/Confirm
|
|
208
|
+
#$20 ;01 Attack
|
|
209
|
+
#$40 ;02 Cancel
|
|
210
|
+
#$02 ;03 Use Item
|
|
211
|
+
#$08 ;04 Block1
|
|
212
|
+
#$04 ;05 Block2
|
|
213
|
+
#$10 ;06 Run
|
|
214
|
+
#$01 ;07 Cycle Item
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
---------------------------------------------
|
|
218
|
+
; TabHoverOptions — preview display when hovering over Optn. tab.
|
|
219
|
+
|
|
220
|
+
TabHoverOptions {
|
|
221
|
+
JSR $&HideAllItemSlots
|
|
222
|
+
JSR $&HideEquipCursor
|
|
223
|
+
JSR $&HideStatusActors
|
|
224
|
+
LDA #$0000
|
|
225
|
+
STA $bg1ConfigMode
|
|
226
|
+
COP [RunBg3Script] ( @system_strings.consolestring_01E912 )
|
|
227
|
+
COP [RunBg3Script] ( @optstr_description )
|
|
228
|
+
JSR $&OptionsDrawAll
|
|
229
|
+
LDA #$0001
|
|
230
|
+
TSB $displayModeFlags
|
|
231
|
+
RTL
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
---------------------------------------------
|
|
235
|
+
; OptionsTab — confirmed options tab. Full interactive menu.
|
|
236
|
+
|
|
237
|
+
OptionsTab {
|
|
238
|
+
LDA #$0000
|
|
239
|
+
STA $bg1ConfigMode
|
|
240
|
+
JSR $&HideAllItemSlots
|
|
241
|
+
JSR $&HideEquipCursor
|
|
242
|
+
JSR $&HideStatusActors
|
|
243
|
+
COP [SpawnAfterFlags] ( @SelectionCursorActor, #$0802 )
|
|
244
|
+
STY $20
|
|
245
|
+
STZ $22
|
|
246
|
+
|
|
247
|
+
opt_redraw:
|
|
248
|
+
JSR $&OptionsDrawAll
|
|
249
|
+
LDA #$0001
|
|
250
|
+
TSB $displayModeFlags
|
|
251
|
+
|
|
252
|
+
opt_position:
|
|
253
|
+
JSR $&OptionsPositionCursor
|
|
254
|
+
JSR $&OptShowDescription
|
|
255
|
+
COP [SetEntryHereAndYield]
|
|
256
|
+
COP [BranchIfPressed] ( #$8000, &OptionsRowConfirm )
|
|
257
|
+
COP [BranchIfPressed] ( #$0800, &OptionsCursorUp )
|
|
258
|
+
COP [BranchIfPressed] ( #$0400, &OptionsCursorDown )
|
|
259
|
+
COP [BranchIfPressed] ( #$0200, &OptionsCursorLeft )
|
|
260
|
+
COP [BranchIfPressed] ( #$0100, &OptionsCursorRight )
|
|
261
|
+
COP [BranchIfPressed] ( #$4000, &OptionsExit )
|
|
262
|
+
RTL
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
---------------------------------------------
|
|
266
|
+
; OptionsCursorUp — move cursor up. Left column rows 0-7, right column rows
|
|
267
|
+
; 8..(7+settings). Both columns wrap.
|
|
268
|
+
|
|
269
|
+
OptionsCursorUp {
|
|
270
|
+
LDA #$0800
|
|
271
|
+
TSB $joypadHeld
|
|
272
|
+
COP [PlaySoundCh2] ( #10 )
|
|
273
|
+
LDA $22
|
|
274
|
+
CMP #$0008
|
|
275
|
+
BCS ocu_right
|
|
276
|
+
DEC
|
|
277
|
+
BPL ocu_store
|
|
278
|
+
LDA #$0007
|
|
279
|
+
BRA ocu_store
|
|
280
|
+
|
|
281
|
+
ocu_right:
|
|
282
|
+
DEC
|
|
283
|
+
CMP #$0008
|
|
284
|
+
BCS ocu_store
|
|
285
|
+
JSR $&OptCountSettings
|
|
286
|
+
CLC
|
|
287
|
+
ADC #$0007
|
|
288
|
+
|
|
289
|
+
ocu_store:
|
|
290
|
+
STA $22
|
|
291
|
+
JMP opt_position
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
---------------------------------------------
|
|
295
|
+
; OptionsCursorDown — move cursor down with wrap inside the current column.
|
|
296
|
+
|
|
297
|
+
OptionsCursorDown {
|
|
298
|
+
LDA #$0400
|
|
299
|
+
TSB $joypadHeld
|
|
300
|
+
COP [PlaySoundCh2] ( #10 )
|
|
301
|
+
LDA $22
|
|
302
|
+
CMP #$0008
|
|
303
|
+
BCS ocd_right
|
|
304
|
+
INC
|
|
305
|
+
CMP #$0008
|
|
306
|
+
BCC ocd_store
|
|
307
|
+
LDA #$0000
|
|
308
|
+
BRA ocd_store
|
|
309
|
+
|
|
310
|
+
ocd_right:
|
|
311
|
+
INC
|
|
312
|
+
PHA
|
|
313
|
+
JSR $&OptCountSettings
|
|
314
|
+
CLC
|
|
315
|
+
ADC #$0008
|
|
316
|
+
STA $0000
|
|
317
|
+
PLA
|
|
318
|
+
CMP $0000
|
|
319
|
+
BCC ocd_store
|
|
320
|
+
LDA #$0008
|
|
321
|
+
|
|
322
|
+
ocd_store:
|
|
323
|
+
STA $22
|
|
324
|
+
JMP opt_position
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
---------------------------------------------
|
|
328
|
+
; OptionsCursorLeft — from a setting, jump to the action row at a similar height.
|
|
329
|
+
|
|
330
|
+
OptionsCursorLeft {
|
|
331
|
+
LDA #$0200
|
|
332
|
+
TSB $joypadHeld
|
|
333
|
+
LDA $22
|
|
334
|
+
CMP #$0008
|
|
335
|
+
BCC ocl_done
|
|
336
|
+
COP [PlaySoundCh2] ( #10 )
|
|
337
|
+
SEC
|
|
338
|
+
SBC #$0008
|
|
339
|
+
ASL
|
|
340
|
+
SEC
|
|
341
|
+
SBC #$0002
|
|
342
|
+
BPL ocl_store
|
|
343
|
+
LDA #$0000
|
|
344
|
+
|
|
345
|
+
ocl_store:
|
|
346
|
+
STA $22
|
|
347
|
+
|
|
348
|
+
ocl_done:
|
|
349
|
+
JMP opt_position
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
---------------------------------------------
|
|
353
|
+
; OptionsCursorRight — from an action row, jump to the setting at a similar height.
|
|
354
|
+
|
|
355
|
+
OptionsCursorRight {
|
|
356
|
+
LDA #$0100
|
|
357
|
+
TSB $joypadHeld
|
|
358
|
+
LDA $22
|
|
359
|
+
CMP #$0008
|
|
360
|
+
BCS ocr_done
|
|
361
|
+
LDA #$0008
|
|
362
|
+
STA $22
|
|
363
|
+
COP [PlaySoundCh2] ( #10 )
|
|
364
|
+
|
|
365
|
+
ocr_done:
|
|
366
|
+
JMP opt_position
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
---------------------------------------------
|
|
370
|
+
; OptionsRowConfirm — Confirm on the selected row. Action rows enter assignment
|
|
371
|
+
; mode; setting rows enter value editing.
|
|
372
|
+
|
|
373
|
+
OptionsRowConfirm {
|
|
374
|
+
LDA $22
|
|
375
|
+
CMP #$0008
|
|
376
|
+
BCC orc_assign
|
|
377
|
+
JMP $&OptionsSettingEdit
|
|
378
|
+
|
|
379
|
+
orc_assign:
|
|
380
|
+
LDA #$8000
|
|
381
|
+
TSB $joypadHeld
|
|
382
|
+
COP [PlaySoundCh2] ( #11 )
|
|
383
|
+
|
|
384
|
+
; Show "Press a button..." in the bottom-right description area
|
|
385
|
+
COP [RunBg3Script] ( @system_strings.consolestring_01E912 )
|
|
386
|
+
COP [RunBg3Script] ( @optstr_press_text )
|
|
387
|
+
|
|
388
|
+
; Wait for all buttons to be released first.
|
|
389
|
+
; Read JOY1L directly — joypadRaw has remapped action bits, not physical buttons.
|
|
390
|
+
orc_wait_release:
|
|
391
|
+
COP [SetEntryHereAndYield]
|
|
392
|
+
LDA $L_JOY1L
|
|
393
|
+
AND #$C0F0
|
|
394
|
+
BNE orc_wait_release
|
|
395
|
+
|
|
396
|
+
; Now wait for a new button press
|
|
397
|
+
orc_wait_press:
|
|
398
|
+
COP [SetEntryHereAndYield]
|
|
399
|
+
LDA $L_JOY1L
|
|
400
|
+
AND #$C0F0
|
|
401
|
+
BEQ orc_wait_press
|
|
402
|
+
|
|
403
|
+
; Determine which button was pressed and toggle the action
|
|
404
|
+
LDA #$C000
|
|
405
|
+
TSB $joypadHeld
|
|
406
|
+
COP [PlaySoundCh2] ( #11 )
|
|
407
|
+
JSR $&OptionsToggleMapping
|
|
408
|
+
|
|
409
|
+
; Rebuild remap words from updated save bytes
|
|
410
|
+
JSL $@options_input_remap.ApplyButtonMapping
|
|
411
|
+
|
|
412
|
+
; Redraw everything (also re-detects the Btn. Preset value)
|
|
413
|
+
JMP opt_redraw
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
---------------------------------------------
|
|
417
|
+
; OptionsSettingEdit — value editing for the setting under the cursor ($22 >= 8).
|
|
418
|
+
;
|
|
419
|
+
; The cursor drops one tile row onto the value text. Left/Up step backwards,
|
|
420
|
+
; Right/Down step forwards (wrapping at opt_count). Confirm commits through the
|
|
421
|
+
; record's commit handler, Cancel discards the temp value. Both leave through
|
|
422
|
+
; opt_redraw, which reloads every temp word from storage.
|
|
423
|
+
|
|
424
|
+
OptionsSettingEdit {
|
|
425
|
+
LDA #$8000
|
|
426
|
+
TSB $joypadHeld
|
|
427
|
+
COP [PlaySoundCh2] ( #11 )
|
|
428
|
+
LDA $22
|
|
429
|
+
SEC
|
|
430
|
+
SBC #$0008
|
|
431
|
+
JSR $&OptSelectSetting
|
|
432
|
+
JSR $&OptLoadSetting
|
|
433
|
+
|
|
434
|
+
COP [RunBg3Script] ( @system_strings.consolestring_01E912 )
|
|
435
|
+
COP [RunBg3Script] ( @optstr_edit_hint )
|
|
436
|
+
|
|
437
|
+
ose_position:
|
|
438
|
+
JSR $&OptionsPositionEditCursor
|
|
439
|
+
COP [SetEntryHereAndYield]
|
|
440
|
+
COP [BranchIfPressed] ( #$8000, &OptEditCommit )
|
|
441
|
+
COP [BranchIfPressed] ( #$4000, &OptEditCancel )
|
|
442
|
+
COP [BranchIfPressed] ( #$0200, &OptEditPrev )
|
|
443
|
+
COP [BranchIfPressed] ( #$0800, &OptEditPrev )
|
|
444
|
+
COP [BranchIfPressed] ( #$0100, &OptEditNext )
|
|
445
|
+
COP [BranchIfPressed] ( #$0400, &OptEditNext )
|
|
446
|
+
RTL
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
OptEditPrev {
|
|
450
|
+
LDA #$0A00
|
|
451
|
+
TSB $joypadHeld
|
|
452
|
+
COP [PlaySoundCh2] ( #10 )
|
|
453
|
+
LDA #$FFFF
|
|
454
|
+
JSR $&OptEditStep
|
|
455
|
+
JMP ose_position
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
OptEditNext {
|
|
459
|
+
LDA #$0500
|
|
460
|
+
TSB $joypadHeld
|
|
461
|
+
COP [PlaySoundCh2] ( #10 )
|
|
462
|
+
LDA #$0001
|
|
463
|
+
JSR $&OptEditStep
|
|
464
|
+
JMP ose_position
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
OptEditCommit {
|
|
468
|
+
LDA #$8000
|
|
469
|
+
TSB $joypadHeld
|
|
470
|
+
COP [PlaySoundCh2] ( #11 )
|
|
471
|
+
JSR $&OptCommitSetting
|
|
472
|
+
JMP opt_redraw
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
OptEditCancel {
|
|
476
|
+
LDA #$4000
|
|
477
|
+
TSB $joypadHeld
|
|
478
|
+
COP [PlaySoundCh2] ( #10 )
|
|
479
|
+
JMP opt_redraw
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
---------------------------------------------
|
|
483
|
+
; OptEditStep — step the selected setting and redraw only its two rows.
|
|
484
|
+
; Entry: A = +1 or -1 ($FFFF). $0BF0 already selects the record.
|
|
485
|
+
|
|
486
|
+
OptEditStep {
|
|
487
|
+
JSR $&OptStepSetting
|
|
488
|
+
LDA $22
|
|
489
|
+
SEC
|
|
490
|
+
SBC #$0008
|
|
491
|
+
JSR $&OptRenderSetting
|
|
492
|
+
RTS
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
---------------------------------------------
|
|
496
|
+
; OptionsExit — cancel out of options tab, return to main menu.
|
|
497
|
+
|
|
498
|
+
OptionsExit {
|
|
499
|
+
COP [PlaySoundCh2] ( #11 )
|
|
500
|
+
LDA #$4000
|
|
501
|
+
TSB $joypadHeld
|
|
502
|
+
COP [KillNext]
|
|
503
|
+
JMP $&InventoryMainLoop
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
---------------------------------------------
|
|
507
|
+
; OptionsPositionCursor — position the selection cursor actor on row $22.
|
|
508
|
+
; Rows 0-7: table lookup. Rows 8+: setting label row (X=$88, Y=$35 + 16*n).
|
|
509
|
+
|
|
510
|
+
OptionsPositionCursor {
|
|
511
|
+
PHX
|
|
512
|
+
LDY $20
|
|
513
|
+
LDA $22
|
|
514
|
+
CMP #$0008
|
|
515
|
+
BCS opc_setting
|
|
516
|
+
ASL
|
|
517
|
+
ASL
|
|
518
|
+
TAX
|
|
519
|
+
LDA $@OptionsCursorPositions, X
|
|
520
|
+
STA $0014, Y
|
|
521
|
+
LDA $@OptionsCursorPositions+2, X
|
|
522
|
+
STA $0016, Y
|
|
523
|
+
BRA opc_done
|
|
524
|
+
|
|
525
|
+
opc_setting:
|
|
526
|
+
SEC
|
|
527
|
+
SBC #$0008
|
|
528
|
+
ASL
|
|
529
|
+
ASL
|
|
530
|
+
ASL
|
|
531
|
+
ASL
|
|
532
|
+
CLC
|
|
533
|
+
ADC #$002D
|
|
534
|
+
STA $0016, Y
|
|
535
|
+
LDA #$0088
|
|
536
|
+
STA $0014, Y
|
|
537
|
+
|
|
538
|
+
opc_done:
|
|
539
|
+
PLX
|
|
540
|
+
RTS
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
---------------------------------------------
|
|
544
|
+
; OptionsPositionEditCursor — cursor on the value row of the setting under edit
|
|
545
|
+
; (one tile row below its label, one tile right: X=$90, Y=$3D + 16*n).
|
|
546
|
+
|
|
547
|
+
OptionsPositionEditCursor {
|
|
548
|
+
PHX
|
|
549
|
+
LDY $20
|
|
550
|
+
LDA $22
|
|
551
|
+
SEC
|
|
552
|
+
SBC #$0008
|
|
553
|
+
ASL
|
|
554
|
+
ASL
|
|
555
|
+
ASL
|
|
556
|
+
ASL
|
|
557
|
+
CLC
|
|
558
|
+
ADC #$0035
|
|
559
|
+
STA $0016, Y
|
|
560
|
+
LDA #$0090
|
|
561
|
+
STA $0014, Y
|
|
562
|
+
PLX
|
|
563
|
+
RTS
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
---------------------------------------------
|
|
567
|
+
; OptionsDrawAll — draw the left panel and every registered setting.
|
|
568
|
+
|
|
569
|
+
OptionsDrawAll {
|
|
570
|
+
REP #$20
|
|
571
|
+
LDA #$0000
|
|
572
|
+
STA $bg1ConfigMode
|
|
573
|
+
COP [RunBg3Script] ( @system_strings.consolestring_01E8E2 )
|
|
574
|
+
COP [RunBg3Script] ( @optstr_pane )
|
|
575
|
+
LDA #$0000
|
|
576
|
+
JSR $&OptionsPrepareWram
|
|
577
|
+
COP [RunBg3Script] ( @optstr_rows_left )
|
|
578
|
+
|
|
579
|
+
JSR $&OptCountSettings
|
|
580
|
+
BEQ oda_done
|
|
581
|
+
PHA ; [S+3] setting count
|
|
582
|
+
LDA #$0000
|
|
583
|
+
PHA ; [S+1] current index
|
|
584
|
+
|
|
585
|
+
oda_loop:
|
|
586
|
+
LDA $01, S
|
|
587
|
+
JSR $&OptSelectSetting
|
|
588
|
+
JSR $&OptLoadSetting
|
|
589
|
+
LDA $01, S
|
|
590
|
+
JSR $&OptRenderSetting
|
|
591
|
+
LDA $01, S
|
|
592
|
+
INC
|
|
593
|
+
STA $01, S
|
|
594
|
+
CMP $03, S
|
|
595
|
+
BCC oda_loop
|
|
596
|
+
PLA
|
|
597
|
+
PLA
|
|
598
|
+
|
|
599
|
+
oda_done:
|
|
600
|
+
RTS
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
---------------------------------------------
|
|
604
|
+
; OptShowDescription — redraw the lower-right description for the cursor row.
|
|
605
|
+
|
|
606
|
+
OptShowDescription {
|
|
607
|
+
COP [RunBg3Script] ( @system_strings.consolestring_01E912 )
|
|
608
|
+
LDA $22
|
|
609
|
+
CMP #$0008
|
|
610
|
+
BCS osd_setting
|
|
611
|
+
SEP #$20
|
|
612
|
+
LDA #$^optstr_description
|
|
613
|
+
STA $opt_str_bank
|
|
614
|
+
REP #$20
|
|
615
|
+
LDA #$&optstr_description
|
|
616
|
+
BRA osd_draw
|
|
617
|
+
|
|
618
|
+
osd_setting:
|
|
619
|
+
SEC
|
|
620
|
+
SBC #$0008
|
|
621
|
+
JSR $&OptSelectSetting
|
|
622
|
+
LDA #$ro_desc
|
|
623
|
+
JSR $&OptRecLong
|
|
624
|
+
|
|
625
|
+
osd_draw:
|
|
626
|
+
LDY #$0000
|
|
627
|
+
JSR $&OptRenderString
|
|
628
|
+
RTS
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
---------------------------------------------
|
|
632
|
+
; OptRenderString — run ConsoleStringRenderer on a string in any bank.
|
|
633
|
+
;
|
|
634
|
+
; Entry: A = string pointer (word), $opt_str_bank = its bank byte,
|
|
635
|
+
; Y = starting VRAM buffer offset (0 when the string carries its own
|
|
636
|
+
; [POS]). The offset is also stored as the [N] anchor.
|
|
637
|
+
; Preserves X. Sets displayModeFlags bit 0 so BG3 is flushed.
|
|
638
|
+
; DBR is switched to the string's bank (the renderer reads TBL temp words
|
|
639
|
+
; through DBR, which reaches WRAM $0000-$1FFF in banks $00-$3F and $80-$BF).
|
|
640
|
+
|
|
641
|
+
OptRenderString {
|
|
642
|
+
PHP
|
|
643
|
+
REP #$20
|
|
644
|
+
PHX
|
|
645
|
+
PHD
|
|
646
|
+
PHB
|
|
647
|
+
STY $09A0
|
|
648
|
+
TYX
|
|
649
|
+
TAY
|
|
650
|
+
SEP #$20
|
|
651
|
+
LDA $opt_str_bank
|
|
652
|
+
PHA
|
|
653
|
+
PLB
|
|
654
|
+
REP #$20
|
|
655
|
+
LDA #$0000
|
|
656
|
+
TCD
|
|
657
|
+
JSL $@ConsoleStringRenderer
|
|
658
|
+
PLB
|
|
659
|
+
PLD
|
|
660
|
+
PLX
|
|
661
|
+
LDA #$0001
|
|
662
|
+
TSB $displayModeFlags
|
|
663
|
+
PLP
|
|
664
|
+
RTS
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
---------------------------------------------
|
|
668
|
+
; OptRenderSetting — clear and redraw one setting.
|
|
669
|
+
; Entry: A = setting index. Leaves $0BF0 selecting that record.
|
|
670
|
+
|
|
671
|
+
OptRenderSetting {
|
|
672
|
+
PHX
|
|
673
|
+
PHY
|
|
674
|
+
PHA
|
|
675
|
+
JSR $&OptSelectSetting
|
|
676
|
+
PLA
|
|
677
|
+
XBA
|
|
678
|
+
LSR ; index * $80 (two tile rows)
|
|
679
|
+
CLC
|
|
680
|
+
ADC #$0126 ; row 5, col 19
|
|
681
|
+
TAY
|
|
682
|
+
JSR $&OptClearSetting
|
|
683
|
+
LDA #$ro_render
|
|
684
|
+
JSR $&OptRecLong
|
|
685
|
+
JSR $&OptRenderString
|
|
686
|
+
PLY
|
|
687
|
+
PLX
|
|
688
|
+
RTS
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
---------------------------------------------
|
|
692
|
+
; OptClearSetting — blank 12 tiles on both rows of a setting.
|
|
693
|
+
; Entry: Y = VRAM buffer offset of the label row start.
|
|
694
|
+
|
|
695
|
+
OptClearSetting {
|
|
696
|
+
PHX
|
|
697
|
+
PHY
|
|
698
|
+
TYX
|
|
699
|
+
LDY #$000C
|
|
700
|
+
LDA #$0000
|
|
701
|
+
|
|
702
|
+
ocs_loop:
|
|
703
|
+
STA $7F0200, X
|
|
704
|
+
STA $7F0240, X
|
|
705
|
+
INX
|
|
706
|
+
INX
|
|
707
|
+
DEY
|
|
708
|
+
BNE ocs_loop
|
|
709
|
+
PLY
|
|
710
|
+
PLX
|
|
711
|
+
RTS
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
---------------------------------------------
|
|
715
|
+
; OptCountSettings — number of registered settings (clamped to the 5 the panel
|
|
716
|
+
; can show). Exit: A = count, Z set when there are none.
|
|
717
|
+
|
|
718
|
+
OptCountSettings {
|
|
719
|
+
PHX
|
|
720
|
+
PHY
|
|
721
|
+
LDX #$0002 ; skip the head word
|
|
722
|
+
LDY #$0000
|
|
723
|
+
|
|
724
|
+
ocn_loop:
|
|
725
|
+
LDA $@InventoryOptionSetups, X
|
|
726
|
+
CMP #$FFFF
|
|
727
|
+
BEQ ocn_done
|
|
728
|
+
INY
|
|
729
|
+
TXA
|
|
730
|
+
CLC
|
|
731
|
+
ADC #$ro_stride
|
|
732
|
+
TAX
|
|
733
|
+
BRA ocn_loop
|
|
734
|
+
|
|
735
|
+
ocn_done:
|
|
736
|
+
TYA
|
|
737
|
+
CMP #$0006
|
|
738
|
+
BCC ocn_return
|
|
739
|
+
LDA #$0006
|
|
740
|
+
|
|
741
|
+
ocn_return:
|
|
742
|
+
PLY
|
|
743
|
+
PLX
|
|
744
|
+
CMP #$0000
|
|
745
|
+
RTS
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
---------------------------------------------
|
|
749
|
+
; OptSelectSetting — select a record. Entry: A = index.
|
|
750
|
+
; Sets $0BF0 = 2 + index * 24 (offset into InventoryOptionSetups, past the head word).
|
|
751
|
+
|
|
752
|
+
OptSelectSetting {
|
|
753
|
+
PHX
|
|
754
|
+
ASL
|
|
755
|
+
ASL
|
|
756
|
+
ASL ; 8n
|
|
757
|
+
STA $0000
|
|
758
|
+
ASL ; 16n
|
|
759
|
+
CLC
|
|
760
|
+
ADC $0000 ; 24n
|
|
761
|
+
ADC #$0002 ; skip the head word
|
|
762
|
+
STA $opt_rec
|
|
763
|
+
PLX
|
|
764
|
+
RTS
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
---------------------------------------------
|
|
768
|
+
; OptRecWord — read one word of the selected record.
|
|
769
|
+
; Entry: A = field offset (ro_*). Exit: A = word. Preserves X.
|
|
770
|
+
; Flags are NOT meaningful afterwards (compare explicitly).
|
|
771
|
+
|
|
772
|
+
OptRecWord {
|
|
773
|
+
PHX
|
|
774
|
+
CLC
|
|
775
|
+
ADC $opt_rec
|
|
776
|
+
TAX
|
|
777
|
+
LDA $@InventoryOptionSetups, X
|
|
778
|
+
PLX
|
|
779
|
+
RTS
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
---------------------------------------------
|
|
783
|
+
; OptRecLong — read a 3-byte pointer field of the selected record.
|
|
784
|
+
; Entry: A = field offset (ro_render / ro_desc).
|
|
785
|
+
; Exit: A = pointer word, $opt_str_bank = bank byte. Preserves X and Y.
|
|
786
|
+
|
|
787
|
+
OptRecLong {
|
|
788
|
+
PHX
|
|
789
|
+
CLC
|
|
790
|
+
ADC $opt_rec
|
|
791
|
+
TAX
|
|
792
|
+
INX
|
|
793
|
+
INX
|
|
794
|
+
SEP #$20
|
|
795
|
+
LDA $@InventoryOptionSetups, X
|
|
796
|
+
STA $opt_str_bank
|
|
797
|
+
REP #$20
|
|
798
|
+
DEX
|
|
799
|
+
DEX
|
|
800
|
+
LDA $@InventoryOptionSetups, X
|
|
801
|
+
PLX
|
|
802
|
+
RTS
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
---------------------------------------------
|
|
806
|
+
; OptCallHandler — call a record handler.
|
|
807
|
+
; Entry: A = handler address (bank-02 subroutine ending in RTS).
|
|
808
|
+
; Restores X = D (the actor id) first so handlers may use COPs. The handler's
|
|
809
|
+
; RTS returns straight to the caller of OptCallHandler.
|
|
810
|
+
|
|
811
|
+
OptCallHandler {
|
|
812
|
+
PHA
|
|
813
|
+
TDC
|
|
814
|
+
TAX
|
|
815
|
+
PLA
|
|
816
|
+
DEC
|
|
817
|
+
PHA
|
|
818
|
+
RTS
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
---------------------------------------------
|
|
822
|
+
; OptLoadSetting — refresh the selected setting's temp word from storage.
|
|
823
|
+
; Also resets opt_count to the record's count (handlers may raise it).
|
|
824
|
+
|
|
825
|
+
OptLoadSetting {
|
|
826
|
+
PHX
|
|
827
|
+
LDA #$ro_count
|
|
828
|
+
JSR $&OptRecWord
|
|
829
|
+
STA $opt_count
|
|
830
|
+
LDA #$ro_load
|
|
831
|
+
JSR $&OptRecWord
|
|
832
|
+
CMP #$0000
|
|
833
|
+
BEQ ols_packed
|
|
834
|
+
JSR $&OptCallHandler
|
|
835
|
+
BRA ols_done
|
|
836
|
+
|
|
837
|
+
ols_packed:
|
|
838
|
+
JSR $&OptLoadPacked
|
|
839
|
+
|
|
840
|
+
ols_done:
|
|
841
|
+
PLX
|
|
842
|
+
RTS
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
---------------------------------------------
|
|
846
|
+
; OptCommitSetting — persist the selected setting's temp word.
|
|
847
|
+
|
|
848
|
+
OptCommitSetting {
|
|
849
|
+
PHX
|
|
850
|
+
LDA #$ro_commit
|
|
851
|
+
JSR $&OptRecWord
|
|
852
|
+
CMP #$0000
|
|
853
|
+
BEQ ocm_packed
|
|
854
|
+
JSR $&OptCallHandler
|
|
855
|
+
BRA ocm_done
|
|
856
|
+
|
|
857
|
+
ocm_packed:
|
|
858
|
+
JSR $&OptCommitPacked
|
|
859
|
+
|
|
860
|
+
ocm_done:
|
|
861
|
+
PLX
|
|
862
|
+
RTS
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
---------------------------------------------
|
|
866
|
+
; OptStepSetting — move the temp value by A (+1 / -1), wrapping inside
|
|
867
|
+
; opt_count, then run the record's change handler.
|
|
868
|
+
|
|
869
|
+
OptStepSetting {
|
|
870
|
+
PHX
|
|
871
|
+
STA $0000 ; step direction
|
|
872
|
+
LDA #$ro_temp
|
|
873
|
+
JSR $&OptRecWord
|
|
874
|
+
TAX ; X = temp word address
|
|
875
|
+
LDA $0000, X
|
|
876
|
+
CLC
|
|
877
|
+
ADC $0000
|
|
878
|
+
BPL oss_high
|
|
879
|
+
LDA $opt_count ; stepped below zero: wrap to the last choice
|
|
880
|
+
DEC
|
|
881
|
+
BRA oss_store
|
|
882
|
+
|
|
883
|
+
oss_high:
|
|
884
|
+
CMP $opt_count
|
|
885
|
+
BCC oss_store
|
|
886
|
+
LDA #$0000 ; stepped past the last choice: wrap to zero
|
|
887
|
+
|
|
888
|
+
oss_store:
|
|
889
|
+
STA $0000, X
|
|
890
|
+
LDA #$ro_change
|
|
891
|
+
JSR $&OptRecWord
|
|
892
|
+
CMP #$0000
|
|
893
|
+
BEQ oss_done
|
|
894
|
+
JSR $&OptCallHandler
|
|
895
|
+
|
|
896
|
+
oss_done:
|
|
897
|
+
PLX
|
|
898
|
+
RTS
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
---------------------------------------------
|
|
902
|
+
; OptLoadPacked — default load: temp = ((storage >> shift) & mask) XOR xor,
|
|
903
|
+
; forced to 0 when it is not below opt_count.
|
|
904
|
+
|
|
905
|
+
OptLoadPacked {
|
|
906
|
+
LDA #$ro_store
|
|
907
|
+
JSR $&OptRecWord
|
|
908
|
+
STA $0000 ; storage address
|
|
909
|
+
LDA #$ro_temp
|
|
910
|
+
JSR $&OptRecWord
|
|
911
|
+
STA $0002 ; temp address
|
|
912
|
+
LDA #$ro_shift
|
|
913
|
+
JSR $&OptRecWord
|
|
914
|
+
STA $0004
|
|
915
|
+
LDA #$ro_mask
|
|
916
|
+
JSR $&OptRecWord
|
|
917
|
+
STA $0006
|
|
918
|
+
LDA #$ro_xor
|
|
919
|
+
JSR $&OptRecWord
|
|
920
|
+
STA $0008
|
|
921
|
+
|
|
922
|
+
PHX
|
|
923
|
+
LDX $0000
|
|
924
|
+
LDA $0000, X ; storage word (neighbour bits are masked off)
|
|
925
|
+
LDY $0004
|
|
926
|
+
BEQ olp_shifted
|
|
927
|
+
|
|
928
|
+
olp_shift:
|
|
929
|
+
LSR
|
|
930
|
+
DEY
|
|
931
|
+
BNE olp_shift
|
|
932
|
+
|
|
933
|
+
olp_shifted:
|
|
934
|
+
AND $0006
|
|
935
|
+
EOR $0008
|
|
936
|
+
CMP $opt_count
|
|
937
|
+
BCC olp_store
|
|
938
|
+
LDA #$0000
|
|
939
|
+
|
|
940
|
+
olp_store:
|
|
941
|
+
LDX $0002
|
|
942
|
+
STA $0000, X
|
|
943
|
+
PLX
|
|
944
|
+
RTS
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
---------------------------------------------
|
|
948
|
+
; OptCommitPacked — default commit: write ((temp XOR xor) & mask) << shift into
|
|
949
|
+
; the storage byte, leaving the other bits of that byte untouched.
|
|
950
|
+
|
|
951
|
+
OptCommitPacked {
|
|
952
|
+
LDA #$ro_store
|
|
953
|
+
JSR $&OptRecWord
|
|
954
|
+
STA $0000 ; storage address
|
|
955
|
+
LDA #$ro_temp
|
|
956
|
+
JSR $&OptRecWord
|
|
957
|
+
STA $0002 ; temp address
|
|
958
|
+
LDA #$ro_shift
|
|
959
|
+
JSR $&OptRecWord
|
|
960
|
+
STA $0004
|
|
961
|
+
LDA #$ro_mask
|
|
962
|
+
JSR $&OptRecWord
|
|
963
|
+
STA $0006
|
|
964
|
+
LDA #$ro_xor
|
|
965
|
+
JSR $&OptRecWord
|
|
966
|
+
STA $0008
|
|
967
|
+
|
|
968
|
+
PHX
|
|
969
|
+
LDX $0002
|
|
970
|
+
LDA $0000, X ; temp value
|
|
971
|
+
EOR $0008
|
|
972
|
+
AND $0006
|
|
973
|
+
LDY $0004
|
|
974
|
+
BEQ ocp_value_ready
|
|
975
|
+
|
|
976
|
+
ocp_value_shift:
|
|
977
|
+
ASL
|
|
978
|
+
DEY
|
|
979
|
+
BNE ocp_value_shift
|
|
980
|
+
|
|
981
|
+
ocp_value_ready:
|
|
982
|
+
STA $000A ; new field bits, already shifted
|
|
983
|
+
LDA $0006
|
|
984
|
+
LDY $0004
|
|
985
|
+
BEQ ocp_mask_ready
|
|
986
|
+
|
|
987
|
+
ocp_mask_shift:
|
|
988
|
+
ASL
|
|
989
|
+
DEY
|
|
990
|
+
BNE ocp_mask_shift
|
|
991
|
+
|
|
992
|
+
ocp_mask_ready:
|
|
993
|
+
EOR #$FFFF
|
|
994
|
+
STA $000C ; inverted shifted mask
|
|
995
|
+
LDX $0000
|
|
996
|
+
SEP #$20
|
|
997
|
+
LDA $0000, X
|
|
998
|
+
AND $000C
|
|
999
|
+
ORA $000A
|
|
1000
|
+
STA $0000, X
|
|
1001
|
+
REP #$20
|
|
1002
|
+
PLX
|
|
1003
|
+
RTS
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
---------------------------------------------
|
|
1007
|
+
; Btn. Preset handlers (registered record at the top of this file).
|
|
1008
|
+
;
|
|
1009
|
+
; temp ($0BE8): 0 = Classic A, 1 = Classic B, 2 = Custom.
|
|
1010
|
+
|
|
1011
|
+
OptPresetLoad {
|
|
1012
|
+
JSL $@options_input_remap.DetectPreset
|
|
1013
|
+
STA $opt_temp_preset
|
|
1014
|
+
CMP #$0002
|
|
1015
|
+
BCC opl_done
|
|
1016
|
+
LDA #$0003 ; live mapping is custom: offer the Custom choice
|
|
1017
|
+
STA $opt_count
|
|
1018
|
+
|
|
1019
|
+
opl_done:
|
|
1020
|
+
RTS
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
; Preview the highlighted preset in the left panel. Custom shows the player's
|
|
1024
|
+
; own mapping again.
|
|
1025
|
+
OptPresetChange {
|
|
1026
|
+
LDA $opt_temp_preset
|
|
1027
|
+
CMP #$0002
|
|
1028
|
+
BCS opch_live
|
|
1029
|
+
INC ; 0 -> source 1 (Classic A), 1 -> source 2 (Classic B)
|
|
1030
|
+
BRA opch_draw
|
|
1031
|
+
|
|
1032
|
+
opch_live:
|
|
1033
|
+
LDA #$0000
|
|
1034
|
+
|
|
1035
|
+
opch_draw:
|
|
1036
|
+
JSR $&OptionsPrepareWram
|
|
1037
|
+
COP [RunBg3Script] ( @optstr_rows_left )
|
|
1038
|
+
RTS
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
; Classic A/B overwrite the live mapping; Custom leaves it untouched.
|
|
1042
|
+
OptPresetCommit {
|
|
1043
|
+
LDA $opt_temp_preset
|
|
1044
|
+
CMP #$0002
|
|
1045
|
+
BCS opcm_done
|
|
1046
|
+
JSL $@options_input_remap.SetButtonPreset
|
|
1047
|
+
JSL $@options_input_remap.ApplyButtonMapping
|
|
1048
|
+
|
|
1049
|
+
opcm_done:
|
|
1050
|
+
RTS
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
---------------------------------------------
|
|
1054
|
+
; OptionsPrepareWram — populate WRAM with button display indices.
|
|
1055
|
+
;
|
|
1056
|
+
; Entry: A = mapping source (see LoadButtonMapPreview): 0 = live mapping,
|
|
1057
|
+
; 1 = Classic A, 2 = Classic B.
|
|
1058
|
+
;
|
|
1059
|
+
; For each of the 8 action rows, finds which physical button (if any)
|
|
1060
|
+
; has that action's bit set, and stores a single TBL index at $0BD0+row*2:
|
|
1061
|
+
; 0 = not assigned, 1 = A, 2 = B, 3 = X, 4 = Y, 5 = L, 6 = R
|
|
1062
|
+
;
|
|
1063
|
+
; Each action maps to at most one button (exclusive assignment).
|
|
1064
|
+
;
|
|
1065
|
+
; NOTE: ActionBitMasks is in ROM. DBR=$81 during actor code, so we
|
|
1066
|
+
; MUST use long,X addressing ($@) for the ROM table read.
|
|
1067
|
+
; Y is used for button iteration (WRAM reads are DBR-safe).
|
|
1068
|
+
|
|
1069
|
+
OptionsPrepareWram {
|
|
1070
|
+
PHP
|
|
1071
|
+
PHX
|
|
1072
|
+
PHY
|
|
1073
|
+
|
|
1074
|
+
REP #$20
|
|
1075
|
+
JSL $@options_input_remap.LoadButtonMapPreview
|
|
1076
|
+
|
|
1077
|
+
STZ $0004 ; $04 = WRAM output offset (0, 2, 4, ..., 14)
|
|
1078
|
+
LDX #$0000 ; X = row index (0..7)
|
|
1079
|
+
SEP #$20
|
|
1080
|
+
|
|
1081
|
+
opw_row:
|
|
1082
|
+
LDA $@ActionBitMasks, X
|
|
1083
|
+
STA $0000 ; $0000 = action bit mask for this row
|
|
1084
|
+
STX $0006 ; save row index
|
|
1085
|
+
|
|
1086
|
+
LDY #$0000 ; Y = button index (0..5)
|
|
1087
|
+
|
|
1088
|
+
opw_btn:
|
|
1089
|
+
LDA $opt_map, Y ; preview byte for this button
|
|
1090
|
+
AND $0000 ; test action bit
|
|
1091
|
+
BNE opw_found ; this button has the action
|
|
1092
|
+
INY
|
|
1093
|
+
CPY #$0006
|
|
1094
|
+
BNE opw_btn
|
|
1095
|
+
|
|
1096
|
+
; No button found — store 0 (blank)
|
|
1097
|
+
LDX $0004
|
|
1098
|
+
STZ $opt_wram_base, X
|
|
1099
|
+
BRA opw_next
|
|
1100
|
+
|
|
1101
|
+
opw_found:
|
|
1102
|
+
TYA ; button index (0..5)
|
|
1103
|
+
INC ; +1 → display index (1=A, 2=B, 3=X, 4=Y, 5=L, 6=R)
|
|
1104
|
+
LDX $0004
|
|
1105
|
+
STA $opt_wram_base, X
|
|
1106
|
+
|
|
1107
|
+
opw_next:
|
|
1108
|
+
INX
|
|
1109
|
+
INX
|
|
1110
|
+
STX $0004 ; save updated WRAM offset
|
|
1111
|
+
LDX $0006 ; restore row index
|
|
1112
|
+
INX
|
|
1113
|
+
CPX #$0008
|
|
1114
|
+
BNE opw_row
|
|
1115
|
+
|
|
1116
|
+
PLY
|
|
1117
|
+
PLX
|
|
1118
|
+
PLP
|
|
1119
|
+
RTS
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
---------------------------------------------
|
|
1123
|
+
; OptionsToggleMapping — assign an action exclusively to one button.
|
|
1124
|
+
;
|
|
1125
|
+
; Entry: $22 = selected action row (0-7)
|
|
1126
|
+
; joypadRaw ($0660) has the pressed physical button
|
|
1127
|
+
;
|
|
1128
|
+
; Clears the action from ALL buttons, then sets it on the pressed
|
|
1129
|
+
; button (unless it was already on that button — toggle off).
|
|
1130
|
+
; This enforces one button per action.
|
|
1131
|
+
|
|
1132
|
+
OptionsToggleMapping {
|
|
1133
|
+
PHX
|
|
1134
|
+
|
|
1135
|
+
; Determine which physical button was pressed.
|
|
1136
|
+
; Read JOY1L directly — joypadRaw has remapped action bits, not physical buttons.
|
|
1137
|
+
LDA $L_JOY1L
|
|
1138
|
+
BIT #$0080
|
|
1139
|
+
BNE otm_btn_a
|
|
1140
|
+
BIT #$8000
|
|
1141
|
+
BNE otm_btn_b
|
|
1142
|
+
BIT #$0040
|
|
1143
|
+
BNE otm_btn_x
|
|
1144
|
+
BIT #$4000
|
|
1145
|
+
BNE otm_btn_y
|
|
1146
|
+
BIT #$0020
|
|
1147
|
+
BNE otm_btn_l
|
|
1148
|
+
BIT #$0010
|
|
1149
|
+
BNE otm_btn_r
|
|
1150
|
+
PLX
|
|
1151
|
+
RTS ; no recognized button
|
|
1152
|
+
|
|
1153
|
+
otm_btn_a:
|
|
1154
|
+
LDX #$0000
|
|
1155
|
+
BRA otm_toggle
|
|
1156
|
+
otm_btn_b:
|
|
1157
|
+
LDX #$0001
|
|
1158
|
+
BRA otm_toggle
|
|
1159
|
+
otm_btn_x:
|
|
1160
|
+
LDX #$0002
|
|
1161
|
+
BRA otm_toggle
|
|
1162
|
+
otm_btn_y:
|
|
1163
|
+
LDX #$0003
|
|
1164
|
+
BRA otm_toggle
|
|
1165
|
+
otm_btn_l:
|
|
1166
|
+
LDX #$0004
|
|
1167
|
+
BRA otm_toggle
|
|
1168
|
+
otm_btn_r:
|
|
1169
|
+
LDX #$0005
|
|
1170
|
+
|
|
1171
|
+
otm_toggle:
|
|
1172
|
+
; X = button index (0-5), $22 = action row (0-7)
|
|
1173
|
+
; Load the action bit mask for the selected row.
|
|
1174
|
+
; Must use long,X ($@) because DBR=$81 during actor code.
|
|
1175
|
+
PHX
|
|
1176
|
+
LDA $22
|
|
1177
|
+
AND #$00FF
|
|
1178
|
+
TAX
|
|
1179
|
+
LDA $@ActionBitMasks, X
|
|
1180
|
+
AND #$00FF
|
|
1181
|
+
STA $0000 ; action bit mask
|
|
1182
|
+
PLX
|
|
1183
|
+
|
|
1184
|
+
; Check if pressed button already has this action
|
|
1185
|
+
SEP #$20
|
|
1186
|
+
LDA $btnMapA, X
|
|
1187
|
+
AND $0000
|
|
1188
|
+
STA $0002 ; non-zero if was already set
|
|
1189
|
+
|
|
1190
|
+
; Clear the action from all 6 buttons
|
|
1191
|
+
LDA $0000
|
|
1192
|
+
EOR #$FF ; invert mask
|
|
1193
|
+
STA $0006
|
|
1194
|
+
PHY
|
|
1195
|
+
LDY #$0005
|
|
1196
|
+
otm_clear:
|
|
1197
|
+
LDA $btnMapA, Y
|
|
1198
|
+
AND $0006
|
|
1199
|
+
STA $btnMapA, Y
|
|
1200
|
+
DEY
|
|
1201
|
+
BPL otm_clear
|
|
1202
|
+
PLY
|
|
1203
|
+
|
|
1204
|
+
; If button already had the action, leave cleared (toggle off)
|
|
1205
|
+
LDA $0002
|
|
1206
|
+
BEQ otm_assign
|
|
1207
|
+
LDA $22
|
|
1208
|
+
CMP #$05
|
|
1209
|
+
BCS otm_done
|
|
1210
|
+
|
|
1211
|
+
; Assign: set the action on the pressed button
|
|
1212
|
+
otm_assign:
|
|
1213
|
+
LDA $btnMapA, X
|
|
1214
|
+
ORA $0000
|
|
1215
|
+
STA $btnMapA, X
|
|
1216
|
+
|
|
1217
|
+
otm_done:
|
|
1218
|
+
REP #$20
|
|
1219
|
+
PLX
|
|
1220
|
+
RTS
|
|
1221
|
+
}
|