First steps to modular emulator

This commit is contained in:
g1n 2021-10-25 16:31:31 +03:00
parent 702c02383c
commit 5c7112879a
5 changed files with 24 additions and 12 deletions

View File

@ -205,17 +205,8 @@ void execute() {
}
}
}
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("%s: No input file specified\n", "yemu");
return 1;
}
void init6502(FILE *infile) {
reset();
FILE *infile = fopen(argv[1], "rb");
if (infile == NULL) {
perror("yemu");
return 1;
}
char ch;
int pos = 0;
while (1) { // FIXME
@ -229,5 +220,5 @@ int main(int argc, char *argv[]) {
execute();
dump_cpu(cpu);
return 0;
return;
}

View File

@ -1,3 +1,5 @@
#include <stdio.h>
typedef unsigned char byte; // 8 bit
typedef unsigned short word; // 16 bit
@ -66,3 +68,4 @@ struct CPU {
byte N; // Negative Flag
};
void init6502(FILE *infile);

Binary file not shown.

View File

@ -2,7 +2,7 @@ CC = gcc
CFLAGS= -O2 -Wall -Wextra
LFLAGS=
SRCFILES= main.c
SRCFILES= main.c 6502/6502.c
OBJFILES= yemu-6502
.PHONY: all clean

18
src/main.c Normal file
View File

@ -0,0 +1,18 @@
#include "6502/6502.h"
#include <stdio.h>
#include <stddef.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("%s: No input file specified\n", "yemu");
return 1;
}
FILE *infile = fopen(argv[1], "rb");
if (infile == NULL) {
perror("yemu");
return 1;
}
init6502(infile);
return 0;
}