]> git.sur5r.net Git - cc65/blob - libsrc/geos-cbm/disk/dio_openclose.s
Fixed _textcolor definition.
[cc65] / libsrc / geos-cbm / disk / dio_openclose.s
1 ;
2 ; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak
3 ; 2015-08-24, Greg King
4 ;
5 ; based on Atari version by Christian Groessler
6 ;
7 ; dhandle_t     __fastcall__ dio_open  (unsigned char device);
8 ; unsigned char __fastcall__ dio_close (dhandle_t handle);
9 ;
10 ; dio_open sets given device as current and initializes disk
11 ; dio_close does nothing special
12
13             .export _dio_open, _dio_close
14             .import __oserror, _OpenDisk
15             .importzp ptr1, tmp1
16
17             .include "dio.inc"
18             .include "jumptab.inc"
19             .include "geossym.inc"
20             .include "const.inc"
21
22 .bss
23
24 sectsizetab:
25         .res 4 * sst_size       ; this is hardcoded
26
27 .code
28
29 _dio_open:
30         cmp #4
31         bcs _inv_drive
32         tax
33         lda driveType,x         ; check if there's a device
34         beq _inv_drive
35         txa
36         pha
37         clc
38         adc #8                  ; normalize devnum
39         sta curDevice
40         jsr SetDevice
41         jsr _OpenDisk           ; take care for errors there
42
43         pla
44         tay                     ; drive #
45         asl a                   ; make index from drive id
46         asl a
47         tax
48             
49         lda #0
50         sta sectsizetab+sst_sectsize,x
51         lda #128
52         sta sectsizetab+sst_flag,x ; set flag that drive is "open"
53         lda #1
54         sta sectsizetab+sst_sectsize+1,x
55         tya
56         sta sectsizetab+sst_driveno,x
57             
58         stx tmp1
59         lda #<sectsizetab
60         clc
61         adc tmp1
62         sta tmp1
63         lda #>sectsizetab
64         adc #0
65         tax
66         lda tmp1
67
68         rts
69
70 _inv_drive:
71         lda #DEV_NOT_FOUND
72         sta __oserror
73         lda #0
74         tax
75         rts
76
77 _dio_close:
78         sta ptr1
79         stx ptr1+1
80         lda #0
81         ldy #sst_flag
82         sta (ptr1),y
83         sta __oserror           ; success
84         tax
85         rts                     ; return no error