Some changes

This commit is contained in:
2025-02-16 17:28:10 +01:00
parent 0fc4040ad7
commit 4d3755e2ce
18 changed files with 562 additions and 80 deletions

View File

@@ -121,7 +121,7 @@ void renderState(CPU *cpu, BitmapFont *titleFont, SDL_Renderer *renderer, SDL_Te
} else if (cpu->mode & CPU_MODE_HALTED) {
strcat(valueStr, "HLT ");
} else if (cpu->mode & CPU_MODE_PAUSED) {
strcat(valueStr, "PAUS ");
strcat(valueStr, "PS ");
} else {
strcat(valueStr, "RUN ");
}
@@ -136,6 +136,8 @@ void renderState(CPU *cpu, BitmapFont *titleFont, SDL_Renderer *renderer, SDL_Te
strcat(valueStr, "STP");
} else if (cpu->mode & CPU_MODE_SECOND) {
strcat(valueStr, "SEC");
} else if (cpu->mode & CPU_MODE_FRAME) {
strcat(valueStr, "FRM");
} else {
strcat(valueStr, "BRR");
}

View File

@@ -13,10 +13,10 @@ prepText(SDL_Renderer *renderer, unsigned char pxSize, const char *file, uint8_t
unsigned int i = 1;
do {
if (i == 173) { //specifically this char is 0 width (IDK why)
out.surface[i] = SDL_CreateRGBSurface(0,pxSize,pxSize,32,0,0,0,0);
out.surface[i] = SDL_CreateRGBSurface(0, pxSize, pxSize, 32, 0, 0, 0, 0);
} else {
char tmpOut[2] = {i, 0};
out.surface[i] = TTF_RenderText_Solid(gFont, tmpOut, out.color);
char tmpOut[2] = {i, 0};
out.surface[i] = TTF_RenderText_Solid(gFont, tmpOut, out.color);
}
out.texture[i] = SDL_CreateTextureFromSurface(renderer, out.surface[i]);
i++;
@@ -51,7 +51,11 @@ void renderText(SDL_Renderer *renderer, BitmapFont font, char *string, uint16_t
void destroyFont(BitmapFont *font) {
for (uint16_t i = 1; i < 256; i++) {
SDL_DestroyTexture(font->texture[i]);
SDL_FreeSurface(font->surface[i]);
if (font->texture[i]) {
SDL_DestroyTexture(font->texture[i]);
}
if (font->surface[i]) {
SDL_FreeSurface(font->surface[i]);
}
}
}

View File

@@ -49,8 +49,9 @@ void init_editor(TextEditor *editor, BitmapFont *font, int x, int y, SDL_Rendere
}
// Allocate output and display strings.
editor->outputString = (char *) malloc(sizeof(char) * (editor->max_line_width * editor->maxLines + 1));
editor->displayString = (char *) malloc(sizeof(char) * (editor->max_line_width * editor->displayLineCount + 1));
editor->outputString = (char *) malloc(sizeof(char) * ((editor->max_line_width + 1) * editor->maxLines + 1) + 1);
editor->displayString = (char *) malloc(
sizeof(char) * ((editor->max_line_width + 1) * editor->displayLineCount + 1) + 1);
if (!editor->outputString || !editor->displayString) {
fprintf(stderr, "Failed to allocate memory for output/display strings.\n");
exit(EXIT_FAILURE);
@@ -301,9 +302,9 @@ void generate_string_display(TextEditor *editor, SDL_Renderer *renderer) {
charDstRect.x += charDstRect.w + 1;
linePTR++;
}
strcat(editor->displayString, "\n");
charDstRect.x = 4;
charDstRect.y += charDstRect.h + 1;
strcat(editor->displayString, "\n");
}
}
SDL_SetRenderTarget(renderer, NULL);