From 18e9c6f6a03be1092ca8d8b885f9804b87834d4c Mon Sep 17 00:00:00 2001 From: Dan Sanderson Date: Tue, 18 Nov 2025 00:36:10 -0800 Subject: [PATCH 1/6] c65 target: conio accesses all color RAM in 80x25 text mode --- libsrc/c65/cpeekcolor.s | 11 +++++++++++ libsrc/c65/cputc.s | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/libsrc/c65/cpeekcolor.s b/libsrc/c65/cpeekcolor.s index f4b4a5573..7e4fcf61d 100644 --- a/libsrc/c65/cpeekcolor.s +++ b/libsrc/c65/cpeekcolor.s @@ -18,8 +18,19 @@ _cpeekcolor: lda SCREEN_PTR sta ptr1 + php + sei + lda $d030 + ora #$01 + sta $d030 ldy #0 lda (ptr1),y + tay + lda $d030 + and #$fe + sta $d030 + plp + tya ldx #>$0000 rts diff --git a/libsrc/c65/cputc.s b/libsrc/c65/cputc.s index 926776df0..74a403eb3 100644 --- a/libsrc/c65/cputc.s +++ b/libsrc/c65/cputc.s @@ -116,7 +116,16 @@ putchar: adc #>$d000 sta ptr4 + 1 + php + sei + lda $d030 + ora #$01 + sta $d030 lda CHARCOLOR sta (ptr4),y ; Set color + lda $d030 + and #$fe + sta $d030 + plp rts From cfb55a89d42701bc80e16066dd73579589c100c7 Mon Sep 17 00:00:00 2001 From: Dan Sanderson Date: Tue, 18 Nov 2025 00:47:49 -0800 Subject: [PATCH 2/6] Update coding style for asm --- libsrc/c65/cpeekcolor.s | 10 +++++----- libsrc/c65/cputc.s | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libsrc/c65/cpeekcolor.s b/libsrc/c65/cpeekcolor.s index 7e4fcf61d..0ed0b1792 100644 --- a/libsrc/c65/cpeekcolor.s +++ b/libsrc/c65/cpeekcolor.s @@ -20,15 +20,15 @@ _cpeekcolor: php sei - lda $d030 + lda $D030 ora #$01 - sta $d030 + sta $D030 ldy #0 lda (ptr1),y tay - lda $d030 - and #$fe - sta $d030 + lda $D030 + and #$FE + sta $D030 plp tya diff --git a/libsrc/c65/cputc.s b/libsrc/c65/cputc.s index 74a403eb3..d033ab234 100644 --- a/libsrc/c65/cputc.s +++ b/libsrc/c65/cputc.s @@ -113,19 +113,19 @@ putchar: lda ptr4 + 1 clc - adc #>$d000 + adc #>$D000 sta ptr4 + 1 php sei - lda $d030 + lda $D030 ora #$01 - sta $d030 + sta $D030 lda CHARCOLOR sta (ptr4),y ; Set color - lda $d030 - and #$fe - sta $d030 + lda $D030 + and #$FE + sta $D030 plp rts From 6fb5934b87506ef0124c773869290e4b9ac43bd6 Mon Sep 17 00:00:00 2001 From: Dan Sanderson Date: Tue, 18 Nov 2025 20:22:47 -0800 Subject: [PATCH 3/6] Improve CRAM2K flip to preserve previous value --- libsrc/c65/cpeekcolor.s | 4 ++-- libsrc/c65/cputc.s | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libsrc/c65/cpeekcolor.s b/libsrc/c65/cpeekcolor.s index 0ed0b1792..c32111b88 100644 --- a/libsrc/c65/cpeekcolor.s +++ b/libsrc/c65/cpeekcolor.s @@ -21,13 +21,13 @@ _cpeekcolor: php sei lda $D030 + pha ora #$01 sta $D030 ldy #0 lda (ptr1),y tay - lda $D030 - and #$FE + pla sta $D030 plp tya diff --git a/libsrc/c65/cputc.s b/libsrc/c65/cputc.s index d033ab234..413521f25 100644 --- a/libsrc/c65/cputc.s +++ b/libsrc/c65/cputc.s @@ -119,12 +119,12 @@ putchar: php sei lda $D030 + pha ora #$01 sta $D030 lda CHARCOLOR sta (ptr4),y ; Set color - lda $D030 - and #$FE + pla sta $D030 plp From d2f91a8116b39aa7c60865ea147ec2f7ae19fed9 Mon Sep 17 00:00:00 2001 From: Dan Sanderson Date: Thu, 20 Nov 2025 17:49:40 -0800 Subject: [PATCH 4/6] Assume conio owns Interrupt flag and CRAM2K, don't stash and restore --- libsrc/c65/cputc.s | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libsrc/c65/cputc.s b/libsrc/c65/cputc.s index 413521f25..46b3bddeb 100644 --- a/libsrc/c65/cputc.s +++ b/libsrc/c65/cputc.s @@ -116,16 +116,15 @@ putchar: adc #>$D000 sta ptr4 + 1 - php sei lda $D030 - pha ora #$01 sta $D030 lda CHARCOLOR sta (ptr4),y ; Set color - pla + lda $D030 + and #$FE sta $D030 - plp + cli rts From c14f2b7252164ccc789589d14e6775a724b50ac8 Mon Sep 17 00:00:00 2001 From: Dan Sanderson Date: Thu, 20 Nov 2025 18:03:38 -0800 Subject: [PATCH 5/6] cpeekcolor: don't stash and restore I flag or CRAM2K --- libsrc/c65/cpeekcolor.s | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libsrc/c65/cpeekcolor.s b/libsrc/c65/cpeekcolor.s index c32111b88..5737a7503 100644 --- a/libsrc/c65/cpeekcolor.s +++ b/libsrc/c65/cpeekcolor.s @@ -18,18 +18,17 @@ _cpeekcolor: lda SCREEN_PTR sta ptr1 - php sei lda $D030 - pha ora #$01 sta $D030 ldy #0 lda (ptr1),y tay - pla + lda $D030 + and #$FE sta $D030 - plp + cli tya ldx #>$0000 From 5296d394e47a85f941fd6da896745d5ac310def6 Mon Sep 17 00:00:00 2001 From: Dan Sanderson Date: Fri, 28 Nov 2025 11:09:21 -0800 Subject: [PATCH 6/6] Use php/sei/plp to preserve original state of the interrupt flag --- libsrc/c65/cpeekcolor.s | 3 ++- libsrc/c65/cputc.s | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libsrc/c65/cpeekcolor.s b/libsrc/c65/cpeekcolor.s index 5737a7503..66bb03f4e 100644 --- a/libsrc/c65/cpeekcolor.s +++ b/libsrc/c65/cpeekcolor.s @@ -18,6 +18,7 @@ _cpeekcolor: lda SCREEN_PTR sta ptr1 + php sei lda $D030 ora #$01 @@ -28,8 +29,8 @@ _cpeekcolor: lda $D030 and #$FE sta $D030 - cli tya + plp ldx #>$0000 rts diff --git a/libsrc/c65/cputc.s b/libsrc/c65/cputc.s index 46b3bddeb..d033ab234 100644 --- a/libsrc/c65/cputc.s +++ b/libsrc/c65/cputc.s @@ -116,6 +116,7 @@ putchar: adc #>$D000 sta ptr4 + 1 + php sei lda $D030 ora #$01 @@ -125,6 +126,6 @@ putchar: lda $D030 and #$FE sta $D030 - cli + plp rts