Make z80_types.h an internal header.
Do not pollute the global namespace by defining byte, sbyte, and word.
This commit is contained in:
parent
4d0e434589
commit
8acec1b95d
10
Makefile
10
Makefile
@ -18,7 +18,7 @@
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
CPPFLAGS += -Iinclude
|
CPPFLAGS += -I. -Iinclude
|
||||||
CFLAGS += -O3
|
CFLAGS += -O3
|
||||||
|
|
||||||
package := zel
|
package := zel
|
||||||
@ -48,9 +48,9 @@ here := $(shell pwd)
|
|||||||
|
|
||||||
dist_source := z80.c \
|
dist_source := z80.c \
|
||||||
z80_instructions.c \
|
z80_instructions.c \
|
||||||
|
z80_types.h \
|
||||||
include/zel/z80.h \
|
include/zel/z80.h \
|
||||||
include/zel/z80_instructions.h \
|
include/zel/z80_instructions.h \
|
||||||
include/zel/z80_types.h \
|
|
||||||
include/zel/z80_instruction_types.h \
|
include/zel/z80_instruction_types.h \
|
||||||
tables/gen.pl \
|
tables/gen.pl \
|
||||||
$(spec) \
|
$(spec) \
|
||||||
@ -104,8 +104,8 @@ include/zel/z80_instruction_types.h: $(itables)
|
|||||||
echo >>$@
|
echo >>$@
|
||||||
echo '#endif' >>$@
|
echo '#endif' >>$@
|
||||||
|
|
||||||
z80.o: z80.c include/zel/z80.h include/zel/z80_instructions.h include/zel/z80_types.h include/zel/z80_instruction_types.h
|
z80.o: z80.c z80_types.h include/zel/z80.h include/zel/z80_instructions.h include/zel/z80_instruction_types.h
|
||||||
z80_instructions.o: z80_instructions.c include/zel/z80_instructions.h include/zel/z80.h include/zel/z80_types.h include/zel/z80_instruction_types.h $(itables)
|
z80_instructions.o: z80_instructions.c z80_types.h include/zel/z80_instructions.h include/zel/z80.h include/zel/z80_instruction_types.h $(itables)
|
||||||
|
|
||||||
check: all
|
check: all
|
||||||
$(MAKE) -C tests check
|
$(MAKE) -C tests check
|
||||||
@ -140,14 +140,12 @@ install:
|
|||||||
$(INSTALL) -d $(DESTDIR)$(includedir)/zel
|
$(INSTALL) -d $(DESTDIR)$(includedir)/zel
|
||||||
$(INSTALL_DATA) include/zel/z80.h $(DESTDIR)$(includedir)/zel
|
$(INSTALL_DATA) include/zel/z80.h $(DESTDIR)$(includedir)/zel
|
||||||
$(INSTALL_DATA) include/zel/z80_instructions.h $(DESTDIR)$(includedir)/zel
|
$(INSTALL_DATA) include/zel/z80_instructions.h $(DESTDIR)$(includedir)/zel
|
||||||
$(INSTALL_DATA) include/zel/z80_types.h $(DESTDIR)$(includedir)/zel
|
|
||||||
$(INSTALL_DATA) include/zel/z80_instruction_types.h $(DESTDIR)$(includedir)/zel
|
$(INSTALL_DATA) include/zel/z80_instruction_types.h $(DESTDIR)$(includedir)/zel
|
||||||
|
|
||||||
uninstall: uninstall-doc
|
uninstall: uninstall-doc
|
||||||
$(RM) $(DESTDIR)$(libdir)/libzel.a
|
$(RM) $(DESTDIR)$(libdir)/libzel.a
|
||||||
$(RM) $(DESTDIR)$(includedir)/zel/z80.h
|
$(RM) $(DESTDIR)$(includedir)/zel/z80.h
|
||||||
$(RM) $(DESTDIR)$(includedir)/zel/z80_instructions.h
|
$(RM) $(DESTDIR)$(includedir)/zel/z80_instructions.h
|
||||||
$(RM) $(DESTDIR)$(includedir)/zel/z80_types.h
|
|
||||||
$(RM) $(DESTDIR)$(includedir)/zel/z80_instruction_types.h
|
$(RM) $(DESTDIR)$(includedir)/zel/z80_instruction_types.h
|
||||||
rmdir $(DESTDIR)$(includedir)/zel
|
rmdir $(DESTDIR)$(includedir)/zel
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ extern "C" {
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <zel/z80_types.h>
|
|
||||||
|
|
||||||
/*! Opaque type representing a z80 processor. */
|
/*! Opaque type representing a z80 processor. */
|
||||||
typedef struct Z80_t *Z80;
|
typedef struct Z80_t *Z80;
|
||||||
|
|
||||||
@ -91,32 +89,32 @@ typedef struct
|
|||||||
* \param cpu The \c Z80 instance making the read call.
|
* \param cpu The \c Z80 instance making the read call.
|
||||||
* \return The byte from memory.
|
* \return The byte from memory.
|
||||||
*/
|
*/
|
||||||
byte (*ReadMem)(word addr, bool inst, Z80 cpu);
|
uint8_t (*ReadMem)(uint16_t addr, bool inst, Z80 cpu);
|
||||||
/*! Write a byte of memory.
|
/*! Write a byte of memory.
|
||||||
* \param addr The address to write.
|
* \param addr The address to write.
|
||||||
* \param val The byte to write.
|
* \param val The byte to write.
|
||||||
* \param cpu The \c Z80 instance making the write call.
|
* \param cpu The \c Z80 instance making the write call.
|
||||||
*/
|
*/
|
||||||
void (*WriteMem)(word addr, byte val, Z80 cpu);
|
void (*WriteMem)(uint16_t addr, uint8_t val, Z80 cpu);
|
||||||
/*! Read the interrupt data.
|
/*! Read the interrupt data.
|
||||||
* \param n Read the \a n th byte of data.
|
* \param n Read the \a n th byte of data.
|
||||||
* \param cpu The \c Z80 instance making the read call.
|
* \param cpu The \c Z80 instance making the read call.
|
||||||
*/
|
*/
|
||||||
byte (*ReadInterruptData)(word n, Z80 cpu);
|
uint8_t (*ReadInterruptData)(uint16_t n, Z80 cpu);
|
||||||
/*! Read a byte from an I/O port.
|
/*! Read a byte from an I/O port.
|
||||||
* \param addr The contents of the address bus during the
|
* \param addr The contents of the address bus during the
|
||||||
* request. The low 8 bits specify the port.
|
* request. The low 8 bits specify the port.
|
||||||
* \param cpu The \c Z80 instance making the read call.
|
* \param cpu The \c Z80 instance making the read call.
|
||||||
* \return The byte from the I/O port.
|
* \return The byte from the I/O port.
|
||||||
*/
|
*/
|
||||||
byte (*ReadIO)(word addr, Z80 cpu);
|
uint8_t (*ReadIO)(uint16_t addr, Z80 cpu);
|
||||||
/*! Write a byte from an I/O port.
|
/*! Write a byte from an I/O port.
|
||||||
* \param addr The contents of the address bus during the
|
* \param addr The contents of the address bus during the
|
||||||
* request. The low 8 bits specify the port.
|
* request. The low 8 bits specify the port.
|
||||||
* \param val The byte to write.
|
* \param val The byte to write.
|
||||||
* \param cpu The \c Z80 instance making the read call.
|
* \param cpu The \c Z80 instance making the read call.
|
||||||
*/
|
*/
|
||||||
void (*WriteIO)(word addr, byte val, Z80 cpu);
|
void (*WriteIO)(uint16_t addr, uint8_t val, Z80 cpu);
|
||||||
/*! Notify the peripherials that a return from interrupt
|
/*! Notify the peripherials that a return from interrupt
|
||||||
* instruction has occured.
|
* instruction has occured.
|
||||||
* \param cpu The \c Z80 instance performing the notification.
|
* \param cpu The \c Z80 instance performing the notification.
|
||||||
@ -130,7 +128,7 @@ typedef struct
|
|||||||
* \param type The type of control flow.
|
* \param type The type of control flow.
|
||||||
* \param cpu The \c Z80 instance performing the notification.
|
* \param cpu The \c Z80 instance performing the notification.
|
||||||
*/
|
*/
|
||||||
void (*ControlFlow)(word pc, word target, ControlFlowType type, Z80 cpu);
|
void (*ControlFlow)(uint16_t pc, uint16_t target, ControlFlowType type, Z80 cpu);
|
||||||
} Z80FunctionBlock;
|
} Z80FunctionBlock;
|
||||||
|
|
||||||
/*! Create a new \c Z80 instance using the callbacks specified in \a blk.
|
/*! Create a new \c Z80 instance using the callbacks specified in \a blk.
|
||||||
@ -152,7 +150,7 @@ void Z80_Free( Z80 cpu );
|
|||||||
* \return The number of clock ticks that have elapsed while executing
|
* \return The number of clock ticks that have elapsed while executing
|
||||||
* the instruction.
|
* the instruction.
|
||||||
*/
|
*/
|
||||||
int Z80_Step( word *outPC, Z80 cpu );
|
int Z80_Step( uint16_t *outPC, Z80 cpu );
|
||||||
|
|
||||||
/*! Check if \a cpu has halted.
|
/*! Check if \a cpu has halted.
|
||||||
* \param cpu The \c Z80 instance.
|
* \param cpu The \c Z80 instance.
|
||||||
@ -165,14 +163,14 @@ bool Z80_HasHalted( Z80 cpu );
|
|||||||
* \param cpu The \c Z80 instance.
|
* \param cpu The \c Z80 instance.
|
||||||
* \return The contents of the register specified by \a reg.
|
* \return The contents of the register specified by \a reg.
|
||||||
*/
|
*/
|
||||||
word Z80_GetReg( int reg, Z80 cpu );
|
uint16_t Z80_GetReg( int reg, Z80 cpu );
|
||||||
|
|
||||||
/*! Set a 16 bit paired register.
|
/*! Set a 16 bit paired register.
|
||||||
* \param reg The register to set.
|
* \param reg The register to set.
|
||||||
* \param value The value to assign to the register.
|
* \param value The value to assign to the register.
|
||||||
* \param cpu The \c Z80 instance.
|
* \param cpu The \c Z80 instance.
|
||||||
*/
|
*/
|
||||||
void Z80_SetReg( int reg, word value, Z80 cpu );
|
void Z80_SetReg( int reg, uint16_t value, Z80 cpu );
|
||||||
|
|
||||||
/*! Disassemble the z80 instruction pointed to by \a address into \a buffer.
|
/*! Disassemble the z80 instruction pointed to by \a address into \a buffer.
|
||||||
* \param address The address of the beginning the instruction.
|
* \param address The address of the beginning the instruction.
|
||||||
@ -183,7 +181,7 @@ void Z80_SetReg( int reg, word value, Z80 cpu );
|
|||||||
* function will be called to read the instructions.
|
* function will be called to read the instructions.
|
||||||
* \return The length of the instruction in bytes.
|
* \return The length of the instruction in bytes.
|
||||||
*/
|
*/
|
||||||
int Z80_Disassemble( word address, char *buffer, Z80 cpu );
|
int Z80_Disassemble( uint16_t address, char *buffer, Z80 cpu );
|
||||||
|
|
||||||
/*! Simulate the NMI pin going active. This causes the z80 to jump to
|
/*! Simulate the NMI pin going active. This causes the z80 to jump to
|
||||||
* the nmi handler.
|
* the nmi handler.
|
||||||
|
@ -41,7 +41,6 @@ extern "C" {
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <zel/z80_types.h>
|
|
||||||
#include <zel/z80_instruction_types.h>
|
#include <zel/z80_instruction_types.h>
|
||||||
|
|
||||||
/*! The type of a z80 instruction. Many z80 instructions are similar
|
/*! The type of a z80 instruction. Many z80 instructions are similar
|
||||||
@ -220,7 +219,7 @@ extern const InstructionTemplate FDCB_Prefixed[256];
|
|||||||
* \param data Callback data from IF_ID().
|
* \param data Callback data from IF_ID().
|
||||||
* \return The value at address \a addr.
|
* \return The value at address \a addr.
|
||||||
*/
|
*/
|
||||||
typedef byte (*ReadMemFunction)(word addr, void *data);
|
typedef uint8_t (*ReadMemFunction)(uint16_t addr, void *data);
|
||||||
|
|
||||||
/*! Instruction fetch and instruction decode. Fetchs and decodes the
|
/*! Instruction fetch and instruction decode. Fetchs and decodes the
|
||||||
* instruction pointed to by \a address into \a *inst.
|
* instruction pointed to by \a address into \a *inst.
|
||||||
@ -232,7 +231,7 @@ typedef byte (*ReadMemFunction)(word addr, void *data);
|
|||||||
* \param data Arbitrary data passed to the \a ReadMem callback.
|
* \param data Arbitrary data passed to the \a ReadMem callback.
|
||||||
* \return The length of the instruction.
|
* \return The length of the instruction.
|
||||||
*/
|
*/
|
||||||
int IF_ID( Instruction *inst, word address, ReadMemFunction ReadMem, void *data );
|
int IF_ID( Instruction *inst, uint16_t address, ReadMemFunction ReadMem, void *data );
|
||||||
|
|
||||||
/*! Disassemble the instruction pointed to by \a inst into \a buffer.
|
/*! Disassemble the instruction pointed to by \a inst into \a buffer.
|
||||||
* \param inst Pointer to an \c Instruction.
|
* \param inst Pointer to an \c Instruction.
|
||||||
|
@ -22,7 +22,7 @@ sources = $(wildcard test_*.c)
|
|||||||
tests = $(sources:.c=)
|
tests = $(sources:.c=)
|
||||||
itests = $(subst test,itest,$(tests))
|
itests = $(subst test,itest,$(tests))
|
||||||
|
|
||||||
CPPFLAGS += -I../include
|
CPPFLAGS += -I.. -I../include
|
||||||
CFLAGS += -O3 -Wall -Werror
|
CFLAGS += -O3 -Wall -Werror
|
||||||
LDFLAGS += -L..
|
LDFLAGS += -L..
|
||||||
LIBS += -lzel
|
LIBS += -lzel
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zel/z80_instructions.h>
|
#include <zel/z80_instructions.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
extern const char *disasm[];
|
extern const char *disasm[];
|
||||||
extern byte data[];
|
extern byte data[];
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <z80.h>
|
#include <z80.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
byte data[] = {};
|
byte data[] = {};
|
||||||
const byte interrupt_data [] = {};
|
const byte interrupt_data [] = {};
|
||||||
const byte input_data[] = {};
|
const byte input_data[] = {};
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <zel/z80.h>
|
#include <zel/z80.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
extern byte data[];
|
extern byte data[];
|
||||||
extern const size_t size;
|
extern const size_t size;
|
||||||
extern const byte interrupt_data[];
|
extern const byte interrupt_data[];
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <zel/z80.h>
|
#include <zel/z80.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
const char *disasm[] = {
|
const char *disasm[] = {
|
||||||
"add a,b",
|
"add a,b",
|
||||||
"sub c",
|
"sub c",
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <zel/z80.h>
|
#include <zel/z80.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
const char *disasm[] = {
|
const char *disasm[] = {
|
||||||
"ld a,15h",
|
"ld a,15h",
|
||||||
"ld b,a",
|
"ld b,a",
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <zel/z80.h>
|
#include <zel/z80.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
const char *disasm[] = {
|
const char *disasm[] = {
|
||||||
"ld ix,0020h",
|
"ld ix,0020h",
|
||||||
"set 0,(ix-10h)",
|
"set 0,(ix-10h)",
|
||||||
|
2
z80.c
2
z80.c
@ -23,6 +23,8 @@
|
|||||||
#include <zel/z80.h>
|
#include <zel/z80.h>
|
||||||
#include <zel/z80_instructions.h>
|
#include <zel/z80_instructions.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
struct Z80_t
|
struct Z80_t
|
||||||
{
|
{
|
||||||
/* C guarantees consecutive layout */
|
/* C guarantees consecutive layout */
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <zel/z80.h> /* Need registers */
|
#include <zel/z80.h> /* Need registers */
|
||||||
#include <zel/z80_instructions.h>
|
#include <zel/z80_instructions.h>
|
||||||
|
|
||||||
|
#include "z80_types.h"
|
||||||
|
|
||||||
const InstructionTemplate Unprefixed[] =
|
const InstructionTemplate Unprefixed[] =
|
||||||
{
|
{
|
||||||
#include "tables/no_prefix.tab"
|
#include "tables/no_prefix.tab"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008 Steve Checkoway
|
/* Copyright (c) 2008, 2017 Stephen Checkoway
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -22,7 +22,7 @@
|
|||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* Types used by the z80.
|
* Types used by the z80.
|
||||||
* \author Steve Checkoway
|
* \author Stephen Checkoway
|
||||||
* \version 0.1
|
* \version 0.1
|
||||||
* \date 2008
|
* \date 2008
|
||||||
*/
|
*/
|
Loading…
Reference in New Issue
Block a user