]> git.sur5r.net Git - cc65/blob - libsrc/geos-cbm/disk/dio_openclose.s
Normalized coding style.
[cc65] / libsrc / geos-cbm / 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
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         pha
31         tax
32         lda driveType,x         ; check if there's a device
33         beq _inv_drive
34         txa
35         clc
36         adc #8                  ; normalize devnum
37         sta curDevice
38         jsr SetDevice
39         jsr _OpenDisk           ; take care for errors there
40
41         pla
42         tay                     ; drive #
43         asl a                   ; make index from drive id
44         asl a
45         tax
46             
47         lda #0
48         sta sectsizetab+sst_sectsize,x
49         lda #128
50         sta sectsizetab+sst_flag,x ; set flag that drive is "open"
51         lda #1
52         sta sectsizetab+sst_sectsize+1,x
53         tya
54         sta sectsizetab+sst_driveno,x
55             
56         stx tmp1
57         lda #<sectsizetab
58         clc
59         adc tmp1
60         sta tmp1
61         lda #>sectsizetab
62         adc #0
63         tax
64         lda tmp1
65
66         rts
67
68 _inv_drive:
69         lda #DEV_NOT_FOUND
70         sta __oserror
71         lda #0
72         tax
73         rts
74
75 _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