]> git.sur5r.net Git - cc65/blob - libsrc/geos-cbm/system/get_ostype.s
Avoid paths in .include directives. The path needs to be rather set in the Makefile...
[cc65] / libsrc / geos-cbm / system / get_ostype.s
1                                         
2 ;
3 ; Maciej 'YTM/Elysium' Witkowiak
4 ;
5 ; 10.09.2001
6 ;
7 ; Plus4 and GEOS 1.1 detection by
8 ; Marco van den Heuvel, 2010-02-02
9 ;
10
11 ; unsigned char get_ostype (void);
12 ; unsigned char get_tv (void);
13
14             .export _get_ostype
15             .export _get_tv
16             .importzp tmp1
17
18             .include "const.inc"
19             .include "geossym.inc"
20             .include "geossym2.inc"
21
22 _get_ostype:
23             ldx #0
24             lda version
25             cmp #$a9
26             beq geos11
27             and #%11110000
28             cmp #$10
29             beq geos10
30             lda c128Flag                ; we're on at least 2.0
31             cmp #$18
32             beq geos_on_plus4
33             ora version
34             rts
35 geos10:
36             lda version
37             rts
38 geos11:
39             lda #$11
40             rts
41 geos_on_plus4:
42             lda #$04
43             rts
44
45 _get_tv:
46             jsr _get_ostype
47             cmp #$04
48             beq plus4_get_tv
49             bpl only40                  ; C64 with 40 columns only
50             lda graphMode
51             bpl only40                  ; C128 but currently on 40 columns
52             ldx #1                      ; COLUMNS80
53             bne tvmode
54 only40:     ldx #0                      ; COLUMNS40
55 tvmode:                                 ; PAL/NTSC check here, result in A
56             php
57             sei                         ; disable interrupts
58             lda CPU_DATA                ; this is for C64
59             pha
60             lda #IO_IN                  ; enable access to I/O
61             sta CPU_DATA
62             bit rasreg
63             bpl tvmode                  ; wait for rasterline  127<x<256
64             lda #24                     ; (rasterline now >=256!)
65 modelp:
66             cmp rasreg                  ; wait for rasterline = 24 (or 280 on PAL)
67             bne modelp
68             lda grcntrl1                ; 24 or 280 ?
69             bpl ntsc
70             lda #0                      ; PAL
71             beq modeend
72 ntsc:
73             lda #$80                    ; NTSC
74
75 modeend:
76             stx tmp1
77             ora tmp1
78             sta tmp1
79             ldx #0
80             pla
81             sta CPU_DATA                ; restore memory config
82             plp                         ; restore interrupt state
83             lda tmp1
84             rts
85 plus4_get_tv:
86             ldx #1                      ; Assume PAL
87             bit $FF07                   ; Test bit 6
88             bvc plus4pal
89             dex                         ; NTSC
90 plus4pal:
91             txa
92             ldx #0
93             rts