14 #include <SDL2/SDL_timer.h>
16 #define ALIGNED_PREFIX (1<<16)
17 #define ROM_OFFSET 0x0
18 #define VRAM_OFFSET 0x2400
19 #define VRAM_SIZE 0x1C00
20 #define VRAM_DELAY 0x9
24 #define WINDOW_WIDTH (256)
25 #define WINDOW_HEIGHT (224)
26 #define GREEN_PIXEL 0xFF00
27 #define BLACK_PIXEL 0x0
30 #define CREDIT_COIN SDLK_c
31 #define P1_START SDLK_RETURN
32 #define P2_START SDLK_s
33 #define P1_LEFT SDLK_LEFT
34 #define P1_RIGHT SDLK_RIGHT
35 #define P1_SHOOT SDLK_UP
36 #define P2_LEFT SDLK_a
37 #define P2_RIGHT SDLK_d
38 #define P2_SHOOT SDLK_w
110 void space_OUT(uint8_t port, uint8_t data);
129 void set_pixel(uint32_t *pixels, uint32_t x, uint32_t y, uint8_t state);
This file simulates and disassembles part of 8080 processor.
#define UNUSED
Definition: cpu_8080.h:16
void set_pixel(uint32_t *pixels, uint32_t x, uint32_t y, uint8_t state)
Set the pixel object to a static value.
Definition: space.c:332
void process_SDL_event(cpu_state *cpu, invaders_window *game_window)
Process the incoming SDL event. Called whenever a new event is seen during the polling process.
Definition: space.c:251
void process_key_event(SDL_KeyboardEvent key_event)
processes a key_event by setting the IO_Ports in order to pass the input into the CPU state
Definition: space.c:179
void space_OUT(uint8_t port, uint8_t data)
Space_OUT, data to write callback.
Definition: space.c:152
int copy_invaders_rom(char *path, cpu_state *cpu)
Copies the invaders ROM into the correct memory locations. The way memory is mapped is documented at:...
Definition: space.c:101
void destroy_game_window(invaders_window *game_window)
Destorys the game window object.
Definition: space.c:369
void render_vram(cpu_state *cpu, uint32_t *pixels)
Renders the Vram into the surface Pixel.
Definition: space.c:303
uint8_t space_IN(uint8_t port)
Space_IN, IN instruction function callback. Handles all the IN PORT instruction IO.
Definition: space.c:131
invaders_window * init_game_window()
Initializes the SDL game window.
Definition: space.c:336
uint32_t update_vram_cb(uint32_t interval, UNUSED void *param)
callback which is triggered when scan line reaches 1/2 of the display, or at 120Hz
Definition: space.c:284
cpu_state: This structure keeps runtime state of all the registers in the CPU.
Definition: cpu_8080.h:63
invader window struct which keeps track of all the window related state including the SDL components ...
Definition: space.h:46
SDL_Window * window
Definition: space.h:47
uint8_t quit_event
Definition: space.h:51
SDL_Surface * surf
Definition: space.h:49
SDL_Event event
Definition: space.h:52
SDL_TimerID vram_timer
Definition: space.h:53
uint32_t * pixels
Definition: space.h:50
Imaginary external Ports used to communicate with the player and hardware.
Definition: space.h:60
uint16_t hidden_reg
Definition: space.h:81
uint8_t shift_config
Definition: space.h:74
uint8_t y
Definition: space.h:78
uint8_t port_3
Definition: space.h:69
uint8_t x
Definition: space.h:79
uint8_t port_0
Definition: space.h:63