Skip to content

Commit 93339e0

Browse files
committed
Add RAM address map
1 parent 6cb25e6 commit 93339e0

12 files changed

Lines changed: 462 additions & 120 deletions

File tree

RandomizerCore/Asm/BuffCarock.s

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
22

33
.segment "PRG4"
44

5-
ProjectileYPosition = $30
6-
ProjectileXVelocity = $77
7-
ProjectileType = $87
8-
EnemyType = $a1
9-
LinkXPosition = $4d
10-
EnemyXPositionLo = $4e
11-
EnemyXPositionHi = $3c
12-
RNG = $051b
135
ProjectileEnemyData = $07c0
14-
15-
EnemyYVelocity = $057e
166
; SinWaveVelocityIncrement = $ba1c
177

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

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

4131
; At this point, the carry contains the bit for the opposite side of the screen for link
4232
; So shift it back into bosses position
43-
ror EnemyXPositionLo,x
33+
ror Enemy0XPositionLo,x
4434

4535
; Vanilla checks to see if carrock is too close to the right edge, and prevents going
4636
; offscreen by dividing the position by two if it would
4737
lda #$e0
48-
cmp EnemyXPositionLo,x
38+
cmp Enemy0XPositionLo,x
4939
bcs @SetXHighPos
5040
sbc #$10 - 1
51-
sta EnemyXPositionLo,x
41+
sta Enemy0XPositionLo,x
5242
@SetXHighPos:
5343
lda #1
54-
sta EnemyXPositionHi,x
44+
sta Enemy0XPositionHi,x
5545
rts
5646

5747
; Inside a funciton that updates motion for (maybe?) all projectiles
@@ -72,10 +62,10 @@ MoveSinWaveWifiShot:
7262
lda ProjectileEnemyData,x
7363
and #$01
7464
tay
75-
lda EnemyYVelocity,x
65+
lda Enemy0YVelocity,x
7666
clc
7767
adc SinWaveVelocityIncrement,y
78-
sta EnemyYVelocity,x
68+
sta Enemy0YVelocity,x
7969
cmp SinWaveMaxVelocityExtant,y
8070
bne @NotAtMaxVelocity
8171
inc ProjectileEnemyData,x
@@ -88,8 +78,8 @@ MoveSinWaveWifiShot:
8878
bcc @PositiveVelocity
8979
ora #$f0
9080
@PositiveVelocity:
91-
adc ProjectileYPosition,x
92-
sta ProjectileYPosition,x
81+
adc Projectile0YPosition,x
82+
sta Projectile0YPosition,x
9383
ldy #$12
9484
@NotAWifiShot:
9585
; Perform the original patched call
@@ -102,12 +92,12 @@ MoveSinWaveWifiShot:
10292
.reloc
10393
RandomizeWifiShotType:
10494
ldx $10
105-
lda EnemyType,x
95+
lda Enemy0Type,x
10696
cmp #$22 ; check if its spawned by carock and skip it. carock code id is 0x22
10797
beq @CarockShot
10898
; Do the original code since its not our new buffed carock
10999
lda #$c0
110-
sta ProjectileYPosition,y
100+
sta Projectile0YPosition,y
111101
rts
112102
@CarockShot:
113103
; Fetch a random number and 50/50 chance its a straight shot
@@ -120,7 +110,7 @@ RandomizeWifiShotType:
120110
@HiPositionShot:
121111
sta ProjectileEnemyData,y
122112
lda #0
123-
sta EnemyYVelocity,y
113+
sta Enemy0YVelocity,y
124114
lda ProjectileEnemyData,y
125115
ora #$b0
126116
; Firing a sin wave shot, so set the flag for sin wave and then follow through setting up the position
@@ -136,12 +126,12 @@ RandomizeWifiShotType:
136126
clc
137127
adc #$10
138128
@WriteShotYCoord:
139-
sta ProjectileYPosition,y
129+
sta Projectile0YPosition,y
140130
; roll a random number to see if we shoot a fast beam
141131
lda RNG+1
142132
and #1
143133
beq @Exit
144-
lda ProjectileXVelocity,y
134+
lda Projectile0XVelocity,y
145135
bmi @NegativeVelocity
146136
clc
147137
adc #$10
@@ -150,7 +140,7 @@ RandomizeWifiShotType:
150140
sec
151141
sbc #$10
152142
@DoneVelocityUpdate:
153-
sta ProjectileXVelocity,y
143+
sta Projectile0XVelocity,y
154144
@Exit:
155145
rts
156146

RandomizerCore/Asm/DashSpell.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.reloc
1414
ReplaceFireWithDashSpell:
1515
pha
16-
lda $076f ; Current magic state
16+
lda FireSpellActive ; Current magic state
1717
and #$10 ; fire is on
1818
bne @HasFire
1919
pla

RandomizerCore/Asm/ExpandedPauseMenu.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
.reloc
1111
CheckIfLevelingUp:
12-
lda $074c ; When 74c is 0 we are doing the normal pause screen
12+
lda CurrentDialogType ; When 74c is 0 we are doing the normal pause screen
1313
lsr ; so set the carry if 74c is 1
1414
lda $0525 ; Then reload the row draw count
1515
bcc @skip

RandomizerCore/Asm/FullItemShuffle.s

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ HandlePBagDeath:
320320
; since there a lot of NPCs walking around.
321321
bmi @Exit ; unconditional
322322
@FoundEmpty:
323-
lda $20,x ; enemy y hi
324-
sta $20,y
325-
lda $2a,x ; enemy y lo
326-
sta $2a,y
327-
lda $3c,x ; enemy x hi
328-
sta $3c,y
329-
lda $4e,x ; enemy x lo
330-
sta $4e,y
323+
lda Enemy0Condition,x
324+
sta Enemy0Condition,y
325+
lda Enemy0YPositionLo,x
326+
sta Enemy0YPositionLo,y
327+
lda Enemy0XPositionHi,x
328+
sta Enemy0XPositionHi,y
329+
lda Enemy0XPositionLo,x
330+
sta Enemy0XPositionLo,y
331331
; don't reset DontKillEnemyFlag here since its needed in HandlePBagTimerClear
332332
tya
333333
tax
@@ -376,7 +376,7 @@ ExpandedGetItem:
376376
@NotDashSpell:
377377
; flash screen as if you got the spell from a wizard
378378
lda #$c0
379-
sta $074b
379+
sta LinkFlashingTimer
380380
; Convert from expanded item ID to regular spell ID
381381
tya
382382
sec
@@ -393,7 +393,7 @@ ExpandedGetItem:
393393
bpl @CheckAllSpells
394394
; Update the cursor position to point to the new spell
395395
pla
396-
sta $0749
396+
sta MagicSelectorPosition
397397
.byte $24 ; OPCODE bit $zp (hides pla)
398398
@FoundLearnedSpell:
399399
pla
@@ -418,9 +418,9 @@ ExpandedGetItem:
418418
sta $ef
419419
jmp $e84b ; Red/blue jar handler
420420
@ItemStab:
421-
lda $0796
421+
lda HaveStabs
422422
ora @StabTable - ITEM_UPSTAB,y
423-
sta $0796
423+
sta HaveStabs
424424
bne @Exit ; unconditional
425425
@ItemBagu:
426426
lda $079a

RandomizerCore/Asm/MMC5.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ HandleLagFrame:
149149
and #$10
150150
beq @HandleAudio
151151
; Check that we are in the side view mode
152-
lda $0736
152+
lda GameMode
153153
cmp #$0b
154154
bne @HandleAudio
155155
; Check if we even have a sprite zero on the screen (Spoiler: there is not, sprite zero was removed)
@@ -320,7 +320,7 @@ IncStatTimer:
320320
cmp #$0b
321321
bne @Exit
322322
; in an encounter (includes caves)
323-
lda $0748
323+
lda LocationNumber
324324
cmp #$3e
325325
bne @Exit
326326
; In a random encounter
@@ -334,7 +334,7 @@ IncStatTimer:
334334
lda RegionNumber
335335
asl
336336
asl
337-
adc PalaceNumber
337+
adc PalaceRegionIndex
338338
tay
339339
ldx PalaceMappingTable,y
340340
@IncrementTimer:
@@ -548,7 +548,7 @@ SwapToPRG0:
548548
lda #$00
549549
beq SwapPRG
550550
SwapToSavedPRG:
551-
lda $0769
551+
lda CurrentPrgBank
552552
SwapPRG:
553553
asl
554554
ora #$80
@@ -677,7 +677,7 @@ UPDATE_REFS SwapToSavedPRG @ $E002
677677
LoadAreaBGMetatile:
678678
; guarantee the code is in a000 or higher otherwise we would switch this bank out from under itself
679679
.assert * > $a000
680-
lda $0769
680+
lda CurrentPrgBank
681681
asl
682682
ora #$80
683683
sta NmiBankShadow8

RandomizerCore/Asm/Recoil.s

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
.segment "PRG7"
44

5-
LinkXVelocity = $70
6-
EnemyID = $a1
7-
LinkYVelocityLo = $03E6
8-
LinkYVelocityHi = $057D
9-
105
LinkHitRoutine = $E2EF
116

127
; Patch when a boss hits link for a strong hit to ignore the 2x multiplier
@@ -32,15 +27,15 @@ SetLinkXRecoil:
3227
lda #$ff
3328
@InvertRecoil:
3429
pha
35-
lda EnemyID,x
30+
lda Enemy0Type,x
3631
tay
3732
pla
3833
eor RecoilTableX,y
3934
rts
4035

4136
.reloc
4237
SetLinkYRecoil:
43-
lda EnemyID,x
38+
lda Enemy0Type,x
4439
tay
4540
lda RecoilTableYLo,y
4641
sta LinkYVelocityLo

RandomizerCore/Asm/StatTracking.s

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ StatTrackSwordSwipe:
5252
; Need to use X so we need to preserve it
5353
txa
5454
tay
55-
lda $17 ; 0 if crouching 1 if not
55+
lda LinkStanding ; 0 if crouching 1 if not
5656
eor #1 ; so invert the bit to get 1 if crouching 0 if not
5757
asl
5858
tax
@@ -122,29 +122,29 @@ SaveTimestampForPalace:
122122
lda RegionNumber
123123
asl
124124
asl
125-
adc PalaceNumber
125+
adc PalaceRegionIndex
126126
tay
127127
lda PalaceTable,y
128128
jmp AddTimestamp
129129

130130
.reloc
131131
PalaceTable:
132-
; region 0 - east hyrule
132+
; region 0 - West Hyrule
133133
.byte RealPalaceAtLocation1 + TsPalace1
134134
.byte RealPalaceAtLocation2 + TsPalace1
135135
.byte RealPalaceAtLocation3 + TsPalace1
136136
.byte $ff ; unused 4th palace in region 0
137-
; region 1 - death mountain
137+
; region 1 - Death Mountain
138138
.byte $ff ; unused 1st palace in region 1
139139
.byte $ff ; unused 2nd palace in region 1
140140
.byte $ff ; unused 3th palace in region 1
141141
.byte $ff ; unused 4th palace in region 1
142-
; region 2 - west hyrule
142+
; region 2 - East Hyrule
143143
.byte RealPalaceAtLocation5 + TsPalace1
144144
.byte RealPalaceAtLocation6 + TsPalace1
145145
.byte RealPalaceAtLocationGP+ TsPalace1
146146
.byte $ff ; unused 4th palace in region 2
147-
; region 3 - maze island
147+
; region 3 - Maze Island
148148
.byte RealPalaceAtLocation4 + TsPalace1
149149

150150
.segment "PRG7"
@@ -292,7 +292,7 @@ bank7_Display = $ef11
292292
jmp AddPressStartToSkip
293293
.reloc
294294
AddPressStartToSkip:
295-
inc $0736
295+
inc GameMode
296296

297297
; rendering is off so we can just draw whatever we want
298298
lda #$23
@@ -324,9 +324,9 @@ StopTimers:
324324
@AlreadyDoneOnce:
325325
; setup and draw the old man over an over
326326
lda #$d0
327-
sta $4e ;monster x
327+
sta Enemy0XPositionLo
328328
lda #$50
329-
sta $2a ;monster y
329+
sta Enemy0YPositionLo
330330
lda #$cf
331331
sta $cd ;monster position on screen (fixes triforce position on first frame)
332332
jsr bank7_Display ; its the credits who cares about a few cycles
@@ -412,7 +412,7 @@ LoadStatsFromCheckpoint:
412412
.reloc
413413
CheckToSkipToEnd:
414414
; check if start is pressed
415-
lda $f5
415+
lda Controller1ButtonsPressed
416416
and #$10
417417
beq @skip
418418
; don't let this skip code run once we've moved to the stats
@@ -767,7 +767,7 @@ UpdateSpritePosition:
767767
sta $cc
768768
; link y offset
769769
lda #$20
770-
sta $29
770+
sta LinkYPos
771771
; link metasprite
772772
lda #3
773773
sta $80
@@ -777,7 +777,7 @@ UpdateSpritePosition:
777777
.reloc
778778
WaitForStart:
779779
; check if start is pressed
780-
lda $f5
780+
lda Controller1ButtonsPressed
781781
and #$10
782782
beq :>rts
783783
inc StatDisplayState
@@ -883,7 +883,7 @@ PALETTE_FADE_LEN = * - RandomOrderTable
883883
.reloc
884884
FadeOut:
885885
; Every 16 frames step to the next palette
886-
lda $12 ; global timer
886+
lda FrameCounter
887887
and #$01
888888
beq :>rts
889889
ldx InternalState
@@ -923,7 +923,7 @@ SprPaletteTable = $80AE
923923
FadeIn:
924924
ldx InternalState
925925
; Every 16 frames step to the next palette
926-
lda $12 ; global timer
926+
lda FrameCounter
927927
and #$01
928928
beq :>rts
929929
cpx #12

0 commit comments

Comments
 (0)