some random fixes.

This commit is contained in:
2025-02-19 21:35:26 -07:00
parent 435a4c5ebe
commit 5da4219f09
10 changed files with 70 additions and 10 deletions

View File

@ -6,10 +6,14 @@
#include <audio.h>
#include <string.h>
#include <lcd.h>
#include <cpu.h>
#include <cart.h>
#include <SDL.h>
#include <SDL_ttf.h>
#define VRAM_DEBUG 0
SDL_Window *sdlWindow;
SDL_Renderer *sdlRenderer;
SDL_Texture *sdlTexture;
@ -41,7 +45,7 @@ void ui_init(){
SDL_TEXTUREACCESS_STREAMING,
SCREEN_WIDTH,
SCREEN_HEIGHT);
#if VRAM_DEBUG == 1
SDL_CreateWindowAndRenderer(16 * 8 * scale, 32 * 8 * scale, 0, &sdlDebugWindow, &sdlDebugRenderer);
debugScreen = SDL_CreateRGBSurface(0, (16 * 8 * scale) + (16 * scale),
(32 * 8 * scale) + (64 * scale), 32,
@ -57,9 +61,10 @@ void ui_init(){
int x, y;
SDL_GetWindowPosition(sdlWindow, &x, &y);
SDL_SetWindowPosition(sdlDebugWindow, x+SCREEN_WIDTH, y);
#endif
}
static unsigned long tile_colors[4] = {0xFF759833, 0xFF588F51, 0xFF3B7560, 0xFF2E615A};
static unsigned long tile_colors[4] = {0xFF9ABB1B, 0xFF8AAB19, 0xFF2F6130, 0xFF0E370F};
void display_tile(SDL_Surface *surface, u16 startLocation, u16 tileNum, int x, int y) {
SDL_Rect rc;
@ -278,9 +283,23 @@ void ui_update() {
break;
}
}
SDL_RenderPresent(sdlRenderer);
char cpu_buffer[1024];
sprintf_s(cpu_buffer, 1024, "PC: %04X, SP: %04X, AF: %02X%02X, BC: %02X%02X, DE: %02X%02X, HL: %02X%02X, Cart_Bank: %02d", cpu_get_context()->regs.pc, cpu_get_context()->regs.sp, cpu_get_context()->regs.a, cpu_get_context()->regs.f, cpu_get_context()->regs.b, cpu_get_context()->regs.c, cpu_get_context()->regs.d, cpu_get_context()->regs.e, cpu_get_context()->regs.h, cpu_get_context()->regs.l, cart_get_rom_bank());
message = TTF_RenderText_Solid(sans, cpu_buffer, text_color);
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
messageRect.x = 0;
messageRect.y = (YRES * scale) + 10;
messageRect.w = 500;
messageRect.h = 20;
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
SDL_FreeSurface(message);
SDL_DestroyTexture(messageTexture);
SDL_RenderPresent(sdlRenderer);
#if VRAM_DEBUG == 1
update_debug_window();
#endif
}
void ui_on_key(bool down, u32 key_code) {
@ -325,6 +344,7 @@ void ui_on_key(bool down, u32 key_code) {
case SDLK_LEFT: gamepad_get_state()->left = down; break;
case SDLK_RIGHT: gamepad_get_state()->right = down; break;
}
gamepad_int_update();
}