コード例 #1
0
ファイル: ts_list.c プロジェクト: JeffersonLab/tsUtil
void
rocPrestart()
{
  unsigned short iflag;
  int stat;

  /* Check ffile for changes (usrstrutils) 
     Useful for items that may change without re-download (e.g. prescale factors) */
  init_strings();
  ps1 = getint("ps1");
  printf("usrstrutils configuration:\n");
  printf("\tps1 = %d\n",ps1);

  /* Program/Init Trigger Supervisor and VME Modules Here */
  tsReset(0);

  tsCsr2Set(TS_CSR2_LOCK_ALL);  /* ROC Lock mode on all BRANCHES */
  tsEnableInput(0xfff,0);       /* Enable all Trigger inputs in non-strobe mode */
  tsRoc(0,0,0,0);               /* Enable ACK 0,1 on BRANCH 1  and ACK 2 on Branch 2*/

  /* Synchronization programming */
  tsSync(100);                      /* schedule Sync every 100th physics trigger */
  tsCsr2Set(TS_CSR2_ENABLE_SYNC);   /* Enable Scheduled syncs */ 

  /* Set nominal Level 2/3 timer values */
  tsTimerWrite(TS_TIMER_L2A,0x05);   /* Level 2 Timer 40ns/count */
  tsTimerWrite(TS_TIMER_L3A,0x05);   /* Level 3 Timer 40ns/count */

  /* Front End Busy timer 40ns/count */
  tsTimerWrite(TS_TIMER_FB,250);         /* 250 = 10 microsec */   
  tsCsr2Set(TS_CSR2_ENABLE_FB_TIMER);    /* Enable FEB Timer */

  /*  Construct TS memory data  ---  in the following model, all trigger patterns 
      that form the memory address are assigned to trigger class 1.  For those 
      trigger patterns with a single hit, the ROC code is set to be the trigger 
      input number.  Otherwise, the ROC code is set to 0xE.  All LEVEL 1 ACCEPT 
      signals are asserted for every pattern.  */
   
  tsMemInit();

  /* Fix special cases - both inputs 1 and 2 firing - type 13 (0xd) 
     all L1 accept outputs firing 0xff03 */
  tsMemWrite(3,0xdff03);

  /* Set specific input prescale factors */
  tsPrescale(1,0);
  tsPrescale(2,0);

  printf("rocPrestart: User Prestart Executed\n");

}
コード例 #2
0
ファイル: z80.c プロジェクト: samstyle/Xpeccy
int loadZ80_f(Computer* comp, FILE* file) {
	int btm;
	int err = ERR_OK;
	unsigned char tmp,tmp2,reg,lst;
	unsigned short adr, twrd;
//	CPU* cpu = comp->cpu;
	char pageBuf[0xc000];
	z80v1Header hd;
	comp->p7FFD = 0x10;
	comp->pEFF7 = 0x00;
	memSetBank(comp->mem,0x00,MEM_ROM,1,MEM_16K,NULL,NULL,NULL);
	memSetBank(comp->mem,0xc0,MEM_RAM,0,MEM_16K,NULL,NULL,NULL);
	comp->vid->curscr = 5;

	fread((char*)&hd, sizeof(z80v1Header), 1, file);
	if (hd.flag12 == 0xff) hd.flag12 = 0x01;	// Because of compatibility, if byte 12 is 255, it has to be regarded as being 1.

	comp->cpu->af = (hd.a << 8) | hd.f;
	comp->cpu->bc = (hd.b << 8) | hd.c;
	comp->cpu->de = (hd.d << 8) | hd.e;
	comp->cpu->hl = (hd.h << 8) | hd.l;
	comp->cpu->af_ = (hd._a << 8) | hd._f;
	comp->cpu->bc_ = (hd._b << 8) | hd._c;
	comp->cpu->de_ = (hd._d << 8) | hd._e;
	comp->cpu->hl_ = (hd._h << 8) | hd._l;
	comp->cpu->pc = (hd.pch << 8) | hd.pcl;
	comp->cpu->sp = (hd.sph << 8) | hd.spl;
	comp->cpu->ix = (hd.ixh << 8) | hd.ixl;
	comp->cpu->iy = (hd.iyh << 8) | hd.iyl;
	comp->cpu->i = hd.i;
	comp->cpu->r7 = (hd.flag12 & 1) ? 0x80 : 0;
	comp->cpu->r = (hd.r7 & 0x7f) | comp->cpu->r7;
	comp->cpu->imode = hd.flag29 & 3;
	comp->cpu->iff1 = hd.iff1;
	comp->cpu->iff2 = hd.iff2;
	comp->cpu->inten = Z80_NMI | (hd.iff1 ? Z80_INT : 0);
	comp->vid->brdcol = (hd.flag12 >> 1) & 7;
	comp->vid->nextbrd = comp->vid->brdcol;
// unsupported things list
	if (hd.flag12 & 0x10) printf("...flag 12.bit 4.Basic SamRom switched in\n");
	if (hd.flag29 & 0x04) printf("...flag 29.bit 2.Issue 2 emulation\n");
	if (hd.flag29 & 0x08) printf("...flag 29.bit 3.Double interrupt frequency\n");
// continued
	if (comp->cpu->pc == 0) {
		adr = fgetw(file);
		twrd = fgetw(file);
		comp->cpu->pc = twrd;
		lst = fgetc(file);			// 34: HW mode
		tmp = fgetc(file);			// 35: 7FFD last out
		comp->hw->out(comp, 0x7ffd, tmp, 0);
		tmp = fgetc(file);			// 36: skip (IF1)
		tmp = fgetc(file);			// 37: skip (flags) TODO
		reg = fgetc(file);			// 38: last out to fffd
		for (tmp2 = 0; tmp2 < 16; tmp2++) {	// AY regs
			tmp = fgetc(file);
			tsOut(comp->ts, 0xfffd, tmp2);
			tsOut(comp->ts, 0xbffd, tmp);
		}
		comp->hw->out(comp, 0xfffd, reg, 0);

		if (adr > 23) {
printf(".z80 version 3\n");
			if (lst < 16) printf("Hardware: %s\n",v3hardware[lst]);
			switch (lst) {
				case 0:
				case 1:
				case 2: lst = 1; break;		// 48K
				case 4:
				case 5:
				case 6:
				case 9: lst = 2; break;		// 128K
				case 10: lst = 3; break;	// 256K
				default: lst = 0; break;	// undef
			}
			fseek(file, adr-23, SEEK_CUR);		// skip all other bytes
		} else {
printf(".z80 version 2\n");
			if (lst < 16) printf("Hardware: %s\n",v2hardware[lst]);
			switch (lst) {
				case 0:
				case 1: lst = 1; break;
				case 3:
				case 4:
				case 9: lst = 2; break;		// 128K
				case 10: lst = 3; break;	// 256K
				default: lst = 0; break;	// undef
			}
		}
		switch (lst) {
			case 1:
				btm = 1;
				do {
					tmp = z80readblock(file,pageBuf);
					switch (tmp) {
						case 4: memPutData(comp->mem,MEM_RAM,2,MEM_16K,pageBuf); break;
						case 5: memPutData(comp->mem,MEM_RAM,0,MEM_16K,pageBuf); break;
						case 8: memPutData(comp->mem,MEM_RAM,5,MEM_16K,pageBuf); break;
						default: btm = 0; break;
					}
				} while (btm && !feof(file));
				break;
			case 2:
				btm = 1;
				do {
					tmp = z80readblock(file,pageBuf);
					if ((tmp > 2) && (tmp < 11)) {
						memPutData(comp->mem,MEM_RAM,tmp-3,MEM_16K,pageBuf);
					} else {
						btm = 0;
					}
				} while (btm && !feof(file));
				break;
			case 3:
				btm = 1;
				do {
					tmp = z80readblock(file,pageBuf);
					if ((tmp > 2) && (tmp < 19)) {
						memPutData(comp->mem,MEM_RAM,tmp-3,MEM_16K,pageBuf);
					} else {
						btm = 0;
					}
				} while (btm && !feof(file));
				break;
			default:
				printf("Hardware mode not supported. reset\n");
				compReset(comp, RES_DEFAULT);
				err = ERR_Z80_HW;
				break;
		}
	} else {			// version 1
printf(".z80 version 1\n");
		if (hd.flag12 & 0x20) {
			printf("data is compressed\n");
			z80uncompress(file,pageBuf,0xc000);
			memPutData(comp->mem,MEM_RAM,5,MEM_16K,pageBuf);
			memPutData(comp->mem,MEM_RAM,2,MEM_16K,pageBuf + MEM_16K);
			memPutData(comp->mem,MEM_RAM,0,MEM_16K,pageBuf + MEM_32K);
		} else {
			printf("data is not compressed\n");
			fread(pageBuf, 0x4000, 1, file);
			memPutData(comp->mem,MEM_RAM,5,MEM_16K,pageBuf);
			fread(pageBuf, 0x4000, 1, file);
			memPutData(comp->mem,MEM_RAM,2,MEM_16K,pageBuf);
			fread(pageBuf, 0x4000, 1, file);
			memPutData(comp->mem,MEM_RAM,0,MEM_16K,pageBuf);
		}
	}
	tsReset(comp->ts);
	return err;
}
コード例 #3
0
int loadSNA_f(Computer* comp, FILE* file, size_t fileSize) {

	unsigned char tmp, tmp2;
	unsigned short adr;
	char* pageBuf = malloc(0x4000);
	char* tmpgBuf = malloc(0x4000);

	compReset(comp, (fileSize < 49180) ? RES_48 : RES_128);

	snaHead hd;
	fread((char*)&hd, sizeof(snaHead), 1, file);
	comp->cpu->hl_ = (hd._h << 8) | hd._l;
	comp->cpu->de_ = (hd._d << 8) | hd._e;
	comp->cpu->bc_ = (hd._b << 8) | hd._c;
	comp->cpu->af_ = (hd._a << 8) | hd._f;
	comp->cpu->hl = (hd.h << 8) | hd.l;
	comp->cpu->de = (hd.d << 8) | hd.e;
	comp->cpu->bc = (hd.b << 8) | hd.c;
	comp->cpu->af = (hd.a << 8) | hd.f;
	comp->cpu->ix = (hd.hx << 8) | hd.lx;
	comp->cpu->iy = (hd.hy << 8) | hd.ly;
	comp->cpu->sp = (hd.hsp << 8) | hd.lsp;
	comp->cpu->i = hd.i;
	comp->cpu->r = hd.r;
	comp->cpu->r7 = hd.r & 0x80;
	comp->cpu->imode = hd.imod & 3;
	comp->cpu->iff1 = (hd.flag19 & 4) ? 1 : 0;
	comp->vid->brdcol = hd.border & 7;
	comp->vid->nextbrd = hd.border & 7;

	fread(pageBuf, 0x4000, 1, file);
	memSetPageData(comp->mem,MEM_RAM,5,pageBuf);
	fread(pageBuf, 0x4000, 1, file);
	memSetPageData(comp->mem,MEM_RAM,2,pageBuf);
	fread(tmpgBuf, 0x4000, 1, file);

	if (fileSize < 49180) {
		comp->p7FFD = 0x10;
		comp->pEFF7 = 0x00;
		comp->dos = 0;
		comp->hw->mapMem(comp);
		memSetBank(comp->mem, MEM_BANK3, MEM_RAM,0);
		memSetPageData(comp->mem, MEM_RAM, 0, tmpgBuf);
		comp->vid->curscr = 5;
		adr = (hd.hsp << 8) | hd.lsp;
		tmp = memRd(comp->mem, adr++);
		tmp2 = memRd(comp->mem, adr++);
		comp->cpu->sp = adr;
		comp->cpu->pc = tmp | (tmp2 << 8);
	} else {
		adr = fgetc(file);
		adr |= fgetc(file) << 8;
		comp->cpu->pc = adr;
		tmp = fgetc(file);
		comp->hw->out(comp,0x7ffd,tmp,0);
		tmp2 = fgetc(file);
		comp->dos = (tmp2 & 1) ? 1 : 0;
		for (tmp2 = 0; tmp2 < 8; tmp2++) {
			if ((tmp2 == 2) || (tmp2 == 5)) tmp2++;
			if ((tmp & 7) != tmp2) {
				fread(pageBuf, 0x4000, 1, file);
				memSetPageData(comp->mem, MEM_RAM, tmp2, pageBuf);
			}
		}
		memSetPageData(comp->mem, MEM_RAM, tmp & 7, tmpgBuf);
	}
	tsReset(comp->ts);
	free(pageBuf);
	free(tmpgBuf);
	return ERR_OK;
}