; Joypad Test Cartridge (U) application-specific RAM aliases - Pass 1 ; Generated from every direct zero-page operand in reachable code: ; ref counts are reads/writes, `where` lists the referencing addresses. ; ZpXX names indicate storage with a role not yet unique enough for a behavioral name; ; Pass 2 replaces them with names derived from observed usage. Zp00 = $00 ; 22 refs; reads=13 writes=9; used at $C013, C05D, C252, CB16, +18 more Zp01 = $01 ; 9 refs; reads=4 writes=5; used at $CD95, CD97, CDA8, CDB8, +5 more Zp02 = $02 ; 7 refs; reads=4 writes=3; used at $CDF2, CE10, CE1F, CE9A, +3 more Zp03 = $03 ; 4 refs; reads=2 writes=2; used at $CE98, CEB2, CEE5, CEE7 Zp04 = $04 ; 2 refs; reads=1 writes=1; used at $CEA5, CEC2 Zp05 = $05 ; 7 refs; reads=4 writes=3; used at $CDCC, CDD5, CDDA, CDE1, +2 more Zp06 = $06 ; 5 refs; reads=2 writes=3; used at $CDD1, CDE8, CEC4, CED2 Zp40 = $40 ; 57 refs; reads=32 writes=25; used at $C0E7, C0E9, C0EB, C0EF, +30 more Zp41 = $41 ; 3 refs; reads=3 writes=0; used at $C1BB, C304, CBB7 Zp42 = $42 ; 2 refs; reads=0 writes=2; used at $CCCE, CCDC Zp43 = $43 ; 2 refs; reads=2 writes=0; used at $C1BF, C308 Zp44 = $44 ; 3 refs; reads=3 writes=0; used at $C1C3, C30C, CCCC Zp45 = $45 ; 2 refs; reads=1 writes=1; used at $CC75 Zp46 = $46 ; 1 refs; reads=1 writes=0; used at $CCDA Zp47 = $47 ; 2 refs; reads=1 writes=1; used at $CC72 Zp49 = $49 ; 3 refs; reads=2 writes=1; used at $CC88, CC94 Zp4A = $4A ; 1 refs; reads=1 writes=0; used at $CCA0 Zp4B = $4B ; 3 refs; reads=2 writes=1; used at $CC85, CCAC Zp4C = $4C ; 1 refs; reads=1 writes=0; used at $CCB8 Zp4D = $4D ; 10 refs; reads=5 writes=5; used at $CC92, CC9C, CC9E, CCA8, +6 more Zp4E = $4E ; 40 refs; reads=19 writes=21; used at $C212, C2BC, C331, C3A3, +27 more Zp4F = $4F ; 4 refs; reads=2 writes=2; used at $C2BE, C335, CB74, CBD9 Zp51 = $51 ; 3 refs; reads=1 writes=2; used at $C2C0, C339, CB76 Zp52 = $52 ; 3 refs; reads=1 writes=2; used at $C2C2, C33D, CB78 Zp53 = $53 ; 13 refs; reads=6 writes=7; used at $C0DB, C0FD, C107, C2C6, +6 more Zp54 = $54 ; 13 refs; reads=6 writes=7; used at $C0DD, C0F9, C101, C2C4, +6 more Zp55 = $55 ; 8 refs; reads=6 writes=2; used at $C0D7, C113, C119, C11F, +4 more Zp56 = $56 ; 21 refs; reads=12 writes=9; used at $C2CC, C371, C37D, C60A, +15 more Zp57 = $57 ; 16 refs; reads=10 writes=6; used at $C2D2, C763, C769, C76E, +12 more Zp59 = $59 ; 14 refs; reads=10 writes=4; used at $C8BD, C8C3, C8C8, C8CF, +10 more Zp5A = $5A ; 14 refs; reads=10 writes=4; used at $CA16, CA1C, CA21, CA28, +10 more Zp5B = $5B ; 21 refs; reads=12 writes=9; used at $C2CA, C3B6, C3C4, C597, +15 more Zp5C = $5C ; 16 refs; reads=10 writes=6; used at $C2D0, C6F0, C6F6, C6FB, +12 more Zp5E = $5E ; 14 refs; reads=10 writes=4; used at $C84A, C850, C855, C85C, +10 more Zp5F = $5F ; 14 refs; reads=10 writes=4; used at $C9A3, C9A9, C9AE, C9B5, +10 more Zp60 = $60 ; 21 refs; reads=12 writes=9; used at $C2C8, C429, C439, C524, +15 more Zp61 = $61 ; 16 refs; reads=10 writes=6; used at $C2CE, C67D, C683, C688, +12 more Zp63 = $63 ; 14 refs; reads=10 writes=4; used at $C7D7, C7DD, C7E2, C7E9, +10 more Zp64 = $64 ; 14 refs; reads=10 writes=4; used at $C930, C936, C93B, C942, +10 more Zp65 = $65 ; 40 refs; reads=18 writes=22; used at $C2D4, C36D, C379, C380, +18 more Zp66 = $66 ; 3 refs; reads=0 writes=3; used at $C2D6, CAAA, CB8C Zp68 = $68 ; 3 refs; reads=0 writes=3; used at $C2D8, CAAC, CB8E Zp69 = $69 ; 3 refs; reads=0 writes=3; used at $C2DA, CAAE, CB90 Zp6A = $6A ; 9 refs; reads=4 writes=5; used at $C2B8, C2EA, C2EE, CA8C, +3 more ZpC1 = $C1 ; 2 refs; reads=1 writes=1; used at $C2A3 ZpCF = $CF ; 6 refs; reads=3 writes=3; used at $C095, C287, CB4B ZpD0 = $D0 ; 2 refs; reads=1 writes=1; used at $CB53 ZpD1 = $D1 ; 1 refs; reads=1 writes=0; used at $C28F ZpE0 = $E0 ; 3 refs; reads=1 writes=2; used at $CCEF, CCF2, CD0F ZpEC = $EC ; 2 refs; reads=1 writes=1; used at $C04D, CE44 ZpED = $ED ; 2 refs; reads=1 writes=1; used at $C04B, CE3F ZpEE = $EE ; 7 refs; reads=2 writes=5; used at $C03D, C084, C279, CB3D, +3 more ZpEF = $EF ; 15 refs; reads=6 writes=9; used at $C036, C07D, C272, CB36, +11 more ; --------------------------------------------------------------------------- ; Pass 2 semantic aliases ; ; Aliases sit beside the generated ZpXX names rather than replacing them, since ; several addresses are reused for more than one role. Each name below is ; justified by the referencing routines named in its comment. ; --------------------------------------------------------------------------- ; VRAM writer state. $00/$01 form the indirect pointer used by ; `lda (Zp00),y` in WriteVramStreamByte, VramPtrTableRead and DispatchVramOp. VramPtrLo = $00 VramPtrHi = $01 VramOpLength = $02 ; byte count for the current VRAM op VramOpResult = $03 ; DispatchVramOp / StoreVramOpResult VramOpTemp = $04 RetAddrTempLo = $05 ; RetAddrUpdate pulls the caller's PC off the stack RetAddrTempHi = $06 ; Player 1 controller bits. Read by ReadControllerBitsLoop as ; `lda $4016,x / lsr a / rol Zp40,x` for x = 0..7, so $40 holds all eight ; buttons and is subsequently rotated one bit at a time by ; PollControllerShiftRegister and DispatchButtonBits. P1Buttons = $40 ; bit0 A, 1 B, 2 Select, 3 Start, 4 Up, 5 Down, 6 Left, 7 Right P1ButtonA = $40 ; aliases for the individual bit tests P1ButtonB = $41 P1ButtonSelect = $42 P1ButtonStart = $43 P1ButtonUp = $44 P1ButtonDown = $45 P1ButtonLeft = $46 P1ButtonRight = $47 ; Previous-direction latch written by LatchPreviousStickState (`sta Zp42,x`), ; read by CheckStickUp/Down/Left/Right against $10/$20/$C0 thresholds. PrevStickState = $42 StickDiagonalState = $46 ; Second and third shift registers from the alternate read paths ; (`rol Zp47,x` at ReadControllerBitsAltLoop, `rol Zp4B,x` at ; ReadControllerBitsAlt2Loop). P1ButtonsAlt = $47 P2Buttons = $4B ButtonShiftAlt = $65 ; second shift register in DispatchButtonBits ; Direction accumulators compared in CheckStickUp..Right StickAccumUp = $4A StickAccumDown = $4B StickAccumLeft = $4C StickAccumRight = $4D ; 16-bit frame counter: IncrementFrameCounter does ; `inc Zp54 / bne / inc Zp53`, so $53 is the high byte and $54 the low byte. FrameCounterHi = $53 ; incremented on carry out of the low byte FrameCounterLo = $54 ; incremented every frame ; Holds one of $70 / $88 / $A0. DispatchOnMarkerValue compares it against $70 ; and $88 to choose a test mode; ApplyMarkerValueEnableAudio stores it to ; $0200 and to the shadow at $EE. NOTE: an earlier Pass 2 draft called this a ; "P1 Down timer", which the instructions do not support. MarkerValue = $55 ; Per-button-state marker variables. Each drives one group of ; MarkerUpdateN routines, which OR $F0 or $D0 into the variable and write the ; result to an OAM Y-coordinate slot. Which player and button each belongs to ; is NOT yet established, so they are named by position, not by button. MarkerVar01 = $60 ; MarkerUpdate1 MarkerVar02 = $5B ; MarkerUpdate2 MarkerVar03 = $56 ; MarkerUpdate3 MarkerVar04 = $61 ; MarkerUpdate4 MarkerVar05 = $5C ; MarkerUpdate5 MarkerVar06 = $57 ; MarkerUpdate6 MarkerVar07 = $63 ; MarkerUpdate7 MarkerVar08 = $5E ; MarkerUpdate8 MarkerVar09 = $59 ; MarkerUpdate9 MarkerVar10 = $64 ; MarkerUpdate10 MarkerVar11 = $5F ; MarkerUpdate11 MarkerVar12 = $5A ; MarkerUpdate12 ButtonHoldCounter = $6A ; PollControllerCountFrames: inc / cmp #$0F VramBurstIndex = $0302 ; SetBurstWriteIndex stores #$22 here ; PPU register shadows. $EF is read by WaitForVblank and masked with #$7F ; before reaching $2000; $EE is masked with #$E7 by PpuMaskSetup. PpuScrollXInit = $ED ; latched to $2005 by PpuScrollLatch PpuMaskShadow = $EE ; PPUMASK shadow PpuCtrlShadow = $EF ; PPUCTRL shadow ; Set at $E0 and polled by `bit ZpE0 / bmi` in WaitForNmiComplete; NMI clears it. NmiInProgressFlag = $E0