|
|
| version 1.3, 2004/03/10 02:42:51 | version 1.5, 2004/03/25 08:51:23 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "bmpdata.h" | |
| #include "scrnmng.h" | #include "scrnmng.h" |
| #include "cpucore.h" | #include "cpucore.h" |
| #include "font.h" | #include "font.h" |
| #include "cmndraw.h" | #include "cmndraw.h" |
| #include "minifont.res" | |
| void cmndraw_getpals(CMNPALFN *fn, CMNPAL *pal, UINT pals) { | void cmndraw_getpals(CMNPALFN *fn, CMNPALS *pal, UINT pals) { |
| UINT i; | UINT i; |
| Line 426 const BYTE *p; | Line 428 const BYTE *p; |
| // ---- | // ---- |
| void cmddraw_fill(CMNVRAM *vram, int x, int y, int cx, int cy, CMNPAL *pal) { | void cmddraw_fill(CMNVRAM *vram, int x, int y, int cx, int cy, CMNPALS *pal) { |
| if ((vram == NULL) || (pal == NULL)) { | if ((vram == NULL) || (pal == NULL)) { |
| return; | return; |
| Line 455 void cmddraw_fill(CMNVRAM *vram, int x, | Line 457 void cmddraw_fill(CMNVRAM *vram, int x, |
| } | } |
| } | } |
| void cmddraw_text8(CMNVRAM *vram, int x, int y, const char *str, CMNPAL *pal) { | void cmddraw_text8(CMNVRAM *vram, int x, int y, const char *str, CMNPALS *pal) { |
| UINT s; | UINT s; |
| const BYTE *ptr; | |
| BYTE src[10]; | BYTE src[10]; |
| if ((vram == NULL) || (str == NULL) || (pal == NULL)) { | if ((vram == NULL) || (str == NULL) || (pal == NULL)) { |
| return; | return; |
| } | } |
| src[0] = 8; | src[0] = 0; |
| src[1] = 8; | src[1] = 7; |
| while(*str) { | while(*str) { |
| s = (UINT)(*str++); | s = (UINT)(*str++); |
| CopyMemory(src + 2, fontrom + 0x82000 + (s * 16), 8); | ptr = NULL; |
| if ((s >= 0x20) && (s < 0x80)) { | |
| ptr = minifont + (s - 0x20) * 8; | |
| } | |
| else if ((s >= 0xa0) && (s < 0xe0)) { | |
| ptr = minifont + (s - 0xa0 + 0x60) * 8; | |
| } | |
| if (ptr == NULL) { | |
| continue; | |
| } | |
| src[0] = ptr[0]; | |
| CopyMemory(src + 2, ptr + 1, 7); | |
| switch(vram->bpp) { | switch(vram->bpp) { |
| #if defined(SUPPORT_8BPP) | #if defined(SUPPORT_8BPP) |
| case 8: | case 8: |
| Line 490 void cmddraw_text8(CMNVRAM *vram, int x, | Line 504 void cmddraw_text8(CMNVRAM *vram, int x, |
| break; | break; |
| #endif | #endif |
| } | } |
| x += 8; | x += ptr[0] + 1; |
| } | |
| } | |
| // ---- bmp | |
| void cmddraw_bmp16(CMNVRAM *vram, const void *bmp, CMNPALCNV cnv) { | |
| const BMPFILE *bf; | |
| const BMPINFO *bi; | |
| const BYTE *palptr; | |
| BMPDATA inf; | |
| BYTE *src; | |
| int bmpalign; | |
| UINT pals; | |
| UINT c; | |
| RGB32 paltbl[16]; | |
| CMNPAL pal[16]; | |
| BYTE *dst; | |
| int yalign; | |
| int x; | |
| int y; | |
| if ((vram == NULL) || (bmp == NULL) || (cnv == NULL)) { | |
| return; | |
| } | |
| bf = (BMPFILE *)bmp; | |
| bi = (BMPINFO *)(bf + 1); | |
| palptr = (BYTE *)(bi + 1); | |
| if (((bf->bfType[0] != 'B') && (bf->bfType[1] != 'M')) || | |
| (bmpdata_getinfo(bi, &inf) != SUCCESS) || (inf.bpp != 4)) { | |
| return; | |
| } | |
| src = (BYTE *)bf + (LOADINTELDWORD(bf->bfOffBits)); | |
| bmpalign = bmpdata_getalign(bi); | |
| if (inf.height > 0) { | |
| src += (inf.height - 1) * bmpalign; | |
| bmpalign *= -1; | |
| } | |
| else { | |
| inf.height *= -1; | |
| } | |
| if ((vram->width < inf.width) || (vram->height < inf.height)) { | |
| return; | |
| } | |
| pals = LOADINTELDWORD(bi->biClrUsed); | |
| pals = min(pals, 16); | |
| ZeroMemory(paltbl, sizeof(paltbl)); | |
| for (c=0; c<pals; c++) { | |
| paltbl[c].p.b = palptr[c*4+0]; | |
| paltbl[c].p.g = palptr[c*4+1]; | |
| paltbl[c].p.r = palptr[c*4+2]; | |
| } | |
| (*cnv)(pal, paltbl, pals, vram->bpp); | |
| dst = vram->ptr; | |
| #if 0 | |
| dst += ((vram->width - inf.width) / 2) * vram->xalign; | |
| dst += ((vram->height - inf.height) / 2) * vram->yalign; | |
| #endif | |
| yalign = vram->yalign - (inf.width * vram->xalign); | |
| switch(vram->bpp) { | |
| #if defined(SUPPORT_16BPP) | |
| case 16: | |
| for (y=0; y<inf.height; y++) { | |
| for (x=0; x<inf.width; x++) { | |
| if (!(x & 1)) { | |
| c = src[x >> 1] >> 4; | |
| } | |
| else { | |
| c = src[x >> 1] & 15; | |
| } | |
| *(UINT16 *)dst = pal[c].pal16; | |
| dst += vram->xalign; | |
| } | |
| src += bmpalign; | |
| dst += yalign; | |
| } | |
| break; | |
| #endif | |
| #if defined(SUPPORT_32BPP) | |
| case 32: | |
| for (y=0; y<inf.height; y++) { | |
| for (x=0; x<inf.width; x++) { | |
| if (!(x & 1)) { | |
| c = src[x >> 1] >> 4; | |
| } | |
| else { | |
| c = src[x >> 1] & 15; | |
| } | |
| *(UINT32 *)dst = pal[c].pal32.d; | |
| dst += vram->xalign; | |
| } | |
| src += bmpalign; | |
| dst += yalign; | |
| } | |
| break; | |
| #endif | |
| } | } |
| } | } |