]> git.sur5r.net Git - cc65/blob - libsrc/geos/system/get_ostype.s
ea6801e5caff68125d9fcbcb3866d168ca2564ae
[cc65] / libsrc / geos / system / get_ostype.s
1
2 ;
3 ; Maciej 'YTM/Elysium' Witkowiak
4 ;
5 ; 10.09.2001
6
7 ; unsigned char get_ostype (void);
8 ; unsigned char get_tv (void);
9
10             .export _get_ostype
11             .export _get_tv
12             .importzp tmp1
13
14             .include "../inc/const.inc"
15             .include "../inc/geossym.inc"
16             .include "../inc/geossym2.inc"
17
18 _get_ostype:
19             ldx #0
20             lda version
21             and #%11110000
22             cmp #$10
23             beq geos10
24             lda c128Flag                ; we're on at least 2.0
25             ora version
26             rts
27 geos10:
28             lda version
29             rts
30
31 _get_tv:
32             jsr _get_ostype
33             bpl only40                  ; C64 with 40 columns only
34             lda graphMode
35             bpl only40                  ; C128 but currently on 40 columns
36             ldx #1                      ; COLUMNS80
37             bne tvmode
38 only40:     ldx #0                      ; COLUMNS40
39 tvmode:                                 ; PAL/NTSC check here, result in A
40             php
41             sei                         ; disable interrupts
42             lda CPU_DATA                ; this is for C64
43             pha
44             lda #IO_IN                  ; enable access to I/O
45             sta CPU_DATA
46             bit rasreg
47             bpl tvmode                  ; wait for rasterline  127<x<256
48             lda #24                     ; (rasterline now >=256!)
49 modelp:     cmp rasreg                  ; wait for rasterline = 24 (or 280 on PAL)
50             bne modelp
51             lda grcntrl1                ; 24 or 280 ?
52             bpl ntsc
53             lda #0                      ; PAL
54             beq modeend
55 ntsc:       lda #$80                    ; NTSC
56
57 modeend:    stx tmp1
58             ora tmp1
59             sta tmp1
60             ldx #0
61             pla
62             sta CPU_DATA                ; restore memory config
63             plp                         ; restore interrupt state
64             lda tmp1
65             rts