├── README.md ├── adivtab.h ├── anorms.h ├── asm_draw.h ├── asm_i386.h ├── bgmusic.c ├── bgmusic.h ├── bspfile.h ├── cdaudio.h ├── chase.c ├── cl_demo.c ├── cl_input.c ├── cl_main.c ├── cl_parse.c ├── cl_tent.c ├── client.h ├── cmd.c ├── cmd.h ├── common.c ├── common.h ├── console.c ├── console.h ├── crc.c ├── crc.h ├── cvar.c ├── cvar.h ├── d_draw.S ├── d_draw16.S ├── d_edge.c ├── d_iface.h ├── d_ifacea.h ├── d_init.c ├── d_local.h ├── d_modech.c ├── d_part.c ├── d_parta.S ├── d_polysa.S ├── d_polyse.c ├── d_scan.c ├── d_sky.c ├── d_spr8.S ├── d_sprite.c ├── d_surf.c ├── d_vars.c ├── d_varsa.S ├── d_zpoint.c ├── doc ├── Building the Flash version.txt ├── Super8 Console Commands and Variables.txt ├── TECHINFO.TXT ├── ToChriS.txt ├── gnu.txt ├── newskip.txt ├── readme_fisheye.txt ├── readme_makaqu.txt ├── readme_makaqu_effects.txt ├── readme_qbismSuper8.txt └── readme_quakesrc.txt ├── draw.c ├── draw.h ├── easy.h ├── gnu.txt ├── host.c ├── host_cmd.c ├── input.h ├── keys.c ├── keys.h ├── mathlib.c ├── mathlib.h ├── menu.c ├── menu.h ├── model.c ├── model.h ├── multi.h ├── net.h ├── net_dgrm.c ├── net_dgrm.h ├── net_loop.c ├── net_loop.h ├── net_main.c ├── net_none.c ├── pr_cmds.c ├── pr_comp.h ├── pr_edict.c ├── pr_exec.c ├── progdefs.h ├── progdefs.q1 ├── progs.h ├── protocol.h ├── qbS8.workspace ├── qbismSuper8.cbp ├── quakeasm.h ├── quakedef.h ├── r_aclip.c ├── r_alias.c ├── r_bsp.c ├── r_draw.c ├── r_edge.c ├── r_efrag.c ├── r_light.c ├── r_local.h ├── r_main.c ├── r_misc.c ├── r_part.c ├── r_shared.h ├── r_sky.c ├── r_sprite.c ├── r_surf.c ├── r_vars.c ├── r_varsa.S ├── render.h ├── s_win32 ├── QBS8.ico ├── QBS8_48x48.gif ├── QBS8_64x64.gif ├── cd_win.c ├── codecs │ ├── include │ │ ├── ogg │ │ │ ├── config_types.h │ │ │ ├── ogg.h │ │ │ └── os_types.h │ │ └── vorbis │ │ │ ├── codec.h │ │ │ └── vorbisfile.h │ └── x86 │ │ ├── libogg-0.dll │ │ ├── libogg.dll.a │ │ ├── libogg.lib │ │ ├── libvorbis-0.dll │ │ ├── libvorbis.dll.a │ │ ├── libvorbis.lib │ │ ├── libvorbisfile-3.dll │ │ ├── libvorbisfile.dll.a │ │ └── libvorbisfile.lib ├── conproc.c ├── conproc.h ├── in_win.c ├── movie.c ├── movie_avi.c ├── movie_avi.h ├── net_win.c ├── net_wins.c ├── net_wins.h ├── qbS8_install.iss ├── qbism-s8.rc ├── resource.h ├── snd_win.c ├── sys_win.c ├── vid_win.c └── winquake.h ├── sbar.c ├── sbar.h ├── screen.c ├── screen.h ├── server.h ├── snd_codec.c ├── snd_codec.h ├── snd_codeci.h ├── snd_dma.c ├── snd_mem.c ├── snd_mix.c ├── snd_mp3.c ├── snd_mp3.h ├── snd_vorbis.c ├── snd_vorbis.h ├── snd_wave.c ├── snd_wave.h ├── sound.h ├── spritegn.h ├── sv_main.c ├── sv_move.c ├── sv_phys.c ├── sv_user.c ├── sys.h ├── tools ├── qb_hmap2 │ ├── brush.c │ ├── bsp2prt.c │ ├── bsp5.h │ ├── bspfile.c │ ├── bspfile.h │ ├── bspinfo.c │ ├── cmdlib.c │ ├── cmdlib.h │ ├── csg4.c │ ├── faces.c │ ├── light.c │ ├── light.h │ ├── light_face.c │ ├── light_trace.c │ ├── map.c │ ├── map.h │ ├── mathlib.c │ ├── mathlib.h │ ├── mem.c │ ├── mem.h │ ├── outside.c │ ├── portals.c │ ├── qb_hmap2.cbp │ ├── qbsp.c │ ├── scriptlib.c │ ├── solidbsp.c │ ├── threads.c │ ├── threads.h │ ├── tjunc.c │ ├── tree.c │ ├── vis.c │ ├── vis.h │ ├── vis_flow.c │ ├── vis_sound.c │ ├── wad.c │ ├── winding.c │ ├── winding.h │ └── writebsp.c └── qb_newskip │ ├── newskip.c │ └── qb_newskip.cbp ├── version.bat ├── vid.h ├── view.c ├── view.h ├── wad.c ├── wad.h ├── world.c ├── world.h ├── zone.c └── zone.h /asm_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 | // asm_draw.h 22 | // 23 | // Include file for asm drawing routines. 24 | // 25 | 26 | // 27 | // !!! note that this file must match the corresponding C structures at all 28 | // times !!! 29 | // 30 | 31 | // !!! if this is changed, it must be changed in r_local.h too !!! 32 | #define NEAR_CLIP 0.01 33 | 34 | // !!! if this is changed, it must be changed in r_local.h too !!! 35 | #define CYCLE 128 36 | 37 | // espan_t structure 38 | // !!! if this is changed, it must be changed in r_shared.h too !!! 39 | #define espan_t_u 0 40 | #define espan_t_v 4 41 | #define espan_t_count 8 42 | #define espan_t_pnext 12 43 | #define espan_t_size 16 44 | 45 | // sspan_t structure 46 | // !!! if this is changed, it must be changed in d_local.h too !!! 47 | #define sspan_t_u 0 48 | #define sspan_t_v 4 49 | #define sspan_t_count 8 50 | #define sspan_t_size 12 51 | 52 | // spanpackage_t structure 53 | // !!! if this is changed, it must be changed in d_polyset.c too !!! 54 | #define spanpackage_t_pdest 0 55 | #define spanpackage_t_pz 4 56 | #define spanpackage_t_count 8 57 | #define spanpackage_t_ptex 12 58 | #define spanpackage_t_sfrac 16 59 | #define spanpackage_t_tfrac 20 60 | #define spanpackage_t_light 24 61 | #define spanpackage_t_zi 28 62 | #define spanpackage_t_size 32 63 | 64 | // edge_t structure 65 | // !!! if this is changed, it must be changed in r_shared.h too !!! 66 | #define et_u 0 67 | #define et_u_step 4 68 | #define et_prev 8 69 | #define et_next 12 70 | #define et_surfs 16 71 | #define et_nextremove 20 72 | #define et_nearzi 24 73 | #define et_owner 28 74 | #define et_size 32 75 | 76 | // surf_t structure 77 | // !!! if this is changed, it must be changed in r_shared.h too !!! 78 | #define SURF_T_SHIFT 6 79 | #define st_next 0 80 | #define st_prev 4 81 | #define st_spans 8 82 | #define st_key 12 83 | #define st_last_u 16 84 | #define st_spanstate 20 85 | #define st_flags 24 86 | #define st_data 28 87 | #define st_entity 32 88 | #define st_nearzi 36 89 | #define st_insubmodel 40 90 | #define st_d_ziorigin 44 91 | #define st_d_zistepu 48 92 | #define st_d_zistepv 52 93 | #define st_pad 56 94 | #define st_size 64 95 | 96 | // clipplane_t structure 97 | // !!! if this is changed, it must be changed in r_local.h too !!! 98 | #define cp_normal 0 99 | #define cp_dist 12 100 | #define cp_next 16 101 | #define cp_leftedge 20 102 | #define cp_rightedge 21 103 | #define cp_reserved 22 104 | #define cp_size 24 105 | 106 | // medge_t structure 107 | // !!! if this is changed, it must be changed in model.h too !!! 108 | #define me_v 0 109 | #define me_cachededgeoffset 4 110 | #define me_size 16 111 | 112 | // mvertex_t structure 113 | // !!! if this is changed, it must be changed in model.h too !!! 114 | #define mv_position 0 115 | #define mv_size 12 116 | 117 | // refdef_t structure 118 | // !!! if this is changed, it must be changed in render.h too !!! 119 | #define rd_vrect 0 120 | #define rd_aliasvrect 20 121 | #define rd_vrectright 40 122 | #define rd_vrectbottom 44 123 | #define rd_aliasvrectright 48 124 | #define rd_aliasvrectbottom 52 125 | #define rd_vrectrightedge 56 126 | #define rd_fvrectx 60 127 | #define rd_fvrecty 64 128 | #define rd_fvrectx_adj 68 129 | #define rd_fvrecty_adj 72 130 | #define rd_vrect_x_adj_shift20 76 131 | #define rd_vrectright_adj_shift20 80 132 | #define rd_fvrectright_adj 84 133 | #define rd_fvrectbottom_adj 88 134 | #define rd_fvrectright 92 135 | #define rd_fvrectbottom 96 136 | #define rd_horizontalFieldOfView 100 137 | #define rd_xOrigin 104 138 | #define rd_yOrigin 108 139 | #define rd_vieworg 112 140 | #define rd_viewangles 124 141 | #define rd_ambientlight 136 142 | #define rd_size 140 143 | 144 | // mtriangle_t structure 145 | // !!! if this is changed, it must be changed in model.h too !!! 146 | #define mtri_facesfront 0 147 | #define mtri_vertindex 4 148 | #define mtri_size 16 // !!! if this changes, array indexing in !!! 149 | // !!! d_polysa.s must be changed to match !!! 150 | #define mtri_shift 4 151 | 152 | -------------------------------------------------------------------------------- /asm_i386.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 __ASM_I386__ 22 | #define __ASM_I386__ 23 | 24 | #ifdef ELF 25 | #define C(label) label 26 | #else 27 | #define C(label) _##label 28 | #endif 29 | 30 | // 31 | // !!! note that this file must match the corresponding C structures at all 32 | // times !!! 33 | // 34 | 35 | // plane_t structure 36 | // !!! if this is changed, it must be changed in model.h too !!! 37 | // !!! if the size of this is changed, the array lookup in SV_HullPointContents 38 | // must be changed too !!! 39 | #define pl_normal 0 40 | #define pl_dist 12 41 | #define pl_type 16 42 | #define pl_signbits 17 43 | #define pl_pad 18 44 | #define pl_size 20 45 | 46 | // hull_t structure 47 | // !!! if this is changed, it must be changed in model.h too !!! 48 | #define hu_clipnodes 0 49 | #define hu_planes 4 50 | #define hu_firstclipnode 8 51 | #define hu_lastclipnode 12 52 | #define hu_clip_mins 16 53 | #define hu_clip_maxs 28 54 | #define hu_size 40 55 | 56 | // dnode_t structure 57 | // !!! if this is changed, it must be changed in bspfile.h too !!! 58 | #define nd_planenum 0 59 | #define nd_children 4 60 | #define nd_mins 8 61 | #define nd_maxs 20 62 | #define nd_firstface 32 63 | #define nd_numfaces 36 64 | #define nd_size 40 65 | 66 | // sfxcache_t structure 67 | // !!! if this is changed, it much be changed in sound.h too !!! 68 | #define sfxc_length 0 69 | #define sfxc_loopstart 4 70 | #define sfxc_speed 8 71 | #define sfxc_width 12 72 | #define sfxc_stereo 16 73 | #define sfxc_data 20 74 | 75 | // channel_t structure 76 | // !!! if this is changed, it much be changed in sound.h too !!! 77 | #define ch_sfx 0 78 | #define ch_leftvol 4 79 | #define ch_rightvol 8 80 | #define ch_end 12 81 | #define ch_pos 16 82 | #define ch_looping 20 83 | #define ch_entnum 24 84 | #define ch_entchannel 28 85 | #define ch_origin 32 86 | #define ch_dist_mult 44 87 | #define ch_master_vol 48 88 | #define ch_size 52 89 | 90 | // portable_samplepair_t structure 91 | // !!! if this is changed, it much be changed in sound.h too !!! 92 | #define psp_left 0 93 | #define psp_right 4 94 | #define psp_size 8 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /bgmusic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Background music handling for Quakespasm (adapted from uHexen2) 3 | * Handles streaming music as raw sound samples and runs the midi driver 4 | * 5 | * Copyright (C) 1999-2005 Id Software, Inc. 6 | * Copyright (C) 2010-2011 O.Sezer 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or (at 11 | * your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * See the GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | */ 24 | 25 | #ifndef _BGMUSIC_H_ 26 | #define _BGMUSIC_H_ 27 | 28 | extern qboolean bgmloop; 29 | extern cvar_t bgm_extmusic; 30 | 31 | qboolean BGM_Init (void); 32 | void BGM_Shutdown (void); 33 | 34 | void BGM_Play (char *filename); 35 | void BGM_Stop (void); 36 | void BGM_Update (void); 37 | void BGM_Pause (void); 38 | void BGM_Resume (void); 39 | 40 | void BGM_PlayCDtrack (byte track, qboolean looping); 41 | 42 | #endif /* _BGMUSIC_H_ */ 43 | 44 | -------------------------------------------------------------------------------- /cdaudio.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | int CDAudio_Init(void); 19 | int CDAudio_Play(byte track, qboolean looping); 20 | void CDAudio_Stop(void); 21 | void CDAudio_Pause(void); 22 | void CDAudio_Resume(void); 23 | void CDAudio_Shutdown(void); 24 | void CDAudio_Update(void); 25 | // Manoel Kasimier - CD player in menu - begin 26 | extern qboolean cdValid; 27 | extern qboolean playing; 28 | extern qboolean wasPlaying; 29 | extern qboolean initialized; 30 | extern qboolean enabled; 31 | extern qboolean playLooping; 32 | //extern float cdvolume; 33 | //extern byte remap[100]; 34 | extern byte cdrom; 35 | extern byte playTrack; 36 | extern byte maxTrack; 37 | extern byte audioTrack[1+99+1]; // first and last values are dummy, and should always be zero 38 | extern cvar_t cd_enabled; 39 | // Manoel Kasimier - CD player in menu - end 40 | -------------------------------------------------------------------------------- /chase.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // chase.c -- chase camera code 18 | 19 | #include "quakedef.h" 20 | 21 | cvar_t chase_back = {"chase_back", "100", "chase_back[distance] Camera location behind player if chase_active = 1 or 2.", true}; 22 | cvar_t chase_up = {"chase_up", "16", "chase_up [distance] Camera location behind player if chase_active = 1 or 2.", true}; 23 | cvar_t chase_right = {"chase_right", "0", "chase_right[distance] Camera location behind player, when chase_active = 1 or 2.", true}; 24 | 25 | //qb: custom chase by frag.machine 26 | cvar_t chase_active = {"chase_active", "0", "chase_active[0/1/2] Third-person cam.\n[1] Camera faces player direction.\n[2] Fixed camera direction.", true}; 27 | cvar_t chase_roll = {"chase_roll", "0", "chase_roll[angle] Camera roll when chase_active = 2.", true}; 28 | cvar_t chase_yaw = {"chase_yaw", "180", "chase_yaw[angle] Camera yaw when chase_active = 2.", true}; 29 | cvar_t chase_pitch = {"chase_pitch", "45", "chase_pitch[angle] Camera pitch when chase_active = 2.", true}; 30 | 31 | vec3_t chase_dest; 32 | vec3_t chase_dest_angles; 33 | 34 | void Chase_Init (void) 35 | { 36 | Cvar_RegisterVariable (&chase_back); 37 | Cvar_RegisterVariable (&chase_up); 38 | Cvar_RegisterVariable (&chase_right); 39 | Cvar_RegisterVariable (&chase_active); 40 | Cvar_RegisterVariable (&chase_roll); //qb: custom chase 41 | Cvar_RegisterVariable (&chase_yaw); 42 | Cvar_RegisterVariable (&chase_pitch); 43 | } 44 | 45 | void TraceLine (vec3_t start, vec3_t end, vec3_t impact) 46 | { 47 | trace_t trace; 48 | 49 | memset (&trace, 0, sizeof(trace)); 50 | SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace); 51 | 52 | VectorCopy (trace.endpos, impact); 53 | } 54 | 55 | 56 | void Chase_Update (void) //qb: custom chase by frag.machine 57 | { 58 | int i; 59 | float dist; 60 | vec3_t forward, up, right; 61 | vec3_t dest, stop; 62 | 63 | if ((int)chase_active.value != 2) 64 | { 65 | // if can't see player, reset 66 | AngleVectors (cl.viewangles, forward, right, up); 67 | 68 | // calc exact destination 69 | for (i=0 ; i<3 ; i++) 70 | chase_dest[i] = r_refdef.vieworg[i] 71 | - forward[i]*chase_back.value 72 | - right[i]*chase_right.value; 73 | chase_dest[2] = r_refdef.vieworg[2] + chase_up.value; 74 | 75 | // find the spot the player is looking at 76 | VectorMA (r_refdef.vieworg, 4096, forward, dest); 77 | TraceLine (r_refdef.vieworg, dest, stop); 78 | 79 | // calculate pitch to look at the same spot from camera 80 | VectorSubtract (stop, r_refdef.vieworg, stop); 81 | dist = DotProduct (stop, forward); 82 | if (dist < 1) 83 | dist = 1; 84 | 85 | r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180; 86 | 87 | TraceLine(r_refdef.vieworg, chase_dest, stop); 88 | if (Length(stop) != 0) 89 | VectorCopy(stop, chase_dest); 90 | 91 | // move towards destination 92 | VectorCopy (chase_dest, r_refdef.vieworg); 93 | } 94 | else 95 | { 96 | chase_dest[0] = r_refdef.vieworg[0] + chase_back.value; 97 | chase_dest[1] = r_refdef.vieworg[1] + chase_right.value; 98 | chase_dest[2] = r_refdef.vieworg[2] + chase_up.value; 99 | 100 | // this is from the chasecam fix - start 101 | TraceLine (r_refdef.vieworg, chase_dest, stop); 102 | if (Length (stop) != 0) 103 | { 104 | VectorCopy (stop, chase_dest); 105 | } 106 | // this is from the chasecam fix - end 107 | 108 | VectorCopy (chase_dest, r_refdef.vieworg); 109 | r_refdef.viewangles[ROLL] = chase_roll.value; 110 | r_refdef.viewangles[YAW] = chase_yaw.value; 111 | r_refdef.viewangles[PITCH] = chase_pitch.value; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /console.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // 19 | // console 20 | // 21 | #define MAXCMDLINE 256 22 | extern int con_totallines; 23 | extern int con_backscroll; 24 | extern qboolean con_forcedup; // because no entities to refresh 25 | extern qboolean con_initialized; 26 | extern byte *con_chars; 27 | extern int con_notifylines; // scan lines to clear for notify lines 28 | extern int edit_line; 29 | extern int key_linepos; 30 | extern char chat_buffer[]; 31 | extern qboolean team_message; 32 | extern char *COM_NiceFloatString(float floatvalue); // qb: from FQmV 33 | 34 | extern void M_Main_f (void); // edited 35 | 36 | void Con_DrawCharacter (int cx, int line, int num); 37 | 38 | void Con_CheckResize (void); 39 | void Con_Init (void); 40 | void Con_DrawConsole (int lines, qboolean drawinput); 41 | void Con_Print (char *txt); 42 | void Con_Printf (char *fmt, ...); 43 | void Con_DPrintf (char *fmt, ...); 44 | void Con_Printf (char *fmt, ...); 45 | void Con_LogCenterPrint (char *str); 46 | void Con_Clear_f (void); 47 | void Con_DrawNotify (void); 48 | void Con_ClearNotify (void); 49 | void Con_ToggleConsole_f (void); 50 | 51 | void Con_NotifyBox (char *text); // during startup for sound / cd warnings 52 | 53 | -------------------------------------------------------------------------------- /crc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | /* crc.c */ 18 | 19 | #include "quakedef.h" 20 | 21 | // this is a 16 bit, non-reflected CRC using the polynomial 0x1021 22 | // and the initial and final xor values shown below... in other words, the 23 | // CCITT standard CRC used by XMODEM 24 | 25 | #define CRC_INIT_VALUE 0xffff 26 | #define CRC_XOR_VALUE 0x0000 27 | 28 | static unsigned short crctable[256] = 29 | { 30 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 31 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 32 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 33 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 34 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 35 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 36 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 37 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 38 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 39 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 40 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 41 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 42 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 43 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 44 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 45 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 46 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 47 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 48 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 49 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 50 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 51 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 52 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 53 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 54 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 55 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 56 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 57 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 58 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 59 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 60 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 61 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 62 | }; 63 | 64 | void CRC_Init(unsigned short *crcvalue) 65 | { 66 | *crcvalue = CRC_INIT_VALUE; 67 | } 68 | 69 | void CRC_ProcessByte(unsigned short *crcvalue, byte data) 70 | { 71 | *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; 72 | } 73 | 74 | unsigned short CRC_Value(unsigned short crcvalue) 75 | { 76 | return crcvalue ^ CRC_XOR_VALUE; 77 | } 78 | -------------------------------------------------------------------------------- /crc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | /* crc.h */ 18 | 19 | void CRC_Init(unsigned short *crcvalue); 20 | void CRC_ProcessByte(unsigned short *crcvalue, byte data); 21 | unsigned short CRC_Value(unsigned short crcvalue); 22 | -------------------------------------------------------------------------------- /cvar.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // cvar.h 18 | 19 | /* 20 | 21 | 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 22 | in C code. 23 | 24 | it is sufficient to initialize a cvar_t with just the first two fields, or 25 | you can add a ,true flag for variables that you want saved to the configuration 26 | file when the game is quit: 27 | 28 | cvar_t r_draworder = {"r_draworder","1", "helpstring"}; 29 | cvar_t scr_screensize = {"screensize","1", "helpstring", true}; 30 | 31 | 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: 32 | Cvar_RegisterVariable (&host_framerate); 33 | 34 | 35 | C code usually just references a cvar in place: 36 | if ( r_draworder.value ) 37 | 38 | It could optionally ask for the value to be looked up for a string name: 39 | if (Cvar_VariableValue ("r_draworder")) 40 | 41 | Interpreted prog code can access cvars with the cvar(name) or 42 | cvar_set (name, value) internal functions: 43 | teamplay = cvar("teamplay"); 44 | cvar_set ("registered", "1"); 45 | 46 | The user can access cvars from the console in two ways: 47 | r_draworder prints the current value 48 | r_draworder 0 sets the current value to 0 49 | Cvars are restricted from having the same names as commands to keep this 50 | interface from being ambiguous. 51 | */ 52 | 53 | typedef struct cvar_s 54 | { 55 | char *name; 56 | char *string; 57 | char *helpstring; //qb: docs 58 | qboolean archive; // set to true to cause it to be saved to vars.rc 59 | qboolean server; // notifies players when changed 60 | float value; 61 | char *defaultstring; //qb: save the default value 62 | struct cvar_s *next; 63 | void (*Cvar_Changed) (void); //Heffo - Cvar Callback Function 64 | } cvar_t; 65 | 66 | void Cvar_RegisterVariableWithCallback (cvar_t *variable, void *function); //Heffo - Cvar Callback Function // Manoel Kasimier - edited 67 | void Cvar_RegisterVariable (cvar_t *variable); 68 | // registers a cvar that allready has the name, string, and optionally the 69 | // archive elements set. 70 | 71 | cvar_t *Cvar_SetWithNoCallback (char *var_name, char *value); 72 | // do not fire up callback Cvar_Set() version 73 | 74 | void Cvar_Set (char *var_name, char *value); 75 | // equivelant to " " typed at the console 76 | 77 | void Cvar_SetValue (char *var_name, float value); 78 | // expands value to a string and calls Cvar_Set 79 | 80 | float Cvar_VariableValue (char *var_name); 81 | // returns 0 if not defined or non numeric 82 | 83 | char *Cvar_VariableString (char *var_name); 84 | // returns an empty string if not defined 85 | 86 | //qb: qrack command line begin 87 | int Cvar_CompleteCountPossible (char *partial); // by joe 88 | //qb: qrack command line end 89 | 90 | char *Cvar_CompleteVariable (char *partial); 91 | // attempts to match a partial variable name for command line completion 92 | // returns NULL if nothing fits 93 | 94 | qboolean Cvar_Command (void); 95 | // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known 96 | // command. Returns true if the command was a variable reference that 97 | // was handled. (print or change) 98 | 99 | void Cvar_WriteVariables (FILE *f); 100 | // Writes lines containing "set variable value" for all variables 101 | // with the archive flag set to true. 102 | 103 | cvar_t *Cvar_FindVar (char *var_name); 104 | 105 | extern cvar_t *cvar_vars; 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /d_init.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // d_init.c: rasterization driver initialization 18 | 19 | #include "quakedef.h" 20 | #include "d_local.h" 21 | 22 | #define NUM_MIPS 4 23 | 24 | cvar_t d_mipcap = {"d_mipcap", "0", "d_mipcap [0-3] max undetail texture level."}; 25 | cvar_t d_mipscale = {"d_mipscale", "1", "d_mipscale [value] undetail distance."}; 26 | cvar_t d_subdiv16 = {"d_subdiv16", "1", "d_subdiv16 [0/1] use division per 16 pixel instead of per 8 pixel. Faster, less accurate", true}; 27 | 28 | surfcache_t *d_initial_rover; 29 | qboolean d_roverwrapped; 30 | int d_minmip; 31 | float d_scalemip[NUM_MIPS-1]; 32 | 33 | static float basemip[NUM_MIPS-1] = {1.0, 0.5*0.8, 0.25*0.8}; 34 | 35 | void (*d_drawspans) (espan_t *pspan); 36 | 37 | /* 38 | =============== 39 | D_Init 40 | =============== 41 | */ 42 | void D_Init (void) 43 | { 44 | 45 | Cvar_RegisterVariable (&d_mipcap); 46 | Cvar_RegisterVariable (&d_mipscale); 47 | 48 | r_recursiveaffinetriangles = true; 49 | r_aliasuvscale = 1.0; 50 | } 51 | 52 | 53 | 54 | /* 55 | =============== 56 | D_SetupFrame 57 | =============== 58 | */ 59 | void D_SetupFrame (void) 60 | { 61 | int i; 62 | 63 | d_viewbuffer = vid.buffer; 64 | screenwidth = vid.rowbytes; //qb: was vid.width 65 | 66 | d_roverwrapped = false; 67 | d_initial_rover = sc_rover; 68 | 69 | d_minmip = d_mipcap.value; 70 | if (d_minmip > 3) 71 | d_minmip = 3; 72 | else if (d_minmip < 0) 73 | d_minmip = 0; 74 | 75 | for (i=0 ; i<(NUM_MIPS-1) ; i++) 76 | d_scalemip[i] = basemip[i] * d_mipscale.value; 77 | 78 | #if id386 79 | d_drawspans = D_DrawSpans16; 80 | #else 81 | d_drawspans = D_DrawSpans16_C; 82 | #endif 83 | 84 | d_aflatcolor = 0; 85 | } 86 | 87 | 88 | /* 89 | =============== 90 | D_UpdateRects 91 | =============== 92 | */ 93 | void D_UpdateRects (vrect_t *prect) 94 | { 95 | 96 | // the software driver draws these directly to the vid buffer 97 | 98 | UNUSED(prect); 99 | } 100 | 101 | -------------------------------------------------------------------------------- /d_local.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // d_local.h: private rasterization driver defs 18 | 19 | #include "r_shared.h" 20 | 21 | // 22 | // TODO: fine-tune this; it's based on providing some overage even if there 23 | // is a 2k-wide scan, with subdivision every 8, for 256 spans of 12 bytes each 24 | // 25 | #define SCANBUFFERPAD 0x1000 26 | 27 | #define R_SKY_SMASK 0x007F0000 28 | #define R_SKY_TMASK 0x007F0000 29 | 30 | #define DS_SPAN_LIST_END -128 31 | 32 | #define SURFCACHE_SIZE_AT_320X200 600*1024 33 | 34 | typedef struct surfcache_s 35 | { 36 | struct surfcache_s *next; 37 | struct surfcache_s **owner; // NULL is an empty chunk of memory 38 | int lightadj[MAXLIGHTMAPS]; // checked for strobe flush 39 | int dlight; 40 | int size; // including header 41 | unsigned width; 42 | unsigned height; // DEBUG only needed for debug 43 | float mipscale; 44 | struct texture_s *texture; // checked for animating textures 45 | byte data[4]; // width*height elements 46 | } surfcache_t; 47 | 48 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 49 | typedef struct sspan_s 50 | { 51 | int u, v, count; 52 | } sspan_t; 53 | 54 | extern cvar_t d_subdiv16; 55 | 56 | extern float scale_for_mip; 57 | 58 | extern qboolean d_roverwrapped; 59 | extern surfcache_t *sc_rover; 60 | extern surfcache_t *d_initial_rover; 61 | 62 | extern float d_sdivzstepu, d_tdivzstepu, d_zistepu; 63 | extern float d_sdivzstepv, d_tdivzstepv, d_zistepv; 64 | extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin; 65 | 66 | extern fixed16_t sadjust, tadjust; 67 | extern fixed16_t bbextents, bbextentt; 68 | 69 | void D_DrawSpans16 (espan_t *pspans); 70 | void D_DrawZSpans (espan_t *pspans); 71 | void D_DrawSpans16_C (espan_t *pspans); //qb: up it to 16 72 | void D_DrawSpans16_Blend (espan_t *pspan); 73 | void D_DrawSpans16_Fence (espan_t *pspan); 74 | void D_DrawSpans16_Blend50 (espan_t *pspan); 75 | void D_DrawSpans16_BlendBackwards (espan_t *pspan); 76 | void Turbulent8 (espan_t *pspan, float trans); 77 | void D_SpriteDrawSpans (sspan_t *pspan); 78 | void D_PolysetDraw_C(void); 79 | 80 | void D_DrawSkyScans8 (espan_t *pspan); 81 | void D_DrawSkyScans16 (espan_t *pspan); 82 | 83 | void R_ShowSubDiv (void); 84 | //extern void (*prealspandrawer)(void); 85 | surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel); 86 | 87 | //qb: fog 88 | extern float fog_density, fog_red, fog_green, fog_blue; 89 | extern float old_density, old_red, old_green, old_blue; 90 | extern int foglevel[256]; 91 | extern int fognoise[256]; 92 | extern cvar_t r_fog; 93 | 94 | extern int D_MipLevelForScale (float scale); 95 | 96 | extern short *d_pzbuffer; 97 | extern unsigned int d_zrowbytes, d_zwidth; 98 | 99 | extern int *d_pscantable; 100 | extern int d_scantable[MAXHEIGHT]; 101 | 102 | extern int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; 103 | 104 | extern int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; 105 | 106 | extern pixel_t *d_viewbuffer; 107 | 108 | extern unsigned short *zspantable[MAXHEIGHT]; 109 | 110 | extern int d_minmip; 111 | extern float d_scalemip[3]; 112 | 113 | extern void (*d_drawspans) (espan_t *pspan); 114 | 115 | extern byte *skyunderlay, *skyoverlay; // Manoel Kasimier - smooth sky 116 | //qb: remove stipple extern cvar_t sw_stipplealpha; // Manoel Kasimier 117 | 118 | -------------------------------------------------------------------------------- /d_modech.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // d_modech.c: called when mode has just changed 18 | 19 | #include "quakedef.h" 20 | #include "d_local.h" 21 | 22 | int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; 23 | 24 | int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; 25 | 26 | int d_scantable[MAXHEIGHT]; 27 | unsigned short *zspantable[MAXHEIGHT]; 28 | 29 | 30 | /* 31 | ================ 32 | D_ViewChanged 33 | ================ 34 | */ 35 | void D_ViewChanged (void) 36 | { 37 | int rowbytes=vid.rowbytes; // look below 38 | 39 | scale_for_mip = xscale; 40 | if (yscale > xscale) 41 | scale_for_mip = yscale; 42 | 43 | d_zrowbytes = vid.width * 2; 44 | d_zwidth = vid.width; 45 | 46 | d_pix_min = r_refdef.vrect.width / 320; 47 | if (d_pix_min < 1) 48 | d_pix_min = 1; 49 | 50 | d_pix_max = (int)((float)r_refdef.vrect.width / (320.0 / 12.0) + 0.5)* r_part_scale.value; //qb: was 4.0, bigger particles 51 | d_pix_max = (int)((float)d_pix_max*fovscale); // Manoel Kasimier - FOV-based scaling - fix 52 | if (d_pix_max < 1) 53 | d_pix_max = 1; 54 | 55 | if (pixelAspect > 1.4) 56 | d_y_aspect_shift = 1; 57 | else 58 | d_y_aspect_shift = 0; 59 | 60 | d_vrectx = r_refdef.vrect.x; 61 | d_vrecty = r_refdef.vrect.y; 62 | d_vrectright_particle = r_refdef.vrectright;// - d_pix_max; // Manoel Kasimier - FOV-based scaling - fixed 63 | d_vrectbottom_particle = 64 | r_refdef.vrectbottom;// - (d_pix_max << d_y_aspect_shift); // Manoel Kasimier - FOV-based scaling - fixed 65 | 66 | { 67 | unsigned int i; 68 | 69 | for (i=0 ; iSetup menu (ala Quake2) 42 | - improvements in software renderer to make it look a bit nicer 43 | - major code cleanup 44 | 45 | /*================================================*/ 46 | What's new in 1.11 47 | /*================================================*/ 48 | - .lmp and gfx.wad pictures support alpha pixels now. Tixels that have their color set to 255 will be automatically detected by TOChriS Quake and skipped at drawing stage. 49 | - added '()' to say_team, so team messages are QW-style now. 50 | - skyboxes support. To load a skybox you can use type 'loadsky skyboxname' or 'r_skyname skyboxname' at the console. Mapper can assign skybox to his map by setting "sky" field of worldspawn entity to the name of the wanted skybox. 6 .pcx files, that should be placed in gfx/env/ directory, are required. 51 | - stereo sound support ('loadas8bit' cvar is gone, added 'snd_swapstereo' cvar for people with backwards sound wiring). 52 | - added '+use' button support. 53 | - win32 Copy & Paste to console. 54 | - 'crosshair 2' (cross), 'crosshair 3' (square) and 'crosshair 4' (dot), 'crosshaircolor' cvars. 55 | - 'cl_freelook' cvar (actually it was implemented in 1.10 but I forgot to document it). 56 | - 'viewalias' command (usage: 'viewalias aliasname'). Displays body of the alias. 57 | - 'writeconfig' command (usage: 'writeconfig filename'). Also was implemented in 1.10 but left undocumented until 1.11. 58 | - fixed the nasty bug, that could lead to invalid rendering of surfaces. 59 | 60 | /*================================================*/ 61 | What's new in 1.10 62 | /*================================================*/ 63 | - Frame ('r_im_animation' cvar) and movement ('r_im_transform' cvar) interpolation (!). 64 | - Ability to load .lit files (set 'r_loadlits' to 1 once in the game and restart the map). You won't notice any difference between original mode (no coloured lights), but I kept in the case you want it... 65 | - Fixed chase cam. Use 'chase_active' cvar to turn it on/off. 66 | - Bobbing items ('r_bobbing' cvar). 67 | - Advanced console. 68 | - Increased number of maximum vertexes per model to 2024 (so FBI MOD works). 69 | - Fixed bounding boxes of models (affects static entities). 70 | - Support for rotating bmodels. 71 | - 'show_fps' cvar. 72 | - Fast sky. Use 'r_fastsky' and 'r_skycolor' cvars to change options of the sky. 73 | - 'Graphics options' menu to play with. 74 | - Tons of tweaks, speedups and bugfixes that may be not that visible but make game a lot more playable. 75 | 76 | /*================================================*/ 77 | Thanks 78 | /*================================================*/ 79 | 80 | - LordHavoc: bounding boxes fix, .lit files, stereo sound support (just great programmer!). 81 | - Pheonix: original interpolation code, which mine is based on. 82 | - FrikaC: improved\fixed chasecam and support for more than 3 years (or maybe even 4?). 83 | - EvilTypeGuy: advanced console. Be as evil as possible! 84 | - Tonik (aka Bemep): fast sky code, advice, help and examples of good coding! 85 | - All Twilight (http://twilight.sf.net/) guys. Hey, I'm one of them! 86 | -------------------------------------------------------------------------------- /doc/newskip.txt: -------------------------------------------------------------------------------- 1 | 2 | ================================================================================ 3 | Newskip version 1.0 by John Fitzgibbons 4 | email: johnfitz@u.washington.edu 5 | web: http://www.celephais.net/ 6 | July 13, 2007 7 | 8 | Newskip is a tool that removes "skip" surfaces from a Quake bsp file so that 9 | the game won't draw them. It works on both world brushes and entities, and 10 | supports liquids too. Based on the original concept by Tyrann. 11 | 12 | How To Use It 13 | -------------------------------------------------------------------------------- 14 | 15 | 1) Using the textures in newskip.wad, mark surfaces in your map that you don't 16 | want drawn in-game. Skip can be used on any solid brush, *waterskip, *slimeskip, 17 | and *lavaskip are necessary when a brush contains a liquid, becuase all faces on 18 | a brush need to have the same contents type for Qbsp. Be sure to run Qbsp with 19 | the option -transwater if you do use skip on liquid brushes, otherwise you 20 | won't be able to see anything on the other side of the skipped face. 21 | 22 | 2) Place newskip.exe somewhere convenient, like where you keep Qbsp. Call it 23 | from the command prompt or in a batch file, like so: "newskip " 24 | 25 | How It Works 26 | -------------------------------------------------------------------------------- 27 | 28 | Newskip does not actually delete anything from the bsp file, so the processed 29 | file will still be the same size as the original. What newskip does is re- 30 | arrange the internal arrays of surfaces in the file, and lowers the total 31 | surface counts so that the surfaces at the end of the list are ignored by the 32 | engine when rendering. 33 | 34 | For the world itself, Newskip edits each leaf's "nummarksurfaces" count and 35 | reorders the marksurfaces array. For brush entities, Newskip edits each 36 | model's "numfaces" count and reorders the surfaces array. 37 | 38 | Copyright / Permissions 39 | -------------------------------------------------------------------------------- 40 | 41 | Copyright (C) 2007 John Fitzgibbons 42 | 43 | This program is free software; you can redistribute it and/or modify it under 44 | the terms of the GNU General Public License as published by the Free Software 45 | Foundation; either version 2 of the License, or (at your option) any later 46 | version. 47 | 48 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 49 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 50 | PARTICULAR PURPOSE. 51 | 52 | See the GNU General Public License for more details. 53 | 54 | You should have received a copy of the GNU General Public License along with 55 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 56 | Place - Suite 330, Boston, MA 02111-1307, USA. 57 | 58 | History 59 | -------------------------------------------------------------------------------- 60 | 61 | version 1.0 62 | - initial release 63 | - removes skip on both worldmodel and entities 64 | - supports skip on liquids -------------------------------------------------------------------------------- /doc/readme_fisheye.txt: -------------------------------------------------------------------------------- 1 | Fisheye Quake! 2 | 3 | By Aardappel (aardappel@planetquake.com) & Brick (brick@gamesinferno.com) 4 | 5 | http://www.planetquake.com/aardappel 6 | http://www.ecs.soton.ac.uk/~wvo96r/gfxengine/fisheyequake/ 7 | http://www.gamesinferno.com/aardappel 8 | 9 | http://www.gamesinferno.com/brick 10 | 11 | 12 | Running it 13 | ========== 14 | Put fisheyequake.exe in your quake directory and run it! couldn't be easier! 15 | 16 | WARNING: Fisheye Quake is by nature very computationally intensive. 17 | Run in 320x200, and unless you have a p500 or better do not expect to get 18 | playable fps. 19 | 20 | Two new cvars are available: 21 | - "ffov" (default = 180). Change this to ANY value for the corresponding fov. 22 | Most practical values lie between 120 and 250, depending on you taste. 23 | - "fviews" (default = 6). Fisheye Quake renders by first having quake render 24 | 6 fov 90 views, and then sampling the final view from that. If your ffov 25 | is around 200 or lower, you will never see the back view so you can set 26 | fviews to 5 for a tiny speedup. If you use a really low ffov like around 27 | 120, you can set it to 3 for quite a significant speedup (panorama mode :). 28 | 29 | A couple of old cvars have had their name changed because they should never 30 | be changed from their default values, because the fisheye renderer expects 31 | them to have certain values. They are: "fov" (duh!) and "viewsize" (can't 32 | have a statusbar, sorry!). 33 | 34 | 35 | Problems 36 | ======== 37 | Fisheye Quake is a drop-in replacement for WinQuake, so if you never had that 38 | installed you may miss some DLLs. Get it here: 39 | http://www.cdrom.com/pub/idgames2/planetquake/academy/essentials/wq100.zip 40 | Also, if your machine has problems running winquake, it will have the same 41 | problems running fisheyequake. You may need to experiment with commandline 42 | flags (note that things like -dibonly can slow it down greatly). 43 | 44 | On some machines, it used to crash randonly after a few minutes. This is likely 45 | fixed now though. 46 | 47 | 48 | What! Why? How? 49 | =============== 50 | If you are left full of questions about fisheye, check out the homepage, esp. 51 | the page on there that compares fisheye with normal fov (url above). 52 | 53 | 54 | Source Code 55 | =========== 56 | In the source directory you will find the modified files (screen.c, r_main.c 57 | and view.c). Almost all fisheye code sits at the end of view.c. 58 | To compile for yourself, get the original id sourcecode release and simply 59 | replace these 3 files. If you want to add fisheye to an already modified 60 | port, you'll have to make a diff, and merge the code in yourself. 61 | 62 | The code is covered by the same license as the original id code, the GNU public 63 | license. Do not ask me to help in using the source, if you can't get it to work 64 | you probably shouldn't be doing it anyway. 65 | 66 | 67 | Cheating 68 | ======== 69 | There will be some people who will see no other purpose to Fisheye Quake than 70 | cheating. Yes it would be quite an effective cheat (given you have an Athlon 71 | 800 or better), but that's not the reason I made it. Fisheye is simply a 72 | superior way of displaying a 3d world, deal with it. I dig it for the way it 73 | looks (more curves than q3a!) and the way it feels when you move, if your 74 | only interest is cheating you are a sad bastard, I can't fix that. 75 | Similarly if you feel like accusing me of helping people cheat, grow up. 76 | 77 | 78 | Timedemos 79 | ========= 80 | If you have a brutally fast machine and wanna impress me with your framerate, 81 | do a "timedemo demo1" on (note well!) 320x200 full screen mode. Send me your 82 | fps along with details of cpu/videocard/os (last two can influence performance 83 | a lot, as Fisheye Quake does a lot of copying from and to videomemory). 84 | For comparison, my machine (ppro200/voodoo3/w95) gets 6.5 fps, a mates 85 | p3-600/geforce/w98 machine gets about 24 fps, and a celeron oc to 450/tnt/ 86 | w2k only got about 9. 87 | 88 | History 89 | ======= 90 | I just love fisheye, and when I stumbled across a leaked copy of the quake 91 | source code (for linux, version 1.01) I just couldn't resist. To avoid being 92 | sued by id I couldn't release it though, so best I could do was screenshots 93 | and AVIs on my homepage... highly irritating as some people even thought they 94 | were merely fakes, warped in photoshop. Then in december'99 came the official 95 | source code release so I could finally release the code. 96 | 97 | 98 | Future 99 | ====== 100 | I intend to do this all in OpenGL, and a bit faster :) -------------------------------------------------------------------------------- /doc/readme_makaqu_effects.txt: -------------------------------------------------------------------------------- 1 | Effects comments from dcemulation.org board (thought this was interesting - qbism) 2 | 3 | --------- 4 | FEATURE REUQEST cvar that makes second sky scroll layer additive if addmap exists 5 | 6 | It's funny that you mentioned the additive sky blending, because I had done this for Fightoon (hard coded, no cvar) and reverted it for Makaqu 1.3. There's actually a handful of interesting blending effects that would work well in different situations, and it would be interesting to implement a way to select between different blend maps not only for the sky but also for the other parts of the renderer that uses blending effects (liquids, sprites, alias models, console background, etc.). 7 | 8 | Personally I'd like to replace EF_ADDITIVE with a string field called .r_blendmap and a float field called .r_blendintensity, and EF_CELSHADING with a float field called .r_shading (.r_shading would also replace EF_FULLBRIGHT and the metallic shading whose EF_ name I don't remember right now) and another called .r_outline (which could probably be replaced with a .r_wireframe), but I don't see the point in making all these standards for an obscure engine such as Makaqu. 9 | 10 | By the way, I just remembered that Makaqu supports multiple sky textures in the same map (normal Quake engines always uses the same sky texture on all sky surfaces). And Makaqu 1.3 can display skyboxes in maps without sky surfaces (the skyboxes replaces the void, noclip out of a map to see). 11 | 12 | Well, enough rambling. Currently I'm kinda busy working in a Java dancing game, but when I get enough free time I'll work on Makaqu 1.4, which should be the last release. 13 | 14 | 15 | -------------------------------------------------------------------------------- /doc/readme_quakesrc.txt: -------------------------------------------------------------------------------- 1 | 2 | This is the complete source code for winquake, glquake, quakeworld, and 3 | glquakeworld. 4 | 5 | The projects have been tested with visual C++ 6.0, but masm is also required 6 | to build the assembly language files. It is possible to change a #define and 7 | build with only C code, but the software rendering versions lose almost half 8 | its speed. The OpenGL versions will not be effected very much. The 9 | gas2masm tool was created to allow us to use the same source for the dos, 10 | linux, and windows versions, but I don't really recommend anyone mess 11 | with the asm code. 12 | 13 | The original dos version of Quake should also be buildable from these 14 | sources, but we didn't bother trying. 15 | 16 | The code is all licensed under the terms of the GPL (gnu public license). 17 | You should read the entire license, but the gist of it is that you can do 18 | anything you want with the code, including sell your new version. The catch 19 | is that if you distribute new binary versions, you are required to make the 20 | entire source code available for free to everyone. 21 | 22 | Our previous code releases have been under licenses that preclude 23 | commercial exploitation, but have no clause forcing sharing of source code. 24 | There have been some unfortunate losses to the community as a result of 25 | mod teams keeping their sources closed (and sometimes losing them). If 26 | you are going to publicly release modified versions of this code, you must 27 | also make source code available. I would encourage teams to even go a step 28 | farther and investigate using public CVS servers for development where 29 | possible. 30 | 31 | The primary intent of this release is for entertainment and educational 32 | purposes, but the GPL does allow commercial exploitation if you obey the 33 | full license. If you want to do something commercial and you just can't bear 34 | to have your source changes released, we could still negotiate a separate 35 | license agreement (for $$$), but I would encourage you to just live with the 36 | GPL. 37 | 38 | All of the Quake data files remain copyrighted and licensed under the 39 | original terms, so you cannot redistribute data from the original game, but if 40 | you do a true total conversion, you can create a standalone game based on 41 | this code. 42 | 43 | I will see about having the license changed on the shareware episode of 44 | quake to allow it to be duplicated more freely (for linux distributions, for 45 | example), but I can't give a timeframe for it. You can still download one of 46 | the original quake demos and use that data with the code, but there are 47 | restrictions on the redistribution of the demo data. 48 | 49 | If you never actually bought a complete version of Quake, you might want 50 | to rummage around in a local software bargain bin for one of the originals, 51 | or perhaps find a copy of the "Quake: the offering" boxed set with both 52 | mission packs. 53 | 54 | Thanks to Dave "Zoid" Kirsh and Robert Duffy for doing the grunt work of 55 | building this release. 56 | 57 | John Carmack 58 | Id Software 59 | 60 | 61 | -------------------------------------------------------------------------------- /draw.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // draw.h -- these are the only functions outside the refresh allowed 19 | // to touch the vid buffer 20 | 21 | extern qpic_t *draw_disc; // also used on sbar 22 | 23 | void Draw_Init (void); 24 | void Draw_Character (int x, int y, int num); 25 | #if 0 26 | void Draw_DebugChar (char num); 27 | #endif 28 | void Draw_TransPic (int x, int y, qpic_t *pic); 29 | void Draw_TransPicMirror (int x, int y, qpic_t *pic); // Manoel Kasimier 30 | void Draw_ConsoleBackground (int lines); 31 | void Draw_TileClear (int x, int y, int w, int h); 32 | void Draw_Fill (int x, int y, int w, int h, int c); 33 | void M_Draw_Fill (int x, int y, int w, int h, byte c); //qb: from Makaqu 1.6 34 | void Draw_FadeScreen (void); 35 | void Draw_String (int x, int y, char *str, qboolean sscale); 36 | qpic_t *Draw_PicFromWad (char *name); 37 | qpic_t *Draw_CachePic (char *path); 38 | // Manoel Kasimier - begin 39 | void M_Print (int cx, int cy, char *str); 40 | void M_PrintWhite (int cx, int cy, char *str); 41 | void M_DrawTransPic (int x, int y, qpic_t *pic, qboolean sscale); 42 | void M_DrawTransPicTranslate (int x, int y, qpic_t *pic, qboolean sscale); 43 | void M_DrawTextBox (int x, int y, int width, int lines); 44 | void M_DrawPlaque (char *c, qboolean b); 45 | // Manoel Kasimier - end 46 | -------------------------------------------------------------------------------- /easy.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_EASY_H 2 | #define __CURL_EASY_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * $Id: easy.h,v 1.13 2004/11/09 14:02:58 giva Exp $ 24 | ***************************************************************************/ 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | CURL_EXTERN CURL *curl_easy_init(void); 30 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 31 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); 32 | CURL_EXTERN void curl_easy_cleanup(CURL *curl); 33 | 34 | /* 35 | * NAME curl_easy_getinfo() 36 | * 37 | * DESCRIPTION 38 | * 39 | * Request internal information from the curl session with this function. The 40 | * third argument MUST be a pointer to a long, a pointer to a char * or a 41 | * pointer to a double (as the documentation describes elsewhere). The data 42 | * pointed to will be filled in accordingly and can be relied upon only if the 43 | * function returns CURLE_OK. This function is intended to get used *AFTER* a 44 | * performed transfer, all results from this function are undefined until the 45 | * transfer is completed. 46 | */ 47 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 48 | 49 | 50 | /* 51 | * NAME curl_easy_duphandle() 52 | * 53 | * DESCRIPTION 54 | * 55 | * Creates a new curl session handle with the same options set for the handle 56 | * passed in. Duplicating a handle could only be a matter of cloning data and 57 | * options, internal state info and things like persistant connections cannot 58 | * be transfered. It is useful in multithreaded applications when you can run 59 | * curl_easy_duphandle() for each new thread to avoid a series of identical 60 | * curl_easy_setopt() invokes in every thread. 61 | */ 62 | CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl); 63 | 64 | /* 65 | * NAME curl_easy_reset() 66 | * 67 | * DESCRIPTION 68 | * 69 | * Re-initializes a CURL handle to the default values. This puts back the 70 | * handle to the same state as it was in when it was just created. 71 | * 72 | * It does keep: live connections, the Session ID cache, the DNS cache and the 73 | * cookies. 74 | */ 75 | CURL_EXTERN void curl_easy_reset(CURL *curl); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /host.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/host.c -------------------------------------------------------------------------------- /input.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // input.h -- external (non-keyboard) input devices 18 | 19 | void IN_Init (void); 20 | 21 | void IN_Shutdown (void); 22 | 23 | void IN_Commands (void); 24 | // oportunity for devices to stick commands on the script buffer 25 | 26 | void IN_Move (usercmd_t *cmd); 27 | // add additional movement on top of the keyboard move cmd 28 | 29 | void IN_ClearStates (void); 30 | // restores all button and position states to defaults 31 | 32 | -------------------------------------------------------------------------------- /keys.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // 19 | // these are the key numbers that should be passed to Key_Event 20 | // 21 | #define K_TAB 9 22 | #define K_ENTER 13 23 | #define K_ESCAPE 27 24 | #define K_SPACE 32 25 | 26 | // normal keys should be passed as lowercased ascii 27 | 28 | #define K_BACKSPACE 127 29 | #define K_UPARROW 128 30 | #define K_DOWNARROW 129 31 | #define K_LEFTARROW 130 32 | #define K_RIGHTARROW 131 33 | 34 | #define K_ALT 132 35 | #define K_CTRL 133 36 | #define K_SHIFT 134 37 | #define K_F1 135 38 | #define K_F2 136 39 | #define K_F3 137 40 | #define K_F4 138 41 | #define K_F5 139 42 | #define K_F6 140 43 | #define K_F7 141 44 | #define K_F8 142 45 | #define K_F9 143 46 | #define K_F10 144 47 | #define K_F11 145 48 | #define K_F12 146 49 | #define K_INS 147 50 | #define K_DEL 148 51 | #define K_PGDN 149 52 | #define K_PGUP 150 53 | #define K_HOME 151 54 | #define K_END 152 55 | 56 | #define K_PAUSE 255 57 | 58 | // 59 | // mouse buttons generate virtual keys 60 | // 61 | #define K_MOUSE1 200 62 | #define K_MOUSE2 201 63 | #define K_MOUSE3 202 64 | 65 | // 66 | // joystick buttons 67 | // 68 | #define K_JOY1 203 69 | #define K_JOY2 204 70 | #define K_JOY3 205 71 | #define K_JOY4 206 72 | 73 | // 74 | // aux keys are for multi-buttoned joysticks to generate so they can use 75 | // the normal binding process 76 | // 77 | #define K_AUX1 207 78 | #define K_AUX2 208 79 | #define K_AUX3 209 80 | #define K_AUX4 210 81 | #define K_AUX5 211 82 | #define K_AUX6 212 83 | #define K_AUX7 213 84 | #define K_AUX8 214 85 | #define K_AUX9 215 86 | #define K_AUX10 216 87 | #define K_AUX11 217 88 | #define K_AUX12 218 89 | #define K_AUX13 219 90 | #define K_AUX14 220 91 | #define K_AUX15 221 92 | #define K_AUX16 222 93 | #define K_AUX17 223 94 | #define K_AUX18 224 95 | #define K_AUX19 225 96 | #define K_AUX20 226 97 | #define K_AUX21 227 98 | #define K_AUX22 228 99 | #define K_AUX23 229 100 | #define K_AUX24 230 101 | #define K_AUX25 231 102 | #define K_AUX26 232 103 | #define K_AUX27 233 104 | #define K_AUX28 234 105 | #define K_AUX29 235 106 | #define K_AUX30 236 107 | #define K_AUX31 237 108 | #define K_AUX32 238 109 | 110 | // JACK: Intellimouse(c) Mouse Wheel Support 111 | 112 | #define K_MWHEELUP 239 113 | #define K_MWHEELDOWN 240 114 | 115 | // MH - POV hat support - keep it separate from the joy buttons 116 | #define K_POV1 241 117 | #define K_POV2 242 118 | #define K_POV3 243 119 | #define K_POV4 244 120 | 121 | /* Extra mouse buttons */ 122 | #define K_MOUSE4 245 123 | #define K_MOUSE5 246 124 | #define K_MOUSE6 247 125 | #define K_MOUSE7 248 126 | #define K_MOUSE8 249 127 | 128 | // Manoel Kasimier - for testing purposes - begin 129 | #if 1 130 | #define K_DC_A K_JOY1 131 | #define K_DC_B K_JOY2 132 | #define K_DC_C K_JOY3 133 | #define K_DC_X K_JOY4 134 | #define K_DC_Y K_AUX5 135 | #define K_DC_Z K_AUX6 136 | #define K_DC_LTRIG K_AUX7 137 | #define K_DC_RTRIG K_AUX8 138 | #define K_DC_START K_AUX10 139 | #define K_DPAD1_LEFT K_AUX13 140 | #define K_DPAD1_DOWN K_AUX14 141 | #define K_DPAD1_RIGHT K_AUX15 142 | #define K_DPAD1_UP K_AUX16 143 | #endif 144 | // Manoel Kasimier - for testing purposes - end 145 | 146 | //qb: qrack command line begin 147 | #define MAXCMDLINE 256 148 | 149 | //qb: qrack command line end 150 | 151 | typedef enum {key_game, key_console, key_message, key_menu} keydest_t; 152 | 153 | extern qboolean shift_function; // Manoel Kasimier - function shift 154 | extern keydest_t key_dest; 155 | extern char *keybindings[256]; 156 | extern char *shiftbindings[256]; // Manoel Kasimier - function shift 157 | extern int key_repeats[256]; 158 | extern int key_count; // incremented every key event 159 | extern int key_lastpress; 160 | 161 | void Key_Event (int key, qboolean down); 162 | void Key_Init (void); 163 | void Key_WriteBindings (FILE *f); 164 | void Key_SetBinding (int keynum, char *binding); 165 | void Key_SetShiftBinding (int keynum, char *binding); // Manoel Kasimier - function shift 166 | void Key_ClearStates (void); 167 | int Key_StringToKeynum (char *str); // Manoel Kasimier 168 | 169 | // Manoel Kasimier - on-screen keyboard - begin 170 | int M_OnScreenKeyboard_Key (int key); 171 | void M_OnScreenKeyboard_Reset (void); 172 | // Manoel Kasimier - on-screen keyboard - end 173 | -------------------------------------------------------------------------------- /mathlib.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // mathlib.h 18 | 19 | typedef float vec_t; 20 | typedef vec_t vec3_t[3]; 21 | typedef vec_t vec5_t[5]; 22 | 23 | typedef int fixed4_t; 24 | typedef int fixed8_t; 25 | typedef int fixed16_t; 26 | 27 | #ifndef M_PI 28 | #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h 29 | #endif 30 | 31 | struct mplane_s; 32 | 33 | extern vec3_t vec3_origin; 34 | extern int nanmask; 35 | 36 | #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) 37 | 38 | #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) 39 | #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} 40 | #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} 41 | #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} 42 | #define VectorClear(a) {((a)[0]=(a)[1]=(a)[2]=0);} //qb: from engoo 43 | #define anglemod(a) ((360.0 / 65536) * ((int)((a) * (65536 / 360.0)) & 65535)) //qb: move this here 44 | 45 | void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc); 46 | vec_t VectorDistance (vec3_t x,vec3_t y); 47 | vec_t _DotProduct (vec3_t v1, vec3_t v2); 48 | void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); 49 | void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out); 50 | void _VectorCopy (vec3_t in, vec3_t out); 51 | 52 | int VectorCompare (vec3_t v1, vec3_t v2); 53 | vec_t Length (vec3_t v); 54 | void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross); 55 | float VectorNormalize (vec3_t v); // returns vector length 56 | void VectorInverse (vec3_t v); 57 | void VectorScale (vec3_t in, vec_t scale, vec3_t out); 58 | int Q_log2(int val); 59 | 60 | void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); 61 | void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); 62 | 63 | void FloorDivMod (double numer, double denom, int *quotient, 64 | int *rem); 65 | fixed16_t Invert24To16(fixed16_t val); 66 | int GreatestCommonDivisor (int i1, int i2); 67 | 68 | void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); 69 | int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); 70 | 71 | #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ 72 | (((p)->type < 3)? \ 73 | ( \ 74 | ((p)->dist <= (emins)[(p)->type])? \ 75 | 1 \ 76 | : \ 77 | ( \ 78 | ((p)->dist >= (emaxs)[(p)->type])?\ 79 | 2 \ 80 | : \ 81 | 3 \ 82 | ) \ 83 | ) \ 84 | : \ 85 | BoxOnPlaneSide( (emins), (emaxs), (p))) 86 | 87 | // 2001-11-15 DarkPlaces general builtin functions by LordHavoc start 88 | #define bound(min,num,max) (num >= min ? (num < max ? num : max) : min) 89 | #define CLAMP(min, x, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) //johnfitz 90 | 91 | #ifndef min 92 | #define min(val1,val2) (val2 < val1 ? val2 : val1) 93 | #endif 94 | 95 | #ifndef max 96 | #define max(val1,val2) (val2 > val1 ? val2 : val1) 97 | #endif 98 | 99 | // 2001-11-15 DarkPlaces general builtin functions by LordHavoc end 100 | 101 | #define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //qb: jqavi -todo- use elsewhere? look at jq and fitzq 102 | -------------------------------------------------------------------------------- /menu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/menu.c -------------------------------------------------------------------------------- /menu.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // 19 | // the net drivers should just set the apropriate bits in m_activenet, 20 | // instead of having the menu code look through their internal tables 21 | // 22 | #define MNET_IPX 1 23 | #define MNET_TCP 2 24 | 25 | extern int m_activenet; 26 | 27 | // 28 | // menus 29 | // 30 | void M_Init (void); 31 | void M_Keydown (int key); 32 | void M_Draw (void); 33 | void M_ToggleMenu_f (void); 34 | 35 | 36 | -------------------------------------------------------------------------------- /net_dgrm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // net_dgrm.h 18 | 19 | 20 | int Datagram_Init (void); 21 | void Datagram_Listen (qboolean state); 22 | void Datagram_SearchForHosts (qboolean xmit); 23 | qsocket_t *Datagram_Connect (char *host); 24 | qsocket_t *Datagram_CheckNewConnections (void); 25 | int Datagram_GetMessage (qsocket_t *sock); 26 | int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data); 27 | int Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data); 28 | qboolean Datagram_CanSendMessage (qsocket_t *sock); 29 | qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock); 30 | void Datagram_Close (qsocket_t *sock); 31 | void Datagram_Shutdown (void); 32 | -------------------------------------------------------------------------------- /net_loop.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // net_loop.h 18 | 19 | int Loop_Init (void); 20 | void Loop_Listen (qboolean state); 21 | void Loop_SearchForHosts (qboolean xmit); 22 | qsocket_t *Loop_Connect (char *host); 23 | qsocket_t *Loop_CheckNewConnections (void); 24 | int Loop_GetMessage (qsocket_t *sock); 25 | int Loop_SendMessage (qsocket_t *sock, sizebuf_t *data); 26 | int Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data); 27 | qboolean Loop_CanSendMessage (qsocket_t *sock); 28 | qboolean Loop_CanSendUnreliableMessage (qsocket_t *sock); 29 | void Loop_Close (qsocket_t *sock); 30 | void Loop_Shutdown (void); 31 | -------------------------------------------------------------------------------- /net_none.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | #include "quakedef.h" 18 | 19 | #include "net_loop.h" 20 | 21 | net_driver_t net_drivers[MAX_NET_DRIVERS] = 22 | { 23 | { 24 | "Loopback", 25 | false, 26 | Loop_Init, 27 | Loop_Listen, 28 | Loop_SearchForHosts, 29 | Loop_Connect, 30 | Loop_CheckNewConnections, 31 | Loop_GetMessage, 32 | Loop_SendMessage, 33 | Loop_SendUnreliableMessage, 34 | Loop_CanSendMessage, 35 | Loop_CanSendUnreliableMessage, 36 | Loop_Close, 37 | Loop_Shutdown 38 | } 39 | }; 40 | int net_numdrivers = 1; 41 | 42 | net_landriver_t net_landrivers[MAX_NET_DRIVERS]; 43 | int net_numlandrivers = 0; 44 | -------------------------------------------------------------------------------- /pr_comp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // this file is shared by quake and qcc 19 | 20 | typedef int func_t; 21 | typedef int string_t; 22 | 23 | typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; 24 | 25 | 26 | #define OFS_NULL 0 27 | #define OFS_RETURN 1 28 | #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors 29 | #define OFS_PARM1 7 30 | #define OFS_PARM2 10 31 | #define OFS_PARM3 13 32 | #define OFS_PARM4 16 33 | #define OFS_PARM5 19 34 | #define OFS_PARM6 22 35 | #define OFS_PARM7 25 36 | #define RESERVED_OFS 28 37 | 38 | 39 | enum { 40 | OP_DONE, 41 | OP_MUL_F, 42 | OP_MUL_V, 43 | OP_MUL_FV, 44 | OP_MUL_VF, 45 | OP_DIV_F, 46 | OP_ADD_F, 47 | OP_ADD_V, 48 | OP_SUB_F, 49 | OP_SUB_V, 50 | 51 | OP_EQ_F, 52 | OP_EQ_V, 53 | OP_EQ_S, 54 | OP_EQ_E, 55 | OP_EQ_FNC, 56 | 57 | OP_NE_F, 58 | OP_NE_V, 59 | OP_NE_S, 60 | OP_NE_E, 61 | OP_NE_FNC, 62 | 63 | OP_LE, 64 | OP_GE, 65 | OP_LT, 66 | OP_GT, 67 | 68 | OP_LOAD_F, 69 | OP_LOAD_V, 70 | OP_LOAD_S, 71 | OP_LOAD_ENT, 72 | OP_LOAD_FLD, 73 | OP_LOAD_FNC, 74 | 75 | OP_ADDRESS, 76 | 77 | OP_STORE_F, 78 | OP_STORE_V, 79 | OP_STORE_S, 80 | OP_STORE_ENT, 81 | OP_STORE_FLD, 82 | OP_STORE_FNC, 83 | 84 | OP_STOREP_F, 85 | OP_STOREP_V, 86 | OP_STOREP_S, 87 | OP_STOREP_ENT, 88 | OP_STOREP_FLD, 89 | OP_STOREP_FNC, 90 | 91 | OP_RETURN, 92 | OP_NOT_F, 93 | OP_NOT_V, 94 | OP_NOT_S, 95 | OP_NOT_ENT, 96 | OP_NOT_FNC, 97 | OP_IF, 98 | OP_IFNOT, 99 | OP_CALL0, 100 | OP_CALL1, 101 | OP_CALL2, 102 | OP_CALL3, 103 | OP_CALL4, 104 | OP_CALL5, 105 | OP_CALL6, 106 | OP_CALL7, 107 | OP_CALL8, 108 | OP_STATE, 109 | OP_GOTO, 110 | OP_AND, 111 | OP_OR, 112 | 113 | OP_BITAND, 114 | OP_BITOR 115 | }; 116 | 117 | 118 | typedef struct statement_s 119 | { 120 | unsigned short op; 121 | short a,b,c; 122 | } dstatement_t; 123 | 124 | typedef struct 125 | { 126 | unsigned short type; // if DEF_SAVEGLOBGAL bit is set 127 | // the variable needs to be saved in savegames 128 | unsigned short ofs; 129 | int s_name; 130 | } ddef_t; 131 | #define DEF_SAVEGLOBAL (1<<15) 132 | 133 | #define MAX_PARMS 8 134 | 135 | typedef struct 136 | { 137 | int first_statement; // negative numbers are builtins 138 | int parm_start; 139 | int locals; // total ints of parms + locals 140 | 141 | int profile; // runtime 142 | 143 | int s_name; 144 | int s_file; // source file defined in 145 | 146 | int numparms; 147 | byte parm_size[MAX_PARMS]; 148 | } dfunction_t; 149 | 150 | 151 | #define PROG_VERSION 6 152 | typedef struct 153 | { 154 | int version; 155 | int crc; // check of header file 156 | 157 | int ofs_statements; 158 | int numstatements; // statement 0 is an error 159 | 160 | int ofs_globaldefs; 161 | int numglobaldefs; 162 | 163 | int ofs_fielddefs; 164 | int numfielddefs; 165 | 166 | int ofs_functions; 167 | int numfunctions; // function 0 is an empty 168 | 169 | int ofs_strings; 170 | int numstrings; // first string is a null string 171 | 172 | int ofs_globals; 173 | int numglobals; 174 | 175 | int entityfields; 176 | } dprograms_t; 177 | 178 | -------------------------------------------------------------------------------- /progdefs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | #include "progdefs.q1" 19 | -------------------------------------------------------------------------------- /progdefs.q1: -------------------------------------------------------------------------------- 1 | 2 | /* file generated by qcc, do not modify */ 3 | 4 | typedef struct 5 | { int pad[28]; 6 | int self; 7 | int other; 8 | int world; 9 | float time; 10 | float frametime; 11 | float force_retouch; 12 | string_t mapname; 13 | float deathmatch; 14 | float coop; 15 | float teamplay; 16 | float serverflags; 17 | float total_secrets; 18 | float total_monsters; 19 | float found_secrets; 20 | float killed_monsters; 21 | float parm1; 22 | float parm2; 23 | float parm3; 24 | float parm4; 25 | float parm5; 26 | float parm6; 27 | float parm7; 28 | float parm8; 29 | float parm9; 30 | float parm10; 31 | float parm11; 32 | float parm12; 33 | float parm13; 34 | float parm14; 35 | float parm15; 36 | float parm16; 37 | vec3_t v_forward; 38 | vec3_t v_up; 39 | vec3_t v_right; 40 | float trace_allsolid; 41 | float trace_startsolid; 42 | float trace_fraction; 43 | vec3_t trace_endpos; 44 | vec3_t trace_plane_normal; 45 | float trace_plane_dist; 46 | int trace_ent; 47 | float trace_inopen; 48 | float trace_inwater; 49 | int msg_entity; 50 | func_t main; 51 | func_t StartFrame; 52 | func_t PlayerPreThink; 53 | func_t PlayerPostThink; 54 | func_t ClientKill; 55 | func_t ClientConnect; 56 | func_t PutClientInServer; 57 | func_t ClientDisconnect; 58 | func_t SetNewParms; 59 | func_t SetChangeParms; 60 | } globalvars_t; 61 | 62 | typedef struct 63 | { 64 | float modelindex; 65 | vec3_t absmin; 66 | vec3_t absmax; 67 | float ltime; 68 | float movetype; 69 | float solid; 70 | vec3_t origin; 71 | vec3_t oldorigin; 72 | vec3_t velocity; 73 | vec3_t angles; 74 | vec3_t avelocity; 75 | vec3_t punchangle; 76 | string_t classname; 77 | string_t model; 78 | float frame; 79 | float skin; 80 | float effects; 81 | vec3_t mins; 82 | vec3_t maxs; 83 | vec3_t size; 84 | func_t touch; 85 | func_t use; 86 | func_t think; 87 | func_t blocked; 88 | float nextthink; 89 | int groundentity; 90 | float health; 91 | float frags; 92 | float weapon; 93 | string_t weaponmodel; 94 | float weaponframe; 95 | float currentammo; 96 | float ammo_shells; 97 | float ammo_nails; 98 | float ammo_rockets; 99 | float ammo_cells; 100 | float items; 101 | float takedamage; 102 | int chain; 103 | float deadflag; 104 | vec3_t view_ofs; 105 | float button0; 106 | float button1; 107 | float button2; 108 | float impulse; 109 | float fixangle; 110 | vec3_t v_angle; 111 | float idealpitch; 112 | string_t netname; 113 | int enemy; 114 | float flags; 115 | float colormap; 116 | float team; 117 | float max_health; 118 | float teleport_time; 119 | float armortype; 120 | float armorvalue; 121 | float waterlevel; 122 | float watertype; 123 | float ideal_yaw; 124 | float yaw_speed; 125 | int aiment; 126 | int goalentity; 127 | float spawnflags; 128 | string_t target; 129 | string_t targetname; 130 | float dmg_take; 131 | float dmg_save; 132 | int dmg_inflictor; 133 | int owner; 134 | vec3_t movedir; 135 | string_t message; 136 | float sounds; 137 | string_t noise; 138 | string_t noise1; 139 | string_t noise2; 140 | string_t noise3; 141 | } entvars_t; 142 | 143 | #define PROGHEADER_CRC 5927 144 | -------------------------------------------------------------------------------- /qbS8.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /r_alias.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/r_alias.c -------------------------------------------------------------------------------- /r_vars.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // r_vars.c: global refresh variables 18 | 19 | #include "quakedef.h" 20 | 21 | // all global and static refresh variables are collected in a contiguous block 22 | // to avoid cache conflicts. 23 | 24 | //------------------------------------------------------- 25 | // global refresh variables 26 | //------------------------------------------------------- 27 | 28 | // FIXME: make into one big structure, like cl or sv 29 | // FIXME: do separately for refresh engine and driver 30 | 31 | int r_bmodelactive; 32 | 33 | -------------------------------------------------------------------------------- /r_varsa.S: -------------------------------------------------------------------------------- 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 | // r_varsa.s 22 | // 23 | 24 | #include "asm_i386.h" 25 | #include "quakeasm.h" 26 | #include "asm_draw.h" 27 | #include "d_ifacea.h" 28 | 29 | #if id386 30 | 31 | .data 32 | 33 | //------------------------------------------------------- 34 | // ASM-only variables 35 | //------------------------------------------------------- 36 | .globl float_1, float_particle_z_clip, float_point5 37 | .globl float_minus_1, float_0 38 | float_0: .single 0.0 39 | float_1: .single 1.0 40 | float_minus_1: .single -1.0 41 | float_particle_z_clip: .single PARTICLE_Z_CLIP 42 | float_point5: .single 0.5 43 | 44 | .globl fp_16, fp_64k, fp_1m, fp_64kx64k 45 | .globl fp_1m_minus_1 46 | .globl fp_8 47 | fp_1m: .single 1048576.0 48 | fp_1m_minus_1: .single 1048575.0 49 | fp_64k: .single 65536.0 50 | fp_8: .single 8.0 51 | fp_16: .single 16.0 52 | fp_64kx64k: .long 0x4f000000 // (float)0x8000*0x10000 53 | 54 | 55 | .globl FloatZero, Float2ToThe31nd, FloatMinus2ToThe31nd 56 | FloatZero: .long 0 57 | Float2ToThe31nd: .long 0x4f000000 58 | FloatMinus2ToThe31nd: .long 0xcf000000 59 | 60 | .globl C(r_bmodelactive) 61 | C(r_bmodelactive): .long 0 62 | 63 | #endif // id386 64 | 65 | -------------------------------------------------------------------------------- /s_win32/QBS8.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/QBS8.ico -------------------------------------------------------------------------------- /s_win32/QBS8_48x48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/QBS8_48x48.gif -------------------------------------------------------------------------------- /s_win32/QBS8_64x64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/QBS8_64x64.gif -------------------------------------------------------------------------------- /s_win32/codecs/include/ogg/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | #ifndef _MSC_VER 6 | #define INCLUDE_INTTYPES_H 1 7 | #define INCLUDE_STDINT_H 1 8 | #endif /* !MSVC */ 9 | #define INCLUDE_SYS_TYPES_H 1 10 | 11 | #if INCLUDE_INTTYPES_H 12 | # include 13 | #endif 14 | #if INCLUDE_STDINT_H 15 | # include 16 | #endif 17 | #if INCLUDE_SYS_TYPES_H 18 | # include 19 | #endif 20 | 21 | typedef short ogg_int16_t; 22 | typedef unsigned short ogg_uint16_t; 23 | typedef int ogg_int32_t; 24 | typedef unsigned int ogg_uint32_t; 25 | typedef long long ogg_int64_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /s_win32/codecs/include/ogg/os_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 14 | last mod: $Id: os_types.h 17712 2010-12-03 17:10:02Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | #ifndef _OS_TYPES_H 18 | #define _OS_TYPES_H 19 | 20 | /* make it easy on the folks that want to compile the libs with a 21 | different malloc than stdlib */ 22 | #define _ogg_malloc malloc 23 | #define _ogg_calloc calloc 24 | #define _ogg_realloc realloc 25 | #define _ogg_free free 26 | 27 | #if defined(_WIN32) 28 | 29 | # if defined(__CYGWIN__) 30 | # include 31 | typedef int16_t ogg_int16_t; 32 | typedef uint16_t ogg_uint16_t; 33 | typedef int32_t ogg_int32_t; 34 | typedef uint32_t ogg_uint32_t; 35 | typedef int64_t ogg_int64_t; 36 | typedef uint64_t ogg_uint64_t; 37 | # elif defined(__MINGW32__) 38 | # include 39 | typedef short ogg_int16_t; 40 | typedef unsigned short ogg_uint16_t; 41 | typedef int ogg_int32_t; 42 | typedef unsigned int ogg_uint32_t; 43 | typedef long long ogg_int64_t; 44 | typedef unsigned long long ogg_uint64_t; 45 | # elif defined(__MWERKS__) 46 | typedef long long ogg_int64_t; 47 | typedef int ogg_int32_t; 48 | typedef unsigned int ogg_uint32_t; 49 | typedef short ogg_int16_t; 50 | typedef unsigned short ogg_uint16_t; 51 | # else 52 | /* MSVC/Borland */ 53 | typedef __int64 ogg_int64_t; 54 | typedef __int32 ogg_int32_t; 55 | typedef unsigned __int32 ogg_uint32_t; 56 | typedef __int16 ogg_int16_t; 57 | typedef unsigned __int16 ogg_uint16_t; 58 | # endif 59 | 60 | #elif defined(__MACOS__) 61 | 62 | # include 63 | typedef SInt16 ogg_int16_t; 64 | typedef UInt16 ogg_uint16_t; 65 | typedef SInt32 ogg_int32_t; 66 | typedef UInt32 ogg_uint32_t; 67 | typedef SInt64 ogg_int64_t; 68 | 69 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 70 | 71 | # include 72 | typedef int16_t ogg_int16_t; 73 | typedef uint16_t ogg_uint16_t; 74 | typedef int32_t ogg_int32_t; 75 | typedef uint32_t ogg_uint32_t; 76 | typedef int64_t ogg_int64_t; 77 | 78 | #elif defined(__HAIKU__) 79 | 80 | /* Haiku */ 81 | # include 82 | typedef short ogg_int16_t; 83 | typedef unsigned short ogg_uint16_t; 84 | typedef int ogg_int32_t; 85 | typedef unsigned int ogg_uint32_t; 86 | typedef long long ogg_int64_t; 87 | 88 | #elif defined(__BEOS__) 89 | 90 | /* Be */ 91 | # include 92 | typedef int16_t ogg_int16_t; 93 | typedef uint16_t ogg_uint16_t; 94 | typedef int32_t ogg_int32_t; 95 | typedef uint32_t ogg_uint32_t; 96 | typedef int64_t ogg_int64_t; 97 | 98 | #elif defined (__EMX__) 99 | 100 | /* OS/2 GCC */ 101 | typedef short ogg_int16_t; 102 | typedef unsigned short ogg_uint16_t; 103 | typedef int ogg_int32_t; 104 | typedef unsigned int ogg_uint32_t; 105 | typedef long long ogg_int64_t; 106 | 107 | #elif defined (DJGPP) 108 | 109 | /* DJGPP */ 110 | typedef short ogg_int16_t; 111 | typedef int ogg_int32_t; 112 | typedef unsigned int ogg_uint32_t; 113 | typedef long long ogg_int64_t; 114 | 115 | #elif defined(R5900) 116 | 117 | /* PS2 EE */ 118 | typedef long ogg_int64_t; 119 | typedef int ogg_int32_t; 120 | typedef unsigned ogg_uint32_t; 121 | typedef short ogg_int16_t; 122 | 123 | #elif defined(__SYMBIAN32__) 124 | 125 | /* Symbian GCC */ 126 | typedef signed short ogg_int16_t; 127 | typedef unsigned short ogg_uint16_t; 128 | typedef signed int ogg_int32_t; 129 | typedef unsigned int ogg_uint32_t; 130 | typedef long long int ogg_int64_t; 131 | 132 | #elif defined(__TMS320C6X__) 133 | 134 | /* TI C64x compiler */ 135 | typedef signed short ogg_int16_t; 136 | typedef unsigned short ogg_uint16_t; 137 | typedef signed int ogg_int32_t; 138 | typedef unsigned int ogg_uint32_t; 139 | typedef long long int ogg_int64_t; 140 | 141 | #else 142 | 143 | # include 144 | 145 | #endif 146 | 147 | #endif /* _OS_TYPES_H */ 148 | -------------------------------------------------------------------------------- /s_win32/codecs/x86/libogg-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libogg-0.dll -------------------------------------------------------------------------------- /s_win32/codecs/x86/libogg.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libogg.dll.a -------------------------------------------------------------------------------- /s_win32/codecs/x86/libogg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libogg.lib -------------------------------------------------------------------------------- /s_win32/codecs/x86/libvorbis-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libvorbis-0.dll -------------------------------------------------------------------------------- /s_win32/codecs/x86/libvorbis.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libvorbis.dll.a -------------------------------------------------------------------------------- /s_win32/codecs/x86/libvorbis.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libvorbis.lib -------------------------------------------------------------------------------- /s_win32/codecs/x86/libvorbisfile-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libvorbisfile-3.dll -------------------------------------------------------------------------------- /s_win32/codecs/x86/libvorbisfile.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libvorbisfile.dll.a -------------------------------------------------------------------------------- /s_win32/codecs/x86/libvorbisfile.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/s_win32/codecs/x86/libvorbisfile.lib -------------------------------------------------------------------------------- /s_win32/conproc.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 | // conproc.h 21 | 22 | #define CCOM_WRITE_TEXT 0x2 23 | // Param1 : Text 24 | 25 | #define CCOM_GET_TEXT 0x3 26 | // Param1 : Begin line 27 | // Param2 : End line 28 | 29 | #define CCOM_GET_SCR_LINES 0x4 30 | // No params 31 | 32 | #define CCOM_SET_SCR_LINES 0x5 33 | // Param1 : Number of lines 34 | 35 | void InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild); 36 | void DeinitConProc (void); 37 | 38 | -------------------------------------------------------------------------------- /s_win32/movie_avi.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Quake done Quick 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 | // movie_avi.h 21 | 22 | void AVI_LoadLibrary (void); 23 | void ACM_LoadLibrary (void); 24 | qboolean Capture_Open (char *filename); 25 | void Capture_WriteVideo (byte *pixel_buffer); 26 | void Capture_WriteAudio (int samples, byte *sample_buffer); 27 | void Capture_Close (void); 28 | 29 | void Movie_Init (void); 30 | void Movie_StopPlayback (void); 31 | double Movie_FrameTime (void); 32 | void Movie_TransferStereo16 (void); 33 | void Movie_UpdateScreen (void); 34 | 35 | qboolean Movie_GetSoundtime (void); 36 | qboolean Movie_IsActive (void); 37 | 38 | extern cvar_t capture_hack; //qb 39 | extern qboolean avi_loaded, acm_loaded; 40 | extern cvar_t capture_codec, capture_fps, capture_mp3, capture_mp3_kbps; 41 | extern float scr_con_current; 42 | extern qboolean scr_drawloading; 43 | extern short *snd_out; 44 | extern int snd_linear_count, soundtime; 45 | -------------------------------------------------------------------------------- /s_win32/net_win.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | #include "../quakedef.h" 18 | #include "../net_loop.h" 19 | #include "../net_dgrm.h" 20 | 21 | net_driver_t net_drivers[MAX_NET_DRIVERS] = 22 | { 23 | { 24 | "Loopback", 25 | false, 26 | Loop_Init, 27 | Loop_Listen, 28 | Loop_SearchForHosts, 29 | Loop_Connect, 30 | Loop_CheckNewConnections, 31 | Loop_GetMessage, 32 | Loop_SendMessage, 33 | Loop_SendUnreliableMessage, 34 | Loop_CanSendMessage, 35 | Loop_CanSendUnreliableMessage, 36 | Loop_Close, 37 | Loop_Shutdown 38 | } 39 | , 40 | { 41 | "Datagram", 42 | false, 43 | Datagram_Init, 44 | Datagram_Listen, 45 | Datagram_SearchForHosts, 46 | Datagram_Connect, 47 | Datagram_CheckNewConnections, 48 | Datagram_GetMessage, 49 | Datagram_SendMessage, 50 | Datagram_SendUnreliableMessage, 51 | Datagram_CanSendMessage, 52 | Datagram_CanSendUnreliableMessage, 53 | Datagram_Close, 54 | Datagram_Shutdown 55 | } 56 | }; 57 | 58 | int net_numdrivers = 2; 59 | 60 | 61 | #include "net_wins.h" 62 | 63 | net_landriver_t net_landrivers[MAX_NET_DRIVERS] = 64 | { 65 | { 66 | "Winsock TCPIP", 67 | false, 68 | 0, 69 | WINS_Init, 70 | WINS_Shutdown, 71 | WINS_Listen, 72 | WINS_OpenSocket, 73 | WINS_CloseSocket, 74 | WINS_Connect, 75 | WINS_CheckNewConnections, 76 | WINS_Read, 77 | WINS_Write, 78 | WINS_Broadcast, 79 | WINS_AddrToString, 80 | WINS_StringToAddr, 81 | WINS_GetSocketAddr, 82 | WINS_GetNameFromAddr, 83 | WINS_GetAddrFromName, 84 | WINS_AddrCompare, 85 | WINS_GetSocketPort, 86 | WINS_SetSocketPort 87 | } 88 | }; 89 | 90 | int net_numlandrivers = 1; 91 | -------------------------------------------------------------------------------- /s_win32/net_wins.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_wins.h 21 | 22 | int WINS_Init (void); 23 | void WINS_Shutdown (void); 24 | void WINS_Listen (qboolean state); 25 | int WINS_OpenSocket (int port); 26 | int WINS_CloseSocket (int socket); 27 | int WINS_Connect (int socket, struct qsockaddr *addr); 28 | int WINS_CheckNewConnections (void); 29 | int WINS_Read (int socket, byte *buf, int len, struct qsockaddr *addr); 30 | int WINS_Write (int socket, byte *buf, int len, struct qsockaddr *addr); 31 | int WINS_Broadcast (int socket, byte *buf, int len); 32 | char *WINS_AddrToString (struct qsockaddr *addr); 33 | int WINS_StringToAddr (char *string, struct qsockaddr *addr); 34 | int WINS_GetSocketAddr (int socket, struct qsockaddr *addr); 35 | int WINS_GetNameFromAddr (struct qsockaddr *addr, char *name); 36 | int WINS_GetAddrFromName (char *name, struct qsockaddr *addr); 37 | int WINS_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2); 38 | int WINS_GetSocketPort (struct qsockaddr *addr); 39 | int WINS_SetSocketPort (struct qsockaddr *addr, int port); 40 | -------------------------------------------------------------------------------- /s_win32/qbS8_install.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "qbism Super8" 5 | #define MyAppVersion "235" 6 | #define MyAppPublisher "qbism game engine" 7 | #define MyAppURL "http://super8.qbism.com" 8 | #define MyAppExeName "qbismS8.exe" 9 | 10 | [Setup] 11 | ; NOTE: The value of AppId uniquely identifies this application. 12 | ; Do not use the same AppId value in installers for other applications. 13 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 14 | AppId={{5637AFB8-F573-4A7E-8887-C3DF20871ADC} 15 | AppName={#MyAppName} 16 | AppVersion={#MyAppVersion} 17 | ;AppVerName={#MyAppName} {#MyAppVersion} 18 | AppPublisher={#MyAppPublisher} 19 | AppPublisherURL={#MyAppURL} 20 | AppSupportURL={#MyAppURL} 21 | AppUpdatesURL={#MyAppURL} 22 | DefaultDirName=C:\Quake 23 | DefaultGroupName={#MyAppName} 24 | AllowNoIcons=yes 25 | LicenseFile=C:\quake\super8\docs\gnu3.txt 26 | OutputBaseFilename=setup 27 | Compression=lzma 28 | SolidCompression=yes 29 | 30 | [Languages] 31 | Name: "english"; MessagesFile: "compiler:Default.isl" 32 | 33 | [Tasks] 34 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 35 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 36 | 37 | [Files] 38 | Source: "C:\quake\qbismS8.exe"; DestDir: "{app}"; Flags: ignoreversion 39 | Source: "C:\quake\libmad-0.dll"; DestDir: "{app}"; Flags: ignoreversion 40 | Source: "C:\quake\libogg-0.dll"; DestDir: "{app}"; Flags: ignoreversion 41 | Source: "C:\quake\libvorbis-0.dll"; DestDir: "{app}"; Flags: ignoreversion 42 | Source: "C:\quake\libvorbisfile-3.dll"; DestDir: "{app}"; Flags: ignoreversion 43 | Source: "C:\quake\super8\pak88.pak"; DestDir: "{app}\super8"; Flags: ignoreversion 44 | Source: "C:\quake\super8\docs\*"; DestDir: "{app}\super8\docs"; Flags: ignoreversion recursesubdirs createallsubdirs 45 | 46 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 47 | 48 | [Icons] 49 | Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 50 | Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" 51 | Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" 52 | Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 53 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon 54 | 55 | [Run] 56 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 57 | 58 | -------------------------------------------------------------------------------- /s_win32/qbism-s8.rc: -------------------------------------------------------------------------------- 1 | #if HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | 5 | #include 6 | 7 | #pragma code_page(65001) 8 | 9 | #ifdef _DEBUG 10 | #define VER_FILEFLAGS VS_FF_DEBUG 11 | #else 12 | #define VER_FILEFLAGS 0x0L 13 | #endif 14 | 15 | #define VER_FILEDESCRIPTION_STR "qbism Super8" 16 | #define VER_ORIGINALFILENAME_STR "qbismS8.exe" 17 | 18 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 19 | 20 | VS_VERSION_INFO VERSIONINFO 21 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 22 | FILEFLAGS VER_FILEFLAGS 23 | FILEOS VOS_NT_WINDOWS32 24 | FILETYPE VFT_APP 25 | FILESUBTYPE VFT2_UNKNOWN 26 | BEGIN 27 | BLOCK "StringFileInfo" 28 | BEGIN 29 | BLOCK "040904B0" 30 | BEGIN 31 | VALUE "Comments", "http://super8.qbism.com" 32 | VALUE "CompanyName", "qbism.com" 33 | VALUE "FileDescription", VER_FILEDESCRIPTION_STR 34 | VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR 35 | VALUE "InternalName", "qbismS8" 36 | VALUE "ProductName", "QBISMS8" 37 | END 38 | END 39 | BLOCK "VarFileInfo" 40 | BEGIN 41 | VALUE "Translation", 0x409, 0x4B0 42 | END 43 | END 44 | 45 | LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT 46 | 47 | 48 | 100 ICON "QBS8.ico" 49 | -------------------------------------------------------------------------------- /s_win32/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by C:\CYGWIN\home\Manoel\Makaqu\winquake.rc 4 | // 5 | #define IDS_STRING1 1 6 | #define IDI_ICON2 1 7 | #define IDD_DIALOG1 108 8 | #define IDD_PROGRESS 109 9 | #define IDC_PROGRESS 1000 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 112 16 | #define _APS_NEXT_COMMAND_VALUE 40001 17 | #define _APS_NEXT_CONTROL_VALUE 1004 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /s_win32/winquake.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // winquake.h: Win32-specific Quake header file 18 | 19 | #include 20 | //qb: already defined in windows.h #define WM_MOUSEWHEEL 0x020A 21 | 22 | #ifndef SERVERONLY 23 | #include 24 | #include 25 | #ifndef GLQUAKE 26 | //#include qb: gone! mh vid_win.c 27 | #endif 28 | #endif 29 | 30 | extern HINSTANCE global_hInstance; 31 | extern int global_nCmdShow; 32 | 33 | #ifndef SERVERONLY 34 | 35 | extern LPDIRECTDRAW lpDD; 36 | //extern qboolean DDActive; 37 | extern LPDIRECTDRAWSURFACE lpPrimary; 38 | extern LPDIRECTDRAWSURFACE lpFrontBuffer; 39 | extern LPDIRECTDRAWSURFACE lpBackBuffer; 40 | extern LPDIRECTDRAWPALETTE lpDDPal; 41 | extern LPDIRECTSOUND pDS; 42 | extern LPDIRECTSOUNDBUFFER pDSBuf; 43 | 44 | extern DWORD gSndBufSize; 45 | //#define SNDBUFSIZE 65536 46 | 47 | void VID_LockBuffer (void); 48 | void VID_UnlockBuffer (void); 49 | 50 | #endif 51 | 52 | typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t; 53 | 54 | typedef struct 55 | { 56 | modestate_t type; 57 | int width; 58 | int height; 59 | int modenum; 60 | int fullscreen; 61 | char modedesc[20]; 62 | qboolean stretched; 63 | } vmode_t; 64 | 65 | #define MAX_MODE_LIST 200 //qb: 40 will fit on menu, I think 66 | extern modestate_t modestate; 67 | extern vmode_t modelist[MAX_MODE_LIST]; 68 | extern int nummodes; 69 | extern int vid_modenum; 70 | 71 | extern HWND mainwindow; 72 | extern int ActiveApp, Minimized; 73 | 74 | extern int WinNT; 75 | 76 | void IN_ShowMouse (void); 77 | void IN_DeactivateMouse (void); 78 | void IN_HideMouse (void); 79 | void IN_ActivateMouse (void); 80 | void IN_RestoreOriginalMouseState (void); 81 | void IN_SetQuakeMouseState (void); 82 | void IN_MouseEvent (int mstate); 83 | 84 | extern qboolean winsock_lib_initialized; 85 | 86 | //extern cvar_t _windowed_mouse; // Manoel Kasimier - removed 87 | 88 | extern int window_center_x, window_center_y; 89 | extern RECT window_rect; 90 | 91 | extern qboolean mouseinitialized; 92 | extern HWND hwnd_dialog; 93 | 94 | extern HANDLE hinput, houtput; 95 | 96 | extern float hack_ctr; 97 | 98 | void IN_UpdateClipCursor (void); 99 | void CenterWindow(HWND hWndCenter); 100 | 101 | void S_BlockSound (void); 102 | void S_UnblockSound (void); 103 | 104 | void VID_SetDefaultMode (void); 105 | 106 | extern int (PASCAL FAR *pWSAStartup)(WORD wVersionRequired, LPWSADATA lpWSAData); 107 | extern int (PASCAL FAR *pWSACleanup)(void); 108 | extern int (PASCAL FAR *pWSAGetLastError)(void); 109 | extern SOCKET (PASCAL FAR *psocket)(int af, int type, int protocol); 110 | extern int (PASCAL FAR *pioctlsocket)(SOCKET s, long cmd, u_long FAR *argp); 111 | extern int (PASCAL FAR *psetsockopt)(SOCKET s, int level, int optname, 112 | const char FAR * optval, int optlen); 113 | extern int (PASCAL FAR *precvfrom)(SOCKET s, char FAR * buf, int len, int flags, 114 | struct sockaddr FAR *from, int FAR * fromlen); 115 | extern int (PASCAL FAR *psendto)(SOCKET s, const char FAR * buf, int len, int flags, 116 | const struct sockaddr FAR *to, int tolen); 117 | extern int (PASCAL FAR *pclosesocket)(SOCKET s); 118 | extern int (PASCAL FAR *pgethostname)(char FAR * name, int namelen); 119 | extern struct hostent FAR * (PASCAL FAR *pgethostbyname)(const char FAR * name); 120 | extern struct hostent FAR * (PASCAL FAR *pgethostbyaddr)(const char FAR * addr, 121 | int len, int type); 122 | extern int (PASCAL FAR *pgetsockname)(SOCKET s, struct sockaddr FAR *name, 123 | int FAR * namelen); 124 | -------------------------------------------------------------------------------- /sbar.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/sbar.c -------------------------------------------------------------------------------- /sbar.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // the status bar is only redrawn if something has changed, but if anything 19 | // does, the entire thing will be redrawn for the next vid.numpages frames. 20 | 21 | #define SBAR_HEIGHT 24 22 | 23 | 24 | void CheckSbarScale (void); 25 | 26 | 27 | void Sbar_Init (void); 28 | 29 | void Sbar_Changed (void); 30 | // call whenever any of the client stats represented on the sbar changes 31 | 32 | void Sbar_Draw (void); 33 | // called every frame by screen 34 | 35 | void Sbar_IntermissionOverlay (void); 36 | // called each frame after the level has been completed 37 | 38 | void Sbar_FinaleOverlay (void); 39 | void Sbar_SizeScreen (void); 40 | 41 | -------------------------------------------------------------------------------- /screen.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/screen.c -------------------------------------------------------------------------------- /screen.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // screen.h 18 | 19 | void SCR_Init (void); 20 | 21 | void SCR_UpdateScreen (void); 22 | 23 | 24 | void SCR_SizeUp (void); 25 | void SCR_SizeDown (void); 26 | void SCR_CenterPrint (char *str); 27 | 28 | void SCR_BeginLoadingPlaque (void); 29 | void SCR_EndLoadingPlaque (void); 30 | 31 | int SCR_ModalMessage (char *text); 32 | 33 | extern float scr_con_current; 34 | extern float scr_conlines; // lines of console to display 35 | 36 | extern int scr_fullupdate; // set to 0 to force full redraw 37 | extern int sb_lines; 38 | 39 | extern int clearnotify; // set to 0 whenever notify text is drawn 40 | extern qboolean scr_disabled_for_loading; 41 | extern qboolean scr_skipupdate; 42 | extern float frame_timescale; 43 | 44 | extern cvar_t scr_viewsize; 45 | 46 | // only the refresh window will be updated unless these variables are flagged 47 | extern int scr_copytop; 48 | extern int scr_copyeverything; 49 | 50 | extern qboolean block_drawing; 51 | 52 | void SCR_UpdateWholeScreen (void); 53 | 54 | extern cvar_t scr_ofsx; //qb: moved here 55 | extern cvar_t scr_ofsy; //qb: 56 | extern cvar_t scr_ofsz; //qb: 57 | extern cvar_t scr_viewsize; 58 | extern cvar_t con_alpha; // Manoel Kasimier - transparent console 59 | extern cvar_t sbar; //qb: 60 | extern cvar_t crosshair; 61 | extern cvar_t cl_crossx; 62 | extern cvar_t cl_crossy; 63 | extern cvar_t scr_fadecolor; //qb: 64 | -------------------------------------------------------------------------------- /snd_codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Audio Codecs: Adapted from ioquake3 with changes. 3 | * For now, only handles streaming music, not sound effects. 4 | * 5 | * Copyright (C) 1999-2005 Id Software, Inc. 6 | * Copyright (C) 2005 Stuart Dalton 7 | * Copyright (C) 2010-2011 O.Sezer 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or (at 12 | * your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * See the GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License along 21 | * with this program; if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | * 24 | */ 25 | 26 | #ifndef _SND_CODEC_H_ 27 | #define _SND_CODEC_H_ 28 | 29 | typedef struct snd_info_s 30 | { 31 | int rate; 32 | int width; 33 | int channels; 34 | int samples; 35 | int size; 36 | int dataofs; 37 | } snd_info_t; 38 | 39 | typedef enum { 40 | STREAM_NONE = -1, 41 | STREAM_INIT, 42 | STREAM_PAUSE, 43 | STREAM_PLAY 44 | } stream_status_t; 45 | 46 | typedef struct snd_codec_s snd_codec_t; 47 | 48 | typedef struct snd_stream_s 49 | { 50 | fshandle_t fh; 51 | qboolean pak; 52 | snd_info_t info; 53 | stream_status_t status; 54 | snd_codec_t *codec; /* codec handling this stream */ 55 | void *priv; /* data private to the codec. */ 56 | } snd_stream_t; 57 | 58 | 59 | void S_CodecInit (void); 60 | void S_CodecShutdown (void); 61 | 62 | /* Callers of the following S_CodecOpenStream* functions 63 | * are reponsible for attaching any path to the filename */ 64 | 65 | snd_stream_t *S_CodecOpenStreamType (char *filename, unsigned int type); 66 | /* Decides according to the required type. */ 67 | 68 | snd_stream_t *S_CodecOpenStreamAny (char *filename); 69 | /* Decides according to file extension. if the 70 | * name has no extension, try all available. */ 71 | 72 | snd_stream_t *S_CodecOpenStreamExt (char *filename); 73 | /* Decides according to file extension. the name 74 | * MUST have an extension. */ 75 | 76 | void S_CodecCloseStream (snd_stream_t *stream); 77 | int S_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer); 78 | int S_CodecRewindStream (snd_stream_t *stream); 79 | 80 | snd_stream_t *S_CodecUtilOpen(char *filename, snd_codec_t *codec); 81 | void S_CodecUtilClose(snd_stream_t **stream); 82 | 83 | 84 | #define CODECTYPE_NONE 0 85 | #define CODECTYPE_MID (1U << 0) 86 | #define CODECTYPE_MOD (1U << 1) 87 | #define CODECTYPE_FLAC (1U << 2) 88 | #define CODECTYPE_WAV (1U << 3) 89 | #define CODECTYPE_MP3 (1U << 4) 90 | #define CODECTYPE_OGG (1U << 5) 91 | 92 | #define CODECTYPE_VORBIS CODECTYPE_OGG 93 | #define CODECTYPE_WAVE CODECTYPE_WAV 94 | #define CODECTYPE_MIDI CODECTYPE_MID 95 | 96 | int S_CodecIsAvailable (unsigned int type); 97 | /* return 1 if available, 0 if codec failed init 98 | * or -1 if no such codec is present. */ 99 | 100 | #endif /* _SND_CODEC_H_ */ 101 | 102 | -------------------------------------------------------------------------------- /snd_codeci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Audio Codecs: Adapted from ioquake3 with changes. 3 | * For now, only handles streaming music, not sound effects. 4 | * 5 | * Copyright (C) 1999-2005 Id Software, Inc. 6 | * Copyright (C) 2005 Stuart Dalton 7 | * Copyright (C) 2010-2011 O.Sezer 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or (at 12 | * your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * See the GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License along 21 | * with this program; if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | * 24 | */ 25 | 26 | #ifndef _SND_CODECI_H_ 27 | #define _SND_CODECI_H_ 28 | 29 | /* Codec internals */ 30 | typedef qboolean (*CODEC_INIT)(void); 31 | typedef void (*CODEC_SHUTDOWN)(void); 32 | typedef snd_stream_t *(*CODEC_OPEN)(const char *filename); 33 | typedef int (*CODEC_READ)(snd_stream_t *stream, int bytes, void *buffer); 34 | typedef int (*CODEC_REWIND)(snd_stream_t *stream); 35 | typedef void (*CODEC_CLOSE)(snd_stream_t *stream); 36 | 37 | struct snd_codec_s 38 | { 39 | unsigned int type; /* handled data type. (1U << n) */ 40 | qboolean initialized; /* init succeedded */ 41 | char *ext; /* expected extension */ 42 | CODEC_INIT initialize; 43 | CODEC_SHUTDOWN shutdown; 44 | CODEC_OPEN codec_open; 45 | CODEC_READ codec_read; 46 | CODEC_REWIND codec_rewind; 47 | CODEC_CLOSE codec_close; 48 | snd_codec_t *next; 49 | }; 50 | 51 | #endif /* _SND_CODECI_H_ */ 52 | 53 | -------------------------------------------------------------------------------- /snd_mp3.h: -------------------------------------------------------------------------------- 1 | /* MP3 decoding support using libmad or libmpg123. */ 2 | 3 | #if !defined(_SND_MP3_H_) 4 | #define _SND_MP3_H_ 5 | 6 | #if defined(USE_CODEC_MP3) 7 | 8 | extern snd_codec_t mp3_codec; 9 | 10 | #endif /* USE_CODEC_MP3 */ 11 | 12 | #endif /* ! _SND_MP3_H_ */ 13 | 14 | -------------------------------------------------------------------------------- /snd_vorbis.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Ogg/Vorbis streaming music support, loosely based on several open source 3 | * Quake engine based projects with many modifications. 4 | * 5 | * Copyright (C) 2010-2012 O.Sezer 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | #include "quakedef.h" 25 | 26 | #if defined(USE_CODEC_VORBIS) 27 | #include "snd_codec.h" 28 | #include "snd_codeci.h" 29 | #include "snd_vorbis.h" 30 | 31 | #define OV_EXCLUDE_STATIC_CALLBACKS 32 | #if defined(VORBIS_USE_TREMOR) 33 | /* for Tremor / Vorbisfile api differences, 34 | * see doc/diff.html in the Tremor package. */ 35 | #include 36 | #else 37 | #include 38 | #endif 39 | 40 | /* The OGG codec can return the samples in a number of different 41 | * formats, we use the standard signed short format. */ 42 | #define OGG_SAMPLEWIDTH 2 43 | #define OGG_SIGNED_DATA 1 44 | 45 | /* CALLBACK FUNCTIONS: */ 46 | 47 | static int ovc_fclose (void *f) 48 | { 49 | return 0; /* we fclose() elsewhere. */ 50 | } 51 | 52 | static int ovc_fseek (void *f, ogg_int64_t off, int whence) 53 | { 54 | if (f == NULL) return (-1); 55 | return FS_fseek((fshandle_t *)f, (long) off, whence); 56 | } 57 | 58 | static const ov_callbacks ovc_qfs = 59 | { 60 | (size_t (*)(void *, size_t, size_t, void *)) FS_fread, 61 | (int (*)(void *, ogg_int64_t, int)) ovc_fseek, 62 | (int (*)(void *)) ovc_fclose, 63 | (long (*)(void *)) FS_ftell 64 | }; 65 | 66 | #define OV_OPEN_CALLBACKS ov_open_callbacks 67 | 68 | static qboolean S_OGG_CodecInitialize (void) 69 | { 70 | return true; 71 | } 72 | 73 | static void S_OGG_CodecShutdown (void) 74 | { 75 | } 76 | 77 | static snd_stream_t *S_OGG_CodecOpenStream (const char *filename) 78 | { 79 | snd_stream_t *stream; 80 | OggVorbis_File *ovFile; 81 | vorbis_info *ogg_info; 82 | int res; 83 | 84 | stream = S_CodecUtilOpen(filename, &ogg_codec); 85 | if (!stream) 86 | return NULL; 87 | 88 | ovFile = (OggVorbis_File *) Q_malloc(sizeof(OggVorbis_File), "ovFile"); 89 | res = OV_OPEN_CALLBACKS(&stream->fh, ovFile, NULL, 0, ovc_qfs); 90 | if (res != 0) 91 | { 92 | Con_Printf("%s is not a valid Ogg Vorbis file (error %i).\n", 93 | filename, res); 94 | goto _fail; 95 | } 96 | 97 | stream->priv = ovFile; 98 | 99 | if (!ov_seekable(ovFile)) 100 | { 101 | Con_Printf("OGG_Open: stream %s not seekable.\n", filename); 102 | goto _fail; 103 | } 104 | 105 | ogg_info = ov_info(ovFile, 0); 106 | if (!ogg_info) 107 | { 108 | Con_Printf("Unable to get stream information for %s.\n", filename); 109 | goto _fail; 110 | } 111 | 112 | if (ogg_info->channels != 1 && ogg_info->channels != 2) 113 | { 114 | Con_Printf("Unsupported number of channels %d in %s\n", 115 | ogg_info->channels, filename); 116 | goto _fail; 117 | } 118 | 119 | stream->info.rate = ogg_info->rate; 120 | stream->info.channels = ogg_info->channels; 121 | stream->info.width = OGG_SAMPLEWIDTH; 122 | 123 | return stream; 124 | _fail: 125 | if (res == 0) 126 | ov_clear(ovFile); 127 | Q_free(ovFile); 128 | S_CodecUtilClose(&stream); 129 | return NULL; 130 | } 131 | 132 | static int S_OGG_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer) 133 | { 134 | int section; /* FIXME: handle section changes */ 135 | int cnt, res, rem; 136 | char * ptr; 137 | 138 | cnt = 0; rem = bytes; 139 | ptr = (char *) buffer; 140 | while (1) 141 | { 142 | /* # ov_read() from libvorbisfile returns the decoded PCM audio 143 | * in requested endianness, signedness and word size. 144 | * # ov_read() from Tremor (libvorbisidec) returns decoded audio 145 | * always in host-endian, signed 16 bit PCM format. 146 | * # For both of the libraries, if the audio is multichannel, 147 | * the channels are interleaved in the output buffer. 148 | */ 149 | res = ov_read( (OggVorbis_File *)stream->priv, ptr, rem, 150 | #if !defined(VORBIS_USE_TREMOR) 151 | host_bigendian, 152 | OGG_SAMPLEWIDTH, 153 | OGG_SIGNED_DATA, 154 | #endif /* ! VORBIS_USE_TREMOR */ 155 | §ion ); 156 | if (res <= 0) 157 | break; 158 | rem -= res; 159 | cnt += res; 160 | if (rem <= 0) 161 | break; 162 | ptr += res; 163 | } 164 | return (res >= 0) ? cnt : res; 165 | } 166 | 167 | static void S_OGG_CodecCloseStream (snd_stream_t *stream) 168 | { 169 | ov_clear((OggVorbis_File *)stream->priv); 170 | Q_free(stream->priv); 171 | S_CodecUtilClose(&stream); 172 | } 173 | 174 | static int S_OGG_CodecRewindStream (snd_stream_t *stream) 175 | { 176 | /* for libvorbisfile, the ov_time_seek() position argument 177 | * is seconds as doubles, whereas for Tremor libvorbisidec 178 | * it is milliseconds as 64 bit integers. 179 | */ 180 | return ov_time_seek ((OggVorbis_File *)stream->priv, 0); 181 | } 182 | 183 | snd_codec_t ogg_codec = 184 | { 185 | CODECTYPE_OGG, 186 | true, /* always available. */ 187 | "ogg", 188 | S_OGG_CodecInitialize, 189 | S_OGG_CodecShutdown, 190 | S_OGG_CodecOpenStream, 191 | S_OGG_CodecReadStream, 192 | S_OGG_CodecRewindStream, 193 | S_OGG_CodecCloseStream, 194 | NULL 195 | }; 196 | 197 | #endif /* USE_CODEC_VORBIS */ 198 | 199 | -------------------------------------------------------------------------------- /snd_vorbis.h: -------------------------------------------------------------------------------- 1 | /* Ogg/Vorbis streaming music support. */ 2 | 3 | #if !defined(_SND_VORBIS_H_) 4 | #define _SND_VORBIS_H_ 5 | 6 | #if defined(USE_CODEC_VORBIS) 7 | 8 | extern snd_codec_t ogg_codec; 9 | 10 | #endif /* USE_CODEC_VORBIS */ 11 | 12 | #endif /* ! _SND_VORBIS_H_ */ 13 | 14 | -------------------------------------------------------------------------------- /snd_wave.h: -------------------------------------------------------------------------------- 1 | /* WAV streaming music support. */ 2 | 3 | #if !defined(_SND_WAVE_H_) 4 | #define _SND_WAVE_H_ 5 | 6 | #if defined(USE_CODEC_WAVE) 7 | 8 | extern snd_codec_t wav_codec; 9 | 10 | #endif /* USE_CODEC_WAVE */ 11 | 12 | #endif /* ! _SND_WAVE_H_ */ 13 | 14 | -------------------------------------------------------------------------------- /sound.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // sound.h -- client sound i/o functions 18 | 19 | #ifndef __SOUND__ 20 | #define __SOUND__ 21 | 22 | #define DEFAULT_SOUND_PACKET_VOLUME 255 23 | #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 24 | 25 | typedef struct 26 | { 27 | int left; 28 | int right; 29 | } portable_samplepair_t; 30 | 31 | typedef struct sfx_s 32 | { 33 | char name[MAX_QPATH]; 34 | cache_user_t cache; 35 | } sfx_t; 36 | 37 | typedef struct 38 | { 39 | int length; 40 | int loopstart; 41 | int speed; 42 | int width; 43 | int stereo; 44 | byte data[1]; // variable sized 45 | } sfxcache_t; 46 | 47 | typedef struct 48 | { 49 | qboolean gamealive; 50 | qboolean soundalive; 51 | qboolean splitbuffer; 52 | int channels; 53 | int samples; // mono samples in buffer 54 | int submission_chunk; // don't mix less than this # 55 | int samplepos; // in mono samples 56 | int samplebits; 57 | int speed; 58 | byte *buffer; 59 | } dma_t; 60 | 61 | typedef struct 62 | { 63 | sfx_t *sfx; // sfx number 64 | int leftvol; // 0-255 volume 65 | int rightvol; // 0-255 volume 66 | int end; // end time in global paintsamples 67 | unsigned int pos; // sample position in sfx 68 | int looping; // where to loop, -1 = no looping 69 | int entnum; // to allow overriding a specific sound 70 | int entchannel; // 71 | vec3_t origin; // origin of sound effect 72 | vec_t dist_mult; // distance multiplier (attenuation/clipK) 73 | int master_vol; // 0-255 master volume 74 | } channel_t; 75 | 76 | typedef struct 77 | { 78 | int rate; 79 | int width; 80 | int channels; 81 | int loopstart; 82 | int samples; 83 | int dataofs; // chunk starts this many bytes from file start 84 | } wavinfo_t; 85 | 86 | void S_Init (void); 87 | void S_Startup (void); 88 | void S_Shutdown (void); 89 | void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); 90 | void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation); 91 | void S_StopSound (int entnum, int entchannel); 92 | void S_StopAllSounds(qboolean clear); 93 | void S_ClearBuffer (void); 94 | void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up); 95 | void S_ExtraUpdate (void); 96 | 97 | sfx_t *S_PrecacheSound (char *sample); 98 | void S_TouchSound (char *sample); 99 | void S_PaintChannels(int endtime); 100 | void S_InitPaintChannels (void); 101 | 102 | // picks a channel based on priorities, empty slots, number of channels 103 | channel_t *SND_PickChannel(int entnum, int entchannel); 104 | 105 | // spatializes a channel 106 | void SND_Spatialize(channel_t *ch); 107 | 108 | /* qb: QS - music stream support */ 109 | void S_RawSamples(int samples, int rate, int width, int channels, byte * data, float volume); 110 | /* Expects data in signed 16 bit, or unsigned 8 bit format. */ 111 | 112 | // initializes cycling through a DMA buffer and returns information on it 113 | int SNDDMA_Init(void); //qb: was qboolean, type conflict 114 | 115 | // gets the current DMA position 116 | int SNDDMA_GetDMAPos(void); 117 | 118 | // shutdown the DMA xfer. 119 | void SNDDMA_Shutdown(void); 120 | 121 | // ==================================================================== 122 | // User-setable variables 123 | // ==================================================================== 124 | 125 | #define MAX_CHANNELS 1024 //qb: for 'telefragged' map. 512 per qsb was 128 126 | #define MAX_DYNAMIC_CHANNELS 128 //qb: 128 per qsb was 8 127 | 128 | 129 | extern channel_t channels[MAX_CHANNELS]; 130 | // 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds 131 | // MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc 132 | // MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds 133 | 134 | extern int total_channels; 135 | 136 | // 137 | // Fake dma is a synchronous faking of the DMA progress used for 138 | // isolating performance in the renderer. The fakedma_updates is 139 | // number of times S_Update() is called per second. 140 | // 141 | 142 | extern qboolean fakedma; 143 | extern int fakedma_updates; 144 | extern int paintedtime; 145 | extern vec3_t listener_origin; 146 | extern vec3_t listener_forward; 147 | extern vec3_t listener_right; 148 | extern vec3_t listener_up; 149 | extern volatile dma_t *shm; 150 | extern volatile dma_t sn; 151 | extern vec_t sound_nominal_clip_dist; 152 | 153 | extern cvar_t bgmvolume; 154 | extern cvar_t sfxvolume; 155 | extern int s_rawend; //qb: QuakeSpasm 156 | 157 | extern qboolean snd_initialized; 158 | 159 | extern int snd_blocked; 160 | 161 | void S_LocalSound (char *s); 162 | sfxcache_t *S_LoadSound (sfx_t *s); 163 | 164 | wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength); 165 | 166 | void SND_InitScaletable (void); 167 | void SNDDMA_Submit(void); 168 | 169 | void S_AmbientOff (void); 170 | void S_AmbientOn (void); 171 | 172 | #endif 173 | -------------------------------------------------------------------------------- /spritegn.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // 18 | // spritegn.h: header file for sprite generation program 19 | // 20 | 21 | // ********************************************************** 22 | // * This file must be identical in the spritegen directory * 23 | // * and in the Quake directory, because it's used to * 24 | // * pass data from one to the other via .spr files. * 25 | // ********************************************************** 26 | 27 | //------------------------------------------------------- 28 | // This program generates .spr sprite package files. 29 | // The format of the files is as follows: 30 | // 31 | // dsprite_t file header structure 32 | // 33 | // 34 | // dspriteframe_t frame header structure 35 | // sprite bitmap 36 | // 37 | // dspriteframe_t frame header structure 38 | // sprite bitmap 39 | // 40 | //------------------------------------------------------- 41 | 42 | #ifdef INCLUDELIBS 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include "cmdlib.h" 50 | #include "scriplib.h" 51 | #include "dictlib.h" 52 | #include "trilib.h" 53 | #include "lbmlib.h" 54 | #include "mathlib.h" 55 | 56 | #endif 57 | 58 | #define SPRITE_VERSION 1 59 | 60 | // must match definition in modelgen.h 61 | #ifndef SYNCTYPE_T 62 | #define SYNCTYPE_T 63 | typedef enum {ST_SYNC=0, ST_RAND } synctype_t; 64 | #endif 65 | 66 | // TODO: shorten these? 67 | typedef struct { 68 | int ident; 69 | int version; 70 | int type; 71 | float boundingradius; 72 | int width; 73 | int height; 74 | int numframes; 75 | float beamlength; 76 | synctype_t synctype; 77 | } dsprite_t; 78 | 79 | #define SPR_VP_PARALLEL_UPRIGHT 0 80 | #define SPR_FACING_UPRIGHT 1 81 | #define SPR_VP_PARALLEL 2 82 | #define SPR_ORIENTED 3 83 | #define SPR_VP_PARALLEL_ORIENTED 4 84 | 85 | typedef struct { 86 | int origin[2]; 87 | int width; 88 | int height; 89 | } dspriteframe_t; 90 | 91 | typedef struct { 92 | int numframes; 93 | } dspritegroup_t; 94 | 95 | typedef struct { 96 | float interval; 97 | } dspriteinterval_t; 98 | 99 | typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t; 100 | 101 | typedef struct { 102 | spriteframetype_t type; 103 | } dspriteframetype_t; 104 | 105 | #define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I') 106 | // little-endian "IDSP" 107 | 108 | -------------------------------------------------------------------------------- /sys.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // sys.h -- non-portable functions 18 | 19 | // 20 | // file IO 21 | // 22 | 23 | // returns the file size 24 | // return -1 if file is not present 25 | // the file should be in BINARY mode for stupid OSs that care 26 | int Sys_FileOpenAppend (char *path); //qb: from mh FRIK_FILE tute 27 | int Sys_FileOpenRead (char *path, int *hndl); 28 | 29 | int Sys_FileOpenWrite (char *path); 30 | void Sys_FileClose (int handle); 31 | void Sys_FileSeek (int handle, int position); 32 | int Sys_FileRead (int handle, void *dest, int count); 33 | int Sys_FileWrite (int handle, void *data, int count); 34 | int Sys_FileTime (char *path); 35 | void Sys_mkdir (char *path); 36 | 37 | // 38 | // memory protection 39 | // 40 | void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length); 41 | 42 | // 43 | // system IO 44 | // 45 | void Sys_DebugLog(char *file, char *fmt, ...); 46 | 47 | void Sys_Error (char *error, ...); 48 | // an error will cause the entire program to exit 49 | 50 | void Sys_Printf (char *fmt, ...); 51 | // send text to the console 52 | 53 | void Sys_Quit (void); 54 | 55 | double Sys_DoubleTime (void); 56 | 57 | char *Sys_ConsoleInput (void); 58 | 59 | void Sys_Sleep (void); 60 | // called to yield for a little bit so as 61 | // not to hog cpu when paused or debugging 62 | 63 | void Sys_SendKeyEvents (void); 64 | // Perform Key_Event () callbacks until the input que is empty 65 | 66 | // Manoel Kasimier - begin 67 | extern int vibration_update[2]; 68 | void Vibration_Update (void); 69 | void Vibration_Stop (int player); // 0=player1, 1=player2 70 | // Manoel Kasimier - end 71 | 72 | extern byte *hunk_base; // JPG - needed for Sys_Quit 73 | 74 | -------------------------------------------------------------------------------- /tools/qb_hmap2/bsp2prt.c: -------------------------------------------------------------------------------- 1 | #include "bsp5.h" 2 | 3 | /* 4 | ================== 5 | Bsp2Prt_BuildTree_r 6 | ================== 7 | */ 8 | static node_t *Bsp2Prt_BuildTree_r( int nodenum ) 9 | { 10 | node_t *n; 11 | 12 | if( nodenum < 0 ) { 13 | dleaf_t *leaf = &dleafs[-1-nodenum]; 14 | 15 | n = AllocNode (); 16 | n->planenum = PLANENUM_LEAF; 17 | n->contents = leaf->contents; 18 | } else { 19 | int side; 20 | plane_t plane; 21 | dnode_t *node = &dnodes[nodenum]; 22 | 23 | n = AllocNode (); 24 | plane.dist = dplanes[node->planenum].dist; 25 | VectorCopy( dplanes[node->planenum].normal, plane.normal ); 26 | n->planenum = FindPlane( &plane, &side ); 27 | 28 | if( side ) 29 | printf( "bsp2prt: Bad node plane (non-optimized)\n" ); 30 | 31 | n->children[0] = Bsp2Prt_BuildTree_r( node->children[0] ); 32 | n->children[1] = Bsp2Prt_BuildTree_r( node->children[1] ); 33 | } 34 | 35 | return n; 36 | } 37 | 38 | /* 39 | ================== 40 | Bsp2Prt_GetWorldBounds 41 | ================== 42 | */ 43 | static void Bsp2Prt_GetWorldBounds( vec3_t mins, vec3_t maxs ) 44 | { 45 | int i, j, e; 46 | dface_t *face; 47 | dvertex_t *v; 48 | vec3_t point; 49 | 50 | ClearBounds( mins, maxs ); 51 | 52 | for( i = 0, face = dfaces; i < dmodels[0].numfaces; i++, face++ ) { 53 | for( j = 0; j < face->numedges; j++ ) { 54 | e = dsurfedges[face->firstedge + j]; 55 | if( e >= 0 ) 56 | v = dvertexes + dedges[e].v[0]; 57 | else 58 | v = dvertexes + dedges[-e].v[1]; 59 | 60 | VectorCopy( v->point, point ); 61 | AddPointToBounds( point, mins, maxs ); 62 | } 63 | } 64 | } 65 | 66 | /* 67 | ================== 68 | Bsp2Prt_ProcessFile 69 | ================== 70 | */ 71 | static void Bsp2Prt_ProcessFile( void ) 72 | { 73 | tree_t *tree; 74 | 75 | LoadBSPFile( filename_bsp ); 76 | 77 | tree = AllocTree (); 78 | 79 | Bsp2Prt_GetWorldBounds( tree->mins, tree->maxs ); 80 | 81 | tree->headnode = Bsp2Prt_BuildTree_r( 0 ); 82 | 83 | PortalizeTree( tree ); 84 | WritePortalfile( tree ); 85 | FreeTreePortals( tree ); 86 | 87 | FreeTree( tree ); 88 | } 89 | 90 | /* 91 | ================== 92 | Bsp2Prt_Main 93 | ================== 94 | */ 95 | int Bsp2Prt_Main( int argc, char **argv ) 96 | { 97 | int i; 98 | double start, end; 99 | 100 | transwater = true; 101 | 102 | for( i = 1; i < argc; i++ ) { 103 | if (!strcmp (argv[i],"-nowater")) 104 | transwater = false; 105 | else if( argv[i][0] == '-' ) 106 | Error( "Unknown option \"%s\"", argv[i] ); 107 | else 108 | break; 109 | } 110 | 111 | if( i != argc - 1 ) 112 | Error( "%s", 113 | "usage: hmap2 -bsp2prt [options] sourcefile\n" 114 | "Makes a .prt file from a .bsp, to allow it to be vised\n" 115 | "\n" 116 | "What the options do:\n" 117 | "-nowater disable watervis; r_wateralpha in glquake will not work right\n" 118 | ); 119 | 120 | // init memory 121 | Q_InitMem (); 122 | 123 | // do it! 124 | start = I_DoubleTime (); 125 | 126 | end = I_DoubleTime (); 127 | Bsp2Prt_ProcessFile (); 128 | printf( "%5.2f seconds elapsed\n\n", end - start ); 129 | 130 | // print memory stats 131 | Q_PrintMem (); 132 | 133 | // free allocated memory 134 | Q_ShutdownMem (); 135 | 136 | return 0; 137 | } 138 | -------------------------------------------------------------------------------- /tools/qb_hmap2/bspinfo.c: -------------------------------------------------------------------------------- 1 | #include "bsp5.h" 2 | 3 | /* 4 | ================== 5 | BspInfo_PrintInfo 6 | ================== 7 | */ 8 | static void BspInfo_PrintInfo( const char *filename ) 9 | { 10 | int length; 11 | FILE *file; 12 | 13 | // get file length 14 | file = SafeOpenRead( filename_bsp ); 15 | length = Q_filelength( file ); 16 | fclose( file ); 17 | 18 | // print file length 19 | printf( "%s: %i bytes\n", filename_bsp, length ); 20 | printf( "\n" ); 21 | 22 | LoadBSPFile( filename_bsp ); 23 | 24 | // print .bsp info 25 | PrintBSPFileSizes (); 26 | } 27 | 28 | /* 29 | ================== 30 | BspInfo_Main 31 | ================== 32 | */ 33 | int BspInfo_Main( int argc, char **argv ) 34 | { 35 | if( argc < 2 ) { 36 | Error ("%s", 37 | "usage: hmap2 -bspinfo bspfile\n" 38 | "Prints information about a .bsp file\n" 39 | ); 40 | } 41 | 42 | // init memory 43 | Q_InitMem (); 44 | 45 | BspInfo_PrintInfo( argv[argc-1] ); 46 | 47 | // free allocated memory 48 | Q_ShutdownMem (); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /tools/qb_hmap2/cmdlib.h: -------------------------------------------------------------------------------- 1 | // cmdlib.h 2 | 3 | #ifndef __CMDLIB__ 4 | #define __CMDLIB__ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | //#include 14 | 15 | #ifndef __BYTEBOOL__ 16 | #define __BYTEBOOL__ 17 | typedef enum {false, true} qboolean; 18 | typedef unsigned char byte; 19 | #endif 20 | 21 | // the dec offsetof macro doesn't work very well... 22 | #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) 23 | 24 | // LordHavoc: increased maximum token length from 128 to 16384 25 | #define MAXTOKEN 16384 26 | 27 | // set these before calling CheckParm 28 | extern int myargc; 29 | extern char **myargv; 30 | 31 | extern char *Q_strupr (char *in); 32 | extern char *Q_strlower (char *in); 33 | extern int Q_strncasecmp (char *s1, char *s2, int n); 34 | extern int Q_strcasecmp (char *s1, char *s2); 35 | //extern void Q_getwd (char *out); 36 | 37 | extern int Q_filelength (FILE *f); 38 | extern int FileTime (char *path); 39 | 40 | extern void Q_mkdir (char *path); 41 | 42 | extern double I_DoubleTime (void); 43 | 44 | extern void Error (char *error, ...); 45 | 46 | extern int CheckParm (char *check); 47 | 48 | extern FILE *SafeOpenWrite (char *filename); 49 | extern FILE *SafeOpenRead (char *filename); 50 | extern void SafeRead (FILE *f, void *buffer, int count); 51 | extern void SafeWrite (FILE *f, void *buffer, int count); 52 | 53 | extern int LoadFile (char *filename, void **bufferptr); 54 | extern void SaveFile (char *filename, void *buffer, int count); 55 | 56 | extern void DefaultPath (char *path, char *basepath); 57 | extern void ReplaceExtension (char *path, char *oldextension, char *replacementextension, char *missingextension); 58 | 59 | extern void ExtractFilePath (char *path, char *dest); 60 | extern void ExtractFileBase (char *path, char *dest); 61 | extern void ExtractFileExtension (char *path, char *dest); 62 | 63 | extern int ParseNum (char *str); 64 | 65 | extern short BigShort (short l); 66 | extern short LittleShort (short l); 67 | extern int BigLong (int l); 68 | extern int LittleLong (int l); 69 | extern float BigFloat (float l); 70 | extern float LittleFloat (float l); 71 | 72 | 73 | extern char *COM_Parse (char *data); 74 | 75 | extern char com_token[MAXTOKEN]; 76 | extern qboolean com_eof; 77 | 78 | extern char *copystring(char *s); 79 | 80 | extern char token[MAXTOKEN]; 81 | extern int scriptline; 82 | 83 | void StartTokenParsing (char *data); 84 | qboolean GetToken (qboolean crossline); 85 | void UngetToken (void); 86 | 87 | extern void CRC_Init(unsigned short *crcvalue); 88 | extern void CRC_ProcessByte(unsigned short *crcvalue, byte data); 89 | extern unsigned short CRC_Value(unsigned short crcvalue); 90 | 91 | extern void COM_CreatePath (char *path); 92 | extern void COM_CopyFile (char *from, char *to); 93 | 94 | extern char filename_map[1024]; 95 | extern char filename_bsp[1024]; 96 | extern char filename_prt[1024]; 97 | extern char filename_pts[1024]; 98 | extern char filename_lin[1024]; 99 | extern char filename_lit[1024]; 100 | extern char filename_dlit[1024]; 101 | extern char filename_lights[1024]; 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /tools/qb_hmap2/light.h: -------------------------------------------------------------------------------- 1 | 2 | #include "cmdlib.h" 3 | #include "mathlib.h" 4 | #include "bspfile.h" 5 | #include "mem.h" 6 | 7 | typedef enum lighttype_e 8 | { 9 | LIGHTTYPE_MINUSX, // id light/arghlite/tyrlite mode 0, equation 1-x 10 | LIGHTTYPE_RECIPX, // tyrlite mode 1, equation 1/x 11 | LIGHTTYPE_RECIPXX, // hlight/tyrlite mode 2, realistic, equation 1/(x*x) 12 | LIGHTTYPE_NONE, // tyrlite mode 3, no fade, equation 1 13 | LIGHTTYPE_SUN, // sun light from sky polygons, equation 1 14 | LIGHTTYPE_MINUSXX, // tenebrae/doom3-like, 1-(x*x) 15 | LIGHTTYPE_TOTAL // total number of light types 16 | } lighttype_t; 17 | 18 | typedef struct 19 | { 20 | lighttype_t type; 21 | 22 | vec3_t origin; // location of light (unused on LIGHTTYPE_SUN) 23 | vec_t radius; // used by all light types except LIGHTTYPE_SUN 24 | vec3_t color; // color of light in output scale (128 for example, or a huge number for LIGHTTYPE_RECIPX and LIGHTTYPE_RECIPXX) 25 | vec_t angle; // cone angle for spotlights 26 | int light; // light radius from quake light entity 27 | int style; // which style the light belongs to 28 | 29 | vec3_t spotdir; // spotlight cone direction 30 | vec_t spotcone; // spotlight cone cosine (DotProduct(spotdir, lightdir) compare value) 31 | vec_t clampradius; // confine light to this radius, without affecting its attenuation behavior (fades to black at this radius) 32 | } directlight_t; 33 | 34 | typedef struct lightchain_s 35 | { 36 | directlight_t *light; 37 | struct lightchain_s *next; 38 | } lightchain_t; 39 | 40 | typedef struct 41 | { 42 | int startcontents; 43 | int endcontents; 44 | vec_t fraction; 45 | vec3_t start; 46 | vec3_t end; 47 | vec3_t impact; 48 | vec3_t filter; 49 | plane_t plane; 50 | qboolean hitsky; 51 | } lightTrace_t; 52 | 53 | //=============================================================================== 54 | 55 | // light.c 56 | extern int c_occluded; 57 | extern qboolean relight; 58 | 59 | extern int num_directlights; 60 | extern directlight_t directlights[MAP_DIRECTLIGHTS]; 61 | 62 | extern int extrasamplesbit; // power of 2 extra sampling (0 = 1x1 sampling, 1 = 2x2 sampling, 2 = 4x4 sampling, etc) 63 | extern vec_t extrasamplesscale; // 1.0 / pointspersample (extrasamples related) 64 | 65 | extern vec_t globallightscale; 66 | 67 | extern int harshshade; 68 | 69 | extern int minlight; 70 | extern int ambientlight; 71 | 72 | // light_face.c 73 | void LightFace( dface_t *f, const lightchain_t *lightchain, const directlight_t **novislight, int novislights, const vec3_t faceorg ); 74 | 75 | // light_trace.c 76 | dleaf_t *Light_PointInLeaf( const vec3_t point ); 77 | int Light_PointContents( const vec3_t p ); 78 | void Light_TraceLine( lightTrace_t *trace, const vec3_t start, const vec3_t end, qboolean hitsky ); 79 | -------------------------------------------------------------------------------- /tools/qb_hmap2/light_trace.c: -------------------------------------------------------------------------------- 1 | // trace.c 2 | 3 | #include "light.h" 4 | 5 | /* 6 | ============================================================================== 7 | 8 | LINE TRACING 9 | 10 | The major lighting operation is a point to point visibility test, performed 11 | by recursive subdivision of the line by the BSP tree. 12 | 13 | ============================================================================== 14 | */ 15 | 16 | /* 17 | ============== 18 | Light_PointInLeaf 19 | ============== 20 | */ 21 | dleaf_t *Light_PointInLeaf( const vec3_t point ) 22 | { 23 | int num = 0; 24 | 25 | while( num >= 0 ) 26 | num = dnodes[num].children[PlaneDiff(point, &dplanes[dnodes[num].planenum]) < 0]; 27 | 28 | return dleafs + (-1 - num); 29 | } 30 | 31 | /* 32 | ============== 33 | Light_PointContents 34 | ============== 35 | */ 36 | int Light_PointContents( const vec3_t point ) 37 | { 38 | return Light_PointInLeaf(point)->contents; 39 | } 40 | 41 | #define TESTLINESTATE_BLOCKED 0 42 | #define TESTLINESTATE_EMPTY 1 43 | #define TESTLINESTATE_SOLID 2 44 | 45 | static int RecursiveTestLine (lightTrace_t *trace, int num, float p1f, float p2f, const vec3_t p1, const vec3_t p2) 46 | { 47 | int side, ret; 48 | vec_t t1, t2, frac, midf; 49 | vec3_t mid; 50 | dnode_t *node; 51 | dplane_t *plane; 52 | 53 | // LordHavoc: this function operates by doing depth-first front-to-back 54 | // recursion through the BSP tree, checking at every split for an empty to 55 | // solid transition (impact) in the children, and returns 56 | // TESTLINESTATE_BLOCKED if one is found 57 | 58 | // LordHavoc: note: 'no impact' does not mean it is empty, it occurs when 59 | // there is no transition from empty to solid; all solid or a transition 60 | // from solid to empty are not considered impacts. (this does mean that 61 | // tracing is not symmetrical; point A to point B may have different 62 | // results than point B to point A, if either start in solid) 63 | 64 | while (num >= 0) 65 | { 66 | // find the point distances 67 | node = dnodes + num; 68 | plane = dplanes + node->planenum; 69 | 70 | if (plane->type < 3) 71 | { 72 | t1 = p1[plane->type] - plane->dist; 73 | t2 = p2[plane->type] - plane->dist; 74 | } 75 | else 76 | { 77 | t1 = DotProduct (plane->normal, p1) - plane->dist; 78 | t2 = DotProduct (plane->normal, p2) - plane->dist; 79 | } 80 | 81 | if (t1 >= 0) 82 | { 83 | if (t2 >= 0) 84 | { 85 | num = node->children[0]; 86 | continue; 87 | } 88 | side = 0; 89 | } 90 | else 91 | { 92 | if (t2 < 0) 93 | { 94 | num = node->children[1]; 95 | continue; 96 | } 97 | side = 1; 98 | } 99 | 100 | frac = t1 / (t1 - t2); 101 | midf = p1f + (p2f - p1f) * frac; 102 | mid[0] = p1[0] + frac * (p2[0] - p1[0]); 103 | mid[1] = p1[1] + frac * (p2[1] - p1[1]); 104 | mid[2] = p1[2] + frac * (p2[2] - p1[2]); 105 | 106 | // front side first 107 | ret = RecursiveTestLine (trace, node->children[side], p1f, midf, p1, mid); 108 | if (ret != TESTLINESTATE_EMPTY) 109 | return ret; // solid or blocked 110 | 111 | ret = RecursiveTestLine (trace, node->children[!side], midf, p2f, mid, p2); 112 | if (ret != TESTLINESTATE_SOLID) 113 | return ret; // empty or blocked 114 | 115 | if (!side) 116 | { 117 | VectorCopy (plane->normal, trace->plane.normal); 118 | trace->plane.dist = plane->dist; 119 | trace->plane.type = plane->type; 120 | } 121 | else 122 | { 123 | VectorNegate (plane->normal, trace->plane.normal); 124 | trace->plane.dist = -plane->dist; 125 | trace->plane.type = PLANE_ANYX; 126 | } 127 | 128 | // calculate the return fraction which is nudged off the surface a bit 129 | t1 = DotProduct(trace->plane.normal, trace->start) - trace->plane.dist; 130 | t2 = DotProduct(trace->plane.normal, trace->end) - trace->plane.dist; 131 | trace->fraction = (t1 - (1.0 / 32.0)) / (t1 - t2); 132 | 133 | return TESTLINESTATE_BLOCKED; 134 | } 135 | 136 | // check leaf contents 137 | num = dleafs[-num - 1].contents; 138 | if (!trace->startcontents) 139 | trace->startcontents = num; 140 | trace->endcontents = num; 141 | if (num == CONTENTS_SOLID || (num == CONTENTS_SKY && trace->hitsky)) 142 | { 143 | //VectorClear( trace->filter ); 144 | return TESTLINESTATE_SOLID; 145 | } 146 | else if (num == CONTENTS_WATER) 147 | { 148 | //trace->filter[0] *= 0.6; 149 | //trace->filter[1] *= 0.6; 150 | } 151 | else if (num == CONTENTS_LAVA) 152 | { 153 | //trace->filter[1] *= 0.6; 154 | //trace->filter[2] *= 0.6; 155 | } 156 | return TESTLINESTATE_EMPTY; 157 | } 158 | 159 | /* 160 | ============== 161 | Light_TraceLine 162 | ============== 163 | */ 164 | void Light_TraceLine( lightTrace_t *trace, const vec3_t start, const vec3_t end, qboolean hitsky ) 165 | { 166 | if( !trace ) 167 | return; 168 | 169 | memset(trace, 0, sizeof(*trace)); 170 | trace->fraction = 1.0; 171 | trace->hitsky = hitsky; 172 | VectorSet (trace->filter, 1, 1, 1); 173 | VectorCopy (start, trace->start); 174 | VectorCopy (end, trace->end); 175 | 176 | RecursiveTestLine( trace, 0, 0, 1, start, end ); 177 | 178 | trace->fraction = bound(0, trace->fraction, 1); 179 | trace->impact[0] = trace->start[0] + trace->fraction * (trace->end[0] - trace->start[0]); 180 | trace->impact[1] = trace->start[1] + trace->fraction * (trace->end[1] - trace->start[1]); 181 | trace->impact[2] = trace->start[2] + trace->fraction * (trace->end[2] - trace->start[2]); 182 | } 183 | 184 | -------------------------------------------------------------------------------- /tools/qb_hmap2/map.h: -------------------------------------------------------------------------------- 1 | 2 | // LordHavoc: raised MAX_FACES From 32 to 256 3 | #define MAX_FACES 256 4 | 5 | typedef struct mface_s 6 | { 7 | struct mface_s *next; 8 | plane_t plane; 9 | int texinfo; 10 | // LordHavoc: better error reporting 11 | int scriptline; 12 | } mface_t; 13 | 14 | typedef struct mbrush_s 15 | { 16 | struct mbrush_s *next; 17 | mface_t *faces; 18 | // LordHavoc: better error reporting 19 | int scriptline; 20 | } mbrush_t; 21 | 22 | extern int nummapbrushes; 23 | extern mbrush_t mapbrushes[MAX_MAP_BRUSHES]; 24 | 25 | extern int nummapplanes; 26 | extern plane_t mapplanes[MAX_MAP_PLANES]; 27 | 28 | extern int nummiptex; 29 | extern char miptex[MAX_MAP_TEXINFO][128]; // LordHavoc: was [16] 30 | 31 | void LoadMapFile (char *filename); 32 | 33 | int FindPlane( plane_t *dplane, int *side ); 34 | int FindMiptex (char *name); 35 | -------------------------------------------------------------------------------- /tools/qb_hmap2/mathlib.c: -------------------------------------------------------------------------------- 1 | // mathlib.c -- math primitives 2 | 3 | #include "cmdlib.h" 4 | #include "mathlib.h" 5 | 6 | vec3_t vec3_origin = { 0, 0, 0 }; 7 | 8 | vec_t VectorNormalize( vec3_t v ) 9 | { 10 | vec_t length; 11 | 12 | length = VectorLength( v ); 13 | if( length ) { 14 | vec_t ilength; 15 | 16 | ilength = 1.0 / length; 17 | VectorScale( v, ilength, v ); 18 | } 19 | 20 | return length; 21 | } 22 | 23 | vec_t Q_rint( vec_t n ) 24 | { 25 | if (n >= 0) 26 | return ( vec_t )(( int )(n + 0.5)); 27 | else 28 | return ( vec_t )(( int )(n - 0.5)); 29 | } 30 | 31 | /* 32 | ================= 33 | ClearBounds 34 | ================= 35 | */ 36 | void ClearBounds( vec3_t mins, vec3_t maxs ) 37 | { 38 | int i; 39 | 40 | for( i = 0; i < 3; i++ ) { 41 | mins[i] = BOGUS_RANGE; 42 | maxs[i] = -BOGUS_RANGE; 43 | } 44 | } 45 | 46 | /* 47 | ================= 48 | AddPointToBounds 49 | ================= 50 | */ 51 | void AddPointToBounds( vec3_t v, vec3_t mins, vec3_t maxs ) 52 | { 53 | int i; 54 | 55 | for( i = 0; i < 3; i++ ) { 56 | if (v[i] < mins[i]) 57 | mins[i] = v[i]; 58 | if (v[i] > maxs[i]) 59 | maxs[i] = v[i]; 60 | } 61 | } 62 | 63 | /* 64 | ================= 65 | RadiusFromBounds 66 | ================= 67 | */ 68 | vec_t RadiusFromBounds( vec3_t mins, vec3_t maxs ) 69 | { 70 | vec_t mind, maxd; 71 | 72 | if( mins[0] < mins[1] ) 73 | mind = mins[0]; 74 | else 75 | mind = mins[1]; 76 | if( mins[2] < mind ) 77 | mind = mins[2]; 78 | mind = fabs( mind ); 79 | 80 | if( maxs[0] > maxs[1] ) 81 | maxd = maxs[0]; 82 | else 83 | maxd = maxs[1]; 84 | if( maxs[2] > maxd ) 85 | maxd = maxs[2]; 86 | maxd = fabs( maxd ); 87 | 88 | if( mind > maxd ) 89 | return mind; 90 | return maxd; 91 | } 92 | 93 | /* 94 | ================= 95 | PlaneTypeForNormal 96 | ================= 97 | */ 98 | int PlaneTypeForNormal( vec3_t normal ) 99 | { 100 | vec_t ax, ay, az; 101 | 102 | // NOTE: should these have an epsilon around 1.0? 103 | if( normal[0] == 1.0 ) 104 | return PLANE_X; 105 | if( normal[1] == 1.0 ) 106 | return PLANE_Y; 107 | if( normal[2] == 1.0 ) 108 | return PLANE_Z; 109 | if( normal[0] == -1.0 || normal[1] == -1.0 || normal[2] == -1.0 ) 110 | Error ("PlaneTypeForNormal: not a canonical vector (%f %f %f)", normal[0], normal[1], normal[2]); 111 | 112 | ax = fabs( normal[0] ); 113 | ay = fabs( normal[1] ); 114 | az = fabs( normal[2] ); 115 | 116 | if( ax >= ay && ax >= az ) 117 | return PLANE_ANYX; 118 | if( ay >= ax && ay >= az ) 119 | return PLANE_ANYY; 120 | return PLANE_ANYZ; 121 | } 122 | 123 | /* 124 | ================= 125 | NormalizePlane 126 | ================= 127 | */ 128 | void NormalizePlane( plane_t *dp ) 129 | { 130 | vec_t ax, ay, az; 131 | 132 | if( dp->normal[0] == -1.0 ) { 133 | dp->normal[0] = 1.0; 134 | dp->dist = -dp->dist; 135 | } else if( dp->normal[1] == -1.0 ) { 136 | dp->normal[1] = 1.0; 137 | dp->dist = -dp->dist; 138 | } else if( dp->normal[2] == -1.0 ) { 139 | dp->normal[2] = 1.0; 140 | dp->dist = -dp->dist; 141 | } 142 | 143 | if( dp->normal[0] == 1.0 ) { 144 | dp->type = PLANE_X; 145 | VectorSet(dp->normal, 1, 0, 0); 146 | return; 147 | } 148 | if( dp->normal[1] == 1.0 ) { 149 | dp->type = PLANE_Y; 150 | VectorSet(dp->normal, 0, 1, 0); 151 | return; 152 | } 153 | if( dp->normal[2] == 1.0 ) { 154 | dp->type = PLANE_Z; 155 | VectorSet(dp->normal, 0, 0, 1); 156 | return; 157 | } 158 | 159 | ax = fabs( dp->normal[0] ); 160 | ay = fabs( dp->normal[1] ); 161 | az = fabs( dp->normal[2] ); 162 | 163 | if( ax >= ay && ax >= az ) 164 | dp->type = PLANE_ANYX; 165 | else if( ay >= ax && ay >= az ) 166 | dp->type = PLANE_ANYY; 167 | else 168 | dp->type = PLANE_ANYZ; 169 | 170 | if( dp->normal[dp->type - PLANE_ANYX] < 0 ) { 171 | VectorNegate( dp->normal, dp->normal ); 172 | dp->dist = -dp->dist; 173 | } 174 | } 175 | 176 | /* 177 | ================= 178 | PlaneCompare 179 | ================= 180 | */ 181 | qboolean PlaneCompare( plane_t *p1, plane_t *p2 ) 182 | { 183 | int i; 184 | 185 | if( fabs( p1->dist - p2->dist ) > 0.01) 186 | return false; 187 | 188 | for( i = 0; i < 3; i++ ) 189 | if( fabs(p1->normal[i] - p2->normal[i] ) > 0.001 ) 190 | return false; 191 | 192 | return true; 193 | } 194 | -------------------------------------------------------------------------------- /tools/qb_hmap2/mathlib.h: -------------------------------------------------------------------------------- 1 | // mathlib.h 2 | 3 | #ifndef __MATHLIB__ 4 | #define __MATHLIB__ 5 | 6 | #include 7 | 8 | #if _MSC_VER 9 | # pragma warning(disable : 4244) // MIPS 10 | # pragma warning(disable : 4136) // X86 11 | # pragma warning(disable : 4051) // ALPHA 12 | #endif 13 | 14 | #define DOUBLEVEC_T 15 | 16 | #ifdef DOUBLEVEC_T 17 | typedef double vec_t; 18 | #else 19 | typedef float vec_t; 20 | #endif 21 | typedef vec_t vec3_t[3]; 22 | 23 | // LordHavoc: these epsilons came from tyrqbsp by Tyrann 24 | // Misc EPSILON values 25 | // FIXME: document which to use where 26 | // use float.h stuff for better choices? 27 | #define TIGHTER_EPSILONS 28 | #ifdef TIGHTER_EPSILONS 29 | # define NORMAL_EPSILON ((vec_t)0.000001) 30 | # define ANGLE_EPSILON ((vec_t)0.000001) 31 | # define DIST_EPSILON ((vec_t)0.0001) 32 | # define ZERO_EPSILON ((vec_t)0.0001) 33 | # define POINT_EPSILON ((vec_t)0.0001) 34 | # define ON_EPSILON ((vec_t)0.0001) 35 | # define EQUAL_EPSILON ((vec_t)0.0001) 36 | # define CONTINUOUS_EPSILON ((vec_t)0.0001) 37 | # define T_EPSILON ((vec_t)0.0001) 38 | #else 39 | # define NORMAL_EPSILON ((vec_t)0.00001) 40 | # define ANGLE_EPSILON ((vec_t)0.00001) 41 | # define DIST_EPSILON ((vec_t)0.01) 42 | # define ZERO_EPSILON ((vec_t)0.001) 43 | # define POINT_EPSILON ((vec_t)0.01) 44 | # define ON_EPSILON ((vec_t)0.05) 45 | # define EQUAL_EPSILON ((vec_t)0.001) 46 | # define CONTINUOUS_EPSILON ((vec_t)0.001) 47 | # define T_EPSILON ((vec_t)0.01) 48 | #endif 49 | 50 | extern vec3_t vec3_origin; 51 | 52 | typedef struct 53 | { 54 | vec3_t normal; 55 | vec_t dist; 56 | int type; 57 | } plane_t; 58 | 59 | #define SIDE_FRONT 0 60 | #define SIDE_ON 2 61 | #define SIDE_BACK 1 62 | #define SIDE_CROSS -2 63 | 64 | #define Q_PI 3.14159265358979323846 65 | 66 | #ifndef PLANE_X 67 | 68 | // 0-2 are axial planes 69 | # define PLANE_X 0 70 | # define PLANE_Y 1 71 | # define PLANE_Z 2 72 | 73 | // 3-5 are non-axial planes snapped to the nearest 74 | # define PLANE_ANYX 3 75 | # define PLANE_ANYY 4 76 | # define PLANE_ANYZ 5 77 | 78 | #endif 79 | 80 | // LordHavoc: moved BOGUS_RANGE from bsp5.h and increased from 18000 to 1000000000 81 | #define BOGUS_RANGE 1000000000 82 | 83 | #ifndef max 84 | #define max(a,b) ((a) > (b) ? (a) : (b)) 85 | #endif 86 | 87 | #ifndef min 88 | #define min(a,b) ((a) < (b) ? (a) : (b)) 89 | #endif 90 | 91 | #define bound(a,b,c) ((a) >= (c) ? (a) : (b) < (a) ? (a) : (b) > (c) ? (c) : (b)) 92 | #define clamp(a,b,c) ((b) >= (c) ? (a)=(b) : (a) < (b) ? (a)=(b) : (a) > (c) ? (a)=(c) : (a)) 93 | 94 | #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) 95 | #define VectorSet(a,x,y,z) ((a)[0]=(x),(a)[1]=(y),(a)[2]=(z)) 96 | #define VectorSet4(a,x,y,z,w) ((a)[0]=(x),(a)[1]=(y),(a)[2]=(z),(a)[3]=(w)) 97 | #define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) 98 | #define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) 99 | #define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) 100 | #define VectorLength(v) (sqrt(((v)[0]*v[0]) + ((v)[1]*v[1]) + ((v)[2]*(v)[2]))) 101 | #define VectorCompare(v1, v2) (fabs((v1)[0]-(v2)[0]) < EQUAL_EPSILON && \ 102 | fabs((v1)[1]-(v2)[1]) < EQUAL_EPSILON && \ 103 | fabs((v1)[2]-(v2)[2]) < EQUAL_EPSILON) 104 | #define VectorMA(va, scale, vb, vc) ((vc)[0]=(va)[0]+(scale)*(vb)[0],(vc)[1]=(va)[1]+(scale)*(vb)[1],(vc)[2]=(va)[2]+(scale)*(vb)[2]) 105 | #define CrossProduct(v1, v2, cross) ((cross)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1],(cross)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2],(cross)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0]) 106 | #define VectorClear(v) ((v)[0]=(v)[1]=(v)[2]=0) 107 | #define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) 108 | #define VectorInverse(v) ((v)[0]=-(v)[0],(v)[1]=-(v)[1],(v)[2]=-(v)[2]) 109 | #define VectorScale(v, scale, out) ((out)[0]=(v)[0]*(scale),(out)[1]=(v)[1]*(scale),(out)[2]=(v)[2]*(scale)) 110 | #define PlaneDiff(point,plane) (((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal)) - (plane)->dist) 111 | 112 | vec_t VectorNormalize( vec3_t v ); 113 | 114 | vec_t Q_rint( vec_t n ); 115 | 116 | void ClearBounds( vec3_t mins, vec3_t maxs ); 117 | void AddPointToBounds( vec3_t v, vec3_t mins, vec3_t maxs ); 118 | vec_t RadiusFromBounds( vec3_t mins, vec3_t maxs ); 119 | 120 | int PlaneTypeForNormal( vec3_t normal ); 121 | void NormalizePlane( plane_t *dp ); 122 | qboolean PlaneCompare( plane_t *p1, plane_t *p2 ); 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /tools/qb_hmap2/mem.c: -------------------------------------------------------------------------------- 1 | #include "cmdlib.h" 2 | #include "mem.h" 3 | 4 | static qboolean mem_initialized = false; 5 | 6 | typedef struct chunkheader_s 7 | { 8 | // next and previous memheaders in chain belonging to pool 9 | struct chunkheader_s *next; 10 | struct chunkheader_s *prev; 11 | 12 | // size of the memory after the header (excluding header and sentinel2) 13 | size_t size; 14 | 15 | // immediately followed by data 16 | } chunkheader_t; 17 | 18 | static chunkheader_t *chunks; 19 | static size_t total_allocated; 20 | static size_t total_active, total_peakactive; 21 | 22 | void Q_InitMem( void ) 23 | { 24 | if( mem_initialized ) 25 | return; 26 | 27 | chunks = NULL; 28 | mem_initialized = true; 29 | total_allocated = 0; 30 | total_active = 0; 31 | total_peakactive = 0; 32 | } 33 | 34 | void Q_PrintMem( void ) 35 | { 36 | if( !mem_initialized ) 37 | return; 38 | 39 | printf( "Active memory: %f MB (%u bytes)\n", total_active / 1048576.0, (unsigned int)total_active ); 40 | printf( "Peak active memory: %f MB (%u bytes)\n", total_peakactive / 1048576.0, (unsigned int)total_peakactive ); 41 | printf( "Total memory allocated: %f MB (%u bytes)\n", total_allocated / 1048576.0, (unsigned int)total_allocated ); 42 | } 43 | 44 | void Q_ShutdownMem( void ) 45 | { 46 | size_t total; 47 | 48 | if( !mem_initialized ) 49 | return; 50 | 51 | total = 0; 52 | while( chunks ) { 53 | total += chunks->size; 54 | qfree( (void *)((unsigned char *)chunks + sizeof(chunkheader_t)) ); 55 | } 56 | 57 | // printf( "Leaked memory: %f MB (%i bytes)\n", total / 1048576.0, total ); 58 | // printf( "Total memory allocated: %f MB (%i bytes)\n", total_allocated / 1048576.0, total_allocated ); 59 | 60 | mem_initialized = false; 61 | } 62 | 63 | void *qmalloc( size_t size ) 64 | { 65 | void *data; 66 | chunkheader_t *chunk; 67 | 68 | if( size <= 0 ) 69 | return NULL; 70 | 71 | if( mem_initialized ) 72 | data = malloc( sizeof(chunkheader_t) + size ); 73 | else 74 | data = malloc( size ); 75 | 76 | if( !data ) 77 | Error( "Failed on allocating %d bytes\n", size ); 78 | 79 | if( !mem_initialized ) 80 | return data; 81 | 82 | chunk = ( chunkheader_t * )data; 83 | chunk->size = size; 84 | chunk->next = chunks; 85 | chunk->prev = NULL; 86 | chunks = chunk; 87 | if (chunk->next) 88 | chunk->next->prev = chunk; 89 | 90 | total_allocated += size; 91 | total_active += size; 92 | if( total_active > total_peakactive ) 93 | total_peakactive = total_active; 94 | 95 | return ( void * )(( unsigned char * )data + sizeof(chunkheader_t) ); 96 | } 97 | 98 | void qfree( void *data ) 99 | { 100 | chunkheader_t *chunk; 101 | 102 | if( !data ) 103 | return; 104 | if( !mem_initialized ) { 105 | free( data ); 106 | return; 107 | } 108 | 109 | chunk = ( chunkheader_t * )(( unsigned char * )data - sizeof(chunkheader_t) ); 110 | if( chunk->prev ) 111 | chunk->prev->next = chunk->next; 112 | else 113 | chunks = chunk->next; 114 | if( chunk->next ) 115 | chunk->next->prev = chunk->prev; 116 | 117 | total_active -= chunk->size; 118 | 119 | free( chunk ); 120 | } 121 | -------------------------------------------------------------------------------- /tools/qb_hmap2/mem.h: -------------------------------------------------------------------------------- 1 | 2 | void Q_InitMem( void ); 3 | void Q_PrintMem( void ); 4 | void Q_ShutdownMem( void ); 5 | 6 | void *qmalloc( size_t size ); 7 | void qfree( void *data ); 8 | -------------------------------------------------------------------------------- /tools/qb_hmap2/outside.c: -------------------------------------------------------------------------------- 1 | 2 | #include "bsp5.h" 3 | 4 | int outleafs; 5 | 6 | /* 7 | =========== 8 | PointInLeaf 9 | 10 | Vic: rewrote to be faster 11 | LordHavoc: shortened a little 12 | =========== 13 | */ 14 | node_t *PointInLeaf (node_t *node, vec3_t point) 15 | { 16 | while (!node->contents) 17 | node = node->children[PlaneDiff( point, &mapplanes[node->planenum] ) <= 0]; 18 | return node; 19 | } 20 | 21 | /* 22 | =========== 23 | PlaceOccupant 24 | =========== 25 | */ 26 | qboolean PlaceOccupant (int num, vec3_t point, node_t *headnode) 27 | { 28 | node_t *n; 29 | 30 | n = PointInLeaf (headnode, point); 31 | if (n->contents == CONTENTS_SOLID) 32 | return false; 33 | n->occupied = num; 34 | return true; 35 | } 36 | 37 | 38 | /* 39 | ============== 40 | MarkLeakTrail 41 | ============== 42 | */ 43 | portal_t *prevleaknode; 44 | FILE *leakfilepts; 45 | FILE *leakfilelin; 46 | void MarkLeakTrail (portal_t *n2) 47 | { 48 | int i; 49 | vec3_t p1, p2, dir; 50 | vec_t len; 51 | portal_t *n1; 52 | 53 | n1 = prevleaknode; 54 | prevleaknode = n2; 55 | 56 | if (!n1) 57 | return; 58 | 59 | WindingCentre( n2->winding, p1, NULL ); 60 | WindingCentre( n1->winding, p2, NULL ); 61 | 62 | VectorSubtract (p2, p1, dir); 63 | len = VectorLength (dir); 64 | VectorNormalize (dir); 65 | 66 | if (!leakfilepts) 67 | { 68 | leakfilepts = fopen (filename_pts, "w"); 69 | if (!leakfilepts) 70 | Error ("Couldn't open %s\n", filename_pts); 71 | } 72 | if (!leakfilelin) 73 | { 74 | leakfilelin = fopen (filename_lin, "w"); 75 | if (!leakfilelin) 76 | Error ("Couldn't open %s\n", filename_lin); 77 | fprintf (leakfilelin, "%f %f %f\n", p1[0], p1[1], p1[2]); 78 | } 79 | 80 | if (leakfilepts) 81 | { 82 | while (len > 2) 83 | { 84 | fprintf (leakfilepts, "%f %f %f\n", p1[0], p1[1], p1[2]); 85 | for (i = 0;i < 3;i++) 86 | p1[i] += dir[i] * 2; 87 | len -= 2; 88 | } 89 | } 90 | 91 | if (leakfilelin) 92 | fprintf (leakfilelin, "%f %f %f\n", p2[0], p2[1], p2[2]); 93 | } 94 | 95 | /* 96 | ================== 97 | RecursiveFillOutside 98 | 99 | If fill is false, just check, don't fill 100 | Returns true if an occupied leaf is reached 101 | ================== 102 | */ 103 | int hit_occupied; 104 | qboolean RecursiveFillOutside (node_t *l, int hullnum, qboolean fill) 105 | { 106 | portal_t *p; 107 | int s; 108 | 109 | if (l->contents == CONTENTS_SOLID || l->contents == CONTENTS_SKY) 110 | return false; 111 | 112 | if (l->valid == valid) 113 | return false; 114 | 115 | if (l->occupied) 116 | { 117 | hit_occupied = l->occupied; // LordHavoc: this was missing from the released source... odd 118 | return true; 119 | } 120 | 121 | l->valid = valid; 122 | 123 | // fill it and it's neighbors 124 | if (fill) 125 | l->contents = CONTENTS_SOLID; 126 | outleafs++; 127 | 128 | for (p = l->portals;p;) 129 | { 130 | s = (p->nodes[0] == l); 131 | 132 | if (RecursiveFillOutside (p->nodes[s], hullnum, fill) ) 133 | { 134 | // leaked, so stop filling 135 | if (!hullnum) 136 | MarkLeakTrail (p); 137 | return true; 138 | } 139 | p = p->next[!s]; 140 | } 141 | 142 | return false; 143 | } 144 | 145 | /* 146 | ================== 147 | ClearOutFaces 148 | 149 | ================== 150 | */ 151 | void ClearOutFaces (node_t *node) 152 | { 153 | face_t **fp; 154 | 155 | if (node->planenum != PLANENUM_LEAF) 156 | { 157 | ClearOutFaces (node->children[0]); 158 | ClearOutFaces (node->children[1]); 159 | return; 160 | } 161 | if (node->contents != CONTENTS_SOLID) 162 | return; 163 | 164 | for( fp = node->markfaces; *fp; fp++ ) { 165 | // mark all the original faces that are removed 166 | FreeWinding( (*fp)->winding ); 167 | (*fp)->winding = NULL; 168 | } 169 | node->faces = NULL; 170 | } 171 | 172 | 173 | //============================================================================= 174 | 175 | /* 176 | =========== 177 | FillOutside 178 | 179 | =========== 180 | */ 181 | qboolean FillOutside (tree_t *tree, int hullnum) 182 | { 183 | int i; 184 | int s; 185 | qboolean inside; 186 | vec3_t origin; 187 | 188 | qprintf ("----- FillOutside ----\n"); 189 | 190 | if (nofill) 191 | { 192 | printf ("skipped\n"); 193 | return false; 194 | } 195 | 196 | inside = false; 197 | for (i=1 ; i= 0.1 && entities[i].brushes == NULL) 202 | { 203 | if (PlaceOccupant (i, origin, tree->headnode)) 204 | inside = true; 205 | } 206 | } 207 | 208 | if (!inside) 209 | { 210 | printf ("Hullnum %i: No entities in empty space -- no filling performed\n", hullnum); 211 | return false; 212 | } 213 | 214 | s = !(outside_node.portals->nodes[1] == &outside_node); 215 | 216 | // first check to see if an occupied leaf is hit 217 | outleafs = 0; 218 | valid++; 219 | 220 | prevleaknode = NULL; 221 | 222 | if (RecursiveFillOutside (outside_node.portals->nodes[s], hullnum, false)) 223 | { 224 | if (leakfilepts) 225 | fclose(leakfilepts); 226 | leakfilepts = NULL; 227 | if (leakfilelin) 228 | fclose(leakfilelin); 229 | leakfilelin = NULL; 230 | if (!hullnum) 231 | { 232 | GetVectorForKey (&entities[hit_occupied], "origin", origin); 233 | 234 | qprintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); 235 | qprintf ("reached occupant at: (%4.0f,%4.0f,%4.0f)\n", origin[0], origin[1], origin[2]); 236 | qprintf ("no filling performed\n"); 237 | qprintf ("leak file written to %s\n", filename_pts); 238 | qprintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); 239 | } 240 | 241 | // remove faces from filled in leafs 242 | ClearOutFaces (tree->headnode); 243 | return false; 244 | } 245 | 246 | // now go back and fill things in 247 | valid++; 248 | RecursiveFillOutside (outside_node.portals->nodes[s], hullnum, true); 249 | 250 | // remove faces from filled in leafs 251 | ClearOutFaces (tree->headnode); 252 | 253 | qprintf ("%4i outleafs\n", outleafs); 254 | return true; 255 | } 256 | -------------------------------------------------------------------------------- /tools/qb_hmap2/scriptlib.c: -------------------------------------------------------------------------------- 1 | #include "cmdlib.h" 2 | 3 | char token[MAXTOKEN]; 4 | qboolean unget; 5 | char *script_p; 6 | int scriptline; 7 | 8 | void StartTokenParsing (char *data) 9 | { 10 | scriptline = 1; 11 | script_p = data; 12 | unget = false; 13 | } 14 | 15 | qboolean GetToken (qboolean crossline) 16 | { 17 | char *token_p, *temp; 18 | 19 | if (unget) // is a token already waiting? 20 | return true; 21 | 22 | // return something even if the caller ignores a return false 23 | token[0] = 0; 24 | 25 | // 26 | // skip space 27 | // 28 | for (;;) 29 | { 30 | if (*script_p == 0) 31 | return false; 32 | else if (*script_p == '\n') 33 | { 34 | if (!crossline) 35 | return false; 36 | script_p++; 37 | scriptline++; 38 | } 39 | else if (*script_p <= ' ') 40 | script_p++; 41 | else if (script_p[0] == '/' && script_p[1] == '/') 42 | { 43 | while (*script_p && *script_p != '\n') 44 | script_p++; 45 | } 46 | else if (script_p[0] == '/' && script_p[1] == '*') 47 | { 48 | temp = script_p; 49 | for (;;) 50 | { 51 | if (*script_p == 0) 52 | break; 53 | else if (script_p[0] == '*' && script_p[1] == '/') 54 | { 55 | script_p += 2; 56 | break; 57 | } 58 | else if (*script_p == '\n') 59 | { 60 | if (!crossline) 61 | { 62 | script_p = temp; 63 | return false; 64 | } 65 | script_p++; 66 | scriptline++; 67 | } 68 | else 69 | script_p++; 70 | } 71 | } 72 | else 73 | break; 74 | } 75 | 76 | // 77 | // copy token 78 | // 79 | token_p = token; 80 | 81 | if (*script_p == '"') 82 | { 83 | script_p++; 84 | while ( *script_p != '"' ) 85 | { 86 | if (!*script_p) 87 | Error ("EOF inside quoted token"); 88 | *token_p++ = *script_p++; 89 | if (token_p > &token[MAXTOKEN-1]) 90 | Error ("Token too large on line %i",scriptline); 91 | } 92 | script_p++; 93 | } 94 | else while ( *script_p > 32 ) 95 | { 96 | *token_p++ = *script_p++; 97 | if (token_p > &token[MAXTOKEN-1]) 98 | Error ("Token too large on line %i",scriptline); 99 | } 100 | 101 | *token_p = 0; 102 | 103 | return true; 104 | } 105 | 106 | void UngetToken (void) 107 | { 108 | unget = true; 109 | } 110 | 111 | -------------------------------------------------------------------------------- /tools/qb_hmap2/threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2006 Id Software, Inc. and contributors. 3 | For a list of contributors, see the accompanying CONTRIBUTORS file. 4 | 5 | This file is part of GtkRadiant. 6 | 7 | GtkRadiant is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | GtkRadiant is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with GtkRadiant; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef _THREADS_H 22 | 23 | #define _THREADS_H 24 | 25 | extern int numthreads; 26 | 27 | void ThreadSetDefault (void); 28 | int GetThreadWork (void); 29 | void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int)); 30 | void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int)); 31 | void ThreadLock (void); 32 | void ThreadUnlock (void); 33 | 34 | #endif // _THREADS_H 35 | -------------------------------------------------------------------------------- /tools/qb_hmap2/tree.c: -------------------------------------------------------------------------------- 1 | #include "bsp5.h" 2 | 3 | //============================================================================ 4 | 5 | qboolean func_water; //qb: pOX 6 | 7 | /* 8 | =========== 9 | AllocTree 10 | =========== 11 | */ 12 | tree_t *AllocTree( void ) 13 | { 14 | tree_t *t; 15 | 16 | t = qmalloc( sizeof( tree_t ) ); 17 | memset( t, 0, sizeof( tree_t ) ); 18 | ClearBounds( t->mins, t->maxs ); 19 | 20 | return t; 21 | } 22 | 23 | /* 24 | =========== 25 | FreeTree 26 | =========== 27 | */ 28 | void FreeTree( tree_t *t ) 29 | { 30 | brush_t *b, *next; 31 | 32 | for( b = t->brushes; b; b = next ) 33 | { 34 | next = b->next; 35 | FreeBrush( b ); 36 | } 37 | qfree( t ); 38 | } 39 | 40 | //============================================================================ 41 | 42 | /* 43 | =============== 44 | Tree_ProcessEntity 45 | =============== 46 | */ 47 | tree_t *Tree_ProcessEntity( entity_t *ent, int modnum, int hullnum ) 48 | { 49 | tree_t *tree; 50 | qboolean worldmodel; 51 | 52 | func_water = false; //qb: pOX 53 | if (!strcmp (ValueForKey(ent, "classname"), "func_water")) 54 | { 55 | if (!FloatForKey(ent, "_nomirror"))// allow it to be turned off selectively 56 | func_water = true; 57 | worldmodel = false; 58 | } 59 | else if (!strcmp (ValueForKey(ent, "classname"), "worldspawn")) 60 | worldmodel = true; 61 | else 62 | { 63 | worldmodel = false; 64 | 65 | if (verbose) 66 | PrintEntity (ent); 67 | } 68 | 69 | // allocate a tree to hold our entity 70 | tree = AllocTree (); 71 | 72 | // take the brushes and clip off all overlapping and contained faces, 73 | // leaving a perfect skin of the model with no hidden faces 74 | Brush_LoadEntity( ent, tree, hullnum, worldmodel ); 75 | if( ent->brushes == NULL && hullnum == 0 ) 76 | { 77 | PrintEntity( ent ); 78 | printf( "WARNING: line %i: Entity with no valid brushes\n", ent->scriptline ); 79 | } 80 | 81 | CSGFaces( tree ); 82 | 83 | if( hullnum != 0 ) 84 | { 85 | SolidBSP( tree, true ); 86 | 87 | // assume non-world bmodels are simple 88 | if( worldmodel && !nofill ) 89 | { 90 | PortalizeTree( tree ); 91 | 92 | if( FillOutside( tree, hullnum ) ) 93 | { 94 | GatherTreeFaces( tree ); 95 | SolidBSP( tree, false ); // make a really good tree 96 | } 97 | FreeTreePortals( tree ); 98 | } 99 | } 100 | else 101 | { 102 | // if not the world, make a good tree first 103 | // the world is just going to make a bad tree 104 | // because the outside filling will force a regeneration later 105 | SolidBSP( tree, worldmodel ); // SolidBSP generates a node tree 106 | 107 | // build all the portals in the bsp tree 108 | // some portals are solid polygons, and some are paths to other leafs 109 | 110 | // assume non-world bmodels are simple 111 | if( worldmodel && (!nofill || forcevis) ) 112 | { 113 | PortalizeTree( tree ); 114 | 115 | if( FillOutside( tree, 0 ) || forcevis ) 116 | { 117 | FreeTreePortals( tree ); 118 | 119 | // get the remaining faces together into surfaces again 120 | GatherTreeFaces( tree ); 121 | 122 | // merge polygons 123 | MergeTreeFaces( tree ); 124 | 125 | // make a really good tree 126 | SolidBSP( tree, false ); 127 | 128 | // make the real portals for vis tracing 129 | PortalizeTree( tree ); 130 | 131 | // save portal file for vis tracing 132 | WritePortalfile( tree ); 133 | 134 | // fix tjunctions 135 | FixTJunctions( tree ); 136 | } 137 | FreeTreePortals( tree ); 138 | } 139 | } 140 | 141 | return tree; 142 | } 143 | -------------------------------------------------------------------------------- /tools/qb_hmap2/vis.h: -------------------------------------------------------------------------------- 1 | // vis.h 2 | 3 | #include "cmdlib.h" 4 | #include "mathlib.h" 5 | #include "bspfile.h" 6 | #include "mem.h" 7 | 8 | #define MAX_PORTALS 32768 9 | 10 | #define PORTALFILE "PRT1" 11 | 12 | typedef struct 13 | { 14 | qboolean original; // don't free, it's part of the portal 15 | int numpoints; 16 | vec3_t points[8]; // variable sized 17 | } viswinding_t; 18 | 19 | #define MAX_POINTS_ON_VISWINDING 64 20 | 21 | viswinding_t *NewVisWinding (int points); 22 | void FreeVisWinding (viswinding_t *w); 23 | viswinding_t *ClipVisWinding (viswinding_t *in, plane_t *split, qboolean keepon); 24 | viswinding_t *CopyVisWinding (viswinding_t *w); 25 | void PlaneFromVisWinding (viswinding_t *w, plane_t *plane); 26 | void VisWindingCentre( viswinding_t *w, vec3_t centre, vec_t *radius ); 27 | 28 | 29 | typedef enum {stat_none, stat_working, stat_done} vstatus_t; 30 | typedef struct 31 | { 32 | plane_t plane; // normal pointing into neighbor 33 | vec3_t origin; 34 | vec_t radius; 35 | int leaf; // neighbor 36 | viswinding_t *winding; 37 | vstatus_t status; 38 | byte *visbits; 39 | byte *mightsee; 40 | int nummightsee; 41 | int numcansee; 42 | } portal_t; 43 | 44 | typedef struct seperating_plane_s 45 | { 46 | struct seperating_plane_s *next; 47 | plane_t plane; // from portal is on positive side 48 | } sep_t; 49 | 50 | 51 | typedef struct passage_s 52 | { 53 | struct passage_s *next; 54 | int from, to; // leaf numbers 55 | sep_t *planes; 56 | } passage_t; 57 | 58 | // LordHavoc: a friend ran into this limit (was 128) 59 | #define MAX_PORTALS_ON_LEAF 512 60 | typedef struct leaf_s 61 | { 62 | int numportals; 63 | passage_t *passages; 64 | portal_t *portals[MAX_PORTALS_ON_LEAF]; 65 | } leaf_t; 66 | 67 | 68 | typedef struct pstack_s 69 | { 70 | struct pstack_s *next; 71 | leaf_t *leaf; 72 | portal_t *portal; // portal exiting 73 | viswinding_t *source, *pass; 74 | plane_t portalplane; 75 | byte *mightsee; // bit string 76 | } pstack_t; 77 | 78 | typedef struct 79 | { 80 | byte *leafvis; // bit string 81 | portal_t *base; 82 | pstack_t pstack_head; 83 | } threaddata_t; 84 | 85 | extern int numportals; 86 | extern int portalleafs; 87 | 88 | extern portal_t *portals; 89 | extern leaf_t *leafs; 90 | 91 | extern int c_portaltest, c_portalpass, c_portalcheck; 92 | extern int c_portalskip, c_leafskip; 93 | extern int c_vistest, c_mighttest; 94 | extern int c_chains; 95 | extern int c_reused; 96 | 97 | extern byte *vismap, *vismap_p, *vismap_end; // past visfile 98 | 99 | extern int testlevel; 100 | 101 | extern vec_t farplane; 102 | 103 | extern qboolean rvis; 104 | extern qboolean noreuse; 105 | extern qboolean noambientwater, noambientslime, noambientlava, noambientsky; 106 | 107 | extern byte *uncompressed; 108 | extern int bitbytes; 109 | extern int bitlongs; 110 | 111 | void LeafFlow (int leafnum); 112 | void BasePortalVis (void); 113 | 114 | void PortalFlow (portal_t *p); 115 | 116 | void CalcAmbientSounds (void); 117 | -------------------------------------------------------------------------------- /tools/qb_hmap2/vis_sound.c: -------------------------------------------------------------------------------- 1 | 2 | #include "vis.h" 3 | 4 | /* 5 | 6 | Some textures (sky, water, slime, lava) are considered ambient sound emiters. 7 | Find an aproximate distance to the nearest emiter of each class for each leaf. 8 | 9 | */ 10 | 11 | /* 12 | ==================== 13 | SurfaceBBox 14 | ==================== 15 | */ 16 | void SurfaceBBox (dface_t *s, vec3_t mins, vec3_t maxs) 17 | { 18 | int i; 19 | int e; 20 | int vi; 21 | vec3_t v; 22 | 23 | ClearBounds( mins, maxs ); 24 | 25 | // Vic: old buggy code 26 | // mins[0] = mins[1] = BOGUS_RANGE; 27 | // maxs[0] = maxs[1] = -BOGUS_RANGE; 28 | 29 | for (i=0 ; inumedges ; i++) 30 | { 31 | e = dsurfedges[s->firstedge+i]; 32 | if (e >= 0) 33 | vi = dedges[e].v[0]; 34 | else 35 | vi = dedges[-e].v[1]; 36 | 37 | VectorCopy( dvertexes[vi].point, v ); 38 | AddPointToBounds( v, mins, maxs ); 39 | } 40 | } 41 | 42 | /* 43 | ==================== 44 | CalcAmbientSounds 45 | ==================== 46 | */ 47 | void CalcAmbientSounds (void) 48 | { 49 | int i, j, k, l; 50 | dleaf_t *leaf, *hit; 51 | byte *vis; 52 | dface_t *surf; 53 | vec3_t mins, maxs; 54 | vec_t d, maxd; 55 | int ambient_type; 56 | texinfo_t *info; 57 | miptex_t *miptex; 58 | int ofs; 59 | vec_t dists[NUM_AMBIENTS]; 60 | vec_t vol; 61 | 62 | printf ("---- ambient ----\n"); 63 | 64 | if (noambientslime) 65 | printf ("defaulting slime to water\n"); 66 | 67 | for (i=0 ; i< portalleafs ; i++) 68 | { 69 | leaf = &dleafs[i+1]; 70 | 71 | // 72 | // clear ambients 73 | // 74 | for (j=0 ; j>3] & (1<<(j&7))) ) 82 | continue; 83 | 84 | // 85 | // check this leaf for sound textures 86 | // 87 | hit = &dleafs[j+1]; 88 | 89 | for (k=0 ; k< hit->nummarksurfaces ; k++) 90 | { 91 | surf = &dfaces[dmarksurfaces[hit->firstmarksurface + k]]; 92 | info = &texinfo[surf->texinfo]; 93 | ofs = ((dmiptexlump_t *)dtexdata)->dataofs[info->miptex]; 94 | miptex = (miptex_t *)(&dtexdata[ofs]); 95 | 96 | // LordHavoc: optimized this to reduce wasted Q_strncasecmp calls 97 | if ((miptex->name[0] == 's' || miptex->name[0] == 'S') && (miptex->name[1] == 'k' || miptex->name[1] == 'K') && (miptex->name[2] == 'y' || miptex->name[2] == 'Y')) 98 | { 99 | if (noambientsky) 100 | continue; 101 | ambient_type = AMBIENT_SKY; 102 | } 103 | else if (miptex->name[0] == '*') 104 | { 105 | if ( !Q_strncasecmp (miptex->name, "*water", 6) ) 106 | { 107 | if (noambientwater) 108 | continue; 109 | ambient_type = AMBIENT_WATER; 110 | } 111 | else if ( !Q_strncasecmp (miptex->name, "*slime", 6) ) 112 | { 113 | if (noambientwater) 114 | continue; 115 | if (noambientslime) 116 | ambient_type = AMBIENT_WATER; 117 | else 118 | ambient_type = AMBIENT_SLIME; 119 | } 120 | else if ( !Q_strncasecmp (miptex->name, "*lava", 6) ) 121 | { 122 | if (noambientlava) 123 | continue; 124 | ambient_type = AMBIENT_LAVA; 125 | } 126 | else if ( !Q_strncasecmp (miptex->name, "*04water", 8) ) 127 | { 128 | if (noambientwater) 129 | continue; 130 | ambient_type = AMBIENT_WATER; 131 | } 132 | else 133 | continue; 134 | } 135 | else 136 | continue; 137 | 138 | // find distance from source leaf to polygon 139 | SurfaceBBox (surf, mins, maxs); 140 | maxd = 0; 141 | for (l=0 ; l<3 ; l++) 142 | { 143 | if (mins[l] > leaf->maxs[l]) 144 | d = mins[l] - leaf->maxs[l]; 145 | else if (maxs[l] < leaf->mins[l]) 146 | d = leaf->mins[l] - mins[l]; 147 | else 148 | d = 0; 149 | if (d > maxd) 150 | maxd = d; 151 | } 152 | 153 | // Vic: old buggy code 154 | // maxd = 0.25; 155 | if (maxd < dists[ambient_type]) 156 | dists[ambient_type] = maxd; 157 | } 158 | } 159 | 160 | for (j=0 ; j 1.0) 172 | vol = 1.0; // Vic 173 | } 174 | leaf->ambient_level[j] = vol*255; 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /tools/qb_hmap2/winding.h: -------------------------------------------------------------------------------- 1 | #ifndef __WINDING_H__ 2 | #define __WINDING_H__ 3 | 4 | typedef struct 5 | { 6 | int numpoints; 7 | vec3_t points[8]; // variable sized 8 | } winding_t; 9 | 10 | #define MAX_POINTS_ON_WINDING 64 11 | 12 | winding_t *AllocWinding (int points); 13 | void FreeWinding (winding_t *w); 14 | void PrintWinding(winding_t *w); 15 | winding_t *CopyWinding (winding_t *w); 16 | winding_t *CopyWindingExt( int numpoints, vec3_t *points ); 17 | winding_t *ReverseWinding( winding_t *w ); 18 | winding_t *BaseWindingForPlane( plane_t *p ); 19 | void CheckWinding( winding_t *w, int scriptline ); 20 | qboolean WindingIsTiny( winding_t *w ); 21 | vec_t WindingArea( winding_t *w ); 22 | void WindingCentre( winding_t *w, vec3_t centre, vec_t *radius ); 23 | void PlaneFromWinding( winding_t *w, plane_t *plane ); 24 | int WindingOnPlaneSide( winding_t *w, plane_t *plane ); 25 | winding_t *ClipWinding( winding_t *in, plane_t *split, qboolean keepon ); 26 | winding_t *ClipWindingEpsilon( winding_t *in, plane_t *split, vec_t epsilon, qboolean keepon ); 27 | void DivideWinding( winding_t *in, plane_t *split, winding_t **front, winding_t **back ); 28 | void DivideWindingEpsilon( winding_t *in, plane_t *split, winding_t **front, winding_t **back, vec_t epsilon ); 29 | winding_t *TryMergeWinding( winding_t *w1, winding_t *w2, vec3_t planenormal ); 30 | 31 | #endif //__WINDING_H__ 32 | -------------------------------------------------------------------------------- /tools/qb_newskip/qb_newskip.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 45 | 46 | -------------------------------------------------------------------------------- /version.bat: -------------------------------------------------------------------------------- 1 | svnversion > version.txt 2 | set /p version= < version.txt 3 | echo #define BUILDVERSION "%version%" > version.h 4 | 5 | del version.txt -------------------------------------------------------------------------------- /vid.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // vid.h -- video driver defs 18 | 19 | #define VID_CBITS 6 20 | #define VID_GRADES (1 << VID_CBITS) 21 | 22 | #define MIN_VID_WIDTH 360 //qb: If this changed, a bunch of menu stuff must change. 23 | #define MIN_VID_HEIGHT 200 24 | 25 | typedef byte pixel_t; 26 | 27 | typedef struct vrect_s 28 | { 29 | int x,y,width,height; 30 | struct vrect_s *pnext; 31 | } vrect_t; 32 | 33 | extern pixel_t colormap_cel[256*COLORLEVELS]; // Manoel Kasimier - EF_CELSHADING 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 | int rowbytes; // may be > width if displayed in a window //qb: signed per szo 41 | int width; 42 | int height; 43 | //qb: replace with cvar. float aspect; // width / height -- < 1 is taller than wide 44 | int numpages; 45 | int recalc_refdef; // if true, recalc vid-based stuff 46 | //qb: clean up junk. byte *conbuffer; 47 | int conrowbytes; 48 | unsigned conwidth; 49 | unsigned conheight; 50 | int maxwarpwidth; 51 | int maxwarpheight; 52 | //qb: clean up junk. byte *direct; // direct drawing to framebuffer, if not NULL 53 | //qboolean bottomup; //qb: debugging 54 | } viddef_t; 55 | 56 | extern viddef_t vid; // global video state 57 | extern unsigned short d_8to16table[256]; 58 | extern unsigned d_8to24table[256]; 59 | extern void (*vid_menudrawfn)(void); 60 | extern void (*vid_menukeyfn)(int key); 61 | 62 | void VID_SetPalette (byte *palette); 63 | // called at startup and after any gamma correction 64 | 65 | void VID_ShiftPalette (byte *palette); 66 | // called for bonus and pain flashes, and for underwater color changes 67 | 68 | void VID_Init (byte *palette); 69 | // Called at startup to set up translation tables, takes 256 8 bit RGB values 70 | // the palette data will go away after the call, so it must be copied off if 71 | // the video driver will need it again 72 | 73 | void VID_Shutdown (void); 74 | // Called at shutdown 75 | 76 | void VID_Update (vrect_t *rects); 77 | // flushes the given rectangles from the view buffer to the screen 78 | 79 | int VID_SetMode (int modenum, byte *palette); 80 | // sets the mode; only used by the Quake engine for resetting to mode 0 (the 81 | // base mode) on memory allocation failures 82 | 83 | void VID_HandlePause (qboolean pause); 84 | // called only on Win32, when pause happens, so the mouse can be released 85 | 86 | -------------------------------------------------------------------------------- /view.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qbism/super8/104a62e82f0ce36418c450c357348fc5bf1841e1/view.c -------------------------------------------------------------------------------- /view.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // view.h 18 | 19 | extern cvar_t v_gamma; 20 | 21 | extern byte gammatable[256]; // palette is sent through this 22 | extern byte ramps[3][256]; 23 | extern float v_blend[4]; 24 | 25 | 26 | void V_Init (void); 27 | void V_RenderView (void); 28 | float V_CalcRoll (vec3_t angles, vec3_t velocity); 29 | void V_UpdatePalette (void); 30 | 31 | -------------------------------------------------------------------------------- /wad.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | 18 | // wad.c 19 | 20 | #include "quakedef.h" 21 | 22 | unsigned wad_numlumps; 23 | lumpinfo_t *wad_lumps; 24 | byte *wad_base = NULL; //qb: johnfitz -- set to null 25 | 26 | void SwapPic (qpic_t *pic); 27 | 28 | /* 29 | ================== 30 | W_CleanupName 31 | 32 | Lowercases name and pads with spaces and a terminating 0 to the length of 33 | lumpinfo_t->name. 34 | Used so lumpname lookups can proceed rapidly by comparing 4 chars at a time 35 | Space padding is so names can be printed nicely in tables. 36 | Can safely be performed in place. 37 | ================== 38 | */ 39 | void W_CleanupName (char *in, char *out) 40 | { 41 | int i; 42 | int c; 43 | 44 | for (i=0 ; i<16 ; i++ ) 45 | { 46 | c = in[i]; 47 | if (!c) 48 | break; 49 | 50 | if (c >= 'A' && c <= 'Z') 51 | c += ('a' - 'A'); 52 | out[i] = c; 53 | } 54 | 55 | for ( ; i< 16 ; i++ ) 56 | out[i] = 0; 57 | } 58 | 59 | 60 | 61 | /* 62 | ==================== 63 | W_LoadWadFile 64 | ==================== 65 | */ 66 | void W_LoadWadFile (char *filename) 67 | { 68 | lumpinfo_t *lump_p; 69 | wadinfo_t *header; 70 | unsigned i; 71 | int infotableofs; 72 | loadedfile_t *fileinfo; // 2001-09-12 Returning information about loaded file by Maddes 73 | 74 | // 2001-09-12 Returning information about loaded file by Maddes start 75 | /* 76 | wad_base = COM_LoadHunkFile (filename); 77 | if (!wad_base) 78 | */ 79 | fileinfo = COM_LoadHunkFile (filename); 80 | if (!fileinfo) 81 | // 2001-09-12 Returning information about loaded file by Maddes end 82 | Sys_Error ("W_LoadWadFile: couldn't load %s", filename); 83 | wad_base = fileinfo->data; // 2001-09-12 Returning information about loaded file by Maddes 84 | 85 | header = (wadinfo_t *)wad_base; 86 | 87 | if (header->identification[0] != 'W' 88 | || header->identification[1] != 'A' 89 | || header->identification[2] != 'D' 90 | || header->identification[3] != '2') 91 | Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename); 92 | 93 | wad_numlumps = LittleLong(header->numlumps); 94 | infotableofs = LittleLong(header->infotableofs); 95 | wad_lumps = (lumpinfo_t *)(wad_base + infotableofs); 96 | 97 | for (i=0, lump_p = wad_lumps ; ifilepos = LittleLong(lump_p->filepos); 100 | lump_p->size = LittleLong(lump_p->size); 101 | W_CleanupName (lump_p->name, lump_p->name); 102 | if (lump_p->type == TYP_QPIC) 103 | SwapPic ( (qpic_t *)(wad_base + lump_p->filepos)); 104 | } 105 | } 106 | 107 | 108 | /* 109 | ============= 110 | W_GetLumpinfo 111 | ============= 112 | */ 113 | lumpinfo_t *W_GetLumpinfo (char *name) 114 | { 115 | int i; 116 | lumpinfo_t *lump_p; 117 | char clean[16]; 118 | 119 | W_CleanupName (name, clean); 120 | 121 | for (lump_p=wad_lumps, i=0 ; iname)) 124 | return lump_p; 125 | } 126 | 127 | Sys_Error ("W_GetLumpinfo: %s not found", name); 128 | return NULL; 129 | } 130 | 131 | void *W_GetLumpName (char *name) 132 | { 133 | lumpinfo_t *lump; 134 | 135 | lump = W_GetLumpinfo (name); 136 | 137 | return (void *)(wad_base + lump->filepos); 138 | } 139 | 140 | void *W_GetLumpNum (int num) 141 | { 142 | lumpinfo_t *lump; 143 | 144 | if (num < 0 || num > wad_numlumps) 145 | Sys_Error ("W_GetLumpNum: bad number: %i", num); 146 | 147 | lump = wad_lumps + num; 148 | 149 | return (void *)(wad_base + lump->filepos); 150 | } 151 | 152 | /* 153 | ============================================================================= 154 | 155 | automatic byte swapping 156 | 157 | ============================================================================= 158 | */ 159 | 160 | void SwapPic (qpic_t *pic) 161 | { 162 | pic->width = LittleLong(pic->width); 163 | pic->height = LittleLong(pic->height); 164 | } 165 | -------------------------------------------------------------------------------- /wad.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // wad.h 18 | 19 | //=============== 20 | // TYPES 21 | //=============== 22 | 23 | #define CMP_NONE 0 24 | #define CMP_LZSS 1 25 | 26 | #define TYP_NONE 0 27 | #define TYP_LABEL 1 28 | 29 | #define TYP_LUMPY 64 // 64 + grab command number 30 | #define TYP_PALETTE 64 31 | #define TYP_QTEX 65 32 | #define TYP_QPIC 66 33 | #define TYP_SOUND 67 34 | #define TYP_MIPTEX 68 35 | 36 | typedef struct 37 | { 38 | unsigned int width, height; 39 | byte data[4]; // variably sized 40 | } qpic_t; 41 | 42 | // mankrip - begin 43 | typedef struct 44 | { 45 | short palette[256]; 46 | unsigned int width, height; 47 | byte data[4]; // variably sized 48 | } satpic_t; 49 | // mankrip - end 50 | 51 | 52 | typedef struct 53 | { 54 | char identification[4]; // should be WAD2 or 2DAW 55 | int numlumps; 56 | int infotableofs; 57 | } wadinfo_t; 58 | 59 | typedef struct 60 | { 61 | int filepos; 62 | int disksize; 63 | int size; // uncompressed 64 | char type; 65 | char compression; 66 | char pad1, pad2; 67 | char name[16]; // must be null terminated 68 | } lumpinfo_t; 69 | 70 | extern unsigned wad_numlumps; 71 | extern lumpinfo_t *wad_lumps; 72 | extern byte *wad_base; 73 | 74 | void W_LoadWadFile (char *filename); 75 | void W_CleanupName (char *in, char *out); 76 | lumpinfo_t *W_GetLumpinfo (char *name); 77 | void *W_GetLumpName (char *name); 78 | void *W_GetLumpNum (int num); 79 | 80 | void SwapPic (qpic_t *pic); 81 | -------------------------------------------------------------------------------- /world.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | // world.h 18 | 19 | typedef struct 20 | { 21 | vec3_t normal; 22 | float dist; 23 | } plane_t; 24 | 25 | typedef struct 26 | { 27 | qboolean allsolid; // if true, plane is not valid 28 | qboolean startsolid; // if true, the initial point was in a solid area 29 | qboolean inopen, inwater; 30 | float fraction; // time completed, 1.0 = didn't hit anything 31 | vec3_t endpos; // final position 32 | plane_t plane; // surface normal at impact 33 | edict_t *ent; // entity the surface is on 34 | } trace_t; 35 | 36 | 37 | #define MOVE_NORMAL 0 38 | #define MOVE_NOMONSTERS 1 39 | #define MOVE_MISSILE 2 40 | 41 | 42 | void SV_ClearWorld (void); 43 | // called after the world model has been loaded, before linking any entities 44 | 45 | void SV_UnlinkEdict (edict_t *ent); 46 | // call before removing an entity, and before trying to move one, 47 | // so it doesn't clip against itself 48 | // flags ent->v.modified 49 | 50 | void SV_LinkEdict (edict_t *ent, qboolean touch_triggers); 51 | // Needs to be called any time an entity changes origin, mins, maxs, or solid 52 | // flags ent->v.modified 53 | // sets ent->v.absmin and ent->v.absmax 54 | // if touchtriggers, calls prog functions for the intersected triggers 55 | 56 | int SV_PointContents (vec3_t p); 57 | int SV_TruePointContents (vec3_t p); 58 | // returns the CONTENTS_* value from the world at the given point. 59 | // does not check any entities at all 60 | // the non-true version remaps the water current contents to content_water 61 | 62 | edict_t *SV_TestEntityPosition (edict_t *ent); 63 | 64 | trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict); 65 | // mins and maxs are reletive 66 | 67 | // if the entire move stays in a solid volume, trace.allsolid will be set 68 | 69 | // if the starting point is in a solid, it will be allowed to move out 70 | // to an open area 71 | 72 | // nomonsters is used for line of sight or edge testing, where mosnters 73 | // shouldn't be considered solid objects 74 | 75 | // passedict is explicitly excluded from clipping checks (normally NULL) 76 | -------------------------------------------------------------------------------- /zone.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996-1997 Id Software, Inc. 2 | Copyright (C) 1999-2012 other authors as noted in code comments 3 | 4 | This program is free software; you can redistribute it and/or modify it under 5 | the terms of the GNU General Public License as published by the Free Software 6 | Foundation; either version 3 of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 9 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10 | PARTICULAR PURPOSE. 11 | 12 | See the GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software Foundation, Inc., 16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 | /* 18 | memory allocation 19 | 20 | 21 | H_??? The hunk manages the entire memory block given to quake. It must be 22 | contiguous. Memory can be allocated from either the low or high end in a 23 | stack fashion. The only way memory is released is by resetting one of the 24 | pointers. 25 | 26 | Hunk allocations should be given a name, so the Hunk_Print () function 27 | can display usage. 28 | 29 | Hunk allocations are guaranteed to be 16 byte aligned. 30 | 31 | The video buffers are allocated high to avoid leaving a hole underneath 32 | server allocations when changing to a higher video mode. 33 | 34 | 35 | Z_??? Zone memory functions used for small, dynamic allocations like text 36 | strings from command input. There is only about 48K for it, allocated at 37 | the very bottom of the hunk. 38 | 39 | Cache_??? Cache memory is for objects that can be dynamically loaded and 40 | can usefully stay persistant between levels. The size of the cache 41 | fluctuates from level to level. 42 | 43 | To allocate a cachable object 44 | 45 | 46 | Temp_??? Temp memory is used for file loading and surface caching. The size 47 | of the cache memory is adjusted so that there is a minimum of 512k remaining 48 | for temp memory. 49 | 50 | 51 | ------ Top of Memory ------- 52 | 53 | high hunk allocations 54 | 55 | <--- high hunk reset point held by vid 56 | 57 | video buffer 58 | 59 | z buffer 60 | 61 | surface cache 62 | 63 | <--- high hunk used 64 | 65 | cachable memory 66 | 67 | <--- low hunk used 68 | 69 | client and server low hunk allocations 70 | 71 | <-- low hunk reset point held by host 72 | 73 | startup hunk allocations 74 | 75 | Zone block 76 | 77 | ----- Bottom of Memory ----- 78 | 79 | 80 | 81 | */ 82 | 83 | void Memory_Init (void *buf, int size); 84 | 85 | void *Hunk_Alloc (int size); // returns 0 filled memory 86 | void *Hunk_AllocName (int size, char *name); 87 | 88 | void *Hunk_HighAllocName (int size, char *name); 89 | 90 | int Hunk_LowMark (void); 91 | void Hunk_FreeToLowMark (int mark); 92 | 93 | int Hunk_HighMark (void); 94 | void Hunk_FreeToHighMark (int mark); 95 | 96 | void *Hunk_TempAlloc (int size); 97 | 98 | void Hunk_Check (void); 99 | 100 | typedef struct cache_user_s 101 | { 102 | void *data; 103 | } cache_user_t; 104 | 105 | void Cache_Flush (void); 106 | 107 | void *Cache_Check (cache_user_t *c); 108 | // returns the cached data, and moves to the head of the LRU list 109 | // if present, otherwise returns NULL 110 | 111 | void Cache_Free (cache_user_t *c); 112 | 113 | void *Cache_Alloc (cache_user_t *c, int size, const char *name); 114 | // Returns NULL if all purgable data was tossed and there still 115 | // wasn't enough room. 116 | 117 | void Cache_Report (void); 118 | 119 | 120 | //qb: jqavi begin 121 | void *Q_malloc (size_t size, char *caller); // joe 122 | void *Q_calloc (char *str, size_t n); 123 | void *Q_realloc (void *ptr, size_t size); 124 | void *Q_strdup (const char *str); 125 | //qb: jqavi end 126 | 127 | //qb: qrack begin 128 | #define Q_free(ptr) if(ptr) { free(ptr); ptr = NULL; } 129 | //qb: qrack end 130 | --------------------------------------------------------------------------------