Init
This commit is contained in:
commit
75516e41cf
|
@ -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)
|
Binary file not shown.
|
@ -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);
|
||||
}
|
||||
|
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue