Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jaymcgavren/9a3986d30ce7aa8b0efdd5d37ad5eccd to your computer and use it in GitHub Desktop.

Select an option

Save jaymcgavren/9a3986d30ce7aa8b0efdd5d37ad5eccd to your computer and use it in GitHub Desktop.
❯ In smbdis.asm, what functions are stored in the fixed bank? What functions are instead stored in bank 0?
⏺ Let me explore the project structure to understand how the code is organized.
Searched for 4 patterns, read 3 files, listed 1 directory (ctrl+o to expand)
⏺ The map.txt file should have the exact addresses. Let me check it.
Searched for 6 patterns, read 2 files (ctrl+o to expand)
⏺ Now I have the full picture. Let me generate a detailed symbol map to see which functions land above or below the $C000 boundary.
⏺ Bash(ld65 -C ldconfig.txt smbdis.o -m fullmap.txt 2>&1 | head -5; head -100 fullmap.txt)
⎿  Modules list:
-------------
smbdis.o:
… +24 lines (ctrl+o to expand)
⏺ Bash(ca65 smbdis.asm -l smbdis.lst 2>&1 | head -5; wc -l smbdis.lst)
⎿  17823 smbdis.lst
Searching for 6 patterns, reading 1 file… (ctrl+o to expand)
Searched for 6 patterns, read 1 file (ctrl+o to expand)
⏺ Bash(# Extract all lines with a label (colon), parse the address and label name
# Fixed bank is $C000-$FFFF = 00C000-00FFFF in listing…)
⎿  008000 Start:
00800A
00800F
… +32 lines (ctrl+o to expand)
⏺ Bash(# Get all labels with their hex addresses, then split at C000
grep "^00[89ABCDEFabcdef]" /Users/jay/work/SMBASM/smbdis.lst | grep "[A-Z][a-zA-Z0-9_]*:" | \…)
⎿  1993 /tmp/smb_labels.txt
--- Last few bank 0 labels (just before C000) ---
00BF6D ContVMove:
… +50 lines (ctrl+o to expand)
Searched for 7 patterns (ctrl+o to expand)
⏺ Here's a breakdown of what lives in each bank, based on the assembler listing and linker config:
---
Bank 0 ($8000–$BFFF) — switchable, default at power-up
Boot / NMI:
Start, VBlank1/2, WBootCheck, ColdBoot, NonMaskableInterrupt, ScreenOff, InitBuffer
Frame management:
DecTimers, SpriteShuffler, OperModeExecutionTree, PauseRoutine
Title / menu / demo:
TitleScreenMode, GameMenuRoutine, StartGame, DemoEngine, DrawMushroomIcon, ChkWorldSel
Victory / end-of-game:
VictoryMode, AutoPlayer, PrintVictoryMessages, PlayerEndWorld
HUD / status display:
FloateyNumbersRoutine, WriteTopStatusLine, WriteBottomStatusLine, DisplayTimeUp, DisplayIntermediate, WriteGameText, PutLives,
PrintWarpZoneNumbers
Screen / palette setup:
ScreenRoutines, InitScreen, SetupIntermediate, GetAreaPalette, ColorRotation, RenderAreaGraphics, RenderAttributeTables,
DrawTitleScreen
Area parser:
AreaParserTaskControl
Block / metatile graphics:
BlockGfxData, MetatileGraphics_Low/High, Palette0–3_MTiles, RemoveCoin_Axe, WriteBlockMetatile, DestroyBlockMetatile,
ReplaceBlockMetatile, WriteBlankMT
Block object logic:
BlockObjectsCore, BouncingBlockHandler, BumpBlock, BrickShatter, SpawnBrickChunks, BlockObjMT_Updater, MushFlowerBlock, StarBlock,
VineBlock, ExtraLifeMushBlock
Shared movement / gravity:
MoveObjectHorizontally, MovePlayerHorizontally, MoveEnemyHorizontally, MovePlayerVertically, MoveD_EnemyVertically, MoveRedPTroopa,
MovePlatformDown/Up, ImposeGravity, AlterYP
---
Fixed Bank ($C000–$FFFF) — always mapped
Enemy/loop core:
EnemiesAndLoopsCore, ProcLoopCommand, FindLoop, LoopCmdWorldNumber/PageNumber/YPosition, ExecGameLoopback
Enemy data parsing:
ProcessEnemyData, CheckEndofBuffer, CheckRightBounds, PositionEnemyObj, CheckForEnemyGroup, BuzzyBeetleMutate, InitEnemyObject,
CheckFrenzyBuffer
Enemy init (one per type):
InitGoomba, InitPodoboo, InitRedKoopa, InitHammerBro, InitBloober, InitRedPTroopa, InitBulletBill, InitCheepCheep, InitLakitu,
InitLongFirebar, InitShortFirebar, InitFlyingCheepCheep, InitBowser, InitBowserFlame, InitFireworks, InitPiranhaPlant,
InitEnemyFrenzy, InitJumpGPTroopa, InitBalPlatform, InitDropPlatform, InitHoriPlatform, InitVertPlatform
Enemy run / AI:
RunEnemyObjectsCore, RunNormalEnemies, RunBowserFlame, RunFirebarObj, RunSmallPlatform, RunLargePlatform, MoveNormalEnemy,
MoveDefeatedEnemy, MoveJumpingEnemy, MovePodoboo, ProcHammerBro, HammerBroJumpCode, LakituAndSpinyHandler, CreateSpiny,
DoBulletBills, MovePiranhaPlant, FirebarSpin, BalancePlatform, DrawEraseRope, RunBowser, BowserControl, MoveD_Bowser
Enemy collision / physics:
ChkToStunEnemies, LandEnemyProperly, ProcEnemyDirection, DoEnemySideCheck, EnemyJump, EnemyLanding, PlayerEnemyDiff,
HammerBroBGColl, KillEnemyAboveBlock, FireballBGCollision, InitFireballExplode
Bounding box / collision detection:
BoundingBoxCore, PlayerCollisionCore, SprObjectCollisionCore, BlockBufferChk_Enemy, BlockBufferChk_FBall, GetEnemyBoundBox,
GetFireballBoundBox, LargePlatformBoundBox
Enemy / misc drawing:
DrawEnemyObjRow, DrawBrickChunks, DrawFireball, DrawFirebar, DrawExplosion_Fireball/Fireworks, DrawSmallPlatform, DrawBubble,
BowserGfxHandler, RunStarFlagObj, DrawStarFlag
Player graphics:
PlayerGraphicsTable, PlayerGfxHandler, FindPlayerAction, PlayerGfxProcessing, RenderPlayerSub, DrawPlayerLoop, ProcessPlayerAction
Music engine + all music data:
HandleSquare1/2Music, HandleTriangleMusic, HandleNoiseMusic, LoadEnvelopeData, FindAreaMusicHeader, all *MusData and *Hdr tables,
FreqRegLookupTbl, MusicLengthLookupTbl
Bank-switching helpers (must live in fixed bank):
ReadAreaData ($FFD5) and BankSwitch ($FFF5) — these survive the bank switch precisely because they're in the fixed bank.
---
The pattern: Bank 0 holds boot, init, UI, metatile graphics, and shared movement code. The fixed bank holds everything needed during
active gameplay: all enemy logic, collision detection, player rendering, the full music engine, and the bank-switching helpers
themselves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment