Rev 889 | Details | Compare with Previous | Last modification | View Log
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 574 | alone | 1 | strcp |
| 2 | ;hl=s1 |
||
| 3 | ;de=s2 |
||
| 4 | ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2) |
||
| 5 | strcp0. |
||
| 6 | ld a,[de] ;s2 |
||
| 7 | cp [hl] ;s1 |
||
| 8 | ret nz |
||
| 9 | inc hl |
||
| 10 | inc de |
||
| 11 | or a |
||
| 12 | jp nz,strcp0. |
||
| 13 | ret ;z |
||
| 14 | |||
| 646 | alone | 15 | dotname_to_cpmname |
| 16 | ;de -> hl |
||
| 17 | ;out: de=pointer to termination character |
||
| 18 | ;push hl ;buffer |
||
| 19 | |||
| 20 | push de ;ASCIIZ string for parsing |
||
| 21 | push hl ;Pointer to 11 byte buffer |
||
| 22 | ld d,h |
||
| 23 | ld e,l |
||
| 24 | inc de |
||
| 25 | ld [hl],' ' |
||
| 26 | ld bc,11-1 |
||
| 27 | ldir ;empty filename |
||
| 28 | pop hl ;Pointer to 11 byte buffer |
||
| 29 | pop de ;ASCIIZ string for parsing |
||
| 30 | |||
| 745 | alone | 31 | ;change dots to 1, except the last |
| 32 | ld a,(de) |
||
| 33 | cp '.' |
||
| 34 | jr z,parse_filename_changedots |
||
| 35 | push de |
||
| 36 | jr parse_filename_changedots0getgo |
||
| 37 | parse_filename_changedots0get |
||
| 38 | ld a,1 |
||
| 39 | ld (de),a |
||
| 40 | parse_filename_changedots0getgo |
||
| 41 | ld b,d |
||
| 42 | ld c,e |
||
| 43 | parse_filename_changedots0 |
||
| 44 | ld a,(de) |
||
| 45 | cp '.' |
||
| 46 | jr z,parse_filename_changedots0get |
||
| 47 | inc de |
||
| 48 | or a |
||
| 49 | jr nz,parse_filename_changedots0 |
||
| 50 | ld a,(bc) |
||
| 51 | cp 1 |
||
| 52 | jr nz,$+5 |
||
| 53 | ld a,'.' |
||
| 54 | ld (bc),a |
||
| 55 | pop de |
||
| 56 | parse_filename_changedots |
||
| 57 | |||
| 646 | alone | 58 | ld b,9 |
| 59 | |||
| 60 | ld a,(de) |
||
| 61 | cp '.' |
||
| 62 | jr nz,parse_filename0. |
||
| 63 | ld (hl),a |
||
| 64 | inc de |
||
| 65 | ld a,(de) |
||
| 66 | cp '.' |
||
| 67 | jr nz,parse_filenameq_findterminator. |
||
| 68 | inc hl |
||
| 69 | ld (hl),a |
||
| 70 | jr parse_filenameq_findterminator. |
||
| 71 | parse_filename0. |
||
| 72 | ld a,[de] |
||
| 73 | or a |
||
| 74 | ret z ;jr z,parse_filenameq. ;no extension in string |
||
| 75 | cp '.' |
||
| 76 | jr z,parse_filenamedot. ; 㦥 ନ |
||
| 658 | alone | 77 | ;cp 0x80 |
| 78 | ;jr nc,$+4 |
||
| 79 | ;or 0x20 |
||
| 745 | alone | 80 | cp 1 |
| 81 | jr nz,$+5 |
||
| 82 | ld a,'.' |
||
| 83 | ld [de],a |
||
| 646 | alone | 84 | ld [hl],a |
| 745 | alone | 85 | inc de |
| 646 | alone | 86 | inc hl |
| 87 | djnz parse_filename0. |
||
| 88 | ;9 bytes in filename, no dot (9th byte goes to extension) |
||
| 89 | ;, , , ࠭ - 窠 ନ |
||
| 90 | ; 㦥 ନ 窥 |
||
| 91 | dec hl |
||
| 92 | ld [hl],' ' |
||
| 93 | parse_filenamelongname0. |
||
| 94 | ld a,[de] |
||
| 95 | or a |
||
| 96 | ret z ;jr z,parse_filenameq. ;a=0 |
||
| 97 | inc de |
||
| 98 | cp '.' |
||
| 99 | jr z,parse_filenameLONGnamedot. ; 㦥 ନ |
||
| 100 | jr parse_filenamelongname0. |
||
| 101 | parse_filenamedot. |
||
| 745 | alone | 102 | inc de |
| 646 | alone | 103 | inc hl |
| 104 | djnz $-1 ;hl points to extension in FCB |
||
| 105 | dec hl |
||
| 106 | parse_filenameLONGnamedot. |
||
| 107 | ld a,[de] ;extension in string |
||
| 108 | or a |
||
| 109 | ret z ;jr z,parse_filenameq. ;a=0 |
||
| 658 | alone | 110 | ;cp 0x80 |
| 111 | ;jr nc,$+4 |
||
| 112 | ;or 0x20 |
||
| 646 | alone | 113 | ld [hl],a ;extension in FCB |
| 114 | inc hl |
||
| 115 | inc de |
||
| 116 | ld a,[de] ;extension in string |
||
| 117 | or a |
||
| 118 | ret z ;jr z,parse_filenameq. ;a=0 |
||
| 658 | alone | 119 | ;cp 0x80 |
| 120 | ;jr nc,$+4 |
||
| 121 | ;or 0x20 |
||
| 646 | alone | 122 | ld [hl],a ;extension in FCB |
| 123 | inc hl |
||
| 124 | inc de |
||
| 125 | ld a,[de] ;extension in string |
||
| 126 | or a |
||
| 127 | ret z ;jr z,parse_filenameq. ;a=0 |
||
| 658 | alone | 128 | ;cp 0x80 |
| 129 | ;jr nc,$+4 |
||
| 130 | ;or 0x20 |
||
| 646 | alone | 131 | ld [hl],a ;extension in FCB |
| 132 | parse_filenameq_findterminator. |
||
| 133 | inc de |
||
| 134 | ld a,[de] |
||
| 135 | or a |
||
| 136 | jr nz,parse_filenameq_findterminator. |
||
| 137 | ;parse_filenameq. ;de ନ |
||
| 138 | ;pop hl ;buffer |
||
| 139 | ret ;a=0 |
||
| 140 | |||
| 574 | alone | 141 | cpmname_to_dotname |
| 142 | ;hl -> de |
||
| 143 | push hl |
||
| 144 | ld b,8 |
||
| 145 | cpmname_to_dotname0 |
||
| 146 | ld a,(hl) |
||
| 147 | cp ' ' |
||
| 148 | jr z,cpmname_to_dotname0q |
||
| 149 | ld (de),a |
||
| 150 | inc hl |
||
| 151 | inc de |
||
| 152 | djnz cpmname_to_dotname0 |
||
| 153 | cpmname_to_dotname0q |
||
| 154 | pop hl |
||
| 155 | ld bc,8 |
||
| 156 | add hl,bc ;hl=pointer to ext |
||
| 157 | ld a,(hl) |
||
| 158 | cp ' ' |
||
| 159 | jr z,cpmname_to_dotnameq |
||
| 160 | ld a,'.' |
||
| 161 | ld (de),a |
||
| 162 | inc de |
||
| 163 | ld c,3 |
||
| 164 | ldir |
||
| 165 | cpmname_to_dotnameq |
||
| 166 | xor a |
||
| 167 | ld (de),a |
||
| 168 | ret |
||
| 169 | |||
| 170 | makeprompt |
||
| 171 | ;keeps ix |
||
| 172 | push ix |
||
| 173 | ld de,cmdprompt ;de=pointer to 64 byte (MAXPATH_sz!) buf |
||
| 889 | alone | 174 | OS_GETPATH ;TODO ⥫ |
| 574 | alone | 175 | pop ix |
| 176 | ret |
||
| 177 | |||
| 178 | cmdcalctextaddr |
||
| 179 | ;out: hl=addr, a=curcmdx |
||
| 180 | ;keeps ix |
||
| 651 | alone | 181 | ld hl,cmdbuf |
| 574 | alone | 182 | ld a,(curcmdx) |
| 651 | alone | 183 | cmdcalctextaddr_hlbase_ax |
| 574 | alone | 184 | ld c,a |
| 185 | ld b,0 |
||
| 186 | add hl,bc |
||
| 187 | ret |
||
| 188 | |||
| 189 | cmdcalcpromptsz |
||
| 878 | alone | 190 | ;out: hl=len, a=(len+1)<64 or 64 |
| 574 | alone | 191 | ld hl,cmdprompt |
| 192 | call strlen |
||
| 193 | ld a,l |
||
| 194 | inc a |
||
| 759 | alone | 195 | cp 64 |
| 196 | ret c |
||
| 197 | ld a,64 |
||
| 574 | alone | 198 | ret |
| 199 | |||
| 200 | cmdcalccurxy |
||
| 201 | ;out: de=yx |
||
| 202 | ;x=cmdpromptsz+curcmdx-curcmdscroll |
||
| 203 | call cmdcalcpromptsz ;a=promptsz |
||
| 204 | ld hl,curcmdx ; ࠭, |
||
| 205 | add a,(hl) |
||
| 206 | ld hl,curcmdscroll ;ᤢ ⭮⥫쭮 ࠭ |
||
| 207 | sub (hl) |
||
| 1410 | alone | 208 | ;ld d,txtscrhgt-1 |
| 209 | ;ld d,CMDLINEY |
||
| 210 | ld de,(scrhgt-1) ;d |
||
| 211 | dec d |
||
| 212 | dec d |
||
| 574 | alone | 213 | ld e,a |
| 214 | ret |
||
| 215 | |||
| 216 | strlen |
||
| 217 | ;hl=str |
||
| 218 | ;out: hl=length |
||
| 219 | xor a |
||
| 878 | alone | 220 | ld b,a |
| 221 | ld c,a ;⮡ 筮 ନ |
||
| 574 | alone | 222 | cpir ; 易⥫쭮, =0, bc=-1 .. |
| 878 | alone | 223 | ld h,a |
| 224 | ld l,a |
||
| 225 | scf |
||
| 574 | alone | 226 | sbc hl,bc |
| 227 | ret |
||
| 228 | |||
| 229 | fixscroll_prcmd |
||
| 230 | ;横 ᪠ ⥪饣 |
||
| 231 | editcmd_scroll0 |
||
| 232 | call cmdcalccurxy ;e=scrx |
||
| 233 | call cmdcalcpromptsz ;a=promptsz |
||
| 234 | ld hl,curcmdscroll |
||
| 235 | dec a |
||
| 236 | cp e ;scrx |
||
| 237 | jr c,editcmd_noscrollleft ;x>=promptsz (x>(promptsz-1)) |
||
| 238 | ;x<promptsz - |
||
| 239 | dec (hl) |
||
| 240 | jr editcmd_scroll0 |
||
| 241 | editcmd_noscrollleft |
||
| 242 | ld a,e ;scrx |
||
| 243 | cp txtscrwid |
||
| 244 | jr c,editcmd_noscrollright |
||
| 245 | ;x>=txtscrwid - ࠢ |
||
| 246 | inc (hl) |
||
| 247 | jr editcmd_scroll0 |
||
| 248 | editcmd_noscrollright |
||
| 249 | ;prcmd |
||
| 250 | ld de,_COLOR |
||
| 841 | alone | 251 | if PRSTDIO |
| 574 | alone | 252 | SETCOLOR_ |
| 841 | alone | 253 | else |
| 254 | call nv_setcolor |
||
| 255 | endif |
||
| 574 | alone | 256 | ;ld de,+(txtscrhgt-1)*256+0 |
| 1410 | alone | 257 | ;ld de,CMDLINEY*256+0 |
| 258 | ld de,(scrhgt-1) ;d |
||
| 259 | dec d |
||
| 260 | dec d |
||
| 261 | ld e,0 |
||
| 889 | alone | 262 | call nv_setxy ;keeps de,hl,ix |
| 759 | alone | 263 | call cmdcalcpromptsz |
| 264 | dec a |
||
| 265 | ld e,a ;!=0, .. 㪢 |
||
| 266 | ld d,0 |
||
| 574 | alone | 267 | ld hl,cmdprompt |
| 889 | alone | 268 | ld c,d;0 |
| 759 | alone | 269 | ;call prtext |
| 270 | call cmdprNchars |
||
| 574 | alone | 271 | push bc |
| 272 | ld a,'>' |
||
| 889 | alone | 273 | MYPRCHAR |
| 574 | alone | 274 | pop bc |
| 275 | inc c |
||
| 276 | ld hl,(curcmdscroll) |
||
| 277 | ld h,0 |
||
| 278 | ld de,cmdbuf |
||
| 279 | add hl,de |
||
| 280 | call prtext |
||
| 281 | ; ⮪ ப |
||
| 605 | alone | 282 | ;ld hl,tspaces |
| 283 | ;jp prtext |
||
| 284 | jp clearrestofline |
||
| 574 | alone | 285 | |
| 1410 | alone | 286 | tspaces ;for drawfilecursor_sizeb_colorhl |
| 574 | alone | 287 | ds txtscrwid-1,' ' |
| 288 | db 0 |
||
| 289 | |||
| 290 | cmdprNchars |
||
| 291 | ;hl=buffer |
||
| 292 | ;de=size |
||
| 293 | ;out: hl=buffer+size |
||
| 294 | ex de,hl |
||
| 295 | push de |
||
| 296 | push hl |
||
| 297 | call sendchars |
||
| 298 | pop hl |
||
| 299 | pop de |
||
| 300 | add hl,de |
||
| 301 | ret |
||
| 302 | |||
| 303 | prtext |
||
| 304 | ;c=x |
||
| 305 | push bc |
||
| 306 | push hl |
||
| 307 | ld a,txtscrwid-1 |
||
| 308 | sub c |
||
| 309 | ld c,a |
||
| 310 | push bc |
||
| 311 | call strlen ;hl=length |
||
| 312 | pop bc |
||
| 313 | ld b,0 |
||
| 314 | call minhl_bc_tobc |
||
| 315 | ld h,b |
||
| 316 | ld l,c |
||
| 317 | pop de |
||
| 318 | pop bc ;c=x |
||
| 319 | ld a,h |
||
| 320 | or l |
||
| 321 | ;de=buf |
||
| 322 | ;hl=len |
||
| 323 | push bc |
||
| 324 | push de |
||
| 325 | push hl |
||
| 326 | call nz,sendchars |
||
| 327 | pop hl |
||
| 328 | pop de |
||
| 329 | pop bc |
||
| 330 | ld a,l |
||
| 331 | add a,c |
||
| 332 | ld c,a |
||
| 333 | add hl,de |
||
| 334 | inc hl |
||
| 335 | ;c=x |
||
| 336 | ;hl=after terminator |
||
| 337 | ret |
||
| 338 | |||
| 339 | minhl_bc_tobc |
||
| 340 | or a |
||
| 341 | sbc hl,bc |
||
| 342 | add hl,bc |
||
| 343 | ret nc ;bc<=hl |
||
| 344 | ld b,h |
||
| 345 | ld c,l |
||
| 346 | ret |
||
| 347 | |||
| 348 | strdelch |
||
| 349 | ;delete char at (hl-1), shift string left |
||
| 350 | ;keeps ix |
||
| 351 | editcmd_bs0 |
||
| 352 | ld a,(hl) |
||
| 353 | dec hl |
||
| 354 | ld (hl),a |
||
| 355 | inc hl |
||
| 356 | inc hl |
||
| 357 | or a |
||
| 358 | jr nz,editcmd_bs0 |
||
| 359 | ret |
||
| 360 | |||
| 361 | strinsch |
||
| 362 | ;insert char E at (hl), shift string right |
||
| 363 | ;keeps ix |
||
| 364 | editcmd_ins0 |
||
| 365 | ld a,(hl) |
||
| 366 | ld (hl),e |
||
| 367 | ld e,a |
||
| 368 | inc hl |
||
| 369 | or a |
||
| 370 | jr nz,editcmd_ins0 |
||
| 371 | ld (hl),a |
||
| 372 | ret |
||
| 373 | |||
| 374 | curcmdscroll ;ᤢ ⭮⥫쭮 ࠭ |
||
| 375 | db 0 |
||
| 376 | curcmdx ; ࠭, |
||
| 377 | db 0 |
||
| 378 | cmdprompt |
||
| 379 | ds MAXPATH_sz;MAXCMDSZ+1 |
||
| 380 | tcmd |
||
| 381 | db "cmd " |
||
| 382 | tcmd_sz=$-tcmd |
||
| 383 | cmdbuf |
||
| 384 | db 0 |
||
| 385 | ds cmdbuf+MAXCMDSZ+1-$ |