]> git.sur5r.net Git - cc65/blob - libsrc/atari/romswitch.inc
Minor clarification.
[cc65] / libsrc / atari / romswitch.inc
1 ;
2 ; Macros to disable and enable the ROM on Atari XL systems.
3 ;
4 ; Christian Groessler, chris@groessler.org, 19-Sep-2013
5 ;
6 ;
7 ; Defines which modify the operation of the macros:
8 ;
9 ; CHARGEN_RELOC: If defined, CHBAS and CHBASE are updated when
10 ;                enabling or disabling the ROM.
11 ;                If the ROM is enabled, $E0 is written to CHBAS
12 ;                and CHBASE.
13 ;                If the ROM is disabled, the upper byte of
14 ;                __CHARGEN_START__ is written to CHBAS and CHBASE.
15 ; USEWSYNC:      If defined, the code waits for horizontal retrace
16 ;                before switching the ROM and updating CHBAS and
17 ;                CHBASE. This define only has effect if CHARGEN_RELOC
18 ;                is also defined.
19
20
21 .ifdef __ATARIXL__
22
23 .ifdef CHARGEN_RELOC
24
25 .macro  set_chbase val
26         lda     #val
27         sta     CHBAS
28         sta     CHBASE
29 .endmacro
30
31 .else   ; above CHARGEN_RELOC, below not
32
33 .macro  set_chbase val
34 .endmacro
35
36 .endif  ; .ifdef CHARGEN_RELOC
37
38
39 .if .defined(USEWSYNC) .and .defined(CHARGEN_RELOC)
40
41 .macro  wsync
42         sta     WSYNC
43 .endmacro
44
45 .else   ; above USEWSYNC, below not
46
47 .macro  wsync
48 .endmacro
49
50 .endif
51
52
53 ; "disable ROM" macros
54
55 .macro  disable_rom
56         lda     PORTB
57         and     #$fe
58         wsync
59         sta     PORTB
60         set_chbase >__CHARGEN_START__
61 .endmacro
62
63 .macro  disable_rom_quick
64         lda     PORTB
65         and     #$fe
66         sta     PORTB
67         set_chbase >__CHARGEN_START__
68 .endmacro
69
70 .macro  disable_rom_val val
71         lda     val
72         wsync
73         sta     PORTB
74         set_chbase >__CHARGEN_START__
75 .endmacro
76
77 ; "enable ROM" macros
78
79 .macro  enable_rom
80         lda     PORTB
81         ora     #1
82         wsync
83         sta     PORTB
84         set_chbase $E0
85 .endmacro
86
87 .macro  enable_rom_quick
88         lda     PORTB
89         ora     #1
90         sta     PORTB
91         set_chbase $E0
92 .endmacro
93
94 .else   ; above __ATARIXL__, below not
95
96 .macro  disable_rom
97 .endmacro
98 .macro  enable_rom
99 .endmacro
100
101 .endif