FInal opcodes
This commit is contained in:
+11
-5
@@ -6,9 +6,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MACHINE_SPEED_HZ 1e6 // 1 MHz;
|
||||
|
||||
static struct termios orig_termios;
|
||||
static struct timespec sleepTime;
|
||||
|
||||
void restore_terminal(void) { tcsetattr(STDIN_FILENO, TCSANOW, &orig_termios); }
|
||||
|
||||
@@ -44,7 +48,8 @@ int main(void) {
|
||||
|
||||
/* DEBUG */
|
||||
|
||||
FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_functional_test.bin", "rb");
|
||||
//FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_functional_test.bin", "rb");
|
||||
FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_decimal_test.bin", "rb");
|
||||
if (!fp) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
@@ -65,14 +70,15 @@ int main(void) {
|
||||
resetCPU(&cpu, rom);
|
||||
|
||||
while (1) {
|
||||
//printf("\tPC: 0x%x\tOP: 0x%x\n", cpu.ProgrammeCounter, ram[cpu.ProgrammeCounter]);
|
||||
useconds_t sleep = runCycle(&cpu, ram, rom);
|
||||
// printf("\tPC: 0x%x\tOP: 0x%x\n", cpu.ProgrammeCounter, ram[cpu.ProgrammeCounter]);
|
||||
uint8_t sleep = runCycle(&cpu, ram, rom);
|
||||
if (sleep == 1) {
|
||||
printf("opcode missing: 0x%X\n", ram[cpu.ProgrammeCounter - 1]);
|
||||
return 1;
|
||||
}
|
||||
fflush(stdout);
|
||||
usleep(sleep);
|
||||
sleepTime.tv_sec = 0;
|
||||
sleepTime.tv_nsec = sleep * (1000 / MACHINE_SPEED_HZ);
|
||||
nanosleep(&sleepTime, NULL);
|
||||
}
|
||||
|
||||
/* CPU WORK */
|
||||
|
||||
Reference in New Issue
Block a user