]> git.sur5r.net Git - cc65/blob - libsrc/apple2/videomode.s
Fixed gcc compiler warning (#867)
[cc65] / libsrc / apple2 / videomode.s
1 ;
2 ; Oliver Schmidt, 07.09.2009
3 ;
4 ; unsigned __fastcall__ videomode (unsigned mode);
5 ;
6         .ifdef  __APPLE2ENH__
7
8         .export         _videomode
9         .import         COUT
10
11         .include        "apple2.inc"
12
13         .segment        "LOWCODE"
14
15 _videomode:
16         ; Get and save current videomode flag
17         bit     RD80VID
18         php
19         
20         ; If we are in 80 column mode then the 80 column firmware is
21         ; known to be active so we can just print the ctrl-char code
22         ; (even if this only means staying in the current videomode)
23         bpl     :+
24         jsr     COUT
25         bra     done
26
27         ; If we are in 40 column mode and want to set 40 column mode
28         ; then we explicitly do nothing as we neither know about the
29         ; current state of the 80 column firmware nor want to fix it
30 :       cmp     #$11            ; Ctrl-char code for 40 cols
31         beq     done
32         
33         ; If we are in 40 column mode and want to set 80 column mode
34         ; then we first presume the 80 column firmware being already
35         ; active and print the ctrl-char code (this causes a garbage
36         ; char to be printed on the screen if isn't already active)
37         jsr     COUT
38         
39         ; If we successfully switched to 80 column mode then the 80
40         ; column firmware was in fact already active and we're done
41         bit     RD80VID
42         bmi     done
43         
44         ; The 80 column firmware isn't already active so we need to
45         ; initialize it - causing the screen to be cleared and thus
46         ; the garbage char printed above to be erased (but for some
47         ; reason the cursor horizontal position not to be zeroed)
48         stz     CH
49
50         ; Initializing the 80 column firmware needs the ROM switched
51         ; in, otherwise it would copy the F8 ROM to the LC (@ $CEF4)
52         bit     $C082
53
54         ; Initialize 80 column firmware
55         jsr     $C300           ; PR#3
56
57         ; Switch in LC bank 2 for R/O
58         bit     $C080
59                 
60         ; Return ctrl-char code for setting previous
61         ; videomode using the saved videomode flag
62 done:   lda     #$11            ; Ctrl-char code for 40 cols
63         plp
64         bpl     :+
65         lda     #$12            ; Ctrl-char code for 80 cols
66 :       rts                     ; X was preserved all the way
67
68         .endif                  ; __APPLE2ENH__