83 lines
1.8 KiB
C++
83 lines
1.8 KiB
C++
//
|
|
// Created by Palindromic Bread Loaf on 7/21/25.
|
|
//
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include "system.h"
|
|
|
|
class CPU;
|
|
class PPU;
|
|
class APU;
|
|
class Bus;
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
|
|
std::cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
SDL_Window* window = SDL_CreateWindow(
|
|
"BreadedSNES",
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
256, 224, // SNES output resolution
|
|
SDL_WINDOW_SHOWN
|
|
);
|
|
|
|
if (!window) {
|
|
std::cout << "Window could not be created! SDL_Error: " << SDL_GetError() << std::endl;
|
|
SDL_Quit();
|
|
return -1;
|
|
}
|
|
|
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
|
if (!renderer) {
|
|
std::cout << "Renderer could not be created! SDL_Error: " << SDL_GetError() << std::endl;
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
return -1;
|
|
}
|
|
|
|
System snes;
|
|
|
|
if (argc > 1) {
|
|
if (!snes.LoadROM(argv[1])) {
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
snes.Reset();
|
|
|
|
bool quit = false;
|
|
SDL_Event e;
|
|
|
|
while (!quit) {
|
|
while (SDL_PollEvent(&e)) {
|
|
if (e.type == SDL_QUIT) {
|
|
quit = true;
|
|
}
|
|
}
|
|
|
|
// Run emulation step
|
|
snes.Step();
|
|
|
|
// Clear screen
|
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
|
SDL_RenderClear(renderer);
|
|
|
|
// TODO: Render frame
|
|
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
|
|
return 0;
|
|
} |