The main driver to run invaders, the ATARI game.
More...
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <signal.h>
#include "debug.h"
#include "space.h"
|
int | main () |
| main emulator driver. Creates the vCPU and game window instances More...
|
|
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: http://www.emutalk.net/threads/38177-Space-Invaders. More...
|
|
uint8_t | space_IN (uint8_t port) |
| Space_IN, IN instruction function callback. Handles all the IN PORT instruction IO. More...
|
|
void | space_OUT (uint8_t port, uint8_t data) |
| Space_OUT, data to write callback. More...
|
|
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 More...
|
|
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. More...
|
|
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 More...
|
|
void | render_vram (cpu_state *cpu, uint32_t *pixels) |
| Renders the Vram into the surface Pixel. More...
|
|
void | set_pixel (uint32_t *pixels, uint32_t x, uint32_t y, uint8_t state) |
| Set the pixel object to a static value. More...
|
|
invaders_window * | init_game_window () |
| Initializes the SDL game window. More...
|
|
void | destroy_game_window (invaders_window *game_window) |
| Destorys the game window object. More...
|
|
The main driver to run invaders, the ATARI game.
- Author
- Pranay Garg (prana.nosp@m.yga@.nosp@m.andre.nosp@m.w.cm.nosp@m.u.edu)
- Version
- 0.1
- Date
- 2020-12-20
◆ copy_invaders_rom()
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: http://www.emutalk.net/threads/38177-Space-Invaders.
- Parameters
-
path | to the folder containing the ROM |
cpu | pointer to the CPU instance executing the ROM |
- Returns
- int -1 if fail, array of file descriptors if pass
◆ destroy_game_window()
Destorys the game window object.
- Parameters
-
◆ init_game_window()
Initializes the SDL game window.
- Returns
- invaders_window* pointer to the game window object
◆ main()
main emulator driver. Creates the vCPU and game window instances
- Returns
- int 0 if success, else error code
◆ process_key_event()
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
- Parameters
-
key_event | the key event being pressed/released |
◆ process_SDL_event()
Process the incoming SDL event. Called whenever a new event is seen during the polling process.
- Parameters
-
cpu | to modify using the event |
game_window | relating to the generated event |
◆ render_vram()
void render_vram |
( |
cpu_state * |
cpu, |
|
|
uint32_t * |
pixels |
|
) |
| |
Renders the Vram into the surface Pixel.
- Parameters
-
cpu | cpu emulating the game |
pixels | underlying uint32_t[] pointer for the SDL surface |
◆ set_pixel()
void set_pixel |
( |
uint32_t * |
pixels, |
|
|
uint32_t |
x, |
|
|
uint32_t |
y, |
|
|
uint8_t |
state |
|
) |
| |
Set the pixel object to a static value.
- Parameters
-
pixels | underlying uint32_t[] pointer for the SDL surface |
x | index to update |
y | index to update |
state | 0 for OFF, 1 for ON |
◆ space_IN()
uint8_t space_IN |
( |
uint8_t |
port | ) |
|
Space_IN, IN instruction function callback. Handles all the IN PORT
instruction IO.
- Note
- Intercept READs on port and handles according to Spec
- Parameters
-
- Returns
- uint8_t Data Read
◆ space_OUT()
void space_OUT |
( |
uint8_t |
port, |
|
|
uint8_t |
data |
|
) |
| |
Space_OUT, data to write callback.
- Note
- Handles the write according to the callback behaviour
- Parameters
-
port | PORT to read/write |
data | Data to write |
◆ update_vram_cb()
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
- Parameters
-
interval | Interval to trigger at |
param | NULL |
- Returns
- uint32_t Interval