]> git.sur5r.net Git - cc65/blob - libsrc/geos/disk/dio_openclose.s
don't use constructor to setup runtime stack
[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         beq _inv_drive
33         txa
34         clc
35         adc #8                  ; normalize devnum
36         sta curDevice
37         jsr SetDevice
38         jsr _OpenDisk           ; take care for errors there
39
40         pla
41         tay                     ; drive #
42         asl     a               ; make index from drive id
43         asl     a
44         tax
45
46         lda     #0
47         sta     sectsizetab+sst_sectsize,x
48         lda     #128
49         sta     sectsizetab+sst_flag,x          ; set flag that drive is "open"
50         lda     #1
51         sta     sectsizetab+sst_sectsize+1,x
52         tya
53         sta     sectsizetab+sst_driveno,x
54
55         stx     tmp1
56         lda     #<sectsizetab
57         clc
58         adc     tmp1
59         sta     tmp1
60         lda     #>sectsizetab
61         adc     #0
62         tax
63         lda     tmp1
64
65         rts
66
67 _inv_drive:
68         lda #DEV_NOT_FOUND
69         sta __oserror
70         lda #0
71         tax
72         rts
73
74 .endproc
75
76 .proc   _dio_close
77         sta     ptr1
78         stx     ptr1+1
79         lda     #0
80         ldy     #sst_flag
81         sta     (ptr1),y
82         sta     __oserror       ; success
83         tax
84         rts                     ; return no error
85 .endproc