//
// Project UnReality: The First Nintendo 64 Emulator
// Copyright (C) 1997-1998, Cold Fusion Entertainment
// All rights reserved
//
// This source code is unpublished propietary information of Cold Fusion Entertainment.  No portion of this software
// may be disclosed to any third party or copied or duplicated in any form, in whole or in part, without the prior
// written consent of Cold Fusion Entertainment.
// 

//
// $Log: r4300i.h $
// Revision 1.10  1998/05/25 04:39:28  BREAKPOINT
// Added 'Call Stack' to debugger which shows the history of JAL[R]/JR RA instructions.
// Revision 1.9  1998/05/24 20:48:59  BREAKPOINT
// Beginning of TLB implementation... fixed c0reg.Context to be 32 bit, changed exception handler to support TLB and modified
// assembly core to be re-entrant.
// Revision 1.8  1998/04/19 16:32:59  BREAKPOINT
// Added Trap Exceptions and included TEQ opcode.
// Revision 1.7  1998/04/07 23:29:41  BREAKPOINT
// Fixed up debugger... added 'Safe_Read*()' calls to access memory without causing crashes when reading from unmapped memory.
// Revision 1.6  1998/04/05 15:09:32  BREAKPOINT
// Added extra variables to MEM_* functions so RSP can call as well...
// Revision 1.5  1998/04/02 21:18:51  BREAKPOINT
// Implemented new memory mapping routines and changed ROM loading code.
// Revision 1.4  1998/03/29 20:26:49  BREAKPOINT
// Added Arithmetic Overflow Exception to exception handler...
// Revision 1.3  1998/03/22 17:52:32  BREAKPOINT
// New breakpoint detection routine to speed up debugging and emulation by changing the opcode to and invalid one.
// Needs more work, also Breakpoint on RegV is broken too.
// Revision 1.2  1998/03/08 19:13:12  BREAKPOINT
// Version 0.3b.3 checkin... I need to really check this stuff in more often..
// Revision 1.1  1998/01/31 19:59:45  BREAKPOINT
// Initial revision
//

//---------------------------------------------------------------------------------------------------------------------

#ifndef R4300I_H
#define R4300I_H

#include "emu.h"

extern "C"
{
	extern R4RegSet             r4reg;
	extern TLB_EntryDef         tlb[TLBENTRIES];
	extern C0RegSet             c0reg;
	extern C1RegSet             c1reg;
	extern RDRAM_RegSet         rdreg;
	extern SP_RegSet            spreg;
	extern SP_PC_RegSet         sp_pc;
	extern SP_IMEM_BIST_RegSet  sp_ibist;
	extern DPC_RegSet           dpcreg;
	extern DPS_RegSet           dpsreg;
	extern MIPS_Intf_RegSet     mireg;
	extern VI_RegSet            vireg;
	extern AI_RegSet            aireg;
	extern PI_RegSet            pireg;
	extern RI_RegSet            rireg;
	extern SI_RegSet            sireg;
	extern LEO_RegSet           leoreg;
	extern MemMapDef            memmap[NUM_MEMMAPS];

	extern bool  DMA_running;
	extern ulong DMA_src_addr, DMA_dest_addr, DMA_bytes_to_copy, DMA_len;

	extern ulong MMIO_offs;
	extern uchar MMIO_size;
	extern ulong MMIO_val[2];

	extern ulong MEM_addr;
	extern ulong MEM_val[2];
	extern ulong MEM_return_val[2];

	extern ulong RSP_MEM_addr;
	extern ulong RSP_MEM_val[2];
	extern ulong RSP_MEM_return_val[2];

	extern ulong FUNC_MemCopy;
	extern ulong FUNC_MemReadFail;
	extern ulong FUNC_MemWriteFail;

	extern ulong FUNC_UnknownOpcode;
	extern ulong FUNC_COP_Unusable;
	extern ulong FUNC_COP0_Unknown;
	extern ulong FUNC_COP1_Unknown;
	extern ulong FUNC_COP2_Unknown;
	extern ulong FUNC_UnhandledOpcode;
    extern ulong FUNC_RegenIntr;

	extern ulong FUNC_GenArithOflow;
	extern ulong FUNC_GenTrapExcept;

	extern ulong EventFUNC_Compare;
	extern ulong EventFUNC_PI;

	extern ulong R4PC_newPC;
	extern uchar R4PC_count;

	extern ulong CSTACK_count;
	extern CallStackDef CSTACK_data[1024];

	extern void _cdecl InitMainEmulation(void);
	extern void _cdecl MainEmulation(void);

	// Memory read/write calls.  Set 'MEM_*' variables above, or use inline.cpp interface.  These do *NOT* call the MMIO functions.
	extern void _cdecl MEM_Read8(void);
	extern void _cdecl MEM_Read16(void);
	extern void _cdecl MEM_Read32(void);
	extern void _cdecl MEM_Read64(void);
	extern void _cdecl MEM_Write8(void);
	extern void _cdecl MEM_Write16(void);
	extern void _cdecl MEM_Write32(void);
	extern void _cdecl MEM_Write64(void);

	// Memory read/write calls for the RSP.  Set 'MEM_*' variables above, or use inline.cpp interface.  These do *NOT* call the MMIO functions.
	extern void _cdecl RSP_MEM_Read8(void);
	extern void _cdecl RSP_MEM_Read16(void);
	extern void _cdecl RSP_MEM_Read32(void);
	extern void _cdecl RSP_MEM_Read64(void);
	extern void _cdecl RSP_MEM_Write8(void);
	extern void _cdecl RSP_MEM_Write16(void);
	extern void _cdecl RSP_MEM_Write32(void);
	extern void _cdecl RSP_MEM_Write64(void);

	// Memory read/write calls that *DO* call the MMIO functions.
	extern void _cdecl MMIO_Read8(void);
	extern void _cdecl MMIO_Read16(void);
	extern void _cdecl MMIO_Read32(void);
	extern void _cdecl MMIO_Read64(void);
	extern void _cdecl MMIO_Write8(void);
	extern void _cdecl MMIO_Write16(void);
	extern void _cdecl MMIO_Write32(void);
	extern void _cdecl MMIO_Write64(void);
}

#endif
