Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion patches/rom_map/Bank 82.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ FF00 - FF10: reserve_hud.asm
FF10 - FF30: escape.asm
FF30 - FF80: reserve_hud.asm
FF80 - FFFC: pause_menu_objectives.asm
FFFC - FFFE: fast_pause_menu
FFFC - FFFE: objectives/fast_pause_menu
FFFE - end: custom etank color
6 changes: 6 additions & 0 deletions patches/src/constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@
!nmi_area4 = $1F86
!nmi_area5 = $1F87
!nmi_area6 = $1F88

; Objectives
!objectives_max = $0014
!objectives_num = $82FFFC ; bits 0-15
!objectives_addrs = $8FEBC0
!objectives_bitmasks #= !objectives_addrs+(2*!objectives_max)
142 changes: 95 additions & 47 deletions patches/src/mb_barrier_clear.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,70 @@ lorom
!bank_84_freespace_start = $84F200
!bank_84_freespace_end = $84F300

org $83AAD2
dw $EB00 ; Set door ASM for Rinka Room toward Mother Brain

macro check_objective(i,plm)
lda.w #$007E
sta.b $02
lda.l ObjectiveAddrs+<i>
sta.b $00
lda.l ObjectiveBitmasks+<i>
sta.b $04
lda.b [$00]
bit.b $04
beq ?skip ; skip clearing if objective not done
incsrc "constants.asm"

macro clear_plm(plm)
jsl $8483D7
db <plm>
db $04
dw clear_barrier_plm
?skip:
endmacro

org $83AAD2
dw $EB00 ; Set door ASM for Rinka Room toward Mother Brain

; Free space in bank $8F
org $8FEB00
; clear barriers in mother brain room based on main bosses killed:
%check_objective(0,$39)
%check_objective(2,$38)
%check_objective(4,$37)
%check_objective(6,$36)
door_asm_start:
; 3 potential scenarios for barriers:
; obj_num < 4, clear from left to right
; obj_num = 4, stock behavior
; obj_num > 4, maintain all 4 until all obj's cleared
lda !objectives_num : and $7FFF
beq clear_all ; None ?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the zero-objective case doesn't need special handling? It should work being handled the same as <=4 objectives? With zero objectives, X would get initialized to 0-4 = -4, which is the same as what is being done manually?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove the clear_all segment, just be sure to update patch.rs too

cmp #$0005
bcc normal_objs ; <= 4 ?

ldx #$0000
tay
; iterate through all obj's
.check_lp
jsr check_objective
beq motherbrain
dey
bne .check_lp

; either none or all cleared
clear_all:
ldx #$FFFB
bra start_obj_checks

; # obj's - 4
normal_objs:
sec
sbc #$0004
tax

; starting value of X determines check/clear behavior
; X = 0 for stock behavior (4 objs)
; X < 0 will clear until 0, then check (for 0-3 objs)
; X = -4 will clear all objs
start_obj_checks:
jsr check_objective
beq .skip_1
%clear_plm($36)
.skip_1
jsr check_objective
beq .skip_2
%clear_plm($37)
.skip_2
jsr check_objective
beq .skip_3
%clear_plm($38)
.skip_3
jsr check_objective
beq motherbrain
%clear_plm($39)

motherbrain:
lda $7ed82d
Expand All @@ -46,43 +82,55 @@ motherbrain:
jsl remove_spikes
done:
rts

check_objective:
; X >= 0 obj to check; X < 0 = return obj cleared
; also increments X
phx
txa
bmi .bypass_check
asl
tax
lda.w #$007E
sta.b $02
lda.l ObjectiveAddrs, X
sta.b $00
lda.l ObjectiveBitmasks, X
plx
inx
sta.b $04
lda.b [$00]
bit.b $04
rts
.bypass_check
plx
inx
lda #$0001
rts

warnpc $8FEBC0
org $8FEBC0
warnpc !objectives_addrs

org !objectives_addrs
ObjectiveAddrs:
dw $D829, $D82A, $D82B, $D82C
dw $D829, $D82A, $D82B, $D82C, $D82D
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section will get overwritten by the randomizer, so it doesn't really matter what data is put here by the patch. The addresses $D829, $D82A, $D82B, $D82C were for the Bosses objectives, Kraid, Ridley, Phantoon, and Draygon (it looks like I had them in the wrong order), just to make the patch usable without running the randomizer. If we still want that to work, then the patch should probably also set objectives_num ($82FFFC) to a default value of 4.

The other values $D82D, $D82E, etc., won't point to valid objective bits, so I think it would be better to just put $0000 or $FFFF here, to avoid causing confusion. You could also just put $0000 or $FFFF for the whole thing (including the first 4 entries) if we don't care about running the patch on its own.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that was just for easy testing. Sounds good

dw $D82E, $D82F, $D830, $D831, $D832
dw $D833, $D834, $D835, $D836, $D837
dw $D838, $D839, $D83A, $D83B, $D83C
dw $D83D, $D83E, $D83F, $D840, $D841
ObjectiveBitmasks:
dw $0001, $0001, $0001, $0001
dw $0001, $0001, $0001, $0001, $0002
dw $0001, $0001, $0001, $0001, $0001
dw $0001, $0001, $0001, $0001, $0001
dw $0001, $0001, $0001, $0001, $0001
dw $0001, $0001, $0001, $0001, $0001

; OBJECTIVE: None (must match address in patch.rs)
warnpc $8FECA0
org $8FECA0

jsl $8483D7
db $39
db $04
dw clear_barrier_plm

jsl $8483D7
db $38
db $04
dw clear_barrier_plm

jsl $8483D7
db $37
db $04
dw clear_barrier_plm

jsl $8483D7
db $36
db $04
dw clear_barrier_plm

jmp motherbrain

jmp clear_all ; this section can be removed once patch.rs is updated

warnpc $8FED00


; Remove invisible spikes where Mother Brain used to be (common routine used by both the left and right door ASMs)
org !bank_84_freespace_start

Expand Down
13 changes: 5 additions & 8 deletions patches/src/pause_menu_objectives.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ arch 65816

math pri on

incsrc "constants.asm"

!bank_82_free_space_start = $82FF80
!bank_82_free_space_end = $82FFFC

Expand Down Expand Up @@ -72,11 +74,6 @@ org $82A61D

!n_lines = #$0012

!ObjectiveAddrs = $8FEBC0
!ObjectiveBitmasks = $8FEBE8

!n_objectives = $82fffc

;;; character conversion table
table "tables/pause_menu_objectives_chars.tbl",RTL

Expand Down Expand Up @@ -313,7 +310,7 @@ pad_0:
check_objs:
;;; check objectives and add check marks
LDY.w #!line_size*2 ; start of 1st line
LDA !n_objectives : AND $7FFF
LDA !objectives_num : AND $7FFF
STA !tmp_tile_offset ; # objectives
BEQ .check_animals
LDX #$0000
Expand Down Expand Up @@ -355,9 +352,9 @@ check_objective: ; X = index
TAX
LDA.w #$007E
STA.b $02
LDA.l !ObjectiveAddrs, X
LDA.l !objectives_addrs, X
STA.b $00
LDA.l !ObjectiveBitmasks, X
LDA.l !objectives_bitmasks, X
STA.b $04
LDA.b [$00]
PLX
Expand Down