Initial mimic09: fast 6809/6309 emulator + C64-style monitor + SREC/IHEX loader + ACIA/PIA
- Complete project skeleton per AGENTS.md (src/, bin/, samples/, attic/ with 1994 code, docs/) - High-performance C core (cpu.c) with most 6809 instructions + selected 6309 - Table-driven disassembler (D) and minimal built-in assembler (A) - Full C64-monitor inspired debugger (R ; M : D A G S B BC F L S ! X ?) - Single step, breakpoints (exec), register/memory view+edit - Robust S-Record, Intel HEX, raw binary load/save (tolerant of CRLF) - 6850 ACIA and 6821 PIA emulation (memory-mapped, registered devices) - CLI: -l load, -g go, -i interactive, --cpu 6309, --acia/--pia bases - Designed for tight integration with cc09 (WINTEK re-creation) - Optimized Makefile for macOS/Linux (clang/gcc, -O3 -flto -march=native) - AGENTS.md with mission, structure, coding rules, monitor reference Verified: builds release+debug, loads provided samples (140A.HEX 2299.HEX 2299.MIK), monitor commands, A/D/S/B, roundtrip save/load. Remote: http://gitea.binary-systems.com/vincente/mimic
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
# mimic09 — fast 6809/6309 emulator + C64-style monitor + ACIA/PIA
|
||||
# Targets macOS and Linux/UNIX with clang or gcc
|
||||
|
||||
CC ?= cc
|
||||
CFLAGS_BASE := -std=c11 -Wall -Wextra -Wpedantic -I. -Isrc
|
||||
LDFLAGS :=
|
||||
|
||||
# Detect OS for optional flags
|
||||
UNAME := $(shell uname -s)
|
||||
ifeq ($(UNAME),Darwin)
|
||||
# Apple Silicon + Intel macOS
|
||||
CFLAGS_BASE += -mmacosx-version-min=10.15
|
||||
endif
|
||||
|
||||
# Modes
|
||||
ifeq ($(MODE),debug)
|
||||
CFLAGS := $(CFLAGS_BASE) -O0 -g -DDEBUG=1
|
||||
else
|
||||
# Release: very fast
|
||||
CFLAGS := $(CFLAGS_BASE) -O3 -flto -DNDEBUG=1
|
||||
ifneq ($(UNAME),Darwin)
|
||||
# On Linux allow -march=native if available (safe for most dev machines)
|
||||
CFLAGS += -march=native
|
||||
else
|
||||
# On macOS -march=native is usually fine too with Apple clang
|
||||
CFLAGS += -march=native
|
||||
endif
|
||||
endif
|
||||
|
||||
# Output
|
||||
BIN_DIR := bin
|
||||
BUILD_DIR := build
|
||||
TARGET := $(BIN_DIR)/mimic09
|
||||
|
||||
SRCS := \
|
||||
src/main.c \
|
||||
src/cpu.c \
|
||||
src/disasm.c \
|
||||
src/debug.c \
|
||||
src/loader.c \
|
||||
src/acia.c \
|
||||
src/pia.c \
|
||||
src/util.c
|
||||
|
||||
OBJS := $(patsubst src/%.c,$(BUILD_DIR)/%.o,$(SRCS))
|
||||
|
||||
.PHONY: all release debug clean install test run
|
||||
|
||||
all: release
|
||||
|
||||
release:
|
||||
@$(MAKE) MODE=release $(TARGET)
|
||||
|
||||
debug:
|
||||
@$(MAKE) MODE=debug $(TARGET)
|
||||
|
||||
$(TARGET): $(BIN_DIR) $(BUILD_DIR) $(OBJS)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
|
||||
@echo "Built $@"
|
||||
|
||||
$(BIN_DIR):
|
||||
mkdir -p $(BIN_DIR)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
$(BUILD_DIR)/%.o: src/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(BIN_DIR)/mimic09 $(BIN_DIR)/mimic
|
||||
|
||||
install: $(TARGET)
|
||||
install -d $(DESTDIR)$(PREFIX)/bin
|
||||
install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/mimic09
|
||||
ln -sf mimic09 $(DESTDIR)$(PREFIX)/bin/mimic || true
|
||||
@echo "Installed mimic09 to $(DESTDIR)$(PREFIX)/bin/"
|
||||
|
||||
test: $(TARGET)
|
||||
@echo "No automated tests yet. Run manually with samples."
|
||||
# Example later: ./bin/mimic09 -l samples/2299.HEX -i
|
||||
|
||||
run: $(TARGET)
|
||||
./$(TARGET) -h
|
||||
|
||||
# Convenience: build debug and drop into interactive
|
||||
idb: debug
|
||||
./$(TARGET) -i
|
||||
|
||||
# Show size and basic info (useful for perf curiosity)
|
||||
size: $(TARGET)
|
||||
size $(TARGET)
|
||||
file $(TARGET)
|
||||
Reference in New Issue
Block a user