diskcmd.s
1 ; CCGMS Terminal 2 ; 3 ; Copyright (c) 2016,2020, Craig Smith, alwyz. All rights reserved. 4 ; This project is licensed under the BSD 3-Clause License. 5 ; 6 ; Disk Command 7 ; 8 9 ;---------------------------------------------------------------------- 10 txt_diskcommand: 11 .byte WHITE,CR 12 .byte "#" 13 txt_diskcommand_devno: 14 .byte "**" 15 .byte "> " 16 .byte CSR_LEFT,CSR_LEFT,CSR_LEFT,CSR_LEFT,CSR_LEFT,CSR_LEFT,0 17 int2dectab: 18 .byte "8 " ; [XXX potential for optimization ($bdcd] 19 .byte "9 " 20 .byte "10" 21 .byte "11" 22 .byte "12" 23 .byte "13" 24 .byte "14" 25 .byte "15" 26 .byte "16" 27 .byte "17" 28 .byte "18" 29 .byte "19" 30 .byte "20" 31 .byte "21" 32 .byte "22" 33 .byte "23" 34 .byte "24" 35 .byte "25" 36 .byte "26" 37 .byte "27" 38 .byte "28" 39 .byte "29" 40 .byte "30" 41 42 ;---------------------------------------------------------------------- 43 handle_f5_diskcommand: 44 jsr disablexfer 45 jsr ercopn 46 jsr text_color_save 47 dskcmd 48 lda device_disk 49 sec 50 sbc #$08 51 asl a 52 tay 53 lda int2dectab,y 54 sta txt_diskcommand_devno 55 lda int2dectab+1,y 56 sta txt_diskcommand_devno+1 57 lda #<txt_diskcommand 58 ldy #>txt_diskcommand 59 ldx #36;1 - what does this do? limit length of command? 60 jsr input 61 beq drverr ; nothing entered, drive error code? 62 lda inpbuf 63 cmp #'#' ; drive 64 beq chgdev 65 jsr is_drive_present 66 bmi drvext 67 lda #CR ; exit 68 jsr chrout 69 lda inpbuf 70 cmp #'$' ; directory 71 bne drvsnd 72 lda max 73 ldx #<inpbuf 74 ldy #>inpbuf 75 jmp dodir 76 drvsnd 77 ldx device_disk 78 stx 612 ; dev# table, log#15 79 ldx #LFN_DISK_CMD 80 jsr chkout 81 ldx #0 82 drvlop 83 lda inpbuf,x 84 jsr chrout 85 inx 86 cpx max 87 bne drvlop 88 lda #CR 89 jsr chrout 90 drvext 91 jsr clrchn 92 jsr text_color_restore 93 lda #CR 94 jsr chrout 95 jsr enablexfer 96 jmp term_mainloop 97 drverr 98 jsr is_drive_present 99 bmi drvext 100 jsr clrchn 101 ldx #LFN_DISK_CMD 102 jsr chkin 103 drver2 104 jsr getin 105 drver3 106 jsr chrout 107 cmp #CR 108 bne drver2 109 beq drvext 110 111 ;---------------------------------------------------------------------- 112 chgdev: 113 ldy #1 114 ldx inpbuf,y 115 txa 116 sec 117 sbc #$30 118 beq chgdv2 ; if first char is 0 as in 08 or 09 119 cmp #$03 ; devices 10-29 "1x or 2x" 120 bpl chgdv8 ; might be 8 or 9.. anything over 3 doesnt count here so lets try and see if it matches 8 or 9. 121 clc ; definitely starts with 1 or 2 if it makes it this far 122 adc #$09 ; $0a-$0b for device starting with 1x or 2x, convert to hex 123 jmp chgdv2 124 chgdv8 125 cmp #$07 126 bpl chgdv9 ; assume its 8 or 9, which is the only options when it starts with 8 or 9 127 jmp drvext ; nope there was nothing in the 00-29 range 128 chgdv2 iny ; get the second character 129 sta drivetemp 130 lda inpbuf,y 131 sec 132 sbc #'0' ; decimal petscii to hex, again... 133 clc 134 adc drivetemp 135 chgdv9 136 cmp #8 ; lowest drive # (8) 137 bcc drvext 138 cmp #30 ; highest drive # (30) 139 bcs drvext 140 tay ;y now holds complete hex of drive # 141 lda device_disk 142 pha 143 sty device_disk 144 sty 612 145 jsr is_drive_present 146 bmi chgdv3 147 pla 148 lda #CSR_UP 149 jsr chrout 150 jmp dskcmd 151 chgdv3 152 pla 153 sta device_disk 154 sta 612 155 chgdv4 156 lda #' ' 157 jsr chrout 158 lda #'-' 159 jsr chrout 160 lda #' ' 161 jsr chrout 162 ldy #0 163 chgdv5 164 lda $a1d0,y ;device not present 165 php 166 and #$7f 167 jsr chrout 168 plp 169 bmi chgdv6 170 iny 171 bne chgdv5 172 chgdv6 173 jmp drvext