add 6502 CPU emu
This commit is contained in:
parent
317239c9cf
commit
6d69200bc3
26
3rdparty/6502-illegal-opcode.patch
vendored
Normal file
26
3rdparty/6502-illegal-opcode.patch
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
commit 800f1f7b0393d61fb03aad776e79e8f801014512
|
||||
Author: Thomas Bernard <miniupnp@free.fr>
|
||||
Date: Sat Nov 23 16:32:04 2019 +0100
|
||||
|
||||
silent "unused parameter" warning
|
||||
|
||||
6502.c:379:53: warning: unused parameter 'object' [-Wunused-parameter]
|
||||
379 | #define INSTRUCTION(name) static zuint8 name(M6502 *object)
|
||||
| ~~~~~~~^~~~~~
|
||||
6502.c:766:1: note: in expansion of macro 'INSTRUCTION'
|
||||
766 | INSTRUCTION(illegal) {return 2;}
|
||||
| ^~~~~~~~~~~
|
||||
|
||||
diff --git a/sources/6502.c b/sources/6502.c
|
||||
index 9a95cf0..6b8f8d5 100644
|
||||
--- a/sources/6502.c
|
||||
+++ b/sources/6502.c
|
||||
@@ -763,7 +763,7 @@ INSTRUCTION(brk)
|
||||
}
|
||||
|
||||
|
||||
-INSTRUCTION(illegal) {return 2;}
|
||||
+INSTRUCTION(illegal) {(void)object; return 2;}
|
||||
|
||||
|
||||
/* MARK: - Instruction Function Table */
|
||||
21
3rdparty/Makefile
vendored
21
3rdparty/Makefile
vendored
@ -129,6 +129,12 @@ RECOILARCH=$(RECOIL).tar.gz
|
||||
RECOILURL=https://downloads.sourceforge.net/project/recoil/recoil/$(RECOILVER)/$(RECOILARCH)
|
||||
RECOILURLALT=http://nanard.free.fr/grafx2/$(RECOILARCH)
|
||||
RECOILSHA256=b9691db9e0d2b6cec23c9dec8628ecf6870f1e9d34ce95513fb4a671d781b19c
|
||||
#https://github.com/redcode/6502/releases/download/v0.1/6502-v0.1.tar.xz
|
||||
REDCODE6502=6502-v0.1
|
||||
REDCODE6502ARCH=6502-v0.1.tar.xz
|
||||
REDCODE6502URL=https://github.com/redcode/6502/releases/download/v0.1/$(REDCODE6502ARCH)
|
||||
REDCODE6502SHA256=bba50f327163d40b1014f5affc8042137f37b200dae50a4f0fe56b5769b3940f
|
||||
REDCODE6502PATCHES = 6502-illegal-opcode.patch
|
||||
|
||||
ARCHIVES = $(addprefix archives/, $(SDLARCH) $(SDLIMAGEARCH) $(SDLTTFARCH) \
|
||||
$(SDL2ARCH) $(SDL2IMAGEARCH) $(SDL2TTFARCH) $(LIBPNGARCH) \
|
||||
@ -604,17 +610,30 @@ endif
|
||||
recoil: $(RECOIL)/.ok
|
||||
$(CP) $(RECOIL)/README ../doc/README-recoil.txt
|
||||
|
||||
6502: 6502/.ok
|
||||
$(CP) 6502/README ../doc/README-6502.txt
|
||||
|
||||
6502/.ok: archives/$(REDCODE6502ARCH)
|
||||
$(TAR) xJf $<
|
||||
cd $(@D) ; for p in $(REDCODE6502PATCHES) ; do echo "applying $$p" ; patch -p1 < ../$$p ; done
|
||||
touch $@
|
||||
|
||||
# generic rule to unpack tarball and apply patches
|
||||
%/.ok: archives/%.tar.gz
|
||||
$(TAR) xzf $<
|
||||
cd $(@D) ; for p in $($(shell echo $* | cut -d- -f1 | tr a-z A-Z | tr -d _)PATCHES) ; do echo "applying $$p" ; patch -p1 < ../$$p ; done
|
||||
touch $@
|
||||
|
||||
# the following archive name won't work with the generic rule
|
||||
# the following archive names won't work with the generic rule
|
||||
archives/$(JPEGARCH):
|
||||
@$(MKDIR) $(@D)
|
||||
cd $(@D) && $(GETURL) $(JPEGURL)
|
||||
|
||||
archives/$(REDCODE6502ARCH):
|
||||
@$(MKDIR) $(@D)
|
||||
cd $(@D) && $(GETURL) $(REDCODE6502URL)
|
||||
@[ "`$(SHA256CMD) < $@`" = "$(REDCODE6502SHA256)" ] || ( $(RM) $@ && echo "$@ SHA256 mismatch !" && false )
|
||||
|
||||
# generic rule to download tarballs
|
||||
archives/%.tar.gz:
|
||||
@$(MKDIR) $(@D)
|
||||
|
||||
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
recoil.c
|
||||
recoil.h
|
||||
6502.c
|
||||
6502.h
|
||||
|
||||
85
src/6502types.h
Normal file
85
src/6502types.h
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef F6502TYPES_H_INCLUDED
|
||||
#define F6502TYPES_H_INCLUDED
|
||||
|
||||
#if defined(__BEOS__) || defined(__TRU64__)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned int zusize;
|
||||
typedef uint8_t zuint8;
|
||||
typedef uint16_t zuint16;
|
||||
typedef uint8_t zboolean;
|
||||
typedef unsigned int zuint;
|
||||
typedef int8_t zsint8;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/* MARK: - Addresses */
|
||||
|
||||
#define Z_6502_ADDRESS_NMI_POINTER 0xFFFA
|
||||
#define Z_6502_ADDRESS_RESET_POINTER 0XFFFC
|
||||
#define Z_6502_ADDRESS_IRQ_POINTER 0xFFFE
|
||||
#define Z_6502_ADDRESS_BRK_POINTER 0xFFFE
|
||||
#define Z_6502_ADDRESS_STACK 0x0100
|
||||
|
||||
/* MARK: - Values after power on */
|
||||
|
||||
#define Z_6502_VALUE_AFTER_POWER_ON_PC 0x0000
|
||||
#define Z_6502_VALUE_AFTER_POWER_ON_S 0xFD
|
||||
#define Z_6502_VALUE_AFTER_POWER_ON_P 0x36
|
||||
#define Z_6502_VALUE_AFTER_POWER_ON_A 0x00
|
||||
#define Z_6502_VALUE_AFTER_POWER_ON_X 0x00
|
||||
#define Z_6502_VALUE_AFTER_POWER_ON_Y 0x00
|
||||
|
||||
/* MARK: - State storage type */
|
||||
typedef struct {
|
||||
zuint16 pc;
|
||||
zuint8 s, p, a, x, y;
|
||||
|
||||
struct {zuint8 irq :1;
|
||||
zuint8 nmi :1;
|
||||
} internal;
|
||||
} Z6502State;
|
||||
|
||||
#define Z_6502_STATE_PC( object) (object)->pc
|
||||
#define Z_6502_STATE_S( object) (object)->s
|
||||
#define Z_6502_STATE_P( object) (object)->p
|
||||
#define Z_6502_STATE_A( object) (object)->a
|
||||
#define Z_6502_STATE_X( object) (object)->x
|
||||
#define Z_6502_STATE_Y( object) (object)->y
|
||||
#define Z_6502_STATE_NMI(object) (object)->internal.nmi
|
||||
#define Z_6502_STATE_IRQ(object) (object)->internal.irq
|
||||
|
||||
#define Z_6502_STATE_MEMBER_PC pc
|
||||
#define Z_6502_STATE_MEMBER_S s
|
||||
#define Z_6502_STATE_MEMBER_P p
|
||||
#define Z_6502_STATE_MEMBER_A a
|
||||
#define Z_6502_STATE_MEMBER_X x
|
||||
#define Z_6502_STATE_MEMBER_Y y
|
||||
#define Z_6502_STATE_MEMBER_NMI internal.nmi
|
||||
#define Z_6502_STATE_MEMBER_IRQ internal.irq
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define Z_C_SYMBOLS_BEGIN extern "C" {
|
||||
# define Z_C_SYMBOLS_END }
|
||||
#else
|
||||
# define Z_C_SYMBOLS_BEGIN
|
||||
# define Z_C_SYMBOLS_END
|
||||
#endif
|
||||
|
||||
#define Z_INLINE
|
||||
|
||||
#define Z_EMPTY_(dummy)
|
||||
#define Z_EMPTY Z_EMPTY_(.)
|
||||
|
||||
#endif
|
||||
11
src/Makefile
11
src/Makefile
@ -1160,6 +1160,17 @@ $(OBJDIR)/loadrecoil.o: recoil.c recoil.h
|
||||
if [ -d ../3rdparty ] ; then $(MAKE) -C ../3rdparty recoil ; fi
|
||||
endif
|
||||
|
||||
6502.h: 6502.c
|
||||
|
||||
6502.c: ../3rdparty/6502/sources/6502.c
|
||||
$(CP) $< $@
|
||||
$(CP) ../3rdparty/6502/API/emulation/CPU/6502.h 6502.h
|
||||
|
||||
../3rdparty/6502/sources/6502.c:
|
||||
if [ -d ../3rdparty ] ; then $(MAKE) -C ../3rdparty 6502 ; fi
|
||||
|
||||
$(OBJDIR)/6502.o: CFLAGS += -DCPU_6502_STATIC -DCPU_6502_USE_LOCAL_HEADER -DCPU_6502_DEPENDENCIES_H=\"6502types.h\"
|
||||
|
||||
$(OBJ): $(CFLAGS_CACHE)
|
||||
|
||||
$(OBJDIR)/%.o : %.c
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user