Moved debug info to separate windows
This commit is contained in:
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
static const int SCREEN_WIDTH = 1024;
|
|
||||||
static const int SCREEN_HEIGHT = 768;
|
|
||||||
|
|
||||||
void ui_init();
|
void ui_init();
|
||||||
void ui_handle_events();
|
void ui_handle_events();
|
||||||
void ui_update();
|
void ui_update();
|
408
lib/ui.c
408
lib/ui.c
@ -13,22 +13,29 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_ttf.h>
|
#include <SDL_ttf.h>
|
||||||
|
|
||||||
#define VRAM_DEBUG 0
|
|
||||||
|
|
||||||
SDL_Window *sdlWindow;
|
SDL_Window *sdlWindow;
|
||||||
SDL_Renderer *sdlRenderer;
|
SDL_Renderer *sdlRenderer;
|
||||||
SDL_Texture *sdlTexture;
|
SDL_Texture *sdlTexture;
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
|
|
||||||
SDL_Window *sdlDebugWindow;
|
SDL_Window *sdlVramWindow;
|
||||||
SDL_Renderer *sdlDebugRenderer;
|
SDL_Renderer *sdlVramRenderer;
|
||||||
SDL_Texture *sdlDebugTexture;
|
SDL_Texture *sdlVramTexture;
|
||||||
SDL_Surface *debugScreen;
|
SDL_Surface *vramScreen;
|
||||||
|
|
||||||
|
SDL_Window *sdlAudioWindow;
|
||||||
|
SDL_Renderer *sdlAudioRenderer;
|
||||||
|
SDL_Texture *sdlAudioTexture;
|
||||||
|
SDL_Surface *audioScreen;
|
||||||
TTF_Font *sans;
|
TTF_Font *sans;
|
||||||
|
|
||||||
static int scale = 4;
|
static int scale = 4;
|
||||||
|
static int screenWidth;
|
||||||
|
static int screenHeight;
|
||||||
|
|
||||||
void ui_init(){
|
void ui_init(){
|
||||||
|
screenWidth = XRES*scale;
|
||||||
|
screenHeight = YRES*scale;
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
printf("SDL INIT\n");
|
printf("SDL INIT\n");
|
||||||
TTF_Init();
|
TTF_Init();
|
||||||
@ -42,10 +49,10 @@ void ui_init(){
|
|||||||
if ( !sans ) {
|
if ( !sans ) {
|
||||||
printf("Failed to load font: %s\n", TTF_GetError());
|
printf("Failed to load font: %s\n", TTF_GetError());
|
||||||
}
|
}
|
||||||
SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, 0, &sdlWindow, &sdlRenderer);
|
SDL_CreateWindowAndRenderer(screenWidth, screenHeight, 0, &sdlWindow, &sdlRenderer);
|
||||||
|
|
||||||
screen = SDL_CreateRGBSurface(0, SCREEN_WIDTH,
|
screen = SDL_CreateRGBSurface(0, screenWidth,
|
||||||
SCREEN_HEIGHT, 32,
|
screenHeight, 32,
|
||||||
0x00FF0000,
|
0x00FF0000,
|
||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
0x000000FF,
|
0x000000FF,
|
||||||
@ -53,28 +60,37 @@ void ui_init(){
|
|||||||
sdlTexture = SDL_CreateTexture(sdlRenderer,
|
sdlTexture = SDL_CreateTexture(sdlRenderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
SCREEN_WIDTH,
|
screenWidth,
|
||||||
SCREEN_HEIGHT);
|
screenHeight);
|
||||||
#if VRAM_DEBUG == 1
|
|
||||||
SDL_CreateWindowAndRenderer(16 * 8 * scale, 32 * 8 * scale, 0, &sdlDebugWindow, &sdlDebugRenderer);
|
SDL_CreateWindowAndRenderer(16 * 9 * scale, 24 * 9 * scale, SDL_WINDOW_HIDDEN, &sdlVramWindow, &sdlVramRenderer);
|
||||||
debugScreen = SDL_CreateRGBSurface(0, (16 * 8 * scale) + (16 * scale),
|
vramScreen = SDL_CreateRGBSurface(0, (16 * 9 * scale),
|
||||||
(32 * 8 * scale) + (64 * scale), 32,
|
(24 * 9 * scale), 32,
|
||||||
0x00FF0000,
|
0x00FF0000,
|
||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
0x000000FF,
|
0x000000FF,
|
||||||
0xFF000000);
|
0xFF000000);
|
||||||
sdlDebugTexture = SDL_CreateTexture(sdlDebugRenderer,
|
sdlVramTexture = SDL_CreateTexture(sdlVramRenderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
(16 * 8 * scale) + (16 * scale),
|
(16 * 9 * scale),
|
||||||
(32 * 8 * scale) + (64 * scale));
|
(24 * 9 * scale));
|
||||||
int x, y;
|
|
||||||
SDL_GetWindowPosition(sdlWindow, &x, &y);
|
SDL_CreateWindowAndRenderer(384, 730, SDL_WINDOW_HIDDEN, &sdlAudioWindow, &sdlAudioRenderer);
|
||||||
SDL_SetWindowPosition(sdlDebugWindow, x+SCREEN_WIDTH, y);
|
audioScreen = SDL_CreateRGBSurface(0, 384,
|
||||||
#endif
|
730, 32,
|
||||||
|
0x00FF0000,
|
||||||
|
0x0000FF00,
|
||||||
|
0x000000FF,
|
||||||
|
0xFF000000);
|
||||||
|
sdlAudioTexture = SDL_CreateTexture(sdlAudioRenderer,
|
||||||
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
|
384,
|
||||||
|
730);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long tile_colors[4] = {0xFF9ABB1B, 0xFF8AAB19, 0xFF2F6130, 0xFF0E370F};
|
static unsigned long tile_colors[4] = {0xFFFFFFFF, 0xFFAAAAAA, 0xFF555555, 0xFF000000};
|
||||||
|
|
||||||
void display_tile(SDL_Surface *surface, u16 startLocation, u16 tileNum, int x, int y) {
|
void display_tile(SDL_Surface *surface, u16 startLocation, u16 tileNum, int x, int y) {
|
||||||
SDL_Rect rc;
|
SDL_Rect rc;
|
||||||
@ -96,7 +112,7 @@ void display_tile(SDL_Surface *surface, u16 startLocation, u16 tileNum, int x, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_debug_window() {
|
void update_vram_window() {
|
||||||
int xDraw = 0;
|
int xDraw = 0;
|
||||||
int yDraw = 0;
|
int yDraw = 0;
|
||||||
int tileNum = 0;
|
int tileNum = 0;
|
||||||
@ -104,9 +120,9 @@ void update_debug_window() {
|
|||||||
SDL_Rect rc;
|
SDL_Rect rc;
|
||||||
rc.x = 0;
|
rc.x = 0;
|
||||||
rc.y = 0;
|
rc.y = 0;
|
||||||
rc.w = debugScreen->w;
|
rc.w = vramScreen->w;
|
||||||
rc.h = debugScreen->h;
|
rc.h = vramScreen->h;
|
||||||
SDL_FillRect(debugScreen, &rc, 0xFF111111);
|
SDL_FillRect(vramScreen, &rc, 0xFF111111);
|
||||||
|
|
||||||
u16 addr = 0x8000;
|
u16 addr = 0x8000;
|
||||||
|
|
||||||
@ -114,7 +130,7 @@ void update_debug_window() {
|
|||||||
|
|
||||||
for(int y = 0; y < 24; y++) {
|
for(int y = 0; y < 24; y++) {
|
||||||
for(int x = 0; x < 16; x++) {
|
for(int x = 0; x < 16; x++) {
|
||||||
display_tile(debugScreen, addr, tileNum, xDraw + (x * scale), yDraw + (y * scale));
|
display_tile(vramScreen, addr, tileNum, xDraw + (x * scale), yDraw + (y * scale));
|
||||||
xDraw += (8 * scale);
|
xDraw += (8 * scale);
|
||||||
tileNum++;
|
tileNum++;
|
||||||
}
|
}
|
||||||
@ -122,10 +138,165 @@ void update_debug_window() {
|
|||||||
xDraw = 0;
|
xDraw = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UpdateTexture(sdlDebugTexture, NULL, debugScreen->pixels, debugScreen->pitch);
|
SDL_UpdateTexture(sdlVramTexture, NULL, vramScreen->pixels, vramScreen->pitch);
|
||||||
SDL_RenderClear(sdlDebugRenderer);
|
SDL_RenderClear(sdlVramRenderer);
|
||||||
SDL_RenderCopy(sdlDebugRenderer, sdlDebugTexture, NULL, NULL);
|
SDL_RenderCopy(sdlVramRenderer, sdlVramTexture, NULL, NULL);
|
||||||
SDL_RenderPresent(sdlDebugRenderer);
|
SDL_RenderPresent(sdlVramRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_audio_window() {
|
||||||
|
int xDraw = 0;
|
||||||
|
int yDraw = 0;
|
||||||
|
int tileNum = 0;
|
||||||
|
|
||||||
|
SDL_Rect rc;
|
||||||
|
rc.x = 0;
|
||||||
|
rc.y = 0;
|
||||||
|
rc.w = audioScreen->w;
|
||||||
|
rc.h = audioScreen->h;
|
||||||
|
SDL_FillRect(audioScreen, &rc, 0xFF111111);
|
||||||
|
SDL_UpdateTexture(sdlAudioTexture, NULL, audioScreen->pixels, audioScreen->pitch);
|
||||||
|
SDL_RenderClear(sdlAudioRenderer);
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, sdlAudioTexture, NULL, NULL);
|
||||||
|
SDL_Color text_color = {255,255,255};
|
||||||
|
int yOffset = 70;
|
||||||
|
int lastY = (yOffset) - (audio_get_context()->sq1_history[audio_get_context()->sq1_index] * 50);
|
||||||
|
int xOffset = 0;
|
||||||
|
SDL_Surface* message = TTF_RenderText_Solid(sans, "Square 1", text_color);
|
||||||
|
SDL_Texture* messageTexture = SDL_CreateTextureFromSurface(sdlAudioRenderer, message);
|
||||||
|
SDL_Rect messageRect;
|
||||||
|
messageRect.x = xOffset;
|
||||||
|
messageRect.y = yOffset-70;
|
||||||
|
messageRect.w = 50;
|
||||||
|
messageRect.h = 20;
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, messageTexture, NULL, &messageRect);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_FreeSurface(message);
|
||||||
|
SDL_DestroyTexture(messageTexture);
|
||||||
|
for(int x = 1; x < 384; x++){
|
||||||
|
int y = (yOffset) - (audio_get_context()->sq1_history[(x + audio_get_context()->sq1_index) % 384] * 50);
|
||||||
|
SDL_RenderDrawLine(sdlAudioRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||||
|
lastY = y;
|
||||||
|
if(x+xOffset == screenWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yOffset = 190;
|
||||||
|
lastY = (yOffset) - (audio_get_context()->sq2_history[audio_get_context()->sq2_index] * 50);
|
||||||
|
message = TTF_RenderText_Solid(sans, "Square 2", text_color);
|
||||||
|
messageTexture = SDL_CreateTextureFromSurface(sdlAudioRenderer, message);
|
||||||
|
messageRect.x = xOffset;
|
||||||
|
messageRect.y = yOffset-70;
|
||||||
|
messageRect.w = 50;
|
||||||
|
messageRect.h = 20;
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, messageTexture, NULL, &messageRect);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_FreeSurface(message);
|
||||||
|
SDL_DestroyTexture(messageTexture);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
for(int x = 1; x < 384; x++){
|
||||||
|
int y = (yOffset) - (audio_get_context()->sq2_history[(x + audio_get_context()->sq2_index) % 384] * 50);
|
||||||
|
SDL_RenderDrawLine(sdlAudioRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||||
|
lastY = y;
|
||||||
|
if(x+xOffset == screenWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yOffset = 310;
|
||||||
|
lastY = (yOffset) - (audio_get_context()->ch3_history[audio_get_context()->ch3_index] * 50);
|
||||||
|
message = TTF_RenderText_Solid(sans, "Wave", text_color);
|
||||||
|
messageTexture = SDL_CreateTextureFromSurface(sdlAudioRenderer, message);
|
||||||
|
messageRect.x = xOffset;
|
||||||
|
messageRect.y = yOffset-70;
|
||||||
|
messageRect.w = 50;
|
||||||
|
messageRect.h = 20;
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, messageTexture, NULL, &messageRect);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_FreeSurface(message);
|
||||||
|
SDL_DestroyTexture(messageTexture);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
for(int x = 1; x < 384; x++){
|
||||||
|
int y = (yOffset) - (audio_get_context()->ch3_history[(x + audio_get_context()->ch3_index) % 384] * 50);
|
||||||
|
SDL_RenderDrawLine(sdlAudioRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||||
|
lastY = y;
|
||||||
|
if(x+xOffset == screenWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yOffset = 430;
|
||||||
|
lastY = (yOffset) - (audio_get_context()->ch4_history[audio_get_context()->ch4_index] * 50);
|
||||||
|
message = TTF_RenderText_Solid(sans, "Noise", text_color);
|
||||||
|
messageTexture = SDL_CreateTextureFromSurface(sdlAudioRenderer, message);
|
||||||
|
messageRect.x = xOffset;
|
||||||
|
messageRect.y = yOffset-70;
|
||||||
|
messageRect.w = 50;
|
||||||
|
messageRect.h = 20;
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, messageTexture, NULL, &messageRect);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_FreeSurface(message);
|
||||||
|
SDL_DestroyTexture(messageTexture);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
for(int x = 1; x < 384; x++){
|
||||||
|
int y = (yOffset) - (audio_get_context()->ch4_history[(x + audio_get_context()->ch4_index) % 384] * 50);
|
||||||
|
SDL_RenderDrawLine(sdlAudioRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||||
|
lastY = y;
|
||||||
|
if(x+xOffset == screenWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yOffset = 550;
|
||||||
|
lastY = (yOffset) - (audio_get_context()->left_history[audio_get_context()->left_index] * 50);
|
||||||
|
message = TTF_RenderText_Solid(sans, "Left Out", text_color);
|
||||||
|
messageTexture = SDL_CreateTextureFromSurface(sdlAudioRenderer, message);
|
||||||
|
messageRect.x = xOffset;
|
||||||
|
messageRect.y = yOffset-70;
|
||||||
|
messageRect.w = 50;
|
||||||
|
messageRect.h = 20;
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, messageTexture, NULL, &messageRect);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_FreeSurface(message);
|
||||||
|
SDL_DestroyTexture(messageTexture);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 0, 255, 255);
|
||||||
|
for(int x = 1; x < 384; x++){
|
||||||
|
int y = (yOffset) - (audio_get_context()->left_history[(x + audio_get_context()->left_index) % 384] * 50);
|
||||||
|
SDL_RenderDrawLine(sdlAudioRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||||
|
lastY = y;
|
||||||
|
if(x+xOffset == screenWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yOffset = 680;
|
||||||
|
lastY = (yOffset) - (audio_get_context()->right_history[audio_get_context()->right_index] * 50);
|
||||||
|
message = TTF_RenderText_Solid(sans, "Right Out", text_color);
|
||||||
|
messageTexture = SDL_CreateTextureFromSurface(sdlAudioRenderer, message);
|
||||||
|
messageRect.x = xOffset;
|
||||||
|
messageRect.y = yOffset-70;
|
||||||
|
messageRect.w = 50;
|
||||||
|
messageRect.h = 20;
|
||||||
|
SDL_RenderCopy(sdlAudioRenderer, messageTexture, NULL, &messageRect);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_FreeSurface(message);
|
||||||
|
SDL_DestroyTexture(messageTexture);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 255, 0, 255);
|
||||||
|
SDL_SetRenderDrawColor(sdlAudioRenderer, 0, 0, 255, 255);
|
||||||
|
for(int x = 1; x < 384; x++){
|
||||||
|
int y = (yOffset) - (audio_get_context()->right_history[(x + audio_get_context()->right_index) % 384] * 50);
|
||||||
|
SDL_RenderDrawLine(sdlAudioRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||||
|
lastY = y;
|
||||||
|
if(x+xOffset == screenWidth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_RenderPresent(sdlAudioRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_update() {
|
void ui_update() {
|
||||||
@ -148,160 +319,10 @@ void ui_update() {
|
|||||||
SDL_UpdateTexture(sdlTexture, NULL, screen->pixels, screen->pitch);
|
SDL_UpdateTexture(sdlTexture, NULL, screen->pixels, screen->pitch);
|
||||||
SDL_RenderClear(sdlRenderer);
|
SDL_RenderClear(sdlRenderer);
|
||||||
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
|
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
|
||||||
SDL_Color text_color = {255,255,255};
|
|
||||||
int yOffset = 50;
|
|
||||||
int lastY = (yOffset) - (audio_get_context()->sq1_history[audio_get_context()->sq1_index] * 50);
|
|
||||||
int xOffset = XRES*scale;
|
|
||||||
SDL_Surface* message = TTF_RenderText_Solid(sans, "Square 1", text_color);
|
|
||||||
SDL_Texture* messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
|
||||||
SDL_Rect messageRect;
|
|
||||||
messageRect.x = xOffset;
|
|
||||||
messageRect.y = yOffset-50;
|
|
||||||
messageRect.w = 50;
|
|
||||||
messageRect.h = 20;
|
|
||||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_FreeSurface(message);
|
|
||||||
SDL_DestroyTexture(messageTexture);
|
|
||||||
for(int x = 1; x < 384; x++){
|
|
||||||
int y = (yOffset) - (audio_get_context()->sq1_history[(x + audio_get_context()->sq1_index) % 384] * 50);
|
|
||||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
|
||||||
lastY = y;
|
|
||||||
if(x+xOffset == SCREEN_WIDTH) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yOffset = 150;
|
|
||||||
lastY = (yOffset) - (audio_get_context()->sq2_history[audio_get_context()->sq2_index] * 50);
|
|
||||||
message = TTF_RenderText_Solid(sans, "Square 2", text_color);
|
|
||||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
|
||||||
messageRect.x = xOffset;
|
|
||||||
messageRect.y = yOffset-50;
|
|
||||||
messageRect.w = 50;
|
|
||||||
messageRect.h = 20;
|
|
||||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_FreeSurface(message);
|
|
||||||
SDL_DestroyTexture(messageTexture);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
for(int x = 1; x < 384; x++){
|
|
||||||
int y = (yOffset) - (audio_get_context()->sq2_history[(x + audio_get_context()->sq2_index) % 384] * 50);
|
|
||||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
|
||||||
lastY = y;
|
|
||||||
if(x+xOffset == SCREEN_WIDTH) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yOffset = 250;
|
|
||||||
lastY = (yOffset) - (audio_get_context()->ch3_history[audio_get_context()->ch3_index] * 50);
|
|
||||||
message = TTF_RenderText_Solid(sans, "Wave", text_color);
|
|
||||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
|
||||||
messageRect.x = xOffset;
|
|
||||||
messageRect.y = yOffset-50;
|
|
||||||
messageRect.w = 50;
|
|
||||||
messageRect.h = 20;
|
|
||||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_FreeSurface(message);
|
|
||||||
SDL_DestroyTexture(messageTexture);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
for(int x = 1; x < 384; x++){
|
|
||||||
int y = (yOffset) - (audio_get_context()->ch3_history[(x + audio_get_context()->ch3_index) % 384] * 50);
|
|
||||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
|
||||||
lastY = y;
|
|
||||||
if(x+xOffset == SCREEN_WIDTH) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yOffset = 350;
|
|
||||||
lastY = (yOffset) - (audio_get_context()->ch4_history[audio_get_context()->ch4_index] * 50);
|
|
||||||
message = TTF_RenderText_Solid(sans, "Noise", text_color);
|
|
||||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
|
||||||
messageRect.x = xOffset;
|
|
||||||
messageRect.y = yOffset-50;
|
|
||||||
messageRect.w = 50;
|
|
||||||
messageRect.h = 20;
|
|
||||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_FreeSurface(message);
|
|
||||||
SDL_DestroyTexture(messageTexture);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
for(int x = 1; x < 384; x++){
|
|
||||||
int y = (yOffset) - (audio_get_context()->ch4_history[(x + audio_get_context()->ch4_index) % 384] * 50);
|
|
||||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
|
||||||
lastY = y;
|
|
||||||
if(x+xOffset == SCREEN_WIDTH) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yOffset = 450;
|
|
||||||
lastY = (yOffset) - (audio_get_context()->left_history[audio_get_context()->left_index] * 50);
|
|
||||||
message = TTF_RenderText_Solid(sans, "Left Out", text_color);
|
|
||||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
|
||||||
messageRect.x = xOffset;
|
|
||||||
messageRect.y = yOffset-50;
|
|
||||||
messageRect.w = 50;
|
|
||||||
messageRect.h = 20;
|
|
||||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_FreeSurface(message);
|
|
||||||
SDL_DestroyTexture(messageTexture);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 255, 255);
|
|
||||||
for(int x = 1; x < 384; x++){
|
|
||||||
int y = (yOffset) - (audio_get_context()->left_history[(x + audio_get_context()->left_index) % 384] * 50);
|
|
||||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
|
||||||
lastY = y;
|
|
||||||
if(x+xOffset == SCREEN_WIDTH) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yOffset = 550;
|
|
||||||
lastY = (yOffset) - (audio_get_context()->right_history[audio_get_context()->right_index] * 50);
|
|
||||||
message = TTF_RenderText_Solid(sans, "Right Out", text_color);
|
|
||||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
|
||||||
messageRect.x = xOffset;
|
|
||||||
messageRect.y = yOffset-50;
|
|
||||||
messageRect.w = 50;
|
|
||||||
messageRect.h = 20;
|
|
||||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_FreeSurface(message);
|
|
||||||
SDL_DestroyTexture(messageTexture);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
|
||||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 255, 255);
|
|
||||||
for(int x = 1; x < 384; x++){
|
|
||||||
int y = (yOffset) - (audio_get_context()->right_history[(x + audio_get_context()->right_index) % 384] * 50);
|
|
||||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
|
||||||
lastY = y;
|
|
||||||
if(x+xOffset == SCREEN_WIDTH) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
SDL_RenderPresent(sdlRenderer);
|
||||||
#if VRAM_DEBUG == 1
|
update_vram_window();
|
||||||
update_debug_window();
|
update_audio_window();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_on_key(bool down, u32 key_code) {
|
void ui_on_key(bool down, u32 key_code) {
|
||||||
@ -351,6 +372,20 @@ void ui_on_key(bool down, u32 key_code) {
|
|||||||
state_load_file(0);
|
state_load_file(0);
|
||||||
emu_start();
|
emu_start();
|
||||||
}
|
}
|
||||||
|
if(key_code == SDLK_v && down == true) {
|
||||||
|
if(SDL_GetWindowFlags(sdlVramWindow) & SDL_WINDOW_HIDDEN) {
|
||||||
|
SDL_ShowWindow(sdlVramWindow);
|
||||||
|
} else {
|
||||||
|
SDL_HideWindow(sdlVramWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(key_code == SDLK_a && down == true) {
|
||||||
|
if(SDL_GetWindowFlags(sdlAudioWindow) & SDL_WINDOW_HIDDEN) {
|
||||||
|
SDL_ShowWindow(sdlAudioWindow);
|
||||||
|
} else {
|
||||||
|
SDL_HideWindow(sdlAudioWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(key_code){
|
switch(key_code){
|
||||||
case SDLK_z: gamepad_get_state()->b = down; break;
|
case SDLK_z: gamepad_get_state()->b = down; break;
|
||||||
case SDLK_x: gamepad_get_state()->a = down; break;
|
case SDLK_x: gamepad_get_state()->a = down; break;
|
||||||
@ -379,7 +414,12 @@ void ui_handle_events(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_CLOSE) {
|
if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||||
|
if(e.window.windowID == SDL_GetWindowID(sdlWindow)){
|
||||||
emu_get_context()->die = true;
|
emu_get_context()->die = true;
|
||||||
|
} else {
|
||||||
|
SDL_Window *w = SDL_GetWindowFromID(e.window.windowID);
|
||||||
|
SDL_HideWindow(w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user