Add comments to both Harddisk.cpp & the firmware code about 'sta abs16,x' false-reads, etc.
Harddisk.cpp: Fix typos and update the notes on the r/w commands' operation.
This commit is contained in:
parent
5ed901f720
commit
6282790c3d
|
@ -49,13 +49,19 @@
|
||||||
|
|
||||||
; constants
|
; constants
|
||||||
hd_execute = $c080
|
hd_execute = $c080
|
||||||
hd_error = $c081 ; b7=busy, b0=error
|
hd_status = $c081 ; b7=busy, b0=error
|
||||||
hd_command = $c082
|
hd_command = $c082
|
||||||
hd_unitnum = $c083
|
hd_unitnum = $c083
|
||||||
hd_memblock = $c084
|
hd_memblock = $c084
|
||||||
hd_diskblock = $c086
|
hd_diskblock = $c086
|
||||||
;hd_nextbyte = $c088 ; legacy read-only port (still supported by AppleWin)
|
;hd_nextbyte = $c088 ; legacy read-only port (still supported by AppleWin)
|
||||||
|
|
||||||
|
; Notes on accesses to I/O registers:
|
||||||
|
; . ROR ABS16,X and ROL ABS16,X - only used for $C081+s*$10 STATUS register:
|
||||||
|
; 6502: double read (old data), write (old data), write (new data). The writes are harmless as writes are ignored to STATUS.
|
||||||
|
; 65C02: double read (old data), write (new data). The write is harmless as writes are ignored to STATUS.
|
||||||
|
; . STA ABS16,X does a false-read. This is harmless for writable I/O registers, since the false-read has no side effect.
|
||||||
|
|
||||||
command = $42
|
command = $42
|
||||||
unitnum = $43
|
unitnum = $43
|
||||||
memblock = $44
|
memblock = $44
|
||||||
|
@ -168,7 +174,7 @@ Bootstrap2
|
||||||
sta hd_unitnum,x ; b7=0 => disk 1
|
sta hd_unitnum,x ; b7=0 => disk 1
|
||||||
sta hd_command,x
|
sta hd_command,x
|
||||||
lda hd_execute,x
|
lda hd_execute,x
|
||||||
ror hd_error,x ; Post: C=0 or 1
|
ror hd_status,x ; Post: C=0 or 1
|
||||||
bcc hdboot
|
bcc hdboot
|
||||||
|
|
||||||
; no image ready, boot diskette image instead
|
; no image ready, boot diskette image instead
|
||||||
|
@ -272,7 +278,7 @@ GetSlotInX
|
||||||
; C=1 => via GetSlotInX (eg. Entrypoint / SmartPort2)
|
; C=1 => via GetSlotInX (eg. Entrypoint / SmartPort2)
|
||||||
; X = Slot# << 4
|
; X = Slot# << 4
|
||||||
; Post:
|
; Post:
|
||||||
; C = hd_error.b0
|
; C = hd_status.b0
|
||||||
; A = result of hd_execute
|
; A = result of hd_execute
|
||||||
; X = Slot# << 4
|
; X = Slot# << 4
|
||||||
cmdproc
|
cmdproc
|
||||||
|
@ -292,17 +298,17 @@ cmdproc
|
||||||
sta hd_diskblock+1,x
|
sta hd_diskblock+1,x
|
||||||
lda hd_execute,x ; A = result of hd_execute (NB. instantaneous 512 byte r/w!)
|
lda hd_execute,x ; A = result of hd_execute (NB. instantaneous 512 byte r/w!)
|
||||||
|
|
||||||
- rol hd_error,x ; b7=busy doing DMA?
|
- rol hd_status,x ; b7=busy doing DMA?
|
||||||
bcs -
|
bcs -
|
||||||
|
|
||||||
plp ; restore C from start of cmdproc
|
plp ; restore C from start of cmdproc
|
||||||
bcs done
|
bcs done
|
||||||
ror hd_error,x ; Post: C=0 or 1
|
ror hd_status,x ; Post: C=0 or 1
|
||||||
lda #0
|
lda #0
|
||||||
beq hdboot2
|
beq hdboot2
|
||||||
|
|
||||||
done
|
done
|
||||||
ror hd_error,x ; Post: C=0 or 1
|
ror hd_status,x ; Post: C=0 or 1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;======================================
|
;======================================
|
||||||
|
|
|
@ -42,54 +42,64 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#include "../resource/resource.h"
|
#include "../resource/resource.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Memory map:
|
Memory map (for slot 7):
|
||||||
|
|
||||||
C0F0 (r) EXECUTE AND RETURN STATUS
|
C0F0 (r) EXECUTE AND RETURN STATUS
|
||||||
C0F1 (r) STATUS (or ERROR)
|
C0F1 (r) STATUS (or ERROR): b7=busy, b0=error
|
||||||
C0F2 (r/w) COMMAND
|
C0F2 (r/w) COMMAND
|
||||||
C0F3 (r/w) UNIT NUMBER
|
C0F3 (r/w) UNIT NUMBER
|
||||||
C0F4 (r/w) LOW BYTE OF MEMORY BUFFER
|
C0F4 (r/w) LOW BYTE OF MEMORY BUFFER
|
||||||
C0F5 (r/w) HIGH BYTE OF MEMORY BUFFER
|
C0F5 (r/w) HIGH BYTE OF MEMORY BUFFER
|
||||||
C0F6 (r/w) LOW BYTE OF BLOCK NUMBER
|
C0F6 (r/w) LOW BYTE OF BLOCK NUMBER
|
||||||
C0F7 (r/w) HIGH BYTE OF BLOCK NUMBER
|
C0F7 (r/w) HIGH BYTE OF BLOCK NUMBER
|
||||||
C0F8 (r) NEXT BYTE
|
C0F8 (r) NEXT BYTE (legacy read-only port - still supported)
|
||||||
|
|
||||||
|
Firmware notes:
|
||||||
|
. ROR ABS16,X and ROL ABS16,X - only used for $C081+s*$10 STATUS register:
|
||||||
|
6502: double read (old data), write (old data), write (new data). The writes are harmless as writes to STATUS are ignored.
|
||||||
|
65C02: double read (old data), write (new data). The write is harmless as writes to STATUS are ignored.
|
||||||
|
. STA ABS16,X does a false-read. This is harmless for writable I/O registers, since the false-read has no side effect.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Hard drive emulation in Applewin.
|
Hard drive emulation in AppleWin.
|
||||||
|
|
||||||
Concept
|
Concept
|
||||||
To emulate a 32mb hard drive connected to an Apple IIe via Applewin.
|
To emulate a 32mb hard drive connected to an Apple IIe via AppleWin.
|
||||||
Designed to work with Autoboot Rom and Prodos.
|
Designed to work with Autoboot Rom and Prodos.
|
||||||
|
|
||||||
Overview
|
Overview
|
||||||
1. Hard drive image file
|
1. Hard drive image file
|
||||||
The hard drive image file (.HDV) will be formatted into blocks of 512
|
The hard drive image file (.HDV) will be formatted into blocks of 512
|
||||||
bytes, in a linear fashion. The internal formatting and meaning of each
|
bytes, in a linear fashion. The internal formatting and meaning of each
|
||||||
block to be decided by the Apple's operating system (ProDos). To create
|
block to be decided by the Apple's operating system (ProDOS). To create
|
||||||
an empty .HDV file, just create a 0 byte file (I prefer the debug method).
|
an empty .HDV file, just create a 0 byte file.
|
||||||
|
|
||||||
2. Emulation code
|
2. Emulation code
|
||||||
There are 4 commands Prodos will send to a block device.
|
There are 4 commands ProDOS will send to a block device.
|
||||||
Listed below are each command and how it's handled:
|
Listed below are each command and how it's handled:
|
||||||
|
|
||||||
1. STATUS
|
1. STATUS
|
||||||
In the emulation's case, returns only a DEVICE OK (0) or DEVICE I/O ERROR (8).
|
In the emulation's case, returns only a DEVICE OK (0), DEVICE I/O ERROR ($27) or DEVICE NOT CONNECTED ($28)
|
||||||
DEVICE I/O ERROR only returned if no HDV file is selected.
|
DEVICE NOT CONNECTED only returned if no HDV file is selected.
|
||||||
|
|
||||||
2. READ
|
2. READ
|
||||||
Loads requested block into a 512 byte buffer by attempting to seek to
|
Loads requested block into a 512 byte buffer by attempting to seek to
|
||||||
location in HDV file.
|
location in HDV file.
|
||||||
If seek fails, returns a DEVICE I/O ERROR. Resets hd_buf_ptr used by HD_NEXTBYTE
|
If seek fails, returns a DEVICE I/O ERROR. Resets m_buf_ptr used by legacy HD_NEXTBYTE
|
||||||
|
Copies requested block from a 512 byte buffer to the Apple's memory.
|
||||||
|
Sets STATUS.busy=1 until the DMA operation completes.
|
||||||
Returns a DEVICE OK if read was successful, or a DEVICE I/O ERROR otherwise.
|
Returns a DEVICE OK if read was successful, or a DEVICE I/O ERROR otherwise.
|
||||||
|
|
||||||
3. WRITE
|
3. WRITE
|
||||||
Copies requested block from the Apple's memory to a 512 byte buffer
|
Copies requested block from the Apple's memory to a 512 byte buffer
|
||||||
then attempts to seek to requested block.
|
then attempts to seek to requested block.
|
||||||
If the seek fails (usually because the seek is beyond the EOF for the
|
If the seek fails (usually because the seek is beyond the EOF for the
|
||||||
HDV file), the Emulation will attempt to "grow" the HDV file to accomodate.
|
HDV file), the emulation will attempt to "grow" the HDV file to accommodate.
|
||||||
Once the file can accomodate, or if the seek did not fail, the buffer is
|
Once the file can accommodate, or if the seek did not fail, the buffer is
|
||||||
written to the HDV file. NOTE: A2PC will grow *AND* shrink the HDV file.
|
written to the HDV file. NOTE: A2PC will grow *AND* shrink the HDV file.
|
||||||
|
Sets STATUS.busy=1 until the DMA operation completes.
|
||||||
I didn't see the point in shrinking the file as this behaviour would require
|
I didn't see the point in shrinking the file as this behaviour would require
|
||||||
patching prodos (to detect DELETE FILE calls).
|
patching prodos (to detect DELETE FILE calls).
|
||||||
|
|
||||||
|
@ -99,9 +109,9 @@ Overview
|
||||||
|
|
||||||
3. Bugs
|
3. Bugs
|
||||||
The only thing I've noticed is that Copy II+ 7.1 seems to crash or stall
|
The only thing I've noticed is that Copy II+ 7.1 seems to crash or stall
|
||||||
occasionally when trying to calculate how many free block are available
|
occasionally when trying to calculate how many free blocks are available
|
||||||
when running a catalog. This might be due to the great number of blocks
|
when running a catalog. This might be due to the great number of blocks
|
||||||
available. Also, DDD pro will not optimise the disk correctally (it's
|
available. Also, DDD pro will not optimise the disk correctly (it's
|
||||||
doing a disk defragment of some sort, and when it requests a block outside
|
doing a disk defragment of some sort, and when it requests a block outside
|
||||||
the range of the image file, it starts getting I/O errors), so don't
|
the range of the image file, it starts getting I/O errors), so don't
|
||||||
bother. Any program that preforms a read before write to an "unwritten"
|
bother. Any program that preforms a read before write to an "unwritten"
|
||||||
|
|
Loading…
Reference in New Issue