forked from xjsxjs197/WiiSXRX_2022
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpsxhw.h
95 lines (80 loc) · 3.41 KB
/
psxhw.h
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
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __PSXHW_H__
#define __PSXHW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
#include "r3000a.h"
#include "psxmem.h"
#include "sio.h"
#include "psxcounters.h"
#define HW_DMA0_MADR (psxHu32ref(0x1080)) // MDEC in DMA
#define HW_DMA0_BCR (psxHu32ref(0x1084))
#define HW_DMA0_CHCR (psxHu32ref(0x1088))
#define HW_DMA1_MADR (psxHu32ref(0x1090)) // MDEC out DMA
#define HW_DMA1_BCR (psxHu32ref(0x1094))
#define HW_DMA1_CHCR (psxHu32ref(0x1098))
#define HW_DMA2_MADR (psxHu32ref(0x10a0)) // GPU DMA
#define HW_DMA2_BCR (psxHu32ref(0x10a4))
#define HW_DMA2_CHCR (psxHu32ref(0x10a8))
#define HW_DMA3_MADR (psxHu32ref(0x10b0)) // CDROM DMA
#define HW_DMA3_BCR (psxHu32ref(0x10b4))
#define HW_DMA3_CHCR (psxHu32ref(0x10b8))
#define HW_DMA4_MADR (psxHu32ref(0x10c0)) // SPU DMA
#define HW_DMA4_BCR (psxHu32ref(0x10c4))
#define HW_DMA4_CHCR (psxHu32ref(0x10c8))
#define HW_DMA6_MADR (psxHu32ref(0x10e0)) // GPU DMA (OT)
#define HW_DMA6_BCR (psxHu32ref(0x10e4))
#define HW_DMA6_CHCR (psxHu32ref(0x10e8))
#define HW_DMA_PCR (psxHu32ref(0x10f0))
#define HW_DMA_ICR (psxHu32ref(0x10f4))
#define HW_DMA_ICR_BUS_ERROR (1<<15)
#define HW_DMA_ICR_GLOBAL_ENABLE (1<<23)
#define HW_DMA_ICR_IRQ_SENT (1<<31)
#define DMA_INTERRUPT(n) \
u32 icr = LOAD_SWAP32p(psxHAddr(0x10f4)); \
if (icr & (1 << (16 + n))) { \
icr |= 1 << (24 + n); \
if (icr & HW_DMA_ICR_GLOBAL_ENABLE && !(icr & HW_DMA_ICR_IRQ_SENT)) { \
psxHu32ref(0x1070) |= SWAP32(8); \
icr |= HW_DMA_ICR_IRQ_SENT; \
} \
STORE_SWAP32p(psxHAddr(0x10f4), icr); \
}
void psxHwReset();
u8 psxHwRead8 (u32 add);
u16 psxHwRead16(u32 add);
u32 psxHwRead32(u32 add);
void psxHwWrite8 (u32 add, u32 value);
void psxHwWrite16(u32 add, u32 value);
void psxHwWrite32(u32 add, u32 value);
u32 sio1ReadStat16(void);
int psxHwFreeze(gzFile f, int Mode);
void psxHwWriteIstat(u32 value);
void psxHwWriteImask(u32 value);
void psxHwWriteDmaIcr32(u32 value);
void psxHwWriteGpuSR(u32 value);
u32 psxHwReadGpuSR(void);
u32 psxHwReadGpuSRbusyHack(void);
#ifdef __cplusplus
}
#endif
#endif