|
|
| version 1.1.1.1, 2003/10/16 17:58:15 | version 1.7, 2007/11/11 12:46:07 |
|---|---|
| Line 6 | Line 6 |
| #include "palettes.h" | #include "palettes.h" |
| RGB32 np2_pal32[256]; | #if defined(SUPPORT_PC9821) |
| RGB32 np2_pal32[NP2PAL_EXTEND]; | |
| #if defined(SUPPORT_16BPP) | #if defined(SUPPORT_16BPP) |
| UINT16 np2_pal16[256]; | RGB16 np2_pal16[NP2PAL_EXTEND]; |
| #endif | #endif |
| #else | |
| RGB32 np2_pal32[NP2PAL_NORMAL]; | |
| #if defined(SUPPORT_16BPP) | |
| RGB16 np2_pal16[NP2PAL_NORMAL]; | |
| #endif | |
| #endif | |
| PALEVENT palevent; | PALEVENT palevent; |
| static RGB32 degpal1[8]; | static RGB32 degpal1[8]; |
| static RGB32 degpal2[8]; | static RGB32 degpal2[8]; |
| static BYTE anapal1[16]; | static UINT8 anapal1[16]; |
| static BYTE anapal2[16]; | static UINT8 anapal2[16]; |
| static RGB32 lcdpal[15]; | static RGB32 lcdpal[15]; |
| static BYTE lcdtbl[0x1000]; | static UINT8 lcdtbl[0x1000]; |
| BYTE pal_monotable[16] = {0, 0, 0, 0, 1, 1, 1, 1, | UINT8 pal_monotable[16] = {0, 0, 0, 0, 1, 1, 1, 1, |
| 0, 0, 0, 0, 1, 1, 1, 1}; | 0, 0, 0, 0, 1, 1, 1, 1}; |
| static const BYTE lcdpal_a[27] = {0, 1, 2, 3, 5, 2, 4, 4, 6, | static const UINT8 lcdpal_a[27] = { 0, 1, 2, 3, 5, 2, 4, 4, 6, |
| 7, 9, 2,11,13, 2, 4, 4, 6, | 7, 9, 2,11,13, 2, 4, 4, 6, |
| 8, 8,10, 8, 8,10,12,12,14}; | 8, 8,10, 8, 8,10,12,12,14}; |
| static const BYTE deftbl[4] = {0x04, 0x15, 0x26, 0x37}; | static const UINT8 deftbl[4] = {0x04, 0x15, 0x26, 0x37}; |
| void pal_makegrad(RGB32 *pal, int pals, UINT32 bg, UINT32 fg) { | void pal_makegrad(RGB32 *pal, int pals, UINT32 bg, UINT32 fg) { |
| Line 34 void pal_makegrad(RGB32 *pal, int pals, | Line 42 void pal_makegrad(RGB32 *pal, int pals, |
| if (pals >= 2) { | if (pals >= 2) { |
| pals--; | pals--; |
| for (i=0; i<=pals; i++) { | for (i=0; i<=pals; i++) { |
| pal[i].p.b = (BYTE) | pal[i].p.b = (UINT8) |
| ((((fg >> 0) & 0x0000ff) * i + | ((((fg >> 0) & 0x0000ff) * i + |
| ((bg >> 0) & 0x0000ff) * (pals-i)) / pals); | ((bg >> 0) & 0x0000ff) * (pals-i)) / pals); |
| pal[i].p.g = (BYTE) | pal[i].p.g = (UINT8) |
| ((((fg >> 8) & 0x0000ff) * i + | ((((fg >> 8) & 0x0000ff) * i + |
| ((bg >> 8) & 0x0000ff) * (pals-i)) / pals); | ((bg >> 8) & 0x0000ff) * (pals-i)) / pals); |
| pal[i].p.r = (BYTE) | pal[i].p.r = (UINT8) |
| ((((fg >> 16) & 0x0000ff) * i + | ((((fg >> 16) & 0x0000ff) * i + |
| ((bg >> 16) & 0x0000ff) * (pals-i)) / pals); | ((bg >> 16) & 0x0000ff) * (pals-i)) / pals); |
| pal[i].p.e = 0; | pal[i].p.e = 0; |
| Line 94 void pal_makeskiptable(void) { | Line 102 void pal_makeskiptable(void) { |
| int i; | int i; |
| RGB32 pal; | RGB32 pal; |
| UINT8 ana; | |
| for (i=0; i<8; i++) { | for (i=0; i<8; i++) { |
| pal.p.b = (BYTE)(i & 1); | pal.p.b = (UINT8)(i & 1); |
| pal.p.r = (BYTE)((i >> 1) & 1); | pal.p.r = (UINT8)((i >> 1) & 1); |
| pal.p.g = (BYTE)((i >> 2) & 1); | pal.p.g = (UINT8)((i >> 2) & 1); |
| pal.p.e = 0; | pal.p.e = 0; |
| degpal1[i].d = pal.d * 255; | degpal1[i].d = pal.d * 255; |
| degpal2[i].d = pal.d * np2cfg.skiplight; | degpal2[i].d = pal.d * np2cfg.skiplight; |
| } | } |
| for (i=0; i<16; i++) { | for (i=0; i<16; i++) { |
| anapal1[i] = (BYTE)(i * 0x11); | ana = (UINT8)(i * 0x11); |
| anapal2[i] = (BYTE)((np2cfg.skiplight * anapal1[i]) / 255); | anapal1[i] = ana; |
| anapal2[i] = (UINT8)((np2cfg.skiplight * anapal1[i]) / 255); | |
| } | } |
| } | } |
| Line 142 void pal_makeanalog(RGB32 *pal, UINT16 b | Line 152 void pal_makeanalog(RGB32 *pal, UINT16 b |
| #endif | #endif |
| } | } |
| static void pal_makedegital(const BYTE *paltbl) { | static void pal_makedegital(const UINT8 *paltbl) { |
| UINT i; | UINT i; |
| Line 213 void pal_makeanalog_lcd(RGB32 *pal, UINT | Line 223 void pal_makeanalog_lcd(RGB32 *pal, UINT |
| #endif | #endif |
| } | } |
| static void pal_makedegital_lcd(const BYTE *paltbl) { | static void pal_makedegital_lcd(const UINT8 *paltbl) { |
| UINT i; | UINT i; |
| UINT32 pal32; | UINT32 pal32; |
| #if defined(SUPPORT_16BPP) | #if defined(SUPPORT_16BPP) |
| UINT16 pal16; | RGB16 pal16; |
| #endif | #endif |
| for (i=0; i<4; i++) { | for (i=0; i<4; i++) { |
| Line 267 static void pal_maketext(void) { | Line 277 static void pal_maketext(void) { |
| UINT j; | UINT j; |
| UINT k; | UINT k; |
| #if defined(SUPPORT_16BPP) | #if defined(SUPPORT_16BPP) |
| UINT16 pal16; | RGB16 pal16; |
| #endif | #endif |
| k = NP2PAL_TEXT2; | k = NP2PAL_TEXT2; |
| Line 301 static void pal_maketext_lcd(void) { | Line 311 static void pal_maketext_lcd(void) { |
| UINT j; | UINT j; |
| UINT k; | UINT k; |
| #if defined(SUPPORT_16BPP) | #if defined(SUPPORT_16BPP) |
| UINT16 pal16; | RGB16 pal16; |
| #endif | #endif |
| k = NP2PAL_TEXT2; | k = NP2PAL_TEXT2; |
| Line 329 static void pal_maketext_lcd(void) { | Line 339 static void pal_maketext_lcd(void) { |
| #endif | #endif |
| } | } |
| #if defined(SUPPORT_PC9821) | |
| static void pal_maketext256(void) { | |
| UINT i; | |
| #if defined(SUPPORT_16BPP) | |
| RGB16 pal16; | |
| #endif | |
| for (i=0; i<8; i++) { | |
| np2_pal32[i+1+NP2PAL_TEXTEX].d = degpal1[i].d; | |
| np2_pal32[i+1+NP2PAL_TEXTEX3].d = degpal1[i].d; | |
| } | |
| #if defined(SUPPORT_16BPP) | |
| if (scrnmng_getbpp() == 16) { | |
| for (i=0; i<8; i++) { | |
| pal16 = scrnmng_makepal16(degpal1[i]); | |
| np2_pal16[i+1+NP2PAL_TEXTEX] = pal16; | |
| np2_pal16[i+1+NP2PAL_TEXTEX3] = pal16; | |
| } | |
| } | |
| #endif | |
| } | |
| #endif | |
| static void pal_makeingmono(void) { // ver0.28/pr4 | static void pal_makeingmono(void) { // ver0.28/pr4 |
| int i; | int i; |
| Line 348 static void pal_makeingmono(void) { | Line 382 static void pal_makeingmono(void) { |
| } | } |
| } | } |
| void pal_change(BYTE textpalset) { | |
| #if defined(SUPPORT_PC9821) | |
| static void pal_make9821(const UINT8 *pal) { | |
| int i; | |
| RGB32 *p; | |
| p = np2_pal32 + NP2PAL_GRPHEX; | |
| for (i=0; i<256; i++) { | |
| p[i].p.g = pal[i*4+0]; | |
| p[i].p.r = pal[i*4+1]; | |
| p[i].p.b = pal[i*4+2]; | |
| } | |
| np2_pal32[NP2PAL_TEXTEX3].d = np2_pal32[NP2PAL_GRPHEX].d; | |
| #if defined(SUPPORT_16BPP) | |
| if (scrnmng_getbpp() == 16) { | |
| for (i=0; i<256; i++) { | |
| np2_pal16[i + NP2PAL_GRPHEX] = | |
| scrnmng_makepal16(np2_pal32[i + NP2PAL_GRPHEX]); | |
| } | |
| np2_pal16[NP2PAL_TEXTEX3] = np2_pal16[NP2PAL_GRPHEX]; | |
| } | |
| #endif | |
| } | |
| #endif | |
| void pal_change(UINT8 textpalset) { | |
| if (textpalset) { | if (textpalset) { |
| if (!(np2cfg.LCD_MODE & 1)) { | if (!(np2cfg.LCD_MODE & 1)) { |
| Line 361 void pal_change(BYTE textpalset) { | Line 421 void pal_change(BYTE textpalset) { |
| #if defined(SUPPORT_16BPP) | #if defined(SUPPORT_16BPP) |
| np2_pal16[NP2PAL_TEXT] = np2_pal16[NP2PAL_TEXT2]; | np2_pal16[NP2PAL_TEXT] = np2_pal16[NP2PAL_TEXT2]; |
| #endif | #endif |
| #if defined(SUPPORT_PC9821) | |
| pal_maketext256(); | |
| #endif | |
| } | } |
| #if defined(SUPPORT_PC9821) | |
| if (gdc.analog & 2) { | |
| pal_make9821(gdc.anareg + (16 * 3)); | |
| scrndraw_changepalette(); | |
| return; | |
| } | |
| #endif | |
| if (!(np2cfg.LCD_MODE & 1)) { | if (!(np2cfg.LCD_MODE & 1)) { |
| if (gdc.mode1 & 2) { // ver0.28/pr4 | if (gdc.mode1 & 2) { |
| pal_makedegital(deftbl); | pal_makedegital(deftbl); |
| pal_makeingmono(); | pal_makeingmono(); |
| } | } |
| Line 377 void pal_change(BYTE textpalset) { | Line 447 void pal_change(BYTE textpalset) { |
| } | } |
| } | } |
| else { | else { |
| if (gdc.mode1 & 2) { // ver0.28/pr4 | if (gdc.mode1 & 2) { |
| pal_makedegital_lcd(deftbl); | pal_makedegital_lcd(deftbl); |
| pal_makeingmono(); | pal_makeingmono(); |
| } | } |
| Line 403 void pal_eventclear(void) { | Line 473 void pal_eventclear(void) { |
| palevent.anabit = 0; | palevent.anabit = 0; |
| palevent.events = 0; | palevent.events = 0; |
| if ((!drawframe) || (!np2cfg.RASTER) || (scrnmng_getbpp() == 8)) { | if ((!pcstat.drawframe) || (!np2cfg.RASTER) || (scrnmng_getbpp() == 8)) { |
| palevent.events--; // 0xffffffff にする... | palevent.events--; // 0xffffffff にする... |
| } | } |
| else { | else { |
| CopyMemory(palevent.pal, gdc.anapal, sizeof(gdc.anapal)); | CopyMemory(palevent.pal, gdc.anapal, sizeof(gdc.anapal)); |
| palevent.vsyncpal = 0; | |
| } | } |
| } | } |