Bitmap graphics working.
This commit is contained in:
parent
949258c1ab
commit
bf26570362
5 changed files with 34 additions and 31 deletions
|
@ -31,6 +31,7 @@ PATH=${LLVM}/bin:${PATH}
|
|||
START=0x2000
|
||||
|
||||
echo "__f256_start = ${START};" > ${SETTINGS}
|
||||
:<<SKIP
|
||||
mos-f256k-clang \
|
||||
-fno-builtin-memset \
|
||||
-I${F256}/include \
|
||||
|
@ -39,6 +40,14 @@ mos-f256k-clang \
|
|||
-Os \
|
||||
pgztest.c \
|
||||
${F256}/f256lib/f256.c
|
||||
SKIP
|
||||
|
||||
CLANG="mos-f256k-clang -I${F256}/include -I${F256}/f256lib -Os"
|
||||
|
||||
${CLANG} -c ${F256}/f256lib/f256.c
|
||||
${CLANG} -c pgztest.c
|
||||
${CLANG} -o pgztest pgztest.o f256.o
|
||||
|
||||
mv -f pgztest pgztest.bin
|
||||
|
||||
${F256}/header/header \
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "bitmap.h"
|
||||
|
||||
|
||||
static int _MAX_X = 320;
|
||||
static int _MAX_Y = 200;
|
||||
static int32_t _MAX_X = 320;
|
||||
static int32_t _MAX_Y = 240;
|
||||
static uint32_t _BITMAP_BASE = 0x10000;
|
||||
static byte _color = 255;
|
||||
|
||||
|
@ -33,13 +33,14 @@ static byte _color = 255;
|
|||
char error;
|
||||
|
||||
|
||||
void clear(void) {
|
||||
int x;
|
||||
int y;
|
||||
void clearBitmap(void) {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
//***TODO*** Use DMA
|
||||
|
||||
// This is just test code.
|
||||
setGraphicsColor(0);
|
||||
for (y=0; y<_MAX_Y; y++) {
|
||||
for (x=0; x<_MAX_X; x++) {
|
||||
putpixel(x, y);
|
||||
|
@ -66,17 +67,16 @@ void defineGraphicsColor(byte slot, byte r, byte g, byte b) {
|
|||
|
||||
|
||||
void putpixel(int x, int y) {
|
||||
uint32_t pixelRAM;
|
||||
byte block;
|
||||
uint32_t pixelRAM;
|
||||
byte block;
|
||||
|
||||
// We only map 8k of the bitmap into CPU RAM at once.
|
||||
// We use slot 5 for this. We need to figure out
|
||||
// where our pixel lands and bring that into RAM.
|
||||
pixelRAM = _BITMAP_BASE + (y * _MAX_X) + x;
|
||||
block = pixelRAM / 0x2000;
|
||||
pixelRAM &= 0x1FFF; // Find offset into this block.
|
||||
POKE(MMU_MEM_BANK_5, block);
|
||||
//pixelRAM -= 0x2000 * block; // Find offset into this block.
|
||||
pixelRAM &= 0x1FFF;
|
||||
POKE(0xa000 + pixelRAM, _color);
|
||||
POKE(MMU_MEM_BANK_5, 5);
|
||||
}
|
||||
|
@ -84,11 +84,10 @@ void putpixel(int x, int y) {
|
|||
|
||||
void resetGraphics(void) {
|
||||
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||
byte x;
|
||||
int y;
|
||||
int x;
|
||||
|
||||
_MAX_X = 320;
|
||||
_MAX_Y = 200;
|
||||
_MAX_Y = 240;
|
||||
_BITMAP_BASE = 0x10000;
|
||||
_color = 255;
|
||||
|
||||
|
@ -101,23 +100,17 @@ void resetGraphics(void) {
|
|||
|
||||
// Set up bitmap 0.
|
||||
POKE(VKY_BM0_CTRL, 1); // Enable bitmap 0, GLUT 0.
|
||||
//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.
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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]) {
|
||||
|
|
Loading…
Add table
Reference in a new issue