; ============================================================================= ; Volleyball (U) - application-specific RAM aliases (Pass 3) ; ============================================================================= ; ; Every name below is taken from observed ROM behaviour: the game state ; machine, the VRAM update-script interpreter, the controller reader, the ; drawing engine and the sound engine are all visible in the code, and each ; name is anchored to one of them. ; ; A number of zero-page slots keep their neutral `ZpXX` name. Those are the ; ones where two unrelated subsystems share the byte, or where the role ; changes with the active game state; the reason is recorded next to each of ; them, as the promotion rules require. ; ; ----------------------------------------------------------------------------- ; ---- the game state machine ------------------------------------------------ GameState = $2B ; 11 game states; indexes GameStateDispatchTable GameSubState = $2C ; sub-state; the handler receives it in X FrameCounter = $2D ; incremented once per NMI StateTimerLo = $02 ; 16-bit delay timer, low byte StateTimerHi = $03 ; 16-bit delay timer, high byte StateTablePtrLo = $25 ; pointer into GameStateDispatchTable, low StateTablePtrHi = $26 ; pointer into GameStateDispatchTable, high StateTableIndexLo = $28 ; GameState * 2, low StateTableIndexHi = $29 ; GameState * 2, high ; ---- the indirect jump used by the state dispatcher ------------------------ JumpTargetLo = $04 ; low byte of the `JMP ($0004)` target JumpTargetHi = $05 ; high byte of the `JMP ($0004)` target ; ---- the VRAM update-script interpreter ----------------------------------- VramUpdatePending = $40 ; set while a script still has bytes to write VramScriptPtrLo = $41 ; script pointer, low VramScriptPtrHi = $42 ; script pointer, high VramScriptByteCount = $43 ; bytes left in the current run OamDirty = $44 ; the OAM shadow at $03FF needs uploading ; ---- PPU state ------------------------------------------------------------- ScrollX = $06 ; written to PPUSCROLL ScrollXNametable = $07 ; nametable bit for the X scroll ScrollY = $08 ; written to PPUSCROLL ScrollYNametable = $09 ; nametable bit for the Y scroll PpuCtrlShadow = $19 ; shadow of PPUCTRL PpuMaskShadow = $1A ; shadow of PPUMASK AttributeScriptLength = $14 ; bytes queued in the $0180 attribute script PpuAddrLo = $7C ; high byte of a PPU address built at runtime PpuAddrHi = $7D ; low byte of a PPU address built at runtime ; ---- the per-frame command stream ----------------------------------------- CmdStreamPtrLo = $0E ; pointer into the $05C0 command block CmdStreamPtrHi = $0F ; pointer into the $05C0 command block CmdStreamOpcode = $0D ; the command byte just fetched CmdStreamValue = $0C ; first argument of the current command CmdStreamValue2 = $10 ; second argument of the current command CmdStreamValue3 = $11 ; third argument of the current command ; ---- the controllers ------------------------------------------------------- ButtonsPlayer1 = $1B ; current button byte, player 1 ButtonsPlayer1Prev = $1C ; previous button byte, player 1 ButtonsPlayer1Pressed = $1D ; buttons newly pressed, player 1 ButtonsPlayer2Pressed = $1E ; buttons newly pressed, player 2 ControllerShiftReg = $1F ; the shift register the bits are read from ButtonsPlayer2 = $20 ; current button byte, player 2 PlayerLeftIndex = $73 ; which controller drives the left team PlayerRightIndex = $74 ; which controller drives the right team PlayerLeftInput = $75 ; live input of the left team PlayerRightInput = $76 ; live input of the right team PlayerLeftPressed = $77 ; newly pressed buttons, left team PlayerRightPressed = $78 ; newly pressed buttons, right team ; ---- scores, teams and nations -------------------------------------------- ScoreTeam1 = $79 ; left team's score ScoreTeam2 = $7A ; right team's score TeamId = $70 ; which nation each side plays TeamColorA = $58 ; palette entry for the left team TeamColorB = $59 ; palette entry for the right team TeamNumber = $66 ; the team whose players are being moved TeamFlags = $67 ; per-team animation flags PlayerCount = $2E ; how many players take part TeamScore1Lo = $54 ; left team's 16-bit score, low TeamScore1Hi = $55 ; left team's 16-bit score, high ; ---- the drawing engine ---------------------------------------------------- TileListPtrLo = $4A ; pointer into the tilemap byte lists, low TileListPtrHi = $4B ; pointer into the tilemap byte lists, high TileIndex = $4C ; the tile currently being written TileAttribute = $4D ; the attribute currently being written TableIndex = $4E ; index into an 8-byte-per-entry table DrawPointerLo = $48 ; the write cursor in the nametable, low DrawPointerHi = $49 ; the write cursor in the nametable, high ScrollTargetX = $4F ; the scroll position the court is drawn at CrowdOffsetA = $85 ; base X of the spectators CrowdOffsetB = $87 ; selects the left or the right stand CrowdFlagsA = $50 ; per-stand spectator animation flags CrowdFlagsB = $51 ; per-stand spectator animation flags NumberTileColumn = $15 ; tile column of the number being drawn NumberTileRow = $18 ; tile row of the number being drawn ; ---- sprite slots ---------------------------------------------------------- PlayerSlotIndex = $8B ; the player slot being updated PlayerSlotIndex2 = $8C ; the player slot being updated, other side ; ---- flags ----------------------------------------------------------------- PointFlag = $6F ; set while a point is being scored BallFlags = $6E ; ball direction and spin flags ServeFlag = $72 ; a serve is pending IndicatorEnable = $7B ; the indicator board is being updated IndicatorIndex = $64 ; which indicator cell is being drawn IndicatorValue = $68 ; the value shown in the indicator ServeReady = $7E ; the server may play the ball DemoModeFlag = $81 ; the attract demo is running DemoCounterA = $82 ; demo countdown, high DemoCounterB = $83 ; demo countdown, low NumberParity = $84 ; which of the two number slots is live TitleFlag = $8D ; the title screen is on BallInPlayFlag = $8E ; the ball is live GameInitializedFlag = $DE ; set to $55 once the RAM has been cleared NmiInProgress = $DF ; the NMI handler sets it while it works ; ---- the sound engine ------------------------------------------------------ SfxCommand = $EF ; bit mask of the sound effects to play SoundPlayingFlags = $E0 ; which channels are currently sounding SoundEffectTimer1 = $E1 ; countdown for the first effect SoundEffectTimer2 = $E2 ; countdown for the second effect CrowdNoiseStep = $E3 ; which step of the crowd noise pattern SoundSequenceFlags = $E4 ; the state of the music byte-code player SoundNoteIndex = $E5 ; the note currently played SoundNoteIndex2 = $E6 ; the note currently played, second voice MusicCommand = $EB ; the music sequence to play CrowdSoundCommand = $EC ; the crowd sound to play ApplauseCommand = $ED ; the applause effect to play MusicPlayingFlag = $EE ; the music player is busy ; ---- zero-page bytes whose role is not unique ---------------------------- ; ; $00 is the general scratch byte: BuildPlayerSpriteEntries uses it as the ; sprite-slot counter and ClearGameRam uses it as the low byte of the RAM ; clear pointer. Both uses are proven but they are unrelated, so the slot ; keeps a neutral name. ; $01 is the high byte of that same RAM-clear pointer. ; $16/$17 are the low/high bytes of a 16-bit pointer into the per-team ; data; LoadTeamSpriteOffsets and ReadTeamSpriteData fill them in. ; $3F is never referenced by a direct zero-page operand. ; $45/$46 carry the number and the sub-phase that the ball and the score code ; work on; the meaning changes with the active game state. ; $50/$51 hold per-stand spectator flags in the crowd code and a plain ; clear-to-zero value in the state handlers. ; $53 is a short delay counter. ; $56/$57 select which of the duplicated per-player routines runs. ; $5C/$5D index the per-nation tables; $5E/$5F hold the matching state bytes. ; $60/$61 and $62/$63 are 16-bit scratch values used by the drawing code. ; $65, $69-$6D and $71 are single-use scratch bytes. ; $77/$78 are the newly-pressed button bytes of the two teams. ; $7F/$80, $86 and $88-$93 are single-use scratch bytes. ; $E7-$EA are scratch bytes inside the sound engine. ; OamBufferSelect = $2F ; which OAM buffer ($0200 or $0300) is shown Zp00 = $00 ; sprite-slot counter / RAM-clear pointer low Zp01 = $01 ; RAM-clear pointer high TeamSpritePtrLo = $16 ; pointer into the per-team data, low TeamSpritePtrHi = $17 ; pointer into the per-team data, high Zp3E = $3E ; sound effect index (reused by the ball code) Zp3F = $3F ; never referenced directly NumberToDisplay = $45 ; the two-digit number to draw on the court SpriteOffsetIndex = $46 ; index into the table of team sprite offsets PlayerSpriteId = $56 ; selects one of the duplicated player routines PlayerSpriteIdB = $57 ; selects one of the duplicated player routines NationSlotA = $5C ; index into the per-nation tables NationSlotB = $5D ; index into the per-nation tables NationStateA = $5E ; state byte matching NationSlotA NationStateB = $5F ; state byte matching NationSlotB Zp60 = $60 ; 16-bit scratch in the drawing code Zp61 = $61 ; 16-bit scratch in the drawing code Zp62 = $62 ; 16-bit scratch in the drawing code Zp63 = $63 ; 16-bit scratch in the drawing code Zp65 = $65 ; single-use scratch byte Zp69 = $69 ; single-use scratch byte Zp6A = $6A ; single-use scratch byte Zp6B = $6B ; single-use scratch byte Zp6C = $6C ; single-use scratch byte Zp6D = $6D ; single-use scratch byte Zp71 = $71 ; single-use scratch byte Zp7F = $7F ; single-use scratch byte Zp80 = $80 ; single-use scratch byte Zp86 = $86 ; single-use scratch byte Zp88 = $88 ; single-use scratch byte Zp89 = $89 ; single-use scratch byte Zp8A = $8A ; single-use scratch byte Zp90 = $90 ; single-use scratch byte Zp91 = $91 ; single-use scratch byte Zp92 = $92 ; single-use scratch byte Zp93 = $93 ; single-use scratch byte ZpE7 = $E7 ; scratch byte in the sound engine ZpE8 = $E8 ; scratch byte in the sound engine ZpE9 = $E9 ; scratch byte in the sound engine ZpEA = $EA ; scratch byte in the sound engine ColorIndex = $47 ; the palette entry the players are drawn with Zp53 = $53 ; short delay counter ; ---- the ball and the match structures at $0500 -------------------------- BallX = $0500 ; the ball's position on the court BallY = $0501 ; the ball's position on the court BallFrameCounter = $0502 ; how long the ball has been in flight BallVelocityX = $0503 ; the ball's horizontal step BallVelocityY = $0504 ; the ball's vertical step BallSpeed = $0505 ; the ball's speed BallCountdown = $0506 ; the ball's animation countdown BallPreviousY = $0507 ; the ball's position on the previous frame BallPreviousX = $0508 ; the ball's position on the previous frame BallFractionX = $0509 ; the ball's sub-pixel horizontal position BallFractionY = $050A ; the ball's sub-pixel vertical position BallTargetX = $050B ; where the ball is heading BallTargetY = $050C ; where the ball is heading BallPositionX = $050F ; the ball's 16-bit horizontal position BallPositionY = $0510 ; the ball's 16-bit vertical position BallTargetPositionX = $0511 ; the ball's 16-bit target BallTargetPositionY = $0512 ; the ball's 16-bit target ScoreRecord = $0513 ; array of six eight-byte score records CameraTargetX = $053F ; where the court is scrolled to CameraTargetY = $0540 ; where the court is scrolled to IndicatorStep = $0587 ; which step of the indicator board is live CrowdAnimationCounter = $0588 ; counts the crowd animation steps