From 6377e896de980764ad16e909b8291968ee9b9723 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Thu, 26 Nov 2026 13:59:09 -0500 Subject: [PATCH] M0.1: game glyphs at screen codes 128+ so conio text stays readable cc65 conio writes capital letters as screen codes 65-90, which collided with the game glyphs at 64-69. Copy ROM codes 0-127 from the lower/upper-case set and move the glyphs to 128-133. Spec Visuals decision and project.json updated to match (approved by user). M0 smoke passes; manual check pending. Co-Authored-By: Claude Opus 5.5 --- docs/spec.md | 2 +- docs/verification-status.md | 3 ++- project.json | 2 +- src/charset.c | 32 +++++++++++++++++++------------- src/charset.h | 21 +++++++++++++-------- src/main.c | 4 ++-- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/docs/spec.md b/docs/spec.md index 0599ba4..c67900e 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -177,7 +177,7 @@ Capabilities: text-ui | Topic | Decision | Source | |---|---|---| | Controls | Commodore 1351 mouse in control port 1 (proportional mode): a sprite pointer, the dig cursor is the tile under the pointer, the left button marks/unmarks, the pointer at a view edge scrolls the map. Joystick in port 2: move the cursor, fire marks/unmarks. Keyboard: cursor keys or W/A/S/D move, D marks/unmarks, SPACE pauses/resumes. All three can be used together. | decided by user | -| Visuals | Character mode with an original custom character set at $3800 (VIC bank 0, screen at $0400): codes 0-63 copied from the uppercase ROM set so text stays readable, codes 64+ hold the game's own glyphs (soft rock, hard rock, floor, marked rock, dwarf, cursor). Colours: rock brown, hard rock grey, floor dark grey, marked rock yellow, dwarves orange, cursor white, on a black background. The mouse pointer is hardware sprite 0. | decided by user | +| Visuals | Character mode with an original custom character set at $3800 (VIC bank 0, screen at $0400): codes 0-127 copied from the lower/upper-case ROM set so conio text (capital letters at screen codes 65-90) stays readable, codes 128+ hold the game's own glyphs (soft rock, hard rock, floor, marked rock, dwarf, cursor). Colours: rock brown, hard rock grey, floor dark grey, marked rock yellow, dwarves orange, cursor white, on a black background. The mouse pointer is hardware sprite 0. | decided by user | | Sound | SID effects only: a mark/unmark click and a pick strike while mining. No music. | decided by user | | Persistence (save/load) | None. Nothing is saved in the first release. | not applicable | | File formats | None. A single PRG. | not applicable | diff --git a/docs/verification-status.md b/docs/verification-status.md index cb9a9d0..9721c64 100644 --- a/docs/verification-status.md +++ b/docs/verification-status.md @@ -8,7 +8,7 @@ manual = `pending`, `confirmed by user ()`, `problem reported (): )`, `problem reported (): #include "charset.h" -#define CPU_PORT (*(unsigned char *)0x01) -#define CHARROM ((const unsigned char *)0xD000) +#define CPU_PORT (*(unsigned char *)0x01) +#define CHARROM_MIX ((const unsigned char *)0xD800) /* lower/upper-case ROM set */ /* Original game glyphs, 8 bytes each, in screen-code order starting at GLYPH_ROCK_SOFT. */ static const unsigned char glyphs[] = { - /* 64 soft rock: rough solid block */ + /* soft rock: rough solid block */ 0xFF, 0xDD, 0xFF, 0x77, 0xFF, 0xDD, 0xFF, 0x77, - /* 65 hard rock: dense crosshatch */ + /* hard rock: dense crosshatch */ 0xFF, 0x99, 0xFF, 0x66, 0xFF, 0x99, 0xFF, 0x66, - /* 66 floor: sparse pebbles */ + /* floor: sparse pebbles */ 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, - /* 67 marked rock: framed X */ + /* marked rock: framed X */ 0xFF, 0xC3, 0xA5, 0x99, 0x99, 0xA5, 0xC3, 0xFF, - /* 68 dwarf: hooded figure */ + /* dwarf: hooded figure */ 0x18, 0x3C, 0x18, 0x7E, 0x5A, 0x18, 0x24, 0x66, - /* 69 cursor: corner brackets */ + /* cursor: corner brackets */ 0xE7, 0x81, 0x81, 0x00, 0x00, 0x81, 0x81, 0xE7 }; +static unsigned char saved_vic_addr; + void charset_install(void) { unsigned char *dst = (unsigned char *)CHARSET_ADDR; @@ -30,12 +32,13 @@ void charset_install(void) memset(dst, 0, 2048); - /* Map the character ROM in at $D000 (clear CHAREN) to copy codes 0-63. */ + /* Map the character ROM in at $D000 (clear CHAREN) and copy codes 0-127 + ** of the lower/upper-case set, so conio text keeps its normal shapes. */ __asm__("sei"); old_port = CPU_PORT; CPU_PORT = (unsigned char)(old_port & 0xFB); - for (i = 0; i < 64u * 8u; ++i) { - dst[i] = CHARROM[i]; + for (i = 0; i < 128u * 8u; ++i) { + dst[i] = CHARROM_MIX[i]; } CPU_PORT = old_port; __asm__("cli"); @@ -43,10 +46,13 @@ void charset_install(void) memcpy(dst + GLYPH_ROCK_SOFT * 8u, glyphs, sizeof glyphs); /* Screen at $0400 (upper nibble 1), charset at $3800 (bits 1-3 = 7). */ - VIC.addr = 0x1E; + saved_vic_addr = VIC.addr; + VIC.addr = (unsigned char)((saved_vic_addr & 0xF0) | 0x0E); } void charset_remove(void) { - VIC.addr = 0x15; /* screen $0400, ROM uppercase set */ + if (saved_vic_addr != 0) { + VIC.addr = saved_vic_addr; + } } diff --git a/src/charset.h b/src/charset.h index fe715bf..81b5830 100644 --- a/src/charset.h +++ b/src/charset.h @@ -4,18 +4,23 @@ /* Custom character set location (VIC bank 0, 2 KB). See docs and assumption A3. */ #define CHARSET_ADDR 0x3800u -/* Game glyph screen codes (codes 0-63 keep the ROM letter shapes). */ -#define GLYPH_ROCK_SOFT 64 -#define GLYPH_ROCK_HARD 65 -#define GLYPH_FLOOR 66 -#define GLYPH_MARKED 67 -#define GLYPH_DWARF 68 -#define GLYPH_CURSOR 69 +/* Game glyph screen codes. +** cc65 runs the C64 in the lower/upper-case character set, where conio puts +** capital letters at screen codes 65-90. Codes 0-127 therefore keep the ROM +** lower/upper-case shapes, and the game's own glyphs live at 128 and up. +** (Codes 128-255 are the reverse-video copies in ROM; this game does not use revers().) +*/ +#define GLYPH_ROCK_SOFT 128 +#define GLYPH_ROCK_HARD 129 +#define GLYPH_FLOOR 130 +#define GLYPH_MARKED 131 +#define GLYPH_DWARF 132 +#define GLYPH_CURSOR 133 /* Build the charset at CHARSET_ADDR and point the VIC-II at it. */ void charset_install(void); -/* Point the VIC-II back at the ROM uppercase set. */ +/* Point the VIC-II back at the character set that was active before charset_install(). */ void charset_remove(void); #endif diff --git a/src/main.c b/src/main.c index cc08d04..eb29d0f 100644 --- a/src/main.c +++ b/src/main.c @@ -5,8 +5,8 @@ ** (wait_frame() from frame.s) with a visible frame counter. ** ** Character set layout: -** codes 0-63 copied from the uppercase ROM set (letters, digits, punctuation) -** codes 64-69 game glyphs (see charset.h) +** codes 0-127 copied from the lower/upper-case ROM set (conio puts capitals at 65-90) +** codes 128-133 game glyphs (see charset.h) ** ** Screen layout (40x25 text, VIC-II): ** row 0 title