# HG changeset patch # User tlindner # Date 1417412598 28800 # Node ID 6d81211487741105c6a9a22398680ebfc33849fe # Parent 1c7b7f93138a1d7a341be87739592cb429e29632 Added sdrive. diff -r 1c7b7f93138a -r 6d8121148774 3rdparty/utils/tlindner/makefile --- a/3rdparty/utils/tlindner/makefile Sun Nov 30 12:43:43 2014 -0800 +++ b/3rdparty/utils/tlindner/makefile Sun Nov 30 21:43:18 2014 -0800 @@ -2,7 +2,7 @@ DEPENDS = ./makefile -CMDS = snake sdir +CMDS = snake sdir sdrive ALLOBJS = $(CMDS) diff -r 1c7b7f93138a -r 6d8121148774 3rdparty/utils/tlindner/sdrive.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/utils/tlindner/sdrive.asm Sun Nov 30 21:43:18 2014 -0800 @@ -0,0 +1,372 @@ +******************************************************************** +* sdrive - Assign disk image to SDC slot +* +* $Id$ +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 1 2014/11/30 tim lindner +* Started writing code. + + nam sdrive + ttl Assign disk image to SDC slot + + ifp1 + use defsfile + endc + +* Here are some tweakable options +DOHELP set 1 1 = include help info +STACKSZ set 32 estimated stack size in bytes +PARMSZ set 256 estimated parameter size in bytes + +* Module header definitions +tylg set Prgrm+Objct +atrv set ReEnt+rev +rev set $00 +edition set 1 + +********************************************************************* +*** Hardware Addressing +********************************************************************* +CTRLATCH equ $FF40 ; controller latch (write) +CMDREG equ $FF48 ; command register (write) +STATREG equ $FF48 ; status register (read) +PREG1 equ $FF49 ; param register 1 +PREG2 equ $FF4A ; param register 2 +PREG3 equ $FF4B ; param register 3 +DATREGA equ PREG2 ; first data register +DATREGB equ PREG3 ; second data register +********************************************************************* +*** STATUS BIT MASKS +********************************************************************* +BUSY equ %00000001 +READY equ %00000010 +FAILED equ %10000000 + + mod eom,name,tylg,atrv,start,size + + org 0 +slot rmb 1 + +cleartop equ . everything up to here gets cleared at start +* Finally the stack for any PSHS/PULS/BSR/LBSRs that we might do + rmb STACKSZ+PARMSZ +size equ . + +* The utility name and edition goes here +name fcs /sdrive/ + fcb edition +* Place constant strings here +timeout fcc /Timeout./ + fcb C$LF + fcb C$CR +timeoutL equ *-timout + +targetInUse fcc /Target in use./ + fcb C$LF + fcb C$CR +targetInUseL equ *-targetInUse + +dirNotFound fcc /Directory not found./ + fcb C$LF + fcb C$CR +dirNotFoundL equ *-dirNotFound + +pathNameInvalid fcc /Pathname is invalid./ + fcb C$LF + fcb C$CR +pathNameInvalidL equ *-pathNameInvalid + +miscHardware fcc /Miscellaneous hardware error./ + fcb C$LF + fcb C$CR +miscHardwareL equ *-miscHardware + +unknown fcc /Unknown error./ + fcb C$LF + fcb C$CR +unknownL equ *-unknown + +targetNotFound fcc /Target not found./ + fcb C$LF + fcb C$CR +targetNotFoundL equ *-targetNotFound + + IFNE DOHELP +HlpMsg fcb C$LF + fcc /Use: sdrive / + fcb C$LF + fcb C$CR + fcc / is a number, either 0 or 1./ + fcb C$LF + fcb C$CR + fcc / is valid path and image name./ + fcb C$LF + fcb C$CR + fcc / can be blank to eject an image./ + fcb C$LF + fcb C$CR +HlpMsgL equ *-HlpMsg + ENDC +* +* Here's how registers are set when this process is forked: +* +* +-----------------+ <-- Y (highest address) +* ! Parameter ! +* ! Area ! +* +-----------------+ <-- X, SP +* ! Data Area ! +* +-----------------+ +* ! Direct Page ! +* +-----------------+ <-- U, DP (lowest address) +* +* D = parameter area size +* PC = module entry point abs. address +* CC = F=0, I=0, others undefined + +* The start of the program is here. +* main program +start + cmpd #1 + lbeq ShowHelp + subb #1 + sbca #0 + clr d,x put null at end of parameter area (not CR) + leas -3,s make some more room in parameter area + lbsr SkipSpcs + clr slot,u + lda ,x+ + cmpa #'0 + beq slot0 + cmpa #'1 + beq slot1 + lbra ShowHelp +slot1 inc slot,u +slot0 + lbsr SkipSpcs skip forward to parameter + leax -2,x back off two bytes +* Add M: to start of parameter + ldd #"M: + std ,x +* setup SDC for command mode + orcc #IntMasks mask interrupts + lbsr CmdSetup + bcc sendCommand + andcc #^IntMasks unmask interrupts + ldb #$f6 Not ready error code + lbra Exit +sendCommand + ldb #$e0 + orb slot,u + stb CMDREG send to SDC command register + exg a,a wait + lbsr txData transmit buffer to SDC + lda #$0 + sta CTRLATCH + andcc #^IntMasks unmask interrupts + bcc ExitOK + tstb + beq timeOutError + bitb #$20 + bne targetInUseError + bitb #$10 + bne targetNotFoundError + bitb #$08 + bne miscHardwareError + bitb #$04 + bne pathNameInvalidError + bra unknownError +targetInUseError + ldy #targetInUseL + leax targetInUse,pc + bra wrtErr +targetNotFoundError + ldy #targetNotFoundL + leax targetNotFound,pc + bra wrtErr +miscHardwareError + ldy #miscHardwareL + leax miscHardware,pc + bra wrtErr +pathNameInvalidError + ldy #pathNameInvalidL + leax pathNameInvalid,pc + bra wrtErr +unknownError + ldy #unknownL + leax unknown,pc + bra wrtErr +timeOutError + ldy #timeoutL + leax timeout,pc +wrtErr lda #$2 + os9 I$Write + +ExitOK clrb +Exit + os9 F$Exit + +ShowHelp equ * + IFNE DOHELP + leax >HlpMsg,pcr point to help message + ldy #HlpMsgL get length + lda #$02 std error + os9 I$Write write it + ENDC + bra ExitOk + +* Stolen from BASIC09 +* Convert # in D to ASCII version (decimal) +L09BA pshs y,x,d Preserve End of data mem ptr,?,Data mem size + pshs d Preserve data mem size again + leay $0100,x Bump X up to $3000 + subd ,y Subtract value from table + bhs L09C6 No underflow, keep subtracting current power of 10 + addd ,y++ Restore to before underflow state + pshs d Preserve remainder of this power + ldd ,y Get next lower power of 10 + tfr x,d Promptly overwrite it with X (doesn't chg flags) + beq L09E6 If finished table, skip ahead + cmpd #$3000 Just went through once? + beq L09C1 Yes, reset X & do again +* lbsr L1373 Go save A @ [