167 lines
4.3 KiB
C
167 lines
4.3 KiB
C
/*
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
|
|
/*
|
|
* To Do:
|
|
*
|
|
* - Replace any direct data manipulation from outside a class with methods to handle it
|
|
* - More widget states: Ghosted (underway), 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
|
|
* - Layout container widgets!
|
|
* - DOS makefile is placing thirdparty object files in the wrong place
|
|
*/
|
|
|
|
|
|
#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 "config.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;
|
|
int8_t key = 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 == '=') guiDebugWidgetTreeDump(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[]) {
|
|
|
|
memoryStartup(argv[0]);
|
|
logOpenByHandle(memoryLogHandleGet());
|
|
configStartup(argv[0]);
|
|
|
|
// 0 1 2 3 4 5 6 7 8
|
|
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
logWrite("%s", "Kangaroo Punch MultiPlayer DOS Game Client Mark II\n");
|
|
logWrite("%s", "Copyright (C) 2020-2021 Scott Duensing scott@kangaroopunch.com\n\n");
|
|
|
|
if (argc > 1) {
|
|
if (strcmp(argv[1], "/?") == 0) {
|
|
vbeInfoShow();
|
|
configShutdown();
|
|
logClose();
|
|
memoryShutdown();
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
// Do we have the video mode they asked for?
|
|
if (vbeStartup(_configData.videoWidth, _configData.videoHeight, _configData.videoDepth)) {
|
|
configShutdown();
|
|
logClose();
|
|
memoryShutdown();
|
|
return 1;
|
|
}
|
|
|
|
surfaceStartup();
|
|
mouseStartup();
|
|
timerStartup();
|
|
guiStartup();
|
|
taskStartup();
|
|
|
|
#ifdef TESTING
|
|
taskCreate(comPortScanTest, NULL);
|
|
#else
|
|
taskCreate(taskWelcome, NULL);
|
|
taskCreate(taskGuiEventLoop, NULL);
|
|
#endif
|
|
|
|
taskRun();
|
|
|
|
taskShutdown();
|
|
guiShutdown();
|
|
timerShutdown();
|
|
mouseShutdown();
|
|
surfaceShutdown();
|
|
vbeShutdown();
|
|
configShutdown();
|
|
logClose();
|
|
memoryShutdown();
|
|
|
|
return 0;
|
|
}
|