Apple II notes ** Memory Map |---------+-------------------------------------------| | Page | Use | |---------+-------------------------------------------| | $00 | Page Zero | | $01 | System stack | | $02 | Input buffer | | $03 | Monitor vector locations | | $04-$07 | Text/Lo-Res Primary | | $08-$0B | Text/Lo-Res Secondary | | $0C-$1F | Free RAM | | $20-$3F | Hires Primary | | $40-$5F | Hires Secondary | | $60-$BF | Free RAM | | $C0 | I/O and softswitches | | $C1-$C7 | ROM for seven peripheral cards | | $C8-$CF | switchable ROM for peripheral cards | | $D0-$D7 | empty ROM socket #1 / Programmer's Aid #1 | | $D8-$DF | empty ROM socket #2 | | $E0-$F7 | Integer BASIC ROM | | $F8-$FF | Monitor ROM | |---------+-------------------------------------------| * Integer Basic Map |-------------+---------------------------------| | Address | Use | |-------------+---------------------------------| | $E000-$F424 | BASIC | | $F425-$F4FB | Floating point math package 1/2 | | $F4FC-$F4FF | ??? (4 bytes) | | $F500-$F63C | Miniassembler | | $F63D-$F65D | Floating point math package 2/2 | | $F65E-$F665 | ??? (8 bytes) | | $F666-$F668 | Miniassembler entry point | | $F669-$F688 | ??? (32 bytes) | | $F689-$F7FC | SWEET 16 interpreter | | $F800-$FFFF | Monitor | |-------------+---------------------------------| * I/O and softswitches |---------+--------+------------------------------------------------------------------| | Address | Dec | Use | |---------+--------+------------------------------------------------------------------| | $C00X | -16384 | Read keyboard: High bit = key pressed | | $C01X | -16368 | Set to 0 to clear keyboard strobe | | $C01A | -16358 | Read: High bit 1 = TEXT switch "ON" | | $C01B | -16357 | Read: High bit 1 = MIXED switch "ON" | | $C01C | -16356 | Read: High bit 1 = PAGE2 switch "ON" | | $C01D | -16355 | Read: High bit 1 = HIRES switch "ON" | | $C02X | | Casette output toggle | | $C03X | -16336 | Speaker toggle | | $C04X | | Output strobe to Game I/O connector | | $C050 | -16304 | Set graphics mode | | $C051 | -16303 | Set text mode | | $C052 | -16302 | Set bottom 4 lines graphics | | $C053 | -16301 | Set bottom 4 lines text | | $C054 | -16300 | Display primary page | | $C055 | -16299 | Display secondary page | | $C056 | -16298 | Set HIRES graphics mode | | $C057 | -16297 | Set color graphics mode | | $CØ58 | -l6296 | Clear Game I/O ANØ output | | $CØ59 | -l6295 | Set Game I/O ANØ output | | $CØ5A | -l6294 | Clear Game I/O ANl output | | $CØ5B | -l6293 | Set Game I/O ANl output | | $CØ5C | -l6292 | Clear Game I/O AN2 output | | $CØ5D | -l629l | Set Game I/O AN2 output | | $CØ5E | -l629Ø | Clear Game I/O AN3 output | | $CØ5F | -l6289 | Set Game I/O AN3 output | | $C060/8 | | Tape in (bit 7) | | $C061/9 | -16287 | "SW1": PDL(0) switch: High bit 1 = "on" | | $C062/A | -16286 | "SW2": PDL(1) switch: High bit 1 = "on" | | $C063/B | -16285 | "SW3": PDL(2) switch: High bit 1 = "on" | | $C064/C | | Paddle 0 timer output: state of timer output in high bit | | $C065/D | | Paddle 1 timer output: state of timer output in high bit | | $C066/E | | Paddle 2 timer output: state of timer output in high bit | | $C067/F | | Paddle 3 timer output: state of timer output in high bit | | $C064 | | Paddle0 | | $C07X | | Trigger paddle timers during \Zero_2 | | $C08X | | Device select 0: Pin 41 on Peripheral Connector low during 0_2 | | $C09X | | Device select 1: Pin 41 on Peripheral Connector low during 0_2 | | $C0AX | | Device select 2: Pin 41 on Peripheral Connector low during 0_2 | | $C0BX | | Device select 3: Pin 41 on Peripheral Connector low during 0_2 | | $C0CX | | Device select 4: Pin 41 on Peripheral Connector low during 0_2 | | $C0DX | | Device select 5: Pin 41 on Peripheral Connector low during 0_2 | | $C0EX | | Device select 6: Pin 41 on Peripheral Connector low during 0_2 | | $C0FX | | Device select 7: Pin 41 on Peripheral Connector low during 0_2 | | $C10X | | Device select (8): Pin 41 on Peripheral Connector low during 0_2 | | $C11X | | Device select (9): Pin 41 on Peripheral Connector low during 0_2 | | $C12X | | Device select (A): Pin 41 on Peripheral Connector low during 0_2 | | $C13X | | Device select (B): Pin 41 on Peripheral Connector low during 0_2 | | $C14X | | Device select (C): Pin 41 on Peripheral Connector low during 0_2 | | $C15X | | Device select (D): Pin 41 on Peripheral Connector low during 0_2 | | $C16X | | Device select (E): Pin 41 on Peripheral Connector low during 0_2 | | $C17X | | Device select (F): Pin 41 on Peripheral Connector low during 0_2 | | $C1XX | | I/O Select 1: Pin 1 on Peripheral Connector low during 0_2 | | $C2XX | | I/O Select 2: Pin 1 on Peripheral Connector low during 0_2 | | $C3XX | | I/O Select 3: Pin 1 on Peripheral Connector low during 0_2 | | $C4XX | | I/O Select 4: Pin 1 on Peripheral Connector low during 0_2 | | $C5XX | | I/O Select 5: Pin 1 on Peripheral Connector low during 0_2 | | $C6XX | | I/O Select 6: Pin 1 on Peripheral Connector low during 0_2 | | $C7XX | | I/O Select 7: Pin 1 on Peripheral Connector low during 0_2 | | $C8XX | | I/O Select (8): Pin 1 on Peripheral Connector low during 0_2 | | $C9XX | | I/O Select (9): Pin 1 on Peripheral Connector low during 0_2 | | $CAXX | | I/O Select (A): Pin 1 on Peripheral Connector low during 0_2 | | $CBXX | | I/O Select (B): Pin 1 on Peripheral Connector low during 0_2 | | $CCXX | | I/O Select (C): Pin 1 on Peripheral Connector low during 0_2 | | $CDXX | | I/O Select (D): Pin 1 on Peripheral Connector low during 0_2 | | $CEXX | | I/O Select (E): Pin 1 on Peripheral Connector low during 0_2 | | $CFXX | | I/O Select (F): Pin 1 on Peripheral Connector low during 0_2 | | $CFFF | | switchable peripheral ROM - find out more | | | | | | | | | * Page 00 |---------+---------+----------------------------------------------------------------| | Address | Dec | Description | |---------+---------+----------------------------------------------------------------| | $00-$1F | | Register area for "sweet 16" | | $18 | | (DOS) first track of data | | $19 | | (DOS) first sector of data | | $1A | | (DOS) number of sectors to load | | $1B | | (DOS) HIGH BYTE of buffer (LO is always 0) | | $1A/B | | Shape pointer used by DRAW and XDRAW | | $1C | | Last color used (HCOLOR converted to its color byte) | | $20 | 32 | Left edge of window (0-39) | | $21 | 33 | Width of the window (0 to 40 - Left) | | $22 | 34 | Top edge of window (0-23) | | $23 | 35 | Bottom of window (0-23) Bottom > Top | | $24 | 36 | HTAB: 0-39 | | $25 | 37 | VTAB: 0-23 | | $2B | 43 | Boot SLOT * 16 | | $2C | 44 | Lo-res line end-point | | $30 | 48 | Lores color * 17 | | $32 | 50 | Inverse($3F), Flash($7F), Normal($FF), Invisible($80) | | $33 | | Prompt-char | | $4A/B | 74-75 | LOMEM address (INT) | | $4C/D | 76-77 | HIMEM address (INT) | | $4E-$4F | 78-79 | 16-bit number, randomized with each key entry | | | 214 | Poke 255 to auto-run program | | | 212 | Error code flag in decimal | | | 216 | High bit set if error detected: zero to clear | | | 222 | Error code | | | 224-226 | HIRES GR X&Y coordinates | | $E4 | 228 | Color being used {0=0:42=1:85=2:127=3:128=4:170=5:213=6:255=7} | | $E6 | 230 | HIRES PLOTTING PAGE (32=1/64=2/96=3) | | $E7 | 231 | SCALE of shape | | $EA | 234 | COLLISION COUNTER for shapes | | | 241 | 256-SPEED | | $F3 | 243 | FLASH MASK | | $F9 | 249 | ROT | * Page 03 |-------------+--------------------------------------| | Address | Description | |-------------+--------------------------------------| | $0320/1 | Low-endian HIRES X coordinate: 0-279 | | $0322 | HIRES Y coordinate: 0-159 | | $0324/5 | Start address of SHAPE TABLE | | $032C | COLOR for HIRES | | $03F8 | CTRL-Y in Monitor with JSR here | | $03FB | NMI | | $03FE-$03FF | IRQ sent to this address | | | | * Basic locations |---------+------+--------------------------------| | Address | Dec | Description | |---------+------+--------------------------------| | | 2049 | Set to 1 for "list protection" | * DOS routines |---------+-------+-------------| | Address | Dec | Description | |---------+-------+-------------| | | 42350 | Catalog | * Monitor routines |---------+-------+-------+------------------------------------------------------------| | Address | Dec | Dec | Description | |---------+-------+-------+------------------------------------------------------------| | | $F3D4 | -3116 | HGR2 | | | $F3DE | -3106 | HGR | | | $F3F2 | -3086 | CLEAR HIRES SCREEN | | | $F3F6 | -3082 | CLEAR HIRES SCREEN to HCOLOR | | | $FB2F | -1233 | TEXT | | | $FB40 | -1216 | GR | | | $FB60 | -1184 | PRINT "APPLE ][" | | | $FBE4 | -1052 | RING BELL | | | $FBF4 | -1036 | MOVE CURSOR RIGHT | | | $FC10 | -1008 | MOVE CURSOR LEFT | | | $FC1A | -998 | MOVE CURSOR UP 1 LINE | | | $FC58 | -936 | HOME | | | $FD0C | -756 | WAIT FOR KEYPRESS | | | $FD67 | -665 | GET a LINE of input with PROMPT, LINE FEED, and wait. | | | $FD6A | -662 | GET a LINE of input with PROMPT, NO LINE FEED, and wait. | | | $FD6F | -657 | GET a LINE of input with NO PROMPT or LINE FEED, and wait. | | | $FE80 | -384 | INVERSE | | | $FE84 | -380 | NORMAL | | | $FECA | -310 | WRITE to tape | | | $FEFD | -259 | READ from tape | | | | | | ** References - http://apple2history.org/history/ah03/ - http://www.textfiles.com/apple/peekpk.txt - http://www.textfiles.com/apple/peekpoke.app - http://www.textfiles.com/apple/peeks.pokes.2 - http://www.applefritter.com/node/24236 - http://www.easy68k.com/paulrsm/6502/index.html - Information about firmware - http://www-personal.umich.edu/~mressl/a2dp/index.html - Apple II documentation project * Language card Install in slot 0. Replaces RAM chip in E3 with a cable to the card. Contains "autostart ROM" Adds Esc-ijkm movement Ctrl-S stop/start program listings ** Autostart ROM details $3F0/1 Break vector: $59,$FA $3F2/3 Reset vector: $03, $E0 (for non-disk systems after power-up reset) $3F4 Powered up mask: $45 ** Memory details |-------------+-------------------------| | Address | Description | |-------------+-------------------------| | $D000-$DFFF | 4K bank-switched memory | | $E000-$F7FF | RAM | | $F800-$FFFF | Language card ROM | |-------------+-------------------------| * Control codes Bit 2 is ignored. Bit 3 chooses which RAM banks is switched in to $D000-$DFFF. When RAM is deselected (and write-enabled), it can be written but not read. When RAM is deselected, Language Card ROM is mapped to $F800-$FFFF. Power-on RESET initializes ROM to read mode, and RAM to write mode, and selects the second 4K bank for $D000-$DFFF. |----------------+---------------+---------------------------------------------------| | Second 4K Bank | First 4K Bank | Description | |----------------+---------------+---------------------------------------------------| | $C080 | $C088 | Select RAM read. Write-protect RAM | | $C081 | $C089 | Deselect RAM reaad (enable ROM) | | | | Two or more successive reads = write-enable RAM | | $C082 | $C08A | Deselect RAM read (enable ROM). Write-protect RAM | | $C083 | $C08B | Select RAM read. | | | | Two or more successive reads = write-enable RAM | |----------------+---------------+---------------------------------------------------| * Revisions ** II - Integer Basic - Revision 0 - Only 4 hires colors: black, white, violet, green - Revision 1 - 6 hires colors - Color killer - power-on-reset - auto-start - 24k memory map problem (?!) - keyboard strobe flip flop connected to reset ** II+ - Applesoft - Usually with 16k "Language Card" ** IIe - 80-column card * Keyboard | Key | Alone | CTRL | SHIFT | BOTH | | space | A0 | | A0 | | | , < | AC | | BC | | | - = | AD | | BD | | | . > | AE | | BE | | | / ? | AF | | BF | | | 0 | B0 | | B0 | | | 1 ! | B1 | | A1 | | | 2 " | B2 | | A2 | | | 3 # | B3 | | A3 | | | 4 $ | B4 | | A4 | | | 5 % | B5 | | A5 | | | 6 & | B6 | | A6 | | | 7 ' | B7 | | A7 | | | 8 ( | B8 | | A8 | | | 9 ) | B9 | | A9 | | | : * | BA | | AA | | | ; + | BB | | AB | | | A | C1 | 81 | | | | B | C2 | 82 | | | | C | C3 | 83 | | | | D | C4 | 84 | | | | E | C5 | 85 | | | | F | C6 | 86 | | | | G | C7 | 87 | | | | H | C8 | 88 | | | | l arrow | 88 | | | | | I | C9 | 89 | | | | J | CA | 8A | | | | K | CB | 8B | | | | L | CC | 8C | | | | M ] | CD | 8D | DD | 9D | | RETURN | 8D | | | | | N ^ | CE | 8E | DE | 9E | | O | CF | 8F | | | | P @ | D0 | 90 | C0 | 80 | | Q | D1 | 91 | | | | R | D2 | 92 | | | | S | D3 | 93 | | | | T | D4 | 94 | | | | U | D5 | 95 | | | | r arrow | 95 | | | | | V | D6 | 96 | | | | W | D7 | 97 | | | | X | D8 | 98 | | | | Y | D9 | 99 | | | | Z | DA | 9A | | | | ESC | 9B | 9B | | | * Character set @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]^_ !"#$%&'()*+,-./ 0123456789:;<=>? 64 * 8 = 512 Revision 7: 256 * 8 = 2048 * Video scanning H0,H1,H2,H3,H4,H5,HPE' VA,VB,VC,V0,V1,V2,V3,V4,V5 ** Horizontal scanning: H0-H5,HPE' 7 bits, 65 states. 0000000,1000000-1111111. HPE' is low only for one cycle, the long cycle. 40/65 states send picture output. 25/65 are blanked. ** Vertical scanning: VA-VC,V0-V5 Increments on overflow from the horizontal section. 9 bits, 262 states. 011111010-111111111. 192/262 states send picture information, 70/262 are blanked. V4V3 divides the screen into thirds: - V4'V3' - Top third - V4'V3 - Middle third - V4 V3' - Bottom third - V4 V3 - Undisplayed (VBL) 6 cycles blanked: 011111010-011111111 64 cycles blanked: 111000000-111111111 | Location on TV screen | Least significant address bits | |-----------------------+--------------------------------| | Top | 0000000 - 0100111 (First 40) | | Middle | 0101000 - 1001111 (Second 40) | | Bottom | 1010000 - 1110111 (Third 40) | Lowest 3 bits are easy: H2,H1,H0 == A2,A1,A0 Next four bits are H5-H4-H3 + offset = SUM-A{3..6} - 0000-0100, 0101-1001, 1010-1110. H5-H4-H3: 000..010 are undisplayed: right margin, retrace, left margin. 011 first displayed. H543 -3 in First 40, +2 in second 40, +7 in Third 40. 1 1 0 1 + H5 H4 H3 + V4 V3 V4 V3 --------------------------- SUM-A6 SUM-A5 SUM-A4 SUM-A3 ** Pages: $0000-$3FFF - ! HIRES PAGE 2 $4000-$7FFF - HIRES PAGE 2 HIRES TIME: - high when in HIRES, GRAPHICS, NO MIX mode - high when in HIRES, GRAPHICS, MIX, !(V4•V2) (·) | A0 | H0 | | A1 | H1 | | A2 | H2 | | A3 | SUM-A3 | | A4 | SUM-A4 | | A5 | SUM-A5 | | A6 | SUM-A6 | | A7 | V0 | | A8 | V1 | | A9 | V2 | | A10 | HIRES•VA + TEXT/LORES•PAGE1 | | A11 | HIRES•VB + TEXT/LORES•PAGE2 | | A12 | HIRES•VC + TEXT/LORES•HBL | | A13 | HIRES•PAGE1 | | A14 | HIRES•PAGE2 | | A15 | - | VA,VB,VC determine which part of text characters to draw. VC determines which of two LORES blocks to draw. * Colors | Color Ref | 0011 | | Dark Magenta | 0001 | | Light Magenta | 1011 | | HIRES Violet | 0011 | | Dark Blue | 0010 | | Light Blue | 0111 | | HIRES Blue | 0110 | | Dark Blue-Green | 0100 | | Light Blue-Green | 1110 | | HIRES Green | 1100 | | Dark Brown | 1000 | | Light Brown | 1101 | | HIRES Orange | 1001 | | $5 Grey | 0101 | | $A Grey | 1010 | | White | 1111 | | Black | 0000 | * Design Event loop runs everything. Key/mouse/resize/quit events come from somewhere (sdl) Key events go to CPU. Event loop can pause emulator and bring up menu. - change disks - save state, etc. - change parameters Video scanner scanning memory -> chroma/luma signal -> color interpreter -> plotting Event loop hands colorplotter a pixelplotter colorplotter does green / b/w / color choice Some kind of menu subsystem for paused/config mode. * Gospeccy design spectrum.Application - HasTerminated chan - RequestExit() spectrum.Spectrum48k (app, *rom) - EmulatorLoop() - CommandChannel - speccy.Keyboard.Key{Down,Up} sdl_output.Main(): - Get a spectrum.Application - Get a spectrum.Spectrum48k - r = NewSDLRenderer(app, speccy, ...) - setUI(r) - initCLI() - go sdlEventLoop(app, speccy) - wait for shutdown - sdl.Quit() sdlEventLoop(): - evtLoop = app.NewEventLoop() * Firmware card $D000-$FFFF B2-B set (motherboard ROM) - RESET+switch down - odd addresses between $C081 and $C08F (slot 0) B2-B reset (firmware card ROM) - RESET+switch up - even addresses between $C080 and $C08E F8 jumper jumpered: use F8 ROM on card when card is enabled. F8 jumper not jumpered: never use F8 ROM on card: use motherboard. (Apple sold jumpered+autostart ROM, non-jumpered+no-rom. [UtA2: 6-11]) * Questions ** Color Can a previously rendered dot change colors? Gray?