diff --git a/Makefile.djgpp b/Makefile.djgpp index 725b045..51b02cb 100644 --- a/Makefile.djgpp +++ b/Makefile.djgpp @@ -43,7 +43,7 @@ TARGET_ARCH := # Compiler Flags ALL_CFLAGS := $(CFLAGS) -ALL_CFLAGS += -Wall -O2 +ALL_CFLAGS += -Wall -Ofast # Preprocessor Flags ALL_CPPFLAGS := $(CPPFLAGS) @@ -54,7 +54,7 @@ ALL_LDLIBS := -lc # Source, Binaries, Dependencies -SRC := $(shell find $(SRCDIR) -type f -name '*.c' | grep -v '/linux/' | grep -v '/server/' | grep -v '/font/' | grep -v '/retired/') +SRC := $(shell find $(SRCDIR) -type f -name '*.c' | grep -v '/linux/' | grep -v '/server/' | grep -v '/primes/' | grep -v '/font/' | grep -v '/retired/') OBJ := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SRC:.c=.o)) DEP := $(OBJ:.o=.d) BIN := $(BINDIR)/$(TARGET) diff --git a/client/src/config.c b/client/src/config.c index 60e2b19..7517320 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -24,7 +24,7 @@ #include "util.h" -ConfigT _configData; +ConfigT __configData; static char *_configName = NULL; @@ -46,19 +46,19 @@ void configShutdown(void) { "PORT=%d\n\n" "[USER]\n" "NAME=%s\n", - _configData.videoWidth, _configData.videoHeight, _configData.videoDepth, - _configData.serialCom, - _configData.serverHost, _configData.serverPort, - _configData.userName + __configData.videoWidth, __configData.videoHeight, __configData.videoDepth, + __configData.serialCom, + __configData.serverHost, __configData.serverPort, + __configData.userName ); fclose(out); } - free(_configData.serverHost); - _configData.serverHost = NULL; + free(__configData.serverHost); + __configData.serverHost = NULL; - free(_configData.userName); - _configData.userName = NULL; + free(__configData.userName); + __configData.userName = NULL; free(_configName); _configName = NULL; @@ -72,26 +72,26 @@ void configStartup(char *file) { _configName = utilAppNameWithNewExtensionGet(file, "ini"); // Numeric Defaults. - _configData.videoWidth = 800; - _configData.videoHeight = 600; - _configData.videoDepth = 16; - _configData.serialCom = 0; - _configData.serverPort = 16550; + __configData.videoWidth = 800; + __configData.videoHeight = 600; + __configData.videoDepth = 16; + __configData.serialCom = 0; + __configData.serverPort = 16550; // Load from disk if available. ini = ini_load(_configName); if (ini) { - ini_sget(ini, "VIDEO", "WIDTH", "%d", &_configData.videoWidth); - ini_sget(ini, "VIDEO", "HEIGHT", "%d", &_configData.videoHeight); - ini_sget(ini, "VIDEO", "DEPTH", "%d", &_configData.videoDepth); - ini_sget(ini, "SERIAL", "COM", "%d", &_configData.serialCom); - _configData.serverHost = strdup(ini_get(ini, "SERVER", "HOST")); - ini_sget(ini, "SERVER", "PORT", "%d", &_configData.serverPort); - _configData.userName = strdup(ini_get(ini, "USER", "NAME")); + ini_sget(ini, "VIDEO", "WIDTH", "%d", &__configData.videoWidth); + ini_sget(ini, "VIDEO", "HEIGHT", "%d", &__configData.videoHeight); + ini_sget(ini, "VIDEO", "DEPTH", "%d", &__configData.videoDepth); + ini_sget(ini, "SERIAL", "COM", "%d", &__configData.serialCom); + __configData.serverHost = strdup(ini_get(ini, "SERVER", "HOST")); + ini_sget(ini, "SERVER", "PORT", "%d", &__configData.serverPort); + __configData.userName = strdup(ini_get(ini, "USER", "NAME")); ini_free(ini); } // String defaults. - if (!_configData.serverHost) _configData.serverHost = strdup("kanga.world"); - if (!_configData.userName) _configData.userName = strdup("New User"); + if (!__configData.serverHost) __configData.serverHost = strdup("kanga.world"); + if (!__configData.userName) __configData.userName = strdup("New User"); } diff --git a/client/src/config.h b/client/src/config.h index bd801e5..06d936c 100644 --- a/client/src/config.h +++ b/client/src/config.h @@ -36,7 +36,7 @@ typedef struct ConfigS { } ConfigT; -extern ConfigT _configData; +extern ConfigT __configData; void configShutdown(void); diff --git a/client/src/dos/vesa.c b/client/src/dos/vesa.c index 9b20378..038a71f 100644 --- a/client/src/dos/vesa.c +++ b/client/src/dos/vesa.c @@ -133,6 +133,13 @@ typedef struct VBESurfaceS { } VBESurfaceT; +static VBESurfaceT _vbeSurface; +static VBEInfoT _vbeInfo; +static VBEModeInfoT _vbeModeInfo; +static PModeInterfaceT *_pmodeInterfacePtr; +static uint32_t *_yTable; + + static void vbeCreatePalette(void); static VBEInfoT *vbeGetInfo(void); static VBEModeInfoT *vbeGetModeInfo(uint16_t vbeModeNumber); @@ -145,13 +152,6 @@ static uint16_t vbeSetScanlineLength(uint16_t pixelLength); static void (*pmVBESetDisplayStart)(void); -static VBESurfaceT _vbeSurface; -static VBEInfoT _vbeInfo; -static VBEModeInfoT _vbeModeInfo; -static PModeInterfaceT *_pmodeInterfacePtr; -static uint32_t *_yTable; - - static void vbeCreatePalette(void) { uint8_t color = 0; uint8_t red; diff --git a/client/src/gui/button.c b/client/src/gui/button.c index f13bd97..45d19b0 100644 --- a/client/src/gui/button.c +++ b/client/src/gui/button.c @@ -112,35 +112,31 @@ static void buttonPaint(WidgetT *widget, uint8_t enabled, RectT pos) { ColorT background; ColorT text; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - b = (ButtonT *)widget; - active = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE); + b = (ButtonT *)widget; + active = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE); - if (enabled) { - highlight = active ? _guiColor[COLOR_BUTTON_SHADOW] : _guiColor[COLOR_BUTTON_HIGHLIGHT]; - shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT] : _guiColor[COLOR_BUTTON_SHADOW]; - background = _guiColor[COLOR_BUTTON_BACKGROUND]; - text = _guiColor[COLOR_BUTTON_TEXT]; - } else { - highlight = active ? _guiColor[COLOR_BUTTON_SHADOW_DISABLED] : _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED]; - shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_BUTTON_SHADOW_DISABLED]; - background = _guiColor[COLOR_BUTTON_BACKGROUND_DISABLED]; - text = _guiColor[COLOR_BUTTON_TEXT_DISABLED]; - } - - // Draw bezel. - for (i=0; i<_guiMetric[METRIC_BUTTON_BEZEL_SIZE]; i++) { - surfaceHighlightFrameDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, highlight, shadow); - } - - // Draw background (depends on x from above). - surfaceRectangleFilledDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, background); - - // Draw title (depends on x from above). - fontRender(_guiFont, b->title, text, background, pos.x + i + _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] + active, pos.y + i + _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] + active); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); + if (enabled) { + highlight = active ? _guiColor[COLOR_BUTTON_SHADOW] : _guiColor[COLOR_BUTTON_HIGHLIGHT]; + shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT] : _guiColor[COLOR_BUTTON_SHADOW]; + background = _guiColor[COLOR_BUTTON_BACKGROUND]; + text = _guiColor[COLOR_BUTTON_TEXT]; + } else { + highlight = active ? _guiColor[COLOR_BUTTON_SHADOW_DISABLED] : _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED]; + shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_BUTTON_SHADOW_DISABLED]; + background = _guiColor[COLOR_BUTTON_BACKGROUND_DISABLED]; + text = _guiColor[COLOR_BUTTON_TEXT_DISABLED]; } + + // Draw bezel. + for (i=0; i<_guiMetric[METRIC_BUTTON_BEZEL_SIZE]; i++) { + surfaceHighlightFrameDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, highlight, shadow); + } + + // Draw background (depends on x from above). + surfaceRectangleFilledDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, background); + + // Draw title (depends on x from above). + fontRender(_guiFont, b->title, text, background, pos.x + i + _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] + active, pos.y + i + _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] + active); } diff --git a/client/src/gui/checkbox.c b/client/src/gui/checkbox.c index 47a495d..f2e151a 100644 --- a/client/src/gui/checkbox.c +++ b/client/src/gui/checkbox.c @@ -99,36 +99,32 @@ static void checkboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) { ColorT text; ColorT background; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - active = checkboxValueGet(c); - if (enabled) { - highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT]; - shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT] : _guiColor[COLOR_CHECKBOX_SHADOW]; - fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE] : _guiColor[COLOR_CHECKBOX_INACTIVE]; - text = _guiColor[COLOR_CHECKBOX_TEXT]; - background = _guiColor[COLOR_WINDOW_BACKGROUND]; - } else { - highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED]; - shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] : _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED]; - fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] : _guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED]; - text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED]; - background = _guiColor[COLOR_WINDOW_BACKGROUND]; - } - - // Checkbox is 10x10 pixels. Find offset based on font height. - o = (_guiFont->height - 10) * 0.5; - - // Draw outline of checkbox. - surfaceHighlightFrameDraw(pos.x, pos.y + o, pos.x + 10, pos.y + 10 + o, highlight, shadow); - - // Draw background. - surfaceRectangleFilledDraw(pos.x + 1, pos.y + o + 1, pos.x + 9, pos.y + + o + 9, fill); - - // Draw title. - fontRender(_guiFont, c->title, text, background, pos.x + 10 + _guiMetric[METRIC_CHECKBOX_PADDING], pos.y); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); + active = checkboxValueGet(c); + if (enabled) { + highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT]; + shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT] : _guiColor[COLOR_CHECKBOX_SHADOW]; + fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE] : _guiColor[COLOR_CHECKBOX_INACTIVE]; + text = _guiColor[COLOR_CHECKBOX_TEXT]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; + } else { + highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED]; + shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] : _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED]; + fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] : _guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED]; + text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; } + + // Checkbox is 10x10 pixels. Find offset based on font height. + o = (_guiFont->height - 10) * 0.5; + + // Draw outline of checkbox. + surfaceHighlightFrameDraw(pos.x, pos.y + o, pos.x + 10, pos.y + 10 + o, highlight, shadow); + + // Draw background. + surfaceRectangleFilledDraw(pos.x + 1, pos.y + o + 1, pos.x + 9, pos.y + + o + 9, fill); + + // Draw title. + fontRender(_guiFont, c->title, text, background, pos.x + 10 + _guiMetric[METRIC_CHECKBOX_PADDING], pos.y); } diff --git a/client/src/gui/desktop.c b/client/src/gui/desktop.c index 70dc566..ce34f03 100644 --- a/client/src/gui/desktop.c +++ b/client/src/gui/desktop.c @@ -61,11 +61,9 @@ DesktopT *desktopNew(void) { static void desktopPaint(WidgetT *desktop, uint8_t enabled, RectT pos) { + (void)desktop; (void)pos; (void)enabled; - if (GUI_GET_FLAG(desktop, WIDGET_FLAG_DIRTY)) { - surfaceClear(_guiColor[COLOR_DESKTOP]); - GUI_CLEAR_FLAG(desktop, WIDGET_FLAG_DIRTY); - } + surfaceClear(_guiColor[COLOR_DESKTOP]); } diff --git a/client/src/gui/frame.c b/client/src/gui/frame.c index 7c6bf5f..5ef6de9 100644 --- a/client/src/gui/frame.c +++ b/client/src/gui/frame.c @@ -66,15 +66,11 @@ FrameT *frameNew(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title) { static void framePaint(WidgetT *widget, uint8_t enabled, RectT pos) { FrameT *f = (FrameT *)widget; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - // Draw frame. - surfaceHighlightFrameDraw(pos.x, pos.y + (fontHeightGet(_guiFont) * 0.5), pos.x + pos.w, pos.y + pos.h, _guiColor[COLOR_FRAME_SHADOW], _guiColor[COLOR_FRAME_HIGHLIGHT]); + // Draw frame. + surfaceHighlightFrameDraw(pos.x, pos.y + (fontHeightGet(_guiFont) * 0.5), pos.x + pos.w, pos.y + pos.h, _guiColor[COLOR_FRAME_SHADOW], _guiColor[COLOR_FRAME_HIGHLIGHT]); - // Draw title. - fontRender(_guiFont, f->title, _guiColor[COLOR_FRAME_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x + 10, pos.y); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); - } + // Draw title. + fontRender(_guiFont, f->title, _guiColor[COLOR_FRAME_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x + 10, pos.y); } diff --git a/client/src/gui/gui.c b/client/src/gui/gui.c index 3dbeadb..00220e0 100644 --- a/client/src/gui/gui.c +++ b/client/src/gui/gui.c @@ -68,6 +68,7 @@ static char *_magicDebugNames[MAGIC_COUNT] = { static void guiDeleteList(void); static void guiDeleteListItem(WidgetT **widget); static void guiPaintBoundsGet(WidgetT *widget, RectT *pos); +static void guiPaintChildren(WidgetT *widget); static void guiKeyboardChildrenProcess(WidgetT *widget, uint8_t ascii, uint8_t extended, uint8_t scancode, uint8_t shift, uint8_t control, uint8_t alt); static uint8_t guiMouseChildrenProcess(WidgetT *widget, MouseT *mouse); static WindowT *guiWindowFindTopChildrenProcess(WidgetT *widget); @@ -197,22 +198,24 @@ void guiDelete(WidgetT **widget) { static void guiDeleteList(void) { - WidgetT **w = NULL; - WindowT *win = NULL; + WidgetT **w = NULL; + WindowT *win = NULL; - while (arrlen(_guiDeleteList) > 0) { - w = arrpop(_guiDeleteList); - guiDeleteListItem(w); - } + if (_guiDeleteList) { + while (arrlen(_guiDeleteList) > 0) { + w = arrpop(_guiDeleteList); + guiDeleteListItem(w); + } - arrfree(_guiDeleteList); - _guiDeleteList = NULL; + arrfree(_guiDeleteList); + _guiDeleteList = NULL; - // Is the top level window no longer active? If so, select it. - win = guiWindowFindTop(); - if (win) { - if (!GUI_GET_FLAG(W(win), WIDGET_FLAG_ACTIVE)) { - windowActiveSet(win); + // Is the top level window no longer active? If so, select it. + win = guiWindowFindTop(); + if (win) { + if (!GUI_GET_FLAG(W(win), WIDGET_FLAG_ACTIVE)) { + windowActiveSet(win); + } } } } @@ -453,19 +456,28 @@ void guiMouseProcess(MouseT *mouse) { void guiPaint(WidgetT *widget) { - size_t len; - size_t x; - RectT pos; // Process any pending widget deletions. guiDeleteList(); - // Paint us. Widget handles dirty flag so they can animate if needed. + guiPaintChildren(widget); +} + + +static void guiPaintChildren(WidgetT *widget) { + size_t len; + size_t x; + RectT pos; + + // Paint us. if (!GUI_GET_FLAG(widget, WIDGET_FLAG_HIDDEN)) { - if (widget->paintMethod) { - surfaceSet(widget->surface); - guiPaintBoundsGet(widget, &pos); - widget->paintMethod(widget, !GUI_GET_FLAG(widget, WIDGET_FLAG_DISABLED), pos); + if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY) || GUI_GET_FLAG(widget, WIDGET_FLAG_ALWAYS_PAINT)) { + if (widget->paintMethod) { + surfaceSet(widget->surface); + guiPaintBoundsGet(widget, &pos); + widget->paintMethod(widget, !GUI_GET_FLAG(widget, WIDGET_FLAG_DISABLED), pos); + GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); + } } } @@ -473,7 +485,7 @@ void guiPaint(WidgetT *widget) { len = arrlenu(widget->children); if (len > 0) { for (x=0; xchildren[x]); + guiPaintChildren(widget->children[x]); } } } diff --git a/client/src/gui/label.c b/client/src/gui/label.c index 38fa3fc..0bd5213 100644 --- a/client/src/gui/label.c +++ b/client/src/gui/label.c @@ -124,12 +124,8 @@ static void labelPaint(WidgetT *widget, uint8_t enabled, RectT pos) { LabelT *l = (LabelT *)widget; ColorT text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? l->active : l->foreground; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - // Draw title. - fontRender(_guiFont, l->title, text, l->background, pos.x, pos.y); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); - } + // Draw title. + fontRender(_guiFont, l->title, text, l->background, pos.x, pos.y); } diff --git a/client/src/gui/listbox.c b/client/src/gui/listbox.c index 6732549..586dd72 100644 --- a/client/src/gui/listbox.c +++ b/client/src/gui/listbox.c @@ -237,70 +237,66 @@ static void listboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) { int16_t len; ColorT color; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - listboxSizesRecalculate(l); + listboxSizesRecalculate(l); - // Move a few things into screen space, not widget space. - _arrowStart += pos.x; - _valueTop += pos.y; - _valueBottom += pos.y; + // Move a few things into screen space, not widget space. + _arrowStart += pos.x; + _valueTop += pos.y; + _valueBottom += pos.y; - len = arrlenu(l->values); + len = arrlenu(l->values); - // How many items can we draw? - items = len - l->offset; - if (items > _visibleY - 1) items = _visibleY - 1; + // How many items can we draw? + items = len - l->offset; + if (items > _visibleY - 1) items = _visibleY - 1; - // Draw title. - fontRender(_guiFont, l->title, _guiColor[COLOR_LISTBOX_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y); + // Draw title. + fontRender(_guiFont, l->title, _guiColor[COLOR_LISTBOX_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y); - // Draw outline of listbox. - surfaceHighlightFrameDraw(pos.x, _valueTop, pos.x + _valueWidth, _valueBottom, _guiColor[COLOR_LISTBOX_SHADOW], _guiColor[COLOR_LISTBOX_HIGHLIGHT]); + // Draw outline of listbox. + surfaceHighlightFrameDraw(pos.x, _valueTop, pos.x + _valueWidth, _valueBottom, _guiColor[COLOR_LISTBOX_SHADOW], _guiColor[COLOR_LISTBOX_HIGHLIGHT]); - // Draw background of listbox. - surfaceRectangleFilledDraw(pos.x + 1, _valueTop + 1, pos.x + _valueWidth - 1, _valueBottom - 1, _guiColor[COLOR_LISTBOX_BACKGROUND]); + // Draw background of listbox. + surfaceRectangleFilledDraw(pos.x + 1, _valueTop + 1, pos.x + _valueWidth - 1, _valueBottom - 1, _guiColor[COLOR_LISTBOX_BACKGROUND]); - // Draw listbox contents. - o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; - for (i=0; iselected) { - surfaceRectangleFilledDraw(pos.x + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o, pos.x + _valueWidth - _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o + fontHeightGet(_guiFont) - 1, _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND]); - fontRender(_guiFont, l->values[l->offset + i], _guiColor[COLOR_LISTBOX_SELECTED_TEXT], _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND], pos.x + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o); - } else { - fontRender(_guiFont, l->values[l->offset + i], _guiColor[COLOR_LISTBOX_TEXT], _guiColor[COLOR_LISTBOX_BACKGROUND], pos.x + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o); - } - o += fontHeightGet(_guiFont); + // Draw listbox contents. + o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; + for (i=0; iselected) { + surfaceRectangleFilledDraw(pos.x + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o, pos.x + _valueWidth - _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o + fontHeightGet(_guiFont) - 1, _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND]); + fontRender(_guiFont, l->values[l->offset + i], _guiColor[COLOR_LISTBOX_SELECTED_TEXT], _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND], pos.x + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o); + } else { + fontRender(_guiFont, l->values[l->offset + i], _guiColor[COLOR_LISTBOX_TEXT], _guiColor[COLOR_LISTBOX_BACKGROUND], pos.x + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o); } - - // Draw outline of arrows. - surfaceHighlightFrameDraw(_arrowStart, _valueTop, _arrowStart + _arrowWidth, _valueBottom, _guiColor[COLOR_LISTBOX_SHADOW], _guiColor[COLOR_LISTBOX_HIGHLIGHT]); - - // Draw background of arrows. - surfaceRectangleFilledDraw(_arrowStart + 1, _valueTop + 1, _arrowStart + _arrowWidth - 1, _valueBottom - 1, _guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND]); - - // Draw up arrow - _arrowStart += _halfFont + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING]; // Center of up arrow - o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Top of up arrow - color = l->offset + l->selected > 0 ? _guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] : _guiColor[COLOR_LISTBOX_ARROWS_INACTIVE]; - for (i=0; i<=fontHeightGet(_guiFont); i++) { - surfaceLineDraw(_arrowStart - i * 0.5, o + i, _arrowStart + i * 0.5, o + i, color); - } - surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_SHADOW]); - surfaceLineDraw(_arrowStart - _halfFont, o + fontHeightGet(_guiFont), _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_SHADOW]); - surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_HIGHLIGHT]); - - // Draw down arrow - o = _valueBottom - 1 - _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Bottom of down arrow - color = l->offset + l->selected < len - 1 ? _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE]; - for (i=0; i<=fontHeightGet(_guiFont); i++) { - surfaceLineDraw(_arrowStart - i * 0.5, o - i, _arrowStart + i * 0.5, o - i, color); - } - surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_SHADOW]); - surfaceLineDraw(_arrowStart - _halfFont, o - fontHeightGet(_guiFont), _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]); - surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); + o += fontHeightGet(_guiFont); } + + // Draw outline of arrows. + surfaceHighlightFrameDraw(_arrowStart, _valueTop, _arrowStart + _arrowWidth, _valueBottom, _guiColor[COLOR_LISTBOX_SHADOW], _guiColor[COLOR_LISTBOX_HIGHLIGHT]); + + // Draw background of arrows. + surfaceRectangleFilledDraw(_arrowStart + 1, _valueTop + 1, _arrowStart + _arrowWidth - 1, _valueBottom - 1, _guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND]); + + // Draw up arrow + _arrowStart += _halfFont + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING]; // Center of up arrow + o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Top of up arrow + color = l->offset + l->selected > 0 ? _guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] : _guiColor[COLOR_LISTBOX_ARROWS_INACTIVE]; + for (i=0; i<=fontHeightGet(_guiFont); i++) { + surfaceLineDraw(_arrowStart - i * 0.5, o + i, _arrowStart + i * 0.5, o + i, color); + } + surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_SHADOW]); + surfaceLineDraw(_arrowStart - _halfFont, o + fontHeightGet(_guiFont), _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_SHADOW]); + surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_HIGHLIGHT]); + + // Draw down arrow + o = _valueBottom - 1 - _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Bottom of down arrow + color = l->offset + l->selected < len - 1 ? _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE]; + for (i=0; i<=fontHeightGet(_guiFont); i++) { + surfaceLineDraw(_arrowStart - i * 0.5, o - i, _arrowStart + i * 0.5, o - i, color); + } + surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_SHADOW]); + surfaceLineDraw(_arrowStart - _halfFont, o - fontHeightGet(_guiFont), _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]); + surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]); } diff --git a/client/src/gui/msgbox.c b/client/src/gui/msgbox.c index fd3117e..db693d9 100644 --- a/client/src/gui/msgbox.c +++ b/client/src/gui/msgbox.c @@ -43,22 +43,19 @@ #define ICN_SIZE 32 -static msgBoxCallback cbOne = NULL; -static msgBoxCallback cbTwo = NULL; -static msgBoxCallback cbThree = NULL; +static msgBoxCallback _cbOne = NULL; +static msgBoxCallback _cbTwo = NULL; +static msgBoxCallback _cbThree = NULL; -static WindowT *winDialog = NULL; -static PictureT *picIcon = NULL; -static LabelT *lblText = NULL; -static ButtonT *btnOne = NULL; -static ButtonT *btnTwo = NULL; -static ButtonT *btnThree = NULL; +static WindowT *_winDialog = NULL; +static PictureT *_picIcon = NULL; +static LabelT *_lblText = NULL; +static ButtonT *_btnOne = NULL; +static ButtonT *_btnTwo = NULL; +static ButtonT *_btnThree = NULL; -static void btnMsgBox(WidgetT *widget); - - -static char *iconFiles[MSGBOX_ICON_COUNT] = { +static char *_iconFiles[MSGBOX_ICON_COUNT] = { "data/mbie32.png", "data/mbiw32.png", "data/mbii32.png", @@ -67,18 +64,21 @@ static char *iconFiles[MSGBOX_ICON_COUNT] = { }; +static void btnMsgBox(WidgetT *widget); + + static void btnMsgBox(WidgetT *widget) { // Remove us from the display. - guiDelete(D(winDialog)); + guiDelete(D(_winDialog)); // Call whoever wanted called. - if (widget == W(btnOne)) { - if (cbOne) cbOne(MSGBOX_BUTTON_ONE); + if (widget == W(_btnOne)) { + if (_cbOne) _cbOne(MSGBOX_BUTTON_ONE); } - if (widget == W(btnTwo)) { - if (cbTwo) cbTwo(MSGBOX_BUTTON_TWO); + if (widget == W(_btnTwo)) { + if (_cbTwo) _cbTwo(MSGBOX_BUTTON_TWO); } - if (widget == W(btnThree)) { - if (cbThree) cbThree(MSGBOX_BUTTON_THREE); + if (widget == W(_btnThree)) { + if (_cbThree) _cbThree(MSGBOX_BUTTON_THREE); } } @@ -103,14 +103,14 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne, char *text = NULL; // Null these for later. - btnOne = NULL; - btnTwo = NULL; - btnThree = NULL; + _btnOne = NULL; + _btnTwo = NULL; + _btnThree = NULL; // Remember callbacks for later. - cbOne = callbackOne; - cbTwo = callbackTwo; - cbThree = callbackThree; + _cbOne = callbackOne; + _cbTwo = callbackTwo; + _cbThree = callbackThree; // Calculate size of dialog box window. @@ -162,8 +162,8 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne, // Draw dialog. h -= 5; // Height is off for some reason. At least, to me, it doesn't look right. - winDialog = windowNew(vbeDisplayWidthGet() / 2 - w / 2, vbeDisplayHeightGet() / 2 - h / 2, w, h, title); - guiAttach(guiRootGet(), W(winDialog)); + _winDialog = windowNew(vbeDisplayWidthGet() / 2 - w / 2, vbeDisplayHeightGet() / 2 - h / 2, w, h, title); + guiAttach(guiRootGet(), W(_winDialog)); // Initial x cursor is the (implied window left margin +) padding x = MSG_PADDING; @@ -173,8 +173,8 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne, // Load proper icon, if desired. if (icon > MSGBOX_ICON_NONE && icon < MSGBOX_ICON_COUNT) { - picIcon = pictureNew(x, y, iconFiles[icon - 1]); - guiAttach(W(winDialog), W(picIcon)); + _picIcon = pictureNew(x, y, _iconFiles[icon - 1]); + guiAttach(W(_winDialog), W(_picIcon)); } // Draw message text. @@ -183,8 +183,8 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne, text = strdup(message); token = strtok(text, "\n"); while (token) { - lblText = labelNew(x, t, token); - guiAttach(W(winDialog), W(lblText)); + _lblText = labelNew(x, t, token); + guiAttach(W(_winDialog), W(_lblText)); t += fontHeightGet(_guiFont); token = strtok(NULL, "\n"); } @@ -195,21 +195,21 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne, y += cursorH + MSG_PADDING; // We always have at least one button. - btnOne = buttonNew(x, y, buttonOne, btnMsgBox); - guiAttach(W(winDialog), W(btnOne)); + _btnOne = buttonNew(x, y, buttonOne, btnMsgBox); + guiAttach(W(_winDialog), W(_btnOne)); // Two buttons? if (buttonTwo) { x -= (MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonTwo))); - btnTwo = buttonNew(x, y, buttonTwo, btnMsgBox); - guiAttach(W(winDialog), W(btnTwo)); + _btnTwo = buttonNew(x, y, buttonTwo, btnMsgBox); + guiAttach(W(_winDialog), W(_btnTwo)); } // Three buttons? if (buttonThree) { x -= (MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonThree))); - btnThree = buttonNew(x, y, buttonThree, btnMsgBox); - guiAttach(W(winDialog), W(btnThree)); + _btnThree = buttonNew(x, y, buttonThree, btnMsgBox); + guiAttach(W(_winDialog), W(_btnThree)); } } diff --git a/client/src/gui/picture.c b/client/src/gui/picture.c index 67617cb..1986c27 100644 --- a/client/src/gui/picture.c +++ b/client/src/gui/picture.c @@ -104,9 +104,5 @@ PictureT *pictureNew(uint16_t x, uint16_t y, char *filename) { static void picturePaint(WidgetT *widget, uint8_t enabled, RectT pos) { PictureT *p = (PictureT *)widget; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - imageRender(p->image, pos.x, pos.y); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); - } + imageRender(p->image, pos.x, pos.y); } diff --git a/client/src/gui/radio.c b/client/src/gui/radio.c index 4e6120d..cf01acf 100644 --- a/client/src/gui/radio.c +++ b/client/src/gui/radio.c @@ -105,42 +105,38 @@ static void radioPaint(WidgetT *widget, uint8_t enabled, RectT pos) { ColorT text; ColorT background; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - active = (radioSelectedGet(r) == r); - if (enabled) { - highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT]; - shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] : _guiColor[COLOR_RADIOBUTTON_SHADOW]; - fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE] : _guiColor[COLOR_RADIOBUTTON_INACTIVE]; - text = _guiColor[COLOR_CHECKBOX_TEXT]; - background = _guiColor[COLOR_WINDOW_BACKGROUND]; - } else { - highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED]; - shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED]; - fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] : _guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED]; - text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED]; - background = _guiColor[COLOR_WINDOW_BACKGROUND]; - } - - // Radio button is 10x10 pixels. Find offset based on font height. - o = (_guiFont->height - 10) * 0.5; - - // Draw outline of radio button. - surfaceLineDraw(pos.x, pos.y + o + 5, pos.x + 5, pos.y + o, highlight); - surfaceLineDraw(pos.x + 5, pos.y + o, pos.x + 10, pos.y + o + 5, highlight); - surfaceLineDraw(pos.x, pos.y + o + 5, pos.x + 5, pos.y + o + 10, shadow); - surfaceLineDraw(pos.x + 5, pos.y + o + 10, pos.x + 10, pos.y + o + 5, shadow); - - // Fill radio button. - for (i=0; i<4; i++) { - surfaceLineDraw(pos.x + 5 - i, pos.y + o + i + 1, pos.x + 5 + i, pos.y + o + i + 1, fill); - surfaceLineDraw(pos.x + 5 - i, pos.y + o - i + 8, pos.x + 5 + i, pos.y + o - i + 8, fill); - } - - // Draw title. - fontRender(_guiFont, r->title, text, background, pos.x + 10 + _guiMetric[METRIC_RADIOBUTTON_PADDING], pos.y); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); + active = (radioSelectedGet(r) == r); + if (enabled) { + highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT]; + shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] : _guiColor[COLOR_RADIOBUTTON_SHADOW]; + fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE] : _guiColor[COLOR_RADIOBUTTON_INACTIVE]; + text = _guiColor[COLOR_CHECKBOX_TEXT]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; + } else { + highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED]; + shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED]; + fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] : _guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED]; + text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; } + + // Radio button is 10x10 pixels. Find offset based on font height. + o = (_guiFont->height - 10) * 0.5; + + // Draw outline of radio button. + surfaceLineDraw(pos.x, pos.y + o + 5, pos.x + 5, pos.y + o, highlight); + surfaceLineDraw(pos.x + 5, pos.y + o, pos.x + 10, pos.y + o + 5, highlight); + surfaceLineDraw(pos.x, pos.y + o + 5, pos.x + 5, pos.y + o + 10, shadow); + surfaceLineDraw(pos.x + 5, pos.y + o + 10, pos.x + 10, pos.y + o + 5, shadow); + + // Fill radio button. + for (i=0; i<4; i++) { + surfaceLineDraw(pos.x + 5 - i, pos.y + o + i + 1, pos.x + 5 + i, pos.y + o + i + 1, fill); + surfaceLineDraw(pos.x + 5 - i, pos.y + o - i + 8, pos.x + 5 + i, pos.y + o - i + 8, fill); + } + + // Draw title. + fontRender(_guiFont, r->title, text, background, pos.x + 10 + _guiMetric[METRIC_RADIOBUTTON_PADDING], pos.y); } diff --git a/client/src/gui/terminal.c b/client/src/gui/terminal.c index eb5a796..9ba7f60 100644 --- a/client/src/gui/terminal.c +++ b/client/src/gui/terminal.c @@ -668,25 +668,20 @@ static void terminalPaint(WidgetT *widget, uint8_t enabled, RectT pos) { uint16_t yp; char c[2]; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { + c[1] = 0; - c[1] = 0; - - yp = pos.y; - for (y=0; yrows; y++) { - xp = pos.x; - for (x=0; xcols; x++) { - if (TERMINAL_CELL_GET_FLAG(t, x, y, TERMINAL_FLAG_DIRTY)) { - c[0] = t->cells[x][y].character; - fontRender(t->font, c, t->palette[t->cells[x][y].foreground], t->palette[t->cells[x][y].background], xp, yp); - TERMINAL_CELL_CLEAR_FLAG(t, x, y, TERMINAL_FLAG_DIRTY); - } - xp += fontWidthGet(t->font); + yp = pos.y; + for (y=0; yrows; y++) { + xp = pos.x; + for (x=0; xcols; x++) { + if (TERMINAL_CELL_GET_FLAG(t, x, y, TERMINAL_FLAG_DIRTY)) { + c[0] = t->cells[x][y].character; + fontRender(t->font, c, t->palette[t->cells[x][y].foreground], t->palette[t->cells[x][y].background], xp, yp); + TERMINAL_CELL_CLEAR_FLAG(t, x, y, TERMINAL_FLAG_DIRTY); } - yp += fontHeightGet(t->font); + xp += fontWidthGet(t->font); } - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); + yp += fontHeightGet(t->font); } } diff --git a/client/src/gui/textbox.c b/client/src/gui/textbox.c index ce5d35d..788f9b7 100644 --- a/client/src/gui/textbox.c +++ b/client/src/gui/textbox.c @@ -65,6 +65,9 @@ WidgetT *textboxInit(WidgetT *widget, char *title) { // Visible is set in textboxSetTitle textboxTitleSet(t, title); + // We need to blink a cursor. + GUI_SET_FLAG(widget, WIDGET_FLAG_ALWAYS_PAINT); + return widget; } @@ -289,7 +292,7 @@ static void textboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) { free(draw); // Draw cursor. - if (guiFocusGet() == widget && _timerQuarterSecondOn) { + if (guiFocusGet() == widget && __timerQuarterSecondOn) { caretPos = textX + fontWidthGet(_guiFont) * t->caret; fontRender(_guiFont, cursor, _guiColor[COLOR_TEXTBOX_TEXT], _guiColor[COLOR_TEXTBOX_BACKGROUND], caretPos, textY); } diff --git a/client/src/gui/updown.c b/client/src/gui/updown.c index 9d08375..7ef5b93 100644 --- a/client/src/gui/updown.c +++ b/client/src/gui/updown.c @@ -77,6 +77,9 @@ WidgetT *updownInit(WidgetT *widget, int32_t min, int32_t max, int32_t step, cha updownMaximumSet(u, max); updownStepSet(u, step); + // We need to blink a cursor. + GUI_SET_FLAG(widget, WIDGET_FLAG_ALWAYS_PAINT); + return widget; } @@ -307,7 +310,7 @@ static void updownPaint(WidgetT *widget, uint8_t enabled, RectT pos) { fontRender(_guiFont, draw, _guiColor[COLOR_UPDOWN_TEXT], _guiColor[COLOR_UPDOWN_BACKGROUND], textX, textY); // Draw cursor. - if (guiFocusGet() == widget && _timerQuarterSecondOn) { + if (guiFocusGet() == widget && __timerQuarterSecondOn) { textX += (strlen(draw) - 1) * fontWidthGet(_guiFont); fontRender(_guiFont, cursor, _guiColor[COLOR_TEXTBOX_TEXT], _guiColor[COLOR_TEXTBOX_BACKGROUND], textX, textY); } diff --git a/client/src/gui/widget.h b/client/src/gui/widget.h index 7873e32..0b5b47b 100644 --- a/client/src/gui/widget.h +++ b/client/src/gui/widget.h @@ -27,6 +27,7 @@ enum WidgetE { WIDGET_FLAG_DIRTY = 0, + WIDGET_FLAG_ALWAYS_PAINT, WIDGET_FLAG_ACTIVE, WIDGET_FLAG_OWNS_SURFACE, WIDGET_FLAG_ALWAYS_RECEIVE_KEYBOARD_EVENTS, diff --git a/client/src/gui/window.c b/client/src/gui/window.c index 80ade69..9b390e7 100644 --- a/client/src/gui/window.c +++ b/client/src/gui/window.c @@ -174,29 +174,25 @@ static void windowPaint(WidgetT *widget, uint8_t enabled, RectT pos) { ColorT background; ColorT text; - if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - x2 = pos.w - 1; - y2 = pos.h - 1; - background = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? _guiColor[COLOR_WINDOW_TITLE_ACTIVE] : _guiColor[COLOR_WINDOW_TITLE_INACTIVE]; - text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? _guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] : _guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE]; + x2 = pos.w - 1; + y2 = pos.h - 1; + background = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? _guiColor[COLOR_WINDOW_TITLE_ACTIVE] : _guiColor[COLOR_WINDOW_TITLE_INACTIVE]; + text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? _guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] : _guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE]; - // Background. - surfaceClear(_guiColor[COLOR_WINDOW_BACKGROUND]); + // Background. + surfaceClear(_guiColor[COLOR_WINDOW_BACKGROUND]); - // Outer edge. - surfaceHighlightFrameDraw(0, 0, x2, y2, _guiColor[COLOR_WINDOW_HIGHLIGHT], _guiColor[COLOR_WINDOW_SHADOW]); + // Outer edge. + surfaceHighlightFrameDraw(0, 0, x2, y2, _guiColor[COLOR_WINDOW_HIGHLIGHT], _guiColor[COLOR_WINDOW_SHADOW]); - // Inner edge - skip METRIC_WINDOW_BORDER_WIDTH pixels. Be sure shadow and highlight are not included in the width. - surfaceHighlightFrameDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, y2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, _guiColor[COLOR_WINDOW_SHADOW], _guiColor[COLOR_WINDOW_HIGHLIGHT]); + // Inner edge - skip METRIC_WINDOW_BORDER_WIDTH pixels. Be sure shadow and highlight are not included in the width. + surfaceHighlightFrameDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, y2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, _guiColor[COLOR_WINDOW_SHADOW], _guiColor[COLOR_WINDOW_HIGHLIGHT]); - // Title bar - METRIC_WINDOW_TITLE_HEIGHT pixels high. Be sure shadow and highlight are not included in the width. - surfaceHighlightFrameDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 3, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 4, _guiColor[COLOR_WINDOW_HIGHLIGHT], _guiColor[COLOR_WINDOW_SHADOW]); - surfaceRectangleFilledDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 4, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 2, background); + // Title bar - METRIC_WINDOW_TITLE_HEIGHT pixels high. Be sure shadow and highlight are not included in the width. + surfaceHighlightFrameDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 3, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 4, _guiColor[COLOR_WINDOW_HIGHLIGHT], _guiColor[COLOR_WINDOW_SHADOW]); + surfaceRectangleFilledDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 4, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 2, background); - fontRender(_guiFont, w->title, text, background, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 16, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 5); - - GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); - } + fontRender(_guiFont, w->title, text, background, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 16, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 5); } diff --git a/client/src/linux/linux.c b/client/src/linux/linux.c index 89905d1..9eeac73 100644 --- a/client/src/linux/linux.c +++ b/client/src/linux/linux.c @@ -41,35 +41,35 @@ #define MODEM_RESULT_ERROR 2 -static MouseT _mouse; -static SDL_Window *_window = NULL; -static SDL_Renderer *_renderer = NULL; -static SDL_Surface *_surface = NULL; -static SDL_Texture *_texture = NULL; -static uint16_t _width = 0; -static uint16_t _height = 0; -static uint8_t _windowScale = 1; -static uint8_t _alt = 0; -static uint8_t _control = 0; -static uint8_t _shift = 0; -static uint8_t _ASCII = 0; -static uint8_t _scanCode = 0; -static uint8_t _extended = 0; -static uint8_t _ASCIIKeep = 0; -static uint8_t _scanCodeKeep = 0; -static uint8_t _keyPressed = 0; -static uint8_t _debounce = 0; -static long _timerTicks = 0; -static SDL_TimerID _timerID; -static ENetHost *_host = NULL; -static ENetPeer *_peer = NULL; -static ENetAddress _address; -static uint8_t _comPortOpen = 0; -static uint8_t _modemCommandMode = 1; -static char _buffer[COM_BUFFER_SIZE]; -static uint16_t _bufferHead = 0; -static uint16_t _bufferTail = 0; -static uint8_t _connected = 0; +static MouseT _mouse = { 0 }; +static SDL_Window *_window = NULL; +static SDL_Renderer *_renderer = NULL; +static SDL_Surface *_surface = NULL; +static SDL_Texture *_texture = NULL; +static uint16_t _width = 0; +static uint16_t _height = 0; +static uint8_t _windowScale = 1; +static uint8_t _alt = 0; +static uint8_t _control = 0; +static uint8_t _shift = 0; +static uint8_t _ASCII = 0; +static uint8_t _scanCode = 0; +static uint8_t _extended = 0; +static uint8_t _ASCIIKeep = 0; +static uint8_t _scanCodeKeep = 0; +static uint8_t _keyPressed = 0; +static uint8_t _debounce = 0; +static long _timerTicks = 0; +static SDL_TimerID _timerID = { 0 }; +static ENetHost *_host = NULL; +static ENetPeer *_peer = NULL; +static ENetAddress _address = { 0 }; +static uint8_t _comPortOpen = 0; +static uint8_t _modemCommandMode = 1; +static char _buffer[COM_BUFFER_SIZE] = { 0 }; +static uint16_t _bufferHead = 0; +static uint16_t _bufferTail = 0; +static uint8_t _connected = 0; static void comAddToBuffer(char *data, uint16_t len); diff --git a/client/src/main.c b/client/src/main.c index 6909cca..9e5c915 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) { } // Do we have the video mode they asked for? - if (vbeStartup(_configData.videoWidth, _configData.videoHeight, _configData.videoDepth)) { + if (vbeStartup(__configData.videoWidth, __configData.videoHeight, __configData.videoDepth)) { configShutdown(); logClose(); memoryShutdown(); diff --git a/client/src/settings.c b/client/src/settings.c index 526bc10..398495d 100644 --- a/client/src/settings.c +++ b/client/src/settings.c @@ -55,16 +55,16 @@ typedef struct PortS { } PortT; -static WindowT *winDetecting; -static LabelT *lblOneMoment; -static WindowT *winSettings; -static FrameT *frmComPorts; -static FrameT *frmServer; -static ButtonT *btnOkay; -static TextboxT *txtServer; -static UpdownT *updPort; -static PortT port[4]; -static widgetCallback done; +static WindowT *_winDetecting; +static LabelT *_lblOneMoment; +static WindowT *_winSettings; +static FrameT *_frmComPorts; +static FrameT *_frmServer; +static ButtonT *_btnOkay; +static TextboxT *_txtServer; +static UpdownT *_updPort; +static PortT _port[4]; +static widgetCallback _done; static void btnOkayClick(WidgetT *widget); @@ -72,26 +72,26 @@ static void btnOkayClick(WidgetT *widget); static void btnOkayClick(WidgetT *widget) { uint8_t x; - RadioT *selected = radioSelectedGet(port[0].rdoCOM); + RadioT *selected = radioSelectedGet(_port[0].rdoCOM); (void)widget; // Save selected COM port. for (x=0; x<4; x++) { - if (selected == port[x].rdoCOM) { - _configData.serialCom = x + 1; + if (selected == _port[x].rdoCOM) { + __configData.serialCom = x + 1; break; } } // Save server info. - free(_configData.serverHost); - _configData.serverHost = strdup(textboxValueGet(txtServer)); - _configData.serverPort = updownValueGet(updPort); + free(__configData.serverHost); + __configData.serverHost = strdup(textboxValueGet(_txtServer)); + __configData.serverPort = updownValueGet(_updPort); // Return to calling routine. - guiDelete(D(winSettings)); - done(NULL); + guiDelete(D(_winSettings)); + _done(NULL); } @@ -102,14 +102,14 @@ void taskSettings(void *data) { char buffer[1024]; uint8_t selected = 1; - done = (widgetCallback)data; + _done = (widgetCallback)data; TagItemT uiDetecting[] = { T_START, - T_WINDOW, O(winDetecting), + T_WINDOW, O(_winDetecting), T_TITLE, P("Detecting Modems"), T_WIDTH, 200, T_HEIGHT, 100, - T_LABEL, O(lblOneMoment), + T_LABEL, O(_lblOneMoment), T_X, 25, T_Y, 25, T_TITLE, P("One Moment Please!"), T_LABEL, T_DONE, @@ -130,64 +130,64 @@ void taskSettings(void *data) { len = comRead(x, buffer, 1023); buffer[len] = 0; if (strstr(buffer, "OK")) { - snprintf(port[x].title, TITLE_LEN - 1, "COM%d - SoftModem Found!", x + 1); - port[x].status = PORT_GOOD_MODEM; - port[x].selected = selected; - port[x].enabled = 1; + snprintf(_port[x].title, TITLE_LEN - 1, "COM%d - SoftModem Found!", x + 1); + _port[x].status = PORT_GOOD_MODEM; + _port[x].selected = selected; + _port[x].enabled = 1; selected = 0; } else { if (strstr(buffer, "ERROR")) { - snprintf(port[x].title, TITLE_LEN - 1, "COM%d - Incompatable Modem", x + 1); - port[x].status = PORT_BAD_MODEM; - port[x].selected = 0; - port[x].enabled = 0; + snprintf(_port[x].title, TITLE_LEN - 1, "COM%d - Incompatable Modem", x + 1); + _port[x].status = PORT_BAD_MODEM; + _port[x].selected = 0; + _port[x].enabled = 0; } else { - snprintf(port[x].title, TITLE_LEN - 1, "COM%d - No Modem", x + 1); - port[x].status = PORT_NO_MODEM; - port[x].selected = 0; - port[x].enabled = 0; + snprintf(_port[x].title, TITLE_LEN - 1, "COM%d - No Modem", x + 1); + _port[x].status = PORT_NO_MODEM; + _port[x].selected = 0; + _port[x].enabled = 0; } } comClose(x); } else { - snprintf(port[x].title, TITLE_LEN - 1, "COM%d - Not Present", x + 1); - port[x].status = PORT_NONE; - port[x].selected = 0; - port[x].enabled = 0; + snprintf(_port[x].title, TITLE_LEN - 1, "COM%d - Not Present", x + 1); + _port[x].status = PORT_NONE; + _port[x].selected = 0; + _port[x].enabled = 0; } } - guiDelete(D(winDetecting)); + guiDelete(D(_winDetecting)); TagItemT uiSettings[] = { T_START, - T_WINDOW, O(winSettings), + T_WINDOW, O(_winSettings), T_TITLE, P("Settings"), T_WIDTH, 300, T_HEIGHT, 295, - T_FRAME, O(frmComPorts), + T_FRAME, O(_frmComPorts), T_X, 10, T_Y, 5, T_WIDTH, 266, T_HEIGHT, 100, T_TITLE, P("COM Ports"), T_FRAME, T_DONE, - T_FRAME, O(frmServer), + T_FRAME, O(_frmServer), T_X, 10, T_Y, 110, T_WIDTH, 266, T_HEIGHT, 100, T_TITLE, P("Server"), - T_TEXTBOX, O(txtServer), + T_TEXTBOX, O(_txtServer), T_X, 5, T_WIDTH, 250, T_TITLE, P("Address:"), - T_VALUE, P(_configData.serverHost), + T_VALUE, P(__configData.serverHost), T_TEXTBOX, T_DONE, - T_UPDOWN, O(updPort), + T_UPDOWN, O(_updPort), T_X, 5, T_Y, 30, T_WIDTH, 250, T_TITLE, P(" Port:"), - T_VALUE, _configData.serverPort, + T_VALUE, __configData.serverPort, T_MINIMUM, 1, T_MAXIMUM, 65535, T_UPDOWN, T_DONE, T_FRAME, T_DONE, - T_BUTTON, O(btnOkay), + T_BUTTON, O(_btnOkay), T_X, 225, T_Y, 225, T_TITLE, P("Okay"), T_CLICK, P(btnOkayClick), @@ -200,22 +200,22 @@ void taskSettings(void *data) { tagListRun(uiSettings); // If we found more than one, use the last selected. - if (_configData.serialCom > 0 && _configData.serialCom < 4) { - if (port[_configData.serialCom - 1].enabled) { + if (__configData.serialCom > 0 && __configData.serialCom < 4) { + if (_port[__configData.serialCom - 1].enabled) { for (len=0; len<4; len++) { - port[len].selected = 0; + _port[len].selected = 0; } - port[_configData.serialCom - 1].selected = 1; + _port[__configData.serialCom - 1].selected = 1; } } // Add COM discovery to GUI. rc = 0; for (len=0; len<4; len++) { - port[len].rdoCOM = radioNew(5, rc, port[len].title, GROUP_COM); - if (port[len].selected) radioSelectedSet(port[len].rdoCOM); - widgetEnableSet(W(port[len].rdoCOM), port[len].enabled); - guiAttach(W(frmComPorts), W(port[len].rdoCOM)); + _port[len].rdoCOM = radioNew(5, rc, _port[len].title, GROUP_COM); + if (_port[len].selected) radioSelectedSet(_port[len].rdoCOM); + widgetEnableSet(W(_port[len].rdoCOM), _port[len].enabled); + guiAttach(W(_frmComPorts), W(_port[len].rdoCOM)); rc += 20; } } diff --git a/client/src/system/comport.c b/client/src/system/comport.c index 1376ab9..e76c238 100644 --- a/client/src/system/comport.c +++ b/client/src/system/comport.c @@ -65,7 +65,7 @@ int comWaitWithTimeout(int com, char *buffer, int len, int quarterSeconds, char break; } } - if (_timerQuarterSecondTick) { + if (__timerQuarterSecondTick) { quarterTicks++; } taskYield(); diff --git a/client/src/system/timer.c b/client/src/system/timer.c index f589257..8711dae 100644 --- a/client/src/system/timer.c +++ b/client/src/system/timer.c @@ -28,18 +28,18 @@ #define TICKS_PER_DAY (SECONDS_IN_DAY * TICKS_PER_SECOND) -uint8_t _timerQuarterSecondTick = 0; -uint8_t _timerHalfSecondTick = 0; -uint8_t _timerSecondTick = 0; +uint8_t __timerQuarterSecondTick = 0; +uint8_t __timerHalfSecondTick = 0; +uint8_t __timerSecondTick = 0; -uint8_t _timerQuarterSecondOn = 0; -uint8_t _timerHalfSecondOn = 0; -uint8_t _timerSecondOn = 0; +uint8_t __timerQuarterSecondOn = 0; +uint8_t __timerHalfSecondOn = 0; +uint8_t __timerSecondOn = 0; -static long timerLast = 0; -static uint8_t timerHalfSecond = 2; -static uint8_t timerSecond = 2; +static long _timerLast = 0; +static uint8_t _timerHalfSecond = 2; +static uint8_t _timerSecond = 2; void timerShutdown(void) { @@ -48,7 +48,7 @@ void timerShutdown(void) { void timerStartup(void) { - timerLast = biostime(0, 0); + _timerLast = biostime(0, 0); } @@ -59,37 +59,37 @@ void timerUpdate(void) { now = biostime(0, 0); // Reset ticks. - _timerQuarterSecondTick = 0; - _timerHalfSecondTick = 0; - _timerSecondTick = 0; + __timerQuarterSecondTick = 0; + __timerHalfSecondTick = 0; + __timerSecondTick = 0; // Ensure we haven't rolled past midnight between calls. - if (now >= timerLast) { - delta = now - timerLast; + if (now >= _timerLast) { + delta = now - _timerLast; } else { // Compensate for midnight rollover. - delta = (now + TICKS_PER_DAY) - timerLast; + delta = (now + TICKS_PER_DAY) - _timerLast; } // Everything ticks off the quarter second. if (delta > TICKS_PER_SECOND * 0.25) { - timerLast = now; + _timerLast = now; // Quarter Second timer. - _timerQuarterSecondOn = !_timerQuarterSecondOn; - _timerQuarterSecondTick = 1; + __timerQuarterSecondOn = !__timerQuarterSecondOn; + __timerQuarterSecondTick = 1; // Half Second timer. - if (--timerHalfSecond == 0) { - timerHalfSecond = 2; - _timerHalfSecondOn = !_timerHalfSecondOn; - _timerHalfSecondTick = 1; + if (--_timerHalfSecond == 0) { + _timerHalfSecond = 2; + __timerHalfSecondOn = !__timerHalfSecondOn; + __timerHalfSecondTick = 1; // Second timer - if (--timerSecond == 0) { - timerSecond = 2; - _timerSecondOn = !_timerSecondOn; - _timerSecondTick = 1; + if (--_timerSecond == 0) { + _timerSecond = 2; + __timerSecondOn = !__timerSecondOn; + __timerSecondTick = 1; } // Second. } // Half Second. @@ -98,11 +98,11 @@ void timerUpdate(void) { } -void timerQuarterSecondsWait(u_int8_t quarterSeconds) { +void timerQuarterSecondsWait(uint8_t quarterSeconds) { uint8_t counter = 0; while (counter <= quarterSeconds && !guiHasStopped()) { - if (_timerQuarterSecondTick) { + if (__timerQuarterSecondTick) { counter++; } taskYield(); diff --git a/client/src/system/timer.h b/client/src/system/timer.h index de2ca49..f9b8fd0 100644 --- a/client/src/system/timer.h +++ b/client/src/system/timer.h @@ -25,19 +25,19 @@ #include "os.h" -extern uint8_t _timerQuarterSecondTick; -extern uint8_t _timerHalfSecondTick; -extern uint8_t _timerSecondTick; +extern uint8_t __timerQuarterSecondTick; +extern uint8_t __timerHalfSecondTick; +extern uint8_t __timerSecondTick; -extern uint8_t _timerQuarterSecondOn; -extern uint8_t _timerHalfSecondOn; -extern uint8_t _timerSecondOn; +extern uint8_t __timerQuarterSecondOn; +extern uint8_t __timerHalfSecondOn; +extern uint8_t __timerSecondOn; void timerShutdown(void); void timerStartup(void); void timerUpdate(void); -void timerQuarterSecondsWait(u_int8_t quarterSeconds); +void timerQuarterSecondsWait(uint8_t quarterSeconds); #endif // TIMER_H diff --git a/client/src/test.c b/client/src/test.c index eefdf91..4280913 100644 --- a/client/src/test.c +++ b/client/src/test.c @@ -41,9 +41,9 @@ #include -uint8_t lastKey = 0; +uint8_t _lastKey = 0; -static TerminalT *t1 = NULL; +static TerminalT *_t1 = NULL; static void buttonClick(WidgetT *widget); @@ -309,7 +309,7 @@ void taskTestTagList(void *data) { T_WINDOW, O(w4), T_TITLE, P("Terminal"), T_X, 10, T_Y, 10, T_WIDTH, 7 + 8 + (80 * 8), T_HEIGHT, 26 + 8 + (24 * 14), - T_TERMINAL, O(t1), + T_TERMINAL, O(_t1), T_X, 0, T_Y, 0, T_WIDTH, 80, T_HEIGHT, 24, T_TERMINAL, T_DONE, T_WINDOW, T_DONE, @@ -340,7 +340,7 @@ static void testTerminal(void *data) { fclose(in); buffer[length] = 0; - terminalStringPrint(t1, buffer); + terminalStringPrint(_t1, buffer); free(buffer); } diff --git a/client/src/test.h b/client/src/test.h index fee0b69..288e245 100644 --- a/client/src/test.h +++ b/client/src/test.h @@ -26,7 +26,7 @@ #include "terminal.h" -extern uint8_t lastKey; +extern uint8_t _lastKey; void comPortScanTest(void *data); diff --git a/client/src/welcome.c b/client/src/welcome.c index e001e2b..6e16f37 100644 --- a/client/src/welcome.c +++ b/client/src/welcome.c @@ -33,14 +33,14 @@ #include "msgbox.h" -static WindowT *winWelcome = NULL; -static PictureT *picLogo = NULL; -static PictureT *picInit = NULL; -static PictureT *picDialing = NULL; -static PictureT *picConnect = NULL; -static ButtonT *btnQuit = NULL; -static ButtonT *btnSettings = NULL; -static ButtonT *btnConnect = NULL; +static WindowT *_winWelcome = NULL; +static PictureT *_picLogo = NULL; +static PictureT *_picInit = NULL; +static PictureT *_picDialing = NULL; +static PictureT *_picConnect = NULL; +static ButtonT *_btnQuit = NULL; +static ButtonT *_btnSettings = NULL; +static ButtonT *_btnConnect = NULL; static void taskConnectClick(void *data); @@ -59,10 +59,10 @@ static void btnMsgBox(MsgBoxButtonT button) { setButtons(1); // Reset to Welcome image. - widgetVisibleSet(W(picLogo), 1); - widgetVisibleSet(W(picInit), 0); - widgetVisibleSet(W(picDialing), 0); - widgetVisibleSet(W(picConnect), 0); + widgetVisibleSet(W(_picLogo), 1); + widgetVisibleSet(W(_picInit), 0); + widgetVisibleSet(W(_picDialing), 0); + widgetVisibleSet(W(_picConnect), 0); } @@ -82,55 +82,55 @@ static void taskConnectClick(void *data) { (void)data; // Ghost all buttons. - widgetEnableSet(W(btnConnect), 0); - widgetEnableSet(W(btnSettings), 0); - widgetEnableSet(W(btnQuit), 0); + widgetEnableSet(W(_btnConnect), 0); + widgetEnableSet(W(_btnSettings), 0); + widgetEnableSet(W(_btnQuit), 0); // Hide welcome banner, show init. - widgetVisibleSet(W(picLogo), 0); - widgetVisibleSet(W(picInit), 1); + widgetVisibleSet(W(_picLogo), 0); + widgetVisibleSet(W(_picInit), 1); taskYield(); // Open COM port. - r = comOpen(_configData.serialCom - 1, 57600L, 8, 'n', 1, SER_HANDSHAKING_RTSCTS); + r = comOpen(__configData.serialCom - 1, 57600L, 8, 'n', 1, SER_HANDSHAKING_RTSCTS); if (r != SER_SUCCESS) { msgBoxOne("COM Problem", MSGBOX_ICON_ERROR, "Unable to open COM port!\nPlease check settings.", "Okay", btnMsgBox); return; } // Send a CR to clear anything in the modem. snprintf(buffer, 1023, "%c", 13); - comWrite(_configData.serialCom - 1, buffer, strlen(buffer)); + comWrite(__configData.serialCom - 1, buffer, strlen(buffer)); // Wait roughly a second for anything. - comWaitWithTimeout(_configData.serialCom - 1, buffer, 1023, 4, "weExpectNothing"); + comWaitWithTimeout(__configData.serialCom - 1, buffer, 1023, 4, "weExpectNothing"); // Send actual init snprintf(buffer, 1023, "%s%c", "AT+SOCK1", 13); - comWrite(_configData.serialCom - 1, buffer, strlen(buffer)); + comWrite(__configData.serialCom - 1, buffer, strlen(buffer)); // Wait roughly a second for "OK". - r = comWaitWithTimeout(_configData.serialCom - 1, buffer, 1023, 4, "\rOK\r"); + r = comWaitWithTimeout(__configData.serialCom - 1, buffer, 1023, 4, "\rOK\r"); if (r <= 0) { - comClose(_configData.serialCom - 1); + comClose(__configData.serialCom - 1); msgBoxOne("Modem Problem", MSGBOX_ICON_ERROR, "Modem does not support ENET!\nPlease check settings.", "Okay", btnMsgBox); return; } // Flush COM port. timerQuarterSecondsWait(4); - comReceiveBufferFlush(_configData.serialCom - 1); + comReceiveBufferFlush(__configData.serialCom - 1); // Show dialing, dial service. - widgetVisibleSet(W(picDialing), 1); + widgetVisibleSet(W(_picDialing), 1); taskYield(); - snprintf(buffer, 1023, "ATDT%s:%d%c", _configData.serverHost, _configData.serverPort, 13); - comWrite(_configData.serialCom - 1, buffer, strlen(buffer)); + snprintf(buffer, 1023, "ATDT%s:%d%c", __configData.serverHost, __configData.serverPort, 13); + comWrite(__configData.serialCom - 1, buffer, strlen(buffer)); // Wait 7 seconds for welcome banner. - r = comWaitWithTimeout(_configData.serialCom - 1, buffer, 1023, 4 * 7, "KPMPGSMKII\r"); + r = comWaitWithTimeout(__configData.serialCom - 1, buffer, 1023, 4 * 7, "KPMPGSMKII\r"); if (r <= 0) { - comClose(_configData.serialCom - 1); + comClose(__configData.serialCom - 1); msgBoxOne("No Connection", MSGBOX_ICON_INFORMATION, "Unable to connect to server!\nPlease check settings or try later.", "Okay", btnMsgBox); return; } // Connected! Show icon and negotiate session. - widgetVisibleSet(W(picConnect), 1); + widgetVisibleSet(W(_picConnect), 1); taskYield(); } @@ -150,9 +150,9 @@ static void btnSettingsClick(WidgetT *widget) { void setButtons(uint8_t enabled) { - widgetEnableSet(W(btnConnect), (_configData.serialCom > 0 && strlen(_configData.serverHost) > 2) ? enabled : 0); - widgetEnableSet(W(btnSettings), enabled); - widgetEnableSet(W(btnQuit), enabled); + widgetEnableSet(W(_btnConnect), (__configData.serialCom > 0 && strlen(__configData.serverHost) > 2) ? enabled : 0); + widgetEnableSet(W(_btnSettings), enabled); + widgetEnableSet(W(_btnQuit), enabled); } @@ -170,47 +170,47 @@ void taskWelcome(void *data) { TagItemT uiWelcome[] = { T_START, - T_WINDOW, O(winWelcome), + T_WINDOW, O(_winWelcome), T_TITLE, P("Welcome to KangaWorld!"), T_WIDTH, 500, T_HEIGHT, 225, - T_PICTURE, O(picLogo), + T_PICTURE, O(_picLogo), T_FILENAME, P("data/logo.png"), T_X, 18, T_Y, 18, T_PICTURE, T_DONE, - T_PICTURE, O(picInit), + T_PICTURE, O(_picInit), T_FILENAME, P("data/dinit.png"), T_X, 18, T_Y, 18, T_VISIBLE, T_FALSE, T_PICTURE, T_DONE, - T_PICTURE, O(picDialing), + T_PICTURE, O(_picDialing), T_FILENAME, P("data/ddialing.png"), T_X, 179, T_Y, 18, T_VISIBLE, T_FALSE, T_PICTURE, T_DONE, - T_PICTURE, O(picConnect), + T_PICTURE, O(_picConnect), T_FILENAME, P("data/dconnect.png"), T_X, 339, T_Y, 18, T_VISIBLE, T_FALSE, T_PICTURE, T_DONE, - T_BUTTON, O(btnQuit), + T_BUTTON, O(_btnQuit), T_TITLE, P("Quit"), T_X, 30, T_Y, 157, T_CLICK, P(btnQuitClick), T_BUTTON, T_DONE, - T_BUTTON, O(btnSettings), + T_BUTTON, O(_btnSettings), T_TITLE, P("Settings"), T_X, 201, T_Y, 157, T_CLICK, P(btnSettingsClick), T_BUTTON, T_DONE, - T_BUTTON, O(btnConnect), + T_BUTTON, O(_btnConnect), T_TITLE, P("Connect"), T_X, 379, T_Y, 157, T_CLICK, P(taskProxy), T_USER_DATA, P(taskConnectClick), - T_ENABLED, (_configData.serialCom > 0 && strlen(_configData.serverHost) > 2) ? T_TRUE : T_FALSE, + T_ENABLED, (__configData.serialCom > 0 && strlen(__configData.serverHost) > 2) ? T_TRUE : T_FALSE, T_BUTTON, T_DONE, T_WINDOW, T_DONE, diff --git a/test.conf b/test.conf index e372484..68770e3 100644 --- a/test.conf +++ b/test.conf @@ -193,8 +193,8 @@ convergence = 0 # cycledown: Setting it lower than 100 will be a percentage. core = auto -cputype = auto -cycles = auto +cputype = 486 +cycles = 5000 cycleup = 10 cycledown = 20 @@ -438,7 +438,7 @@ deadzone = 10 # Possible values: dummy, disabled, modem, nullmodem, directserial. # phonebookfile: File used to map fake phone numbers to addresses. -serial1 = modem listenport:8192 +serial1 = modem listenport:8192 sock:1 serial2 = dummy serial3 = disabled serial4 = disabled