--- previous/src/statusbar.c 2018/04/24 19:29:46 1.1.1.4 +++ previous/src/statusbar.c 2018/04/24 19:31:08 1.1.1.5 @@ -24,18 +24,12 @@ hiding the overlay drive led when drive leds are turned OFF. - If other information shown by Statusbar (TOS version etc) changes, call Statusbar_UpdateInfo() - - TODO: - - re-calculate colors on each update to make sure they're - correct in Falcon & TT 8-bit palette modes? - - call Statusbar_AddMessage() from log.c? */ const char Statusbar_fileid[] = "Hatari statusbar.c : " __DATE__ " " __TIME__; #include #include "main.h" #include "configuration.h" -#include "screenSnapShot.h" #include "sdlgui.h" #include "statusbar.h" #include "screen.h" @@ -78,20 +72,15 @@ static bool bOldSystemLed; static SDL_Rect DspLedRect; static bool bOldDspLed; -#if ENABLE_DIMENSION static SDL_Rect NdLedRect; static int nOldNdLed; -#endif /* led colors */ -static Uint32 LedColorOn, LedColorOff, SysColorOn, SysColorOff, DspColorOn, DspColorOff; -#if ENABLE_DIMENSION +static Uint32 LedColorOn, LedColorOnWP, LedColorOff, SysColorOn, SysColorOff, DspColorOn, DspColorOff; static Uint32 NdColorOn, NdColorCS8, NdColorOff; -#endif static Uint32 GrayBg, LedColorBg; - -#define MAX_MESSAGE_LEN 66 /* changed for Previous, was 50 */ +#define MAX_MESSAGE_LEN 69 /* changed for Previous, was 50 */ typedef struct msg_item { struct msg_item *next; char msg[MAX_MESSAGE_LEN+1]; @@ -103,12 +92,6 @@ typedef struct msg_item { static msg_item_t DefaultMessage; static msg_item_t *MessageList = &DefaultMessage; static SDL_Rect MessageRect; -#if 0 -/* rect for both frame skip value and fast forward indicator */ -static SDL_Rect FrameSkipsRect; -static int nOldFrameSkips; -static int bOldFastForward; -#endif /* screen height above statusbar and height of statusbar below screen */ static int ScreenHeight; @@ -173,25 +156,20 @@ void Statusbar_BlinkLed(drive_index_t dr /*-----------------------------------------------------------------------*/ /** - * Set system, dsp and nextdimension led state, anything enabling led with + * Set system, DSP, CPU and NeXTdimension led state, anything enabling led with * this needs also to take care of disabling it. */ -void Statusbar_SetSystemLed(bool state) -{ +void Statusbar_SetSystemLed(bool state) { bOldSystemLed = state; } -void Statusbar_SetDspLed(bool state) -{ +void Statusbar_SetDspLed(bool state) { bOldDspLed = state; } -#if ENABLE_DIMENSION -void Statusbar_SetNdLed(int state) -{ +void Statusbar_SetNdLed(int state) { nOldNdLed = state; } -#endif /*-----------------------------------------------------------------------*/ /** @@ -234,20 +212,19 @@ void Statusbar_Init(SDL_Surface *surf) assert(surf); /* dark green and light green for leds themselves */ - LedColorOff = SDL_MapRGB(surf->format, 0x00, 0x40, 0x00); - LedColorOn = SDL_MapRGB(surf->format, 0x00, 0xe0, 0x00); - LedColorBg = SDL_MapRGB(surf->format, 0x00, 0x00, 0x00); - SysColorOff = SDL_MapRGB(surf->format, 0x40, 0x00, 0x00); - SysColorOn = SDL_MapRGB(surf->format, 0xe0, 0x00, 0x00); - DspColorOff = SDL_MapRGB(surf->format, 0x00, 0x00, 0x40); - DspColorOn = SDL_MapRGB(surf->format, 0x00, 0x00, 0xe0); -#if ENABLE_DIMENSION - NdColorOff = SDL_MapRGB(surf->format, 0x00, 0x00, 0x40); - NdColorCS8 = SDL_MapRGB(surf->format, 0xe0, 0x00, 0x00); - NdColorOn = SDL_MapRGB(surf->format, 0x00, 0x00, 0xe0); -#endif - GrayBg = SDL_MapRGB(surf->format, 0xb5, 0xb7, 0xaa); - + LedColorOff = SDL_MapRGB(surf->format, 0x00, 0x40, 0x00); + LedColorOn = SDL_MapRGB(surf->format, 0x00, 0xe0, 0x00); + LedColorOnWP = SDL_MapRGB(surf->format, 0xFF, 0xe0, 0x00); + LedColorBg = SDL_MapRGB(surf->format, 0x00, 0x00, 0x00); + SysColorOff = SDL_MapRGB(surf->format, 0x40, 0x00, 0x00); + SysColorOn = SDL_MapRGB(surf->format, 0xe0, 0x00, 0x00); + DspColorOff = SDL_MapRGB(surf->format, 0x00, 0x00, 0x40); + DspColorOn = SDL_MapRGB(surf->format, 0x00, 0x00, 0xe0); + NdColorOff = SDL_MapRGB(surf->format, 0x00, 0x00, 0x40); + NdColorCS8 = SDL_MapRGB(surf->format, 0xe0, 0x00, 0x00); + NdColorOn = SDL_MapRGB(surf->format, 0x00, 0x00, 0xe0); + GrayBg = SDL_MapRGB(surf->format, 0xb5, 0xb7, 0xaa); + /* disable leds */ for (i = 0; i < NUM_DEVICE_LEDS; i++) { Led[i].state = Led[i].oldstate = false; @@ -312,35 +289,13 @@ void Statusbar_Init(SDL_Surface *surf) Led[i].offset = offset; offset += LedRect.w + fontw; } -#if 0 - /* draw frameskip */ - FrameSkipsRect.x = offset; - FrameSkipsRect.y = MessageRect.y; - SDLGui_Text(FrameSkipsRect.x, FrameSkipsRect.y, "FS:"); - FrameSkipsRect.x += 3 * fontw + fontw/2; - FrameSkipsRect.w = 4 * fontw; - FrameSkipsRect.h = fonth; - - if(ConfigureParams.System.bFastForward) { - SDLGui_Text(FrameSkipsRect.x, FrameSkipsRect.y, "0 >>"); - } else { - SDLGui_Text(FrameSkipsRect.x, FrameSkipsRect.y, "0"); - } - - nOldFrameSkips = 0; - - /* intialize messages */ - MessageRect.x = FrameSkipsRect.x + FrameSkipsRect.w + fontw; -#else MessageRect.x = offset + fontw; -#endif MessageRect.w = MAX_MESSAGE_LEN * fontw; MessageRect.h = fonth; for (item = MessageList; item; item = item->next) { item->shown = false; } - -#if ENABLE_DIMENSION + /* draw i860 led box */ NdLedRect = LedRect; NdLedRect.x = surf->w - 15*fontw - NdLedRect.w; @@ -349,7 +304,6 @@ void Statusbar_Init(SDL_Surface *surf) SDL_FillRect(surf, &ledbox, LedColorBg); SDL_FillRect(surf, &NdLedRect, NdColorOff); nOldNdLed = 0; -#endif /* draw dsp led box */ DspLedRect = LedRect; @@ -427,7 +381,6 @@ void Statusbar_UpdateInfo(void) char *end = DefaultMessage.msg; char memsize[8]; -#if ENABLE_DIMENSION /* Message for NeXTdimension */ if (ConfigureParams.Dimension.bEnabled && ConfigureParams.Screen.nMonitorType==MONITOR_TYPE_DIMENSION) { @@ -440,14 +393,9 @@ void Statusbar_UpdateInfo(void) DefaultMessage.shown = false; return; } -#endif /* CPU MHz */ - if (ConfigureParams.System.nCpuFreq > 9) { - *end++ = '0' + ConfigureParams.System.nCpuFreq / 10; - } - *end++ = '0' + ConfigureParams.System.nCpuFreq % 10; - end = Statusbar_AddString(end, "MHz/"); + end = Statusbar_AddString(end, Main_SpeedMsg()); /* CPU type */ if(ConfigureParams.System.nCpuLevel > 0) { @@ -637,7 +585,7 @@ static void Statusbar_OverlayDraw(SDL_Su Led[i].state = false; continue; } - Statusbar_OverlayDrawLed(surf, LedColorOn); + Statusbar_OverlayDrawLed(surf, ConfigureParams.SCSI.nWriteProtection == WRITEPROT_ON && i == DEVICE_LED_SCSI ? LedColorOnWP : LedColorOn); break; } } @@ -664,8 +612,7 @@ static void Statusbar_OverlayDraw(SDL_Su * * May not be called when screen is locked (SDL limitation). */ -void Statusbar_Update(SDL_Surface *surf) -{ +void Statusbar_Update(SDL_Surface *surf) { Uint32 color, currentticks; SDL_Rect rect; int i; @@ -692,14 +639,13 @@ void Statusbar_Update(SDL_Surface *surf) } Led[i].oldstate = Led[i].state; if (Led[i].state) { - color = LedColorOn; + color = ConfigureParams.SCSI.nWriteProtection == WRITEPROT_ON && i == DEVICE_LED_SCSI ? LedColorOnWP : LedColorOn; } else { color = LedColorOff; } rect.x = Led[i].offset; SDL_FillRect(surf, &rect, color); SDL_UpdateRects(surf, 1, &rect); - DEBUGPRINT(("LED[%d] = %s\n", i, Led[i].state?"ON":"OFF")); } Statusbar_ShowMessage(surf, currentticks); @@ -712,7 +658,6 @@ void Statusbar_Update(SDL_Surface *surf) } SDL_FillRect(surf, &DspLedRect, color); SDL_UpdateRects(surf, 1, &DspLedRect); - DEBUGPRINT(("DSP LED = ON\n")); /* Draw scr2 LED */ if (bOldSystemLed) { @@ -722,18 +667,14 @@ void Statusbar_Update(SDL_Surface *surf) } SDL_FillRect(surf, &SystemLedRect, color); SDL_UpdateRects(surf, 1, &SystemLedRect); - DEBUGPRINT(("SCR2 LED = ON\n")); -#if ENABLE_DIMENSION /* Draw NeXTdimension LED */ switch(nOldNdLed) { - case 0: color = NdColorOff; break; - case 1: color = NdColorCS8; break; - case 2: color = NdColorOn; break; + case 0: color = NdColorOff; break; + case 1: color = NdColorCS8; break; + case 2: color = NdColorOn; break; default: color = NdColorOff; break; } SDL_FillRect(surf, &NdLedRect, color); SDL_UpdateRects(surf, 1, &NdLedRect); - DEBUGPRINT(("ND LED = ON\n")); -#endif }