From 153b42249616fbbcbc04752eb460ad97f551589b Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 20 Nov 2022 19:19:01 +0100 Subject: [PATCH] cx16: retain display mode (composite etc) --- compiler/res/prog8lib/cx16/gfx2.p8 | 7 +++---- compiler/res/prog8lib/cx16/syslib.p8 | 9 ++++++++- examples/cx16/testgfx2.p8 | 10 +++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 9b5385751..63d076976 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -82,11 +82,10 @@ gfx2 { bpp = 2 } else -> { - ; back to default text mode and colors - cx16.VERA_CTRL = %10000000 ; reset VERA and palette - c64.IOINIT() - c64.RESTOR() + ; back to default text mode + cx16.r15L = cx16.VERA_DC_VIDEO & %00000111 ; retain chroma + output mode c64.CINT() + cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11111000) | cx16.r15L width = 0 height = 0 bpp = 0 diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index e394a1754..670eb8f09 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -613,12 +613,19 @@ asmsub init_system() { %asm {{ sei cld + lda VERA_DC_VIDEO + and #%00000111 ; retain chroma + output mode + sta P8ZP_SCRATCH_REG lda #$80 - sta VERA_CTRL + sta VERA_CTRL ; reset vera stz $01 ; select rom bank 0 (enable kernal) jsr c64.IOINIT jsr c64.RESTOR jsr c64.CINT + lda VERA_DC_VIDEO + and #%11111000 + ora P8ZP_SCRATCH_REG + sta VERA_DC_VIDEO ; keep old output mode lda #$90 ; black jsr c64.CHROUT lda #1 ; swap fg/bg diff --git a/examples/cx16/testgfx2.p8 b/examples/cx16/testgfx2.p8 index 24773f1e0..5263e3b33 100644 --- a/examples/cx16/testgfx2.p8 +++ b/examples/cx16/testgfx2.p8 @@ -1,22 +1,22 @@ %import gfx2 %import textio -%import test_stack %import math +%option no_sysinit +%zeropage basicsafe + main { sub start() { gfx2.screen_mode(5) -; demo1() -; sys.wait(3*60) + demo1() + sys.wait(2*60) demo2() gfx2.screen_mode(0) txt.print("done!\n") - - test_stack.test() } sub demo1() {