From 5a1dcbbe4c1b32eb42db7c622747954582a4ee0c Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Wed, 11 Sep 2013 23:59:24 +0200 Subject: [PATCH] Reduce flicker by waiting for horizontal retrace before switching ROM and CHARGEN. Can be disabled by setting USEWSYNC to 0. --- libsrc/atari/shadow_ram_handlers.s | 101 ++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 31 deletions(-) diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index adf9085b1..e9b682cf1 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -5,6 +5,7 @@ ; DEBUG = 1 +USEWSYNC= 1 CHKBUF = 1 ; check if bounce buffering is needed (bounce buffering is always done if set to 0) .if .defined(__ATARIXL__) @@ -24,7 +25,22 @@ CHKBUF = 1 ; check if bounce buffering is needed (bounce buffering is always don BUFSZ = 128 ; bounce buffer size BUFSZ_SIO = 256 +.macro wsync +.if USEWSYNC + sta WSYNC +.endif +.endmacro + .macro disable_rom + lda PORTB + and #$fe + wsync + sta PORTB + lda #>__CHARGEN_START__ + sta CHBAS + sta CHBASE +.endmacro +.macro disable_rom_quick lda PORTB and #$fe sta PORTB @@ -32,7 +48,25 @@ BUFSZ_SIO = 256 sta CHBAS sta CHBASE .endmacro +.macro disable_rom_val val + lda val + wsync + sta PORTB + lda #>__CHARGEN_START__ + sta CHBAS + sta CHBASE +.endmacro + .macro enable_rom + lda PORTB + ora #1 + wsync + sta PORTB + lda #$E0 + sta CHBAS + sta CHBASE +.endmacro +.macro enable_rom_quick lda PORTB ora #1 sta PORTB @@ -48,9 +82,9 @@ BUFSZ_SIO = 256 sram_init: ; disable all interrupts - sei ldx #0 stx NMIEN ; disable NMI + sei ; disable ROMs disable_rom @@ -72,9 +106,9 @@ sram_init: sta $fffb ; enable interrupts + cli lda #$40 sta NMIEN - cli rts @@ -104,14 +138,14 @@ bounce_buffer: .res BUFSZ_SIO .macro int_wrap orgvec .local ret pha - enable_rom + enable_rom_quick lda #>ret pha lda #