⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regfiles.c

📁 有关OSD开发和ADI公司的几款ADC软件控制
💻 C
字号:
/*
 *
 *  regfiles.c - VDP1 register files access
 *
 *  history:
 *
 *  who  when        what
 *  ---  ----------  ----
 *  ury  30/04/2000  creation
 *
 *
 *  description:
 *  ------------
 *  This module contains functions which provide read and write access to the
 *  VDP1 register files.
 *
 */

#include <stdio.h>
//#include <malloc.h>
#include "vdp1.h"
#include "vdp1priv.h"
#include "regtbl.h"
#include "regaddr.h"



/* Read all registers of the group file */
void VDP1_GetGroup(TRegisterGroup  Group,
						 TByte          *Destination)
{
  int i;

  /* Clear address counter */
  VDP1_REG(Group.ClearRegAddress) = 1 << Group.ClearRegOffset;

  switch (Group.RegisterSize)
	  {
		case 1 :
			for (i = 0 ; i < Group.Size ; i++)
				Destination[i] = VDP1_REG(Group.Address);
			break;

		case 2 :
			for (i = 0 ; i < Group.Size ; i++)
				{
				Destination[2 * i] = VDP1_REG(Group.Address);
				Destination[2 * i + 1] = VDP1_REG(Group.Address);
				}
			break;
	 }

}  /* VDP1_GetGroup */

/* Write all registers of the group file */
void VDP1_SetGroup(TRegisterGroup  Group,
						 TByte          *Source)
{
	int i;

	/* Clear address counter */
	VDP1_REG(Group.ClearRegAddress) = 1 << Group.ClearRegOffset;

	switch (Group.RegisterSize)
		{
		case 1:
			for (i = 0 ; i < Group.Size ; i++)
				VDP1_REG(Group.Address) = Source[i];
		  break;

		case 2 :
			for (i = 0 ; i < Group.Size ; i++)
				{
				VDP1_REG(Group.Address) = Source[2 * i];
				VDP1_REG(Group.Address) = Source[2 * i + 1];
				}
			break;
	 }

}  /* VDP1_GetGroup */

#pragma option -Od
/* Write a specific register of the group file */
void VDP1_SetGroupMember(TRegisterGroup Group,
								 TWord          RegisterOffset,
								 unsigned short Value)
{
	TBYTE data; /* dummy read */
	int i;
	TByte volatile huge *reg = (TByte volatile huge *)&VDP1_REG(Group.Address);

	/* Clear address counter */
	VDP1_REG(Group.ClearRegAddress) = 1 << Group.ClearRegOffset;

	 switch (Group.RegisterSize)
		{
		case 1:
			/* Dummy reads just to increase address counter */
			for (i = 0 ; i < RegisterOffset; i++)
				data = *reg;	/* dummy xor to overcome compiler optimazation problem*/
			/* Now, write the data */
			*reg = LO_CHAR(Value);
		  break;

		case 2 :
			/* Dummy reads just to increase address counter */
			for (i = 0 ;i < 2*RegisterOffset; i++)
				data = *reg;	/* dummy xor to overcome compiler optimazation problem*/
			/* Now, write the data in word format */
			*reg = LO_CHAR(Value);
			*reg = HI_CHAR(Value);;
			break;
	 }

}

/* Read a specific register of the group file */
unsigned short VDP1_GetGroupMember(TRegisterGroup  Group,
											  TWord           RegisterOffset)
{
	unsigned short ReturnGroupMember;
	TBYTE data; /* dummy read */
	TByte volatile huge *reg = (TByte volatile huge *)&VDP1_REG(Group.Address);
	int i;

	/* Clear address counter */
	VDP1_REG(Group.ClearRegAddress) = 1 << Group.ClearRegOffset;

	 switch (Group.RegisterSize)
		{
		case 1:
			/* Dummy reads just to increase address counter */
			for (i = 0 ; i < RegisterOffset; i++)
				data = *reg;
			/* Now, read actual data */
			ReturnGroupMember = *reg;
		  break;

		case 2 :
			/* Dummy reads just to increase address counter */
			for (i = 0 ;i < 2*RegisterOffset; i++)
				data = *reg;
			/* Now, read actual data in word format */
			data = *reg;
			ReturnGroupMember = (*reg << 8) | data;
			break;
	 }

	return (ReturnGroupMember);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -