Separate machine detection from crt0 and put it in get_tv

This commit is contained in:
Karri Kaksonen
2022-03-25 14:44:54 +02:00
parent 4c3120b935
commit 8d0b0e6ffc
2 changed files with 53 additions and 43 deletions

View File

@@ -1,26 +1,63 @@
;
; Stefan Haubenthal, 2007-01-21
; Karri Kaksonen, 2022-03-25
;
; unsigned char get_tv (void);
; /* Return the video mode the machine is using */
; unsigned char get_tv (void)
;
.include "atari7800.inc"
.export _get_tv
.include "atari7800.inc"
.include "get_tv.inc"
.importzp tmp1, tmp2
.import _paldetected
.segment "DATA"
;--------------------------------------------------------------------------
; _get_tv
_paldetected:
.byte $FF
.proc _get_tv
; ---------------------------------------------------------------
; unsigned char get_tv (void)
; ---------------------------------------------------------------
lda _paldetected
beq ntsc
lda #TV::PAL
rts
ntsc:
lda #TV::NTSC
.segment "CODE"
.proc _get_tv: near
.segment "CODE"
ldx #$00
lda #$FF
cmp _paldetected
bne L8
L1: lda $0028
and #$80
bne L1
L2: lda $0028
and #$80
beq L2
L3: lda $0028
and #$80
bne L3
lda #$00
sta M0001
jmp L5
L4: sta $0024
sta $0024
dec M0001
L5: lda $0028
and #$80
beq L4
lda M0001
cmp #$78
bcc L6
lda #$00
jmp L7
L6: lda #$01
L7: sta _paldetected
ldx #$00
L8: lda _paldetected
rts
.segment "BSS"
M0001:
.res 1,$00
.endproc