Remove residual/unnecessary code and data

develop
Christophe Parent 2024-05-28 23:44:30 -07:00
parent 0e0dc84aeb
commit 61b894ae1e
1 changed files with 13 additions and 111 deletions

View File

@ -74,7 +74,6 @@ FrenzyEnemyTimer = $078f
BowserFireBreathTimer = $0790
StompTimer = $0791
AirBubbleTimer = $0792
ScrollIntervalTimer = $0795
EnemyIntervalTimer = $0796
BrickCoinTimer = $079d
InjuryTimer = $079e
@ -410,7 +409,6 @@ Block_BBuf_Low = $03e6
Block_Metatile = $03e8
Block_PageLoc2 = $03ea
Block_RepFlag = $03ec
Block_ResidualCounter = $03f0
Block_Orig_XPos = $03f1
BoundingBox_UL_XPos = $04ac
@ -428,7 +426,6 @@ FireballCounter = $06ce
FireballThrowingTimer = $0711
HammerEnemyOffset = $06ae
JumpCoinMiscOffset = $06b7
Block_Buffer_1 = $0500
Block_Buffer_2 = $05d0
@ -906,7 +903,6 @@ ExitPause:
; $00 - used for preset value
SpriteShuffler:
ldy AreaType ; load level type, likely residual code
lda #$28 ; load preset value which will put it at
sta $00 ; sprite #10
ldx #$0e ; start at the end of OAM data offsets
@ -1086,7 +1082,6 @@ StartWorld1:
sta OperMode_Task ; set game mode here, and clear demo timer
sta DemoTimer
ldx #$17
lda #$00
InitScores:
sta ScoreAndCoinDisplay,x ; clear player scores and coin displays
dex
@ -1227,8 +1222,6 @@ PrintVictoryMessages:
bne IncMsgCounter ; if set, branch to increment message counters
lda PrimaryMsgCounter ; otherwise load primary message counter
beq ThankPlayer ; if set to zero, branch to print first message
cmp #$09 ; if at 9 or above, branch elsewhere (this comparison
bcs IncMsgCounter ; is residual code, counter never reaches 9)
ldy WorldNumber ; check world number
cpy #World8
bne MRetainerMsg ; if not at world 8, skip to next part
@ -1292,7 +1285,6 @@ PlayerEndWorld:
ldy WorldNumber ; check world number
cpy #World8 ; if on world 8, player is done with game,
bcs EndChkBButton ; thus branch to read controller
lda #$00
sta AreaNumber ; otherwise initialize area number used as offset
sta LevelNumber ; and level number control to start at area 1
sta OperMode_Task ; initialize secondary mode of operation
@ -1623,9 +1615,6 @@ DisplayIntermediate:
beq GameOverInter ; if so, proceed to display game over screen
lda AltEntranceControl ; otherwise check for mode of alternate entry
bne NoInter ; and branch if found
ldy AreaType ; check if we are on castle level
cpy #$03 ; and if so, branch (possibly residual)
beq PlayerInter
lda DisableIntermediate ; if this flag is set, skip intermediate lives display
bne NoInter ; and jump to specific task, otherwise
PlayerInter:
@ -2138,8 +2127,6 @@ WriteBlankMT:
ReplaceBlockMetatile:
jsr WriteBlockMetatile ; write metatile to vram buffer to replace block object
inc Block_ResidualCounter ; increment unused counter (residual code)
dec Block_RepFlag,x ; decrement flag (residual code)
rts ; leave
DestroyBlockMetatile:
@ -2615,12 +2602,9 @@ RepeatByte:
lda #$00
adc $01
sta $01
lda #$3f ; sets vram address to $3f00
sta PPU_ADDRESS
lda #$00
sta PPU_ADDRESS
sta PPU_ADDRESS ; then reinitializes it for some reason
sta PPU_ADDRESS
sta PPU_ADDRESS ; reinitialize vram address to $0000
UpdateScreen:
ldx PPU_STATUS ; reset flip-flop
ldy #$00 ; load first byte from indirect as a pointer
@ -2906,8 +2890,6 @@ ISpr0Loop:
sta Sprite_Data,y
dey
bpl ISpr0Loop
jsr DoNothing2 ; these jsrs doesn't do anything useful
jsr DoNothing1
inc Sprite0HitDetectFlag ; set sprite #0 check flag
inc OperMode_Task ; increment to next task
rts
@ -3148,7 +3130,6 @@ TerminateGame:
lda WorldNumber ; otherwise put world number of current
sta ContinueWorld ; player into secret continue function variable
lda #$00
asl ; residual ASL instruction
sta OperMode_Task ; reset all modes to title screen and
sta ScreenTimer ; leave
sta OperMode
@ -3194,15 +3175,6 @@ ExTrans:
;-------------------------------------------------------------------------------------
DoNothing1:
lda #$ff ; this is residual code, this value is
sta $06c9 ; not used anywhere in the program
DoNothing2:
rts
;-------------------------------------------------------------------------------------
AreaParserTaskHandler:
ldy AreaParserTaskNum ; check number of tasks here
bne DoAPTasks ; if already set, go ahead
@ -4007,7 +3979,6 @@ ExitCastle:
WaterPipe:
jsr GetLrgObjAttrib ; get row and lower nybble
ldy AreaObjectLength,x ; get length (residual code, water pipe is 1 col thick)
ldx $07 ; get row
lda #$6b
sta MetatileBuffer,x ; draw something here and below it
@ -4458,8 +4429,6 @@ DrawQBlk:
GetAreaObjectID:
lda $00 ; get value saved from area parser routine
sec
sbc #$00 ; possibly residual code
tay ; save to Y
ExitDecBlock:
rts
@ -4514,7 +4483,6 @@ RenderUnderPart:
beq WaitOneRow ; if middle part (mushroom ledge), wait until next row
cpy #$c0
beq DrawThisRow ; if question block w/ coin, overwrite
cpy #$c0
bcs WaitOneRow ; if any other metatile with palette 3, wait until next row
cpy #$54
bne DrawThisRow ; if cracked rock terrain, overwrite
@ -5698,8 +5666,6 @@ ScrollScreen:
ora $00 ; get saved bit here and save in PPU register 1
sta Mirror_PPU_CTRL_REG1 ; mirror to be used to set name table later
jsr GetScreenPosition ; figure out where the right side is
lda #$08
sta ScrollIntervalTimer ; set scroll timer (residual, not used elsewhere)
jmp ChkPOffscr ; skip this part
InitScrlAmt:
lda #$00
@ -6120,7 +6086,7 @@ ExitDeath:
FlagpoleSlide:
lda Enemy_ID+5 ; check special use enemy slot
cmp #FlagpoleFlagObject ; for flagpole flag object
bne NoFPObj ; if not found, branch to something residual
bne NoFPObj ; if not found, branch to exit
lda FlagpoleSoundQueue ; load flagpole sound
sta Square1SoundQueue ; into square 1's sfx queue
lda #$00
@ -6132,8 +6098,8 @@ FlagpoleSlide:
SlidePlayer:
jmp AutoControlPlayer ; jump to player control routine
NoFPObj:
inc GameEngineSubroutine ; increment to next routine (this may
rts ; be residual code)
inc GameEngineSubroutine ; increment to next routine
rts
;-------------------------------------------------------------------------------------
@ -6579,7 +6545,6 @@ SetAnimSpd:
ImposeFriction:
and Player_CollisionBits ; perform AND between left/right controller bits and collision flag
cmp #$00 ; then compare to zero (this instruction is redundant)
bne JoypFrict ; if any bits set, branch to next part
lda Player_X_Speed
beq SetAbsSpd ; if player has no horizontal speed, branch ahead to last part
@ -7299,7 +7264,6 @@ NoHammer:
;--------------------------------
; $00 - used to set downward force
; $01 - used to set upward force (residual)
; $02 - used to set maximum speed
ProcHammerObj:
@ -7317,8 +7281,6 @@ ProcHammerObj:
tax ; return offset to X
lda #$10
sta $00 ; set downward movement force
lda #$0f
sta $01 ; set upward movement force (not used)
lda #$04
sta $02 ; set maximum vertical speed
lda #$00 ; set A to impose gravity on hammer
@ -7414,7 +7376,6 @@ FMiscLoop:
bne FMiscLoop ; do this until all slots are checked
ldy #$08 ; if no empty slots found, use last slot
UseMiscS:
sty JumpCoinMiscOffset ; store offset of misc object buffer here (residual)
rts
;-------------------------------------------------------------------------------------
@ -7432,7 +7393,6 @@ MiscLoop:
;--------------------------------
; $00 - used to set downward force
; $01 - used to set upward force (residual)
; $02 - used to set maximum speed
ProcJumpCoin:
@ -7462,8 +7422,6 @@ JCoinRun:
sta $00
lda #$06 ; set maximum vertical speed
sta $02
lsr ; divide by 2 and set
sta $01 ; as upward movement amount (apparently residual)
lda #$00 ; set A to impose gravity on jumping coin
jsr ImposeGravity ; do sub to move coin vertically and impose gravity on it
ldx ObjectOffset ; get original misc object offset
@ -7474,7 +7432,6 @@ JCoinRun:
RunJCSubs:
jsr RelativeMiscPosition ; get relative coordinates
jsr GetMiscOffscreenBits ; get offscreen information
jsr GetMiscBoundBox ; get bounding box coordinates (why?)
jsr JCoinGfxHandler ; draw the coin or floatey number
MiscLoopBack:
@ -7548,8 +7505,7 @@ SetupPowerUp:
sec
sbc #$08 ; subtract 8 pixels
sta Enemy_Y_Position+5 ; and use as vertical coordinate of power-up object
PwrUpJmp:
lda #$01 ; this is a residual jump point in enemy object jump table
lda #$01
sta Enemy_State+5 ; set power-up object's state
sta Enemy_Flag+5 ; set buffer flag
lda #$03
@ -7868,8 +7824,6 @@ SpawnBrickChunks:
clc ; add 8 pixels to vertical coordinate
adc #$08 ; and save as vertical coordinate for one of them
sta Block_Y_Position+2,x
lda #$fa
sta Block_Y_Speed,x ; set vertical speed...again??? (redundant)
rts
;-------------------------------------------------------------------------------------
@ -8100,10 +8054,6 @@ SetXMoveAmt:
MaxSpdBlockData:
.byte $06, $08
ResidualGravityCode:
ldy #$00 ; this part appears to be residual,
.byte $2c ; no code branches or jumps to it...
ImposeGravityBlock:
ldy #$01 ; set offset for maximum speed
lda #$50 ; set movement amount here
@ -8124,13 +8074,8 @@ MovePlatformDown:
MovePlatformUp:
lda #$01 ; save value to stack
pha
ldy Enemy_ID,x ; get enemy object identifier
inx ; increment offset for enemy object
lda #$05 ; load default value here
cpy #$29 ; residual comparison, object #29 never executes
bne SetDplSpd ; this code, thus unconditional branch here
lda #$09 ; residual code
SetDplSpd:
sta $00 ; save downward movement amount here
lda #$0a ; save upward movement amount here
sta $01
@ -8356,12 +8301,7 @@ CheckEndofBuffer:
beq CheckRightBounds ; if found, branch, otherwise
cpx #$05 ; check for end of buffer
bcc CheckRightBounds ; if not at end of buffer, branch
iny
lda (EnemyData),y ; check for specific value here
and #%00111111 ; not sure what this was intended for, exactly
cmp #$2e ; this part is quite possibly residual code
beq CheckRightBounds ; but it has the effect of keeping enemies out of
rts ; the sixth slot
rts
CheckRightBounds:
lda ScreenRight_X_Pos ; add 48 to pixel coordinate of right boundary
@ -8583,7 +8523,7 @@ InitEnemyRoutines:
.addr PlatLiftUp
.addr PlatLiftDown
.addr InitBowser
.addr PwrUpJmp ; possibly dummy value
.addr NoInitCode
.addr Setup_Vine
.addr NoInitCode ; for objects $30-$36
@ -10141,7 +10081,6 @@ NotDefB:
SwimCCXMoveData:
.byte $40, $80
.byte $04, $04 ; residual data, not used
MoveSwimmingCheepCheep:
lda Enemy_State,x ; check cheep-cheep's enemy object state
@ -10279,7 +10218,6 @@ SkpFSte:
SetupGFB:
sta $ef ; save high byte of spinning thing, modified or otherwise
jsr RelativeEnemyPosition ; get relative coordinates to screen
jsr GetFirebarPosition ; do a sub here (residual, too early to be used now)
ldy Enemy_SprDataOffset,x ; get OAM data offset
lda Enemy_Rel_YPos ; get relative vertical coordinate
sta Sprite_Y_Position,y ; store as Y in OAM data
@ -10494,9 +10432,6 @@ GetVAdder:
PRandomSubtracter:
.byte $f8, $a0, $70, $bd, $00
FlyCCBPriority:
.byte $20, $20, $20, $00, $00
MoveFlyingCheepCheep:
lda Enemy_State,x ; check cheep-cheep's enemy state
and #%00100000 ; for d5 set
@ -10535,9 +10470,7 @@ AddCCF:
lsr
tay
BPGet:
lda FlyCCBPriority,y ; load bg priority data and store (this is very likely
sta Enemy_SprAttrib,x ; broken or residual code, value is overwritten before
rts ; drawing it next frame), then leave
rts
;--------------------------------
; $00 - used to hold horizontal difference
@ -11002,20 +10935,14 @@ DrawFlameLoop:
ldy Enemy_SprDataOffset,x ; get OAM data offset
lda Enemy_OffscreenBits ; get enemy object offscreen bits
lsr ; move d0 to carry and result to stack
pha
bcc M3FOfs ; branch if carry not set
lda #$f8 ; otherwise move sprite offscreen, this part likely
sta Sprite_Y_Position+12,y ; residual since flame is only made of three sprites
M3FOfs:
pla ; get bits from stack
lsr ; move d1 to carry and move bits back to stack
pha
bcc M2FOfs ; branch if carry not set again
lda #$f8 ; otherwise move third sprite offscreen
sta Sprite_Y_Position+8,y
M2FOfs:
pla ; get bits from stack again
lsr ; move d2 to carry and move bits back to stack again
pla ; get bits from stack
lsr ; move d2 to carry and move bits back to stack
pha
bcc M1FOfs ; branch if carry not set yet again
lda #$f8 ; otherwise move second sprite offscreen
@ -11267,7 +11194,6 @@ FirebarSpin:
sta $07 ; save spinning speed here
lda FirebarSpinDirection,x ; check spinning direction
bne SpinCounterClockwise ; if moving counter-clockwise, branch to other part
ldy #$18 ; possibly residual ldy
lda FirebarSpinState_Low,x
clc ; add spinning speed to what would normally be
adc $07 ; the horizontal speed
@ -11277,7 +11203,6 @@ FirebarSpin:
rts
SpinCounterClockwise:
ldy #$08 ; possibly residual ldy
lda FirebarSpinState_Low,x
sec ; subtract spinning speed to what would normally be
sbc $07 ; the horizontal speed
@ -11604,11 +11529,9 @@ ExDPl:
rts ; leave
;--------------------------------
; $00 - residual value from sub
RightPlatform:
jsr MoveEnemyHorizontally ; move platform with current horizontal speed, if any
sta $00 ; store saved value here (residual code)
lda PlatformCollisionFlag,x ; check collision flag, if no collision between player
bmi ExRPl ; and platform, branch ahead, leave speed unaltered
lda #$10
@ -11938,9 +11861,6 @@ NoPUp:
;--------------------------------
ResidualXSpdData:
.byte $18, $e8
KickedShellXSpdData:
.byte $30, $d0
@ -13243,7 +13163,6 @@ ChkLandedEnemyState:
beq ProcEnemyDirection ; then branch elsewhere
cmp #$03 ; if already in state used by koopas and buzzy beetles
bcs ExSteChk ; or in higher numbered state, branch to leave
lda Enemy_State,x ; load enemy state again (why?)
cmp #$02 ; if not in $02 state (used by koopas and buzzy beetles)
bne ProcEnemyDirection ; then branch elsewhere
lda #$10 ; load default timer here
@ -13750,21 +13669,12 @@ BlockBufferChk_Enemy:
pla ; pull A from stack and jump elsewhere
jmp BBChk_E
ResidualMiscObjectCode:
txa
clc ; supposedly used once to set offset for
adc #$0d ; miscellaneous objects
tax
ldy #$1b ; supposedly used once to set offset for block buffer data
jmp ResJmpM ; probably used in early stages to do misc to bg collision detection
BlockBufferChk_FBall:
ldy #$1a ; set offset for block buffer adder data
txa
clc
adc #$07 ; add seven bytes to use
tax
ResJmpM:
lda #$00 ; set A to return vertical coordinate
BBChk_E:
jsr BlockBufferCollision ; do collision detection subroutine for sprite object
@ -13999,7 +13909,7 @@ NoHOffscr:
;-------------------------------------------------------------------------------------
; $00-$01 - used to hold tile numbers ($01 addressed in draw floatey number part)
; $02 - used to hold Y coordinate for floatey number
; $03 - residual byte used for flip (but value set here affects nothing)
; $03 - used for flip
; $04 - attribute byte for floatey number
; $05 - used as X coordinate for floatey number
@ -14028,7 +13938,7 @@ FlagpoleGfxHandler:
lda FlagpoleFNum_Y_Pos ; get vertical coordinate for floatey number
sta $02 ; store it here
lda #$01
sta $03 ; set value for flip which will not be used, and
sta $03 ; set value for flip, and
sta $04 ; attribute byte for floatey number
sta Sprite_Attributes,y ; set attribute bytes for all three sprites
sta Sprite_Attributes+4,y
@ -14612,7 +14522,6 @@ CheckToAnimateEnemy:
ldy #$00
cmp #$15 ; check for mushroom retainer/princess object
bne CheckForSecondFrame ; which uses different code here, branch if not found
iny ; residual instruction
lda WorldNumber ; are we on world 8?
cmp #World8
bcs CheckDefeatedState ; if so, leave the offset alone (use princess)
@ -16189,9 +16098,6 @@ PowerUpGrabFreqData:
.byte $28, $4a, $50, $4a, $64, $3c, $32, $3c, $32
.byte $2c, $24, $3a, $64, $3a, $34, $2c, $22, $2c
; residual frequency data
.byte $22, $1c, $14
PUp_VGrow_FreqData:
.byte $14, $04, $22, $24, $16, $04, $24, $26 ; used by both
.byte $18, $04, $26, $28, $1a, $04, $28, $2a
@ -16508,8 +16414,7 @@ HandleAreaMusicLoopB:
bne GMLoopB ; unconditional branch
FindAreaMusicHeader:
ldy #$08 ; load Y for offset of area music
sty MusicOffset_Square2 ; residual instruction here
ldy #$08 ; load Y for offset of area music
FindEventMusicHeader:
iny ; increment Y pointer based on previously loaded queue contents
@ -16875,9 +16780,6 @@ Star_CloudHdr:
EndOfLevelMusHdr:
.byte $20, <WinLevelMusData, >WinLevelMusData, $3c, $21
ResidualHeaderData:
.byte $20, $c4, $fc, $3f, $1d
UndergroundMusHdr:
.byte $18, <UndergroundMusData, >UndergroundMusData, $00, $00