--- previous/src/statusbar.c 2018/04/24 19:25:10 1.1.1.1 +++ previous/src/statusbar.c 2018/04/24 19:29:46 1.1.1.4 @@ -38,8 +38,9 @@ const char Statusbar_fileid[] = "Hatari #include "screenSnapShot.h" #include "sdlgui.h" #include "statusbar.h" +#include "screen.h" #include "video.h" -#include "avi_record.h" +#include "dimension.h" #define DEBUG 0 #if DEBUG @@ -48,15 +49,13 @@ const char Statusbar_fileid[] = "Hatari #define DEBUGPRINT(x) #endif -#define MAX_DRIVE_LEDS (DRIVE_LED_HD + 1) - /* whether drive leds should be ON and their previous shown state */ static struct { bool state; bool oldstate; Uint32 expire; /* when to disable led, valid only if >0 && state=TRUE */ int offset; /* led x-pos on screen */ -} Led[MAX_DRIVE_LEDS]; +} Led[NUM_DEVICE_LEDS]; /* drive leds size & y-pos */ static SDL_Rect LedRect; @@ -73,15 +72,26 @@ static enum { OVERLAY_RESTORED } bOverlayState; -static SDL_Rect RecLedRect; -static bool bOldRecording; +static SDL_Rect SystemLedRect; +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, RecColorOn, RecColorOff; +static Uint32 LedColorOn, LedColorOff, SysColorOn, SysColorOff, DspColorOn, DspColorOff; +#if ENABLE_DIMENSION +static Uint32 NdColorOn, NdColorCS8, NdColorOff; +#endif static Uint32 GrayBg, LedColorBg; -#define MAX_MESSAGE_LEN 33 +#define MAX_MESSAGE_LEN 66 /* changed for Previous, was 50 */ typedef struct msg_item { struct msg_item *next; char msg[MAX_MESSAGE_LEN+1]; @@ -93,12 +103,12 @@ 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; @@ -151,26 +161,37 @@ int Statusbar_GetHeight(void) /*-----------------------------------------------------------------------*/ /** - * Enable HD drive led, it will be automatically disabled after a while. + * Enable device led, it will be automatically disabled after a while. */ -void Statusbar_EnableHDLed(void) +void Statusbar_BlinkLed(drive_index_t drive) { /* leds are shown for 1/2 sec after enabling */ - Led[DRIVE_LED_HD].expire = SDL_GetTicks() + 1000/2; - Led[DRIVE_LED_HD].state = true; + Led[drive].expire = SDL_GetTicks() + 1000/2; + Led[drive].state = true; } + /*-----------------------------------------------------------------------*/ /** - * Set given floppy drive led state, anything enabling led with this - * needs also to take care of disabling it. + * Set system, dsp and nextdimension led state, anything enabling led with + * this needs also to take care of disabling it. */ -void Statusbar_SetFloppyLed(drive_index_t drive, bool state) +void Statusbar_SetSystemLed(bool state) { - assert(drive == DRIVE_LED_A || drive == DRIVE_LED_B); - Led[drive].state = state; + bOldSystemLed = state; } +void Statusbar_SetDspLed(bool state) +{ + bOldDspLed = state; +} + +#if ENABLE_DIMENSION +void Statusbar_SetNdLed(int state) +{ + nOldNdLed = state; +} +#endif /*-----------------------------------------------------------------------*/ /** @@ -208,7 +229,7 @@ void Statusbar_Init(SDL_Surface *surf) msg_item_t *item; SDL_Rect ledbox, sbarbox; int i, fontw, fonth, offset; - const char *text[MAX_DRIVE_LEDS] = { "A:", "B:", "HD:" }; + const char *text[NUM_DEVICE_LEDS] = { "EN:", "MO:", "SD:", "FD:" }; assert(surf); @@ -216,12 +237,19 @@ void Statusbar_Init(SDL_Surface *surf) LedColorOff = SDL_MapRGB(surf->format, 0x00, 0x40, 0x00); LedColorOn = SDL_MapRGB(surf->format, 0x00, 0xe0, 0x00); LedColorBg = SDL_MapRGB(surf->format, 0x00, 0x00, 0x00); - RecColorOff = SDL_MapRGB(surf->format, 0x40, 0x00, 0x00); - RecColorOn = SDL_MapRGB(surf->format, 0xe0, 0x00, 0x00); - GrayBg = SDL_MapRGB(surf->format, 0xc0, 0xc0, 0xc0); + 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); /* disable leds */ - for (i = 0; i < MAX_DRIVE_LEDS; i++) { + for (i = 0; i < NUM_DEVICE_LEDS; i++) { Led[i].state = Led[i].oldstate = false; Led[i].expire = 0; } @@ -270,7 +298,7 @@ void Statusbar_Init(SDL_Surface *surf) offset = fontw; MessageRect.y = LedRect.y - 2; /* draw led texts and boxes + calculate box offsets */ - for (i = 0; i < MAX_DRIVE_LEDS; i++) { + for (i = 0; i < NUM_DEVICE_LEDS; i++) { SDLGui_Text(offset, MessageRect.y, text[i]); offset += strlen(text[i]) * fontw; offset += fontw/2; @@ -284,7 +312,7 @@ 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; @@ -303,20 +331,43 @@ void Statusbar_Init(SDL_Surface *surf) /* 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; } - /* draw recording led box */ - RecLedRect = LedRect; - RecLedRect.x = surf->w - fontw - RecLedRect.w; - ledbox.x = RecLedRect.x - 1; - SDLGui_Text(ledbox.x - 4*fontw - fontw/2, MessageRect.y, "REC:"); +#if ENABLE_DIMENSION + /* draw i860 led box */ + NdLedRect = LedRect; + NdLedRect.x = surf->w - 15*fontw - NdLedRect.w; + ledbox.x = NdLedRect.x - 1; + SDLGui_Text(ledbox.x - 3*fontw - fontw/2, MessageRect.y, "ND:"); + SDL_FillRect(surf, &ledbox, LedColorBg); + SDL_FillRect(surf, &NdLedRect, NdColorOff); + nOldNdLed = 0; +#endif + + /* draw dsp led box */ + DspLedRect = LedRect; + DspLedRect.x = surf->w - 8*fontw - DspLedRect.w; + ledbox.x = DspLedRect.x - 1; + SDLGui_Text(ledbox.x - 4*fontw - fontw/2, MessageRect.y, "DSP:"); SDL_FillRect(surf, &ledbox, LedColorBg); - SDL_FillRect(surf, &RecLedRect, RecColorOff); - bOldRecording = false; + SDL_FillRect(surf, &DspLedRect, DspColorOff); + bOldDspLed = false; + + /* draw system led box */ + SystemLedRect = LedRect; + SystemLedRect.x = surf->w - fontw - SystemLedRect.w; + ledbox.x = SystemLedRect.x - 1; + SDLGui_Text(ledbox.x - 4*fontw - fontw/2, MessageRect.y, "LED:"); + SDL_FillRect(surf, &ledbox, LedColorBg); + SDL_FillRect(surf, &SystemLedRect, SysColorOff); + bOldSystemLed = false; /* and blit statusbar on screen */ SDL_UpdateRects(surf, 1, &sbarbox); @@ -374,7 +425,23 @@ static char *Statusbar_AddString(char *b 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) { + end = Statusbar_AddString(end, "33MHz/i860XR/"); + sprintf(memsize, "%iMB/",Configuration_CheckDimensionMemory(ConfigureParams.Dimension.nMemoryBankSize)); + end = Statusbar_AddString(end, memsize); + end = Statusbar_AddString(end, "NeXTdimension"); + *end = '\0'; + assert(end - DefaultMessage.msg < MAX_MESSAGE_LEN); + DefaultMessage.shown = false; + return; + } +#endif + /* CPU MHz */ if (ConfigureParams.System.nCpuFreq > 9) { *end++ = '0' + ConfigureParams.System.nCpuFreq / 10; @@ -384,32 +451,52 @@ void Statusbar_UpdateInfo(void) /* CPU type */ if(ConfigureParams.System.nCpuLevel > 0) { + *end++ = '6'; + *end++ = '8'; *end++ = '0'; - *end++ = '0' + ConfigureParams.System.nCpuLevel % 10; + switch (ConfigureParams.System.nCpuLevel) { + case 0: *end++ = '0'; break; + case 1: *end++ = '1'; break; + case 2: *end++ = '2'; break; + case 3: *end++ = '3'; break; + case 4: *end++ = '4'; break; + case 5: *end++ = '6'; break; + default: break; + } *end++ = '0'; *end++ = '/'; } /* amount of memory */ - if (ConfigureParams.Memory.nMemorySize > 9) { - *end++ = '1'; - *end++ = '0' + ConfigureParams.Memory.nMemorySize % 10; - } else { - if (ConfigureParams.Memory.nMemorySize) { - *end++ = '0' + ConfigureParams.Memory.nMemorySize; - } else { - end = Statusbar_AddString(end, "1/2"); - } - } - end = Statusbar_AddString(end, "MB "); + sprintf(memsize, "%iMB/", Configuration_CheckMemory(ConfigureParams.Memory.nMemoryBankSize)); + end = Statusbar_AddString(end, memsize); /* machine type */ - end = Statusbar_AddString(end, "NEXT"); + switch (ConfigureParams.System.nMachineType) { + case NEXT_CUBE030: + end = Statusbar_AddString(end, "NeXT Computer"); + break; + case NEXT_CUBE040: + end = Statusbar_AddString(end, "NeXTcube"); + break; + case NEXT_STATION: + end = Statusbar_AddString(end, "NeXTstation"); + break; + + default: + break; + } + if (ConfigureParams.System.bTurbo) + end = Statusbar_AddString(end, (ConfigureParams.System.nCpuFreq==40)?" Nitro":" Turbo"); + + if (ConfigureParams.System.bColor) + end = Statusbar_AddString(end, " Color"); *end = '\0'; assert(end - DefaultMessage.msg < MAX_MESSAGE_LEN); DEBUGPRINT(("Set default message: '%s'\n", DefaultMessage.msg)); + /* make sure default message gets (re-)drawn when next checked */ DefaultMessage.shown = false; } @@ -441,7 +528,7 @@ static void Statusbar_ShowMessage(SDL_Su if (MessageList->shown) { if (!MessageList->expire) { - /* last/default message */ + /* last/default message never expires */ return; } if (MessageList->expire > ticks) { @@ -544,7 +631,7 @@ static void Statusbar_OverlayDraw(SDL_Su int i; assert(surf); - for (i = 0; i < MAX_DRIVE_LEDS; i++) { + for (i = 0; i < NUM_DEVICE_LEDS; i++) { if (Led[i].state) { if (Led[i].expire && Led[i].expire < currentticks) { Led[i].state = false; @@ -596,7 +683,7 @@ void Statusbar_Update(SDL_Surface *surf) rect = LedRect; currentticks = SDL_GetTicks(); - for (i = 0; i < MAX_DRIVE_LEDS; i++) { + for (i = 0; i < NUM_DEVICE_LEDS; i++) { if (Led[i].expire && Led[i].expire < currentticks) { Led[i].state = false; } @@ -617,5 +704,36 @@ void Statusbar_Update(SDL_Surface *surf) Statusbar_ShowMessage(surf, currentticks); - + /* Draw dsp LED */ + if (bOldDspLed) { + color = DspColorOn; + } else { + color = DspColorOff; + } + SDL_FillRect(surf, &DspLedRect, color); + SDL_UpdateRects(surf, 1, &DspLedRect); + DEBUGPRINT(("DSP LED = ON\n")); + + /* Draw scr2 LED */ + if (bOldSystemLed) { + color = SysColorOn; + } else { + color = SysColorOff; + } + 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; + default: color = NdColorOff; break; + } + SDL_FillRect(surf, &NdLedRect, color); + SDL_UpdateRects(surf, 1, &NdLedRect); + DEBUGPRINT(("ND LED = ON\n")); +#endif }