--- np2/generic/keydisp.c 2003/11/21 06:51:11 1.1 +++ np2/generic/keydisp.c 2005/02/07 14:46:10 1.9 @@ -11,59 +11,59 @@ typedef struct { UINT16 posx; UINT16 pals; -const BYTE *data; +const UINT8 *data; } KDKEYPOS; typedef struct { - BYTE k[KEYDISP_NOTEMAX]; - BYTE r[KEYDISP_NOTEMAX]; + UINT8 k[KEYDISP_NOTEMAX]; + UINT8 r[KEYDISP_NOTEMAX]; UINT remain; - BYTE flag; - BYTE padding[3]; + UINT8 flag; + UINT8 padding[3]; } KDCHANNEL; typedef struct { - BYTE ch; - BYTE key; + UINT8 ch; + UINT8 key; } KDDELAYE; typedef struct { UINT pos; UINT rem; - BYTE warm; - BYTE warmbase; + UINT8 warm; + UINT8 warmbase; } KDDELAY; typedef struct { UINT16 fnum[4]; - BYTE lastnote[4]; - BYTE flag; - BYTE extflag; + UINT8 lastnote[4]; + UINT8 flag; + UINT8 extflag; } KDFMCTRL; typedef struct { UINT16 fto[4]; - BYTE lastnote[4]; - BYTE flag; - BYTE mix; - BYTE padding[2]; + UINT8 lastnote[4]; + UINT8 flag; + UINT8 mix; + UINT8 padding[2]; } KDPSGCTRL; typedef struct { - BYTE mode; - BYTE dispflag; - BYTE framepast; - BYTE keymax; - BYTE fmmax; - BYTE psgmax; - BYTE fmpos[KEYDISP_FMMAX]; - BYTE psgpos[KEYDISP_PSGMAX]; + UINT8 mode; + UINT8 dispflag; + UINT8 framepast; + UINT8 keymax; + UINT8 fmmax; + UINT8 psgmax; + UINT8 fmpos[KEYDISP_FMMAX]; + UINT8 psgpos[KEYDISP_PSGMAX]; UINT fmreg[KEYDISP_FMMAX]; KDDELAY delay; KDCHANNEL ch[KEYDISP_CHMAX]; KDFMCTRL fmctl[KEYDISP_FMMAX]; KDPSGCTRL psgctl[KEYDISP_PSGMAX]; - BYTE pal8[KEYDISP_PALS]; + UINT8 pal8[KEYDISP_PALS]; UINT16 pal16[KEYDISP_LEVEL*2]; RGB32 pal32[KEYDISP_LEVEL*2]; KDKEYPOS keypos[128]; @@ -77,7 +77,7 @@ static KEYDISP keydisp; // ---- event -static void keyon(UINT ch, BYTE note) { +static void keyon(UINT ch, UINT8 note) { UINT i; KDCHANNEL *kdch; @@ -104,7 +104,7 @@ static void keyon(UINT ch, BYTE note) { } } -static void keyoff(UINT ch, BYTE note) { +static void keyoff(UINT ch, UINT8 note) { UINT i; KDCHANNEL *kdch; @@ -136,7 +136,7 @@ static void chkeyoff(UINT ch) { static void keyalloff(void) { - BYTE i; + UINT8 i; for (i=0; i> 11) & 7; @@ -288,12 +288,12 @@ static BYTE getfmnote(UINT16 fnum) { return(ret); } -static void fmkeyoff(BYTE ch, KDFMCTRL *k) { +static void fmkeyoff(UINT8 ch, KDFMCTRL *k) { delaysetevent(keydisp.fmpos[ch], k->lastnote[0]); } -static void fmkeyon(BYTE ch, KDFMCTRL *k) { +static void fmkeyon(UINT8 ch, KDFMCTRL *k) { UINT reg; @@ -301,7 +301,7 @@ static void fmkeyon(BYTE ch, KDFMCTRL *k reg = keydisp.fmreg[ch] + 0xa0; k->fnum[0] = ((opn.reg[reg + 4] & 0x3f) << 8) + opn.reg[reg]; k->lastnote[0] = getfmnote(k->fnum[0]); - delaysetevent(keydisp.fmpos[ch], (BYTE)(k->lastnote[0] | 0x80)); + delaysetevent(keydisp.fmpos[ch], (UINT8)(k->lastnote[0] | 0x80)); } static void fmkeyreset(void) { @@ -309,7 +309,7 @@ static void fmkeyreset(void) { ZeroMemory(keydisp.fmctl, sizeof(keydisp.fmctl)); } -void keydisp_fmkeyon(BYTE ch, BYTE value) { +void keydisp_fmkeyon(UINT8 ch, UINT8 value) { KDFMCTRL *k; @@ -333,7 +333,7 @@ void keydisp_fmkeyon(BYTE ch, BYTE value static void fmkeysync(void) { - BYTE ch; + UINT8 ch; KDFMCTRL *k; UINT16 reg; UINT16 fnum; @@ -343,7 +343,7 @@ static void fmkeysync(void) { reg = keydisp.fmreg[ch] + 0xa0; fnum = ((opn.reg[reg + 4] & 0x3f) << 8) + opn.reg[reg]; if (k->fnum[0] != fnum) { - BYTE n; + UINT8 n; k->fnum[0] = fnum; n = getfmnote(fnum); if (k->lastnote[0] != n) { @@ -351,7 +351,7 @@ static void fmkeysync(void) { } k->lastnote[0] = n; delaysetevent(keydisp.fmpos[ch], - (BYTE)(k->lastnote[0] | 0x80)); + (UINT8)(k->lastnote[0] | 0x80)); } } } @@ -362,9 +362,9 @@ static void fmkeysync(void) { static const void *psgtbl[3] = {&psg1, &psg2, &psg3}; -static BYTE getpsgnote(UINT16 tone) { +static UINT8 getpsgnote(UINT16 tone) { - BYTE ret; + UINT8 ret; int i; ret = 60; @@ -393,13 +393,13 @@ static BYTE getpsgnote(UINT16 tone) { return(ret); } -static void psgmix(BYTE ch, PSGGEN psg) { +static void psgmix(UINT8 ch, PSGGEN psg) { KDPSGCTRL *k; k = keydisp.psgctl + ch; if ((k->mix ^ psg->reg.mixer) & 7) { - BYTE i, bit, pos; + UINT8 i, bit, pos; k->mix = psg->reg.mixer; pos = keydisp.psgpos[ch]; for (i=0, bit=1; i<3; i++, pos++, bit<<=1) { @@ -409,19 +409,19 @@ static void psgmix(BYTE ch, PSGGEN psg) } else if ((!(k->mix & bit)) && (psg->reg.vol[i] & 0x1f)) { k->flag |= bit; - k->fto[i] = (*(WORD *)(psg->reg.tune[i])) & 0xfff; + k->fto[i] = LOADINTELWORD(psg->reg.tune[i]) & 0xfff; k->lastnote[i] = getpsgnote(k->fto[i]); - delaysetevent(pos, (BYTE)(k->lastnote[i] | 0x80)); + delaysetevent(pos, (UINT8)(k->lastnote[i] | 0x80)); } } } } -static void psgvol(BYTE ch, PSGGEN psg, BYTE i) { +static void psgvol(UINT8 ch, PSGGEN psg, UINT8 i) { KDPSGCTRL *k; - BYTE bit; - BYTE pos; + UINT8 bit; + UINT8 pos; UINT16 tune; k = keydisp.psgctl + ch; @@ -434,7 +434,7 @@ static void psgvol(BYTE ch, PSGGEN psg, tune &= 0xfff; k->fto[i] = tune; k->lastnote[i] = getpsgnote(tune); - delaysetevent(pos, (BYTE)(k->lastnote[i] | 0x80)); + delaysetevent(pos, (UINT8)(k->lastnote[i] | 0x80)); } } else if (k->flag & bit) { @@ -450,7 +450,7 @@ static void psgkeyreset(void) { void keydisp_psgmix(void *psg) { - BYTE c; + UINT8 c; if (keydisp.mode != KEYDISP_MODEFM) { return; @@ -463,9 +463,9 @@ void keydisp_psgmix(void *psg) { } } -void keydisp_psgvol(void *psg, BYTE ch) { +void keydisp_psgvol(void *psg, UINT8 ch) { - BYTE c; + UINT8 c; if (keydisp.mode != KEYDISP_MODEFM) { return; @@ -480,14 +480,14 @@ void keydisp_psgvol(void *psg, BYTE ch) static void psgkeysync(void) { - BYTE ch; + UINT8 ch; KDPSGCTRL *k; - BYTE bit; - BYTE i; - BYTE pos; + UINT8 bit; + UINT8 i; + UINT8 pos; PSGGEN psg; UINT16 tune; - BYTE n; + UINT8 n; for (ch=0, k=keydisp.psgctl; chlastnote[i] != n) { delaysetevent(pos, k->lastnote[i]); k->lastnote[i] = n; - delaysetevent(pos, (BYTE)(n | 0x80)); + delaysetevent(pos, (UINT8)(n | 0x80)); } } } @@ -513,7 +513,7 @@ static void psgkeysync(void) { // ---- BOARD change... -static void setfmhdl(BYTE items, UINT base) { +static void setfmhdl(UINT8 items, UINT base) { while(items--) { if ((keydisp.keymax < KEYDISP_CHMAX) && @@ -529,7 +529,7 @@ static void setfmhdl(BYTE items, UINT ba } } -static void setpsghdl(BYTE items) { +static void setpsghdl(UINT8 items) { while(items--) { if ((keydisp.keymax <= (KEYDISP_CHMAX - 3)) && @@ -540,7 +540,7 @@ static void setpsghdl(BYTE items) { } } -void keydisp_setfmboard(BYTE b) { +void keydisp_setfmboard(UINT b) { keydisp.keymax = 0; keydisp.fmmax = 0; @@ -586,7 +586,7 @@ void keydisp_setfmboard(BYTE b) { // ---- MIDI -void keydisp_midi(const BYTE *cmd) { +void keydisp_midi(const UINT8 *cmd) { if (keydisp.mode != KEYDISP_MODEMIDI) { return; @@ -645,83 +645,80 @@ static int getdispkeys(void) { static void clearrect(CMNVRAM *vram, int x, int y, int cx, int cy) { + CMNPAL col; + switch(vram->bpp) { #if defined(SUPPORT_8BPP) case 8: - cmndraw8_fill(vram, x, y, cx, cy, keydisp.pal8[KEYDISP_PALBG]); + col.pal8 = keydisp.pal8[KEYDISP_PALBG]; break; #endif #if defined(SUPPORT_16BPP) case 16: - cmndraw16_fill(vram, x, y, cx, cy, keydisp.pal16[KEYDISP_LEVEL]); + col.pal16 = keydisp.pal16[KEYDISP_LEVEL]; break; #endif #if defined(SUPPORT_24BPP) case 24: - cmndraw24_fill(vram, x, y, cx, cy, keydisp.pal32[KEYDISP_LEVEL]); - break; #endif #if defined(SUPPORT_32BPP) case 32: - cmndraw32_fill(vram, x, y, cx, cy, keydisp.pal32[KEYDISP_LEVEL]); +#endif +#if defined(SUPPORT_24BPP) || defined(SUPPORT_32BPP) + col.pal32 = keydisp.pal32[KEYDISP_LEVEL]; break; #endif + default: + return; } + cmndraw_fill(vram, x, y, cx, cy, col); } static void drawkeybg(CMNVRAM *vram) { + CMNPAL bg; + CMNPAL fg; int i; switch(vram->bpp) { #if defined(SUPPORT_8BPP) case 8: - for (i=0; i<10; i++) { - cmndraw8_setpat(vram, keybrd1, i * KEYDISP_KEYCX, 0, - keydisp.pal8[KEYDISP_PALBG], keydisp.pal8[KEYDISP_PALFG]); - } - cmndraw8_setpat(vram, keybrd2, 10 * KEYDISP_KEYCX, 0, - keydisp.pal8[KEYDISP_PALBG], keydisp.pal8[KEYDISP_PALFG]); + bg.pal8 = keydisp.pal8[KEYDISP_PALBG]; + fg.pal8 = keydisp.pal8[KEYDISP_PALFG]; break; #endif #if defined(SUPPORT_16BPP) case 16: - for (i=0; i<10; i++) { - cmndraw16_setpat(vram, keybrd1, i * KEYDISP_KEYCX, 0, - keydisp.pal16[KEYDISP_LEVEL], keydisp.pal16[0]); - } - cmndraw16_setpat(vram, keybrd2, 10 * KEYDISP_KEYCX, 0, - keydisp.pal16[KEYDISP_LEVEL], keydisp.pal16[0]); + bg.pal16 = keydisp.pal16[KEYDISP_LEVEL]; + fg.pal16 = keydisp.pal16[0]; break; #endif #if defined(SUPPORT_24BPP) case 24: - for (i=0; i<10; i++) { - cmndraw24_setpat(vram, keybrd1, i * KEYDISP_KEYCX, 0, - keydisp.pal32[KEYDISP_LEVEL], keydisp.pal32[0]); - } - cmndraw24_setpat(vram, keybrd2, 10 * KEYDISP_KEYCX, 0, - keydisp.pal32[KEYDISP_LEVEL], keydisp.pal32[0]); + bg.pal32 = keydisp.pal32[KEYDISP_LEVEL]; + fg.pal32 = keydisp.pal32[0]; break; #endif #if defined(SUPPORT_32BPP) case 32: - for (i=0; i<10; i++) { - cmndraw32_setpat(vram, keybrd1, i * KEYDISP_KEYCX, 0, - keydisp.pal32[KEYDISP_LEVEL], keydisp.pal32[0]); - } - cmndraw32_setpat(vram, keybrd2, 10 * KEYDISP_KEYCX, 0, - keydisp.pal32[KEYDISP_LEVEL], keydisp.pal32[0]); + bg.pal32 = keydisp.pal32[KEYDISP_LEVEL]; + fg.pal32 = keydisp.pal32[0]; break; #endif + default: + return; } + for (i=0; i<10; i++) { + cmndraw_setpat(vram, keybrd1, i * KEYDISP_KEYCX, 0, bg, fg); + } + cmndraw_setpat(vram, keybrd2, 10 * KEYDISP_KEYCX, 0, bg, fg); } static BOOL draw1key(CMNVRAM *vram, KDCHANNEL *kdch, UINT n) { KDKEYPOS *pos; UINT pal; - BYTE pal8; + CMNPAL fg; pos = keydisp.keypos + (kdch->k[n] & 0x7f); pal = kdch->r[n] & 0x7f; @@ -729,43 +726,43 @@ static BOOL draw1key(CMNVRAM *vram, KDCH #if defined(SUPPORT_8BPP) case 8: if (pal != (KEYDISP_LEVEL - 1)) { - pal8 = keydisp.pal8[(pos->pals)?KEYDISP_PALBG:KEYDISP_PALFG]; - cmndraw8_setfg(vram, pos->data, pos->posx, 0, pal8); + fg.pal8 = keydisp.pal8[ + (pos->pals)?KEYDISP_PALBG:KEYDISP_PALFG]; + cmndraw_setfg(vram, pos->data, pos->posx, 0, fg); kdch->r[n] = 0; return(TRUE); } - cmndraw8_setfg(vram, pos->data, pos->posx, 0, - keydisp.pal8[KEYDISP_PALHIT]); + fg.pal8 = keydisp.pal8[KEYDISP_PALHIT]; break; #endif #if defined(SUPPORT_16BPP) case 16: - cmndraw16_setfg(vram, pos->data, pos->posx, 0, - keydisp.pal16[pal + pos->pals]); + fg.pal16 = keydisp.pal16[pal + pos->pals]; break; #endif #if defined(SUPPORT_24BPP) case 24: - cmndraw24_setfg(vram, pos->data, pos->posx, 0, - keydisp.pal32[pal + pos->pals]); + fg.pal32 = keydisp.pal32[pal + pos->pals]; break; #endif #if defined(SUPPORT_32BPP) case 32: - cmndraw32_setfg(vram, pos->data, pos->posx, 0, - keydisp.pal32[pal + pos->pals]); + fg.pal32 = keydisp.pal32[pal + pos->pals]; break; #endif + default: + return(FALSE); } + cmndraw_setfg(vram, pos->data, pos->posx, 0, fg); return(FALSE); } -static BOOL draw1ch(CMNVRAM *vram, BYTE framepast, KDCHANNEL *kdch) { +static BOOL draw1ch(CMNVRAM *vram, UINT8 framepast, KDCHANNEL *kdch) { BOOL draw; UINT i; BOOL coll; - BYTE nextf; + UINT8 nextf; UINT j; draw = FALSE; @@ -866,7 +863,7 @@ void keydisp_setpal(CMNPALFN *palfn) { keydisp.dispflag |= KEYDISP_FLAGREDRAW; } -void keydisp_setmode(BYTE mode) { +void keydisp_setmode(UINT8 mode) { if (keydisp.mode != mode) { keydisp.mode = mode; @@ -883,13 +880,13 @@ void keydisp_setmode(BYTE mode) { } } -void keydisp_setdelay(BYTE frames) { +void keydisp_setdelay(UINT8 frames) { keydisp.delay.warmbase = frames; delayreset(); } -BYTE keydisp_process(BYTE framepast) { +UINT8 keydisp_process(UINT8 framepast) { int keys; int i; @@ -917,7 +914,7 @@ void keydisp_getsize(int *width, int *he if (width) { *width = KEYDISP_WIDTH; } - if (*height) { + if (height) { *height = (getdispkeys() * KEYDISP_KEYCY) + 1; } keydisp.dispflag &= ~KEYDISP_FLAGSIZING; @@ -957,6 +954,5 @@ BOOL keydisp_paint(CMNVRAM *vram, BOOL r kdpnt_exit: return(draw); } - #endif