Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ To be assembled using [Asar](https://github.com/RPGHacker/asar), see the Makefil
- infinite lives
- DK coins will always respawn
- manage your kongs on the map (by BlueImp)
- `L` to toggle between having 1 or 2 kongs
- `R` to change which kong is in front
- hold `R` and press `L` to toggle between having 1 or 2 kongs
- hold `R` and press `select` to change which kong is in front
- hold `L` and press `R` to toggle the autojump state on and off
- hold `L` and press `select` to quickly return to the overworld from a world map

you're probably gonna need a completed save file for now, sorry
16 changes: 15 additions & 1 deletion src/defines.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@include
include

; define rom locations based on rom revision
if !rom_revision == 0
Expand All @@ -15,6 +15,8 @@ if !rom_revision == 0
end_bananas = $BEC89F
draw_digit = $BEC814
freerom_BE = $BEFB8A
play_high_priority_sound = $B58021
vgheroes_check = $B4877D
elseif !rom_revision == 1
hijack_level = $808640
hijack_nmi = $80F3D8
Expand All @@ -29,13 +31,17 @@ elseif !rom_revision == 1
end_bananas = $BEC8AA
draw_digit = $BEC81F
freerom_BE = $BEFB67
play_high_priority_sound = $B58021
vgheroes_check = $B4878F
endif

; constants
!dropped_frames_x = $0008
!dropped_frames_y = $0900
!timer_x = $00CC
!timer_y = $0900
!sfx_notallowed = $5F
!sfx_balloon = $2C

; wram
!freeram = $1A00
Expand All @@ -46,20 +52,28 @@ macro def_freeram(id, size)
!freeram_used #= !freeram_used+<size>
endmacro

!nmi_pointer = $0020
!nmi_pointer_dp = $20
!io_axlr = $050E
!io_byetudlr = $050F
!io_axlr_1f = $0510
!io_byetudlr_1f = $0511
!fade_type = $0513
!main_kong = $0593
!follower_kong = $0597
!map_index = $06B1
!current_map_kong = $08A4
!pause_flags = $08C2
!extra_kong_flag = $08C2
!level_state = $0AF1

!counter_60hz_pausable = $002A
!counter_60hz_pausable_dp = $2A
!counter_60hz = $2C

!reg_joy1l = $4218
!reg_joy1h = $4219

%def_freeram(previous_60hz, 2)

%def_freeram(dropped_frames, 2)
Expand Down
6 changes: 5 additions & 1 deletion src/edits.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@include
include

; u1.0 checksum
org $00FFDC
Expand All @@ -21,3 +21,7 @@ org bypass_hud_face
; always spawn dk coins as not collected
org dk_coin_check
BRA $0E

; don't load the video game heroes screen
org vgheroes_check
BRA $11 : NOP
2 changes: 1 addition & 1 deletion src/hijacks.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@include
include

org hijack_level
JSL every_igt_frame
Expand Down
2 changes: 1 addition & 1 deletion src/hud.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@include
include

handle_displays:
SEP #$20
Expand Down
2 changes: 1 addition & 1 deletion src/level.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@include
include

every_igt_frame:
JSR handle_frame_counters
Expand Down
5 changes: 3 additions & 2 deletions src/main.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
asar 1.91
hirom

; 0 for 1.0
Expand All @@ -13,9 +14,9 @@ org freerom_BB
incsrc "level.asm"
incsrc "map.asm"

warnpc $BBFFFF
assert pc() <= $BBFFFF

org freerom_BE
incsrc "hud.asm"

warnpc $BEFFFF
assert pc() <= $BEFFFF
56 changes: 47 additions & 9 deletions src/map.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@include
include

every_map_frame:
STZ !dropped_frames
Expand All @@ -14,18 +14,58 @@ every_map_frame:
LDA !counter_60hz
STA !previous_60hz

JSR check_goto_overworld
JSR check_toggle_autojump
JSR check_kong_swap

SEP #$20
LDA $0512
RTL


check_goto_overworld:
LDA !io_axlr : BIT #$0020 : BEQ .done ; L held?
LDA !io_byetudlr_1f : BIT #$0020 : BEQ .done ; select pressed?

; the nmi_pointer selects the address in bank $80 to run at the start of each frame
; $8087D9 jumps to $B5CDFD, which loads a world map screen based on the value in map_index
LDA #$87D9 : STA !nmi_pointer_dp
STZ !map_index ; 0 = overworld

; $06AF/B0 seems to store a movement value for when the kongs move between map nodes
; if you try to load the overworld while this is non-zero, you will softlock as they run offscreen
STZ $06AF

; $06AD seems to store a value that dictates where the kongs move after beating a level
; it gets set even when they don't move automatically, and is only cleared when a new node is reached
; zeroing it prevents another softlock when loading the overworld immediately after beating a level
STZ $06AD
.done:
RTS

; when deciding whether or not to allow a jump, the game checks if B was pressed in the last 15 frames:
; current_frame_counter - frame_counter_at_time_of_B_press < 16
; if a value is greater than $8000, it is considered negative in two's complement
; so autojump is active if the current frame counter is at least $8000 (as long as the B press var remains at zero)
check_toggle_autojump:
LDA !io_axlr : BIT #$0020 : BEQ .done ; L held?
LDA !io_axlr_1f : BIT #$0010 : BEQ .done ; R pressed?

; flip the frame counter between 0 (inactive) and two's complement -32768 (active)
LDA !counter_60hz_pausable_dp : AND #$8000 : EOR #$8000 : STA !counter_60hz_pausable_dp
BMI +
LDA.w #!sfx_notallowed
BRA .play_sound
+
LDA.w #!sfx_balloon
.play_sound:
JSL play_high_priority_sound
.done:
RTS

check_kong_swap:
; if L was pressed, toggle between 1 or 2 kongs
LDA !io_axlr_1f
BIT #$0020
BEQ .check_swap
LDA !io_axlr : BIT #$0010 : BEQ .check_swap ; R held?
LDA !io_axlr_1f : BIT #$0020 : BEQ .check_swap ; L pressed?

; toggle sprite visibility
LDX !follower_kong
Expand All @@ -39,10 +79,8 @@ check_kong_swap:
STA !extra_kong_flag

.check_swap:
; if R was pressed, change which kong is in front
LDA !io_axlr_1f
BIT #$0010
BEQ .done
LDA !io_axlr : BIT #$0010 : BEQ .done ; R held?
LDA !io_byetudlr_1f : BIT #$0020 : BEQ .done ; select pressed?

; toggle between diddy and dixie
LDA !current_map_kong
Expand Down