Skip to content

Commit

Permalink
Merge pull request #217 from idlechild/master
Browse files Browse the repository at this point in the history
Practice Hack 2.6.4
  • Loading branch information
idlechild authored Nov 18, 2024
2 parents 395919b + 0886c04 commit 3e1f2e3
Show file tree
Hide file tree
Showing 29 changed files with 1,470 additions and 716 deletions.
29 changes: 0 additions & 29 deletions src/custompresets.asm
Original file line number Diff line number Diff line change
Expand Up @@ -529,35 +529,6 @@ custom_preset_load:
endif
endif

preset_clear_map_data_if_necessary:
{
; Called from category_preset_load where $C1 is start of preset data
; and $C5 is the starting bank of preset data

; If this is a map category, then clear map data
LDA $C1 : CMP.w #preset_100map_bombs_ceres_elevator : BNE .done
LDA $C5 : AND #$00FF : CMP.w #preset_100map_bombs_ceres_elevator>>16 : BEQ preset_clear_map_data

.done
RTL
}

preset_clear_map_data:
{
PHX : LDX #$00FE : TDC
.clearMapDataLoop
STA $07F7,X
STA $7ECD52,X
STA $7ECE52,X
STA $7ECF52,X
STA $7ED052,X
STA $7ED152,X
STA $7ED252,X
DEX : DEX
BPL .clearMapDataLoop
PLX : RTL
}

preset_scroll_fixes:
{
; Fixes bad scrolling caused by loading into a position that
Expand Down
9 changes: 9 additions & 0 deletions src/damage.asm
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,13 @@ healthalarm_turn_on_table:
dw healthalarm_turn_on_vanilla
dw healthalarm_turn_on_pb_fix
dw healthalarm_turn_on_improved
dw healthalarm_turn_on_always_on

healthalarm_turn_on_improved:
; Do not sound alarm until below 30 combined health
LDA $09C2 : CLC : ADC $09D6 : CMP #$001E : BPL healthalarm_turn_on_done

healthalarm_turn_on_always_on:
healthalarm_turn_on_pb_fix:
; Do not sound alarm if it won't play due to power bomb explosion
LDA $0592 : BMI healthalarm_turn_on_done
Expand All @@ -350,6 +352,7 @@ healthalarm_turn_off_table:
dw healthalarm_turn_off_vanilla
dw healthalarm_turn_off_pb_fix
dw healthalarm_turn_off_improved
dw healthalarm_turn_off_always_on

healthalarm_turn_off_improved:
healthalarm_turn_off_pb_fix:
Expand All @@ -365,6 +368,12 @@ healthalarm_turn_off_never:
healthalarm_turn_off_done:
PLX : RTS

healthalarm_turn_off_always_on:
; Do not sound alarm if it won't play due to power bomb explosion
LDA $0592 : BMI healthalarm_turn_off_done
LDA #$0002 : JSL $80914D
BRA healthalarm_turn_off_never


healthalarm_turn_on_remote:
if !FEATURE_PAL
Expand Down
12 changes: 12 additions & 0 deletions src/defines.asm
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@
!ram_cm_watch_enemy_side = !WRAM_MENU_START+$84
!ram_cm_watch_common_address = !WRAM_MENU_START+$86

!ram_cm_preset_elevator = !WRAM_MENU_START+$80

!ram_cm_door_dynamic = !WRAM_MENU_START+$80
!ram_cm_door_menu_value = !WRAM_MENU_START+$82
!ram_cm_door_menu_bank = !WRAM_MENU_START+$84
Expand Down Expand Up @@ -520,6 +522,9 @@
!LOAD_STATION_INDEX = $078B
!DOOR_ID = $078D
!DOOR_DIRECTION = $0791
!DOOR_TRANSITION_FLAG_ELEVATOR = $0795
!DOOR_TRANSITION_FLAG_ENEMIES = $0797
!ELEVATOR_DIRECTION = $0799
!ROOM_ID = $079B
!AREA_ID = $079F
!ROOM_MAP_X_COORDINATE = $07A1
Expand All @@ -531,6 +536,8 @@
!CRE_BITSET = $07B3
!STATE_POINTER = $07BB
!ROOM_MUSIC_DATA_INDEX = $07CB
!ENEMY_POPULATION = $07CF
!ENEMY_SET = $07D1
!MUSIC_DATA = $07F3
!MUSIC_TRACK = $07F5
!LAYER1_X = $0911
Expand All @@ -541,6 +548,8 @@
!BG1_Y_OFFSET = $091F
!BG2_X_OFFSET = $0921
!BG2_Y_OFFSET = $0923
!DOOR_DESTINATION_X = $0927
!DOOR_DESTINATION_Y = $0929
!SAMUS_DOOR_SUBSPEED = $092B
!SAMUS_DOOR_SPEED = $092D
!CURRENT_SAVE_FILE = $0952
Expand Down Expand Up @@ -792,6 +801,9 @@ endif
!PRESETS_PRESERVE_ENEMIES = #$0010
!PRESETS_CLEAR_MAP_TILES = #$0020
!PRESETS_AUTO_SEGMENT_OFF = #$0040
!PRESETS_ELEVATOR_LONG = #$0100
!PRESETS_ELEVATOR_OFF = #$0200
!PRESETS_ELEVATOR_MASK = #$0300

!PRESET_EQUIP_RANDO_ENABLE = #$0001
!PRESET_EQUIP_RANDO_FORCE_MORPH = #$0002
Expand Down
38 changes: 32 additions & 6 deletions src/fanfare.asm
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
; $82:9396: Queue Samus movement sound effects
org $829396
JSL hook_unpause_play_sound

; $82:E126: Logic to queue room music after fanfare
org $82E126
JSL hook_resume_room_music
BRA $08

; $84:8BDD: Instruction - clear music queue and queue music track [[Y]] ;;;
org $848BDD
JML play_or_skip_fanfare

; $85:80BA: End message box routine
org $8580BA
JML hook_end_fanfare

; $85:8493: Handle message box interaction
org $858493
JSR hook_message_box_wait
BRA $0B

; $82:E126: Logic to queue room music after fanfare
org $82E126
JSL hook_resume_room_music
BRA $08


if !ORIGINAL_MESSAGE_TEXT
else
Expand Down Expand Up @@ -224,12 +232,30 @@ hook_resume_room_music:
RTL

.resume
LDA #$0000 ; original logic to queue room music after fanfare
TDC ; original logic to queue room music after fanfare
JSL $808FF7
LDA $07F5
JSL $808FC1
RTL
}

hook_unpause_play_sound:
{
JSL $82BE2F ; original logic to queue Samus movement sound effects
LDA !sram_healthalarm : CMP #$0004 : BNE .done_health_alarm
LDA #$0002 : JSL $80914D
.done_health_alarm
RTL
}

hook_end_fanfare:
{
LDA !sram_healthalarm : CMP #$0004 : BNE .done_health_alarm
LDA #$0002 : JSL $80914D
.done_health_alarm
PLY : PLX ; original logic
PLB : PLP : RTL
}

print pc, " fanfare end"

94 changes: 89 additions & 5 deletions src/infohudmodes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1534,13 +1534,73 @@ status_armpump:

status_shottimer:
{
LDA !IH_CONTROLLER_PRI_NEW : AND !IH_INPUT_SHOT : BEQ .inc
LDA !IH_CONTROLLER_PRI_NEW : AND !IH_INPUT_SHOT : BEQ .incShot
LDA !ram_shot_timer : LDX #$0088 : JSR Draw4
LDA #$0000 : STA !ram_shot_timer

.inc
.incShot
LDA !ram_shot_timer : INC : STA !ram_shot_timer
LDA !ROOM_ID : CMP #ROOM_PhantoonRoom : BEQ .phantoon
RTS

.phantoonCheckInit
LDA $0FB2
if !FEATURE_PAL
CMP #$D641
else
CMP #$D60D
endif
BNE .done
LDA $0FB0 : CMP #$0010 : BEQ .phantoonInit
CMP #$000F : BNE .done

; Phantoon must be doing a fast eye close
LDA !IH_LETTER_F : STA !ram_HUD_check
BRA .phantoonInitCounters

.phantoonInit
LDA !IH_BLANK : STA !ram_HUD_check

.phantoonInitCounters
TDC : STA !ram_roomstrat_counter
LDA !ENEMY_HP : STA !ram_roomstrat_state

.done
RTS

.phantoon
LDA !ram_roomstrat_state : CMP #$02BC : BMI .phantoonCheckInit
SEC : SBC !ENEMY_HP : CMP #$0258 : BPL .phantoonHit
LDA !ram_roomstrat_counter : CMP #$0058 : BPL .phantoonClear
INC : STA !ram_roomstrat_counter
RTS

.phantoonHit
LDA !ram_HUD_check : STA !HUD_TILEMAP+$88
LDA !IH_BLANK : STA !HUD_TILEMAP+$8A
LDA !ram_roomstrat_counter : CMP #$0018 : BEQ .framePerfect : BMI .hitEarly

; Hit late
SEC : SBC #$0018 : ASL : TAY : LDA.w NumberGFXTable,Y : STA !HUD_TILEMAP+$8E
LDA !IH_LETTER_L : STA !HUD_TILEMAP+$8C
BRA .phantoonClear

.framePerfect
LDA !sram_display_mode_reward : BEQ .doneReward
%sfxreward()

.doneReward
LDA !IH_LETTER_Y : STA !HUD_TILEMAP+$8C : STA !HUD_TILEMAP+$8E

.phantoonClear
TDC : STA !ram_roomstrat_state : STA !ram_roomstrat_counter
RTS

.hitEarly
LDA #$0018 : SEC : SBC !ram_roomstrat_counter
ASL : TAY : LDA.w NumberGFXTable,Y : STA !HUD_TILEMAP+$8E
LDA !IH_LETTER_E : STA !HUD_TILEMAP+$8C
BRA .phantoonClear
}

status_ramwatch:
Expand Down Expand Up @@ -3787,7 +3847,7 @@ status_twocries:
CMP #$0009 : BMI .check

.reset
TDC : STA !ram_roomstrat_state
TDC : STA !ram_roomstrat_state : STA !ram_quickdrop_counter
RTS

.start
Expand Down Expand Up @@ -3921,7 +3981,7 @@ status_twocries:
status_twocries_nosb:
{
LDA !ram_roomstrat_state : CMP #$0008 : BEQ .firstcheck
CMP #$0009 : BEQ .wait : BPL .done
CMP #$0009 : BEQ .wait : BPL .hangtimeonly
BRL .secondcheck

.firstscam
Expand Down Expand Up @@ -3950,6 +4010,9 @@ status_twocries_nosb:
.done
RTS

.hangtimeonly
BRL .hangtime

.ignore
LDA #$0009 : STA !ram_roomstrat_state
RTS
Expand All @@ -3963,14 +4026,24 @@ status_twocries_nosb:
LDA #$008E : SEC : SBC !ram_roomstrat_counter
ASL : TAY : LDA.w NumberGFXTable,Y : STA !HUD_TILEMAP+$8A
LDA !IH_LETTER_E : STA !HUD_TILEMAP+$88
BRA .donechecking
BRL .donechecking

.secondlate
SEC : SBC #$0098 : ASL : TAY : LDA.w NumberGFXTable,Y : STA !HUD_TILEMAP+$8E
LDA !IH_LETTER_L : STA !HUD_TILEMAP+$8C
BRA .donechecking

.secondcheck
LDA !SAMUS_Y : CMP #$003C : BPL .secondcheckclearhangtime
LDA !SAMUS_Y_DIRECTION : CMP #$0001 : BNE .secondcheckclearhangtime
LDA !ram_quickdrop_counter : INC : STA !ram_quickdrop_counter
LDX #$008C : JSR Draw2
BRA .secondcheckunmorph

.secondcheckclearhangtime
TDC : STA !ram_quickdrop_counter

.secondcheckunmorph
LDA !IH_CONTROLLER_PRI_NEW : AND !IH_INPUT_UP : BEQ .seconddone
LDA !ram_roomstrat_counter : CMP #$0057 : BMI .seconddone
CMP #$00D5 : BPL .seconddone : CMP #$0098 : BEQ .checkscam : BPL .secondlate
Expand Down Expand Up @@ -4020,5 +4093,16 @@ status_twocries_nosb:
ASL : TAY : LDA.w NumberGFXTable,Y : STA !HUD_TILEMAP+$8E
LDA !IH_LETTER_E : STA !HUD_TILEMAP+$8C
BRA .donechecking

.hangtime
LDA !SAMUS_Y : CMP #$003C : BPL .clearhangtime
LDA !SAMUS_Y_DIRECTION : CMP #$0001 : BNE .clearhangtime
LDA !ram_quickdrop_counter : INC : STA !ram_quickdrop_counter
LDX #$008C : JSR Draw2
RTS

.clearhangtime
TDC : STA !ram_quickdrop_counter
RTS
}

8 changes: 2 additions & 6 deletions src/init.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ org $808490
DEX : DEX
BPL .clear_bank_loop
JSL init_nonzero_wram

STY.w !ram_quickboot_spc_state
BRA .end_clear_bank


warnpc $8084AF

org $8084AF
Expand Down Expand Up @@ -59,8 +56,6 @@ endif

init_nonzero_wram:
{
JSL init_wram_based_on_sram

; RAM $7E0000 fluctuates so it is not a good default value
LDA #!ENEMY_HP : STA !ram_watch_left
LDA #!SAMUS_HP : STA !ram_watch_right
Expand All @@ -71,7 +66,8 @@ init_nonzero_wram:

LDA #$0001 : STA !ram_cm_dummy_on
STA !ram_cm_sfxlib1 : STA !ram_cm_sfxlib2 : STA !ram_cm_sfxlib3
RTL

JML init_wram_based_on_sram
}

init_sram:
Expand Down
1 change: 1 addition & 0 deletions src/layout.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,7 @@ layout_asm_waterway_external:
}

print pc, " layout bank83 end"
warnpc $83F000 ; presets


; Allow debug save stations to be used
Expand Down
2 changes: 1 addition & 1 deletion src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lorom

!VERSION_MAJOR = 2
!VERSION_MINOR = 6
!VERSION_BUILD = 3
!VERSION_BUILD = 4
!VERSION_REV = 0

table ../resources/normal.tbl
Expand Down
Loading

0 comments on commit 3e1f2e3

Please sign in to comment.