]> git.sur5r.net Git - cc65/blob - libsrc/geos/disk/dio_openclose.s
Added new mouse functions
[cc65] / libsrc / geos / disk / dio_openclose.s
1 ;
2 ; Maciej 'YTM/Elysium' Witkowiak
3 ;
4 ; based on Atari version by Christian Groessler
5 ; 2.7.2001
6 ;
7 ; dhandle_t     __fastcall__ dio_open  (driveid_t drive_id);
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         .include "../inc/dio.inc"
17         .include "../inc/jumptab.inc"
18         .include "../inc/geossym.inc"
19         .include "../inc/const.inc"
20
21 .bss
22
23 sectsizetab:
24         .res    4 * sst_size            ; this is hardcoded
25
26 .code
27
28 .proc   _dio_open
29         pha
30         tax
31         lda driveType,x         ; check if there's a device
32         bne _inv_drive
33         clc
34         adc #8                  ; normalize devnum
35         sta curDevice
36         jsr SetDevice
37         jsr _OpenDisk           ; take care for errors there
38
39         pla
40         tay                     ; drive #
41         asl     a               ; make index from drive id
42         asl     a
43         tax
44
45         lda     #0
46         sta     sectsizetab+sst_sectsize,x
47         lda     #128
48         sta     sectsizetab+sst_flag,x          ; set flag that drive is "open"
49         lda     #1
50         sta     sectsizetab+sst_sectsize+1,x
51         tya
52         sta     sectsizetab+sst_driveno,x
53
54         stx     tmp1
55         lda     #<sectsizetab
56         clc
57         adc     tmp1
58         sta     tmp1
59         lda     #>sectsizetab
60         adc     #0
61         tax
62         lda     tmp1
63
64         rts
65
66 _inv_drive:
67         lda #DEV_NOT_FOUND
68         sta __oserror
69         lda #0
70         tax
71         rts
72
73 .endproc
74
75 .proc   _dio_close
76         sta     ptr1
77         stx     ptr1+1
78         lda     #0
79         ldy     #sst_flag
80         sta     (ptr1),y
81         sta     __oserror       ; success
82         tax
83         rts                     ; return no error
84 .endproc