shithub: qk2


clone: git:// gits://
push: hjgit://

Last commit

4c66d61f – Sigrid Solveig Haflínudóttir <> authored on 2022/08/19 14:07
sys: use fstat and avoid unaligned data access on stack


qk2 - (9) quake 2
Port of linux/x11 quake 2 to plan9front.
- Works on amd64 and 386, broken on some arm machines and probably other arches
- Rendering bugs on non-4:3 resolutions

For details, see:

Besides building and installation, qk2 needs the data from its retail cd.
Those are to be installed in /sys/games/lib/quake2/baseq2.  In a complete
install, that directory will contain pak^(0 1 2)^.pak, as well as the players
and video directories.  Neither players (for single play) nor video are
mandatory.  All filenames should be lowercased.

; mk install
; mkdir -p /sys/games/lib/quake2/baseq2/^(players video)
; cd /n/quake2cd/baseq2/
; cp *.pak /sys/games/lib/quake2/baseq2/
; for(i in (players video)){ dircp $i /sys/games/lib/quake2/baseq2/$i }

Savegames, configuration files and other user data will be written under

Note: to enable grabbing the mouse, set the m_windowed console variable to 1.

Quake2 mods
Quake2 mods are C code built as shared libraries (called "game modules").  Here,
the code will have to be ported to plan9, adapted to qk2, then built and loaded
against it.  This repo contains the code for the official ctf mod, the two
expansions, and a mod.  For the rest of this file, let $mod the name of a mod.
The data for the mod is to be stored in /sys/games/lib/quake2/$mod/.

Installing a mod
A makefile is provided with each mod. "baseq2" is the main game.
For example, for ctf:

; mkfile -f mkfile.ctf install


; bind mkfile.ctf mkfile
; mk install

Each mod is built as a library, later linked to the rest of the common code.

; q2ctf +set game ctf +set ctf 1

Porting a mod
In the case you wish to play a mod which has not been ported, and have nothing
better to do, you will need to port it yourself.  fwiw, ctf and crbot-1.0 took
me about 4-5 hours each (not including debugging).  Note that all of this
assumes the mod only alters code for the game module (game/).  If that's not
the case, no standard operational procedure exists.

Having obtained the $mod's source code, you can use game/*.[ch] as reference
for your porting efforts.  One thing specific to qk2 is how header files are
handled: most common headers, including game/q_shared.h, were merged into dat.h
and fns.h.  game/[gp]*.h were merged into game/game.h.  game/game.h is
unfortunately included in dat.h, as some required structure definitions vary
from mod to mod.  As such, a mod is required to have $mod/game.h, which defines
anything necessary for common code to work.

You'll also need to write mkfiles (cf. mod installation instructions above).

- raise resolution limit above 2047x2048
- fix underwater rendering glitches on non-4:3
- edict_t definitions merged without much looking
- sys.c: stupid posixish glob stuff
- udp.c mostly horrid; need to rewrite networking stuff to use plan9 semantics
- garbled stdout (Sys_ConsoleOutput): \r instead of \n
- cinematic palette is fucked up if you resize during playback
- sound only (sortof) works thanks to shitty workarounds; in particular, sound
  buffer seems to be overwritten as its being written to /dev/audio
- multiplayer menu bugs: memory leaks and bugged map list
- compliling with -DPARANOID reveals hidden truths
- video menu doesn't make sense anymore; options menu includes deprecated crap
- (bjnh) clean up code more, plan9 C style everywhere
- (bjnh) better performance, use asm from original release
- (bjnh) redesign everything to be super cool

Differences with linux/x11 quake2
- mouse wheel up and down recognized and useable (but parsing is ugly)
- mouse buttons have (correct) plan9 names
- arbitrary resolutions up to 2047x2048 allowed (dat.h) and resize by dragging
  window edges; no fullscreen
- no dynamic linking → "modules" are statically linked
- merged headers: dat.h,fns.h,game/game.h
- m_windowed cvar and IN_Grabm() for mouse grabbing
- ungrabs mouse when menu or console are opened
- removed some useless sys cvars
- mproc stuff for not letting mouse escape too often whenever the use swipes it
  probably sucks

Quake 2, hence qk2, is licensed under the GPLv2. See COPYING for details.
All of the Q2 data files remain copyrighted and licensed under the original