2012-10-07 19:18:56 +00:00
|
|
|
;
|
|
|
|
; Oliver Schmidt, 2012-09-10
|
|
|
|
;
|
|
|
|
; char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);
|
|
|
|
;
|
|
|
|
|
|
|
|
.export _getdevicedir
|
2012-10-17 20:24:43 +00:00
|
|
|
.import diskinit, devicestr, fnunit
|
2012-10-07 19:18:56 +00:00
|
|
|
.import popa, popax
|
|
|
|
.importzp ptr2, ptr3
|
|
|
|
|
|
|
|
.include "errno.inc"
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; _getdevicedir
|
|
|
|
|
|
|
|
.proc _getdevicedir
|
|
|
|
|
|
|
|
; Save size
|
|
|
|
|
|
|
|
sta ptr3
|
|
|
|
stx ptr3+1
|
|
|
|
|
|
|
|
; Save buf
|
|
|
|
|
|
|
|
jsr popax
|
|
|
|
sta ptr2
|
|
|
|
stx ptr2+1
|
|
|
|
|
2012-10-17 20:24:43 +00:00
|
|
|
; Check device readiness
|
2012-10-07 19:18:56 +00:00
|
|
|
|
|
|
|
jsr popa
|
2012-10-17 20:24:43 +00:00
|
|
|
jsr diskinit
|
|
|
|
beq size
|
2022-08-28 19:52:53 +00:00
|
|
|
jsr ___mappederrno
|
2012-10-17 20:24:43 +00:00
|
|
|
bne fail ; Branch always
|
2012-10-07 19:18:56 +00:00
|
|
|
|
|
|
|
; Check for sufficient buf size
|
|
|
|
|
2012-10-17 20:24:43 +00:00
|
|
|
size: lda ptr3+1
|
2012-10-07 19:18:56 +00:00
|
|
|
bne okay ; Buf >= 256
|
|
|
|
lda ptr3
|
|
|
|
cmp #3
|
|
|
|
bcs okay ; Buf >= 3
|
2012-10-17 20:24:43 +00:00
|
|
|
lda #<ERANGE
|
2022-08-28 19:52:53 +00:00
|
|
|
jsr ___directerrno
|
2012-10-10 20:51:10 +00:00
|
|
|
fail: lda #0 ; Return NULL
|
|
|
|
tax
|
2012-10-07 19:18:56 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; Copy device string representation into buf
|
|
|
|
|
2012-10-17 20:24:43 +00:00
|
|
|
okay: lda fnunit ; Set by diskinit
|
2012-10-07 20:20:54 +00:00
|
|
|
jsr devicestr ; Returns 0 in A
|
2022-08-28 20:37:33 +00:00
|
|
|
sta ___oserror ; Clear __oserror
|
2012-10-07 19:18:56 +00:00
|
|
|
|
|
|
|
; Success, return buf
|
|
|
|
|
|
|
|
lda ptr2
|
|
|
|
ldx ptr2+1
|
|
|
|
rts
|
|
|
|
|
|
|
|
.endproc
|