summaryrefslogtreecommitdiff
path: root/src/usf/cpu.h
blob: 48510fee5bd8e356440b99df5e10ae223d180b70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * Project 64 - A Nintendo 64 emulator.
 *
 * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and
 * Jabo (jabo@emulation64.com).
 *
 * pj64 homepage: www.pj64.net
 *
 * Permission to use, copy, modify and distribute Project64 in both binary and
 * source form, for non-commercial purposes, is hereby granted without fee,
 * providing that this license information and copyright notice appear with
 * all copies and any derived work.
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event shall the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Project64 is freeware for PERSONAL USE only. Commercial users should
 * seek permission of the copyright holders first. Commercial use includes
 * charging money for Project64 or software derived from Project64.
 *
 * The copyright holders request that bug fixes and improvements to the code
 * should be forwarded to them so if they want them.
 *
 */
#ifndef _CPU_H_
#define _CPU_H_

#include "interpreter_cpu.h"
#include "interpreter_ops.h"
#include "recompiler_cpu.h"
#include "registers.h"
#include "recompiler_ops.h"
#include "tlb.h"
#include "memory.h"
#include "dma.h"
#include "exception.h"
#include "pif.h"
#include "opcode.h"
#include "usf.h"

#ifdef __LP64__
#define USEX86
#define EXTREGS
#endif

typedef struct {
	int32_t DoSomething;
	int32_t CloseCPU;
	int32_t CheckInterrupts;
	int32_t DoInterrupt;
} CPU_ACTION;

#define MaxTimers				3
#define CompareTimer			0
#define ViTimer					1
#define AiTimer					2

typedef struct {
	int32_t NextTimer[MaxTimers];
	int32_t Active[MaxTimers];
	int32_t CurrentTimerType;
	int32_t Timer;
} SYSTEM_TIMERS;

void ChangeCompareTimer ( void );
void ChangeTimer        ( int32_t Type, int32_t Value );
void CheckTimer         ( void );
void CloseCpu           ( void );
int32_t  DelaySlotEffectsCompare ( uint32_t PC, uint32_t Reg1, uint32_t Reg2 );
int32_t  DelaySlotEffectsJump (uint32_t JumpPC);
void DoSomething        ( void );
void InPermLoop         ( void );
void InitiliazeCPUFlags ( void );
void RefreshScreen      ( void );
void RunRsp             ( void );
void StartEmulation     ( void );
void TimerDone          ( void );
void RecompileTimerDone ( void );
void controlfp			(uint32_t mask);
void StartEmulationFromSave ( void * savestate );

#define NORMAL					0
#define DO_DELAY_SLOT			1
#define DO_END_DELAY_SLOT		2
#define DELAY_SLOT				3
#define END_DELAY_SLOT			4
#define LIKELY_DELAY_SLOT		5
#define JUMP	 				6
#define DELAY_SLOT_DONE			7
#define LIKELY_DELAY_SLOT_DONE	8
#define END_BLOCK 				9

enum SaveType {
	Auto,
	Eeprom_4K,
	Eeprom_16K,
	Sram,
	FlashRam
};


extern uint32_t NextInstruction, JumpToLocation, ManualPaused, CPU_Paused, CountPerOp, AudioIntrReg, * WaitMode, CPU_Type;
extern CPU_ACTION * CPU_Action;
extern SYSTEM_TIMERS * Timers;
extern OPCODE Opcode;
extern uint32_t CPURunning;
#endif