1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00
cc65/libsrc/atari7800/get_tv.s

66 lines
976 B
ArmAsm
Raw Normal View History

2022-03-22 19:28:35 +00:00
;
; Karri Kaksonen, 2022-03-25
2022-03-22 19:28:35 +00:00
;
; unsigned char get_tv (void)
2022-03-22 19:28:35 +00:00
;
.include "atari7800.inc"
2022-03-25 13:02:43 +00:00
.include "get_tv.inc"
.export _get_tv
2022-03-25 13:08:14 +00:00
.export _paldetected
2022-03-22 19:28:35 +00:00
.segment "DATA"
2022-03-22 19:28:35 +00:00
_paldetected:
.byte $FF
2022-03-22 19:28:35 +00:00
; ---------------------------------------------------------------
; unsigned char get_tv (void)
; ---------------------------------------------------------------
2022-03-22 19:28:35 +00:00
.segment "CODE"
.proc _get_tv: near
.segment "CODE"
ldx #$00
lda #$FF
cmp _paldetected
bne L8
2022-03-25 13:02:43 +00:00
L1: lda MSTAT
and #$80
bne L1
2022-03-25 13:02:43 +00:00
L2: lda MSTAT
and #$80
beq L2
2022-03-25 13:02:43 +00:00
L3: lda MSTAT
and #$80
bne L3
lda #$00
sta M0001
jmp L5
2022-03-25 13:02:43 +00:00
L4: sta MWSYNC
sta MWSYNC
dec M0001
2022-03-25 13:02:43 +00:00
L5: lda MSTAT
and #$80
beq L4
lda M0001
cmp #$78
bcc L6
2022-03-25 13:02:43 +00:00
lda #TV::NTSC
jmp L7
2022-03-25 13:02:43 +00:00
L6: lda #TV::PAL
L7: sta _paldetected
ldx #$00
L8: lda _paldetected
2022-03-22 19:28:35 +00:00
rts
.segment "BSS"
M0001:
.res 1,$00
2022-03-22 19:28:35 +00:00
.endproc