| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/lib/gameos.h $ |
| 21 | * $Revision: 3 $ |
| 22 | * $Date: 7/28/99 3:24p $ |
| 23 | * $Author: Kevin $ |
| 24 | * |
| 25 | * Operating system management library |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/lib/gameos.h $ |
| 28 | * |
| 29 | * 3 7/28/99 3:24p Kevin |
| 30 | * Mac |
| 31 | * |
| 32 | * 2 5/10/99 10:53p Ardussi |
| 33 | * changes to compile on Mac |
| 34 | * |
| 35 | * 17 3/14/97 6:11 PM Jeremy |
| 36 | * added get_user_name to osDatabase |
| 37 | * |
| 38 | * 16 3/14/97 4:15p Matt |
| 39 | * Changed title of OutrageMessageBox() dialogs |
| 40 | * |
| 41 | * 15 3/13/97 11:04a Samir |
| 42 | * Took out file functions. Kept console because the OS must initialize |
| 43 | * the console before doing anything else to report messages. |
| 44 | * |
| 45 | * 14 3/10/97 11:13a Samir |
| 46 | * Changes made to reflect deletion of OSDebug class from system |
| 47 | * |
| 48 | * 13 3/04/97 1:00p Samir |
| 49 | * Fixed return type prototype errors. |
| 50 | * |
| 51 | * 12 3/04/97 12:54p Samir |
| 52 | * Added type constants for message boxes. |
| 53 | * |
| 54 | * 11 3/03/97 3:12p Samir |
| 55 | * Fixed GetWorkingDir prototype. |
| 56 | * |
| 57 | * 10 3/03/97 1:16p Samir |
| 58 | * Added some file operations |
| 59 | * |
| 60 | * 9 2/28/97 11:04a Samir |
| 61 | * Use a generic structure to pass in init info instead of params. |
| 62 | * |
| 63 | * 8 2/27/97 5:26 PM Jeremy |
| 64 | * removed mac\oemac_os.h and replaced it with #include "oemac_os.h" |
| 65 | * because the mac compiler doesn't need the path and the "\" doesn't work |
| 66 | * anyway. mac path delimiter is a ":" |
| 67 | * |
| 68 | * 7 2/26/97 7:36p Samir |
| 69 | * include oexxx_os.h from mac or win directories. |
| 70 | * |
| 71 | * 6 2/26/97 7:05p Samir |
| 72 | * debug_break function in osObject. |
| 73 | * |
| 74 | * 5 2/04/97 5:03p Samir |
| 75 | * Adjusted create to take out code_write parm |
| 76 | * |
| 77 | * 4 1/30/97 6:07p Samir |
| 78 | * A more object oriented approach to our OS library |
| 79 | * |
| 80 | * $NoKeywords: $ |
| 81 | */ |
| 82 | #ifndef GAMEOS_H |
| 83 | #define GAMEOS_H |
| 84 | #include "pstypes.h" |
| 85 | struct gameos_packet { |
| 86 | int code; |
| 87 | unsigned time_stamp; |
| 88 | }; |
| 89 | |
| 90 | const int GAMEOS_QUIT = 1, // This gameos object is shutting down |
| 91 | GAMEOS_IDLE = 2, // currently idle. |
| 92 | GAMEOS_UNKNOWN = 255; // Unknown message |
| 93 | /* class osObject |
| 94 | contains code to initialize all the OS dependent info and structures for an application |
| 95 | this class should be the parent of a class created by the programmer to match the |
| 96 | platform he's developing on. i.e. there should be a osWinObject for the Win32 version, |
| 97 | and must have all the functionality of this base Class. |
| 98 | */ |
| 99 | class osObject { |
| 100 | protected: |
| 101 | bool m_Init, m_Created; // did we initialize this object or created and init. |
| 102 | osObject *m_ParentOS; // determines if this is a parent process |
| 103 | virtual void os_init() = 0; // os specific initialization |
| 104 | |
| 105 | public: |
| 106 | osObject() { |
| 107 | m_Init = 0; |
| 108 | m_Created = 0; |
| 109 | }; |
| 110 | virtual ~osObject(){}; |
| 111 | |
| 112 | // parent_os is the osObject that is the parent of this new object. |
| 113 | // info is a device dependent structure passed in using device independent parms. |
| 114 | virtual void init(osObject *parent_os, void *info) = 0; |
| 115 | virtual bool create(osObject *parent_os, void *info) = 0; |
| 116 | // returns a packet with a code telling us either to quit or that we are in some |
| 117 | // sort of idle state, which means we perform tasks like a game. |
| 118 | virtual gameos_packet *defer() = 0; // defers game operation to OS. |
| 119 | virtual void get_info(void *info, int size_str) = 0; |
| 120 | }; |
| 121 | /* osDatabase |
| 122 | to get info about the application from an OS managed database (or a custom info file) |
| 123 | Again, this class should be the parent of a OS specific class like osWinDatabase, for instance. |
| 124 | */ |
| 125 | class osDatabase { |
| 126 | public: |
| 127 | osDatabase(){}; |
| 128 | virtual ~osDatabase(){}; |
| 129 | virtual bool init() = 0; |
| 130 | // creates an empty classification or structure where you can store information |
| 131 | virtual bool create_record(const char *pathname) = 0; |
| 132 | // set current database focus to a particular record |
| 133 | virtual bool lookup_record(const char *pathname) = 0; |
| 134 | // read either an integer or string from the current record |
| 135 | virtual bool read(const char *label, char *entry, int *entrylen) = 0; |
| 136 | virtual bool read(const char *label, int *entry) = 0; |
| 137 | // write either an integer or string to a record. |
| 138 | virtual bool write(const char *label, char *entry, int entrylen) = 0; |
| 139 | virtual bool write(const char *label, int *entry) = 0; |
| 140 | |
| 141 | // get the current user's name from the os |
| 142 | virtual void get_user_name(char *buffer, size_t *size) = 0; |
| 143 | }; |
| 144 | // Data structures |
| 145 | struct os_date { |
| 146 | uint16_t year; // 1-65535 A.D. (or C.E.) |
| 147 | uint8_t month; |
| 148 | uint8_t day; |
| 149 | uint8_t hour; |
| 150 | uint8_t min; |
| 151 | uint8_t sec; |
| 152 | uint8_t pad; // to keep dword aligned |
| 153 | }; |
| 154 | // --------------------------------------------------------------------------- |
| 155 | // Debug system functions |
| 156 | // --------------------------------------------------------------------------- |
| 157 | #define OSMBOX_OK 1 |
| 158 | #define OSMBOX_YESNO 2 |
| 159 | bool os_ErrorBox(const char *str); // displays an error message on the screen |
| 160 | int os_MessageBox(int type, const char *title, const char *str); |
| 161 | bool os_ConsoleInit(); |
| 162 | void os_ConsoleOpen(int n, int row, int col, int width, int height, char *title); |
| 163 | void os_ConsoleClose(int n); |
| 164 | void os_ConsolePrintf(int n, char *format, ...); |
| 165 | void os_ConsolePrintf(int n, int row, int col, char *format, ...); |
| 166 | // --------------------------------------------------------------------------- |
| 167 | // Operating system includes |
| 168 | // --------------------------------------------------------------------------- |
| 169 | // #if defined(WIN32) |
| 170 | // #include "win\oewin_os.h" |
| 171 | // #endif |
| 172 | #endif |