Skip to content

Commit

Permalink
Initial drop of nibble receive/write (serial only, still doesn't quit…
Browse files Browse the repository at this point in the history
…e lay down tracks correctly)
  • Loading branch information
David Schmidt committed Sep 27, 2007
1 parent 13994b5 commit c4f775a
Show file tree
Hide file tree
Showing 13 changed files with 531 additions and 68 deletions.
4 changes: 3 additions & 1 deletion build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<delete file="${builddir}/ADTPROETH" />
<delete file="${builddir}/${distName}.tar.gz" />
<delete file="${builddir}/${distName}.zip" />
<delete file="${builddir}/${distName}/disks/${diskName}.DSK" />
<delete file="${builddir}/${distName}/disks/${diskName}.PO" />
<delete file="${builddir}/${distName}/disks/${dosDistName}.DSK" />
<delete file="${projdir}/org/adtpro/resources/adt.dmp" />
<delete file="${projdir}/org/adtpro/resources/adtpro.dmp" />
<delete file="${projdir}/org/adtpro/resources/adtproaud.dmp" />
Expand All @@ -54,7 +57,6 @@
<fileset dir="${projdir}/client/src" includes="**/*.lst"/>
<fileset dir="${projdir}/client/src" includes="**/*.lib"/>
</delete>
<delete dir="${builddir}/${distName}" />
</target>

<target name="assemble">
Expand Down
6 changes: 6 additions & 0 deletions client/src/audio/audproto.asm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ LASTIN = $2f
TAPEIN = $C060
TAPEOUT = $C020

RECVNIBCHUNK:
brk;

GETNIBREQUEST:
brk;

;---------------------------------------------------------
; DIRREQUEST - Request current directory contents
;---------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions client/src/ethernet/ethproto.asm
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ RECVERR:

ACK_CHAR: .byte CHR_ACK

RECVNIBCHUNK:
brk

GETNIBREQUEST:
brk

;---------------------------------------------------------
; RECVHBLK - Receive half a block with RLE
; CRCY is set to $01 on error, $00 on success
Expand Down
10 changes: 9 additions & 1 deletion client/src/format.asm
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ Trans:
ldx #$67
sta Buffer
stx Buffer+1
Trans2:
; Trans2 entry point preconditions:
; Buffer set to the start of nibble page to write (with leading sync bytes)
ldy #$32 ; Set Y offset to 1st sync byte (max=50)
ldx SlotF ; Set X offset to FORMAT slot/drive
sec ; (assume the disk is write protected)
Expand Down Expand Up @@ -675,7 +678,10 @@ MStore:
cmp DiskRD,x ; Set Read softswitch
iny ; Increment Y offset
bne LSync2
inc Buffer+1 ; Increment Buffer by 255
inc Buffer+1 ; Increment Buffer by one page
; We may have to let everybody use the $6600 buffer space after all.
; That lets us avoid the extra boundary checking, and just use the 'bpl'
; method of waiting for the pointer to go above $7f to page $80.
bpl LSync3 ; If < $8000 get more FORMAT data
lda ModeRD,x ; Restore Mode softswitch to READ
lda DiskRD,x ; Restore Read softswitch to READ
Expand All @@ -691,6 +697,8 @@ LWRprot:
pla
jmp Died ; Prompt for another FORMAT...

TransEnd: .byte $80

;************************************
;* *
;* BUILD - Build GAP1 and 16 sector *
Expand Down
120 changes: 115 additions & 5 deletions client/src/nibble.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,57 @@
; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;

;---------------------------------------------------------
; ReceiveNib - receive nibble image
;---------------------------------------------------------
ReceiveNib:
jsr nibtitle
jsr GETNIBREQUEST
jsr GETREPLY
beq ReceiveNibOK
jmp PCERROR

ReceiveNibOK:
; Build Gap bytes
lda #<BIGBUF+$10 ; Set Buffer to BIGBUF+0x10
ldx #>BIGBUF
sta Buffer
stx Buffer+1
ldy #$00 ; (Y offset always zero)
ldx #$F0
lda #$7F ; Build GAP1 using $7F (sync byte)
sta LByte
jsr LFill ; Store sync bytes from BIGBUF+$10 to BIGBUF+$100

lda UNITNBR ; Fetch target drive SLOTNUM value
and #$70 ; Mask off bit 7 and the lower 4 bits
sta SlotF ; Store result in FORMAT slot storage

lda #CHR_N
sta SendType ; Configure the nibble screen for output
; Here's where we set up a loop
; for all chunks to transfer.
lda #$00
sta ECOUNT ; Clear error flag
sta BLKHI
jsr calibrat ; Fire up the drive
: jsr rnibtrak ; Read a track from the comms device
lda #<BIGBUF ; Connect the Buffer pointer to the
sta Buffer ; beginning of the Big Buffer(TM)
lda #>BIGBUF
sta Buffer+1
jsr Trans2 ; Write track to disk
inc BLKHI
lda BLKHI
cmp #$23
beq ReceiveNibDone
sta iobtrk
jsr nibnextt ; Go to next track
jmp :-
ReceiveNibDone:
jsr motoroff ; We're finished with the drive
jmp COMPLETE ; Finish using sr.asm's completion code

;---------------------------------------------------------
; sendnib - send entire disk as nibbles
;
Expand Down Expand Up @@ -51,8 +102,8 @@ sendnib:
snibloop:
lda #$00
sta BLKLO ; Reset "sector" number using BLKLO
lda #CHR_R
jsr nibshow ; Show and "R" at current track
lda #CHR_V
jsr nibshow ; Show and "V" at current track
jsr rdnibtr ; Read track as nibbles
jsr snibtrak ; Send nibbles to other side
lda <ZP
Expand Down Expand Up @@ -80,6 +131,67 @@ snibfin:
jmp COMPLETE ; Finish using sr.asm's completion code


;---------------------------------------------------------
; rnibtrak - receive a nibble track
; Track number is set in BLKHI
; Each 256 byte page is followed by a 16-bit crc.
; we know the buffer is set up at "BIGBUF", and is
; NIBPAGES * 256 bytes long. BIGBUF is at page boundary.
;---------------------------------------------------------
rnibtrak:
lda #0 ; a = 0
sta BLKPTR ; Init running ptr
sta BLKLO
lda #>BIGBUF+1 ; BIGBUF address high
sta BLKPTR+1 ; We will be storing stuff at BIGBUF+0x100
lda #$1A ; Only run for 26 (decimal) pages
sta NIBPCNT ; Page counter
lda #CHR_R
jsr nibshow ; Show "R" at current track
rnibtr1:
lda #$02
sta <ZP
lda #CHR_ACK
rnib2:
tax
ldy #$00 ; Clear out the new chunk
tya
rnib3:
sta (BLKPTR),Y
iny
bne rnib3
txa
jsr RECVNIBCHUNK
bcs rnib4 ; Error during receive?
jsr UNDIFF

lda <CRC
cmp PCCRC
bne rnib4
lda <CRC+1
cmp PCCRC+1
bne rnib4

inc <BLKPTR+1 ; Get next 256 bytes
inc BLKLO ; Increment chunk number
lda BLKLO
cmp NIBPCNT ; Have we done all nibble pages?
beq rnibdone
lda #CHR_ACK
jmp rnib2
rnibdone:
lda #CHR_BLK ; Entire track transferred ok
jsr nibshow ; Show status of current track
lda #$00
rts

rnib4:
lda #_I'!' ; Error during receive
jsr nibshow ; Show status of current track
lda #CHR_NAK ; CRC error, ask for a resend
jmp rnib2


;---------------------------------------------------------
; snibtrak - send nibble track to the other side
; and wait for acknowledgement. each 256 byte page is
Expand Down Expand Up @@ -127,8 +239,6 @@ snibtr5:
bne snibtr1 ; and back if more pages
snibtrdloop:
jsr PUTINITIALACK ; Ready to go again
; TODO: Note: maybe we need to send a packet that says the track is done?
; That gives the client something to resend in case of timeout.
; for test only: activate next and deactivate line after
; lda #CHR_ACK ; Simulate response
jsr GETREPLY2 ; Get response from host for whole track
Expand Down Expand Up @@ -262,7 +372,7 @@ chekscnt:
tay ; reset y to 0
adc synccnt+1 ; high-order part
sta synccnt+1
cmp #$34 ; sets carry when a >= data
cmp #$34 ; sets carry when a >= data
rts

;---------------------------------------------------------
Expand Down
39 changes: 39 additions & 0 deletions client/src/serial/serproto.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DIRREQUEST:
jsr PUTC
rts


;---------------------------------------------------------
; DIRREPLY - Reply to current directory contents
;---------------------------------------------------------
Expand Down Expand Up @@ -55,6 +56,7 @@ DIRREPLY:
sta BLKPTR+1
rts


;---------------------------------------------------------
; DIRABORT - Abort current directory contents
;---------------------------------------------------------
Expand All @@ -74,6 +76,7 @@ CDREQUEST:
; Implicit rts from SENDFN
rts


;---------------------------------------------------------
; PUTREQUEST - Request to send an image to the host
; Accumulator holds request type:
Expand Down Expand Up @@ -104,6 +107,7 @@ PUTINITIALACK:
jsr PUTC
rts


;---------------------------------------------------------
; PUTFINALACK - Send error count for PUT request
;---------------------------------------------------------
Expand All @@ -112,6 +116,18 @@ PUTFINALACK:
jsr PUTC ; Send error flag to host
rts


;---------------------------------------------------------
; GETNIBREQUEST - Request a nibble image be sent from the host
;---------------------------------------------------------
GETNIBREQUEST:
jsr PARMINT ; Clean up the comms device
lda #CHR_O ; Tell host we are Getting/Receiving a nibble
jsr PUTC
jsr SENDFN ; Send file name
rts


;---------------------------------------------------------
; GETREQUEST - Request an image be sent from the host
;---------------------------------------------------------
Expand Down Expand Up @@ -243,6 +259,29 @@ RECVERR:
lda #CHR_NAK ; CRC error, ask for a resend
jmp RECVMORE

;---------------------------------------------------------
; RECVNIBCHUNK - Receive a nibble chunk with RLE
; Called with Acknowledgement in accumulator
;---------------------------------------------------------
RECVNIBCHUNK:
jsr PUTC ; Send ack/nak
lda BLKLO
jsr PUTC ; Send the track number (LSB)
lda BLKHI
jsr PUTC ; Send the chunk number (MSB)
lda <ZP
jsr PUTC ; Send protocol filler
jsr RECVHBLK
bcs :+ ; Do we have an error from block count?
jsr GETC ; Receive reply
sta PCCRC ; Receive the CRC of that block
jsr GETC
sta PCCRC+1
clc
:
rts


;---------------------------------------------------------
; RECVHBLK - Receive half a block with RLE
;
Expand Down
26 changes: 24 additions & 2 deletions client/src/sr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ SRSTART:
SRREENTRY:
bmi SMDONE ; Branch backwards... we just need an RTS close by
sta SLOWA ; Hang on to the device table index

jsr CheckForNib ; See if this is a nibble image
bcs GoForNib ; It is - so receive it
lda HOSTBLX
cmp NUMBLKS
bne SRMISMATCH
Expand All @@ -240,6 +241,9 @@ SRREENTRY:
bne SRMISMATCH
jmp SROK2

GoForNib:
jmp ReceiveNib

SRMISMATCH:
jsr CLRMSGAREA

Expand All @@ -260,7 +264,6 @@ SROK2:

jsr GETREQUEST
jsr GETREPLY
cmp #$00
beq SROK3
jmp PCERROR

Expand Down Expand Up @@ -471,6 +474,25 @@ SRBDONE:

SRBCNT: .byte $00

;---------------------------------------------------------
; CheckForNib - Check if the user has picked a .nib, and
; is wanting to write it to a Disk II drive
; Sets carry if it is sized as .nib and destination is Disk II
;---------------------------------------------------------
CheckForNib:
clc
lda HOSTBLX
cmp #$C7 ; LSB of 455 blocks (.nib size)
bne NotNib
lda HOSTBLX+1
cmp #$01 ; MSB of 455 blocks (.nib size)
bne NotNib
lda NonDiskII ; Is this a Disk II?
beq NotNib ; No - skip it
sec ; Yep - everything matches.
NotNib:
rts

;---------------------------------------------------------
; UNDIFF - Finish RLE decompression and update CRC
;---------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion client/src/vars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ PARMBUF:
BLKLO = PARMBUF+$04 ; Part of PARMBUF structure
BLKHI = PARMBUF+$05 ; Part of PARMBUF structure

BIGBUF = $6C00 ; The place where all the action happens
BIGBUF = $6600 ; The place where all the action happens
; Note: we now have 6 pages of free space between $B600 and $BC00.
CRCTBLL = $BC00 ; CRC LOW TABLE ($100 Bytes)
CRCTBLH = $BD00 ; CRC HIGH TABLE ($100 Bytes)
NUMBLKS:
Expand Down
Loading

0 comments on commit c4f775a

Please sign in to comment.