From e6879b8ae1ad38884f6a2bb1d0e8c5a0ecc173be Mon Sep 17 00:00:00 2001 From: meep-eep Date: Sat, 22 Jan 2005 01:08:12 +0000 Subject: [PATCH] Big patch with header file restructuring, cleanups, and some added comments. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1479 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/msvc++/UrQuanMasters.dsp | 63 +- sc2/src/options.c | 19 +- sc2/src/options.h | 1 + sc2/src/sc2code/Makeinfo | 17 +- sc2/src/sc2code/battle.c | 13 +- sc2/src/sc2code/battle.h | 29 + sc2/src/sc2code/border.c | 10 +- sc2/src/sc2code/build.c | 8 +- sc2/src/sc2code/build.h | 4 + sc2/src/sc2code/cleanup.c | 16 +- sc2/src/sc2code/clock.c | 9 +- sc2/src/sc2code/clock.h | 26 +- sc2/src/sc2code/collide.c | 6 +- sc2/src/sc2code/colors.h | 53 ++ sc2/src/sc2code/comm.c | 29 +- sc2/src/sc2code/comm.h | 9 +- sc2/src/sc2code/comm/arilou/arilouc.c | 7 +- sc2/src/sc2code/comm/blackur/blackurc.c | 4 +- sc2/src/sc2code/comm/chmmr/chmmrc.c | 7 +- sc2/src/sc2code/comm/comandr/comandr.c | 5 +- sc2/src/sc2code/comm/commall.h | 27 + sc2/src/sc2code/comm/druuge/druugec.c | 8 +- sc2/src/sc2code/comm/ilwrath/ilwrathc.c | 7 +- sc2/src/sc2code/comm/melnorm/melnorm.c | 10 +- sc2/src/sc2code/comm/mycon/myconc.c | 8 +- sc2/src/sc2code/comm/orz/orzc.c | 6 +- sc2/src/sc2code/comm/pkunk/pkunkc.c | 8 +- sc2/src/sc2code/comm/rebel/rebel.c | 7 +- sc2/src/sc2code/comm/shofixt/shofixt.c | 7 +- sc2/src/sc2code/comm/slyhome/slyhome.c | 6 +- sc2/src/sc2code/comm/slyland/slyland.c | 10 +- sc2/src/sc2code/comm/spahome/spahome.c | 8 +- sc2/src/sc2code/comm/spathi/spathic.c | 7 +- sc2/src/sc2code/comm/starbas/starbas.c | 11 +- sc2/src/sc2code/comm/supox/supoxc.c | 7 +- sc2/src/sc2code/comm/syreen/syreenc.c | 7 +- sc2/src/sc2code/comm/talkpet/talkpet.c | 7 +- sc2/src/sc2code/comm/thradd/thraddc.c | 8 +- sc2/src/sc2code/comm/umgah/umgahc.c | 7 +- sc2/src/sc2code/comm/urquan/urquanc.c | 4 +- sc2/src/sc2code/comm/utwig/utwigc.c | 8 +- sc2/src/sc2code/comm/vux/vuxc.c | 4 +- sc2/src/sc2code/comm/yehat/yehatc.c | 9 +- sc2/src/sc2code/comm/zoqfot/zoqfotc.c | 8 +- sc2/src/sc2code/commglue.c | 4 +- sc2/src/sc2code/commglue.h | 3 + sc2/src/sc2code/confirm.c | 11 +- sc2/src/sc2code/controls.h | 14 +- sc2/src/sc2code/credits.c | 14 +- sc2/src/sc2code/credits.h | 7 +- sc2/src/sc2code/cyborg.c | 11 +- sc2/src/sc2code/dummy.c | 11 +- sc2/src/sc2code/dummy.h | 31 + sc2/src/sc2code/element.h | 10 +- sc2/src/sc2code/encount.c | 21 +- sc2/src/sc2code/encount.h | 8 + sc2/src/sc2code/fmv.c | 15 +- sc2/src/sc2code/fmv.h | 29 + sc2/src/sc2code/galaxy.c | 9 +- sc2/src/sc2code/gameev.c | 728 ++++++++++++++++ sc2/src/sc2code/gameev.h | 58 ++ sc2/src/sc2code/gameinp.c | 10 +- sc2/src/sc2code/gameopt.c | 20 +- sc2/src/sc2code/gamestr.h | 52 ++ sc2/src/sc2code/gendef.c | 2 +- sc2/src/sc2code/getchar.c | 3 +- sc2/src/sc2code/globdata.c | 29 +- sc2/src/sc2code/globdata.h | 35 +- sc2/src/sc2code/gravity.c | 4 +- sc2/src/sc2code/gravwell.c | 4 +- sc2/src/sc2code/grpinfo.c | 13 +- sc2/src/sc2code/hyper.c | 66 +- sc2/src/sc2code/hyper.h | 3 +- sc2/src/sc2code/init.c | 57 +- sc2/src/sc2code/init.h | 29 + sc2/src/sc2code/intel.c | 6 +- sc2/src/sc2code/intel.h | 15 + sc2/src/sc2code/intro.c | 74 +- sc2/src/sc2code/ipdisp.c | 28 +- sc2/src/sc2code/libs/Makeinfo | 4 + sc2/src/sc2code/libs/compiler.h | 2 + sc2/src/sc2code/libs/decomp/lzencode.c | 6 +- sc2/src/sc2code/libs/gfxlib.h | 10 + sc2/src/sc2code/libs/graphics/cmap.c | 2 + sc2/src/sc2code/libs/graphics/filegfx.c | 2 +- sc2/src/sc2code/libs/graphics/font.c | 4 +- sc2/src/sc2code/libs/graphics/gfx_common.h | 1 - sc2/src/sc2code/libs/graphics/sdl/2xscalers.c | 2 + sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c | 2 + sc2/src/sc2code/libs/graphics/sdl/canvas.c | 1 + sc2/src/sc2code/libs/graphics/sdl/dcqueue.c | 22 +- sc2/src/sc2code/libs/graphics/sdl/dcqueue.h | 4 + .../sc2code/libs/graphics/sdl/sdl_common.c | 62 +- sc2/src/sc2code/libs/graphics/tfb_draw.c | 59 +- sc2/src/sc2code/libs/graphics/tfb_draw.h | 3 + sc2/src/sc2code/libs/graphics/widgets.c | 2 +- sc2/src/sc2code/libs/input/input_common.c | 1 + sc2/src/sc2code/libs/misc.h | 3 + sc2/src/sc2code/libs/resource/getres.c | 3 +- sc2/src/sc2code/libs/resource/resinit.c | 2 +- sc2/src/sc2code/libs/sndlib.h | 3 - sc2/src/sc2code/libs/sound/decoders/dukaud.c | 2 +- .../sound/mixer/nosound/audiodrv_nosound.c | 3 + .../libs/sound/mixer/sdl/audiodrv_sdl.c | 3 + sc2/src/sc2code/libs/sound/sound.c | 2 + sc2/src/sc2code/libs/sound/sound.h | 3 +- sc2/src/sc2code/libs/sound/stream.c | 119 ++- sc2/src/sc2code/libs/sound/trackplayer.c | 7 +- sc2/src/sc2code/libs/sound/trackplayer.h | 3 + sc2/src/sc2code/libs/uio/uiostream.c | 2 +- sc2/src/sc2code/libs/video/video.c | 3 + sc2/src/sc2code/libs/video/video.h | 4 +- sc2/src/sc2code/libs/video/vidplayer.c | 8 +- sc2/src/sc2code/load.c | 12 +- sc2/src/sc2code/loadship.c | 6 +- sc2/src/sc2code/master.c | 5 +- sc2/src/sc2code/melee.c | 193 ++-- sc2/src/sc2code/melee.h | 4 + sc2/src/sc2code/menu.c | 7 +- sc2/src/sc2code/misc.c | 9 +- sc2/src/sc2code/nameref.h | 14 +- sc2/src/sc2code/oscill.c | 1 + sc2/src/sc2code/outfit.c | 51 +- sc2/src/sc2code/pickmele.c | 11 +- sc2/src/sc2code/pickship.c | 9 +- sc2/src/sc2code/plandata.c | 4 +- sc2/src/sc2code/planets/calc.c | 3 +- sc2/src/sc2code/planets/cargo.c | 9 +- sc2/src/sc2code/planets/devices.c | 10 +- sc2/src/sc2code/planets/elemdata.h | 3 + sc2/src/sc2code/planets/genall.h | 25 + sc2/src/sc2code/planets/genburv.c | 19 +- sc2/src/sc2code/planets/genchmmr.c | 18 +- sc2/src/sc2code/planets/gencol.c | 6 +- sc2/src/sc2code/planets/gendru.c | 10 +- sc2/src/sc2code/planets/genilw.c | 10 +- sc2/src/sc2code/planets/genmel.c | 8 +- sc2/src/sc2code/planets/genmyc.c | 11 +- sc2/src/sc2code/planets/genorz.c | 12 +- sc2/src/sc2code/planets/genpet.c | 11 +- sc2/src/sc2code/planets/genpku.c | 10 +- sc2/src/sc2code/planets/genrain.c | 5 +- sc2/src/sc2code/planets/gensam.c | 10 +- sc2/src/sc2code/planets/genshof.c | 13 +- sc2/src/sc2code/planets/gensly.c | 5 +- sc2/src/sc2code/planets/gensol.c | 13 +- sc2/src/sc2code/planets/genspa.c | 10 +- sc2/src/sc2code/planets/gensup.c | 9 +- sc2/src/sc2code/planets/gensyr.c | 5 +- sc2/src/sc2code/planets/genthrad.c | 11 +- sc2/src/sc2code/planets/genutw.c | 10 +- sc2/src/sc2code/planets/genvault.c | 9 +- sc2/src/sc2code/planets/genvux.c | 12 +- sc2/src/sc2code/planets/genwreck.c | 7 +- sc2/src/sc2code/planets/genyeh.c | 10 +- sc2/src/sc2code/planets/genzoq.c | 10 +- sc2/src/sc2code/planets/lander.c | 12 +- sc2/src/sc2code/planets/lander.h | 6 + sc2/src/sc2code/planets/lifeform.h | 3 + sc2/src/sc2code/planets/orbits.c | 6 +- sc2/src/sc2code/planets/oval.c | 8 +- sc2/src/sc2code/planets/pl_stuff.c | 6 +- sc2/src/sc2code/planets/plandata.h | 3 + sc2/src/sc2code/planets/planets.c | 5 +- sc2/src/sc2code/planets/planets.h | 3 + sc2/src/sc2code/planets/plangen.c | 160 ++-- sc2/src/sc2code/planets/pstarmap.c | 17 +- sc2/src/sc2code/planets/report.c | 19 +- sc2/src/sc2code/planets/roster.c | 89 +- sc2/src/sc2code/planets/scan.c | 21 +- sc2/src/sc2code/planets/scan.h | 3 + sc2/src/sc2code/planets/solarsys.c | 328 ++++--- sc2/src/sc2code/planets/sundata.h | 4 + sc2/src/sc2code/planets/surface.c | 4 +- sc2/src/sc2code/process.c | 172 +--- sc2/src/sc2code/races.h | 5 + sc2/src/sc2code/restart.c | 17 +- sc2/src/sc2code/save.c | 18 +- sc2/src/sc2code/settings.c | 6 +- sc2/src/sc2code/settings.h | 35 + sc2/src/sc2code/setup.c | 172 ++-- sc2/src/sc2code/setup.h | 64 ++ sc2/src/sc2code/setupmenu.c | 5 +- sc2/src/sc2code/ship.c | 10 +- sc2/src/sc2code/ships/androsyn/androsyn.c | 3 + sc2/src/sc2code/ships/arilou/arilou.c | 3 + sc2/src/sc2code/ships/blackurq/blackurq.c | 3 + sc2/src/sc2code/ships/chenjesu/chenjesu.c | 4 + sc2/src/sc2code/ships/chmmr/chmmr.c | 5 + sc2/src/sc2code/ships/human/human.c | 4 + sc2/src/sc2code/ships/ilwrath/ilwrath.c | 4 + sc2/src/sc2code/ships/lastbat/lastbat.c | 6 + sc2/src/sc2code/ships/melnorme/melnorme.c | 4 + sc2/src/sc2code/ships/mmrnmhrm/mmrnmhrm.c | 3 + sc2/src/sc2code/ships/orz/orz.c | 5 + sc2/src/sc2code/ships/pkunk/pkunk.c | 4 + sc2/src/sc2code/ships/ship.h | 9 +- sc2/src/sc2code/ships/shofixti/shofixti.c | 4 + sc2/src/sc2code/ships/sis_ship/sis_ship.c | 5 + sc2/src/sc2code/ships/slylandr/slylandr.c | 4 + sc2/src/sc2code/ships/supox/supox.c | 3 + sc2/src/sc2code/ships/syreen/syreen.c | 3 + sc2/src/sc2code/ships/thradd/thradd.c | 3 + sc2/src/sc2code/ships/umgah/umgah.c | 3 + sc2/src/sc2code/ships/urquan/urquan.c | 5 + sc2/src/sc2code/ships/utwig/utwig.c | 4 + sc2/src/sc2code/ships/vux/vux.c | 6 +- sc2/src/sc2code/ships/yehat/yehat.c | 3 + sc2/src/sc2code/ships/zoqfot/zoqfot.c | 3 + sc2/src/sc2code/shipstat.c | 7 +- sc2/src/sc2code/shipyard.c | 24 +- sc2/src/sc2code/sis.c | 12 +- sc2/src/sc2code/sis.h | 3 + sc2/src/sc2code/sounds.c | 200 +++++ sc2/src/sc2code/sounds.h | 37 + sc2/src/sc2code/starbase.c | 14 +- sc2/src/sc2code/starbase.h | 8 + sc2/src/sc2code/starcon.c | 821 +----------------- sc2/src/sc2code/starcon.h | 239 ----- sc2/src/sc2code/starmap.c | 7 +- sc2/src/sc2code/state.c | 6 +- sc2/src/sc2code/state.h | 4 +- sc2/src/sc2code/status.c | 9 +- sc2/src/sc2code/strtemp.h | 45 + sc2/src/sc2code/tactrans.c | 45 +- sc2/src/sc2code/trans.c | 4 +- sc2/src/sc2code/units.h | 27 + sc2/src/sc2code/uqmdebug.c | 14 +- sc2/src/sc2code/uqmdebug.h | 7 + sc2/src/sc2code/util.c | 8 +- sc2/src/sc2code/util.h | 30 + sc2/src/sc2code/velocity.c | 6 +- sc2/src/sc2code/weapon.c | 14 +- sc2/src/sc2code/weapon.h | 3 + sc2/src/starcon2.c | 4 +- 236 files changed, 3562 insertions(+), 2298 deletions(-) create mode 100644 sc2/src/sc2code/battle.h create mode 100644 sc2/src/sc2code/colors.h create mode 100644 sc2/src/sc2code/comm/commall.h create mode 100644 sc2/src/sc2code/dummy.h create mode 100644 sc2/src/sc2code/fmv.h create mode 100644 sc2/src/sc2code/gameev.c create mode 100644 sc2/src/sc2code/gameev.h create mode 100644 sc2/src/sc2code/gamestr.h create mode 100644 sc2/src/sc2code/init.h create mode 100644 sc2/src/sc2code/planets/genall.h create mode 100644 sc2/src/sc2code/settings.h create mode 100644 sc2/src/sc2code/setup.h create mode 100644 sc2/src/sc2code/sounds.c delete mode 100644 sc2/src/sc2code/starcon.h create mode 100644 sc2/src/sc2code/strtemp.h create mode 100644 sc2/src/sc2code/util.h diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 48c5223f6..334b21e5c 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.4: +- Massive amount of file restructuring and cleanups. Need many more. - SvdB - Added Intro and Ending slide shows (bug #46); use "-i pc" -Alex - Cross-fades in OpenGL mode with complex scalers fixed (bug #674) -Alex - Added doc/devel/dialogs - SvdB diff --git a/sc2/src/msvc++/UrQuanMasters.dsp b/sc2/src/msvc++/UrQuanMasters.dsp index 781dccb19..fe3dadae7 100644 --- a/sc2/src/msvc++/UrQuanMasters.dsp +++ b/sc2/src/msvc++/UrQuanMasters.dsp @@ -1228,6 +1228,10 @@ SOURCE=..\sc2code\comm\comandr\restypes.h SOURCE=..\sc2code\comm\comandr\strings.h # End Source File # End Group +# Begin Source File + +SOURCE=..\sc2code\comm\commall.h +# End Source File # Begin Group "druuge.comm" # PROP Default_Filter "" @@ -2010,6 +2014,10 @@ SOURCE=..\sc2code\planets\elemdata.h # End Source File # Begin Source File +SOURCE=..\sc2code\planets\genall.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\planets\genburv.c # End Source File # Begin Source File @@ -3203,6 +3211,10 @@ SOURCE=..\sc2code\battle.c # End Source File # Begin Source File +SOURCE=..\sc2code\battle.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\border.c # End Source File # Begin Source File @@ -3239,6 +3251,9 @@ SOURCE=..\sc2code\collide.h # End Source File # Begin Source File +SOURCE=..\sc2code\colors.h +# Begin Source File + SOURCE=..\sc2code\comm.c # End Source File # Begin Source File @@ -3291,6 +3306,10 @@ SOURCE=..\sc2code\dummy.c # End Source File # Begin Source File +SOURCE=..\sc2code\dummy.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\element.h # End Source File # Begin Source File @@ -3307,10 +3326,22 @@ SOURCE=..\sc2code\fmv.c # End Source File # Begin Source File +SOURCE=..\sc2code\fmv.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\galaxy.c # End Source File # Begin Source File +SOURCE=..\sc2code\gameev.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\gameev.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\gameinp.c # End Source File # Begin Source File @@ -3319,6 +3350,10 @@ SOURCE=..\sc2code\gameopt.c # End Source File # Begin Source File +SOURCE=..\sc2code\gamestr.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\gendef.c # End Source File # Begin Source File @@ -3367,6 +3402,10 @@ SOURCE=..\sc2code\init.c # End Source File # Begin Source File +SOURCE=..\sc2code\init.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\intel.c # End Source File # Begin Source File @@ -3479,10 +3518,18 @@ SOURCE=..\sc2code\settings.c # End Source File # Begin Source File +SOURCE=..\sc2code\settings.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\setup.c # End Source File # Begin Source File +SOURCE=..\sc2code\setup.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\setupmenu.c # End Source File # Begin Source File @@ -3511,6 +3558,10 @@ SOURCE=..\sc2code\sis.h # End Source File # Begin Source File +SOURCE=..\sc2code\sounds.c +# End Source File +# Begin Source File + SOURCE=..\sc2code\sounds.h # End Source File # Begin Source File @@ -3519,6 +3570,10 @@ SOURCE=..\sc2code\starbase.c # End Source File # Begin Source File +SOURCE=..\sc2code\strtemp.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\starbase.h # End Source File # Begin Source File @@ -3527,10 +3582,6 @@ SOURCE=..\sc2code\starcon.c # End Source File # Begin Source File -SOURCE=..\sc2code\starcon.h -# End Source File -# Begin Source File - SOURCE=..\sc2code\starmap.c # End Source File # Begin Source File @@ -3571,6 +3622,10 @@ SOURCE=..\sc2code\util.c # End Source File # Begin Source File +SOURCE=..\sc2code\util.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\velocity.c # End Source File # Begin Source File diff --git a/sc2/src/options.c b/sc2/src/options.c index 7aa879581..cfea7050d 100644 --- a/sc2/src/options.c +++ b/sc2/src/options.c @@ -19,19 +19,22 @@ * for now there's few options which indicate 3do/pc flavors. */ +#include "options.h" + +#include "port.h" +#include "libs/graphics/gfx_common.h" +#include "file.h" +#include "config.h" +#include "libs/compiler.h" +#include "libs/uio.h" +#include "libs/strlib.h" + #include #include #include #include #include -#include "port.h" -#include "libs/graphics/gfx_common.h" -#include "compiler.h" -#include "options.h" -#include "file.h" -#include "config.h" -#include "libs/uio.h" -#include "libs/strlib.h" + int optWhichMusic; int optWhichCoarseScan; diff --git a/sc2/src/options.h b/sc2/src/options.h index 625cee1b0..0b3784474 100644 --- a/sc2/src/options.h +++ b/sc2/src/options.h @@ -23,6 +23,7 @@ #define OPTIONS_H #include "port.h" +#include "libs/compiler.h" #include "libs/uio.h" #define OPT_3DO 0x01 diff --git a/sc2/src/sc2code/Makeinfo b/sc2/src/sc2code/Makeinfo index 531cd7dce..f4418a12c 100644 --- a/sc2/src/sc2code/Makeinfo +++ b/sc2/src/sc2code/Makeinfo @@ -1,14 +1,13 @@ uqm_SUBDIRS="comm libs planets ships" uqm_CFILES="battle.c border.c build.c cleanup.c clock.c collide.c comm.c - commglue.c confirm.c credits.c cyborg.c demo.c displist.c - dummy.c encount.c fmv.c galaxy.c gameinp.c gameopt.c - gendef.c getchar.c globdata.c gravity.c gravwell.c grpinfo.c - hyper.c init.c intel.c intro.c ipdisp.c load.c loadship.c - master.c melee.c menu.c misc.c oscill.c outfit.c pickmele.c - pickship.c plandata.c process.c restart.c save.c settings.c - setup.c setupmenu.c ship.c shipstat.c shipyard.c sis.c starbase.c - starcon.c starmap.c state.c status.c tactrans.c - trans.c util.c velocity.c weapon.c" + commglue.c confirm.c credits.c cyborg.c demo.c displist.c dummy.c + encount.c fmv.c galaxy.c gameev.c gameinp.c gameopt.c gendef.c + getchar.c globdata.c gravity.c gravwell.c grpinfo.c hyper.c init.c + intel.c intro.c ipdisp.c load.c loadship.c master.c melee.c menu.c + misc.c oscill.c outfit.c pickmele.c pickship.c plandata.c process.c + restart.c save.c settings.c setup.c setupmenu.c ship.c shipstat.c + shipyard.c sis.c sounds.c starbase.c starcon.c starmap.c state.c + status.c tactrans.c trans.c uqmdebug.c util.c velocity.c weapon.c" if [ "$DEBUG" = 1 ]; then uqm_CFILES="$uqm_CFILES uqmdebug.c" diff --git a/sc2/src/sc2code/battle.c b/sc2/src/sc2code/battle.c index 93f01f3e1..31fc84826 100644 --- a/sc2/src/sc2code/battle.c +++ b/sc2/src/sc2code/battle.c @@ -16,9 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "libs/graphics/gfx_common.h" -//#include "starcon.h" +#include "battle.h" + #include "controls.h" +#include "init.h" +#include "intel.h" +#include "resinst.h" +#include "setup.h" +#include "settings.h" +#include "sounds.h" +#include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" + QUEUE disp_q; SIZE battle_counter; diff --git a/sc2/src/sc2code/battle.h b/sc2/src/sc2code/battle.h new file mode 100644 index 000000000..21b771f18 --- /dev/null +++ b/sc2/src/sc2code/battle.h @@ -0,0 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _BATTLE_H +#define _BATTLE_H + +#include "libs/compiler.h" +#include "displist.h" + +extern QUEUE disp_q; +extern SIZE battle_counter; +extern BOOLEAN instantVictory; + +extern BOOLEAN Battle (void); + +#endif /* _BATTLE_H */ + diff --git a/sc2/src/sc2code/border.c b/sc2/src/sc2code/border.c index 4d2607962..ba66fa429 100644 --- a/sc2/src/sc2code/border.c +++ b/sc2/src/sc2code/border.c @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" + +#include "libs/gfxlib.h" +#include "libs/threadlib.h" +#include "colors.h" +#include "setup.h" +#include "sis.h" +#include "units.h" +#include "util.h" + void InitSISContexts (void) diff --git a/sc2/src/sc2code/build.c b/sc2/src/sc2code/build.c index 4fa8a8900..9c7fd5c26 100644 --- a/sc2/src/sc2code/build.c +++ b/sc2/src/sc2code/build.c @@ -16,7 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" + +#include "races.h" +#include "setup.h" +#include "libs/compiler.h" +#include "libs/mathlib.h" + HSTARSHIP Build (PQUEUE pQueue, DWORD RaceResIndex, COUNT which_player, BYTE diff --git a/sc2/src/sc2code/build.h b/sc2/src/sc2code/build.h index 771d503b3..88055319a 100644 --- a/sc2/src/sc2code/build.h +++ b/sc2/src/sc2code/build.h @@ -19,6 +19,10 @@ #ifndef _BUILD_H #define _BUILD_H +#include "races.h" +#include "displist.h" +#include "libs/compiler.h" + #define CREW_XOFFS 4 #define ENERGY_XOFFS 52 #define GAUGE_YOFFS (SHIP_INFO_HEIGHT - 10) diff --git a/sc2/src/sc2code/cleanup.c b/sc2/src/sc2code/cleanup.c index bc2323336..2b427baca 100644 --- a/sc2/src/sc2code/cleanup.c +++ b/sc2/src/sc2code/cleanup.c @@ -16,7 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "battle.h" +#include "nameref.h" +#include "reslib.h" +#include "gamestr.h" +#include "setup.h" +#include "sounds.h" +#include "libs/sndlib.h" #include "libs/vidlib.h" //Added by Chris @@ -35,6 +41,10 @@ void FreeHyperData (void); //End Added by Chris +static void UninitContexts (void); +static void UninitKernel (BOOLEAN ships); + + void FreeKernel (void) { @@ -56,7 +66,7 @@ FreeKernel (void) UninitGraphics (); } -void +static void UninitContexts (void) { UninitQueue (&disp_q); @@ -66,7 +76,7 @@ UninitContexts (void) DestroyContext (ReleaseContext (StatusContext)); } -void +static void UninitKernel (BOOLEAN ships) { extern FRAME status; diff --git a/sc2/src/sc2code/clock.c b/sc2/src/sc2code/clock.c index 6f0f66e1d..618014d98 100644 --- a/sc2/src/sc2code/clock.c +++ b/sc2/src/sc2code/clock.c @@ -16,7 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "gameev.h" +#include "globdata.h" +#include "setup.h" +#include "libs/compiler.h" +#include "libs/gfxlib.h" +#include "libs/tasklib.h" +#include "libs/threadlib.h" + // the running of the game-clock is based on game framerates // *not* on the system (or translated) timer diff --git a/sc2/src/sc2code/clock.h b/sc2/src/sc2code/clock.h index e69ec07cb..cd439837b 100644 --- a/sc2/src/sc2code/clock.h +++ b/sc2/src/sc2code/clock.h @@ -20,33 +20,11 @@ #define _CLOCK_H #include "libs/tasklib.h" +#include "displist.h" + #define START_YEAR 2155 -enum -{ - ARILOU_ENTRANCE_EVENT = 0, - ARILOU_EXIT_EVENT, - HYPERSPACE_ENCOUNTER_EVENT, - KOHR_AH_VICTORIOUS_EVENT, - ADVANCE_PKUNK_MISSION, - ADVANCE_THRADD_MISSION, - ZOQFOT_DISTRESS_EVENT, - ZOQFOT_DEATH_EVENT, - SHOFIXTI_RETURN_EVENT, - ADVANCE_UTWIG_SUPOX_MISSION, - KOHR_AH_GENOCIDE_EVENT, - SPATHI_SHIELD_EVENT, - ADVANCE_ILWRATH_MISSION, - ADVANCE_MYCON_MISSION, - ARILOU_UMGAH_CHECK, - YEHAT_REBEL_EVENT, - SLYLANDRO_RAMP_UP, - SLYLANDRO_RAMP_DOWN, - - NUM_EVENTS -}; - #define UPDATE_DAY (1 << 0) #define UPDATE_MONTH (1 << 1) #define UPDATE_YEAR (1 << 2) diff --git a/sc2/src/sc2code/collide.c b/sc2/src/sc2code/collide.c index 10fdb05e0..80e7ff300 100644 --- a/sc2/src/sc2code/collide.c +++ b/sc2/src/sc2code/collide.c @@ -16,8 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "collide.h" +#include "element.h" +#include "races.h" +#include "units.h" +#include "libs/mathlib.h" + //#define DEBUG_COLLIDE diff --git a/sc2/src/sc2code/colors.h b/sc2/src/sc2code/colors.h new file mode 100644 index 000000000..711c684bc --- /dev/null +++ b/sc2/src/sc2code/colors.h @@ -0,0 +1,53 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef _COLORS_H +#define _COLORS_H + + +#define BLACK_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) +#define LTGRAY_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x07) +#define DKGRAY_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) +#define WHITE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) + +#define NORMAL_ILLUMINATED_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) +#define NORMAL_SHADOWED_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) +#define HIGHLIGHT_ILLUMINATED_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) +#define HIGHLIGHT_SHADOWED_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) +#define MENU_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x07) +#define MENU_FOREGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) +#define MENU_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) +#define MENU_HIGHLIGHT_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) + +#define STATUS_ILLUMINATED_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) +#define STATUS_SHADOWED_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) +#define STATUS_SHAPE_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) +#define STATUS_SHAPE_OUTLINE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) + +#define CONTROL_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) + +#define ALLIANCE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) +#define HIERARCHY_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) +#define ALLIANCE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) +#define HIERARCHY_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) +#define ALLIANCE_BOX_HIGHLIGHT_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) +#define HIERARCHY_BOX_HIGHLIGHT_COLOR HIERARCHY_BACKGROUND_COLOR + +#define MESSAGE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) +#define MESSAGE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) + + +#endif /* _COLORS_H */ + diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index f006c92c7..b1da72730 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -16,18 +16,29 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "libs/graphics/gfx_common.h" -#include "libs/graphics/drawable.h" -#include "libs/sound/trackplayer.h" -#include "starcon.h" -#include "commglue.h" -#include "options.h" #include "comm.h" -#include "libs/sound/sound.h" -#include "libs/sound/trackint.h" + +#include "build.h" +#include "commglue.h" #include "controls.h" +#include "encount.h" #include "endian_uqm.h" +#include "gamestr.h" +#include "options.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "libs/graphics/drawable.h" +#include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" +#include "libs/inplib.h" +#include "libs/sound/sound.h" +#include "libs/sound/trackplayer.h" +#include "libs/sound/trackint.h" + +#include + void InitOscilloscope (int x, int y, int width, int height, FRAME_DESC *f); void SetSliderImage (void *f); diff --git a/sc2/src/sc2code/comm.h b/sc2/src/sc2code/comm.h index 9b01aa48c..533c2bb5a 100644 --- a/sc2/src/sc2code/comm.h +++ b/sc2/src/sc2code/comm.h @@ -17,9 +17,12 @@ #ifndef _COMM_H #define _COMM_H -void init_communication (void); -void uninit_communication (void); -int do_subtitles (UNICODE *pStr); +#include "libs/compiler.h" + +extern void init_communication (void); +extern void uninit_communication (void); +extern int do_subtitles (UNICODE *pStr); +extern void AlienTalkSegue (COUNT wait_track); #endif /* _COMM_H */ diff --git a/sc2/src/sc2code/comm/arilou/arilouc.c b/sc2/src/sc2code/comm/arilou/arilouc.c index 9009a2bd6..387ef168f 100644 --- a/sc2/src/sc2code/comm/arilou/arilouc.c +++ b/sc2/src/sc2code/comm/arilou/arilouc.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/arilou/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/arilou/strings.h" +#include "gameev.h" + + static LOCDATA arilou_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/blackur/blackurc.c b/sc2/src/sc2code/comm/blackur/blackurc.c index 1ab3788b4..4e6b6a456 100644 --- a/sc2/src/sc2code/comm/blackur/blackurc.c +++ b/sc2/src/sc2code/comm/blackur/blackurc.c @@ -16,10 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/blackur/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/blackur/strings.h" static LOCDATA blackurq_desc = diff --git a/sc2/src/sc2code/comm/chmmr/chmmrc.c b/sc2/src/sc2code/comm/chmmr/chmmrc.c index 49b5239b9..1dc608116 100644 --- a/sc2/src/sc2code/comm/chmmr/chmmrc.c +++ b/sc2/src/sc2code/comm/chmmr/chmmrc.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/chmmr/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/chmmr/strings.h" +#include "build.h" + + static LOCDATA chmmr_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/comandr/comandr.c b/sc2/src/sc2code/comm/comandr/comandr.c index c11c5d7e4..60959d7b4 100644 --- a/sc2/src/sc2code/comm/comandr/comandr.c +++ b/sc2/src/sc2code/comm/comandr/comandr.c @@ -16,10 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "setup.h" +#include "comm/commall.h" #include "comm/comandr/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/comandr/strings.h" #include "libs/graphics/gfx_common.h" diff --git a/sc2/src/sc2code/comm/commall.h b/sc2/src/sc2code/comm/commall.h new file mode 100644 index 000000000..c26030446 --- /dev/null +++ b/sc2/src/sc2code/comm/commall.h @@ -0,0 +1,27 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _COMMALL_H +#define _COMMALL_H + +#include "colors.h" +#include "comm.h" +#include "commglue.h" +#include "encount.h" +#include "reslib.h" + +#endif /* _COMMALL_H */ + diff --git a/sc2/src/sc2code/comm/druuge/druugec.c b/sc2/src/sc2code/comm/druuge/druugec.c index cdef8d0e1..ed10a8a95 100644 --- a/sc2/src/sc2code/comm/druuge/druugec.c +++ b/sc2/src/sc2code/comm/druuge/druugec.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/druuge/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/druuge/strings.h" +#include "build.h" +#include "setup.h" + + static LOCDATA druuge_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/ilwrath/ilwrathc.c b/sc2/src/sc2code/comm/ilwrath/ilwrathc.c index 4c93286dc..8076a9d11 100644 --- a/sc2/src/sc2code/comm/ilwrath/ilwrathc.c +++ b/sc2/src/sc2code/comm/ilwrath/ilwrathc.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/ilwrath/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/ilwrath/strings.h" +#include "gameev.h" + + static LOCDATA ilwrath_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/melnorm/melnorm.c b/sc2/src/sc2code/comm/melnorm/melnorm.c index 2d3df3d7a..780d8cd8b 100644 --- a/sc2/src/sc2code/comm/melnorm/melnorm.c +++ b/sc2/src/sc2code/comm/melnorm/melnorm.c @@ -16,12 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/melnorm/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/melnorm/strings.h" +#include "gameev.h" +#include "setup.h" +#include "libs/inplib.h" +#include "libs/mathlib.h" + + //Added by Chris void DrawCargoStrings (BYTE OldElement, BYTE NewElement); diff --git a/sc2/src/sc2code/comm/mycon/myconc.c b/sc2/src/sc2code/comm/mycon/myconc.c index 7ed24e715..3dca4b288 100644 --- a/sc2/src/sc2code/comm/mycon/myconc.c +++ b/sc2/src/sc2code/comm/mycon/myconc.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/mycon/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/mycon/strings.h" +#include "gameev.h" +#include "libs/mathlib.h" + + static LOCDATA mycon_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/orz/orzc.c b/sc2/src/sc2code/comm/orz/orzc.c index 53a5cb9ce..58a946c55 100644 --- a/sc2/src/sc2code/comm/orz/orzc.c +++ b/sc2/src/sc2code/comm/orz/orzc.c @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/orz/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/orz/strings.h" +#include "build.h" + static LOCDATA orz_desc = { diff --git a/sc2/src/sc2code/comm/pkunk/pkunkc.c b/sc2/src/sc2code/comm/pkunk/pkunkc.c index 689d69d14..e42c11395 100644 --- a/sc2/src/sc2code/comm/pkunk/pkunkc.c +++ b/sc2/src/sc2code/comm/pkunk/pkunkc.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/pkunk/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/pkunk/strings.h" +#include "build.h" +#include "gameev.h" + + static LOCDATA pkunk_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/rebel/rebel.c b/sc2/src/sc2code/comm/rebel/rebel.c index 3b5375ee8..a509338c8 100644 --- a/sc2/src/sc2code/comm/rebel/rebel.c +++ b/sc2/src/sc2code/comm/rebel/rebel.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/yehat/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/rebel/strings.h" +#include "build.h" + + static LOCDATA yehat_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/shofixt/shofixt.c b/sc2/src/sc2code/comm/shofixt/shofixt.c index 75b897b2e..9adabdc0f 100644 --- a/sc2/src/sc2code/comm/shofixt/shofixt.c +++ b/sc2/src/sc2code/comm/shofixt/shofixt.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/shofixt/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/shofixt/strings.h" +#include "gameev.h" + + static LOCDATA shofixti_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/slyhome/slyhome.c b/sc2/src/sc2code/comm/slyhome/slyhome.c index ff3f0449f..e1efa9015 100644 --- a/sc2/src/sc2code/comm/slyhome/slyhome.c +++ b/sc2/src/sc2code/comm/slyhome/slyhome.c @@ -16,12 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "gameev.h" +#include "comm/commall.h" #include "comm/slyhome/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/slyhome/strings.h" + static LOCDATA slylandro_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/slyland/slyland.c b/sc2/src/sc2code/comm/slyland/slyland.c index 9efde3282..f884b1ec4 100644 --- a/sc2/src/sc2code/comm/slyland/slyland.c +++ b/sc2/src/sc2code/comm/slyland/slyland.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/slyland/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/slyland/strings.h" +#include "battle.h" +#include "setup.h" + + static LOCDATA slylandro_desc = { NULL_PTR, /* init_encounter_func */ @@ -201,8 +203,6 @@ CombatIsInevitable (RESPONSE_REF R) } else if (PLAYER_SAID (R, destruct_code)) { - extern BOOLEAN instantVictory; - NPCPhrase (DESTRUCT_SEQUENCE); instantVictory = TRUE; SET_GAME_STATE (BATTLE_SEGUE, 1); diff --git a/sc2/src/sc2code/comm/spahome/spahome.c b/sc2/src/sc2code/comm/spahome/spahome.c index 4966ab779..17863902c 100644 --- a/sc2/src/sc2code/comm/spahome/spahome.c +++ b/sc2/src/sc2code/comm/spahome/spahome.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/spathi/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/spahome/strings.h" +#include "build.h" +#include "gameev.h" + + static LOCDATA spahome_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/spathi/spathic.c b/sc2/src/sc2code/comm/spathi/spathic.c index dfe91d1c3..857c7bbbc 100644 --- a/sc2/src/sc2code/comm/spathi/spathic.c +++ b/sc2/src/sc2code/comm/spathi/spathic.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/spathi/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/spathi/strings.h" +#include "build.h" + + static LOCDATA spathi_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/starbas/starbas.c b/sc2/src/sc2code/comm/starbas/starbas.c index e1e4bb331..d9f56cb0d 100644 --- a/sc2/src/sc2code/comm/starbas/starbas.c +++ b/sc2/src/sc2code/comm/starbas/starbas.c @@ -16,12 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/comandr/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/starbas/strings.h" + +#include "build.h" +#include "setup.h" #include "libs/graphics/gfx_common.h" +#include "libs/inplib.h" +#include "libs/mathlib.h" +#include "libs/inplib.h" + //Added by Chris diff --git a/sc2/src/sc2code/comm/supox/supoxc.c b/sc2/src/sc2code/comm/supox/supoxc.c index a1b617022..ff4f81104 100644 --- a/sc2/src/sc2code/comm/supox/supoxc.c +++ b/sc2/src/sc2code/comm/supox/supoxc.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/supox/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/supox/strings.h" +#include "build.h" + + static LOCDATA supox_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/syreen/syreenc.c b/sc2/src/sc2code/comm/syreen/syreenc.c index 47d0d5e42..6dfeea16c 100644 --- a/sc2/src/sc2code/comm/syreen/syreenc.c +++ b/sc2/src/sc2code/comm/syreen/syreenc.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/syreen/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/syreen/strings.h" +#include "build.h" + + static LOCDATA syreen_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/talkpet/talkpet.c b/sc2/src/sc2code/comm/talkpet/talkpet.c index cba6d1ac2..c59e6583b 100644 --- a/sc2/src/sc2code/comm/talkpet/talkpet.c +++ b/sc2/src/sc2code/comm/talkpet/talkpet.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/talkpet/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/talkpet/strings.h" +#include "build.h" + + static LOCDATA talkpet_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/thradd/thraddc.c b/sc2/src/sc2code/comm/thradd/thraddc.c index 927aa3423..8a7563270 100644 --- a/sc2/src/sc2code/comm/thradd/thraddc.c +++ b/sc2/src/sc2code/comm/thradd/thraddc.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/thradd/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/thradd/strings.h" +#include "build.h" +#include "gameev.h" + + static LOCDATA thradd_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/umgah/umgahc.c b/sc2/src/sc2code/comm/umgah/umgahc.c index c64b503d2..4720ea5a0 100644 --- a/sc2/src/sc2code/comm/umgah/umgahc.c +++ b/sc2/src/sc2code/comm/umgah/umgahc.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/umgah/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/umgah/strings.h" +#include "build.h" + + static LOCDATA umgah_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/urquan/urquanc.c b/sc2/src/sc2code/comm/urquan/urquanc.c index e7b388051..a139bc12f 100644 --- a/sc2/src/sc2code/comm/urquan/urquanc.c +++ b/sc2/src/sc2code/comm/urquan/urquanc.c @@ -16,10 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/urquan/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/urquan/strings.h" static LOCDATA urquan_desc = diff --git a/sc2/src/sc2code/comm/utwig/utwigc.c b/sc2/src/sc2code/comm/utwig/utwigc.c index 4dfed8928..7b6493938 100644 --- a/sc2/src/sc2code/comm/utwig/utwigc.c +++ b/sc2/src/sc2code/comm/utwig/utwigc.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/utwig/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/utwig/strings.h" +#include "build.h" +#include "gameev.h" + + static LOCDATA utwig_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/vux/vuxc.c b/sc2/src/sc2code/comm/vux/vuxc.c index 1ede48ead..5fecfdb7b 100644 --- a/sc2/src/sc2code/comm/vux/vuxc.c +++ b/sc2/src/sc2code/comm/vux/vuxc.c @@ -16,10 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/vux/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/vux/strings.h" static LOCDATA vux_desc = diff --git a/sc2/src/sc2code/comm/yehat/yehatc.c b/sc2/src/sc2code/comm/yehat/yehatc.c index d6c1e29f1..c71e7cba0 100644 --- a/sc2/src/sc2code/comm/yehat/yehatc.c +++ b/sc2/src/sc2code/comm/yehat/yehatc.c @@ -16,12 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/yehat/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/yehat/strings.h" +#include "build.h" +#include "gameev.h" +#include "libs/mathlib.h" + + static LOCDATA yehat_desc = { NULL_PTR, /* init_encounter_func */ diff --git a/sc2/src/sc2code/comm/zoqfot/zoqfotc.c b/sc2/src/sc2code/comm/zoqfot/zoqfotc.c index cdd53a5a7..056a435ad 100644 --- a/sc2/src/sc2code/comm/zoqfot/zoqfotc.c +++ b/sc2/src/sc2code/comm/zoqfot/zoqfotc.c @@ -16,12 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "reslib.h" +#include "comm/commall.h" #include "comm/zoqfot/resinst.h" -#include "starcon.h" -#include "commglue.h" #include "comm/zoqfot/strings.h" +#include "build.h" +#include "gameev.h" + + #define ZOQ_FG_COLOR WHITE_COLOR #define ZOQ_BG_COLOR BLACK_COLOR #define ZOQ_BASE_X (TEXT_X_OFFS + ((SIS_TEXT_WIDTH >> 1) >> 1)) diff --git a/sc2/src/sc2code/commglue.c b/sc2/src/sc2code/commglue.c index e455542fd..2b8b95059 100644 --- a/sc2/src/sc2code/commglue.c +++ b/sc2/src/sc2code/commglue.c @@ -16,8 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "commglue.h" + +#include "races.h" + #include #include diff --git a/sc2/src/sc2code/commglue.h b/sc2/src/sc2code/commglue.h index d14130f56..1f5ff0f01 100644 --- a/sc2/src/sc2code/commglue.h +++ b/sc2/src/sc2code/commglue.h @@ -19,8 +19,11 @@ #ifndef _COMMGLUE_H #define _COMMGLUE_H +#include "globdata.h" +#include "resinst.h" #include "libs/sound/trackplayer.h" + extern LOCDATA CommData; extern int cur_comm; extern UNICODE shared_phrase_buf[256]; diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index 5a8ca9f2d..ae2602382 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -16,13 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "starcon.h" +#include "controls.h" #include "commglue.h" #include "comm.h" +#include "colors.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/widgets.h" +#include "libs/inplib.h" #include "libs/sound/trackplayer.h" +#include + + #define CONFIRM_WIN_WIDTH 80 #define CONFIRM_WIN_HEIGHT 22 diff --git a/sc2/src/sc2code/controls.h b/sc2/src/sc2code/controls.h index 6c4f77659..25a6a29ee 100644 --- a/sc2/src/sc2code/controls.h +++ b/sc2/src/sc2code/controls.h @@ -19,8 +19,8 @@ #ifndef _CONTROLS_H_ #define _CONTROLS_H_ -#include "starcon.h" -#include "compiler.h" +#include "libs/compiler.h" + // Enumerated type for controls enum { @@ -75,8 +75,8 @@ typedef UBYTE BATTLE_INPUT_STATE; #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6)) typedef BATTLE_INPUT_STATE (*battle_summary_func) (void); -extern battle_summary_func ComputerInput, HumanInput[NUM_PLAYERS]; -extern battle_summary_func PlayerInput[NUM_PLAYERS]; +extern battle_summary_func ComputerInput, HumanInput[]; +extern battle_summary_func PlayerInput[]; extern CONTROLLER_INPUT_STATE CurrentInputState, PulsedInputState; extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; @@ -91,8 +91,14 @@ BOOLEAN PauseGame (void); BOOLEAN DoConfirmExit (void); void TFB_Abort (void); BOOLEAN WaitAnyButtonOrQuit (BOOLEAN CheckSpecial); +extern BOOLEAN ConfirmExit (void); +extern void DoInput (PVOID pInputState, BOOLEAN resetInput); BATTLE_INPUT_STATE p1_combat_summary (void); BATTLE_INPUT_STATE p2_combat_summary (void); +extern volatile BOOLEAN GamePaused, ExitRequested; + #endif + + diff --git a/sc2/src/sc2code/credits.c b/sc2/src/sc2code/credits.c index 9400e0cc6..99579a49f 100644 --- a/sc2/src/sc2code/credits.c +++ b/sc2/src/sc2code/credits.c @@ -16,11 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "credits.h" + +#include "controls.h" +#include "encount.h" +#include "options.h" +#include "oscill.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" #include "libs/graphics/gfx_common.h" #include "libs/sound/sound.h" -#include "oscill.h" -#include "options.h" + void Credits (void) @@ -165,3 +172,4 @@ OutTakes (void) optSubtitles = oldsubtitles; sliderDisabled = FALSE; } + diff --git a/sc2/src/sc2code/credits.h b/sc2/src/sc2code/credits.h index 1d3f6b9e8..c238f6d66 100644 --- a/sc2/src/sc2code/credits.h +++ b/sc2/src/sc2code/credits.h @@ -14,6 +14,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef _CREDITS_H +#define _CREDITS_H + void OutTakes (void); -void Victory (void); void Credits (void); + +#endif /* _CREDITS_H */ + diff --git a/sc2/src/sc2code/cyborg.c b/sc2/src/sc2code/cyborg.c index d14c9cf2a..628f927bf 100644 --- a/sc2/src/sc2code/cyborg.c +++ b/sc2/src/sc2code/cyborg.c @@ -16,8 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "battle.h" +#include "colors.h" #include "collide.h" +#include "element.h" +#include "globdata.h" +#include "intel.h" +#include "setup.h" +#include "units.h" +#include "libs/inplib.h" +#include "libs/mathlib.h" + //#define DEBUG_CYBORG diff --git a/sc2/src/sc2code/dummy.c b/sc2/src/sc2code/dummy.c index 348dd0a4a..58fbb287a 100644 --- a/sc2/src/sc2code/dummy.c +++ b/sc2/src/sc2code/dummy.c @@ -16,9 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "starcon.h" +/* + * This file seems to be a collection of functions that don't do + * much. + */ + + #include "coderes.h" +#include "races.h" +#include + MEM_HANDLE LoadVidInstance (DWORD res) diff --git a/sc2/src/sc2code/dummy.h b/sc2/src/sc2code/dummy.h new file mode 100644 index 000000000..a1c2efb39 --- /dev/null +++ b/sc2/src/sc2code/dummy.h @@ -0,0 +1,31 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _DUMMY_H +#define _DUMMY_H + +#include "libs/gfxlib.h" + +//extern MEM_HANDLE LoadVidInstance (DWORD res); + +//extern DRAWABLE CreatePixmapRegion (FRAME Frame, PPOINT pOrg, SIZE width, +// SIZE height); + +extern void SetPrimNextLink (PPRIMITIVE pPrim, COUNT Link); +extern COUNT GetPrimNextLink (PPRIMITIVE pPrim); + +#endif /* DUMMY_H */ + diff --git a/sc2/src/sc2code/element.h b/sc2/src/sc2code/element.h index 4378307f2..0027da1c4 100644 --- a/sc2/src/sc2code/element.h +++ b/sc2/src/sc2code/element.h @@ -19,10 +19,10 @@ #ifndef _ELEMENT_H #define _ELEMENT_H +#include "battle.h" #include "displist.h" #include "velocity.h" #include "libs/gfxlib.h" -#include "libs/sndlib.h" #define BATTLE_FRAME_RATE (ONE_SECOND / 24) @@ -165,14 +165,6 @@ extern BOOLEAN DeltaEnergy (ELEMENTPTR ElementPtr, SIZE extern BOOLEAN DeltaCrew (ELEMENTPTR ElementPtr, SIZE crew_delta); -// XXX: To be moved to some separate file. -// Don't forget to remove the '#include "libs/sndlib.h"' -extern void PlaySound (SOUND S, SoundPosition Pos, - ELEMENTPTR PositionalObject, BYTE Priority); -extern void ProcessSound (SOUND Sound, ELEMENTPTR PositionalObject); -extern SoundPosition CalcSoundPosition (ELEMENTPTR ElementPtr); -extern SoundPosition NotPositional (void); - extern void PreProcessStatus (PELEMENT ShipPtr); extern void PostProcessStatus (PELEMENT ShipPtr); diff --git a/sc2/src/sc2code/encount.c b/sc2/src/sc2code/encount.c index cb74eedbc..e951d8062 100644 --- a/sc2/src/sc2code/encount.c +++ b/sc2/src/sc2code/encount.c @@ -16,9 +16,26 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" + +#include "battle.h" +#include "build.h" +#include "colors.h" #include "controls.h" +#include "gamestr.h" +#include "globdata.h" +#include "init.h" +#include "intel.h" +#include "nameref.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "state.h" #include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" +#include "libs/inplib.h" + static BOOLEAN DoSelectAction (PMENU_STATE pMS) @@ -709,8 +726,6 @@ EncounterBattle (void) MEM_HANDLE hLastIndex; ACTIVITY OldActivity; extern UWORD nth_frame; - extern BOOLEAN LoadSC2Data (void); - extern BOOLEAN FreeSC2Data (void); LockMutex (GraphicsLock); diff --git a/sc2/src/sc2code/encount.h b/sc2/src/sc2code/encount.h index 1fe22aba8..f373b4e1b 100644 --- a/sc2/src/sc2code/encount.h +++ b/sc2/src/sc2code/encount.h @@ -19,6 +19,12 @@ #ifndef _ENCOUNT_H #define _ENCOUNT_H +#include "displist.h" +#include "libs/gfxlib.h" +#include "planets/planets.h" +#include "races.h" + + typedef QUEUE_HANDLE HENCOUNTER; #define MAX_HYPER_SHIPS 7 @@ -136,6 +142,8 @@ enum ATTACK }; + +extern void EncounterBattle (void); extern void BuildBattle (COUNT which_player); extern COUNT InitEncounter (void); extern COUNT UninitEncounter (void); diff --git a/sc2/src/sc2code/fmv.c b/sc2/src/sc2code/fmv.c index fa6392e10..7e8e3bb17 100644 --- a/sc2/src/sc2code/fmv.c +++ b/sc2/src/sc2code/fmv.c @@ -16,17 +16,22 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "fmv.h" + +#include "controls.h" +#include "hyper.h" +#include "options.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" #include "vidlib.h" #include "libs/graphics/gfx_common.h" -#include "options.h" +#include "libs/inplib.h" + //Added by Chris -void FreeHyperData (void); - BOOLEAN InitGameKernel (void); - void LoadMasterShipList (void); //End Added by Chris diff --git a/sc2/src/sc2code/fmv.h b/sc2/src/sc2code/fmv.h new file mode 100644 index 000000000..44dfec0ea --- /dev/null +++ b/sc2/src/sc2code/fmv.h @@ -0,0 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _FMV_H +#define _FMV_H + +extern void Logo (void); +extern void Introduction (void); +extern void Victory (void); + +#ifdef WANT_SHIP_SPINS +extern void DoShipSpin (COUNT index, MUSIC_REF hMusic); +#endif + +#endif /* _FMV_H */ + diff --git a/sc2/src/sc2code/galaxy.c b/sc2/src/sc2code/galaxy.c index efe3a44d6..0363b4dd9 100644 --- a/sc2/src/sc2code/galaxy.c +++ b/sc2/src/sc2code/galaxy.c @@ -18,7 +18,14 @@ /* background starfield - used to generate agalaxy.asm */ -#include "starcon.h" +#include "element.h" +#include "globdata.h" +#include "init.h" +#include "units.h" +#include "libs/compiler.h" +#include "libs/gfxlib.h" +#include "libs/mathlib.h" + //Added by Chris diff --git a/sc2/src/sc2code/gameev.c b/sc2/src/sc2code/gameev.c new file mode 100644 index 000000000..cd28104ca --- /dev/null +++ b/sc2/src/sc2code/gameev.c @@ -0,0 +1,728 @@ +//Copyright Paul Reiche, Fred Ford. 1992-2002 +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gameev.h" + +#include "build.h" +#include "clock.h" +#include "encount.h" +#include "globdata.h" +#include "hyper.h" +#include "libs/compiler.h" +#include "libs/mathlib.h" + + +static void arilou_entrance_event (void); +static void arilou_exit_event (void); +static void check_race_growth (void); +static void black_urquan_genocide (void); +static void pkunk_mission (void); +static void thradd_mission (void); +static void ilwrath_mission (void); +static void utwig_supox_mission (void); +static void mycon_mission (void); + + +void +AddInitialGameEvents (void) { + AddEvent (RELATIVE_EVENT, 0, 1, 0, HYPERSPACE_ENCOUNTER_EVENT); + AddEvent (ABSOLUTE_EVENT, 3, 17, START_YEAR, ARILOU_ENTRANCE_EVENT); + AddEvent (RELATIVE_EVENT, 0, 0, YEARS_TO_KOHRAH_VICTORY, + KOHR_AH_VICTORIOUS_EVENT); + AddEvent (RELATIVE_EVENT, 0, 0, 0, SLYLANDRO_RAMP_UP); +} + +void +EventHandler (BYTE selector) +{ + switch (selector) + { + case ARILOU_ENTRANCE_EVENT: + arilou_entrance_event (); + break; + case ARILOU_EXIT_EVENT: + arilou_exit_event (); + break; + case HYPERSPACE_ENCOUNTER_EVENT: + check_race_growth (); + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE + && GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) + check_hyperspace_encounter (); + + AddEvent (RELATIVE_EVENT, 0, 1, 0, HYPERSPACE_ENCOUNTER_EVENT); + break; + case KOHR_AH_VICTORIOUS_EVENT: + if (GET_GAME_STATE (UTWIG_SUPOX_MISSION)) + { + AddEvent (RELATIVE_EVENT, 0, 0, 1, KOHR_AH_GENOCIDE_EVENT); + break; + } + /* FALLTHROUGH */ + case KOHR_AH_GENOCIDE_EVENT: + if (!GET_GAME_STATE (KOHR_AH_FRENZY) + && LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY + && CurStarDescPtr + && CurStarDescPtr->Index == SAMATRA_DEFINED) + AddEvent (RELATIVE_EVENT, 0, 7, 0, KOHR_AH_GENOCIDE_EVENT); + else + black_urquan_genocide (); + break; + case ADVANCE_PKUNK_MISSION: + pkunk_mission (); + break; + case ADVANCE_THRADD_MISSION: + thradd_mission (); + break; + case ZOQFOT_DISTRESS_EVENT: + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY + && CurStarDescPtr + && CurStarDescPtr->Index == ZOQFOT_DEFINED) + AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DISTRESS_EVENT); + else + { + SET_GAME_STATE (ZOQFOT_DISTRESS, 1); + AddEvent (RELATIVE_EVENT, 6, 0, 0, ZOQFOT_DEATH_EVENT); + } + break; + case ZOQFOT_DEATH_EVENT: + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY + && CurStarDescPtr + && CurStarDescPtr->Index == ZOQFOT_DEFINED) + AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DEATH_EVENT); + else if (GET_GAME_STATE (ZOQFOT_DISTRESS)) + { + HSTARSHIP hZoqFot; + EXTENDED_SHIP_FRAGMENTPTR ZoqFotPtr; + + hZoqFot = GetStarShipFromIndex (&GLOBAL (avail_race_q), + ZOQFOTPIK_SHIP); + ZoqFotPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hZoqFot); + ZoqFotPtr->ShipInfo.actual_strength = 0; + ZoqFotPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); + UnlockStarShip ( &GLOBAL (avail_race_q), hZoqFot); + + SET_GAME_STATE (ZOQFOT_DISTRESS, 2); + } + break; + case SHOFIXTI_RETURN_EVENT: + ActivateStarShip (SHOFIXTI_SHIP, 0); + GLOBAL (CrewCost) -= 2; + /* crew is not an issue anymore */ + SET_GAME_STATE (CREW_PURCHASED0, 0); + SET_GAME_STATE (CREW_PURCHASED1, 0); + break; + case ADVANCE_UTWIG_SUPOX_MISSION: + utwig_supox_mission (); + break; + case SPATHI_SHIELD_EVENT: + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY + && CurStarDescPtr + && CurStarDescPtr->Index == SPATHI_DEFINED) + AddEvent (RELATIVE_EVENT, 0, 7, 0, SPATHI_SHIELD_EVENT); + else + { + HSTARSHIP hSpathi; + EXTENDED_SHIP_FRAGMENTPTR SpathiPtr; + + hSpathi = GetStarShipFromIndex ( + &GLOBAL (avail_race_q), SPATHI_SHIP); + SpathiPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hSpathi); + + if (SpathiPtr->ShipInfo.actual_strength) + { + ActivateStarShip (SPATHI_SHIP, -1); + SET_GAME_STATE (SPATHI_SHIELDED_SELVES, 1); + SpathiPtr->ShipInfo.actual_strength = 0; + } + + UnlockStarShip (&GLOBAL (avail_race_q), hSpathi); + } + break; + case ADVANCE_ILWRATH_MISSION: + ilwrath_mission (); + break; + case ADVANCE_MYCON_MISSION: + mycon_mission (); + break; + case ARILOU_UMGAH_CHECK: + SET_GAME_STATE (ARILOU_CHECKED_UMGAH, 2); + break; + case YEHAT_REBEL_EVENT: + { + HSTARSHIP hRebel, hRoyalist; + EXTENDED_SHIP_FRAGMENTPTR RebelPtr, RoyalistPtr; + + hRebel = GetStarShipFromIndex (&GLOBAL (avail_race_q), + YEHAT_REBEL_SHIP); + RebelPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hRebel); + hRoyalist = GetStarShipFromIndex (&GLOBAL (avail_race_q), + YEHAT_SHIP); + RoyalistPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hRoyalist); + RebelPtr->ShipInfo.actual_strength = + RoyalistPtr->ShipInfo.actual_strength = + RoyalistPtr->ShipInfo.actual_strength * 2 / 3; + RebelPtr->ShipInfo.loc.x = 5150; + RebelPtr->ShipInfo.loc.y = 0; + UnlockStarShip (&GLOBAL (avail_race_q), hRoyalist); + UnlockStarShip (&GLOBAL (avail_race_q), hRebel); + ActivateStarShip (YEHAT_REBEL_SHIP, SPHERE_TRACKING); + break; + } + case SLYLANDRO_RAMP_UP: + if (!GET_GAME_STATE (DESTRUCT_CODE_ON_SHIP)) + { + BYTE ramp_factor; + + ramp_factor = GET_GAME_STATE (SLYLANDRO_MULTIPLIER); + if (++ramp_factor <= 4) + { + SET_GAME_STATE (SLYLANDRO_MULTIPLIER, ramp_factor); + AddEvent (RELATIVE_EVENT, 0, 182, 0, SLYLANDRO_RAMP_UP); + } + } + break; + case SLYLANDRO_RAMP_DOWN: + { + BYTE ramp_factor; + + ramp_factor = GET_GAME_STATE (SLYLANDRO_MULTIPLIER); + if (--ramp_factor) + AddEvent (RELATIVE_EVENT, 0, 23, 0, SLYLANDRO_RAMP_DOWN); + SET_GAME_STATE (SLYLANDRO_MULTIPLIER, ramp_factor); + break; + } + } +} + +void +SetRaceDest (BYTE which_race, COORD x, COORD y, BYTE days_left, BYTE + func_index) +{ + HSTARSHIP hStarShip; + EXTENDED_SHIP_FRAGMENTPTR TemplatePtr; + + hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), which_race); + TemplatePtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hStarShip); + + TemplatePtr->ShipInfo.dest_loc.x = x; + TemplatePtr->ShipInfo.dest_loc.y = y; + TemplatePtr->ShipInfo.days_left = days_left; + TemplatePtr->ShipInfo.func_index = func_index; + + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); +} + + + +static void +arilou_entrance_event (void) +{ + SET_GAME_STATE (ARILOU_SPACE, OPENING); + AddEvent (RELATIVE_EVENT, 0, 3, 0, ARILOU_EXIT_EVENT); +} + +static void +arilou_exit_event (void) +{ + COUNT month_index, year_index; + + year_index = GLOBAL (GameClock.year_index); + if ((month_index = GLOBAL (GameClock.month_index) % 12) == 0) + ++year_index; + ++month_index; + + SET_GAME_STATE (ARILOU_SPACE, CLOSING); + AddEvent (ABSOLUTE_EVENT, + month_index, 17, year_index, ARILOU_ENTRANCE_EVENT); +} + +static void +check_race_growth (void) +{ + HSTARSHIP hStarShip, hNextShip; + + for (hStarShip = GetHeadLink (&GLOBAL (avail_race_q)); + hStarShip; hStarShip = hNextShip) + { + EXTENDED_SHIP_FRAGMENTPTR TemplatePtr; + + TemplatePtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hStarShip); + hNextShip = _GetSuccLink (TemplatePtr); + + if (TemplatePtr->ShipInfo.actual_strength + && TemplatePtr->ShipInfo.actual_strength != (COUNT)~0) + { + SIZE delta_strength; + + delta_strength = (SBYTE)TemplatePtr->ShipInfo.energy_level; + if (TemplatePtr->ShipInfo.growth_err_term <= + TemplatePtr->ShipInfo.growth_fract) + { + if (delta_strength <= 0) + --delta_strength; + else + ++delta_strength; + } + TemplatePtr->ShipInfo.growth_err_term -= + TemplatePtr->ShipInfo.growth_fract; + + delta_strength += TemplatePtr->ShipInfo.actual_strength; + if (delta_strength <= 0) + { + delta_strength = 0; + TemplatePtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); + } + else if (delta_strength > MAX_FLEET_STRENGTH) + delta_strength = MAX_FLEET_STRENGTH; + + TemplatePtr->ShipInfo.actual_strength = (COUNT)delta_strength; + if (TemplatePtr->ShipInfo.actual_strength && + TemplatePtr->ShipInfo.days_left) + { + TemplatePtr->ShipInfo.loc.x += + (TemplatePtr->ShipInfo.dest_loc.x + - TemplatePtr->ShipInfo.loc.x) + / TemplatePtr->ShipInfo.days_left; + TemplatePtr->ShipInfo.loc.y += + (TemplatePtr->ShipInfo.dest_loc.y + - TemplatePtr->ShipInfo.loc.y) + / TemplatePtr->ShipInfo.days_left; + + if (--TemplatePtr->ShipInfo.days_left == 0 + && TemplatePtr->ShipInfo.func_index != (BYTE) ~0) + EventHandler (TemplatePtr->ShipInfo.func_index); + } + } + + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); + } +} + +static void +black_urquan_genocide (void) +{ + BYTE Index; + long best_dist; + SIZE best_dx, best_dy; + HSTARSHIP hStarShip, hNextShip; + HSTARSHIP hBlackUrquan; + EXTENDED_SHIP_FRAGMENTPTR BlackUrquanPtr; + + hBlackUrquan = GetStarShipFromIndex ( + &GLOBAL (avail_race_q), BLACK_URQUAN_SHIP); + BlackUrquanPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hBlackUrquan); + + best_dist = -1; + best_dx = SOL_X - BlackUrquanPtr->ShipInfo.loc.x; + best_dy = SOL_Y - BlackUrquanPtr->ShipInfo.loc.y; + for (Index = 0, hStarShip = GetHeadLink (&GLOBAL (avail_race_q)); + hStarShip; ++Index, hStarShip = hNextShip) + { + EXTENDED_SHIP_FRAGMENTPTR TemplatePtr; + + TemplatePtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hStarShip); + hNextShip = _GetSuccLink (TemplatePtr); + + if (Index != BLACK_URQUAN_SHIP + && Index != URQUAN_SHIP + && TemplatePtr->ShipInfo.actual_strength != (COUNT)~0) + { + SIZE dx, dy; + + dx = TemplatePtr->ShipInfo.loc.x - BlackUrquanPtr->ShipInfo.loc.x; + dy = TemplatePtr->ShipInfo.loc.y - BlackUrquanPtr->ShipInfo.loc.y; + if (dx == 0 && dy == 0) + { + // Arrived at the victim's home world. Cleanse it. + TemplatePtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); + TemplatePtr->ShipInfo.actual_strength = 0; + } + else if (TemplatePtr->ShipInfo.actual_strength) + { + long dist; + + dist = (long)dx * dx + (long)dy * dy; + if (best_dist < 0 || dist < best_dist || Index == DRUUGE_SHIP) + { + best_dist = dist; + best_dx = dx; + best_dy = dy; + + if (Index == DRUUGE_SHIP) + hNextShip = 0; + } + } + } + + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); + } + + if (best_dist < 0 && best_dx == 0 && best_dy == 0) + { + // All spheres of influence are gone - game over. + GLOBAL (CurrentActivity) &= ~IN_BATTLE; + GLOBAL_SIS (CrewEnlisted) = (COUNT)~0; + + SET_GAME_STATE (KOHR_AH_KILLED_ALL, 1); + } + else + { + // Moving towards new race to cleanse. + COUNT speed; + + if (best_dist < 0) + best_dist = (long)best_dx * best_dx + (long)best_dy * best_dy; + + speed = square_root (best_dist) / 158; + if (speed == 0) + speed = 1; + else if (speed > 255) + speed = 255; + + SET_GAME_STATE (KOHR_AH_FRENZY, 1); + SET_GAME_STATE (KOHR_AH_VISITS, 0); + SET_GAME_STATE (KOHR_AH_REASONS, 0); + SET_GAME_STATE (KOHR_AH_PLEAD, 0); + SET_GAME_STATE (KOHR_AH_INFO, 0); + SET_GAME_STATE (URQUAN_VISITS, 0); + SetRaceDest (BLACK_URQUAN_SHIP, + BlackUrquanPtr->ShipInfo.loc.x + best_dx, + BlackUrquanPtr->ShipInfo.loc.y + best_dy, + (BYTE)speed, KOHR_AH_GENOCIDE_EVENT); + } + + UnlockStarShip (&GLOBAL (avail_race_q), hBlackUrquan); +} + +static void +pkunk_mission (void) +{ + HSTARSHIP hPkunk; + EXTENDED_SHIP_FRAGMENTPTR PkunkPtr; + + hPkunk = GetStarShipFromIndex (&GLOBAL (avail_race_q), PKUNK_SHIP); + PkunkPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hPkunk); + + if (PkunkPtr->ShipInfo.actual_strength) + { + BYTE MissionState; + + MissionState = GET_GAME_STATE (PKUNK_MISSION); + if (PkunkPtr->ShipInfo.days_left == 0 && MissionState) + { + if ((MissionState & 1) + /* made it to Yehat space */ + || (PkunkPtr->ShipInfo.loc.x == 4970 + && PkunkPtr->ShipInfo.loc.y == 400)) + PkunkPtr->ShipInfo.actual_strength = 0; + else if (PkunkPtr->ShipInfo.loc.x == 502 + && PkunkPtr->ShipInfo.loc.y == 401 + && GET_GAME_STATE (PKUNK_ON_THE_MOVE)) + { + SET_GAME_STATE (PKUNK_ON_THE_MOVE, 0); + AddEvent (RELATIVE_EVENT, 3, 0, 0, ADVANCE_PKUNK_MISSION); + UnlockStarShip (&GLOBAL (avail_race_q), hPkunk); + return; + } + } + + if (PkunkPtr->ShipInfo.actual_strength == 0) + { + SET_GAME_STATE (YEHAT_ABSORBED_PKUNK, 1); + PkunkPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); + ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING); + } + else + { + COORD x, y; + + if (!(MissionState & 1)) + { + x = 4970; + y = 400; + } + else + { + x = 502; + y = 401; + } + SET_GAME_STATE (PKUNK_ON_THE_MOVE, 1); + SET_GAME_STATE (PKUNK_SWITCH, 0); + SetRaceDest (PKUNK_SHIP, x, y, + (BYTE)((365 >> 1) - PkunkPtr->ShipInfo.days_left), + ADVANCE_PKUNK_MISSION); + } + SET_GAME_STATE (PKUNK_MISSION, MissionState + 1); + } + + UnlockStarShip (&GLOBAL (avail_race_q), hPkunk); +} + +static void +thradd_mission (void) +{ + BYTE MissionState; + HSTARSHIP hThradd; + EXTENDED_SHIP_FRAGMENTPTR ThraddPtr; + + hThradd = GetStarShipFromIndex (&GLOBAL (avail_race_q), THRADDASH_SHIP); + ThraddPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hThradd); + + MissionState = GET_GAME_STATE (THRADD_MISSION); + if (ThraddPtr->ShipInfo.actual_strength && MissionState < 3) + { + if (MissionState & 1) + { + SIZE strength_loss; + + AddEvent (RELATIVE_EVENT, 0, 14, 0, ADVANCE_THRADD_MISSION); + strength_loss = (SIZE)(ThraddPtr->ShipInfo.actual_strength >> 1); + + ThraddPtr->ShipInfo.energy_level = + (BYTE)(-strength_loss / 14); + ThraddPtr->ShipInfo.growth_fract = + (BYTE)(((strength_loss % 14) << 8) / 14); + ThraddPtr->ShipInfo.growth_err_term = 255 >> 1; + } + else + { + COORD x, y; + + if (MissionState == 0) + { + x = 4879; + y = 7201; + } + else + { + x = 2535; + y = 8358; + + ThraddPtr->ShipInfo.energy_level = 0; + ThraddPtr->ShipInfo.growth_fract = 0; + } + SetRaceDest (THRADDASH_SHIP, x, y, 14, ADVANCE_THRADD_MISSION); + } + } + SET_GAME_STATE (THRADD_MISSION, MissionState + 1); + + UnlockStarShip (&GLOBAL (avail_race_q), hThradd); +} + +static void +ilwrath_mission (void) +{ + HSTARSHIP hIlwrath, hThradd; + EXTENDED_SHIP_FRAGMENTPTR IlwrathPtr, ThraddPtr; + + hIlwrath = GetStarShipFromIndex (&GLOBAL (avail_race_q), ILWRATH_SHIP); + IlwrathPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hIlwrath); + hThradd = GetStarShipFromIndex (&GLOBAL (avail_race_q), THRADDASH_SHIP); + ThraddPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hThradd); + + if (IlwrathPtr->ShipInfo.loc.x == ((2500 + 2535) >> 1) + && IlwrathPtr->ShipInfo.loc.y == ((8070 + 8358) >> 1)) + { + IlwrathPtr->ShipInfo.actual_strength = + ThraddPtr->ShipInfo.actual_strength = 0; + IlwrathPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); + ThraddPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); + } + else if (IlwrathPtr->ShipInfo.actual_strength) + { + if (IlwrathPtr->ShipInfo.dest_loc.x != 2500 + || IlwrathPtr->ShipInfo.dest_loc.y != 8070) + SetRaceDest (ILWRATH_SHIP, 2500, 8070, 90, + ADVANCE_ILWRATH_MISSION); + else + { +#define MADD_LENGTH 128 + SIZE strength_loss; + + SET_GAME_STATE (ILWRATH_FIGHT_THRADDASH, 1); + SET_GAME_STATE (HELIX_UNPROTECTED, 1); + strength_loss = (SIZE)IlwrathPtr->ShipInfo.actual_strength; + IlwrathPtr->ShipInfo.energy_level = + (BYTE)(-strength_loss / MADD_LENGTH); + IlwrathPtr->ShipInfo.growth_fract = + (BYTE)(((strength_loss % MADD_LENGTH) << 8) / MADD_LENGTH); + SetRaceDest (ILWRATH_SHIP, + (2500 + 2535) >> 1, (8070 + 8358) >> 1, + MADD_LENGTH - 1, ADVANCE_ILWRATH_MISSION); + + strength_loss = (SIZE)ThraddPtr->ShipInfo.actual_strength; + ThraddPtr->ShipInfo.energy_level = + (BYTE)(-strength_loss / MADD_LENGTH); + ThraddPtr->ShipInfo.growth_fract = + (BYTE)(((strength_loss % MADD_LENGTH) << 8) / MADD_LENGTH); + SetRaceDest (THRADDASH_SHIP, + (2500 + 2535) >> 1, (8070 + 8358) >> 1, + MADD_LENGTH, (BYTE)~0); + SET_GAME_STATE (THRADD_VISITS, 0); + if (ThraddPtr->ShipInfo.ship_flags & GOOD_GUY) + ActivateStarShip (THRADDASH_SHIP, -1); + } + } + + UnlockStarShip (&GLOBAL (avail_race_q), hThradd); + UnlockStarShip (&GLOBAL (avail_race_q), hIlwrath); +} + +static void +utwig_supox_mission (void) +{ + BYTE MissionState; + HSTARSHIP hUtwig, hSupox; + EXTENDED_SHIP_FRAGMENTPTR UtwigPtr, SupoxPtr; + + hUtwig = GetStarShipFromIndex (&GLOBAL (avail_race_q), UTWIG_SHIP); + UtwigPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hUtwig); + hSupox = GetStarShipFromIndex (&GLOBAL (avail_race_q), SUPOX_SHIP); + SupoxPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hSupox); + + MissionState = GET_GAME_STATE (UTWIG_SUPOX_MISSION); + if (UtwigPtr->ShipInfo.actual_strength && MissionState < 5) + { + if (MissionState == 1) + { + SIZE strength_loss; + + AddEvent (RELATIVE_EVENT, 0, (160 >> 1), 0, + ADVANCE_UTWIG_SUPOX_MISSION); + + strength_loss = (SIZE)(UtwigPtr->ShipInfo.actual_strength >> 1); + UtwigPtr->ShipInfo.energy_level = + (BYTE)(-strength_loss / 160); + UtwigPtr->ShipInfo.growth_fract = + (BYTE)(((strength_loss % 160) << 8) / 160); + UtwigPtr->ShipInfo.growth_err_term = 255 >> 1; + + strength_loss = (SIZE)(SupoxPtr->ShipInfo.actual_strength >> 1); + if (strength_loss) + { + SupoxPtr->ShipInfo.energy_level = + (BYTE)(-strength_loss / 160); + SupoxPtr->ShipInfo.growth_fract = + (BYTE)(((strength_loss % 160) << 8) / 160); + SupoxPtr->ShipInfo.growth_err_term = 255 >> 1; + } + + SET_GAME_STATE (UTWIG_WAR_NEWS, 0); + SET_GAME_STATE (SUPOX_WAR_NEWS, 0); + } + else if (MissionState == 2) + { + AddEvent (RELATIVE_EVENT, 0, (160 >> 1), 0, + ADVANCE_UTWIG_SUPOX_MISSION); + ++MissionState; + } + else + { + COORD ux, uy, sx, sy; + + if (MissionState == 0) + { + ux = 7208; + uy = 7000; + + sx = 6479; + sy = 7541; + } + else + { + ux = 8534; + uy = 8797; + + sx = 7468; + sy = 9246; + + UtwigPtr->ShipInfo.energy_level = 0; + UtwigPtr->ShipInfo.growth_fract = 0; + SupoxPtr->ShipInfo.energy_level = 0; + SupoxPtr->ShipInfo.growth_fract = 0; + + SET_GAME_STATE (UTWIG_WAR_NEWS, 0); + SET_GAME_STATE (SUPOX_WAR_NEWS, 0); + } + SET_GAME_STATE (UTWIG_VISITS, 0); + SET_GAME_STATE (UTWIG_INFO, 0); + SET_GAME_STATE (SUPOX_VISITS, 0); + SET_GAME_STATE (SUPOX_INFO, 0); + SetRaceDest (UTWIG_SHIP, ux, uy, 21, ADVANCE_UTWIG_SUPOX_MISSION); + SetRaceDest (SUPOX_SHIP, sx, sy, 21, (BYTE)~0); + } + } + SET_GAME_STATE (UTWIG_SUPOX_MISSION, MissionState + 1); + + UnlockStarShip (&GLOBAL (avail_race_q), hSupox); + UnlockStarShip (&GLOBAL (avail_race_q), hUtwig); +} + +static void +mycon_mission (void) +{ + HSTARSHIP hMycon; + EXTENDED_SHIP_FRAGMENTPTR MyconPtr; + + hMycon = GetStarShipFromIndex (&GLOBAL (avail_race_q), MYCON_SHIP); + MyconPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( + &GLOBAL (avail_race_q), hMycon); + + if (MyconPtr->ShipInfo.actual_strength) + { + if (MyconPtr->ShipInfo.energy_level) + { + SET_GAME_STATE (MYCON_KNOW_AMBUSH, 1); + SetRaceDest (MYCON_SHIP, 6392, 2200, 30, (BYTE)~0); + + MyconPtr->ShipInfo.energy_level = 0; + MyconPtr->ShipInfo.growth_fract = 0; + } + else if (MyconPtr->ShipInfo.loc.x != 6858 + || MyconPtr->ShipInfo.loc.y != 577) + SetRaceDest (MYCON_SHIP, 6858, 577, 30, ADVANCE_MYCON_MISSION); + else + { + SIZE strength_loss; + + AddEvent (RELATIVE_EVENT, 0, 14, 0, ADVANCE_MYCON_MISSION); + strength_loss = (SIZE)(MyconPtr->ShipInfo.actual_strength >> 1); + MyconPtr->ShipInfo.energy_level = + (BYTE)(-strength_loss / 14); + MyconPtr->ShipInfo.growth_fract = + (BYTE)(((strength_loss % 14) << 8) / 14); + MyconPtr->ShipInfo.growth_err_term = 255 >> 1; + } + } + + UnlockStarShip (&GLOBAL (avail_race_q), hMycon); +} + diff --git a/sc2/src/sc2code/gameev.h b/sc2/src/sc2code/gameev.h new file mode 100644 index 000000000..92a7c911f --- /dev/null +++ b/sc2/src/sc2code/gameev.h @@ -0,0 +1,58 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GAMEEV_H +#define _GAMEEV_H + +#include "libs/compiler.h" + + +enum +{ + ARILOU_ENTRANCE_EVENT = 0, + ARILOU_EXIT_EVENT, + HYPERSPACE_ENCOUNTER_EVENT, + KOHR_AH_VICTORIOUS_EVENT, + ADVANCE_PKUNK_MISSION, + ADVANCE_THRADD_MISSION, + ZOQFOT_DISTRESS_EVENT, + ZOQFOT_DEATH_EVENT, + SHOFIXTI_RETURN_EVENT, + ADVANCE_UTWIG_SUPOX_MISSION, + KOHR_AH_GENOCIDE_EVENT, + SPATHI_SHIELD_EVENT, + ADVANCE_ILWRATH_MISSION, + ADVANCE_MYCON_MISSION, + ARILOU_UMGAH_CHECK, + YEHAT_REBEL_EVENT, + SLYLANDRO_RAMP_UP, + SLYLANDRO_RAMP_DOWN, + + NUM_EVENTS +}; + +typedef enum +{ + CLOSING = 0, + OPENING +} ARILOU_GATE_STATE; + +extern void AddInitialGameEvents (void); +extern void EventHandler (BYTE selector); + + +#endif /* _GAMEEV_H */ + diff --git a/sc2/src/sc2code/gameinp.c b/sc2/src/sc2code/gameinp.c index a7f8a135f..a06db39ec 100644 --- a/sc2/src/sc2code/gameinp.c +++ b/sc2/src/sc2code/gameinp.c @@ -16,13 +16,21 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "controls.h" +#include "init.h" +#include "planets/planets.h" +#include "settings.h" +#include "sounds.h" +#include "libs/timelib.h" +#include "libs/threadlib.h" + battle_summary_func ComputerInput, HumanInput[NUM_PLAYERS]; battle_summary_func PlayerInput[NUM_PLAYERS]; #define ACCELERATION_INCREMENT (ONE_SECOND / 12) +#define MENU_REPEAT_DELAY (ONE_SECOND >> 1) + typedef struct { diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 49ca56c39..07d0a104b 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -16,13 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "starcon.h" +#include "build.h" +#include "colors.h" #include "commglue.h" -#include "options.h" -#include "libs/graphics/gfx_common.h" -#include "inplib.h" #include "controls.h" +#include "encount.h" +#include "gamestr.h" +#include "options.h" +#include "inplib.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "state.h" +#include "util.h" +#include "libs/graphics/gfx_common.h" + +#include + //Added by Chris diff --git a/sc2/src/sc2code/gamestr.h b/sc2/src/sc2code/gamestr.h new file mode 100644 index 000000000..d2fb4806f --- /dev/null +++ b/sc2/src/sc2code/gamestr.h @@ -0,0 +1,52 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * This file contains definitions relating to using strings specific to + * the game. libs/strlib.h is for the string library. + */ + +#ifndef _GAMESTR_H +#define _GAMESTR_H + + +#include "libs/strlib.h" + +#define STAR_STRING_BASE 0 +#define DEVICE_STRING_BASE 133 +#define CARGO_STRING_BASE 162 +#define ELEMENTS_STRING_BASE 172 +#define SCAN_STRING_BASE 305 +#define STAR_NUMBER_BASE 361 +#define PLANET_NUMBER_BASE 375 +#define MONTHS_STRING_BASE 407 +#define FEEDBACK_STRING_BASE 419 +#define STARBASE_STRING_BASE 420 +#define ENCOUNTER_STRING_BASE 425 +#define NAVIGATION_STRING_BASE 433 +#define NAMING_STRING_BASE 439 +#define MELEE_STRING_BASE 443 +#define SAVEGAME_STRING_BASE 452 +#define OPTION_STRING_BASE 455 + +#define GAME_STRING(i) ((UNICODE *)GetStringAddress (SetAbsStringTableIndex (GameStrings, (i)))) + +extern STRING GameStrings; + + + +#endif /* _GAMESTR_H */ + diff --git a/sc2/src/sc2code/gendef.c b/sc2/src/sc2code/gendef.c index 1fb837918..d06cf3c41 100644 --- a/sc2/src/sc2code/gendef.c +++ b/sc2/src/sc2code/gendef.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" PLAN_GEN_FUNC GenerateIP (BYTE Index) diff --git a/sc2/src/sc2code/getchar.c b/sc2/src/sc2code/getchar.c index f68760be2..68afefcbc 100644 --- a/sc2/src/sc2code/getchar.c +++ b/sc2/src/sc2code/getchar.c @@ -17,7 +17,8 @@ */ #include -#include "starcon.h" +#include "controls.h" + static UWORD cur_char = ' '; diff --git a/sc2/src/sc2code/globdata.c b/sc2/src/sc2code/globdata.c index 672bd26f5..3df74691c 100644 --- a/sc2/src/sc2code/globdata.c +++ b/sc2/src/sc2code/globdata.c @@ -16,8 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "globdata.h" + #include "coderes.h" +#include "encount.h" +#include "setup.h" +#include "resinst.h" +#include "build.h" +#include "state.h" +#include "gamestr.h" + +#include //Added by Chris @@ -62,15 +71,15 @@ LoadSC2Data (void) hOldIndex = SetResourceIndex (hResIndex); - if ((flagship_status = CaptureDrawable ( - LoadGraphic (FLAGSTAT_MASK_PMAP_ANIM) - )) == 0) - return (FALSE); + flagship_status = CaptureDrawable ( + LoadGraphic (FLAGSTAT_MASK_PMAP_ANIM)); + if (flagship_status == NULL) + return FALSE; - if ((misc_data = CaptureDrawable ( - LoadGraphic (MISCDATA_MASK_PMAP_ANIM) - )) == 0) - return (FALSE); + misc_data = CaptureDrawable ( + LoadGraphic (MISCDATA_MASK_PMAP_ANIM)); + if (misc_data == NULL) + return FALSE; SetResourceIndex (hOldIndex); } @@ -83,7 +92,7 @@ LoadSC2Data (void) GLOBAL (ShipStamp.origin.y) = -1; } - return (TRUE); + return TRUE; } BOOLEAN diff --git a/sc2/src/sc2code/globdata.h b/sc2/src/sc2code/globdata.h index 70fdcdbb8..2037033fd 100644 --- a/sc2/src/sc2code/globdata.h +++ b/sc2/src/sc2code/globdata.h @@ -20,6 +20,10 @@ #define _GLOBDATA_H #include "clock.h" +#include "libs/gfxlib.h" +#include "sis.h" +#include "velocity.h" + #define RANDOM_ANIM (1 << 0) #define CIRCULAR_ANIM (1 << 1) @@ -959,38 +963,15 @@ void setGameState (int startBit, int endBit, BYTE val setGameState ((SName), (END_##SName), (val)) #endif + +extern CONTEXT RadarContext; extern void DiscardStarMap (PVOID CodeRef); extern void RetrieveStarMap (void); -#define STAR_STRING_BASE 0 -#define DEVICE_STRING_BASE 133 -#define CARGO_STRING_BASE 162 -#define ELEMENTS_STRING_BASE 172 -#define SCAN_STRING_BASE 305 -#define STAR_NUMBER_BASE 361 -#define PLANET_NUMBER_BASE 375 -#define MONTHS_STRING_BASE 407 -#define FEEDBACK_STRING_BASE 419 -#define STARBASE_STRING_BASE 420 -#define ENCOUNTER_STRING_BASE 425 -#define NAVIGATION_STRING_BASE 433 -#define NAMING_STRING_BASE 439 -#define MELEE_STRING_BASE 443 -#define SAVEGAME_STRING_BASE 452 -#define OPTION_STRING_BASE 455 +extern void FreeSC2Data (void); +extern BOOLEAN LoadSC2Data (void); -#define GAME_STRING(i) ((UNICODE *)GetStringAddress (SetAbsStringTableIndex (GameStrings, (i)))) - -#define wsprintf sprintf -#define wstrlen strlen -#define wstrcpy strcpy -#define wstrcat strcat -#define wstrupr strupr -#define wstrncpy strncpy -#define wstricmp stricmp -#define wstrtoul strtoul -#define wstrcspn strcspn #endif /* _GLOBDATA_H */ diff --git a/sc2/src/sc2code/gravity.c b/sc2/src/sc2code/gravity.c index e93e5d465..a773774ef 100644 --- a/sc2/src/sc2code/gravity.c +++ b/sc2/src/sc2code/gravity.c @@ -16,8 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "collide.h" +#include "races.h" +#include "units.h" + //#define DEBUG_GRAVITY diff --git a/sc2/src/sc2code/gravwell.c b/sc2/src/sc2code/gravwell.c index 9b4a6d2bd..4c8fbd2d3 100644 --- a/sc2/src/sc2code/gravwell.c +++ b/sc2/src/sc2code/gravwell.c @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "resinst.h" +#include "setup.h" + FRAME planet[NUM_VIEWS]; diff --git a/sc2/src/sc2code/grpinfo.c b/sc2/src/sc2code/grpinfo.c index f38ccdb0c..fe43d3f24 100644 --- a/sc2/src/sc2code/grpinfo.c +++ b/sc2/src/sc2code/grpinfo.c @@ -16,11 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "file.h" +#include "globdata.h" +#include "intel.h" +#include "sis.h" +#include "state.h" + +#include "libs/mathlib.h" + #ifdef HAVE_UNISTD_H #include #endif -#include "file.h" + //#define DEBUG_GROUPS diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index c472e09e0..0d2cf39b1 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -16,9 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "collide.h" +#include "colors.h" +#include "controls.h" +#include "encount.h" +#include "globdata.h" +#include "init.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" + //Added by Chris @@ -274,16 +285,13 @@ LoadHyperData (void) if (hyperstars[0] == 0) { hyperstars[0] = CaptureDrawable ( - LoadGraphic (AMBIENT_MASK_PMAP_ANIM) - ); + LoadGraphic (AMBIENT_MASK_PMAP_ANIM)); hyperstars[1] = CaptureDrawable ( - LoadGraphic (HYPERSTARS_MASK_PMAP_ANIM) - ); + LoadGraphic (HYPERSTARS_MASK_PMAP_ANIM)); hypercmaps[0] = CaptureColorMap (LoadColorMap (HYPER_COLOR_TAB)); hyperstars[2] = CaptureDrawable ( - LoadGraphic (ARISPACE_MASK_PMAP_ANIM) - ); + LoadGraphic (ARISPACE_MASK_PMAP_ANIM)); hypercmaps[1] = CaptureColorMap (LoadColorMap (ARISPACE_COLOR_TAB)); } } @@ -954,17 +962,12 @@ AddEncounterElement (ENCOUNTERPTR EncounterPtr, HSTARSHIP hStarShip; SHIP_FRAGMENTPTR TemplatePtr; - hStarShip = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), Type - ); + hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), Type); TemplatePtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + &GLOBAL (avail_race_q), hStarShip); EncounterPtr->SD.ShipList[i] = TemplatePtr->ShipInfo; EncounterPtr->SD.ShipList[i].var1 = Type; - UnlockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); } @@ -1015,10 +1018,8 @@ AddEncounterElement (ENCOUNTERPTR EncounterPtr, if (i == 0 || i > NUM_VORTEX_TRANSITIONS) i = NUM_VORTEX_TRANSITIONS; - ElementPtr->current.image.frame = - SetRelFrameIndex ( - ElementPtr->current.image.farray[0], -i - ); + ElementPtr->current.image.frame = SetRelFrameIndex ( + ElementPtr->current.image.farray[0], -i); ElementPtr->death_func = encounter_transition; } else @@ -1057,7 +1058,8 @@ DrawHyperGrid (COORD ux, COORD uy, COORD ox, RECT r; ClearDrawable (); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x6B)); + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x6B)); if ((sx = ux - (RADAR_SCAN_WIDTH >> 1)) < 0) sx = 0; @@ -1073,22 +1075,20 @@ DrawHyperGrid (COORD ux, COORD uy, COORD ox, if ((ey = uy + (RADAR_SCAN_HEIGHT >> 1)) > MAX_Y_UNIVERSE + 1) ey = MAX_Y_UNIVERSE + 1; - r.corner.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) + r.corner.y = (COORD) ((long)(MAX_Y_UNIVERSE - ey) * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy; r.extent.width = 1; - r.extent.height = ((COORD)((long)(MAX_Y_UNIVERSE - sy) - * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy) - - r.corner.y + 1; + r.extent.height = ((COORD) ((long)(MAX_Y_UNIVERSE - sy) + * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy) - r.corner.y + 1; for (ux = sx; ux <= ex; ux += GRID_OFFSET) { - r.corner.x = (COORD)((long)ux + r.corner.x = (COORD) ((long)ux * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox; DrawFilledRectangle (&r); } while ((ux += GRID_OFFSET) < ex); - r.corner.x = (COORD)((long)sx - * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox; - r.extent.width = ((COORD)((long)ex + r.corner.x = (COORD) ((long)sx * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox; + r.extent.width = ((COORD) ((long)ex * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox) - r.corner.x + 1; r.extent.height = 1; @@ -1119,9 +1119,7 @@ ProcessEncounters (PPOINT puniverse, COORD ox, hNextEncounter = GetSuccEncounter (EncounterPtr); if (EncounterPtr->hElement == 0 - && AddEncounterElement ( - EncounterPtr, puniverse - ) == 0) + && AddEncounterElement (EncounterPtr, puniverse) == 0) { DeleteEncounter: UnlockEncounter (hEncounter); @@ -1171,13 +1169,11 @@ DeleteEncounter: COUNT cur_facing, delta_facing; cur_facing = ANGLE_TO_FACING ( - GetVelocityTravelAngle (&ElementPtr->velocity) - ); + GetVelocityTravelAngle (&ElementPtr->velocity)); delta_facing = NORMALIZE_FACING (cur_facing - ANGLE_TO_FACING (ARCTAN ( puniverse->x - EncounterPtr->SD.star_pt.x, - puniverse->y - EncounterPtr->SD.star_pt.y - ))); + puniverse->y - EncounterPtr->SD.star_pt.y))); if (delta_facing || (delta_x == 0 && delta_y == 0)) { SIZE s, RaceHyperSpeed[] = diff --git a/sc2/src/sc2code/hyper.h b/sc2/src/sc2code/hyper.h index 06326bc5e..4d228144b 100644 --- a/sc2/src/sc2code/hyper.h +++ b/sc2/src/sc2code/hyper.h @@ -20,7 +20,8 @@ #define _HYPER_H -extern ENCOUNTER_INFO SISinfo; +extern void FreeHyperData (void); +extern void check_hyperspace_encounter (void); #endif /* _HYPER_H */ diff --git a/sc2/src/sc2code/init.c b/sc2/src/sc2code/init.c index 702d99647..d61e764c9 100644 --- a/sc2/src/sc2code/init.c +++ b/sc2/src/sc2code/init.c @@ -16,19 +16,22 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "build.h" +#include "colors.h" +#include "element.h" +#include "globdata.h" +#include "init.h" #include "port.h" -#include "starcon.h" -#include "libs/uio.h" +#include "resinst.h" +#include "setup.h" +#include "units.h" + FRAME stars_in_space, asteroid[NUM_VIEWS], blast[NUM_VIEWS], explosion[NUM_VIEWS]; -uio_Repository *repository; -uio_DirHandle *rootDir; - - BOOLEAN load_animation (PFRAME pixarray, DWORD big_res, DWORD med_res, DWORD sml_res) @@ -78,31 +81,31 @@ InitSpace (void) if (space_ini_cnt++ == 0 && LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER) { - if ((stars_in_space = CaptureDrawable ( - LoadGraphic (STAR_MASK_PMAP_ANIM) - )) == 0) - return (FALSE); + stars_in_space = CaptureDrawable ( + LoadGraphic (STAR_MASK_PMAP_ANIM)); + if (stars_in_space == NULL) + return FALSE; if (!load_animation (explosion, BOOM_BIG_MASK_PMAP_ANIM, BOOM_MED_MASK_PMAP_ANIM, BOOM_SML_MASK_PMAP_ANIM)) - return (FALSE); + return FALSE; if (!load_animation (blast, BLAST_BIG_MASK_PMAP_ANIM, BLAST_MED_MASK_PMAP_ANIM, BLAST_SML_MASK_PMAP_ANIM)) - return (FALSE); + return FALSE; if (!load_animation (asteroid, ASTEROID_BIG_MASK_PMAP_ANIM, ASTEROID_MED_MASK_PMAP_ANIM, ASTEROID_SML_MASK_PMAP_ANIM)) - return (FALSE); + return FALSE; } - return (TRUE); + return TRUE; } void @@ -272,29 +275,7 @@ InitGlobData (void) // but it is always cleared before set, so it toggled between // 2 and 1, which doesn't actually do anything. - GLOBAL (GameClock.clock_sem) = CreateSemaphore(0, "Clock", SYNC_CLASS_TOPLEVEL); + GLOBAL (GameClock.clock_sem) = + CreateSemaphore(0, "Clock", SYNC_CLASS_TOPLEVEL); } -int -initIO (void) -{ - uio_init (); - repository = uio_openRepository (0); - - rootDir = uio_openDir(repository, "/", 0); - if (rootDir == NULL) { - fprintf(stderr, "Could not open '/' dir.\n"); - return -1; - } - return 0; -} - -void -uninitIO (void) -{ - uio_closeDir (rootDir); - uio_closeRepository (repository); - uio_unInit (); -} - - diff --git a/sc2/src/sc2code/init.h b/sc2/src/sc2code/init.h new file mode 100644 index 000000000..de64cf75d --- /dev/null +++ b/sc2/src/sc2code/init.h @@ -0,0 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _INIT_H +#define _INIT_H + +#include "libs/gfxlib.h" + +#define NUM_PLAYERS 2 +#define NUM_SIDES 2 + +extern FRAME stars_in_space; + + +#endif /* _INIT_H */ + diff --git a/sc2/src/sc2code/intel.c b/sc2/src/sc2code/intel.c index 95d18864a..a43379003 100644 --- a/sc2/src/sc2code/intel.c +++ b/sc2/src/sc2code/intel.c @@ -16,8 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "intel.h" + #include "controls.h" +#include "globdata.h" +#include "setup.h" + SIZE cur_player; diff --git a/sc2/src/sc2code/intel.h b/sc2/src/sc2code/intel.h index 0b7047e52..aae203dad 100644 --- a/sc2/src/sc2code/intel.h +++ b/sc2/src/sc2code/intel.h @@ -20,6 +20,8 @@ #define _INTEL_H #include "controls.h" +#include "element.h" +#include "races.h" typedef enum { @@ -59,6 +61,7 @@ enum }; extern STARSHIPPTR CyborgDescPtr; +extern SIZE cur_player; extern BATTLE_INPUT_STATE computer_intelligence (void); extern BATTLE_INPUT_STATE tactical_intelligence (void); @@ -73,5 +76,17 @@ extern void Avoid (ELEMENTPTR ShipPtr, EVALUATE_DESCPTR EvalDescPtr); extern BOOLEAN TurnShip (ELEMENTPTR ShipPtr, COUNT angle); extern BOOLEAN ThrustShip (ELEMENTPTR ShipPtr, COUNT angle); + +#define HUMAN_CONTROL (BYTE)(1 << 0) +#define CYBORG_CONTROL (BYTE)(1 << 1) +#define PSYTRON_CONTROL (BYTE)(1 << 2) +#define COMPUTER_CONTROL (CYBORG_CONTROL | PSYTRON_CONTROL) + +#define STANDARD_RATING (BYTE)(1 << 3) +#define GOOD_RATING (BYTE)(1 << 4) +#define AWESOME_RATING (BYTE)(1 << 5) + + #endif /* _INTEL_H */ + diff --git a/sc2/src/sc2code/intro.c b/sc2/src/sc2code/intro.c index f7fd11ff8..f99a1fab4 100644 --- a/sc2/src/sc2code/intro.c +++ b/sc2/src/sc2code/intro.c @@ -16,20 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "starcon.h" -#include "libs/vidlib.h" +#include "controls.h" #include "options.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/gfx_common.h" #include "libs/sound/sound.h" +#include "libs/vidlib.h" +#include "libs/inplib.h" -//Added by Chris +#include -BOOLEAN InitGameKernel (void); - -void LoadMasterShipList (void); - -//End Added by Chris typedef struct { @@ -563,62 +561,4 @@ ShowPresentation (char *name) return TRUE; } -/* //Already defined in fmv.c -void -Introduction (void) -{ - BYTE xform_buf[1]; - STAMP s; - DWORD TimeOut; - BOOLEAN InputState; - - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR)xform_buf, ONE_SECOND / 120)); - LockMutex (GraphicsLock); - SetContext (ScreenContext); - s.origin.x = s.origin.y = 0; - s.frame = CaptureDrawable (LoadGraphic (TITLE_ANIM)); - DrawStamp (&s); - DestroyDrawable (ReleaseDrawable (s.frame)); - UnlockMutex (GraphicsLock); - - FlushInput (); - - xform_buf[0] = FadeAllToColor; - TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2); - LoadMasterShipList (); - SleepThreadUntil (TimeOut); - - GLOBAL (CurrentActivity) |= CHECK_ABORT; - TimeOut += ONE_SECOND * 3; - while (!(InputState = AnyButtonPress (FALSE)) && TaskSwitch () <= TimeOut) - ; - GLOBAL (CurrentActivity) &= ~CHECK_ABORT; - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); - - if (InputState == 0) - DoFMV ("intro", NULL, FALSE); - - InitGameKernel (); -} -*/ - -/* //Already defined in fmv.c -void -Victory (void) -{ - BYTE xform_buf[1]; - - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); - - DoFMV ("victory", NULL, TRUE); - - InitGameKernel (); -} -*/ - - diff --git a/sc2/src/sc2code/ipdisp.c b/sc2/src/sc2code/ipdisp.c index 933babce6..df7d3ebbe 100644 --- a/sc2/src/sc2code/ipdisp.c +++ b/sc2/src/sc2code/ipdisp.c @@ -16,8 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "collide.h" +#include "globdata.h" +#include "init.h" +#include "races.h" +#include "libs/mathlib.h" + void NotifyOthers (COUNT which_race, BYTE target_loc) @@ -30,8 +34,7 @@ NotifyOthers (COUNT which_race, BYTE target_loc) SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (npc_built_ship_q), hStarShip - ); + &GLOBAL (npc_built_ship_q), hStarShip); hNextShip = _GetSuccLink (StarShipPtr); if (GET_RACE_ID (StarShipPtr) == which_race) @@ -53,8 +56,7 @@ NotifyOthers (COUNT which_race, BYTE target_loc) #ifdef OLD target_loc = (BYTE)(( (COUNT)TFB_Random () - % pSolarSysState->SunDesc[0].NumPlanets - ) + 1); + % pSolarSysState->SunDesc[0].NumPlanets) + 1); #endif /* OLD */ if (!(task & REFORM_GROUP)) { @@ -62,8 +64,7 @@ NotifyOthers (COUNT which_race, BYTE target_loc) StarShipPtr->ShipInfo.group_counter = 0; else StarShipPtr->ShipInfo.group_counter = - ((COUNT)TFB_Random () - % MAX_REVOLUTIONS) + ((COUNT) TFB_Random () % MAX_REVOLUTIONS) << FACING_SHIFT; } } @@ -72,9 +73,7 @@ NotifyOthers (COUNT which_race, BYTE target_loc) SET_GROUP_DEST (StarShipPtr, target_loc); } - UnlockStarShip ( - &GLOBAL (npc_built_ship_q), hStarShip - ); + UnlockStarShip (&GLOBAL (npc_built_ship_q), hStarShip); } } @@ -166,7 +165,7 @@ ip_group_preprocess (PELEMENT ElementPtr) { if (target_loc == 0 && task != FLEE) { - /* if intercepting flagship */ + /* if intercepting flagship */ target_loc = flagship_loc; if (EPtr->thrust_wait > TRACK_WAIT) { @@ -286,11 +285,8 @@ ip_group_preprocess (PELEMENT ElementPtr) if (GET_GROUP_DEST (StarShipPtr) == 0) dest_pt = pSolarSysState->SunDesc[0].location; else - XFormIPLoc ( - &pSolarSysState->PlanetDesc[target_loc - 1].image.origin, - &dest_pt, - FALSE - ); + XFormIPLoc (&pSolarSysState->PlanetDesc[ + target_loc - 1].image.origin, &dest_pt, FALSE); } else { diff --git a/sc2/src/sc2code/libs/Makeinfo b/sc2/src/sc2code/libs/Makeinfo index 9824e5605..d626c6c52 100644 --- a/sc2/src/sc2code/libs/Makeinfo +++ b/sc2/src/sc2code/libs/Makeinfo @@ -1,2 +1,6 @@ uqm_SUBDIRS="decomp file graphics input math memory resource sound strings task threads time uio video" +#if [ "$DEBUG" = 1 ]; then +# uqm_SUBDIRS="$UQM_SUBDIRS debug" +#fi + diff --git a/sc2/src/sc2code/libs/compiler.h b/sc2/src/sc2code/libs/compiler.h index a00ba5bab..e50e3f202 100644 --- a/sc2/src/sc2code/libs/compiler.h +++ b/sc2/src/sc2code/libs/compiler.h @@ -44,6 +44,8 @@ typedef SWORD SIZE; typedef SIZE *PSIZE; typedef unsigned char UNICODE; +#include "strtemp.h" + // XXX: this include should be removed in the future. #define NULL_PTR 0L diff --git a/sc2/src/sc2code/libs/decomp/lzencode.c b/sc2/src/sc2code/libs/decomp/lzencode.c index 9b56de849..126bfd16c 100644 --- a/sc2/src/sc2code/libs/decomp/lzencode.c +++ b/sc2/src/sc2code/libs/decomp/lzencode.c @@ -57,10 +57,8 @@ InitTree (void) *(MEM_HANDLE *)lson = h; lson = (PSWORD)((PBYTE)lson + sizeof (h)); - rson = lson; - ((BYTE *) rson) += (N + 1) * sizeof (lson[0]); - dad = rson; - ((BYTE *) dad) += (N + 257) * sizeof (rson[0]); + rson = lson + (N + 1); + dad = rson + (N + 257); for (i = N + 1; i <= N + 256; i++) rson[i] = NIL; /* root */ diff --git a/sc2/src/sc2code/libs/gfxlib.h b/sc2/src/sc2code/libs/gfxlib.h index b9285e9d7..d0f73c455 100644 --- a/sc2/src/sc2code/libs/gfxlib.h +++ b/sc2/src/sc2code/libs/gfxlib.h @@ -223,6 +223,16 @@ typedef struct BYTE type; } FONTEFFECT; +enum +{ + FadeAllToWhite = 250, + FadeSomeToWhite, + FadeAllToBlack, + FadeAllToColor, + FadeSomeToBlack, + FadeSomeToColor +}; + #endif /* _GFXLIB_H */ diff --git a/sc2/src/sc2code/libs/graphics/cmap.c b/sc2/src/sc2code/libs/graphics/cmap.c index 542fca514..30130599e 100644 --- a/sc2/src/sc2code/libs/graphics/cmap.c +++ b/sc2/src/sc2code/libs/graphics/cmap.c @@ -18,6 +18,8 @@ #include "gfx_common.h" #include "libs/tasklib.h" +#include + static struct { diff --git a/sc2/src/sc2code/libs/graphics/filegfx.c b/sc2/src/sc2code/libs/graphics/filegfx.c index 8165a78d5..19df71d7d 100644 --- a/sc2/src/sc2code/libs/graphics/filegfx.c +++ b/sc2/src/sc2code/libs/graphics/filegfx.c @@ -57,7 +57,7 @@ LoadFontFile (PVOID pStr) return 0; fp = res_OpenResFile (contentDir, pStr, "rb"); - if (fp == ~0) + if (fp == (uio_Stream *) ~0) { MEM_HANDLE hData; diff --git a/sc2/src/sc2code/libs/graphics/font.c b/sc2/src/sc2code/libs/graphics/font.c index 4c5e541aa..7151f0c23 100644 --- a/sc2/src/sc2code/libs/graphics/font.c +++ b/sc2/src/sc2code/libs/graphics/font.c @@ -19,7 +19,9 @@ #include "gfxintrn.h" #include "tfb_prim.h" -extern FRAME Build_Font_Effect (FRAME FramePtr, DWORD from, DWORD to, BYTE type); + +extern FRAME Build_Font_Effect (FRAME FramePtr, DWORD from, DWORD to, + BYTE type); static BYTE char_delta_array[MAX_DELTAS]; diff --git a/sc2/src/sc2code/libs/graphics/gfx_common.h b/sc2/src/sc2code/libs/graphics/gfx_common.h index a8084c59a..41ae57fe4 100644 --- a/sc2/src/sc2code/libs/graphics/gfx_common.h +++ b/sc2/src/sc2code/libs/graphics/gfx_common.h @@ -22,7 +22,6 @@ #include #include -#include "starcon.h" #include "libs/gfxlib.h" #include "libs/vidlib.h" #include "libs/misc.h" diff --git a/sc2/src/sc2code/libs/graphics/sdl/2xscalers.c b/sc2/src/sc2code/libs/graphics/sdl/2xscalers.c index d0de0dc80..54e35f123 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/2xscalers.c +++ b/sc2/src/sc2code/libs/graphics/sdl/2xscalers.c @@ -19,6 +19,8 @@ #include "libs/graphics/sdl/sdl_common.h" #include "2xscalers.h" +#include "types.h" + static const Uint32 bilinear_table[4][4] = { diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c b/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c index 7ccd66473..d404768a9 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_funcs.c @@ -22,9 +22,11 @@ #include "pure.h" #include "opengl.h" #include "primitives.h" +#include "units.h" #include "graphics/drawcmd.h" #include "graphics/tfb_draw.h" + int batch_depth = 0; diff --git a/sc2/src/sc2code/libs/graphics/sdl/canvas.c b/sc2/src/sc2code/libs/graphics/sdl/canvas.c index 956487b85..353fe38e8 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/canvas.c +++ b/sc2/src/sc2code/libs/graphics/sdl/canvas.c @@ -4,6 +4,7 @@ #include "libs/graphics/sdl/primitives.h" #include "libs/graphics/tfb_draw.h" #include "options.h" +#include "types.h" typedef SDL_Surface *NativeCanvas; diff --git a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c index ea4b3386f..981e134d8 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c +++ b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c @@ -24,8 +24,11 @@ #include "libs/graphics/drawcmd.h" #include "libs/graphics/sdl/dcqueue.h" + static RecursiveMutex DCQ_Mutex; +CondVar RenderingCond; + TFB_DrawCommand DCQ[DCQ_MAX]; TFB_DrawCommandQueue DrawCommandQueue; @@ -35,7 +38,10 @@ static void TFB_WaitForSpace (int requested_slots) { int old_depth, i; - fprintf (stderr, "DCQ overload (Size = %d, FullSize = %d, Requested = %d). Sleeping until renderer is done.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize, requested_slots); + fprintf (stderr, "DCQ overload (Size = %d, FullSize = %d, " + "Requested = %d). Sleeping until renderer is done.\n", + DrawCommandQueue.Size, DrawCommandQueue.FullSize, + requested_slots); // Restore the DCQ locking level. I *think* this is // always 1, but... TFB_BatchReset (); @@ -45,7 +51,8 @@ TFB_WaitForSpace (int requested_slots) WaitCondVar (RenderingCond); for (i = 0; i < old_depth; i++) LockRecursiveMutex (DCQ_Mutex); - fprintf (stderr, "DCQ clear (Size = %d, FullSize = %d). Continuing.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize); + fprintf (stderr, "DCQ clear (Size = %d, FullSize = %d). Continuing.\n", + DrawCommandQueue.Size, DrawCommandQueue.FullSize); } void @@ -144,7 +151,8 @@ TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command) { Lock_DCQ (1); DCQ[DrawCommandQueue.InsertionPoint] = *Command; - DrawCommandQueue.InsertionPoint = (DrawCommandQueue.InsertionPoint + 1) % DCQ_MAX; + DrawCommandQueue.InsertionPoint = (DrawCommandQueue.InsertionPoint + 1) + % DCQ_MAX; DrawCommandQueue.FullSize++; Synchronize_DCQ (); Unlock_DCQ (); @@ -161,9 +169,11 @@ TFB_DrawCommandQueue_Pop (TFB_DrawCommand *target) return (0); } - if (DrawCommandQueue.Front == DrawCommandQueue.Back && DrawCommandQueue.Size != DCQ_MAX) + if (DrawCommandQueue.Front == DrawCommandQueue.Back && + DrawCommandQueue.Size != DCQ_MAX) { - fprintf (stderr, "Augh! Assertion failure in DCQ! Front == Back, Size != DCQ_MAX\n"); + fprintf (stderr, "Augh! Assertion failure in DCQ! Front == Back, " + "Size != DCQ_MAX\n"); DrawCommandQueue.Size = 0; Unlock_DCQ (); return (0); @@ -239,3 +249,5 @@ TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand) } #endif + + diff --git a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.h b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.h index fc7278e0e..1e98a6af5 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.h +++ b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.h @@ -50,4 +50,8 @@ #define DCQ_LIVELOCK_MAX 4096 #endif +extern CondVar RenderingCond; + #endif + + diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 8f8d2f699..2db93baf5 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -31,6 +31,8 @@ #include "bbox.h" #include "port.h" #include "libs/uio.h" +#include "controls.h" + // XXX: Should not be included from here. #include "uqmdebug.h" SDL_Surface *SDL_Video; @@ -60,9 +62,10 @@ void TFB_PreInit (void) { fprintf (stderr, "Initializing base SDL functionality.\n"); - fprintf (stderr, "Using SDL version %d.%d.%d (compiled with %d.%d.%d)\n", - SDL_Linked_Version ()->major, SDL_Linked_Version ()->minor, SDL_Linked_Version ()->patch, - SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); + fprintf (stderr, "Using SDL version %d.%d.%d (compiled with " + "%d.%d.%d)\n", SDL_Linked_Version ()->major, + SDL_Linked_Version ()->minor, SDL_Linked_Version ()->patch, + SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); if ((SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) == -1)) { fprintf (stderr, "Could not initialize SDL: %s.\n", SDL_GetError()); @@ -92,7 +95,8 @@ TFB_InitGraphics (int driver, int flags, int width, int height, int bpp) result = TFB_GL_InitGraphics (driver, flags, width, height, bpp); #else driver = TFB_GFXDRIVER_SDL_PURE; - fprintf (stderr, "OpenGL support not compiled in, so using pure sdl driver\n"); + fprintf (stderr, "OpenGL support not compiled in, so using pure " + "sdl driver\n"); result = TFB_Pure_InitGraphics (driver, flags, width, height, bpp); #endif } @@ -113,6 +117,9 @@ TFB_InitGraphics (int driver, int flags, int width, int height, int bpp) TFB_FlushPaletteCache (); TFB_DrawCanvas_Initialize (); + RenderingCond = CreateCondVar ("DCQ empty", + SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); + return 0; } @@ -341,7 +348,8 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, if (nb > 255) nb = 255; - putpix (dst, dst_x2, dst_y2, SDL_MapRGB (dst->format, nr, ng, nb)); + putpix (dst, dst_x2, dst_y2, + SDL_MapRGB (dst->format, nr, ng, nb)); } } } @@ -378,7 +386,8 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, if (nb < 0) nb = 0; - putpix (dst, dst_x2, dst_y2, SDL_MapRGB (dst->format, nr, ng, nb)); + putpix (dst, dst_x2, dst_y2, + SDL_MapRGB (dst->format, nr, ng, nb)); } } } @@ -414,7 +423,8 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, if (nb > 255) nb = 255; - putpix (dst, dst_x2, dst_y2, SDL_MapRGB (dst->format, nr, ng, nb)); + putpix (dst, dst_x2, dst_y2, + SDL_MapRGB (dst->format, nr, ng, nb)); } } } @@ -459,7 +469,8 @@ TFB_FlushGraphics () // Only call from main thread!! int current_transition = TransitionAmount; if ((current_fade != 255 && current_fade != last_fade) || - (current_transition != 255 && current_transition != last_transition) || + (current_transition != 255 && + current_transition != last_transition) || (current_fade == 255 && last_fade != 255) || (current_transition == 255 && last_transition != 255)) { @@ -508,7 +519,8 @@ TFB_FlushGraphics () // Only call from main thread!! } ++commands_handled; - if (!livelock_deterrence && commands_handled + DrawCommandQueue.Size > DCQ_LIVELOCK_MAX) + if (!livelock_deterrence && commands_handled + DrawCommandQueue.Size + > DCQ_LIVELOCK_MAX) { // fprintf (stderr, "Initiating livelock deterrence!\n"); livelock_deterrence = TRUE; @@ -523,7 +535,8 @@ TFB_FlushGraphics () // Only call from main thread!! int index = DC.data.setpalette.index; if (index < 0 || index > 255) { - fprintf(stderr, "DCQ panic: Tried to set palette #%i", index); + fprintf(stderr, "DCQ panic: Tried to set palette #%i", + index); } else { @@ -572,9 +585,11 @@ TFB_FlushGraphics () // Only call from main thread!! int x = DC.data.filledimage.x; int y = DC.data.filledimage.y; - TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, DC.data.filledimage.x, DC.data.filledimage.y, - DC.data.filledimage.scale, DC.data.filledimage.r, DC.data.filledimage.g, - DC.data.filledimage.b, SDL_Screens[DC.data.filledimage.destBuffer]); + TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, + DC.data.filledimage.x, DC.data.filledimage.y, + DC.data.filledimage.scale, DC.data.filledimage.r, + DC.data.filledimage.g, DC.data.filledimage.b, + SDL_Screens[DC.data.filledimage.destBuffer]); if (DC.data.filledimage.destBuffer == 0) { @@ -595,8 +610,8 @@ TFB_FlushGraphics () // Only call from main thread!! TFB_BBox_RegisterPoint (DC.data.line.x1, DC.data.line.y1); TFB_BBox_RegisterPoint (DC.data.line.x2, DC.data.line.y2); } - TFB_DrawCanvas_Line (DC.data.line.x1, DC.data.line.y1, - DC.data.line.x2, DC.data.line.y2, + TFB_DrawCanvas_Line (DC.data.line.x1, DC.data.line.y1, + DC.data.line.x2, DC.data.line.y2, DC.data.line.r, DC.data.line.g, DC.data.line.b, SDL_Screens[DC.data.line.destBuffer]); break; @@ -605,8 +620,8 @@ TFB_FlushGraphics () // Only call from main thread!! { if (DC.data.rect.destBuffer == 0) TFB_BBox_RegisterRect (&DC.data.rect.rect); - TFB_DrawCanvas_Rect (&DC.data.rect.rect, DC.data.rect.r, - DC.data.rect.g, DC.data.rect.b, + TFB_DrawCanvas_Rect (&DC.data.rect.rect, DC.data.rect.r, + DC.data.rect.g, DC.data.rect.b, SDL_Screens[DC.data.rect.destBuffer]); break; @@ -635,7 +650,8 @@ TFB_FlushGraphics () // Only call from main thread!! if (DC_image == 0) { - fprintf (stderr, "DCQ ERROR: COPYTOIMAGE passed null image ptr\n"); + fprintf (stderr, "DCQ ERROR: COPYTOIMAGE passed null " + "image ptr\n"); break; } LockMutex (DC_image->mutex); @@ -647,7 +663,8 @@ TFB_FlushGraphics () // Only call from main thread!! dest.x = 0; dest.y = 0; - SDL_BlitSurface(SDL_Screens[DC.data.copytoimage.srcBuffer], &src, DC_image->NormalImg, &dest); + SDL_BlitSurface(SDL_Screens[DC.data.copytoimage.srcBuffer], + &src, DC_image->NormalImg, &dest); UnlockMutex (DC_image->mutex); break; } @@ -665,7 +682,8 @@ TFB_FlushGraphics () // Only call from main thread!! TFB_BBox_RegisterPoint (src.x + src.w, src.y + src.h); } - SDL_BlitSurface(SDL_Screens[DC.data.copy.srcBuffer], &src, SDL_Screens[DC.data.copy.destBuffer], &dest); + SDL_BlitSurface(SDL_Screens[DC.data.copy.srcBuffer], &src, + SDL_Screens[DC.data.copy.destBuffer], &dest); break; } case TFB_DRAWCOMMANDTYPE_DELETEIMAGE: @@ -678,7 +696,8 @@ TFB_FlushGraphics () // Only call from main thread!! ClearSemaphore (DC.data.sendsignal.sem); break; case TFB_DRAWCOMMANDTYPE_REINITVIDEO: - fprintf (stderr, "TODO: REINITVIDEO command set. Not yet implemented.\n"); + fprintf (stderr, "TODO: REINITVIDEO command set. Not yet" + " implemented.\n"); break; } } @@ -707,3 +726,4 @@ TFB_SetGamma (float gamma) } #endif + diff --git a/sc2/src/sc2code/libs/graphics/tfb_draw.c b/sc2/src/sc2code/libs/graphics/tfb_draw.c index f2437f06f..2f5b50ac8 100644 --- a/sc2/src/sc2code/libs/graphics/tfb_draw.c +++ b/sc2/src/sc2code/libs/graphics/tfb_draw.c @@ -1,9 +1,28 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "gfx_common.h" #include "tfb_draw.h" #include "drawcmd.h" +#include "units.h" + void -TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest) +TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + SCREEN dest) { TFB_DrawCommand DC; @@ -76,7 +95,8 @@ TFB_FlushPaletteCache () } void -TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, SCREEN dest) +TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, + TFB_Palette *palette, SCREEN dest) { TFB_DrawCommand DC; @@ -101,13 +121,13 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale _localpal[i][0] = palette[i].r; _localpal[i][1] = palette[i].g; _localpal[i][2] = palette[i].b; - TFB_DrawScreen_SetPalette (i, palette[i].r, palette[i].g, + TFB_DrawScreen_SetPalette (i, palette[i].r, palette[i].g, palette[i].b); } } // if (changed) { fprintf (stderr, "Actually changing palette! "); } DC.data.image.UsePalette = TRUE; - } + } else { Lock_DCQ (1); @@ -121,7 +141,8 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale } void -TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, SCREEN dest) +TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, + int r, int g, int b, SCREEN dest) { TFB_DrawCommand DC; @@ -209,7 +230,8 @@ TFB_DrawScreen_WaitForSignal (void) } void -TFB_DrawScreen_ReinitVideo (int driver, int flags, int width, int height, int bpp) +TFB_DrawScreen_ReinitVideo (int driver, int flags, int width, int height, + int bpp) { TFB_DrawCommand DrawCommand; DrawCommand.Type = TFB_DRAWCOMMANDTYPE_REINITVIDEO; @@ -222,7 +244,8 @@ TFB_DrawScreen_ReinitVideo (int driver, int flags, int width, int height, int bp } void -TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Image *dest) +TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + TFB_Image *dest) { LockMutex (dest->mutex); TFB_DrawCanvas_Line (x1, y1, x2, y2, r, g, b, dest->NormalImg); @@ -240,7 +263,8 @@ TFB_DrawImage_Rect (PRECT rect, int r, int g, int b, TFB_Image *image) } void -TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Image *target) +TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, + TFB_Palette *palette, TFB_Image *target) { LockMutex (target->mutex); TFB_DrawCanvas_Image (img, x, y, scale, palette, target->NormalImg); @@ -249,7 +273,8 @@ TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palet } void -TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Image *target) +TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, + int r, int g, int b, TFB_Image *target) { LockMutex (target->mutex); TFB_DrawCanvas_FilledImage (img, x, y, scale, r, g, b, target->NormalImg); @@ -327,10 +352,12 @@ void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type) { EXTENT old = image->extent; - TFB_DrawCanvas_GetScaledExtent (image->NormalImg, image->MipmapImg, target, &image->extent); + TFB_DrawCanvas_GetScaledExtent (image->NormalImg, image->MipmapImg, + target, &image->extent); - if ((old.width != image->extent.width) || (old.height != image->extent.height) || - image->dirty || !image->ScaledImg || type != image->last_scale_type) + if ((old.width != image->extent.width) || + (old.height != image->extent.height) || image->dirty || + !image->ScaledImg || type != image->last_scale_type) { image->dirty = FALSE; image->ScaledImg = TFB_DrawCanvas_New_ScaleTarget (image->NormalImg, @@ -338,10 +365,10 @@ TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type) image->last_scale_type = type; if (type == TFB_SCALE_NEAREST) - TFB_DrawCanvas_Rescale_Nearest (image->NormalImg, image->ScaledImg, - image->extent); + TFB_DrawCanvas_Rescale_Nearest (image->NormalImg, + image->ScaledImg, image->extent); else - TFB_DrawCanvas_Rescale_Trilinear (image->NormalImg, image->ScaledImg, - image->MipmapImg, image->extent); + TFB_DrawCanvas_Rescale_Trilinear (image->NormalImg, + image->ScaledImg, image->MipmapImg, image->extent); } } diff --git a/sc2/src/sc2code/libs/graphics/tfb_draw.h b/sc2/src/sc2code/libs/graphics/tfb_draw.h index 9154f1d04..4baec5301 100644 --- a/sc2/src/sc2code/libs/graphics/tfb_draw.h +++ b/sc2/src/sc2code/libs/graphics/tfb_draw.h @@ -21,6 +21,7 @@ #include "libs/threadlib.h" + typedef void *TFB_Canvas; typedef enum { @@ -44,6 +45,8 @@ typedef struct tfb_palette UBYTE unused; } TFB_Palette; +#include "graphics/gfx_common.h" + typedef struct tfb_image { TFB_Canvas NormalImg; diff --git a/sc2/src/sc2code/libs/graphics/widgets.c b/sc2/src/sc2code/libs/graphics/widgets.c index d2a1ef089..26fbc499a 100644 --- a/sc2/src/sc2code/libs/graphics/widgets.c +++ b/sc2/src/sc2code/libs/graphics/widgets.c @@ -1,4 +1,4 @@ -#include "starcon.h" +#include "graphics/gfx_common.h" #include "graphics/widgets.h" void diff --git a/sc2/src/sc2code/libs/input/input_common.c b/sc2/src/sc2code/libs/input/input_common.c index 14b80d3f3..52e690612 100644 --- a/sc2/src/sc2code/libs/input/input_common.c +++ b/sc2/src/sc2code/libs/input/input_common.c @@ -20,3 +20,4 @@ #include "inpintrn.h" volatile BOOLEAN ExitRequested, GamePaused; + diff --git a/sc2/src/sc2code/libs/misc.h b/sc2/src/sc2code/libs/misc.h index 125f95985..2945cc767 100644 --- a/sc2/src/sc2code/libs/misc.h +++ b/sc2/src/sc2code/libs/misc.h @@ -22,6 +22,9 @@ #ifndef MISC_H #define MISC_H +#include + + extern void *HMalloc (int size); extern void HFree (void *p); extern void *HCalloc (int size); diff --git a/sc2/src/sc2code/libs/resource/getres.c b/sc2/src/sc2code/libs/resource/getres.c index 00bb19b2a..4dd40046a 100644 --- a/sc2/src/sc2code/libs/resource/getres.c +++ b/sc2/src/sc2code/libs/resource/getres.c @@ -289,7 +289,8 @@ load_package (INDEX_HEADERPTR ResHeaderPtr, RES_PACKAGE res_package) #ifdef DEBUG if (hData == 0) fprintf (stderr, "fp = 0x%08lx(%d), type = %u, " - "file_offs = %lu, len = %lu\n", fp, + "file_offs = %lu, len = %lu\n", + (unsigned long) fp, DanglingOpen, type, file_offs, data_len); #endif /* DEBUG */ } diff --git a/sc2/src/sc2code/libs/resource/resinit.c b/sc2/src/sc2code/libs/resource/resinit.c index 286442821..7fcebeaf9 100644 --- a/sc2/src/sc2code/libs/resource/resinit.c +++ b/sc2/src/sc2code/libs/resource/resinit.c @@ -229,7 +229,7 @@ InitResourceSystem (PVOID resfile, COUNT resindex_type, BOOLEAN _GetResFileData, FreeResourceHeader); } - (void) FileErrorFunc; /* Satisfy compiler (unused parameter) */ + (void) FileErrorFunc; /* Satisfy compiler (unused parameter) */ return (h); } diff --git a/sc2/src/sc2code/libs/sndlib.h b/sc2/src/sc2code/libs/sndlib.h index bdf33379c..8173f4ab4 100644 --- a/sc2/src/sc2code/libs/sndlib.h +++ b/sc2/src/sc2code/libs/sndlib.h @@ -93,8 +93,5 @@ extern COUNT GetSampleLength (SOUND Sound); extern PBYTE GetSampleAddress (SOUND Sound); extern DWORD FadeMusic (BYTE end_vol, SIZE TimeInterval); -extern void SetSoundTracking (BOOLEAN toggle); -extern void GetSoundTrackingBuf (PSBYTE pdigi_buf); - #endif /* _SNDLIB_H */ diff --git a/sc2/src/sc2code/libs/sound/decoders/dukaud.c b/sc2/src/sc2code/libs/sound/decoders/dukaud.c index 5d4b604e5..4a34f4ac4 100644 --- a/sc2/src/sc2code/libs/sound/decoders/dukaud.c +++ b/sc2/src/sc2code/libs/sound/decoders/dukaud.c @@ -501,7 +501,7 @@ duka_Decode (THIS_PTR, void* buf, sint32 bufsize) do { stuffed = duka_stuffBuffer (duka, buf, bufsize); - ((uint8*)buf) += stuffed; + buf = (void *) ((uint8 *) buf + stuffed); bufsize -= stuffed; total += stuffed; diff --git a/sc2/src/sc2code/libs/sound/mixer/nosound/audiodrv_nosound.c b/sc2/src/sc2code/libs/sound/mixer/nosound/audiodrv_nosound.c index 092d418aa..1e3dfe651 100644 --- a/sc2/src/sc2code/libs/sound/mixer/nosound/audiodrv_nosound.c +++ b/sc2/src/sc2code/libs/sound/mixer/nosound/audiodrv_nosound.c @@ -20,6 +20,9 @@ */ #include "audiodrv_nosound.h" +#include "libs/tasklib.h" +#include + static Task StreamDecoderTask; static Task PlaybackTask; diff --git a/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c b/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c index 6e4ae6433..7c042ac39 100644 --- a/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c +++ b/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c @@ -20,6 +20,9 @@ */ #include "audiodrv_sdl.h" +#include "libs/tasklib.h" +#include + static Task StreamDecoderTask; diff --git a/sc2/src/sc2code/libs/sound/sound.c b/sc2/src/sc2code/libs/sound/sound.c index f6b5b045c..e309b38c0 100644 --- a/sc2/src/sc2code/libs/sound/sound.c +++ b/sc2/src/sc2code/libs/sound/sound.c @@ -17,6 +17,8 @@ */ #include "sound.h" +#include "../compiler.h" +#include "../tasklib.h" static Task FadeTask; static SIZE TTotal; diff --git a/sc2/src/sc2code/libs/sound/sound.h b/sc2/src/sc2code/libs/sound/sound.h index ec4f053bb..f8ef1abba 100644 --- a/sc2/src/sc2code/libs/sound/sound.h +++ b/sc2/src/sc2code/libs/sound/sound.h @@ -17,12 +17,13 @@ #ifndef _UQM_SOUND_H // try avoiding collisions on id #define _UQM_SOUND_H -#include "starcon.h" #include "misc.h" #include "libs/strings/strintrn.h" #include "sndintrn.h" #include "audiocore.h" #include "decoders/decoder.h" +#include "libs/threadlib.h" + #define FIRST_SFX_SOURCE 0 #define LAST_SFX_SOURCE 4 diff --git a/sc2/src/sc2code/libs/sound/stream.c b/sc2/src/sc2code/libs/sound/stream.c index 538de6fdc..fee574fc6 100644 --- a/sc2/src/sc2code/libs/sound/stream.c +++ b/sc2/src/sc2code/libs/sound/stream.c @@ -16,9 +16,12 @@ #include #include "sound.h" +#include "../tasklib.h" + void -PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope, bool rewind) +PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope, + bool rewind) { uint32 i, pos = 0; sint32 offset = 0; @@ -39,7 +42,8 @@ PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope, bo if (rewind) SoundDecoder_Rewind (sample->decoder); else - offset += (sint32)(SoundDecoder_GetTime (sample->decoder) * (float)ONE_SECOND); + offset += (sint32)(SoundDecoder_GetTime (sample->decoder) * + (float)ONE_SECOND); soundSource[source].sample = sample; soundSource[source].sample->decoder->looping = looping; audio_Sourcei (soundSource[source].handle, audio_LOOPING, false); @@ -60,16 +64,19 @@ PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope, bo if (decoded_bytes == 0) break; - audio_BufferData (sample->buffer[i], sample->decoder->format, sample->decoder->buffer, - decoded_bytes, sample->decoder->frequency); - audio_SourceQueueBuffers (soundSource[source].handle, 1, &sample->buffer[i]); + audio_BufferData (sample->buffer[i], sample->decoder->format, + sample->decoder->buffer, decoded_bytes, + sample->decoder->frequency); + audio_SourceQueueBuffers (soundSource[source].handle, 1, + &sample->buffer[i]); if (sample->callbacks.OnQueueBuffer) sample->callbacks.OnQueueBuffer (sample, sample->buffer[i]); if (scope) { UBYTE *p; - soundSource[source].sbuffer = HRealloc (soundSource[source].sbuffer, + soundSource[source].sbuffer = HRealloc ( + soundSource[source].sbuffer, pos + decoded_bytes + PAD_SCOPE_BYTES); p = (UBYTE *)soundSource[source].sbuffer; memcpy (&p[pos], sample->decoder->buffer, decoded_bytes); @@ -224,24 +231,32 @@ StreamDecoderTaskFunc (void *data) continue; } - audio_GetSourcei (soundSource[i].handle, audio_BUFFERS_PROCESSED, &processed); - audio_GetSourcei (soundSource[i].handle, audio_BUFFERS_QUEUED, &queued); + audio_GetSourcei (soundSource[i].handle, audio_BUFFERS_PROCESSED, + &processed); + audio_GetSourcei (soundSource[i].handle, audio_BUFFERS_QUEUED, + &queued); if (processed == 0) { - audio_GetSourcei (soundSource[i].handle, audio_SOURCE_STATE, &state); + audio_GetSourcei (soundSource[i].handle, audio_SOURCE_STATE, + &state); if (state != audio_PLAYING) { - if (queued == 0 && soundSource[i].sample->decoder->error == SOUNDDECODER_EOF) + if (queued == 0 && soundSource[i].sample->decoder->error + == SOUNDDECODER_EOF) { - fprintf (stderr, "StreamDecoderTaskFunc(): finished playing %s, source %d\n", soundSource[i].sample->decoder->filename, i); + fprintf (stderr, "StreamDecoderTaskFunc(): " + "finished playing %s, source %d\n", + soundSource[i].sample->decoder->filename, i); soundSource[i].stream_should_be_playing = FALSE; if (soundSource[i].sample->callbacks.OnEndStream) - soundSource[i].sample->callbacks.OnEndStream (soundSource[i].sample); + soundSource[i].sample->callbacks.OnEndStream ( + soundSource[i].sample); } else { - fprintf (stderr, "StreamDecoderTaskFunc(): buffer underrun when playing %s, source %d\n", + fprintf (stderr, "StreamDecoderTaskFunc(): buffer " + "underrun when playing %s, source %d\n", soundSource[i].sample->decoder->filename, i); audio_SourcePlay (soundSource[i].handle); } @@ -260,15 +275,20 @@ StreamDecoderTaskFunc (void *data) audio_SourceUnqueueBuffers (soundSource[i].handle, 1, &buffer); - if ((error = audio_GetError()) != audio_NO_ERROR) + error = audio_GetError(); + if (error != audio_NO_ERROR) { - fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alSourceUnqueueBuffers: %x, file %s, source %d\n", error, soundSource[i].sample->decoder->filename, i); + fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL " + "error after alSourceUnqueueBuffers: %x, " + "file %s, source %d\n", error, + soundSource[i].sample->decoder->filename, i); break; } if (soundSource[i].sample->callbacks.OnTaggedBuffer) { - TFB_SoundTag* tag = TFB_FindTaggedBuffer (soundSource[i].sample, buffer); + TFB_SoundTag* tag = TFB_FindTaggedBuffer ( + soundSource[i].sample, buffer); if (tag) { soundSource[i].sample->callbacks.OnTaggedBuffer ( @@ -281,13 +301,15 @@ StreamDecoderTaskFunc (void *data) audio_GetBufferi(buffer, audio_SIZE, &buf_size); soundSource[i].sbuf_offset += buf_size; if (soundSource[i].sbuf_offset > soundSource[i].sbuf_size) - soundSource[i].sbuf_offset -= soundSource[i].sbuf_size; + soundSource[i].sbuf_offset -= + soundSource[i].sbuf_size; } //soundSource[i].total_decoded += soundSource[i].sample->decoder->buffer_size; if (soundSource[i].sample->decoder->error) { - if (soundSource[i].sample->decoder->error == SOUNDDECODER_EOF) + if (soundSource[i].sample->decoder->error == + SOUNDDECODER_EOF) { if (!soundSource[i].sample->callbacks.OnEndChunk || !soundSource[i].sample->callbacks.OnEndChunk ( @@ -306,10 +328,16 @@ StreamDecoderTaskFunc (void *data) } } - decoded_bytes = SoundDecoder_Decode (soundSource[i].sample->decoder); - if (soundSource[i].sample->decoder->error == SOUNDDECODER_ERROR) + decoded_bytes = SoundDecoder_Decode ( + soundSource[i].sample->decoder); + if (soundSource[i].sample->decoder->error == + SOUNDDECODER_ERROR) { - fprintf (stderr, "StreamDecoderTaskFunc(): SoundDecoder_Decode error %d, file %s, source %d\n", soundSource[i].sample->decoder->error, soundSource[i].sample->decoder->filename, i); + fprintf (stderr, "StreamDecoderTaskFunc(): " + "SoundDecoder_Decode error %d, file %s, " + "source %d\n", + soundSource[i].sample->decoder->error, + soundSource[i].sample->decoder->filename, i); soundSource[i].stream_should_be_playing = FALSE; processed--; continue; @@ -317,19 +345,26 @@ StreamDecoderTaskFunc (void *data) if (decoded_bytes > 0) { - audio_BufferData (buffer, soundSource[i].sample->decoder->format, - soundSource[i].sample->decoder->buffer, decoded_bytes, - soundSource[i].sample->decoder->frequency); + audio_BufferData (buffer, + soundSource[i].sample->decoder->format, + soundSource[i].sample->decoder->buffer, + decoded_bytes, + soundSource[i].sample->decoder->frequency); - if ((error = audio_GetError()) != audio_NO_ERROR) + error = audio_GetError(); + if (error != audio_NO_ERROR) { - fprintf (stderr, "StreamDecoderTaskFunc(): TFBSound error after audio_BufferData: %x, file %s, source %d, decoded_bytes %d\n", - error, soundSource[i].sample->decoder->filename, i, decoded_bytes); + fprintf (stderr, "StreamDecoderTaskFunc(): " + "TFBSound error after audio_BufferData: " + "%x, file %s, source %d, decoded_bytes %d\n", + error, soundSource[i].sample->decoder->filename, + i, decoded_bytes); } else { last_buffer[i] = buffer; - audio_SourceQueueBuffers (soundSource[i].handle, 1, &buffer); + audio_SourceQueueBuffers (soundSource[i].handle, 1, + &buffer); // do OnQueue callback if (soundSource[i].sample->callbacks.OnQueueBuffer) soundSource[i].sample->callbacks.OnQueueBuffer ( @@ -341,12 +376,15 @@ StreamDecoderTaskFunc (void *data) uint32 j, remaining_bytes = 0; UBYTE *sbuffer = (UBYTE *) soundSource[i].sbuffer; - UBYTE *decoder_buffer = (UBYTE *) soundSource[i].sample->decoder->buffer; + UBYTE *decoder_buffer = (UBYTE *) soundSource[i]. + sample->decoder->buffer; - if (soundSource[i].sbuf_start + decoded_bytes > soundSource[i].sbuf_size) + if (soundSource[i].sbuf_start + decoded_bytes > + soundSource[i].sbuf_size) { j = soundSource[i].sbuf_size; - remaining_bytes = decoded_bytes - (j - soundSource[i].sbuf_start); + remaining_bytes = decoded_bytes - + (j - soundSource[i].sbuf_start); } else { @@ -356,13 +394,17 @@ StreamDecoderTaskFunc (void *data) if (j - soundSource[i].sbuf_start >= 1) { //fprintf (stderr, "copying_a to %d - %d, %d bytes\n", soundSource[i].sbuf_start, j, j - soundSource[i].sbuf_start); - memcpy (&sbuffer[soundSource[i].sbuf_start], decoder_buffer, j - soundSource[i].sbuf_start); + memcpy (&sbuffer[soundSource[i].sbuf_start], + decoder_buffer, + j - soundSource[i].sbuf_start); } if (remaining_bytes) { //fprintf (stderr, "copying_b to 0 - %d\n", remaining_bytes); - memcpy (sbuffer, &decoder_buffer[j - soundSource[i].sbuf_start], remaining_bytes); + memcpy (sbuffer, &decoder_buffer[ + j - soundSource[i].sbuf_start], + remaining_bytes); soundSource[i].sbuf_start = remaining_bytes; } else @@ -371,10 +413,15 @@ StreamDecoderTaskFunc (void *data) } } - if ((error = audio_GetError()) != audio_NO_ERROR) + error = audio_GetError(); + if (error != audio_NO_ERROR) { - fprintf (stderr, "StreamDecoderTaskFunc(): TFBSound error after audio_SourceQueueBuffers: %x, file %s, source %d, decoded_bytes %d\n", - error, soundSource[i].sample->decoder->filename, i, decoded_bytes); + fprintf (stderr, "StreamDecoderTaskFunc(): " + "TFBSound error after " + "audio_SourceQueueBuffers: %x, file %s, " + "source %d, decoded_bytes %d\n", error, + soundSource[i].sample->decoder->filename, + i, decoded_bytes); } } } diff --git a/sc2/src/sc2code/libs/sound/trackplayer.c b/sc2/src/sc2code/libs/sound/trackplayer.c index b1a6f741c..743a3e273 100644 --- a/sc2/src/sc2code/libs/sound/trackplayer.c +++ b/sc2/src/sc2code/libs/sound/trackplayer.c @@ -14,13 +14,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include #include "sound.h" #include "libs/sound/trackplayer.h" #include "libs/sound/trackint.h" #include "comm.h" +#include "sis.h" #include "options.h" +#include +#include +#include + static int tct; //total number of subtitle tracks static int tcur; //currently playing subtitle track diff --git a/sc2/src/sc2code/libs/sound/trackplayer.h b/sc2/src/sc2code/libs/sound/trackplayer.h index 6867e5297..02ee34bfb 100644 --- a/sc2/src/sc2code/libs/sound/trackplayer.h +++ b/sc2/src/sc2code/libs/sound/trackplayer.h @@ -19,6 +19,9 @@ #ifndef TRACKPLAYER_H #define TRACKPLAYER_H +#include "compiler.h" + + typedef void (*TFB_TrackCB) (void); #define ACCEL_SCROLL_SPEED 300 diff --git a/sc2/src/sc2code/libs/uio/uiostream.c b/sc2/src/sc2code/libs/uio/uiostream.c index 08e8c4cd7..c9ea8b0d1 100644 --- a/sc2/src/sc2code/libs/uio/uiostream.c +++ b/sc2/src/sc2code/libs/uio/uiostream.c @@ -141,7 +141,7 @@ uio_fread(void *buf, size_t size, size_t nmemb, uio_Stream *stream) { numRead = minu(stream->readEnd - stream->bufPtr, bytesToRead); memcpy(buf, stream->bufPtr, numRead); - (char *) buf += numRead; + buf = (void *) ((char *) buf + numRead); stream->bufPtr += numRead; bytesToRead -= numRead; bytesRead += numRead; diff --git a/sc2/src/sc2code/libs/video/video.c b/sc2/src/sc2code/libs/video/video.c index 03c8b38c3..73c9d7e8f 100644 --- a/sc2/src/sc2code/libs/video/video.c +++ b/sc2/src/sc2code/libs/video/video.c @@ -14,8 +14,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "setup.h" #include "video.h" #include "vidplayer.h" +#include "libs/inplib.h" + #define NULL_VIDEO_REF (0) static VIDEO_REF _cur_video = NULL_VIDEO_REF; diff --git a/sc2/src/sc2code/libs/video/video.h b/sc2/src/sc2code/libs/video/video.h index 49a1db98f..db3e830da 100644 --- a/sc2/src/sc2code/libs/video/video.h +++ b/sc2/src/sc2code/libs/video/video.h @@ -17,13 +17,15 @@ #ifndef _UQM_VIDEO_H #define _UQM_VIDEO_H -#include "starcon.h" #include "options.h" #include "misc.h" #include "vidlib.h" #include "libs/graphics/tfb_draw.h" +#include "types.h" #include "videodec.h" #include "libs/sound/sound.h" +#include "libs/tasklib.h" + typedef struct tfb_videoclip { diff --git a/sc2/src/sc2code/libs/video/vidplayer.c b/sc2/src/sc2code/libs/video/vidplayer.c index 6adbf9c76..de5ce8948 100644 --- a/sc2/src/sc2code/libs/video/vidplayer.c +++ b/sc2/src/sc2code/libs/video/vidplayer.c @@ -14,9 +14,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "vidplayer.h" + +#include "controls.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/tfb_draw.h" -#include "vidplayer.h" + // video callbacks static void* vp_GetCanvasLine (TFB_VideoDecoder*, uint32 line); diff --git a/sc2/src/sc2code/load.c b/sc2/src/sc2code/load.c index e6a0e4037..68cdb048c 100644 --- a/sc2/src/sc2code/load.c +++ b/sc2/src/sc2code/load.c @@ -16,11 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "declib.h" -#include "libs/tasklib.h" -#include "options.h" +#include "encount.h" #include "file.h" +#include "globdata.h" +#include "options.h" +#include "setup.h" +#include "state.h" + +#include "libs/tasklib.h" + //#define DEBUG_LOAD diff --git a/sc2/src/sc2code/loadship.c b/sc2/src/sc2code/loadship.c index 9851b8514..0da08da58 100644 --- a/sc2/src/sc2code/loadship.c +++ b/sc2/src/sc2code/loadship.c @@ -16,8 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "coderes.h" +#include "globdata.h" +#include "nameref.h" +#include "races.h" + MEM_HANDLE load_ship (STARSHIPPTR StarShipPtr, BOOLEAN LoadBattleData) diff --git a/sc2/src/sc2code/master.c b/sc2/src/sc2code/master.c index 3acb324a0..e21deee02 100644 --- a/sc2/src/sc2code/master.c +++ b/sc2/src/sc2code/master.c @@ -16,9 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "resinst.h" +#include "displist.h" #include "melee.h" + QUEUE master_q; void diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 72bccb6bc..65b2c432c 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -16,19 +16,35 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include "starcon.h" -#include "libs/graphics/drawable.h" #include "melee.h" -#include "options.h" -#include "file.h" + +#include "build.h" +#include "colors.h" #include "controls.h" +#include "file.h" +#include "gamestr.h" +#include "intel.h" +#include "nameref.h" +#include "options.h" +#include "races.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "util.h" +#include "libs/graphics/drawable.h" +#include "libs/gfxlib.h" +#include "libs/inplib.h" +#include "libs/mathlib.h" + + +#include +#include +#include + //Added by Chris -#include "string.h" - void ConfirmSaveLoad (STAMP *MsgStamp); void SaveProblem (void); @@ -75,29 +91,49 @@ enum #define RACE_INFO_ORIGIN_Y (SHIP_INFO_HEIGHT + 6) #define RACE_INFO_HEIGHT ((STATUS_HEIGHT - 3) - RACE_INFO_ORIGIN_Y) -#define MELEE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) -#define MELEE_TITLE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) -#define MELEE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) -#define MELEE_TEAM_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) +#define MELEE_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) +#define MELEE_TITLE_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) +#define MELEE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) +#define MELEE_TEAM_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) -#define STATE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) -#define STATE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03) -#define ACTIVE_STATE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) -#define UNAVAILABLE_STATE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) -#define HI_STATE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) -#define HI_STATE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) +#define STATE_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) +#define STATE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03) +#define ACTIVE_STATE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) +#define UNAVAILABLE_STATE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) +#define HI_STATE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) +#define HI_STATE_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) -#define LIST_INFO_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05) -#define LIST_INFO_TITLE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) -#define LIST_INFO_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x07) -#define LIST_INFO_CURENTRY_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) -#define HI_LIST_INFO_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) -#define HI_LIST_INFO_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x1F), 0x0D) +#define LIST_INFO_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05) +#define LIST_INFO_TITLE_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) +#define LIST_INFO_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x07) +#define LIST_INFO_CURENTRY_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) +#define HI_LIST_INFO_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) +#define HI_LIST_INFO_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x1F), 0x0D) -#define TEAM_NAME_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (15, 16, 27), 0x00) -#define TEAM_NAME_EDIT_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (23, 24, 29), 0x00) -#define TEAM_NAME_EDIT_RECT_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05) -#define TEAM_NAME_EDIT_CURS_COLOR WHITE_COLOR +#define TEAM_NAME_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (15, 16, 27), 0x00) +#define TEAM_NAME_EDIT_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (23, 24, 29), 0x00) +#define TEAM_NAME_EDIT_RECT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05) +#define TEAM_NAME_EDIT_CURS_COLOR \ + WHITE_COLOR FRAME PickMeleeFrame; static FRAME MeleeFrame; @@ -149,12 +185,14 @@ DrawShipBox (PMELEE_STATE pMS, BOOLEAN HiLite) DrawStarConBox (&r, 1, BUILD_COLOR (MAKE_RGB15 (0x7, 0x00, 0xC), 0x3E), BUILD_COLOR (MAKE_RGB15 (0xC, 0x00, 0x14), 0x3C), - (BOOLEAN)(StarShip != (BYTE)~0), BUILD_COLOR (MAKE_RGB15 (0xA, 0x00, 0x11), 0x3D)); + (BOOLEAN)(StarShip != (BYTE)~0), + BUILD_COLOR (MAKE_RGB15 (0xA, 0x00, 0x11), 0x3D)); else DrawStarConBox (&r, 1, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x9), 0x56), BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0xE), 0x54), - (BOOLEAN)(StarShip != (BYTE)~0), BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0xC), 0x55)); + (BOOLEAN)(StarShip != (BYTE)~0), + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0xC), 0x55)); if (StarShip != (BYTE)~0) { @@ -297,13 +335,9 @@ DrawTeamString (PMELEE_STATE pMS, COUNT HiLiteState) TEXT lfText; r.corner.x = MELEE_X_OFFS - 1; - r.corner.y = - (pMS->side + 1) - * (MELEE_Y_OFFS - + ((MELEE_BOX_HEIGHT + MELEE_BOX_SPACE) - * NUM_MELEE_ROWS + 2)); - r.extent.width = NUM_MELEE_COLUMNS - * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE); + r.corner.y = (pMS->side + 1) * (MELEE_Y_OFFS + + ((MELEE_BOX_HEIGHT + MELEE_BOX_SPACE) * NUM_MELEE_ROWS + 2)); + r.extent.width = NUM_MELEE_COLUMNS * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE); r.extent.height = 13; if (HiLiteState == 4) { @@ -429,7 +463,8 @@ Deselect (BYTE opt) GetFrameRect (SetAbsFrameIndex (MeleeFrame, 27), &r); - hStarShip = GetStarShipFromIndex (&master_q, pMeleeState->CurIndex); + hStarShip = GetStarShipFromIndex (&master_q, + pMeleeState->CurIndex); StarShipPtr = LockStarShip (&master_q, hStarShip); s.origin.x = r.corner.x + 20 + (pMeleeState->CurIndex % NUM_PICK_COLS) * 18; @@ -645,11 +680,13 @@ GetTeamValue (TEAM_IMAGE *pTI) { BYTE StarShip; - if ((StarShip = pTI->ShipList[row][col]) != (BYTE)~0) + StarShip = pTI->ShipList[row][col]; + if (StarShip != (BYTE) ~0) { HSTARSHIP hStarShip; - if ((hStarShip = GetStarShipFromIndex (&master_q, StarShip)) == 0) + hStarShip = GetStarShipFromIndex (&master_q, StarShip); + if (hStarShip == 0) pTI->ShipList[row][col] = (BYTE)~0; else { @@ -747,11 +784,9 @@ DrawFileStrings (PMELEE_STATE pMS, int HiLiteState) Text.baseline.y = y + bot * ENTRY_HEIGHT; Text.pStr = pMS->FileList[bot].TeamName; Text.CharCount = (COUNT)~0; - SetContextForeGroundColor ( - HiLiteState == 0 - ? BUILD_COLOR (MAKE_RGB15 (15, 16, 27), 0x00) - : BUILD_COLOR (MAKE_RGB15 (23, 24, 29), 0x00) - ); + SetContextForeGroundColor (HiLiteState == 0 ? + BUILD_COLOR (MAKE_RGB15 (15, 16, 27), 0x00) + : BUILD_COLOR (MAKE_RGB15 (23, 24, 29), 0x00)); font_DrawText (&Text); rtText.baseline.y = Text.baseline.y; @@ -767,8 +802,7 @@ DrawFileStrings (PMELEE_STATE pMS, int HiLiteState) Text.baseline.y = y; teams_left = (COUNT)( - GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - top - ); + GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - top); if (teams_left) { bot = top - 1; @@ -811,8 +845,8 @@ DrawFileStrings (PMELEE_STATE pMS, int HiLiteState) { BYTE StarShip; - if ((StarShip = pMS->FileList[bot - top].ShipList[row][col]) - != (BYTE)~0) + StarShip = pMS->FileList[bot - top].ShipList[row][col]; + if (StarShip != (BYTE)~0) { HSTARSHIP hStarShip; STARSHIPPTR StarShipPtr; @@ -844,7 +878,8 @@ DoLoadTeam (PMELEE_STATE pMS) if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_PAGEUP | + MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); if (!pMS->Initialized) { @@ -862,13 +897,13 @@ DoLoadTeam (PMELEE_STATE pMS) pMS->InputFunc = DoLoadTeam; UnlockMutex (GraphicsLock); } - else if (PulsedInputState.key[KEY_MENU_SELECT] | PulsedInputState.key[KEY_MENU_CANCEL]) + else if (PulsedInputState.key[KEY_MENU_SELECT] | + PulsedInputState.key[KEY_MENU_CANCEL]) { if (!PulsedInputState.key[KEY_MENU_CANCEL]) { pMS->TeamImage[pMS->side] = pMS->FileList[ - pMS->CurIndex - pMS->TopTeamIndex - ]; + pMS->CurIndex - pMS->TopTeamIndex]; pMS->star_bucks[pMS->side] = GetTeamValue (&pMS->TeamImage[pMS->side]); } @@ -900,7 +935,8 @@ DoLoadTeam (PMELEE_STATE pMS) } else if (PulsedInputState.key[KEY_MENU_DOWN]) { - if ((int)index < (int)GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - 1) + if ((int)index < (int)GetDirEntryTableCount (pMS->TeamDE) + + NUM_PREBUILT - 1) ++index; if ((int)index > (int)pMS->BotTeamIndex) @@ -908,17 +944,23 @@ DoLoadTeam (PMELEE_STATE pMS) } else if (PulsedInputState.key[KEY_MENU_PAGE_UP]) { - if ((index -= MAX_VIS_TEAMS) < 0) - index = NewTop = 0; + index -= MAX_VIS_TEAMS; + if (index < 0) + { + index = 0; + NewTop = 0; + } else { - if ((NewTop -= MAX_VIS_TEAMS) < 0) + NewTop -= MAX_VIS_TEAMS; + if (NewTop < 0) NewTop = 0; } } else if (PulsedInputState.key[KEY_MENU_PAGE_DOWN]) { - if ((int)(index += MAX_VIS_TEAMS) < + index += MAX_VIS_TEAMS; + if ((int) index < (int)(GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT)) NewTop += MAX_VIS_TEAMS; else @@ -926,7 +968,8 @@ DoLoadTeam (PMELEE_STATE pMS) index = GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - 1; if (index - (MAX_VIS_TEAMS - 1) > NewTop) { - if ((NewTop = index - (MAX_VIS_TEAMS - 1)) < 0) + NewTop = index - (MAX_VIS_TEAMS - 1); + if (NewTop < 0) NewTop = 0; } } @@ -1136,7 +1179,7 @@ DeleteCurrentShip (PMELEE_STATE pMS) UnlockStarShip (&master_q, hStarShip); pMS->TeamImage[pMS->side].ShipList[pMS->row][pMS->col] = (BYTE)~0; - } + } LockMutex (GraphicsLock); GetShipBox (&r, pMS->side, pMS->row, pMS->col); RepairMeleeFrame (&r); @@ -1444,12 +1487,9 @@ LoadMeleeInfo (PMELEE_STATE pMS) if (PickMeleeFrame) DestroyDrawable (ReleaseDrawable (PickMeleeFrame)); PickMeleeFrame = CaptureDrawable (CreateDrawable ( - WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2 - )); + WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2)); s.origin.x = s.origin.y = 0; - s.frame = CaptureDrawable ( - LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM) - ); + s.frame = CaptureDrawable (LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM)); SetContextFGFrame (PickMeleeFrame); DrawStamp (&s); @@ -1458,9 +1498,7 @@ LoadMeleeInfo (PMELEE_STATE pMS) DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); - MeleeFrame = CaptureDrawable ( - LoadGraphic (MELEE_SCREEN_PMAP_ANIM) - ); + MeleeFrame = CaptureDrawable (LoadGraphic (MELEE_SCREEN_PMAP_ANIM)); SetContext (OldContext); @@ -1509,8 +1547,7 @@ BuildAndDrawShipList (PMELEE_STATE pMS) GetFrameRect (s.frame, &r); t.baseline.x = r.extent.width >> 1; - t.baseline.y = r.extent.height - - NAME_AREA_HEIGHT + 4; + t.baseline.y = r.extent.height - NAME_AREA_HEIGHT + 4; r.corner.x += 2; r.corner.y += 2; r.extent.width -= (2 * 2) + (ICON_WIDTH + 2) + 1; @@ -1614,11 +1651,17 @@ DoMelee (PMELEE_STATE pMS) pMS->MeleeOption = EDIT_MELEE; pMS->Initialized = FALSE; if (PulsedInputState.key[KEY_MENU_CANCEL]) - pMS->side = pMS->row = pMS->col = 0; + { + pMS->side = 0; + pMS->row = 0; + pMS->col = 0; + } else - pMS->side = 0, - pMS->row = NUM_MELEE_ROWS - 1, + { + pMS->side = 0; + pMS->row = NUM_MELEE_ROWS - 1; pMS->col = NUM_MELEE_COLUMNS - 1; + } DoEdit (pMS); } else @@ -1700,8 +1743,8 @@ DoMelee (PMELEE_STATE pMS) BYTE black_buf[] = {FadeAllToBlack}; SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR)black_buf, ONE_SECOND / 2 - ) + ONE_SECOND / 60); + (COLORMAPPTR)black_buf, ONE_SECOND / 2) + + ONE_SECOND / 60); FlushColorXForms (); } } while (0 /* !(GLOBAL (CurrentActivity) & CHECK_ABORT) */); diff --git a/sc2/src/sc2code/melee.h b/sc2/src/sc2code/melee.h index 72610e9f6..ff3c7dba5 100644 --- a/sc2/src/sc2code/melee.h +++ b/sc2/src/sc2code/melee.h @@ -19,7 +19,11 @@ #ifndef _MELEE_H #define _MELEE_H +#include "init.h" #include "libs/tasklib.h" +#include "libs/gfxlib.h" +#include "libs/reslib.h" + enum { diff --git a/sc2/src/sc2code/menu.c b/sc2/src/sc2code/menu.c index d36b1717b..f3d9fcdef 100644 --- a/sc2/src/sc2code/menu.c +++ b/sc2/src/sc2code/menu.c @@ -16,12 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "commglue.h" +#include "controls.h" +#include "options.h" +#include "setup.h" #include "libs/graphics/gfx_common.h" #include "libs/tasklib.h" -#include "options.h" -#include "controls.h" + extern Task flash_task; extern RECT flash_rect; diff --git a/sc2/src/sc2code/misc.c b/sc2/src/sc2code/misc.c index b0d46fd66..f66c22831 100644 --- a/sc2/src/sc2code/misc.c +++ b/sc2/src/sc2code/misc.c @@ -16,7 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "element.h" +#include "init.h" +#include "races.h" +#include "setup.h" +#include "sounds.h" +#include "weapon.h" +#include "libs/mathlib.h" + void spawn_planet (void) diff --git a/sc2/src/sc2code/nameref.h b/sc2/src/sc2code/nameref.h index 3f65b5c77..b64e8715f 100644 --- a/sc2/src/sc2code/nameref.h +++ b/sc2/src/sc2code/nameref.h @@ -19,17 +19,21 @@ #ifndef _NAMEREF_H #define _NAMEREF_H +#include "restypes.h" + #define LoadCodeRes(r) LoadCodeResInstance (r) #define LoadColorMap(r) LoadColorMapInstance (r) #define LoadStringTable(r) LoadStringTableInstance(r) #define LoadSound(r) LoadSoundInstance(r) #define LoadMusic(r) LoadMusicInstance(r) -#define INIT_INSTANCES() \ - InstallGraphicResTypes (GFXRES, FONTRES); \ - InstallStringTableResType (STRTAB); \ - InstallAudioResTypes (SNDRES, MUSICRES); \ - InstallCodeResType (CODE) +#define INIT_INSTANCES() do \ + { \ + InstallGraphicResTypes (GFXRES, FONTRES); \ + InstallStringTableResType (STRTAB); \ + InstallAudioResTypes (SNDRES, MUSICRES); \ + InstallCodeResType (CODE); \ + } while (0) #define UNINIT_INSTANCES() #endif /* _NAMEREF_H */ diff --git a/sc2/src/sc2code/oscill.c b/sc2/src/sc2code/oscill.c index abccc34aa..6e50a1ae9 100644 --- a/sc2/src/sc2code/oscill.c +++ b/sc2/src/sc2code/oscill.c @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "sis.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" #include "libs/sound/trackplayer.h" diff --git a/sc2/src/sc2code/outfit.c b/sc2/src/sc2code/outfit.c index 2da655db7..83c0b6bb3 100644 --- a/sc2/src/sc2code/outfit.c +++ b/sc2/src/sc2code/outfit.c @@ -16,16 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "libs/graphics/gfx_common.h" #include "options.h" +#include "colors.h" #include "controls.h" +#include "gamestr.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sis.h" +#include "sounds.h" +#include "state.h" +#include "libs/graphics/gfx_common.h" -//Added by Chris - -void GetGaugeRect (PRECT pRect, BOOLEAN IsCrewRect); - -//End Added by Chris enum { @@ -179,7 +181,10 @@ DoInstallModule (PMENU_STATE pMS) select = PulsedInputState.key[KEY_MENU_SELECT]; cancel = PulsedInputState.key[KEY_MENU_CANCEL]; - motion = PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN]; + motion = PulsedInputState.key[KEY_MENU_LEFT] || + PulsedInputState.key[KEY_MENU_RIGHT] || + PulsedInputState.key[KEY_MENU_UP] || + PulsedInputState.key[KEY_MENU_DOWN]; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); @@ -389,18 +394,21 @@ DoInstallModule (PMENU_STATE pMS) if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 3) { if (NewState == EMPTY_SLOT + 3) - NewState = PulsedInputState.key[KEY_MENU_UP] ? EMPTY_SLOT + 2 : EMPTY_SLOT; + NewState = PulsedInputState.key[KEY_MENU_UP] ? + EMPTY_SLOT + 2 : EMPTY_SLOT; if (NewState == EMPTY_SLOT + 2) NewItem = NUM_BOMB_MODULES; } pMS->delta_item = NewItem; } - else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP]) + else if (PulsedInputState.key[KEY_MENU_LEFT] || + PulsedInputState.key[KEY_MENU_UP]) { if (NewItem-- == FirstItem) NewItem = LastItem; } - else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN]) + else if (PulsedInputState.key[KEY_MENU_RIGHT] || + PulsedInputState.key[KEY_MENU_DOWN]) { if (NewItem++ == LastItem) NewItem = FirstItem; @@ -587,17 +595,14 @@ DoOutfit (PMENU_STATE pMS) extern void DrawFlagshipStats (void); pMS->CurFrame = CaptureDrawable ( - LoadGraphic (MODULES_PMAP_ANIM) - ); + LoadGraphic (MODULES_PMAP_ANIM)); pMS->hMusic = LoadMusicInstance (OUTFIT_MUSIC); pMS->CurState = OUTFIT_FUEL; pMS->ModuleFrame = CaptureDrawable ( - LoadGraphic (SISMODS_MASK_PMAP_ANIM) - ); + LoadGraphic (SISMODS_MASK_PMAP_ANIM)); s.origin.x = s.origin.y = 0; s.frame = CaptureDrawable ( - LoadGraphic (OUTFIT_PMAP_ANIM) - ); + LoadGraphic (OUTFIT_PMAP_ANIM)); SetTransitionSource (NULL); BatchGraphics (); @@ -615,24 +620,24 @@ DoOutfit (PMENU_STATE pMS) { BYTE which_piece; - if ((which_piece = - GLOBAL_SIS (DriveSlots[num_frames])) < EMPTY_SLOT) + which_piece = GLOBAL_SIS (DriveSlots[num_frames]); + if (which_piece < EMPTY_SLOT) DrawShipPiece (pMS, which_piece, num_frames, FALSE); } for (num_frames = 0; num_frames < NUM_JET_SLOTS; ++num_frames) { BYTE which_piece; - if ((which_piece = - GLOBAL_SIS (JetSlots[num_frames])) < EMPTY_SLOT) + which_piece = GLOBAL_SIS (JetSlots[num_frames]); + if (which_piece < EMPTY_SLOT) DrawShipPiece (pMS, which_piece, num_frames, FALSE); } for (num_frames = 0; num_frames < NUM_MODULE_SLOTS; ++num_frames) { BYTE which_piece; - if ((which_piece = - GLOBAL_SIS (ModuleSlots[num_frames])) < EMPTY_SLOT) + which_piece = GLOBAL_SIS (ModuleSlots[num_frames]); + if (which_piece < EMPTY_SLOT) DrawShipPiece (pMS, which_piece, num_frames, FALSE); } RedistributeFuel (); diff --git a/sc2/src/sc2code/pickmele.c b/sc2/src/sc2code/pickmele.c index e154c6d4b..2cebc7152 100644 --- a/sc2/src/sc2code/pickmele.c +++ b/sc2/src/sc2code/pickmele.c @@ -16,8 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "controls.h" +#include "intel.h" #include "melee.h" +#include "races.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "libs/inplib.h" +#include "libs/mathlib.h" + #define NUM_MELEE_COLS_ORIG NUM_MELEE_COLUMNS #define PICK_X_OFFS 57 diff --git a/sc2/src/sc2code/pickship.c b/sc2/src/sc2code/pickship.c index e8aeafbc2..bfe610b9c 100644 --- a/sc2/src/sc2code/pickship.c +++ b/sc2/src/sc2code/pickship.c @@ -16,8 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "colors.h" #include "controls.h" +#include "races.h" +#include "resinst.h" +#include "setup.h" +#include "sounds.h" +#include "libs/mathlib.h" + #define NUM_PICK_SHIP_ROWS 2 #define NUM_PICK_SHIP_COLUMNS 6 diff --git a/sc2/src/sc2code/plandata.c b/sc2/src/sc2code/plandata.c index 58236b5bb..01fc27e07 100644 --- a/sc2/src/sc2code/plandata.c +++ b/sc2/src/sc2code/plandata.c @@ -16,9 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "resinst.h" #include "planets/elemdata.h" + STAR_DESC starmap_array[] = { // postfix name index (like 'Normae') diff --git a/sc2/src/sc2code/planets/calc.c b/sc2/src/sc2code/planets/calc.c index 0ad520012..738754d9e 100644 --- a/sc2/src/sc2code/planets/calc.c +++ b/sc2/src/sc2code/planets/calc.c @@ -17,7 +17,8 @@ */ /* ----------------------------- INCLUDES ---------------------------- */ -#include "starcon.h" +#include "encount.h" +#include "libs/mathlib.h" /* -------------------------------- DATA -------------------------------- */ /* -------------------------------- CODE -------------------------------- */ diff --git a/sc2/src/sc2code/planets/cargo.c b/sc2/src/sc2code/planets/cargo.c index f9324190c..5b1a7cca4 100644 --- a/sc2/src/sc2code/planets/cargo.c +++ b/sc2/src/sc2code/planets/cargo.c @@ -16,15 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "colors.h" #include "controls.h" +#include "gamestr.h" +#include "setup.h" +#include "sounds.h" +#include "util.h" -//Added by Chris void DrawCargoStrings (BYTE OldElement, BYTE NewElement); -//End Added by Chris - void ShowRemainingCapacity (void) { diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index 43e886427..fb4d4983b 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -16,8 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "gamestr.h" #include "controls.h" +#include "settings.h" +#include "setup.h" +#include "state.h" +#include "sounds.h" +#include "util.h" + // If DEBUG_DEVICES is defined, the device list shown in the game will // include the pictures of all devices defined, regardless of which diff --git a/sc2/src/sc2code/planets/elemdata.h b/sc2/src/sc2code/planets/elemdata.h index 175346060..f37dfa386 100644 --- a/sc2/src/sc2code/planets/elemdata.h +++ b/sc2/src/sc2code/planets/elemdata.h @@ -19,6 +19,9 @@ #ifndef _ELEMDATA_H #define _ELEMDATA_H +#include "libs/compiler.h" + + /*------------------------------ Type Defines ----------------------------- */ enum { diff --git a/sc2/src/sc2code/planets/genall.h b/sc2/src/sc2code/planets/genall.h new file mode 100644 index 000000000..dfdb01277 --- /dev/null +++ b/sc2/src/sc2code/planets/genall.h @@ -0,0 +1,25 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GENALL_H +#define _GENALL_H + +#include "planets/planets.h" +#include "libs/compiler.h" + + +#endif /* _GENALL_H */ + diff --git a/sc2/src/sc2code/planets/genburv.c b/sc2/src/sc2code/planets/genburv.c index 5f3d99546..ca201c46c 100644 --- a/sc2/src/sc2code/planets/genburv.c +++ b/sc2/src/sc2code/planets/genburv.c @@ -16,7 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateBurvixes (BYTE control) @@ -152,12 +157,10 @@ GenerateBurvixes (BYTE control) CaptureFont (LoadGraphic (LANDER_FONT)); pSolarSysState->PlanetSideFrame[1] = CaptureDrawable ( - LoadGraphic (RUINS_MASK_PMAP_ANIM) - ); + LoadGraphic (RUINS_MASK_PMAP_ANIM)); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( - LoadStringTable (BURV_RUINS_STRTAB) - ); + LoadStringTable (BURV_RUINS_STRTAB)); pSolarSysState->SysInfo.PlanetInfo.Weather = 0; pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0; } @@ -169,12 +172,10 @@ GenerateBurvixes (BYTE control) CaptureFont (LoadGraphic (LANDER_FONT)); pSolarSysState->PlanetSideFrame[1] = CaptureDrawable ( - LoadGraphic (BURV_BCS_MASK_PMAP_ANIM) - ); + LoadGraphic (BURV_BCS_MASK_PMAP_ANIM)); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( - LoadStringTable (BURV_BCS_STRTAB) - ); + LoadStringTable (BURV_BCS_STRTAB)); } LoadPlanet (FALSE); break; diff --git a/sc2/src/sc2code/planets/genchmmr.c b/sc2/src/sc2code/planets/genchmmr.c index 079b2c9f5..5aaf17a06 100644 --- a/sc2/src/sc2code/planets/genchmmr.c +++ b/sc2/src/sc2code/planets/genchmmr.c @@ -16,8 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "sounds.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateChmmr (BYTE control) @@ -103,8 +113,7 @@ GenerateChmmr (BYTE control) ); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( - LoadStringTable (CHMMR_BASE_STRTAB) - ); + LoadStringTable (CHMMR_BASE_STRTAB)); ScanContext = CaptureContext (CreateContext ()); SetContext (ScanContext); @@ -126,8 +135,7 @@ GenerateChmmr (BYTE control) )); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; DestroyFont (ReleaseFont ( - pSolarSysState->SysInfo.PlanetInfo.LanderFont - )); + pSolarSysState->SysInfo.PlanetInfo.LanderFont)); pSolarSysState->SysInfo.PlanetInfo.LanderFont = 0; UnlockMutex (GraphicsLock); diff --git a/sc2/src/sc2code/planets/gencol.c b/sc2/src/sc2code/planets/gencol.c index ba5cb7c73..9d4b388fe 100644 --- a/sc2/src/sc2code/planets/gencol.c +++ b/sc2/src/sc2code/planets/gencol.c @@ -16,7 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "globdata.h" +#include "state.h" +#include "planets/genall.h" + void GenerateColony (BYTE control) diff --git a/sc2/src/sc2code/planets/gendru.c b/sc2/src/sc2code/planets/gendru.c index d14e77074..8ba263ffb 100644 --- a/sc2/src/sc2code/planets/gendru.c +++ b/sc2/src/sc2code/planets/gendru.c @@ -16,8 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateDruuge (BYTE control) diff --git a/sc2/src/sc2code/planets/genilw.c b/sc2/src/sc2code/planets/genilw.c index 8533ecb58..324e24238 100644 --- a/sc2/src/sc2code/planets/genilw.c +++ b/sc2/src/sc2code/planets/genilw.c @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateIlwrath (BYTE control) diff --git a/sc2/src/sc2code/planets/genmel.c b/sc2/src/sc2code/planets/genmel.c index 98ed2258f..33202b1c3 100644 --- a/sc2/src/sc2code/planets/genmel.c +++ b/sc2/src/sc2code/planets/genmel.c @@ -16,7 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "state.h" +#include "planets/genall.h" + + static DWORD GetMelnormeRef (void) diff --git a/sc2/src/sc2code/planets/genmyc.c b/sc2/src/sc2code/planets/genmyc.c index 7bb0057e7..20bcf2b5b 100644 --- a/sc2/src/sc2code/planets/genmyc.c +++ b/sc2/src/sc2code/planets/genmyc.c @@ -16,7 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateMycon (BYTE control) diff --git a/sc2/src/sc2code/planets/genorz.c b/sc2/src/sc2code/planets/genorz.c index cd679be60..95d571e98 100644 --- a/sc2/src/sc2code/planets/genorz.c +++ b/sc2/src/sc2code/planets/genorz.c @@ -16,8 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "sounds.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + static void GenerateAndrosynth (BYTE control) diff --git a/sc2/src/sc2code/planets/genpet.c b/sc2/src/sc2code/planets/genpet.c index 365bf0654..432051af3 100644 --- a/sc2/src/sc2code/planets/genpet.c +++ b/sc2/src/sc2code/planets/genpet.c @@ -16,7 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + static void ZapToUrquanEncounter (void) diff --git a/sc2/src/sc2code/planets/genpku.c b/sc2/src/sc2code/planets/genpku.c index a904d4ff4..a43ad0618 100644 --- a/sc2/src/sc2code/planets/genpku.c +++ b/sc2/src/sc2code/planets/genpku.c @@ -16,8 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GeneratePkunk (BYTE control) diff --git a/sc2/src/sc2code/planets/genrain.c b/sc2/src/sc2code/planets/genrain.c index f9d9aea7f..99c272316 100644 --- a/sc2/src/sc2code/planets/genrain.c +++ b/sc2/src/sc2code/planets/genrain.c @@ -16,7 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "globdata.h" +#include "planets/genall.h" + void GenerateRainbow (BYTE control) diff --git a/sc2/src/sc2code/planets/gensam.c b/sc2/src/sc2code/planets/gensam.c index 9a580cd24..db481f6c7 100644 --- a/sc2/src/sc2code/planets/gensam.c +++ b/sc2/src/sc2code/planets/gensam.c @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "resinst.h" +#include "races.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + static void BuildUrquanGuard (void) diff --git a/sc2/src/sc2code/planets/genshof.c b/sc2/src/sc2code/planets/genshof.c index 675706c3c..81e11f4d0 100644 --- a/sc2/src/sc2code/planets/genshof.c +++ b/sc2/src/sc2code/planets/genshof.c @@ -16,7 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "globdata.h" +#include "state.h" +#include "planets/genall.h" + static void check_old_shofixti (void) @@ -24,17 +28,14 @@ check_old_shofixti (void) HSTARSHIP hStarShip; if (GLOBAL (BattleGroupRef) - && (hStarShip = GetHeadLink ( - &GLOBAL (npc_built_ship_q) - )) + && (hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q))) && GET_GAME_STATE (SHOFIXTI_RECRUITED)) { BYTE task; SHIP_FRAGMENTPTR FragPtr; FragPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (npc_built_ship_q), hStarShip - ); + &GLOBAL (npc_built_ship_q), hStarShip); task = GET_GROUP_MISSION (FragPtr); SET_GROUP_MISSION (FragPtr, diff --git a/sc2/src/sc2code/planets/gensly.c b/sc2/src/sc2code/planets/gensly.c index 894615cbb..1614b9eb9 100644 --- a/sc2/src/sc2code/planets/gensly.c +++ b/sc2/src/sc2code/planets/gensly.c @@ -16,7 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "resinst.h" +#include "planets/genall.h" + void GenerateSlylandro (BYTE control) diff --git a/sc2/src/sc2code/planets/gensol.c b/sc2/src/sc2code/planets/gensol.c index 7a97d2e6e..952a5ef79 100644 --- a/sc2/src/sc2code/planets/gensol.c +++ b/sc2/src/sc2code/planets/gensol.c @@ -16,9 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "lifeform.h" +#include "build.h" +#include "gamestr.h" +#include "globdata.h" #include "lander.h" +#include "lifeform.h" +#include "nameref.h" +#include "races.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + static DWORD GetProbeRef (void) diff --git a/sc2/src/sc2code/planets/genspa.c b/sc2/src/sc2code/planets/genspa.c index b5e4ca6dc..21924cbe0 100644 --- a/sc2/src/sc2code/planets/genspa.c +++ b/sc2/src/sc2code/planets/genspa.c @@ -16,8 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lifeform.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateSpathi (BYTE control) diff --git a/sc2/src/sc2code/planets/gensup.c b/sc2/src/sc2code/planets/gensup.c index a7ea7b77d..ff23cf9c1 100644 --- a/sc2/src/sc2code/planets/gensup.c +++ b/sc2/src/sc2code/planets/gensup.c @@ -16,8 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" void GenerateSupox (BYTE control) diff --git a/sc2/src/sc2code/planets/gensyr.c b/sc2/src/sc2code/planets/gensyr.c index d7d7e7674..be5992c70 100644 --- a/sc2/src/sc2code/planets/gensyr.c +++ b/sc2/src/sc2code/planets/gensyr.c @@ -16,7 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "resinst.h" +#include "planets/genall.h" + static void GenerateTrap (BYTE control) diff --git a/sc2/src/sc2code/planets/genthrad.c b/sc2/src/sc2code/planets/genthrad.c index 433051e6a..fa9693b61 100644 --- a/sc2/src/sc2code/planets/genthrad.c +++ b/sc2/src/sc2code/planets/genthrad.c @@ -16,7 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateThradd (BYTE control) diff --git a/sc2/src/sc2code/planets/genutw.c b/sc2/src/sc2code/planets/genutw.c index f8c0fb076..f52ae90c1 100644 --- a/sc2/src/sc2code/planets/genutw.c +++ b/sc2/src/sc2code/planets/genutw.c @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" void GenerateUtwig (BYTE control) diff --git a/sc2/src/sc2code/planets/genvault.c b/sc2/src/sc2code/planets/genvault.c index 9ff735505..25456f020 100644 --- a/sc2/src/sc2code/planets/genvault.c +++ b/sc2/src/sc2code/planets/genvault.c @@ -16,8 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateShipVault (BYTE control) diff --git a/sc2/src/sc2code/planets/genvux.c b/sc2/src/sc2code/planets/genvux.c index fcc72d5f8..f7bc740ae 100644 --- a/sc2/src/sc2code/planets/genvux.c +++ b/sc2/src/sc2code/planets/genvux.c @@ -16,9 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" #include "lander.h" #include "lifeform.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "state.h" +#include "sounds.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateVUX (BYTE control) diff --git a/sc2/src/sc2code/planets/genwreck.c b/sc2/src/sc2code/planets/genwreck.c index a8cf1a3df..064223397 100644 --- a/sc2/src/sc2code/planets/genwreck.c +++ b/sc2/src/sc2code/planets/genwreck.c @@ -16,8 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "globdata.h" #include "lander.h" +#include "nameref.h" +#include "resinst.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateUrquanWreck (BYTE control) diff --git a/sc2/src/sc2code/planets/genyeh.c b/sc2/src/sc2code/planets/genyeh.c index d3e99c729..47893affc 100644 --- a/sc2/src/sc2code/planets/genyeh.c +++ b/sc2/src/sc2code/planets/genyeh.c @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + void GenerateYehat (BYTE control) diff --git a/sc2/src/sc2code/planets/genzoq.c b/sc2/src/sc2code/planets/genzoq.c index e0e0a3eb0..970f022ee 100644 --- a/sc2/src/sc2code/planets/genzoq.c +++ b/sc2/src/sc2code/planets/genzoq.c @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "encount.h" +#include "globdata.h" +#include "nameref.h" +#include "resinst.h" +#include "state.h" +#include "planets/genall.h" +#include "libs/mathlib.h" + static void check_scout (void) diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index 981acb8e2..e396bd9ee 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -16,11 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "controls.h" +#include "colors.h" +#include "encount.h" +#include "gamestr.h" #include "lander.h" #include "lifeform.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/gfx_common.h" -#include "controls.h" +#include "libs/mathlib.h" + //define SPIN_ON_LAUNCH to let the planet spin while // the lander animation is playing diff --git a/sc2/src/sc2code/planets/lander.h b/sc2/src/sc2code/planets/lander.h index 286b0595b..db2f0a606 100644 --- a/sc2/src/sc2code/planets/lander.h +++ b/sc2/src/sc2code/planets/lander.h @@ -19,6 +19,12 @@ #ifndef _LANDER_H #define _LANDER_H +#include "planets/elemdata.h" +#include "libs/compiler.h" +#include "libs/gfxlib.h" +#include "libs/sndlib.h" + + #define NUM_TEXT_FRAMES 32 typedef struct diff --git a/sc2/src/sc2code/planets/lifeform.h b/sc2/src/sc2code/planets/lifeform.h index b711a8706..ca9d49d22 100644 --- a/sc2/src/sc2code/planets/lifeform.h +++ b/sc2/src/sc2code/planets/lifeform.h @@ -19,6 +19,9 @@ #ifndef _LIFEFORM_H #define _LIFEFORM_H +#include "libs/compiler.h" + + #define BEHAVIOR_HUNT (0 << 0) #define BEHAVIOR_FLEE (1 << 0) #define BEHAVIOR_UNPREDICTABLE (2 << 0) diff --git a/sc2/src/sc2code/planets/orbits.c b/sc2/src/sc2code/planets/orbits.c index f21b5e49e..b3fd3f470 100644 --- a/sc2/src/sc2code/planets/orbits.c +++ b/sc2/src/sc2code/planets/orbits.c @@ -16,7 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "planets/planets.h" +#include "libs/compiler.h" +#include "libs/mathlib.h" + //#define DEBUG_ORBITS diff --git a/sc2/src/sc2code/planets/oval.c b/sc2/src/sc2code/planets/oval.c index 7506a384c..bc0d4e8de 100644 --- a/sc2/src/sc2code/planets/oval.c +++ b/sc2/src/sc2code/planets/oval.c @@ -16,8 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "graphics/gfxintrn.h" -#include "starcon.h" +#include "units.h" +#include "dummy.h" +#include "libs/gfxlib.h" +#include "graphics/context.h" +#include "graphics/drawable.h" + #define NUM_QUADS 4 diff --git a/sc2/src/sc2code/planets/pl_stuff.c b/sc2/src/sc2code/planets/pl_stuff.c index e2e922d87..8dd918bfb 100644 --- a/sc2/src/sc2code/planets/pl_stuff.c +++ b/sc2/src/sc2code/planets/pl_stuff.c @@ -16,16 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "planets/planets.h" +#include "setup.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" #include + + // define USE_ADDITIVE_SCAN_BLIT to use additive blittting // instead of transparency for the planet scans. // It still doesn't look right though (it is too bright) #define USE_ADDITIVE_SCAN_BLIT + DWORD frame_mapRGBA (FRAME FramePtr,UBYTE r, UBYTE g, UBYTE b, UBYTE a); DWORD frame_mapRGBA (FRAME FramePtr,UBYTE r, UBYTE g, UBYTE b, UBYTE a); diff --git a/sc2/src/sc2code/planets/plandata.h b/sc2/src/sc2code/planets/plandata.h index afcc3dabe..3bfc0d74e 100644 --- a/sc2/src/sc2code/planets/plandata.h +++ b/sc2/src/sc2code/planets/plandata.h @@ -19,6 +19,9 @@ #ifndef _PLANDATA_H #define _PLANDATA_H +#include "libs/reslib.h" + + /*------------------------------ Type Defines ----------------------------- */ #define NUMBER_OF_ORBITS 16 #define VACANT 0xFF diff --git a/sc2/src/sc2code/planets/planets.c b/sc2/src/sc2code/planets/planets.c index 062f25685..24c8aabbb 100644 --- a/sc2/src/sc2code/planets/planets.c +++ b/sc2/src/sc2code/planets/planets.c @@ -16,10 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "element.h" #include "scan.h" +#include "settings.h" +#include "setup.h" #include "libs/graphics/gfx_common.h" + //Added by Chris void diff --git a/sc2/src/sc2code/planets/planets.h b/sc2/src/sc2code/planets/planets.h index b1e8ed7d2..841827d10 100644 --- a/sc2/src/sc2code/planets/planets.h +++ b/sc2/src/sc2code/planets/planets.h @@ -19,6 +19,9 @@ #ifndef _PLANETS_H #define _PLANETS_H +#include "starbase.h" +#include "units.h" + #define END_INTERPLANETARY START_INTERPLANETARY enum diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index c28fb9d0f..5f353e83a 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -16,11 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "dummy.h" +#include "nameref.h" +#include "resinst.h" +#include "setup.h" +#include "planets/planets.h" #include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" + #include #include + #define PROFILE 1 #define ROTATION_TIME 12 @@ -40,7 +47,8 @@ void SetPlanetTilt (int da); void RepairBackRect (PRECT pRect); -PRECT RotatePlanet (int x, int dx, int dy, COUNT scale_amt, UBYTE zoom_from, PRECT r); +PRECT RotatePlanet (int x, int dx, int dy, COUNT scale_amt, UBYTE zoom_from, + PRECT r); DWORD frame_mapRGBA (FRAME FramePtr,UBYTE r, UBYTE g, UBYTE b, UBYTE a); @@ -48,7 +56,8 @@ void process_rgb_bmp (FRAME FramePtr, DWORD *rgba, int maxx, int maxy); FRAME stretch_frame (FRAME FramePtr, int neww, int newh,int destroy); -void fill_frame_rgb (FRAME FramePtr, DWORD color, int x0, int y0, int x, int y); +void fill_frame_rgb (FRAME FramePtr, DWORD color, int x0, int y0, + int x, int y); void arith_frame_blit (FRAME srcFrame, RECT *rsrc, FRAME dstFrame, RECT *rdst, int num, int denom); @@ -142,7 +151,8 @@ RenderTopography (BOOLEAN Reconstruct) HOT_SPOT OldHot; RECT ClipRect; - OldHot = SetFrameHot (pSolarSysState->TopoFrame, MAKE_HOT_SPOT (0, 0)); + OldHot = SetFrameHot (pSolarSysState->TopoFrame, + MAKE_HOT_SPOT (0, 0)); GetContextClipRect (&ClipRect); SetContextClipRect (NULL_PTR); SetContextClipping (FALSE); @@ -204,7 +214,8 @@ RenderTopography (BOOLEAN Reconstruct) // fixed planet surfaces being too dark // ctab shifts were previously >> 3 .. -Mika - SetPrimColor (pBatch, BUILD_COLOR (MAKE_RGB15 (ctab[0] >> 1, ctab[1] >> 1, ctab[2] >> 1), d)); + SetPrimColor (pBatch, BUILD_COLOR (MAKE_RGB15 (ctab[0] >> 1, + ctab[1] >> 1, ctab[2] >> 1), d)); } if (--i) @@ -241,11 +252,11 @@ void P3sub (POINT3 *res, POINT3 *v1, POINT3 *v2) res->y = v1->y - v2->y; res->z = v1->z - v2->z; } -double P3dot (POINT3 *v1, POINT3 *v2) +double P3dot (POINT3 *v1, POINT3 *v2) { return (v1->x * v2->x + v1->y * v2->y + v1->z * v2->z); } -void P3norm (POINT3 *res, POINT3 *vec) +void P3norm (POINT3 *res, POINT3 *vec) { double mag = sqrt (P3dot (vec, vec)); P3mult (res, vec, 1/mag); @@ -298,15 +309,18 @@ RenderPhongMask (POINT loc) // norm is the sphere's surface normal. norm.x = (double)x; norm.y = (double)y; - norm.z = (sqrt (RADIUS_2 - x_2) * sqrt (RADIUS_2 - y_2)) / RADIUS; + norm.z = (sqrt (RADIUS_2 - x_2) * sqrt (RADIUS_2 - y_2)) / + RADIUS; P3norm(&norm,&norm); // diffuse component is norm dot light diff =P3dot (&norm, &light); // negative diffuse is bad if(diff < 0) diff = 0.0; - // specular highlight is the phong equation: (rvec dot view)^MSHI - // where rvec = (2*diff)*norm - light (reflection of light around norm) + // specular highlight is the phong equation: + // (rvec dot view)^MSHI + // where rvec = (2*diff)*norm - light (reflection of light + // around norm) P3mult (&rvec,&norm,2 * diff); P3sub (&rvec, &rvec, &light); fb = P3dot (&rvec, &view); @@ -317,8 +331,10 @@ RenderPhongMask (POINT loc) // adjust for the ambient light if (diff < AMBIENT_LIGHT) diff = AMBIENT_LIGHT; - // stepint allows us multiply by a ratio without usig floating-point - // instead of color*diff, we use ((color << 24) - stepint*color) >> 24 + // stepint allows us multiply by a ratio without using + // floating-point. + // instead of color*diff, we use ((color << 24) - + // stepint*color) >> 24 stepint = step - (DWORD)(diff * step + 0.5); // Now we antialias the edge of the spere to look nice if(rad_2 > (RADIUS - 1) * (RADIUS - 1)) @@ -547,7 +563,8 @@ static void CreateShieldMask (void) { DWORD r; r = rad2 - ((RADIUS + 1) * (RADIUS + 1)); - red = (UBYTE)red - (red * r / (SHIELD_RADIUS_2 - RADIUS_2 + 1)); + red = (UBYTE)red - (red * r / (SHIELD_RADIUS_2 - + RADIUS_2 + 1)); } p = frame_mapRGBA (ShieldFrame, red, 0, 0, 255); } @@ -559,7 +576,8 @@ static void CreateShieldMask (void) } } process_rgb_bmp (ShieldFrame, rgba, SHIELD_DIAM, SHIELD_DIAM); - SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS + 1,SHIELD_RADIUS + 1)); + SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS + 1, + SHIELD_RADIUS + 1)); { // Applythe shield to the topo data UBYTE a; @@ -575,7 +593,8 @@ static void CreateShieldMask (void) #endif p = frame_mapRGBA (tintFrame, 255, 0, 0, a); fill_frame_rgb (tintFrame, p, 0, 0, 0, 0); - arith_frame_blit (tintFrame, NULL, pSolarSysState->TopoFrame, NULL, 0, blit_type); + arith_frame_blit (tintFrame, NULL, pSolarSysState->TopoFrame, NULL, + 0, blit_type); } } @@ -601,8 +620,9 @@ RenderLevelMasks (int offset) #endif rgba = pSolarSysState->Orbit.ScratchArray; p_rgba = rgba; - // Choose the correct Frame to wrte to - MaskFrame = SetAbsFrameIndex (pSolarSysState->Orbit.PlanetFrameArray, (COUNT)(offset + 1)); + // Choose the correct Frame to write to + MaskFrame = SetAbsFrameIndex (pSolarSysState->Orbit.PlanetFrameArray, + (COUNT)(offset + 1)); pixels = pSolarSysState->Orbit.lpTopoMap; for (pt.y = 0, y = -RADIUS; pt.y <= TWORADIUS; ++pt.y, ++y) { @@ -620,19 +640,22 @@ RenderLevelMasks (int offset) { if (ppt->m[0] == 0) { - p = pixels[PT_TO_ADDR (ppt->p[0].y, ppt->p[0].x) + offset]; + p = pixels[PT_TO_ADDR (ppt->p[0].y, ppt->p[0].x) + + offset]; c[0] = (UBYTE)(p >> 8); c[1] = (UBYTE)(p >> 16); c[2] = (UBYTE)(p >> 24); - } + } else { for (i = 0; i < 4; i++) - p1[i]=pixels[PT_TO_ADDR (ppt->p[i].y, ppt->p[i].x) + offset]; + p1[i] = pixels[PT_TO_ADDR (ppt->p[i].y, ppt->p[i].x) + + offset]; for (i = 1; i < 4; i++) c[i-1] = get_avg_rgb (p1, ppt->m, i); } - // Apply the lighting model. This also bounds the sphere to make it circular + // Apply the lighting model. This also bounds the sphere + // to make it circular. if (pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) { c[2] = GET_LIGHT (255, diffus, spec); @@ -735,13 +758,17 @@ DitherMap (PSBYTE DepthArray) rand_val = TFB_Random (); *lpDst++ += (SBYTE) ((1 << (RANGE_SHIFT - 4)) - - (LOBYTE (LOWORD (rand_val)) & ((1 << (RANGE_SHIFT - 3)) - 1))); + - (LOBYTE (LOWORD (rand_val)) & + ((1 << (RANGE_SHIFT - 3)) - 1))); *lpDst++ += (SBYTE) ((1 << (RANGE_SHIFT - 4)) - - (HIBYTE (LOWORD (rand_val)) & ((1 << (RANGE_SHIFT - 3)) - 1))); + - (HIBYTE (LOWORD (rand_val)) & + ((1 << (RANGE_SHIFT - 3)) - 1))); *lpDst++ += (SBYTE) ((1 << (RANGE_SHIFT - 4)) - - (LOBYTE (HIWORD (rand_val)) & ((1 << (RANGE_SHIFT - 3)) - 1))); + - (LOBYTE (HIWORD (rand_val)) & + ((1 << (RANGE_SHIFT - 3)) - 1))); *lpDst++ += (SBYTE) ((1 << (RANGE_SHIFT - 4)) - - (HIBYTE (HIWORD (rand_val)) & ((1 << (RANGE_SHIFT - 3)) - 1))); + - (HIBYTE (HIWORD (rand_val)) & + ((1 << (RANGE_SHIFT - 3)) - 1))); } while (--i); } @@ -784,8 +811,10 @@ MakeCrater (PRECT pRect, PSBYTE DepthArray, SIZE rim_delta, SIZE rt_x = A + x; if (SetDepth) { - memset ((PSBYTE)&DepthArray[TopIndex + lf_x], 0, rt_x - lf_x + 1); - memset ((PSBYTE)&DepthArray[BotIndex + lf_x], 0, rt_x - lf_x + 1); + memset ((PSBYTE)&DepthArray[TopIndex + lf_x], 0, + rt_x - lf_x + 1); + memset ((PSBYTE)&DepthArray[BotIndex + lf_x], 0, + rt_x - lf_x + 1); } if (lf_x == rt_x) { @@ -1190,22 +1219,21 @@ void planet_orbit_init () Orbit->isPFADefined = (BYTE *)HCalloc (sizeof(BYTE) * MAP_WIDTH); Orbit->PlanetFrameArray = CaptureDrawable ( - CreateDrawable (WANT_PIXMAP, DIAMETER, DIAMETER, (COUNT)MAP_WIDTH) - ); + CreateDrawable (WANT_PIXMAP, DIAMETER, DIAMETER, + (COUNT)MAP_WIDTH)); Orbit->TintFrame = CaptureDrawable ( - CreateDrawable (WANT_PIXMAP, (SWORD)MAP_WIDTH, (SWORD)MAP_HEIGHT, 2) - ); + CreateDrawable (WANT_PIXMAP, (SWORD)MAP_WIDTH, + (SWORD)MAP_HEIGHT, 2)); Orbit->ShieldFrame = CaptureDrawable ( - CreateDrawable (WANT_PIXMAP, SHIELD_DIAM, SHIELD_DIAM, 1) - ); + CreateDrawable (WANT_PIXMAP, SHIELD_DIAM, SHIELD_DIAM, 1)); Orbit->lpTopoData = HMalloc (MAP_WIDTH * MAP_HEIGHT); Orbit->TopoZoomFrame = CaptureDrawable ( CreateDrawable (WANT_PIXMAP, (COUNT)(MAP_WIDTH << 2), (COUNT)(MAP_HEIGHT << 2), 1)); - Orbit->lpTopoMap=(DWORD *)HMalloc (sizeof(DWORD) + Orbit->lpTopoMap=(DWORD *)HMalloc (sizeof(DWORD) * (MAP_HEIGHT * (MAP_WIDTH + MAP_HEIGHT))); - Orbit->ScratchArray = (DWORD *)HMalloc (sizeof (DWORD *) + Orbit->ScratchArray = (DWORD *)HMalloc (sizeof (DWORD *) * (SHIELD_DIAM) * (SHIELD_DIAM)); } @@ -1254,7 +1282,8 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth) case CRATERED_ALGO: if (PlanDataPtr->num_faults) DeltaTopography (PlanDataPtr->num_faults, - Orbit->lpTopoData, &r, PlanDataPtr->fault_depth); + Orbit->lpTopoData, &r, + PlanDataPtr->fault_depth); for (i = 0; i < PlanDataPtr->num_blemishes; ++i) { @@ -1303,45 +1332,48 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth) } } pSolarSysState->TopoFrame = CaptureDrawable ( - CreateDrawable (WANT_PIXMAP, (SIZE)MAP_WIDTH, (SIZE)MAP_HEIGHT, 1) - ); + CreateDrawable (WANT_PIXMAP, (SIZE)MAP_WIDTH, + (SIZE)MAP_HEIGHT, 1)); pSolarSysState->OrbitalCMap = CaptureColorMap ( - LoadColorMap (PlanDataPtr->CMapInstance) - ); + LoadColorMap (PlanDataPtr->CMapInstance)); pSolarSysState->XlatRef = CaptureStringTable ( - LoadStringTable (PlanDataPtr->XlatTabInstance) - ); + LoadStringTable (PlanDataPtr->XlatTabInstance)); - if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > HOT_THRESHOLD) + if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > + HOT_THRESHOLD) { pSolarSysState->OrbitalCMap = SetAbsColorMapIndex ( - pSolarSysState->OrbitalCMap, 2 - ); - pSolarSysState->XlatRef = SetAbsStringTableIndex (pSolarSysState->XlatRef, 2); + pSolarSysState->OrbitalCMap, 2); + pSolarSysState->XlatRef = SetAbsStringTableIndex ( + pSolarSysState->XlatRef, 2); } - else if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > COLD_THRESHOLD) + else if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > + COLD_THRESHOLD) { pSolarSysState->OrbitalCMap = SetAbsColorMapIndex ( - pSolarSysState->OrbitalCMap, 1 - ); - pSolarSysState->XlatRef = SetAbsStringTableIndex (pSolarSysState->XlatRef, 1); + pSolarSysState->OrbitalCMap, 1); + pSolarSysState->XlatRef = SetAbsStringTableIndex ( + pSolarSysState->XlatRef, 1); } pSolarSysState->XlatPtr = GetStringAddress (pSolarSysState->XlatRef); RenderTopography (FALSE); } // Generate a pixel array fromthe Topography map. - // We use this instead of lpTopoData because it needs to be WAP_WIDTH+MAP_HEIGHT wide - // and we need this method for Earth anyway. It may be more efficient to build it - // from lpTopoData instead of the FRAMPTR though + // We use this instead of lpTopoData because it needs to be + // WAP_WIDTH+MAP_HEIGHT wide and we need this method for Earth anyway. + // It may be more efficient to build it from lpTopoData instead of the + // FRAMPTR though. x = MAP_WIDTH + MAP_HEIGHT; y = MAP_HEIGHT; scale16xRandomizeFrame(Orbit->TopoZoomFrame, pSolarSysState->TopoFrame); getpixelarray (Orbit->lpTopoMap, pSolarSysState->TopoFrame, x, y); // Extend the width from MAP_WIDTH to MAP_WIDTH+MAP_HEIGHT - for (y = 0; y < MAP_HEIGHT * (MAP_WIDTH + MAP_HEIGHT); y+= MAP_WIDTH + MAP_HEIGHT) + for (y = 0; y < MAP_HEIGHT * (MAP_WIDTH + MAP_HEIGHT); + y += MAP_WIDTH + MAP_HEIGHT) for (x = 0; x < MAP_HEIGHT; x++) - Orbit->lpTopoMap[y + x + MAP_WIDTH] = Orbit->lpTopoMap[y +x]; - if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0]) + Orbit->lpTopoMap[y + x + MAP_WIDTH] = Orbit->lpTopoMap[y + x]; + if (pSolarSysState->pOrbitalDesc->pPrevDesc == + &pSolarSysState->SunDesc[0]) { // This is a planet. Get its location loc = pSolarSysState->pOrbitalDesc->location; @@ -1380,7 +1412,8 @@ rotate_planet_task (void *data) zooming = TRUE; pSS = pSolarSysState; - while (*(volatile SIZE *)&pSS->MenuState.Initialized < 2 && !Task_ReadState (task, TASK_EXIT)) + while (*(volatile SIZE *)&pSS->MenuState.Initialized < 2 && + !Task_ReadState (task, TASK_EXIT)) TaskSwitch (); // SetPlanetTilt ((pSS->SysInfo.PlanetInfo.AxialTilt << 8) / 360); @@ -1424,8 +1457,7 @@ rotate_planet_task (void *data) pSS->PauseRotate = 1; repair = RotatePlanet (x, SIS_SCREEN_WIDTH >> 1, - (148 - SIS_ORG_Y) >> 1, zoom_amt, zoom_from, repair - ); + (148 - SIS_ORG_Y) >> 1, zoom_amt, zoom_from, repair); if (!repair && zooming) { @@ -1448,18 +1480,22 @@ rotate_planet_task (void *data) frame_num++; if (frame_num > zoom_frames) { - fprintf (stderr, "rotate_planet_task() : zoom frame out of bounds!\n"); + fprintf (stderr, "rotate_planet_task() : zoom frame " + "out of bounds!\n"); frame_num = zoom_frames; } zoom_amt = zoom_arr[frame_num]; } - SleepThreadUntil (TimeIn + (ONE_SECOND * ROTATION_TIME) / (MAP_WIDTH)); + SleepThreadUntil (TimeIn + (ONE_SECOND * ROTATION_TIME) / + (MAP_WIDTH)); // SleepThreadUntil (TimeIn + (ONE_SECOND * 5 / (MAP_WIDTH-32))); TimeIn = GetTimeCounter (); } while (--view_index && !Task_ReadState (task, TASK_EXIT)); } FinishTask (task); - return(0); + return 0; } + + diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index dc568b4a5..8bce97cca 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -16,12 +16,21 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "libs/graphics/gfx_common.h" -#include "options.h" +#include "colors.h" #include "controls.h" -#include "libs/inplib.h" +#include "encount.h" +#include "gamestr.h" +#include "globdata.h" +#include "options.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "state.h" #include "uqmdebug.h" +#include "libs/inplib.h" +#include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" + //Added by Chris diff --git a/sc2/src/sc2code/planets/report.c b/sc2/src/sc2code/planets/report.c index fd8f266aa..62ade76bc 100644 --- a/sc2/src/sc2code/planets/report.c +++ b/sc2/src/sc2code/planets/report.c @@ -16,10 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include "starcon.h" -#include "lander.h" +#include "colors.h" +#include "controls.h" +#include "dummy.h" +#include "gamestr.h" #include "options.h" +#include "setup.h" +#include "sounds.h" +#include "planets/lander.h" +#include "planets/planets.h" +#include "libs/inplib.h" + +#include +#include + #define NUM_CELL_COLS MAP_WIDTH / 6 #define NUM_CELL_ROWS MAP_HEIGHT / 6 @@ -152,7 +162,8 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen) font_DrawText (&t); UnlockMutex (GraphicsLock); - PlaySound (ReadOutSounds, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlaySound (ReadOutSounds, NotPositional (), NULL, + GAME_SOUND_PRIORITY); if (t.pStr[0] == ',') TimeOut += ONE_SECOND / 4; diff --git a/sc2/src/sc2code/planets/roster.c b/sc2/src/sc2code/planets/roster.c index 777ffb984..fec550508 100644 --- a/sc2/src/sc2code/planets/roster.c +++ b/sc2/src/sc2code/planets/roster.c @@ -16,11 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "colors.h" #include "controls.h" +#include "races.h" +#include "setup.h" +#include "sounds.h" +#include "libs/gfxlib.h" +#include "libs/tasklib.h" + int -flash_ship_task(void *data) +flash_ship_task (void *data) { DWORD TimeIn; COLOR c; @@ -38,14 +45,10 @@ flash_ship_task(void *data) LockMutex (GraphicsLock); s.origin = pMenuState->first_item; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), - (HSTARSHIP)pMenuState->CurFrame - ); + &GLOBAL (built_ship_q), (HSTARSHIP)pMenuState->CurFrame); s.frame = StarShipPtr->ShipInfo.icons; - UnlockStarShip ( - &GLOBAL (built_ship_q), - (HSTARSHIP)pMenuState->CurFrame - ); + UnlockStarShip (&GLOBAL (built_ship_q), + (HSTARSHIP)pMenuState->CurFrame); OldContext = SetContext (StatusContext); if (c >= BUILD_COLOR (MAKE_RGB15 (0x1F, 0x19, 0x19), 0x24)) c = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x24); @@ -60,7 +63,7 @@ flash_ship_task(void *data) TimeIn = GetTimeCounter (); } FinishTask (task); - return(0); + return 0; } static HSTARSHIP @@ -76,29 +79,20 @@ MatchSupportShip (PMENU_STATE pMS) SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); + &GLOBAL (built_ship_q), hStarShip); if (pship_pos->x == pMS->first_item.x && pship_pos->y == pMS->first_item.y) { - UnlockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); - - return (hStarShip); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); + return hStarShip; } hNextShip = _GetSuccLink (StarShipPtr); - UnlockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); } - return (0); + return 0; } static void @@ -109,16 +103,11 @@ DeltaSupportCrew (SIZE crew_delta) SHIP_FRAGMENTPTR StarShipPtr, TemplatePtr; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), - (HSTARSHIP)pMenuState->CurFrame - ); - hTemplate = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), - GET_RACE_ID (StarShipPtr) - ); + &GLOBAL (built_ship_q), (HSTARSHIP)pMenuState->CurFrame); + hTemplate = GetStarShipFromIndex (&GLOBAL (avail_race_q), + GET_RACE_ID (StarShipPtr)); TemplatePtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hTemplate - ); + &GLOBAL (avail_race_q), hTemplate); StarShipPtr->ShipInfo.crew_level += crew_delta; @@ -153,13 +142,8 @@ DeltaSupportCrew (SIZE crew_delta) } } - UnlockStarShip ( - &GLOBAL (avail_race_q), hTemplate - ); - UnlockStarShip ( - &GLOBAL (built_ship_q), - (HSTARSHIP)pMenuState->CurFrame - ); + UnlockStarShip (&GLOBAL (avail_race_q), hTemplate); + UnlockStarShip (&GLOBAL (built_ship_q), (HSTARSHIP)pMenuState->CurFrame); } #define SHIP_TOGGLE ((BYTE)(1 << 7)) @@ -183,14 +167,9 @@ RosterCleanup (PMENU_STATE pMS) SetContext (StatusContext); s.origin = pMS->first_item; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), - (HSTARSHIP)pMS->CurFrame - ); + &GLOBAL (built_ship_q), (HSTARSHIP)pMS->CurFrame); s.frame = StarShipPtr->ShipInfo.icons; - UnlockStarShip ( - &GLOBAL (built_ship_q), - (HSTARSHIP)pMS->CurFrame - ); + UnlockStarShip (&GLOBAL (built_ship_q), (HSTARSHIP)pMS->CurFrame); if (!(pMS->CurState & SHIP_TOGGLE)) DrawStamp (&s); else @@ -218,18 +197,20 @@ DoModifyRoster (PMENU_STATE pMS) UnlockMutex (GraphicsLock); pMS->CurFrame = 0; - return (FALSE); + return FALSE; } select = PulsedInputState.key[KEY_MENU_SELECT]; cancel = PulsedInputState.key[KEY_MENU_CANCEL]; up = PulsedInputState.key[KEY_MENU_UP]; down = PulsedInputState.key[KEY_MENU_DOWN]; - horiz = PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT]; + horiz = PulsedInputState.key[KEY_MENU_LEFT] || + PulsedInputState.key[KEY_MENU_RIGHT]; if (pMS->Initialized && (pMS->CurState & SHIP_TOGGLE)) { - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, + MENU_SOUND_SELECT | MENU_SOUND_CANCEL); } else { @@ -255,7 +236,7 @@ DoModifyRoster (PMENU_STATE pMS) DrawStatusMessage (NULL_PTR); UnlockMutex (GraphicsLock); - return (FALSE); + return FALSE; } else if (select || cancel) { @@ -375,7 +356,7 @@ SelectSupport: "flash roster menu"); } - return (TRUE); + return TRUE; } BOOLEAN @@ -452,9 +433,9 @@ Roster (void) pMenuState = pOldMenuState; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 51bac8f0e..3ca5ccbb1 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -16,11 +16,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "lifeform.h" -#include "libs/graphics/gfx_common.h" -#include "options.h" +#include "build.h" #include "controls.h" +#include "dummy.h" +#include "encount.h" +#include "gamestr.h" +#include "lifeform.h" +#include "nameref.h" +#include "options.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "state.h" +#include "libs/graphics/gfx_common.h" +#include "libs/inplib.h" +#include "libs/mathlib.h" + + //Added by Chris void diff --git a/sc2/src/sc2code/planets/scan.h b/sc2/src/sc2code/planets/scan.h index 7a4f7e4be..e5c2ea5f9 100644 --- a/sc2/src/sc2code/planets/scan.h +++ b/sc2/src/sc2code/planets/scan.h @@ -19,6 +19,9 @@ #ifndef _SCAN_H #define _SCAN_H +#include "libs/gfxlib.h" + + typedef struct { POINT start; diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index b51c67ee4..27bc00817 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -16,10 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "libs/graphics/gfx_common.h" +#include "colors.h" #include "controls.h" +#include "encount.h" +#include "gamestr.h" +#include "globdata.h" +#include "init.h" +#include "nameref.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "state.h" #include "uqmdebug.h" +#include "libs/graphics/gfx_common.h" +#include "libs/mathlib.h" +#include "libs/inplib.h" + //#define DEBUG_SOLARSYS @@ -75,8 +88,7 @@ GenerateMoons (void) (*pSolarSysState->GenFunc) (GENERATE_MOONS); facing = NORMALIZE_FACING (ANGLE_TO_FACING ( - ARCTAN (pCurDesc->location.x, pCurDesc->location.y) - )); + ARCTAN (pCurDesc->location.x, pCurDesc->location.y))); for (i = 0, pMoonDesc = &pSolarSysState->MoonDesc[0]; i < MAX_MOONS; ++i, ++pMoonDesc) { @@ -95,15 +107,13 @@ GenerateMoons (void) if (data_index == (BYTE)~0) { pMoonDesc->image.frame = SetAbsFrameIndex ( - SpaceJunkFrame, 16 - ); + SpaceJunkFrame, 16); } /* Samatra */ else if (data_index == (BYTE)(~0 - 1)) { pMoonDesc->image.frame = SetAbsFrameIndex ( - SpaceJunkFrame, 19 - ); + SpaceJunkFrame, 19); } } } @@ -135,17 +145,12 @@ LoadIPData (void) if (SpaceJunkFrame == 0) { SpaceJunkFrame = CaptureDrawable ( - LoadGraphic (IPBKGND_MASK_PMAP_ANIM) - ); - SISIPFrame = - CaptureDrawable ( - LoadGraphic (SISIP_MASK_PMAP_ANIM) - ); + LoadGraphic (IPBKGND_MASK_PMAP_ANIM)); + SISIPFrame = CaptureDrawable (LoadGraphic (SISIP_MASK_PMAP_ANIM)); OrbitalCMap = CaptureColorMap (LoadColorMap (ORBPLAN_COLOR_MAP)); OrbitalFrame = CaptureDrawable ( - LoadGraphic (ORBPLAN_MASK_PMAP_ANIM) - ); + LoadGraphic (ORBPLAN_MASK_PMAP_ANIM)); SunFrame = CaptureDrawable (LoadGraphic (SUN_MASK_PMAP_ANIM)); SpaceMusic = LoadMusicInstance (IP_MUSIC); @@ -175,8 +180,7 @@ LoadSolarSys (void) { GLOBAL (ShipStamp.frame) = (FRAME)MAKE_DWORD ( LOWORD (GLOBAL (ShipStamp.frame)), - LOBYTE (HIWORD (GLOBAL (ShipStamp.frame))) - ); + LOBYTE (HIWORD (GLOBAL (ShipStamp.frame)))); ++pSolarSysState->MenuState.Initialized; } else @@ -184,21 +188,18 @@ LoadSolarSys (void) // LoadIPData (); } - old_seed = TFB_SeedRandom ( - MAKE_DWORD (CurStarDescPtr->star_pt.x, - CurStarDescPtr->star_pt.y) - ); + old_seed = TFB_SeedRandom (MAKE_DWORD (CurStarDescPtr->star_pt.x, + CurStarDescPtr->star_pt.y)); - SunFrame = SetAbsFrameIndex (SunFrame, - STAR_TYPE (CurStarDescPtr->Type) - ); + SunFrame = SetAbsFrameIndex (SunFrame, STAR_TYPE (CurStarDescPtr->Type)); pCurDesc = &pSolarSysState->SunDesc[0]; pCurDesc->pPrevDesc = 0; pCurDesc->rand_seed = TFB_Random (); pCurDesc->data_index = STAR_TYPE (CurStarDescPtr->Type); - pCurDesc->location.x = pCurDesc->location.y = 0; + pCurDesc->location.x = 0; + pCurDesc->location.y = 0; pCurDesc->image.origin = pCurDesc->location; pCurDesc->image.frame = SunFrame; @@ -273,15 +274,15 @@ LoadSolarSys (void) sort_array[i + 1]; } - if ((i = LOBYTE (HIWORD (GLOBAL (ShipStamp.frame)))) == 0) + i = LOBYTE (HIWORD (GLOBAL (ShipStamp.frame))); + if (i == 0) pSolarSysState->pBaseDesc = pSolarSysState->pOrbitalDesc = pSolarSysState->PlanetDesc; else { pSolarSysState->pOrbitalDesc = 0; pSolarSysState->pBaseDesc = &pSolarSysState->PlanetDesc[i - 1]; - pSolarSysState->SunDesc[0].location = - GLOBAL (ip_location); + pSolarSysState->SunDesc[0].location = GLOBAL (ip_location); GenerateMoons (); SET_GAME_STATE (PLANETARY_LANDING, 0); @@ -297,8 +298,7 @@ LoadSolarSys (void) ++num_thrusters; } pSolarSysState->max_ship_speed = (BYTE)( - (num_thrusters + 5) * IP_SHIP_THRUST_INCREMENT - ); + (num_thrusters + 5) * IP_SHIP_THRUST_INCREMENT); pSolarSysState->turn_wait = IP_SHIP_TURN_WAIT; for (i = 0; i < NUM_JET_SLOTS; ++i) @@ -311,21 +311,22 @@ LoadSolarSys (void) i = pSolarSysState->MenuState.Initialized; if (i) { - if ((i -= 2) == 0) - pSolarSysState->pOrbitalDesc = pSolarSysState->pBaseDesc->pPrevDesc; + i -= 2; + if (i == 0) + pSolarSysState->pOrbitalDesc = + pSolarSysState->pBaseDesc->pPrevDesc; else pSolarSysState->pOrbitalDesc = &pSolarSysState->MoonDesc[i - 1]; pSolarSysState->MenuState.Initialized = 2; - GLOBAL (ip_location) = - pSolarSysState->SunDesc[0].location; + GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location; } else { - if ((i = LOWORD (GLOBAL (ShipStamp.frame))) == 0) + i = LOWORD (GLOBAL (ShipStamp.frame)); + if (i == 0) ++i; - GLOBAL (ShipStamp.frame) = - SetAbsFrameIndex (SISIPFrame, i - 1); + GLOBAL (ShipStamp.frame) = SetAbsFrameIndex (SISIPFrame, i - 1); } TFB_SeedRandom (old_seed); @@ -436,7 +437,8 @@ ShowPlanet: PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin; if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) { - PlanetOffset = pCurDesc->pPrevDesc - pSolarSysState->PlanetDesc; + PlanetOffset = pCurDesc->pPrevDesc - + pSolarSysState->PlanetDesc; MoonOffset = pCurDesc - pSolarSysState->MoonDesc + 2; } else @@ -446,8 +448,10 @@ ShowPlanet: } ++PlanetOffset; if (pSolarSysState->WaitIntersect != (COUNT)~0 - && pSolarSysState->WaitIntersect != MAKE_WORD (PlanetOffset, MoonOffset)) - PlanetIntersect.IntersectStamp.frame = DecFrameIndex (stars_in_space); + && pSolarSysState->WaitIntersect != MAKE_WORD ( + PlanetOffset, MoonOffset)) + PlanetIntersect.IntersectStamp.frame = + DecFrameIndex (stars_in_space); else PlanetIntersect.IntersectStamp.frame = pCurDesc->image.frame; @@ -461,7 +465,8 @@ ShowPlanet: return; else if (pSolarSysState->WaitIntersect == NewWaitPlanet) continue; - else if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) + else if (pSolarSysState->pBaseDesc == + pSolarSysState->MoonDesc) goto ShowPlanet; else if (!just_checking) /* pBaseDesc == PlanetDesc */ { @@ -475,25 +480,20 @@ ShowPlanet: (SIS_SCREEN_WIDTH >> 1) + COSINE ( angle, MIN_MOON_RADIUS + ((MAX_MOONS - 1) * MOON_DELTA) - + (MOON_DELTA >> 2) - ); + + (MOON_DELTA >> 2)); GLOBAL (ShipStamp.origin.y) = (SIS_SCREEN_HEIGHT >> 1) + SINE ( angle, MIN_MOON_RADIUS + ((MAX_MOONS - 1) * MOON_DELTA) - + (MOON_DELTA >> 2) - ); + + (MOON_DELTA >> 2)); if (GLOBAL (ShipStamp.origin.y) < 0) GLOBAL (ShipStamp.origin.y) = 1; else if (GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT) GLOBAL (ShipStamp.origin.y) = (SIS_SCREEN_HEIGHT - 1) - 1; pSolarSysState->pBaseDesc = pCurDesc; - XFormIPLoc ( - &pCurDesc->image.origin, - &pSolarSysState->SunDesc[0].location, - FALSE - ); + XFormIPLoc (&pCurDesc->image.origin, + &pSolarSysState->SunDesc[0].location, FALSE); ZeroVelocityComponents (&GLOBAL (velocity)); GenerateMoons (); @@ -501,7 +501,8 @@ ShowPlanet: SetTransitionSource (NULL); BatchGraphics (); SetGraphicGrabOther (1); - DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE); + DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, + TRUE); SetGraphicGrabOther (0); r.corner.x = SIS_ORG_X; r.corner.y = SIS_ORG_Y; @@ -535,13 +536,14 @@ GetOrbitRect (PRECT pRect, COORD cx, COORD cy, SIZE + (SIZE)((long)-cx * (long)xnumer / (long)denom); pRect->corner.y = (SIS_SCREEN_HEIGHT >> 1) + (SIZE)((long)-cy * (long)ynumer / (long)denom); - pRect->extent.width = (SIZE)((long)radius * (long)(xnumer << 1) / (long)denom); + pRect->extent.width = (SIZE)((long)radius * (long)(xnumer << 1) / + (long)denom); pRect->extent.height = pRect->extent.width >> 1; } static void -DrawOrbit (PPLANET_DESC pPlanetDesc, COUNT xnumer, COUNT - ynumer0, COUNT ynumer1, COUNT denom) +DrawOrbit (PPLANET_DESC pPlanetDesc, COUNT xnumer, COUNT ynumer0, + COUNT ynumer1, COUNT denom) { COUNT index; COORD cx, cy; @@ -550,14 +552,14 @@ DrawOrbit (PPLANET_DESC pPlanetDesc, COUNT xnumer, COUNT if (!(draw_sys_flags & (DRAW_ORBITS | DRAW_PLANETS))) return; - cx = cy = pPlanetDesc->radius; + cx = pPlanetDesc->radius; + cy = pPlanetDesc->radius; if (xnumer > (COUNT)DISPLAY_FACTOR) { cx = cx + pPlanetDesc->location.x; cy = (cy + pPlanetDesc->location.y) << 1; } - GetOrbitRect (&r, cx, cy, - pPlanetDesc->radius, xnumer, ynumer0, denom); + GetOrbitRect (&r, cx, cy, pPlanetDesc->radius, xnumer, ynumer0, denom); if (draw_sys_flags & DRAW_ORBITS) { @@ -587,10 +589,8 @@ if (!(draw_sys_flags & DRAW_PLANETS)) COUNT Size; Type = PlanData[index].Type; - SetColorMap (GetColorMapAddress ( - SetAbsColorMapIndex (OrbitalCMap, - PLANCOLOR (Type)) - )); + SetColorMap (GetColorMapAddress (SetAbsColorMapIndex (OrbitalCMap, + PLANCOLOR (Type)))); Size = PLANSIZE (Type); if (denom == 2 || xnumer > (COUNT)DISPLAY_FACTOR) @@ -611,15 +611,11 @@ if (!(draw_sys_flags & DRAW_PLANETS)) else { --Size; - pPlanetDesc->image.frame = - SetAbsFrameIndex (OrbitalFrame, - (Size << FACING_SHIFT) - + NORMALIZE_FACING (ANGLE_TO_FACING ( - ARCTAN ( - pPlanetDesc->pPrevDesc->location.x, - pPlanetDesc->pPrevDesc->location.y - ) - ))); + pPlanetDesc->image.frame = SetAbsFrameIndex (OrbitalFrame, + (Size << FACING_SHIFT) + NORMALIZE_FACING ( + ANGLE_TO_FACING (ARCTAN ( + pPlanetDesc->pPrevDesc->location.x, + pPlanetDesc->pPrevDesc->location.y)))); } } @@ -661,13 +657,10 @@ FindRadius (void) GetOrbitRect (&pSolarSysState->MenuState.flash_rect0, radius, radius, radius, - DISPLAY_FACTOR, - DISPLAY_FACTOR >> 2, + DISPLAY_FACTOR, DISPLAY_FACTOR >> 2, pSolarSysState->SunDesc[0].radius); - XFormIPLoc (&GLOBAL (ip_location), - &GLOBAL (ShipStamp.origin), - TRUE); + XFormIPLoc (&GLOBAL (ip_location), &GLOBAL (ShipStamp.origin), TRUE); } while (radius && (delta_x = GLOBAL (ShipStamp.origin.x) @@ -714,8 +707,8 @@ flagship_inertial_thrust (COUNT CurrentAngle) max_speed = pSolarSysState->max_ship_speed; VelocityPtr = &GLOBAL (velocity); GetCurrentVelocityComponents (VelocityPtr, &cur_delta_x, &cur_delta_y); - if ((TravelAngle = - GetVelocityTravelAngle (VelocityPtr)) == CurrentAngle + TravelAngle = GetVelocityTravelAngle (VelocityPtr); + if (TravelAngle == CurrentAngle && cur_delta_x == COSINE (CurrentAngle, max_speed) && cur_delta_y == SINE (CurrentAngle, max_speed)) return (SHIP_AT_MAX_SPEED); @@ -765,7 +758,7 @@ flagship_inertial_thrust (COUNT CurrentAngle) *VelocityPtr = v; } - return (0); + return 0; } } @@ -904,8 +897,7 @@ UndrawShip (void) return; } - if (GLOBAL (autopilot.x) == ~0 - && GLOBAL (autopilot.y) == ~0) + if (GLOBAL (autopilot.x) == ~0 && GLOBAL (autopilot.y) == ~0) CheckIntersect (FALSE); } @@ -1055,7 +1047,8 @@ IP_frame (void) if (pSolarSysState->MenuState.CurState || pSolarSysState->MenuState.Initialized == 0) { - select = cancel = FALSE; + select = FALSE; + cancel = FALSE; if (draw_sys_flags & DRAW_REFRESH) goto TheMess; } @@ -1087,14 +1080,18 @@ IP_frame (void) UndrawShip (); if (pSolarSysState->MenuState.Initialized != 1) - select = cancel = FALSE; + { + select = FALSE; + cancel = FALSE; + } } if (old_radius) ScaleSystem (); BatchGraphics (); - if (!(draw_sys_flags & DRAW_REFRESH)) // don't repair from Extra or draw ship if forcing repair + if (!(draw_sys_flags & DRAW_REFRESH)) + // don't repair from Extra or draw ship if forcing repair { CONTEXT OldContext; @@ -1107,7 +1104,8 @@ IP_frame (void) // this screws up ScreenTransition by leaving an image of the // ship in the ExtraScreen (which we use for repair) if (pSolarSysState->MenuState.CurState == 0 - && (InnerSystem ^ (BOOLEAN)(pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc))) + && (InnerSystem ^ (BOOLEAN)( + pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc))) ; else RedrawQueue (FALSE); @@ -1148,8 +1146,8 @@ IP_frame (void) } // LoadInto Extra if we left inner system, or we forced a redraw - if ((InnerSystem && pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) - || (draw_sys_flags & DRAW_REFRESH)) + if ((InnerSystem && pSolarSysState->pBaseDesc == + pSolarSysState->PlanetDesc) || (draw_sys_flags & DRAW_REFRESH)) { LoadIntoExtraScreen (&r); draw_sys_flags &= ~DRAW_REFRESH; @@ -1164,7 +1162,10 @@ IP_frame (void) IP_next_time = GetTimeCounter (); if (pSolarSysState->MenuState.CurState || pSolarSysState->MenuState.Initialized != 1) - cancel = select = 0; + { + cancel = 0; + select = 0; + } else { /* Updating the input state is handled by @@ -1217,14 +1218,12 @@ ValidateOrbits (void) PPLANET_DESC pCurDesc; InnerSystem = (BOOLEAN)( - pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc - ); + pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc); if (InnerSystem) { old_pts[0] = GLOBAL (ShipStamp.origin); old_pts[1] = GLOBAL (ip_location); - GLOBAL (ip_location) = - pSolarSysState->SunDesc[0].location; + GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location; } pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS << 1; @@ -1232,13 +1231,10 @@ ValidateOrbits (void) pSolarSysState->pBaseDesc = 0; for (i = pSolarSysState->SunDesc[0].NumPlanets, - pCurDesc = &pSolarSysState->PlanetDesc[0]; - i; --i, ++pCurDesc) + pCurDesc = &pSolarSysState->PlanetDesc[0]; i; --i, ++pCurDesc) { DrawOrbit (pCurDesc, - DISPLAY_FACTOR, - DISPLAY_FACTOR >> 2, - DISPLAY_FACTOR >> 1, + DISPLAY_FACTOR, DISPLAY_FACTOR >> 2, DISPLAY_FACTOR >> 1, pSolarSysState->SunDesc[0].radius); } @@ -1302,7 +1298,8 @@ StartGroups: UnbatchGraphics (); } LockMutex (GraphicsLock); - while (pSolarSysState->SunDesc[0].radius == (MAX_ZOOM_RADIUS << 1)) + while (pSolarSysState->SunDesc[0].radius == + (MAX_ZOOM_RADIUS << 1)) { UnlockMutex (GraphicsLock); IP_frame (); @@ -1341,8 +1338,8 @@ StartGroups: GetPlanetInfo (); (*pSolarSysState->GenFunc) (GENERATE_ORBITAL); LastActivity &= ~(CHECK_LOAD | CHECK_RESTART); - if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD | START_ENCOUNTER)) - || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 + if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD | + START_ENCOUNTER)) || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) return; @@ -1387,17 +1384,15 @@ InitSolarSys (void) Reentry = (BOOLEAN)(GLOBAL (ShipStamp.frame) != 0); if (!Reentry) { - GLOBAL (autopilot.x) = - GLOBAL (autopilot.y) = ~0; + GLOBAL (autopilot.x) = ~0; + GLOBAL (autopilot.y) = ~0; GLOBAL (ShipStamp.origin.x) = SIS_SCREEN_WIDTH >> 1; GLOBAL (ShipStamp.origin.y) = SIS_SCREEN_HEIGHT >> 1; GLOBAL (ShipStamp.origin.y) += (SIS_SCREEN_HEIGHT >> 1) - 1; pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS; - XFormIPLoc (&GLOBAL (ShipStamp.origin), - &GLOBAL (ip_location), - FALSE); + XFormIPLoc (&GLOBAL (ShipStamp.origin), &GLOBAL (ip_location), FALSE); } LoadSolarSys (); @@ -1423,7 +1418,8 @@ InitSolarSys (void) if (LastActivity & (CHECK_LOAD | CHECK_RESTART)) { - if ((LastActivity & (CHECK_LOAD | CHECK_RESTART)) == LastActivity) + if ((LastActivity & (CHECK_LOAD | CHECK_RESTART)) == + LastActivity) { extern ACTIVITY NextActivity; @@ -1470,7 +1466,7 @@ InitSolarSys (void) DrawHyperCoords (CurStarDescPtr->star_pt); /* Adjust position */ UnlockMutex (GraphicsLock); - /* force a redraw */ + /* force a redraw */ pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS << 1; } } @@ -1502,16 +1498,16 @@ UninitSolarSys (void) best_dist = ~0L; for (i = 0, pCurDesc = pSolarSysState->PlanetDesc; - i < pSolarSysState->SunDesc[0].NumPlanets; ++i, ++pCurDesc) + i < pSolarSysState->SunDesc[0].NumPlanets; + ++i, ++pCurDesc) { SIZE dx, dy; DWORD dist; - dx = GLOBAL (ShipStamp.origin.x) - - pCurDesc->image.origin.x; - dy = GLOBAL (ShipStamp.origin.y) - - pCurDesc->image.origin.y; - if ((dist = (DWORD)((long)dx * dx + (long)dy * dy)) < best_dist) + dx = GLOBAL (ShipStamp.origin.x) - pCurDesc->image.origin.x; + dy = GLOBAL (ShipStamp.origin.y) - pCurDesc->image.origin.y; + dist = (DWORD) ((long) dx * dx + (long) dy * dy); + if (dist < best_dist) { best_dist = dist; pSolarSysState->pBaseDesc = pCurDesc; @@ -1547,59 +1543,68 @@ GenerateRandomIP (BYTE control) ReinitQueue (&GLOBAL (npc_built_ship_q)); break; case GENERATE_MINERAL: - GenerateMineralDeposits (&pSolarSysState->SysInfo, &pSolarSysState->CurNode); + GenerateMineralDeposits (&pSolarSysState->SysInfo, + &pSolarSysState->CurNode); break; case GENERATE_ENERGY: pSolarSysState->CurNode = 0; break; case GENERATE_LIFE: - GenerateLifeForms (&pSolarSysState->SysInfo, &pSolarSysState->CurNode); + GenerateLifeForms (&pSolarSysState->SysInfo, + &pSolarSysState->CurNode); break; case GENERATE_ORBITAL: { #ifdef DEBUG_SOLARSYS if (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) - fprintf (stderr, "Planet index = %d\n", pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc); + fprintf (stderr, "Planet index = %d\n", + pSolarSysState->pOrbitalDesc - + pSolarSysState->PlanetDesc); else fprintf (stderr, "Planet index = %d, Moon index = %d\n", - pSolarSysState->pOrbitalDesc->pPrevDesc - pSolarSysState->PlanetDesc, - pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc); + pSolarSysState->pOrbitalDesc->pPrevDesc - + pSolarSysState->PlanetDesc, + pSolarSysState->pOrbitalDesc - + pSolarSysState->MoonDesc); #endif /* DEBUG_SOLARSYS */ - rand_val = DoPlanetaryAnalysis ( - &pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc - ); + rand_val = DoPlanetaryAnalysis (&pSolarSysState->SysInfo, + pSolarSysState->pOrbitalDesc); - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; + pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = + rand_val; i = (COUNT)~0; rand_val = GenerateLifeForms (&pSolarSysState->SysInfo, &i); - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; + pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = + rand_val; i = (COUNT)~0; GenerateMineralDeposits (&pSolarSysState->SysInfo, &i); - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; + pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = + rand_val; LoadPlanet (FALSE); break; } case GENERATE_NAME: { i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc; - wsprintf (GLOBAL_SIS (PlanetName), "%s", GAME_STRING (PLANET_NUMBER_BASE + (9 + 7) + i)); - SET_GAME_STATE (BATTLE_PLANET, pSolarSysState->PlanetDesc[i].data_index); + wsprintf (GLOBAL_SIS (PlanetName), "%s", + GAME_STRING (PLANET_NUMBER_BASE + (9 + 7) + i)); + SET_GAME_STATE (BATTLE_PLANET, + pSolarSysState->PlanetDesc[i].data_index); break; } case GENERATE_MOONS: - FillOrbits ( - pSolarSysState->pBaseDesc->NumPlanets, - &pSolarSysState->MoonDesc[0], FALSE - ); + FillOrbits (pSolarSysState->pBaseDesc->NumPlanets, + &pSolarSysState->MoonDesc[0], FALSE); break; case GENERATE_PLANETS: { FillOrbits ((BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE); for (i = pSolarSysState->SunDesc[0].NumPlanets, - pCurDesc = &pSolarSysState->PlanetDesc[0]; i; --i, ++pCurDesc) + pCurDesc = &pSolarSysState->PlanetDesc[0]; i; + --i, ++pCurDesc) { BYTE byte_val; BYTE num_moons; @@ -1609,8 +1614,7 @@ GenerateRandomIP (BYTE control) num_moons = 0; switch (PLANSIZE (PlanData[ - pCurDesc->data_index & ~PLANET_SHIELDED - ].Type)) + pCurDesc->data_index & ~PLANET_SHIELDED].Type)) { case LARGE_ROCKY_WORLD: if (byte_val < 0x00FF * 25 / 100) @@ -1665,11 +1669,8 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem) pCurDesc = pBaseDesc->pPrevDesc; pSolarSysState->pOrbitalDesc = pCurDesc; - DrawOrbit (pCurDesc, - DISPLAY_FACTOR << 2, - DISPLAY_FACTOR, - DISPLAY_FACTOR << 1, - radius); + DrawOrbit (pCurDesc, DISPLAY_FACTOR << 2, DISPLAY_FACTOR, + DISPLAY_FACTOR << 1, radius); } for (i = pBaseDesc->pPrevDesc->NumPlanets, @@ -1678,11 +1679,8 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem) if (IsInnerSystem) DrawOrbit (pCurDesc, 2, 1, 1, 2); else - DrawOrbit (pCurDesc, - DISPLAY_FACTOR, - DISPLAY_FACTOR >> 2, - DISPLAY_FACTOR >> 1, - radius); + DrawOrbit (pCurDesc, DISPLAY_FACTOR, DISPLAY_FACTOR >> 2, + DISPLAY_FACTOR >> 1, radius); } if (IsInnerSystem) @@ -1702,8 +1700,7 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem) pCurDesc = &pSolarSysState->SunDesc[0]; pCurDesc->image.origin.x = SIS_SCREEN_WIDTH >> 1; pCurDesc->image.origin.y = SIS_SCREEN_HEIGHT >> 1; - pCurDesc->image.frame = - SetRelFrameIndex (SunFrame, index); + pCurDesc->image.frame = SetRelFrameIndex (SunFrame, index); index = pSolarSysState->FirstPlanetIndex; if (draw_sys_flags & DRAW_PLANETS) @@ -1718,12 +1715,10 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem) color_index = STAR_COLOR (CurStarDescPtr->Type); else color_index = PLANCOLOR (PlanData[ - pCurDesc->data_index & ~PLANET_SHIELDED - ].Type); + pCurDesc->data_index & ~PLANET_SHIELDED ].Type); SetColorMap (GetColorMapAddress ( - SetAbsColorMapIndex (OrbitalCMap, color_index) - )); + SetAbsColorMapIndex (OrbitalCMap, color_index))); DrawStamp (&pCurDesc->image); if (index == pSolarSysState->LastPlanetIndex) @@ -1812,7 +1807,8 @@ DrawStarBackGround (BOOLEAN ForPlanet) { RECT r; - // 2002-12-13 PhracturedBlue's fix to planet changing color when using device problem + // 2002-12-13 PhracturedBlue's fix to planet changing color when + // using device problem /*if (pSolarSysState->MenuState.flash_task || (LastActivity & CHECK_LOAD)) RenderTopography (TRUE);*/ @@ -1821,14 +1817,16 @@ DrawStarBackGround (BOOLEAN ForPlanet) SetContext (ScreenContext); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08)); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), + 0x08)); r.corner.x = SIS_ORG_X - 1; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 4; r.extent.width = SIS_SCREEN_WIDTH + 2; r.extent.height = 3; DrawFilledRectangle (&r); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F)); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), + 0x1F)); r.extent.width = 1; r.extent.height = MAP_HEIGHT + 1; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT; @@ -1842,7 +1840,8 @@ DrawStarBackGround (BOOLEAN ForPlanet) r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 5; DrawFilledRectangle (&r); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 ( + 0x10, 0x10, 0x10), 0x19)); r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 1; r.extent.width = MAP_WIDTH + 2; r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH - 1; @@ -1865,28 +1864,22 @@ XFormIPLoc (PPOINT pIn, PPOINT pOut, BOOLEAN ToDisplay) if (ToDisplay) { pOut->x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)pIn->x - * (DISPLAY_FACTOR >> 1) + + (SIZE)((long)pIn->x * (DISPLAY_FACTOR >> 1) // / (long)pSolarSysState->SunDesc[0].radius); / pSolarSysState->SunDesc[0].radius); pOut->y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)pIn->y - * (DISPLAY_FACTOR >> 1) + + (SIZE)((long)pIn->y * (DISPLAY_FACTOR >> 1) // / (long)pSolarSysState->SunDesc[0].radius); / pSolarSysState->SunDesc[0].radius); } else { - pOut->x = (SIZE)((long)(pIn->x - - (SIS_SCREEN_WIDTH >> 1)) + pOut->x = (SIZE)((long)(pIn->x - (SIS_SCREEN_WIDTH >> 1)) // * (long)pSolarSysState->SunDesc[0].radius - * pSolarSysState->SunDesc[0].radius - / (DISPLAY_FACTOR >> 1)); - pOut->y = (SIZE)((long)(pIn->y - - (SIS_SCREEN_HEIGHT >> 1)) + * pSolarSysState->SunDesc[0].radius / (DISPLAY_FACTOR >> 1)); + pOut->y = (SIZE)((long)(pIn->y - (SIS_SCREEN_HEIGHT >> 1)) // * (long)pSolarSysState->SunDesc[0].radius - * pSolarSysState->SunDesc[0].radius - / (DISPLAY_FACTOR >> 1)); + * pSolarSysState->SunDesc[0].radius / (DISPLAY_FACTOR >> 1)); } } @@ -1906,8 +1899,8 @@ ExploreSolarSys (void) exit(1); dumpStars(out, DUMP_PLANETS); fclose(out); - fprintf(stdout, "*** Star dump complete. You can terminate the program " - "now if it does not do so automatically.\n"); + fprintf(stdout, "*** Star dump complete. You can terminate the " + "program now if it does not do so automatically.\n"); exit(0); // There may be other threads left. } @@ -1943,3 +1936,4 @@ ExploreSolarSys (void) pSolarSysState = 0; } + diff --git a/sc2/src/sc2code/planets/sundata.h b/sc2/src/sc2code/planets/sundata.h index b09c5a4a4..1dc6cd09d 100644 --- a/sc2/src/sc2code/planets/sundata.h +++ b/sc2/src/sc2code/planets/sundata.h @@ -19,6 +19,10 @@ #ifndef _SUNDATA_H #define _SUNDATA_H +#include "planets/plandata.h" +#include "libs/compiler.h" + + /*------------------------------ Global Data ------------------------------ */ #define NUMBER_OF_SUN_SIZES (SUPER_GIANT_STAR - DWARF_STAR + 1) diff --git a/sc2/src/sc2code/planets/surface.c b/sc2/src/sc2code/planets/surface.c index 7619cc6ef..785f17efd 100644 --- a/sc2/src/sc2code/planets/surface.c +++ b/sc2/src/sc2code/planets/surface.c @@ -16,8 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "lifeform.h" +#include "planets.h" +#include "libs/mathlib.h" + //#define DEBUG_SURFACE diff --git a/sc2/src/sc2code/process.c b/sc2/src/sc2code/process.c index c586e62b2..bd714d421 100644 --- a/sc2/src/sc2code/process.c +++ b/sc2/src/sc2code/process.c @@ -16,12 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "collide.h" -#include "libs/graphics/gfx_common.h" +#include "options.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" +#include "weapon.h" #include "libs/graphics/drawable.h" #include "libs/graphics/drawcmd.h" -#include "options.h" +#include "libs/graphics/gfx_common.h" + //#define DEBUG_PROCESS @@ -620,11 +625,6 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr, return (ElementPtr->state_flags & COLLISION); } -#define MAX_SOUNDS 8 -static BYTE num_sounds; -static SOUND sound_buf[MAX_SOUNDS]; -static ELEMENTPTR sound_posobj[MAX_SOUNDS]; - static VIEW_STATE PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y) { @@ -1055,56 +1055,6 @@ InitDisplayList (void) DisplayLinks = MakeLinks (END_OF_LIST, END_OF_LIST); } -void -PlaySound (SOUND S, SoundPosition Pos, ELEMENTPTR PositionalObject, - BYTE Priority) -{ -#define MIN_FX_CHANNEL 1 -#define NUM_FX_CHANNELS 4 /* obviously number of channels - is assumed to be at least 5 */ - BYTE chan, c; - static BYTE lru_channel[NUM_FX_CHANNELS] = {0, 1, 2, 3}; - static SOUND channel[NUM_FX_CHANNELS]; - - if (S == 0) return; - - for (chan = 0; chan < NUM_FX_CHANNELS; ++chan) - { - if (S == channel[chan]) - break; - } - - if (chan == NUM_FX_CHANNELS) - { - for (chan = 0; chan < NUM_FX_CHANNELS; ++chan) - { - if (!ChannelPlaying (chan + MIN_FX_CHANNEL)) - break; - } - - if (chan == NUM_FX_CHANNELS) - chan = lru_channel[0]; - } - - channel[chan] = S; - - for (c = 0; c < NUM_FX_CHANNELS - 1; ++c) - { - if (lru_channel[c] == chan) - { - memmove ( - (PBYTE)&lru_channel[c], - (PBYTE)&lru_channel[c + 1], - (NUM_FX_CHANNELS - 1) - c - ); - break; - } - } - lru_channel[NUM_FX_CHANNELS - 1] = chan; - - PlaySoundEffect (S, chan + MIN_FX_CHANNEL, Pos, PositionalObject, Priority); -} - UWORD nth_frame; void @@ -1112,7 +1062,6 @@ RedrawQueue (BOOLEAN clear) { SIZE scroll_x, scroll_y; VIEW_STATE view_state; - int i; SetContext (StatusContext); @@ -1120,21 +1069,7 @@ RedrawQueue (BOOLEAN clear) PostProcessQueue (view_state, scroll_x, scroll_y); if (optStereoSFX) - { - for (i = 0; i <= NUM_FX_CHANNELS; ++i) - { - /* Updates positional sound effects */ - - ELEMENTPTR posobj; - if (ChannelPlaying (i) && ((posobj = GetPositionalObject (i)) != NULL)) - { - SoundPosition pos; - pos = CalcSoundPosition (posobj); - if (pos.positional) - UpdateSoundPosition (i, pos); - } - } - } + UpdateSoundPositions (); SetContext (SpaceContext); if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE @@ -1158,80 +1093,11 @@ RedrawQueue (BOOLEAN clear) SetGraphicScale (0); } - if (num_sounds > 0) - { - SOUND *pSound; - ELEMENTPTR *pSoundPosObj; - - pSound = sound_buf; - pSoundPosObj = sound_posobj; - do - { - SoundPosition pos = CalcSoundPosition (*pSoundPosObj); - PlaySound (*pSound++, pos, *pSoundPosObj++, - GAME_SOUND_PRIORITY); - } while (--num_sounds); - } + FlushSounds (); } DisplayLinks = MakeLinks (END_OF_LIST, END_OF_LIST); } -void -ProcessSound (SOUND Sound, ELEMENTPTR PositionalObject) -{ - if (Sound == (SOUND)~0) - { - memset (sound_buf, 0, sizeof (sound_buf)); - memset (sound_posobj, 0, sizeof (sound_posobj)); - num_sounds = MAX_SOUNDS; - } - else if (num_sounds < MAX_SOUNDS) - { - sound_buf[num_sounds] = Sound; - sound_posobj[num_sounds++] = PositionalObject; - } -} - -SoundPosition -CalcSoundPosition (ELEMENTPTR ElementPtr) -{ - SoundPosition pos; - - if (ElementPtr == NULL) - { - pos.x = pos.y = 0; - pos.positional = FALSE; - } - else - { - GRAPHICS_PRIM objtype; - - objtype = GetPrimType (&DisplayArray[ElementPtr->PrimIndex]); - if (objtype == LINE_PRIM) - { - pos.x = DisplayArray[ElementPtr->PrimIndex].Object.Line.first.x; - pos.y = DisplayArray[ElementPtr->PrimIndex].Object.Line.first.y; - } - else - { - pos.x = DisplayArray[ElementPtr->PrimIndex].Object.Point.x; - pos.y = DisplayArray[ElementPtr->PrimIndex].Object.Point.y; - } - - pos.x -= (SPACE_WIDTH >> 1); - pos.y -= (SPACE_HEIGHT); - pos.positional = TRUE; - } - - return pos; -} - -SoundPosition -NotPositional (void) -{ - return CalcSoundPosition (NULL); -} - void Untarget (ELEMENTPTR ElementPtr) { @@ -1265,24 +1131,14 @@ RemoveElement (HLINK hLink) { if (optStereoSFX) { - ELEMENTPTR ElementPtr, PosObj; + ELEMENTPTR ElementPtr; LockElement (hLink, &ElementPtr); if (ElementPtr != NULL) - { - int i; - for (i = 0; i <= NUM_FX_CHANNELS; ++i) - { - if ((PosObj = GetPositionalObject (i)) == ElementPtr) - SetPositionalObject (i, NULL); - } - for (i = 0; i < num_sounds; ++i) - { - if (sound_posobj[i] == ElementPtr) - sound_posobj[i] = NULL; - } - } + RemoveSoundsForObject(ElementPtr); UnlockElement (hLink); } RemoveQueue (&disp_q, hLink); } + + diff --git a/sc2/src/sc2code/races.h b/sc2/src/sc2code/races.h index 4ee0f1b1a..dee8fbf08 100644 --- a/sc2/src/sc2code/races.h +++ b/sc2/src/sc2code/races.h @@ -19,6 +19,11 @@ #ifndef _RACES_H #define _RACES_H +#include "units.h" +#include "element.h" +#include "libs/sndlib.h" + + #define RACES_PER_PLAYER 7 #define MAX_SHIPS_PER_SIDE 14 diff --git a/sc2/src/sc2code/restart.c b/sc2/src/sc2code/restart.c index b2defec32..6331cb7d8 100644 --- a/sc2/src/sc2code/restart.c +++ b/sc2/src/sc2code/restart.c @@ -16,12 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "uqmversion.h" +#include "colors.h" #include "controls.h" #include "credits.h" -#include "libs/graphics/gfx_common.h" +#include "encount.h" +#include "fmv.h" +#include "globdata.h" +#include "intel.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" #include "setupmenu.h" +#include "util.h" +#include "uqmversion.h" +#include "libs/graphics/gfx_common.h" +#include "libs/inplib.h" + //Added by Chris diff --git a/sc2/src/sc2code/save.c b/sc2/src/sc2code/save.c index a8ab700d0..02ce35378 100644 --- a/sc2/src/sc2code/save.c +++ b/sc2/src/sc2code/save.c @@ -16,15 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "declib.h" -#include "file.h" -#include "options.h" #include "controls.h" - -void FreeSC2Data (void); - -BOOLEAN LoadSC2Data (void); +#include "encount.h" +#include "file.h" +#include "gamestr.h" +#include "globdata.h" +#include "options.h" +#include "races.h" +#include "setup.h" +#include "state.h" +#include "util.h" +#include "libs/inplib.h" static void diff --git a/sc2/src/sc2code/settings.c b/sc2/src/sc2code/settings.c index faaf54076..8b9b7bd6c 100644 --- a/sc2/src/sc2code/settings.c +++ b/sc2/src/sc2code/settings.c @@ -16,7 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "settings.h" + +#include "globdata.h" +#include "libs/compiler.h" + static MUSIC_REF LastMusicRef; static BOOLEAN LastContinuous; diff --git a/sc2/src/sc2code/settings.h b/sc2/src/sc2code/settings.h new file mode 100644 index 000000000..c91393525 --- /dev/null +++ b/sc2/src/sc2code/settings.h @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _SETTINGS_H +#define _SETTINGS_H + +#include "libs/sndlib.h" + +extern void ToggleMusic (void); +extern void StopMusic (void); +extern void ResumeMusic (void); +extern void PauseMusic (void); +extern void ToggleSoundEffect (void); + +extern void PlayMusic (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE + Priority); +extern void PlaySoundEffect (SOUND S, COUNT Channel, SoundPosition Pos, + void *PositionalObject, BYTE Priority); + + +#endif /* _SETTINGS_H */ + diff --git a/sc2/src/sc2code/setup.c b/sc2/src/sc2code/setup.c index a94523fd8..4f1b31627 100644 --- a/sc2/src/sc2code/setup.c +++ b/sc2/src/sc2code/setup.c @@ -16,16 +16,26 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "setup.h" + +#include "coderes.h" +#include "controls.h" +#include "options.h" +#include "nameref.h" +#include "init.h" +#include "intel.h" +#include "resinst.h" +#include "sounds.h" +#include "libs/compiler.h" +#include "libs/uio.h" +#include "libs/file.h" +#include "libs/graphics/gfx_common.h" +#include "libs/threadlib.h" + #include #include #include -#include "starcon.h" -#include "coderes.h" -#include "libs/threadlib.h" -#include "libs/graphics/gfx_common.h" -#include "libs/file.h" -#include "options.h" -#include "controls.h" + //Added by Chris @@ -38,19 +48,27 @@ extern BOOLEAN InitVideo (BOOLEAN UseCDROM); ACTIVITY LastActivity; BYTE PlayerControl[NUM_PLAYERS]; +// XXX: These declarations should really go to the file they belong to. MEM_HANDLE hResIndex; -CONTEXT ScreenContext, SpaceContext, StatusContext, OffScreenContext, - TaskContext; +CONTEXT ScreenContext; +CONTEXT SpaceContext; +CONTEXT StatusContext; +CONTEXT OffScreenContext; +CONTEXT TaskContext; SIZE screen_width, screen_height; FRAME Screen; -FONT StarConFont, MicroFont, TinyFont; +FONT StarConFont; +FONT MicroFont; +FONT TinyFont; QUEUE race_q[NUM_PLAYERS]; -SOUND MenuSounds, GameSounds; FRAME ActivityFrame, status, flagship_status, misc_data; Mutex GraphicsLock; -CondVar RenderingCond; STRING GameStrings; +uio_Repository *repository; +uio_DirHandle *rootDir; + + static void InitPlayerInput (void) { @@ -72,23 +90,26 @@ LoadKernel (int argc, char *argv[]) { #define MIN_K_REQUIRED (580000L / 1024) if (!InitGraphics (argc, argv, MIN_K_REQUIRED)) - return (FALSE); + return FALSE; InitSound (argc, argv); InitVideo (TRUE); - if ((ScreenContext = CaptureContext (CreateContext ())) == 0) - return(FALSE); - if ((Screen = CaptureDrawable ( - CreateDisplay (WANT_MASK | WANT_PIXMAP, &screen_width, &screen_height) - )) == 0) - return(FALSE); + ScreenContext = CaptureContext (CreateContext ()); + if (ScreenContext == NULL) + return FALSE; + + Screen = CaptureDrawable (CreateDisplay (WANT_MASK | WANT_PIXMAP, + &screen_width, &screen_height)); + if (Screen == NULL) + return FALSE; SetContext (ScreenContext); SetContextFGFrame (Screen); SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0)); - if ((hResIndex = InitResourceSystem ("starcon", RES_INDEX, NULL)) == 0) - return (FALSE); + hResIndex = InitResourceSystem ("starcon", RES_INDEX, NULL); + if (hResIndex == 0) + return FALSE; INIT_INSTANCES (); { @@ -102,17 +123,17 @@ LoadKernel (int argc, char *argv[]) InitPlayerInput (); GLOBAL (CurrentActivity) = (ACTIVITY)~0; - return (TRUE); + return TRUE; } BOOLEAN InitContexts (void) { RECT r; - if ((StatusContext = CaptureContext ( - CreateContext () - )) == 0) - return (FALSE); + + StatusContext = CaptureContext (CreateContext ()); + if (StatusContext == NULL) + return FALSE; SetContext (StatusContext); SetContextFGFrame (Screen); @@ -122,20 +143,18 @@ InitContexts (void) r.extent.height = STATUS_HEIGHT; SetContextClipRect (&r); - if ((SpaceContext = CaptureContext ( - CreateContext () - )) == 0) - return (FALSE); + SpaceContext = CaptureContext (CreateContext ()); + if (SpaceContext == NULL) + return FALSE; - if ((OffScreenContext = CaptureContext ( - CreateContext () - )) == 0) - return (FALSE); + OffScreenContext = CaptureContext (CreateContext ()); + if (OffScreenContext == NULL) + return FALSE; if (!InitQueue (&disp_q, 100, sizeof (ELEMENT))) - return (FALSE); + return FALSE; - return (TRUE); + return TRUE; } BOOLEAN @@ -144,47 +163,40 @@ InitKernel (void) COUNT counter; for (counter = 0; counter < NUM_PLAYERS; ++counter) - { InitQueue (&race_q[counter], MAX_SHIPS_PER_SIDE, sizeof (STARSHIP)); - } - if ((StarConFont = CaptureFont ( - LoadGraphic (STARCON_FONT) - )) == 0) - return (FALSE); + StarConFont = CaptureFont (LoadGraphic (STARCON_FONT)); + if (StarConFont == NULL) + return FALSE; - if ((TinyFont = CaptureFont ( - LoadGraphic (TINY_FONT) - )) == 0) - return (FALSE); - if ((ActivityFrame = CaptureDrawable ( - LoadGraphic (ACTIVITY_ANIM) - )) == 0) - return (FALSE); + TinyFont = CaptureFont (LoadGraphic (TINY_FONT)); + if (TinyFont == NULL) + return FALSE; - if ((status = CaptureDrawable ( - LoadGraphic (STATUS_MASK_PMAP_ANIM) - )) == 0) - return (FALSE); + ActivityFrame = CaptureDrawable (LoadGraphic (ACTIVITY_ANIM)); + if (ActivityFrame == NULL) + return FALSE; - if ((GameStrings = CaptureStringTable ( - LoadStringTableInstance (STARCON_GAME_STRINGS) - )) == 0) - return (FALSE); + status = CaptureDrawable (LoadGraphic (STATUS_MASK_PMAP_ANIM)); + if (status == NULL) + return FALSE; - if ((MicroFont = CaptureFont ( - LoadGraphic (MICRO_FONT) - )) == 0) - return (FALSE); + GameStrings = CaptureStringTable (LoadStringTableInstance ( + STARCON_GAME_STRINGS)); + if (GameStrings == 0) + return FALSE; - if ((MenuSounds = CaptureSound ( - LoadSound (MENU_SOUNDS) - )) == 0) - return (FALSE); + MicroFont = CaptureFont (LoadGraphic (MICRO_FONT)); + if (MicroFont == NULL) + return FALSE; + + MenuSounds = CaptureSound (LoadSound (MENU_SOUNDS)); + if (MenuSounds == 0) + return FALSE; InitSpace (); - return (TRUE); + return TRUE; } BOOLEAN @@ -195,7 +207,7 @@ InitGameKernel (void) InitKernel (); InitContexts (); } - return(TRUE); + return TRUE; } void @@ -222,3 +234,27 @@ SetPlayerInput (void) } } +int +initIO (void) +{ + uio_init (); + repository = uio_openRepository (0); + + rootDir = uio_openDir (repository, "/", 0); + if (rootDir == NULL) { + fprintf(stderr, "Could not open '/' dir.\n"); + return -1; + } + return 0; +} + +void +uninitIO (void) +{ + uio_closeDir (rootDir); + uio_closeRepository (repository); + uio_unInit (); +} + + + diff --git a/sc2/src/sc2code/setup.h b/sc2/src/sc2code/setup.h new file mode 100644 index 000000000..77aaa6ad2 --- /dev/null +++ b/sc2/src/sc2code/setup.h @@ -0,0 +1,64 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _SETUP_H +#define _SETUP_H + +#include "displist.h" +#include "globdata.h" +#include "libs/sndlib.h" +#include "libs/gfxlib.h" +#include "libs/threadlib.h" + + +extern MEM_HANDLE hResIndex; + +extern FRAME Screen; +extern FRAME ActivityFrame; + +extern CONTEXT OffScreenContext; +extern CONTEXT ScreenContext; +extern CONTEXT SpaceContext; +extern CONTEXT StatusContext; +extern CONTEXT TaskContext; + +extern SIZE screen_width, screen_height; + +extern FONT StarConFont; +extern FONT MicroFont; +extern FONT TinyFont; + +extern Mutex GraphicsLock; +extern CondVar RenderingCond; + +extern QUEUE race_q[]; + +extern ACTIVITY LastActivity; + +extern BYTE PlayerControl[]; +extern SIZE cur_player; + +extern BOOLEAN InitContexts (void); + +int initIO (void); +void uninitIO (void); + +extern void SetPlayerInput (void); + + +#endif /* _SETUP_H */ + + diff --git a/sc2/src/sc2code/setupmenu.c b/sc2/src/sc2code/setupmenu.c index 0a7c83ae3..a277e7730 100644 --- a/sc2/src/sc2code/setupmenu.c +++ b/sc2/src/sc2code/setupmenu.c @@ -16,13 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "setupmenu.h" + #include "controls.h" #include "options.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/widgets.h" + typedef struct setup_menu_state { BOOLEAN (*InputFunc) (struct setup_menu_state *pInputState); COUNT MenuRepeatDelay; diff --git a/sc2/src/sc2code/ship.c b/sc2/src/sc2code/ship.c index 3e9e1832d..99c87b20d 100644 --- a/sc2/src/sc2code/ship.c +++ b/sc2/src/sc2code/ship.c @@ -16,8 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "collide.h" +#include "colors.h" +#include "globdata.h" +#include "intel.h" +#include "races.h" +#include "setup.h" +#include "sounds.h" +#include "libs/mathlib.h" + void animation_preprocess (PELEMENT ElementPtr) diff --git a/sc2/src/sc2code/ships/androsyn/androsyn.c b/sc2/src/sc2code/ships/androsyn/androsyn.c index b43ac22a7..60e29bf04 100644 --- a/sc2/src/sc2code/ships/androsyn/androsyn.c +++ b/sc2/src/sc2code/ships/androsyn/androsyn.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/androsyn/resinst.h" +#include "libs/mathlib.h" + + #define MAX_CREW 20 #define MAX_ENERGY 24 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/arilou/arilou.c b/sc2/src/sc2code/ships/arilou/arilou.c index 37281c664..c1b3c6ce9 100644 --- a/sc2/src/sc2code/ships/arilou/arilou.c +++ b/sc2/src/sc2code/ships/arilou/arilou.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/arilou/resinst.h" +#include "libs/mathlib.h" + + #define MAX_CREW 6 #define MAX_ENERGY 20 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/blackurq/blackurq.c b/sc2/src/sc2code/ships/blackurq/blackurq.c index c514232d7..cf69f6dce 100644 --- a/sc2/src/sc2code/ships/blackurq/blackurq.c +++ b/sc2/src/sc2code/ships/blackurq/blackurq.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/blackurq/resinst.h" +#include "globdata.h" + + #define MAX_CREW MAX_CREW_SIZE #define MAX_ENERGY MAX_ENERGY_SIZE #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/chenjesu/chenjesu.c b/sc2/src/sc2code/ships/chenjesu/chenjesu.c index 5d733aced..12f20e133 100644 --- a/sc2/src/sc2code/ships/chenjesu/chenjesu.c +++ b/sc2/src/sc2code/ships/chenjesu/chenjesu.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/chenjesu/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 36 #define MAX_ENERGY 30 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/chmmr/chmmr.c b/sc2/src/sc2code/ships/chmmr/chmmr.c index 1c4fe9687..311c4e078 100644 --- a/sc2/src/sc2code/ships/chmmr/chmmr.c +++ b/sc2/src/sc2code/ships/chmmr/chmmr.c @@ -19,6 +19,11 @@ #include "ships/ship.h" #include "ships/chmmr/resinst.h" +#include "colors.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW MAX_CREW_SIZE #define MAX_ENERGY MAX_ENERGY_SIZE #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/human/human.c b/sc2/src/sc2code/ships/human/human.c index b3250ae2e..d1be6df0c 100644 --- a/sc2/src/sc2code/ships/human/human.c +++ b/sc2/src/sc2code/ships/human/human.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/human/resinst.h" +#include "colors.h" +#include "globdata.h" + + #define MAX_CREW 18 #define MAX_ENERGY 18 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/ilwrath/ilwrath.c b/sc2/src/sc2code/ships/ilwrath/ilwrath.c index 1454372cc..7fde5e898 100644 --- a/sc2/src/sc2code/ships/ilwrath/ilwrath.c +++ b/sc2/src/sc2code/ships/ilwrath/ilwrath.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/ilwrath/resinst.h" +#include "colors.h" +#include "globdata.h" + + #define MAX_CREW 22 #define MAX_ENERGY 16 #define ENERGY_REGENERATION 4 diff --git a/sc2/src/sc2code/ships/lastbat/lastbat.c b/sc2/src/sc2code/ships/lastbat/lastbat.c index 0e8a0dd90..49736a8bb 100644 --- a/sc2/src/sc2code/ships/lastbat/lastbat.c +++ b/sc2/src/sc2code/ships/lastbat/lastbat.c @@ -19,6 +19,12 @@ #include "ships/ship.h" #include "ships/lastbat/resinst.h" +#include "colors.h" +#include "globdata.h" +#include "libs/mathlib.h" +#include "libs/timelib.h" + + #define num_generators characteristics.max_thrust #define MAX_CREW 1 diff --git a/sc2/src/sc2code/ships/melnorme/melnorme.c b/sc2/src/sc2code/ships/melnorme/melnorme.c index 2ef6ca50e..7fcfbee21 100644 --- a/sc2/src/sc2code/ships/melnorme/melnorme.c +++ b/sc2/src/sc2code/ships/melnorme/melnorme.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/melnorme/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 20 #define MAX_ENERGY MAX_ENERGY_SIZE #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/mmrnmhrm/mmrnmhrm.c b/sc2/src/sc2code/ships/mmrnmhrm/mmrnmhrm.c index 67b355acd..8e24e6f8a 100644 --- a/sc2/src/sc2code/ships/mmrnmhrm/mmrnmhrm.c +++ b/sc2/src/sc2code/ships/mmrnmhrm/mmrnmhrm.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/mmrnmhrm/resinst.h" +#include "init.h" + + #define MAX_CREW 20 #define MAX_ENERGY 10 #define ENERGY_REGENERATION 2 diff --git a/sc2/src/sc2code/ships/orz/orz.c b/sc2/src/sc2code/ships/orz/orz.c index f6d9a623c..9206f84d4 100644 --- a/sc2/src/sc2code/ships/orz/orz.c +++ b/sc2/src/sc2code/ships/orz/orz.c @@ -19,6 +19,11 @@ #include "ships/ship.h" #include "ships/orz/resinst.h" +#include "colors.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 16 #define MAX_ENERGY 20 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/pkunk/pkunk.c b/sc2/src/sc2code/ships/pkunk/pkunk.c index 4d39d68db..3b21343ab 100644 --- a/sc2/src/sc2code/ships/pkunk/pkunk.c +++ b/sc2/src/sc2code/ships/pkunk/pkunk.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/pkunk/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 8 #define MAX_ENERGY 12 #define ENERGY_REGENERATION 0 diff --git a/sc2/src/sc2code/ships/ship.h b/sc2/src/sc2code/ships/ship.h index c606243c2..0c03373c4 100644 --- a/sc2/src/sc2code/ships/ship.h +++ b/sc2/src/sc2code/ships/ship.h @@ -24,10 +24,11 @@ #include "collide.h" // XXX: Do we really need this one? -#include "reslib.h" - -// XXX: Remove this one later. -#include "starcon.h" +//#include "reslib.h" +#include "intel.h" +#include "races.h" +#include "sounds.h" +#include "weapon.h" #endif /* _SHIP_H */ diff --git a/sc2/src/sc2code/ships/shofixti/shofixti.c b/sc2/src/sc2code/ships/shofixti/shofixti.c index d5bdc2b04..138fd1b54 100644 --- a/sc2/src/sc2code/ships/shofixti/shofixti.c +++ b/sc2/src/sc2code/ships/shofixti/shofixti.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/shofixti/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 6 #define MAX_ENERGY 4 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/sis_ship/sis_ship.c b/sc2/src/sc2code/ships/sis_ship/sis_ship.c index e8bbadf48..147f2a404 100644 --- a/sc2/src/sc2code/ships/sis_ship/sis_ship.c +++ b/sc2/src/sc2code/ships/sis_ship/sis_ship.c @@ -18,7 +18,12 @@ #include "ships/ship.h" #include "ships/sis_ship/resinst.h" + +#include "colors.h" #include "controls.h" +#include "globdata.h" +#include "libs/mathlib.h" + #define MAX_TRACKING 3 #define MAX_DEFENSE 8 diff --git a/sc2/src/sc2code/ships/slylandr/slylandr.c b/sc2/src/sc2code/ships/slylandr/slylandr.c index df6ad4336..e507bab0f 100644 --- a/sc2/src/sc2code/ships/slylandr/slylandr.c +++ b/sc2/src/sc2code/ships/slylandr/slylandr.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/slylandr/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 12 #define MAX_ENERGY 20 #define ENERGY_REGENERATION 0 diff --git a/sc2/src/sc2code/ships/supox/supox.c b/sc2/src/sc2code/ships/supox/supox.c index ac8a089af..e9bda751a 100644 --- a/sc2/src/sc2code/ships/supox/supox.c +++ b/sc2/src/sc2code/ships/supox/supox.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/supox/resinst.h" +#include "libs/mathlib.h" + + #define MAX_CREW 12 #define MAX_ENERGY 16 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/syreen/syreen.c b/sc2/src/sc2code/ships/syreen/syreen.c index f3159a1b1..73f5cd8ad 100644 --- a/sc2/src/sc2code/ships/syreen/syreen.c +++ b/sc2/src/sc2code/ships/syreen/syreen.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/syreen/resinst.h" +#include "libs/mathlib.h" + + #define SYREEN_MAX_CREW_SIZE MAX_CREW_SIZE #define MAX_CREW 12 #define MAX_ENERGY 16 diff --git a/sc2/src/sc2code/ships/thradd/thradd.c b/sc2/src/sc2code/ships/thradd/thradd.c index c73231b2c..2d3351ab2 100644 --- a/sc2/src/sc2code/ships/thradd/thradd.c +++ b/sc2/src/sc2code/ships/thradd/thradd.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/thradd/resinst.h" +#include "globdata.h" + + #define MAX_CREW 8 #define MAX_ENERGY 24 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/umgah/umgah.c b/sc2/src/sc2code/ships/umgah/umgah.c index 21e9d753c..5b4764c68 100644 --- a/sc2/src/sc2code/ships/umgah/umgah.c +++ b/sc2/src/sc2code/ships/umgah/umgah.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/umgah/resinst.h" +#include "libs/mathlib.h" + + #define MAX_CREW 10 #define MAX_ENERGY 30 #define ENERGY_REGENERATION MAX_ENERGY diff --git a/sc2/src/sc2code/ships/urquan/urquan.c b/sc2/src/sc2code/ships/urquan/urquan.c index 0b28a8991..e5b115259 100644 --- a/sc2/src/sc2code/ships/urquan/urquan.c +++ b/sc2/src/sc2code/ships/urquan/urquan.c @@ -19,6 +19,11 @@ #include "ships/ship.h" #include "ships/urquan/resinst.h" +#include "globdata.h" + +#include + + #define MAX_CREW MAX_CREW_SIZE #define MAX_ENERGY MAX_ENERGY_SIZE #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/ships/utwig/utwig.c b/sc2/src/sc2code/ships/utwig/utwig.c index e105960ec..f5404acb2 100644 --- a/sc2/src/sc2code/ships/utwig/utwig.c +++ b/sc2/src/sc2code/ships/utwig/utwig.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/utwig/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 20 #define MAX_ENERGY 20 #define ENERGY_REGENERATION 0 diff --git a/sc2/src/sc2code/ships/vux/vux.c b/sc2/src/sc2code/ships/vux/vux.c index 2af2d30b0..f982d7063 100644 --- a/sc2/src/sc2code/ships/vux/vux.c +++ b/sc2/src/sc2code/ships/vux/vux.c @@ -19,6 +19,10 @@ #include "ships/ship.h" #include "ships/vux/resinst.h" +#include "globdata.h" +#include "libs/mathlib.h" + + #define MAX_CREW 20 #define MAX_ENERGY 40 #define ENERGY_REGENERATION 1 @@ -319,7 +323,7 @@ vux_preprocess (PELEMENT ElementPtr) // Originally, the warp distance was: // DISPLAY_TO_WORLD (SPACE_HEIGHT << 1) // where SPACE_HEIGHT = SCREEN_HEIGHT - (SAFE_Y * 2) - // But in reality this should be relative to the laser-range + // But in reality this should be relative to the laser-range #define MAXX_ENTRY_DIST DISPLAY_TO_WORLD ((LASER_BASE + VUX_OFFSET + WARP_OFFSET) << 1) #define MAXY_ENTRY_DIST DISPLAY_TO_WORLD ((LASER_BASE + VUX_OFFSET + WARP_OFFSET) << 1) SIZE dx, dy; diff --git a/sc2/src/sc2code/ships/yehat/yehat.c b/sc2/src/sc2code/ships/yehat/yehat.c index a67da3c25..2617743a5 100644 --- a/sc2/src/sc2code/ships/yehat/yehat.c +++ b/sc2/src/sc2code/ships/yehat/yehat.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/yehat/resinst.h" +#include "libs/mathlib.h" + + #define MAX_CREW 20 #define MAX_ENERGY 10 #define ENERGY_REGENERATION 2 diff --git a/sc2/src/sc2code/ships/zoqfot/zoqfot.c b/sc2/src/sc2code/ships/zoqfot/zoqfot.c index 56597d55c..d6264736a 100644 --- a/sc2/src/sc2code/ships/zoqfot/zoqfot.c +++ b/sc2/src/sc2code/ships/zoqfot/zoqfot.c @@ -19,6 +19,9 @@ #include "ships/ship.h" #include "ships/zoqfot/resinst.h" +#include "libs/mathlib.h" + + #define MAX_CREW 10 #define MAX_ENERGY 10 #define ENERGY_REGENERATION 1 diff --git a/sc2/src/sc2code/shipstat.c b/sc2/src/sc2code/shipstat.c index 17d12a0d1..2a2a5c61c 100644 --- a/sc2/src/sc2code/shipstat.c +++ b/sc2/src/sc2code/shipstat.c @@ -16,8 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "colors.h" +#include "globdata.h" #include "options.h" +#include "build.h" +#include "setup.h" +#include "libs/gfxlib.h" + void DrawCrewFuelString (COORD y, SIZE state) diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index 9a296c6c8..57982f1e1 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -16,21 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "melee.h" +#include "build.h" +#include "colors.h" #include "controls.h" +#include "fmv.h" +#include "gamestr.h" +#include "melee.h" #include "options.h" +#include "races.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sis.h" +#include "sounds.h" +#include "state.h" #include "libs/graphics/gfx_common.h" +#include "libs/inplib.h" -//Added by Chris - -#ifdef WANT_SHIP_SPINS -void DoShipSpin (COUNT index, MUSIC_REF hMusic); // Defined in fmv.c -#endif - -void GetGaugeRect (PRECT pRect, BOOLEAN IsCrewRect); // Defined in sis.c - -//End added by Chris #ifdef USE_3DO_HANGAR // 3DO 4x3 hangar layout diff --git a/sc2/src/sc2code/sis.c b/sc2/src/sc2code/sis.c index 1c255ef4c..11a6357fa 100644 --- a/sc2/src/sc2code/sis.c +++ b/sc2/src/sc2code/sis.c @@ -16,11 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "colors.h" #include "commglue.h" +#include "encount.h" +#include "gamestr.h" +#include "options.h" +#include "setup.h" +#include "state.h" #include "libs/graphics/gfx_common.h" #include "libs/tasklib.h" -#include "options.h" + static const UNICODE *describeWeapon (BYTE moduleType); @@ -37,7 +42,8 @@ RepairSISBorder (void) r.corner.y = SIS_ORG_Y - 1; r.extent.width = 1; r.extent.height = SIS_SCREEN_HEIGHT + 2; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); DrawFilledRectangle (&r); SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F)); diff --git a/sc2/src/sc2code/sis.h b/sc2/src/sc2code/sis.h index 8ca9c8d71..f6200d9cb 100644 --- a/sc2/src/sc2code/sis.h +++ b/sc2/src/sc2code/sis.h @@ -249,6 +249,7 @@ extern void RepairSISBorder (void); extern void InitSISContexts (void); extern void DrawSISFrame (void); extern void ClearSISRect (BYTE ClearFlags); +extern void SetFlashRect (PRECT pRect, FRAME f); extern void DrawHyperCoords (POINT puniverse); extern void DrawSISTitle (UNICODE *pStr); extern void DrawSISMessage (UNICODE *pStr); @@ -258,6 +259,8 @@ extern void DateToString (UNICODE *buf, BYTE month_index, BYTE day_index, extern void DrawStatusMessage (UNICODE *pStr); extern void DrawLanders (void); extern void DrawStorageBays (BOOLEAN Refresh); +extern void GetGaugeRect (PRECT pRect, BOOLEAN IsCrewRect); + extern void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta); extern COUNT GetCrewCount (void); diff --git a/sc2/src/sc2code/sounds.c b/sc2/src/sc2code/sounds.c new file mode 100644 index 000000000..c35c3b0b3 --- /dev/null +++ b/sc2/src/sc2code/sounds.c @@ -0,0 +1,200 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "settings.h" +#include "sounds.h" +#include "units.h" + + +SOUND MenuSounds; +SOUND GameSounds; + +#define MAX_SOUNDS 8 +static BYTE num_sounds; +static SOUND sound_buf[MAX_SOUNDS]; +static ELEMENTPTR sound_posobj[MAX_SOUNDS]; + + +void +PlaySound (SOUND S, SoundPosition Pos, ELEMENTPTR PositionalObject, + BYTE Priority) +{ +#define MIN_FX_CHANNEL 1 +#define NUM_FX_CHANNELS 4 + /* obviously number of channels is assumed to be at least 5 */ + BYTE chan, c; + static BYTE lru_channel[NUM_FX_CHANNELS] = {0, 1, 2, 3}; + static SOUND channel[NUM_FX_CHANNELS]; + + if (S == 0) + return; + + for (chan = 0; chan < NUM_FX_CHANNELS; ++chan) + { + if (S == channel[chan]) + break; + } + + if (chan == NUM_FX_CHANNELS) + { + for (chan = 0; chan < NUM_FX_CHANNELS; ++chan) + { + if (!ChannelPlaying (chan + MIN_FX_CHANNEL)) + break; + } + + if (chan == NUM_FX_CHANNELS) + chan = lru_channel[0]; + } + + channel[chan] = S; + + for (c = 0; c < NUM_FX_CHANNELS - 1; ++c) + { + if (lru_channel[c] == chan) + { + memmove ((PBYTE)&lru_channel[c], (PBYTE)&lru_channel[c + 1], + (NUM_FX_CHANNELS - 1) - c); + break; + } + } + lru_channel[NUM_FX_CHANNELS - 1] = chan; + + PlaySoundEffect (S, chan + MIN_FX_CHANNEL, Pos, PositionalObject, Priority); +} + +void +ProcessSound (SOUND Sound, ELEMENTPTR PositionalObject) +{ + if (Sound == (SOUND)~0) + { + memset (sound_buf, 0, sizeof (sound_buf)); + memset (sound_posobj, 0, sizeof (sound_posobj)); + num_sounds = MAX_SOUNDS; + } + else if (num_sounds < MAX_SOUNDS) + { + sound_buf[num_sounds] = Sound; + sound_posobj[num_sounds++] = PositionalObject; + } +} + +SoundPosition +CalcSoundPosition (ELEMENTPTR ElementPtr) +{ + SoundPosition pos; + + if (ElementPtr == NULL) + { + pos.x = pos.y = 0; + pos.positional = FALSE; + } + else + { + GRAPHICS_PRIM objtype; + + objtype = GetPrimType (&DisplayArray[ElementPtr->PrimIndex]); + if (objtype == LINE_PRIM) + { + pos.x = DisplayArray[ElementPtr->PrimIndex].Object.Line.first.x; + pos.y = DisplayArray[ElementPtr->PrimIndex].Object.Line.first.y; + } + else + { + pos.x = DisplayArray[ElementPtr->PrimIndex].Object.Point.x; + pos.y = DisplayArray[ElementPtr->PrimIndex].Object.Point.y; + } + + pos.x -= (SPACE_WIDTH >> 1); + pos.y -= (SPACE_HEIGHT); + pos.positional = TRUE; + } + + return pos; +} + +SoundPosition +NotPositional (void) +{ + return CalcSoundPosition (NULL); +} + +/* Updates positional sound effects */ +void +UpdateSoundPositions (void) { + COUNT i; + + for (i = 0; i <= NUM_FX_CHANNELS; ++i) + { + // XXX: (possible BUG): shouldn't the "<=" be "<" + // TODO: investigate - SvdB + + ELEMENTPTR posobj; + if (!ChannelPlaying(i)) + continue; + + posobj = GetPositionalObject (i); + if (posobj != NULL) + { + SoundPosition pos; + pos = CalcSoundPosition (posobj); + if (pos.positional) + UpdateSoundPosition (i, pos); + } + } +} + +void +FlushSounds (void) +{ + if (num_sounds > 0) + { + SOUND *pSound; + ELEMENTPTR *pSoundPosObj; + + pSound = sound_buf; + pSoundPosObj = sound_posobj; + do + { + SoundPosition pos = CalcSoundPosition (*pSoundPosObj); + PlaySound (*pSound++, pos, *pSoundPosObj++, + GAME_SOUND_PRIORITY); + } while (--num_sounds); + } +} + +void +RemoveSoundsForObject (ELEMENTPTR PosObj) +{ + int i; + + for (i = 0; i <= NUM_FX_CHANNELS; ++i) + { + // XXX: (possible BUG): shouldn't the "<=" be "<" + // TODO: investigate - SvdB + + if (GetPositionalObject (i) == PosObj) + SetPositionalObject (i, NULL); + } + + for (i = 0; i < num_sounds; ++i) + { + if (sound_posobj[i] == PosObj) + sound_posobj[i] = NULL; + } +} + + diff --git a/sc2/src/sc2code/sounds.h b/sc2/src/sc2code/sounds.h index dd44191b9..817acddae 100644 --- a/sc2/src/sc2code/sounds.h +++ b/sc2/src/sc2code/sounds.h @@ -19,6 +19,10 @@ #ifndef _SOUNDS_H #define _SOUNDS_H +#include "element.h" +#include "libs/compiler.h" +#include "libs/sndlib.h" + typedef enum { GRAB_CREW = 0, @@ -29,5 +33,38 @@ typedef enum TARGET_DAMAGED_FOR_6_PLUS_PT } SOUND_EFFECTS; +extern SOUND MenuSounds; +extern SOUND GameSounds; + +/* Constants for DoInput */ +typedef UWORD MENU_SOUND_FLAGS; +#define MENU_SOUND_UP ((MENU_SOUND_FLAGS)(1 << 0)) +#define MENU_SOUND_DOWN ((MENU_SOUND_FLAGS)(1 << 1)) +#define MENU_SOUND_LEFT ((MENU_SOUND_FLAGS)(1 << 2)) +#define MENU_SOUND_RIGHT ((MENU_SOUND_FLAGS)(1 << 3)) +#define MENU_SOUND_SELECT ((MENU_SOUND_FLAGS)(1 << 4)) +#define MENU_SOUND_CANCEL ((MENU_SOUND_FLAGS)(1 << 5)) +#define MENU_SOUND_SPECIAL ((MENU_SOUND_FLAGS)(1 << 6)) +#define MENU_SOUND_PAGEUP ((MENU_SOUND_FLAGS)(1 << 7)) +#define MENU_SOUND_PAGEDOWN ((MENU_SOUND_FLAGS)(1 << 8)) +#define MENU_SOUND_DELETE ((MENU_SOUND_FLAGS)(1 << 9)) +#define MENU_SOUND_ARROWS (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_LEFT | MENU_SOUND_RIGHT) +#define MENU_SOUND_NONE ((MENU_SOUND_FLAGS)0) + +extern void SetMenuSounds (MENU_SOUND_FLAGS sound_0, + MENU_SOUND_FLAGS sound_1); +extern void GetMenuSounds (MENU_SOUND_FLAGS *sound_0, + MENU_SOUND_FLAGS *sound_1); + +extern void PlaySound (SOUND S, SoundPosition Pos, + ELEMENTPTR PositionalObject, BYTE Priority); +extern void ProcessSound (SOUND Sound, ELEMENTPTR PositionalObject); +extern SoundPosition CalcSoundPosition (ELEMENTPTR ElementPtr); +extern SoundPosition NotPositional (void); +extern void UpdateSoundPositions (void); +extern void FlushSounds (void); +extern void RemoveSoundsForObject (ELEMENTPTR PosObj); + #endif /* _SOUNDS_H */ + diff --git a/sc2/src/sc2code/starbase.c b/sc2/src/sc2code/starbase.c index 80a29c502..878b5847d 100644 --- a/sc2/src/sc2code/starbase.c +++ b/sc2/src/sc2code/starbase.c @@ -16,10 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" +#include "colors.h" +#include "controls.h" +#include "encount.h" +#include "gamestr.h" +#include "resinst.h" +#include "settings.h" +#include "setup.h" +#include "sounds.h" #include "libs/graphics/gfx_common.h" #include "libs/tasklib.h" -#include "controls.h" +#include "libs/inplib.h" + PMENU_STATE pMenuState; @@ -517,6 +526,7 @@ ExitStarBase: } } +// XXX: Doesn't really belong in this file. COUNT WrapText (UNICODE *pStr, COUNT len, TEXT *tarray, SIZE field_width) { diff --git a/sc2/src/sc2code/starbase.h b/sc2/src/sc2code/starbase.h index 5e7219134..04199cedc 100644 --- a/sc2/src/sc2code/starbase.h +++ b/sc2/src/sc2code/starbase.h @@ -19,8 +19,11 @@ #ifndef _STARBASE_H #define _STARBASE_H +#include "libs/gfxlib.h" +#include "libs/sndlib.h" #include "libs/tasklib.h" + enum { TALK_COMMANDER = 0, @@ -63,7 +66,12 @@ extern BOOLEAN DoShipyard (PMENU_STATE pMS); extern void DrawShipPiece (PMENU_STATE pMS, COUNT which_piece, COUNT which_slot, BOOLEAN DrawBluePrint); +extern COUNT WrapText (UNICODE *pStr, COUNT len, TEXT *tarray, SIZE + field_width); + // XXX: Doesn't really belong in this file. + extern const char starbase_str_array[][20]; #endif /* _STARBASE_H */ + diff --git a/sc2/src/sc2code/starcon.c b/sc2/src/sc2code/starcon.c index 56415a916..27d1db53d 100644 --- a/sc2/src/sc2code/starcon.c +++ b/sc2/src/sc2code/starcon.c @@ -16,21 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" -#include "demo.h" -#include "credits.h" -//Added by Chris +#include "encount.h" +#include "element.h" +#include "fmv.h" +#include "gameev.h" +#include "types.h" +#include "globdata.h" +#include "resinst.h" +#include "setup.h" +#include "libs/tasklib.h" -void Logo (void); - -//End Added by Chris - -enum -{ - CLOSING = 0, - OPENING -}; // Open or close the periodically occuring QuasiSpace portal. // A seperate thread is always inside this function when the player @@ -73,790 +69,13 @@ int arilou_gate_task(void* data) return(0); } -static void -arilou_entrance_event (void) -{ - SET_GAME_STATE (ARILOU_SPACE, OPENING); - AddEvent (RELATIVE_EVENT, 0, 3, 0, ARILOU_EXIT_EVENT); -} - -static void -arilou_exit_event (void) -{ - COUNT month_index, year_index; - - year_index = GLOBAL (GameClock.year_index); - if ((month_index = GLOBAL (GameClock.month_index) % 12) == 0) - ++year_index; - ++month_index; - - SET_GAME_STATE (ARILOU_SPACE, CLOSING); - AddEvent (ABSOLUTE_EVENT, - month_index, 17, year_index, ARILOU_ENTRANCE_EVENT); -} - -void -SetRaceDest (BYTE which_race, COORD x, COORD y, BYTE days_left, BYTE - func_index) -{ - HSTARSHIP hStarShip; - EXTENDED_SHIP_FRAGMENTPTR TemplatePtr; - - hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), which_race); - TemplatePtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hStarShip - ); - - TemplatePtr->ShipInfo.dest_loc.x = x; - TemplatePtr->ShipInfo.dest_loc.y = y; - TemplatePtr->ShipInfo.days_left = days_left; - TemplatePtr->ShipInfo.func_index = func_index; - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hStarShip - ); -} - -static void -check_race_growth (void) -{ - HSTARSHIP hStarShip, hNextShip; - - for (hStarShip = GetHeadLink (&GLOBAL (avail_race_q)); - hStarShip; hStarShip = hNextShip) - { - EXTENDED_SHIP_FRAGMENTPTR TemplatePtr; - - TemplatePtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hStarShip - ); - hNextShip = _GetSuccLink (TemplatePtr); - - if (TemplatePtr->ShipInfo.actual_strength - && TemplatePtr->ShipInfo.actual_strength != (COUNT)~0) - { - SIZE delta_strength; - - delta_strength = (SBYTE)TemplatePtr->ShipInfo.energy_level; - if (TemplatePtr->ShipInfo.growth_err_term <= - TemplatePtr->ShipInfo.growth_fract) - { - if (delta_strength <= 0) - --delta_strength; - else - ++delta_strength; - } - TemplatePtr->ShipInfo.growth_err_term -= - TemplatePtr->ShipInfo.growth_fract; - - delta_strength += TemplatePtr->ShipInfo.actual_strength; - if (delta_strength <= 0) - { - delta_strength = 0; - TemplatePtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); - } - else if (delta_strength > MAX_FLEET_STRENGTH) - delta_strength = MAX_FLEET_STRENGTH; - - TemplatePtr->ShipInfo.actual_strength = (COUNT)delta_strength; - if (TemplatePtr->ShipInfo.actual_strength && TemplatePtr->ShipInfo.days_left) - { - TemplatePtr->ShipInfo.loc.x += - (TemplatePtr->ShipInfo.dest_loc.x - - TemplatePtr->ShipInfo.loc.x) - / TemplatePtr->ShipInfo.days_left; - TemplatePtr->ShipInfo.loc.y += - (TemplatePtr->ShipInfo.dest_loc.y - - TemplatePtr->ShipInfo.loc.y) - / TemplatePtr->ShipInfo.days_left; - - if (--TemplatePtr->ShipInfo.days_left == 0 - && TemplatePtr->ShipInfo.func_index != (BYTE)~0) - EventHandler (TemplatePtr->ShipInfo.func_index); - } - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hStarShip - ); - } -} - -static void -black_urquan_genocide (void) -{ - BYTE Index; - long best_dist; - SIZE best_dx, best_dy; - HSTARSHIP hStarShip, hNextShip; - HSTARSHIP hBlackUrquan; - EXTENDED_SHIP_FRAGMENTPTR BlackUrquanPtr; - - hBlackUrquan = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), BLACK_URQUAN_SHIP - ); - BlackUrquanPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hBlackUrquan - ); - - best_dist = -1; - best_dx = SOL_X - BlackUrquanPtr->ShipInfo.loc.x; - best_dy = SOL_Y - BlackUrquanPtr->ShipInfo.loc.y; - for (Index = 0, hStarShip = GetHeadLink (&GLOBAL (avail_race_q)); - hStarShip; ++Index, hStarShip = hNextShip) - { - EXTENDED_SHIP_FRAGMENTPTR TemplatePtr; - - TemplatePtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hStarShip - ); - hNextShip = _GetSuccLink (TemplatePtr); - - if (Index != BLACK_URQUAN_SHIP - && Index != URQUAN_SHIP - && TemplatePtr->ShipInfo.actual_strength != (COUNT)~0) - { - SIZE dx, dy; - - dx = TemplatePtr->ShipInfo.loc.x - BlackUrquanPtr->ShipInfo.loc.x; - dy = TemplatePtr->ShipInfo.loc.y - BlackUrquanPtr->ShipInfo.loc.y; - if (dx == 0 && dy == 0) - { - // Arrived at the victim's home world. Cleanse it. - TemplatePtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); - TemplatePtr->ShipInfo.actual_strength = 0; - } - else if (TemplatePtr->ShipInfo.actual_strength) - { - long dist; - - dist = (long)dx * dx + (long)dy * dy; - if (best_dist < 0 || dist < best_dist || Index == DRUUGE_SHIP) - { - best_dist = dist; - best_dx = dx; - best_dy = dy; - - if (Index == DRUUGE_SHIP) - hNextShip = 0; - } - } - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hStarShip - ); - } - - if (best_dist < 0 && best_dx == 0 && best_dy == 0) - { - // All spheres of influence are gone - game over. - GLOBAL (CurrentActivity) &= ~IN_BATTLE; - GLOBAL_SIS (CrewEnlisted) = (COUNT)~0; - - SET_GAME_STATE (KOHR_AH_KILLED_ALL, 1); - } - else - { - // Moving towards new race to cleanse. - COUNT speed; - - if (best_dist < 0) - best_dist = (long)best_dx * best_dx - + (long)best_dy * best_dy; - - speed = square_root (best_dist) / 158; - if (speed == 0) - speed = 1; - else if (speed > 255) - speed = 255; - - SET_GAME_STATE (KOHR_AH_FRENZY, 1); - SET_GAME_STATE (KOHR_AH_VISITS, 0); - SET_GAME_STATE (KOHR_AH_REASONS, 0); - SET_GAME_STATE (KOHR_AH_PLEAD, 0); - SET_GAME_STATE (KOHR_AH_INFO, 0); - SET_GAME_STATE (URQUAN_VISITS, 0); - SetRaceDest (BLACK_URQUAN_SHIP, - BlackUrquanPtr->ShipInfo.loc.x + best_dx, - BlackUrquanPtr->ShipInfo.loc.y + best_dy, - (BYTE)speed, KOHR_AH_GENOCIDE_EVENT); - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hBlackUrquan - ); -} - -static void -pkunk_mission (void) -{ - HSTARSHIP hPkunk; - EXTENDED_SHIP_FRAGMENTPTR PkunkPtr; - - hPkunk = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), PKUNK_SHIP - ); - PkunkPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hPkunk - ); - - if (PkunkPtr->ShipInfo.actual_strength) - { - BYTE MissionState; - - MissionState = GET_GAME_STATE (PKUNK_MISSION); - if (PkunkPtr->ShipInfo.days_left == 0 && MissionState) - { - if ((MissionState & 1) - /* made it to Yehat space */ - || (PkunkPtr->ShipInfo.loc.x == 4970 - && PkunkPtr->ShipInfo.loc.y == 400)) - PkunkPtr->ShipInfo.actual_strength = 0; - else if (PkunkPtr->ShipInfo.loc.x == 502 - && PkunkPtr->ShipInfo.loc.y == 401 - && GET_GAME_STATE (PKUNK_ON_THE_MOVE)) - { - SET_GAME_STATE (PKUNK_ON_THE_MOVE, 0); - AddEvent (RELATIVE_EVENT, 3, 0, 0, ADVANCE_PKUNK_MISSION); - UnlockStarShip ( - &GLOBAL (avail_race_q), - hPkunk - ); - return; - } - } - - if (PkunkPtr->ShipInfo.actual_strength == 0) - { - SET_GAME_STATE (YEHAT_ABSORBED_PKUNK, 1); - PkunkPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); - ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING); - } - else - { - COORD x, y; - - if (!(MissionState & 1)) - { - x = 4970; - y = 400; - } - else - { - x = 502; - y = 401; - } - SET_GAME_STATE (PKUNK_ON_THE_MOVE, 1); - SET_GAME_STATE (PKUNK_SWITCH, 0); - SetRaceDest (PKUNK_SHIP, x, y, - (BYTE)((365 >> 1) - PkunkPtr->ShipInfo.days_left), - ADVANCE_PKUNK_MISSION); - } - SET_GAME_STATE (PKUNK_MISSION, MissionState + 1); - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hPkunk - ); -} - -static void -thradd_mission (void) -{ - BYTE MissionState; - HSTARSHIP hThradd; - EXTENDED_SHIP_FRAGMENTPTR ThraddPtr; - - hThradd = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), THRADDASH_SHIP - ); - ThraddPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hThradd - ); - - MissionState = GET_GAME_STATE (THRADD_MISSION); - if (ThraddPtr->ShipInfo.actual_strength && MissionState < 3) - { - if (MissionState & 1) - { - SIZE strength_loss; - - AddEvent (RELATIVE_EVENT, 0, 14, 0, ADVANCE_THRADD_MISSION); - strength_loss = (SIZE)(ThraddPtr->ShipInfo.actual_strength >> 1); - - ThraddPtr->ShipInfo.energy_level = - (BYTE)(-strength_loss / 14); - ThraddPtr->ShipInfo.growth_fract = - (BYTE)(((strength_loss % 14) << 8) / 14); - ThraddPtr->ShipInfo.growth_err_term = 255 >> 1; - } - else - { - COORD x, y; - - if (MissionState == 0) - { - x = 4879; - y = 7201; - } - else - { - x = 2535; - y = 8358; - - ThraddPtr->ShipInfo.energy_level = 0; - ThraddPtr->ShipInfo.growth_fract = 0; - } - SetRaceDest (THRADDASH_SHIP, x, y, 14, ADVANCE_THRADD_MISSION); - } - } - SET_GAME_STATE (THRADD_MISSION, MissionState + 1); - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hThradd - ); -} - -static void -ilwrath_mission (void) -{ - HSTARSHIP hIlwrath, hThradd; - EXTENDED_SHIP_FRAGMENTPTR IlwrathPtr, ThraddPtr; - - hIlwrath = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), ILWRATH_SHIP - ); - IlwrathPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hIlwrath - ); - hThradd = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), THRADDASH_SHIP - ); - ThraddPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hThradd - ); - - if (IlwrathPtr->ShipInfo.loc.x == ((2500 + 2535) >> 1) - && IlwrathPtr->ShipInfo.loc.y == ((8070 + 8358) >> 1)) - { - IlwrathPtr->ShipInfo.actual_strength = - ThraddPtr->ShipInfo.actual_strength = 0; - IlwrathPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); - ThraddPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); - } - else if (IlwrathPtr->ShipInfo.actual_strength) - { - if (IlwrathPtr->ShipInfo.dest_loc.x != 2500 - || IlwrathPtr->ShipInfo.dest_loc.y != 8070) - SetRaceDest (ILWRATH_SHIP, 2500, 8070, 90, ADVANCE_ILWRATH_MISSION); - else - { -#define MADD_LENGTH 128 - SIZE strength_loss; - - SET_GAME_STATE (ILWRATH_FIGHT_THRADDASH, 1); - SET_GAME_STATE (HELIX_UNPROTECTED, 1); - strength_loss = (SIZE)IlwrathPtr->ShipInfo.actual_strength; - IlwrathPtr->ShipInfo.energy_level = - (BYTE)(-strength_loss / MADD_LENGTH); - IlwrathPtr->ShipInfo.growth_fract = - (BYTE)(((strength_loss % MADD_LENGTH) << 8) / MADD_LENGTH); - SetRaceDest (ILWRATH_SHIP, - (2500 + 2535) >> 1, - (8070 + 8358) >> 1, - MADD_LENGTH - 1, - ADVANCE_ILWRATH_MISSION); - - strength_loss = (SIZE)ThraddPtr->ShipInfo.actual_strength; - ThraddPtr->ShipInfo.energy_level = - (BYTE)(-strength_loss / MADD_LENGTH); - ThraddPtr->ShipInfo.growth_fract = - (BYTE)(((strength_loss % MADD_LENGTH) << 8) / MADD_LENGTH); - SetRaceDest (THRADDASH_SHIP, - (2500 + 2535) >> 1, - (8070 + 8358) >> 1, - MADD_LENGTH, (BYTE)~0); - SET_GAME_STATE (THRADD_VISITS, 0); - if (ThraddPtr->ShipInfo.ship_flags & GOOD_GUY) - ActivateStarShip (THRADDASH_SHIP, -1); - } - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hThradd - ); - UnlockStarShip ( - &GLOBAL (avail_race_q), - hIlwrath - ); -} - -static void -utwig_supox_mission (void) -{ - BYTE MissionState; - HSTARSHIP hUtwig, hSupox; - EXTENDED_SHIP_FRAGMENTPTR UtwigPtr, SupoxPtr; - - hUtwig = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), UTWIG_SHIP - ); - UtwigPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hUtwig - ); - hSupox = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), SUPOX_SHIP - ); - SupoxPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hSupox - ); - - MissionState = GET_GAME_STATE (UTWIG_SUPOX_MISSION); - if (UtwigPtr->ShipInfo.actual_strength && MissionState < 5) - { - if (MissionState == 1) - { - SIZE strength_loss; - - AddEvent (RELATIVE_EVENT, 0, (160 >> 1), 0, ADVANCE_UTWIG_SUPOX_MISSION); - - strength_loss = (SIZE)(UtwigPtr->ShipInfo.actual_strength >> 1); - UtwigPtr->ShipInfo.energy_level = - (BYTE)(-strength_loss / 160); - UtwigPtr->ShipInfo.growth_fract = - (BYTE)(((strength_loss % 160) << 8) / 160); - UtwigPtr->ShipInfo.growth_err_term = 255 >> 1; - - strength_loss = (SIZE)(SupoxPtr->ShipInfo.actual_strength >> 1); - if (strength_loss) - { - SupoxPtr->ShipInfo.energy_level = - (BYTE)(-strength_loss / 160); - SupoxPtr->ShipInfo.growth_fract = - (BYTE)(((strength_loss % 160) << 8) / 160); - SupoxPtr->ShipInfo.growth_err_term = 255 >> 1; - } - - SET_GAME_STATE (UTWIG_WAR_NEWS, 0); - SET_GAME_STATE (SUPOX_WAR_NEWS, 0); - } - else if (MissionState == 2) - { - AddEvent (RELATIVE_EVENT, 0, (160 >> 1), 0, ADVANCE_UTWIG_SUPOX_MISSION); - ++MissionState; - } - else - { - COORD ux, uy, sx, sy; - - if (MissionState == 0) - { - ux = 7208; - uy = 7000; - - sx = 6479; - sy = 7541; - } - else - { - ux = 8534; - uy = 8797; - - sx = 7468; - sy = 9246; - - UtwigPtr->ShipInfo.energy_level = 0; - UtwigPtr->ShipInfo.growth_fract = 0; - SupoxPtr->ShipInfo.energy_level = 0; - SupoxPtr->ShipInfo.growth_fract = 0; - - SET_GAME_STATE (UTWIG_WAR_NEWS, 0); - SET_GAME_STATE (SUPOX_WAR_NEWS, 0); - } - SET_GAME_STATE (UTWIG_VISITS, 0); - SET_GAME_STATE (UTWIG_INFO, 0); - SET_GAME_STATE (SUPOX_VISITS, 0); - SET_GAME_STATE (SUPOX_INFO, 0); - SetRaceDest (UTWIG_SHIP, ux, uy, 21, ADVANCE_UTWIG_SUPOX_MISSION); - SetRaceDest (SUPOX_SHIP, sx, sy, 21, (BYTE)~0); - } - } - SET_GAME_STATE (UTWIG_SUPOX_MISSION, MissionState + 1); - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hSupox - ); - UnlockStarShip ( - &GLOBAL (avail_race_q), - hUtwig - ); -} - -static void -mycon_mission (void) -{ - HSTARSHIP hMycon; - EXTENDED_SHIP_FRAGMENTPTR MyconPtr; - - hMycon = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), MYCON_SHIP - ); - MyconPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hMycon - ); - - if (MyconPtr->ShipInfo.actual_strength) - { - if (MyconPtr->ShipInfo.energy_level) - { - SET_GAME_STATE (MYCON_KNOW_AMBUSH, 1); - SetRaceDest (MYCON_SHIP, 6392, 2200, 30, (BYTE)~0); - - MyconPtr->ShipInfo.energy_level = 0; - MyconPtr->ShipInfo.growth_fract = 0; - } - else if (MyconPtr->ShipInfo.loc.x != 6858 - || MyconPtr->ShipInfo.loc.y != 577) - SetRaceDest (MYCON_SHIP, 6858, 577, 30, ADVANCE_MYCON_MISSION); - else - { - SIZE strength_loss; - - AddEvent (RELATIVE_EVENT, 0, 14, 0, ADVANCE_MYCON_MISSION); - strength_loss = (SIZE)(MyconPtr->ShipInfo.actual_strength >> 1); - MyconPtr->ShipInfo.energy_level = - (BYTE)(-strength_loss / 14); - MyconPtr->ShipInfo.growth_fract = - (BYTE)(((strength_loss % 14) << 8) / 14); - MyconPtr->ShipInfo.growth_err_term = 255 >> 1; - } - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hMycon - ); -} - -void -EventHandler (BYTE selector) -{ - switch (selector) - { - case ARILOU_ENTRANCE_EVENT: - arilou_entrance_event (); - break; - case ARILOU_EXIT_EVENT: - arilou_exit_event (); - break; - case HYPERSPACE_ENCOUNTER_EVENT: - check_race_growth (); - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE - && GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) - { - extern void check_hyperspace_encounter (void); - - check_hyperspace_encounter (); - } - - AddEvent (RELATIVE_EVENT, 0, 1, 0, HYPERSPACE_ENCOUNTER_EVENT); - break; - case KOHR_AH_VICTORIOUS_EVENT: - if (GET_GAME_STATE (UTWIG_SUPOX_MISSION)) - { - AddEvent (RELATIVE_EVENT, 0, 0, 1, KOHR_AH_GENOCIDE_EVENT); - break; - } - case KOHR_AH_GENOCIDE_EVENT: - if (!GET_GAME_STATE (KOHR_AH_FRENZY) - && LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY - && CurStarDescPtr - && CurStarDescPtr->Index == SAMATRA_DEFINED) - AddEvent (RELATIVE_EVENT, 0, 7, 0, KOHR_AH_GENOCIDE_EVENT); - else - black_urquan_genocide (); - break; - case ADVANCE_PKUNK_MISSION: - pkunk_mission (); - break; - case ADVANCE_THRADD_MISSION: - thradd_mission (); - break; - case ZOQFOT_DISTRESS_EVENT: - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY - && CurStarDescPtr - && CurStarDescPtr->Index == ZOQFOT_DEFINED) - AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DISTRESS_EVENT); - else - { - SET_GAME_STATE (ZOQFOT_DISTRESS, 1); - AddEvent (RELATIVE_EVENT, 6, 0, 0, ZOQFOT_DEATH_EVENT); - } - break; - case ZOQFOT_DEATH_EVENT: - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY - && CurStarDescPtr - && CurStarDescPtr->Index == ZOQFOT_DEFINED) - AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DEATH_EVENT); - else if (GET_GAME_STATE (ZOQFOT_DISTRESS)) - { - HSTARSHIP hZoqFot; - EXTENDED_SHIP_FRAGMENTPTR ZoqFotPtr; - - hZoqFot = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), ZOQFOTPIK_SHIP - ); - ZoqFotPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hZoqFot - ); - ZoqFotPtr->ShipInfo.actual_strength = 0; - ZoqFotPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); - UnlockStarShip ( - &GLOBAL (avail_race_q), - hZoqFot - ); - - SET_GAME_STATE (ZOQFOT_DISTRESS, 2); - } - break; - case SHOFIXTI_RETURN_EVENT: - ActivateStarShip (SHOFIXTI_SHIP, 0); - GLOBAL (CrewCost) -= 2; - /* crew is not an issue anymore */ - SET_GAME_STATE (CREW_PURCHASED0, 0); - SET_GAME_STATE (CREW_PURCHASED1, 0); - break; - case ADVANCE_UTWIG_SUPOX_MISSION: - utwig_supox_mission (); - break; - case SPATHI_SHIELD_EVENT: - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY - && CurStarDescPtr - && CurStarDescPtr->Index == SPATHI_DEFINED) - AddEvent (RELATIVE_EVENT, 0, 7, 0, SPATHI_SHIELD_EVENT); - else - { - HSTARSHIP hSpathi; - EXTENDED_SHIP_FRAGMENTPTR SpathiPtr; - - hSpathi = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), SPATHI_SHIP - ); - SpathiPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hSpathi - ); - - if (SpathiPtr->ShipInfo.actual_strength) - { - ActivateStarShip (SPATHI_SHIP, -1); - SET_GAME_STATE (SPATHI_SHIELDED_SELVES, 1); - SpathiPtr->ShipInfo.actual_strength = 0; - } - - UnlockStarShip ( - &GLOBAL (avail_race_q), - hSpathi - ); - } - break; - case ADVANCE_ILWRATH_MISSION: - ilwrath_mission (); - break; - case ADVANCE_MYCON_MISSION: - mycon_mission (); - break; - case ARILOU_UMGAH_CHECK: - SET_GAME_STATE (ARILOU_CHECKED_UMGAH, 2); - break; - case YEHAT_REBEL_EVENT: - { - HSTARSHIP hRebel, hRoyalist; - EXTENDED_SHIP_FRAGMENTPTR RebelPtr, RoyalistPtr; - - hRebel = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), YEHAT_REBEL_SHIP - ); - RebelPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hRebel - ); - hRoyalist = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), YEHAT_SHIP - ); - RoyalistPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), - hRoyalist - ); - RebelPtr->ShipInfo.actual_strength = - RoyalistPtr->ShipInfo.actual_strength = - RoyalistPtr->ShipInfo.actual_strength * 2 / 3; - RebelPtr->ShipInfo.loc.x = 5150; - RebelPtr->ShipInfo.loc.y = 0; - UnlockStarShip ( - &GLOBAL (avail_race_q), - hRoyalist - ); - UnlockStarShip ( - &GLOBAL (avail_race_q), - hRebel - ); - ActivateStarShip (YEHAT_REBEL_SHIP, SPHERE_TRACKING); - break; - } - case SLYLANDRO_RAMP_UP: - if (!GET_GAME_STATE (DESTRUCT_CODE_ON_SHIP)) - { - BYTE ramp_factor; - - ramp_factor = GET_GAME_STATE (SLYLANDRO_MULTIPLIER); - if (++ramp_factor <= 4) - { - SET_GAME_STATE (SLYLANDRO_MULTIPLIER, ramp_factor); - AddEvent (RELATIVE_EVENT, 0, 182, 0, SLYLANDRO_RAMP_UP); - } - } - break; - case SLYLANDRO_RAMP_DOWN: - { - BYTE ramp_factor; - - ramp_factor = GET_GAME_STATE (SLYLANDRO_MULTIPLIER); - if (--ramp_factor) - AddEvent (RELATIVE_EVENT, 0, 23, 0, SLYLANDRO_RAMP_DOWN); - SET_GAME_STATE (SLYLANDRO_MULTIPLIER, ramp_factor); - } - break; - } -} #define DEBUG_PSYTRON 0 /* TODO: Remove these declarations once threading is gone. */ extern int snddriver, soundflags; -int Starcon2Main(void* blah) +int Starcon2Main(void *threadArg) { #if DEBUG_PSYTRON || CREATE_JOURNAL { @@ -910,20 +129,11 @@ while (--ac > 0) InitSIS (); InitGameClock (); - AddEvent (RELATIVE_EVENT, 0, 1, 0, HYPERSPACE_ENCOUNTER_EVENT); - AddEvent (ABSOLUTE_EVENT, 3, 17, START_YEAR, ARILOU_ENTRANCE_EVENT); - AddEvent (RELATIVE_EVENT, 0, 0, YEARS_TO_KOHRAH_VICTORY, - KOHR_AH_VICTORIOUS_EVENT); - AddEvent (RELATIVE_EVENT, 0, 0, 0, SLYLANDRO_RAMP_UP); + AddInitialGameEvents(); do { extern ACTIVITY NextActivity; -#ifdef TESTING -COUNT sc; -extern COUNT _simple_count; -sc = _simple_count; -#endif //TESTING SuspendGameClock (); if (!((GLOBAL (CurrentActivity) | NextActivity) & CHECK_LOAD)) @@ -987,11 +197,6 @@ sc = _simple_count; if (ArilouTask) Task_SetState (ArilouTask, TASK_EXIT); } -#ifdef TESTING - if (_simple_count != sc) - fprintf (stderr, "%d difference!\n", - (int)_simple_count - (int)sc); -#endif //TESTING LockMutex (GraphicsLock); SetFlashRect (NULL_PTR, (FRAME)0); @@ -1025,6 +230,6 @@ sc = _simple_count; } FreeKernel (); - (void) blah; /* Satisfying compiler (unused parameter) */ - return(0); + (void) threadArg; /* Satisfying compiler (unused parameter) */ + return 0; } diff --git a/sc2/src/sc2code/starcon.h b/sc2/src/sc2code/starcon.h deleted file mode 100644 index 1c0e282d3..000000000 --- a/sc2/src/sc2code/starcon.h +++ /dev/null @@ -1,239 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _STARCON_H -#define _STARCON_H - -#define MAX_PLAYERS 4 -#define NUM_PLAYERS 2 -#define NUM_SIDES 2 - -extern int ScreenWidth; -extern int ScreenHeight; - -#define SCREEN_WIDTH ScreenWidth -#define SCREEN_HEIGHT ScreenHeight -#define SAFE_X 0 - /* Left and right screen margin to be left unused */ -#define SAFE_Y 0 - /* Top and bottom screen margin to be left unused */ -#define SIS_ORG_X (7 + SAFE_X) -#define SIS_ORG_Y (10 + SAFE_Y) -#define STATUS_WIDTH 64 - /* Width of the status "window" (the right part of the screen) */ -#define STATUS_HEIGHT (SCREEN_HEIGHT - (SAFE_Y * 2)) - /* Height of the status "window" (the right part of the screen) */ -#define SPACE_WIDTH (SCREEN_WIDTH - STATUS_WIDTH - (SAFE_X * 2)) - /* Width of the space "window" (the left part of the screen) */ -#define SPACE_HEIGHT (SCREEN_HEIGHT - (SAFE_Y * 2)) - /* Height of the space "window" (the left part of the screen) */ -#define SIS_SCREEN_WIDTH (SPACE_WIDTH - 14) - /* Width of the usable part of the space "window" */ -#define SIS_SCREEN_HEIGHT (SPACE_HEIGHT - 13) - /* Height of the usable part of the space "window" */ - -#include "config.h" -#include "../port.h" -#include "libs/file.h" -#include -#include "gfxlib.h" -#include "inplib.h" -#include "timelib.h" -#include "sndlib.h" -#include "strlib.h" -#include "mathlib.h" -#include "reslib.h" -#include "threadlib.h" -#include "restypes.h" -#include "resinst.h" -#include "displist.h" -#include "nameref.h" -#include "units.h" -#include "velocity.h" -#include "element.h" -#include "races.h" -#include "weapon.h" -#include "build.h" -#include "intel.h" -#include "sounds.h" -#include "starbase.h" -#include "sis.h" -#include "state.h" -#include "globdata.h" -#include "encount.h" - -#define HUMAN_CONTROL (BYTE)(1 << 0) -#define CYBORG_CONTROL (BYTE)(1 << 1) -#define PSYTRON_CONTROL (BYTE)(1 << 2) -#define COMPUTER_CONTROL (CYBORG_CONTROL | PSYTRON_CONTROL) - -#define STANDARD_RATING (BYTE)(1 << 3) -#define GOOD_RATING (BYTE)(1 << 4) -#define AWESOME_RATING (BYTE)(1 << 5) - -#define SELECT_RATE 20 -#define INVALID_INPUT ((INPUT_STATE)0xFF) -#define INPUT_TIMED_OUT ((INPUT_STATE)0) - -#define BLACK_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) -#define LTGRAY_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x07) -#define DKGRAY_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) -#define WHITE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) - -#define NORMAL_ILLUMINATED_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) -#define NORMAL_SHADOWED_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) -#define HIGHLIGHT_ILLUMINATED_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) -#define HIGHLIGHT_SHADOWED_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) -#define MENU_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x07) -#define MENU_FOREGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) -#define MENU_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) -#define MENU_HIGHLIGHT_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) - -#define STATUS_ILLUMINATED_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) -#define STATUS_SHADOWED_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) -#define STATUS_SHAPE_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) -#define STATUS_SHAPE_OUTLINE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) - -#define CONTROL_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) - -#define ALLIANCE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) -#define HIERARCHY_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) -#define ALLIANCE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) -#define HIERARCHY_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) -#define ALLIANCE_BOX_HIGHLIGHT_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) -#define HIERARCHY_BOX_HIGHLIGHT_COLOR HIERARCHY_BACKGROUND_COLOR - -#define MESSAGE_BACKGROUND_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) -#define MESSAGE_TEXT_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) - -enum -{ - FadeAllToWhite = 250, - FadeSomeToWhite, - FadeAllToBlack, - FadeAllToColor, - FadeSomeToBlack, - FadeSomeToColor -}; - -#define SetPlayerIconColor(wp, z) \ - if ((wp) == 0) \ - SetContextForeGroundColor ((COLOR)((z) >= 0 ? \ - BUILD_COLOR (MAKE_RGB15 (0xA, 0x1F, 0x1F), 0x0B) : \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03))); \ - else \ - SetContextForeGroundColor ((COLOR)((z) >= 0 ? \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0xA, 0xA), 0x0C) : \ - BUILD_COLOR (MAKE_RGB15 (0x14, 0xA, 0x00), 0x06))) - -#define CONTROL_STRING_INDEX 0 -#define USING_STRING_INDEX 1 -#define RATING_STRING_INDEX 2 -#define OK_STRING_INDEX 3 -#define LABEL_STRING_COUNT (OK_STRING_INDEX + 1) - -#define MENU_REPEAT_DELAY (ONE_SECOND >> 1) - -extern ACTIVITY LastActivity; -extern BYTE PlayerControl[NUM_PLAYERS]; -extern SIZE cur_player, cur_race; -extern QUEUE disp_q; -extern SIZE battle_counter; -extern FRAME stars_in_space; -extern MEM_HANDLE hResIndex; -extern CONTEXT ScreenContext, StatusContext, - SpaceContext, OffScreenContext, - RadarContext, TaskContext; -extern FRAME BackFrame; -extern SIZE screen_width, screen_height; -extern FRAME Screen, RadarFrame; -extern FONT StarConFont, MicroFont, TinyFont; -extern BOOLEAN PagingEnabled; -extern FRAME ActivityFrame; -extern SOUND MenuSounds, GameSounds; -extern QUEUE race_q[NUM_PLAYERS]; -extern Mutex GraphicsLock; -extern CondVar RenderingCond; -extern STRING GameStrings; - -extern void Introduction (void); -int initIO (void); -void uninitIO (void); - -/* Constants for DoInput */ -typedef UWORD MENU_SOUND_FLAGS; -#define MENU_SOUND_UP ((MENU_SOUND_FLAGS)(1 << 0)) -#define MENU_SOUND_DOWN ((MENU_SOUND_FLAGS)(1 << 1)) -#define MENU_SOUND_LEFT ((MENU_SOUND_FLAGS)(1 << 2)) -#define MENU_SOUND_RIGHT ((MENU_SOUND_FLAGS)(1 << 3)) -#define MENU_SOUND_SELECT ((MENU_SOUND_FLAGS)(1 << 4)) -#define MENU_SOUND_CANCEL ((MENU_SOUND_FLAGS)(1 << 5)) -#define MENU_SOUND_SPECIAL ((MENU_SOUND_FLAGS)(1 << 6)) -#define MENU_SOUND_PAGEUP ((MENU_SOUND_FLAGS)(1 << 7)) -#define MENU_SOUND_PAGEDOWN ((MENU_SOUND_FLAGS)(1 << 8)) -#define MENU_SOUND_DELETE ((MENU_SOUND_FLAGS)(1 << 9)) -#define MENU_SOUND_ARROWS (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_LEFT | MENU_SOUND_RIGHT) -#define MENU_SOUND_NONE ((MENU_SOUND_FLAGS)0) - -extern void SetFlashRect (PRECT pRect, FRAME f); - -extern void DrawStarConBox (PRECT pRect, SIZE BorderWidth, COLOR - TopLeftColor, COLOR BottomRightColor, BOOLEAN FillInterior, COLOR - InteriorColor); -extern BOOLEAN ConfirmExit (void); -extern DWORD SeedRandomNumbers (void); -extern void DoInput (PVOID pInputState, BOOLEAN resetInput); -void SetMenuSounds (MENU_SOUND_FLAGS sound_0, MENU_SOUND_FLAGS sound_1); -void GetMenuSounds (MENU_SOUND_FLAGS *sound_0, MENU_SOUND_FLAGS *sound_1); -extern BOOLEAN Battle (void); -extern void EncounterBattle (void); -extern void SetPlayerInput (void); -extern BOOLEAN InitContexts (void); -extern void UninitContexts (void); -extern COUNT WrapText (UNICODE *pStr, COUNT len, TEXT *tarray, SIZE - field_width); - -extern void ToggleMusic (void); -extern void PlayMusic (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE - Priority); -extern void StopMusic (void); -extern void ResumeMusic (void); -extern void PauseMusic (void); -extern void ToggleSoundEffect (void); -extern void PlaySoundEffect (SOUND S, COUNT Channel, SoundPosition Pos, - void *PositionalObject, BYTE Priority); - -/* dummy.c */ -extern void SetSoundTracking (BOOLEAN toggle); -extern void GetSoundTrackingBuf (PSBYTE pdigi_buf); - -extern MEM_HANDLE LoadVidInstance (DWORD res); - -extern DRAWABLE CreatePixmapRegion (FRAME Frame, PPOINT pOrg, SIZE width, - SIZE height); - -extern void SetPrimNextLink (PPRIMITIVE pPrim, COUNT Link); -extern COUNT GetPrimNextLink (PPRIMITIVE pPrim); -extern volatile BOOLEAN GamePaused, ExitRequested; - -//Added by Chris - -void AlienTalkSegue (COUNT wait_track); - -#endif /* _STARCON_H */ - diff --git a/sc2/src/sc2code/starmap.c b/sc2/src/sc2code/starmap.c index b95c8ef15..915250bde 100644 --- a/sc2/src/sc2code/starmap.c +++ b/sc2/src/sc2code/starmap.c @@ -16,7 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "encount.h" +#include "gamestr.h" +#include "globdata.h" +#include "libs/compiler.h" +#include "libs/gfxlib.h" + STAR_DESCPTR star_array; STAR_DESCPTR CurStarDescPtr = 0; diff --git a/sc2/src/sc2code/state.c b/sc2/src/sc2code/state.c index 595dfebd7..0e393f3ad 100644 --- a/sc2/src/sc2code/state.c +++ b/sc2/src/sc2code/state.c @@ -16,11 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "state.h" + +#include "encount.h" +#include "file.h" #ifdef HAVE_UNISTD_H #include #endif -#include "file.h" void InitPlanetInfo (void) diff --git a/sc2/src/sc2code/state.h b/sc2/src/sc2code/state.h index 9d8c0ae6b..311c3c806 100644 --- a/sc2/src/sc2code/state.h +++ b/sc2/src/sc2code/state.h @@ -19,6 +19,8 @@ #ifndef _STATE_H #define _STATE_H +#include "libs/compiler.h" + extern void InitPlanetInfo (void); extern void UninitPlanetInfo (void); extern void GetPlanetInfo (void); @@ -37,7 +39,7 @@ typedef UNICODE GAME_DESC[MAX_DESC_CHARS + 1]; #define STARINFO_FILE "starinfo.dat" #define STAR_BUFSIZE (NUM_SOLAR_SYSTEMS * sizeof (DWORD) \ - + 3800 * (3 * sizeof (DWORD))) + + 3800 * (3 * sizeof (DWORD))) #define RANDGRPINFO_FILE "randgrp.dat" #define RAND_BUFSIZE (4 * 1024) #define DEFGRPINFO_FILE "defgrp.dat" diff --git a/sc2/src/sc2code/status.c b/sc2/src/sc2code/status.c index d88660c64..e818cacfe 100644 --- a/sc2/src/sc2code/status.c +++ b/sc2/src/sc2code/status.c @@ -16,10 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "build.h" +#include "colors.h" +#include "globdata.h" +#include "races.h" +#include "setup.h" +#include "options.h" + #include #include -#include "starcon.h" -#include "options.h" static void CaptainsWindow (CAPTAIN_STUFFPTR CSPtr, COORD y, ELEMENT_FLAGS diff --git a/sc2/src/sc2code/strtemp.h b/sc2/src/sc2code/strtemp.h new file mode 100644 index 000000000..c0806440b --- /dev/null +++ b/sc2/src/sc2code/strtemp.h @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* + * This file stores some temporary definitions relating to strings. + * Some history of these definitions: + * At some point when Chris Nelson was working at Toys for Bob on the + * code which would later be released as UQM, a lot of "char *" strings + * were changed to "UNICODE", and string operations like strcpy() were + * replaced by their wide-char variants. But this code wasn't ready yet, + * so UNICODE was defined back to "char *", and the wide string operations + * were defined to the regular ones. + * I've created this file as I've got no better place to put these + * definitions now. I expect that somewhere in the future I'll change + * everything back to "char *" and use UTF-8 internally. - SvdB + */ + +#ifndef _STRTEMP_H +#define _STRTEMP_H + +#define wsprintf sprintf +#define wstrlen strlen +#define wstrcpy strcpy +#define wstrcat strcat +#define wstrupr strupr +#define wstrncpy strncpy +#define wstricmp stricmp +#define wstrtoul strtoul +#define wstrcspn strcspn + +#endif /* _STRTEMP_H */ + + diff --git a/sc2/src/sc2code/tactrans.c b/sc2/src/sc2code/tactrans.c index e9d166058..f477ca9e5 100644 --- a/sc2/src/sc2code/tactrans.c +++ b/sc2/src/sc2code/tactrans.c @@ -16,8 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "build.h" #include "collide.h" +#include "globdata.h" +#include "init.h" +#include "races.h" +#include "settings.h" +#include "sounds.h" +#include "libs/mathlib.h" + BOOLEAN OpponentAlive (STARSHIPPTR TestStarShipPtr) @@ -34,15 +41,12 @@ OpponentAlive (STARSHIPPTR TestStarShipPtr) GetElementStarShip (ElementPtr, &StarShipPtr); UnlockElement (hElement); - if (StarShipPtr - && StarShipPtr != TestStarShipPtr + if (StarShipPtr && StarShipPtr != TestStarShipPtr && StarShipPtr->RaceDescPtr->ship_info.crew_level == 0) - { - return (FALSE); - } + return FALSE; } - return (TRUE); + return TRUE; } void @@ -75,8 +79,7 @@ new_ship (PELEMENT DeadShipPtr) MusicStarted = FALSE; DeadShipPtr->turn_wait = (BYTE)( - DeadShipPtr->state_flags & (GOOD_GUY | BAD_GUY) - ); + DeadShipPtr->state_flags & (GOOD_GUY | BAD_GUY)); for (hElement = GetHeadElement (); hElement; hElement = hSuccElement) { ELEMENTPTR ElementPtr; @@ -288,8 +291,9 @@ ship_death (PELEMENT ShipPtr) { PlaySound (SetAbsSoundIndex ( - StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1 - ), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); + StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), + CalcSoundPosition (ShipPtr), ShipPtr, + GAME_SOUND_PRIORITY + 1); DeltaCrew ((ELEMENTPTR)ShipPtr, -(SIZE)ShipPtr->crew_level); if (VictoriousStarShipPtr == 0) @@ -333,10 +337,10 @@ spawn_ion_trail (PELEMENT ElementPtr) IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; IonElementPtr->life_span = IonElementPtr->thrust_wait = ION_LIFE; SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM); - SetPrimColor ( - &DisplayArray[IonElementPtr->PrimIndex], START_ION_COLOR - ); - IonElementPtr->current.image.frame = DecFrameIndex (stars_in_space); + SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex], + START_ION_COLOR); + IonElementPtr->current.image.frame = + DecFrameIndex (stars_in_space); IonElementPtr->current.image.farray = &stars_in_space; IonElementPtr->current.location = ElementPtr->current.location; IonElementPtr->current.location.x += @@ -384,17 +388,16 @@ spawn_ion_trail (PELEMENT ElementPtr) if (Color != 0x2F) { ElementPtr->life_span = ElementPtr->thrust_wait; - + ++Color; if (Color > 0x7F) Color = 0x2A; if (Color <= 0x2f && Color >= 0x2a) - color_index = (COUNT)Color - 0x2a; + color_index = (COUNT)Color - 0x2a; else /* color is between 0x7a and 0x7f */ - color_index = (COUNT)(Color - 0x7a) + (NUM_TAB_COLORS >> 1); - SetPrimColor ( - &DisplayArray[ElementPtr->PrimIndex], color_tab[color_index] - ); + color_index = (COUNT)(Color - 0x7a) + (NUM_TAB_COLORS >> 1); + SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], + color_tab[color_index]); ElementPtr->state_flags &= ~DISAPPEARING; ElementPtr->state_flags |= CHANGING; diff --git a/sc2/src/sc2code/trans.c b/sc2/src/sc2code/trans.c index e9117d368..a6eb6d542 100644 --- a/sc2/src/sc2code/trans.c +++ b/sc2/src/sc2code/trans.c @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "units.h" +#include "libs/compiler.h" + SIZE sinetab[] = { diff --git a/sc2/src/sc2code/units.h b/sc2/src/sc2code/units.h index 8a296013b..65b0e0657 100644 --- a/sc2/src/sc2code/units.h +++ b/sc2/src/sc2code/units.h @@ -19,6 +19,33 @@ #ifndef _UNITS_H #define _UNITS_H +#include "libs/gfxlib.h" + +extern int ScreenWidth; +extern int ScreenHeight; + +#define SCREEN_WIDTH ScreenWidth +#define SCREEN_HEIGHT ScreenHeight +#define SAFE_X 0 + /* Left and right screen margin to be left unused */ +#define SAFE_Y 0 + /* Top and bottom screen margin to be left unused */ +#define SIS_ORG_X (7 + SAFE_X) +#define SIS_ORG_Y (10 + SAFE_Y) +#define STATUS_WIDTH 64 + /* Width of the status "window" (the right part of the screen) */ +#define STATUS_HEIGHT (SCREEN_HEIGHT - (SAFE_Y * 2)) + /* Height of the status "window" (the right part of the screen) */ +#define SPACE_WIDTH (SCREEN_WIDTH - STATUS_WIDTH - (SAFE_X * 2)) + /* Width of the space "window" (the left part of the screen) */ +#define SPACE_HEIGHT (SCREEN_HEIGHT - (SAFE_Y * 2)) + /* Height of the space "window" (the left part of the screen) */ +#define SIS_SCREEN_WIDTH (SPACE_WIDTH - 14) + /* Width of the usable part of the space "window" */ +#define SIS_SCREEN_HEIGHT (SPACE_HEIGHT - 13) + /* Height of the usable part of the space "window" */ + + #define MAX_REDUCTION 3 #define MAX_VIS_REDUCTION 2 #define REDUCTION_SHIFT 1 diff --git a/sc2/src/sc2code/uqmdebug.c b/sc2/src/sc2code/uqmdebug.c index 65361d5da..c2286d2bb 100644 --- a/sc2/src/sc2code/uqmdebug.c +++ b/sc2/src/sc2code/uqmdebug.c @@ -19,11 +19,19 @@ * but MSVC will compile and link it. */ -#include - -#include "starcon.h" #include "uqmdebug.h" +#include "colors.h" +#include "clock.h" +#include "encount.h" +#include "gamestr.h" +#include "gameev.h" +#include "globdata.h" +#include "races.h" +#include "setup.h" + +#include + static void dumpEventCallback (EVENTPTR eventPtr, void *arg); static void dumpStarCallback(STAR_DESC *star, void *arg); static void dumpPlanetCallback (PLANET_DESC *planet, void *arg); diff --git a/sc2/src/sc2code/uqmdebug.h b/sc2/src/sc2code/uqmdebug.h index 8ca2b8180..b62559383 100644 --- a/sc2/src/sc2code/uqmdebug.h +++ b/sc2/src/sc2code/uqmdebug.h @@ -17,6 +17,13 @@ #if !defined(_DEBUG_H) && defined(DEBUG) #define _DEBUG_H +#include "clock.h" +#include "planets/planets.h" +#include "libs/compiler.h" + +#include + + // Called when the debug key (symbol 'Debug' in the keys.cfg) is pressed. extern void debugKeyPressed (void); diff --git a/sc2/src/sc2code/util.c b/sc2/src/sc2code/util.c index 40f580902..6f2d7d1be 100644 --- a/sc2/src/sc2code/util.c +++ b/sc2/src/sc2code/util.c @@ -16,11 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" #include "commglue.h" #include "comm.h" -#include "libs/sound/trackplayer.h" #include "controls.h" +#include "setup.h" +#include "libs/inplib.h" +#include "libs/sound/trackplayer.h" +#include "libs/mathlib.h" + void DrawStarConBox (PRECT pRect, SIZE BorderWidth, COLOR TopLeftColor, COLOR @@ -232,3 +235,4 @@ WaitAnyButtonOrQuit (BOOLEAN CheckSpecial) return (GLOBAL (CurrentActivity) & CHECK_ABORT) != 0; } + diff --git a/sc2/src/sc2code/util.h b/sc2/src/sc2code/util.h new file mode 100644 index 000000000..03f5d1c6d --- /dev/null +++ b/sc2/src/sc2code/util.h @@ -0,0 +1,30 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _UTIL_H +#define _UTIL_H + +#include "libs/compiler.h" +#include "libs/gfxlib.h" + +extern void DrawStarConBox (PRECT pRect, SIZE BorderWidth, + COLOR TopLeftColor, COLOR BottomRightColor, BOOLEAN FillInterior, + COLOR InteriorColor); +extern DWORD SeedRandomNumbers (void); + + +#endif /* _UTIL_H */ + diff --git a/sc2/src/sc2code/velocity.c b/sc2/src/sc2code/velocity.c index d311e9da9..e47944a44 100644 --- a/sc2/src/sc2code/velocity.c +++ b/sc2/src/sc2code/velocity.c @@ -16,7 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "starcon.h" +#include "velocity.h" + +#include "units.h" +#include "libs/compiler.h" + #define VELOCITY_REMAINDER(v) ((v) & (VELOCITY_SCALE - 1)) diff --git a/sc2/src/sc2code/weapon.c b/sc2/src/sc2code/weapon.c index cad159d42..1153d0289 100644 --- a/sc2/src/sc2code/weapon.c +++ b/sc2/src/sc2code/weapon.c @@ -16,8 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "weapon.h" + +#include "build.h" +#include "colors.h" +#include "globdata.h" +#include "init.h" +#include "races.h" +#include "setup.h" +#include "sounds.h" +#include "units.h" +#include "libs/mathlib.h" + #include -#include "starcon.h" + HELEMENT initialize_laser (PLASER_BLOCK pLaserBlock) diff --git a/sc2/src/sc2code/weapon.h b/sc2/src/sc2code/weapon.h index fc5fb3072..fae446523 100644 --- a/sc2/src/sc2code/weapon.h +++ b/sc2/src/sc2code/weapon.h @@ -19,6 +19,9 @@ #ifndef _WEAPON_H #define _WEAPON_H +#include "element.h" +#include "libs/gfxlib.h" + typedef struct { COORD cx, cy, ex, ey; diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index bc94bb01e..c9c0872d3 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -38,6 +38,8 @@ #include "options.h" #include "uqmversion.h" #include "comm.h" +#include "setup.h" + #if defined(GFXMODULE_SDL) # include @@ -208,8 +210,6 @@ main (int argc, char *argv[]) GraphicsLock = CreateMutex ("Graphics", SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); - RenderingCond = CreateCondVar ("DCQ empty", - SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); TFB_InitGraphics (options.gfxDriver, options.gfxFlags, options.width, options.height, options.bpp);