Subject: Re: [stella] PAL/NTSC Auto-Detect - Cleaned Up with Source From: Christopher Tumber <christophertumber@xxxxxxxxxx> Date: Fri, 15 Nov 2002 18:47:01 -0500 |
Call me unable to leave well enough alone, but here it is cleaned up. It may still be possible to remove some extraneous code but I think it's down to the essentials (The auto-detect routine is 126 bytes; Code to draw the PAL/NTSC text is considerably longer...) Chris...
;NTSC/PAL Auto-Detect ;Nov, 15 2002 ;by Christopher L Tumber ; ;Result winds up in $80 but you certainly don't have to do it that way processor 6502 include vcs.h VDEL01 = $26 org $F000 Start LDX #$FF TXS ;Set stack to beginning jsr FindPALorNTSC jmp DrawStatus FindPALorNTSC: LDA #2 STA VSYNC ;Begin vertical sync. STA WSYNC ; First line of VSYNC STA WSYNC ; Second line of VSYNC. LDA #41 STA TIM64T LDA #0 STA CXCLR STA WSYNC ; Third line of VSYNC. STA VSYNC ; (0) DrawScreen LDA INTIM BNE DrawScreen STA WSYNC STA VBLANK ;End the VBLANK period with a zero. STA WSYNC STA HMCLR JSR LF03D lda CXPPMM and #128 sta $80 ;Save result of NTSC/PAL check rts LF000: .byte $02 LF03D: LDA #$00 STA WSYNC STA HMOVE STA COLUBK STA CTRLPF LDA #$D0 STA HMP0 LDA #$20 STA HMP1 LDY LF000 LF066: NOP DEY BNE LF066 STA RESP0 STA RESP1 LDA #$01 STA VDELP0 STA VDEL01 STA WSYNC STA HMOVE STA GRP0 STA GRP1 STA GRP0 LDA #$03 STA NUSIZ0 STA NUSIZ1 STA HMCLR LDA #$ff STA WSYNC STA HMOVE STY $BD STA GRP0 NOP sta $2e ;Waste 3 cycles STA GRP1 NOP sta $2e ;Waste 3 cycles STA GRP0 LDA #$00 STA WSYNC STA VDELP0 STA VDEL01 RTS DrawStatus: LDX #0 LDA #2 STA VSYNC ;Begin vertical sync. STA WSYNC ; First line of VSYNC STA WSYNC ; Second line of VSYNC. LDA #41 STA TIM64T LDA #0 STA CXCLR STA WSYNC ; Third line of VSYNC. STA VSYNC ; (0) DrawScreen2 LDA INTIM BNE DrawScreen2 STA WSYNC STA VBLANK ;End the VBLANK period with a zero. ldy #7 lda $80 beq DrawPAL ldy #15 DrawPAL: sta WSYNC lda #$00 sta GRP0 sta GRP1 lda #0 sta COLUBK lda #$ff sta COLUPF sta COLUP0 sta COLUP1 lda #3 sta NUSIZ0 sta NUSIZ1 sta RESP0 sta RESP1 nextrow: sta WSYNC lda char1,y sta GRP0 lda char2,y sta GRP1 nop nop nop nop nop nop nop lda char3,y ldx char4,y sta GRP0 stx GRP1 lda #0 sta GRP0 sta GRP1 dey bmi donedraw cpy #7 beq donedraw jmp nextrow donedraw: sta WSYNC lda #$00 sta GRP0 sta GRP1 ldy #186 nextblankline2: sta WSYNC dey bne nextblankline2 LDA #2 STA WSYNC ;Finish this scanline. STA VBLANK ; Make TIA output invisible, lda #35 sta TIM64T OverScanWait2: lda INTIM bne OverScanWait2 jmp DrawStatus org $fa00 char1: .byte 66,70,78,90,114,98,66,66 .byte 64,64,64,64,126,66,66,126 char2: .byte 24,24,24,24,24,24,24,126 .byte 66,66,66,66,126,66,66,126 char3: .byte 126,2,2,126,126,64,64,126 .byte 126,64,64,64,64,64,64,64 char4: .byte 126,64,64,64,64,64,64,126 .byte 0,0,0,0,0,0,0,0 org $FFFC .word Start .word Start
Attachment:
NTSCPAL3.BIN
Description: Binary data
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[stella] PAL/NTSC Auto-Detect (Need, Christopher Tumber | Thread | Re: [stella] PAL/NTSC Auto-Detect (, Andrew Wallace |
Re: [stella] PAL/NTSC Auto-Detect (, Paul Slocum | Date | Re: [stella] PAL/NTSC Auto-Detect (, Christopher Tumber |
Month |