This commit is contained in:
FyloZ 2023-09-21 23:53:14 -04:00
commit 75516e41cf
Signed by: william
GPG Key ID: 835378AE9AF4AE97
7 changed files with 122 additions and 0 deletions

30
Makefile Normal file
View File

@ -0,0 +1,30 @@
CC = gcc
BIN = ./bin
OBJ = ./obj
SRC = ./src
SRCS = $(wildcard $(SRC)/*.c)
OBJS = $(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRCS))
EXE = $(BIN)/emu
CFLAGS = -Wall
LDLIBS = -lm
.PHONY: all run clean
all: $(EXE)
$(EXE): $(OBJS) | $(BIN)
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
$(OBJ)/%.o: $(SRC)/%.c | $(OBJ)
$(CC) $(CFLAGS) -c $< -o $@
$(BIN) $(OBJ):
mkdir $@
run: $(EXE)
$<
clean:
rm -rf $(OBJ) $(BIN)

BIN
bin/emu Executable file

Binary file not shown.

BIN
obj/cpu.o Normal file

Binary file not shown.

BIN
obj/main.o Normal file

Binary file not shown.

27
src/cpu.c Normal file
View File

@ -0,0 +1,27 @@
/*
* =====================================================================================
*
* Filename: cpu.c
*
* Description: 6502 CPU emulator
*
* Version: 1.0
* Created: 2023-09-21 10:10:26 PM
* Revision: none
* Compiler: gcc
*
* Author: William Nolin,
* Organization:
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
long cpu_clock = 0;
void cpu_step_to(long cycle) {
cpu_clock = cycle;
printf("Clock: %ld", cpu_clock);
}

27
src/cpu.h Normal file
View File

@ -0,0 +1,27 @@
/*
* =====================================================================================
*
* Filename: cpu.h
*
* Description: 6502 CPU emulator headers
*
* Version: 1.0
* Created: 2023-09-21 10:12:33 PM
* Revision: none
* Compiler: gcc
*
* Author: William Nolin,
* Organization:
*
* =====================================================================================
*/
#ifndef EMU_CPU_H
#define EMU_CPU_H
/**
* @brief Set clock
*/
void cpu_step_to(int cycle);
#endif

38
src/main.c Normal file
View File

@ -0,0 +1,38 @@
/*
* =====================================================================================
*
* Filename: main.c
*
* Description: Emulator main loop
*
* Version: 1.0
* Created: 2023-09-21 09:50:34 PM
* Revision: none
* Compiler: gcc
*
* Author: William Nolin,
* Organization:
*
* =====================================================================================
*/
#include <stdlib.h>
#include "cpu.h"
long master_clock = 0;
void step() {
master_clock += 1;
cpu_step_to(master_clock);
return;
}
int main() {
while (1) {
step();
}
return -1;
}