2012-10-16 21:39:40 +00:00
|
|
|
;
|
2014-07-17 11:11:14 +00:00
|
|
|
; 2012-10-16, Oliver Schmidt
|
|
|
|
; 2014-07-16, Greg King
|
2012-10-16 21:39:40 +00:00
|
|
|
;
|
|
|
|
; unsigned char __fastcall__ _syschdir (const char* name);
|
|
|
|
;
|
|
|
|
|
|
|
|
.export __syschdir
|
2012-10-17 20:24:43 +00:00
|
|
|
.import diskinit, fnunit, curunit, initcwd
|
2012-10-16 21:39:40 +00:00
|
|
|
.importzp ptr1, tmp1, tmp2
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------------
|
|
|
|
; __syschdir
|
|
|
|
|
|
|
|
.proc __syschdir
|
|
|
|
|
|
|
|
; Save name
|
|
|
|
|
|
|
|
sta ptr1
|
|
|
|
stx ptr1+1
|
|
|
|
|
|
|
|
; Process first character
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
lda (ptr1),y
|
|
|
|
beq err
|
|
|
|
jsr getdigit
|
|
|
|
bcs err
|
|
|
|
tax
|
|
|
|
|
|
|
|
; Process second character
|
|
|
|
|
|
|
|
iny
|
|
|
|
lda (ptr1),y
|
2012-10-17 20:24:43 +00:00
|
|
|
beq init
|
2012-10-16 21:39:40 +00:00
|
|
|
jsr getdigit
|
|
|
|
bcs err
|
|
|
|
stx tmp1 ; First digit
|
|
|
|
sta tmp2 ; Second digit
|
|
|
|
|
|
|
|
; Multiply first digit by 10
|
|
|
|
|
2014-07-17 11:11:14 +00:00
|
|
|
txa
|
|
|
|
asl a ; * 2
|
|
|
|
asl a ; * 4, carry cleared
|
|
|
|
adc tmp1 ; * 5
|
|
|
|
asl a ; * 10, carry cleared
|
2012-10-16 21:39:40 +00:00
|
|
|
|
|
|
|
; Add second digit to product
|
|
|
|
|
|
|
|
adc tmp2
|
|
|
|
tax
|
|
|
|
|
|
|
|
; Process third character
|
|
|
|
|
|
|
|
iny
|
|
|
|
lda (ptr1),y
|
|
|
|
bne err
|
|
|
|
|
2012-10-17 20:24:43 +00:00
|
|
|
; Check device readiness
|
|
|
|
|
|
|
|
init: txa
|
|
|
|
jsr diskinit
|
|
|
|
bne done
|
|
|
|
|
2012-10-16 21:39:40 +00:00
|
|
|
; Success, update cwd
|
|
|
|
|
2012-10-17 20:24:43 +00:00
|
|
|
lda fnunit ; Set by diskinit
|
|
|
|
sta curunit
|
2012-10-16 21:39:40 +00:00
|
|
|
jmp initcwd ; Returns with A = 0
|
|
|
|
|
2012-10-17 20:24:43 +00:00
|
|
|
; Return with error in A
|
|
|
|
|
2014-04-03 21:28:36 +00:00
|
|
|
err: lda #9 ; "Illegal device"
|
2012-10-17 20:24:43 +00:00
|
|
|
done: rts
|
2012-10-16 21:39:40 +00:00
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------------
|
2014-07-17 11:11:14 +00:00
|
|
|
; getdigit -- Converts PetSCII to binary.
|
|
|
|
; Sets carry if the character is outside of '0'-'9'.
|
2012-10-16 21:39:40 +00:00
|
|
|
|
|
|
|
.proc getdigit
|
|
|
|
|
|
|
|
sec
|
|
|
|
sbc #'0'
|
|
|
|
bcs @L0
|
|
|
|
sec
|
|
|
|
rts
|
|
|
|
@L0: cmp #10
|
|
|
|
rts
|
|
|
|
|
2014-04-03 21:28:36 +00:00
|
|
|
.endproc
|