]> git.sur5r.net Git - cc65/blob - libsrc/atari/romswitch.inc
cleanup and document CHARGEN_RELOC change
[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 CHAGEN_RELOC
18 ;                is also defined.
19
20
21 .ifdef __ATARIXL__
22
23 USEWSYNC =      1
24 CHARGEN_RELOC = 1
25
26
27 .ifdef CHARGEN_RELOC
28
29 .macro  set_chbase val
30         lda     #val
31         sta     CHBAS
32         sta     CHBASE
33 .endmacro
34
35 .else
36
37 .macro  set_chbase val
38 .endmacro
39
40 .endif  ; .ifdef CHARGEN_RELOC
41
42
43 .if .defined(USEWSYNC) .and .defined(CHARGEN_RELOC)
44
45 .macro  wsync
46         sta     WSYNC
47 .endmacro
48
49 .else   ; above 
50
51 .macro  wsync
52 .endmacro
53
54 .endif
55
56
57 ; "disable ROM" macros
58
59 .macro  disable_rom
60         lda     PORTB
61         and     #$fe
62         wsync
63         sta     PORTB
64         set_chbase >__CHARGEN_START__
65 .endmacro
66
67 .macro  disable_rom_quick
68         lda     PORTB
69         and     #$fe
70         sta     PORTB
71         set_chbase >__CHARGEN_START__
72 .endmacro
73
74 .macro  disable_rom_val val
75         lda     val
76         wsync
77         sta     PORTB
78         set_chbase >__CHARGEN_START__
79 .endmacro
80
81 ; "enable ROM" macros
82
83 .macro  enable_rom
84         lda     PORTB
85         ora     #1
86         wsync
87         sta     PORTB
88         set_chbase $E0
89 .endmacro
90
91 .macro  enable_rom_quick
92         lda     PORTB
93         ora     #1
94         sta     PORTB
95         set_chbase $E0
96 .endmacro
97
98 .else   ; above __ATARIXL__, below not
99
100 .macro  disable_rom
101 .endmacro
102 .macro  enable_rom
103 .endmacro
104
105 .endif