File:  [RetroPC.NET] / xmil / adv / vram / palettes.c
Revision 1.1: download - view: text, annotated - select for diffs
Fri Feb 4 15:42:10 2005 JST (20 years, 8 months ago) by yui
Branches: MAIN
CVS tags: HEAD
RetroPC CVS restarting 2005/02/04 (T.Yui)

#include	"compiler.h"
#include	"pccore.h"
#include	"iocore.h"
#include	"palettes.h"
#include	"makescrn.h"


// ----

typedef struct {
	UINT16	text[8];
} PALS;

static	PALS	pals;


static void pal_settext(REG8 num) {

	REG16	rgb;

	rgb = (num & 1)?(0x1f << 10):0;
	rgb += (num & 4)?(0x1f << 5):0;
	rgb += (num & 2)?(0x1f << 0):0;
	pals.text[num] = rgb;
	crtc.e.palandply = 1;
}


// ----

void pal_update1(const UINT8 *rgbp) {

	UINT16	*advpal;
	UINT	i;
	UINT	j;
	REG8	bit;
	UINT	c;
	UINT	bcnt;
	REG16	txtpal;

	advpal = ADVVIDEOPAL;
	for (i=0, bit=1; i<8; i++, bit<<=1) {
		c = 0;
		if (rgbp[CRTC_PALB] & bit) {
			c += 1;
		}
		if (rgbp[CRTC_PALR] & bit) {
			c += 2;
		}
		if (rgbp[CRTC_PALG] & bit) {
			c += 4;
		}
		txtpal = pals.text[c];
		*advpal++ = (UINT16)txtpal;
		if (rgbp[CRTC_PLY] & bit) {
			for (j=1; j<8; j++) {
				*advpal++ = (UINT16)txtpal;
			}
		}
		else {
			bcnt = (rgbp[CRTC_BLACK] & 15) - 8;
			for (j=1; j<8; j++) {
				bcnt--;
				if (bcnt) {
					c = j;
				}
				else {
					c = 0;
				}
				*advpal++ = pals.text[c];
			}
		}
	}
	advv_palupdate();
}

void pal_update(void) {

	pal_update1(crtc.s.rgbp);
}


// ----

void pal_reset(void) {

	REG8	i;

	for (i=0; i<8; i++) {
		pal_settext(i);
	}
}


RetroPC.NET-CVS <cvs@retropc.net>