From 6be2806499299bb13edde3481803f28416429902 Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 1 Mar 2007 00:36:54 +0000 Subject: Changed lower screen to 8-bits and added overlayed text mode. Monitor stub in place. Text mode helpers being developed. --- source/framebuffer.c | 193 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 139 insertions(+), 54 deletions(-) (limited to 'source/framebuffer.c') diff --git a/source/framebuffer.c b/source/framebuffer.c index 691862e..6d16529 100644 --- a/source/framebuffer.c +++ b/source/framebuffer.c @@ -25,12 +25,16 @@ #include #include +#include "framebuffer.h" + /* ---------------------------------------- STATIC DATA */ #define WIDTH 256 +#define SCAN 128 #define HEIGHT 192 -static uint16 *buff=0; +static uint16 *buff; +static uint16 *pal; static uint8 font[]= { @@ -132,60 +136,138 @@ static uint8 font[]= 0x3c, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3c }; + +/* ---------------------------------------- PRIVATE INTERFACES +*/ +static inline void Plot(int x, int y, int col) +{ + uint16 *base; + uint16 cur; + int odd; + + if (col == -1) + return; + + odd = x&1; + x /= 2; + + base = buff+x+y*SCAN; + cur = *base; + + if (odd) + { + cur = (cur & 0xff) | (col<<8); + } + else + { + cur = (cur & 0xff00) | col; + } + + *base = cur; +} + + /* ---------------------------------------- PUBLIC INTERFACES */ -void FB_Init(uint16 *vram) +void FB_Init(uint16 *vram, uint16 *palette) { - buff=vram; + buff = vram; + pal = palette; + + pal[COL_BLACK] = RGB15(0,0,0); + pal[COL_WHITE] = RGB15(31,31,31); + pal[COL_RED] = RGB15(31,0,0); + pal[COL_GREEN] = RGB15(0,31,0); + pal[COL_BLUE] = RGB15(0,0,31); + pal[COL_GUISELECT] = RGB15(8,8,31); + pal[COL_GREY] = RGB15(15,15,15); + pal[COL_LIGHTGREY] = RGB15(22,22,22); + pal[COL_DARKGREY] = RGB15(8,8,8); + pal[COL_YELLOW] = RGB15(31,31,0); } -void FB_Print(const char *text, int x, int y, int colour, int paper) +void FB_LoadASCIITiles(uint16 *tiles) { - uint16 *base; + uint8 *src; + int c; + int row; + int val; + int mask; - base=buff+y*WIDTH+x; + src = font; - while(*text) + for(c = 32; c < 127; c++) { - int x,y; - int ch; + for(row = 0; row < 8; row++) + { + for(mask = 1; mask < 0xff; mask<<=1) + { + if (*src & mask) + { + val = COL_WHITE; + } + else + { + val = 0; + } + + mask <<= 1; + + if (*src & mask) + { + val |= COL_WHITE << 8; + } + + *tiles++ = val; + } + + src++; + } + } +} + +void FB_Print(const char *text, int x, int y, FB_Colour colour, FB_Colour paper) +{ + int cx,cy; + int ch; + + while(*text) + { ch=((*text)-32)*8; - for(y=0;y<8;y++) + for(cy=0;cy<8;cy++) { - for(x=0;x<8;x++) + for(cx=0;cx<8;cx++) { - if (font[ch]&(1<width==WIDTH && img->height==HEIGHT) + uint16 *dest; + uint16 *row; + uint8 *src; + uint16 pix; + int hww; + int ht; + int f; + + x /= 2; + + ht = img->height; + hww = img->width / 2; + dest = buff+x+y*SCAN; + src = img->image.data8; + + for(f=0;f<16;f++) { - dmaCopy(img->image.data8,buff,SCREEN_WIDTH*SCREEN_HEIGHT*2); + pal[offset+f] = img->palette[f]; } - else + + while(ht--) { - int f; + row = dest; - for(f=0;fheight;f++) + for(f=0;fimage.data16+(f*img->width), - buff+x+(y+f)*WIDTH,img->width*2); + pix = *src++ + offset; + pix |= (*src++ + offset) << 8; + + *row++ = pix; } + + dest += SCAN; } } -- cgit v1.2.3