made test work independently

This commit is contained in:
Michael Steil 2010-10-06 16:33:26 +00:00
parent 9318b580e4
commit f8fe8d9d46
5 changed files with 53 additions and 24 deletions

View File

@ -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
CC=clang

View File

@ -625,9 +625,9 @@ readP()
}
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
@ -654,7 +654,13 @@ readPC()
return (readPCH() << 8) | readPCL();
}
static int cycle;
BOOL
readRW()
{
return isNodeHigh(rw);
}
unsigned int cycle;
void
chipStatus()
@ -676,7 +682,7 @@ chipStatus()
readY(),
readSP(),
readP(),
readNOTIR() ^ 0xFF);
readIR());
if (clk)
if (r_w)
@ -813,7 +819,6 @@ void init_monitor();
void handle_monitor();
#ifdef TEST
#include "test.c"
#elif defined(BROKEN_TRANSISTORS)
#include "broken_transistors.c"
#elif defined(COMPARE)

View File

@ -1,3 +1,18 @@
extern void initAndResetChip();
extern void resetChip();
extern void step();
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;

View File

@ -1,16 +1,8 @@
#include <stdio.h>
#include "perfect6502.h"
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();
/* XXX hook up memory[] with RAM[] in runtime.c */
/************************************************************
*
* Interface to OS Library Code / Monitor

31
test.c
View File

@ -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 */
@ -13,8 +26,8 @@
#define X_OFFSET 5
#define Y_OFFSET 10
#define IS_READ_CYCLE (isNodeHigh(clk0) && isNodeHigh(rw))
#define IS_WRITE_CYCLE (isNodeHigh(clk0) && !isNodeHigh(rw))
#define IS_READ_CYCLE ((cycle & 1) && readRW())
#define IS_WRITE_CYCLE ((cycle & 1) && !readRW())
#define IS_READING(a) (IS_READ_CYCLE && readAddressBus() == (a))
struct {
@ -111,10 +124,7 @@ resetChip_test()
int
main()
{
/* set up data structures for efficient emulation */
setupNodesAndTransistors();
verbose = 0;
initAndResetChip();
for (int opcode = 0x00; opcode <= 0xFF; opcode++) {
// for (int opcode = 0xA9; opcode <= 0xAA; opcode++) {
@ -147,10 +157,15 @@ main()
resetChip_test();
for (i = 0; i < MAX_CYCLES; i++) {
step();
if ((readNOTIR() ^ 0xFF) == 0x00)
// chipStatus();
//printf("cycle = %d %x\n", cycle, readIR());
if (readIR() == 0x00)
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