From bf265703626be94ce5a219b68f243a9edb5a8410 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Thu, 4 Jan 2024 18:54:37 -0600 Subject: [PATCH] Bitmap graphics working. --- examples/pgztest/build.sh | 9 ++++++++ f256lib/bitmap.c | 47 +++++++++++++++++---------------------- f256lib/bitmap.h | 2 +- f256lib/f256.c | 1 + f256lib/text.c | 6 ++--- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/examples/pgztest/build.sh b/examples/pgztest/build.sh index 5e4df1d..7064004 100755 --- a/examples/pgztest/build.sh +++ b/examples/pgztest/build.sh @@ -31,6 +31,7 @@ PATH=${LLVM}/bin:${PATH} START=0x2000 echo "__f256_start = ${START};" > ${SETTINGS} +:<> 8) & 0xFF); // Location of bitmap data. - POKE(VKY_BM0_ADDR_H, (_BITMAP_BASE >> 16) & 0xFF); // Location of bitmap data. - - // Set palette to a gradient so there's at least *something*. - for (x=0; x<=255; x++) defineGraphicsColor(x, x, x, x); - - clear(); - - /* - POKE(MMU_MEM_BANK_5, 8); - for (y=0; y<8192; y++) POKE(0xa000 + y, 255); - POKE(MMU_MEM_BANK_5, 5); - */ + POKED(VKY_BM0_ADDR_L, _BITMAP_BASE); // Location of bitmap data. + //POKE(VKY_BM0_ADDR_L, _BITMAP_BASE & 0xFF); // Location of bitmap data. + //POKE(VKY_BM0_ADDR_M, (_BITMAP_BASE >> 8) & 0xFF); // Location of bitmap data. + //POKE(VKY_BM0_ADDR_H, (_BITMAP_BASE >> 16) & 0xFF); // Location of bitmap data. POKE(MMU_IO_CTRL, mmu); // Restore MMU state. + + // Set palette to a gradient so there's at least *something*. + for (x=0; x<256; x++) defineGraphicsColor(x, x, x, x); + + clearBitmap(); } diff --git a/f256lib/bitmap.h b/f256lib/bitmap.h index 7545692..1627206 100644 --- a/f256lib/bitmap.h +++ b/f256lib/bitmap.h @@ -34,7 +34,7 @@ extern "C" #include "f256.h" -void clear(void); +void clearBitmap(void); void defineGraphicsColor(byte slot, byte r, byte g, byte b); void putpixel(int x, int y); void resetGraphics(void); diff --git a/f256lib/f256.c b/f256lib/f256.c index b1f6a65..a86afd0 100644 --- a/f256lib/f256.c +++ b/f256lib/f256.c @@ -32,6 +32,7 @@ void f256Init(void) { POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6. + //POKE(VKY_MSTR_CTRL_0, 1); // Enable text. POKE(VKY_MSTR_CTRL_0, 12); // Enable bitmaps. //POKE(VKY_MSTR_CTRL_0, 15); // Enable text and bitmaps. //POKE(VKY_MSTR_CTRL_0, 63); // Enable text and all graphics. diff --git a/f256lib/text.c b/f256lib/text.c index cdba9b2..577a4ad 100644 --- a/f256lib/text.c +++ b/f256lib/text.c @@ -59,8 +59,8 @@ static byte _ccolor = 240; // Clear screen to current text attributes. void cls(void) { int i; - byte *vram = (byte *)TEXT_MATRIX; byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state. + volatile byte *vram = (byte *)TEXT_MATRIX; POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6. for (i = 0; i < _MAX_COL * _MAX_ROW; i++) *vram++ = 32; @@ -122,9 +122,9 @@ void print(char *message) { int x = 0; int i = 0; int j = 0; - byte *vram = (byte *)TEXT_MATRIX + _col + (_MAX_COL * _row); - byte *save = 0; byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state. + volatile byte *vram = (byte *)TEXT_MATRIX + _col + (_MAX_COL * _row); + volatile byte *save = 0; while (message[x] != 0) { switch (message[x]) {