mirror of
https://github.com/mist64/perfect6502.git
synced 2024-06-02 17:41:32 +00:00
made test work independently
This commit is contained in:
parent
9318b580e4
commit
f8fe8d9d46
4
Makefile
4
Makefile
|
@ -1,4 +1,6 @@
|
||||||
OBJS=runtime.o runtime_init.o plugin.o perfect6502.o console.o emu.o
|
OBJS=perfect6502.o
|
||||||
|
#OBJS+=runtime.o runtime_init.o plugin.o console.o emu.o
|
||||||
|
OBJS+=test.o
|
||||||
CFLAGS=-Wall -O3
|
CFLAGS=-Wall -O3
|
||||||
CC=clang
|
CC=clang
|
||||||
|
|
||||||
|
|
|
@ -625,9 +625,9 @@ readP()
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
readNOTIR()
|
readIR()
|
||||||
{
|
{
|
||||||
return read8(notir0,notir1,notir2,notir3,notir4,notir5,notir6,notir7);
|
return ((uint8_t)read8(notir0,notir1,notir2,notir3,notir4,notir5,notir6,notir7)) ^ 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
|
@ -654,7 +654,13 @@ readPC()
|
||||||
return (readPCH() << 8) | readPCL();
|
return (readPCH() << 8) | readPCL();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cycle;
|
BOOL
|
||||||
|
readRW()
|
||||||
|
{
|
||||||
|
return isNodeHigh(rw);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int cycle;
|
||||||
|
|
||||||
void
|
void
|
||||||
chipStatus()
|
chipStatus()
|
||||||
|
@ -676,7 +682,7 @@ chipStatus()
|
||||||
readY(),
|
readY(),
|
||||||
readSP(),
|
readSP(),
|
||||||
readP(),
|
readP(),
|
||||||
readNOTIR() ^ 0xFF);
|
readIR());
|
||||||
|
|
||||||
if (clk)
|
if (clk)
|
||||||
if (r_w)
|
if (r_w)
|
||||||
|
@ -813,7 +819,6 @@ void init_monitor();
|
||||||
void handle_monitor();
|
void handle_monitor();
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#include "test.c"
|
|
||||||
#elif defined(BROKEN_TRANSISTORS)
|
#elif defined(BROKEN_TRANSISTORS)
|
||||||
#include "broken_transistors.c"
|
#include "broken_transistors.c"
|
||||||
#elif defined(COMPARE)
|
#elif defined(COMPARE)
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
extern void initAndResetChip();
|
extern void initAndResetChip();
|
||||||
|
extern void resetChip();
|
||||||
extern void step();
|
extern void step();
|
||||||
extern void chipStatus();
|
extern void chipStatus();
|
||||||
|
extern unsigned short readPC();
|
||||||
|
extern unsigned char readA();
|
||||||
|
extern unsigned char readX();
|
||||||
|
extern unsigned char readY();
|
||||||
|
extern unsigned char readSP();
|
||||||
|
extern unsigned char readP();
|
||||||
|
extern unsigned int readRW();
|
||||||
|
extern unsigned short readAddressBus();
|
||||||
|
extern unsigned char readDataBus();
|
||||||
|
extern unsigned char readIR();
|
||||||
|
|
||||||
|
extern unsigned char memory[65536];
|
||||||
|
extern unsigned int cycle;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "perfect6502.h"
|
#include "perfect6502.h"
|
||||||
|
/* XXX hook up memory[] with RAM[] in runtime.c */
|
||||||
extern unsigned char memory[65536]; /* XXX must be hooked up with RAM[] in runtime.c */
|
|
||||||
|
|
||||||
extern unsigned short readPC();
|
|
||||||
extern unsigned char readA();
|
|
||||||
extern unsigned char readX();
|
|
||||||
extern unsigned char readY();
|
|
||||||
extern unsigned char readSP();
|
|
||||||
extern unsigned char readP();
|
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
*
|
*
|
||||||
* Interface to OS Library Code / Monitor
|
* Interface to OS Library Code / Monitor
|
||||||
|
|
31
test.c
31
test.c
|
@ -1,3 +1,16 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
#include "perfect6502.h"
|
||||||
|
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef unsigned int BOOL;
|
||||||
|
|
||||||
|
extern uint8_t memory[65536];
|
||||||
|
|
||||||
|
#define YES 1
|
||||||
|
#define NO 0
|
||||||
|
|
||||||
#define BRK_LENGTH 2 /* BRK pushes PC + 2 onto the stack */
|
#define BRK_LENGTH 2 /* BRK pushes PC + 2 onto the stack */
|
||||||
|
|
||||||
|
@ -13,8 +26,8 @@
|
||||||
#define X_OFFSET 5
|
#define X_OFFSET 5
|
||||||
#define Y_OFFSET 10
|
#define Y_OFFSET 10
|
||||||
|
|
||||||
#define IS_READ_CYCLE (isNodeHigh(clk0) && isNodeHigh(rw))
|
#define IS_READ_CYCLE ((cycle & 1) && readRW())
|
||||||
#define IS_WRITE_CYCLE (isNodeHigh(clk0) && !isNodeHigh(rw))
|
#define IS_WRITE_CYCLE ((cycle & 1) && !readRW())
|
||||||
#define IS_READING(a) (IS_READ_CYCLE && readAddressBus() == (a))
|
#define IS_READING(a) (IS_READ_CYCLE && readAddressBus() == (a))
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -111,10 +124,7 @@ resetChip_test()
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
/* set up data structures for efficient emulation */
|
initAndResetChip();
|
||||||
setupNodesAndTransistors();
|
|
||||||
|
|
||||||
verbose = 0;
|
|
||||||
|
|
||||||
for (int opcode = 0x00; opcode <= 0xFF; opcode++) {
|
for (int opcode = 0x00; opcode <= 0xFF; opcode++) {
|
||||||
// for (int opcode = 0xA9; opcode <= 0xAA; opcode++) {
|
// for (int opcode = 0xA9; opcode <= 0xAA; opcode++) {
|
||||||
|
@ -147,10 +157,15 @@ main()
|
||||||
resetChip_test();
|
resetChip_test();
|
||||||
for (i = 0; i < MAX_CYCLES; i++) {
|
for (i = 0; i < MAX_CYCLES; i++) {
|
||||||
step();
|
step();
|
||||||
if ((readNOTIR() ^ 0xFF) == 0x00)
|
// chipStatus();
|
||||||
|
//printf("cycle = %d %x\n", cycle, readIR());
|
||||||
|
if (readIR() == 0x00)
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
data[opcode].cycles = (cycle - 1) / 2;
|
if (cycle)
|
||||||
|
data[opcode].cycles = cycle / 2;
|
||||||
|
else
|
||||||
|
data[opcode].cycles = 0;
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* find out zp or abs reads
|
* find out zp or abs reads
|
||||||
|
|
Loading…
Reference in New Issue
Block a user