Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
melonDS
Commits
2a33a5c4
Commit
2a33a5c4
authored
Mar 03, 2017
by
StapleButter
Browse files
* fixes to GXFIFO IRQ. refine IRQ support a bit.
* fix potential bug when multiple DMAs are running.
parent
e0fa57fb
Changes
8
Hide whitespace changes
Inline
Side-by-side
DMA.cpp
View file @
2a33a5c4
...
...
@@ -191,14 +191,14 @@ void DMA::Start()
NDSCart
::
DMA
(
CurDstAddr
);
Cnt
&=
~
0x80000000
;
if
(
Cnt
&
0x40000000
)
NDS
::
Trigger
IRQ
(
CPU
,
NDS
::
IRQ_DMA0
+
Num
);
NDS
::
Set
IRQ
(
CPU
,
NDS
::
IRQ_DMA0
+
Num
);
return
;
}
// TODO eventually: not stop if we're running code in ITCM
Running
=
true
;
NDS
::
StopCPU
(
CPU
,
true
);
NDS
::
StopCPU
(
CPU
,
1
<<
Num
);
}
s32
DMA
::
Run
(
s32
cycles
)
...
...
@@ -247,9 +247,9 @@ s32 DMA::Run(s32 cycles)
if
(
IterCount
==
0
)
{
Running
=
false
;
NDS
::
Stop
CPU
(
CPU
,
false
);
NDS
::
Resume
CPU
(
CPU
,
1
<<
Num
);
if
(
StartMode
&
0x07
)
if
(
StartMode
==
0x07
)
GPU3D
::
CheckFIFODMA
();
}
...
...
@@ -260,10 +260,10 @@ s32 DMA::Run(s32 cycles)
Cnt
&=
~
0x80000000
;
if
(
Cnt
&
0x40000000
)
NDS
::
Trigger
IRQ
(
CPU
,
NDS
::
IRQ_DMA0
+
Num
);
NDS
::
Set
IRQ
(
CPU
,
NDS
::
IRQ_DMA0
+
Num
);
Running
=
false
;
NDS
::
Stop
CPU
(
CPU
,
false
);
NDS
::
Resume
CPU
(
CPU
,
1
<<
Num
);
return
cycles
-
2
;
}
GPU.cpp
View file @
2a33a5c4
...
...
@@ -646,8 +646,8 @@ void StartHBlank(u32 line)
if
(
line
<
192
)
NDS
::
CheckDMAs
(
0
,
0x02
);
if
(
DispStat
[
0
]
&
(
1
<<
4
))
NDS
::
Trigger
IRQ
(
0
,
NDS
::
IRQ_HBlank
);
if
(
DispStat
[
1
]
&
(
1
<<
4
))
NDS
::
Trigger
IRQ
(
1
,
NDS
::
IRQ_HBlank
);
if
(
DispStat
[
0
]
&
(
1
<<
4
))
NDS
::
Set
IRQ
(
0
,
NDS
::
IRQ_HBlank
);
if
(
DispStat
[
1
]
&
(
1
<<
4
))
NDS
::
Set
IRQ
(
1
,
NDS
::
IRQ_HBlank
);
if
(
line
<
262
)
NDS
::
ScheduleEvent
(
NDS
::
Event_LCD
,
true
,
(
LINE_CYCLES
-
HBLANK_CYCLES
),
StartScanline
,
line
+
1
);
...
...
@@ -664,7 +664,7 @@ void StartScanline(u32 line)
{
DispStat
[
0
]
|=
(
1
<<
2
);
if
(
DispStat
[
0
]
&
(
1
<<
5
))
NDS
::
Trigger
IRQ
(
0
,
NDS
::
IRQ_VCount
);
if
(
DispStat
[
0
]
&
(
1
<<
5
))
NDS
::
Set
IRQ
(
0
,
NDS
::
IRQ_VCount
);
}
else
DispStat
[
0
]
&=
~
(
1
<<
2
);
...
...
@@ -673,7 +673,7 @@ void StartScanline(u32 line)
{
DispStat
[
1
]
|=
(
1
<<
2
);
if
(
DispStat
[
1
]
&
(
1
<<
5
))
NDS
::
Trigger
IRQ
(
1
,
NDS
::
IRQ_VCount
);
if
(
DispStat
[
1
]
&
(
1
<<
5
))
NDS
::
Set
IRQ
(
1
,
NDS
::
IRQ_VCount
);
}
else
DispStat
[
1
]
&=
~
(
1
<<
2
);
...
...
@@ -704,8 +704,8 @@ void StartScanline(u32 line)
NDS
::
CheckDMAs
(
0
,
0x01
);
NDS
::
CheckDMAs
(
1
,
0x11
);
if
(
DispStat
[
0
]
&
(
1
<<
3
))
NDS
::
Trigger
IRQ
(
0
,
NDS
::
IRQ_VBlank
);
if
(
DispStat
[
1
]
&
(
1
<<
3
))
NDS
::
Trigger
IRQ
(
1
,
NDS
::
IRQ_VBlank
);
if
(
DispStat
[
0
]
&
(
1
<<
3
))
NDS
::
Set
IRQ
(
0
,
NDS
::
IRQ_VBlank
);
if
(
DispStat
[
1
]
&
(
1
<<
3
))
NDS
::
Set
IRQ
(
1
,
NDS
::
IRQ_VBlank
);
GPU2D_A
->
VBlank
();
GPU2D_B
->
VBlank
();
...
...
GPU3D.cpp
View file @
2a33a5c4
...
...
@@ -1324,6 +1324,11 @@ void ExecuteCommand()
Viewport
[
2
]
=
((
ExecParams
[
0
]
>>
16
)
&
0xFF
)
-
Viewport
[
0
]
+
1
;
Viewport
[
3
]
=
(
ExecParams
[
0
]
>>
24
)
-
Viewport
[
1
]
+
1
;
break
;
default:
//if (entry.Command != 0x41)
//printf("!! UNKNOWN GX COMMAND %02X %08X\n", entry.Command, entry.Param);
break
;
}
}
}
...
...
@@ -1360,7 +1365,8 @@ void CheckFIFOIRQ()
case
2
:
irq
=
CmdFIFO
->
IsEmpty
();
break
;
}
if
(
irq
)
NDS
::
TriggerIRQ
(
0
,
NDS
::
IRQ_GXFIFO
);
if
(
irq
)
NDS
::
SetIRQ
(
0
,
NDS
::
IRQ_GXFIFO
);
else
NDS
::
ClearIRQ
(
0
,
NDS
::
IRQ_GXFIFO
);
}
void
CheckFIFODMA
()
...
...
@@ -1456,6 +1462,7 @@ void Write32(u32 addr, u32 val)
val
&=
0xC0000000
;
GXStat
&=
0x3FFFFFFF
;
GXStat
|=
val
;
CheckFIFOIRQ
();
return
;
}
...
...
NDS.cpp
View file @
2a33a5c4
...
...
@@ -374,7 +374,7 @@ void RunFrame()
CalcIterationCycles
();
if
(
CPUStop
&
0x
1
)
if
(
CPUStop
&
0x
FFFF
)
{
s32
cycles
=
CurIterationCycles
;
cycles
=
DMAs
[
0
]
->
Run
(
cycles
);
...
...
@@ -393,7 +393,7 @@ void RunFrame()
ndscyclestorun
=
ARM9
->
Cycles
>>
1
;
}
if
(
CPUStop
&
0x
2
)
if
(
CPUStop
&
0x
FFFF0000
)
{
s32
cycles
=
ndscyclestorun
-
ARM7Offset
;
cycles
=
DMAs
[
4
]
->
Run
(
cycles
);
...
...
@@ -529,14 +529,14 @@ void MapSharedWRAM(u8 val)
}
void
Trigger
IRQ
(
u32
cpu
,
u32
irq
)
void
Set
IRQ
(
u32
cpu
,
u32
irq
)
{
irq
=
1
<<
irq
;
IF
[
cpu
]
|=
irq
;
IF
[
cpu
]
|
=
(
1
<<
irq
)
;
}
// this is redundant
if
(
!
(
IME
[
cpu
]
&
0x1
))
return
;
//(cpu?ARM7:ARM9)->TriggerIRQ(
);
void
ClearIRQ
(
u32
cpu
,
u32
irq
)
{
IF
[
cpu
]
&=
~
(
1
<<
irq
);
}
bool
HaltInterrupted
(
u32
cpu
)
...
...
@@ -553,10 +553,16 @@ bool HaltInterrupted(u32 cpu)
return
false
;
}
void
StopCPU
(
u32
cpu
,
bool
stop
)
void
StopCPU
(
u32
cpu
,
u32
mask
)
{
if
(
cpu
)
mask
<<=
16
;
CPUStop
|=
mask
;
}
void
ResumeCPU
(
u32
cpu
,
u32
mask
)
{
if
(
stop
)
CPUStop
|=
(
1
<<
cpu
)
;
else
CPUStop
&=
~
(
1
<<
cpu
)
;
if
(
cpu
)
mask
<<=
16
;
CPUStop
&=
~
mask
;
}
...
...
@@ -607,7 +613,7 @@ void TimerOverflow(u32 param)
timer
->
Counter
=
timer
->
Reload
<<
16
;
if
(
timer
->
Cnt
&
(
1
<<
6
))
Trigger
IRQ
(
cpu
,
IRQ_Timer0
+
tid
);
Set
IRQ
(
cpu
,
IRQ_Timer0
+
tid
);
// cascade
if
(
tid
==
3
)
...
...
@@ -1425,7 +1431,7 @@ u32 ARM9IORead32(u32 addr)
ret
=
IPCFIFO7
->
Read
();
if
(
IPCFIFO7
->
IsEmpty
()
&&
(
IPCFIFOCnt7
&
0x0004
))
Trigger
IRQ
(
1
,
IRQ_IPCSendDone
);
Set
IRQ
(
1
,
IRQ_IPCSendDone
);
}
return
ret
;
}
...
...
@@ -1554,7 +1560,7 @@ void ARM9IOWrite16(u32 addr, u16 val)
IPCSync9
|=
(
val
&
0x4F00
);
if
((
val
&
0x2000
)
&&
(
IPCSync7
&
0x4000
))
{
Trigger
IRQ
(
1
,
IRQ_IPCSync
);
Set
IRQ
(
1
,
IRQ_IPCSync
);
}
//CompensateARM7();
return
;
...
...
@@ -1563,9 +1569,9 @@ void ARM9IOWrite16(u32 addr, u16 val)
if
(
val
&
0x0008
)
IPCFIFO9
->
Clear
();
if
((
val
&
0x0004
)
&&
(
!
(
IPCFIFOCnt9
&
0x0004
))
&&
IPCFIFO9
->
IsEmpty
())
Trigger
IRQ
(
0
,
IRQ_IPCSendDone
);
Set
IRQ
(
0
,
IRQ_IPCSendDone
);
if
((
val
&
0x0400
)
&&
(
!
(
IPCFIFOCnt9
&
0x0400
))
&&
(
!
IPCFIFO7
->
IsEmpty
()))
Trigger
IRQ
(
0
,
IRQ_IPCRecv
);
Set
IRQ
(
0
,
IRQ_IPCRecv
);
if
(
val
&
0x4000
)
IPCFIFOCnt9
&=
~
0x4000
;
IPCFIFOCnt9
=
val
&
0x8404
;
...
...
@@ -1695,7 +1701,7 @@ void ARM9IOWrite32(u32 addr, u32 val)
bool
wasempty
=
IPCFIFO9
->
IsEmpty
();
IPCFIFO9
->
Write
(
val
);
if
((
IPCFIFOCnt7
&
0x0400
)
&&
wasempty
)
Trigger
IRQ
(
1
,
IRQ_IPCRecv
);
Set
IRQ
(
1
,
IRQ_IPCRecv
);
}
}
return
;
...
...
@@ -1908,7 +1914,7 @@ u32 ARM7IORead32(u32 addr)
ret
=
IPCFIFO9
->
Read
();
if
(
IPCFIFO9
->
IsEmpty
()
&&
(
IPCFIFOCnt9
&
0x0004
))
Trigger
IRQ
(
0
,
IRQ_IPCSendDone
);
Set
IRQ
(
0
,
IRQ_IPCSendDone
);
}
return
ret
;
}
...
...
@@ -2023,7 +2029,7 @@ void ARM7IOWrite16(u32 addr, u16 val)
IPCSync7
|=
(
val
&
0x4F00
);
if
((
val
&
0x2000
)
&&
(
IPCSync9
&
0x4000
))
{
Trigger
IRQ
(
0
,
IRQ_IPCSync
);
Set
IRQ
(
0
,
IRQ_IPCSync
);
}
return
;
...
...
@@ -2031,9 +2037,9 @@ void ARM7IOWrite16(u32 addr, u16 val)
if
(
val
&
0x0008
)
IPCFIFO7
->
Clear
();
if
((
val
&
0x0004
)
&&
(
!
(
IPCFIFOCnt7
&
0x0004
))
&&
IPCFIFO7
->
IsEmpty
())
Trigger
IRQ
(
1
,
IRQ_IPCSendDone
);
Set
IRQ
(
1
,
IRQ_IPCSendDone
);
if
((
val
&
0x0400
)
&&
(
!
(
IPCFIFOCnt7
&
0x0400
))
&&
(
!
IPCFIFO9
->
IsEmpty
()))
Trigger
IRQ
(
1
,
IRQ_IPCRecv
);
Set
IRQ
(
1
,
IRQ_IPCRecv
);
if
(
val
&
0x4000
)
IPCFIFOCnt7
&=
~
0x4000
;
IPCFIFOCnt7
=
val
&
0x8404
;
...
...
@@ -2135,7 +2141,7 @@ void ARM7IOWrite32(u32 addr, u32 val)
bool
wasempty
=
IPCFIFO7
->
IsEmpty
();
IPCFIFO7
->
Write
(
val
);
if
((
IPCFIFOCnt9
&
0x0400
)
&&
wasempty
)
Trigger
IRQ
(
0
,
IRQ_IPCRecv
);
Set
IRQ
(
0
,
IRQ_IPCRecv
);
}
}
return
;
...
...
NDS.h
View file @
2a33a5c4
...
...
@@ -140,9 +140,11 @@ void Halt();
void
MapSharedWRAM
(
u8
val
);
void
TriggerIRQ
(
u32
cpu
,
u32
irq
);
void
SetIRQ
(
u32
cpu
,
u32
irq
);
void
ClearIRQ
(
u32
cpu
,
u32
irq
);
bool
HaltInterrupted
(
u32
cpu
);
void
StopCPU
(
u32
cpu
,
bool
stop
);
void
StopCPU
(
u32
cpu
,
u32
mask
);
void
ResumeCPU
(
u32
cpu
,
u32
mask
);
void
CheckDMAs
(
u32
cpu
,
u32
mode
);
...
...
NDSCart.cpp
View file @
2a33a5c4
...
...
@@ -713,7 +713,7 @@ void EndTransfer()
ROMCnt
&=
~
(
1
<<
31
);
if
(
SPICnt
&
(
1
<<
14
))
NDS
::
Trigger
IRQ
((
NDS
::
ExMemCnt
[
0
]
>>
11
)
&
0x1
,
NDS
::
IRQ_CartSendDone
);
NDS
::
Set
IRQ
((
NDS
::
ExMemCnt
[
0
]
>>
11
)
&
0x1
,
NDS
::
IRQ_CartSendDone
);
}
void
ROMPrepareData
(
u32
param
)
...
...
SPI.cpp
View file @
2a33a5c4
...
...
@@ -451,7 +451,7 @@ void WriteData(u8 val)
}
if
(
Cnt
&
(
1
<<
14
))
NDS
::
Trigger
IRQ
(
1
,
NDS
::
IRQ_SPI
);
NDS
::
Set
IRQ
(
1
,
NDS
::
IRQ_SPI
);
}
}
melonDS.depend
View file @
2a33a5c4
...
...
@@ -5,12 +5,12 @@
"NDS.h"
"GPU.h"
148
7303037
c:\documents\sources\melonds\nds.h
148
8497585
c:\documents\sources\melonds\nds.h
"types.h"
1481161027 c:\documents\sources\melonds\types.h
14884
77261
source:c:\documents\sources\melonds\nds.cpp
14884
97660
source:c:\documents\sources\melonds\nds.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
@@ -24,7 +24,7 @@
"RTC.h"
"Wifi.h"
148
7349559
source:c:\documents\sources\melonds\arm.cpp
148
8497771
source:c:\documents\sources\melonds\arm.cpp
<stdio.h>
"NDS.h"
"ARM.h"
...
...
@@ -81,7 +81,7 @@
1486502258 c:\documents\sources\melonds\spi.h
148
6502498
source:c:\documents\sources\melonds\spi.cpp
148
8496264
source:c:\documents\sources\melonds\spi.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
@@ -109,7 +109,7 @@
1486511075 c:\documents\sources\melonds\fifo.h
"types.h"
148
735403
0 source:c:\documents\sources\melonds\dma.cpp
148
849784
0 source:c:\documents\sources\melonds\dma.cpp
<stdio.h>
"NDS.h"
"DMA.h"
...
...
@@ -119,7 +119,7 @@
1487305393 c:\documents\sources\melonds\dma.h
"types.h"
1488
227337
source:c:\documents\sources\melonds\gpu.cpp
1488
496264
source:c:\documents\sources\melonds\gpu.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
@@ -140,15 +140,15 @@
1486506409 c:\documents\sources\melonds\ndscart.h
"types.h"
148
6506451
source:c:\documents\sources\melonds\ndscart.cpp
148
8496264
source:c:\documents\sources\melonds\ndscart.cpp
<stdio.h>
<string.h>
"NDS.h"
"NDSCart.h"
1488
239485
c:\documents\sources\melonds\gpu3d.h
1488
497796
c:\documents\sources\melonds\gpu3d.h
14884
1004
5 source:c:\documents\sources\melonds\gpu3d.cpp
14884
9782
5 source:c:\documents\sources\melonds\gpu3d.cpp
<stdio.h>
<string.h>
"NDS.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment