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