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
42 changes: 16 additions & 26 deletions RandomizerCore/Asm/BuffCarock.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

.segment "PRG4"

ProjectileYPosition = $30
ProjectileXVelocity = $77
ProjectileType = $87
EnemyType = $a1
LinkXPosition = $4d
EnemyXPositionLo = $4e
EnemyXPositionHi = $3c
RNG = $051b
ProjectileEnemyData = $07c0

EnemyYVelocity = $057e
; SinWaveVelocityIncrement = $ba1c

; Hook into carrock's update code to add the new position calculation
Expand All @@ -29,29 +19,29 @@ ChooseNewCarrockXPosition:
lda RNG,x
; By shifting links opposite side bit twice, we can force Carrock to be closer to the wall
asl
sta EnemyXPositionLo,x
sta Enemy0XPositionLo,x

; Since Link's position can be from roughly $00fb - 01ef
; We can offset this by flipping the high bit, and then checking if its greater than
; $80 - $10 (which would be like starting the range from F0 - 70)
lda LinkXPosition
lda LinkXPositionLo
eor #$80
cmp #$70

; At this point, the carry contains the bit for the opposite side of the screen for link
; So shift it back into bosses position
ror EnemyXPositionLo,x
ror Enemy0XPositionLo,x

; Vanilla checks to see if carrock is too close to the right edge, and prevents going
; offscreen by dividing the position by two if it would
lda #$e0
cmp EnemyXPositionLo,x
cmp Enemy0XPositionLo,x
bcs @SetXHighPos
sbc #$10 - 1
sta EnemyXPositionLo,x
sta Enemy0XPositionLo,x
@SetXHighPos:
lda #1
sta EnemyXPositionHi,x
sta Enemy0XPositionHi,x
rts

; Inside a funciton that updates motion for (maybe?) all projectiles
Expand All @@ -72,10 +62,10 @@ MoveSinWaveWifiShot:
lda ProjectileEnemyData,x
and #$01
tay
lda EnemyYVelocity,x
lda Enemy0YVelocity,x
clc
adc SinWaveVelocityIncrement,y
sta EnemyYVelocity,x
sta Enemy0YVelocity,x
cmp SinWaveMaxVelocityExtant,y
bne @NotAtMaxVelocity
inc ProjectileEnemyData,x
Expand All @@ -88,8 +78,8 @@ MoveSinWaveWifiShot:
bcc @PositiveVelocity
ora #$f0
@PositiveVelocity:
adc ProjectileYPosition,x
sta ProjectileYPosition,x
adc Projectile0YPosition,x
sta Projectile0YPosition,x
ldy #$12
@NotAWifiShot:
; Perform the original patched call
Expand All @@ -102,12 +92,12 @@ MoveSinWaveWifiShot:
.reloc
RandomizeWifiShotType:
ldx $10
lda EnemyType,x
lda Enemy0Type,x
cmp #$22 ; check if its spawned by carock and skip it. carock code id is 0x22
beq @CarockShot
; Do the original code since its not our new buffed carock
lda #$c0
sta ProjectileYPosition,y
sta Projectile0YPosition,y
rts
@CarockShot:
; Fetch a random number and 50/50 chance its a straight shot
Expand All @@ -120,7 +110,7 @@ RandomizeWifiShotType:
@HiPositionShot:
sta ProjectileEnemyData,y
lda #0
sta EnemyYVelocity,y
sta Enemy0YVelocity,y
lda ProjectileEnemyData,y
ora #$b0
; Firing a sin wave shot, so set the flag for sin wave and then follow through setting up the position
Expand All @@ -136,12 +126,12 @@ RandomizeWifiShotType:
clc
adc #$10
@WriteShotYCoord:
sta ProjectileYPosition,y
sta Projectile0YPosition,y
; roll a random number to see if we shoot a fast beam
lda RNG+1
and #1
beq @Exit
lda ProjectileXVelocity,y
lda Projectile0XVelocity,y
bmi @NegativeVelocity
clc
adc #$10
Expand All @@ -150,7 +140,7 @@ RandomizeWifiShotType:
sec
sbc #$10
@DoneVelocityUpdate:
sta ProjectileXVelocity,y
sta Projectile0XVelocity,y
@Exit:
rts

Expand Down
2 changes: 1 addition & 1 deletion RandomizerCore/Asm/DashSpell.s
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.reloc
ReplaceFireWithDashSpell:
pha
lda $076f ; Current magic state
lda FireSpellActive ; Current magic state
and #$10 ; fire is on
bne @HasFire
pla
Expand Down
2 changes: 1 addition & 1 deletion RandomizerCore/Asm/ExpandedPauseMenu.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.reloc
CheckIfLevelingUp:
lda $074c ; When 74c is 0 we are doing the normal pause screen
lda CurrentDialogType ; When 74c is 0 we are doing the normal pause screen
lsr ; so set the carry if 74c is 1
lda $0525 ; Then reload the row draw count
bcc @skip
Expand Down
24 changes: 12 additions & 12 deletions RandomizerCore/Asm/FullItemShuffle.s
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ HandlePBagDeath:
; since there a lot of NPCs walking around.
bmi @Exit ; unconditional
@FoundEmpty:
lda $20,x ; enemy y hi
sta $20,y
lda $2a,x ; enemy y lo
sta $2a,y
lda $3c,x ; enemy x hi
sta $3c,y
lda $4e,x ; enemy x lo
sta $4e,y
lda Enemy0Condition,x
sta Enemy0Condition,y
lda Enemy0YPositionLo,x
sta Enemy0YPositionLo,y
lda Enemy0XPositionHi,x
sta Enemy0XPositionHi,y
lda Enemy0XPositionLo,x
sta Enemy0XPositionLo,y
; don't reset DontKillEnemyFlag here since its needed in HandlePBagTimerClear
tya
tax
Expand Down Expand Up @@ -376,7 +376,7 @@ ExpandedGetItem:
@NotDashSpell:
; flash screen as if you got the spell from a wizard
lda #$c0
sta $074b
sta LinkFlashingTimer
; Convert from expanded item ID to regular spell ID
tya
sec
Expand All @@ -393,7 +393,7 @@ ExpandedGetItem:
bpl @CheckAllSpells
; Update the cursor position to point to the new spell
pla
sta $0749
sta MagicSelectorPosition
.byte $24 ; OPCODE bit $zp (hides pla)
@FoundLearnedSpell:
pla
Expand All @@ -418,9 +418,9 @@ ExpandedGetItem:
sta $ef
jmp $e84b ; Red/blue jar handler
@ItemStab:
lda $0796
lda HaveStabs
ora @StabTable - ITEM_UPSTAB,y
sta $0796
sta HaveStabs
bne @Exit ; unconditional
@ItemBagu:
lda $079a
Expand Down
10 changes: 5 additions & 5 deletions RandomizerCore/Asm/MMC5.s
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ HandleLagFrame:
and #$10
beq @HandleAudio
; Check that we are in the side view mode
lda $0736
lda GameMode
cmp #$0b
bne @HandleAudio
; Check if we even have a sprite zero on the screen (Spoiler: there is not, sprite zero was removed)
Expand Down Expand Up @@ -320,7 +320,7 @@ IncStatTimer:
cmp #$0b
bne @Exit
; in an encounter (includes caves)
lda $0748
lda LocationNumber
cmp #$3e
bne @Exit
; In a random encounter
Expand All @@ -334,7 +334,7 @@ IncStatTimer:
lda RegionNumber
asl
asl
adc PalaceNumber
adc PalaceRegionIndex
tay
ldx PalaceMappingTable,y
@IncrementTimer:
Expand Down Expand Up @@ -548,7 +548,7 @@ SwapToPRG0:
lda #$00
beq SwapPRG
SwapToSavedPRG:
lda $0769
lda CurrentPrgBank
SwapPRG:
asl
ora #$80
Expand Down Expand Up @@ -677,7 +677,7 @@ UPDATE_REFS SwapToSavedPRG @ $E002
LoadAreaBGMetatile:
; guarantee the code is in a000 or higher otherwise we would switch this bank out from under itself
.assert * > $a000
lda $0769
lda CurrentPrgBank
asl
ora #$80
sta NmiBankShadow8
Expand Down
9 changes: 2 additions & 7 deletions RandomizerCore/Asm/Recoil.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

.segment "PRG7"

LinkXVelocity = $70
EnemyID = $a1
LinkYVelocityLo = $03E6
LinkYVelocityHi = $057D

LinkHitRoutine = $E2EF

; Patch when a boss hits link for a strong hit to ignore the 2x multiplier
Expand All @@ -32,15 +27,15 @@ SetLinkXRecoil:
lda #$ff
@InvertRecoil:
pha
lda EnemyID,x
lda Enemy0Type,x
tay
pla
eor RecoilTableX,y
rts

.reloc
SetLinkYRecoil:
lda EnemyID,x
lda Enemy0Type,x
tay
lda RecoilTableYLo,y
sta LinkYVelocityLo
Expand Down
28 changes: 14 additions & 14 deletions RandomizerCore/Asm/StatTracking.s
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ StatTrackSwordSwipe:
; Need to use X so we need to preserve it
txa
tay
lda $17 ; 0 if crouching 1 if not
lda LinkStanding ; 0 if crouching 1 if not
eor #1 ; so invert the bit to get 1 if crouching 0 if not
asl
tax
Expand Down Expand Up @@ -122,29 +122,29 @@ SaveTimestampForPalace:
lda RegionNumber
asl
asl
adc PalaceNumber
adc PalaceRegionIndex
tay
lda PalaceTable,y
jmp AddTimestamp

.reloc
PalaceTable:
; region 0 - east hyrule
; region 0 - West Hyrule
.byte RealPalaceAtLocation1 + TsPalace1
.byte RealPalaceAtLocation2 + TsPalace1
.byte RealPalaceAtLocation3 + TsPalace1
.byte $ff ; unused 4th palace in region 0
; region 1 - death mountain
; region 1 - Death Mountain
.byte $ff ; unused 1st palace in region 1
.byte $ff ; unused 2nd palace in region 1
.byte $ff ; unused 3th palace in region 1
.byte $ff ; unused 4th palace in region 1
; region 2 - west hyrule
; region 2 - East Hyrule
.byte RealPalaceAtLocation5 + TsPalace1
.byte RealPalaceAtLocation6 + TsPalace1
.byte RealPalaceAtLocationGP+ TsPalace1
.byte $ff ; unused 4th palace in region 2
; region 3 - maze island
; region 3 - Maze Island
.byte RealPalaceAtLocation4 + TsPalace1

.segment "PRG7"
Expand Down Expand Up @@ -292,7 +292,7 @@ bank7_Display = $ef11
jmp AddPressStartToSkip
.reloc
AddPressStartToSkip:
inc $0736
inc GameMode

; rendering is off so we can just draw whatever we want
lda #$23
Expand Down Expand Up @@ -324,9 +324,9 @@ StopTimers:
@AlreadyDoneOnce:
; setup and draw the old man over an over
lda #$d0
sta $4e ;monster x
sta Enemy0XPositionLo
lda #$50
sta $2a ;monster y
sta Enemy0YPositionLo
lda #$cf
sta $cd ;monster position on screen (fixes triforce position on first frame)
jsr bank7_Display ; its the credits who cares about a few cycles
Expand Down Expand Up @@ -412,7 +412,7 @@ LoadStatsFromCheckpoint:
.reloc
CheckToSkipToEnd:
; check if start is pressed
lda $f5
lda Controller1ButtonsPressed
and #$10
beq @skip
; don't let this skip code run once we've moved to the stats
Expand Down Expand Up @@ -767,7 +767,7 @@ UpdateSpritePosition:
sta $cc
; link y offset
lda #$20
sta $29
sta LinkYPos
; link metasprite
lda #3
sta $80
Expand All @@ -777,7 +777,7 @@ UpdateSpritePosition:
.reloc
WaitForStart:
; check if start is pressed
lda $f5
lda Controller1ButtonsPressed
and #$10
beq :>rts
inc StatDisplayState
Expand Down Expand Up @@ -883,7 +883,7 @@ PALETTE_FADE_LEN = * - RandomOrderTable
.reloc
FadeOut:
; Every 16 frames step to the next palette
lda $12 ; global timer
lda FrameCounter
and #$01
beq :>rts
ldx InternalState
Expand Down Expand Up @@ -923,7 +923,7 @@ SprPaletteTable = $80AE
FadeIn:
ldx InternalState
; Every 16 frames step to the next palette
lda $12 ; global timer
lda FrameCounter
and #$01
beq :>rts
cpx #12
Expand Down
Loading
Loading