diff --git a/misc/ps1/ps1defs.h b/misc/ps1/ps1defs.h index 2d370369d..79f62cf07 100644 --- a/misc/ps1/ps1defs.h +++ b/misc/ps1/ps1defs.h @@ -15,6 +15,7 @@ enum gpu_status_flags { enum gp0_cmd_type { + GP0_CMD_MEM_FILL = 0x02000000, GP0_CMD_CLEAR_VRAM_CACHE = 0x01000000, GP0_CMD_TRANSFER_TO_VRAM = 0xA0000000, GP0_CMD_POLYGON = 0x20000000, diff --git a/src/Graphics_WiiU.c b/src/Graphics_WiiU.c index 8a3d343a1..d6bec6ecb 100644 --- a/src/Graphics_WiiU.c +++ b/src/Graphics_WiiU.c @@ -21,6 +21,7 @@ #include #include #include +#include /*########################################################################################################################* *------------------------------------------------------Fetch shaders------------------------------------------------------* diff --git a/src/LBackend.c b/src/LBackend.c index 601c4977b..295ee28c0 100644 --- a/src/LBackend.c +++ b/src/LBackend.c @@ -952,6 +952,17 @@ void LBackend_TableFlagAdded(struct LTable* w) { LBackend_NeedsRedraw(w); } +/* Works out top and height of the scrollbar */ +static void LTable_GetScrollbarCoords(struct LTable* w, int* y, int* height) { + float scale; + if (!w->rowsCount) { *y = 0; *height = 0; return; } + + scale = w->height / (float)w->rowsCount; + *y = Math_Ceil(w->topRow * scale); + *height = Math_Ceil(w->visibleRows * scale); + *height = min(*y + *height, w->height) - *y; +} + /* Draws background behind column headers */ static void LTable_DrawHeaderBackground(struct LTable* w) { BitmapCol gridColor = BitmapColor_RGB(20, 20, 10); diff --git a/src/LWidgets.c b/src/LWidgets.c index 6f8697c7a..1a0a2f741 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -556,16 +556,6 @@ void LTable_FormatUptime(cc_string* dst, int uptime) { String_Format2(dst, "%i%r", &uptime, &unit); } -void LTable_GetScrollbarCoords(struct LTable* w, int* y, int* height) { - float scale; - if (!w->rowsCount) { *y = 0; *height = 0; return; } - - scale = w->height / (float)w->rowsCount; - *y = Math_Ceil(w->topRow * scale); - *height = Math_Ceil(w->visibleRows * scale); - *height = min(*y + *height, w->height) - *y; -} - void LTable_ClampTopRow(struct LTable* w) { if (w->topRow > w->rowsCount - w->visibleRows) { w->topRow = w->rowsCount - w->visibleRows; diff --git a/src/LWidgets.h b/src/LWidgets.h index f3f15c352..e8c307919 100644 --- a/src/LWidgets.h +++ b/src/LWidgets.h @@ -241,8 +241,6 @@ void LTable_Sort(struct LTable* table); void LTable_ShowSelected(struct LTable* table); void LTable_FormatUptime(cc_string* dst, int uptime); -/* Works out top and height of the scrollbar */ -void LTable_GetScrollbarCoords(struct LTable* w, int* y, int* height); /* Ensures top/first visible row index lies within table */ void LTable_ClampTopRow(struct LTable* w); /* Returns index of selected row in currently visible rows */ diff --git a/src/Screens.c b/src/Screens.c index 5e8a5e0dd..929714646 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -1148,7 +1148,7 @@ static void ChatScreen_DrawChatBackground(struct ChatScreen* s) { } static void ChatScreen_DrawChat(struct ChatScreen* s, float delta) { - struct Texture tex; + GfxResourceID texID; double now; int i, logIdx; @@ -1165,16 +1165,17 @@ static void ChatScreen_DrawChat(struct ChatScreen* s, float delta) { Widget_Render2(&s->chat, 0); } else { /* Only render recent chat */ - for (i = 0; i < s->chat.lines; i++) { - tex = s->chat.textures[i]; + for (i = 0; i < s->chat.lines; i++) + { + texID = s->chat.textures[i].ID; + if (!texID) continue; logIdx = s->chatIndex + i; - if (!tex.ID) continue; if (logIdx < 0 || logIdx >= Chat_Log.count) continue; /* Only draw chat within last 10 seconds */ if (Chat_GetLogTime(logIdx) + 10 < now) continue; - Gfx_BindTexture(tex.ID); + Gfx_BindTexture(texID); Gfx_DrawVb_IndexedTris_Range(4, i * 4, DRAW_HINT_SPRITE); } } diff --git a/src/Window_PS1.c b/src/Window_PS1.c index ce0d5dea0..d162a2587 100644 --- a/src/Window_PS1.c +++ b/src/Window_PS1.c @@ -16,6 +16,7 @@ #include #include #include +#include "../misc/ps1/ps1defs.h" #define SCREEN_XRES 320 #define SCREEN_YRES 240 @@ -47,6 +48,19 @@ void Window_Init(void) { void Window_Free(void) { } +// Resets screen to an initial grey colour +static void ClearScreen(void) +{ + for (int i = 0; i < 10000; i++) + { + if (GPU_GP1 & GPU_STATUS_CMD_READY) break; + } + + GPU_GP0 = GP0_CMD_MEM_FILL | (0xCC << 16) | (0xCC << 8) | 0xCC; + GPU_GP0 = 0 | ( 0 << 16); + GPU_GP0 = 320 | (200 << 16); +} + void Window_Create2D(int width, int height) { ResetGraph(0); launcherMode = true; @@ -54,6 +68,7 @@ void Window_Create2D(int width, int height) { SetDefDispEnv(&disp, 0, 0, SCREEN_XRES, SCREEN_YRES); PutDispEnv(&disp); SetDispMask(1); + ClearScreen(); } void Window_Create3D(int width, int height) {