rendering Panda correctly

This commit is contained in:
2026-05-14 12:16:43 +02:00
parent df6f382a4b
commit 7c456e50c5
18 changed files with 20 additions and 2351 deletions
+18 -2
View File
@@ -6,15 +6,20 @@
#include <mem.hpp>
#include <broadway.hpp>
#include <SDL3/SDL.h>
#include <filesystem>
namespace fs = std::filesystem;
int main(int argc, char **argv) {
weee::core::mem mem;
weee::core::broadway broadway;
std::string binName;
cflags::cflags flags;
flags.add_string_callback(
'\0', "elf",
[&](const std::string &v) {
binName = fs::path(v).filename().string();
if (!weee::core::load_elf(v, mem, broadway))
ircolib::panic("Could not load '{}'", v);
},
@@ -23,6 +28,7 @@ int main(int argc, char **argv) {
flags.add_string_callback(
'\0', "dol",
[&](const std::string &v) {
binName = fs::path(v).filename().string();
if (!weee::core::load_dol(v, mem, broadway))
ircolib::panic("Could not load '{}'", v);
},
@@ -34,13 +40,20 @@ int main(int argc, char **argv) {
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_UYVY, SDL_TEXTUREACCESS_STREAMING, 640, 240);
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, 640, 240);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
SDL_SetRenderLogicalPresentation(renderer, 640, 480, SDL_LOGICAL_PRESENTATION_LETTERBOX);
ircolib::u8 *rgbTexture = (ircolib::u8 *)calloc(640 * 240, 3);
bool open = true;
while (open) {
ircolib::u64 start = SDL_GetTicks();
broadway.run(mem);
SDL_SetWindowTitle(window,
std::format("weee - {} - {:.2f} fps | {} ms", binName,
1000.f / ((float)SDL_GetTicks() - start), SDL_GetTicks() - start)
.c_str());
SDL_Event e;
while (SDL_PollEvent(&e)) {
@@ -48,8 +61,11 @@ int main(int argc, char **argv) {
open = false;
}
SDL_ConvertPixels(640, 240, SDL_PIXELFORMAT_UYVY, &mem.mem1[0x104000], 640 * 4, SDL_PIXELFORMAT_BGR24,
rgbTexture, 640 * 3);
SDL_RenderClear(renderer);
SDL_UpdateTexture(texture, nullptr, &mem.mem1[0x104000], 640 * 4);
SDL_UpdateTexture(texture, nullptr, rgbTexture, 640 * 3);
SDL_RenderTexture(renderer, texture, nullptr, nullptr);
SDL_RenderPresent(renderer);
}