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
RACE
Commits
00cf8728
Commit
00cf8728
authored
Oct 04, 2020
by
Libretro-Admin
Browse files
Convert DrZ80_support.cpp to C
parent
e16a90d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
DrZ80_support.c
pp
→
DrZ80_support.c
View file @
00cf8728
...
...
@@ -20,28 +20,28 @@
#define INT_IRQ 0x01
#define NMI_IRQ 0x08
Z80_Regs
Z80
;
struct
Z80_Regs
Z80
;
#define
z
80_
int
() Z80.regs.Z80_IRQ = INT_IRQ
#define
z
80_
nmi
() Z80.regs.Z80IF |= NMI_IRQ
#define
Z
80_
INT
() Z80.regs.Z80_IRQ = INT_IRQ
#define
Z
80_
NMI
() Z80.regs.Z80IF |= NMI_IRQ
static
unsigned
int
z80_rebaseSP
(
unsigned
short
address
)
{
Z80
.
regs
.
Z80SP_BASE
=
(
unsigned
int
)
&
mainram
[
0x3000
];
Z80
.
regs
.
Z80SP
=
Z80
.
regs
.
Z80SP_BASE
+
address
;
return
Z80
.
regs
.
Z80SP_BASE
+
address
;
Z80
.
regs
.
Z80SP_BASE
=
(
unsigned
int
)
&
mainram
[
0x3000
];
Z80
.
regs
.
Z80SP
=
Z80
.
regs
.
Z80SP_BASE
+
address
;
return
Z80
.
regs
.
Z80SP_BASE
+
address
;
}
static
unsigned
int
z80_rebasePC
(
unsigned
short
address
)
{
Z80
.
regs
.
Z80PC_BASE
=
(
unsigned
int
)
&
mainram
[
0x3000
];
Z80
.
regs
.
Z80PC
=
Z80
.
regs
.
Z80PC_BASE
+
address
;
return
Z80
.
regs
.
Z80PC_BASE
+
address
;
Z80
.
regs
.
Z80PC_BASE
=
(
unsigned
int
)
&
mainram
[
0x3000
];
Z80
.
regs
.
Z80PC
=
Z80
.
regs
.
Z80PC_BASE
+
address
;
return
Z80
.
regs
.
Z80PC_BASE
+
address
;
}
static
void
z80_irq_callback
(
void
)
{
Z80
.
regs
.
Z80_IRQ
=
0x00
;
Z80
.
regs
.
Z80_IRQ
=
0x00
;
}
...
...
@@ -50,36 +50,36 @@ static void z80_irq_callback(void)
****************************************************************************/
void
Z80_Reset
(
void
)
{
memset
(
&
Z80
,
0
,
sizeof
(
Z80_Regs
));
Z80
.
regs
.
z80_rebasePC
=
z80_rebasePC
;
Z80
.
regs
.
z80_rebaseSP
=
z80_rebaseSP
/* 0 */
;
Z80
.
regs
.
z80_read8
=
z80MemReadB
;
/* z80_read8 */
Z80
.
regs
.
z80_read16
=
z80MemReadW
;
Z80
.
regs
.
z80_write8
=
DrZ80ngpMemWriteB
;
Z80
.
regs
.
z80_write16
=
DrZ80ngpMemWriteW
;
Z80
.
regs
.
z80_in
=
DrZ80ngpPortReadB
;
Z80
.
regs
.
z80_out
=
DrZ80ngpPortWriteB
;
Z80
.
regs
.
z80_irq_callback
=
z80_irq_callback
;
Z80
.
regs
.
Z80BC
=
0013
;
Z80
.
regs
.
Z80DE
=
0x00D8
;
Z80
.
regs
.
Z80HL
=
0x014D
;
Z80
.
regs
.
Z80PC
=
Z80
.
regs
.
z80_rebasePC
(
0
);
Z80
.
regs
.
Z80SP
=
Z80
.
regs
.
z80_rebaseSP
(
0xFFFE
);
Z80_Clear_Pending_Interrupts
();
memset
(
&
Z80
,
0
,
sizeof
(
struct
Z80_Regs
));
Z80
.
regs
.
z80_rebasePC
=
z80_rebasePC
;
Z80
.
regs
.
z80_rebaseSP
=
z80_rebaseSP
/* 0 */
;
Z80
.
regs
.
z80_read8
=
z80MemReadB
;
/* z80_read8 */
Z80
.
regs
.
z80_read16
=
z80MemReadW
;
Z80
.
regs
.
z80_write8
=
DrZ80ngpMemWriteB
;
Z80
.
regs
.
z80_write16
=
DrZ80ngpMemWriteW
;
Z80
.
regs
.
z80_in
=
DrZ80ngpPortReadB
;
Z80
.
regs
.
z80_out
=
DrZ80ngpPortWriteB
;
Z80
.
regs
.
z80_irq_callback
=
z80_irq_callback
;
Z80
.
regs
.
Z80BC
=
0013
;
Z80
.
regs
.
Z80DE
=
0x00D8
;
Z80
.
regs
.
Z80HL
=
0x014D
;
Z80
.
regs
.
Z80PC
=
Z80
.
regs
.
z80_rebasePC
(
0
);
Z80
.
regs
.
Z80SP
=
Z80
.
regs
.
z80_rebaseSP
(
0xFFFE
);
Z80_Clear_Pending_Interrupts
();
}
void
Z80_Cause_Interrupt
(
int
type
)
{
if
(
type
==
Z80_NMI_INT
)
{
z
80_
nmi
();
Z
80_
NMI
();
}
else
if
(
type
!=
Z80_IGNORE_INT
)
{
z
80_
int
();
Z
80_
INT
();
}
}
...
...
@@ -91,7 +91,7 @@ void Z80_Clear_Pending_Interrupts(void)
/****************************************************************************
* Execute IPeriod T-states. Return number of T-states really executed
****************************************************************************/
extern
"C"
int
Z80_Execute
(
int
cycles
)
int
Z80_Execute
(
int
cycles
)
{
Z80
.
regs
.
cycles
=
cycles
;
...
...
DrZ80_support.h
View file @
00cf8728
...
...
@@ -5,7 +5,6 @@
extern
"C"
{
#endif
#include "DrZ80.h"
/****************************************************************************/
...
...
@@ -16,7 +15,7 @@ typedef struct {
struct
DrZ80
regs
;
}
Z80_Regs
;
extern
Z80_Regs
Z80
;
extern
struct
Z80_Regs
Z80
;
#define Z80_IGNORE_INT -1
/* Ignore interrupt */
#define Z80_NMI_INT -2
/* Execute NMI */
...
...
@@ -24,8 +23,8 @@ extern Z80_Regs Z80;
extern
unsigned
Z80_GetPC
(
void
);
/* Get program counter */
extern
int
Z80_GetPreviousPC
(
void
);
extern
void
Z80_GetRegs
(
Z80_Regs
*
Regs
);
/* Get registers */
extern
void
Z80_SetRegs
(
Z80_Regs
*
Regs
);
/* Set registers */
extern
void
Z80_GetRegs
(
struct
Z80_Regs
*
Regs
);
/* Get registers */
extern
void
Z80_SetRegs
(
struct
Z80_Regs
*
Regs
);
/* Set registers */
extern
void
Z80_Reset
(
void
);
extern
int
Z80_Execute
(
int
cycles
);
/* Execute cycles T-States - returns number of cycles actually run */
...
...
Makefile.common
View file @
00cf8728
...
...
@@ -52,7 +52,7 @@ SOURCES_C += \
ifeq
($(DRZ80),1)
FLAGS
+=
-DDRZ80
SOURCES_C
XX
+=
$(CORE_DIR)
/DrZ80_support.c
pp
SOURCES_C
+=
$(CORE_DIR)
/DrZ80_support.c
SOURCES_ASM
:=
$(CORE_DIR)
/DrZ80.s
else
FLAGS
+=
-DCZ80
...
...
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