/* * Kangaroo Punch MultiPlayer Game Server Mark II * Copyright (C) 2020-2021 Scott Duensing * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ //#define TESTING /* * To Do: * * - Replace any direct data manipulation from outside a class with methods to handle it * - More widget states: Ghosted, hidden * - Methods that can change the width of a widget (such as setTitle) need to repaint the parent window as well * - Metrics, colors, etc. should be defined in each widget and not in GUI * - Widgets should support a "changed" callback that can cancel the change * - Use LabelT in all widgets that have a label * - Find a light grey to replace white widget data areas * - No thumb in listbox scrollbar * * - Random crash on exit - looks memwatch / task related - hasn't happened on DOS yet */ #include "stddclmr.h" #include "os.h" #include "vesa.h" #include "surface.h" #include "mouse.h" #include "keyboard.h" #include "task.h" #include "image.h" #include "font.h" #include "timer.h" #include "gui.h" #include "welcome.h" #ifdef TESTING #include "test.h" #endif static void taskGuiEventLoop(void *data); static void taskGuiEventLoop(void *data) { MouseT *mouse = NULL; ImageT *pointer = NULL; ColorT alpha; #ifdef TESTING int8_t debugState = 0; #endif (void)data; pointer = imageLoad("mouse.png"); alpha = imagePixelGet(pointer, 5, 0); do { timerUpdate(); mouse = mouseRead(); if (keyHit()) { #ifdef TESTING lastKey = keyASCIIGet(); //***DEBUG*** #endif guiKeyboardProcess(keyASCIIGet(), keyExtendedGet(), keyScanCodeGet(), keyShiftGet(), keyControlGet(), keyAltGet()); //logWrite("Key '%d' Extended '%d' Scancode '%d' Shift '%d' Control '%d' Alt '%d'\n", keyASCIIGet(), keyExtended(), keyScanCode(), keyShift(), keyControl(), keyAlt()); } guiMouseProcess(mouse); guiComposite(); imageRenderWithAlpha(pointer, mouse->x, mouse->y, alpha); #ifdef TESTING if (key == '=') guiWidgetTreeDump(guiRootGet(), 0); if (key == '+') { debugState++; if (debugState > 2) debugState = 0; } if (debugState > 0) widgetDebugDraw(guiRootGet(), debugState - 1); //if (timerHalfSecondOn) guiDrawRectangle(0, 0, vbeSurfaceWidthGet() - 1, vbeSurfaceHeightGet() - 1, vbeMakeColor(255, 255, 255)); #endif vbeVBlankWait(); vbePresent(); taskYield(); #ifdef TESTING } while (key != 27); // Exit on ESC. #else } while (!guiHasStopped()); #endif imageUnload(&pointer); } int main(int argc, char *argv[]) { uint16_t xResolution = 0; uint16_t yResolution = 0; uint16_t colorDepth = 0; memoryStartup(argv[0]); logOpenByHandle(memoryLogHandleGet()); // 0 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 printf("Kangaroo Punch MultiPlayer DOS Game Client Mark II\n"); printf("Copyright (C) 2020-2021 Scott Duensing scott@kangaroopunch.com\n\n"); fflush(stdout); // Command line needs to have the desired resolution and color depth on it. if (argc != 4) { vbeInfoShow(); fflush(stdout); memoryShutdown(); return 0; } xResolution = atoi(argv[1]); yResolution = atoi(argv[2]); colorDepth = atoi(argv[3]); // Do we have the video mode they asked for? if (vbeStartup(xResolution, yResolution, colorDepth)) { fflush(stdout); memoryShutdown(); return 1; } surfaceStartup(); mouseStartup(); timerStartup(); guiStartup(); taskStartup(); #ifdef TESTING taskCreate(taskTestTagList, NULL); #else taskCreate(taskWelcome, NULL); #endif taskCreate(taskGuiEventLoop, NULL); taskRun(); taskShutdown(); guiShutdown(); timerShutdown(); mouseShutdown(); surfaceShutdown(); vbeShutdown(); logClose(); memoryShutdown(); return 0; }