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 00 DOS [BAD 8-42] |---------+-----+-----------------------------------------------| | Address | Dec | Description | |---------+-----+-----------------------------------------------| | 24 | | Cursor horizontal | | 26,27 | | Sector read buffer address (ROM) | | 28,29 | | BASL/BASH (DOS) | | 2A | | Segment merge counter (ROM,BOOT) | | | | Scratch space (RWTS) | | 2B | | BOOT slot*16 (ROM) | | | | Scratch space (RWTS) | | 2C | | Checksum from sector header (RWTS) | | 2D | | Sector number form sector header (RWTS) | | 2E | | Track number form sector header (RWTS) | | 2F | | Volume number form sector header (RWTS) | | 33 | | Prompt character (DOS) | | 35 | | Drive number in high bit (RWTS) | | 36,37 | | CSWL,CSWH (DOS) | | 38,39 | | KSWL,KSWH (DOS) | | 3C | | Workbyte (ROM) | | | | Merge workbyte (BOOT) | | | | Device characteristics table address (RWTS) | | 3D | | Sector number (ROM) | | | | Device characteristics table address (RWTS) | | 3E,3F | | Address of ROM sector-read subroutine (BOOT) | | | | Buffer address (RWTS) | | 40,41 | | DOS image address (BOOT) | | | | File buffer address (DOS) | | 41 | | Format track counter (RWTS) | | 42,43 | | Buffer address (DOS) | | 44,45 | | Numeric operand (DOS) | | 46,47 | | Scratch space (RWTS) | | 48,49 | | IOB address (RWTS) | | 4A,4B | | INTEGER BASIC LOMEM address (DOS) | | | | Format diskette workspace (RWTS) | | 4C,4D | | INTEGER BASIC HIMEM address (DOS) | | 67,68 | | APPLESOFT BASIC PROGRAM START (DOS) | | 69,6A | | APPLESOFT BASIC VARIABLES START (DOS) | | 6F,70 | | APPLESOFT BASIC STRING START (DOS) | | 73,74 | | APPLESOFT BASIC HIMEM address (DOS) | | 76 | | APPLESOFT BASIC line number high (DOS) | | AF,B0 | | APPLESOFT BASIC PROGRAM END (DOS) | | CA,CB | | INTEGER BASIC PROGRAM START (DOS) | | CC,CD | | INTEGER BASIC VARIABLES END (DOS) | | D6 | | APPLESOFT BASIC PROGRAM protection flag (DOS) | | D8,D9 | | INTEGER BASIC line number (DOS) | | | | APPLESOFT BASIC ONERR (DOS) | |---------+-----+-----------------------------------------------| * 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://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/ - 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? ** Disk I thought ProDOS only allowed a read syncing leader from $10 to $1A. But the nybblized disk format seems to have 48 spare bytes for each sector. (- 416 14 5 6 1 342) 48 * Disk formats ** dsk/do - DOS 3.3 order 35 tracks * 16 sectors * 256 bytes = 143,360 ** po - ProDOS order ** nib 232,960 bytes (* 35 16 342) 191,520 (* 35 16 (+ 342 74)) 232,960 bytes Extra bytes per track: 1184 (74 PER SECTOR) https://code.google.com/p/twoapple/source/browse/src/peripheral/diskii.d ADDR: 13 PROLOGUE: 3 D5,AA,96 VOLUME: 2 TRACK: 2 SECTOR: 2 CHECK: 2 EPILOGUE: 2 DE,AA DATAFIELD: 349 PROLOGUE: 3 D5,AA,AD DATA: 343 EPILOGUE: 3 DE,AA,EB SECTOR: ADDR: 13 GAP2: 6 DATAFIELD: 349 GAP3: 45 (+ 13 6 349 45) 413 # 48 byte gap, 413 per sector: (+ 48 (* 16 413)) 6656 http://sourceforge.net/p/java-ace/code/285/tree/jace/src/jace/hardware/FloppyDisk.java - 15 junk bytes - Address block: 14 - D5,AA,96 - 3 - Volume - 2 - Track - 2 - Sector - 2 - Checksum - 2 - DE,AA,EB - 3 - 4 junk bytes - Data block 349 - D5,AA,AD 3 - Data: 342 - Checksum: 1 - DE,AA,EB - 3 - 34 junk bytes (+ 15 14 4 349 34) 416 Writing out: http://sourceforge.net/p/java-ace/code/285/tree/jace/src/jace/hardware/FloppyDisk.java#l260 - Look for D5,AA,96 - Verify track - Read sector - Look for DE,AA - Look for D5,AA,AD - - Look for DE,AA,EB http://mrob.com/apple2/extract.txt https://code.google.com/p/openemulator/source/browse/trunk/libdiskimage/DIApple525DiskStorage.cpp#590 - 128 sync bytes for track 0, 20 for others. - address field - (+ 3 8 3) 14 - 8 sync bytes - data field - (+ 3 86 256 1 3) 349 (+ 108 (* 20 16) (* 16 (+ 14 8 349))) 6364 6656 * Listings * RWTS listing http://www.txbobsc.com/aal/1981/aal8109.html#a5 * DOS 3.3 boot sector http://www.txbobsc.com/aal/1981/aal8108.html#a9 * Volume numbers DOS 3.3: Default = 254 Prodos: not used. [[https://groups.google.com/d/msg/comp.sys.apple2/YjoOR7gza1w/-2-HcNLLucwJ][1?]] * Sector orders ** DOS 3.3 [[ftp://ftp.apple.asimov.net/pub/apple_II/documentation/source_code/Apple2DOS33CSourceListing.pdf][Logical to physical sector mapping source]] Logical to physical 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 0,D,B,9,7,5,3,1,E,C,A,8,6,4,2,F Physical to logical: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 0,7,E,6,D,5,C,4,B,3,A,2,9,1,8,F When writing nybblized track 1, we write track 1 in address header, but read from image track sector 7. logical 4 <==> physical 7 ** Prodos [[http://sourceforge.net/p/java-ace/code/285/tree/jace/src/jace/hardware/FloppyDisk.java#l40][Physical to logical - JACE]] Logical to Physical: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 0,2,4,6,8,A,C,E,1,3,5,7,9,B,D,F Physical to logical: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 0,8,1,9,2,A,3,B,4,C,5,D,6,E,7,F * Formatting... _Prodos note_: tolerance of read syncing leader is $10 to $1A, so drive speed must be close to 300rpm. Syncing leader: 5-40 FFs Address Gap 50 Gap 53 Syncing leader: 5 FFs Guess 40 FFs. Write 128 FF40's before Sector 0, 40 FF40s before the others. Write sectors in order (physical sectors). Sync count reduced by 2s until it reaches 16, then by ones until it reaches 5. If track 0 has >15 sync count, the rest of the tracks will have (sync count - 2). * Byte counts | | Jace | Twoapple | OpenEmulator-Byte | OpenEmulator-Cycle | |-------------+------------------------+---------------------+----------------------+-----------------------------| | Pre-track-0 | | 48 | 108 | (* 108 40) 4320 | | Pre-sync | 15 | | 20 | (+ (* 19 40) 32) 792 | | Address | 14 | 13 | 14 | (+ (* 13 32) 16) 432 | | Intra-sync | 4 | 6 | 8 | (+ (* 7 40) 36) 316 | | Data | 349 | 349 | (+ 3 86 256 3 1) 349 | (* 349 32) 11168 | | Post-sync | 34 | 45 | 0 | 0 | | | (+ 15 14 4 349 34) 416 | (+ 13 6 349 45) 413 | (+ 20 14 8 349) 391 | (+ 792 432 316 11168) 12708 | | | (* 416 16) 6656 | (* 413 16) 6608 | (* 16 391) 6256 | (* 16 12708) 203328 | | | 6656 | (+ 6608 48) 6656 | (+ 6256 108) 6364 | (+ 203328 4320) 207648 | | | | | | (/ 207648 4) 51912 |