2012-10-10 20:55:56 +00:00
|
|
|
;
|
|
|
|
; Oliver Schmidt, 2010-05-24
|
|
|
|
;
|
|
|
|
; char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _getdevicedir
|
2018-05-20 13:30:18 +00:00
|
|
|
.import popptr1, popa
|
2012-10-10 20:55:56 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "zeropage.inc"
|
|
|
|
.include "errno.inc"
|
|
|
|
.include "mli.inc"
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
_getdevicedir:
|
|
|
|
; Save size
|
2013-05-09 11:56:54 +00:00
|
|
|
sta ptr2
|
|
|
|
stx ptr2+1
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Save buf
|
2018-05-20 13:30:18 +00:00
|
|
|
jsr popptr1
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Set buf
|
2018-07-26 12:31:17 +00:00
|
|
|
ldx ptr1+1
|
2013-05-09 11:56:54 +00:00
|
|
|
sta mliparam + MLI::ON_LINE::DATA_BUFFER
|
|
|
|
stx mliparam + MLI::ON_LINE::DATA_BUFFER+1
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Set device
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr popa
|
2012-10-15 21:59:51 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2013-05-09 11:56:54 +00:00
|
|
|
sta mliparam + MLI::ON_LINE::UNIT_NUM
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Check for valid slot
|
2013-05-09 11:56:54 +00:00
|
|
|
and #$70
|
|
|
|
beq erange
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Check for sufficient buf size
|
2013-05-09 11:56:54 +00:00
|
|
|
lda ptr2+1
|
|
|
|
bne :++ ; Buf >= 256
|
|
|
|
lda ptr2
|
|
|
|
cmp #17
|
|
|
|
bcs :++ ; Buf >= 17
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Handle errors
|
2013-05-09 11:56:54 +00:00
|
|
|
erange: lda #<ERANGE
|
2022-08-28 19:52:53 +00:00
|
|
|
jsr ___directerrno
|
2013-05-09 11:56:54 +00:00
|
|
|
bne :+ ; Branch always
|
2022-08-28 19:52:53 +00:00
|
|
|
oserr: jsr ___mappederrno
|
2013-05-09 11:56:54 +00:00
|
|
|
: lda #$00 ; Return NULL
|
2012-10-10 20:55:56 +00:00
|
|
|
tax
|
|
|
|
rts
|
|
|
|
|
|
|
|
; Get volume name
|
2013-05-09 11:56:54 +00:00
|
|
|
: lda #ON_LINE_CALL
|
|
|
|
ldx #ON_LINE_COUNT
|
|
|
|
jsr callmli
|
|
|
|
bcs oserr
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Get volume name length
|
2013-05-09 11:56:54 +00:00
|
|
|
ldy #$00
|
|
|
|
lda (ptr1),y
|
|
|
|
and #15 ; Max volume name length
|
|
|
|
sta tmp1
|
2018-07-26 12:31:17 +00:00
|
|
|
|
2012-10-10 20:55:56 +00:00
|
|
|
; Add leading slash
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #'/'
|
|
|
|
sta (ptr1),y
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Add terminating zero
|
2013-05-09 11:56:54 +00:00
|
|
|
ldy tmp1
|
2012-10-10 20:55:56 +00:00
|
|
|
iny
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #$00
|
|
|
|
sta (ptr1),y
|
2022-08-28 20:37:33 +00:00
|
|
|
sta ___oserror ; Clear __oserror
|
2012-10-10 20:55:56 +00:00
|
|
|
|
|
|
|
; Success, return buf
|
2013-05-09 11:56:54 +00:00
|
|
|
lda ptr1
|
|
|
|
ldx ptr1+1
|
2012-10-10 20:55:56 +00:00
|
|
|
rts
|