Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCBM2SD fastload protocol #5

Open
ytmytm opened this issue Nov 5, 2024 · 0 comments
Open

TCBM2SD fastload protocol #5

ytmytm opened this issue Nov 5, 2024 · 0 comments

Comments

@ytmytm
Copy link

ytmytm commented Nov 5, 2024

TCBM2SD fastload protocol, needs firmware minor revision 2 or higher - the last character of reset string after DOS command UI must be at least 2: as in: 73, TCBM2SD BY YTM 2024,00,02

This can be size optimized

    .print	". plus/4 TCBM2SD fastloader (no exodecrunch support)"
    .namespace iolib {
    .namespace plus4tcbm2sd_fast {
    .pseudopc io_base {

    jmp	startload
    jmp	readbyte
    jmp	writebyte
    jmp	hardsync
    jmp	sync
init:
hardsync:
readbyte:
writebyte:
sync:
	rts

// Send DOS command over channel 15

// in: ports setup correctly
// X=io_addr offset, not modified, A/Y changed
TCBM_SendDOSCommand:
	jsr		TCBM_LISTEN
	lda		#$6F				// command channel
	jsr		TCBM_SECONDARY
	ldy		#0
!:	lda		command,y
	jsr		TCBM_SENDBYTE
	iny
	cpy		#<(commandend-command)
	bne		!-
	// fall through to TCBM_UNLISTEN
TCBM_UNLISTEN:
	lda		#$3F				// UNLISTEN
	.byte $2c
TCBM_LISTEN:
	lda		#$20				// LISTEN
	pha
        lda     #$81    			// this is a command byte
        bne     TCBM_Send
TCBM_SECONDARY:						// send secondary addr ($60 == SECOND after LISTEN and after TALK)
	pha
        lda     #$82    			// this is a second byte
        bne     TCBM_Send
TCBM_SENDBYTE:
	pha
        lda     #$83				// this is a data byte
TCBM_Send:							// send using standard Kernal protocol
        sta padta,x
!:	lda pcdta,x
	bmi !-
	pla
	pha
        sta padta,x
        lsr pcdta,x
!:	lda pcdta,x
	bpl !-
        lda #0
        sta padta,x
        lsr pcdta,x
	pla
	rts

startload:
	stx filename
	sty filename+1
	ldx io_tcbmoffs
	jsr TCBM_SendDOSCommand
	lda #0
	sta padir,x // port A input
	sta pcdta,x // DAV=0 we are ready

!:	lda pcdta,x // wait for ACK low
	bmi !-
	lda padta,x // loadaddr lo
	sta ptr
	lda pbdta,x // STATUS
	tay
	lda #$40
	sta pcdta,x // DAV=1, confirm
	tya
	and #%00000011
	beq cont1
loaderror:
loadend:
	lda #$40	// DAV=1
	sta pcdta,x
	lda #$ff
	sta padir,x
	ldx filename
	ldy filename
	sec
	rts

cont1:
!:	lda pcdta,x // wait for ACK hi
	bpl !-
	lda padta,x // loadaddr hi
	sta ptr+1
	lda pbdta,x // STATUS
	tay
	lda #$00
	sta pcdta,x // DAV=0, confirm
	tya
	and #%00000011
	bne loaderror

// loadstart
	ldy #0
loadloop:
	// even: BMI+$40
!:	lda pcdta,x // wait for ACK low
	bmi !-
	lda padta,x
	sta (ptr),y
	iny
	lda pbdta,x // STATUS
	sta io_bitbuff
	lda #$40
	sta pcdta,x // DAV=1, confirm
	lda io_bitbuff
	and #%00000011
	bne eof
	// odd: BPL+$00
!:	lda pcdta,x // wait for ACK hi
	bpl !-
	lda padta,x
	sta (ptr),y
	iny
	lda pbdta,x // STATUS
	sta io_bitbuff
	lda #$00
	sta pcdta,x // DAV=0, confirm
	lda io_bitbuff
	and #%00000011
	bne eof
	tya
	bne loadloop
	inc ptr+1
	bne loadloop
eof:
	jsr loadend
	clc
	rts

command:
    .text "U0"	// burst command
    .byte %00011111 // fastload utility (filename)
filename:	// followed by name
    .byte 0, 0
commandend:

.if(*>io_base + $100) {
    .error "Build too long: $" + toHexString(*-io_base-$100, 4)
} else {
    .print ". . space remaining: $" + toHexString($100-(* - io_base), 4)
}

}
}
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant