]> git.sur5r.net Git - cc65/blob - libsrc/geos-cbm/system/get_ostype.s
827630f0b21907ad8175c6aead84e9d8d437932b
[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         lda gatewayFlag
30         cmp #$41
31         beq gateway
32         lda mp3Flag
33         cmp #$4d
34         beq megapatch3
35         lda c128Flag            ; we're on at least 2.0
36         cmp #$18
37         beq geos_on_plus4
38         ora version
39         rts
40 geos10:
41         lda version
42         rts
43 geos11:
44         lda #$11
45         rts
46 geos_on_plus4:
47         lda #$04
48         rts
49 gateway:
50         lda #$08
51         ora c128Flag
52         rts
53 megapatch3:
54         lda #$03
55         ora c128Flag
56         rts
57
58 _get_tv:
59         jsr _get_ostype
60         cmp #$04
61         beq plus4_get_tv
62         bpl only40              ; C64 with 40 columns only
63         lda graphMode
64         bpl only40              ; C128 but currently on 40 columns
65         ldx #1                  ; COLUMNS80
66         bne tvmode
67 only40: ldx #0                  ; COLUMNS40
68 tvmode:                         ; PAL/NTSC check here, result in A
69         php
70         sei                     ; disable interrupts
71         lda CPU_DATA            ; this is for C64
72         pha
73         lda #IO_IN              ; enable access to I/O
74         sta CPU_DATA
75         bit rasreg
76         bpl tvmode              ; wait for rasterline  127<x<256
77         lda #24                 ; (rasterline now >=256!)
78 modelp:
79         cmp rasreg              ; wait for rasterline = 24 (or 280 on PAL)
80         bne modelp
81         lda grcntrl1            ; 24 or 280 ?
82         bpl ntsc
83         lda #0                  ; PAL
84         beq modeend
85 ntsc:
86         lda #$80                ; NTSC
87
88 modeend:
89         stx tmp1
90         ora tmp1
91         sta tmp1
92         ldx #0
93         pla
94         sta CPU_DATA            ; restore memory config
95         plp                     ; restore interrupt state
96         lda tmp1
97         rts
98 plus4_get_tv:
99         ldx #1                  ; Assume PAL
100         bit $FF07               ; Test bit 6
101         bvc plus4pal
102         dex                     ; NTSC
103 plus4pal:
104         txa
105         ldx #0
106         rts