]> git.sur5r.net Git - cc65/blob - libsrc/atari/savevec.s
Don't add a mode when opening files for reading
[cc65] / libsrc / atari / savevec.s
1 ;
2 ; save and restore system vectors
3 ; originally by Mark Keates
4 ;
5 ; void save_vecs(void);
6 ; void rest_vecs(void);
7 ;
8
9         .export _save_vecs,_rest_vecs
10 .include        "atari.inc"
11
12         .bss
13
14 old_dli:     .res 2
15 old_dlist:   .res 2
16 old_vbi:     .res 2
17 old_vbd:     .res 2
18 old_gra:     .res 1
19 old_dma:     .res 1
20 old_prior:   .res 1
21 old_cols:    .res 8
22 old_set:     .res 1
23 old_rmargin: .res 1     ; lmargin saved in startup code
24
25         .code
26
27 .proc   _save_vecs
28
29         lda     VDSLST
30         sta     old_dli
31         lda     VDSLST+1
32         sta     old_dli+1
33         lda     SDLSTL
34         sta     old_dlist
35         lda     SDLSTL+1
36         sta     old_dlist+1
37         lda     VVBLKI
38         sta     old_vbi
39         lda     VVBLKI+1
40         sta     old_vbi+1
41         lda     VVBLKD
42         sta     old_vbd
43         lda     VVBLKD+1
44         sta     old_vbd+1
45         lda     GRACTL
46         sta     old_gra
47         lda     SDMCTL
48         sta     old_dma
49         lda     GPRIOR
50         sta     old_prior
51         lda     CHBAS
52         sta     old_set
53         lda     RMARGN
54         sta     old_rmargin
55
56         ldy     #7
57 SETUP1:
58         lda     PCOLR0,y
59         sta     old_cols,y
60         dey
61         bpl     SETUP1
62         rts
63
64 .endproc
65
66 .proc   _rest_vecs
67
68         lda     #6
69         ldx     old_vbi+1
70         ldy     old_vbi
71         jsr     SETVBV
72         lda     #7
73         ldx     old_vbd+1
74         ldy     old_vbd
75         jsr     SETVBV
76         lda     old_dli
77         sta     VDSLST
78         lda     old_dli+1
79         sta     VDSLST+1
80         lda     old_dlist
81         sta     SDLSTL
82         lda     old_dlist+1
83         sta     SDLSTL+1
84         lda     old_gra
85         sta     GRACTL
86         lda     old_prior
87         sta     GPRIOR
88         lda     old_dma
89         sta     SDMCTL
90         lda     old_set
91         sta     CHBAS
92         lda     old_rmargin
93         sta     RMARGN
94         lda     #$FF
95         sta     CH
96         ldy     #7
97 SETUP2:
98         lda     old_cols,Y
99         sta     PCOLR0,Y
100         dey
101         bpl     SETUP2
102         rts
103
104 .endproc
105