1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00
cc65/libsrc/atari7800/get_tv.s

66 lines
1.1 KiB
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
;
2022-04-16 16:16:14 +00:00
.include "atari7800.inc"
.include "get_tv.inc"
.export _get_tv
.export _paldetected
2022-03-22 19:28:35 +00:00
2022-04-16 16:16:14 +00:00
.segment "DATA"
2022-03-22 19:28:35 +00:00
_paldetected:
2022-04-16 16:16:14 +00:00
.byte $FF
2022-03-22 19:28:35 +00:00
; ---------------------------------------------------------------
; unsigned char get_tv (void)
; ---------------------------------------------------------------
2022-03-22 19:28:35 +00:00
2022-04-16 16:16:14 +00:00
.segment "CODE"
2022-04-16 16:16:14 +00:00
.proc _get_tv: near
2022-04-16 16:16:14 +00:00
.segment "CODE"
2022-04-16 16:16:14 +00:00
ldx #$00
lda #$FF
cmp _paldetected
bne L8
L1: lda MSTAT
and #$80
bne L1
L2: lda MSTAT
and #$80
beq L2
L3: lda MSTAT
and #$80
bne L3
lda #$00
sta M0001
jmp L5
L4: sta MWSYNC
sta MWSYNC
dec M0001
L5: lda MSTAT
and #$80
beq L4
lda M0001
cmp #$78
bcc L6
lda #TV::NTSC
jmp L7
L6: lda #TV::PAL
L7: sta _paldetected
ldx #$00
L8: lda _paldetected
rts
2022-03-22 19:28:35 +00:00
2022-04-16 16:16:14 +00:00
.segment "BSS"
M0001:
2022-04-16 16:16:14 +00:00
.res 1,$00
2022-03-22 19:28:35 +00:00
.endproc