Alternate VCS definitions
From KK's Wiki
File _defs.k65 provides alternate definitions of Atari 2600 registers.
While use of this file is not required (standard VCS register names are predefined), after initial learning it can speed up prototyping by using shorter and lowercase names for all registers which are shorter and easier to type.
This file also provides basic frame handling definitions and works well as quick reference to VCS register functions and bit patterns.
VCS register aliases
_defs.k65 provides following extra register alternative names.
TIA registers (Write) | |||
---|---|---|---|
Address | Standard name | Alternate name | Description |
00h | VSYNC | - | Vertical sync set-clear |
01h | VBLANK | - | Vertical blank set-clear |
02h | WSYNC | - | Wait for leading edge of horizontal blank <strobe> |
03h | RSYNC | - | Reset horizontal sync counter <strobe> |
04h | NUSIZ0 | ns0 | Number-size player-missile 0 |
05h | NUSIZ1 | ns1 | Number-size player-missile 1 |
06h | COLUP0 | cp0 | Color Luminosity Player 0, Missile 0 |
07h | COLUP1 | cp1 | Color Luminosity Player 1, Missile 1 |
08h | COLUPF | cpf | Color Luminosity Playfield, Ball |
09h | COLUBK | cbg | Color Luminosity Background |
0Ah | CTRLPF | ctpf | Control Playfield and Ball size |
0Bh | REFP0 | rep0 | Reflect player 0 |
0Ch | REFP1 | rep1 | Reflect player 1 |
0Dh | PF0 | pf0 | Playfield Register 0 (LSB first) (only upper 4bit used) |
0Eh | PF1 | pf1 | Playfield Register 1 (MSB first) (8bit) |
0Fh | PF2 | pf2 | Playfield Register 2 (LSB first) (8bit) |
10h | RESP0 | rp0 | Reset player 0 <strobe> |
11h | RESP1 | rp1 | Reset player 1 <strobe> |
12h | RESM0 | rm0 | Reset missile 0 <strobe> |
13h | RESM1 | rm1 | Reset missile 1 <strobe> |
14h | RESBL | rb | Reset ball <strobe> |
15h | AUDC0 | ac0 | Audio Noise/Division Control, Channel 0 |
16h | AUDC1 | ac1 | Audio Noise/Division Control, Channel 1 |
17h | AUDF0 | af0 | Audio Frequency Divider, Channel 0 |
18h | AUDF1 | af1 | Audio Frequency Divider, Channel 1 |
19h | AUDV0 | av0 | Audio Volume, Channel 0 |
1Ah | AUDV1 | av1 | Audio Volume, Channel 1 |
1Bh | GRP0 | gp0 | Graphics (enable) player 0 |
1Ch | GRP1 | gp1 | Graphics (enable) player 1 |
1Dh | ENAM0 | em0 | Graphics (enable) missile 0 |
1Eh | ENAM1 | em1 | Graphics (enable) missile 1 |
1Fh | ENABL | eb | Graphics (enable) ball |
20h | HMP0 | hp0 | Horizontal motion player 0 |
21h | HMP1 | hp1 | Horizontal motion player 1 |
22h | HMM0 | hm0 | Horizontal motion missile 0 |
23h | HMM1 | hm1 | Horizontal motion missile 1 |
24h | HMBL | hb | Horizontal motion ball |
25h | VDELP0 | vdp0 | Vertical delay player 0 (Delay GRP0 until writing to GRP1) |
26h | VDELP1 | vdp1 | Vertical delay player 1 (Delay GRP1 until writing to GRP0) |
27h | VDELBL | vdb | Vertical delay ball (Delay ENABL until writing to GRP1) |
28h | RESMP0 | rmp0 | Reset missile 0 to player 0 |
29h | RESMP1 | rmp1 | Reset missile 1 to player 1 |
2Ah | HMOVE | hmove | Apply horizontal motion <strobe> |
2Bh | HMCLR | hmclr | Clear horizontal motion registers <strobe> |
2Ch | CXCLR (W) | - | Clear all collision latches <strobe> |
TIA registers (Read) | |||
---|---|---|---|
Address | Standard name | Alternate name | Description |
30h | CXM0P (R) | - | Collision Latch M0-P1, M0-P0 (Bit 7,6) |
31h | CXM1P (R) | - | Collision Latch M1-P0, M1-P1 (Bit 7,6) |
32h | CXP0FB (R) | - | Collision Latch P0-PF, P0-BL (Bit 7,6) |
33h | CXP1FB (R) | - | Collision Latch P1-PF, P1-BL (Bit 7,6) |
34h | CXM0FB (R) | - | Collision Latch M0-PF, M0-BL (Bit 7,6) |
35h | CXM1FB (R) | - | Collision Latch M1-PF, M1-BL (Bit 7,6) |
36h | CXBLPF (R) | - | Collision Latch BL-PF (Bit 7) |
37h | CXPPMM (R) | - | Collision Latch P0-P1, M0-M1 (Bit 7,6) |
PIA registers | |||
---|---|---|---|
Address | Standard name | Alternate name | Description |
280h | SWCHA | swcha | PIA Port A; input or output (R/W) |
281h | SWACNT | - | PIA Port A DDR Data Direction Register (R/W) |
282h | SWCHB | swchb | PIA Port B, Console Switches (R/W) (normally Read Only) |
283h | SWBCNT | - | PIA Port B DDR Data Direction Register (R/W) |
284h | INTIM | - | PIA Current Timer Value (Read only) |
285h | INSTAT | - | PIA Timer Status (Read only) (Undocumented) |
294h | TIM1T | - | PIA Set Timer & Select 1 clock interval (838ns/interval) |
295h | TIM8T | - | PIA Set Timer & Select 8 clock interval (6.7us/interval) |
296h | TIM64T | - | PIA Set Timer & Select 64 clock interval (53.6us/interval) |
297h | T1024T | - | PIA Set Timer & Select 1024 clock interval (858.2us/interval) |
Special macros
_defs.k65 provides following extra inline macros.
Macro name | Description |
---|---|
init | Clears entire zero page (including TIA regs), sets stack to RAM top, disables interrupts and decimal mode |
timwait | Waits until PIA timer is zero (used in sync# macros) |
wsync | Waits for horizontal blanking (simply WSYNC=a) |
sync1 | Waits for timer and starts overscan (lower border) - you have approximately 45 scanlines (NTSC: 37) of overscan time after this. |
sync2 | Waits for timer and pulses VSYNC and starts overscan (upper border) - you have approximately 36 scanlines (NTSC: 30) of overscan time after this. |
sync3 | Waits for timer and visible screen portion - you have to generate approximately 228 scanlines (NTSC: 192) of visible picture now. |
File source code
var zeropage = 0; // Type NTSC PAL/SECAM // V-Sync 3 3 scanlines // V-Blank 37 45 scanlines (upper border) // Picture 192 228 scanlines // Overscan 30 36 scanlines (lower border) // Frame Rate 60 50 Hz // Frame Time 262 312 scanlines // --- scanline numbers --- // Type NTSC PAL/SECAM // V-Sync 3 3 // V-Blank 37 45 // Picture 192 228 // Overscan 30 36 inline init { i+ d- s=x=0xFF a=0 { zeropage,x=a x-- }!= } inline timwait { { a=INTIM }!= } inline wsync { WSYNC=a } // PAL: 0 45 275 312 // NTSC: 0 37 231 262 // PAL inline sync1 { timwait wsync VBLANK=a=2 TIM64T=a=40 } inline sync2 { timwait wsync VSYNC=a=2 wsync wsync a=0 wsync VSYNC=a TIM64T=a=54 } inline sync3 { timwait wsync VBLANK=a=0 T1024T=a=18 } // NTSC //inline sync1 { timwait wsync VBLANK=a=2 TIM64T=a=33 } //inline sync2 { timwait wsync VSYNC=a=2 wsync wsync a=0 wsync VSYNC=a TIM64T=a=44 } //inline sync3 { timwait wsync VBLANK=a=0 TIM64T=a=231 } var ns0=0x04,ns1; // 00xx 0xxx Number-Size player/missle 0/1 // ^^^ - Player-Missile number & Player size (See table below) // 000 0 One copy (X.........) // 001 1 Two copies - close (X.X.......) // 010 2 Two copies - medium (X...X.....) // 011 3 Three copies - close (X.X.X.....) // 100 4 Two copies - wide (X.......X.) // 101 5 Double sized player (XX........) // 110 6 Three copies - medium (X...X...X.) // 111 7 Quad sized player (XXXX......) // ^^ - Missile Size (0..3 = 1,2,4,8 pixels width) var cp0=0x06,cp1,cpf,cbg; // xxxx xxx- Color-Luminance Player 0/1, Playfield, Background var ctpf=0x0A; // --xx -xxx Control Playfield, Ball, Collisions // ^ - Playfield Reflection (0=Normal, 1=Mirror right half) // ^ - Playfield Color (0=Normal, 1=Score Mode, only if Bit2=0) // ^ - Playfield/Ball Priority (0=Normal, 1=Above Players/Missiles) // ^^ - Ball size (0..3 = 1,2,4,8 pixels width) var rep0=0x0B, rep1; // ---- x--- Reflection Player 0/1 var pf0=0x0D, pf1, pf2; // xxxx ---- Playfield Register Byte 0 // xxxx xxxx Playfield Register Byte 1 // xxxx xxxx Playfield Register Byte 2 var rp0=0x10,rp1,rm0,rm1,rb; // ---- ---- Reset Player 0/1, Missile 0/1, Ball var gp0=0x1B,gp1; // xxxx xxxx Graphics Register Player 0/1 var em0=0x1D,em1,eb; // ---- --x- Graphics Enable Missle 0/1, Ball var hp0=0x20,hp1,hm0,hm1,hb; // xxxx ---- Horizontal Motion Player 0/1, Missile 0/1, Ball var vdp0=0x25,vdp1,vdb; // ---- ---x Vertical Delay Player 0/1, Ball var rmp0=0x28,rmp1; // ---- --x- Reset Missle 0/1 to Player 0/1 var hmove=0x2A; // ---- ---- Apply Horizontal Motion var hmclr=0x2B; // ---- ---- Clear Horizontal Move Registers var gp0h=0x11B,gp1h; // xxxx xxxx Graphics Register Player 0/1 var rmp0h=0x128,rmp1h; // ---- --x- Reset Missle 0/1 to Player 0/1 var pf0h=0x10D, pf1h, pf2h; // xxxx ---- Playfield Register Byte 0 var cp0h=0x106,cp1h,cpfh,cbgh; // xxxx xxx- Color-Luminance Player 0/1, Playfield, Background var hp0h=0x120,hp1h,hm0h,hm1h,hbh; // xxxx ---- Horizontal Motion Player 0/1, Missile 0/1, Ball var ac0=0x15,ac1; // ---- xxxx Audio Control 0/1 var af0=0x17,af1; // ---x xxxx Audio Frequency 0/1 var av0=0x19,av1; // ---- xxxx Audio Volume 0/1 var inpt0=0x38; // x--- ---- read pot port var inpt1=0x39; // x--- ---- read pot port var inpt2=0x3A; // x--- ---- read pot port var inpt3=0x3B; // x--- ---- read pot port var inpt4=0x3C; // x--- ---- read input / P0 Fire (0 active) var inpt5=0x3D; // x--- ---- read input / P1 Fire (0 active) var swcha=0x280; // xxxx xxxx Port A // ^ - P1 Up (0 active) // ^ - P1 Down (0 active) // ^ - P1 Left (0 active) // ^ - P1 Right (0 active) // ^ - P0 Up (0 active) // ^ - P0 Down (0 active) // ^ - P0 Left (0 active) // ^ - P0 Right (0 active) var swchb=0x282; // xx-- x-xx Port B // ^ - Reset Button (0=Pressed) // ^ - Select Button (0=Pressed) // ^ - Color Switch (0=B/W, 1=Color) (Always 0 for SECAM) // ^ - P0 Difficulty Switch (0=Beginner (B), 1=Advanced (A)) // ^ - P1 Difficulty Switch (0=Beginner (B), 1=Advanced (A))