2021-10-20 20:39:29 +00:00
|
|
|
|
#include "bus.h"
|
|
|
|
|
|
2021-10-23 18:36:38 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
2021-10-20 20:39:29 +00:00
|
|
|
|
{
|
2021-10-23 18:36:38 +00:00
|
|
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
|
|
|
|
|
|
|
|
SDL_Window* window = SDL_CreateWindow("NES Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 800, SDL_WINDOW_SHOWN);
|
|
|
|
|
if (window == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Failed to create SDL_Window.\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
|
|
|
|
if (renderer == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Failed to create SDL_Renderer\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-20 20:39:29 +00:00
|
|
|
|
struct Bus* bus = createBus();
|
2021-10-21 17:24:53 +00:00
|
|
|
|
|
2021-10-23 18:36:38 +00:00
|
|
|
|
SDL_Event event;
|
|
|
|
|
int running = 1;
|
|
|
|
|
while(running)
|
2021-10-21 17:24:53 +00:00
|
|
|
|
{
|
2021-10-23 18:36:38 +00:00
|
|
|
|
while (SDL_PollEvent(&event))
|
|
|
|
|
{
|
|
|
|
|
switch (event.type)
|
|
|
|
|
{
|
|
|
|
|
case SDL_WINDOWEVENT:
|
|
|
|
|
{
|
|
|
|
|
switch (event.window.event)
|
|
|
|
|
{
|
|
|
|
|
case SDL_WINDOWEVENT_CLOSE:
|
|
|
|
|
running = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doFrame(bus);
|
2021-10-21 17:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-20 20:39:29 +00:00
|
|
|
|
destroyBus(bus);
|
|
|
|
|
|
2021-10-23 18:36:38 +00:00
|
|
|
|
SDL_Quit();
|
|
|
|
|
|
2021-10-20 20:39:29 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|