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