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
50721719
Commit
50721719
authored
May 04, 2021
by
Arisotura
Browse files
GBACart: simulate open-bus decay roughly. fixes #1093
parent
b7d5a7db
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/GBACart.cpp
View file @
50721719
...
...
@@ -40,15 +40,15 @@ const char SOLAR_SENSOR_GAMECODES[10][5] =
bool
CartInserted
;
//bool HasSolarSensor;
u8
*
CartROM
;
u32
CartROMSize
;
u32
CartCRC
;
u32
CartID
;
//GPIO CartGPIO; // overridden GPIO parameters
CartCommon
*
Cart
;
u16
OpenBusDecay
;
CartCommon
::
CartCommon
()
{
...
...
@@ -631,6 +631,9 @@ void Reset()
// This allows resetting a DS game without losing GBA state,
// and resetting to firmware without the slot being emptied.
// The Stop function will clear the cartridge state via Eject().
// OpenBusDecay doesn't need to be reset, either, as it will be set
// through NDS::SetGBASlotTimings().
}
void
Eject
()
...
...
@@ -795,11 +798,17 @@ int SetInput(int num, bool pressed)
}
void
SetOpenBusDecay
(
u16
val
)
{
OpenBusDecay
=
val
;
}
u16
ROMRead
(
u32
addr
)
{
if
(
Cart
)
return
Cart
->
ROMRead
(
addr
);
return
(
addr
>>
1
)
&
0xFFFF
;
return
(
(
addr
>>
1
)
&
0xFFFF
)
|
OpenBusDecay
;
}
void
ROMWrite
(
u32
addr
,
u16
val
)
...
...
src/GBACart.h
View file @
50721719
...
...
@@ -161,6 +161,8 @@ void RelocateSave(const char* path, bool write);
// TODO: make more flexible, support nonbinary inputs
int
SetInput
(
int
num
,
bool
pressed
);
void
SetOpenBusDecay
(
u16
val
);
u16
ROMRead
(
u32
addr
);
void
ROMWrite
(
u32
addr
,
u16
val
);
...
...
src/NDS.cpp
View file @
50721719
...
...
@@ -1242,33 +1242,35 @@ void SetWifiWaitCnt(u16 val)
void
SetGBASlotTimings
()
{
int
curcpu
=
(
ExMemCnt
[
0
]
>>
7
)
&
0x1
;
const
int
ntimings
[
4
]
=
{
10
,
8
,
6
,
18
};
const
u16
openbus
[
4
]
=
{
0xFE08
,
0x0000
,
0x0000
,
0xFFFF
};
u16
curcnt
=
ExMemCnt
[
curcpu
];
int
ramN
=
ntimings
[
curcnt
&
0x3
];
int
romN
=
ntimings
[(
curcnt
>>
2
)
&
0x3
];
int
romS
=
(
curcnt
&
0x10
)
?
4
:
6
;
u16
curcnt
;
int
ramN
,
romN
,
romS
;
// TODO: PHI pin thing?
curcnt
=
ExMemCnt
[
0
];
ramN
=
ntimings
[
curcnt
&
0x3
];
romN
=
ntimings
[(
curcnt
>>
2
)
&
0x3
];
romS
=
(
curcnt
&
0x10
)
?
4
:
6
;
if
(
curcpu
==
0
)
{
SetARM9RegionTimings
(
0x08000000
,
0x0A000000
,
16
,
romN
+
3
,
romS
);
SetARM9RegionTimings
(
0x0A000000
,
0x0B000000
,
8
,
ramN
+
3
,
ramN
);
SetARM9RegionTimings
(
0x08000000
,
0x0A000000
,
16
,
romN
+
3
,
romS
);
SetARM9RegionTimings
(
0x0A000000
,
0x0B000000
,
8
,
ramN
+
3
,
ramN
);
SetARM7RegionTimings
(
0x08000000
,
0x0A000000
,
32
,
1
,
1
);
SetARM7RegionTimings
(
0x0A000000
,
0x0B000000
,
32
,
1
,
1
);
}
else
{
SetARM9RegionTimings
(
0x08000000
,
0x0A000000
,
32
,
1
,
1
);
SetARM9RegionTimings
(
0x0A000000
,
0x0B000000
,
32
,
1
,
1
);
curcnt
=
ExMemCnt
[
1
];
ramN
=
ntimings
[
curcnt
&
0x3
];
romN
=
ntimings
[(
curcnt
>>
2
)
&
0x3
];
romS
=
(
curcnt
&
0x10
)
?
4
:
6
;
SetARM7RegionTimings
(
0x08000000
,
0x0A000000
,
16
,
romN
,
romS
);
SetARM7RegionTimings
(
0x0A000000
,
0x0B000000
,
8
,
ramN
,
ramN
);
}
SetARM7RegionTimings
(
0x08000000
,
0x0A000000
,
16
,
romN
,
romS
);
SetARM7RegionTimings
(
0x0A000000
,
0x0B000000
,
8
,
ramN
,
ramN
);
// this open-bus implementation is a rough way of simulating the way values
// lingering on the bus decay after a while, which is visible at higher waitstates
// for example, the Cartridge Construction Kit relies on this to determine that
// the GBA slot is empty
curcnt
=
ExMemCnt
[(
ExMemCnt
[
0
]
>>
7
)
&
0x1
];
GBACart
::
SetOpenBusDecay
(
openbus
[(
curcnt
>>
2
)
&
0x3
]);
}
...
...
@@ -1863,8 +1865,8 @@ void debug(u32 param)
//for (int i = 0; i < 9; i++)
// printf("VRAM %c: %02X\n", 'A'+i, GPU::VRAMCNT[i]);
/*
FILE*
shit = fopen("debug/
party
.bin", "wb");
FILE
*
shit
=
fopen
(
"debug/
construct
.bin"
,
"wb"
);
fwrite
(
ARM9
->
ITCM
,
0x8000
,
1
,
shit
);
for
(
u32
i
=
0x02000000
;
i
<
0x02400000
;
i
+=
4
)
{
...
...
@@ -1876,9 +1878,9 @@ void debug(u32 param)
u32
val
=
ARM7Read32
(
i
);
fwrite
(
&
val
,
4
,
1
,
shit
);
}
fclose(shit);
*/
fclose
(
shit
);
FILE
*
/*
FILE*
shit = fopen("debug/power9.bin", "wb");
for (u32 i = 0x02000000; i < 0x04000000; i+=4)
{
...
...
@@ -1892,7 +1894,7 @@ void debug(u32 param)
u32 val = DSi::ARM7Read32(i);
fwrite(&val, 4, 1, shit);
}
fclose
(
shit
);
fclose(shit);
*/
}
...
...
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