62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
#include <cflags.hpp>
|
|
#include <ircolib/mem_access.hpp>
|
|
#include <loaders/elf.hpp>
|
|
#include <loaders/dol.hpp>
|
|
#include <ircolib/log.hpp>
|
|
#include <mem.hpp>
|
|
#include <broadway.hpp>
|
|
#include <SDL3/SDL.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
weee::core::mem mem;
|
|
weee::core::broadway broadway;
|
|
|
|
cflags::cflags flags;
|
|
flags.add_string_callback(
|
|
'\0', "elf",
|
|
[&](const std::string &v) {
|
|
if (!weee::core::load_elf(v, mem, broadway))
|
|
ircolib::panic("Could not load '{}'", v);
|
|
},
|
|
"ELF binary to load");
|
|
|
|
flags.add_string_callback(
|
|
'\0', "dol",
|
|
[&](const std::string &v) {
|
|
if (!weee::core::load_dol(v, mem, broadway))
|
|
ircolib::panic("Could not load '{}'", v);
|
|
},
|
|
"DOL binary to load");
|
|
|
|
if (!flags.parse(argc, argv))
|
|
return -1;
|
|
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
SDL_Window *window = SDL_CreateWindow("weee", 800, 600, SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_RESIZABLE);
|
|
SDL_Renderer *renderer = SDL_CreateRenderer(window, nullptr);
|
|
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STREAMING, 640, 480);
|
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
|
SDL_SetRenderLogicalPresentation(renderer, 640, 480, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
|
|
|
bool open = true;
|
|
while (open) {
|
|
broadway.run(mem);
|
|
|
|
SDL_Event e;
|
|
while (SDL_PollEvent(&e)) {
|
|
if (e.type == SDL_EVENT_QUIT)
|
|
open = false;
|
|
}
|
|
|
|
SDL_RenderClear(renderer);
|
|
SDL_UpdateTexture(texture, nullptr, &mem.mem1[0x104000], 640 * 4);
|
|
SDL_RenderTexture(renderer, texture, nullptr, nullptr);
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
|
|
return 0;
|
|
}
|