From 8701131e1720fcf709cebb2ee941bde0827d6865 Mon Sep 17 00:00:00 2001 From: Antoine Vignau <34219772+antoinevignau@users.noreply.github.com> Date: Mon, 19 Jun 2023 15:45:09 +0200 Subject: [PATCH] AS WIP All my Applesqueezer code... --- .DS_Store | Bin 12292 -> 12292 bytes applesqueezer/cda/ascda.s | 484 +++++++++++++++++++++++++ applesqueezer/misc/AS.S | 216 ++++++++++++ applesqueezer/ramdisk/AS.DRIVER.S | 546 +++++++++++++++++++++++++++++ applesqueezer/ramdisk/AS.EQUATES.S | 102 ++++++ applesqueezer/sdcard/AS.EQUATES.S | 119 +++++++ applesqueezer/sdcard/ASSD.DRIVER.S | 398 +++++++++++++++++++++ applesqueezer/sdcard/devices.s | 288 +++++++++++++++ 8 files changed, 2153 insertions(+) create mode 100644 applesqueezer/cda/ascda.s create mode 100644 applesqueezer/misc/AS.S create mode 100644 applesqueezer/ramdisk/AS.DRIVER.S create mode 100644 applesqueezer/ramdisk/AS.EQUATES.S create mode 100644 applesqueezer/sdcard/AS.EQUATES.S create mode 100644 applesqueezer/sdcard/ASSD.DRIVER.S create mode 100644 applesqueezer/sdcard/devices.s diff --git a/.DS_Store b/.DS_Store index 952916f8e35ac826c5cedba8e024d88812bdc130..e853214c17b6387657faf9850a1995a164053f6c 100644 GIT binary patch delta 326 zcmZokXi1phFWSn$z`)GFAi%(o$B@mC%21h`pW-s{qVi+|9Trwbpd`y=19g>+Tf+Gn zeJ6*gubO;AT}YrH!!S5GKeqrV&A`y^z_6J|z?h%Wd^3;2O2&F#hD3$}Aj|=pR?JYy zPzt0|8LEJ|C?_3BA6PR39@V+|E-pzq`AI;99QE}rUY-g^9f54TI#OH=NYhe~G5La` l*5-4HNvt9;oiZ^2>keKz46=-6GmFMgmd&;*pP8^q0|3DxQ33z} delta 115 zcmZokXi1phFWSh!z`)GFAi%(o$B@cU%uvZtT#zyGqVi+|9Trwbpd`!WZ34=SB^$Sd z^E0|{z9C@DKk>mCM$64S3M&~WFI1A;+^3YpI&p%^WFCQ4Y;U{vI5IG7X3_Y`vU#tn IF%zmd0Ar6M%>V!Z diff --git a/applesqueezer/cda/ascda.s b/applesqueezer/cda/ascda.s new file mode 100644 index 0000000..e3bc051 --- /dev/null +++ b/applesqueezer/cda/ascda.s @@ -0,0 +1,484 @@ +* +* AppleSqueezer in 16-bit assembly +* +* (c) 2022, Niek van Suchtelen +* (a) 2022, Brutal Deluxe Software +* + + mx %00 + rel + typ $B9 ; CDA + dsk ascda.l + lst off + +*---------------------------- +* EQUATES +*---------------------------- + +verMAX = "1" +verMIN = "0" + +*---------- +* FIRMWARE +*---------- + +KBD = $c000 ; read a key +CLR80VID = $c00c ; switch to 40-col mode +SET80VID = $c00d ; switch to 80-col mode +CLRALTCHAR = $c00e ; alt char off +SETALTCHAR = $c00f ; alt char on +KBDSTROBE = $c010 ; reset the keyboard +RD80COL = $c018 ; bit 7=1 if 80-col mode +BTN0 = $c061 ; bit 7=1 if button 0 pressed + +*---------- +* TEXT +*---------- + +ptrSCREEN = $000400 + +fgNORMAL = $FFFF ; normal character display +fgINVERSE = $3F3F ; inverse character display + +mask3F = %00111111 ; $3F +mask7F = %01111111 ; $7f +mask80 = %10000000 ; $80 + +chrLARROW = $88 ; all +chrDARROW = $8a ; codes +chrUARROW = $8b ; of +chrRETURN = $8d ; the +chrRARROW = $95 ; authorized +chrESCAPE = $9b ; keys +chrSPACE = " " ; space +chrCHECK = 'D' ; the check mark + +*---------------------------- +* +* CODE - CDA HEADER +* +*---------------------------- + +entryCDA str 'AppleSqueezer GS' + adrl ptrOPEN ; call the open routine + adrl ptrCLOSE ; call (do nothing) on the close routine + +*---------------------------- + +ptrOPEN phb ; save the bank + phk ; our bank please + plb + + jsr doCODE ; do the code + + plb ; restore the bank +ptrCLOSE rtl ; and return + +*---------------------------- +* +* CODE - THE CDA CODE +* +*---------------------------- + +doCODE php + sei + + sep #$20 ; switch to native 8-bit mode + stal CLR80VID ; we want 40-col, please + stal SETALTCHAR ; w/alternate character set + rep #$20 + + jsr drawFRAME ; show the frame window + + ldal BTN0-1 ; we enter the CDA + bmi doCODE1 ; if open-apple is pressed + +* jsr isAppleSqueezer ; is AS present? +* beq doCODE1 ; yes, we have one + + jmp doNOCARD ; we don't have one, go purchase one! + +doCODE1 bit loadValues ; we get the parms on entry + +debug lda #%00000000_00000011 + sta data + + jsr getVALUES ; transform from data + jsr doMAIN ; go to the main menu + jsr setVALUES ; move back to data + bit storeValues ; we set the parms on exit + +doQUIT plp + rts ; and return + +*---------------------------- +* CODE - TEXT SUB-ROUTINES +*---------------------------- + +doMAIN lda #fgNORMAL + sta INVFLG + + jsr showALLSTR ; print all menus + jsr showALLED ; print all enabled/disabled states + jmp readKEY + +*----------- +* Enable / Disable a value +* +* Input: +* A: menu index to change state + +changeSTATE asl ; menu + tax + lda valACCEL,x + eor #1 ; on/off + sta valACCEL,x + jsr (ptrSHOW,x) + rts + +ptrSHOW da showACCEL,showBIRAM,showEXRAM + +*----------- +* Transform data into 0/1 values + +getVALUES lda data + tax + and #%00000000_00000001 + sta valACCEL + + txa + and #%00000000_00000010 + lsr + sta valBIRAM + + txa + and #%00000000_00000100 + lsr + lsr + sta valEXRAM + rts + +*----------- +* Pack values into data + +setVALUES lda valACCEL + sta data + + lda valBIRAM + asl + ora data + sta data + + lda valEXRAM + asl + asl + ora data + sta data + rts + +*----------- +* Show all Strings + +showSACCEL lda #strACCEL ; show acceleration string + ldx #4 + ldy #5 + jmp printSTR + +showSBIRAM lda #strBIRAM ; show built-in ram string + ldx #4 + ldy #6 + jmp printSTR + +showALLSTR jsr showSACCEL ; shows the three entries + jsr showSBIRAM ; goes below + +showSEXRAM lda #strEXRAM ; show extra ram state + ldx #4 + ldy #7 + jmp printSTR + +*----------- +* Show all Enabled/Disabled values + +showACCEL lda valACCEL ; show acceleration state + ldx #18 + ldy #5 + jmp printED + +showBIRAM lda valBIRAM ; show built-in ram state + ldx #18 + ldy #6 + jmp printED + +showALLED jsr showACCEL ; show the three entries + jsr showBIRAM ; goes below + +showEXRAM lda valEXRAM ; show extra ram state + ldx #18 + ldy #7 ; goes below + +*----------- +* print Enabled/Disabled +* +* Input: +* A: bit to test +* X: x-coord to print +* Y: y-coord to print + +printED jsr TABV + lsr ; move bit 0 in carry + bcc printDIS + lda #strENABLED ; it is 1 + jmp printCSTR +printDIS lda #strDISABLED ; it is 0 + jmp printCSTR + +*---------- +* TABV +* +* Input: +* A: not used +* X: x-coord +* Y: y-coord +* Output: +* A: preserved +* X/Y: scrambled +* dpTO: ptr to screen +* + +TABV pha + stx CH + sty CV + + tya + asl + tay + lda ptrTEXT,y + clc + adc CH + sta patchSTR1+1 + sta patchSTR2+1 + pla + rts + +*----------- +* print String with Tabulation +* +* Input: +* A: string pointer +* X: x-coord to print +* Y: y-coord to print + +printSTR jsr TABV ; goes below + +*---------- +* printCSTR +* +* Input: +* A/X/Y: not used +* INVFLG: normal or inverse +* Output: +* A/X/Y: scrambled +* + +printCSTR tay ; pointer to source text + bit INVFLG ; shall we output + bpl printCINV ; in inverse mode? + + ldx #0 ; no, standard + sep #$20 +]lp lda |$0000,y ; upper/lower chars + beq printCSTR1 +patchSTR1 stal ptrSCREEN,x + inx + iny + bne ]lp +printCSTR1 rep #$20 + rts + +printCINV ldx #0 ; yes, print in inverse + sep #$20 +]lp lda |$0000,y + beq printCINV4 + cmp #"a" + bcc printCINV2 + and #mask7F ; mask %01111111 + hex 2c +printCINV2 and #mask3F ; mask %00111111 +patchSTR2 stal ptrSCREEN,x ; for uppercase + inx + iny + bne ]lp +printCINV4 rep #$20 + rts + +*---------- +* drawFRAME +* +* Input: +* A/X/Y: not used +* Output: +* A/X/Y: scrambled +* + +drawFRAME ldx #40-2 ; show strings +]lp lda strHEADER,x + stal $400,x + lda strHEADER+40,x + stal $480,x + lda strHEADER+80,x + stal $500,x + + lda strLINE,x + stal $580,x + stal $600,x + stal $680,x + stal $700,x + stal $780,x + stal $428,x + stal $4a8,x + stal $528,x + stal $5a8,x + stal $628,x + stal $6a8,x + stal $728,x + stal $7a8,x + stal $450,x + stal $4d0,x + stal $550,x + stal $5d0,x + stal $650,x + stal $6d0,x + + lda strFOOTER,x + stal $750,x + lda strFOOTER+40,x + stal $7d0,x + + dex + dex + bpl ]lp + rts + +*---------- +* readKEY +* checkUPDOWN +* +* Input: +* A/X/Y: not used +* Output: +* A: key pressed +* X/Y: unchanged +* + +readKEY sep #$20 +]lp ldal KBD ; wait for a key + bpl ]lp + stal KBDSTROBE + + cmp #chrLARROW + beq readKEYOK + cmp #chrDARROW + beq readKEYOK + cmp #chrUARROW + beq readKEYOK + cmp #chrRETURN + beq readKEYOK + cmp #chrRARROW + beq readKEYOK + cmp #chrESCAPE + bne ]lp +readKEYOK rep #$20 + rts + +*---------------------------- +* No card page +*---------------------------- + +doNOCARD ldx #40-2 +]lp lda strNOAS,x ; no card detected!!!! + stal $5a8,x + dex + dex + bpl ]lp + + jsr readKEY ; Wait for a key + jmp doQUIT ; exit!!! + +*---------------------------- +* DATA - ALL THE DATA +*---------------------------- + +*---------- +* STRINGS +*---------- +* asc "0 1 2 3 " +* asc "0123456789012345678901234567890123456789" + +strHEADER asc " ______________________________________ " ; line 0 + asc 'Z' ; line 1 + asc " AppleSqueezer " + asc ' _' + asc 'ZLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL_' ; line 2 + +strLINE asc 'Z' ; all other lines + asc " " + asc '_' + +strFOOTER asc 'Z' ; line 22 + asc " Select: " + asc 'H' + asc " " + asc 'U' + asc " " + asc 'J' + asc " " + asc 'K' + asc " Cancel:Esc Open: " + asc 'M' + asc " " + asc '_' + asc " " ; line 23 + asc 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL' + asc " " + +strNOAS asc 'Z' + asc " No AppleSqueezer detected! " + asc '_' + +*--- Strings + +strACCEL asc "Acceleration:"00 +strBIRAM asc "Built-in RAM:"00 +strEXRAM asc "Extra RAM :"00 + +strENABLED asc "Enabled"00 +strDISABLED asc "Disabled"00 + +valACCEL ds 2 +valBIRAM ds 2 +valEXRAM ds 2 + +theMENU ds 2 ; default entry is 0 + +*--- Coordinates +* +*strCOORDX dfb 8,8,8 +*strCOORDY dfb 5,6,7 +* +*optCOORDX dfb 23,23,23 +*optCOORDY dfb 5,6,7 +* +*---------- + +ptrTEXT dw $400,$480,$500,$580,$600,$680,$700,$780 + dw $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8 + dw $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0 + +CH ds 2 ; $00 - 2 - cursor horizontal position +CV ds 2 ; $01 - 2 - cursor vertical position +INVFLG dw $ffff ; $02 - 2 - 7F: inverse, FF: normal + +*---------- The low-level routines + + put as.s diff --git a/applesqueezer/misc/AS.S b/applesqueezer/misc/AS.S new file mode 100644 index 0000000..bbd6899 --- /dev/null +++ b/applesqueezer/misc/AS.S @@ -0,0 +1,216 @@ +* +* AppleSqueezer in 16-bit assembly +* +* (c) 2022, Niek van Suchtelen +* (a) 2022, Brutal Deluxe Software +* + + mx %00 + lst off + +*----------------------------------- +* SPI FLASH OPERATIONS +*----------------------------------- + +*----------- +isAppleSqueezer + ldal FL_IDLE + and #$ff + cmp #TRUE ; if AS is present + rts + +*----------- +coreVersion + ldal FL_VERSION + and #$ff + rts + +*----------- +chipSelect + sep #$20 ; 8-bit A + stal FL_CS + rep #$20 ; 16-bit A + rts + +*----------- +waitIdle + ldal FL_IDLE + and #$ff + beq waitIdle + rts + +*----------- +waitReadReady + ldal FL_READY + and #$ff + beq waitReadReady + rts + +*----------- +flashWrite + sep #$20 ; 8-bit A + stal FL_WRITE + rep #$20 ; 16-bit A + jmp waitIdle + +*----------- +flashRead + jsr waitIdle + sep #$20 + lda #0 + stal FL_READ_REQUEST + rep #$20 + jsr waitIdle + jsr waitReadReady + + ldal FL_READ + and #$ff + rts + +*----------- +writeEnable + lda #0 + jsr chipSelect + lda #CMD_WRITE_ENABLE + jsr flashWrite + lda #1 + jmp chipSelect + +*----------- +* before sectorErase, call writeEnable +sectorErase + lda #0 + jsr chipSelect + lda #CMD_SECTOR_ERASE + jsr flashWrite + lda #$0f ; sector 15: 000F 0000 - 000F EFFF + jsr flashWrite + lda #0 + jsr flashWrite + lda #0 + jsr flashWrite + lda #1 + jmp chipSelect + +*----------- +* before bulkErase, call writeEnable +bulkErase + lda #0 + jsr chipSelect + lda #CMD_BULK_ERASE + jsr flashWrite + lda #1 + jmp chipSelect + +*----------- +* before pageProgramSingle, call writeEnable +pageProgramSingle + pha ; save data + + lda #0 + jsr chipSelect + lda #CMD_PAGE_PROGRAM + jsr flashWrite + +* address + lda #$0f ; sector 15: 000F 0000 - 000F EFFF + jsr flashWrite + lda #0 + jsr flashWrite + lda #0 + jsr flashWrite + +* data + pla ; restore data + jsr flashWrite + + lda #1 + jmp chipSelect + +*----------- TO DO - Use the stack I think +* before pageProgram, call writeEnable +pageProgram + rts + +*----------- +readStateRegister + lda #0 + jsr chipSelect + lda #CMD_READ_STATUS_REGISTER + jsr flashWrite + jsr flashRead + pha + lda #1 + jsr chipSelect + pla + rts + +*----------- +writeInProgress + jsr readStateRegister ; WIP - write in progress bit + and #%00000000_00000001 ; if 1, write is in progress + cmp #TRUE + rts ; return TRUE if write is in progress + +*----------- +writeEnabled + jsr readStateRegister ; WEL - write enable latch bit + and #%00000000_00000010 ; if 1, write is enabled + lsr ; move bit 1 in bit 0 for comparison + cmp #TRUE + rts ; return TRUE is write is enabled + +*----------- +readDataBytes + pha ; save address + lda #0 + jsr chipSelect + lda #CMD_READ_DATA_BYTES + jsr flashWrite + +* address + lda #$0f ; sector 15: 000F 0000 - 000F EFFF + jsr flashWrite + lda #0 + jsr flashWrite + pla ; restore address + jsr flashWrite + +* read data + jsr flashRead + pha + lda #1 + jsr chipSelect + pla + rts + +*----------- +loadValues + lda #0 ; read byte at address $0F/0000 + jsr readDataBytes + sta data + rts + +*----------- +storeValues + jsr writeEnable +]lp jsr writeEnabled ; FALSE if not possible to write + bne ]lp + + jsr sectorErase +]lp jsr writeInProgress ; TRUE if write in progress + beq ]lp + + jsr writeEnable +]lp jsr writeEnabled ; FALSE if not possible to write + bne ]lp + + lda data + jsr pageProgramSingle ; CDA/NDA harmonization +]lp jsr writeInProgress ; TRUE if write in progress + beq ]lp + rts + +*----------- DATA + +data ds 2 \ No newline at end of file diff --git a/applesqueezer/ramdisk/AS.DRIVER.S b/applesqueezer/ramdisk/AS.DRIVER.S new file mode 100644 index 0000000..4579835 --- /dev/null +++ b/applesqueezer/ramdisk/AS.DRIVER.S @@ -0,0 +1,546 @@ +* +* AppleSqueezer RAMDISK +* +* +* (c) 2022, Brutal Deluxe Software +* + +* v1.0 (20230104) - AV +* Works on a single 32MB partition only +* v1.1 (20230105) - AV +* Adds support for formatting options (Hello HFS) + + mx %00 + rel + typ $bb + dsk ASRamdisk + + use AS.EQUATES.S + + use 4/Sch.Macs + use 4/Util.Macs + +* +* Entry point +* + +RAMDisk da MyDIB-RAMDisk ; offset to 1st DIB + dw maxIMAGES ; number of devices + dw $0000 ; no configuration list + +* +* Dispatch routine +* + +entryPOINT phk ; Dispatch + plb + cmp #$0009 + bcc L0012 + lda #$0020 + bra L001D +L0012 asl + tax + stz errCODE + jsr (tblDISPATCH,x) + lda errCODE +L001D cmp #$0001 + rtl + +tblDISPATCH da DStartup ; Driver_Startup + da DOpen ; Driver_Open + da DRead ; Driver_Read + da DWrite ; Driver_Write + da DClose ; Driver_Close + da DStatus ; Driver_Status + da DControl ; Driver_Control + da DFlush ; Driver_Flush + da DShutdown ; Driver_Shutdown + +* +* Driver_Startup +* + +DStartup + ldal FL_IDLE + and #$ff + cmp #$01 + bne DShutdown ; no AS found + + ldal FL_VERSION + and #$ff + cmp #minVERSION + bcc DShutdown ; no minimum version + + lda #1 ; we're on + sta fgSTARTED + + sep #$30 + ldx #0 +]lp lda proDEVNAME+3,x + sta MyDevName+1,x + inx + cpx #9 + bcc ]lp + stx MyDevName + rep #$30 + + PushWord #0 + PushLong #myTASK + _SchAddTask + pla + rts + +* +* Driver_Shutdown +* + +DShutdown stz fgSTARTED + +* +* Driver_Open +* Driver_Close +* Driver_Flush +* + +DOpen ; Driver_Open +DClose ; Driver_Close +DFlush ; Driver_Flush + rts + +* +* Driver_Read +* + +DRead jsr doSETUP + bcc dr1 + rts + +*--- The AS magic is here + +dr1 pei bufferPtr+1 ; save pointer + + sep #$20 + lda thePAGE+2 + stal exdram_address_set_main_bank + lda #0 + stal exdram_address_set_addr_low + lda thePAGE + stal exdram_address_set_addr_high + lda thePAGE+1 + stal exdram_address_set_addr_bank + + ldx nbPAGES ; number of 512-byte pages to copy +dr2 ldy #0 ; read one block + sep #$20 +]lp ldal exdram_address_access + sta [bufferPtr],y + iny + cpy #blockSIZE + bcc ]lp + + rep #$20 ; move destination pointer + lda bufferPtr+1 + clc + adc #>blockSIZE ; rwBlockSize+1 + sta bufferPtr+1 + + dex ; next block + bne dr2 + + pla ; restore pointer + sta bufferPtr+1 + rts + +*--- The AS magic ends here + +* +* Driver_Write +* + +DWrite jsr doSETUP + bcc dw1 + rts + +*--- The AS magic is here + +dw1 pei bufferPtr+1 ; save pointer + + sep #$20 + lda thePAGE+2 + stal exdram_address_set_main_bank + lda #0 + stal exdram_address_set_addr_low + lda thePAGE + stal exdram_address_set_addr_high + lda thePAGE+1 + stal exdram_address_set_addr_bank + + ldx nbPAGES ; number of 512 bytes pages to copy +dw2 ldy #0 ; write one block + sep #$20 +]lp lda [bufferPtr],y + stal exdram_address_access + iny + cpy #blockSIZE + bcc ]lp + + rep #$20 ; move destination pointer + lda bufferPtr+1 + clc + adc #>blockSIZE ; rwBlockSize+1 + sta bufferPtr+1 + + dex ; next page + bne dw2 + + pla ; restore pointer + sta bufferPtr+1 + rts + +*--- The AS magic ends here + +* +* Driver_Status +* + +DStatus lda statusCode + cmp #4+1 + bcc DStatus1 + lda #$0021 ; drvrBadCode + sta errCODE + rts + +DStatus1 asl + tax + stz transferCount + stz transferCount+2 + jsr (tblSTATUS,x) + rts + +tblSTATUS da SGetStatus ; GetDeviceStatus + da SGet ; GetConfigParameters + da SGet ; GetWaitStatus + da SGetFormatOptions ; GetFormatOptions + da SNada ; GetPartitionMap + +SNada rts + +*----------- GetDeviceStatus + +SGetStatus lda #2 ; GetDeviceStatus + sta transferCount + + lda requestCount ; check length of buffer + cmp #6 + bcc SGS1 + lda #6 + sta transferCount + + ldy #2 ; we can send the number of blocks + lda #maxBLOCKH + sta [statusListPtr],y + iny + iny + lda #^maxBLOCKH + sta [statusListPtr],y + +SGS1 ldx #diskInDriveBit + lda fgSTARTED ; send the status of the driver + bne SGS2 + inx +SGS2 txa + ora #uncertainBlockCountBit ; we are uncertain of the block count + sta [statusListPtr] + rts + +*----------- GetConfigParameters / GetWaitStatus + +SGet lda #0 ; GetConfigParameters + sta [statusListPtr] ; GetWaitStatus + lda #2 + sta transferCount + rts + +*----------- GetFormatOptions + +SGetFormatOptions + lda requestCount ; check size of buffer + cmp #formatOptionsTableEnd-formatOptionsTable + bcc SGetFormat1 + + ldy #0 ; and move data +]lp lda formatOptionsTable,y + sta [statusListPtr],y + iny + iny + cpy #formatOptionsTableEnd-formatOptionsTable + bcc ]lp + sty transferCount ; save size + +SGetFormat1 rts + +* +* Driver_Control +* + +DControl jsr checkSWITCHED + bcc DControl1 + rts + +DControl1 lda controlCode + cmp #9+1 + bcc DControl2 + + lda #$0021 + sta errCODE + rts + +DControl2 asl + tax + stz transferCount + stz transferCount+2 + jsr (tblCONTROL,x) + rts + +tblCONTROL da CNada ; 0 ResetDevice + da CFormatDevice ; 1 FormatDevice + da CNada ; 2 EjectMedium + da CSet ; 3 SetConfigParameters + da CSet ; 4 SetWaitStatus + da CSetFormatOptions ; 5 SetFormatOptions + da CNada ; 6 AssignPartitionOwner + da CNada ; 7 ArmSignal + da CNada ; 8 DisarmSignal + da CNada ; 9 SetPartitionMap + +CNada rts + +*----------- FormatDevice + +CFormatDevice + lda fgFORMAT ; if 1, the Format call + bne CFormat1 ; was already called + rts + +CFormat1 lda #0 + sep #$20 + stal exdram_address_set_main_bank + stal exdram_address_set_addr_low + stal exdram_address_set_addr_high + stal exdram_address_set_addr_bank + + ldx fBlockCount+2 + ldy fBlockCount +CFormat2 phx +CFormat3 ldx #blockSIZE ; 512-byte blocks +]lp stal exdram_address_access + dex + bne ]lp + dey ; loop fBlockCount + bne CFormat3 + plx ; loop fBlockCount+2 + dex + bne CFormat2 + rep #$20 + rts + +*----------- SetFormatOptions + +CSetFormatOptions + lda [controlListPtr] + beq CSFO9 ; empty option is not ours + cmp #3 ; 1-2 only + bcs CSFO9 + + cmp #1 + bne CSFOHFS + + ldx #^maxBLOCKH ; it is 1, default values for HFS + ldy #maxBLOCKH + bra CSFOAll + +CSFOHFS ldx #^maxBLOCKP ; it is 2, default values for ProDOS + ldy #maxBLOCKP + +CSFOAll sty fBlockCount + stx fBlockCount+2 + +CSFO9 rts + +*----------- SetConfigParameters / SetWaitStatus + +CSet lda [controlListPtr] ; SetConfigParameters + bne CSetERR ; SetWaitStatus + rts +CSetERR lda #$0022 + sta errCODE + rts + +*---------------------------- + +* Status flag of the current device +* $0001: image has been switched (disk switched) +* $0010: image is active (disk in drive) +* $0100: image has been modified + +* +* Checks everything is OK +* + +doSETUP jsr checkSWITCHED + bcc ds2 + rts + +ds2 lda requestCount ; nb of bytes to read + ora requestCount+2 + bne ds4 + + lda #$002C ; invalidByteCount + sta errCODE + sec + rts + +*--- From a Block to a RAM address + +ds4 lda blockNum ; get block number + asl + sta thePAGE ; to calculate + lda blockNum+2 ; RAM address + rol + sta thePAGE+2 + + lda requestCount+1 ; number of pages + lsr + sta nbPAGES ; to calculate + + lda requestCount ; multiple of $0200 + and #blockSIZE-1 + beq ds6 + + lda #$002D ; bad block count + sta errCODE + sec + rts + +*--- Generic transfer now + +ds6 lda requestCount ; assume transfer=request + sta transferCount + lda requestCount+2 + sta transferCount+2 + + clc + rts + +*---------------------------- + +checkSWITCHED + lda fgSTARTED + bne cs1 + + jsl SET_DISKSW + + lda #1 + sta fgSTARTED + lda #$002e + sta errCODE + sec + rts + +cs1 clc + rts + +*---------------------------- Check RAMDISK was init'ed + +myTASK PushLong #proVOLUME + PushWord #$2008 + jsl GSOS2 + bcc myTASK1 + + PushLong #proFORMAT + PushWord #$2024 + jsl GSOS2 + + lda #1 ; tell the driver we've been there + stal fgFORMAT ; a format will now be a real format + + lda #$4000 ; no more silent formatting + stal proFORMAT+14 + +myTASK1 rtl + +*---------------------------- GS/OS + +proVOLUME dw 2 + adrl proDEVNAME + adrl outVOLNAME + +proFORMAT dw 5 ; +00 + adrl proDEVNAME ; +02 + adrl proVOLNAME ; +06 + dw 6 ; +10 + dw 6 ; +12 - Default is ProDOS + dw $2000 ; +14 - Cant rename, can change selection, silent formatting + +proDEVNAME strl '.ASRAMDISK' +proVOLNAME strl ':AppleSqueezer' + +outVOLNAME dw 36 ; (word) output buffer + ds 34 ; (word) strl + (array) string + +*---------------------------- + + +formatOptionsTable + +* 8 bytes + dw 2 ; numOptions + dw 2 ; numDisplayed + dw 1 ; recommendedOption + dw 1 ; currentOption + +* 16 bytes + dw 1 ; formatOptionNum + dw 2 ; linkRefNum + dw 9 ; flags 1001 - MB size - Apple format + adrl maxBLOCKH ; blockCount is 491520 for HFS + dw blockSIZE ; blockSize is 512 bytes + dw 0 ; interleaveFactor + dw 240 ; mediaSize 1000 - MB size + +* 16 bytes + dw 2 ; formatOptionNum + dw 0 ; linkRefNum + dw 9 ; flags 1001 - MB size - Apple format + adrl maxBLOCKP ; blockCount is 65536 for ProDOS 8 + dw blockSIZE ; blockSize is 512 bytes for ProDOS 8 + dw 0 ; interleaveFactor + dw 32 ; mediaSize 1000 - MB size + +formatOptionsTableEnd + +*--- Default formatting options + +fBlockCount adrl maxBLOCKH ; 65536 + +*---------------------------- + +fgSTARTED ds 2 ; 0: not started, 1: started +fgFORMAT ds 2 ; 0: GS/OS Format never called, 1 instead +errCODE ds 2 +thePAGE ds 4 ; page to read/write: $hh/ll00 +nbPAGES ds 2 ; number of blockSIZEP pages to copy + +MyDIB ds 4 ; +00 pointer to the next DIB + adrl entryPOINT ; +04 driver entry point + dw dftCHAR ; +08 characteristics + adrl maxBLOCKH ; +0A block count +MyDevName ds 32 ; +0E device name + dw $8000 ; +2E slot number + dw $0001 ; +30 unit number + dw dftVERSION ; +32 version + dw dftRAMDISK ; +34 device ID + dw $0000 ; +36 first linked device + dw $0000 ; +38 next linked device + adrl $00000000 ; +3A extended DIB ptr + dw $0000 ; +3E device number diff --git a/applesqueezer/ramdisk/AS.EQUATES.S b/applesqueezer/ramdisk/AS.EQUATES.S new file mode 100644 index 0000000..84e4d1c --- /dev/null +++ b/applesqueezer/ramdisk/AS.EQUATES.S @@ -0,0 +1,102 @@ +* +* MountIt: equates +* +* (c) 2009, Brutal Deluxe Software +* + +*----------------------------------- +* APPLESQUEEZER EQUATES +*----------------------------------- + +* data +* bit 0: 1 if Acceralation is enabled +* bit 1: 1 if Built-RAM is enabled +* bit 2: 1 if Extra RAM is enabled +* bit 3-7: values unknown + +FL_WRITE = $e20000 +FL_READ_REQUEST = $e20002 +FL_READ = $e20004 +FL_CS = $e20006 +FL_READY = $e20008 +FL_IDLE = $e2000a +FL_VERSION = $e2000c + +CMD_WRITE_ENABLE = $06 +CMD_WRITE_DISABLE = $04 +CMD_PAGE_PROGRAM = $02 +CMD_SECTOR_ERASE = $d8 +CMD_BULK_ERASE = $c7 +CMD_READ_DATA_BYTES = $03 +CMD_READ_STATUS_REGISTER = $05 + +exdram_address_set_main_bank = $e30000 ; 00..0E +exdram_address_set_addr_low = $e30002 ; 00/00xx +exdram_address_set_addr_high = $e30004 ; 00/xx00 +exdram_address_set_addr_bank = $e30006 ; xx/0000 +exdram_address_access = $e30008 ; R/W auto-increment to end of main bank + +TRUE = 1 +FALSE = 0 + +minVERSION = 7 ; minimum core version to handle the driver + +*----------------------------------- +* GS/OS EQUATES +*----------------------------------- + +GSOS2 = $E100B0 +MOVE_INFO = $01FC70 +SET_DISKSW = $01FC90 + +uncertainBlockCountBit = $8000 +diskSwitchedBit = $0001 +diskInDriveBit = $0010 +diskModifyBit = $0100 + +dftRAMDISK = $000e ; device ID for RAM/ROM disks + +dchar = $08 +dblockcount = $0a +ddeviceid = $34 +ddevnumber = $3e + +*----------------------------------- +* AS DRIVER EQUATES +*----------------------------------- + +maxIMAGES = 1 ; no more than N images +blockSIZE = 512 ; ProDOS 8 block size +maxBLOCKP = 65536 ; 65536 blocks for ProDOS 8 +maxBLOCKH = 491520 ; 491520 blocks for HFS + +* 8 1000 => 8 1000 RAM or ROM disk +* B 1011 => B 1011 restartable + not speed dependent +* E 1110 => E 1110 block device | write allowed | read allowed +* 8 1000 => 8 1000 format allowed + +dftCHAR = $8BE8 ; default characteristics 8FE8 + +dftVERSION = $1000 ; v1 + +*----------------------------------- +* GS/OS DIRECT PAGE +*----------------------------------- + +deviceNum = $00 +callNum = $02 +bufferPtr = $04 +statusListPtr = $04 +controlListPtr = $04 +requestCount = $08 +transferCount = $0C +blockNum = $10 +blockSize = $14 +FSTNum = $16 ; * +statusCode = $16 ; * +controlCode = $16 ; * +volumeID = $18 +cachePriority = $1A +cachePointer = $1C +dibPointer = $20 + diff --git a/applesqueezer/sdcard/AS.EQUATES.S b/applesqueezer/sdcard/AS.EQUATES.S new file mode 100644 index 0000000..853a39d --- /dev/null +++ b/applesqueezer/sdcard/AS.EQUATES.S @@ -0,0 +1,119 @@ +* +* AppleSqueezer - Equates +* +* (c) 2023, Niek Van Suchtelen +* (c) 2023, Brutal Deluxe Software +* + +*----------------------------------- +* APPLESQUEEZER EQUATES +*----------------------------------- + +* data +* bit 0: 1 if Acceralation is enabled +* bit 1: 1 if Built-RAM is enabled +* bit 2: 1 if Extra RAM is enabled +* bit 3-7: values unknown + +FL_WRITE = $e20000 +FL_READ_REQUEST = $e20002 +FL_READ = $e20004 +FL_CS = $e20006 +FL_READY = $e20008 +FL_IDLE = $e2000a +FL_VERSION = $e2000c + +CMD_WRITE_ENABLE = $06 +CMD_WRITE_DISABLE = $04 +CMD_PAGE_PROGRAM = $02 +CMD_SECTOR_ERASE = $d8 +CMD_BULK_ERASE = $c7 +CMD_READ_DATA_BYTES = $03 +CMD_READ_STATUS_REGISTER = $05 + +exdram_address_set_main_bank = $e30000 ; 00..0E +exdram_address_set_addr_low = $e30002 ; 00/00xx +exdram_address_set_addr_high = $e30004 ; 00/xx00 +exdram_address_set_addr_bank = $e30006 ; xx/0000 +exdram_address_access = $e30008 ; R/W auto-increment to end of main bank + +SD_ADDRESS_SET_MSB = $e40000 +SD_ADDRESS_SET_MSB_1 = $e40002 +SD_ADDRESS_SET_MSB_2 = $e40004 +SD_ADDRESS_SET_MSB_3 = $e40006 +SD_START_READ = $e40008 ; starts reading the sector (if it was idle) +SD_ACCESS = $e4000a +SD_START_WRITE = $e4000c ; starts writing the sector (if it was idle) + +STA_NOINIT = 1 ; Drive not initialized +STA_NODISK = 2 ; No medium in the drive + +TRUE = 1 +FALSE = 0 + +minVERSION = 7 ; minimum core version to handle the driver + +*--- Speed settings +* From 233 (3 MHz) to 255 (full speed) +* Setting is not preserved + +AS_SPEED = $e50000 ; just write a speed byte + +*----------------------------------- +* GS/OS EQUATES +*----------------------------------- + +GSOS2 = $E100B0 +MOVE_INFO = $01FC70 +SET_DISKSW = $01FC90 + +uncertainBlockCountBit = $8000 +diskSwitchedBit = $0001 +diskInDriveBit = $0010 +diskModifyBit = $0100 + +dftHDD = $0013 ; device ID for HDD (generic) + +dchar = $08 +dblockcount = $0a +ddeviceid = $34 +ddevnumber = $3e + +*----------------------------------- +* AS DRIVER EQUATES +*----------------------------------- + +maxIMAGES = 1 ; no more than N images +blockSIZE = 512 ; ProDOS 8 block size +maxBLOCKS = $ffffffff ; that is a huge number of blocks + +* 0 0000 => 0 0000 +* B 1011 => B 1011 restartable + not speed dependent +* A 1010 => E 1110 block device | write allowed | read allowed +* 0 0000 => 8 1000 format allowed + +dftCHAR = $0BA8 ; default characteristics 0BA8 + +dftVERSION = $1000 ; v1 + +*----------------------------------- +* GS/OS DIRECT PAGE +*----------------------------------- + +deviceNum = $00 +callNum = $02 +bufferPtr = $04 +statusListPtr = $04 +controlListPtr = $04 +requestCount = $08 +transferCount = $0C +blockNum = $10 +blockSize = $14 +FSTNum = $16 ; * +statusCode = $16 ; * +controlCode = $16 ; * +volumeID = $18 +cachePriority = $1A +cachePointer = $1C +dibPointer = $20 + diff --git a/applesqueezer/sdcard/ASSD.DRIVER.S b/applesqueezer/sdcard/ASSD.DRIVER.S new file mode 100644 index 0000000..d437afb --- /dev/null +++ b/applesqueezer/sdcard/ASSD.DRIVER.S @@ -0,0 +1,398 @@ +* +* AppleSqueezer - SD Driver +* +* (c) 2023, Niek Van Suchtelen +* (c) 2023, Brutal Deluxe Software +* + +* v1.0 (202304) - AV +* Reads a sector +* Type must be $BB +* Auxtype must be $0101 +* +* v1.1 (202306) - AV +* Writes a sector too! +* + + mx %00 + rel + typ $bb + dsk ASSDDriver + + use AS.EQUATES.S + + use 4/Util.Macs + +*----------------------------------------------- + +* +* Entry point +* + +RAMDisk da MyDIB-RAMDisk ; offset to 1st DIB + dw maxIMAGES ; number of devices + dw $0000 ; no configuration list + +* +* Dispatch routine +* + +entryPOINT phk ; Dispatch + plb + cmp #$0009 + bcc L0012 + lda #$0020 + bra L001D +L0012 asl + tax + stz errCODE + jsr (tblDISPATCH,x) + lda errCODE +L001D cmp #$0001 + rtl + +tblDISPATCH da DStartup ; Driver_Startup + da DOpen ; Driver_Open + da DRead ; Driver_Read + da DWrite ; Driver_Write + da DClose ; Driver_Close + da DStatus ; Driver_Status + da DControl ; Driver_Control + da DFlush ; Driver_Flush + da DShutdown ; Driver_Shutdown + +* +* Driver_Startup +* + +DStartup + ldal FL_IDLE + and #$ff + cmp #$01 + bne DShutdown ; no AS found + + ldal FL_VERSION + and #$ff + cmp #minVERSION + bcc DShutdown ; no minimum version + + lda #1 ; we're on + sta fgSTARTED + rts + +* +* Driver_Shutdown +* + +DShutdown stz fgSTARTED + +* +* Driver_Open +* Driver_Close +* Driver_Flush +* + +DOpen ; Driver_Open +DClose ; Driver_Close +DFlush ; Driver_Flush + rts + +* +* Driver_Read +* + +DRead jsr doSETUP + bcc dr1 + rts + +*--- The AS magic is here + +dr1 pei bufferPtr+1 ; save pointer + + sep #$20 + lda blockNum+3 + stal SD_ADDRESS_SET_MSB + lda blockNum+2 + stal SD_ADDRESS_SET_MSB_1 + lda blockNum+1 + stal SD_ADDRESS_SET_MSB_2 + lda blockNum + stal SD_ADDRESS_SET_MSB_3 + + lda #1 + stal SD_START_READ + + ldx nbPAGES ; number of 512-byte pages to copy +dr2 ldy #0 ; read one block + sep #$20 +]lp ldal SD_ACCESS + sta [bufferPtr],y + iny + cpy #blockSIZE + bcc ]lp + + rep #$20 ; move destination pointer + lda bufferPtr+1 + clc + adc #>blockSIZE ; rwBlockSize+1 + sta bufferPtr+1 + + dex ; next block + bne dr2 + + pla ; restore pointer + sta bufferPtr+1 + rts + +*--- The AS magic ends here + +* +* Driver_Write +* + +DWrite jsr doSETUP + bcc dw1 + rts + +*--- The AS magic is here + +dw1 pei bufferPtr+1 ; save pointer + + sep #$20 + lda blockNum+3 + stal SD_ADDRESS_SET_MSB + lda blockNum+2 + stal SD_ADDRESS_SET_MSB_1 + lda blockNum+1 + stal SD_ADDRESS_SET_MSB_2 + lda blockNum + stal SD_ADDRESS_SET_MSB_3 + + lda #1 + stal SD_START_WRITE + + ldx nbPAGES ; number of 512-byte pages to copy +dw2 ldy #0 ; read one block + sep #$20 +]lp lda [bufferPtr],y + stal SD_ACCESS + iny + cpy #blockSIZE + bcc ]lp + + rep #$20 ; move destination pointer + lda bufferPtr+1 + clc + adc #>blockSIZE ; rwBlockSize+1 + sta bufferPtr+1 + + dex ; next block + bne dw2 + + pla ; restore pointer + sta bufferPtr+1 + rts + +*--- The AS magic ends here + +* +* Driver_Status +* + +DStatus lda statusCode + cmp #4+1 + bcc DStatus1 + lda #$0021 ; drvrBadCode + sta errCODE + rts + +DStatus1 asl + tax + stz transferCount + stz transferCount+2 + jsr (tblSTATUS,x) + rts + +tblSTATUS da SGetStatus ; GetDeviceStatus + da SGet ; GetConfigParameters + da SGet ; GetWaitStatus + da SGet ; GetFormatOptions + da SNada ; GetPartitionMap + +SNada rts + +*----------- GetDeviceStatus + +SGetStatus lda #2 ; GetDeviceStatus + sta transferCount + + lda requestCount ; check length of buffer + cmp #6 + bcc SGS1 + lda #6 + sta transferCount + + ldy #2 ; we can send the number of blocks + lda #maxBLOCKS + sta [statusListPtr],y + iny + iny + lda #^maxBLOCKS + sta [statusListPtr],y + +SGS1 ldx #diskInDriveBit + lda fgSTARTED ; send the status of the driver + bne SGS2 + inx +SGS2 txa + ora #uncertainBlockCountBit ; we are uncertain of the block count + sta [statusListPtr] + rts + +*----------- GetConfigParameters / GetWaitStatus + +SGet lda #0 ; GetConfigParameters + sta [statusListPtr] ; GetWaitStatus + lda #2 + sta transferCount + rts + +* +* Driver_Control +* + +DControl jsr checkSWITCHED + bcc DControl1 + rts + +DControl1 lda controlCode + cmp #9+1 + bcc DControl2 + + lda #$0021 + sta errCODE + rts + +DControl2 asl + tax + stz transferCount + stz transferCount+2 + jsr (tblCONTROL,x) + rts + +tblCONTROL da CNada ; 0 ResetDevice + da CNada ; 1 FormatDevice + da CNada ; 2 EjectMedium + da CSet ; 3 SetConfigParameters + da CSet ; 4 SetWaitStatus + da CSet ; 5 SetFormatOptions + da CNada ; 6 AssignPartitionOwner + da CNada ; 7 ArmSignal + da CNada ; 8 DisarmSignal + da CNada ; 9 SetPartitionMap + +CNada rts + +*----------- SetConfigParameters / SetWaitStatus + +CSet lda [controlListPtr] ; SetConfigParameters + bne CSetERR ; SetWaitStatus + rts +CSetERR lda #$0022 + sta errCODE + rts + +*---------------------------- + +* Status flag of the current device +* $0001: image has been switched (disk switched) +* $0010: image is active (disk in drive) +* $0100: image has been modified + +* +* Checks everything is OK +* + +doSETUP jsr checkSWITCHED + bcc ds2 + rts + +ds2 lda requestCount ; nb of bytes to read + ora requestCount+2 + bne ds4 + + lda #$002C ; invalidByteCount + sta errCODE + sec + rts + +* $0102_0400 = + +*--- requestcount : $0200 => 1 +*--- From a Block to a RAM address + +ds4 lda requestCount+3 ; number of pages + and #$00ff ; to calculate + lsr + lda requestCount+1 ; $01020400 => $010204 => $8102 + ror + sta nbPAGES ; to calculate + + lda requestCount ; multiple of $0200 + and #blockSIZE-1 + beq ds6 + + lda #$002D ; bad block count + sta errCODE + sec + rts + +*--- Generic transfer now + +ds6 lda requestCount ; assume transfer=request + sta transferCount + lda requestCount+2 + sta transferCount+2 + + clc + rts + +*---------------------------- + +checkSWITCHED + lda fgSTARTED + bne cs1 + + jsl SET_DISKSW + + lda #1 + sta fgSTARTED + lda #$002e + sta errCODE + sec + rts + +cs1 clc + rts + +*---------------------------- + +fgSTARTED ds 2 ; 0: not started, 1: started +errCODE ds 2 +thePAGE ds 4 ; page to read/write: $hh/ll00 +nbPAGES ds 2 ; number of blockSIZEP pages to copy + +MyDIB ds 4 ; +00 pointer to the next DIB + adrl entryPOINT ; +04 driver entry point + dw dftCHAR ; +08 characteristics + ds 4 ; +0A block count + str 'ASSDDevice' ; +0E device name + ds 21 ; 32 - 12 = 20 + dw $0000 ; +2E slot number + dw $0000 ; +30 unit number + dw dftVERSION ; +32 version + dw dftHDD ; +34 device ID + dw $0000 ; +36 first linked device + dw $0000 ; +38 next linked device + adrl $00000000 ; +3A extended DIB ptr + dw $0000 ; +3E device number diff --git a/applesqueezer/sdcard/devices.s b/applesqueezer/sdcard/devices.s new file mode 100644 index 0000000..81eabab --- /dev/null +++ b/applesqueezer/sdcard/devices.s @@ -0,0 +1,288 @@ +* +* Devices +* Show all connected devices +* +* (c) 2023, Brutal Deluxe Software +* Visit brutaldeluxe.fr +* + + xc + xc + mx %00 + + rel + dsk devices.l + lst off + +*---------- + + use 4/Int.Macs + use 4/Locator.Macs + use 4/Mem.Macs + use 4/Misc.Macs + use 4/Text.Macs + use 4/Util.Macs + +Debut = $00 +GSOS = $e100a8 + +*---------- + +dcREMOVE = $0004 +dcONLINE = $0010 +dcBLOCKDEVICE = $0080 + +maxDEVICES = 128 + +dcINQUIRY = $8012 +doMODESELECT = $8015 +dcMODESENSE6 = $801a +dcSTARTSTOP = $801b ; also eject/insert +dcREADCAPACITY = $8025 +dcSUBCHANNEL = $8042 +dcREADTOC = $8043 +dcPATI = $8048 +dcPAUSERESUME = $804b +dcMODESENSE10 = $805a + +*---------- + + phk + plb + + tdc + sta myDP + + _TLStartUp + pha + _MMStartUp + pla + sta appID + ora #$0100 + sta myID + + _MTStartUp + _TextStartUp + + _IMStartUp + + pha + pha + PushLong #$010000 + PushWord myID + PushWord #%11000000_00011100 + PushLong #0 + _NewHandle + phd + tsc + tcd + lda [3] + sta ptrBUFFER + ldy #2 + lda [3],y + sta ptrBUFFER+2 + pld + ply + sty haBUFFER + plx + stx haBUFFER+2 + +*---------- + + PushWord #$00FF + PushWord #$0080 + _SetInGlobals + PushWord #$00FF + PushWord #$0080 + _SetOutGlobals + PushWord #$00FF + PushWord #$0080 + _SetErrGlobals + + PushWord #0 + PushLong #3 + _SetInputDevice + PushWord #0 + PushLong #3 + _SetOutputDevice + PushWord #0 + PushLong #3 + _SetErrorDevice + + PushWord #0 + _InitTextDev + PushWord #1 + _InitTextDev + PushWord #2 + _InitTextDev + + PushWord #$0c ; home + _WriteChar + +*---------------------------- +* MAIN MENU +*---------------------------- + +mainMENU = * + + PushLong #strMAINMENU + _WriteCString + + jsr pollDEVICES ; show CD-ROM devices + jsr waitFORKEY ; is it 0-9 + jmp doQUIT + +*--- Data + +strMAINMENU asc 0d'Show devices'0d + asc '(c) 2023, Brutal Deluxe Software'0d00 + +*---------------------------- +* QUIT PROGRAM +*---------------------------- + +doQUIT _IMShutDown + _TextShutDown + _MTShutDown + + PushWord myID + _DisposeAll + + PushWord appID + _MMShutDown + + _TLShutDown + + jsl GSOS + dw $2029 + adrl proQUIT + + brk $bd + +*---------------------------- +* POLL DEVICES +*---------------------------- + +pollDEVICES lda #1 ; start with device 1 + sta proDINFO+2 + +]lp jsl GSOS ; do a DInfo + dw $202c + adrl proDINFO + bcc found + + cmp #$0011 ; no more devices + bne loop + rts + +loop inc proDINFO+2 + bra ]lp + +*---------- Show device + +found lda proDINFO+8 ; not removable + and #dcBLOCKDEVICE + beq loop + + jsr showDEVICEINFO + bra loop + +*--- Sub routines +* +* x - $xxxx - .NAMEOFDEVICE + +showDEVICEINFO + lda proDINFO+2 + pha ; from a word to a string + pha + pha + _HexIt + PullLong strDEVID + + PushLong #strDEV ; show the string + _WriteCString + +*--- characteristics + + lda proDINFO+8 + pha ; from a word to a string + pha + pha + _HexIt + PullLong strDEVID + + PushLong #strDEV ; show the string + _WriteCString + +*--- name + + lda devINFO1 ; from a STRL to a STR + xba + sta devINFO1 + + PushLong #devINFO2 + _WriteString + + PushWord #$0d + _WriteChar + rts + +*---------- Data + +strDEV asc '$' +strDEVID asc '0000 - '00 + +*---------------------------- +* TEXT ROUTINES +*---------------------------- + +*---------- Wait for a key + +waitFORKEY PushWord #0 ; wait for key + PushWord #1 ; echo char + _ReadChar + +waitKEY1 lda 1,s ; check CR + and #$ff ; of typed + sta 1,s ; in char + cmp #$8d + beq waitKEY9 + +waitKEY8 PushWord #$0d ; return + _WriteChar + +waitKEY9 pla ; restore entered char + rts + +*---------------------------- +* DATA +*---------------------------- + +proQUIT dw 2 ; pcount + ds 4 ; pathname + ds 2 ; flags + +proDINFO dw 8 ; Parms for DInfo + ds 2 ; 02 device num + adrl devINFO ; 04 device name + ds 2 ; 08 characteristics + ds 4 ; 0A total blocks + ds 2 ; 0E slot number + ds 2 ; 10 unit number + ds 2 ; 12 version + ds 2 ; 14 device id + +devINFO dw $0032 ; buffer size +devINFO1 db $00 ; length +devINFO2 db $00 +devINFO3 ds $30 ; data + +*---------- + +appID ds 2 +myID ds 2 + +myDP ds 2 +ptrBUFFER ds 4 +haBUFFER ds 4 +