This commit is contained in:
Literally A Penguin
2024-09-25 15:38:23 -05:00
committed by GitHub
parent b585e51a81
commit e8bd66b89c
89 changed files with 49934 additions and 0 deletions

716
linux/Makefile.AXP Normal file
View File

@ -0,0 +1,716 @@
#
# Quake2 Makefile for Solaris
#
# Nov '97 by Zoid <zoid@idsoftware.com>
#
# ELF only
#
ARCH=axp
MOUNT_DIR=/chest/Quake2/code
BUILD_DEBUG_DIR=debug$(ARCH)
BUILD_RELEASE_DIR=release$(ARCH)
CLIENT_DIR=$(MOUNT_DIR)/client
SERVER_DIR=$(MOUNT_DIR)/server
COMMON_DIR=$(MOUNT_DIR)/qcommon
LINUX_DIR=$(MOUNT_DIR)/linux
GAME_DIR=$(MOUNT_DIR)/game
CTF_DIR=$(MOUNT_DIR)/ctf
XATRIX_DIR=$(MOUNT_DIR)/xatrix
NULL_DIR=$(MOUNT_DIR)/null
CC=gcc
BASE_CFLAGS=-Dstricmp=strcasecmp -DC_ONLY -DDEDICATED_ONLY
RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations
DEBUG_CFLAGS=$(BASE_CFLAGS) -g
LDFLAGS=-ldl -lm
XCFLAGS=
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
#############################################################################
# SETUP AND BUILD
#############################################################################
TARGETS=$(BUILDDIR)/q2ded \
$(BUILDDIR)/game$(ARCH).$(SHLIBEXT) \
$(BUILDDIR)/ctf/game$(ARCH).$(SHLIBEXT) \
$(BUILDDIR)/xatrix/game$(ARCH).$(SHLIBEXT)
build_debug:
@-mkdir $(BUILD_DEBUG_DIR) \
$(BUILD_DEBUG_DIR)/client \
$(BUILD_DEBUG_DIR)/game \
$(BUILD_DEBUG_DIR)/ctf \
$(BUILD_DEBUG_DIR)/xatrix
$(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) CFLAGS="$(DEBUG_CFLAGS)"
build_release:
@-mkdir $(BUILD_RELEASE_DIR) \
$(BUILD_RELEASE_DIR)/client \
$(BUILD_RELEASE_DIR)/game \
$(BUILD_RELEASE_DIR)/ctf \
$(BUILD_RELEASE_DIR)/xatrix
$(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) CFLAGS="$(RELEASE_CFLAGS)"
all: build_debug build_release
targets: $(TARGETS)
#############################################################################
# CLIENT/SERVER
#############################################################################
QUAKE2_OBJS = \
\
$(BUILDDIR)/client/cmd.o \
$(BUILDDIR)/client/cmodel.o \
$(BUILDDIR)/client/common.o \
$(BUILDDIR)/client/crc.o \
$(BUILDDIR)/client/cvar.o \
$(BUILDDIR)/client/files.o \
$(BUILDDIR)/client/md4.o \
$(BUILDDIR)/client/net_chan.o \
\
$(BUILDDIR)/client/sv_ccmds.o \
$(BUILDDIR)/client/sv_ents.o \
$(BUILDDIR)/client/sv_game.o \
$(BUILDDIR)/client/sv_init.o \
$(BUILDDIR)/client/sv_main.o \
$(BUILDDIR)/client/sv_send.o \
$(BUILDDIR)/client/sv_user.o \
$(BUILDDIR)/client/sv_world.o \
\
$(BUILDDIR)/client/q_shlinux.o \
$(BUILDDIR)/client/sys_linux.o \
$(BUILDDIR)/client/glob.o \
$(BUILDDIR)/client/net_udp.o \
\
$(BUILDDIR)/client/q_shared.o \
$(BUILDDIR)/client/pmove.o \
\
$(BUILDDIR)/client/cl_null.o \
$(BUILDDIR)/client/cd_null.o
$(BUILDDIR)/q2ded : $(QUAKE2_OBJS)
$(CC) $(CFLAGS) -o $@ $(QUAKE2_OBJS) $(LDFLAGS)
$(BUILDDIR)/client/cmd.o : $(COMMON_DIR)/cmd.c
$(DO_CC)
$(BUILDDIR)/client/cmodel.o : $(COMMON_DIR)/cmodel.c
$(DO_CC)
$(BUILDDIR)/client/common.o : $(COMMON_DIR)/common.c
$(DO_CC)
$(BUILDDIR)/client/crc.o : $(COMMON_DIR)/crc.c
$(DO_CC)
$(BUILDDIR)/client/cvar.o : $(COMMON_DIR)/cvar.c
$(DO_CC)
$(BUILDDIR)/client/files.o : $(COMMON_DIR)/files.c
$(DO_CC)
$(BUILDDIR)/client/md4.o : $(COMMON_DIR)/md4.c
$(DO_CC)
$(BUILDDIR)/client/net_chan.o : $(COMMON_DIR)/net_chan.c
$(DO_CC)
$(BUILDDIR)/client/q_shared.o : $(GAME_DIR)/q_shared.c
$(DO_CC)
$(BUILDDIR)/client/pmove.o : $(COMMON_DIR)/pmove.c
$(DO_CC)
$(BUILDDIR)/client/sv_ccmds.o : $(SERVER_DIR)/sv_ccmds.c
$(DO_CC)
$(BUILDDIR)/client/sv_ents.o : $(SERVER_DIR)/sv_ents.c
$(DO_CC)
$(BUILDDIR)/client/sv_game.o : $(SERVER_DIR)/sv_game.c
$(DO_CC)
$(BUILDDIR)/client/sv_init.o : $(SERVER_DIR)/sv_init.c
$(DO_CC)
$(BUILDDIR)/client/sv_main.o : $(SERVER_DIR)/sv_main.c
$(DO_CC)
$(BUILDDIR)/client/sv_send.o : $(SERVER_DIR)/sv_send.c
$(DO_CC)
$(BUILDDIR)/client/sv_user.o : $(SERVER_DIR)/sv_user.c
$(DO_CC)
$(BUILDDIR)/client/sv_world.o : $(SERVER_DIR)/sv_world.c
$(DO_CC)
$(BUILDDIR)/client/q_shlinux.o : $(LINUX_DIR)/q_shlinux.c
$(DO_CC)
$(BUILDDIR)/client/sys_linux.o : $(LINUX_DIR)/sys_linux.c
$(DO_CC)
$(BUILDDIR)/client/glob.o : $(LINUX_DIR)/glob.c
$(DO_CC)
$(BUILDDIR)/client/net_udp.o : $(LINUX_DIR)/net_udp.c
$(DO_CC)
$(BUILDDIR)/client/cd_null.o : $(NULL_DIR)/cd_null.c
$(DO_CC)
$(BUILDDIR)/client/cl_null.o : $(NULL_DIR)/cl_null.c
$(DO_CC)
#############################################################################
# GAME
#############################################################################
GAME_OBJS = \
$(BUILDDIR)/game/g_ai.o \
$(BUILDDIR)/game/p_client.o \
$(BUILDDIR)/game/g_cmds.o \
$(BUILDDIR)/game/g_svcmds.o \
$(BUILDDIR)/game/g_combat.o \
$(BUILDDIR)/game/g_func.o \
$(BUILDDIR)/game/g_items.o \
$(BUILDDIR)/game/g_main.o \
$(BUILDDIR)/game/g_misc.o \
$(BUILDDIR)/game/g_monster.o \
$(BUILDDIR)/game/g_phys.o \
$(BUILDDIR)/game/g_save.o \
$(BUILDDIR)/game/g_spawn.o \
$(BUILDDIR)/game/g_target.o \
$(BUILDDIR)/game/g_trigger.o \
$(BUILDDIR)/game/g_turret.o \
$(BUILDDIR)/game/g_utils.o \
$(BUILDDIR)/game/g_weapon.o \
$(BUILDDIR)/game/m_actor.o \
$(BUILDDIR)/game/m_berserk.o \
$(BUILDDIR)/game/m_boss2.o \
$(BUILDDIR)/game/m_boss3.o \
$(BUILDDIR)/game/m_boss31.o \
$(BUILDDIR)/game/m_boss32.o \
$(BUILDDIR)/game/m_brain.o \
$(BUILDDIR)/game/m_chick.o \
$(BUILDDIR)/game/m_flipper.o \
$(BUILDDIR)/game/m_float.o \
$(BUILDDIR)/game/m_flyer.o \
$(BUILDDIR)/game/m_gladiator.o \
$(BUILDDIR)/game/m_gunner.o \
$(BUILDDIR)/game/m_hover.o \
$(BUILDDIR)/game/m_infantry.o \
$(BUILDDIR)/game/m_insane.o \
$(BUILDDIR)/game/m_medic.o \
$(BUILDDIR)/game/m_move.o \
$(BUILDDIR)/game/m_mutant.o \
$(BUILDDIR)/game/m_parasite.o \
$(BUILDDIR)/game/m_soldier.o \
$(BUILDDIR)/game/m_supertank.o \
$(BUILDDIR)/game/m_tank.o \
$(BUILDDIR)/game/p_hud.o \
$(BUILDDIR)/game/p_trail.o \
$(BUILDDIR)/game/p_view.o \
$(BUILDDIR)/game/p_weapon.o \
$(BUILDDIR)/game/q_shared.o \
$(BUILDDIR)/game/m_flash.o
$(BUILDDIR)/game$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS)
$(BUILDDIR)/game/g_ai.o : $(GAME_DIR)/g_ai.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/p_client.o : $(GAME_DIR)/p_client.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_cmds.o : $(GAME_DIR)/g_cmds.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_svcmds.o : $(GAME_DIR)/g_svcmds.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_combat.o : $(GAME_DIR)/g_combat.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_func.o : $(GAME_DIR)/g_func.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_items.o : $(GAME_DIR)/g_items.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_main.o : $(GAME_DIR)/g_main.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_misc.o : $(GAME_DIR)/g_misc.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_monster.o : $(GAME_DIR)/g_monster.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_phys.o : $(GAME_DIR)/g_phys.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_save.o : $(GAME_DIR)/g_save.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_spawn.o : $(GAME_DIR)/g_spawn.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_target.o : $(GAME_DIR)/g_target.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_trigger.o : $(GAME_DIR)/g_trigger.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_turret.o : $(GAME_DIR)/g_turret.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_utils.o : $(GAME_DIR)/g_utils.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/g_weapon.o : $(GAME_DIR)/g_weapon.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_actor.o : $(GAME_DIR)/m_actor.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_berserk.o : $(GAME_DIR)/m_berserk.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_boss2.o : $(GAME_DIR)/m_boss2.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_boss3.o : $(GAME_DIR)/m_boss3.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_boss31.o : $(GAME_DIR)/m_boss31.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_boss32.o : $(GAME_DIR)/m_boss32.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_brain.o : $(GAME_DIR)/m_brain.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_chick.o : $(GAME_DIR)/m_chick.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_flipper.o : $(GAME_DIR)/m_flipper.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_float.o : $(GAME_DIR)/m_float.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_flyer.o : $(GAME_DIR)/m_flyer.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_gladiator.o : $(GAME_DIR)/m_gladiator.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_gunner.o : $(GAME_DIR)/m_gunner.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_hover.o : $(GAME_DIR)/m_hover.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_infantry.o : $(GAME_DIR)/m_infantry.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_insane.o : $(GAME_DIR)/m_insane.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_medic.o : $(GAME_DIR)/m_medic.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_move.o : $(GAME_DIR)/m_move.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_mutant.o : $(GAME_DIR)/m_mutant.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_parasite.o : $(GAME_DIR)/m_parasite.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_soldier.o : $(GAME_DIR)/m_soldier.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_supertank.o : $(GAME_DIR)/m_supertank.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_tank.o : $(GAME_DIR)/m_tank.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/p_hud.o : $(GAME_DIR)/p_hud.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/p_trail.o : $(GAME_DIR)/p_trail.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/p_view.o : $(GAME_DIR)/p_view.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/p_weapon.o : $(GAME_DIR)/p_weapon.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/q_shared.o : $(GAME_DIR)/q_shared.c
$(DO_SHLIB_CC)
$(BUILDDIR)/game/m_flash.o : $(GAME_DIR)/m_flash.c
$(DO_SHLIB_CC)
#############################################################################
# CTF
#############################################################################
CTF_OBJS = \
$(BUILDDIR)/ctf/g_ai.o \
$(BUILDDIR)/ctf/g_chase.o \
$(BUILDDIR)/ctf/g_cmds.o \
$(BUILDDIR)/ctf/g_combat.o \
$(BUILDDIR)/ctf/g_ctf.o \
$(BUILDDIR)/ctf/g_func.o \
$(BUILDDIR)/ctf/g_items.o \
$(BUILDDIR)/ctf/g_main.o \
$(BUILDDIR)/ctf/g_misc.o \
$(BUILDDIR)/ctf/g_monster.o \
$(BUILDDIR)/ctf/g_phys.o \
$(BUILDDIR)/ctf/g_save.o \
$(BUILDDIR)/ctf/g_spawn.o \
$(BUILDDIR)/ctf/g_svcmds.o \
$(BUILDDIR)/ctf/g_target.o \
$(BUILDDIR)/ctf/g_trigger.o \
$(BUILDDIR)/ctf/g_utils.o \
$(BUILDDIR)/ctf/g_weapon.o \
$(BUILDDIR)/ctf/m_move.o \
$(BUILDDIR)/ctf/p_client.o \
$(BUILDDIR)/ctf/p_hud.o \
$(BUILDDIR)/ctf/p_menu.o \
$(BUILDDIR)/ctf/p_trail.o \
$(BUILDDIR)/ctf/p_view.o \
$(BUILDDIR)/ctf/p_weapon.o \
$(BUILDDIR)/ctf/q_shared.o
$(BUILDDIR)/ctf/game$(ARCH).$(SHLIBEXT) : $(CTF_OBJS)
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(CTF_OBJS)
$(BUILDDIR)/ctf/g_ai.o : $(CTF_DIR)/g_ai.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_chase.o : $(CTF_DIR)/g_chase.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_cmds.o : $(CTF_DIR)/g_cmds.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_combat.o : $(CTF_DIR)/g_combat.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_ctf.o : $(CTF_DIR)/g_ctf.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_func.o : $(CTF_DIR)/g_func.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_items.o : $(CTF_DIR)/g_items.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_main.o : $(CTF_DIR)/g_main.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_misc.o : $(CTF_DIR)/g_misc.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_monster.o : $(CTF_DIR)/g_monster.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_phys.o : $(CTF_DIR)/g_phys.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_save.o : $(CTF_DIR)/g_save.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_spawn.o : $(CTF_DIR)/g_spawn.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_svcmds.o : $(CTF_DIR)/g_svcmds.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_target.o : $(CTF_DIR)/g_target.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_trigger.o : $(CTF_DIR)/g_trigger.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_utils.o : $(CTF_DIR)/g_utils.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/g_weapon.o : $(CTF_DIR)/g_weapon.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/m_move.o : $(CTF_DIR)/m_move.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/p_client.o : $(CTF_DIR)/p_client.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/p_hud.o : $(CTF_DIR)/p_hud.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/p_menu.o : $(CTF_DIR)/p_menu.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/p_trail.o : $(CTF_DIR)/p_trail.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/p_view.o : $(CTF_DIR)/p_view.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/p_weapon.o : $(CTF_DIR)/p_weapon.c
$(DO_SHLIB_CC)
$(BUILDDIR)/ctf/q_shared.o : $(CTF_DIR)/q_shared.c
$(DO_SHLIB_CC)
#############################################################################
# XATRIX
#############################################################################
XATRIX_OBJS = \
$(BUILDDIR)/xatrix/g_ai.o \
$(BUILDDIR)/xatrix/g_cmds.o \
$(BUILDDIR)/xatrix/g_combat.o \
$(BUILDDIR)/xatrix/g_func.o \
$(BUILDDIR)/xatrix/g_items.o \
$(BUILDDIR)/xatrix/g_main.o \
$(BUILDDIR)/xatrix/g_misc.o \
$(BUILDDIR)/xatrix/g_monster.o \
$(BUILDDIR)/xatrix/g_phys.o \
$(BUILDDIR)/xatrix/g_save.o \
$(BUILDDIR)/xatrix/g_spawn.o \
$(BUILDDIR)/xatrix/g_svcmds.o \
$(BUILDDIR)/xatrix/g_target.o \
$(BUILDDIR)/xatrix/g_trigger.o \
$(BUILDDIR)/xatrix/g_turret.o \
$(BUILDDIR)/xatrix/g_utils.o \
$(BUILDDIR)/xatrix/g_weapon.o \
$(BUILDDIR)/xatrix/m_actor.o \
$(BUILDDIR)/xatrix/m_berserk.o \
$(BUILDDIR)/xatrix/m_boss2.o \
$(BUILDDIR)/xatrix/m_boss3.o \
$(BUILDDIR)/xatrix/m_boss31.o \
$(BUILDDIR)/xatrix/m_boss32.o \
$(BUILDDIR)/xatrix/m_boss5.o \
$(BUILDDIR)/xatrix/m_brain.o \
$(BUILDDIR)/xatrix/m_chick.o \
$(BUILDDIR)/xatrix/m_fixbot.o \
$(BUILDDIR)/xatrix/m_flash.o \
$(BUILDDIR)/xatrix/m_flipper.o \
$(BUILDDIR)/xatrix/m_float.o \
$(BUILDDIR)/xatrix/m_flyer.o \
$(BUILDDIR)/xatrix/m_gekk.o \
$(BUILDDIR)/xatrix/m_gladb.o \
$(BUILDDIR)/xatrix/m_gladiator.o \
$(BUILDDIR)/xatrix/m_gunner.o \
$(BUILDDIR)/xatrix/m_hover.o \
$(BUILDDIR)/xatrix/m_infantry.o \
$(BUILDDIR)/xatrix/m_insane.o \
$(BUILDDIR)/xatrix/m_medic.o \
$(BUILDDIR)/xatrix/m_move.o \
$(BUILDDIR)/xatrix/m_mutant.o \
$(BUILDDIR)/xatrix/m_parasite.o \
$(BUILDDIR)/xatrix/m_soldier.o \
$(BUILDDIR)/xatrix/m_supertank.o \
$(BUILDDIR)/xatrix/m_tank.o \
$(BUILDDIR)/xatrix/p_client.o \
$(BUILDDIR)/xatrix/p_hud.o \
$(BUILDDIR)/xatrix/p_trail.o \
$(BUILDDIR)/xatrix/p_view.o \
$(BUILDDIR)/xatrix/p_weapon.o \
$(BUILDDIR)/xatrix/q_shared.o
$(BUILDDIR)/xatrix/game$(ARCH).$(SHLIBEXT) : $(XATRIX_OBJS)
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(XATRIX_OBJS)
$(BUILDDIR)/xatrix/g_ai.o : $(XATRIX_DIR)/g_ai.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_cmds.o : $(XATRIX_DIR)/g_cmds.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_combat.o : $(XATRIX_DIR)/g_combat.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_func.o : $(XATRIX_DIR)/g_func.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_items.o : $(XATRIX_DIR)/g_items.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_main.o : $(XATRIX_DIR)/g_main.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_misc.o : $(XATRIX_DIR)/g_misc.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_monster.o : $(XATRIX_DIR)/g_monster.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_phys.o : $(XATRIX_DIR)/g_phys.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_save.o : $(XATRIX_DIR)/g_save.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_spawn.o : $(XATRIX_DIR)/g_spawn.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_svcmds.o : $(XATRIX_DIR)/g_svcmds.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_target.o : $(XATRIX_DIR)/g_target.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_trigger.o : $(XATRIX_DIR)/g_trigger.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_turret.o : $(XATRIX_DIR)/g_turret.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_utils.o : $(XATRIX_DIR)/g_utils.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/g_weapon.o : $(XATRIX_DIR)/g_weapon.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_actor.o : $(XATRIX_DIR)/m_actor.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_berserk.o : $(XATRIX_DIR)/m_berserk.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_boss2.o : $(XATRIX_DIR)/m_boss2.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_boss3.o : $(XATRIX_DIR)/m_boss3.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_boss31.o : $(XATRIX_DIR)/m_boss31.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_boss32.o : $(XATRIX_DIR)/m_boss32.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_boss5.o : $(XATRIX_DIR)/m_boss5.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_brain.o : $(XATRIX_DIR)/m_brain.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_chick.o : $(XATRIX_DIR)/m_chick.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_fixbot.o : $(XATRIX_DIR)/m_fixbot.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_flash.o : $(XATRIX_DIR)/m_flash.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_flipper.o : $(XATRIX_DIR)/m_flipper.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_float.o : $(XATRIX_DIR)/m_float.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_flyer.o : $(XATRIX_DIR)/m_flyer.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_gekk.o : $(XATRIX_DIR)/m_gekk.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_gladb.o : $(XATRIX_DIR)/m_gladb.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_gladiator.o : $(XATRIX_DIR)/m_gladiator.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_gunner.o : $(XATRIX_DIR)/m_gunner.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_hover.o : $(XATRIX_DIR)/m_hover.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_infantry.o : $(XATRIX_DIR)/m_infantry.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_insane.o : $(XATRIX_DIR)/m_insane.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_medic.o : $(XATRIX_DIR)/m_medic.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_move.o : $(XATRIX_DIR)/m_move.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_mutant.o : $(XATRIX_DIR)/m_mutant.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_parasite.o : $(XATRIX_DIR)/m_parasite.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_soldier.o : $(XATRIX_DIR)/m_soldier.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_supertank.o : $(XATRIX_DIR)/m_supertank.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/m_tank.o : $(XATRIX_DIR)/m_tank.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/p_client.o : $(XATRIX_DIR)/p_client.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/p_hud.o : $(XATRIX_DIR)/p_hud.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/p_trail.o : $(XATRIX_DIR)/p_trail.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/p_view.o : $(XATRIX_DIR)/p_view.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/p_weapon.o : $(XATRIX_DIR)/p_weapon.c
$(DO_SHLIB_CC)
$(BUILDDIR)/xatrix/q_shared.o : $(XATRIX_DIR)/q_shared.c
$(DO_SHLIB_CC)
#############################################################################
# MISC
#############################################################################
clean: clean-debug clean-release
clean-debug:
$(MAKE) clean2 BUILDDIR=$(BUILD_DEBUG_DIR) CFLAGS="$(DEBUG_CFLAGS)"
clean-release:
$(MAKE) clean2 BUILDDIR=$(BUILD_RELEASE_DIR) CFLAGS="$(DEBUG_CFLAGS)"
clean2:
-rm -f $(QUAKE2_OBJS) $(GAME_OBJS) $(CTF_OBJS) $(XATRIX_OBJS)

1085
linux/Makefile.i386 Normal file

File diff suppressed because it is too large Load Diff

123
linux/block16.h Normal file
View File

@ -0,0 +1,123 @@
LEnter16_16:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch0:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch1:
movw %cx,2(%edi)
addl $0x4,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch2:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch3:
movw %cx,2(%edi)
addl $0x4,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch4:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch5:
movw %cx,2(%edi)
addl $0x4,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch6:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch7:
movw %cx,2(%edi)
addl $0x4,%edi
LEnter8_16:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch8:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch9:
movw %cx,2(%edi)
addl $0x4,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch10:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch11:
movw %cx,2(%edi)
addl $0x4,%edi
LEnter4_16:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch12:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch13:
movw %cx,2(%edi)
addl $0x4,%edi
LEnter2_16:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movw 0x12345678(,%eax,2),%ax
LBPatch14:
addl %ebp,%edx
movw %ax,(%edi)
movw 0x12345678(,%ecx,2),%cx
LBPatch15:
movw %cx,2(%edi)
addl $0x4,%edi

124
linux/block8.h Normal file
View File

@ -0,0 +1,124 @@
LEnter16_8:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch0:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch1:
movb %cl,1(%edi)
addl $0x2,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch2:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch3:
movb %cl,1(%edi)
addl $0x2,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch4:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch5:
movb %cl,1(%edi)
addl $0x2,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch6:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch7:
movb %cl,1(%edi)
addl $0x2,%edi
LEnter8_8:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch8:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch9:
movb %cl,1(%edi)
addl $0x2,%edi
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch10:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch11:
movb %cl,1(%edi)
addl $0x2,%edi
LEnter4_8:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch12:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch13:
movb %cl,1(%edi)
addl $0x2,%edi
LEnter2_8:
movb (%esi),%al
movb (%esi,%ebx,),%cl
movb %dh,%ah
addl %ebp,%edx
movb %dh,%ch
leal (%esi,%ebx,2),%esi
movb 0x12345678(%eax),%al
LBPatch14:
addl %ebp,%edx
movb %al,(%edi)
movb 0x12345678(%ecx),%cl
LBPatch15:
movb %cl,1(%edi)
addl $0x2,%edi

420
linux/cd_linux.c Normal file
View File

@ -0,0 +1,420 @@
// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <linux/cdrom.h>
#include "../client/client.h"
static qboolean cdValid = false;
static qboolean playing = false;
static qboolean wasPlaying = false;
static qboolean initialized = false;
static qboolean enabled = true;
static qboolean playLooping = false;
static float cdvolume;
static byte remap[100];
static byte playTrack;
static byte maxTrack;
static int cdfile = -1;
//static char cd_dev[64] = "/dev/cdrom";
cvar_t *cd_volume;
cvar_t *cd_nocd;
cvar_t *cd_dev;
void CDAudio_Pause(void);
static void CDAudio_Eject(void)
{
if (cdfile == -1 || !enabled)
return; // no cd init'd
if ( ioctl(cdfile, CDROMEJECT) == -1 )
Com_DPrintf("ioctl cdromeject failed\n");
}
static void CDAudio_CloseDoor(void)
{
if (cdfile == -1 || !enabled)
return; // no cd init'd
if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
Com_DPrintf("ioctl cdromclosetray failed\n");
}
static int CDAudio_GetAudioDiskInfo(void)
{
struct cdrom_tochdr tochdr;
cdValid = false;
if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
{
Com_DPrintf("ioctl cdromreadtochdr failed\n");
return -1;
}
if (tochdr.cdth_trk0 < 1)
{
Com_DPrintf("CDAudio: no music tracks\n");
return -1;
}
cdValid = true;
maxTrack = tochdr.cdth_trk1;
return 0;
}
void CDAudio_Play(int track, qboolean looping)
{
struct cdrom_tocentry entry;
struct cdrom_ti ti;
if (cdfile == -1 || !enabled)
return;
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
if (!cdValid)
return;
}
track = remap[track];
if (track < 1 || track > maxTrack)
{
Com_DPrintf("CDAudio: Bad track number %u.\n", track);
return;
}
// don't try to play a non-audio track
entry.cdte_track = track;
entry.cdte_format = CDROM_MSF;
if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
{
Com_DPrintf("ioctl cdromreadtocentry failed\n");
return;
}
if (entry.cdte_ctrl == CDROM_DATA_TRACK)
{
Com_Printf("CDAudio: track %i is not audio\n", track);
return;
}
if (playing)
{
if (playTrack == track)
return;
CDAudio_Stop();
}
ti.cdti_trk0 = track;
ti.cdti_trk1 = track;
ti.cdti_ind0 = 1;
ti.cdti_ind1 = 99;
if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
{
Com_DPrintf("ioctl cdromplaytrkind failed\n");
return;
}
if ( ioctl(cdfile, CDROMRESUME) == -1 )
Com_DPrintf("ioctl cdromresume failed\n");
playLooping = looping;
playTrack = track;
playing = true;
if (cd_volume->value == 0.0)
CDAudio_Pause ();
}
void CDAudio_Stop(void)
{
if (cdfile == -1 || !enabled)
return;
if (!playing)
return;
if ( ioctl(cdfile, CDROMSTOP) == -1 )
Com_DPrintf("ioctl cdromstop failed (%d)\n", errno);
wasPlaying = false;
playing = false;
}
void CDAudio_Pause(void)
{
if (cdfile == -1 || !enabled)
return;
if (!playing)
return;
if ( ioctl(cdfile, CDROMPAUSE) == -1 )
Com_DPrintf("ioctl cdrompause failed\n");
wasPlaying = playing;
playing = false;
}
void CDAudio_Resume(void)
{
if (cdfile == -1 || !enabled)
return;
if (!cdValid)
return;
if (!wasPlaying)
return;
if ( ioctl(cdfile, CDROMRESUME) == -1 )
Com_DPrintf("ioctl cdromresume failed\n");
playing = true;
}
static void CD_f (void)
{
char *command;
int ret;
int n;
if (Cmd_Argc() < 2)
return;
command = Cmd_Argv (1);
if (Q_strcasecmp(command, "on") == 0)
{
enabled = true;
return;
}
if (Q_strcasecmp(command, "off") == 0)
{
if (playing)
CDAudio_Stop();
enabled = false;
return;
}
if (Q_strcasecmp(command, "reset") == 0)
{
enabled = true;
if (playing)
CDAudio_Stop();
for (n = 0; n < 100; n++)
remap[n] = n;
CDAudio_GetAudioDiskInfo();
return;
}
if (Q_strcasecmp(command, "remap") == 0)
{
ret = Cmd_Argc() - 2;
if (ret <= 0)
{
for (n = 1; n < 100; n++)
if (remap[n] != n)
Com_Printf(" %u -> %u\n", n, remap[n]);
return;
}
for (n = 1; n <= ret; n++)
remap[n] = atoi(Cmd_Argv (n+1));
return;
}
if (Q_strcasecmp(command, "close") == 0)
{
CDAudio_CloseDoor();
return;
}
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
if (!cdValid)
{
Com_Printf("No CD in player.\n");
return;
}
}
if (Q_strcasecmp(command, "play") == 0)
{
CDAudio_Play((byte)atoi(Cmd_Argv (2)), false);
return;
}
if (Q_strcasecmp(command, "loop") == 0)
{
CDAudio_Play((byte)atoi(Cmd_Argv (2)), true);
return;
}
if (Q_strcasecmp(command, "stop") == 0)
{
CDAudio_Stop();
return;
}
if (Q_strcasecmp(command, "pause") == 0)
{
CDAudio_Pause();
return;
}
if (Q_strcasecmp(command, "resume") == 0)
{
CDAudio_Resume();
return;
}
if (Q_strcasecmp(command, "eject") == 0)
{
if (playing)
CDAudio_Stop();
CDAudio_Eject();
cdValid = false;
return;
}
if (Q_strcasecmp(command, "info") == 0)
{
Com_Printf("%u tracks\n", maxTrack);
if (playing)
Com_Printf("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
else if (wasPlaying)
Com_Printf("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack);
Com_Printf("Volume is %f\n", cdvolume);
return;
}
}
void CDAudio_Update(void)
{
struct cdrom_subchnl subchnl;
static time_t lastchk;
if (cdfile == -1 || !enabled)
return;
if (cd_volume && cd_volume->value != cdvolume)
{
if (cdvolume)
{
Cvar_SetValue ("cd_volume", 0.0);
cdvolume = cd_volume->value;
CDAudio_Pause ();
}
else
{
Cvar_SetValue ("cd_volume", 1.0);
cdvolume = cd_volume->value;
CDAudio_Resume ();
}
}
if (playing && lastchk < time(NULL)) {
lastchk = time(NULL) + 2; //two seconds between chks
subchnl.cdsc_format = CDROM_MSF;
if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
Com_DPrintf("ioctl cdromsubchnl failed\n");
playing = false;
return;
}
if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
playing = false;
if (playLooping)
CDAudio_Play(playTrack, true);
}
}
}
int CDAudio_Init(void)
{
int i;
cvar_t *cv;
extern uid_t saved_euid;
cv = Cvar_Get ("nocdaudio", "0", CVAR_NOSET);
if (cv->value)
return -1;
cd_nocd = Cvar_Get ("cd_nocd", "0", CVAR_ARCHIVE );
if ( cd_nocd->value)
return -1;
cd_volume = Cvar_Get ("cd_volume", "1", CVAR_ARCHIVE);
cd_dev = Cvar_Get("cd_dev", "/dev/cdrom", CVAR_ARCHIVE);
seteuid(saved_euid);
cdfile = open(cd_dev->string, O_RDONLY);
seteuid(getuid());
if (cdfile == -1) {
Com_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev->string, errno);
cdfile = -1;
return -1;
}
for (i = 0; i < 100; i++)
remap[i] = i;
initialized = true;
enabled = true;
if (CDAudio_GetAudioDiskInfo())
{
Com_Printf("CDAudio_Init: No CD in player.\n");
cdValid = false;
}
Cmd_AddCommand ("cd", CD_f);
Com_Printf("CD Audio Initialized\n");
return 0;
}
void CDAudio_Activate (qboolean active)
{
if (active)
CDAudio_Resume ();
else
CDAudio_Pause ();
}
void CDAudio_Shutdown(void)
{
if (!initialized)
return;
CDAudio_Stop();
close(cdfile);
cdfile = -1;
}

147
linux/d_copy.s Normal file
View File

@ -0,0 +1,147 @@
/
// d_copy.s
// x86 assembly-language screen copying code.
//
#include "qasm.h"
.data
LCopyWidth: .long 0
LBlockSrcStep: .long 0
LBlockDestStep: .long 0
LSrcDelta: .long 0
LDestDelta: .long 0
#define bufptr 4+16
// copies 16 rows per plane at a pop; idea is that 16*512 = 8k, and since
// no Mode X mode is wider than 360, all the data should fit in the cache for
// the passes for the next 3 planes
.text
.globl C(VGA_UpdatePlanarScreen)
C(VGA_UpdatePlanarScreen):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables
pushl %ebx
movl C(VGA_bufferrowbytes),%eax
shll $1,%eax
movl %eax,LBlockSrcStep
movl C(VGA_rowbytes),%eax
shll $1,%eax
movl %eax,LBlockDestStep
movl $0x3C4,%edx
movb $2,%al
outb %al,%dx // point the SC to the Map Mask
incl %edx
movl bufptr(%esp),%esi
movl C(VGA_pagebase),%edi
movl C(VGA_height),%ebp
shrl $1,%ebp
movl C(VGA_width),%ecx
movl C(VGA_bufferrowbytes),%eax
subl %ecx,%eax
movl %eax,LSrcDelta
movl C(VGA_rowbytes),%eax
shll $2,%eax
subl %ecx,%eax
movl %eax,LDestDelta
shrl $4,%ecx
movl %ecx,LCopyWidth
LRowLoop:
movb $1,%al
LPlaneLoop:
outb %al,%dx
movb $2,%ah
pushl %esi
pushl %edi
LRowSetLoop:
movl LCopyWidth,%ecx
LColumnLoop:
movb 12(%esi),%bh
movb 8(%esi),%bl
shll $16,%ebx
movb 4(%esi),%bh
movb (%esi),%bl
movl %ebx,(%edi)
addl $16,%esi
addl $4,%edi
decl %ecx
jnz LColumnLoop
addl LDestDelta,%edi
addl LSrcDelta,%esi
decb %ah
jnz LRowSetLoop
popl %edi
popl %esi
incl %esi
shlb $1,%al
cmpb $16,%al
jnz LPlaneLoop
subl $4,%esi
addl LBlockSrcStep,%esi
addl LBlockDestStep,%edi
decl %ebp
jnz LRowLoop
popl %ebx // restore register variables
popl %esi
popl %edi
popl %ebp // restore the caller's stack frame
ret
#define srcptr 4+16
#define destptr 8+16
#define width 12+16
#define height 16+16
#define srcrowbytes 20+16
#define destrowbytes 24+16
.globl C(VGA_UpdateLinearScreen)
C(VGA_UpdateLinearScreen):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables
pushl %ebx
cld
movl srcptr(%esp),%esi
movl destptr(%esp),%edi
movl width(%esp),%ebx
movl srcrowbytes(%esp),%eax
subl %ebx,%eax
movl destrowbytes(%esp),%edx
subl %ebx,%edx
shrl $2,%ebx
movl height(%esp),%ebp
LLRowLoop:
movl %ebx,%ecx
rep/movsl (%esi),(%edi)
addl %eax,%esi
addl %edx,%edi
decl %ebp
jnz LLRowLoop
popl %ebx // restore register variables
popl %esi
popl %edi
popl %ebp // restore the caller's stack frame
ret

79
linux/d_ifacea.h Normal file
View File

@ -0,0 +1,79 @@
//
// d_ifacea.h
//
// Include file for asm driver interface.
//
//
// !!! note that this file must match the corresponding C structures in
// d_iface.h at all times !!!
//
// !!! if this is changed, it must be changed in r_shared.h too !!!
#define ALIAS_ONSEAM 0x0020
// !!! if this is changed, it must be changed in d_iface.h too !!!
#define TURB_TEX_SIZE 64 // base turbulent texture size
// !!! if this is changed, it must be changed in d_iface.h too !!!
#define CYCLE 128
// !!! if this is changed, it must be changed in r_shared.h too !!!
#define MAXHEIGHT 1024
// !!! if this is changed, it must be changed in quakedef.h too !!!
#define CACHE_SIZE 32 // used to align key data structures
// particle_t structure
// !!! if this is changed, it must be changed in d_iface.h too !!!
// driver-usable fields
#define pt_org 0
#define pt_color 12
// drivers never touch the following fields
#define pt_next 16
#define pt_vel 20
#define pt_ramp 32
#define pt_die 36
#define pt_type 40
#define pt_size 44
#define PARTICLE_Z_CLIP 8.0
// finalvert_t structure
// !!! if this is changed, it must be changed in d_iface.h too !!!
#define fv_v 0 // !!! if this is moved, cases where the !!!
// !!! address of this field is pushed in !!!
// !!! d_polysa.s must be changed !!!
#define fv_flags 24
#define fv_reserved 28
#define fv_size 32
#define fv_shift 5
// stvert_t structure
// !!! if this is changed, it must be changed in modelgen.h too !!!
#define stv_onseam 0
#define stv_s 4
#define stv_t 8
#define stv_size 12
// trivertx_t structure
// !!! if this is changed, it must be changed in modelgen.h too !!!
#define tv_v 0
#define tv_lightnormalindex 3
#define tv_size 4
// affinetridesc_t structure
// !!! if this is changed, it must be changed in d_iface.h too !!!
#define atd_pskin 0
#define atd_pskindesc 4
#define atd_skinwidth 8
#define atd_skinheight 12
#define atd_ptriangles 16
#define atd_pfinalverts 20
#define atd_numtriangles 24
#define atd_drawtype 28
#define atd_seamfixupX16 32
#define atd_size 36

1250
linux/d_polysa.s Normal file

File diff suppressed because it is too large Load Diff

206
linux/gl_fxmesa.c Normal file
View File

@ -0,0 +1,206 @@
/*
** GLW_IMP.C
**
** This file contains ALL Linux specific stuff having to do with the
** OpenGL refresh. When a port is being made the following functions
** must be implemented by the port:
**
** GLimp_EndFrame
** GLimp_Init
** GLimp_Shutdown
** GLimp_SwitchFullscreen
**
*/
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/vt.h>
#include <stdarg.h>
#include <stdio.h>
#include <signal.h>
#include "../ref_gl/gl_local.h"
#include "../client/keys.h"
#include "../linux/rw_linux.h"
#include <GL/fxmesa.h>
/*****************************************************************************/
static qboolean GLimp_SwitchFullscreen( int width, int height );
qboolean GLimp_InitGL (void);
extern cvar_t *vid_fullscreen;
extern cvar_t *vid_ref;
static fxMesaContext fc = NULL;
#define NUM_RESOLUTIONS 3
static resolutions[NUM_RESOLUTIONS][3]={
{ 512, 384, GR_RESOLUTION_512x384 },
{ 640, 400, GR_RESOLUTION_640x400 },
{ 640, 480, GR_RESOLUTION_640x480 }
};
static int findres(int *width, int *height)
{
int i;
for(i=0;i<NUM_RESOLUTIONS;i++)
if((*width<=resolutions[i][0]) && (*height<=resolutions[i][1])) {
*width = resolutions[i][0];
*height = resolutions[i][1];
return resolutions[i][2];
}
*width = 640;
*height = 480;
return GR_RESOLUTION_640x480;
}
static void signal_handler(int sig)
{
printf("Received signal %d, exiting...\n", sig);
GLimp_Shutdown();
_exit(0);
}
static void InitSig(void)
{
signal(SIGHUP, signal_handler);
signal(SIGQUIT, signal_handler);
signal(SIGILL, signal_handler);
signal(SIGTRAP, signal_handler);
signal(SIGIOT, signal_handler);
signal(SIGBUS, signal_handler);
signal(SIGFPE, signal_handler);
signal(SIGSEGV, signal_handler);
signal(SIGTERM, signal_handler);
}
/*
** GLimp_SetMode
*/
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
int width, height;
GLint attribs[32];
ri.Con_Printf( PRINT_ALL, "Initializing OpenGL display\n");
ri.Con_Printf (PRINT_ALL, "...setting mode %d:", mode );
if ( !ri.Vid_GetModeInfo( &width, &height, mode ) )
{
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
ri.Con_Printf( PRINT_ALL, " %d %d\n", width, height );
// destroy the existing window
GLimp_Shutdown ();
// set fx attribs
attribs[0] = FXMESA_DOUBLEBUFFER;
attribs[1] = FXMESA_ALPHA_SIZE;
attribs[2] = 1;
attribs[3] = FXMESA_DEPTH_SIZE;
attribs[4] = 1;
attribs[5] = FXMESA_NONE;
fc = fxMesaCreateContext(0, findres(&width, &height), GR_REFRESH_75Hz,
attribs);
if (!fc)
return rserr_invalid_mode;
*pwidth = width;
*pheight = height;
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (width, height);
fxMesaMakeCurrent(fc);
return rserr_ok;
}
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem. Under OpenGL this means NULLing out the current DC and
** HGLRC, deleting the rendering context, and releasing the DC acquired
** for the window. The state structure is also nulled out.
**
*/
void GLimp_Shutdown( void )
{
if (fc) {
fxMesaDestroyContext(fc);
fc = NULL;
}
}
/*
** GLimp_Init
**
** This routine is responsible for initializing the OS specific portions
** of OpenGL.
*/
int GLimp_Init( void *hinstance, void *wndproc )
{
InitSig();
return true;
}
/*
** GLimp_BeginFrame
*/
void GLimp_BeginFrame( float camera_seperation )
{
}
/*
** GLimp_EndFrame
**
** Responsible for doing a swapbuffers and possibly for other stuff
** as yet to be determined. Probably better not to make this a GLimp
** function and instead do a call to GLimp_SwapBuffers.
*/
void GLimp_EndFrame (void)
{
glFlush();
fxMesaSwapBuffers();
}
/*
** GLimp_AppActivate
*/
void GLimp_AppActivate( qboolean active )
{
}
extern void gl3DfxSetPaletteEXT(GLuint *pal);
void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
GLsizei width, GLenum format, GLenum type,
const GLvoid *table )
{
byte temptable[256][4];
byte *intbl;
int i;
for (intbl = (byte *)table, i = 0; i < 256; i++) {
temptable[i][2] = *intbl++;
temptable[i][1] = *intbl++;
temptable[i][0] = *intbl++;
temptable[i][3] = 255;
}
gl3DfxSetPaletteEXT((GLuint *)temptable);
}

164
linux/glob.c Normal file
View File

@ -0,0 +1,164 @@
#include <stdio.h>
#include "../linux/glob.h"
/* Like glob_match, but match PATTERN against any final segment of TEXT. */
static int glob_match_after_star(char *pattern, char *text)
{
register char *p = pattern, *t = text;
register char c, c1;
while ((c = *p++) == '?' || c == '*')
if (c == '?' && *t++ == '\0')
return 0;
if (c == '\0')
return 1;
if (c == '\\')
c1 = *p;
else
c1 = c;
while (1) {
if ((c == '[' || *t == c1) && glob_match(p - 1, t))
return 1;
if (*t++ == '\0')
return 0;
}
}
/* Return nonzero if PATTERN has any special globbing chars in it. */
static int glob_pattern_p(char *pattern)
{
register char *p = pattern;
register char c;
int open = 0;
while ((c = *p++) != '\0')
switch (c) {
case '?':
case '*':
return 1;
case '[': /* Only accept an open brace if there is a close */
open++; /* brace to match it. Bracket expressions must be */
continue; /* complete, according to Posix.2 */
case ']':
if (open)
return 1;
continue;
case '\\':
if (*p++ == '\0')
return 0;
}
return 0;
}
/* Match the pattern PATTERN against the string TEXT;
return 1 if it matches, 0 otherwise.
A match means the entire string TEXT is used up in matching.
In the pattern string, `*' matches any sequence of characters,
`?' matches any character, [SET] matches any character in the specified set,
[!SET] matches any character not in the specified set.
A set is composed of characters or ranges; a range looks like
character hyphen character (as in 0-9 or A-Z).
[0-9a-zA-Z_] is the set of characters allowed in C identifiers.
Any other character in the pattern must be matched exactly.
To suppress the special syntactic significance of any of `[]*?!-\',
and match the character exactly, precede it with a `\'.
*/
int glob_match(char *pattern, char *text)
{
register char *p = pattern, *t = text;
register char c;
while ((c = *p++) != '\0')
switch (c) {
case '?':
if (*t == '\0')
return 0;
else
++t;
break;
case '\\':
if (*p++ != *t++)
return 0;
break;
case '*':
return glob_match_after_star(p, t);
case '[':
{
register char c1 = *t++;
int invert;
if (!c1)
return (0);
invert = ((*p == '!') || (*p == '^'));
if (invert)
p++;
c = *p++;
while (1) {
register char cstart = c, cend = c;
if (c == '\\') {
cstart = *p++;
cend = cstart;
}
if (c == '\0')
return 0;
c = *p++;
if (c == '-' && *p != ']') {
cend = *p++;
if (cend == '\\')
cend = *p++;
if (cend == '\0')
return 0;
c = *p++;
}
if (c1 >= cstart && c1 <= cend)
goto match;
if (c == ']')
break;
}
if (!invert)
return 0;
break;
match:
/* Skip the rest of the [...] construct that already matched. */
while (c != ']') {
if (c == '\0')
return 0;
c = *p++;
if (c == '\0')
return 0;
else if (c == '\\')
++p;
}
if (invert)
return 0;
break;
}
default:
if (c != *t++)
return 0;
}
return *t == '\0';
}

1
linux/glob.h Normal file
View File

@ -0,0 +1 @@
int glob_match(char *pattern, char *text);

29
linux/in_linux.c Normal file
View File

@ -0,0 +1,29 @@
// in_null.c -- for systems without a mouse
#include "../client/client.h"
cvar_t *in_mouse;
cvar_t *in_joystick;
void IN_Init (void)
{
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE);
}
void IN_Shutdown (void)
{
}
void IN_Commands (void)
{
}
void IN_Move (usercmd_t *cmd)
{
}
void IN_Activate (qboolean active)
{
}

403
linux/math.s Normal file
View File

@ -0,0 +1,403 @@
//
// math.s
// x86 assembly-language math routines.
#define GLQUAKE 1 // don't include unneeded defs
#include "qasm.h"
#if id386
.data
#if 0
.align 4
Ljmptab: .long Lcase0, Lcase1, Lcase2, Lcase3
.long Lcase4, Lcase5, Lcase6, Lcase7
#endif
.text
// TODO: rounding needed?
// stack parameter offset
#define val 4
.globl C(Invert24To16)
C(Invert24To16):
movl val(%esp),%ecx
movl $0x100,%edx // 0x10000000000 as dividend
cmpl %edx,%ecx
jle LOutOfRange
subl %eax,%eax
divl %ecx
ret
LOutOfRange:
movl $0xFFFFFFFF,%eax
ret
#define in 4
#define out 8
.align 2
.globl C(TransformVector)
C(TransformVector):
movl in(%esp),%eax
movl out(%esp),%edx
flds (%eax) // in[0]
fmuls C(vright) // in[0]*vright[0]
flds (%eax) // in[0] | in[0]*vright[0]
fmuls C(vup) // in[0]*vup[0] | in[0]*vright[0]
flds (%eax) // in[0] | in[0]*vup[0] | in[0]*vright[0]
fmuls C(vpn) // in[0]*vpn[0] | in[0]*vup[0] | in[0]*vright[0]
flds 4(%eax) // in[1] | ...
fmuls C(vright)+4 // in[1]*vright[1] | ...
flds 4(%eax) // in[1] | in[1]*vright[1] | ...
fmuls C(vup)+4 // in[1]*vup[1] | in[1]*vright[1] | ...
flds 4(%eax) // in[1] | in[1]*vup[1] | in[1]*vright[1] | ...
fmuls C(vpn)+4 // in[1]*vpn[1] | in[1]*vup[1] | in[1]*vright[1] | ...
fxch %st(2) // in[1]*vright[1] | in[1]*vup[1] | in[1]*vpn[1] | ...
faddp %st(0),%st(5) // in[1]*vup[1] | in[1]*vpn[1] | ...
faddp %st(0),%st(3) // in[1]*vpn[1] | ...
faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum
flds 8(%eax) // in[2] | ...
fmuls C(vright)+8 // in[2]*vright[2] | ...
flds 8(%eax) // in[2] | in[2]*vright[2] | ...
fmuls C(vup)+8 // in[2]*vup[2] | in[2]*vright[2] | ...
flds 8(%eax) // in[2] | in[2]*vup[2] | in[2]*vright[2] | ...
fmuls C(vpn)+8 // in[2]*vpn[2] | in[2]*vup[2] | in[2]*vright[2] | ...
fxch %st(2) // in[2]*vright[2] | in[2]*vup[2] | in[2]*vpn[2] | ...
faddp %st(0),%st(5) // in[2]*vup[2] | in[2]*vpn[2] | ...
faddp %st(0),%st(3) // in[2]*vpn[2] | ...
faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum
fstps 8(%edx) // out[2]
fstps 4(%edx) // out[1]
fstps (%edx) // out[0]
ret
#if 0 // in C
#define EMINS 4+4
#define EMAXS 4+8
#define P 4+12
.align 2
.globl C(BoxOnPlaneSide)
C(BoxOnPlaneSide):
pushl %ebx
movl P(%esp),%edx
movl EMINS(%esp),%ecx
xorl %eax,%eax
movl EMAXS(%esp),%ebx
movb pl_signbits(%edx),%al
cmpb $8,%al
jge Lerror
flds pl_normal(%edx) // p->normal[0]
fld %st(0) // p->normal[0] | p->normal[0]
jmp Ljmptab(,%eax,4)
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
Lcase0:
fmuls (%ebx) // p->normal[0]*emaxs[0] | p->normal[0]
flds pl_normal+4(%edx) // p->normal[1] | p->normal[0]*emaxs[0] |
// p->normal[0]
fxch %st(2) // p->normal[0] | p->normal[0]*emaxs[0] |
// p->normal[1]
fmuls (%ecx) // p->normal[0]*emins[0] |
// p->normal[0]*emaxs[0] | p->normal[1]
fxch %st(2) // p->normal[1] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fld %st(0) // p->normal[1] | p->normal[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fmuls 4(%ebx) // p->normal[1]*emaxs[1] | p->normal[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
flds pl_normal+8(%edx) // p->normal[2] | p->normal[1]*emaxs[1] |
// p->normal[1] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fxch %st(2) // p->normal[1] | p->normal[1]*emaxs[1] |
// p->normal[2] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fmuls 4(%ecx) // p->normal[1]*emins[1] |
// p->normal[1]*emaxs[1] |
// p->normal[2] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fxch %st(2) // p->normal[2] | p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fld %st(0) // p->normal[2] | p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fmuls 8(%ebx) // p->normal[2]*emaxs[2] |
// p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fxch %st(5) // p->normal[0]*emins[0] |
// p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
faddp %st(0),%st(3) //p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
fmuls 8(%ecx) //p->normal[2]*emins[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
fxch %st(1) //p->normal[1]*emaxs[1] |
// p->normal[2]*emins[2] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
faddp %st(0),%st(3) //p->normal[2]*emins[2] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|
// p->normal[2]*emaxs[2]
fxch %st(3) //p->normal[2]*emaxs[2] +
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|
// p->normal[2]*emins[2]
faddp %st(0),%st(2) //p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// dist1 | p->normal[2]*emins[2]
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
Lcase1:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ebx) // emaxs[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ecx) // emins[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ebx) // emaxs[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ecx) // emins[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
Lcase2:
fmuls (%ebx) // emaxs[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ecx) // emins[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ebx) // emaxs[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ecx) // emins[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
Lcase3:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ebx) // emaxs[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ecx) // emins[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
Lcase4:
fmuls (%ebx) // emaxs[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ecx) // emins[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ebx) // emaxs[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ecx) // emins[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
Lcase5:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ebx) // emaxs[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ecx) // emins[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
Lcase6:
fmuls (%ebx) // emaxs[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ecx) // emins[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
Lcase7:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
LSetSides:
// sides = 0;
// if (dist1 >= p->dist)
// sides = 1;
// if (dist2 < p->dist)
// sides |= 2;
faddp %st(0),%st(2) // dist1 | dist2
fcomps pl_dist(%edx)
xorl %ecx,%ecx
fnstsw %ax
fcomps pl_dist(%edx)
andb $1,%ah
xorb $1,%ah
addb %ah,%cl
fnstsw %ax
andb $1,%ah
addb %ah,%ah
addb %ah,%cl
// return sides;
popl %ebx
movl %ecx,%eax // return status
ret
Lerror:
call C(BOPS_Error)
#endif
#endif // id386

537
linux/net_udp.c Normal file
View File

@ -0,0 +1,537 @@
// net_wins.c
#include "../qcommon/qcommon.h"
#include <unistd.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <errno.h>
#ifdef NeXT
#include <libc.h>
#endif
netadr_t net_local_adr;
#define LOOPBACK 0x7f000001
#define MAX_LOOPBACK 4
typedef struct
{
byte data[MAX_MSGLEN];
int datalen;
} loopmsg_t;
typedef struct
{
loopmsg_t msgs[MAX_LOOPBACK];
int get, send;
} loopback_t;
loopback_t loopbacks[2];
int ip_sockets[2];
int ipx_sockets[2];
int NET_Socket (char *net_interface, int port);
char *NET_ErrorString (void);
//=============================================================================
void NetadrToSockadr (netadr_t *a, struct sockaddr_in *s)
{
memset (s, 0, sizeof(*s));
if (a->type == NA_BROADCAST)
{
s->sin_family = AF_INET;
s->sin_port = a->port;
*(int *)&s->sin_addr = -1;
}
else if (a->type == NA_IP)
{
s->sin_family = AF_INET;
*(int *)&s->sin_addr = *(int *)&a->ip;
s->sin_port = a->port;
}
}
void SockadrToNetadr (struct sockaddr_in *s, netadr_t *a)
{
*(int *)&a->ip = *(int *)&s->sin_addr;
a->port = s->sin_port;
a->type = NA_IP;
}
qboolean NET_CompareAdr (netadr_t a, netadr_t b)
{
if (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3] && a.port == b.port)
return true;
return false;
}
/*
===================
NET_CompareBaseAdr
Compares without the port
===================
*/
qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b)
{
if (a.type != b.type)
return false;
if (a.type == NA_LOOPBACK)
return true;
if (a.type == NA_IP)
{
if (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3])
return true;
return false;
}
if (a.type == NA_IPX)
{
if ((memcmp(a.ipx, b.ipx, 10) == 0))
return true;
return false;
}
}
char *NET_AdrToString (netadr_t a)
{
static char s[64];
Com_sprintf (s, sizeof(s), "%i.%i.%i.%i:%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3], ntohs(a.port));
return s;
}
char *NET_BaseAdrToString (netadr_t a)
{
static char s[64];
Com_sprintf (s, sizeof(s), "%i.%i.%i.%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3]);
return s;
}
/*
=============
NET_StringToAdr
localhost
idnewt
idnewt:28000
192.246.40.70
192.246.40.70:28000
=============
*/
qboolean NET_StringToSockaddr (char *s, struct sockaddr *sadr)
{
struct hostent *h;
char *colon;
char copy[128];
memset (sadr, 0, sizeof(*sadr));
((struct sockaddr_in *)sadr)->sin_family = AF_INET;
((struct sockaddr_in *)sadr)->sin_port = 0;
strcpy (copy, s);
// strip off a trailing :port if present
for (colon = copy ; *colon ; colon++)
if (*colon == ':')
{
*colon = 0;
((struct sockaddr_in *)sadr)->sin_port = htons((short)atoi(colon+1));
}
if (copy[0] >= '0' && copy[0] <= '9')
{
*(int *)&((struct sockaddr_in *)sadr)->sin_addr = inet_addr(copy);
}
else
{
if (! (h = gethostbyname(copy)) )
return 0;
*(int *)&((struct sockaddr_in *)sadr)->sin_addr = *(int *)h->h_addr_list[0];
}
return true;
}
/*
=============
NET_StringToAdr
localhost
idnewt
idnewt:28000
192.246.40.70
192.246.40.70:28000
=============
*/
qboolean NET_StringToAdr (char *s, netadr_t *a)
{
struct sockaddr_in sadr;
if (!strcmp (s, "localhost"))
{
memset (a, 0, sizeof(*a));
a->type = NA_LOOPBACK;
return true;
}
if (!NET_StringToSockaddr (s, (struct sockaddr *)&sadr))
return false;
SockadrToNetadr (&sadr, a);
return true;
}
qboolean NET_IsLocalAddress (netadr_t adr)
{
return NET_CompareAdr (adr, net_local_adr);
}
/*
=============================================================================
LOOPBACK BUFFERS FOR LOCAL PLAYER
=============================================================================
*/
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message)
{
int i;
loopback_t *loop;
loop = &loopbacks[sock];
if (loop->send - loop->get > MAX_LOOPBACK)
loop->get = loop->send - MAX_LOOPBACK;
if (loop->get >= loop->send)
return false;
i = loop->get & (MAX_LOOPBACK-1);
loop->get++;
memcpy (net_message->data, loop->msgs[i].data, loop->msgs[i].datalen);
net_message->cursize = loop->msgs[i].datalen;
*net_from = net_local_adr;
return true;
}
void NET_SendLoopPacket (netsrc_t sock, int length, void *data, netadr_t to)
{
int i;
loopback_t *loop;
loop = &loopbacks[sock^1];
i = loop->send & (MAX_LOOPBACK-1);
loop->send++;
memcpy (loop->msgs[i].data, data, length);
loop->msgs[i].datalen = length;
}
//=============================================================================
qboolean NET_GetPacket (netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message)
{
int ret;
struct sockaddr_in from;
int fromlen;
int net_socket;
int protocol;
int err;
if (NET_GetLoopPacket (sock, net_from, net_message))
return true;
for (protocol = 0 ; protocol < 2 ; protocol++)
{
if (protocol == 0)
net_socket = ip_sockets[sock];
else
net_socket = ipx_sockets[sock];
if (!net_socket)
continue;
fromlen = sizeof(from);
ret = recvfrom (net_socket, net_message->data, net_message->maxsize
, 0, (struct sockaddr *)&from, &fromlen);
if (ret == -1)
{
err = errno;
if (err == EWOULDBLOCK || err == ECONNREFUSED)
continue;
Com_Printf ("NET_GetPacket: %s", NET_ErrorString());
continue;
}
if (ret == net_message->maxsize)
{
Com_Printf ("Oversize packet from %s\n", NET_AdrToString (*net_from));
continue;
}
net_message->cursize = ret;
SockadrToNetadr (&from, net_from);
return true;
}
return false;
}
//=============================================================================
void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to)
{
int ret;
struct sockaddr_in addr;
int net_socket;
if ( to.type == NA_LOOPBACK )
{
NET_SendLoopPacket (sock, length, data, to);
return;
}
if (to.type == NA_BROADCAST)
{
net_socket = ip_sockets[sock];
if (!net_socket)
return;
}
else if (to.type == NA_IP)
{
net_socket = ip_sockets[sock];
if (!net_socket)
return;
}
else if (to.type == NA_IPX)
{
net_socket = ipx_sockets[sock];
if (!net_socket)
return;
}
else if (to.type == NA_BROADCAST_IPX)
{
net_socket = ipx_sockets[sock];
if (!net_socket)
return;
}
else
Com_Error (ERR_FATAL, "NET_SendPacket: bad address type");
NetadrToSockadr (&to, &addr);
ret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );
if (ret == -1)
{
Com_Printf ("NET_SendPacket ERROR: %i\n", NET_ErrorString());
}
}
//=============================================================================
/*
====================
NET_OpenIP
====================
*/
void NET_OpenIP (void)
{
cvar_t *port, *ip;
port = Cvar_Get ("port", va("%i", PORT_SERVER), CVAR_NOSET);
ip = Cvar_Get ("ip", "localhost", CVAR_NOSET);
if (!ip_sockets[NS_SERVER])
ip_sockets[NS_SERVER] = NET_Socket (ip->string, port->value);
if (!ip_sockets[NS_CLIENT])
ip_sockets[NS_CLIENT] = NET_Socket (ip->string, PORT_ANY);
}
/*
====================
NET_OpenIPX
====================
*/
void NET_OpenIPX (void)
{
}
/*
====================
NET_Config
A single player game will only use the loopback code
====================
*/
void NET_Config (qboolean multiplayer)
{
int i;
if (!multiplayer)
{ // shut down any existing sockets
for (i=0 ; i<2 ; i++)
{
if (ip_sockets[i])
{
close (ip_sockets[i]);
ip_sockets[i] = 0;
}
if (ipx_sockets[i])
{
close (ipx_sockets[i]);
ipx_sockets[i] = 0;
}
}
}
else
{ // open sockets
NET_OpenIP ();
NET_OpenIPX ();
}
}
//===================================================================
/*
====================
NET_Init
====================
*/
void NET_Init (void)
{
}
/*
====================
NET_Socket
====================
*/
int NET_Socket (char *net_interface, int port)
{
int newsocket;
struct sockaddr_in address;
qboolean _true = true;
int i = 1;
if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
{
Com_Printf ("ERROR: UDP_OpenSocket: socket:", NET_ErrorString());
return 0;
}
// make it non-blocking
if (ioctl (newsocket, FIONBIO, &_true) == -1)
{
Com_Printf ("ERROR: UDP_OpenSocket: ioctl FIONBIO:%s\n", NET_ErrorString());
return 0;
}
// make it broadcast capable
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
{
Com_Printf ("ERROR: UDP_OpenSocket: setsockopt SO_BROADCAST:%s\n", NET_ErrorString());
return 0;
}
if (!net_interface || !net_interface[0] || !stricmp(net_interface, "localhost"))
address.sin_addr.s_addr = INADDR_ANY;
else
NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);
if (port == PORT_ANY)
address.sin_port = 0;
else
address.sin_port = htons((short)port);
address.sin_family = AF_INET;
if( bind (newsocket, (void *)&address, sizeof(address)) == -1)
{
Com_Printf ("ERROR: UDP_OpenSocket: bind: %s\n", NET_ErrorString());
close (newsocket);
return 0;
}
return newsocket;
}
/*
====================
NET_Shutdown
====================
*/
void NET_Shutdown (void)
{
NET_Config (false); // close sockets
}
/*
====================
NET_ErrorString
====================
*/
char *NET_ErrorString (void)
{
int code;
code = errno;
return strerror (code);
}
// sleeps msec or until net socket is ready
void NET_Sleep(int msec)
{
struct timeval timeout;
fd_set fdset;
extern cvar_t *dedicated;
extern qboolean stdin_active;
if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated->value))
return; // we're not a server, just run full speed
FD_ZERO(&fdset);
if (stdin_active)
FD_SET(0, &fdset); // stdin is processed too
FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket
timeout.tv_sec = msec/1000;
timeout.tv_usec = (msec%1000)*1000;
select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, &timeout);
}