File:  [RetroPC.NET] / np2 / vram / dispsync.c
Revision 1.1: download - view: text, annotated - select for diffs
Fri Oct 17 02:58:15 2003 JST (22 years ago) by yui
Branches: MAIN
CVS tags: HEAD
Initial revision

#include	"compiler.h"
#include	"scrnmng.h"
#include	"memory.h"
#include	"pccore.h"
#include	"iocore.h"
#include	"scrndraw.h"
#include	"dispsync.h"


	DSYNC	dsync;


void dispsync_init(void) {

	ZeroMemory(&dsync, sizeof(dsync));
	dsync.textymax = 400;
	dsync.grphymax = 400;

	dsync.scrnxmax = 640;
	dsync.scrnxextend = 0;
	dsync.scrnymax = 400;

//	scrnmng_setwidth(0, 640);
//	scrnmng_setextend(0);
//	scrnmng_setheight(0, 400);
}

BOOL dispsync_renewalmode(void) {

	return(0);
}

BOOL dispsync_renewalhorizontal(void) {

	UINT	hbp;
	UINT	cr;
	UINT	scrnxpos;
	UINT	scrnxmax;

	hbp = gdc.m.para[GDC_SYNC + 4] & 0x1f;
	cr = gdc.m.para[GDC_SYNC + 1];

	scrnxpos = 0;
	if (hbp >= 7) {
		scrnxpos = hbp - 7;
	}
	scrnxmax = cr + 2;
	if ((scrnxpos + scrnxmax) > 80) {
		scrnxmax = 80 - scrnxpos;
	}
	scrnxpos <<= 3;
	scrnxmax <<= 3;
	if ((dsync.scrnxpos != scrnxpos) || (dsync.scrnxmax != scrnxmax)) {
		dsync.scrnxpos = scrnxpos;
		dsync.scrnxmax = scrnxmax;
		scrnmng_setwidth(scrnxpos, scrnxmax);
		return(TRUE);
	}
	else {
		return(FALSE);
	}
}

BOOL dispsync_renewalvertical(void) {

	UINT	text_vbp;
	UINT	grph_vbp;
	UINT	textymax;
	UINT	grphymax;
	UINT	scrnymax;

	text_vbp = gdc.m.para[GDC_SYNC + 7] >> 2;
	grph_vbp = gdc.s.para[GDC_SYNC + 7] >> 2;
	if (text_vbp >= grph_vbp) {
		text_vbp -= grph_vbp;
		grph_vbp = 0;
	}
	else {
		grph_vbp -= text_vbp;
		text_vbp = 0;
	}

	textymax = LOADINTELWORD(gdc.m.para + GDC_SYNC + 6);
	textymax &= 0x3ff;
	if (textymax) {
		textymax += text_vbp;
		if (textymax > SURFACE_HEIGHT) {
			textymax = SURFACE_HEIGHT;
		}
	}
	else {
		textymax = SURFACE_HEIGHT;
	}

	grphymax = LOADINTELWORD(gdc.s.para + GDC_SYNC + 6);
	grphymax &= 0x3ff;
	if (grphymax) {
		grphymax += grph_vbp;
		if (grphymax > SURFACE_HEIGHT) {
			grphymax = SURFACE_HEIGHT;
		}
	}
	else {
		grphymax = SURFACE_HEIGHT;
	}
	if ((dsync.text_vbp == text_vbp) && (dsync.grph_vbp == grph_vbp) &&
		(dsync.textymax == textymax) && (dsync.grphymax == grphymax)) {
		return(FALSE);
	}

	dsync.text_vbp = text_vbp;
	dsync.grph_vbp = grph_vbp;
	dsync.textymax = textymax;
	dsync.grphymax = grphymax;

	scrnymax = max(grphymax, textymax);
	scrnymax = (scrnymax + 7) & (~7);
	if (dsync.scrnymax != scrnymax) {
		dsync.scrnymax = scrnymax;
		scrnmng_setheight(0, scrnymax);
	}

	dsync.textvad = text_vbp * 640;
	dsync.grphvad = grph_vbp * 640;
	if (text_vbp) {
		ZeroMemory(np2_tram, text_vbp * 640);
	}
	if (scrnymax - textymax) {
		ZeroMemory(np2_tram + textymax * 640, (scrnymax - textymax) * 640);
	}
	if (grph_vbp) {
		ZeroMemory(np2_vram[0], grph_vbp * 640);
		ZeroMemory(np2_vram[1], grph_vbp * 640);
	}
	if (scrnymax - grphymax) {
		ZeroMemory(np2_vram[0] + grphymax * 640, (scrnymax - grphymax) * 640);
		ZeroMemory(np2_vram[1] + grphymax * 640, (scrnymax - grphymax) * 640);
	}
	return(TRUE);
}


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