#include <stdio.h>
#include "os.h"
#include "bbc.h"

#include "general.h"
#include "Externals.h"

u_char inst;  

extern u_int rPC0;
 
static void rPCDebug(void)
{
}

void FetchI(void)
{
extern void (*ModOp[256])();

while(TRUE)
	{
	extern BOOL (*EmulOp[SIZE_CODE>>8])(u_char pfx);
	static u_int rpclast= 0xffff;
	if((BOOL) Reg_INT)
		{
		extern void Traite_interrupt(void);
		Traite_interrupt();
		continue;
		}
/*	bbc_tab(0,25); printf("rPC %4x\n",Reg_PC); */
	if(Reg_PC == rPC0)
		{
		bbc_vdu(bbc_Bell); printf("%4x",rpclast);
		(void) getchar();
		rPCDebug();
		}
	rpclast= Reg_PC;
	if(EmulOp[Reg_PC>>8])
		if((*EmulOp[Reg_PC>>8])(Reg_PC & 0xff)) continue;
	/* La ligne suivante represente le cycle fetch du Z80 */
	inst= TRSCode->bytes[Reg_PC];
	NEXTPC;
	/* Resolution du code-op. */
	(*ModOp[inst])();
	}
}

#ifndef NMI
void Fetch(void)
{
extern void (*ModOp[256])();

while(TRUE)
	{
	extern BOOL (*EmulOp[SIZE_CODE>>8])(u_char pfx);
	static u_int rpclast= 0xffff;
/*	bbc_tab(0,25); printf("rPC %4x\n",Reg_PC); */
	if(Reg_PC == rPC0)
		{
		bbc_vdu(bbc_Bell); printf("%4x",rpclast);
		(void) getchar();
		rPCDebug();
		}
	rpclast= Reg_PC;
	if(EmulOp[Reg_PC>>8])
		if((*EmulOp[Reg_PC>>8])(Reg_PC & 0xff)) continue;
	/* La ligne suivante represente le cycle fetch du Z80 */
	inst= TRSCode->bytes[Reg_PC];
	NEXTPC;
	/* Resolution du code-op. */
	(*ModOp[inst])();
	}
}
#endif
