1 ; 7800.h
2 ; Version 1.0, 2019/12/13
3 
4 ; This file defines hardware registers and memory mapping for the
5 ; Atari 7800. It is distributed as a companion machine-specific support package
6 ; for the DASM compiler. Updates to this file, DASM, and associated tools are
7 ; available at https://github.com/dasm-assembler/dasm
8 
9 
10 ; ******************** 7800 Hardware Adresses ***************************
11 ;
12 ;       MEMORY MAP USAGE OF THE 7800
13 ;
14 ;	  00 -   1F	TIA REGISTERS
15 ;	  20 -   3F	MARIA REGISTERS
16 ;	  40 -   FF	RAM block 0 (zero page)
17 ;	 100 -  11F	TIA   (mirror of 0000-001f)
18 ;	 120 -  13F	MARIA (mirror of 0020-003f)
19 ;	 140 -  1FF	RAM block 1 (stack)
20 ;	 200 -  21F	TIA   (mirror of 0000-001f)
21 ;	 220 -  23F	MARIA (mirror of 0020-003f)
22 ;	 240 -  27F	???
23 ;	 280 -  2FF	RIOT I/O ports and timers
24 ;	 300 -  31F	TIA   (mirror of 0000-001f)
25 ;	 320 -  33F	MARIA (mirror of 0020-003f)
26 ;	 340 -  3FF	???
27 ;	 400 -  47F	unused address space
28 ;	 480 -  4FF	RIOT RAM
29 ;	 500 -  57F	unused address space
30 ;	 580 -  5FF	RIOT RAM (mirror of 0480-04ff)
31 ;	 600 - 17FF	unused address space
32 ;	1800 - 203F	RAM
33 ;	2040 - 20FF	RAM block 0 (mirror of 0000-001f)
34 ;	2100 - 213F	RAM
35 ;	2140 - 21FF	RAM block 1 (mirror of 0140-01ff)
36 ;	2200 - 27FF	RAM
37 ;	2800 - 2FFF	mirror of 1800-27ff
38 ;	3000 - 3FFF	unused address space
39 ;	4000 - FF7F	potential cartridge address space
40 ;	FF80 - FFF9	RESERVED FOR ENCRYPTION
41 ;	FFFA - FFFF 	6502 VECTORS
42 
43 
44 ;****** 00-1F ********* TIA REGISTERS ******************
45 
46 INPTCTRL = $01     ;Input control. In same address space as TIA. write-only
47 VBLANK   = $01     ;VBLANK. D7=1:dump paddle caps to ground.     write-only
48 INPT0    = $08     ;Paddle Control Input 0                       read-only
49 INPT1    = $09     ;Paddle Control Input 1                       read-only
50 INPT2    = $0A     ;Paddle Control Input 2                       read-only
51 INPT3    = $0B     ;Paddle Control Input 3                       read-only
52 
53 ; ** some common alternate names for INPT0/1/2/3
54 INPT4B   = $08     ;Joystick 0 Fire 1                            read-only
55 INPT4A   = $09     ;Joystick 0 Fire 1                            read-only
56 INPT5B   = $0A     ;Joystick 1 Fire 0                            read-only
57 INPT5A   = $0B     ;Joystick 1 Fire 1                            read-only
58 INPT4R   = $08     ;Joystick 0 Fire 1                            read-only
59 INPT4L   = $09     ;Joystick 0 Fire 1                            read-only
60 INPT5R   = $0A     ;Joystick 1 Fire 0                            read-only
61 INPT5L   = $0B     ;Joystick 1 Fire 1                            read-only
62 
63 INPT4    = $0C     ;Player 0 Fire Button Input                   read-only
64 INPT5    = $0D     ;Player 1 Fire Button Input                   read-only
65 
66 AUDC0    = $15     ;Audio Control Channel   0                    write-only
67 AUDC1    = $16     ;Audio Control Channel   1                    write-only
68 AUDF0    = $17     ;Audio Frequency Channel 0                    write-only
69 AUDF1    = $18     ;Audio Frequency Channel 1                    write-only
70 AUDV0    = $19     ;Audio Volume Channel    0                    write-only
71 AUDV1    = $1A     ;Audio Volume Channel    1                    write-only
72 
73 ;****** 20-3F ********* MARIA REGISTERS ***************
74 
75 BACKGRND = $20     ;Background Color                             write-only
76 P0C1     = $21     ;Palette 0 - Color 1                          write-only
77 P0C2     = $22     ;Palette 0 - Color 2                          write-only
78 P0C3     = $23     ;Palette 0 - Color 3                          write-only
79 WSYNC    = $24     ;Wait For Sync                                write-only
80 P1C1     = $25     ;Palette 1 - Color 1                          write-only
81 P1C2     = $26     ;Palette 1 - Color 2                          write-only
82 P1C3     = $27     ;Palette 1 - Color 3                          write-only
83 MSTAT    = $28     ;Maria Status                                 read-only
84 P2C1     = $29     ;Palette 2 - Color 1                          write-only
85 P2C2     = $2A     ;Palette 2 - Color 2                          write-only
86 P2C3     = $2B     ;Palette 2 - Color 3                          write-only
87 DPPH     = $2C     ;Display List List Pointer High               write-only
88 P3C1     = $2D     ;Palette 3 - Color 1                          write-only
89 P3C2     = $2E     ;Palette 3 - Color 2                          write-only
90 P3C3     = $2F     ;Palette 3 - Color 3                          write-only
91 DPPL     = $30     ;Display List List Pointer Low                write-only
92 P4C1     = $31     ;Palette 4 - Color 1                          write-only
93 P4C2     = $32     ;Palette 4 - Color 2                          write-only
94 P4C3     = $33     ;Palette 4 - Color 3                          write-only
95 CHARBASE = $34     ;Character Base Address                       write-only
96 CHBASE   = $34     ;Character Base Address                       write-only
97 P5C1     = $35     ;Palette 5 - Color 1                          write-only
98 P5C2     = $36     ;Palette 5 - Color 2                          write-only
99 P5C3     = $37     ;Palette 5 - Color 3                          write-only
100 OFFSET   = $38     ;Unused - Store zero here                     write-only
101 P6C1     = $39     ;Palette 6 - Color 1                          write-only
102 P6C2     = $3A     ;Palette 6 - Color 2                          write-only
103 P6C3     = $3B     ;Palette 6 - Color 3                          write-only
104 CTRL     = $3C     ;Maria Control Register                       write-only
105 P7C1     = $3D     ;Palette 7 - Color 1                          write-only
106 P7C2     = $3E     ;Palette 7 - Color 2                          write-only
107 P7C3     = $3F     ;Palette 7 - Color 3                          write-only
108 
109 
110 ;****** 280-2FF ******* PIA PORTS AND TIMERS ************
111 
112 SWCHA    = $280    ;P0+P1 Joystick Directional Input             read-write
113 CTLSWA   = $281    ;I/O Control for SCHWA                        read-write
114 SWACNT   = $281    ;VCS name for above                           read-write
115 SWCHB    = $282    ;Console Switches                             read-write
116 CTLSWB   = $283    ;I/O Control for SCHWB                        read-write
117 SWBCNT   = $283    ;VCS name for above                           read-write
118 
119 INTIM    = $284    ;Iterval Timer Read                           read-only
120 TIM1T    = $294    ;Set 1    CLK Interval (838   nsec/interval)  write-only
121 TIM8T    = $295    ;Set 8    CLK Interval (6.7   usec/interval)  write-only
122 TIM64T   = $296    ;Set 64   CLK Interval (63.6  usec/interval)  write-only
123 T1024T   = $297    ;Set 1024 CLK Interval (858.2 usec/interval)  write-only
124 TIM64TI  = $29E    ;Interrupt timer 64T                          write-only
125 
126 ;XM
127 XCTRL    = $470    ; 7=YM2151 6=RAM@6k 5=RAM@4k 4=pokey@450 3=hsc 2=cart 1=RoF_bank1 0=RoF_bank2
128 
129 ; Pokey register relative locations, since its base may be different
130 ; depending on the hardware.
131 PAUDF0   = $0    ; extra audio channels and frequencies
132 PAUDC0   = $1
133 PAUDF1   = $2
134 PAUDC1   = $3
135 PAUDF2   = $4
136 PAUDC2   = $5
137 PAUDF3   = $6
138 PAUDC3   = $7
139 PAUDCTL  = $8    ; Audio Control
140 PRANDOM  = $A    ; 17 bit polycounter pseudo random
141 PSKCTL   = $F    ; Serial Port control
142