├── main ├── input.h ├── font_8x16.h ├── display.h ├── font_8x16.c ├── usb_hid.h ├── idf_component.yml ├── eth_connect.h ├── CMakeLists.txt ├── main.c ├── audio.c └── input.c ├── components ├── hid_ev │ ├── libusbhid │ │ ├── .gitignore │ │ ├── usb_hid_usages │ │ ├── usage_tables.h │ │ ├── usbvar.h │ │ ├── descr.c │ │ ├── data.c │ │ └── usbhid.h │ ├── CMakeLists.txt │ └── hid_ev.h └── quakegeneric │ ├── quakegeneric │ ├── clean.sh │ ├── .github │ │ └── quakegeneric.png │ ├── .editorconfig │ ├── meson │ │ ├── linux-x86-cross.txt │ │ └── windows-x86-cross.txt │ ├── build-cmake.sh │ ├── build-meson.sh │ ├── .gitignore │ ├── source │ │ ├── crc.h │ │ ├── cdaudio.h │ │ ├── view.h │ │ ├── menu.h │ │ ├── quakegeneric_null.c │ │ ├── input.h │ │ ├── quakegeneric.c │ │ ├── r_vars.c │ │ ├── keys.h │ │ ├── net_none.c │ │ ├── net_loop.h │ │ ├── d_zpoint.c │ │ ├── sbar.h │ │ ├── net_vcr.h │ │ ├── nonintel.c │ │ ├── net_dgrm.h │ │ ├── makefile.wat │ │ ├── cd_null.c │ │ ├── makefile.win │ │ ├── draw.h │ │ ├── console.h │ │ ├── d_vars.c │ │ ├── net_udp.h │ │ ├── screen.h │ │ ├── quakegeneric.h │ │ ├── wad.h │ │ ├── sys.h │ │ ├── d_fill.c │ │ ├── makefile │ │ ├── net_bsd.c │ │ ├── quakegeneric_dos.c │ │ ├── d_modech.c │ │ ├── chase.c │ │ ├── vid.h │ │ ├── world.h │ │ ├── mathlib.h │ │ ├── d_ifacea.h │ │ ├── vid_null.c │ │ ├── quakekeys.h │ │ ├── spritegn.h │ │ ├── d_local.h │ │ ├── modelgen.h │ │ ├── crc.c │ │ ├── cvar.h │ │ ├── zone.h │ │ ├── d_sky.c │ │ ├── d_init.c │ │ ├── pr_comp.h │ │ ├── progdefs.h │ │ ├── wad.c │ │ ├── net_vcr.c │ │ ├── progs.h │ │ ├── d_part.c │ │ ├── r_sky.c │ │ ├── cmd.h │ │ ├── cvar.c │ │ ├── sys_null.c │ │ ├── protocol.h │ │ ├── render.h │ │ ├── r_shared.h │ │ ├── sound.h │ │ └── common.h │ ├── meson.build │ ├── README.md │ └── CMakeLists.txt │ └── CMakeLists.txt ├── .gitignore ├── partitions.csv ├── CMakeLists.txt └── sdkconfig.defaults /main/input.h: -------------------------------------------------------------------------------- 1 | 2 | void input_init(); 3 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/.gitignore: -------------------------------------------------------------------------------- 1 | a.out 2 | -------------------------------------------------------------------------------- /main/font_8x16.h: -------------------------------------------------------------------------------- 1 | extern const unsigned char fontdata_8x16[4096]; -------------------------------------------------------------------------------- /main/display.h: -------------------------------------------------------------------------------- 1 | 2 | void display_init(); 3 | void display_quit(); -------------------------------------------------------------------------------- /main/font_8x16.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp32-quake/HEAD/main/font_8x16.c -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | managed_components 3 | sdkconfig.old 4 | sdkconfig 5 | dependencies.lock 6 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf cmake-build 4 | rm -rf meson-build 5 | -------------------------------------------------------------------------------- /main/usb_hid.h: -------------------------------------------------------------------------------- 1 | #include "hid_ev.h" 2 | 3 | void usb_hid_task(); 4 | int usb_hid_receive_hid_event(hid_ev_t *ev); 5 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/usb_hid_usages: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp32-quake/HEAD/components/hid_ev/libusbhid/usb_hid_usages -------------------------------------------------------------------------------- /main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/esp32_p4_function_ev_board_noglib: "^4.1.0" 4 | usb_host_hid: "^1.0.1" 5 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/.github/quakegeneric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp32-quake/HEAD/components/quakegeneric/quakegeneric/.github/quakegeneric.png -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | -------------------------------------------------------------------------------- /partitions.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs,data,nvs,0x9000,24K, 4 | phy_init,data,phy,0xf000,4K, 5 | factory,app,factory,0x10000,4000K, 6 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/meson/linux-x86-cross.txt: -------------------------------------------------------------------------------- 1 | [binaries] 2 | c = 'gcc' 3 | cpp = 'g++' 4 | ar = 'ar' 5 | strip = 'strip' 6 | 7 | [host_machine] 8 | system = 'linux' 9 | cpu_family = 'x86' 10 | cpu = 'x86' 11 | endian = 'little' 12 | -------------------------------------------------------------------------------- /components/hid_ev/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "hid_ev.c" 2 | "libusbhid/descr.c" "libusbhid/parse.c" 3 | "libusbhid/usage_tables.c" "libusbhid/data.c" 4 | INCLUDE_DIRS "." 5 | PRIV_INCLUDE_DIRS "libusbhid") 6 | 7 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/build-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -d cmake-build ] 4 | then 5 | mkdir cmake-build 6 | fi 7 | 8 | cd cmake-build 9 | 10 | if $1 11 | then 12 | cmake -D CMAKE_TOOLCHAIN_FILE=$1 .. 13 | else 14 | cmake .. 15 | fi 16 | 17 | make 18 | cd .. 19 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/build-meson.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -d meson-build ] 4 | then 5 | mkdir meson-build 6 | fi 7 | 8 | if $1 9 | then 10 | meson setup --cross-file $1 meson-build 11 | else 12 | meson setup meson-build 13 | fi 14 | 15 | cd meson-build 16 | meson compile 17 | cd .. 18 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/meson/windows-x86-cross.txt: -------------------------------------------------------------------------------- 1 | [binaries] 2 | c = 'i686-w64-mingw32-gcc' 3 | cpp = 'i686-w64-mingw32-g++' 4 | ar = 'i686-w64-mingw32-ar' 5 | strip = 'i686-w64-mingw32-strip' 6 | 7 | [host_machine] 8 | system = 'windows' 9 | cpu_family = 'x86' 10 | cpu = 'x86' 11 | endian = 'little' 12 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/usage_tables.h: -------------------------------------------------------------------------------- 1 | 2 | typedef struct { 3 | int usage; 4 | const char *name; 5 | } hid_usage_page_t; 6 | 7 | typedef struct { 8 | int page; 9 | int usage; 10 | const char *name; 11 | } hid_usage_t; 12 | 13 | 14 | extern const hid_usage_page_t hid_usage_pages[]; 15 | extern const hid_usage_t hid_usage[]; 16 | -------------------------------------------------------------------------------- /main/eth_connect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Unlicense OR CC0-1.0 5 | */ 6 | #pragma once 7 | 8 | #include "esp_eth_driver.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void ethernet_connect(); 15 | 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.16) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(quake) 9 | -------------------------------------------------------------------------------- /main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "main.c" "usb_hid.c" "audio.c" "cd_cue.c" 2 | "eth_connect.c" "font_8x16.c" "input.c" "display.c" 3 | INCLUDE_DIRS ".") 4 | 5 | #hack: otherwise audio.c is not linked 6 | #should actually factor refactor all things called by quake into a separate component 7 | target_link_libraries(${COMPONENT_LIB} INTERFACE "-u snd_inited -u CDAudio_Init") -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # local files 3 | .local/ 4 | 5 | # vs code 6 | .vscode/ 7 | *.code-workspace 8 | 9 | # objects 10 | source/quakegeneric 11 | 12 | # game data 13 | source/id1/ 14 | 15 | # object files 16 | *.o 17 | *.exe 18 | *.a 19 | *.obj 20 | *.rsp 21 | *.err 22 | 23 | # vim 24 | *.swp 25 | 26 | # cscope 27 | cscope.in.out 28 | cscope.out 29 | cscope.po.out 30 | 31 | # dosbox-x 32 | dosbox-x.* 33 | 34 | # cmake 35 | cmake-build* 36 | 37 | # meson 38 | meson-build* 39 | -------------------------------------------------------------------------------- /sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 2 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 3 | CONFIG_PARTITION_TABLE_CUSTOM=y 4 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 5 | # CONFIG_ETH_USE_SPI_ETHERNET is not set 6 | CONFIG_SPIRAM=y 7 | CONFIG_SPIRAM_SPEED_200M=y 8 | CONFIG_SPIRAM_XIP_FROM_PSRAM=y 9 | # CONFIG_SPIRAM_MEMTEST is not set 10 | CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y 11 | CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y 12 | CONFIG_CACHE_L2_CACHE_256KB=y 13 | CONFIG_CACHE_L2_CACHE_LINE_128B=y 14 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 15 | CONFIG_ESP_CONSOLE_SECONDARY_NONE=y 16 | # CONFIG_ESP_TASK_WDT_EN is not set 17 | CONFIG_ESP_PANIC_HANDLER_IRAM=y 18 | CONFIG_FATFS_LFN_STACK=y 19 | CONFIG_LWIP_IP4_REASSEMBLY=y 20 | CONFIG_LWIP_IP6_REASSEMBLY=y 21 | CONFIG_LWIP_IP_REASS_MAX_PBUFS=30 22 | CONFIG_USB_HOST_HUBS_SUPPORTED=y 23 | CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS=y 24 | # CONFIG_BSP_ERROR_CHECK is not set 25 | CONFIG_BSP_LCD_DPI_BUFFER_NUMS=2 26 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 27 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* crc.h */ 21 | 22 | void CRC_Init(unsigned short *crcvalue); 23 | void CRC_ProcessByte(unsigned short *crcvalue, byte data); 24 | unsigned short CRC_Value(unsigned short crcvalue); 25 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/cdaudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | int CDAudio_Init(void); 22 | void CDAudio_Play(byte track, qboolean looping); 23 | void CDAudio_Stop(void); 24 | void CDAudio_Pause(void); 25 | void CDAudio_Resume(void); 26 | void CDAudio_Shutdown(void); 27 | void CDAudio_Update(void); 28 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/view.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // view.h 21 | 22 | extern cvar_t v_gamma; 23 | 24 | extern byte gammatable[256]; // palette is sent through this 25 | extern byte ramps[3][256]; 26 | extern float v_blend[4]; 27 | 28 | extern cvar_t lcd_x; 29 | 30 | 31 | void V_Init (void); 32 | void V_RenderView (void); 33 | float V_CalcRoll (vec3_t angles, vec3_t velocity); 34 | void V_UpdatePalette (void); 35 | 36 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // 22 | // the net drivers should just set the apropriate bits in m_activenet, 23 | // instead of having the menu code look through their internal tables 24 | // 25 | #define MNET_IPX 1 26 | #define MNET_TCP 2 27 | 28 | extern int m_activenet; 29 | 30 | // 31 | // menus 32 | // 33 | void M_Init (void); 34 | void M_Keydown (int key); 35 | void M_Draw (void); 36 | void M_ToggleMenu_f (void); 37 | 38 | 39 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/quakegeneric_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #include "quakegeneric.h" 22 | 23 | void QG_Init(void) 24 | { 25 | 26 | } 27 | 28 | int QG_GetKey(int *down, int *key) 29 | { 30 | return 0; 31 | } 32 | 33 | void QG_Quit(void) 34 | { 35 | 36 | } 37 | 38 | void QG_DrawFrame(void *pixels) 39 | { 40 | 41 | } 42 | 43 | void QG_SetPalette(unsigned char palette[768]) 44 | { 45 | 46 | } 47 | 48 | int main(int argc, char *argv[]) 49 | { 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // input.h -- external (non-keyboard) input devices 21 | 22 | void IN_Init (void); 23 | 24 | void IN_Shutdown (void); 25 | 26 | void IN_Commands (void); 27 | // oportunity for devices to stick commands on the script buffer 28 | 29 | void IN_Move (usercmd_t *cmd); 30 | // add additional movement on top of the keyboard move cmd 31 | 32 | void IN_ClearStates (void); 33 | // restores all button and position states to defaults 34 | 35 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/quakegeneric.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #include "quakedef.h" 22 | 23 | void QG_Tick(double duration) 24 | { 25 | Host_Frame(duration); 26 | } 27 | 28 | void QG_Create(int argc, char *argv[]) 29 | { 30 | static quakeparms_t parms; 31 | 32 | parms.memsize = 20*1024*1024; 33 | parms.membase = malloc (parms.memsize); 34 | parms.basedir = "."; 35 | 36 | COM_InitArgv (argc, argv); 37 | 38 | parms.argc = com_argc; 39 | parms.argv = com_argv; 40 | 41 | printf ("Host_Init\n"); 42 | Host_Init (&parms); 43 | } 44 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/r_vars.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // r_vars.c: global refresh variables 21 | 22 | #include "quakedef.h" 23 | 24 | // all global and static refresh variables are collected in a contiguous block 25 | // to avoid cache conflicts. 26 | 27 | //------------------------------------------------------- 28 | // global refresh variables 29 | //------------------------------------------------------- 30 | 31 | // FIXME: make into one big structure, like cl or sv 32 | // FIXME: do separately for refresh engine and driver 33 | 34 | int r_bmodelactive; 35 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/keys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | 22 | #include "quakekeys.h" 23 | 24 | typedef enum {key_game, key_console, key_message, key_menu} keydest_t; 25 | 26 | extern keydest_t key_dest; 27 | extern char *keybindings[256]; 28 | extern int key_repeats[256]; 29 | extern int key_count; // incremented every key event 30 | extern int key_lastpress; 31 | 32 | void Key_Event (int key, qboolean down); 33 | void Key_Init (void); 34 | void Key_WriteBindings (FILE *f); 35 | void Key_SetBinding (int keynum, char *binding); 36 | void Key_ClearStates (void); 37 | 38 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/net_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | #include "quakedef.h" 21 | 22 | #include "net_loop.h" 23 | 24 | net_driver_t net_drivers[MAX_NET_DRIVERS] = 25 | { 26 | { 27 | "Loopback", 28 | false, 29 | Loop_Init, 30 | Loop_Listen, 31 | Loop_SearchForHosts, 32 | Loop_Connect, 33 | Loop_CheckNewConnections, 34 | Loop_GetMessage, 35 | Loop_SendMessage, 36 | Loop_SendUnreliableMessage, 37 | Loop_CanSendMessage, 38 | Loop_CanSendUnreliableMessage, 39 | Loop_Close, 40 | Loop_Shutdown 41 | } 42 | }; 43 | int net_numdrivers = 1; 44 | 45 | net_landriver_t net_landrivers[MAX_NET_DRIVERS]; 46 | int net_numlandrivers = 0; 47 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/net_loop.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_loop.h 21 | 22 | int Loop_Init (void); 23 | void Loop_Listen (qboolean state); 24 | void Loop_SearchForHosts (qboolean xmit); 25 | qsocket_t *Loop_Connect (char *host); 26 | qsocket_t *Loop_CheckNewConnections (void); 27 | int Loop_GetMessage (qsocket_t *sock); 28 | int Loop_SendMessage (qsocket_t *sock, sizebuf_t *data); 29 | int Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data); 30 | qboolean Loop_CanSendMessage (qsocket_t *sock); 31 | qboolean Loop_CanSendUnreliableMessage (qsocket_t *sock); 32 | void Loop_Close (qsocket_t *sock); 33 | void Loop_Shutdown (void); 34 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_zpoint.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_zpoint.c: software driver module for drawing z-buffered points 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | 26 | /* 27 | ===================== 28 | D_DrawZPoint 29 | ===================== 30 | */ 31 | void D_DrawZPoint (void) 32 | { 33 | byte *pdest; 34 | short *pz; 35 | int izi; 36 | 37 | pz = d_pzbuffer + (d_zwidth * r_zpointdesc.v) + r_zpointdesc.u; 38 | pdest = d_viewbuffer + d_scantable[r_zpointdesc.v] + r_zpointdesc.u; 39 | izi = (int)(r_zpointdesc.zi * 0x8000); 40 | 41 | if (*pz <= izi) 42 | { 43 | *pz = izi; 44 | *pdest = r_zpointdesc.color; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/sbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // the status bar is only redrawn if something has changed, but if anything 22 | // does, the entire thing will be redrawn for the next vid.numpages frames. 23 | 24 | #define SBAR_HEIGHT 24 25 | 26 | extern int sb_lines; // scan lines to draw 27 | 28 | void Sbar_Init (void); 29 | 30 | void Sbar_Changed (void); 31 | // call whenever any of the client stats represented on the sbar changes 32 | 33 | void Sbar_Draw (void); 34 | // called every frame by screen 35 | 36 | void Sbar_IntermissionOverlay (void); 37 | // called each frame after the level has been completed 38 | 39 | void Sbar_FinaleOverlay (void); 40 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/net_vcr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_vcr.h 21 | 22 | #define VCR_OP_CONNECT 1 23 | #define VCR_OP_GETMESSAGE 2 24 | #define VCR_OP_SENDMESSAGE 3 25 | #define VCR_OP_CANSENDMESSAGE 4 26 | #define VCR_MAX_MESSAGE 4 27 | 28 | int VCR_Init (void); 29 | void VCR_Listen (qboolean state); 30 | void VCR_SearchForHosts (qboolean xmit); 31 | qsocket_t *VCR_Connect (char *host); 32 | qsocket_t *VCR_CheckNewConnections (void); 33 | int VCR_GetMessage (qsocket_t *sock); 34 | int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data); 35 | qboolean VCR_CanSendMessage (qsocket_t *sock); 36 | void VCR_Close (qsocket_t *sock); 37 | void VCR_Shutdown (void); 38 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/nonintel.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // nonintel.c: code for non-Intel processors only 22 | // 23 | 24 | #include "quakedef.h" 25 | #include "r_local.h" 26 | #include "d_local.h" 27 | 28 | /* 29 | ================ 30 | R_Surf8Patch 31 | ================ 32 | */ 33 | void R_Surf8Patch () 34 | { 35 | // we only patch code on Intel 36 | } 37 | 38 | 39 | /* 40 | ================ 41 | R_Surf16Patch 42 | ================ 43 | */ 44 | void R_Surf16Patch () 45 | { 46 | // we only patch code on Intel 47 | } 48 | 49 | 50 | /* 51 | ================ 52 | R_SurfacePatch 53 | ================ 54 | */ 55 | void R_SurfacePatch (void) 56 | { 57 | // we only patch code on Intel 58 | } 59 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/net_dgrm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_dgrm.h 21 | 22 | 23 | int Datagram_Init (void); 24 | void Datagram_Listen (qboolean state); 25 | void Datagram_SearchForHosts (qboolean xmit); 26 | qsocket_t *Datagram_Connect (char *host); 27 | qsocket_t *Datagram_CheckNewConnections (void); 28 | int Datagram_GetMessage (qsocket_t *sock); 29 | int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data); 30 | int Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data); 31 | qboolean Datagram_CanSendMessage (qsocket_t *sock); 32 | qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock); 33 | void Datagram_Close (qsocket_t *sock); 34 | void Datagram_Shutdown (void); 35 | -------------------------------------------------------------------------------- /components/hid_ev/hid_ev.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef enum { 6 | HIDEV_EVENT_KEY_DOWN = 0, 7 | HIDEV_EVENT_KEY_UP, 8 | HIDEV_EVENT_JOY_BUTTONDOWN, 9 | HIDEV_EVENT_JOY_BUTTONUP, 10 | HIDEV_EVENT_JOY_AXIS, 11 | HIDEV_EVENT_JOY_HAT, 12 | HIDEV_EVENT_MOUSE_BUTTONDOWN, 13 | HIDEV_EVENT_MOUSE_BUTTONUP, 14 | HIDEV_EVENT_MOUSE_MOTION, 15 | HIDEV_EVENT_MOUSE_WHEEL 16 | } hidev_event_type_en; 17 | 18 | typedef struct { 19 | int keycode; 20 | } hidev_ev_key_t; 21 | 22 | typedef struct { 23 | int pos; 24 | } hidev_ev_joyaxis_t; 25 | 26 | typedef struct { 27 | int pos; 28 | } hidev_ev_joyhat_t; 29 | 30 | typedef struct { 31 | int dx; 32 | int dy; 33 | } hidev_ev_mouse_motion_t; 34 | 35 | typedef struct { 36 | int d; 37 | } hidev_ev_mouse_wheel_t; 38 | 39 | typedef struct { 40 | hidev_event_type_en type; 41 | int device_id; 42 | int no; //the how-many-th one of this type this event is about (button4 has no==4) 43 | union { 44 | hidev_ev_key_t key; 45 | hidev_ev_joyaxis_t joyaxis; 46 | hidev_ev_joyhat_t joyhat; 47 | hidev_ev_mouse_motion_t mouse_motion; 48 | hidev_ev_mouse_wheel_t mouse_wheel; 49 | }; 50 | } hid_ev_t; 51 | 52 | typedef void(hidev_event_cb_t)(hid_ev_t *event); 53 | 54 | typedef struct hidev_device_t hidev_device_t; 55 | 56 | hidev_device_t *hidev_device_from_descriptor(uint8_t *descriptor, int descriptor_len, int device_id, hidev_event_cb_t *cb); 57 | void hidev_parse_report(hidev_device_t *dev, uint8_t *report, int report_id); 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/makefile.wat: -------------------------------------------------------------------------------- 1 | CC=wcc386 2 | 3 | CFLAGS=-omaxnet -zp4 -5r -fp3 4 | 5 | OBJECTS=& 6 | cd_null.o& 7 | chase.o& 8 | cl_demo.o& 9 | cl_input.o& 10 | cl_main.o& 11 | cl_parse.o& 12 | cl_tent.o& 13 | cmd.o& 14 | common.o& 15 | console.o& 16 | crc.o& 17 | cvar.o& 18 | d_edge.o& 19 | d_fill.o& 20 | d_init.o& 21 | d_modech.o& 22 | d_part.o& 23 | d_polyse.o& 24 | d_scan.o& 25 | d_sky.o& 26 | d_sprite.o& 27 | d_surf.o& 28 | d_vars.o& 29 | d_zpoint.o& 30 | draw.o& 31 | host_cmd.o& 32 | host.o& 33 | in_null.o& 34 | keys.o& 35 | mathlib.o& 36 | menu.o& 37 | model.o& 38 | net_loop.o& 39 | net_main.o& 40 | net_none.o& 41 | net_vcr.o& 42 | nonintel.o& 43 | pr_cmds.o& 44 | pr_edict.o& 45 | pr_exec.o& 46 | r_aclip.o& 47 | r_alias.o& 48 | r_bsp.o& 49 | r_draw.o& 50 | r_edge.o& 51 | r_efrag.o& 52 | r_light.o& 53 | r_main.o& 54 | r_misc.o& 55 | r_part.o& 56 | r_sky.o& 57 | r_sprite.o& 58 | r_surf.o& 59 | r_vars.o& 60 | sbar.o& 61 | screen.o& 62 | snd_null.o& 63 | sv_main.o& 64 | sv_move.o& 65 | sv_phys.o& 66 | sv_user.o& 67 | sys_null.o& 68 | vid_null.o& 69 | view.o& 70 | wad.o& 71 | world.o& 72 | zone.o& 73 | quakegeneric.o& 74 | quakegeneric_dos.o 75 | 76 | .c.o: 77 | $(CC) $(CFLAGS) $*.c 78 | 79 | quakegeneric.exe: $(OBJECTS) wlink.rsp 80 | wlink @wlink.rsp 81 | 82 | wlink.rsp: makefile.wat 83 | echo name quakegeneric.exe >wlink.rsp 84 | echo system dos4g >>wlink.rsp 85 | echo option dosseg,caseexact,quiet,stack=64k >>wlink.rsp 86 | for %i in ($(OBJECTS)) do echo file %i >>wlink.rsp 87 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/cd_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | #include "quakedef.h" 21 | 22 | /* 23 | Note: The GOG release of the game includes the CDs as cue/gog (actually cue/bin) files 24 | which contains the raw audio as 16-bit signed LE 44100KHz audio. We can simply open those 25 | and use the track timecode to seek to the correct place, then play the track raw. 26 | */ 27 | 28 | void CDAudio_Play(byte track, qboolean looping) 29 | { 30 | } 31 | 32 | 33 | void CDAudio_Stop(void) 34 | { 35 | } 36 | 37 | 38 | void CDAudio_Pause(void) 39 | { 40 | } 41 | 42 | 43 | void CDAudio_Resume(void) 44 | { 45 | } 46 | 47 | 48 | void CDAudio_Update(void) 49 | { 50 | } 51 | 52 | 53 | int CDAudio_Init(void) 54 | { 55 | return 0; 56 | } 57 | 58 | 59 | void CDAudio_Shutdown(void) 60 | { 61 | } 62 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/makefile.win: -------------------------------------------------------------------------------- 1 | !include 2 | 3 | all: winquake.exe 4 | 5 | winquake.exe: cd_null.obj \ 6 | chase.obj \ 7 | cl_demo.obj \ 8 | cl_input.obj \ 9 | cl_main.obj \ 10 | cl_parse.obj \ 11 | cl_tent.obj \ 12 | cmd.obj \ 13 | common.obj \ 14 | console.obj \ 15 | crc.obj \ 16 | cvar.obj \ 17 | d_edge.obj \ 18 | d_fill.obj \ 19 | d_init.obj \ 20 | d_modech.obj \ 21 | d_part.obj \ 22 | d_polyse.obj \ 23 | d_scan.obj \ 24 | d_sky.obj \ 25 | d_sprite.obj \ 26 | d_surf.obj \ 27 | d_vars.obj \ 28 | d_zpoint.obj \ 29 | draw.obj \ 30 | host_cmd.obj \ 31 | host.obj \ 32 | in_null.obj \ 33 | keys.obj \ 34 | mathlib.obj \ 35 | menu.obj \ 36 | model.obj \ 37 | net_loop.obj \ 38 | net_main.obj \ 39 | net_none.obj \ 40 | net_vcr.obj \ 41 | nonintel.obj \ 42 | pr_cmds.obj \ 43 | pr_edict.obj \ 44 | pr_exec.obj \ 45 | r_aclip.obj \ 46 | r_alias.obj \ 47 | r_bsp.obj \ 48 | r_draw.obj \ 49 | r_edge.obj \ 50 | r_efrag.obj \ 51 | r_light.obj \ 52 | r_main.obj \ 53 | r_misc.obj \ 54 | r_part.obj \ 55 | r_sky.obj \ 56 | r_sprite.obj \ 57 | r_surf.obj \ 58 | r_vars.obj \ 59 | sbar.obj \ 60 | screen.obj \ 61 | snd_null.obj \ 62 | sv_main.obj \ 63 | sv_move.obj \ 64 | sv_phys.obj \ 65 | sv_user.obj \ 66 | sys_null.obj \ 67 | vid_null.obj \ 68 | view.obj \ 69 | wad.obj \ 70 | world.obj \ 71 | zone.obj \ 72 | quakegeneric.obj \ 73 | quakegeneric_w32.obj 74 | $(link) $(ldebug) $(conlflags) -out:$*.exe $** $(conlibs) \ 75 | winmm.lib user32.lib gdi32.lib kernel32.lib 76 | 77 | {src}.c{src}.obj: 78 | $(CC) /O2 /Zi /FA /nologo $(CFLAGS) /c /Fosrc\ $< 79 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // draw.h -- these are the only functions outside the refresh allowed 22 | // to touch the vid buffer 23 | 24 | extern qpic_t *draw_disc; // also used on sbar 25 | 26 | void Draw_Init (void); 27 | void Draw_Character (int x, int y, int num); 28 | void Draw_DebugChar (char num); 29 | void Draw_Pic (int x, int y, qpic_t *pic); 30 | void Draw_TransPic (int x, int y, qpic_t *pic); 31 | void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation); 32 | void Draw_ConsoleBackground (int lines); 33 | void Draw_BeginDisc (void); 34 | void Draw_EndDisc (void); 35 | void Draw_TileClear (int x, int y, int w, int h); 36 | void Draw_Fill (int x, int y, int w, int h, int c); 37 | void Draw_FadeScreen (void); 38 | void Draw_String (int x, int y, char *str); 39 | qpic_t *Draw_PicFromWad (char *name); 40 | qpic_t *Draw_CachePic (char *path); 41 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // 22 | // console 23 | // 24 | extern int con_totallines; 25 | extern int con_backscroll; 26 | extern qboolean con_forcedup; // because no entities to refresh 27 | extern qboolean con_initialized; 28 | extern byte *con_chars; 29 | extern int con_notifylines; // scan lines to clear for notify lines 30 | 31 | void Con_DrawCharacter (int cx, int line, int num); 32 | 33 | void Con_CheckResize (void); 34 | void Con_Init (void); 35 | void Con_DrawConsole (int lines, qboolean drawinput); 36 | void Con_Print (char *txt); 37 | void Con_Printf (char *fmt, ...); 38 | void Con_DPrintf (char *fmt, ...); 39 | void Con_SafePrintf (char *fmt, ...); 40 | void Con_Clear_f (void); 41 | void Con_DrawNotify (void); 42 | void Con_ClearNotify (void); 43 | void Con_ToggleConsole_f (void); 44 | 45 | void Con_NotifyBox (char *text); // during startup for sound / cd warnings 46 | 47 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_vars.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // r_vars.c: global refresh variables 21 | 22 | #include "quakedef.h" 23 | 24 | // all global and static refresh variables are collected in a contiguous block 25 | // to avoid cache conflicts. 26 | 27 | //------------------------------------------------------- 28 | // global refresh variables 29 | //------------------------------------------------------- 30 | 31 | // FIXME: make into one big structure, like cl or sv 32 | // FIXME: do separately for refresh engine and driver 33 | 34 | float d_sdivzstepu, d_tdivzstepu, d_zistepu; 35 | float d_sdivzstepv, d_tdivzstepv, d_zistepv; 36 | float d_sdivzorigin, d_tdivzorigin, d_ziorigin; 37 | 38 | fixed16_t sadjust, tadjust, bbextents, bbextentt; 39 | 40 | pixel_t *cacheblock; 41 | int cachewidth; 42 | pixel_t *d_viewbuffer; 43 | short *d_pzbuffer; 44 | unsigned int d_zrowbytes; 45 | unsigned int d_zwidth; 46 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/net_udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_udp.h 21 | 22 | int UDP_Init (void); 23 | void UDP_Shutdown (void); 24 | void UDP_Listen (qboolean state); 25 | int UDP_OpenSocket (int port); 26 | int UDP_CloseSocket (int socket); 27 | int UDP_Connect (int socket, struct qsockaddr *addr); 28 | int UDP_CheckNewConnections (void); 29 | int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr); 30 | int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr); 31 | int UDP_Broadcast (int socket, byte *buf, int len); 32 | char *UDP_AddrToString (struct qsockaddr *addr); 33 | int UDP_StringToAddr (char *string, struct qsockaddr *addr); 34 | int UDP_GetSocketAddr (int socket, struct qsockaddr *addr); 35 | int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name); 36 | int UDP_GetAddrFromName (char *name, struct qsockaddr *addr); 37 | int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2); 38 | int UDP_GetSocketPort (struct qsockaddr *addr); 39 | int UDP_SetSocketPort (struct qsockaddr *addr, int port); 40 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/screen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // screen.h 21 | 22 | void SCR_Init (void); 23 | 24 | void SCR_UpdateScreen (void); 25 | 26 | 27 | void SCR_SizeUp (void); 28 | void SCR_SizeDown (void); 29 | void SCR_BringDownConsole (void); 30 | void SCR_CenterPrint (char *str); 31 | 32 | void SCR_BeginLoadingPlaque (void); 33 | void SCR_EndLoadingPlaque (void); 34 | 35 | int SCR_ModalMessage (char *text); 36 | 37 | extern float scr_con_current; 38 | extern float scr_conlines; // lines of console to display 39 | 40 | extern int scr_fullupdate; // set to 0 to force full redraw 41 | extern int sb_lines; 42 | 43 | extern int clearnotify; // set to 0 whenever notify text is drawn 44 | extern qboolean scr_disabled_for_loading; 45 | extern qboolean scr_skipupdate; 46 | 47 | extern cvar_t scr_viewsize; 48 | 49 | extern cvar_t scr_viewsize; 50 | 51 | // only the refresh window will be updated unless these variables are flagged 52 | extern int scr_copytop; 53 | extern int scr_copyeverything; 54 | 55 | extern qboolean block_drawing; 56 | 57 | void SCR_UpdateWholeScreen (void); 58 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/meson.build: -------------------------------------------------------------------------------- 1 | project('quakegeneric', 'c') 2 | 3 | m_dep = meson.get_compiler('c').find_library('m', required : false) 4 | 5 | quakegeneric_sources = [ 6 | 'source/cd_null.c', 7 | 'source/chase.c', 8 | 'source/cl_demo.c', 9 | 'source/cl_input.c', 10 | 'source/cl_main.c', 11 | 'source/cl_parse.c', 12 | 'source/cl_tent.c', 13 | 'source/cmd.c', 14 | 'source/common.c', 15 | 'source/console.c', 16 | 'source/crc.c', 17 | 'source/cvar.c', 18 | 'source/d_edge.c', 19 | 'source/d_fill.c', 20 | 'source/d_init.c', 21 | 'source/d_modech.c', 22 | 'source/d_part.c', 23 | 'source/d_polyse.c', 24 | 'source/d_scan.c', 25 | 'source/d_sky.c', 26 | 'source/d_sprite.c', 27 | 'source/d_surf.c', 28 | 'source/d_vars.c', 29 | 'source/d_zpoint.c', 30 | 'source/draw.c', 31 | 'source/host_cmd.c', 32 | 'source/host.c', 33 | 'source/in_null.c', 34 | 'source/keys.c', 35 | 'source/mathlib.c', 36 | 'source/menu.c', 37 | 'source/model.c', 38 | 'source/net_loop.c', 39 | 'source/net_main.c', 40 | 'source/net_none.c', 41 | 'source/net_vcr.c', 42 | 'source/nonintel.c', 43 | 'source/pr_cmds.c', 44 | 'source/pr_edict.c', 45 | 'source/pr_exec.c', 46 | 'source/r_aclip.c', 47 | 'source/r_alias.c', 48 | 'source/r_bsp.c', 49 | 'source/r_draw.c', 50 | 'source/r_edge.c', 51 | 'source/r_efrag.c', 52 | 'source/r_light.c', 53 | 'source/r_main.c', 54 | 'source/r_misc.c', 55 | 'source/r_part.c', 56 | 'source/r_sky.c', 57 | 'source/r_sprite.c', 58 | 'source/r_surf.c', 59 | 'source/r_vars.c', 60 | 'source/sbar.c', 61 | 'source/screen.c', 62 | 'source/snd_null.c', 63 | 'source/sv_main.c', 64 | 'source/sv_move.c', 65 | 'source/sv_phys.c', 66 | 'source/sv_user.c', 67 | 'source/sys_null.c', 68 | 'source/vid_null.c', 69 | 'source/view.c', 70 | 'source/wad.c', 71 | 'source/world.c', 72 | 'source/zone.c', 73 | 'source/quakegeneric.c' 74 | ] 75 | 76 | static_library('quakegeneric', quakegeneric_sources, dependencies : m_dep) 77 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/quakegeneric.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef __QUAKEGENERIC__ 22 | #define __QUAKEGENERIC__ 23 | 24 | #include "quakekeys.h" 25 | 26 | 27 | #define QUAKEGENERIC_RES_SCALE 2 28 | 29 | //for comparison with e.g. https://thandor.net/benchmark/33 30 | //in game, press tilde, then 'timedemo demo3' 31 | //#define QUAKEGENERIC_RES_X (320) 32 | //#define QUAKEGENERIC_RES_Y (200) 33 | 34 | 35 | #define QUAKEGENERIC_RES_X 512 36 | #define QUAKEGENERIC_RES_Y 300 37 | 38 | #define QUAKEGENERIC_JOY_MAX_AXES 6 39 | #define QUAKEGENERIC_JOY_AXIS_X 0 40 | #define QUAKEGENERIC_JOY_AXIS_Y 1 41 | #define QUAKEGENERIC_JOY_AXIS_Z 2 42 | #define QUAKEGENERIC_JOY_AXIS_R 3 43 | #define QUAKEGENERIC_JOY_AXIS_U 4 44 | #define QUAKEGENERIC_JOY_AXIS_V 5 45 | 46 | 47 | // provided functions 48 | void QG_Tick(double duration); 49 | void QG_Create(int argc, char *argv[]); 50 | 51 | // user must implement these 52 | void QG_Init(void); 53 | void QG_Quit(void); 54 | void QG_DrawFrame(void *pixels); 55 | void QG_SetPalette(unsigned char palette[768]); 56 | int QG_GetKey(int *down, int *key); 57 | void QG_GetMouseMove(int *x, int *y); 58 | void QG_GetJoyAxes(float *axes); 59 | 60 | #endif // __QUAKEGENERIC__ 61 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/wad.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // wad.h 21 | 22 | //=============== 23 | // TYPES 24 | //=============== 25 | 26 | #define CMP_NONE 0 27 | #define CMP_LZSS 1 28 | 29 | #define TYP_NONE 0 30 | #define TYP_LABEL 1 31 | 32 | #define TYP_LUMPY 64 // 64 + grab command number 33 | #define TYP_PALETTE 64 34 | #define TYP_QTEX 65 35 | #define TYP_QPIC 66 36 | #define TYP_SOUND 67 37 | #define TYP_MIPTEX 68 38 | 39 | typedef struct 40 | { 41 | int width, height; 42 | byte data[4]; // variably sized 43 | } qpic_t; 44 | 45 | 46 | 47 | typedef struct 48 | { 49 | char identification[4]; // should be WAD2 or 2DAW 50 | int numlumps; 51 | int infotableofs; 52 | } wadinfo_t; 53 | 54 | typedef struct 55 | { 56 | int filepos; 57 | int disksize; 58 | int size; // uncompressed 59 | char type; 60 | char compression; 61 | char pad1, pad2; 62 | char name[16]; // must be null terminated 63 | } lumpinfo_t; 64 | 65 | extern int wad_numlumps; 66 | extern lumpinfo_t *wad_lumps; 67 | extern byte *wad_base; 68 | 69 | void W_LoadWadFile (char *filename); 70 | void W_CleanupName (char *in, char *out); 71 | lumpinfo_t *W_GetLumpinfo (char *name); 72 | void *W_GetLumpName (char *name); 73 | void *W_GetLumpNum (int num); 74 | 75 | void SwapPic (qpic_t *pic); 76 | -------------------------------------------------------------------------------- /main/main.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "bsp/esp-bsp.h" 21 | #include "esp_timer.h" 22 | #include "quakegeneric.h" 23 | #include "freertos/FreeRTOS.h" 24 | #include "freertos/task.h" 25 | #include "freertos/semphr.h" 26 | #include "quakekeys.h" 27 | #include "eth_connect.h" 28 | #include "font_8x16.h" 29 | #include "input.h" 30 | #include "display.h" 31 | 32 | #include "quakedef.h" 33 | 34 | void QG_Init(void) { 35 | } 36 | 37 | void QG_Quit(void) { 38 | display_quit(); 39 | while(1) vTaskDelay(100); 40 | } 41 | 42 | 43 | static void quake_task(void *param) { 44 | char *argv[]={ 45 | "quake", 46 | "-basedir", "/sdcard/", 47 | NULL 48 | }; 49 | //initialize Quake 50 | QG_Create(3, argv); 51 | 52 | int64_t oldtime_us = esp_timer_get_time(); 53 | while (1) { 54 | // Run the frame at the correct duration. 55 | int64_t newtime_us = esp_timer_get_time(); 56 | QG_Tick((double)(newtime_us - oldtime_us)/1000000.0); 57 | oldtime_us = newtime_us; 58 | } 59 | } 60 | 61 | void app_main() { 62 | bsp_sdcard_mount(); 63 | display_init(); 64 | 65 | ethernet_connect(); 66 | 67 | input_init(); 68 | 69 | int stack_depth=200*1024; 70 | 71 | StaticTask_t *taskbuf=calloc(1, sizeof(StaticTask_t)); 72 | uint8_t *stackbuf=calloc(stack_depth, 1); 73 | xTaskCreateStaticPinnedToCore(quake_task, "quake", stack_depth, NULL, 2, (StackType_t*)stackbuf, taskbuf, 0); 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/README.md: -------------------------------------------------------------------------------- 1 | # quakegeneric 2 | 3 | ![a low-resolution screenshot of quake](./.github/quakegeneric.png) 4 | 5 | it's like [doomgeneric](https://github.com/ozkl/doomgeneric), but for quake. it's based on the GPL WinQuake source code. 6 | 7 | currently it can only compile for 32-bit architechtures. 8 | 9 | ## implementations 10 | 11 | - [`quakegeneric_null.c`](./source/quakegeneric_null.c) - null 12 | - [`quakegeneric_dos.c`](./source/quakegeneric_dos.c) - MS-DOS 13 | - [`quakegeneric_sdl2.c`](./source/quakegeneric_sdl2.c) - SDL2 14 | - [`quakegeneric_w32.c`](./source/quakegeneric_w32.c) - Win32 15 | 16 | ## building 17 | 18 | on unix-like platforms: 19 | 20 | ``` 21 | cd source/ 22 | make 23 | ``` 24 | 25 | for Open Watcom: 26 | 27 | ``` 28 | cd source/ 29 | wmake -f makefile.wat 30 | ``` 31 | 32 | for CMake: 33 | 34 | ``` 35 | mkdir cmake-build 36 | cd cmake-build/ 37 | cmake .. 38 | make 39 | ``` 40 | 41 | for Meson: 42 | 43 | ``` 44 | mkdir meson-build 45 | meson setup meson-build 46 | cd meson-build/ 47 | meson compile 48 | ``` 49 | 50 | for Windows: 51 | 52 | ``` 53 | cd source/ 54 | nmake makefile.win 55 | ``` 56 | 57 | ## platforms 58 | 59 | the following compilers have been tested to work with this source: 60 | 61 | - GCC 62 | - Clang 63 | - MinGW 64 | - TinyCC 65 | - Open Watcom 66 | - MSVC 67 | 68 | ## License 69 | 70 | Copyright (C) 1996-1997 Id Software, Inc. 71 | 72 | This program is free software; you can redistribute it and/or 73 | modify it under the terms of the GNU General Public License 74 | as published by the Free Software Foundation; either version 2 75 | of the License, or (at your option) any later version. 76 | 77 | This program is distributed in the hope that it will be useful, 78 | but WITHOUT ANY WARRANTY; without even the implied warranty of 79 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 80 | 81 | See the GNU General Public License for more details. 82 | 83 | You should have received a copy of the GNU General Public License 84 | along with this program; if not, write to the Free Software 85 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 86 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/usbvar.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: usbvar.h,v 1.2 1999/05/11 21:15:46 augustss Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1999 Lennart Augustsson 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * $FreeBSD$ 29 | * 30 | */ 31 | 32 | #ifndef _USBVAR_H_ 33 | #define _USBVAR_H_ 34 | 35 | struct report_desc { 36 | uint32_t size; 37 | uint8_t data[1]; 38 | }; 39 | 40 | /* internal backwards compatibility functions */ 41 | 42 | #ifdef HID_COMPAT7 43 | int hid_set_immed_compat7(int fd, int enable); 44 | int hid_get_report_id_compat7(int fd); 45 | report_desc_t hid_get_report_desc_compat7(int fd); 46 | #endif 47 | 48 | #ifdef COMPAT_32BIT 49 | #define hid_pass_ptr(ptr) ((uint64_t)(uintptr_t)(ptr)) 50 | #else 51 | #define hid_pass_ptr(ptr) (ptr) 52 | #endif 53 | 54 | #endif /* _USBVAR_H_ */ 55 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/descr.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: descr.c,v 1.9 2000/09/24 02:13:24 augustss Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1999 Lennart Augustsson 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | __FBSDID("$FreeBSD$"); 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "usbhid.h" 42 | #include "usbvar.h" 43 | 44 | 45 | report_desc_t 46 | hid_use_report_desc(unsigned char *data, unsigned int size) 47 | { 48 | report_desc_t r; 49 | 50 | r = malloc(sizeof(*r) + size); 51 | if (r == 0) { 52 | errno = ENOMEM; 53 | return (NULL); 54 | } 55 | r->size = size; 56 | memcpy(r->data, data, size); 57 | return (r); 58 | } 59 | 60 | void 61 | hid_dispose_report_desc(report_desc_t r) 62 | { 63 | 64 | free(r); 65 | } 66 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // sys.h -- non-portable functions 21 | 22 | // 23 | // file IO 24 | // 25 | 26 | // returns the file size 27 | // return -1 if file is not present 28 | // the file should be in BINARY mode for stupid OSs that care 29 | int Sys_FileOpenRead (char *path, int *hndl); 30 | 31 | int Sys_FileOpenWrite (char *path); 32 | void Sys_FileClose (int handle); 33 | void Sys_FileSeek (int handle, int position); 34 | int Sys_FileRead (int handle, void *dest, int count); 35 | int Sys_FileWrite (int handle, void *data, int count); 36 | int Sys_FileTime (char *path); 37 | void Sys_mkdir (char *path); 38 | 39 | // 40 | // memory protection 41 | // 42 | void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length); 43 | 44 | // 45 | // system IO 46 | // 47 | void Sys_DebugLog(char *file, char *fmt, ...); 48 | 49 | void Sys_Error (char *error, ...); 50 | // an error will cause the entire program to exit 51 | 52 | void Sys_Printf (char *fmt, ...); 53 | // send text to the console 54 | 55 | void Sys_Quit (void); 56 | 57 | double Sys_FloatTime (void); 58 | 59 | char *Sys_ConsoleInput (void); 60 | 61 | void Sys_Sleep (void); 62 | // called to yield for a little bit so as 63 | // not to hog cpu when paused or debugging 64 | 65 | void Sys_SendKeyEvents (void); 66 | // Perform Key_Event () callbacks until the input que is empty 67 | 68 | void Sys_LowFPPrecision (void); 69 | void Sys_HighFPPrecision (void); 70 | void Sys_SetFPCW (void); 71 | 72 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_fill.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_clear: clears a specified rectangle to the specified color 21 | 22 | #include "quakedef.h" 23 | 24 | 25 | /* 26 | ================ 27 | D_FillRect 28 | ================ 29 | */ 30 | void D_FillRect (vrect_t *rect, int color) 31 | { 32 | int rx, ry, rwidth, rheight; 33 | unsigned char *dest; 34 | unsigned *ldest; 35 | 36 | rx = rect->x; 37 | ry = rect->y; 38 | rwidth = rect->width; 39 | rheight = rect->height; 40 | 41 | if (rx < 0) 42 | { 43 | rwidth += rx; 44 | rx = 0; 45 | } 46 | if (ry < 0) 47 | { 48 | rheight += ry; 49 | ry = 0; 50 | } 51 | if (rx+rwidth > vid.width) 52 | rwidth = vid.width - rx; 53 | if (ry+rheight > vid.height) 54 | rheight = vid.height - rx; 55 | 56 | if (rwidth < 1 || rheight < 1) 57 | return; 58 | 59 | dest = ((byte *)vid.buffer + ry*vid.rowbytes + rx); 60 | 61 | if (((rwidth & 0x03) == 0) && (((intptr_t)dest & 0x03) == 0)) 62 | { 63 | // faster aligned dword clear 64 | ldest = (unsigned *)dest; 65 | color += color << 16; 66 | 67 | rwidth >>= 2; 68 | color += color << 8; 69 | 70 | for (ry=0 ; ry 22 | #include 23 | #include 24 | #include 25 | 26 | #include "quakegeneric.h" 27 | 28 | int old_mode; 29 | union REGS regs; 30 | 31 | unsigned char *VGA = 0xA0000L; 32 | 33 | void QG_Init(void) 34 | { 35 | // get old video mode 36 | regs.h.ah = 0x0f; 37 | int386(0x10, ®s, ®s); 38 | old_mode = regs.h.al; 39 | 40 | // set video mode to 320x200x8 41 | regs.w.ax = 0x13; 42 | int386(0x10, ®s, ®s); 43 | } 44 | 45 | int QG_GetKey(int *down, int *key) 46 | { 47 | return 0; 48 | } 49 | 50 | void QG_GetMouseMove(int *x, int *y) 51 | { 52 | 53 | } 54 | 55 | void QG_Quit(void) 56 | { 57 | // set old video mode 58 | regs.w.ax = old_mode; 59 | int386(0x10, ®s, ®s); 60 | } 61 | 62 | void QG_DrawFrame(void *pixels) 63 | { 64 | memcpy(VGA, pixels, QUAKEGENERIC_RES_X * QUAKEGENERIC_RES_Y); 65 | } 66 | 67 | void QG_SetPalette(unsigned char palette[768]) 68 | { 69 | int i; 70 | for (i = 0; i < 256; i++) 71 | { 72 | outp(0x3c8, i); 73 | outp(0x3c9, (palette[i * 3] * 63) / 255); 74 | outp(0x3c9, (palette[(i * 3) + 1] * 63) / 255); 75 | outp(0x3c9, (palette[(i * 3) + 2] * 63) / 255); 76 | } 77 | } 78 | 79 | int main(int argc, char *argv[]) 80 | { 81 | int running; 82 | double oldtime, newtime; 83 | 84 | QG_Create(argc, argv); 85 | 86 | running = 1; 87 | oldtime = (((double)clock()) / CLOCKS_PER_SEC) - 0.1; 88 | while (running) 89 | { 90 | newtime = ((double)clock()) / CLOCKS_PER_SEC; 91 | QG_Tick(newtime - oldtime); 92 | oldtime = newtime; 93 | } 94 | 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_modech.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_modech.c: called when mode has just changed 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | #include "esp_attr.h" 25 | 26 | 27 | int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; 28 | 29 | int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; 30 | 31 | EXT_RAM_BSS_ATTR int d_scantable[MAXHEIGHT]; 32 | EXT_RAM_BSS_ATTR short *zspantable[MAXHEIGHT]; 33 | 34 | /* 35 | ================ 36 | D_ViewChanged 37 | ================ 38 | */ 39 | void D_ViewChanged (void) 40 | { 41 | int rowbytes; 42 | 43 | if (r_dowarp) 44 | rowbytes = WARP_WIDTH; 45 | else 46 | rowbytes = vid.rowbytes; 47 | 48 | scale_for_mip = xscale; 49 | if (yscale > xscale) 50 | scale_for_mip = yscale; 51 | 52 | d_zrowbytes = vid.width * 2; 53 | d_zwidth = vid.width; 54 | 55 | d_pix_min = r_refdef.vrect.width / 320; 56 | if (d_pix_min < 1) 57 | d_pix_min = 1; 58 | 59 | d_pix_max = (int)((float)r_refdef.vrect.width / (320.0 / 4.0) + 0.5); 60 | d_pix_shift = 8 - (int)((float)r_refdef.vrect.width / 320.0 + 0.5); 61 | if (d_pix_max < 1) 62 | d_pix_max = 1; 63 | 64 | if (pixelAspect > 1.4) 65 | d_y_aspect_shift = 1; 66 | else 67 | d_y_aspect_shift = 0; 68 | 69 | d_vrectx = r_refdef.vrect.x; 70 | d_vrecty = r_refdef.vrect.y; 71 | d_vrectright_particle = r_refdef.vrectright - d_pix_max; 72 | d_vrectbottom_particle = 73 | r_refdef.vrectbottom - (d_pix_max << d_y_aspect_shift); 74 | 75 | { 76 | int i; 77 | 78 | for (i=0 ; ihulls, 0, 0, 1, start, end, &trace); 56 | 57 | VectorCopy (trace.endpos, impact); 58 | } 59 | 60 | void Chase_Update (void) 61 | { 62 | int i; 63 | float dist; 64 | vec3_t forward, up, right; 65 | vec3_t dest, stop; 66 | 67 | 68 | // if can't see player, reset 69 | AngleVectors (cl.viewangles, forward, right, up); 70 | 71 | // calc exact destination 72 | for (i=0 ; i<3 ; i++) 73 | chase_dest[i] = r_refdef.vieworg[i] 74 | - forward[i]*chase_back.value 75 | - right[i]*chase_right.value; 76 | chase_dest[2] = r_refdef.vieworg[2] + chase_up.value; 77 | 78 | // find the spot the player is looking at 79 | VectorMA (r_refdef.vieworg, 4096, forward, dest); 80 | TraceLine (r_refdef.vieworg, dest, stop); 81 | 82 | // calculate pitch to look at the same spot from camera 83 | VectorSubtract (stop, r_refdef.vieworg, stop); 84 | dist = DotProduct (stop, forward); 85 | if (dist < 1) 86 | dist = 1; 87 | r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180; 88 | 89 | // move towards destination 90 | VectorCopy (chase_dest, r_refdef.vieworg); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/vid.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // vid.h -- video driver defs 21 | 22 | #define VID_CBITS 6 23 | #define VID_GRADES (1 << VID_CBITS) 24 | 25 | // a pixel can be one, two, or four bytes 26 | typedef byte pixel_t; 27 | 28 | typedef struct vrect_s 29 | { 30 | int x,y,width,height; 31 | struct vrect_s *pnext; 32 | } vrect_t; 33 | 34 | typedef struct 35 | { 36 | pixel_t *buffer; // invisible buffer 37 | pixel_t *colormap; // 256 * VID_GRADES size 38 | unsigned short *colormap16; // 256 * VID_GRADES size 39 | int fullbright; // index of first fullbright color 40 | unsigned rowbytes; // may be > width if displayed in a window 41 | unsigned width; 42 | unsigned height; 43 | float aspect; // width / height -- < 0 is taller than wide 44 | int numpages; 45 | int recalc_refdef; // if true, recalc vid-based stuff 46 | pixel_t *conbuffer; 47 | int conrowbytes; 48 | unsigned conwidth; 49 | unsigned conheight; 50 | int maxwarpwidth; 51 | int maxwarpheight; 52 | pixel_t *direct; // direct drawing to framebuffer, if not 53 | // NULL 54 | } viddef_t; 55 | 56 | extern viddef_t vid; // global video state 57 | extern void (*vid_menudrawfn)(void); 58 | extern void (*vid_menukeyfn)(int key); 59 | 60 | void VID_SetPalette (unsigned char *palette); 61 | // called at startup and after any gamma correction 62 | 63 | void VID_ShiftPalette (unsigned char *palette); 64 | // called for bonus and pain flashes, and for underwater color changes 65 | 66 | void VID_Init (unsigned char *palette); 67 | // Called at startup to set up translation tables, takes 256 8 bit RGB values 68 | // the palette data will go away after the call, so it must be copied off if 69 | // the video driver will need it again 70 | 71 | void VID_Shutdown (void); 72 | // Called at shutdown 73 | 74 | void VID_Update (vrect_t *rects); 75 | // flushes the given rectangles from the view buffer to the screen 76 | 77 | int VID_SetMode (int modenum, unsigned char *palette); 78 | // sets the mode; only used by the Quake engine for resetting to mode 0 (the 79 | // base mode) on memory allocation failures 80 | 81 | void VID_HandlePause (qboolean pause); 82 | // called only on Win32, when pause happens, so the mouse can be released 83 | 84 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/world.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // world.h 21 | 22 | typedef struct 23 | { 24 | vec3_t normal; 25 | float dist; 26 | } plane_t; 27 | 28 | typedef struct 29 | { 30 | qboolean allsolid; // if true, plane is not valid 31 | qboolean startsolid; // if true, the initial point was in a solid area 32 | qboolean inopen, inwater; 33 | float fraction; // time completed, 1.0 = didn't hit anything 34 | vec3_t endpos; // final position 35 | plane_t plane; // surface normal at impact 36 | edict_t *ent; // entity the surface is on 37 | } trace_t; 38 | 39 | 40 | #define MOVE_NORMAL 0 41 | #define MOVE_NOMONSTERS 1 42 | #define MOVE_MISSILE 2 43 | 44 | 45 | void SV_ClearWorld (void); 46 | // called after the world model has been loaded, before linking any entities 47 | 48 | void SV_UnlinkEdict (edict_t *ent); 49 | // call before removing an entity, and before trying to move one, 50 | // so it doesn't clip against itself 51 | // flags ent->v.modified 52 | 53 | void SV_LinkEdict (edict_t *ent, qboolean touch_triggers); 54 | // Needs to be called any time an entity changes origin, mins, maxs, or solid 55 | // flags ent->v.modified 56 | // sets ent->v.absmin and ent->v.absmax 57 | // if touchtriggers, calls prog functions for the intersected triggers 58 | 59 | int SV_PointContents (vec3_t p); 60 | int SV_TruePointContents (vec3_t p); 61 | // returns the CONTENTS_* value from the world at the given point. 62 | // does not check any entities at all 63 | // the non-true version remaps the water current contents to content_water 64 | 65 | edict_t *SV_TestEntityPosition (edict_t *ent); 66 | 67 | trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict); 68 | // mins and maxs are reletive 69 | 70 | // if the entire move stays in a solid volume, trace.allsolid will be set 71 | 72 | // if the starting point is in a solid, it will be allowed to move out 73 | // to an open area 74 | 75 | // nomonsters is used for line of sight or edge testing, where mosnters 76 | // shouldn't be considered solid objects 77 | 78 | // passedict is explicitly excluded from clipping checks (normally NULL) 79 | 80 | qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace); 81 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/mathlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // mathlib.h 21 | 22 | typedef float vec_t; 23 | typedef vec_t vec3_t[3]; 24 | typedef vec_t vec5_t[5]; 25 | 26 | typedef int fixed4_t; 27 | typedef int fixed8_t; 28 | typedef int fixed16_t; 29 | 30 | #ifndef M_PI 31 | #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h 32 | #endif 33 | 34 | struct mplane_s; 35 | 36 | extern vec3_t vec3_origin; 37 | extern int nanmask; 38 | 39 | #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) 40 | 41 | #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) 42 | #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} 43 | #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} 44 | #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} 45 | 46 | void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc); 47 | 48 | vec_t _DotProduct (vec3_t v1, vec3_t v2); 49 | void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); 50 | void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out); 51 | void _VectorCopy (vec3_t in, vec3_t out); 52 | 53 | int VectorCompare (vec3_t v1, vec3_t v2); 54 | vec_t Length (vec3_t v); 55 | void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross); 56 | float VectorNormalize (vec3_t v); // returns vector length 57 | void VectorInverse (vec3_t v); 58 | void VectorScale (vec3_t in, vec_t scale, vec3_t out); 59 | int Q_log2(int val); 60 | 61 | void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); 62 | void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); 63 | 64 | void FloorDivMod (double numer, double denom, int *quotient, 65 | int *rem); 66 | fixed16_t Invert24To16(fixed16_t val); 67 | int GreatestCommonDivisor (int i1, int i2); 68 | 69 | void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); 70 | int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); 71 | float anglemod(float a); 72 | 73 | 74 | 75 | #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ 76 | (((p)->type < 3)? \ 77 | ( \ 78 | ((p)->dist <= (emins)[(p)->type])? \ 79 | 1 \ 80 | : \ 81 | ( \ 82 | ((p)->dist >= (emaxs)[(p)->type])?\ 83 | 2 \ 84 | : \ 85 | 3 \ 86 | ) \ 87 | ) \ 88 | : \ 89 | BoxOnPlaneSide( (emins), (emaxs), (p))) 90 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_ifacea.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // d_ifacea.h 22 | // 23 | // Include file for asm driver interface. 24 | // 25 | 26 | // 27 | // !!! note that this file must match the corresponding C structures in 28 | // d_iface.h at all times !!! 29 | // 30 | 31 | // !!! if this is changed, it must be changed in r_shared.h too !!! 32 | #define ALIAS_ONSEAM 0x0020 33 | 34 | // !!! if this is changed, it must be changed in d_iface.h too !!! 35 | #define TURB_TEX_SIZE 64 // base turbulent texture size 36 | 37 | // !!! if this is changed, it must be changed in d_iface.h too !!! 38 | #define CYCLE 128 39 | 40 | // !!! if this is changed, it must be changed in r_shared.h too !!! 41 | #define MAXHEIGHT 1024 42 | 43 | // !!! if this is changed, it must be changed in quakedef.h too !!! 44 | #define CACHE_SIZE 32 // used to align key data structures 45 | 46 | // particle_t structure 47 | // !!! if this is changed, it must be changed in d_iface.h too !!! 48 | // driver-usable fields 49 | #define pt_org 0 50 | #define pt_color 12 51 | // drivers never touch the following fields 52 | #define pt_next 16 53 | #define pt_vel 20 54 | #define pt_ramp 32 55 | #define pt_die 36 56 | #define pt_type 40 57 | #define pt_size 44 58 | 59 | #define PARTICLE_Z_CLIP 8.0 60 | 61 | // finalvert_t structure 62 | // !!! if this is changed, it must be changed in d_iface.h too !!! 63 | #define fv_v 0 // !!! if this is moved, cases where the !!! 64 | // !!! address of this field is pushed in !!! 65 | // !!! d_polysa.s must be changed !!! 66 | #define fv_flags 24 67 | #define fv_reserved 28 68 | #define fv_size 32 69 | #define fv_shift 5 70 | 71 | 72 | // stvert_t structure 73 | // !!! if this is changed, it must be changed in modelgen.h too !!! 74 | #define stv_onseam 0 75 | #define stv_s 4 76 | #define stv_t 8 77 | #define stv_size 12 78 | 79 | 80 | // trivertx_t structure 81 | // !!! if this is changed, it must be changed in modelgen.h too !!! 82 | #define tv_v 0 83 | #define tv_lightnormalindex 3 84 | #define tv_size 4 85 | 86 | // affinetridesc_t structure 87 | // !!! if this is changed, it must be changed in d_iface.h too !!! 88 | #define atd_pskin 0 89 | #define atd_pskindesc 4 90 | #define atd_skinwidth 8 91 | #define atd_skinheight 12 92 | #define atd_ptriangles 16 93 | #define atd_pfinalverts 20 94 | #define atd_numtriangles 24 95 | #define atd_drawtype 28 96 | #define atd_seamfixupX16 32 97 | #define atd_size 36 98 | 99 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/vid_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // vid_null.c -- null video driver to aid porting efforts 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | #include "quakegeneric.h" 26 | 27 | viddef_t vid; // global video state 28 | 29 | #define BASEWIDTH QUAKEGENERIC_RES_X 30 | #define BASEHEIGHT QUAKEGENERIC_RES_Y 31 | 32 | static byte *vid_buffer[2]; 33 | static short *zbuffer; 34 | static byte *surfcache; 35 | static size_t surfcache_size; 36 | 37 | void VID_SetPalette (unsigned char *palette) 38 | { 39 | // quake generic 40 | QG_SetPalette(palette); 41 | } 42 | 43 | void VID_ShiftPalette (unsigned char *palette) 44 | { 45 | // quake generic 46 | QG_SetPalette(palette); 47 | } 48 | 49 | void VID_Init (unsigned char *palette) 50 | { 51 | zbuffer = calloc(BASEWIDTH*BASEHEIGHT, sizeof(short)); 52 | vid_buffer[0] = calloc(BASEWIDTH*BASEHEIGHT, sizeof(byte)); 53 | vid_buffer[1] = calloc(BASEWIDTH*BASEHEIGHT, sizeof(byte)); 54 | vid.maxwarpwidth = vid.width = vid.conwidth = BASEWIDTH; 55 | vid.maxwarpheight = vid.height = vid.conheight = BASEHEIGHT; 56 | vid.aspect = 1.0; 57 | vid.numpages = 2; 58 | vid.colormap = host_colormap; 59 | vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048)); 60 | vid.buffer = vid.conbuffer = vid_buffer[0]; 61 | vid.rowbytes = vid.conrowbytes = BASEWIDTH; 62 | 63 | d_pzbuffer = zbuffer; 64 | 65 | surfcache_size = D_SurfaceCacheForRes(BASEWIDTH, BASEHEIGHT); 66 | surfcache = malloc(surfcache_size); 67 | D_InitCaches (surfcache, surfcache_size); 68 | 69 | // quake generic 70 | QG_Init(); 71 | } 72 | 73 | void VID_Shutdown (void) 74 | { 75 | free(zbuffer); 76 | free(vid_buffer[0]); 77 | free(vid_buffer[1]); 78 | free(surfcache); 79 | } 80 | 81 | void VID_Update (vrect_t *rects) 82 | { 83 | // quake generic 84 | QG_DrawFrame(vid.buffer); 85 | //swap buffers 86 | if (vid.buffer == vid_buffer[0]) { 87 | vid.buffer = vid_buffer[1]; 88 | } else { 89 | vid.buffer = vid_buffer[0]; 90 | } 91 | vid.conbuffer=vid.buffer; 92 | } 93 | 94 | /* 95 | ================ 96 | D_BeginDirectRect 97 | ================ 98 | */ 99 | void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height) 100 | { 101 | } 102 | 103 | 104 | /* 105 | ================ 106 | D_EndDirectRect 107 | ================ 108 | */ 109 | void D_EndDirectRect (int x, int y, int width, int height) 110 | { 111 | } 112 | 113 | 114 | -------------------------------------------------------------------------------- /components/quakegeneric/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(QUAKE_SOURCE_DIR quakegeneric) 4 | 5 | set(QUAKEGENERIC_SOURCES 6 | ${QUAKE_SOURCE_DIR}/source/chase.c 7 | ${QUAKE_SOURCE_DIR}/source/cl_demo.c 8 | ${QUAKE_SOURCE_DIR}/source/cl_input.c 9 | ${QUAKE_SOURCE_DIR}/source/cl_main.c 10 | ${QUAKE_SOURCE_DIR}/source/cl_parse.c 11 | ${QUAKE_SOURCE_DIR}/source/cl_tent.c 12 | ${QUAKE_SOURCE_DIR}/source/cmd.c 13 | ${QUAKE_SOURCE_DIR}/source/common.c 14 | ${QUAKE_SOURCE_DIR}/source/console.c 15 | ${QUAKE_SOURCE_DIR}/source/crc.c 16 | ${QUAKE_SOURCE_DIR}/source/cvar.c 17 | ${QUAKE_SOURCE_DIR}/source/d_edge.c 18 | ${QUAKE_SOURCE_DIR}/source/d_fill.c 19 | ${QUAKE_SOURCE_DIR}/source/d_init.c 20 | ${QUAKE_SOURCE_DIR}/source/d_modech.c 21 | ${QUAKE_SOURCE_DIR}/source/d_part.c 22 | ${QUAKE_SOURCE_DIR}/source/d_polyse.c 23 | ${QUAKE_SOURCE_DIR}/source/d_scan.c 24 | ${QUAKE_SOURCE_DIR}/source/d_sky.c 25 | ${QUAKE_SOURCE_DIR}/source/d_sprite.c 26 | ${QUAKE_SOURCE_DIR}/source/d_surf.c 27 | ${QUAKE_SOURCE_DIR}/source/d_vars.c 28 | ${QUAKE_SOURCE_DIR}/source/d_zpoint.c 29 | ${QUAKE_SOURCE_DIR}/source/draw.c 30 | ${QUAKE_SOURCE_DIR}/source/host_cmd.c 31 | ${QUAKE_SOURCE_DIR}/source/host.c 32 | ${QUAKE_SOURCE_DIR}/source/in_null.c 33 | ${QUAKE_SOURCE_DIR}/source/keys.c 34 | ${QUAKE_SOURCE_DIR}/source/mathlib.c 35 | ${QUAKE_SOURCE_DIR}/source/menu.c 36 | ${QUAKE_SOURCE_DIR}/source/model.c 37 | ${QUAKE_SOURCE_DIR}/source/net_loop.c 38 | ${QUAKE_SOURCE_DIR}/source/net_main.c 39 | # ${QUAKE_SOURCE_DIR}/source/net_none.c 40 | ${QUAKE_SOURCE_DIR}/source/net_bsd.c 41 | ${QUAKE_SOURCE_DIR}/source/net_udp.c 42 | ${QUAKE_SOURCE_DIR}/source/net_dgrm.c 43 | ${QUAKE_SOURCE_DIR}/source/net_vcr.c 44 | ${QUAKE_SOURCE_DIR}/source/nonintel.c 45 | ${QUAKE_SOURCE_DIR}/source/pr_cmds.c 46 | ${QUAKE_SOURCE_DIR}/source/pr_edict.c 47 | ${QUAKE_SOURCE_DIR}/source/pr_exec.c 48 | ${QUAKE_SOURCE_DIR}/source/r_aclip.c 49 | ${QUAKE_SOURCE_DIR}/source/r_alias.c 50 | ${QUAKE_SOURCE_DIR}/source/r_bsp.c 51 | ${QUAKE_SOURCE_DIR}/source/r_draw.c 52 | ${QUAKE_SOURCE_DIR}/source/r_edge.c 53 | ${QUAKE_SOURCE_DIR}/source/r_efrag.c 54 | ${QUAKE_SOURCE_DIR}/source/r_light.c 55 | ${QUAKE_SOURCE_DIR}/source/r_main.c 56 | ${QUAKE_SOURCE_DIR}/source/r_misc.c 57 | ${QUAKE_SOURCE_DIR}/source/r_part.c 58 | ${QUAKE_SOURCE_DIR}/source/r_sky.c 59 | ${QUAKE_SOURCE_DIR}/source/r_sprite.c 60 | ${QUAKE_SOURCE_DIR}/source/r_surf.c 61 | ${QUAKE_SOURCE_DIR}/source/r_vars.c 62 | ${QUAKE_SOURCE_DIR}/source/sbar.c 63 | ${QUAKE_SOURCE_DIR}/source/screen.c 64 | ${QUAKE_SOURCE_DIR}/source/snd_dma.c 65 | ${QUAKE_SOURCE_DIR}/source/snd_mem.c 66 | ${QUAKE_SOURCE_DIR}/source/snd_mix.c 67 | ${QUAKE_SOURCE_DIR}/source/sv_main.c 68 | ${QUAKE_SOURCE_DIR}/source/sv_move.c 69 | ${QUAKE_SOURCE_DIR}/source/sv_phys.c 70 | ${QUAKE_SOURCE_DIR}/source/sv_user.c 71 | ${QUAKE_SOURCE_DIR}/source/sys_null.c 72 | ${QUAKE_SOURCE_DIR}/source/vid_null.c 73 | ${QUAKE_SOURCE_DIR}/source/view.c 74 | ${QUAKE_SOURCE_DIR}/source/wad.c 75 | ${QUAKE_SOURCE_DIR}/source/world.c 76 | ${QUAKE_SOURCE_DIR}/source/zone.c 77 | ${QUAKE_SOURCE_DIR}/source/quakegeneric.c 78 | ) 79 | 80 | 81 | idf_component_register( 82 | SRCS ${QUAKEGENERIC_SOURCES} 83 | INCLUDE_DIRS ${QUAKE_SOURCE_DIR}/source/ 84 | ) 85 | 86 | idf_build_set_property(COMPILE_OPTIONS "-w" APPEND) # Suppress all warnings (which are often reported as errors) 87 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/quakekeys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | 22 | #ifndef __QUAKEKEYS__ 23 | #define __QUAKEKEYS__ 24 | 25 | // 26 | // these are the key numbers that should be passed to Key_Event 27 | // 28 | #define K_TAB 9 29 | #define K_ENTER 13 30 | #define K_ESCAPE 27 31 | #define K_SPACE 32 32 | 33 | // normal keys should be passed as lowercased ascii 34 | 35 | #define K_BACKSPACE 127 36 | #define K_UPARROW 128 37 | #define K_DOWNARROW 129 38 | #define K_LEFTARROW 130 39 | #define K_RIGHTARROW 131 40 | 41 | #define K_ALT 132 42 | #define K_CTRL 133 43 | #define K_SHIFT 134 44 | #define K_F1 135 45 | #define K_F2 136 46 | #define K_F3 137 47 | #define K_F4 138 48 | #define K_F5 139 49 | #define K_F6 140 50 | #define K_F7 141 51 | #define K_F8 142 52 | #define K_F9 143 53 | #define K_F10 144 54 | #define K_F11 145 55 | #define K_F12 146 56 | #define K_INS 147 57 | #define K_DEL 148 58 | #define K_PGDN 149 59 | #define K_PGUP 150 60 | #define K_HOME 151 61 | #define K_END 152 62 | 63 | #define K_PAUSE 255 64 | 65 | // 66 | // mouse buttons generate virtual keys 67 | // 68 | #define K_MOUSE1 200 69 | #define K_MOUSE2 201 70 | #define K_MOUSE3 202 71 | 72 | // 73 | // joystick buttons 74 | // 75 | #define K_JOY1 203 76 | #define K_JOY2 204 77 | #define K_JOY3 205 78 | #define K_JOY4 206 79 | 80 | // 81 | // aux keys are for multi-buttoned joysticks to generate so they can use 82 | // the normal binding process 83 | // 84 | #define K_AUX1 207 85 | #define K_AUX2 208 86 | #define K_AUX3 209 87 | #define K_AUX4 210 88 | #define K_AUX5 211 89 | #define K_AUX6 212 90 | #define K_AUX7 213 91 | #define K_AUX8 214 92 | #define K_AUX9 215 93 | #define K_AUX10 216 94 | #define K_AUX11 217 95 | #define K_AUX12 218 96 | #define K_AUX13 219 97 | #define K_AUX14 220 98 | #define K_AUX15 221 99 | #define K_AUX16 222 100 | #define K_AUX17 223 101 | #define K_AUX18 224 102 | #define K_AUX19 225 103 | #define K_AUX20 226 104 | #define K_AUX21 227 105 | #define K_AUX22 228 106 | #define K_AUX23 229 107 | #define K_AUX24 230 108 | #define K_AUX25 231 109 | #define K_AUX26 232 110 | #define K_AUX27 233 111 | #define K_AUX28 234 112 | #define K_AUX29 235 113 | #define K_AUX30 236 114 | #define K_AUX31 237 115 | #define K_AUX32 238 116 | 117 | // JACK: Intellimouse(c) Mouse Wheel Support 118 | 119 | #define K_MWHEELUP 239 120 | #define K_MWHEELDOWN 240 121 | 122 | #endif /* __QUAKEKEYS __ */ 123 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/spritegn.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // spritegn.h: header file for sprite generation program 22 | // 23 | 24 | // ********************************************************** 25 | // * This file must be identical in the spritegen directory * 26 | // * and in the Quake directory, because it's used to * 27 | // * pass data from one to the other via .spr files. * 28 | // ********************************************************** 29 | 30 | //------------------------------------------------------- 31 | // This program generates .spr sprite package files. 32 | // The format of the files is as follows: 33 | // 34 | // dsprite_t file header structure 35 | // 36 | // 37 | // dspriteframe_t frame header structure 38 | // sprite bitmap 39 | // 40 | // dspriteframe_t frame header structure 41 | // sprite bitmap 42 | // 43 | //------------------------------------------------------- 44 | 45 | #ifdef INCLUDELIBS 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #include "cmdlib.h" 53 | #include "scriplib.h" 54 | #include "dictlib.h" 55 | #include "trilib.h" 56 | #include "lbmlib.h" 57 | #include "mathlib.h" 58 | 59 | #endif 60 | 61 | #define SPRITE_VERSION 1 62 | 63 | // must match definition in modelgen.h 64 | #ifndef SYNCTYPE_T 65 | #define SYNCTYPE_T 66 | typedef enum {ST_SYNC=0, ST_RAND } synctype_t; 67 | #endif 68 | 69 | // TODO: shorten these? 70 | typedef struct { 71 | int ident; 72 | int version; 73 | int type; 74 | float boundingradius; 75 | int width; 76 | int height; 77 | int numframes; 78 | float beamlength; 79 | synctype_t synctype; 80 | } dsprite_t; 81 | 82 | #define SPR_VP_PARALLEL_UPRIGHT 0 83 | #define SPR_FACING_UPRIGHT 1 84 | #define SPR_VP_PARALLEL 2 85 | #define SPR_ORIENTED 3 86 | #define SPR_VP_PARALLEL_ORIENTED 4 87 | 88 | typedef struct { 89 | int origin[2]; 90 | int width; 91 | int height; 92 | } dspriteframe_t; 93 | 94 | typedef struct { 95 | int numframes; 96 | } dspritegroup_t; 97 | 98 | typedef struct { 99 | float interval; 100 | } dspriteinterval_t; 101 | 102 | typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t; 103 | 104 | typedef struct { 105 | spriteframetype_t type; 106 | } dspriteframetype_t; 107 | 108 | #define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I') 109 | // little-endian "IDSP" 110 | 111 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_local.h: private rasterization driver defs 21 | 22 | #include "r_shared.h" 23 | 24 | // 25 | // TODO: fine-tune this; it's based on providing some overage even if there 26 | // is a 2k-wide scan, with subdivision every 8, for 256 spans of 12 bytes each 27 | // 28 | #define SCANBUFFERPAD 0x1000 29 | 30 | #define R_SKY_SMASK 0x007F0000 31 | #define R_SKY_TMASK 0x007F0000 32 | 33 | #define DS_SPAN_LIST_END -128 34 | 35 | #define SURFCACHE_SIZE_AT_320X200 600*1024 36 | 37 | typedef struct surfcache_s 38 | { 39 | struct surfcache_s *next; 40 | struct surfcache_s **owner; // NULL is an empty chunk of memory 41 | int lightadj[MAXLIGHTMAPS]; // checked for strobe flush 42 | int dlight; 43 | int size; // including header 44 | unsigned width; 45 | unsigned height; // DEBUG only needed for debug 46 | float mipscale; 47 | struct texture_s *texture; // checked for animating textures 48 | byte data[4]; // width*height elements 49 | } surfcache_t; 50 | 51 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 52 | typedef struct sspan_s 53 | { 54 | int u, v, count; 55 | } sspan_t; 56 | 57 | extern cvar_t d_subdiv16; 58 | 59 | extern float scale_for_mip; 60 | 61 | extern qboolean d_roverwrapped; 62 | extern surfcache_t *sc_rover; 63 | extern surfcache_t *d_initial_rover; 64 | 65 | extern float d_sdivzstepu, d_tdivzstepu, d_zistepu; 66 | extern float d_sdivzstepv, d_tdivzstepv, d_zistepv; 67 | extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin; 68 | 69 | extern fixed16_t sadjust, tadjust; 70 | extern fixed16_t bbextents, bbextentt; 71 | 72 | 73 | void D_DrawSpans8 (espan_t *pspans); 74 | void D_DrawSpans16 (espan_t *pspans); 75 | void D_DrawZSpans (espan_t *pspans); 76 | void Turbulent8 (espan_t *pspan); 77 | void D_SpriteDrawSpans (sspan_t *pspan); 78 | 79 | void D_DrawSkyScans8 (espan_t *pspan); 80 | void D_DrawSkyScans16 (espan_t *pspan); 81 | 82 | void R_ShowSubDiv (void); 83 | surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel); 84 | 85 | extern int D_MipLevelForScale (float scale); 86 | 87 | extern short *d_pzbuffer; 88 | extern unsigned int d_zrowbytes, d_zwidth; 89 | 90 | extern int *d_pscantable; 91 | extern int d_scantable[MAXHEIGHT]; 92 | 93 | extern int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; 94 | 95 | extern int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; 96 | 97 | extern pixel_t *d_viewbuffer; 98 | 99 | extern short *zspantable[MAXHEIGHT]; 100 | 101 | extern int d_minmip; 102 | extern float d_scalemip[3]; 103 | 104 | extern void (*d_drawspans) (espan_t *pspan); 105 | 106 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/data.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: data.c,v 1.8 2000/04/02 11:10:53 augustss Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1999 Lennart Augustsson 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | __FBSDID("$FreeBSD$"); 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "usbhid.h" 37 | #include "usbhid_bsd.h" 38 | #include "usbvar.h" 39 | 40 | int32_t 41 | hid_get_data(const void *p, const hid_item_t *h) 42 | { 43 | const uint8_t *buf; 44 | uint32_t hpos; 45 | uint32_t hsize; 46 | uint32_t data; 47 | int i, end, offs; 48 | 49 | buf = p; 50 | 51 | hpos = h->pos; /* bit position of data */ 52 | hsize = h->report_size; /* bit length of data */ 53 | 54 | /* Range check and limit */ 55 | if (hsize == 0) 56 | return (0); 57 | if (hsize > 32) 58 | hsize = 32; 59 | 60 | offs = hpos / 8; 61 | end = (hpos + hsize) / 8 - offs; 62 | data = 0; 63 | for (i = 0; i <= end; i++) 64 | data |= buf[offs + i] << (i*8); 65 | 66 | /* Correctly shift down data */ 67 | data >>= hpos % 8; 68 | hsize = 32 - hsize; 69 | 70 | /* Mask and sign extend in one */ 71 | if ((h->logical_minimum < 0) || (h->logical_maximum < 0)) 72 | data = (int32_t)((int32_t)data << hsize) >> hsize; 73 | else 74 | data = (uint32_t)((uint32_t)data << hsize) >> hsize; 75 | 76 | return (data); 77 | } 78 | 79 | void 80 | hid_set_data(void *p, const hid_item_t *h, int32_t data) 81 | { 82 | uint8_t *buf; 83 | uint32_t hpos; 84 | uint32_t hsize; 85 | uint32_t mask; 86 | int i; 87 | int end; 88 | int offs; 89 | 90 | buf = p; 91 | 92 | hpos = h->pos; /* bit position of data */ 93 | hsize = h->report_size; /* bit length of data */ 94 | 95 | if (hsize != 32) { 96 | mask = (1 << hsize) - 1; 97 | data &= mask; 98 | } else 99 | mask = ~0; 100 | 101 | data <<= (hpos % 8); 102 | mask <<= (hpos % 8); 103 | mask = ~mask; 104 | 105 | offs = hpos / 8; 106 | end = (hpos + hsize) / 8 - offs; 107 | 108 | for (i = 0; i <= end; i++) 109 | buf[offs + i] = (buf[offs + i] & (mask >> (i*8))) | 110 | ((data >> (i*8)) & 0xff); 111 | } 112 | 113 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # project 3 | cmake_minimum_required(VERSION 3.3) 4 | project(quakegeneric DESCRIPTION "portable quake" HOMEPAGE_URL https://github.com/erysdren/quakegeneric LANGUAGES C VERSION 1.0.9) 5 | set(CMAKE_BUILD_TYPE Release) 6 | set(CMAKE_C_STANDARD 99) 7 | set(CMAKE_C_STANDARD_REQUIRED TRUE) 8 | 9 | # compile options 10 | add_compile_options(-m32 -std=gnu99) 11 | add_link_options(-m32) 12 | 13 | # tinycc 14 | if(CMAKE_C_COMPILER_ID STREQUAL "TinyCC") 15 | add_compile_definitions(-DSDL_DISABLE_IMMINTRIN_H=1) 16 | endif() 17 | 18 | # find math library 19 | find_library(MATH m) 20 | if(MATH) 21 | link_libraries(${MATH}) 22 | endif() 23 | 24 | # sources 25 | set(QUAKEGENERIC_SOURCES 26 | ${PROJECT_SOURCE_DIR}/source/cd_null.c 27 | ${PROJECT_SOURCE_DIR}/source/chase.c 28 | ${PROJECT_SOURCE_DIR}/source/cl_demo.c 29 | ${PROJECT_SOURCE_DIR}/source/cl_input.c 30 | ${PROJECT_SOURCE_DIR}/source/cl_main.c 31 | ${PROJECT_SOURCE_DIR}/source/cl_parse.c 32 | ${PROJECT_SOURCE_DIR}/source/cl_tent.c 33 | ${PROJECT_SOURCE_DIR}/source/cmd.c 34 | ${PROJECT_SOURCE_DIR}/source/common.c 35 | ${PROJECT_SOURCE_DIR}/source/console.c 36 | ${PROJECT_SOURCE_DIR}/source/crc.c 37 | ${PROJECT_SOURCE_DIR}/source/cvar.c 38 | ${PROJECT_SOURCE_DIR}/source/d_edge.c 39 | ${PROJECT_SOURCE_DIR}/source/d_fill.c 40 | ${PROJECT_SOURCE_DIR}/source/d_init.c 41 | ${PROJECT_SOURCE_DIR}/source/d_modech.c 42 | ${PROJECT_SOURCE_DIR}/source/d_part.c 43 | ${PROJECT_SOURCE_DIR}/source/d_polyse.c 44 | ${PROJECT_SOURCE_DIR}/source/d_scan.c 45 | ${PROJECT_SOURCE_DIR}/source/d_sky.c 46 | ${PROJECT_SOURCE_DIR}/source/d_sprite.c 47 | ${PROJECT_SOURCE_DIR}/source/d_surf.c 48 | ${PROJECT_SOURCE_DIR}/source/d_vars.c 49 | ${PROJECT_SOURCE_DIR}/source/d_zpoint.c 50 | ${PROJECT_SOURCE_DIR}/source/draw.c 51 | ${PROJECT_SOURCE_DIR}/source/host_cmd.c 52 | ${PROJECT_SOURCE_DIR}/source/host.c 53 | ${PROJECT_SOURCE_DIR}/source/in_null.c 54 | ${PROJECT_SOURCE_DIR}/source/keys.c 55 | ${PROJECT_SOURCE_DIR}/source/mathlib.c 56 | ${PROJECT_SOURCE_DIR}/source/menu.c 57 | ${PROJECT_SOURCE_DIR}/source/model.c 58 | ${PROJECT_SOURCE_DIR}/source/net_loop.c 59 | ${PROJECT_SOURCE_DIR}/source/net_main.c 60 | ${PROJECT_SOURCE_DIR}/source/net_none.c 61 | ${PROJECT_SOURCE_DIR}/source/net_vcr.c 62 | ${PROJECT_SOURCE_DIR}/source/nonintel.c 63 | ${PROJECT_SOURCE_DIR}/source/pr_cmds.c 64 | ${PROJECT_SOURCE_DIR}/source/pr_edict.c 65 | ${PROJECT_SOURCE_DIR}/source/pr_exec.c 66 | ${PROJECT_SOURCE_DIR}/source/r_aclip.c 67 | ${PROJECT_SOURCE_DIR}/source/r_alias.c 68 | ${PROJECT_SOURCE_DIR}/source/r_bsp.c 69 | ${PROJECT_SOURCE_DIR}/source/r_draw.c 70 | ${PROJECT_SOURCE_DIR}/source/r_edge.c 71 | ${PROJECT_SOURCE_DIR}/source/r_efrag.c 72 | ${PROJECT_SOURCE_DIR}/source/r_light.c 73 | ${PROJECT_SOURCE_DIR}/source/r_main.c 74 | ${PROJECT_SOURCE_DIR}/source/r_misc.c 75 | ${PROJECT_SOURCE_DIR}/source/r_part.c 76 | ${PROJECT_SOURCE_DIR}/source/r_sky.c 77 | ${PROJECT_SOURCE_DIR}/source/r_sprite.c 78 | ${PROJECT_SOURCE_DIR}/source/r_surf.c 79 | ${PROJECT_SOURCE_DIR}/source/r_vars.c 80 | ${PROJECT_SOURCE_DIR}/source/sbar.c 81 | ${PROJECT_SOURCE_DIR}/source/screen.c 82 | ${PROJECT_SOURCE_DIR}/source/snd_null.c 83 | ${PROJECT_SOURCE_DIR}/source/sv_main.c 84 | ${PROJECT_SOURCE_DIR}/source/sv_move.c 85 | ${PROJECT_SOURCE_DIR}/source/sv_phys.c 86 | ${PROJECT_SOURCE_DIR}/source/sv_user.c 87 | ${PROJECT_SOURCE_DIR}/source/sys_null.c 88 | ${PROJECT_SOURCE_DIR}/source/vid_null.c 89 | ${PROJECT_SOURCE_DIR}/source/view.c 90 | ${PROJECT_SOURCE_DIR}/source/wad.c 91 | ${PROJECT_SOURCE_DIR}/source/world.c 92 | ${PROJECT_SOURCE_DIR}/source/zone.c 93 | ${PROJECT_SOURCE_DIR}/source/quakegeneric.c 94 | ) 95 | 96 | # library 97 | add_library(quakegeneric STATIC ${QUAKEGENERIC_SOURCES}) 98 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/modelgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // modelgen.h: header file for model generation program 22 | // 23 | 24 | // ********************************************************* 25 | // * This file must be identical in the modelgen directory * 26 | // * and in the Quake directory, because it's used to * 27 | // * pass data from one to the other via model files. * 28 | // ********************************************************* 29 | 30 | #ifdef INCLUDELIBS 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "cmdlib.h" 38 | #include "scriplib.h" 39 | #include "trilib.h" 40 | #include "lbmlib.h" 41 | #include "mathlib.h" 42 | 43 | #endif 44 | 45 | #define ALIAS_VERSION 6 46 | 47 | #define ALIAS_ONSEAM 0x0020 48 | 49 | // must match definition in spritegn.h 50 | #ifndef SYNCTYPE_T 51 | #define SYNCTYPE_T 52 | typedef enum {ST_SYNC=0, ST_RAND } synctype_t; 53 | #endif 54 | 55 | typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t; 56 | 57 | typedef enum { ALIAS_SKIN_SINGLE=0, ALIAS_SKIN_GROUP } aliasskintype_t; 58 | 59 | typedef struct { 60 | int ident; 61 | int version; 62 | vec3_t scale; 63 | vec3_t scale_origin; 64 | float boundingradius; 65 | vec3_t eyeposition; 66 | int numskins; 67 | int skinwidth; 68 | int skinheight; 69 | int numverts; 70 | int numtris; 71 | int numframes; 72 | synctype_t synctype; 73 | int flags; 74 | float size; 75 | } mdl_t; 76 | 77 | // TODO: could be shorts 78 | 79 | typedef struct { 80 | int onseam; 81 | int s; 82 | int t; 83 | } stvert_t; 84 | 85 | typedef struct dtriangle_s { 86 | int facesfront; 87 | int vertindex[3]; 88 | } dtriangle_t; 89 | 90 | #define DT_FACES_FRONT 0x0010 91 | 92 | // This mirrors trivert_t in trilib.h, is present so Quake knows how to 93 | // load this data 94 | 95 | typedef struct { 96 | byte v[3]; 97 | byte lightnormalindex; 98 | } trivertx_t; 99 | 100 | typedef struct { 101 | trivertx_t bboxmin; // lightnormal isn't used 102 | trivertx_t bboxmax; // lightnormal isn't used 103 | char name[16]; // frame name from grabbing 104 | } daliasframe_t; 105 | 106 | typedef struct { 107 | int numframes; 108 | trivertx_t bboxmin; // lightnormal isn't used 109 | trivertx_t bboxmax; // lightnormal isn't used 110 | } daliasgroup_t; 111 | 112 | typedef struct { 113 | int numskins; 114 | } daliasskingroup_t; 115 | 116 | typedef struct { 117 | float interval; 118 | } daliasinterval_t; 119 | 120 | typedef struct { 121 | float interval; 122 | } daliasskininterval_t; 123 | 124 | typedef struct { 125 | aliasframetype_t type; 126 | } daliasframetype_t; 127 | 128 | typedef struct { 129 | aliasskintype_t type; 130 | } daliasskintype_t; 131 | 132 | #define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I') 133 | // little-endian "IDPO" 134 | 135 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/crc.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* crc.c */ 21 | 22 | #include "quakedef.h" 23 | #include "crc.h" 24 | 25 | // this is a 16 bit, non-reflected CRC using the polynomial 0x1021 26 | // and the initial and final xor values shown below... in other words, the 27 | // CCITT standard CRC used by XMODEM 28 | 29 | #define CRC_INIT_VALUE 0xffff 30 | #define CRC_XOR_VALUE 0x0000 31 | 32 | static unsigned short crctable[256] = 33 | { 34 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 35 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 36 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 37 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 38 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 39 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 40 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 41 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 42 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 43 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 44 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 45 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 46 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 47 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 48 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 49 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 50 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 51 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 52 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 53 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 54 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 55 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 56 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 57 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 58 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 59 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 60 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 61 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 62 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 63 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 64 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 65 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 66 | }; 67 | 68 | void CRC_Init(unsigned short *crcvalue) 69 | { 70 | *crcvalue = CRC_INIT_VALUE; 71 | } 72 | 73 | void CRC_ProcessByte(unsigned short *crcvalue, byte data) 74 | { 75 | *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; 76 | } 77 | 78 | unsigned short CRC_Value(unsigned short crcvalue) 79 | { 80 | return crcvalue ^ CRC_XOR_VALUE; 81 | } 82 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/cvar.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // cvar.h 21 | 22 | /* 23 | 24 | cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly 25 | in C code. 26 | 27 | it is sufficient to initialize a cvar_t with just the first two fields, or 28 | you can add a ,true flag for variables that you want saved to the configuration 29 | file when the game is quit: 30 | 31 | cvar_t r_draworder = {"r_draworder","1"}; 32 | cvar_t scr_screensize = {"screensize","1",true}; 33 | 34 | Cvars must be registered before use, or they will have a 0 value instead of the float interpretation of the string. Generally, all cvar_t declarations should be registered in the apropriate init function before any console commands are executed: 35 | Cvar_RegisterVariable (&host_framerate); 36 | 37 | 38 | C code usually just references a cvar in place: 39 | if ( r_draworder.value ) 40 | 41 | It could optionally ask for the value to be looked up for a string name: 42 | if (Cvar_VariableValue ("r_draworder")) 43 | 44 | Interpreted prog code can access cvars with the cvar(name) or 45 | cvar_set (name, value) internal functions: 46 | teamplay = cvar("teamplay"); 47 | cvar_set ("registered", "1"); 48 | 49 | The user can access cvars from the console in two ways: 50 | r_draworder prints the current value 51 | r_draworder 0 sets the current value to 0 52 | Cvars are restricted from having the same names as commands to keep this 53 | interface from being ambiguous. 54 | */ 55 | 56 | typedef struct cvar_s 57 | { 58 | char *name; 59 | char *string; 60 | qboolean archive; // set to true to cause it to be saved to vars.rc 61 | qboolean server; // notifies players when changed 62 | float value; 63 | struct cvar_s *next; 64 | } cvar_t; 65 | 66 | void Cvar_RegisterVariable (cvar_t *variable); 67 | // registers a cvar that allready has the name, string, and optionally the 68 | // archive elements set. 69 | 70 | void Cvar_Set (char *var_name, char *value); 71 | // equivelant to " " typed at the console 72 | 73 | void Cvar_SetValue (char *var_name, float value); 74 | // expands value to a string and calls Cvar_Set 75 | 76 | float Cvar_VariableValue (char *var_name); 77 | // returns 0 if not defined or non numeric 78 | 79 | char *Cvar_VariableString (char *var_name); 80 | // returns an empty string if not defined 81 | 82 | char *Cvar_CompleteVariable (char *partial); 83 | // attempts to match a partial variable name for command line completion 84 | // returns NULL if nothing fits 85 | 86 | qboolean Cvar_Command (void); 87 | // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known 88 | // command. Returns true if the command was a variable reference that 89 | // was handled. (print or change) 90 | 91 | void Cvar_WriteVariables (FILE *f); 92 | // Writes lines containing "set variable value" for all variables 93 | // with the archive flag set to true. 94 | 95 | cvar_t *Cvar_FindVar (char *var_name); 96 | 97 | extern cvar_t *cvar_vars; 98 | -------------------------------------------------------------------------------- /main/audio.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "bsp/esp-bsp.h" 16 | #include "esp_codec_dev_defaults.h" 17 | #include "esp_codec_dev.h" 18 | #include "driver/i2c_master.h" 19 | #include "driver/i2s_std.h" 20 | #include "freertos/FreeRTOS.h" 21 | #include "freertos/task.h" 22 | #include "freertos/semphr.h" 23 | 24 | 25 | #include "quakedef.h" 26 | 27 | #define DEFAULT_VOLUME 50 28 | 29 | static esp_codec_dev_handle_t spk_codec_dev; 30 | int snd_inited; 31 | 32 | //note: keep >64 and power of 2 33 | #define BUFFER_SIZE (16*1024) 34 | 35 | unsigned char dma_buffer[BUFFER_SIZE]; 36 | 37 | int dma_rpos; 38 | 39 | void CDAudio_get_samps(char *samps, int len_bytes); 40 | 41 | #define CHUNKSZ (BUFFER_SIZE/8) 42 | void audio_task(void *param) { 43 | printf("audio task running\n"); 44 | //simulate DMA to audio; just write the DMA buffer in a circular fashion. 45 | int16_t *mix_buf=calloc(CHUNKSZ/2, sizeof(int16_t)); 46 | int old_volume=-1; 47 | while(1) { 48 | int mainvolume = (int)(volume.value * 100.0); 49 | if (mainvolume!=old_volume) { 50 | esp_codec_dev_set_out_vol(spk_codec_dev, mainvolume); 51 | old_volume=mainvolume; 52 | printf("Set volume %f\n", mainvolume); 53 | } 54 | int cdvol = (int)(bgmvolume.value * 255.0); 55 | 56 | CDAudio_get_samps((char*)mix_buf, CHUNKSZ); 57 | int16_t *digaudio=(int16_t*)&dma_buffer[dma_rpos]; 58 | //Mix CD audio and digi samples 59 | for (int i=0; isplitbuffer = 0; 88 | shm->speed = 44100; 89 | shm->samplebits = 16; 90 | shm->channels = 2; 91 | shm->soundalive = true; 92 | shm->samples = sizeof(dma_buffer) / (shm->samplebits/8); 93 | shm->samplepos = 0; 94 | shm->submission_chunk = 1; 95 | shm->buffer = (unsigned char *)dma_buffer; 96 | snd_inited = 1; 97 | Con_Printf("16 bit stereo sound initialized\n"); 98 | xTaskCreatePinnedToCore(audio_task, "audio", 4096, NULL, 7, NULL, 1); 99 | return 1; 100 | } 101 | 102 | int SNDDMA_GetDMAPos(void) //in (e.g. 16-bit) samples 103 | { 104 | if (!snd_inited) return (0); 105 | shm->samplepos=dma_rpos / (shm->samplebits / 8); 106 | return shm->samplepos; 107 | } 108 | 109 | void SNDDMA_Shutdown(void) 110 | { 111 | if (snd_inited) { 112 | snd_inited = 0; 113 | } 114 | } 115 | 116 | //Send sound to device if buffer isn't really the dma buffer 117 | void SNDDMA_Submit(void) 118 | { 119 | } 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/zone.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* 21 | memory allocation 22 | 23 | 24 | H_??? The hunk manages the entire memory block given to quake. It must be 25 | contiguous. Memory can be allocated from either the low or high end in a 26 | stack fashion. The only way memory is released is by resetting one of the 27 | pointers. 28 | 29 | Hunk allocations should be given a name, so the Hunk_Print () function 30 | can display usage. 31 | 32 | Hunk allocations are guaranteed to be 16 byte aligned. 33 | 34 | The video buffers are allocated high to avoid leaving a hole underneath 35 | server allocations when changing to a higher video mode. 36 | 37 | 38 | Z_??? Zone memory functions used for small, dynamic allocations like text 39 | strings from command input. There is only about 48K for it, allocated at 40 | the very bottom of the hunk. 41 | 42 | Cache_??? Cache memory is for objects that can be dynamically loaded and 43 | can usefully stay persistant between levels. The size of the cache 44 | fluctuates from level to level. 45 | 46 | To allocate a cachable object 47 | 48 | 49 | Temp_??? Temp memory is used for file loading and surface caching. The size 50 | of the cache memory is adjusted so that there is a minimum of 512k remaining 51 | for temp memory. 52 | 53 | 54 | ------ Top of Memory ------- 55 | 56 | high hunk allocations 57 | 58 | <--- high hunk reset point held by vid 59 | 60 | video buffer 61 | 62 | z buffer 63 | 64 | surface cache 65 | 66 | <--- high hunk used 67 | 68 | cachable memory 69 | 70 | <--- low hunk used 71 | 72 | client and server low hunk allocations 73 | 74 | <-- low hunk reset point held by host 75 | 76 | startup hunk allocations 77 | 78 | Zone block 79 | 80 | ----- Bottom of Memory ----- 81 | 82 | 83 | 84 | */ 85 | 86 | void Memory_Init (void *buf, int size); 87 | 88 | void Z_Free (void *ptr); 89 | void *Z_Malloc (int size); // returns 0 filled memory 90 | void *Z_TagMalloc (int size, int tag); 91 | 92 | void Z_DumpHeap (void); 93 | void Z_CheckHeap (void); 94 | int Z_FreeMemory (void); 95 | 96 | void *Hunk_Alloc (int size); // returns 0 filled memory 97 | void *Hunk_AllocName (int size, char *name); 98 | 99 | void *Hunk_HighAllocName (int size, char *name); 100 | 101 | int Hunk_LowMark (void); 102 | void Hunk_FreeToLowMark (int mark); 103 | 104 | int Hunk_HighMark (void); 105 | void Hunk_FreeToHighMark (int mark); 106 | 107 | void *Hunk_TempAlloc (int size); 108 | 109 | void Hunk_Check (void); 110 | 111 | typedef struct cache_user_s 112 | { 113 | void *data; 114 | } cache_user_t; 115 | 116 | void Cache_Flush (void); 117 | 118 | void *Cache_Check (cache_user_t *c); 119 | // returns the cached data, and moves to the head of the LRU list 120 | // if present, otherwise returns NULL 121 | 122 | void Cache_Free (cache_user_t *c); 123 | 124 | void *Cache_Alloc (cache_user_t *c, int size, char *name); 125 | // Returns NULL if all purgable data was tossed and there still 126 | // wasn't enough room. 127 | 128 | void Cache_Report (void); 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_sky.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_sky.c 21 | 22 | #include "quakedef.h" 23 | #include "r_local.h" 24 | #include "d_local.h" 25 | 26 | #define SKY_SPAN_SHIFT 5 27 | #define SKY_SPAN_MAX (1 << SKY_SPAN_SHIFT) 28 | 29 | 30 | /* 31 | ================= 32 | D_Sky_uv_To_st 33 | ================= 34 | */ 35 | void D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t) 36 | { 37 | float wu, wv, temp; 38 | vec3_t end; 39 | 40 | if (r_refdef.vrect.width >= r_refdef.vrect.height) 41 | temp = (float)r_refdef.vrect.width; 42 | else 43 | temp = (float)r_refdef.vrect.height; 44 | 45 | wu = 8192.0 * (float)(u-((int)vid.width>>1)) / temp; 46 | wv = 8192.0 * (float)(((int)vid.height>>1)-v) / temp; 47 | 48 | end[0] = 4096*vpn[0] + wu*vright[0] + wv*vup[0]; 49 | end[1] = 4096*vpn[1] + wu*vright[1] + wv*vup[1]; 50 | end[2] = 4096*vpn[2] + wu*vright[2] + wv*vup[2]; 51 | end[2] *= 3; 52 | VectorNormalize (end); 53 | 54 | temp = skytime*skyspeed; // TODO: add D_SetupFrame & set this there 55 | *s = (int)((temp + 6*(SKYSIZE/2-1)*end[0]) * 0x10000); 56 | *t = (int)((temp + 6*(SKYSIZE/2-1)*end[1]) * 0x10000); 57 | } 58 | 59 | 60 | /* 61 | ================= 62 | D_DrawSkyScans8 63 | ================= 64 | */ 65 | void D_DrawSkyScans8 (espan_t *pspan) 66 | { 67 | int count, spancount, u, v; 68 | unsigned char *pdest; 69 | fixed16_t s, t, snext, tnext, sstep, tstep; 70 | int spancountminus1; 71 | 72 | sstep = 0; // keep compiler happy 73 | tstep = 0; // ditto 74 | 75 | do 76 | { 77 | pdest = (unsigned char *)((byte *)d_viewbuffer + 78 | (screenwidth * pspan->v) + pspan->u); 79 | 80 | count = pspan->count; 81 | 82 | // calculate the initial s & t 83 | u = pspan->u; 84 | v = pspan->v; 85 | D_Sky_uv_To_st (u, v, &s, &t); 86 | 87 | do 88 | { 89 | if (count >= SKY_SPAN_MAX) 90 | spancount = SKY_SPAN_MAX; 91 | else 92 | spancount = count; 93 | 94 | count -= spancount; 95 | 96 | if (count) 97 | { 98 | u += spancount; 99 | 100 | // calculate s and t at far end of span, 101 | // calculate s and t steps across span by shifting 102 | D_Sky_uv_To_st (u, v, &snext, &tnext); 103 | 104 | sstep = (snext - s) >> SKY_SPAN_SHIFT; 105 | tstep = (tnext - t) >> SKY_SPAN_SHIFT; 106 | } 107 | else 108 | { 109 | // calculate s and t at last pixel in span, 110 | // calculate s and t steps across span by division 111 | spancountminus1 = (float)(spancount - 1); 112 | 113 | if (spancountminus1 > 0) 114 | { 115 | u += spancountminus1; 116 | D_Sky_uv_To_st (u, v, &snext, &tnext); 117 | 118 | sstep = (snext - s) / spancountminus1; 119 | tstep = (tnext - t) / spancountminus1; 120 | } 121 | } 122 | 123 | do 124 | { 125 | *pdest++ = r_skysource[((t & R_SKY_TMASK) >> 8) + 126 | ((s & R_SKY_SMASK) >> 16)]; 127 | s += sstep; 128 | t += tstep; 129 | } while (--spancount > 0); 130 | 131 | s = snext; 132 | t = tnext; 133 | 134 | } while (count > 0); 135 | 136 | } while ((pspan = pspan->pnext) != NULL); 137 | } 138 | 139 | -------------------------------------------------------------------------------- /components/hid_ev/libusbhid/usbhid.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: usb.h,v 1.8 2000/08/13 22:22:02 augustss Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1999 Lennart Augustsson 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * $FreeBSD$ 29 | * 30 | */ 31 | 32 | #include 33 | 34 | typedef struct report_desc *report_desc_t; 35 | 36 | typedef struct hid_data *hid_data_t; 37 | 38 | typedef enum hid_kind { 39 | hid_input, hid_output, hid_feature, hid_collection, hid_endcollection 40 | } hid_kind_t; 41 | 42 | typedef struct hid_item { 43 | /* Global */ 44 | uint32_t _usage_page; 45 | int32_t logical_minimum; 46 | int32_t logical_maximum; 47 | int32_t physical_minimum; 48 | int32_t physical_maximum; 49 | int32_t unit_exponent; 50 | int32_t unit; 51 | int32_t report_size; 52 | int32_t report_ID; 53 | #define NO_REPORT_ID 0 54 | int32_t report_count; 55 | /* Local */ 56 | uint32_t usage; 57 | int32_t usage_minimum; 58 | int32_t usage_maximum; 59 | int32_t designator_index; 60 | int32_t designator_minimum; 61 | int32_t designator_maximum; 62 | int32_t string_index; 63 | int32_t string_minimum; 64 | int32_t string_maximum; 65 | int32_t set_delimiter; 66 | /* Misc */ 67 | int32_t collection; 68 | int collevel; 69 | enum hid_kind kind; 70 | uint32_t flags; 71 | /* Location */ 72 | uint32_t pos; 73 | /* unused */ 74 | struct hid_item *next; 75 | } hid_item_t; 76 | 77 | #define HID_PAGE(u) (((u) >> 16) & 0xffff) 78 | #define HID_USAGE(u) ((u) & 0xffff) 79 | #define HID_HAS_GET_SET_REPORT 1 80 | 81 | 82 | /* Obtaining a report descriptor, descr.c: */ 83 | report_desc_t hid_use_report_desc(unsigned char *data, unsigned int size); 84 | void hid_dispose_report_desc(report_desc_t); 85 | 86 | /* Parsing of a HID report descriptor, parse.c: */ 87 | hid_data_t hid_start_parse(report_desc_t d, int kindset, int id); 88 | void hid_end_parse(hid_data_t s); 89 | int hid_get_item(hid_data_t s, hid_item_t *h); 90 | int hid_report_size(report_desc_t d, enum hid_kind k, int id); 91 | int hid_locate(report_desc_t d, unsigned int usage, enum hid_kind k, 92 | hid_item_t *h, int id); 93 | 94 | /* Conversion to/from usage names, usage.c: */ 95 | const char *hid_usage_page(int i); 96 | const char *hid_usage_in_page(unsigned int u); 97 | void hid_init(const char *file); 98 | int hid_parse_usage_in_page(const char *name); 99 | int hid_parse_usage_page(const char *name); 100 | 101 | /* Extracting/insertion of data, data.c: */ 102 | int32_t hid_get_data(const void *p, const hid_item_t *h); 103 | void hid_set_data(void *p, const hid_item_t *h, int32_t data); 104 | 105 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_init.c: rasterization driver initialization 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | #define NUM_MIPS 4 26 | 27 | cvar_t d_subdiv16 = {"d_subdiv16", "1"}; 28 | cvar_t d_mipcap = {"d_mipcap", "0"}; 29 | cvar_t d_mipscale = {"d_mipscale", "1"}; 30 | 31 | surfcache_t *d_initial_rover; 32 | qboolean d_roverwrapped; 33 | int d_minmip; 34 | float d_scalemip[NUM_MIPS-1]; 35 | 36 | static float basemip[NUM_MIPS-1] = {1.0, 0.5*0.8, 0.25*0.8}; 37 | 38 | extern int d_aflatcolor; 39 | 40 | void (*d_drawspans) (espan_t *pspan); 41 | 42 | 43 | /* 44 | =============== 45 | D_Init 46 | =============== 47 | */ 48 | void D_Init (void) 49 | { 50 | 51 | r_skydirect = 1; 52 | 53 | Cvar_RegisterVariable (&d_subdiv16); 54 | Cvar_RegisterVariable (&d_mipcap); 55 | Cvar_RegisterVariable (&d_mipscale); 56 | 57 | r_drawpolys = false; 58 | r_worldpolysbacktofront = false; 59 | r_recursiveaffinetriangles = true; 60 | r_aliasuvscale = 1.0; 61 | } 62 | 63 | 64 | /* 65 | =============== 66 | D_CopyRects 67 | =============== 68 | */ 69 | void D_CopyRects (vrect_t *prects, int transparent) 70 | { 71 | 72 | // this function is only required if the CPU doesn't have direct access to the 73 | // back buffer, and there's some driver interface function that the driver 74 | // doesn't support and requires Quake to do in software (such as drawing the 75 | // console); Quake will then draw into wherever the driver points vid.buffer 76 | // and will call this function before swapping buffers 77 | 78 | UNUSED(prects); 79 | UNUSED(transparent); 80 | } 81 | 82 | 83 | /* 84 | =============== 85 | D_EnableBackBufferAccess 86 | =============== 87 | */ 88 | void D_EnableBackBufferAccess (void) 89 | { 90 | VID_LockBuffer (); 91 | } 92 | 93 | 94 | /* 95 | =============== 96 | D_TurnZOn 97 | =============== 98 | */ 99 | void D_TurnZOn (void) 100 | { 101 | // not needed for software version 102 | } 103 | 104 | 105 | /* 106 | =============== 107 | D_DisableBackBufferAccess 108 | =============== 109 | */ 110 | void D_DisableBackBufferAccess (void) 111 | { 112 | VID_UnlockBuffer (); 113 | } 114 | 115 | 116 | /* 117 | =============== 118 | D_SetupFrame 119 | =============== 120 | */ 121 | void D_SetupFrame (void) 122 | { 123 | int i; 124 | 125 | if (r_dowarp) 126 | d_viewbuffer = r_warpbuffer; 127 | else 128 | d_viewbuffer = (void *)(byte *)vid.buffer; 129 | 130 | if (r_dowarp) 131 | screenwidth = WARP_WIDTH; 132 | else 133 | screenwidth = vid.rowbytes; 134 | 135 | d_roverwrapped = false; 136 | d_initial_rover = sc_rover; 137 | 138 | d_minmip = d_mipcap.value; 139 | if (d_minmip > 3) 140 | d_minmip = 3; 141 | else if (d_minmip < 0) 142 | d_minmip = 0; 143 | 144 | for (i=0 ; i<(NUM_MIPS-1) ; i++) 145 | d_scalemip[i] = basemip[i] * d_mipscale.value; 146 | d_drawspans = D_DrawSpans8; 147 | 148 | d_aflatcolor = 0; 149 | } 150 | 151 | 152 | /* 153 | =============== 154 | D_UpdateRects 155 | =============== 156 | */ 157 | void D_UpdateRects (vrect_t *prect) 158 | { 159 | 160 | // the software driver draws these directly to the vid buffer 161 | 162 | UNUSED(prect); 163 | } 164 | 165 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/pr_comp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // this file is shared by quake and qcc 22 | 23 | typedef int func_t; 24 | typedef int string_t; 25 | 26 | typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; 27 | 28 | 29 | #define OFS_NULL 0 30 | #define OFS_RETURN 1 31 | #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors 32 | #define OFS_PARM1 7 33 | #define OFS_PARM2 10 34 | #define OFS_PARM3 13 35 | #define OFS_PARM4 16 36 | #define OFS_PARM5 19 37 | #define OFS_PARM6 22 38 | #define OFS_PARM7 25 39 | #define RESERVED_OFS 28 40 | 41 | 42 | enum { 43 | OP_DONE, 44 | OP_MUL_F, 45 | OP_MUL_V, 46 | OP_MUL_FV, 47 | OP_MUL_VF, 48 | OP_DIV_F, 49 | OP_ADD_F, 50 | OP_ADD_V, 51 | OP_SUB_F, 52 | OP_SUB_V, 53 | 54 | OP_EQ_F, 55 | OP_EQ_V, 56 | OP_EQ_S, 57 | OP_EQ_E, 58 | OP_EQ_FNC, 59 | 60 | OP_NE_F, 61 | OP_NE_V, 62 | OP_NE_S, 63 | OP_NE_E, 64 | OP_NE_FNC, 65 | 66 | OP_LE, 67 | OP_GE, 68 | OP_LT, 69 | OP_GT, 70 | 71 | OP_LOAD_F, 72 | OP_LOAD_V, 73 | OP_LOAD_S, 74 | OP_LOAD_ENT, 75 | OP_LOAD_FLD, 76 | OP_LOAD_FNC, 77 | 78 | OP_ADDRESS, 79 | 80 | OP_STORE_F, 81 | OP_STORE_V, 82 | OP_STORE_S, 83 | OP_STORE_ENT, 84 | OP_STORE_FLD, 85 | OP_STORE_FNC, 86 | 87 | OP_STOREP_F, 88 | OP_STOREP_V, 89 | OP_STOREP_S, 90 | OP_STOREP_ENT, 91 | OP_STOREP_FLD, 92 | OP_STOREP_FNC, 93 | 94 | OP_RETURN, 95 | OP_NOT_F, 96 | OP_NOT_V, 97 | OP_NOT_S, 98 | OP_NOT_ENT, 99 | OP_NOT_FNC, 100 | OP_IF, 101 | OP_IFNOT, 102 | OP_CALL0, 103 | OP_CALL1, 104 | OP_CALL2, 105 | OP_CALL3, 106 | OP_CALL4, 107 | OP_CALL5, 108 | OP_CALL6, 109 | OP_CALL7, 110 | OP_CALL8, 111 | OP_STATE, 112 | OP_GOTO, 113 | OP_AND, 114 | OP_OR, 115 | 116 | OP_BITAND, 117 | OP_BITOR 118 | }; 119 | 120 | 121 | typedef struct statement_s 122 | { 123 | unsigned short op; 124 | short a,b,c; 125 | } dstatement_t; 126 | 127 | typedef struct 128 | { 129 | unsigned short type; // if DEF_SAVEGLOBGAL bit is set 130 | // the variable needs to be saved in savegames 131 | unsigned short ofs; 132 | int s_name; 133 | } ddef_t; 134 | #define DEF_SAVEGLOBAL (1<<15) 135 | 136 | #define MAX_PARMS 8 137 | 138 | typedef struct 139 | { 140 | int first_statement; // negative numbers are builtins 141 | int parm_start; 142 | int locals; // total ints of parms + locals 143 | 144 | int profile; // runtime 145 | 146 | int s_name; 147 | int s_file; // source file defined in 148 | 149 | int numparms; 150 | byte parm_size[MAX_PARMS]; 151 | } dfunction_t; 152 | 153 | 154 | #define PROG_VERSION 6 155 | typedef struct 156 | { 157 | int version; 158 | int crc; // check of header file 159 | 160 | int ofs_statements; 161 | int numstatements; // statement 0 is an error 162 | 163 | int ofs_globaldefs; 164 | int numglobaldefs; 165 | 166 | int ofs_fielddefs; 167 | int numfielddefs; 168 | 169 | int ofs_functions; 170 | int numfunctions; // function 0 is an empty 171 | 172 | int ofs_strings; 173 | int numstrings; // first string is a null string 174 | 175 | int ofs_globals; 176 | int numglobals; 177 | 178 | int entityfields; 179 | } dprograms_t; 180 | 181 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/progdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | /* file generated by qcc, do not modify */ 22 | 23 | typedef struct 24 | { int pad[28]; 25 | int self; 26 | int other; 27 | int world; 28 | float time; 29 | float frametime; 30 | float force_retouch; 31 | string_t mapname; 32 | float deathmatch; 33 | float coop; 34 | float teamplay; 35 | float serverflags; 36 | float total_secrets; 37 | float total_monsters; 38 | float found_secrets; 39 | float killed_monsters; 40 | float parm1; 41 | float parm2; 42 | float parm3; 43 | float parm4; 44 | float parm5; 45 | float parm6; 46 | float parm7; 47 | float parm8; 48 | float parm9; 49 | float parm10; 50 | float parm11; 51 | float parm12; 52 | float parm13; 53 | float parm14; 54 | float parm15; 55 | float parm16; 56 | vec3_t v_forward; 57 | vec3_t v_up; 58 | vec3_t v_right; 59 | float trace_allsolid; 60 | float trace_startsolid; 61 | float trace_fraction; 62 | vec3_t trace_endpos; 63 | vec3_t trace_plane_normal; 64 | float trace_plane_dist; 65 | int trace_ent; 66 | float trace_inopen; 67 | float trace_inwater; 68 | int msg_entity; 69 | func_t main; 70 | func_t StartFrame; 71 | func_t PlayerPreThink; 72 | func_t PlayerPostThink; 73 | func_t ClientKill; 74 | func_t ClientConnect; 75 | func_t PutClientInServer; 76 | func_t ClientDisconnect; 77 | func_t SetNewParms; 78 | func_t SetChangeParms; 79 | } globalvars_t; 80 | 81 | typedef struct 82 | { 83 | float modelindex; 84 | vec3_t absmin; 85 | vec3_t absmax; 86 | float ltime; 87 | float movetype; 88 | float solid; 89 | vec3_t origin; 90 | vec3_t oldorigin; 91 | vec3_t velocity; 92 | vec3_t angles; 93 | vec3_t avelocity; 94 | vec3_t punchangle; 95 | string_t classname; 96 | string_t model; 97 | float frame; 98 | float skin; 99 | float effects; 100 | vec3_t mins; 101 | vec3_t maxs; 102 | vec3_t size; 103 | func_t touch; 104 | func_t use; 105 | func_t think; 106 | func_t blocked; 107 | float nextthink; 108 | int groundentity; 109 | float health; 110 | float frags; 111 | float weapon; 112 | string_t weaponmodel; 113 | float weaponframe; 114 | float currentammo; 115 | float ammo_shells; 116 | float ammo_nails; 117 | float ammo_rockets; 118 | float ammo_cells; 119 | float items; 120 | float takedamage; 121 | int chain; 122 | float deadflag; 123 | vec3_t view_ofs; 124 | float button0; 125 | float button1; 126 | float button2; 127 | float impulse; 128 | float fixangle; 129 | vec3_t v_angle; 130 | float idealpitch; 131 | string_t netname; 132 | int enemy; 133 | float flags; 134 | float colormap; 135 | float team; 136 | float max_health; 137 | float teleport_time; 138 | float armortype; 139 | float armorvalue; 140 | float waterlevel; 141 | float watertype; 142 | float ideal_yaw; 143 | float yaw_speed; 144 | int aiment; 145 | int goalentity; 146 | float spawnflags; 147 | string_t target; 148 | string_t targetname; 149 | float dmg_take; 150 | float dmg_save; 151 | int dmg_inflictor; 152 | int owner; 153 | vec3_t movedir; 154 | string_t message; 155 | float sounds; 156 | string_t noise; 157 | string_t noise1; 158 | string_t noise2; 159 | string_t noise3; 160 | } entvars_t; 161 | 162 | #define PROGHEADER_CRC 5927 163 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/wad.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // wad.c 21 | 22 | #include "quakedef.h" 23 | 24 | int wad_numlumps; 25 | lumpinfo_t *wad_lumps; 26 | byte *wad_base; 27 | 28 | void SwapPic (qpic_t *pic); 29 | 30 | /* 31 | ================== 32 | W_CleanupName 33 | 34 | Lowercases name and pads with spaces and a terminating 0 to the length of 35 | lumpinfo_t->name. 36 | Used so lumpname lookups can proceed rapidly by comparing 4 chars at a time 37 | Space padding is so names can be printed nicely in tables. 38 | Can safely be performed in place. 39 | ================== 40 | */ 41 | void W_CleanupName (char *in, char *out) 42 | { 43 | int i; 44 | int c; 45 | 46 | for (i=0 ; i<16 ; i++ ) 47 | { 48 | c = in[i]; 49 | if (!c) 50 | break; 51 | 52 | if (c >= 'A' && c <= 'Z') 53 | c += ('a' - 'A'); 54 | out[i] = c; 55 | } 56 | 57 | for ( ; i< 16 ; i++ ) 58 | out[i] = 0; 59 | } 60 | 61 | 62 | 63 | /* 64 | ==================== 65 | W_LoadWadFile 66 | ==================== 67 | */ 68 | void W_LoadWadFile (char *filename) 69 | { 70 | lumpinfo_t *lump_p; 71 | wadinfo_t *header; 72 | unsigned i; 73 | int infotableofs; 74 | 75 | wad_base = COM_LoadHunkFile (filename); 76 | if (!wad_base) 77 | Sys_Error ("W_LoadWadFile: couldn't load %s", filename); 78 | 79 | header = (wadinfo_t *)wad_base; 80 | 81 | if (header->identification[0] != 'W' 82 | || header->identification[1] != 'A' 83 | || header->identification[2] != 'D' 84 | || header->identification[3] != '2') 85 | Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename); 86 | 87 | wad_numlumps = LittleLong(header->numlumps); 88 | infotableofs = LittleLong(header->infotableofs); 89 | wad_lumps = (lumpinfo_t *)(wad_base + infotableofs); 90 | 91 | for (i=0, lump_p = wad_lumps ; ifilepos = LittleLong(lump_p->filepos); 94 | lump_p->size = LittleLong(lump_p->size); 95 | W_CleanupName (lump_p->name, lump_p->name); 96 | if (lump_p->type == TYP_QPIC) 97 | SwapPic ( (qpic_t *)(wad_base + lump_p->filepos)); 98 | } 99 | } 100 | 101 | 102 | /* 103 | ============= 104 | W_GetLumpinfo 105 | ============= 106 | */ 107 | lumpinfo_t *W_GetLumpinfo (char *name) 108 | { 109 | int i; 110 | lumpinfo_t *lump_p; 111 | char clean[16]; 112 | 113 | W_CleanupName (name, clean); 114 | 115 | for (lump_p=wad_lumps, i=0 ; iname)) 118 | return lump_p; 119 | } 120 | 121 | Sys_Error ("W_GetLumpinfo: %s not found", name); 122 | return NULL; 123 | } 124 | 125 | void *W_GetLumpName (char *name) 126 | { 127 | lumpinfo_t *lump; 128 | 129 | lump = W_GetLumpinfo (name); 130 | 131 | return (void *)(wad_base + lump->filepos); 132 | } 133 | 134 | void *W_GetLumpNum (int num) 135 | { 136 | lumpinfo_t *lump; 137 | 138 | if (num < 0 || num > wad_numlumps) 139 | Sys_Error ("W_GetLumpNum: bad number: %i", num); 140 | 141 | lump = wad_lumps + num; 142 | 143 | return (void *)(wad_base + lump->filepos); 144 | } 145 | 146 | /* 147 | ============================================================================= 148 | 149 | automatic byte swapping 150 | 151 | ============================================================================= 152 | */ 153 | 154 | void SwapPic (qpic_t *pic) 155 | { 156 | pic->width = LittleLong(pic->width); 157 | pic->height = LittleLong(pic->height); 158 | } 159 | -------------------------------------------------------------------------------- /main/input.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "quakegeneric.h" 22 | #include "freertos/FreeRTOS.h" 23 | #include "freertos/task.h" 24 | #include "freertos/semphr.h" 25 | #include "usb_hid.h" 26 | #include "hid_keys.h" 27 | #include "quakekeys.h" 28 | 29 | //Mapping between USB HID keys and Quake engine keys 30 | const uint16_t key_conv_tab[]={ 31 | [KEY_TAB]=K_TAB, 32 | [KEY_ENTER]=K_ENTER, 33 | [KEY_ESC]=K_ESCAPE, 34 | [KEY_SPACE]=K_SPACE, 35 | [KEY_BACKSPACE]=K_BACKSPACE, 36 | [KEY_UP]=K_UPARROW, 37 | [KEY_DOWN]=K_DOWNARROW, 38 | [KEY_LEFT]=K_LEFTARROW, 39 | [KEY_RIGHT]=K_RIGHTARROW, 40 | [KEY_LEFTALT]=K_ALT, 41 | [KEY_RIGHTALT]=K_ALT, 42 | [KEY_LEFTCTRL]=K_CTRL, 43 | [KEY_RIGHTCTRL]=K_CTRL, 44 | [KEY_LEFTSHIFT]=K_SHIFT, 45 | [KEY_RIGHTSHIFT]=K_SHIFT, 46 | [KEY_F1]=K_F1, 47 | [KEY_F2]=K_F2, 48 | [KEY_F3]=K_F3, 49 | [KEY_F4]=K_F4, 50 | [KEY_F5]=K_F5, 51 | [KEY_F6]=K_F6, 52 | [KEY_F7]=K_F7, 53 | [KEY_F8]=K_F8, 54 | [KEY_F9]=K_F9, 55 | [KEY_F10]=K_F10, 56 | [KEY_F11]=K_F11, 57 | [KEY_F12]=K_F12, 58 | [KEY_INSERT]=K_INS, 59 | [KEY_DELETE]=K_DEL, 60 | [KEY_PAGEDOWN]=K_PGDN, 61 | [KEY_PAGEUP]=K_PGUP, 62 | [KEY_HOME]=K_HOME, 63 | [KEY_END]=K_END, 64 | [KEY_A]='a', 65 | [KEY_B]='b', 66 | [KEY_C]='c', 67 | [KEY_D]='d', 68 | [KEY_E]='e', 69 | [KEY_F]='f', 70 | [KEY_G]='g', 71 | [KEY_H]='h', 72 | [KEY_I]='i', 73 | [KEY_J]='j', 74 | [KEY_K]='k', 75 | [KEY_L]='l', 76 | [KEY_M]='m', 77 | [KEY_N]='n', 78 | [KEY_O]='o', 79 | [KEY_P]='p', 80 | [KEY_Q]='q', 81 | [KEY_R]='r', 82 | [KEY_S]='s', 83 | [KEY_T]='t', 84 | [KEY_U]='u', 85 | [KEY_V]='v', 86 | [KEY_W]='w', 87 | [KEY_X]='x', 88 | [KEY_Y]='y', 89 | [KEY_Z]='z', 90 | [KEY_1]='1', 91 | [KEY_2]='2', 92 | [KEY_3]='3', 93 | [KEY_4]='4', 94 | [KEY_5]='5', 95 | [KEY_6]='6', 96 | [KEY_7]='7', 97 | [KEY_8]='8', 98 | [KEY_9]='9', 99 | [KEY_0]='0', 100 | [KEY_GRAVE]='`', 101 | [KEY_DOT]='.', 102 | [KEY_COMMA]=',', 103 | [KEY_LEFTBRACE]='[', 104 | [KEY_RIGHTBRACE]=']', 105 | [KEY_BACKSLASH]='\\', 106 | [KEY_SEMICOLON]=';', 107 | [KEY_APOSTROPHE]='\'', 108 | [KEY_SLASH]='/', 109 | [KEY_MINUS]='-', 110 | [KEY_EQUAL]='=', 111 | }; 112 | 113 | static int mouse_dx=0, mouse_dy=0; 114 | 115 | int QG_GetKey(int *down, int *key) { 116 | *key=0; 117 | *down=0; 118 | hid_ev_t ev; 119 | int ret=usb_hid_receive_hid_event(&ev); 120 | if (!ret) return 0; 121 | if (ev.type==HIDEV_EVENT_KEY_DOWN || ev.type==HIDEV_EVENT_KEY_UP) { 122 | *down=(ev.type==HIDEV_EVENT_KEY_DOWN)?1:0; 123 | if (ev.key.keycode < sizeof(key_conv_tab)/sizeof(key_conv_tab[0])) { 124 | *key=key_conv_tab[ev.key.keycode]; 125 | } 126 | return 1; 127 | } else if (ev.type==HIDEV_EVENT_MOUSE_BUTTONDOWN || ev.type==HIDEV_EVENT_MOUSE_BUTTONUP) { 128 | *key=K_MOUSE1+ev.no; 129 | *down=(ev.type==HIDEV_EVENT_MOUSE_BUTTONDOWN)?1:0; 130 | return 1; 131 | } else if (ev.type==HIDEV_EVENT_MOUSE_MOTION) { 132 | mouse_dx+=ev.mouse_motion.dx; 133 | mouse_dy+=ev.mouse_motion.dy; 134 | } else if (ev.type==HIDEV_EVENT_MOUSE_WHEEL) { 135 | int d=ev.mouse_wheel.d; 136 | if (d!=0) { 137 | *key=(d<0)?K_MWHEELUP:K_MWHEELDOWN; 138 | *down=1; 139 | return 1; 140 | } 141 | } 142 | return 0; 143 | } 144 | 145 | void QG_GetJoyAxes(float *axes) { 146 | } 147 | 148 | void QG_GetMouseMove(int *x, int *y) { 149 | *x=mouse_dx; 150 | *y=mouse_dy; 151 | mouse_dx=0; 152 | mouse_dy=0; 153 | } 154 | 155 | 156 | void input_init() { 157 | xTaskCreatePinnedToCore(usb_hid_task, "usbhid", 4096, NULL, 4, NULL, 1); 158 | } 159 | 160 | 161 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/net_vcr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_vcr.c 21 | 22 | #include "quakedef.h" 23 | #include "net_vcr.h" 24 | 25 | extern int vcrFile; 26 | 27 | // This is the playback portion of the VCR. It reads the file produced 28 | // by the recorder and plays it back to the host. The recording contains 29 | // everything necessary (events, timestamps, and data) to duplicate the game 30 | // from the viewpoint of everything above the network layer. 31 | 32 | static struct 33 | { 34 | double time; 35 | int op; 36 | intptr_t session; 37 | } next; 38 | 39 | int VCR_Init (void) 40 | { 41 | net_drivers[0].Init = VCR_Init; 42 | 43 | net_drivers[0].SearchForHosts = VCR_SearchForHosts; 44 | net_drivers[0].Connect = VCR_Connect; 45 | net_drivers[0].CheckNewConnections = VCR_CheckNewConnections; 46 | net_drivers[0].QGetMessage = VCR_GetMessage; 47 | net_drivers[0].QSendMessage = VCR_SendMessage; 48 | net_drivers[0].CanSendMessage = VCR_CanSendMessage; 49 | net_drivers[0].Close = VCR_Close; 50 | net_drivers[0].Shutdown = VCR_Shutdown; 51 | 52 | Sys_FileRead(vcrFile, &next, sizeof(next)); 53 | return 0; 54 | } 55 | 56 | void VCR_ReadNext (void) 57 | { 58 | if (Sys_FileRead(vcrFile, &next, sizeof(next)) == 0) 59 | { 60 | next.op = 255; 61 | Sys_Error ("=== END OF PLAYBACK===\n"); 62 | } 63 | if (next.op < 1 || next.op > VCR_MAX_MESSAGE) 64 | Sys_Error ("VCR_ReadNext: bad op"); 65 | } 66 | 67 | 68 | void VCR_Listen (qboolean state) 69 | { 70 | } 71 | 72 | 73 | void VCR_Shutdown (void) 74 | { 75 | } 76 | 77 | 78 | int VCR_GetMessage (qsocket_t *sock) 79 | { 80 | int ret; 81 | 82 | if (host_time != next.time || next.op != VCR_OP_GETMESSAGE || next.session != *(intptr_t *)(&sock->driverdata)) 83 | Sys_Error ("VCR missmatch"); 84 | 85 | Sys_FileRead(vcrFile, &ret, sizeof(int)); 86 | if (ret != 1) 87 | { 88 | VCR_ReadNext (); 89 | return ret; 90 | } 91 | 92 | Sys_FileRead(vcrFile, &net_message.cursize, sizeof(int)); 93 | Sys_FileRead(vcrFile, net_message.data, net_message.cursize); 94 | 95 | VCR_ReadNext (); 96 | 97 | return 1; 98 | } 99 | 100 | 101 | int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data) 102 | { 103 | int ret; 104 | 105 | if (host_time != next.time || next.op != VCR_OP_SENDMESSAGE || next.session != *(intptr_t *)(&sock->driverdata)) 106 | Sys_Error ("VCR missmatch"); 107 | 108 | Sys_FileRead(vcrFile, &ret, sizeof(int)); 109 | 110 | VCR_ReadNext (); 111 | 112 | return ret; 113 | } 114 | 115 | 116 | qboolean VCR_CanSendMessage (qsocket_t *sock) 117 | { 118 | qboolean ret; 119 | 120 | if (host_time != next.time || next.op != VCR_OP_CANSENDMESSAGE || next.session != *(intptr_t *)(&sock->driverdata)) 121 | Sys_Error ("VCR missmatch"); 122 | 123 | Sys_FileRead(vcrFile, &ret, sizeof(int)); 124 | 125 | VCR_ReadNext (); 126 | 127 | return ret; 128 | } 129 | 130 | 131 | void VCR_Close (qsocket_t *sock) 132 | { 133 | } 134 | 135 | 136 | void VCR_SearchForHosts (qboolean xmit) 137 | { 138 | } 139 | 140 | 141 | qsocket_t *VCR_Connect (char *host) 142 | { 143 | return NULL; 144 | } 145 | 146 | 147 | qsocket_t *VCR_CheckNewConnections (void) 148 | { 149 | qsocket_t *sock; 150 | 151 | if (host_time != next.time || next.op != VCR_OP_CONNECT) 152 | Sys_Error ("VCR missmatch"); 153 | 154 | if (!next.session) 155 | { 156 | VCR_ReadNext (); 157 | return NULL; 158 | } 159 | 160 | sock = NET_NewQSocket (); 161 | *(intptr_t *)(&sock->driverdata) = next.session; 162 | 163 | Sys_FileRead (vcrFile, sock->address, NET_NAMELEN); 164 | VCR_ReadNext (); 165 | 166 | return sock; 167 | } 168 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/progs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #include "pr_comp.h" // defs shared with qcc 22 | #include "progdefs.h" // generated by program cdefs 23 | 24 | typedef union eval_s 25 | { 26 | string_t string; 27 | float _float; 28 | float vector[3]; 29 | func_t function; 30 | int _int; 31 | int edict; 32 | } eval_t; 33 | 34 | #define MAX_ENT_LEAFS 16 35 | typedef struct edict_s 36 | { 37 | qboolean free; 38 | link_t area; // linked to a division node or leaf 39 | 40 | int num_leafs; 41 | short leafnums[MAX_ENT_LEAFS]; 42 | 43 | entity_state_t baseline; 44 | 45 | float freetime; // sv.time when the object was freed 46 | entvars_t v; // C exported fields from progs 47 | // other fields from progs come immediately after 48 | } edict_t; 49 | #define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) 50 | 51 | //============================================================================ 52 | 53 | extern dprograms_t *progs; 54 | extern dfunction_t *pr_functions; 55 | extern char *pr_strings; 56 | extern ddef_t *pr_globaldefs; 57 | extern ddef_t *pr_fielddefs; 58 | extern dstatement_t *pr_statements; 59 | extern globalvars_t *pr_global_struct; 60 | extern float *pr_globals; // same as pr_global_struct 61 | 62 | extern int pr_edict_size; // in bytes 63 | 64 | //============================================================================ 65 | 66 | void PR_Init (void); 67 | 68 | void PR_ExecuteProgram (func_t fnum); 69 | void PR_LoadProgs (void); 70 | 71 | void PR_Profile_f (void); 72 | 73 | edict_t *ED_Alloc (void); 74 | void ED_Free (edict_t *ed); 75 | 76 | char *ED_NewString (char *string); 77 | // returns a copy of the string allocated from the server's string heap 78 | 79 | void ED_Print (edict_t *ed); 80 | void ED_Write (FILE *f, edict_t *ed); 81 | char *ED_ParseEdict (char *data, edict_t *ent); 82 | 83 | void ED_WriteGlobals (FILE *f); 84 | void ED_ParseGlobals (char *data); 85 | 86 | void ED_LoadFromFile (char *data); 87 | 88 | //define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size)) 89 | //define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts)/pr_edict_size) 90 | 91 | edict_t *EDICT_NUM(int n); 92 | int NUM_FOR_EDICT(edict_t *e); 93 | 94 | #define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size)) 95 | 96 | #define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts) 97 | #define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) 98 | 99 | //============================================================================ 100 | 101 | #define G_FLOAT(o) (pr_globals[o]) 102 | #define G_INT(o) (*(int *)&pr_globals[o]) 103 | #define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int *)&pr_globals[o])) 104 | #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o)) 105 | #define G_VECTOR(o) (&pr_globals[o]) 106 | #define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o]) 107 | #define G_FUNCTION(o) (*(func_t *)&pr_globals[o]) 108 | 109 | #define E_FLOAT(e,o) (((float*)&e->v)[o]) 110 | #define E_INT(e,o) (*(int *)&((float*)&e->v)[o]) 111 | #define E_VECTOR(e,o) (&((float*)&e->v)[o]) 112 | #define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)&e->v)[o]) 113 | 114 | extern int type_size[8]; 115 | 116 | typedef void (*builtin_t) (void); 117 | extern builtin_t *pr_builtins; 118 | extern int pr_numbuiltins; 119 | 120 | extern int pr_argc; 121 | 122 | extern qboolean pr_trace; 123 | extern dfunction_t *pr_xfunction; 124 | extern int pr_xstatement; 125 | 126 | extern unsigned short pr_crc; 127 | 128 | void PR_RunError (char *error, ...); 129 | 130 | void ED_PrintEdicts (void); 131 | void ED_PrintNum (int ent); 132 | 133 | eval_t *GetEdictFieldValue(edict_t *ed, char *field); 134 | 135 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/d_part.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_part.c: software driver module for drawing particles 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | 26 | /* 27 | ============== 28 | D_EndParticles 29 | ============== 30 | */ 31 | void D_EndParticles (void) 32 | { 33 | // not used by software driver 34 | } 35 | 36 | 37 | /* 38 | ============== 39 | D_StartParticles 40 | ============== 41 | */ 42 | void D_StartParticles (void) 43 | { 44 | // not used by software driver 45 | } 46 | 47 | /* 48 | ============== 49 | D_DrawParticle 50 | ============== 51 | */ 52 | void D_DrawParticle (particle_t *pparticle) 53 | { 54 | vec3_t local, transformed; 55 | float zi; 56 | byte *pdest; 57 | short *pz; 58 | int i, izi, pix, count, u, v; 59 | 60 | // transform point 61 | VectorSubtract (pparticle->org, r_origin, local); 62 | 63 | transformed[0] = DotProduct(local, r_pright); 64 | transformed[1] = DotProduct(local, r_pup); 65 | transformed[2] = DotProduct(local, r_ppn); 66 | 67 | if (transformed[2] < PARTICLE_Z_CLIP) 68 | return; 69 | 70 | // project the point 71 | // FIXME: preadjust xcenter and ycenter 72 | zi = 1.0 / transformed[2]; 73 | u = (int)(xcenter + zi * transformed[0] + 0.5); 74 | v = (int)(ycenter - zi * transformed[1] + 0.5); 75 | 76 | if ((v > d_vrectbottom_particle) || 77 | (u > d_vrectright_particle) || 78 | (v < d_vrecty) || 79 | (u < d_vrectx)) 80 | { 81 | return; 82 | } 83 | 84 | pz = d_pzbuffer + (d_zwidth * v) + u; 85 | pdest = d_viewbuffer + d_scantable[v] + u; 86 | izi = (int)(zi * 0x8000); 87 | 88 | pix = izi >> d_pix_shift; 89 | 90 | if (pix < d_pix_min) 91 | pix = d_pix_min; 92 | else if (pix > d_pix_max) 93 | pix = d_pix_max; 94 | 95 | switch (pix) 96 | { 97 | case 1: 98 | count = 1 << d_y_aspect_shift; 99 | 100 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 101 | { 102 | if (pz[0] <= izi) 103 | { 104 | pz[0] = izi; 105 | pdest[0] = pparticle->color; 106 | } 107 | } 108 | break; 109 | 110 | case 2: 111 | count = 2 << d_y_aspect_shift; 112 | 113 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 114 | { 115 | if (pz[0] <= izi) 116 | { 117 | pz[0] = izi; 118 | pdest[0] = pparticle->color; 119 | } 120 | 121 | if (pz[1] <= izi) 122 | { 123 | pz[1] = izi; 124 | pdest[1] = pparticle->color; 125 | } 126 | } 127 | break; 128 | 129 | case 3: 130 | count = 3 << d_y_aspect_shift; 131 | 132 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 133 | { 134 | if (pz[0] <= izi) 135 | { 136 | pz[0] = izi; 137 | pdest[0] = pparticle->color; 138 | } 139 | 140 | if (pz[1] <= izi) 141 | { 142 | pz[1] = izi; 143 | pdest[1] = pparticle->color; 144 | } 145 | 146 | if (pz[2] <= izi) 147 | { 148 | pz[2] = izi; 149 | pdest[2] = pparticle->color; 150 | } 151 | } 152 | break; 153 | 154 | case 4: 155 | count = 4 << d_y_aspect_shift; 156 | 157 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 158 | { 159 | if (pz[0] <= izi) 160 | { 161 | pz[0] = izi; 162 | pdest[0] = pparticle->color; 163 | } 164 | 165 | if (pz[1] <= izi) 166 | { 167 | pz[1] = izi; 168 | pdest[1] = pparticle->color; 169 | } 170 | 171 | if (pz[2] <= izi) 172 | { 173 | pz[2] = izi; 174 | pdest[2] = pparticle->color; 175 | } 176 | 177 | if (pz[3] <= izi) 178 | { 179 | pz[3] = izi; 180 | pdest[3] = pparticle->color; 181 | } 182 | } 183 | break; 184 | 185 | default: 186 | count = pix << d_y_aspect_shift; 187 | 188 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 189 | { 190 | for (i=0 ; icolor; 196 | } 197 | } 198 | } 199 | break; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/r_sky.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // r_sky.c 21 | 22 | #include "quakedef.h" 23 | #include "r_local.h" 24 | #include "d_local.h" 25 | #include "esp_attr.h" 26 | 27 | int iskyspeed = 8; 28 | int iskyspeed2 = 2; 29 | float skyspeed, skyspeed2; 30 | 31 | float skytime; 32 | 33 | byte *r_skysource; 34 | 35 | int r_skymade; 36 | int r_skydirect; // not used? 37 | 38 | 39 | // TODO: clean up these routines 40 | 41 | EXT_RAM_BSS_ATTR byte bottomsky[128*131]; 42 | EXT_RAM_BSS_ATTR byte bottommask[128*131]; 43 | EXT_RAM_BSS_ATTR byte newsky[128*256]; // newsky and topsky both pack in here, 128 bytes 44 | // of newsky on the left of each scan, 128 bytes 45 | // of topsky on the right, because the low-level 46 | // drawers need 256-byte scan widths 47 | 48 | 49 | /* 50 | ============= 51 | R_InitSky 52 | 53 | A sky texture is 256*128, with the right side being a masked overlay 54 | ============== 55 | */ 56 | void R_InitSky (texture_t *mt) 57 | { 58 | int i, j; 59 | byte *src; 60 | 61 | src = (byte *)mt + mt->offsets[0]; 62 | 63 | for (i=0 ; i<128 ; i++) 64 | { 65 | for (j=0 ; j<128 ; j++) 66 | { 67 | newsky[(i*256) + j + 128] = src[i*256 + j + 128]; 68 | } 69 | } 70 | 71 | for (i=0 ; i<128 ; i++) 72 | { 73 | for (j=0 ; j<131 ; j++) 74 | { 75 | if (src[i*256 + (j & 0x7F)]) 76 | { 77 | bottomsky[(i*131) + j] = src[i*256 + (j & 0x7F)]; 78 | bottommask[(i*131) + j] = 0; 79 | } 80 | else 81 | { 82 | bottomsky[(i*131) + j] = 0; 83 | bottommask[(i*131) + j] = 0xff; 84 | } 85 | } 86 | } 87 | 88 | r_skysource = newsky; 89 | } 90 | 91 | 92 | /* 93 | ================= 94 | R_MakeSky 95 | ================= 96 | */ 97 | void R_MakeSky (void) 98 | { 99 | int x, y; 100 | int ofs, baseofs; 101 | int xshift, yshift; 102 | unsigned *pnewsky; 103 | static int xlast = -1, ylast = -1; 104 | 105 | xshift = skytime*skyspeed; 106 | yshift = skytime*skyspeed; 107 | 108 | if ((xshift == xlast) && (yshift == ylast)) 109 | return; 110 | 111 | xlast = xshift; 112 | ylast = yshift; 113 | 114 | pnewsky = (unsigned *)&newsky[0]; 115 | 116 | for (y=0 ; y argc, so string operations are allways safe. 100 | 101 | int Cmd_CheckParm (char *parm); 102 | // Returns the position (1 to argc-1) in the command's argument list 103 | // where the given parameter apears, or 0 if not present 104 | 105 | void Cmd_TokenizeString (char *text); 106 | // Takes a null terminated string. Does not need to be /n terminated. 107 | // breaks the string up into arg tokens. 108 | 109 | void Cmd_ExecuteString (char *text, cmd_source_t src); 110 | // Parses a single line of text into arguments and tries to execute it. 111 | // The text can come from the command buffer, a remote client, or stdin. 112 | 113 | void Cmd_ForwardToServer (void); 114 | // adds the current command line as a clc_stringcmd to the client message. 115 | // things like godmode, noclip, etc, are commands directed to the server, 116 | // so when they are typed in at the console, they will need to be forwarded. 117 | 118 | void Cmd_Print (char *text); 119 | // used by command functions to send output to either the graphics console or 120 | // passed as a print message to the client 121 | 122 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/cvar.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // cvar.c -- dynamic variable tracking 21 | 22 | #include "quakedef.h" 23 | 24 | cvar_t *cvar_vars; 25 | char *cvar_null_string = ""; 26 | 27 | /* 28 | ============ 29 | Cvar_FindVar 30 | ============ 31 | */ 32 | cvar_t *Cvar_FindVar (char *var_name) 33 | { 34 | cvar_t *var; 35 | 36 | for (var=cvar_vars ; var ; var=var->next) 37 | if (!Q_strcmp (var_name, var->name)) 38 | return var; 39 | 40 | return NULL; 41 | } 42 | 43 | /* 44 | ============ 45 | Cvar_VariableValue 46 | ============ 47 | */ 48 | float Cvar_VariableValue (char *var_name) 49 | { 50 | cvar_t *var; 51 | 52 | var = Cvar_FindVar (var_name); 53 | if (!var) 54 | return 0; 55 | return Q_atof (var->string); 56 | } 57 | 58 | 59 | /* 60 | ============ 61 | Cvar_VariableString 62 | ============ 63 | */ 64 | char *Cvar_VariableString (char *var_name) 65 | { 66 | cvar_t *var; 67 | 68 | var = Cvar_FindVar (var_name); 69 | if (!var) 70 | return cvar_null_string; 71 | return var->string; 72 | } 73 | 74 | 75 | /* 76 | ============ 77 | Cvar_CompleteVariable 78 | ============ 79 | */ 80 | char *Cvar_CompleteVariable (char *partial) 81 | { 82 | cvar_t *cvar; 83 | int len; 84 | 85 | len = Q_strlen(partial); 86 | 87 | if (!len) 88 | return NULL; 89 | 90 | // check functions 91 | for (cvar=cvar_vars ; cvar ; cvar=cvar->next) 92 | if (!Q_strncmp (partial,cvar->name, len)) 93 | return cvar->name; 94 | 95 | return NULL; 96 | } 97 | 98 | 99 | /* 100 | ============ 101 | Cvar_Set 102 | ============ 103 | */ 104 | void Cvar_Set (char *var_name, char *value) 105 | { 106 | cvar_t *var; 107 | qboolean changed; 108 | 109 | var = Cvar_FindVar (var_name); 110 | if (!var) 111 | { // there is an error in C code if this happens 112 | Con_Printf ("Cvar_Set: variable %s not found\n", var_name); 113 | return; 114 | } 115 | 116 | changed = Q_strcmp(var->string, value); 117 | 118 | Z_Free (var->string); // free the old value string 119 | 120 | var->string = Z_Malloc (Q_strlen(value)+1); 121 | Q_strcpy (var->string, value); 122 | var->value = Q_atof (var->string); 123 | if (var->server && changed) 124 | { 125 | if (sv.active) 126 | SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string); 127 | } 128 | } 129 | 130 | /* 131 | ============ 132 | Cvar_SetValue 133 | ============ 134 | */ 135 | void Cvar_SetValue (char *var_name, float value) 136 | { 137 | char val[32]; 138 | 139 | sprintf (val, "%f",value); 140 | Cvar_Set (var_name, val); 141 | } 142 | 143 | 144 | /* 145 | ============ 146 | Cvar_RegisterVariable 147 | 148 | Adds a freestanding variable to the variable list. 149 | ============ 150 | */ 151 | void Cvar_RegisterVariable (cvar_t *variable) 152 | { 153 | char *oldstr; 154 | 155 | // first check to see if it has allready been defined 156 | if (Cvar_FindVar (variable->name)) 157 | { 158 | Con_Printf ("Can't register variable %s, allready defined\n", variable->name); 159 | return; 160 | } 161 | 162 | // check for overlap with a command 163 | if (Cmd_Exists (variable->name)) 164 | { 165 | Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name); 166 | return; 167 | } 168 | 169 | // copy the value off, because future sets will Z_Free it 170 | oldstr = variable->string; 171 | variable->string = Z_Malloc (Q_strlen(variable->string)+1); 172 | Q_strcpy (variable->string, oldstr); 173 | variable->value = Q_atof (variable->string); 174 | 175 | // link the variable in 176 | variable->next = cvar_vars; 177 | cvar_vars = variable; 178 | } 179 | 180 | /* 181 | ============ 182 | Cvar_Command 183 | 184 | Handles variable inspection and changing from the console 185 | ============ 186 | */ 187 | qboolean Cvar_Command (void) 188 | { 189 | cvar_t *v; 190 | 191 | // check variables 192 | v = Cvar_FindVar (Cmd_Argv(0)); 193 | if (!v) 194 | return false; 195 | 196 | // perform a variable print or set 197 | if (Cmd_Argc() == 1) 198 | { 199 | Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string); 200 | return true; 201 | } 202 | 203 | Cvar_Set (v->name, Cmd_Argv(1)); 204 | return true; 205 | } 206 | 207 | 208 | /* 209 | ============ 210 | Cvar_WriteVariables 211 | 212 | Writes lines containing "set variable value" for all variables 213 | with the archive flag set to true. 214 | ============ 215 | */ 216 | void Cvar_WriteVariables (FILE *f) 217 | { 218 | cvar_t *var; 219 | 220 | for (var = cvar_vars ; var ; var = var->next) 221 | if (var->archive) 222 | fprintf (f, "%s \"%s\"\n", var->name, var->string); 223 | } 224 | 225 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/sys_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // sys_null.h -- null system driver to aid porting efforts 21 | 22 | #include "quakedef.h" 23 | #include "errno.h" 24 | #include 25 | #include 26 | 27 | qboolean isDedicated; 28 | 29 | /* 30 | =============================================================================== 31 | 32 | FILE IO 33 | 34 | =============================================================================== 35 | */ 36 | 37 | #define MAX_HANDLES 10 38 | FILE *sys_handles[MAX_HANDLES]; 39 | 40 | int findhandle (void) 41 | { 42 | int i; 43 | 44 | for (i=1 ; i 90 | #define svc_time 7 // [float] server time 91 | #define svc_print 8 // [string] null terminated string 92 | #define svc_stufftext 9 // [string] stuffed into client's console buffer 93 | // the string should be \n terminated 94 | #define svc_setangle 10 // [angle3] set the view angle to this absolute value 95 | 96 | #define svc_serverinfo 11 // [long] version 97 | // [string] signon string 98 | // [string]..[0]model cache 99 | // [string]...[0]sounds cache 100 | #define svc_lightstyle 12 // [byte] [string] 101 | #define svc_updatename 13 // [byte] [string] 102 | #define svc_updatefrags 14 // [byte] [short] 103 | #define svc_clientdata 15 // 104 | #define svc_stopsound 16 // 105 | #define svc_updatecolors 17 // [byte] [byte] 106 | #define svc_particle 18 // [vec3] 107 | #define svc_damage 19 108 | 109 | #define svc_spawnstatic 20 110 | // svc_spawnbinary 21 111 | #define svc_spawnbaseline 22 112 | 113 | #define svc_temp_entity 23 114 | 115 | #define svc_setpause 24 // [byte] on / off 116 | #define svc_signonnum 25 // [byte] used for the signon sequence 117 | 118 | #define svc_centerprint 26 // [string] to put in center of the screen 119 | 120 | #define svc_killedmonster 27 121 | #define svc_foundsecret 28 122 | 123 | #define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten 124 | 125 | #define svc_intermission 30 // [string] music 126 | #define svc_finale 31 // [string] music [string] text 127 | 128 | #define svc_cdtrack 32 // [byte] track [byte] looptrack 129 | #define svc_sellscreen 33 130 | 131 | #define svc_cutscene 34 132 | 133 | // 134 | // client to server 135 | // 136 | #define clc_bad 0 137 | #define clc_nop 1 138 | #define clc_disconnect 2 139 | #define clc_move 3 // [usercmd_t] 140 | #define clc_stringcmd 4 // [string] message 141 | 142 | 143 | // 144 | // temp entity events 145 | // 146 | #define TE_SPIKE 0 147 | #define TE_SUPERSPIKE 1 148 | #define TE_GUNSHOT 2 149 | #define TE_EXPLOSION 3 150 | #define TE_TAREXPLOSION 4 151 | #define TE_LIGHTNING1 5 152 | #define TE_LIGHTNING2 6 153 | #define TE_WIZSPIKE 7 154 | #define TE_KNIGHTSPIKE 8 155 | #define TE_LIGHTNING3 9 156 | #define TE_LAVASPLASH 10 157 | #define TE_TELEPORT 11 158 | #define TE_EXPLOSION2 12 159 | 160 | // PGM 01/21/97 161 | #define TE_BEAM 13 162 | // PGM 01/21/97 163 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/render.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // refresh.h -- public interface to refresh functions 22 | 23 | #define MAXCLIPPLANES 11 24 | 25 | #define TOP_RANGE 16 // soldier uniform colors 26 | #define BOTTOM_RANGE 96 27 | 28 | //============================================================================= 29 | 30 | typedef struct efrag_s 31 | { 32 | struct mleaf_s *leaf; 33 | struct efrag_s *leafnext; 34 | struct entity_s *entity; 35 | struct efrag_s *entnext; 36 | } efrag_t; 37 | 38 | 39 | typedef struct entity_s 40 | { 41 | qboolean forcelink; // model changed 42 | 43 | int update_type; 44 | 45 | entity_state_t baseline; // to fill in defaults in updates 46 | 47 | double msgtime; // time of last update 48 | vec3_t msg_origins[2]; // last two updates (0 is newest) 49 | vec3_t origin; 50 | vec3_t msg_angles[2]; // last two updates (0 is newest) 51 | vec3_t angles; 52 | struct model_s *model; // NULL = no model 53 | struct efrag_s *efrag; // linked list of efrags 54 | int frame; 55 | float syncbase; // for client-side animations 56 | byte *colormap; 57 | int effects; // light, particals, etc 58 | int skinnum; // for Alias models 59 | int visframe; // last frame this entity was 60 | // found in an active leaf 61 | 62 | int dlightframe; // dynamic lighting 63 | int dlightbits; 64 | 65 | // FIXME: could turn these into a union 66 | int trivial_accept; 67 | struct mnode_s *topnode; // for bmodels, first world node 68 | // that splits bmodel, or NULL if 69 | // not split 70 | } entity_t; 71 | 72 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 73 | typedef struct 74 | { 75 | vrect_t vrect; // subwindow in video for refresh 76 | // FIXME: not need vrect next field here? 77 | vrect_t aliasvrect; // scaled Alias version 78 | int vrectright, vrectbottom; // right & bottom screen coords 79 | int aliasvrectright, aliasvrectbottom; // scaled Alias versions 80 | float vrectrightedge; // rightmost right edge we care about, 81 | // for use in edge list 82 | float fvrectx, fvrecty; // for floating-point compares 83 | float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping 84 | int vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20 85 | int vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20 86 | float fvrectright_adj, fvrectbottom_adj; 87 | // right and bottom edges, for clamping 88 | float fvrectright; // rightmost edge, for Alias clamping 89 | float fvrectbottom; // bottommost edge, for Alias clamping 90 | float horizontalFieldOfView; // at Z = 1.0, this many X is visible 91 | // 2.0 = 90 degrees 92 | float xOrigin; // should probably allways be 0.5 93 | float yOrigin; // between be around 0.3 to 0.5 94 | 95 | vec3_t vieworg; 96 | vec3_t viewangles; 97 | 98 | float fov_x, fov_y; 99 | 100 | int ambientlight; 101 | } refdef_t; 102 | 103 | 104 | // 105 | // refresh 106 | // 107 | extern int reinit_surfcache; 108 | 109 | 110 | extern refdef_t r_refdef; 111 | extern vec3_t r_origin, vpn, vright, vup; 112 | 113 | extern struct texture_s *r_notexture_mip; 114 | 115 | 116 | void R_Init (void); 117 | void R_InitTextures (void); 118 | void R_InitEfrags (void); 119 | void R_RenderView (void); // must set r_refdef first 120 | void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect); 121 | // called whenever r_refdef or vid change 122 | void R_InitSky (struct texture_s *mt); // called at level load 123 | 124 | void R_AddEfrags (entity_t *ent); 125 | void R_RemoveEfrags (entity_t *ent); 126 | 127 | void R_NewMap (void); 128 | 129 | 130 | void R_ParseParticleEffect (void); 131 | void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count); 132 | void R_RocketTrail (vec3_t start, vec3_t end, int type); 133 | 134 | void R_EntityParticles (entity_t *ent); 135 | void R_BlobExplosion (vec3_t org); 136 | void R_ParticleExplosion (vec3_t org); 137 | void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength); 138 | void R_LavaSplash (vec3_t org); 139 | void R_TeleportSplash (vec3_t org); 140 | 141 | void R_PushDlights (void); 142 | 143 | 144 | // 145 | // surface cache related 146 | // 147 | extern int reinit_surfcache; // if 1, surface cache is currently empty and 148 | extern qboolean r_cache_thrash; // set if thrashing the surface cache 149 | 150 | int D_SurfaceCacheForRes (int width, int height); 151 | void D_FlushCaches (void); 152 | void D_DeleteSurfaceCache (void); 153 | void D_InitCaches (void *buffer, int size); 154 | void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj); 155 | 156 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/r_shared.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // r_shared.h: general refresh-related stuff shared between the refresh and the 21 | // driver 22 | 23 | // FIXME: clean up and move into d_iface.h 24 | 25 | #ifndef _R_SHARED_H_ 26 | #define _R_SHARED_H_ 27 | 28 | #define MAXVERTS 16 // max points in a surface polygon 29 | #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate 30 | // polygon (while processing) 31 | // !!! if this is changed, it must be changed in d_ifacea.h too !!! 32 | #define MAXHEIGHT 1024 33 | #define MAXWIDTH 1280 34 | #define MAXDIMENSION ((MAXHEIGHT > MAXWIDTH) ? MAXHEIGHT : MAXWIDTH) 35 | 36 | #define SIN_BUFFER_SIZE (MAXDIMENSION+CYCLE) 37 | 38 | #define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to 39 | // be farther away than anything in 40 | // the scene 41 | 42 | //=================================================================== 43 | 44 | extern void R_DrawLine (polyvert_t *polyvert0, polyvert_t *polyvert1); 45 | 46 | extern int cachewidth; 47 | extern pixel_t *cacheblock; 48 | extern int screenwidth; 49 | 50 | extern float pixelAspect; 51 | 52 | extern int r_drawnpolycount; 53 | 54 | extern cvar_t r_clearcolor; 55 | 56 | extern int sintable[SIN_BUFFER_SIZE]; 57 | extern int intsintable[SIN_BUFFER_SIZE]; 58 | 59 | extern vec3_t vup, base_vup; 60 | extern vec3_t vpn, base_vpn; 61 | extern vec3_t vright, base_vright; 62 | extern entity_t *currententity; 63 | 64 | #define NUMSTACKEDGES 2400 65 | #define MINEDGES NUMSTACKEDGES 66 | #define NUMSTACKSURFACES 800 67 | #define MINSURFACES NUMSTACKSURFACES 68 | #define MAXSPANS 3000 69 | 70 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 71 | typedef struct espan_s 72 | { 73 | int u, v, count; 74 | struct espan_s *pnext; 75 | } espan_t; 76 | 77 | // FIXME: compress, make a union if that will help 78 | // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte 79 | typedef struct surf_s 80 | { 81 | struct surf_s *next; // active surface stack in r_edge.c 82 | struct surf_s *prev; // used in r_edge.c for active surf stack 83 | struct espan_s *spans; // pointer to linked list of spans to draw 84 | int key; // sorting key (BSP order) 85 | int last_u; // set during tracing 86 | int spanstate; // 0 = not in span 87 | // 1 = in span 88 | // -1 = in inverted span (end before 89 | // start) 90 | int flags; // currentface flags 91 | void *data; // associated data like msurface_t 92 | entity_t *entity; 93 | float nearzi; // nearest 1/z on surface, for mipmapping 94 | qboolean insubmodel; 95 | float d_ziorigin, d_zistepu, d_zistepv; 96 | 97 | int pad[2]; // to 64 bytes 98 | } surf_t; 99 | 100 | extern surf_t *surfaces, *surface_p, *surf_max; 101 | 102 | // surfaces are generated in back to front order by the bsp, so if a surf 103 | // pointer is greater than another one, it should be drawn in front 104 | // surfaces[1] is the background, and is used as the active surface stack. 105 | // surfaces[0] is a dummy, because index 0 is used to indicate no surface 106 | // attached to an edge_t 107 | 108 | //=================================================================== 109 | 110 | extern vec3_t sxformaxis[4]; // s axis transformed into viewspace 111 | extern vec3_t txformaxis[4]; // t axis transformed into viewspac 112 | 113 | extern vec3_t modelorg, base_modelorg; 114 | 115 | extern float xcenter, ycenter; 116 | extern float xscale, yscale; 117 | extern float xscaleinv, yscaleinv; 118 | extern float xscaleshrink, yscaleshrink; 119 | 120 | extern int d_lightstylevalue[256]; // 8.8 frac of base light value 121 | 122 | extern void TransformVector (vec3_t in, vec3_t out); 123 | extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv, 124 | fixed8_t endvertu, fixed8_t endvertv); 125 | 126 | extern int r_skymade; 127 | extern void R_MakeSky (void); 128 | 129 | extern int ubasestep, errorterm, erroradjustup, erroradjustdown; 130 | 131 | // flags in finalvert_t.flags 132 | #define ALIAS_LEFT_CLIP 0x0001 133 | #define ALIAS_TOP_CLIP 0x0002 134 | #define ALIAS_RIGHT_CLIP 0x0004 135 | #define ALIAS_BOTTOM_CLIP 0x0008 136 | #define ALIAS_Z_CLIP 0x0010 137 | // !!! if this is changed, it must be changed in d_ifacea.h too !!! 138 | #define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h; 139 | // must be kept in sync 140 | #define ALIAS_XY_CLIP_MASK 0x000F 141 | 142 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 143 | typedef struct edge_s 144 | { 145 | fixed16_t u; 146 | fixed16_t u_step; 147 | struct edge_s *prev, *next; 148 | unsigned short surfs[2]; 149 | struct edge_s *nextremove; 150 | float nearzi; 151 | medge_t *owner; 152 | } edge_t; 153 | 154 | #endif // _R_SHARED_H_ 155 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/sound.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // sound.h -- client sound i/o functions 21 | 22 | #ifndef __SOUND__ 23 | #define __SOUND__ 24 | 25 | #define DEFAULT_SOUND_PACKET_VOLUME 255 26 | #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 27 | 28 | // !!! if this is changed, it much be changed in asm_i386.h too !!! 29 | typedef struct 30 | { 31 | int left; 32 | int right; 33 | } portable_samplepair_t; 34 | 35 | typedef struct sfx_s 36 | { 37 | char name[MAX_QPATH]; 38 | cache_user_t cache; 39 | } sfx_t; 40 | 41 | // !!! if this is changed, it much be changed in asm_i386.h too !!! 42 | typedef struct 43 | { 44 | int length; 45 | int loopstart; 46 | int speed; 47 | int width; 48 | int stereo; 49 | byte data[1]; // variable sized 50 | } sfxcache_t; 51 | 52 | typedef struct 53 | { 54 | qboolean gamealive; 55 | qboolean soundalive; 56 | qboolean splitbuffer; 57 | int channels; 58 | int samples; // mono samples in buffer 59 | int submission_chunk; // don't mix less than this # 60 | int samplepos; // in mono samples 61 | int samplebits; 62 | int speed; 63 | unsigned char *buffer; 64 | } dma_t; 65 | 66 | // !!! if this is changed, it much be changed in asm_i386.h too !!! 67 | typedef struct 68 | { 69 | sfx_t *sfx; // sfx number 70 | int leftvol; // 0-255 volume 71 | int rightvol; // 0-255 volume 72 | int end; // end time in global paintsamples 73 | int pos; // sample position in sfx 74 | int looping; // where to loop, -1 = no looping 75 | int entnum; // to allow overriding a specific sound 76 | int entchannel; // 77 | vec3_t origin; // origin of sound effect 78 | vec_t dist_mult; // distance multiplier (attenuation/clipK) 79 | int master_vol; // 0-255 master volume 80 | } channel_t; 81 | 82 | typedef struct 83 | { 84 | int rate; 85 | int width; 86 | int channels; 87 | int loopstart; 88 | int samples; 89 | int dataofs; // chunk starts this many bytes from file start 90 | } wavinfo_t; 91 | 92 | void S_Init (void); 93 | void S_Startup (void); 94 | void S_Shutdown (void); 95 | void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); 96 | void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation); 97 | void S_StopSound (int entnum, int entchannel); 98 | void S_StopAllSounds(qboolean clear); 99 | void S_ClearBuffer (void); 100 | void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up); 101 | void S_ExtraUpdate (void); 102 | 103 | sfx_t *S_PrecacheSound (char *sample); 104 | void S_TouchSound (char *sample); 105 | void S_ClearPrecache (void); 106 | void S_BeginPrecaching (void); 107 | void S_EndPrecaching (void); 108 | void S_PaintChannels(int endtime); 109 | void S_InitPaintChannels (void); 110 | 111 | // picks a channel based on priorities, empty slots, number of channels 112 | channel_t *SND_PickChannel(int entnum, int entchannel); 113 | 114 | // spatializes a channel 115 | void SND_Spatialize(channel_t *ch); 116 | 117 | // initializes cycling through a DMA buffer and returns information on it 118 | qboolean SNDDMA_Init(void); 119 | 120 | // gets the current DMA position 121 | int SNDDMA_GetDMAPos(void); 122 | 123 | // shutdown the DMA xfer. 124 | void SNDDMA_Shutdown(void); 125 | 126 | // ==================================================================== 127 | // User-setable variables 128 | // ==================================================================== 129 | 130 | #define MAX_CHANNELS 128 131 | #define MAX_DYNAMIC_CHANNELS 8 132 | 133 | 134 | extern channel_t channels[MAX_CHANNELS]; 135 | // 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds 136 | // MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc 137 | // MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds 138 | 139 | extern int total_channels; 140 | 141 | // 142 | // Fake dma is a synchronous faking of the DMA progress used for 143 | // isolating performance in the renderer. The fakedma_updates is 144 | // number of times S_Update() is called per second. 145 | // 146 | 147 | extern qboolean fakedma; 148 | extern int fakedma_updates; 149 | extern int paintedtime; 150 | extern vec3_t listener_origin; 151 | extern vec3_t listener_forward; 152 | extern vec3_t listener_right; 153 | extern vec3_t listener_up; 154 | extern volatile dma_t *shm; 155 | extern volatile dma_t sn; 156 | extern vec_t sound_nominal_clip_dist; 157 | 158 | extern cvar_t loadas8bit; 159 | extern cvar_t bgmvolume; 160 | extern cvar_t volume; 161 | 162 | extern qboolean snd_initialized; 163 | 164 | extern int snd_blocked; 165 | 166 | void S_LocalSound (char *s); 167 | sfxcache_t *S_LoadSound (sfx_t *s); 168 | 169 | wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength); 170 | 171 | void SND_InitScaletable (void); 172 | void SNDDMA_Submit(void); 173 | 174 | void S_AmbientOff (void); 175 | void S_AmbientOn (void); 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /components/quakegeneric/quakegeneric/source/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the 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, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // comndef.h -- general definitions 21 | 22 | #if !defined BYTE_DEFINED 23 | typedef unsigned char byte; 24 | #define BYTE_DEFINED 1 25 | #endif 26 | 27 | #undef true 28 | #undef false 29 | 30 | typedef enum {false, true} qboolean; 31 | 32 | //============================================================================ 33 | 34 | typedef struct sizebuf_s 35 | { 36 | qboolean allowoverflow; // if false, do a Sys_Error 37 | qboolean overflowed; // set to true if the buffer size failed 38 | byte *data; 39 | int maxsize; 40 | int cursize; 41 | } sizebuf_t; 42 | 43 | void SZ_Alloc (sizebuf_t *buf, int startsize); 44 | void SZ_Free (sizebuf_t *buf); 45 | void SZ_Clear (sizebuf_t *buf); 46 | void *SZ_GetSpace (sizebuf_t *buf, int length); 47 | void SZ_Write (sizebuf_t *buf, void *data, int length); 48 | void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf 49 | 50 | //============================================================================ 51 | 52 | typedef struct link_s 53 | { 54 | struct link_s *prev, *next; 55 | } link_t; 56 | 57 | 58 | void ClearLink (link_t *l); 59 | void RemoveLink (link_t *l); 60 | void InsertLinkBefore (link_t *l, link_t *before); 61 | void InsertLinkAfter (link_t *l, link_t *after); 62 | 63 | // (type *)STRUCT_FROM_LINK(link_t *link, type, member) 64 | // ent = STRUCT_FROM_LINK(link,entity_t,order) 65 | // FIXME: remove this mess! 66 | #define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (intptr_t)&(((t *)0)->m))) 67 | 68 | //============================================================================ 69 | 70 | #ifndef NULL 71 | #define NULL ((void *)0) 72 | #endif 73 | 74 | #define Q_MAXCHAR ((char)0x7f) 75 | #define Q_MAXSHORT ((short)0x7fff) 76 | #define Q_MAXINT ((int)0x7fffffff) 77 | #define Q_MAXLONG ((int)0x7fffffff) 78 | #define Q_MAXFLOAT ((int)0x7fffffff) 79 | 80 | #define Q_MINCHAR ((char)0x80) 81 | #define Q_MINSHORT ((short)0x8000) 82 | #define Q_MININT ((int)0x80000000) 83 | #define Q_MINLONG ((int)0x80000000) 84 | #define Q_MINFLOAT ((int)0x7fffffff) 85 | 86 | //============================================================================ 87 | 88 | extern qboolean bigendien; 89 | 90 | extern short (*BigShort) (short l); 91 | extern short (*LittleShort) (short l); 92 | extern int (*BigLong) (int l); 93 | extern int (*LittleLong) (int l); 94 | extern float (*BigFloat) (float l); 95 | extern float (*LittleFloat) (float l); 96 | 97 | //============================================================================ 98 | 99 | void MSG_WriteChar (sizebuf_t *sb, int c); 100 | void MSG_WriteByte (sizebuf_t *sb, int c); 101 | void MSG_WriteShort (sizebuf_t *sb, int c); 102 | void MSG_WriteLong (sizebuf_t *sb, int c); 103 | void MSG_WriteFloat (sizebuf_t *sb, float f); 104 | void MSG_WriteString (sizebuf_t *sb, char *s); 105 | void MSG_WriteCoord (sizebuf_t *sb, float f); 106 | void MSG_WriteAngle (sizebuf_t *sb, float f); 107 | 108 | extern int msg_readcount; 109 | extern qboolean msg_badread; // set if a read goes beyond end of message 110 | 111 | void MSG_BeginReading (void); 112 | int MSG_ReadChar (void); 113 | int MSG_ReadByte (void); 114 | int MSG_ReadShort (void); 115 | int MSG_ReadLong (void); 116 | float MSG_ReadFloat (void); 117 | char *MSG_ReadString (void); 118 | 119 | float MSG_ReadCoord (void); 120 | float MSG_ReadAngle (void); 121 | 122 | //============================================================================ 123 | 124 | void Q_memset (void *dest, int fill, int count); 125 | void Q_memcpy (void *dest, void *src, int count); 126 | int Q_memcmp (void *m1, void *m2, int count); 127 | void Q_strcpy (char *dest, char *src); 128 | void Q_strncpy (char *dest, char *src, int count); 129 | int Q_strlen (char *str); 130 | char *Q_strrchr (char *s, char c); 131 | void Q_strcat (char *dest, char *src); 132 | int Q_strcmp (char *s1, char *s2); 133 | int Q_strncmp (char *s1, char *s2, int count); 134 | int Q_strcasecmp (char *s1, char *s2); 135 | int Q_strncasecmp (char *s1, char *s2, int n); 136 | int Q_atoi (char *str); 137 | float Q_atof (char *str); 138 | 139 | //============================================================================ 140 | 141 | extern char com_token[1024]; 142 | extern qboolean com_eof; 143 | 144 | char *COM_Parse (char *data); 145 | 146 | 147 | extern int com_argc; 148 | extern char **com_argv; 149 | 150 | int COM_CheckParm (char *parm); 151 | void COM_Init (char *path); 152 | void COM_InitArgv (int argc, char **argv); 153 | 154 | char *COM_SkipPath (char *pathname); 155 | void COM_StripExtension (char *in, char *out); 156 | void COM_FileBase (char *in, char *out, size_t outsize); 157 | void COM_DefaultExtension (char *path, char *extension); 158 | 159 | char *va(char *format, ...); 160 | // does a varargs printf into a temp buffer 161 | 162 | 163 | //============================================================================ 164 | 165 | extern int com_filesize; 166 | struct cache_user_s; 167 | 168 | extern char com_gamedir[MAX_OSPATH]; 169 | 170 | void COM_WriteFile (char *filename, void *data, int len); 171 | int COM_OpenFile (char *filename, int *hndl); 172 | int COM_FOpenFile (char *filename, FILE **file); 173 | void COM_CloseFile (int h); 174 | 175 | byte *COM_LoadStackFile (char *path, void *buffer, int bufsize); 176 | byte *COM_LoadTempFile (char *path); 177 | byte *COM_LoadHunkFile (char *path); 178 | void COM_LoadCacheFile (char *path, struct cache_user_s *cu); 179 | 180 | 181 | extern struct cvar_s registered; 182 | 183 | extern qboolean standard_quake, rogue, hipnotic; 184 | --------------------------------------------------------------------------------