How carlosdaniel26/intel-8080 works
Project type and purpose
• This is a native C application implementing an Intel 8080 CPU emulator.
• It uses SDL2 for graphical output of the emulated video buffer.
• It loads binary “ROM” files, executes instructions, and renders the result in a window.
File structure
• Top-level:
– src/ – core emulator code (cpu.c, memory/ROM loader, screen renderer, debug hooks).
– include/ – public headers for each module.
– rom/ – test binaries and game ROMs to be loaded.
– Makefile & gdb_script.gdb – build and debug automation.
• Patterns:
– Modular C design: CPU, memory/ROM, screen, debug, helper utilities.
– Single-process, single-binary architecture.
README for additional insights
• Emulation pipeline: fetch → decode → execute cycles in cpu.c.
• SDL2 handles rendering of a memory‐mapped video buffer.
• Supports loading arbitrary Intel 8080 binaries (e.g., Space Invaders).
Main components
a. CPU Core
– Instruction fetch/decode/execute loop.
– Registers, flags, program counter.
b. Memory & ROM Loader
– RAM array + mapped ROM regions.
– Loader module reading .COM/.BIN files into memory.
c. Screen Renderer
– Video memory buffer in C.
– SDL2 window & rendering pipeline.
d. Debug Module
– Logging, state dumps, breakpoints (gdb_script integration).
e. Main/Orchestration
– Entry point (main.c), module initialization, emulation loop, event handling.
f. Utilities (helper.c)
– Timing, I/O abstractions, argument parsing.
Relationships & data flow
• Main → initializes CPU, Memory, Screen, Debug
• CPU ← fetches instructions from Memory → writes results back
• CPU & Helper → invoke Debug hooks/loggers
• Screen module reads a designated memory region each frame → hands pixel data to SDL2
• Event loop in Main captures user/OS events → passes them to CPU or quits
• ROM Loader writes binary data into Memory at startup
Architectural patterns & design principles
• Separation of concerns: CPU logic vs. memory management vs. rendering
• Single-threaded, event-driven loop
• Modular C interfaces via headers (include/)
• External dependency (SDL2) abstracted behind a minimal screen module
Relevant technologies & libraries
• Pure C (GCC, Makefile)
• SDL2 for graphics & window management
• gdb scripting for debug automation