From: <av...@us...> - 2009-11-20 18:37:39
|
Revision: 3331 http://sc2.svn.sourceforge.net/sc2/?rev=3331&view=rev Author: avolkov Date: 2009-11-20 18:37:32 +0000 (Fri, 20 Nov 2009) Log Message: ----------- Removal of redraw hacks obsoleted by revisions 390 (introduction of SOLARSYS_STATE.PauseRotate), 469 (save of screen state) and 1321 (abolishment of IPtask_func); dead PlayMusic() hacks also removed; also fixes bug #868 Modified Paths: -------------- trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/planets/plangen.c Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-11-20 17:14:20 UTC (rev 3330) +++ trunk/sc2/src/uqm/gameopt.c 2009-11-20 18:37:32 UTC (rev 3331) @@ -875,17 +875,6 @@ { // Selected LOAD from main menu, and now canceled GLOBAL (CurrentActivity) |= CHECK_ABORT; } - else if (pSolarSysState) - { -#define DRAW_REFRESH (1 << 5) -#define REPAIR_SCAN (1 << 6) - extern BYTE draw_sys_flags; - - if (pSolarSysState->MenuState.Initialized < 3) - draw_sys_flags |= DRAW_REFRESH; - else if (pSolarSysState->MenuState.Initialized == 4) - draw_sys_flags |= REPAIR_SCAN; - } return (FALSE); } else if (PulsedInputState.menu[KEY_MENU_SELECT]) @@ -922,17 +911,6 @@ goto Restart; } ResumeMusic (); - if (pSolarSysState) - { -#define DRAW_REFRESH (1 << 5) -#define REPAIR_SCAN (1 << 6) - extern BYTE draw_sys_flags; - - if (pSolarSysState->MenuState.Initialized < 3) - draw_sys_flags |= DRAW_REFRESH; - else if (pSolarSysState->MenuState.Initialized == 4) - draw_sys_flags |= REPAIR_SCAN; - } } else { @@ -1120,7 +1098,6 @@ if (pSolarSysState) { - ++pSolarSysState->MenuState.Initialized; pSolarSysState->PauseRotate = 1; TaskSwitch (); } @@ -1132,6 +1109,7 @@ DlgStamp.origin.x = 0; DlgStamp.origin.y = 0; + // Save the current state of the screen for later restoration DlgRect.corner.x = SIS_ORG_X; DlgRect.corner.y = SIS_ORG_Y; DlgRect.extent.width = SIS_SCREEN_WIDTH; @@ -1164,46 +1142,15 @@ } if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) - { // Restore previous screen if necessary - // TODO: Need a better test for in-encounter - if (CommData.ConversationPhrasesRes - || !(pSolarSysState - && pSolarSysState->MenuState.Initialized < 3)) - { - SetTransitionSource (&DlgRect); - BatchGraphics (); - DrawStamp(&DlgStamp); - ScreenTransition (3, &DlgRect); - UnbatchGraphics (); - } + { // Restore previous screen + SetTransitionSource (&DlgRect); + BatchGraphics (); + DrawStamp (&DlgStamp); + ScreenTransition (3, &DlgRect); + UnbatchGraphics (); if (pSolarSysState) - { - /* We're in interplanetary, so we let the IP - * functions know we're ready to draw stuff - * again and then update the frame twice; once - * for the screen transition, and once to draw - * the ships afterwards. */ - --pSolarSysState->MenuState.Initialized; pSolarSysState->PauseRotate = 0; - IP_frame (); - IP_frame (); - - - // TODO: Need a better test for in-encounter - if (!CommData.ConversationPhrasesRes - && !PLRPlaying ((MUSIC_REF)~0)) - { - if (pSolarSysState->MenuState.Initialized < 3) - { - PlayMusic (SpaceMusic, TRUE, 1); - } - else - { - PlayMusic (LanderMusic, TRUE, 1); - } - } - } } DestroyDrawable (ReleaseDrawable (DlgStamp.frame)); Modified: trunk/sc2/src/uqm/planets/plangen.c =================================================================== --- trunk/sc2/src/uqm/planets/plangen.c 2009-11-20 17:14:20 UTC (rev 3330) +++ trunk/sc2/src/uqm/planets/plangen.c 2009-11-20 18:37:32 UTC (rev 3331) @@ -2088,7 +2088,6 @@ // to acquire the graphics lock LockMutex (GraphicsLock); if (*(volatile UBYTE *)&pSS->PauseRotate != 1 -// if (((SOLARSYS_STATE *volatile)pSS)->MenuState.Initialized <= 3 && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { //PauseRotate == 2 is a single-step This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-21 01:15:30
|
Revision: 3333 http://sc2.svn.sourceforge.net/sc2/?rev=3333&view=rev Author: avolkov Date: 2009-11-21 01:15:21 +0000 (Sat, 21 Nov 2009) Log Message: ----------- Header and name cleanup: moved stuff around to relevant headers; removed some irrelevant #includes; better names Modified Paths: -------------- trunk/sc2/src/uqm/build.c trunk/sc2/src/uqm/clock.c trunk/sc2/src/uqm/cnctdlg.c trunk/sc2/src/uqm/comm/chmmr/chmmrc.c trunk/sc2/src/uqm/comm/comandr/comandr.c trunk/sc2/src/uqm/comm/druuge/druugec.c trunk/sc2/src/uqm/comm/melnorm/melnorm.c trunk/sc2/src/uqm/comm/starbas/starbas.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/comm.h trunk/sc2/src/uqm/cons_res.c trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/globdata.c trunk/sc2/src/uqm/globdata.h trunk/sc2/src/uqm/grpinfo.c trunk/sc2/src/uqm/grpinfo.h trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/hyper.h trunk/sc2/src/uqm/init.c trunk/sc2/src/uqm/intro.c trunk/sc2/src/uqm/load.h trunk/sc2/src/uqm/melee.c trunk/sc2/src/uqm/menu.c trunk/sc2/src/uqm/menustat.h trunk/sc2/src/uqm/oscill.c trunk/sc2/src/uqm/outfit.c trunk/sc2/src/uqm/pickship.c trunk/sc2/src/uqm/planets/cargo.c trunk/sc2/src/uqm/planets/devices.c trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/lander.h trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/pstarmap.c trunk/sc2/src/uqm/planets/roster.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/scan.h trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/process.c trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/restart.c trunk/sc2/src/uqm/save.h trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c trunk/sc2/src/uqm/shipyard.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/sis.h trunk/sc2/src/uqm/starbase.c trunk/sc2/src/uqm/starbase.h trunk/sc2/src/uqm/starcon.c trunk/sc2/src/uqm/units.h trunk/sc2/src/uqm/uqmdebug.c trunk/sc2/src/uqm/util.c Modified: trunk/sc2/src/uqm/build.c =================================================================== --- trunk/sc2/src/uqm/build.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/build.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -20,6 +20,7 @@ #include "races.h" #include "master.h" +#include "sis.h" #include "setup.h" #include "libs/compiler.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/clock.c =================================================================== --- trunk/sc2/src/uqm/clock.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/clock.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,6 +19,8 @@ #include <stdlib.h> #include "gameev.h" #include "globdata.h" +#include "sis.h" + // for DrawStatusMessage() #include "setup.h" #include "libs/compiler.h" #include "libs/gfxlib.h" Modified: trunk/sc2/src/uqm/cnctdlg.c =================================================================== --- trunk/sc2/src/uqm/cnctdlg.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/cnctdlg.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -23,6 +23,7 @@ #include "colors.h" #include "gamestr.h" #include "setup.h" +#include "units.h" #include "resinst.h" #include "nameref.h" #include "libs/graphics/widgets.h" Modified: trunk/sc2/src/uqm/comm/chmmr/chmmrc.c =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -21,6 +21,8 @@ #include "strings.h" #include "uqm/build.h" +#include "uqm/hyper.h" + // for SOL_X/SOL_Y static LOCDATA chmmr_desc = Modified: trunk/sc2/src/uqm/comm/comandr/comandr.c =================================================================== --- trunk/sc2/src/uqm/comm/comandr/comandr.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm/comandr/comandr.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -21,6 +21,8 @@ #include "strings.h" #include "uqm/setup.h" +#include "uqm/sis.h" + // for DeltaSISGauges(), DrawLanders() #include "libs/graphics/gfx_common.h" static LOCDATA commander_desc = Modified: trunk/sc2/src/uqm/comm/druuge/druugec.c =================================================================== --- trunk/sc2/src/uqm/comm/druuge/druugec.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm/druuge/druugec.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,6 +22,8 @@ #include "uqm/build.h" #include "uqm/setup.h" +#include "uqm/sis.h" + // for DeltaSISGauges() static LOCDATA druuge_desc = Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -26,8 +26,11 @@ #include "libs/inplib.h" #include "libs/mathlib.h" -// XXX: temporary, for SOL_X/SOL_Y -#include "uqm/races.h" +#include "uqm/hyper.h" + // for SOL_X/SOL_Y +#include "uqm/planets/planets.h" + // for xxx_DISASTER +#include "uqm/sis.h" #define NUM_HISTORY_ITEMS 9 Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -23,6 +23,8 @@ #include "uqm/build.h" #include "uqm/setup.h" #include "uqm/shipcont.h" +#include "uqm/sis.h" + // for DeltaSISGauges() #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" #include "libs/inplib.h" Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -24,6 +24,8 @@ #include "commglue.h" #include "controls.h" #include "colors.h" +#include "sis.h" +#include "units.h" #include "encount.h" #include "endian_uqm.h" #include "gamestr.h" Modified: trunk/sc2/src/uqm/comm.h =================================================================== --- trunk/sc2/src/uqm/comm.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/comm.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -18,6 +18,7 @@ #define _COMM_H #include "globdata.h" +#include "units.h" #include "libs/compiler.h" #include "libs/gfxlib.h" #include "commglue.h" Modified: trunk/sc2/src/uqm/cons_res.c =================================================================== --- trunk/sc2/src/uqm/cons_res.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/cons_res.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,6 +22,10 @@ #include "resinst.h" #include "nameref.h" #include "setup.h" +#include "units.h" + // for NUM_VIEWS +#include "planets/planets.h" + // for NUMBER_OF_PLANET_TYPES, PLANET_SHIELDED static const char *planet_types[] = { "oolite", "yttric", "quasidegenerate", "lanthanide", "treasure", Modified: trunk/sc2/src/uqm/encount.c =================================================================== --- trunk/sc2/src/uqm/encount.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/encount.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -24,9 +24,12 @@ #include "colors.h" #include "cons_res.h" #include "controls.h" +#include "menustat.h" #include "gameopt.h" #include "gamestr.h" #include "globdata.h" +#include "sis.h" + // for DrawStatusMessage(), SetStatusMessageMode() #include "init.h" #include "pickship.h" #include "intel.h" Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/gameopt.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -20,21 +20,19 @@ #include "build.h" #include "colors.h" -#include "commglue.h" - // for CommData #include "controls.h" // XXX: for FindStart(), GetClusterName() #include "encount.h" -#include "planets/lander.h" +#include "menustat.h" +#include "sis.h" +#include "units.h" #include "gamestr.h" #include "load.h" #include "options.h" #include "save.h" -#include "starbase.h" #include "settings.h" #include "setup.h" #include "sounds.h" -#include "state.h" #include "util.h" #include "libs/graphics/gfx_common.h" Modified: trunk/sc2/src/uqm/globdata.c =================================================================== --- trunk/sc2/src/uqm/globdata.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/globdata.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,6 +22,8 @@ #include "encount.h" #include "master.h" #include "setup.h" +#include "units.h" +#include "hyper.h" #include "resinst.h" #include "nameref.h" #include "build.h" @@ -42,7 +44,7 @@ GLOBDATA GlobData; -BOOLEAN initedSIS = 0; +static BOOLEAN initedGameStructs = FALSE; BYTE @@ -184,7 +186,7 @@ } BOOLEAN -InitSIS (void) +InitGameStructures (void) { COUNT i; @@ -351,8 +353,8 @@ * than once, as you can't remove the atexit function (when the full game * ends). */ - initedSIS = TRUE; - atexit (UninitSIS); + initedGameStructs = TRUE; + atexit (UninitGameStructures); return (TRUE); } @@ -371,11 +373,11 @@ } void -UninitSIS (void) +UninitGameStructures (void) { HFLEETINFO hStarShip; - if (!initedSIS) + if (!initedGameStructs) return; UninitQueue (&GLOBAL (encounter_q)); @@ -405,7 +407,7 @@ DestroyDrawable (ReleaseDrawable (PlayFrame)); PlayFrame = 0; - initedSIS = FALSE; + initedGameStructs = FALSE; } void Modified: trunk/sc2/src/uqm/globdata.h =================================================================== --- trunk/sc2/src/uqm/globdata.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/globdata.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,6 +22,7 @@ #include "clock.h" #include "libs/gfxlib.h" #include "libs/reslib.h" +#include "libs/sndlib.h" #include "sis.h" #include "velocity.h" #include "commanim.h" @@ -961,6 +962,7 @@ #define GLOBAL_SIS(f) GlobData.SIS_state.f #define MAX_ENCOUNTERS 16 +#define MAX_BATTLE_GROUPS 32 //#define STATE_DEBUG @@ -1002,8 +1004,10 @@ extern void FreeSC2Data (void); extern BOOLEAN LoadSC2Data (void); -void InitGlobData (void); +extern void InitGlobData (void); +extern BOOLEAN InitGameStructures (void); +extern void UninitGameStructures (void); #endif /* _GLOBDATA_H */ Modified: trunk/sc2/src/uqm/grpinfo.c =================================================================== --- trunk/sc2/src/uqm/grpinfo.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/grpinfo.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,7 +22,6 @@ #include "libs/file.h" #include "globdata.h" #include "intel.h" -#include "sis.h" #include "state.h" #include "grpinfo.h" Modified: trunk/sc2/src/uqm/grpinfo.h =================================================================== --- trunk/sc2/src/uqm/grpinfo.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/grpinfo.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -24,6 +24,9 @@ // for POINT #include <assert.h> +// XXX: Needed to maintain savegame compatibility +#define NUM_SAVED_BATTLE_GROUPS 64 + typedef HLINK HIPGROUP; typedef struct Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/hyper.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,10 +22,14 @@ #include "collide.h" #include "colors.h" #include "controls.h" +#include "menustat.h" + // for DrawMenuStateStrings() #include "encount.h" #include "ship.h" #include "process.h" #include "globdata.h" +#include "sis.h" +#include "units.h" #include "init.h" #include "nameref.h" #include "resinst.h" @@ -1595,7 +1599,7 @@ } void -DoMenuOptions (void) +HyperspaceMenu (void) { COLOR OldColor; CONTEXT OldContext; Modified: trunk/sc2/src/uqm/hyper.h =================================================================== --- trunk/sc2/src/uqm/hyper.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/hyper.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -20,10 +20,42 @@ #define _HYPER_H #include "element.h" +#include "units.h" + // for UNIT_SCREEN_WIDTH/HEIGHT +#define NUM_RADAR_SCREENS 12 + +#define RADAR_SCAN_WIDTH (UNIT_SCREEN_WIDTH * NUM_RADAR_SCREENS) +#define RADAR_SCAN_HEIGHT (UNIT_SCREEN_HEIGHT * NUM_RADAR_SCREENS) + +// Hyperspace coordinates of the naturally occuring portal into QuasiSpace +#define ARILOU_SPACE_X 438 +#define ARILOU_SPACE_Y 6372 + +// QuasiSpace coordinates of the same portal +#define QUASI_SPACE_X 5000 +#define QUASI_SPACE_Y 5000 + +// QuasiSpace coordinates of the Arilou home world +#define ARILOU_HOME_X (QUASI_SPACE_X + ((RADAR_SCAN_WIDTH >> 1) * 3)) +#define ARILOU_HOME_Y (QUASI_SPACE_Y + ((RADAR_SCAN_HEIGHT >> 1) * 3)) + +// Hyperspace coordinates of the Sol system +// Should be the same as in plandata.c +#define SOL_X 1752 +#define SOL_Y 1450 + + +extern BOOLEAN LoadHyperspace (void); +extern BOOLEAN FreeHyperspace (void); +extern void SeedUniverse (void); +extern void MoveSIS (SIZE *pdx, SIZE *pdy); + extern void FreeHyperData (void); extern void check_hyperspace_encounter (void); extern BOOLEAN hyper_transition (ELEMENT *ElementPtr); +extern void HyperspaceMenu (void); + #endif /* _HYPER_H */ Modified: trunk/sc2/src/uqm/init.c =================================================================== --- trunk/sc2/src/uqm/init.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/init.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -25,6 +25,7 @@ #include "pickship.h" #include "process.h" #include "globdata.h" +#include "hyper.h" #include "init.h" #include "port.h" #include "resinst.h" Modified: trunk/sc2/src/uqm/intro.c =================================================================== --- trunk/sc2/src/uqm/intro.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/intro.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,6 +19,8 @@ #include "controls.h" #include "options.h" #include "settings.h" +#include "globdata.h" +#include "sis.h" #include "setup.h" #include "sounds.h" #include "fmv.h" Modified: trunk/sc2/src/uqm/load.h =================================================================== --- trunk/sc2/src/uqm/load.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/load.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -18,6 +18,7 @@ #define _LOAD_H #include "sis.h" + // for SUMMARY_DESC #include "libs/compiler.h" #include "globdata.h" Modified: trunk/sc2/src/uqm/melee.c =================================================================== --- trunk/sc2/src/uqm/melee.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/melee.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -46,6 +46,8 @@ #include "setup.h" #include "sounds.h" #include "util.h" +#include "planets/planets.h" + // for NUMBER_OF_PLANET_TYPES #include "libs/graphics/drawable.h" #include "libs/gfxlib.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/menu.c =================================================================== --- trunk/sc2/src/uqm/menu.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/menu.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -16,8 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "menustat.h" + #include "colors.h" #include "controls.h" +#include "units.h" #include "options.h" #include "setup.h" #include "gamestr.h" Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/menustat.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -48,6 +48,76 @@ void *Extra; } MENU_STATE; +// XXX: Should probably go to menu.h (does not yet exist) +enum +{ + PM_SCAN = 0, + PM_STARMAP, + PM_DEVICES, + PM_CARGO, + PM_ROSTER, + PM_SAVE_LOAD0, + PM_NAVIGATE, + + PM_MIN_SCAN, + PM_ENE_SCAN, + PM_BIO_SCAN, + PM_EXIT_MENU0, + PM_AUTO_SCAN, + PM_LAUNCH_LANDER, + + PM_SAVE_GAME, + PM_LOAD_GAME, + PM_QUIT_GAME, + PM_CHANGE_SETTINGS, + PM_EXIT_MENU1, + + PM_CONVERSE, + PM_ATTACK, + PM_SAVE_LOAD1, + + PM_FUEL, + PM_MODULE, + PM_SAVE_LOAD2, + PM_EXIT_MENU2, + + PM_CREW, + PM_SAVE_LOAD3, + PM_EXIT_MENU3, + + PM_SOUND_ON, + PM_SOUND_OFF, + PM_MUSIC_ON, + PM_MUSIC_OFF, + PM_CYBORG_OFF, + PM_CYBORG_NORMAL, + PM_CYBORG_DOUBLE, + PM_CYBORG_SUPER, + PM_CHANGE_CAPTAIN, + PM_CHANGE_SHIP, + PM_EXIT_MENU4, + + PM_ALT_SCAN, + PM_ALT_STARMAP, + PM_ALT_MANIFEST, + PM_ALT_SAVE0, + PM_ALT_NAVIGATE, + + PM_ALT_CARGO, + PM_ALT_DEVICES, + PM_ALT_ROSTER, + PM_ALT_EXITMENU0, + + PM_ALT_MSCAN, + PM_ALT_ESCAN, + PM_ALT_BSCAN, + PM_ALT_ASCAN, + PM_ALT_DISPATCH, + PM_ALT_EXITMENU1 +}; + +extern BOOLEAN DoMenuChooser (MENU_STATE *pMS, BYTE BaseState); +extern void DrawMenuStateStrings (BYTE beg_index, SWORD NewState); + #endif /* _MENUSTAT_H */ - Modified: trunk/sc2/src/uqm/oscill.c =================================================================== --- trunk/sc2/src/uqm/oscill.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/oscill.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -18,7 +18,9 @@ #include "oscill.h" -#include "sis.h" +// XXX: we should not refer to units.h here because we should not be +// using RADAR_WIDTH constants! +#include "units.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" #include "libs/sound/sound.h" Modified: trunk/sc2/src/uqm/outfit.c =================================================================== --- trunk/sc2/src/uqm/outfit.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/outfit.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,6 +19,7 @@ #include "options.h" #include "colors.h" #include "controls.h" +#include "menustat.h" #include "gameopt.h" #include "gamestr.h" #include "resinst.h" @@ -27,7 +28,10 @@ #include "starbase.h" #include "setup.h" #include "sis.h" +#include "units.h" #include "sounds.h" +#include "planets/planets.h" + // for xxx_DISASTER #include "libs/graphics/gfx_common.h" Modified: trunk/sc2/src/uqm/pickship.c =================================================================== --- trunk/sc2/src/uqm/pickship.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/pickship.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -21,6 +21,7 @@ #include "build.h" #include "colors.h" #include "controls.h" +#include "menustat.h" #include "pickmele.h" #include "battle.h" #include "races.h" Modified: trunk/sc2/src/uqm/planets/cargo.c =================================================================== --- trunk/sc2/src/uqm/planets/cargo.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/cargo.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -23,6 +23,9 @@ #include "../setup.h" #include "../sounds.h" #include "../util.h" +#include "../sis.h" + // for ClearSISRect(), DrawStatusMessage() +#include "planets.h" void Modified: trunk/sc2/src/uqm/planets/devices.c =================================================================== --- trunk/sc2/src/uqm/planets/devices.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/devices.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -25,6 +25,8 @@ #include "../load.h" #include "../setup.h" #include "../state.h" +#include "../sis.h" + // for ClearSISRect(), SaveFlagshipState() #include "../grpinfo.h" #include "../sounds.h" #include "../util.h" Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/lander.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -26,6 +26,7 @@ // XXX: for CurStarDescPtr and XXX_DEFINED #include "../encount.h" #include "../process.h" +#include "../units.h" #include "../gamestr.h" #include "../nameref.h" #include "../resinst.h" Modified: trunk/sc2/src/uqm/planets/lander.h =================================================================== --- trunk/sc2/src/uqm/planets/lander.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/lander.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -27,6 +27,9 @@ #include "../element.h" +// Surface magnification shift (x4) +#define MAG_SHIFT 2 + #define NUM_TEXT_FRAMES 32 typedef struct Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/planets.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "planets.h" + #include "scan.h" #include "lander.h" #include "../element.h" Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,6 +19,7 @@ #include "scan.h" #include "../colors.h" #include "../controls.h" +#include "../menustat.h" // XXX: for stuff that does not belong there #include "../encount.h" #include "../races.h" @@ -26,6 +27,10 @@ #include "../gamestr.h" #include "../globdata.h" #include "../shipcont.h" +#include "../units.h" +#include "../hyper.h" +#include "../sis.h" + // for DrawHyperCoords(), DrawStatusMessage() #include "../settings.h" #include "../setup.h" #include "../sounds.h" Modified: trunk/sc2/src/uqm/planets/roster.c =================================================================== --- trunk/sc2/src/uqm/planets/roster.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/roster.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -20,6 +20,8 @@ #include "../colors.h" #include "../controls.h" #include "../races.h" +#include "../units.h" +#include "../sis.h" #include "../shipcont.h" #include "../setup.h" #include "../sounds.h" @@ -30,7 +32,7 @@ #include <stdlib.h> // Ship icon positions in status display around the flagship -static const POINT ship_pos[MAX_COMBAT_SHIPS] = +static const POINT ship_pos[MAX_BUILT_SHIPS] = { SUPPORT_SHIP_PTS }; @@ -38,7 +40,7 @@ // Ship icon positions split into (lower half) left and right (upper) // and sorted in the Y coord. These are used for navigation around the // escort positions. -static POINT sorted_ship_pos[MAX_COMBAT_SHIPS]; +static POINT sorted_ship_pos[MAX_BUILT_SHIPS]; static SHIP_FRAGMENT* LockSupportShip (MENU_STATE *pMS, HSHIPFRAG *phFrag); Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/scan.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -21,6 +21,7 @@ #include "../build.h" #include "../cons_res.h" #include "../controls.h" +#include "../menustat.h" #include "../encount.h" // for EncounterGroup #include "../gamestr.h" @@ -33,6 +34,7 @@ #include "../setup.h" #include "../sounds.h" #include "../state.h" +#include "../sis.h" #include "options.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" Modified: trunk/sc2/src/uqm/planets/scan.h =================================================================== --- trunk/sc2/src/uqm/planets/scan.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/scan.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,8 +19,8 @@ #ifndef _SCAN_H #define _SCAN_H +#include "libs/compiler.h" #include "libs/gfxlib.h" -#include "../menustat.h" typedef struct @@ -39,10 +39,6 @@ SCAN_DESC *scan_base; } SCAN_BLOCK; -#define SAME_SCAN (1 << 16) -#define SCALED_ROOT_TWO 92682L /* root 2 * (1 << 16) */ -#define SCALE_FACTOR 16 - extern void RepairBackRect (RECT *pRect); extern void GeneratePlanetSide (void); Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,10 +19,13 @@ #include "lander.h" #include "../colors.h" #include "../controls.h" +#include "../menustat.h" + // for DrawMenuStateStrings() #include "../encount.h" #include "../races.h" #include "../gamestr.h" #include "../globdata.h" +#include "../sis.h" #include "../init.h" #include "../nameref.h" #include "../resinst.h" Modified: trunk/sc2/src/uqm/process.c =================================================================== --- trunk/sc2/src/uqm/process.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/process.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -24,6 +24,7 @@ #include "settings.h" #include "setup.h" #include "sounds.h" +#include "hyper.h" #include "element.h" #include "battle.h" #include "weapon.h" Modified: trunk/sc2/src/uqm/races.h =================================================================== --- trunk/sc2/src/uqm/races.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/races.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -664,25 +664,5 @@ BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x20), /* BLACK_URQUAN_SHIP */ \ BUILD_COLOR (MAKE_RGB15 (0x14, 0x07, 0x1F), 0x39), /* YEHAT_REBEL_SHIP */ -#define RADAR_SCAN_WIDTH (UNIT_SCREEN_WIDTH * NUM_RADAR_SCREENS) -#define RADAR_SCAN_HEIGHT (UNIT_SCREEN_HEIGHT * NUM_RADAR_SCREENS) - -// Hyperspace coordinates of the naturally occuring portal into QuasiSpace -#define ARILOU_SPACE_X 438 -#define ARILOU_SPACE_Y 6372 - -// QuasiSpace coordinates of the same portal -#define QUASI_SPACE_X 5000 -#define QUASI_SPACE_Y 5000 - -// QuasiSpace coordinates of the Arilou home world -#define ARILOU_HOME_X (QUASI_SPACE_X + ((RADAR_SCAN_WIDTH >> 1) * 3)) -#define ARILOU_HOME_Y (QUASI_SPACE_Y + ((RADAR_SCAN_HEIGHT >> 1) * 3)) - -// Hyperspace coordinates of the Sol system -// Should be the same as in plandata.c -#define SOL_X 1752 -#define SOL_Y 1450 - #endif /* _RACES_H */ Modified: trunk/sc2/src/uqm/restart.c =================================================================== --- trunk/sc2/src/uqm/restart.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/restart.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -24,6 +24,7 @@ // XXX: for star_array[] #include "encount.h" #include "fmv.h" +#include "menustat.h" #include "gamestr.h" #include "globdata.h" #include "intel.h" Modified: trunk/sc2/src/uqm/save.h =================================================================== --- trunk/sc2/src/uqm/save.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/save.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -18,6 +18,7 @@ #define _SAVE_H #include "sis.h" + // for SUMMARY_DESC #include "libs/compiler.h" extern void SaveProblem (void); Modified: trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c =================================================================== --- trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -22,6 +22,7 @@ #include "uqm/colors.h" #include "uqm/controls.h" #include "uqm/globdata.h" +#include "uqm/hyper.h" #include "libs/mathlib.h" @@ -303,7 +304,7 @@ && StarShipPtr->special_counter == 0) { #define MENU_DELAY 10 - DoMenuOptions (); + HyperspaceMenu (); StarShipPtr->cur_status_flags &= ~SHIP_AT_MAX_SPEED; StarShipPtr->special_counter = MENU_DELAY; } Modified: trunk/sc2/src/uqm/shipyard.c =================================================================== --- trunk/sc2/src/uqm/shipyard.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/shipyard.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,6 +19,7 @@ #include "build.h" #include "colors.h" #include "controls.h" +#include "menustat.h" #include "fmv.h" #include "gameopt.h" #include "gamestr.h" @@ -32,8 +33,8 @@ #include "starbase.h" #include "setup.h" #include "sis.h" +#include "units.h" #include "sounds.h" -#include "state.h" #include "libs/graphics/gfx_common.h" #include "libs/inplib.h" @@ -296,7 +297,7 @@ SHIP_FRAGMENT *StarShipPtr; POINT finished_s; STAMP ship_s, lfdoor_s, rtdoor_s; - } ship_win_info[MAX_COMBAT_SHIPS], *pship_win_info; + } ship_win_info[MAX_BUILT_SHIPS], *pship_win_info; num_ships = 1; pship_win_info = &ship_win_info[0]; Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/sis.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -16,13 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "sis.h" + #include "colors.h" #include "races.h" // XXX: including encount.h for stuff that does not belong there #include "encount.h" +#include "units.h" +#include "menustat.h" + // for DrawMenuStateStrings() #include "gamestr.h" #include "options.h" -#include "starbase.h" #include "battle.h" // For BATTLE_FRAME_RATE #include "element.h" @@ -941,7 +945,7 @@ { HSHIPFRAG hStarShip, hNextShip; POINT *pship_pos; - POINT ship_pos[MAX_COMBAT_SHIPS] = + POINT ship_pos[MAX_BUILT_SHIPS] = { SUPPORT_SHIP_PTS }; Modified: trunk/sc2/src/uqm/sis.h =================================================================== --- trunk/sc2/src/uqm/sis.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/sis.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -1,90 +1,16 @@ #ifndef _SIS_H #define _SIS_H -#include "planets/planets.h" +#include "libs/compiler.h" +#include "libs/gfxlib.h" +#include "planets/elemdata.h" + // for NUM_ELEMENT_CATEGORIES -enum -{ - PM_SCAN = 0, - PM_STARMAP, - PM_DEVICES, - PM_CARGO, - PM_ROSTER, - PM_SAVE_LOAD0, - PM_NAVIGATE, - - PM_MIN_SCAN, - PM_ENE_SCAN, - PM_BIO_SCAN, - PM_EXIT_MENU0, - PM_AUTO_SCAN, - PM_LAUNCH_LANDER, - - PM_SAVE_GAME, - PM_LOAD_GAME, - PM_QUIT_GAME, - PM_CHANGE_SETTINGS, - PM_EXIT_MENU1, - - PM_CONVERSE, - PM_ATTACK, - PM_SAVE_LOAD1, - - PM_FUEL, - PM_MODULE, - PM_SAVE_LOAD2, - PM_EXIT_MENU2, - - PM_CREW, - PM_SAVE_LOAD3, - PM_EXIT_MENU3, - - PM_SOUND_ON, - PM_SOUND_OFF, - PM_MUSIC_ON, - PM_MUSIC_OFF, - PM_CYBORG_OFF, - PM_CYBORG_NORMAL, - PM_CYBORG_DOUBLE, - PM_CYBORG_SUPER, - PM_CHANGE_CAPTAIN, - PM_CHANGE_SHIP, - PM_EXIT_MENU4, - - PM_ALT_SCAN, - PM_ALT_STARMAP, - PM_ALT_MANIFEST, - PM_ALT_SAVE0, - PM_ALT_NAVIGATE, - - PM_ALT_CARGO, - PM_ALT_DEVICES, - PM_ALT_ROSTER, - PM_ALT_EXITMENU0, - - PM_ALT_MSCAN, - PM_ALT_ESCAN, - PM_ALT_BSCAN, - PM_ALT_ASCAN, - PM_ALT_DISPATCH, - PM_ALT_EXITMENU1 -}; - #define CLEAR_SIS_RADAR (1 << 2) #define DRAW_SIS_DISPLAY (1 << 3) #define UNDEFINED_DELTA 0x7FFF -#define RADAR_X (4 + (SCREEN_WIDTH - STATUS_WIDTH - SAFE_X)) -#define RADAR_WIDTH (STATUS_WIDTH - 8) -#define RADAR_HEIGHT 53 -#define RADAR_Y (SIS_ORG_Y + SIS_SCREEN_HEIGHT - RADAR_HEIGHT) -#define NUM_RADAR_SCREENS 12 -#define MAG_SHIFT 2 /* driving on planet */ - -#define SHIP_NAME_WIDTH 60 -#define SHIP_NAME_HEIGHT 7 - #define NUM_DRIVE_SLOTS 11 #define NUM_JET_SLOTS 8 #define NUM_MODULE_SLOTS 16 @@ -105,18 +31,10 @@ #define FUEL_VOLUME_PER_ROW (HEFUEL_TANK_CAPACITY / MAX_FUEL_BARS) #define FUEL_RESERVE FUEL_VOLUME_PER_ROW -#define MAX_COMBAT_SHIPS 12 -#define MAX_BATTLE_GROUPS 32 - -// XXX: Needed to maintain savegame compatibility -#define NUM_SAVED_BATTLE_GROUPS 64 - #define IP_SHIP_THRUST_INCREMENT 8 #define IP_SHIP_TURN_WAIT 17 #define IP_SHIP_TURN_DECREMENT 2 -#define BOGUS_MASS 5 - #define BIO_CREDIT_VALUE 2 enum @@ -189,17 +107,6 @@ {3 + 0, 30 + (5 * 16)}, \ {3 + 42, 30 + (5 * 16)}, -#define SIS_TITLE_BOX_WIDTH 57 -#define SIS_TITLE_WIDTH (SIS_TITLE_BOX_WIDTH - 2) -#define SIS_TITLE_HEIGHT 8 -#define SIS_SPACER_BOX_WIDTH 12 -#define SIS_MESSAGE_BOX_WIDTH (SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH \ - - SIS_SPACER_BOX_WIDTH) -#define SIS_MESSAGE_WIDTH (SIS_MESSAGE_BOX_WIDTH - 2) -#define SIS_MESSAGE_HEIGHT SIS_TITLE_HEIGHT -#define STATUS_MESSAGE_WIDTH (STATUS_WIDTH - 4) -#define STATUS_MESSAGE_HEIGHT 7 - #define SIS_NAME_SIZE 16 typedef struct @@ -250,13 +157,6 @@ #define OVERRIDE_LANDER_FLAGS (1 << 7) #define AFTER_BOMB_INSTALLED (1 << 7) -extern BOOLEAN InitSIS (void); -extern void UninitSIS (void); - -extern void SeedUniverse (void); -extern BOOLEAN LoadHyperspace (void); -extern BOOLEAN FreeHyperspace (void); -extern void MoveSIS (SIZE *pdx, SIZE *pdy); extern void RepairSISBorder (void); extern void InitSISContexts (void); extern void DrawSISFrame (void); @@ -274,7 +174,6 @@ #define DSME_BLOCKCUR (1 << 2) #define DSME_MYCOLOR (1 << 3) extern void DrawSISMessage (const UNICODE *pStr); -extern void DrawGameDate (void); extern void DateToString (unsigned char *buf, size_t bufLen, BYTE month_index, BYTE day_index, COUNT year_index); @@ -307,9 +206,6 @@ extern DWORD GetFTankCapacity (POINT *ppt); extern COUNT CountSISPieces (BYTE piece_type); -extern BOOLEAN DoMenuChooser (MENU_STATE *pMS, BYTE BaseState); -extern void DrawMenuStateStrings (BYTE beg_index, SWORD NewState); -extern void DoMenuOptions (void); extern void DrawFlagshipName (BOOLEAN InStatusArea); extern void DrawCaptainsName (void); Modified: trunk/sc2/src/uqm/starbase.c =================================================================== --- trunk/sc2/src/uqm/starbase.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/starbase.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -25,6 +25,7 @@ #include "gamestr.h" #include "load.h" #include "starbase.h" +#include "sis.h" #include "resinst.h" #include "nameref.h" #include "settings.h" Modified: trunk/sc2/src/uqm/starbase.h =================================================================== --- trunk/sc2/src/uqm/starbase.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/starbase.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -44,8 +44,5 @@ field_width); // XXX: Doesn't really belong in this file. -extern const char starbase_str_array[][20]; - #endif /* _STARBASE_H */ - Modified: trunk/sc2/src/uqm/starcon.c =================================================================== --- trunk/sc2/src/uqm/starcon.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/starcon.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -32,6 +32,12 @@ #include "master.h" #include "controls.h" #include "starcon.h" +#include "clock.h" + // for GameClockTick() +#include "hyper.h" + // for SeedUniverse() +#include "planets/planets.h" + // for ExploreSolarSys() #include "uqmdebug.h" #include "libs/tasklib.h" #include "libs/log.h" @@ -191,7 +197,7 @@ log_add (log_Fatal, "Could not set player input."); explode (); // Does not return; } - InitSIS (); + InitGameStructures (); InitGameClock (); AddInitialGameEvents(); @@ -281,7 +287,7 @@ StopSound (); UninitGameClock (); - UninitSIS (); + UninitGameStructures (); ClearPlayerInputAll (); } // CloseJournal (); Modified: trunk/sc2/src/uqm/units.h =================================================================== --- trunk/sc2/src/uqm/units.h 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/units.h 2009-11-21 01:15:21 UTC (rev 3333) @@ -44,8 +44,26 @@ /* 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 RADAR_X (4 + (SCREEN_WIDTH - STATUS_WIDTH - SAFE_X)) +#define RADAR_WIDTH (STATUS_WIDTH - 8) +#define RADAR_HEIGHT 53 +#define RADAR_Y (SIS_ORG_Y + SIS_SCREEN_HEIGHT - RADAR_HEIGHT) +#define SIS_TITLE_BOX_WIDTH 57 +#define SIS_TITLE_WIDTH (SIS_TITLE_BOX_WIDTH - 2) +#define SIS_TITLE_HEIGHT 8 +#define SIS_SPACER_BOX_WIDTH 12 +#define SIS_MESSAGE_BOX_WIDTH (SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH \ + - SIS_SPACER_BOX_WIDTH) +#define SIS_MESSAGE_WIDTH (SIS_MESSAGE_BOX_WIDTH - 2) +#define SIS_MESSAGE_HEIGHT SIS_TITLE_HEIGHT +#define STATUS_MESSAGE_WIDTH (STATUS_WIDTH - 4) +#define STATUS_MESSAGE_HEIGHT 7 + +#define SHIP_NAME_WIDTH (STATUS_WIDTH - 4) +#define SHIP_NAME_HEIGHT 7 + #define MAX_REDUCTION 3 #define MAX_VIS_REDUCTION 2 #define REDUCTION_SHIFT 1 @@ -87,6 +105,8 @@ #define MAX_FLEET_STRENGTH (254 * SPHERE_RADIUS_INCREMENT) +// XXX: These corrected for the weird screen aspect ratio on DOS +// In part because of them, hyperflight is slower vertically #define UNIT_SCREEN_WIDTH 63 #define UNIT_SCREEN_HEIGHT 50 Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/uqmdebug.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -24,6 +24,7 @@ #include "clock.h" #include "encount.h" #include "element.h" +#include "sis.h" #include "status.h" #include "gamestr.h" #include "gameev.h" Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-11-20 20:14:35 UTC (rev 3332) +++ trunk/sc2/src/uqm/util.c 2009-11-21 01:15:21 UTC (rev 3333) @@ -19,6 +19,7 @@ #include "controls.h" #include "util.h" #include "setup.h" +#include "units.h" #include "settings.h" #include "libs/inplib.h" #include "libs/sound/trackplayer.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-22 14:04:03
|
Revision: 3338 http://sc2.svn.sourceforge.net/sc2/?rev=3338&view=rev Author: Meep-Eep Date: 2009-11-22 14:03:56 +0000 (Sun, 22 Nov 2009) Log Message: ----------- Cleanups. Modified Paths: -------------- trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/sis.c Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/element.h 2009-11-22 14:03:56 UTC (rev 3338) @@ -128,6 +128,11 @@ union { BYTE mass_points; + /* Planetside: + * - for living bio: Index in CreatureData, possibly OR'ed + * with CREATURE_AWARE + * - for canned bio: value of creature + */ BYTE sys_loc; /* IP: location in system */ }; BYTE turn_wait; Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/planets/lander.c 2009-11-22 14:03:56 UTC (rev 3338) @@ -600,6 +600,46 @@ } static void +shotCreature (ELEMENT *ElementPtr, BYTE value, + INTERSECT_CONTROL *LanderControl, PRIMITIVE *pPrim) +{ + if (ElementPtr->hit_points == 0) + { + // Creature is already canned. + return; + } + + --ElementPtr->hit_points; + if (ElementPtr->hit_points == 0) + { + // Can creature. + ElementPtr->mass_points = value; + DisplayArray[ElementPtr->PrimIndex].Object.Stamp.frame = + pSolarSysState->PlanetSideFrame[0]; + } + else if (CreatureData[ElementPtr->mass_points & ~CREATURE_AWARE] + .Attributes & SPEED_MASK) + { + COUNT angle; + + angle = FACING_TO_ANGLE (GetFrameIndex ( + LanderControl->IntersectStamp.frame) - + ANGLE_TO_FACING (FULL_CIRCLE)); + DeltaVelocityComponents (&ElementPtr->velocity, + COSINE (angle, WORLD_TO_VELOCITY (1)), + SINE (angle, WORLD_TO_VELOCITY (1))); + ElementPtr->thrust_wait = 0; + ElementPtr->mass_points |= CREATURE_AWARE; + } + + SetPrimType (pPrim, STAMPFILL_PRIM); + SetPrimColor (pPrim, WHITE_COLOR); + + PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_HITS), + NotPositional (), NULL, GAME_SOUND_PRIORITY); +} + +static void CheckObjectCollision (COUNT index) { INTERSECT_CONTROL LanderControl; @@ -731,8 +771,7 @@ continue; } } - else if (scan == BIOLOGICAL_SCAN - && ElementPtr->hit_points) + else if (scan == BIOLOGICAL_SCAN && ElementPtr->hit_points) { BYTE danger_vals[] = { @@ -782,42 +821,8 @@ ].ValueAndHitPoints))) { /* Collision of a stun bolt with a viable creature */ - if (ElementPtr->hit_points) - { - if (--ElementPtr->hit_points == 0) - { - ElementPtr->mass_points = value; - DisplayArray[ - ElementPtr->PrimIndex - ].Object.Stamp.frame = - pSolarSysState->PlanetSideFrame[0]; - } - else if (CreatureData[ - ElementPtr->mass_points - & ~CREATURE_AWARE - ].Attributes & SPEED_MASK) - { - COUNT angle; - - angle = FACING_TO_ANGLE (GetFrameIndex ( - LanderControl.IntersectStamp.frame - ) - ANGLE_TO_FACING (FULL_CIRCLE)); - DeltaVelocityComponents ( - &ElementPtr->velocity, - COSINE (angle, WORLD_TO_VELOCITY (1)), - SINE (angle, WORLD_TO_VELOCITY (1))); - ElementPtr->thrust_wait = 0; - ElementPtr->mass_points |= CREATURE_AWARE; - } - - SetPrimType (pPrim, STAMPFILL_PRIM); - SetPrimColor (pPrim, WHITE_COLOR); - - PlaySound (SetAbsSoundIndex ( - LanderSounds, LANDER_HITS), - NotPositional (), NULL, - GAME_SOUND_PRIORITY); - } + shotCreature (ElementPtr, value, &LanderControl, + pPrim); UnlockElement (hElement); break; } Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/planets/planets.h 2009-11-22 14:03:56 UTC (rev 3338) @@ -100,6 +100,7 @@ #include "../units.h" #include "elemdata.h" +#include "lifeform.h" #include "plandata.h" #include "sundata.h" @@ -174,6 +175,8 @@ // as its argument, and overwritten by subsequent calls. PLANET_DESC *pBaseDesc; PLANET_DESC *pOrbitalDesc; + // Points into PlanetDesc or MoonDesc to the planet currently + // orbiting. SIZE FirstPlanetIndex, LastPlanetIndex; // The planets get sorted on their image.origin.y value. // PlanetDesc[FirstPlanetIndex] is the planet with the lowest @@ -198,7 +201,15 @@ // Functions to call to fill in various parts of this structure. // See generate.h, doc/devel/generate - FRAME PlanetSideFrame[6]; + FRAME PlanetSideFrame[3 + MAX_LIFE_VARIATION]; + /* Frames for planet-side elements. + * [0] = bio cannister + * [1] = energy node (world-specific) + * [2] = unused (formerly static slave shield, presumed) + * [3] = bio 1 (world-specific) + * [4] = bio 2 (world-specific) + * [5] = bio 3 (world-specific) + */ UWORD Tint_rgb; UBYTE PauseRotate; FRAME TopoFrame; Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/planets/scan.c 2009-11-22 14:03:56 UTC (rev 3338) @@ -1246,17 +1246,65 @@ } } +static void +generateBioNode (SOLARSYS_STATE *system, ELEMENT *NodeElementPtr, + BYTE *life_init_tab) +{ + COUNT i; + COUNT creatureType; + + creatureType = system->SysInfo.PlanetInfo.CurType; + + if (CreatureData[creatureType].Attributes & SPEED_MASK) + { + // Place moving creatures at a random location. + i = (COUNT)TFB_Random (); + NodeElementPtr->current.location.x = + (LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8; + NodeElementPtr->current.location.y = + (HIBYTE (i) % (MAP_HEIGHT - (8 << 1))) + 8; + } + + if (system->PlanetSideFrame[0] == 0) + system->PlanetSideFrame[0] = + CaptureDrawable (LoadGraphic (CANNISTER_MASK_PMAP_ANIM)); + + for (i = 0; i < MAX_LIFE_VARIATION + && life_init_tab[i] != (BYTE)(creatureType + 1); + ++i) + { + if (life_init_tab[i] != 0) + continue; + + life_init_tab[i] = (BYTE)creatureType + 1; + + system->PlanetSideFrame[i + 3] = load_life_form (creatureType); + break; + } + + NodeElementPtr->mass_points = (BYTE)creatureType; + NodeElementPtr->hit_points = HINIBBLE ( + CreatureData[creatureType].ValueAndHitPoints); + DisplayArray[NodeElementPtr->PrimIndex]. + Object.Stamp.frame = SetAbsFrameIndex ( + system->PlanetSideFrame[i + 3], (COUNT)TFB_Random ()); +} + void GeneratePlanetSide (void) { SIZE scan; BYTE life_init_tab[MAX_LIFE_VARIATION]; + // life_init_tab is filled with the creature types of already + // selected creatures. If an entry is 0, none has been selected + // yet, otherwise, it is 1 more than the creature type. InitDisplayList (); if (pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) return; memset (life_init_tab, 0, sizeof (life_init_tab)); + for (scan = BIOLOGICAL_SCAN; scan >= MINERAL_SCAN; --scan) { COUNT num_nodes; @@ -1315,7 +1363,7 @@ DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame = IncFrameIndex (NodeElementPtr->next.image.frame); } - else + else /* (scan == BIOLOGICAL_SCAN || scan == ENERGY_SCAN) */ { NodeElementPtr->current.image.frame = f; NodeElementPtr->next.image.frame = SetRelFrameIndex ( @@ -1325,54 +1373,23 @@ if (scan == ENERGY_SCAN) { if (pSolarSysState->SysInfo.PlanetInfo.CurType == 1) + { NodeElementPtr->mass_points = 0; + } else if (pSolarSysState->SysInfo.PlanetInfo.CurType == 2) + { + // Special case: Fwiffo NodeElementPtr->mass_points = 1; + } else NodeElementPtr->mass_points = MAX_SCROUNGED; DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame = pSolarSysState->PlanetSideFrame[1]; } - else + else /* (scan == BIOLOGICAL_SCAN) */ { - COUNT i, which_node; - - which_node = pSolarSysState->SysInfo.PlanetInfo.CurType; - - if (CreatureData[which_node].Attributes & SPEED_MASK) - { - i = (COUNT)TFB_Random (); - NodeElementPtr->current.location.x = - (LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8; - NodeElementPtr->current.location.y = - (HIBYTE (i) % (MAP_HEIGHT - (8 << 1))) + 8; - } - - if (pSolarSysState->PlanetSideFrame[0] == 0) - pSolarSysState->PlanetSideFrame[0] = - CaptureDrawable (LoadGraphic ( - CANNISTER_MASK_PMAP_ANIM)); - for (i = 0; i < MAX_LIFE_VARIATION - && life_init_tab[i] != (BYTE)(which_node + 1); - ++i) - { - if (life_init_tab[i] != 0) - continue; - - life_init_tab[i] = (BYTE)which_node + 1; - - pSolarSysState->PlanetSideFrame[i + 3] = - load_life_form (which_node); - break; - } - - NodeElementPtr->mass_points = (BYTE)which_node; - NodeElementPtr->hit_points = HINIBBLE ( - CreatureData[which_node].ValueAndHitPoints); - DisplayArray[NodeElementPtr->PrimIndex]. - Object.Stamp.frame = SetAbsFrameIndex ( - pSolarSysState->PlanetSideFrame[i + 3], - (COUNT)TFB_Random ()); + generateBioNode (pSolarSysState, NodeElementPtr, + life_init_tab); } } Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/sis.c 2009-11-22 14:03:56 UTC (rev 3338) @@ -670,8 +670,7 @@ (((100 * ONE_SECOND * energy_regeneration) / ((1 + energy_wait) * BATTLE_FRAME_RATE)) + 5) / 10; sprintf (buf, "%2u.%1u", - energy_per_10_sec / 10, - energy_per_10_sec % 10); + energy_per_10_sec / 10, energy_per_10_sec % 10); } font_DrawText (&t); t.baseline.y += leading; @@ -723,9 +722,7 @@ i = GLOBAL_SIS (NumLanders); r.corner.x = (STATUS_WIDTH >> 1) - r.corner.x; - s.origin.x = r.corner.x - - (((r.extent.width * i) - + (2 * (i - 1))) >> 1); + s.origin.x = r.corner.x - (((r.extent.width * i) + (2 * (i - 1))) >> 1); s.origin.y = 29; width = r.extent.width + 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-22 17:58:40
|
Revision: 3342 http://sc2.svn.sourceforge.net/sc2/?rev=3342&view=rev Author: Meep-Eep Date: 2009-11-22 17:58:28 +0000 (Sun, 22 Nov 2009) Log Message: ----------- Give more colors a name, and move them to colors.h Modified Paths: -------------- trunk/sc2/src/uqm/colors.h trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/sis.h Modified: trunk/sc2/src/uqm/colors.h =================================================================== --- trunk/sc2/src/uqm/colors.h 2009-11-22 17:47:12 UTC (rev 3341) +++ trunk/sc2/src/uqm/colors.h 2009-11-22 17:58:28 UTC (rev 3342) @@ -156,6 +156,154 @@ BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F) +// === SIS === + +// Left border of the "SIS" view (the part in which your ship flies). +#define SIS_LEFT_BORDER_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19) + +// Right and bottom border of the "SIS" view. +#define SIS_BOTTOM_RIGHT_BORDER_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F) + +// Text color of the string "CAPTAIN", when using PC fonts. +#define PC_CAPTAIN_STRING_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x02, 0x04, 0x1E), 0x38) + +// Background color of the string "CAPTAIN", when using PC fonts. +#define PC_CAPTAIN_STRING_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) + +// Text color of the captain's name. +#define CAPTAIN_NAME_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x16, 0x0B, 0x1F), 0x38) + +// Background color of the captain's name. +#define CAPTAIN_NAME_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) + +// Text color of the flagship's name, when using 3DO fonts. +#define THREEDO_FLAGSHIP_NAME_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x0C) + +// Background color of the flagship's name. +#define FLAGSHIP_NAME_BACKGROUND_COLOR \ + BLACK_COLOR + +// Text color for the message area (at the top of the screen, on the left +// hand side, containing the name of the solar system. +#define SIS_MESSAGE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33) + +// Color of autocompleted text after the current cursor position, +// when editing in the title area. +#define SIS_MESSAGE_EXTRA_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x12, 0x00, 0x12), 0x33) + +// Background color for the message area. +#define SIS_MESSAGE_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) + +// Cursor color when editing in the message area. +#define SIS_MESSAGE_CURSOR_COLOR \ + BLACK_COLOR + +// Text color of the title (at the top of the screen, on the right +// hand side, containing the coordinates in HyperSpace, or the planet name +// in IP. +#define SIS_TITLE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33) + +// Background color of the title. +#define SIS_TITLE_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) + +// Text color of the status message, below the flagship overview, containing +// the date, RU, etc. +#define STATUS_MESSAGE_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x6B) + +// Background color of the status message. +#define STATUS_MESSAGE_BACKGROUND_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x08, 0x00), 0x6E) + +// Pulsating color of the string "AUTO-PILOT" +#define AUTOPILOT_COLOR_CYCLE_TABLE \ + { \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x14, 0x18), 0x5B), \ + BUILD_COLOR (MAKE_RGB15 (0x06, 0x10, 0x16), 0x5C), \ + BUILD_COLOR (MAKE_RGB15 (0x03, 0x0E, 0x14), 0x5D), \ + BUILD_COLOR (MAKE_RGB15 (0x02, 0x0C, 0x11), 0x5E), \ + BUILD_COLOR (MAKE_RGB15 (0x01, 0x0B, 0x0F), 0x5F), \ + BUILD_COLOR (MAKE_RGB15 (0x01, 0x09, 0x0D), 0x60), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x07, 0x0B), 0x61), \ + } + +// Colors for the fuel in the fuel tanks as they are filled up, +// when viewed from the shipyard. +#define FUEL_COLOR_TABLE \ + { \ + BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), \ + BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), \ + BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), \ + BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7D), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A), \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x18, 0x00), 0x79), \ + } + +// Colors for the crew in the crew pods as they are filled up, +// when viewed from the shipyard, when using PC fonts. +#define PC_CREW_COLOR_TABLE \ + { \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1E, 0x09), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x1E, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x1B, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x18, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x12, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x0D, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x0A, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x07, 0x00), 0x65), \ + } + +// Colors for the crew in the crew pods as they are filled up, +// when viewed from the shipyard, when using 3DO fonts. +#define THREEDO_CREW_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x05, 0x10, 0x05), 0x65) + +// Colors for the minerals in the storage bays as they are filled up, +// when viewed from the shipyard. +#define STORAGE_BAY_COLOR_TABLE \ + { \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F), \ + BUILD_COLOR (MAKE_RGB15 (0x1C, 0x1C, 0x1C), 0x11), \ + BUILD_COLOR (MAKE_RGB15 (0x18, 0x18, 0x18), 0x13), \ + BUILD_COLOR (MAKE_RGB15 (0x15, 0x15, 0x15), 0x15), \ + BUILD_COLOR (MAKE_RGB15 (0x12, 0x12, 0x12), 0x17), \ + BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19), \ + BUILD_COLOR (MAKE_RGB15 (0x0D, 0x0D, 0x0D), 0x1B), \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x1D), \ + BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F), \ + BUILD_COLOR (MAKE_RGB15 (0x05, 0x05, 0x05), 0x21), \ + } + +// Color of the storage bay indicator, as shown beneath the flagship, +// for the parts which are full. +#define STORAGE_BAY_FULL_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08) + +// Color of the storage bay indicator, as shown beneath the flagship, +// for the parts which are empty. +#define STORAGE_BAY_EMPTY_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x20) + + // === PC Menus === // Background color of the PC-style menus. Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-22 17:47:12 UTC (rev 3341) +++ trunk/sc2/src/uqm/sis.c 2009-11-22 17:58:28 UTC (rev 3342) @@ -51,24 +51,27 @@ OldContext = SetContext (ScreenContext); BatchGraphics (); + + // Left border r.corner.x = SIS_ORG_X - 1; 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 (SIS_LEFT_BORDER_COLOR); DrawFilledRectangle (&r); - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); + // Right border + SetContextForeGroundColor (SIS_BOTTOM_RIGHT_BORDER_COLOR); r.corner.x += (SIS_SCREEN_WIDTH + 2) - 1; DrawFilledRectangle (&r); + // Bottom border r.corner.x = SIS_ORG_X - 1; r.corner.y += (SIS_SCREEN_HEIGHT + 2) - 1; r.extent.width = SIS_SCREEN_WIDTH + 2; r.extent.height = 1; DrawFilledRectangle (&r); + UnbatchGraphics (); SetContext (OldContext); @@ -117,6 +120,9 @@ SetContext (OldContext); } +// Draw the SIS title. This is the field at the top of the screen, on the +// right hand side, containing the coordinates in HyperSpace, or the planet +// name in IP. void DrawSISTitle (UNICODE *pStr) { @@ -140,12 +146,15 @@ SetContextFont (TinyFont); BatchGraphics (); - SetContextBackGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); + + // Background color + SetContextBackGroundColor (SIS_TITLE_BACKGROUND_COLOR); ClearDrawable (); - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33)); + + // Text color + SetContextForeGroundColor (SIS_TITLE_TEXT_COLOR); font_DrawText (&t); + UnbatchGraphics (); SetContextClipRect (NULL); @@ -158,7 +167,7 @@ { UNICODE buf[100]; - sprintf (buf, "%03u.%01u : %03u.%01u", + snprintf (buf, sizeof buf, "%03u.%01u : %03u.%01u", universe.x / 10, universe.x % 10, universe.y / 10, universe.y % 10); @@ -171,6 +180,7 @@ DrawSISMessageEx (pStr, -1, -1, DSME_NONE); } +// See sis.h for the allowed flags. BOOLEAN DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos, SIZE ExPos, COUNT flags) { @@ -189,8 +199,7 @@ SetContextClipRect (&r); BatchGraphics (); - SetContextBackGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); + SetContextBackGroundColor (SIS_MESSAGE_BACKGROUND_COLOR); if (pStr == 0) { @@ -222,8 +231,7 @@ } if (!(flags & DSME_MYCOLOR)) - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33)); + SetContextForeGroundColor (SIS_MESSAGE_TEXT_COLOR); t.baseline.y = SIS_MESSAGE_HEIGHT - 2; t.pStr = pStr; @@ -296,12 +304,11 @@ cur_r.corner.y = 0; cur_r.extent.height = r.extent.height; - SetContextForeGroundColor (BLACK_COLOR); + SetContextForeGroundColor (SIS_MESSAGE_CURSOR_COLOR); DrawFilledRectangle (&cur_r); } - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33)); + SetContextForeGroundColor (SIS_MESSAGE_TEXT_COLOR); if (ExPos >= 0 && ExPos < t.CharCount) { // handle extra characters @@ -309,8 +316,7 @@ font_DrawText (&t); // print extra chars - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x12, 0x00, 0x12), 0x33)); + SetContextForeGroundColor (SIS_MESSAGE_EXTRA_TEXT_COLOR); for (i = ExPos, pchar_deltas = char_deltas; i > 0; --i) t.baseline.x += (SIZE)*pchar_deltas++; t.pStr = skipUTF8Chars (t.pStr, ExPos); @@ -366,8 +372,7 @@ SetContextClipRect (&r); BatchGraphics (); - SetContextBackGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x08, 0x00), 0x6E)); + SetContextBackGroundColor (STATUS_MESSAGE_BACKGROUND_COLOR); ClearDrawable (); if (!pStr) @@ -412,8 +417,7 @@ t.CharCount = (COUNT)~0; SetContextFont (TinyFont); - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x6B)); + SetContextForeGroundColor (STATUS_MESSAGE_TEXT_COLOR); font_DrawText (&t); UnbatchGraphics (); @@ -441,8 +445,7 @@ OldContext = SetContext (StatusContext); OldFont = SetContextFont (TinyFont); - OldColor = SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); + OldColor = SetContextForeGroundColor (CAPTAIN_NAME_BACKGROUND_COLOR); r.corner.x = 2 + 1; r.corner.y = 10; @@ -455,8 +458,7 @@ t.align = ALIGN_CENTER; t.pStr = GLOBAL_SIS (CommanderName); t.CharCount = (COUNT)~0; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x16, 0x0B, 0x1F), 0x38)); + SetContextForeGroundColor (CAPTAIN_NAME_TEXT_COLOR); font_DrawText (&t); SetContextForeGroundColor (OldColor); @@ -504,7 +506,7 @@ strupr (buf); } OldFontEffect = SetContextFontEffect (NULL); - OldColor = SetContextForeGroundColor (BLACK_COLOR); + OldColor = SetContextForeGroundColor (FLAGSHIP_NAME_BACKGROUND_COLOR); DrawFilledRectangle (&r); t.baseline.x = r.corner.x + (r.extent.width >> 1); @@ -515,8 +517,7 @@ SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, InStatusArea ? 0 : 3)); else - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x0C)); + SetContextForeGroundColor (THREEDO_FLAGSHIP_NAME_TEXT_COLOR); font_DrawText (&t); @@ -741,6 +742,7 @@ SetContext (OldContext); } +// Draw the storage bays, beneath the picture of the flagship. void DrawStorageBays (BOOLEAN Refresh) { @@ -770,8 +772,7 @@ r.corner.x = (STATUS_WIDTH >> 1) - ((i * (r.extent.width + 1)) >> 1); - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08)); + SetContextForeGroundColor (STORAGE_BAY_FULL_COLOR); for (j = GLOBAL_SIS (TotalElementMass); j >= STORAGE_BAY_CAPACITY; j -= STORAGE_BAY_CAPACITY) { @@ -791,8 +792,7 @@ if (r.extent.height) { r.corner.y = 123; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x20)); + SetContextForeGroundColor (STORAGE_BAY_EMPTY_COLOR); DrawFilledRectangle (&r); } r.corner.x += r.extent.width + 1; @@ -801,8 +801,7 @@ } r.extent.height = 4; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x20)); + SetContextForeGroundColor (STORAGE_BAY_EMPTY_COLOR); while (i--) { DrawFilledRectangle (&r); @@ -854,15 +853,16 @@ font_DrawText (&t); SetContextFontEffect (NULL); + // Background of text "CAPTAIN". r.corner.x = 2 + 1; r.corner.y = 3; r.extent.width = 58; r.extent.height = 7; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); + SetContextForeGroundColor (PC_CAPTAIN_STRING_BACKGROUND_COLOR); DrawFilledRectangle (&r); - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x02, 0x04, 0x1E), 0x38)); + + // Text "CAPTAIN". + SetContextForeGroundColor (PC_CAPTAIN_STRING_TEXT_COLOR); t.baseline.y = r.corner.y + 6; t.pStr = GAME_STRING (STATUS_STRING_BASE + 5); // "CAPTAIN" font_DrawText (&t); @@ -1104,19 +1104,7 @@ GLOBAL_SIS (CrewEnlisted)) { COUNT pod_remainder, which_row; - static const COLOR crew_rows[] = - { - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1E, 0x09), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x1E, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x1B, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x18, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x12, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x0D, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x0A, 0x00), 0x65), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x07, 0x00), 0x65), - }; + static const COLOR crew_rows[] = PC_CREW_COLOR_TABLE; pod_remainder = GLOBAL_SIS (CrewEnlisted) - capacity; @@ -1127,8 +1115,7 @@ if (optWhichFonts == OPT_PC) SetContextForeGroundColor (crew_rows[which_row]); else - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x05, 0x10, 0x05), 0x65)); + SetContextForeGroundColor (THREEDO_CREW_COLOR); } capacity += CREW_POD_CAPACITY; @@ -1159,19 +1146,7 @@ GLOBAL_SIS (TotalElementMass)) { COUNT bay_remainder, which_row; - static const COLOR color_bars[] = - { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F), - BUILD_COLOR (MAKE_RGB15 (0x1C, 0x1C, 0x1C), 0x11), - BUILD_COLOR (MAKE_RGB15 (0x18, 0x18, 0x18), 0x13), - BUILD_COLOR (MAKE_RGB15 (0x15, 0x15, 0x15), 0x15), - BUILD_COLOR (MAKE_RGB15 (0x12, 0x12, 0x12), 0x17), - BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19), - BUILD_COLOR (MAKE_RGB15 (0x0D, 0x0D, 0x0D), 0x1B), - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x1D), - BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F), - BUILD_COLOR (MAKE_RGB15 (0x05, 0x05, 0x05), 0x21), - }; + static const COLOR color_bars[] = STORAGE_BAY_COLOR_TABLE; bay_remainder = GLOBAL_SIS (TotalElementMass) - capacity; which_row = bay_remainder / SBAY_MASS_PER_ROW; @@ -1218,20 +1193,7 @@ GLOBAL_SIS (FuelOnBoard)) { COUNT which_row; - static const COLOR fuel_colors[] = - { - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7D), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x18, 0x00), 0x79), - }; + static const COLOR fuel_colors[] = FUEL_COLOR_TABLE; which_row = (COUNT)( (GLOBAL_SIS (FuelOnBoard) - capacity) @@ -1297,20 +1259,10 @@ static DWORD cycle_index = 0; BOOLEAN OnAutoPilot; - static const COLOR cycle_tab[] = - { - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x14, 0x18), 0x5B), - BUILD_COLOR (MAKE_RGB15 (0x06, 0x10, 0x16), 0x5C), - BUILD_COLOR (MAKE_RGB15 (0x03, 0x0E, 0x14), 0x5D), - BUILD_COLOR (MAKE_RGB15 (0x02, 0x0C, 0x11), 0x5E), - BUILD_COLOR (MAKE_RGB15 (0x01, 0x0B, 0x0F), 0x5F), - BUILD_COLOR (MAKE_RGB15 (0x01, 0x09, 0x0D), 0x60), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x07, 0x0B), 0x61), - }; -#define NUM_CYCLES (sizeof (cycle_tab) / sizeof (cycle_tab[0])) + static const COLOR cycle_tab[] = AUTOPILOT_COLOR_CYCLE_TABLE; + const size_t cycleCount = sizeof cycle_tab / sizeof cycle_tab[0]; #define BLINK_RATE (ONE_SECOND * 3 / 40) // 9 @ 120 ticks/second - if (Reset) { // Just a reset, not drawing LastPilot = FALSE; @@ -1349,7 +1301,7 @@ SetContext (OldContext); } - cycle_index = (cycle_index + 1) % NUM_CYCLES; + cycle_index = (cycle_index + 1) % cycleCount; NextTime = GetTimeCounter () + BLINK_RATE; } Modified: trunk/sc2/src/uqm/sis.h =================================================================== --- trunk/sc2/src/uqm/sis.h 2009-11-22 17:47:12 UTC (rev 3341) +++ trunk/sc2/src/uqm/sis.h 2009-11-22 17:58:28 UTC (rev 3342) @@ -166,13 +166,21 @@ #define SFR_MENU_ANY ((RECT*)~1L) extern void DrawHyperCoords (POINT puniverse); extern void DrawSISTitle (UNICODE *pStr); -extern BOOLEAN DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos, - SIZE ExPos, COUNT flags); + +// Flags for DrawSISMessageEx (may be OR'ed): #define DSME_NONE 0 #define DSME_SETFR (1 << 0) + // Set the flash rectangle to the message area. #define DSME_CLEARFR (1 << 1) + // Disable the flash rectangle. #define DSME_BLOCKCUR (1 << 2) + // Use a block cursor instead of an insertion point cursor, + // when editing in the message field. #define DSME_MYCOLOR (1 << 3) + // Use the current foreground color, instead of the default. +extern BOOLEAN DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos, + SIZE ExPos, COUNT flags); + extern void DrawSISMessage (const UNICODE *pStr); extern void DateToString (unsigned char *buf, size_t bufLen, BYTE month_index, BYTE day_index, COUNT year_index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-22 23:41:05
|
Revision: 3343 http://sc2.svn.sourceforge.net/sc2/?rev=3343&view=rev Author: avolkov Date: 2009-11-22 23:40:56 +0000 (Sun, 22 Nov 2009) Log Message: ----------- Cleanup of input wait functions and looped AnyButtonPress() uses Modified Paths: -------------- trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/controls.h trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/fmv.c trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/planets/report.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/save.c trunk/sc2/src/uqm/util.c Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/comm.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -678,8 +678,7 @@ static void FlushTalkSegue (void) { - WaitForNoInput (ONE_SECOND / 2); - FlushInput (); + WaitForNoInput (ONE_SECOND / 2, TRUE); // Wait until the animation task stops "talking" do Modified: trunk/sc2/src/uqm/controls.h =================================================================== --- trunk/sc2/src/uqm/controls.h 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/controls.h 2009-11-22 23:40:56 UTC (rev 3343) @@ -21,8 +21,8 @@ #include "libs/compiler.h" #include "libs/strlib.h" +#include "libs/timelib.h" - // Enumerated type for controls enum { KEY_UP, @@ -102,9 +102,16 @@ BOOLEAN PauseGame (void); void SleepGame (void); BOOLEAN DoConfirmExit (void); -BOOLEAN WaitAnyButtonOrQuit (BOOLEAN CheckSpecial); -void WaitForNoInput (SIZE Duration); BOOLEAN ConfirmExit (void); + +#define WAIT_INFINITE ((TimePeriod)-1) +BOOLEAN WaitForAnyButton (BOOLEAN newButton, TimePeriod duration, + BOOLEAN resetInput); +BOOLEAN WaitForAnyButtonUntil (BOOLEAN newButton, TimeCount timeOut, + BOOLEAN resetInput); +BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput); +BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); + void DoPopupWindow(const char *msg); void DoInput (void *pInputState, BOOLEAN resetInput); Modified: trunk/sc2/src/uqm/encount.c =================================================================== --- trunk/sc2/src/uqm/encount.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/encount.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -437,7 +437,6 @@ else { BOOLEAN Sleepy; - DWORD Time; SIZE VictoryState; COUNT RecycleAmount = 0; SIZE i; @@ -625,7 +624,7 @@ if (Sleepy) { - Time = GetTimeCounter (); + TimeCount Time = GetTimeCounter (); for (j = 0; j < NUM_SHIP_FADES; ++j) { UnlockMutex (GraphicsLock); @@ -664,12 +663,8 @@ DestroyDrawable (ReleaseDrawable (s.frame)); #endif /* NEVER */ - FlushInput (); - Time = GetTimeCounter () + (ONE_SECOND * 3); UnlockMutex (GraphicsLock); - // TODO: handle rapid quit - while (!(AnyButtonPress (TRUE)) && GetTimeCounter () < Time) - TaskSwitch (); + WaitForAnyButton (TRUE, ONE_SECOND * 3, FALSE); LockMutex (GraphicsLock); if (!CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE]) { @@ -696,12 +691,8 @@ str2 = GAME_STRING (ENCOUNTER_STRING_BASE + 7); // "Scavenged" DrawFadeText (str1, str2, TRUE, &scavenge_r); - Time = GetTimeCounter () + ONE_SECOND * 2; UnlockMutex (GraphicsLock); - // TODO: handle rapid quit - while (!(AnyButtonPress (TRUE)) - && GetTimeCounter () < Time) - TaskSwitch (); + WaitForAnyButton (TRUE, ONE_SECOND * 2, FALSE); LockMutex (GraphicsLock); if (!CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE]) DrawFadeText (str1, str2, FALSE, &scavenge_r); Modified: trunk/sc2/src/uqm/fmv.c =================================================================== --- trunk/sc2/src/uqm/fmv.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/fmv.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -87,7 +87,6 @@ BYTE xform_buf[1]; STAMP s; DWORD TimeOut; - BOOLEAN InputState; xform_buf[0] = FadeAllToBlack; SleepThreadUntil (XFormColorMap ( @@ -117,13 +116,7 @@ * with the proper operation of the quit operation. * --Michael */ - TimeOut += ONE_SECOND * 3; - while (!(InputState = AnyButtonPress (FALSE)) && - (GetTimeCounter () <= TimeOut) && - !(GLOBAL (CurrentActivity) & CHECK_ABORT)) - { - TaskSwitch (); - } + WaitForAnyButton (FALSE, ONE_SECOND * 3, TRUE); if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return; Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/hyper.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -1634,7 +1634,7 @@ { ClearSISRect (CLEAR_SIS_RADAR); UnlockMutex (GraphicsLock); - WaitForNoInput (ONE_SECOND / 2); + WaitForNoInput (ONE_SECOND / 2, FALSE); LockMutex (GraphicsLock); } Modified: trunk/sc2/src/uqm/planets/report.c =================================================================== --- trunk/sc2/src/uqm/planets/report.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/planets/report.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -151,7 +151,7 @@ word_chars = utf8StringCountN (t.pStr, pStr); if ((col_cells += word_chars) <= NUM_CELL_COLS) { - DWORD TimeOut; + TimeCount TimeOut; if (StrLen -= word_chars) --StrLen; @@ -181,22 +181,12 @@ if (word_chars == 0) TimeOut += ONE_SECOND / 20; - TaskSwitch (); - while (GetTimeCounter () < TimeOut) + if (WaitForAnyButtonUntil (TRUE, TimeOut, FALSE)) { - if (ButtonState) - { - if (!AnyButtonPress (TRUE)) - ButtonState = 0; - } - else if (AnyButtonPress (TRUE)) - { - Sleepy = FALSE; - LockMutex (GraphicsLock); - BatchGraphics (); - break; - } - TaskSwitch(); + Sleepy = FALSE; + // We draw the whole thing at once after this + LockMutex (GraphicsLock); + BatchGraphics (); } } t.pStr = pNextStr; @@ -219,7 +209,7 @@ UnlockMutex (GraphicsLock); } - if (WaitAnyButtonOrQuit (TRUE)) + if (!WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE)) break; InitPageCell: @@ -289,9 +279,7 @@ DestroyContext (context); UnlockMutex (GraphicsLock); - FlushInput (); - while (AnyButtonPress (TRUE)) - TaskSwitch (); + WaitForNoInput (WAIT_INFINITE, TRUE); LockMutex (GraphicsLock); } Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/planets/scan.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -928,7 +928,10 @@ static BOOLEAN DoScan (MENU_STATE *pMS) { - DWORD TimeIn, WaitTime; +#define SCAN_DURATION (ONE_SECOND * 7 / 4) +// NUM_FLASH_COLORS for flashing blips; 1 for the final frame +#define SCAN_LINES (MAP_HEIGHT + NUM_FLASH_COLORS + 1) +#define SCAN_LINE_WAIT (SCAN_DURATION / SCAN_LINES) BOOLEAN select, cancel; select = PulsedInputState.menu[KEY_MENU_SELECT]; @@ -959,7 +962,6 @@ { BYTE min_scan, max_scan; RECT r; - BOOLEAN PressState, ButtonState; if (pMS->CurState == DISPATCH_SHUTTLE) { @@ -1030,7 +1032,7 @@ max_scan = BIOLOGICAL_SCAN; } - do + for ( ; min_scan <= max_scan; ++min_scan) { TEXT t; SWORD i; @@ -1078,6 +1080,7 @@ { DWORD rgb; + TimeCount TimeOut; switch (min_scan) { @@ -1092,46 +1095,44 @@ break; } + // Draw a virgin surface LockMutex (GraphicsLock); BatchGraphics (); DrawPlanet (0, 0, 0, 0); UnbatchGraphics (); UnlockMutex (GraphicsLock); - PressState = AnyButtonPress (TRUE); - WaitTime = (ONE_SECOND << 1) / MAP_HEIGHT; -// LockMutex (GraphicsLock); - TimeIn = GetTimeCounter (); - for (i = 0; i < MAP_HEIGHT + NUM_FLASH_COLORS + 1; i++) + // Draw the scan slowly line by line + TimeOut = GetTimeCounter (); + for (i = 0; i < SCAN_LINES; i++) { - ButtonState = AnyButtonPress (TRUE); - if (PressState) - { - PressState = ButtonState; - ButtonState = FALSE; - } - if (ButtonState) - i = -i; + TimeOut += SCAN_LINE_WAIT; + if (WaitForAnyButtonUntil (TRUE, TimeOut, FALSE)) + break; + LockMutex (GraphicsLock); BatchGraphics (); DrawPlanet (0, 0, i, rgb); - if (i < 0) - i = MAP_HEIGHT + NUM_FLASH_COLORS; - if (pMS->delta_item) - DrawScannedStuff (i, min_scan); + DrawScannedStuff (i, min_scan); UnbatchGraphics (); UnlockMutex (GraphicsLock); -// FlushGraphics (); - SleepThreadUntil (TimeIn + WaitTime); - TimeIn = GetTimeCounter (); } -// UnlockMutex (GraphicsLock); + + if (i < SCAN_LINES) + { // Aborted by a keypress; draw in finished state + LockMutex (GraphicsLock); + BatchGraphics (); + // dy < 0 means "from dy to the end" + DrawPlanet (0, 0, -i, rgb); + DrawScannedStuff (SCAN_LINES - 1, min_scan); + UnbatchGraphics (); + UnlockMutex (GraphicsLock); + } + pSolarSysState->Tint_rgb = 0; - } + } - } while (++min_scan <= max_scan); - LockMutex (GraphicsLock); SetContext (SpaceContext); r.corner.x = 0; Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/save.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -606,15 +606,7 @@ FlushGraphics (); UnlockMutex (GraphicsLock); - while (AnyButtonPress (FALSE)) - ; - do - { - TaskSwitch (); - UpdateInputState (); - } while (!(PulsedInputState.menu[KEY_MENU_SELECT] || - PulsedInputState.menu[KEY_MENU_SPECIAL] || - (GLOBAL (CurrentActivity) & CHECK_ABORT))); + WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE); LockMutex (GraphicsLock); BatchGraphics (); Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-11-22 17:58:28 UTC (rev 3342) +++ trunk/sc2/src/uqm/util.c 2009-11-22 23:40:56 UTC (rev 3343) @@ -111,39 +111,6 @@ return (cur_time); } -void -WaitForNoInput (SIZE Duration) -{ - BOOLEAN PressState; - - PressState = AnyButtonPress (FALSE); - if (Duration < 0) - { - if (PressState) - return; - Duration = -Duration; - } - else if (!PressState) - return; - - { - DWORD TimeOut; - BOOLEAN ButtonState; - - TimeOut = GetTimeCounter () + Duration; - do - { - ButtonState = AnyButtonPress (FALSE); - if (PressState) - { - PressState = ButtonState; - ButtonState = 0; - } - } while (!ButtonState && - (TaskSwitch (), GetTimeCounter ()) <= TimeOut); - } -} - BOOLEAN PauseGame (void) { @@ -215,8 +182,7 @@ SetFrameHot (Screen, OldHot); SetContext (OldContext); - WaitForNoInput (ONE_SECOND / 4); - FlushInput (); + WaitForNoInput (ONE_SECOND / 4, TRUE); if (PlayingTrack ()) ResumeTrack (); @@ -228,24 +194,75 @@ return (TRUE); } -// Waits for a new button to be pressed -// and returns TRUE if Quit was selected +// Waits for a button to be pressed +// Returns TRUE if the wait succeeded (found input) +// FALSE if timed out or game aborted BOOLEAN -WaitAnyButtonOrQuit (BOOLEAN CheckSpecial) +WaitForAnyButtonUntil (BOOLEAN newButton, TimeCount timeOut, + BOOLEAN resetInput) { - while (AnyButtonPress (TRUE)) - TaskSwitch (); + BOOLEAN buttonPressed; - while (!AnyButtonPress (TRUE) && - !(GLOBAL (CurrentActivity) & CHECK_ABORT)) - TaskSwitch (); + if (newButton && !WaitForNoInputUntil (timeOut, FALSE)) + return FALSE; - /* Satisfy unused parameter */ - (void) CheckSpecial; + buttonPressed = AnyButtonPress (TRUE); + while (!buttonPressed + && (timeOut == WAIT_INFINITE || GetTimeCounter () < timeOut) + && !(GLOBAL (CurrentActivity) & CHECK_ABORT) + && !QuitPosted) + { + SleepThread (ONE_SECOND / 40); + buttonPressed = AnyButtonPress (TRUE); + } - return (GLOBAL (CurrentActivity) & CHECK_ABORT) != 0; + if (resetInput) + FlushInput (); + + return buttonPressed; } +BOOLEAN +WaitForAnyButton (BOOLEAN newButton, TimePeriod duration, BOOLEAN resetInput) +{ + TimeCount timeOut = duration; + if (duration != WAIT_INFINITE) + timeOut += GetTimeCounter (); + return WaitForAnyButtonUntil (newButton, timeOut, resetInput); +} + +// Returns TRUE if the wait succeeded (found no input) +// FALSE if timed out or game aborted +BOOLEAN +WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput) +{ + BOOLEAN buttonPressed; + + buttonPressed = AnyButtonPress (TRUE); + while (buttonPressed + && (timeOut == WAIT_INFINITE || GetTimeCounter () < timeOut) + && !(GLOBAL (CurrentActivity) & CHECK_ABORT) + && !QuitPosted) + { + SleepThread (ONE_SECOND / 40); + buttonPressed = AnyButtonPress (TRUE); + } + + if (resetInput) + FlushInput (); + + return !buttonPressed; +} + +BOOLEAN +WaitForNoInput (TimePeriod duration, BOOLEAN resetInput) +{ + TimeCount timeOut = duration; + if (duration != WAIT_INFINITE) + timeOut += GetTimeCounter (); + return WaitForNoInputUntil (timeOut, resetInput); +} + // Stops game clock and music thread and minimizes interrupts/cycles // based on value of global GameActive variable // See similar sleep state for main thread in uqm.c:main() @@ -268,8 +285,7 @@ log_add (log_Debug, "Game is waking up"); - WaitForNoInput (ONE_SECOND / 10); - FlushInput (); + WaitForNoInput (ONE_SECOND / 10, TRUE); ResumeMusic (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-23 11:03:50
|
Revision: 3345 http://sc2.svn.sourceforge.net/sc2/?rev=3345&view=rev Author: avolkov Date: 2009-11-23 11:03:41 +0000 (Mon, 23 Nov 2009) Log Message: ----------- Standardized context frame save/restore; not yet used everywhere it should be Modified Paths: -------------- trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/planets/report.c trunk/sc2/src/uqm/util.c trunk/sc2/src/uqm/util.h Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/gameopt.c 2009-11-23 11:03:41 UTC (rev 3345) @@ -1105,15 +1105,9 @@ LockMutex (GraphicsLock); OldContext = SetContext (SpaceContext); - DlgStamp.origin.x = 0; - DlgStamp.origin.y = 0; // Save the current state of the screen for later restoration - DlgRect.corner.x = SIS_ORG_X; - DlgRect.corner.y = SIS_ORG_Y; - DlgRect.extent.width = SIS_SCREEN_WIDTH; - DlgRect.extent.height = SIS_SCREEN_HEIGHT; - DlgStamp.frame = CaptureDrawable (LoadDisplayPixmap ( - &DlgRect, (FRAME)0)); + DlgStamp = SaveContextFrame (NULL); + GetContextClipRect (&DlgRect); pMS->Initialized = FALSE; pMS->InputFunc = DoPickGame; Modified: trunk/sc2/src/uqm/planets/report.c =================================================================== --- trunk/sc2/src/uqm/planets/report.c 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/planets/report.c 2009-11-23 11:03:41 UTC (rev 3345) @@ -23,6 +23,7 @@ #include "../controls.h" #include "../gamestr.h" #include "../setup.h" +#include "../util.h" #include "../sounds.h" #include "../uqmdebug.h" #include "options.h" @@ -238,6 +239,7 @@ CONTEXT OldContext; CONTEXT context; BOOLEAN ownContext; + STAMP saveStamp; #ifdef DEBUG if (disableInteractivity) @@ -246,6 +248,7 @@ context = GetScanContext (&ownContext); OldContext = SetContext (context); + saveStamp = SaveContextFrame (NULL); { FONT OldFont; FRAME OldFontEffect; @@ -265,14 +268,8 @@ SetContextFontEffect (OldFontEffect); SetContextFont (OldFont); } -#ifdef OLD - ClearDrawable (); - if (pSolarSysState->MenuState.Initialized >= 3) - DrawScannedObjects (FALSE); -#else /* !OLD */ - if (pSolarSysState->MenuState.Initialized < 3) - ClearDrawable (); -#endif /* OLD */ + // Restore previous screen + DrawStamp (&saveStamp); SetContext (OldContext); // TODO: Make CONTEXT ref-counted if (ownContext) Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/util.c 2009-11-23 11:03:41 UTC (rev 3345) @@ -111,6 +111,32 @@ return (cur_time); } +STAMP +SaveContextFrame (RECT *saveRect) +{ + STAMP s; + RECT r; + + GetContextClipRect (&r); + if (saveRect) + { // a portion of the context + r.corner.x += saveRect->corner.x; + r.corner.y += saveRect->corner.y; + r.extent = saveRect->extent; + + s.origin = saveRect->corner; + } + else + { // the entire context + s.origin.x = 0; + s.origin.y = 0; + } + + s.frame = CaptureDrawable (LoadDisplayPixmap (&r, NULL)); + + return s; +} + BOOLEAN PauseGame (void) { Modified: trunk/sc2/src/uqm/util.h =================================================================== --- trunk/sc2/src/uqm/util.h 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/util.h 2009-11-23 11:03:41 UTC (rev 3345) @@ -25,5 +25,8 @@ COLOR InteriorColor); extern DWORD SeedRandomNumbers (void); +// saveRect can be NULL to save the entire context frame +extern STAMP SaveContextFrame (RECT *saveRect); + #endif /* _UTIL_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-26 17:10:23
|
Revision: 3355 http://sc2.svn.sourceforge.net/sc2/?rev=3355&view=rev Author: avolkov Date: 2009-11-26 17:10:02 +0000 (Thu, 26 Nov 2009) Log Message: ----------- Comm animations task retired; Talking Pet mind control strobe reworked into an ambient animation; potential buffer overflow and potential wrong summary context fixed (counts towards bug #576) Modified Paths: -------------- trunk/sc2/src/uqm/comm/talkpet/talkpet.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/comm.h trunk/sc2/src/uqm/commanim.c trunk/sc2/src/uqm/commanim.h trunk/sc2/src/uqm/oscill.c trunk/sc2/src/uqm/oscill.h Modified: trunk/sc2/src/uqm/comm/talkpet/talkpet.c =================================================================== --- trunk/sc2/src/uqm/comm/talkpet/talkpet.c 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/comm/talkpet/talkpet.c 2009-11-26 17:10:02 UTC (rev 3355) @@ -22,6 +22,10 @@ #include "uqm/build.h" +#define STROBE_RATE 10 +#define STROBE_LENGTH (ONE_SECOND * 3 / 2) +#define NUM_STROBES (STROBE_LENGTH * STROBE_RATE / ONE_SECOND) + static LOCDATA talkpet_desc = { NULL, /* init_encounter_func */ @@ -40,7 +44,7 @@ NULL_RESOURCE, /* AlienAltSong */ 0, /* AlienSongFlags */ TALKING_PET_CONVERSATION_PHRASES, /* PlayerPhrases */ - 16, /* NumAnimations */ + 17, /* NumAnimations */ { /* AlienAmbientArray (ambient animations) */ { 7, /* StartIndex */ @@ -173,6 +177,15 @@ ONE_SECOND, ONE_SECOND * 3, /* RestartRate */ 0, /* BlockMask */ }, + { /* Mind control strobe (on-demand) */ + 1, /* StartIndex */ + NUM_STROBES * 2, /* NumFrames */ + CIRCULAR_ANIM | COLORXFORM_ANIM | ONE_SHOT_ANIM + | ANIM_DISABLED, /* AnimFlags */ + ONE_SECOND / (STROBE_RATE * 2), 0, /* FrameRate */ + 0, 0, /* RestartRate */ + 0, /* BlockMask */ + }, }, { /* AlienTransitionDesc */ 0, /* StartIndex */ @@ -197,10 +210,6 @@ NULL, }; -#define STROBE_RATE 15 -#define STROBE_LENGTH (ONE_SECOND * 3 / 2) -#define NUM_STROBES (STROBE_LENGTH * STROBE_RATE / ONE_SECOND) - static void ExitConversation (RESPONSE_REF R) { @@ -266,19 +275,8 @@ static void MindControlStrobe (void) { - BYTE i; - - for (i = 0; i < NUM_STROBES; ++i) - { - XFormColorMap (GetColorMapAddress ( - SetAbsColorMapIndex (CommData.AlienColorMap, 1) - ), 0); - SleepThread (ONE_SECOND / (STROBE_RATE * 2)); - XFormColorMap (GetColorMapAddress ( - SetAbsColorMapIndex (CommData.AlienColorMap, 0) - ), 0); - SleepThread (ONE_SECOND / (STROBE_RATE * 2)); - } + // Enable the one-shot strobe animation + CommData.AlienAmbientArray[16].AnimFlags &= ~ANIM_DISABLED; } static void Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/comm.c 2009-11-26 17:10:02 UTC (rev 3355) @@ -50,7 +50,21 @@ (speechVolumeScale == 0.0f ? NORMAL_VOLUME : (NORMAL_VOLUME >> 1)) #define FOREGROUND_VOL NORMAL_VOLUME +// Oscilloscope frame rate +// Should be <= COMM_ANIM_RATE +// XXX: was 32 picked experimentally? +#define OSCILLOSCOPE_RATE (ONE_SECOND / 32) +// Maximum comm animation frame rate (actual execution rate) +// A gfx frame is not always produced during an execution frame, +// and several animations are combined into one gfx frame. +// The rate was originally 120fps which allowed for more animation +// precision which is ultimately wasted on the human eye anyway. +// The highest known stable animation rate is 40fps, so that's what we use. +#define COMM_ANIM_RATE (ONE_SECOND / 40) + +static CONTEXT AnimContext; + LOCDATA CommData; UNICODE shared_phrase_buf[2048]; @@ -77,20 +91,14 @@ BYTE top_response; RESPONSE_ENTRY response_list[MAX_RESPONSES]; - Task AnimTask; - - COUNT phrase_buf_index; - UNICODE phrase_buf[512]; + UNICODE phrase_buf[1024]; } ENCOUNTER_STATE; static ENCOUNTER_STATE *pCurInputState; -// Mutex guards accesses to SubtitleText, last_subtitle and clear_subtitles. -static Mutex subtitle_mutex; -// These vars are indirectly accessed by the ambient_anim_task -static volatile BOOLEAN clear_subtitles; +static BOOLEAN clear_subtitles; static TEXT SubtitleText; -static const UNICODE * volatile last_subtitle; +static const UNICODE *last_subtitle; static CONTEXT TextCacheContext; static FRAME TextCacheFrame; @@ -104,6 +112,7 @@ static void ClearSubtitles (void); static void CheckSubtitles (void); +static void RedrawSubtitles (void); /* _count_lines - sees how many lines a given input string would take to @@ -392,14 +401,13 @@ void init_communication (void) { - subtitle_mutex = CreateMutex ("Subtitle Lock", - SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); + // now a no-op } void uninit_communication (void) { - DestroyMutex (subtitle_mutex); + // now a no-op } static void @@ -481,34 +489,73 @@ UnbatchGraphics (); } -void -UpdateSpeechGraphics (BOOLEAN Initialize) +static void +InitSpeechGraphics (void) { + RECT r; + RECT sr; + FRAME f; + + InitOscilloscope (0, 0, RADAR_WIDTH, RADAR_HEIGHT, + SetAbsFrameIndex (ActivityFrame, 9)); + + f = SetAbsFrameIndex (ActivityFrame, 2); + GetFrameRect (f, &r); + SetSliderImage (f); + f = SetAbsFrameIndex (ActivityFrame, 5); + GetFrameRect (f, &sr); + InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH, sr.extent.height, + r.extent.width, r.extent.height, f); +} + +static void +UpdateSpeechGraphics (void) +{ + static TimeCount NextTime; CONTEXT OldContext; - if (Initialize) - { - RECT r, sr; - FRAME f; + if (GetTimeCounter () < NextTime) + return; // too early - InitOscilloscope (0, 0, RADAR_WIDTH, RADAR_HEIGHT, - SetAbsFrameIndex (ActivityFrame, 9)); - f = SetAbsFrameIndex (ActivityFrame, 2); - GetFrameRect (f, &r); - SetSliderImage (f); - f = SetAbsFrameIndex (ActivityFrame, 5); - GetFrameRect (f, &sr); - InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH, sr.extent.height, - r.extent.width, r.extent.height, f); - } + NextTime = GetTimeCounter () + OSCILLOSCOPE_RATE; OldContext = SetContext (RadarContext); - Oscilloscope (!Initialize); + DrawOscilloscope (); SetContext (SpaceContext); - Slider (); + DrawSlider (); SetContext (OldContext); } +static void +UpdateAnimations (bool paused) +{ + static TimeCount NextTime; + CONTEXT OldContext; + BOOLEAN change; + + if (GetTimeCounter () < NextTime) + return; // too early + + NextTime = GetTimeCounter () + COMM_ANIM_RATE; + + OldContext = SetContext (AnimContext); + BatchGraphics (); + // Advance and draw ambient, transit and talk animations + change = ProcessCommAnimations (clear_subtitles, paused); + if (change) + RedrawSubtitles (); + UnbatchGraphics (); + clear_subtitles = FALSE; + SetContext (OldContext); +} + +static void +UpdateCommGraphics (void) +{ + UpdateAnimations (false); + UpdateSpeechGraphics (); +} + // Derived from INPUT_STATE_DESC typedef struct talking_state { @@ -560,8 +607,6 @@ right = false; #endif - LockMutex (GraphicsLock); - if (right) { SetSliderImage (SetAbsFrameIndex (ActivityFrame, 3)); @@ -570,10 +615,6 @@ else if (optSmoothScroll == OPT_3DO) FastForward_Smooth (); pTS->seeking = true; - // XXX: This causes all animations (talking and ambient) - // in ambient_anim_task to stop progressing. I see no reason why - // the animations cannot continue while seeking. - PauseAnimTask = TRUE; } else if (left || pTS->rewind) { @@ -584,8 +625,6 @@ else if (optSmoothScroll == OPT_3DO) FastReverse_Smooth (); pTS->seeking = true; - // XXX: See pause discussion above - PauseAnimTask = TRUE; } else if (pTS->seeking) { @@ -595,16 +634,21 @@ SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2)); } else - { // XXX: See pause discussion above - // Additionally, this used to have a buggy guard condition, which + { + // This used to have a buggy guard condition, which // would cause the animations to remain paused in a couple cases // after seeking back to the beginning. // Broken cases were: Syreen "several hours later" and Starbase // VUX Beast analysis by the scientist. - PauseAnimTask = FALSE; CheckSubtitles (); } - + + LockMutex (GraphicsLock); + // XXX: When seeking, all animations (talking and ambient) stop + // progressing. This is an original 3DO behavior, and I see no + // reason why the animations cannot continue while seeking. + UpdateAnimations (pTS->seeking); + UpdateSpeechGraphics (); UnlockMutex (GraphicsLock); curTrack = PlayingTrack (); @@ -617,6 +661,15 @@ return pTS->seeking || (curTrack && curTrack <= pTS->waitTrack); } +static void +runCommAnimFrame (void) +{ + LockMutex (GraphicsLock); + UpdateCommGraphics (); + UnlockMutex (GraphicsLock); + SleepThread (COMM_ANIM_RATE); +} + static BOOLEAN TalkSegue (COUNT wait_track) { @@ -630,12 +683,9 @@ setRunTalkingAnim (); + // wait until the transition finishes while (runningIntroAnim ()) - { // wait until the transition finishes - UnlockMutex (GraphicsLock); - SleepThread (ONE_SECOND / 30); - LockMutex (GraphicsLock); - } + runCommAnimFrame (); } memset (&talkingState, 0, sizeof talkingState); @@ -651,16 +701,12 @@ assert (PlayingTrack ()); } - UnlockMutex (GraphicsLock); - // Run the talking controls + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); talkingState.InputFunc = DoTalkSegue; talkingState.waitTrack = wait_track; DoInput (&talkingState, FALSE); - LockMutex (GraphicsLock); - - PauseAnimTask = FALSE; ClearSubtitles (); if (talkingState.ended) @@ -672,20 +718,11 @@ if (runningTalkingAnim ()) setStopTalkingAnim (); - return talkingState.ended; -} - -static void -FlushTalkSegue (void) -{ - WaitForNoInput (ONE_SECOND / 2, TRUE); - // Wait until the animation task stops "talking" - do - SleepThread (ONE_SECOND / 30); - while (runningTalkingAnim ()); + while (runningTalkingAnim ()) + runCommAnimFrame (); - TalkingFinished = TRUE; + return talkingState.ended; } static void @@ -732,53 +769,34 @@ void AlienTalkSegue (COUNT wait_track) { - BOOLEAN done; - // this skips any talk segues that follow an aborted one if ((GLOBAL (CurrentActivity) & CHECK_ABORT) || TalkingFinished) return; - LockMutex (GraphicsLock); - if (!pCurInputState->Initialized) { + InitSpeechGraphics (); + LockMutex (GraphicsLock); SetColorMap (GetColorMapAddress (CommData.AlienColorMap)); + SetContext (AnimContext); DrawAlienFrame (NULL, 0, TRUE); - UpdateSpeechGraphics (TRUE); - + UpdateSpeechGraphics (); CommIntroTransition (); + UnlockMutex (GraphicsLock); + pCurInputState->Initialized = TRUE; PlayMusic (CommData.AlienSong, TRUE, 1); SetMusicVolume (BACKGROUND_VOL); - { - DWORD TimeOut; + InitCommAnimations (); - TimeOut = GetTimeCounter () + (ONE_SECOND >> 1); - // Anim task processes not only ambient animations, but also - // talking animations and subtitles - pCurInputState->AnimTask = StartCommAnimTask (); - - UnlockMutex (GraphicsLock); - SleepThreadUntil (TimeOut); - LockMutex (GraphicsLock); - } - LastActivity &= ~CHECK_LOAD; } - done = TalkSegue (wait_track); - if (done) + TalkingFinished = TalkSegue (wait_track); + if (TalkingFinished) FadeMusic (FOREGROUND_VOL, ONE_SECOND); - - UnlockMutex (GraphicsLock); - FlushTalkSegue (); - - if (!done) - { // there is more to come - TalkingFinished = FALSE; - } } @@ -835,7 +853,6 @@ RECT r; TEXT t; int row; - FONT oldFont; r.corner.x = 0; r.corner.y = 0; @@ -843,6 +860,7 @@ r.extent.height = SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT + 2; LockMutex (GraphicsLock); + SetContext (AnimContext); SetContextForeGroundColor (COMM_HISTORY_BACKGROUND_COLOR); DrawFilledRectangle (&r); @@ -852,7 +870,7 @@ t.baseline.x = 2; t.align = ALIGN_LEFT; t.baseline.y = DELTA_Y_SUMMARY; - oldFont = SetContextFont (TinyFont); + SetContextFont (TinyFont); for (row = 0; row < MAX_SUMM_ROWS && pSS->NextSub; ++row, pSS->NextSub = GetNextTrackSubtitle (pSS->NextSub)) @@ -910,7 +928,6 @@ font_DrawText (&mt); } - SetContextFont (oldFont); UnlockMutex (GraphicsLock); pSS->PrintNext = FALSE; @@ -927,20 +944,16 @@ static void SelectResponse (ENCOUNTER_STATE *pES) { - const unsigned char *end; TEXT *response_text = &pES->response_list[pES->cur_response].response_text; - end = skipUTF8Chars(response_text->pStr, response_text->CharCount); - pES->phrase_buf_index = end - response_text->pStr; - memcpy(pES->phrase_buf, response_text->pStr, pES->phrase_buf_index); - pES->phrase_buf[pES->phrase_buf_index++] = '\0'; - + utf8StringCopy (pES->phrase_buf, sizeof pES->phrase_buf, + response_text->pStr); LockMutex (GraphicsLock); FeedbackPlayerPhrase (pES->phrase_buf); + UnlockMutex (GraphicsLock); StopTrack (); ClearSubtitles (); SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2)); - UnlockMutex (GraphicsLock); FadeMusic (BACKGROUND_VOL, ONE_SECOND); @@ -959,10 +972,7 @@ LockMutex (GraphicsLock); if (pES) FeedbackPlayerPhrase (pES->phrase_buf); - PauseAnimTask = TRUE; UnlockMutex (GraphicsLock); - // wait for ambient anim task to pause - SleepThread (ONE_SECOND / 30); SummaryState.Initialized = FALSE; DoConvSummary (&SummaryState); @@ -971,7 +981,6 @@ if (pES) RefreshResponses (pES); clear_subtitles = TRUE; - PauseAnimTask = FALSE; UnlockMutex (GraphicsLock); } @@ -982,10 +991,9 @@ LockMutex (GraphicsLock); if (pES) FeedbackPlayerPhrase (pES->phrase_buf); - TalkingFinished = FALSE; - TalkSegue (0); UnlockMutex (GraphicsLock); - FlushTalkSegue (); + + TalkSegue (0); } static void @@ -1058,8 +1066,12 @@ UnlockMutex (GraphicsLock); } + LockMutex (GraphicsLock); + UpdateCommGraphics (); + UnlockMutex (GraphicsLock); + SleepThreadUntil (pES->NextTime); - pES->NextTime = GetTimeCounter () + ONE_SECOND / 20; + pES->NextTime = GetTimeCounter () + COMM_ANIM_RATE; } } @@ -1097,8 +1109,12 @@ pLRS->TimeOut = FadeMusic (0, ONE_SECOND * 2) + ONE_SECOND / 60; } + LockMutex (GraphicsLock); + UpdateCommGraphics (); + UnlockMutex (GraphicsLock); + SleepThreadUntil (pLRS->NextTime); - pLRS->NextTime = GetTimeCounter () + ONE_SECOND / 60; + pLRS->NextTime = GetTimeCounter () + COMM_ANIM_RATE; return TRUE; } @@ -1110,7 +1126,10 @@ // First, finish playing all queued tracks if not done yet if (!TalkingFinished) + { AlienTalkSegue (WAIT_TRACK_ALL); + return TRUE; + } if (GLOBAL (CurrentActivity) & CHECK_ABORT) ; @@ -1128,23 +1147,13 @@ else { PlayerResponseInput (pES); - return (TRUE); + return TRUE; } LockMutex (GraphicsLock); - - if (pES->AnimTask) - { - UnlockMutex (GraphicsLock); - ConcludeTask (pES->AnimTask); - LockMutex (GraphicsLock); - pES->AnimTask = 0; - } - SetContext (SpaceContext); - DestroyContext (TaskContext); - TaskContext = 0; - + DestroyContext (AnimContext); + AnimContext = NULL; UnlockMutex (GraphicsLock); FlushColorXForms (); @@ -1155,7 +1164,7 @@ StopTrack (); SleepThreadUntil (FadeMusic (NORMAL_VOLUME, 0) + ONE_SECOND / 60); - return (FALSE); + return FALSE; } void @@ -1234,6 +1243,8 @@ SubtitleText.baseline = CommData.AlienTextBaseline; SubtitleText.align = CommData.AlienTextAlign; + LockMutex (GraphicsLock); + // init subtitle cache context TextCacheContext = CreateContext ("TextCacheContext"); TextCacheFrame = CaptureDrawable ( @@ -1247,7 +1258,6 @@ ClearDrawable (); SetFrameTransparentColor (TextCacheFrame, TextBack); - ES.phrase_buf_index = 1; ES.phrase_buf[0] = '\0'; SetContext (SpaceContext); @@ -1256,8 +1266,8 @@ { RECT r; - TaskContext = CreateContext ("TaskContext"); - SetContext (TaskContext); + AnimContext = CreateContext ("AnimContext"); + SetContext (AnimContext); SetContextFGFrame (Screen); GetFrameRect (CommData.AlienFrame, &r); r.extent.width = SIS_SCREEN_WIDTH; @@ -1308,6 +1318,9 @@ (*CommData.uninit_encounter_func) (); LockMutex (GraphicsLock); + SetContext (SpaceContext); + SetContextFont (OldFont); + UnlockMutex (GraphicsLock); DestroyStringTable (ReleaseStringTable (CommData.ConversationPhrases)); DestroyMusic (CommData.AlienSong); @@ -1318,8 +1331,6 @@ DestroyContext (TextCacheContext); DestroyDrawable (ReleaseDrawable (TextCacheFrame)); - SetContext (SpaceContext); - SetContextFont (OldFont); DestroyFont (PlayerFont); // Some support code tests either of these to see if the @@ -1373,6 +1384,8 @@ } } + UnlockMutex (GraphicsLock); + if (which_comm == URQUAN_DRONE_CONVERSATION) { status = URQUAN_DRONE_SHIP; @@ -1416,8 +1429,6 @@ CommData = *LocDataPtr; } - UnlockMutex (GraphicsLock); - if (GET_GAME_STATE (BATTLE_SEGUE) == 0) { // Not offered the chance to attack. @@ -1435,8 +1446,6 @@ SET_GAME_STATE (BATTLE_SEGUE, 1); } - LockMutex (GraphicsLock); - if (status == HAIL) { HailAlien (); @@ -1449,8 +1458,6 @@ (*CommData.uninit_encounter_func) (); // cleanup } - UnlockMutex (GraphicsLock); - status = 0; if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { @@ -1625,7 +1632,7 @@ } } -void +static void RedrawSubtitles (void) { TEXT t; @@ -1633,38 +1640,20 @@ if (!optSubtitles) return; - LockMutex (subtitle_mutex); if (SubtitleText.pStr) { t = SubtitleText; add_text (1, &t); } - UnlockMutex (subtitle_mutex); } -// Returns clear_subtitles and resets it -BOOLEAN -HaveSubtitlesChanged (void) -{ - BOOLEAN ret; - - LockMutex (subtitle_mutex); - ret = clear_subtitles; - clear_subtitles = FALSE; - UnlockMutex (subtitle_mutex); - - return ret; -} - static void ClearSubtitles (void) { - LockMutex (subtitle_mutex); clear_subtitles = TRUE; last_subtitle = NULL; SubtitleText.pStr = NULL; SubtitleText.CharCount = 0; - UnlockMutex (subtitle_mutex); } static void @@ -1674,7 +1663,6 @@ pStr = GetTrackSubtitle (); - LockMutex (subtitle_mutex); if (pStr != SubtitleText.pStr) { // Subtitles changed clear_subtitles = TRUE; @@ -1688,7 +1676,6 @@ else SubtitleText.CharCount = 0; } - UnlockMutex (subtitle_mutex); } void Modified: trunk/sc2/src/uqm/comm.h =================================================================== --- trunk/sc2/src/uqm/comm.h 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/comm.h 2009-11-26 17:10:02 UTC (rev 3355) @@ -115,8 +115,6 @@ extern void AlienTalkSegue (COUNT wait_track); BOOLEAN getLineWithinWidth(TEXT *pText, const unsigned char **startNext, SIZE maxWidth, COUNT maxChars); -extern void RedrawSubtitles (void); -extern BOOLEAN HaveSubtitlesChanged (void); extern RECT CommWndRect; /* comm window rect */ Modified: trunk/sc2/src/uqm/commanim.c =================================================================== --- trunk/sc2/src/uqm/commanim.c 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/commanim.c 2009-11-26 17:10:02 UTC (rev 3355) @@ -27,23 +27,20 @@ #include "libs/mathlib.h" -// Maximum ambient animation frame rate (actual execution rate) -// A gfx frame is not always produced during an execution frame, -// and several animations are combined into one gfx frame. -// The rate was originally 120fps which allowed for more animation -// precision which is ultimately wasted on the human eye anyway. -// The highest known stable animation rate is 40fps, so that's what we use. -#define AMBIENT_ANIM_RATE 40 +static TimeCount LastTime; +static SEQUENCE Sequences[MAX_ANIMATIONS + 2]; + // 2 extra for Talk and Transition animations +static DWORD ActiveMask; + // Bit mask of all animations that are currently active. + // Bit 'i' is set if the animation with index 'i' is active. +static ANIMATION_DESC TalkDesc; +static ANIMATION_DESC TransitDesc; +static SEQUENCE* Talk; +static SEQUENCE* Transit; +static COUNT FirstAmbient; +static COUNT TotalSequences; -// Oscilloscope frame rate -// Should be <= AMBIENT_ANIM_RATE -// XXX: was 32 picked experimentally? -#define OSCILLOSCOPE_RATE 32 -static int ambient_anim_task (void *data); - -volatile BOOLEAN PauseAnimTask = FALSE; - static inline DWORD randomFrameRate (SEQUENCE *pSeq) { @@ -354,37 +351,11 @@ return done; } -static int -ambient_anim_task (void *data) +void +InitCommAnimations (void) { - COUNT i; - TimeCount LastTime; - SEQUENCE Sequences[MAX_ANIMATIONS + 2]; - // 2 extra for Talk and Transition animations - SEQUENCE *pSeq; - DWORD ActiveMask; - // Bit mask of all animations that are currently active. - // Bit 'i' is set if the animation with index 'i' is active. - DWORD LastOscillTime; - Task task = (Task) data; - BOOLEAN ColorChange = FALSE; - - ANIMATION_DESC TalkDesc; - ANIMATION_DESC TransitDesc; - SEQUENCE* Talk; - SEQUENCE* Transit; - COUNT FirstAmbient; - COUNT TotalSequences; - - while (!CommData.AlienFrame && !Task_ReadState (task, TASK_EXIT)) - TaskSwitch (); - ActiveMask = 0; - // Certain data must be accessed under GraphicsLock - LockMutex (GraphicsLock); - - memset (&DisplayArray[0], 0, sizeof (DisplayArray)); TalkDesc = CommData.AlienTalkDesc; TransitDesc = CommData.AlienTransitionDesc; @@ -403,41 +374,35 @@ SetupAmbientSequences (Sequences + FirstAmbient, CommData.NumAnimations); TotalSequences += CommData.NumAnimations; - UnlockMutex (GraphicsLock); - LastTime = GetTimeCounter (); - LastOscillTime = LastTime; +} - while (!Task_ReadState (task, TASK_EXIT)) +BOOLEAN +ProcessCommAnimations (BOOLEAN FullRedraw, BOOLEAN paused) +{ + if (paused) + { // Drive colormap xforms and nothing else + XFormColorMap_step (); + return FALSE; + } + else { - BOOLEAN CanTalk; + COUNT i; + SEQUENCE *pSeq; + BOOLEAN Change; + BOOLEAN CanTalk = TRUE; TimeCount CurTime; DWORD ElapsedTicks; DWORD NextActiveMask; - SleepThreadUntil (LastTime + ONE_SECOND / AMBIENT_ANIM_RATE); - - LockMutex (GraphicsLock); - BatchGraphics (); CurTime = GetTimeCounter (); ElapsedTicks = CurTime - LastTime; LastTime = CurTime; - if (PauseAnimTask) - { // anims not processed - i = CommData.NumAnimations; - CanTalk = FALSE; - } - else - { - i = 0; - CanTalk = TRUE; - } - // Process ambient animations NextActiveMask = ActiveMask; pSeq = Sequences + FirstAmbient; - for ( ; i < CommData.NumAnimations; ++i, ++pSeq) + for (i = 0; i < CommData.NumAnimations; ++i, ++pSeq) { ANIMATION_DESC *ADPtr = pSeq->ADPtr; DWORD ActiveBit = 1L << i; @@ -542,61 +507,55 @@ } } else - { // Not talking (task may be paused) - // Disable talking anim if it is done + { // Not talking -- disable talking anim if it is done if (Talk->Direction == NO_DIR) TalkDesc.AnimFlags |= ANIM_DISABLED; } + BatchGraphics (); + // Draw all animations - if (!PauseAnimTask) { - CONTEXT OldContext; - BOOLEAN SubtitleChange; - BOOLEAN FullRedraw; - BOOLEAN Change; + BOOLEAN ColorChange = XFormColorMap_step (); - // Clearing any active subtitles counts as 'change' - SubtitleChange = HaveSubtitlesChanged (); - FullRedraw = ColorChange || SubtitleChange; + if (ColorChange) + FullRedraw = TRUE; - OldContext = SetContext (TaskContext); - // Colormap animations are processed separately // from picture anims (see XFormColorMap_step) ProcessColormapAnims (Sequences + FirstAmbient, CommData.NumAnimations); Change = DrawAlienFrame (Sequences, TotalSequences, FullRedraw); - if (FullRedraw || Change) - RedrawSubtitles (); - - SetContext (OldContext); - - ColorChange = FALSE; + if (FullRedraw) + Change = TRUE; } - if (LastOscillTime + (ONE_SECOND / OSCILLOSCOPE_RATE) < CurTime) + UnbatchGraphics (); + + // Post-process ambient animations + pSeq = Sequences + FirstAmbient; + for (i = 0; i < CommData.NumAnimations; ++i, ++pSeq) { - LastOscillTime = CurTime; - UpdateSpeechGraphics (FALSE); + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + DWORD ActiveBit = 1L << i; + + if (ADPtr->AnimFlags & ANIM_DISABLED) + continue; + + // We can only disable a one-shot anim here, otherwise the + // last frame will not be drawn + if ((ADPtr->AnimFlags & ONE_SHOT_ANIM) + && !(NextActiveMask & ActiveBit)) + { // One-shot animation, inactive next frame + ADPtr->AnimFlags |= ANIM_DISABLED; + } } - - UnbatchGraphics (); - UnlockMutex (GraphicsLock); - - ColorChange = XFormColorMap_step (); + + return Change; } - FinishTask (task); - return 0; } -Task -StartCommAnimTask (void) -{ - return AssignTask (ambient_anim_task, 3072, "ambient animations"); -} - BOOLEAN DrawAlienFrame (SEQUENCE *Sequences, COUNT Num, BOOLEAN fullRedraw) { Modified: trunk/sc2/src/uqm/commanim.h =================================================================== --- trunk/sc2/src/uqm/commanim.h 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/commanim.h 2009-11-26 17:10:02 UTC (rev 3355) @@ -19,7 +19,6 @@ #include "libs/compiler.h" #include "libs/gfxlib.h" -#include "libs/tasklib.h" // Some background: every animation has a neutral frame which returns // the image to the state it was in before the animation began. Which @@ -57,6 +56,10 @@ #define COLORXFORM_ANIM PAUSE_TALKING +#define ONE_SHOT_ANIM TALK_INTRO + // Set in AlienAmbientArray for animations that should be + // disabled after they run once. + typedef struct { COUNT StartIndex; @@ -124,12 +127,9 @@ // Returns TRUE if there was an animation change extern BOOLEAN DrawAlienFrame (SEQUENCE *pSeq, COUNT Num, BOOLEAN fullRedraw); +extern void InitCommAnimations (void); +extern BOOLEAN ProcessCommAnimations (BOOLEAN fullRedraw, BOOLEAN paused); -void UpdateSpeechGraphics (BOOLEAN Initialize); -Task StartCommAnimTask(void); - -extern volatile BOOLEAN PauseAnimTask; - #endif /* _COMMANIM_H */ Modified: trunk/sc2/src/uqm/oscill.c =================================================================== --- trunk/sc2/src/uqm/oscill.c 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/oscill.c 2009-11-26 17:10:02 UTC (rev 3355) @@ -84,16 +84,13 @@ // draws the oscilloscope void -Oscilloscope (DWORD grab_data) +DrawOscilloscope (void) { STAMP s; if (oscillDisabled) return; - if (!grab_data) - return; - TFB_DrawImage_Image (scope_bg, 0, 0, 0, NULL, scope_surf); if (GraphForegroundStream (scope_data, RADAR_WIDTH - 2, RADAR_HEIGHT - 2)) { @@ -150,7 +147,7 @@ } void -Slider (void) +DrawSlider (void) { int offs; static int last_offs = -1; Modified: trunk/sc2/src/uqm/oscill.h =================================================================== --- trunk/sc2/src/uqm/oscill.h 2009-11-25 21:43:48 UTC (rev 3354) +++ trunk/sc2/src/uqm/oscill.h 2009-11-26 17:10:02 UTC (rev 3355) @@ -25,13 +25,13 @@ extern void InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f); -extern void Oscilloscope (DWORD grab_data); +extern void DrawOscilloscope (void); extern void UninitOscilloscope (void); extern void InitSlider (int x, int y, int width, int height, int bwidth, int bheight, FRAME f); extern void SetSliderImage (FRAME f); -void Slider (void); +void DrawSlider (void); #endif /* _OSCILL_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-28 01:53:56
|
Revision: 3356 http://sc2.svn.sourceforge.net/sc2/?rev=3356&view=rev Author: Meep-Eep Date: 2009-11-28 01:53:47 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Cleanups; separate model from view in some functions. Modified Paths: -------------- trunk/sc2/src/uqm/pickship.c trunk/sc2/src/uqm/planets/cargo.c trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/roster.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/sis.h Modified: trunk/sc2/src/uqm/pickship.c =================================================================== --- trunk/sc2/src/uqm/pickship.c 2009-11-26 17:10:02 UTC (rev 3355) +++ trunk/sc2/src/uqm/pickship.c 2009-11-28 01:53:47 UTC (rev 3356) @@ -194,7 +194,7 @@ t.pStr = GLOBAL_SIS (CommanderName); t.CharCount = (COUNT)~0; crew_level = GLOBAL_SIS (CrewEnlisted); - max_crew = GetCPodCapacity (NULL); + max_crew = GetCrewPodCapacity (); } else { Modified: trunk/sc2/src/uqm/planets/cargo.c =================================================================== --- trunk/sc2/src/uqm/planets/cargo.c 2009-11-26 17:10:02 UTC (rev 3355) +++ trunk/sc2/src/uqm/planets/cargo.c 2009-11-28 01:53:47 UTC (rev 3356) @@ -40,8 +40,7 @@ SetContextFont (TinyFont); sprintf (rt_amount_buf, "%u", - GetSBayCapacity (NULL) - - GLOBAL_SIS (TotalElementMass)); + GetStorageBayCapacity () - GLOBAL_SIS (TotalElementMass)); rt.baseline.x = 59; rt.baseline.y = 113; rt.align = ALIGN_RIGHT; Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-11-26 17:10:02 UTC (rev 3355) +++ trunk/sc2/src/uqm/planets/lander.c 2009-11-28 01:53:47 UTC (rev 3356) @@ -1917,8 +1917,7 @@ else PSD.FireChance = FireChanceTab[7]; - PSD.ElementLevel = GetSBayCapacity (NULL) - - GLOBAL_SIS (TotalElementMass); + PSD.ElementLevel = GetStorageBayCapacity () - GLOBAL_SIS (TotalElementMass); PSD.MaxElementLevel = MAX_SCROUNGED; if (GET_GAME_STATE (IMPROVED_LANDER_CARGO)) PSD.MaxElementLevel <<= 1; @@ -2127,7 +2126,7 @@ DrawStamp (&s); } - free_space = GetSBayCapacity (NULL) - GLOBAL_SIS (TotalElementMass); + free_space = GetStorageBayCapacity () - GLOBAL_SIS (TotalElementMass); if ((int)free_space < (int)(MAX_SCROUNGED << capacity_shift)) { r.corner.x = 1; Modified: trunk/sc2/src/uqm/planets/roster.c =================================================================== --- trunk/sc2/src/uqm/planets/roster.c 2009-11-26 17:10:02 UTC (rev 3355) +++ trunk/sc2/src/uqm/planets/roster.c 2009-11-28 01:53:47 UTC (rev 3356) @@ -276,7 +276,7 @@ } else if (down) { - if (GLOBAL_SIS (CrewEnlisted) < GetCPodCapacity (NULL)) + if (GLOBAL_SIS (CrewEnlisted) < GetCrewPodCapacity ()) delta = -1; else failed = TRUE; Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-26 17:10:02 UTC (rev 3355) +++ trunk/sc2/src/uqm/sis.c 2009-11-28 01:53:47 UTC (rev 3356) @@ -868,6 +868,38 @@ font_DrawText (&t); } +// Pre: GraphicsLock is unlocked +static void +DrawSupportShips (void) +{ + HSHIPFRAG hStarShip; + HSHIPFRAG hNextShip; + const POINT *pship_pos; + const POINT ship_pos[MAX_BUILT_SHIPS] = + { + SUPPORT_SHIP_PTS + }; + + for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)), + pship_pos = ship_pos; + hStarShip; hStarShip = hNextShip, ++pship_pos) + { + SHIP_FRAGMENT *StarShipPtr; + STAMP s; + + StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); + hNextShip = _GetSuccLink (StarShipPtr); + + s.origin = *pship_pos; + s.frame = StarShipPtr->icons; + LockMutex (GraphicsLock); + DrawStamp (&s); + UnlockMutex (GraphicsLock); + + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + } +} + void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta) { @@ -887,7 +919,8 @@ { COUNT i; - s.origin.x = s.origin.y = 0; + s.origin.x = 0; + s.origin.y = 0; s.frame = FlagStatFrame; DrawStamp (&s); if (optWhichFonts == OPT_PC) @@ -909,6 +942,7 @@ s.origin.y -= 3; } + s.origin.y = 0; for (i = 0; i < NUM_JET_SLOTS; ++i) { @@ -939,35 +973,9 @@ s.origin.y -= 3; } - { - HSHIPFRAG hStarShip, hNextShip; - POINT *pship_pos; - POINT ship_pos[MAX_BUILT_SHIPS] = - { - SUPPORT_SHIP_PTS - }; - - UnlockMutex (GraphicsLock); - for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)), - pship_pos = ship_pos; - hStarShip; hStarShip = hNextShip, ++pship_pos) - { - SHIP_FRAGMENT *StarShipPtr; - - StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); - hNextShip = _GetSuccLink (StarShipPtr); - - s.origin.x = pship_pos->x; - s.origin.y = pship_pos->y; - s.frame = StarShipPtr->icons; - LockMutex (GraphicsLock); - DrawStamp (&s); - UnlockMutex (GraphicsLock); - - UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); - } - LockMutex (GraphicsLock); - } + UnlockMutex (GraphicsLock); + DrawSupportShips (); + LockMutex (GraphicsLock); } t.baseline.x = STATUS_WIDTH >> 1; @@ -984,9 +992,13 @@ if (crew_delta < 0 && GLOBAL_SIS (CrewEnlisted) <= (COUNT)-crew_delta) GLOBAL_SIS (CrewEnlisted) = 0; - else if ((GLOBAL_SIS (CrewEnlisted) += crew_delta) > - (CrewCapacity = GetCPodCapacity (NULL))) - GLOBAL_SIS (CrewEnlisted) = CrewCapacity; + else + { + GLOBAL_SIS (CrewEnlisted) += crew_delta; + CrewCapacity = GetCrewPodCapacity (); + if (GLOBAL_SIS (CrewEnlisted) > CrewCapacity) + GLOBAL_SIS (CrewEnlisted) = CrewCapacity; + } } sprintf (buf, "%u", GLOBAL_SIS (CrewEnlisted)); @@ -1002,7 +1014,8 @@ if (fuel_delta != 0) { - COUNT old_coarse_fuel, new_coarse_fuel; + COUNT old_coarse_fuel; + COUNT new_coarse_fuel; if (fuel_delta == UNDEFINED_DELTA) old_coarse_fuel = (COUNT)~0; @@ -1018,7 +1031,7 @@ } else { - DWORD FuelCapacity = GetFTankCapacity (NULL); + DWORD FuelCapacity = GetFuelTankCapacity (); GLOBAL_SIS (FuelOnBoard) += fuel_delta; if (GLOBAL_SIS (FuelOnBoard) > FuelCapacity) GLOBAL_SIS (FuelOnBoard) = FuelCapacity; @@ -1079,144 +1092,324 @@ SetContext (OldContext); } + +//////////////////////////////////////////////////////////////////////////// +// Crew +//////////////////////////////////////////////////////////////////////////// + +// Get the total amount of crew aboard the SIS. COUNT GetCrewCount (void) { - return (GLOBAL_SIS (CrewEnlisted)); + return GLOBAL_SIS (CrewEnlisted); } +// Get the number of crew which fit in a module of a specified type. COUNT -GetCPodCapacity (POINT *ppt) +GetModuleCrewCapacity (BYTE moduleType) { - COORD x; - COUNT slot, capacity; + if (moduleType == CREW_POD) + return CREW_POD_CAPACITY; - x = 207; - capacity = 0; - slot = NUM_MODULE_SLOTS - 1; - do + return 0; +} + +// Gets the amount of crew which currently fit in the ship's crew pods. +COUNT +GetCrewPodCapacity (void) +{ + COUNT capacity = 0; + COUNT slotI; + + for (slotI = 0; slotI < NUM_MODULE_SLOTS; slotI++) { - if (GLOBAL_SIS (ModuleSlots[slot]) == CREW_POD) - { - if (ppt - && capacity <= GLOBAL_SIS (CrewEnlisted) - && capacity + CREW_POD_CAPACITY > - GLOBAL_SIS (CrewEnlisted)) - { - COUNT pod_remainder, which_row; - static const COLOR crew_rows[] = PC_CREW_COLOR_TABLE; + BYTE moduleType = GLOBAL_SIS (ModuleSlots[slotI]); + capacity += GetModuleCrewCapacity (moduleType); + } - pod_remainder = GLOBAL_SIS (CrewEnlisted) - capacity; + return capacity; +} - ppt->x = x - ((pod_remainder % CREW_PER_ROW) << 1); - which_row = pod_remainder / CREW_PER_ROW; - ppt->y = 34 - (which_row << 1); +// Find the slot number of the crew pod and "seat" number in that crew pod, +// where the Nth crew member would be located. +// If the crew member does not fit, false is returned, and *slotNr and +// *seatNr are unchanged. +static bool +GetCrewPodForCrewMember (COUNT crewNr, COUNT *slotNr, COUNT *seatNr) +{ + COUNT slotI; + COUNT capacity = 0; - if (optWhichFonts == OPT_PC) - SetContextForeGroundColor (crew_rows[which_row]); - else - SetContextForeGroundColor (THREEDO_CREW_COLOR); - } + slotI = NUM_MODULE_SLOTS; + while (slotI--) { + BYTE moduleType = GLOBAL_SIS (ModuleSlots[slotI]); + COUNT moduleCapacity = GetModuleCrewCapacity (moduleType); - capacity += CREW_POD_CAPACITY; + if (crewNr < capacity + moduleCapacity) + { + *slotNr = slotI; + *seatNr = crewNr - capacity; + return true; } + capacity += moduleCapacity; + } - x -= SHIP_PIECE_OFFSET; - } while (slot--); + return false; +} - return (capacity); +// Get the point where to draw the next crew member, +// set the foreground color to the color for that crew member, +// and return GetCrewPodCapacity (). +// TODO: Split of the parts of this function into separate functions. +COUNT +GetCPodCapacity (POINT *ppt) +{ + COUNT crewCount; + COUNT slotNr; + COUNT seatNr; + + COUNT rowNr; + COUNT colNr; + + static const COLOR crewRows[] = PC_CREW_COLOR_TABLE; + + crewCount = GetCrewCount (); + if (!GetCrewPodForCrewMember (crewCount, &slotNr, &seatNr)) + { + // Crew does not fit. *ppt is unchanged. + return GetCrewPodCapacity (); + } + + rowNr = seatNr / CREW_PER_ROW; + colNr = seatNr % CREW_PER_ROW; + + if (optWhichFonts == OPT_PC) + SetContextForeGroundColor (crewRows[rowNr]); + else + SetContextForeGroundColor (THREEDO_CREW_COLOR); + + ppt->x = 27 + (slotNr * SHIP_PIECE_OFFSET) - (colNr * 2); + ppt->y = 34 - (rowNr * 2); + + return GetCrewPodCapacity (); } + +//////////////////////////////////////////////////////////////////////////// +// Storage bays +//////////////////////////////////////////////////////////////////////////// + +// Get the total amount of minerals aboard the SIS. COUNT -GetSBayCapacity (POINT *ppt) +GetElementMass (void) { - COORD x; - COUNT slot, capacity; + return GLOBAL_SIS (TotalElementMass); +} - x = 207 - 8; - capacity = 0; - slot = NUM_MODULE_SLOTS - 1; - do +// Get the number of crew which fit in a module of a specified type. +COUNT +GetModuleStorageCapacity (BYTE moduleType) +{ + if (moduleType == STORAGE_BAY) + return STORAGE_BAY_CAPACITY; + + return 0; +} + +// Gets the amount of minerals which currently fit in the ship's storage. +COUNT +GetStorageBayCapacity (void) +{ + COUNT capacity = 0; + COUNT slotI; + + for (slotI = 0; slotI < NUM_MODULE_SLOTS; slotI++) { - if (GLOBAL_SIS (ModuleSlots[slot]) == STORAGE_BAY) - { - if (ppt - && capacity < GLOBAL_SIS (TotalElementMass) - && capacity + STORAGE_BAY_CAPACITY >= - GLOBAL_SIS (TotalElementMass)) - { - COUNT bay_remainder, which_row; - static const COLOR color_bars[] = STORAGE_BAY_COLOR_TABLE; + BYTE moduleType = GLOBAL_SIS (ModuleSlots[slotI]); + capacity += GetModuleStorageCapacity (moduleType); + } - bay_remainder = GLOBAL_SIS (TotalElementMass) - capacity; - which_row = bay_remainder / SBAY_MASS_PER_ROW; - if (which_row == 0) - SetContextForeGroundColor (BLACK_COLOR); - else - SetContextForeGroundColor (color_bars[--which_row]); + return capacity; +} - ppt->x = x; - ppt->y = 34 - (which_row << 1); - } +// Find the slot number of the storage bay and "storage cell" number in that +// storage bay, where the N-1th mineral unit would be located. +// If the mineral unit does not fit, false is returned, and *slotNr and +// *cellNr are unchanged. +static bool +GetStorageCellForMineralUnit (COUNT unitNr, COUNT *slotNr, COUNT *cellNr) +{ + COUNT slotI; + COUNT capacity = 0; - capacity += STORAGE_BAY_CAPACITY; + slotI = NUM_MODULE_SLOTS; + while (slotI--) { + BYTE moduleType = GLOBAL_SIS (ModuleSlots[slotI]); + COUNT moduleCapacity = GetModuleStorageCapacity (moduleType); + + if (unitNr <= capacity + moduleCapacity) + { + *slotNr = slotI; + *cellNr = unitNr - capacity; + return true; } + capacity += moduleCapacity; + } - x -= SHIP_PIECE_OFFSET; - } while (slot--); + return false; +} - return capacity; +// Get the point where to draw the next mineral unit, +// set the foreground color to the color for that mineral unit, +// and return GetStorageBayCapacity (). +// TODO: Split of the parts of this function into separate functions. +COUNT +GetSBayCapacity (POINT *ppt) +{ + COUNT massCount; + COUNT slotNr; + COUNT cellNr; + + COUNT rowNr; + COUNT colNr; + + static const COLOR colorBars[] = STORAGE_BAY_COLOR_TABLE; + + massCount = GetElementMass (); + if (!GetStorageCellForMineralUnit (massCount, &slotNr, &cellNr)) + { + // Crew does not fit. *ppt is unchanged. + return GetStorageBayCapacity (); + } + + rowNr = cellNr / SBAY_MASS_PER_ROW; + colNr = cellNr % SBAY_MASS_PER_ROW; + + if (rowNr == 0) + SetContextForeGroundColor (BLACK_COLOR); + else + { + rowNr--; + SetContextForeGroundColor (colorBars[rowNr]); + } + + ppt->x = 19 + (slotNr * SHIP_PIECE_OFFSET); + ppt->y = 34 - (rowNr * 2); + + return GetStorageBayCapacity (); } + +//////////////////////////////////////////////////////////////////////////// +// Fuel tanks +//////////////////////////////////////////////////////////////////////////// + +// Get the total amount of fuel aboard the SIS. DWORD -GetFTankCapacity (POINT *ppt) +GetFuelTotal (void) { - COORD x; - COUNT slot; - DWORD capacity; + return GLOBAL_SIS (FuelOnBoard); +} - x = 200; - capacity = FUEL_RESERVE; - slot = NUM_MODULE_SLOTS - 1; - do +// Get the amount of fuel which fits in a module of a specified type. +DWORD +GetModuleFuelCapacity (BYTE moduleType) +{ + if (moduleType == FUEL_TANK) + return FUEL_TANK_CAPACITY; + + if (moduleType == HIGHEFF_FUELSYS) + return HEFUEL_TANK_CAPACITY; + + return 0; +} + +// Gets the amount of fuel which currently fits in the ship's fuel tanks. +DWORD +GetFuelTankCapacity (void) +{ + DWORD capacity = FUEL_RESERVE; + COUNT slotI; + + for (slotI = 0; slotI < NUM_MODULE_SLOTS; slotI++) { - if (GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK - || GLOBAL_SIS (ModuleSlots[slot]) == HIGHEFF_FUELSYS) + BYTE moduleType = GLOBAL_SIS (ModuleSlots[slotI]); + capacity += GetModuleFuelCapacity (moduleType); + } + + return capacity; +} + +// Find the slot number of the fuel cell and "compartment" number in that +// crew pod, where the Nth unit of fuel would be located. +// If the unit does not fit, false is returned, and *slotNr and +// *compartmentNr are unchanged. +static bool +GetFuelTankForFuelUnit (DWORD unitNr, COUNT *slotNr, DWORD *compartmentNr) +{ + COUNT slotI; + DWORD capacity = FUEL_RESERVE; + + slotI = NUM_MODULE_SLOTS; + while (slotI--) { + BYTE moduleType = GLOBAL_SIS (ModuleSlots[slotI]); + + capacity += GetModuleFuelCapacity (moduleType); + if (unitNr < capacity) { - COUNT volume; + *slotNr = slotI; + *compartmentNr = capacity - unitNr; + return true; + } + } - volume = GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK - ? FUEL_TANK_CAPACITY : HEFUEL_TANK_CAPACITY; - if (ppt - && capacity <= GLOBAL_SIS (FuelOnBoard) - && capacity + volume > - GLOBAL_SIS (FuelOnBoard)) - { - COUNT which_row; - static const COLOR fuel_colors[] = FUEL_COLOR_TABLE; + return false; +} - which_row = (COUNT)( - (GLOBAL_SIS (FuelOnBoard) - capacity) - * MAX_FUEL_BARS / HEFUEL_TANK_CAPACITY); - ppt->x = x + 1; - if (volume == FUEL_TANK_CAPACITY) - ppt->y = 27 - which_row; - else - ppt->y = 30 - which_row; +// Get the point where to draw the next fuel unit, +// set the foreground color to the color for that unit, +// and return GetFuelTankCapacity (). +// TODO: Split of the parts of this function into separate functions. +DWORD +GetFTankCapacity (POINT *ppt) +{ + DWORD fuelAmount; + COUNT slotNr; + DWORD compartmentNr; + BYTE moduleType; + DWORD volume; - SetContextForeGroundColor (fuel_colors[which_row]); - SetContextBackGroundColor (fuel_colors[which_row + 1]); - } + COUNT rowNr; + + static const COLOR fuelColors[] = FUEL_COLOR_TABLE; - capacity += volume; - } + fuelAmount = GetFuelTotal (); + if (!GetFuelTankForFuelUnit (fuelAmount, &slotNr, &compartmentNr)) + { + // Fuel does not fit. *ppt is unchanged. + return GetFuelTankCapacity (); + } - x -= SHIP_PIECE_OFFSET; - } while (slot--); + moduleType = GLOBAL_SIS (ModuleSlots[slotNr]); + volume = GetModuleFuelCapacity (moduleType); - return capacity; + rowNr = ((volume - compartmentNr) * MAX_FUEL_BARS / HEFUEL_TANK_CAPACITY); + + ppt->x = 21 + (slotNr * SHIP_PIECE_OFFSET); + if (volume == FUEL_TANK_CAPACITY) + ppt->y = 27 - rowNr; + else + ppt->y = 30 - rowNr; + + SetContextForeGroundColor (fuelColors[rowNr]); + SetContextBackGroundColor (fuelColors[rowNr + 1]); + + return GetFuelTankCapacity (); } + +//////////////////////////////////////////////////////////////////////////// + COUNT CountSISPieces (BYTE piece_type) { Modified: trunk/sc2/src/uqm/sis.h =================================================================== --- trunk/sc2/src/uqm/sis.h 2009-11-26 17:10:02 UTC (rev 3355) +++ trunk/sc2/src/uqm/sis.h 2009-11-28 01:53:47 UTC (rev 3356) @@ -207,11 +207,19 @@ extern void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta); + extern COUNT GetCrewCount (void); +extern COUNT GetModuleCrewCapacity (BYTE moduleType); + +extern COUNT GetCrewPodCapacity (void); extern COUNT GetCPodCapacity (POINT *ppt); -extern COUNT GetLBayCapacity (POINT *ppt); + +extern COUNT GetStorageBayCapacity (void); extern COUNT GetSBayCapacity (POINT *ppt); + +extern DWORD GetFuelTankCapacity (void); extern DWORD GetFTankCapacity (POINT *ppt); + extern COUNT CountSISPieces (BYTE piece_type); extern void DrawFlagshipName (BOOLEAN InStatusArea); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-28 15:07:48
|
Revision: 3358 http://sc2.svn.sourceforge.net/sc2/?rev=3358&view=rev Author: Meep-Eep Date: 2009-11-28 15:07:38 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Get rid of one abuse of the vga palette index of a COLOR to store state. Modified Paths: -------------- trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-11-28 13:46:56 UTC (rev 3357) +++ trunk/sc2/src/uqm/element.h 2009-11-28 15:07:38 UTC (rev 3358) @@ -123,7 +123,10 @@ COUNT crew_level; COUNT hit_points; COUNT facing; /* Planetside: lava-spot direction of travel */ - COUNT cycle; /* Planetside: lightning cycle length */ + COUNT cycle; + /* Planetside: lightning cycle length + * Melee: color cycle index of ion trails and warp shadows + */ }; union { Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2009-11-28 13:46:56 UTC (rev 3357) +++ trunk/sc2/src/uqm/tactrans.c 2009-11-28 15:07:38 UTC (rev 3358) @@ -578,101 +578,101 @@ #define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) +// Called from the death_func of an element for an ion trail pixel, or a +// ship shadow (when warping in/out). void -spawn_ion_trail (ELEMENT *ElementPtr) +cycle_ion_trail (ELEMENT *ElementPtr) { - - if (ElementPtr->state_flags & PLAYER_SHIP) + static const COLOR color_tab[] = { - HELEMENT hIonElement; + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), + BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), + BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), + BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), + BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), + BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), + }; +#define NUM_TAB_COLORS (sizeof color_tab / sizeof color_tab[0]) + + assert (!(ElementPtr->state_flags & PLAYER_SHIP)); - hIonElement = AllocElement (); - if (hIonElement) - { -#define ION_LIFE 1 - COUNT angle; - RECT r; - ELEMENT *IonElementPtr; - STARSHIP *StarShipPtr; + ElementPtr->cycle++; + if (ElementPtr->cycle != NUM_TAB_COLORS) + { + ElementPtr->life_span = ElementPtr->thrust_wait; + // Reset the life span. + + SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], + color_tab[ElementPtr->cycle]); - GetElementStarShip (ElementPtr, &StarShipPtr); - angle = FACING_TO_ANGLE (StarShipPtr->ShipFacing) + HALF_CIRCLE; - GetFrameRect (StarShipPtr->RaceDescPtr->ship_data.ship[0], &r); - r.extent.height = DISPLAY_TO_WORLD (r.extent.height + r.corner.y); + ElementPtr->state_flags &= ~DISAPPEARING; + ElementPtr->state_flags |= CHANGING; + } // else, the element disappears. +} - InsertElement (hIonElement, GetHeadElement ()); - LockElement (hIonElement, &IonElementPtr); - IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM; - 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); - IonElementPtr->current.image.farray = &stars_in_space; - IonElementPtr->current.location = ElementPtr->current.location; - IonElementPtr->current.location.x += - (COORD)COSINE (angle, r.extent.height); - IonElementPtr->current.location.y += - (COORD)SINE (angle, r.extent.height); - IonElementPtr->death_func = spawn_ion_trail; +void +spawn_ion_trail (ELEMENT *ElementPtr) +{ + HELEMENT hIonElement; - SetElementStarShip (IonElementPtr, StarShipPtr); + assert (ElementPtr->state_flags & PLAYER_SHIP); - { - /* normally done during preprocess, but because - * object is being inserted at head rather than - * appended after tail it may never get preprocessed. - */ - IonElementPtr->next = IonElementPtr->current; - --IonElementPtr->life_span; - IonElementPtr->state_flags |= PRE_PROCESS; - } - - UnlockElement (hIonElement); - } - } - else + hIonElement = AllocElement (); + if (hIonElement) { - static const COLOR color_tab[] = - { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), - }; -#define NUM_TAB_COLORS (sizeof (color_tab) / sizeof (color_tab[0])) - - COUNT color_index = 0; - COLOR Color; +#define ION_LIFE 1 + COUNT angle; + RECT r; + ELEMENT *IonElementPtr; + STARSHIP *StarShipPtr; - Color = COLOR_256 (GetPrimColor (&DisplayArray[ElementPtr->PrimIndex])); - if (Color != 0x2F) + GetElementStarShip (ElementPtr, &StarShipPtr); + angle = FACING_TO_ANGLE (StarShipPtr->ShipFacing) + HALF_CIRCLE; + GetFrameRect (StarShipPtr->RaceDescPtr->ship_data.ship[0], &r); + r.extent.height = DISPLAY_TO_WORLD (r.extent.height + r.corner.y); + + InsertElement (hIonElement, GetHeadElement ()); + LockElement (hIonElement, &IonElementPtr); + IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM; + IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; + IonElementPtr->thrust_wait = ION_LIFE; + IonElementPtr->life_span = IonElementPtr->thrust_wait; + // When the element "dies", in the death_func + // 'cycle_ion_trail', it is given new life a number of + // times, by setting life_span to thrust_wait. + SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM); + SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex], + START_ION_COLOR); + IonElementPtr->cycle = 0; + 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 += + (COORD)COSINE (angle, r.extent.height); + IonElementPtr->current.location.y += + (COORD)SINE (angle, r.extent.height); + IonElementPtr->death_func = cycle_ion_trail; + + SetElementStarShip (IonElementPtr, StarShipPtr); + { - ElementPtr->life_span = ElementPtr->thrust_wait; - - ++Color; - if (Color > 0x7F) - Color = 0x2A; - if (Color <= 0x2f && 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]); + /* normally done during preprocess, but because + * object is being inserted at head rather than + * appended after tail it may never get preprocessed. + */ + IonElementPtr->next = IonElementPtr->current; + --IonElementPtr->life_span; + IonElementPtr->state_flags |= PRE_PROCESS; + } - ElementPtr->state_flags &= ~DISAPPEARING; - ElementPtr->state_flags |= CHANGING; - } + UnlockElement (hIonElement); } } @@ -743,12 +743,16 @@ LockElement (hShipImage, &ShipImagePtr); ShipImagePtr->playerNr = NEUTRAL_PLAYER_NUM; ShipImagePtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; - ShipImagePtr->life_span = ShipImagePtr->thrust_wait = - TRANSITION_LIFE; + ShipImagePtr->thrust_wait = TRANSITION_LIFE; + ShipImagePtr->life_span = ShipImagePtr->thrust_wait; + // When the element "dies", in the death_func + // 'cycle_ion_trail', it is given new life a number of + // times, by setting life_span to thrust_wait. SetPrimType (&DisplayArray[ShipImagePtr->PrimIndex], STAMPFILL_PRIM); SetPrimColor (&DisplayArray[ShipImagePtr->PrimIndex], START_ION_COLOR); + ShipImagePtr->cycle = 0; ShipImagePtr->current.image = ElementPtr->current.image; ShipImagePtr->current.location = ElementPtr->current.location; if (!(ElementPtr->state_flags & PLAYER_SHIP)) @@ -774,7 +778,7 @@ WRAP_Y (ShipImagePtr->current.location.y); } ShipImagePtr->preprocess_func = ship_transition; - ShipImagePtr->death_func = spawn_ion_trail; + ShipImagePtr->death_func = cycle_ion_trail; SetElementStarShip (ShipImagePtr, StarShipPtr); UnlockElement (hShipImage); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-28 16:23:45
|
Revision: 3359 http://sc2.svn.sourceforge.net/sc2/?rev=3359&view=rev Author: Meep-Eep Date: 2009-11-28 16:23:36 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Remove another dependency on the VGA register field in a COLOR. Modified Paths: -------------- trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2009-11-28 15:07:38 UTC (rev 3358) +++ trunk/sc2/src/uqm/battle.c 2009-11-28 16:23:36 UTC (rev 3359) @@ -88,7 +88,8 @@ battle_counter[0]--; ElementPtr->turn_wait = 3; - ElementPtr->thrust_wait = MAKE_BYTE (4, 0); + ElementPtr->thrust_wait = 4; + ElementPtr->colorCycleIndex = 0; ElementPtr->preprocess_func = flee_preprocess; ElementPtr->mass_points = MAX_SHIP_MASS * 10; ZeroVelocityComponents (&ElementPtr->velocity); @@ -97,6 +98,9 @@ SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E)); + // XXX: I think this is supposed to be the same as the + // first entry of the color cycle table in flee_preeprocess, + // but it is slightly different (0x0A as red value). - SvdB. SetPrimType (&DisplayArray[ElementPtr->PrimIndex], STAMPFILL_PRIM); StarShipPtr->ship_input_state = 0; Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-11-28 15:07:38 UTC (rev 3358) +++ trunk/sc2/src/uqm/element.h 2009-11-28 16:23:36 UTC (rev 3359) @@ -124,9 +124,7 @@ COUNT hit_points; COUNT facing; /* Planetside: lava-spot direction of travel */ COUNT cycle; - /* Planetside: lightning cycle length - * Melee: color cycle index of ion trails and warp shadows - */ + /* Planetside: lightning cycle length */ }; union { @@ -145,6 +143,9 @@ BYTE blast_offset; BYTE next_turn; /* Battle: animation interframe for some elements */ }; + BYTE colorCycleIndex; + // Melee: used to cycle ion trails and warp shadows, and + // to cycle the ship color when fleeing. VELOCITY_DESC velocity; INTERSECT_CONTROL IntersectControl; Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2009-11-28 15:07:38 UTC (rev 3358) +++ trunk/sc2/src/uqm/tactrans.c 2009-11-28 16:23:36 UTC (rev 3359) @@ -583,7 +583,7 @@ void cycle_ion_trail (ELEMENT *ElementPtr) { - static const COLOR color_tab[] = + static const COLOR colorTab[] = { BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), @@ -598,18 +598,18 @@ BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), }; -#define NUM_TAB_COLORS (sizeof color_tab / sizeof color_tab[0]) + const size_t colorTabCount = sizeof colorTab / sizeof colorTab[0]; assert (!(ElementPtr->state_flags & PLAYER_SHIP)); - ElementPtr->cycle++; - if (ElementPtr->cycle != NUM_TAB_COLORS) + ElementPtr->colorCycleIndex++; + if (ElementPtr->colorCycleIndex != colorTabCount) { ElementPtr->life_span = ElementPtr->thrust_wait; // Reset the life span. SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], - color_tab[ElementPtr->cycle]); + colorTab[ElementPtr->colorCycleIndex]); ElementPtr->state_flags &= ~DISAPPEARING; ElementPtr->state_flags |= CHANGING; @@ -649,7 +649,7 @@ SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM); SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex], START_ION_COLOR); - IonElementPtr->cycle = 0; + IonElementPtr->colorCycleIndex = 0; IonElementPtr->current.image.frame = DecFrameIndex (stars_in_space); IonElementPtr->current.image.farray = &stars_in_space; @@ -752,7 +752,7 @@ STAMPFILL_PRIM); SetPrimColor (&DisplayArray[ShipImagePtr->PrimIndex], START_ION_COLOR); - ShipImagePtr->cycle = 0; + ShipImagePtr->colorCycleIndex = 0; ShipImagePtr->current.image = ElementPtr->current.image; ShipImagePtr->current.location = ElementPtr->current.location; if (!(ElementPtr->state_flags & PLAYER_SHIP)) @@ -795,10 +795,18 @@ if (--ElementPtr->turn_wait == 0) { - SIZE dir; - COLOR c; - static const COLOR color_tab[] = + static const COLOR colorTab[] = { + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x00, 0x00), 0x2E), + BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), + BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x29), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x04, 0x04), 0x28), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x27), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0F, 0x0F), 0x26), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x13, 0x13), 0x25), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x19, 0x19), 0x24), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x13, 0x13), 0x25), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0F, 0x0F), 0x26), @@ -809,34 +817,26 @@ BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x00, 0x00), 0x2E), }; + const size_t colorTabCount = sizeof colorTab / sizeof colorTab[0]; - dir = HINIBBLE (ElementPtr->thrust_wait) - 1; + ElementPtr->colorCycleIndex++; + if (ElementPtr->colorCycleIndex == colorTabCount) + ElementPtr->colorCycleIndex = 0; - c = COLOR_256 (GetPrimColor (&DisplayArray[ElementPtr->PrimIndex])); - if (c == 0x24) - dir = -dir; - c += dir; - c = color_tab[c - 0x24]; - SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], c); + SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], + colorTab[ElementPtr->colorCycleIndex]); - if (COLOR_256 (c) == 0x2E) - { - dir = -dir; + if (ElementPtr->colorCycleIndex == 0) --ElementPtr->thrust_wait; - } - dir += 1; - ElementPtr->turn_wait = LONIBBLE (ElementPtr->thrust_wait); + ElementPtr->turn_wait = ElementPtr->thrust_wait; if (ElementPtr->turn_wait) { - ElementPtr->thrust_wait = MAKE_BYTE (ElementPtr->turn_wait, dir); ElementPtr->turn_wait = ((ElementPtr->turn_wait - 1) >> 1) + 1; } - else if (COLOR_256 (c) != 0x24) + else if (ElementPtr->colorCycleIndex != (colorTabCount / 2)) { - ElementPtr->thrust_wait = MAKE_BYTE (0, dir); ElementPtr->turn_wait = 1; } else @@ -853,7 +853,8 @@ } GetElementStarShip (ElementPtr, &StarShipPtr); - StarShipPtr->cur_status_flags - &= ~(LEFT | RIGHT | THRUST | WEAPON | SPECIAL); + StarShipPtr->cur_status_flags &= + ~(LEFT | RIGHT | THRUST | WEAPON | SPECIAL); + // Ignore control input when fleeing. PreProcessStatus (ElementPtr); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-28 20:03:12
|
Revision: 3364 http://sc2.svn.sourceforge.net/sc2/?rev=3364&view=rev Author: Meep-Eep Date: 2009-11-28 20:03:05 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Removed another dependency on the VGA register byte in COLOR. Modified Paths: -------------- trunk/sc2/src/uqm/ship.c trunk/sc2/src/uqm/ships/utwig/utwig.c Modified: trunk/sc2/src/uqm/ship.c =================================================================== --- trunk/sc2/src/uqm/ship.c 2009-11-28 19:44:10 UTC (rev 3363) +++ trunk/sc2/src/uqm/ship.c 2009-11-28 20:03:05 UTC (rev 3364) @@ -431,6 +431,7 @@ ShipElementPtr->turn_wait = 0; ShipElementPtr->thrust_wait = 0; ShipElementPtr->life_span = NORMAL_LIFE; + ShipElementPtr->colorCycleIndex = 0; SetPrimType (&DisplayArray[ShipElementPtr->PrimIndex], STAMP_PRIM); ShipElementPtr->current.image.farray = RDPtr->ship_data.ship; Modified: trunk/sc2/src/uqm/ships/utwig/utwig.c =================================================================== --- trunk/sc2/src/uqm/ships/utwig/utwig.c 2009-11-28 19:44:10 UTC (rev 3363) +++ trunk/sc2/src/uqm/ships/utwig/utwig.c 2009-11-28 20:03:05 UTC (rev 3364) @@ -285,7 +285,8 @@ ElementPtr->life_span - (NORMAL_LIFE + 1)); ProcessSound (SetAbsSoundIndex ( - StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), ElementPtr); + StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), + ElementPtr); } if (!(StarShipPtr->cur_status_flags & SPECIAL)) @@ -300,62 +301,60 @@ StarShipPtr->special_counter = StarShipPtr->RaceDescPtr->characteristics.special_wait; ProcessSound (SetAbsSoundIndex ( - StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 2), ElementPtr); + StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 2), + ElementPtr); } } lpPrim = &(GLOBAL (DisplayArray))[ElementPtr->PrimIndex]; if (StarShipPtr->special_counter == 0) { - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78)); + // The shield is off. + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78)); + ElementPtr->colorCycleIndex = 0; ElementPtr->life_span = NORMAL_LIFE; SetPrimType (lpPrim, STAMP_PRIM); } else { - static const COLOR color_tab[] = + // The shield is on. + + /* Originally, this table also contained the now commented out + * entries. It then used some if statements to skip over these. + * The current behaviour is the same as the old behavior, + * but I am not sure that the old behavior was intended. - SvdB + */ + static const COLOR colorTable[] = { + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), + //BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), + //BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), }; - -#define NUM_TAB_COLORS (sizeof (color_tab) / sizeof (color_tab[0])) - - COUNT color_index = 0; - COLOR c; + const size_t colorTableCount = + sizeof colorTable / sizeof colorTable[0]; if (StarShipPtr->weapon_counter == 0) ++StarShipPtr->weapon_counter; - c = COLOR_256 (GetPrimColor (lpPrim)); - if (c >= 0x78) - { - if ((c += 2) > 0x7E) - c = 0x2A; - } - else if (c < 0x2E) - { - if (++c == 0x2B) - c = 0x2C; - } - else - c = 0x7a; - if (c <= 0x2f && c >= 0x2a) - color_index = (COUNT)c - 0x2a; - else /* color is between 0x7a and 0x7f */ - color_index = (COUNT)(c - 0x7a) + (NUM_TAB_COLORS >> 1); - SetPrimColor (lpPrim, color_tab[color_index]); + // colorCycleIndex is actually 1 higher than the entry in colorTable + // which is currently used, as it is 0 when the shield is off, + // and we don't want to skip over the first entry of the table. + ElementPtr->colorCycleIndex++; + if (ElementPtr->colorCycleIndex == colorTableCount + 1) + ElementPtr->colorCycleIndex = 1; + SetPrimColor (lpPrim, colorTable[ElementPtr->colorCycleIndex - 1]); + ElementPtr->life_span = NORMAL_LIFE + 1; SetPrimType (lpPrim, STAMPFILL_PRIM); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-28 20:43:15
|
Revision: 3365 http://sc2.svn.sourceforge.net/sc2/?rev=3365&view=rev Author: Meep-Eep Date: 2009-11-28 20:43:08 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Remove another dependency on the VGA palette index in COLOR. Modified Paths: -------------- trunk/sc2/src/uqm/ships/orz/orz.c trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/src/uqm/ships/orz/orz.c =================================================================== --- trunk/sc2/src/uqm/ships/orz/orz.c 2009-11-28 20:03:05 UTC (rev 3364) +++ trunk/sc2/src/uqm/ships/orz/orz.c 2009-11-28 20:43:08 UTC (rev 3365) @@ -311,46 +311,38 @@ #define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) -void +static void ion_preprocess (ELEMENT *ElementPtr) { - static const COLOR color_tab[] = + /* Originally, this table also contained the now commented out + * entries. It then used some if statements to skip over these. + * The current behaviour is the same as the old behavior. + */ + static const COLOR colorTable[] = { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), + + //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), + BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), + //BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), + BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), + //BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), + //BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), }; -#define NUM_TAB_COLORS (sizeof (color_tab) / sizeof (color_tab[0])) - - COUNT color_index = 0; - COLOR Color; + const size_t colorTabCount = sizeof colorTable / sizeof colorTable[0]; - Color = COLOR_256 (GetPrimColor (&(GLOBAL (DisplayArray))[ - ElementPtr->PrimIndex])); - if (Color != 0x2D) + ElementPtr->colorCycleIndex++; + if (ElementPtr->colorCycleIndex != colorTabCount) { ElementPtr->life_span = ElementPtr->thrust_wait; - Color += 2; - if (Color > 0x7F) - Color = 0x2B; - else if (Color == 0x7E) - Color = 0x7F; - if (Color <= 0x2f && Color >= 0x2a) - color_index = (COUNT)Color - 0x2a; - else /* color is between 0x7a and 0x7f */ - color_index = (COUNT)(Color - 0x7a) + (NUM_TAB_COLORS >> 1); - SetPrimColor (&(GLOBAL (DisplayArray))[ - ElementPtr->PrimIndex], color_tab[color_index]); + SetPrimColor (&(GLOBAL (DisplayArray))[ElementPtr->PrimIndex], + colorTable[ElementPtr->colorCycleIndex]); ElementPtr->state_flags &= ~DISAPPEARING; ElementPtr->state_flags |= CHANGING; @@ -472,7 +464,60 @@ } } +// XXX: merge this with spawn_ion_trail from tactrans.c? static void +spawn_marine_ion_trail (ELEMENT *ElementPtr, STARSHIP *StarShipPtr, + COUNT facing) +{ + HELEMENT hIonElement; + + hIonElement = AllocElement (); + if (hIonElement) + { +#define ION_LIFE 1 + COUNT angle; + ELEMENT *IonElementPtr; + + angle = FACING_TO_ANGLE (facing) + HALF_CIRCLE; + + InsertElement (hIonElement, GetHeadElement ()); + LockElement (hIonElement, &IonElementPtr); + IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM; + IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; + IonElementPtr->thrust_wait = ION_LIFE; + IonElementPtr->life_span = IonElementPtr->thrust_wait; + // When the element "dies", in the death_func + // 'cycle_ion_trail', it is given new life a number of + // times, by setting life_span to thrust_wait. + SetPrimType (&(GLOBAL (DisplayArray))[IonElementPtr->PrimIndex], + POINT_PRIM); + SetPrimColor (&(GLOBAL (DisplayArray))[IonElementPtr->PrimIndex], + START_ION_COLOR); + IonElementPtr->colorCycleIndex = 0; + IonElementPtr->current.location = ElementPtr->current.location; + IonElementPtr->current.location.x += + (COORD)COSINE (angle, DISPLAY_TO_WORLD (2)); + IonElementPtr->current.location.y += + (COORD)SINE (angle, DISPLAY_TO_WORLD (2)); + IonElementPtr->death_func = ion_preprocess; + + SetElementStarShip (IonElementPtr, StarShipPtr); + + { + /* normally done during preprocess, but because + * object is being inserted at head rather than + * appended after tail it may never get preprocessed. + */ + IonElementPtr->next = IonElementPtr->current; + --IonElementPtr->life_span; + IonElementPtr->state_flags |= PRE_PROCESS; + } + + UnlockElement (hIonElement); + } +} + +static void marine_preprocess (ELEMENT *ElementPtr) { ELEMENT *ShipPtr; @@ -668,50 +713,7 @@ || !(thrust_status & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED))) { - HELEMENT hIonElement; - - hIonElement = AllocElement (); - if (hIonElement) - { -#define ION_LIFE 1 - COUNT angle; - ELEMENT *IonElementPtr; - - angle = FACING_TO_ANGLE (facing) + HALF_CIRCLE; - - InsertElement (hIonElement, GetHeadElement ()); - LockElement (hIonElement, &IonElementPtr); - IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM; - IonElementPtr->state_flags = - APPEARING | FINITE_LIFE | NONSOLID; - IonElementPtr->life_span = - IonElementPtr->thrust_wait = ION_LIFE; - SetPrimType (&(GLOBAL (DisplayArray))[ - IonElementPtr->PrimIndex], POINT_PRIM); - SetPrimColor (&(GLOBAL (DisplayArray))[ - IonElementPtr->PrimIndex], START_ION_COLOR); - IonElementPtr->current.location = - ElementPtr->current.location; - IonElementPtr->current.location.x += - (COORD)COSINE (angle, DISPLAY_TO_WORLD (2)); - IonElementPtr->current.location.y += - (COORD)SINE (angle, DISPLAY_TO_WORLD (2)); - IonElementPtr->death_func = ion_preprocess; - - SetElementStarShip (IonElementPtr, StarShipPtr); - - { - /* normally done during preprocess, but because - * object is being inserted at head rather than - * appended after tail it may never get preprocessed. - */ - IonElementPtr->next = IonElementPtr->current; - --IonElementPtr->life_span; - IonElementPtr->state_flags |= PRE_PROCESS; - } - - UnlockElement (hIonElement); - } + spawn_marine_ion_trail (ElementPtr, StarShipPtr, facing); } // XXX: thrust_wait is abused to store marine speed and @@ -1041,9 +1043,10 @@ TurretPtr->playerNr = ElementPtr->playerNr; TurretPtr->state_flags = FINITE_LIFE | NONSOLID | IGNORE_SIMILAR; TurretPtr->life_span = 1; - TurretPtr->current.image.farray = StarShipPtr->RaceDescPtr->ship_data.special; - TurretPtr->current.image.frame = - SetAbsFrameIndex (StarShipPtr->RaceDescPtr->ship_data.special[0], + TurretPtr->current.image.farray = + StarShipPtr->RaceDescPtr->ship_data.special; + TurretPtr->current.image.frame = SetAbsFrameIndex ( + StarShipPtr->RaceDescPtr->ship_data.special[0], StarShipPtr->ShipFacing); TurretPtr->postprocess_func = turret_postprocess; Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2009-11-28 20:03:05 UTC (rev 3364) +++ trunk/sc2/src/uqm/tactrans.c 2009-11-28 20:43:08 UTC (rev 3365) @@ -663,10 +663,10 @@ SetElementStarShip (IonElementPtr, StarShipPtr); { - /* normally done during preprocess, but because - * object is being inserted at head rather than - * appended after tail it may never get preprocessed. - */ + /* normally done during preprocess, but because + * object is being inserted at head rather than + * appended after tail it may never get preprocessed. + */ IonElementPtr->next = IonElementPtr->current; --IonElementPtr->life_span; IonElementPtr->state_flags |= PRE_PROCESS; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-30 21:57:23
|
Revision: 3378 http://sc2.svn.sourceforge.net/sc2/?rev=3378&view=rev Author: avolkov Date: 2009-11-30 21:57:13 +0000 (Mon, 30 Nov 2009) Log Message: ----------- Split DoFlagshipCommands() into separate menu functions for IP, Orbital and Hyperspace; this allowed for some solarsys and manifest menu cleanups; temporary pBaseDesc setups removed; some invariant tests removed; some code moved around to more appropriate places Modified Paths: -------------- trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/ipdisp.c trunk/sc2/src/uqm/outfit.c trunk/sc2/src/uqm/planets/cargo.c trunk/sc2/src/uqm/planets/devices.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/pstarmap.c trunk/sc2/src/uqm/planets/roster.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/scan.h trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/shipcont.h trunk/sc2/src/uqm/shipyard.c trunk/sc2/src/uqm/starcon.c trunk/sc2/src/uqm/uqmdebug.c Modified: trunk/sc2/src/uqm/encount.c =================================================================== --- trunk/sc2/src/uqm/encount.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/encount.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -73,15 +73,14 @@ pMS->CurState = HAIL; return (FALSE); case ATTACK + 1: - pMS->Initialized = GameOptions (); - if (pMS->Initialized) - { - DrawMenuStateStrings (PM_CONVERSE, pMS->CurState); - LockMutex (GraphicsLock); - SetFlashRect (SFR_MENU_3DO); - UnlockMutex (GraphicsLock); - } - return ((BOOLEAN)pMS->Initialized); + // Clearing FlashRect is not necessary + if (!GameOptions ()) + return FALSE; + DrawMenuStateStrings (PM_CONVERSE, pMS->CurState); + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + break; default: printf ("Unknown option: %d\n", pMS->CurState); } Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/gameinp.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -24,7 +24,6 @@ #ifdef NETPLAY # include "netplay/netmelee.h" #endif -#include "planets/planets.h" #include "settings.h" #include "sounds.h" #include "tactrans.h" @@ -377,16 +376,7 @@ soundFlags = MenuKeysToSoundFlags (&PulsedInputState); - if (MenuSounds - && (pSolarSysState == 0 - /* see if in menu */ - || pSolarSysState->MenuState.CurState - || pSolarSysState->MenuState.Initialized > 2) - && (soundFlags & (sound_0 | sound_1)) -#ifdef NEVER - && !PLRPlaying ((MUSIC_REF)~0) -#endif /* NEVER */ - ) + if (MenuSounds && (soundFlags & (sound_0 | sound_1))) { SOUND S; Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/gameopt.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -238,8 +238,6 @@ if (!(state & DDSHS_EDIT)) { // normal state - SetFlashRect (SFR_MENU_3DO); - if (pMS->CurState == CHANGE_CAPTAIN_SETTING) DrawCaptainsName (); else @@ -327,6 +325,10 @@ pMS->Initialized = TRUE; pMS->InputFunc = DoNaming; + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + DrawDescriptionString (pMS, buf, 0, DDSHS_EDIT); LockMutex (GraphicsLock); @@ -357,6 +359,11 @@ utf8StringCopy (Setting, tes.MaxSize, buf); else utf8StringCopy (buf, sizeof (buf), Setting); + + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + DrawDescriptionString (pMS, buf, 0, DDSHS_NORMAL); if (namingCB) @@ -837,11 +844,12 @@ return (FALSE); } - first_time = (BOOLEAN)(pMS->Initialized == 0); + first_time = !pMS->Initialized; SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); if (!pMS->Initialized) { + // XXX: Save DoGameOptions() state pMS->delta_item = (SIZE)pMS->CurState; pMS->CurState = NewState = prev_save; pMS->InputFunc = DoPickGame; @@ -863,10 +871,8 @@ } else if (PulsedInputState.menu[KEY_MENU_CANCEL]) { - LockMutex (GraphicsLock); - SetFlashRect (SFR_MENU_3DO); - UnlockMutex (GraphicsLock); pMS->ModuleFrame = 0; + // XXX: Restore DoGameOptions() state pMS->CurState = (BYTE)pMS->delta_item; ResumeMusic (); if (LastActivity == CHECK_LOAD) @@ -894,7 +900,6 @@ } else { - SetFlashRect (NULL); DrawStamp (&MsgStamp); DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); UnlockMutex (GraphicsLock); @@ -916,10 +921,10 @@ if (LoadGame ((COUNT)pMS->CurState, NULL)) GLOBAL (CurrentActivity) |= CHECK_LOAD; } - SetFlashRect (NULL); UnlockMutex (GraphicsLock); pMS->ModuleFrame = 0; + // XXX: Restore DoGameOptions() state pMS->CurState = (BYTE)pMS->delta_item; return (FALSE); } @@ -1076,7 +1081,6 @@ } UnbatchGraphics (); } - SetFlashRect (NULL); UnlockMutex (GraphicsLock); } @@ -1125,7 +1129,7 @@ DoInput (pMS, TRUE); LockMutex (GraphicsLock); - pMS->Initialized = -1; + pMS->Initialized = FALSE; pMS->InputFunc = DoGameOptions; retval = TRUE; @@ -1169,13 +1173,13 @@ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - if (pMS->Initialized <= 0) + if (!pMS->Initialized) { if (LastActivity == CHECK_LOAD) pMS->CurState = LOAD_GAME; DrawMenuStateStrings (PM_SAVE_GAME, pMS->CurState); - pMS->Initialized = 1; + pMS->Initialized = TRUE; pMS->InputFunc = DoGameOptions; } else if (PulsedInputState.menu[KEY_MENU_CANCEL] @@ -1191,7 +1195,15 @@ { case SAVE_GAME: case LOAD_GAME: - return PickGame (pMS); + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + if (!PickGame (pMS)) + return FALSE; + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + break; case QUIT_GAME: if (ConfirmExit ()) return FALSE; @@ -1220,9 +1232,18 @@ MenuState.InputFunc = DoGameOptions; MenuState.CurState = SAVE_GAME; + + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); DoInput (&MenuState, TRUE); + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + pLocMenuState = 0; return ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) ? FALSE : TRUE); Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/hyper.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -22,10 +22,12 @@ #include "collide.h" #include "colors.h" #include "controls.h" +#include "gameopt.h" #include "menustat.h" // for DrawMenuStateStrings() #include "encount.h" #include "ship.h" +#include "shipcont.h" #include "process.h" #include "globdata.h" #include "sis.h" @@ -35,11 +37,11 @@ #include "resinst.h" #include "setup.h" #include "sounds.h" +#include "options.h" #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" - #define XOFFS ((RADAR_SCAN_WIDTH + (UNIT_SCREEN_WIDTH << 2)) >> 1) #define YOFFS ((RADAR_SCAN_HEIGHT + (UNIT_SCREEN_HEIGHT << 2)) >> 1) @@ -1598,6 +1600,74 @@ } } +static BOOLEAN +DoHyperspaceMenu (MENU_STATE *pMS) +{ + BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT]; + BOOLEAN handled; + + if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) + || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0) + return FALSE; + + handled = DoMenuChooser (pMS, PM_STARMAP); + if (handled) + return TRUE; + + if (!select) + return TRUE; + + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + + switch (pMS->CurState) + { + case EQUIP_DEVICE: + select = DevicesMenu (); + if (GET_GAME_STATE (PORTAL_COUNTER)) + { // A player-induced portal to QuasiSpace is opening + return FALSE; + } + if (GLOBAL (CurrentActivity) & START_ENCOUNTER) + { // Selected Talking Pet, going into conversation + return FALSE; + } + break; + case CARGO: + CargoMenu (); + break; + case ROSTER: + select = RosterMenu (); + break; + case GAME_MENU: + if (!GameOptions ()) + return FALSE; // abort or load + break; + case STARMAP: + StarMap (); + SetDefaultMenuRepeatDelay (); + return FALSE; + case NAVIGATION: + return FALSE; + } + + if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) + { + if (select) + { // 3DO menu jumps to NAVIGATE after a successful submenu run + if (optWhichMenu != OPT_PC) + pMS->CurState = NAVIGATION; + DrawMenuStateStrings (PM_STARMAP, pMS->CurState); + } + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + } + + return TRUE; +} + void HyperspaceMenu (void) { @@ -1613,9 +1683,9 @@ UnlockMutex (GraphicsLock); memset (&MenuState, 0, sizeof (MenuState)); - MenuState.InputFunc = DoFlagshipCommands; - MenuState.Initialized = 1; - MenuState.CurState = STARMAP + 1; + MenuState.InputFunc = DoHyperspaceMenu; + MenuState.Initialized = TRUE; + MenuState.CurState = STARMAP; DrawMenuStateStrings (PM_STARMAP, STARMAP); LockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/ipdisp.c =================================================================== --- trunk/sc2/src/uqm/ipdisp.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/ipdisp.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -144,8 +144,6 @@ - pSolarSysState->PlanetDesc + 1); task = GroupPtr->task; - if (pSolarSysState->MenuState.CurState) - goto ExitIPProcess; if ((task & REFORM_GROUP) && --GroupPtr->group_counter == 0) { // Finished reforming the group @@ -471,7 +469,6 @@ + (SIZE)((long)GroupPtr->loc.y * (DISPLAY_FACTOR >> 1) / radius); -ExitIPProcess: EPtr->next.location.x = DISPLAY_TO_WORLD (dest_pt.x) + (COORD)(LOG_SPACE_WIDTH >> 1) - (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1)); @@ -672,7 +669,6 @@ ElementPtr->thrust_wait = FLIP_WAIT; } - if (pSolarSysState->MenuState.CurState == 0) { BYTE flagship_loc, ec; SIZE vdx, vdy, radius; Modified: trunk/sc2/src/uqm/outfit.c =================================================================== --- trunk/sc2/src/uqm/outfit.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/outfit.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -800,7 +800,8 @@ DoInstallModule (pMS); break; case OUTFIT_SAVELOAD: - if (GameOptions () == 0) + // Clearing FlashRect is not necessary + if (!GameOptions ()) goto ExitOutfit; DrawMenuStateStrings (PM_FUEL, pMS->CurState); LockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/planets/cargo.c =================================================================== --- trunk/sc2/src/uqm/planets/cargo.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/cargo.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -303,10 +303,10 @@ if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); - if (!(pMS->Initialized & 1)) + if (!pMS->Initialized) { pMS->InputFunc = DoDiscardCargo; - ++pMS->Initialized; + pMS->Initialized = TRUE; NewState = pMS->CurState; pMS->CurState = (BYTE)~0; @@ -372,16 +372,18 @@ } void -Cargo (MENU_STATE *pMS) +CargoMenu (void) { - pMS->InputFunc = DoDiscardCargo; - --pMS->Initialized; - pMS->CurState = 1; + // XXX: Should get an own STATE struct + MENU_STATE MenuState; + MenuState.InputFunc = DoDiscardCargo; + MenuState.Initialized = FALSE; + // XXX: 1-based index because this had to work around the + // pSolarSysState->MenuState.CurState abuse. Should be changed. + MenuState.CurState = 1; + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - DoInput (pMS, TRUE); - - pMS->InputFunc = DoFlagshipCommands; - pMS->CurState = CARGO + 1; + DoInput (&MenuState, TRUE); } Modified: trunk/sc2/src/uqm/planets/devices.c =================================================================== --- trunk/sc2/src/uqm/planets/devices.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/devices.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -460,12 +460,12 @@ if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); - if (!(pMS->Initialized & 1)) + if (!pMS->Initialized) { DrawDevices (pMS, (BYTE)~0, (BYTE)~0); pMS->InputFunc = DoManipulateDevices; - ++pMS->Initialized; + pMS->Initialized = TRUE; NewState = pMS->CurState; goto SelectDevice; } @@ -640,28 +640,29 @@ } BOOLEAN -Devices (MENU_STATE *pMS) +DevicesMenu (void) { BYTE DeviceMap[NUM_DEVICES]; + MENU_STATE MenuState; - pMS->first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES); - if (pMS->first_item.x) + memset (&MenuState, 0, sizeof MenuState); + + MenuState.first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES); + if (MenuState.first_item.x) { - pMS->InputFunc = DoManipulateDevices; - --pMS->Initialized; - pMS->CurState = 1; - pMS->first_item.y = 0; + MenuState.InputFunc = DoManipulateDevices; + MenuState.Initialized = FALSE; + // XXX: 1-based index because this had to work around the + // pSolarSysState->MenuState.CurState abuse. Should be changed. + MenuState.CurState = 1; + MenuState.first_item.y = 0; - pMS->CurFrame = (FRAME)DeviceMap; - FlushInput (); - DoManipulateDevices (pMS); /* to make sure it's initialized */ + // XXX: CurFrame hack + MenuState.CurFrame = (FRAME)DeviceMap; + //DoManipulateDevices (pMS); /* to make sure it's initialized */ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - DoInput (pMS, TRUE); - pMS->CurFrame = 0; + DoInput (&MenuState, TRUE); - pMS->InputFunc = DoFlagshipCommands; - pMS->CurState = EQUIP_DEVICE + 1; - if (GLOBAL_SIS (CrewEnlisted) != (COUNT)~0 && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/planets.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -23,10 +23,15 @@ #include "../colors.h" #include "../element.h" #include "../settings.h" +#include "../controls.h" +#include "../sounds.h" +#include "../gameopt.h" +#include "../shipcont.h" #include "../setup.h" #include "../uqmdebug.h" #include "../resinst.h" #include "../nameref.h" +#include "options.h" #include "libs/graphics/gfx_common.h" @@ -295,3 +300,119 @@ DestroyDrawable (ReleaseDrawable (info->LanderFontEff)); info->LanderFontEff = NULL; } + +static BOOLEAN +DoPlanetOrbit (MENU_STATE *pMS) +{ + BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT]; + BOOLEAN handled; + + if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) + || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0) + return FALSE; + + // XXX: pMS actually refers to pSolarSysState->MenuState + handled = DoMenuChooser (pMS, PM_SCAN); + if (handled) + return TRUE; + + if (!select) + return TRUE; + + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + + switch (pMS->CurState) + { + case SCAN: + ScanSystem (); + break; + case EQUIP_DEVICE: + select = DevicesMenu (); + if (GLOBAL (CurrentActivity) & START_ENCOUNTER) + { // Invoked Talking Pet, a Caster or Sun Device over Chmmr, + // or a Caster for Ilwrath + // Going into conversation + return FALSE; + } + break; + case CARGO: + CargoMenu (); + break; + case ROSTER: + select = RosterMenu (); + break; + case GAME_MENU: + if (!GameOptions ()) + return FALSE; // abort or load + break; + case STARMAP: + { + BOOLEAN AutoPilotSet; + + LockMutex (GraphicsLock); + pSolarSysState->PauseRotate = 1; + RepairSISBorder (); + UnlockMutex (GraphicsLock); + TaskSwitch (); + + AutoPilotSet = StarMap (); + SetDefaultMenuRepeatDelay (); + + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + return FALSE; + + if (!AutoPilotSet) + { // Redraw the orbital display + LoadPlanet (NULL); + LockMutex (GraphicsLock); + pSolarSysState->PauseRotate = 0; + UnlockMutex (GraphicsLock); + break; + } + // Fall through !!! + } + case NAVIGATION: + return FALSE; + } + + if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) + { + if (select) + { // 3DO menu jumps to NAVIGATE after a successful submenu run + if (optWhichMenu != OPT_PC) + pMS->CurState = NAVIGATION; + DrawMenuStateStrings (PM_SCAN, pMS->CurState); + } + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + } + + return TRUE; +} + +void +PlanetOrbitMenu (void) +{ + void *oldInputFunc = pSolarSysState->MenuState.InputFunc; + + DrawMenuStateStrings (PM_SCAN, SCAN); + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + + pSolarSysState->MenuState.CurState = SCAN; + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + + // XXX: temporary; will have an own MENU_STATE + pSolarSysState->MenuState.InputFunc = DoPlanetOrbit; + DoInput (&pSolarSysState->MenuState, TRUE); + pSolarSysState->MenuState.InputFunc = oldInputFunc; + + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + DrawMenuStateStrings (PM_STARMAP, -NAVIGATION); +} Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/planets.h 2009-11-30 21:57:13 UTC (rev 3378) @@ -237,20 +237,11 @@ extern void DrawStarBackGround (BOOLEAN ForPlanet); extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay); extern PLAN_GEN_FUNC GenerateIP (BYTE Index); -extern void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem); extern void DrawOval (RECT *pRect, BYTE num_off_pixels); extern void DrawFilledOval (RECT *pRect); extern void FillOrbits (SOLARSYS_STATE *system, BYTE NumPlanets, PLANET_DESC *pBaseDesc, BOOLEAN TypesDefined); -extern void ScanSystem (void); -extern void ChangeSolarSys (void); -extern BOOLEAN DoFlagshipCommands (MENU_STATE *pMS); -extern void ZoomSystem (void); -extern void LoadSolarSys (void); extern void InitLander (BYTE LanderFlags); -extern BOOLEAN ValidateOrbits (void); -extern void IP_reset (void); -extern void IP_frame (void); extern RECT* RotatePlanet (int x, int dx, int dy, COUNT scale_amt, UBYTE zoom_from, RECT *r); @@ -263,5 +254,7 @@ extern UNICODE* GetNamedPlanetaryBody (void); extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize); +extern void PlanetOrbitMenu (void); + #endif /* _PLANETS_H */ Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -1586,8 +1586,8 @@ } } -static BOOLEAN -DoStarMap (void) +BOOLEAN +StarMap (void) { MENU_STATE MenuState; POINT universe; @@ -1614,9 +1614,6 @@ if (cursorLoc.x == ~0 && cursorLoc.y == ~0) cursorLoc = universe; - UnlockMutex (GraphicsLock); - TaskSwitch (); - MenuState.InputFunc = DoMoveCursor; MenuState.Initialized = FALSE; @@ -1643,10 +1640,10 @@ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); LockMutex (GraphicsLock); - DrawHyperCoords (universe); DrawSISMessage (NULL); DrawStatusMessage (NULL); + UnlockMutex (GraphicsLock); if (GLOBAL (autopilot.x) == universe.x && GLOBAL (autopilot.y) == universe.y) @@ -1656,185 +1653,3 @@ && GLOBAL (autopilot.y) != ~0); } -BOOLEAN -DoFlagshipCommands (MENU_STATE *pMS) -{ - /* TODO: Make this carried cleanly by MENU_STATE structure */ - // static DWORD NextTime; - if (!(pMS->Initialized & 1)) - { - /* This has some dependency on the IPtask_func */ - ChangeSolarSys (); - // NextTime = GetTimeCounter (); - } - else - { - BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT]; - LockMutex (GraphicsLock); - if (*(volatile BYTE *)&pMS->CurState == 0 - && (*(volatile SIZE *)&pMS->Initialized & 1) - && !(GLOBAL (CurrentActivity) - & (START_ENCOUNTER | END_INTERPLANETARY - | CHECK_ABORT | CHECK_LOAD)) - && GLOBAL_SIS (CrewEnlisted) != (COUNT)~0) - { - UnlockMutex (GraphicsLock); - IP_frame (); - return TRUE; - } - UnlockMutex (GraphicsLock); - - if (pMS->CurState) - { - BOOLEAN DoMenu; - BYTE NewState; - - /* If pMS->CurState == 0, then we're flying - * around in interplanetary. This needs to be - * corrected for the MenuChooser, which thinks - * that "0" is the first menu option */ - pMS->CurState --; - DoMenu = DoMenuChooser (pMS, - (BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN)); - pMS->CurState ++; - - if (!DoMenu) { - - NewState = pMS->CurState; - if (LastActivity == CHECK_LOAD) - select = TRUE; // Selected LOAD from main menu - if (select) - { - if (NewState != SCAN + 1 && NewState != (GAME_MENU) + 1) - { - LockMutex (GraphicsLock); - SetFlashRect (NULL); - UnlockMutex (GraphicsLock); - } - - switch (NewState - 1) - { - case SCAN: - ScanSystem (); - break; - case EQUIP_DEVICE: - { - if (!Devices (pMS)) - select = FALSE; - if (GET_GAME_STATE (PORTAL_COUNTER)) { - // A player-induced portal to QuasiSpace is - // opening. - return (FALSE); - } - break; - } - case CARGO: - { - Cargo (pMS); - break; - } - case ROSTER: - { - if (!Roster ()) - select = FALSE; - break; - } - case GAME_MENU: - if (GameOptions () == 0) - return (FALSE); - break; - case STARMAP: - { - BOOLEAN AutoPilotSet; - - LockMutex (GraphicsLock); - if (++pMS->Initialized > 3) { - pSolarSysState->PauseRotate = 1; - RepairSISBorder (); - } - - AutoPilotSet = DoStarMap (); - SetDefaultMenuRepeatDelay (); - - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE - || (GLOBAL (CurrentActivity) & CHECK_ABORT)) - { - UnlockMutex (GraphicsLock); - return (FALSE); - } - else if (pMS->Initialized <= 3) - { - ZoomSystem (); - --pMS->Initialized; - } - UnlockMutex (GraphicsLock); - - if (!AutoPilotSet && pMS->Initialized >= 3) - { - LoadPlanet (NULL); - --pMS->Initialized; - pSolarSysState->PauseRotate = 0; - LockMutex (GraphicsLock); - SetFlashRect (SFR_MENU_3DO); - UnlockMutex (GraphicsLock); - break; - } - } - case NAVIGATION: - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) - return (FALSE); - - if (pMS->Initialized <= 1) - { - pMS->Initialized = 1; - } - else if (pMS->flash_task) - { // In planet orbit - FreePlanet (); - LockMutex (GraphicsLock); - LoadSolarSys (); - ValidateOrbits (); - ZoomSystem (); - UnlockMutex (GraphicsLock); - } - - LockMutex (GraphicsLock); - pMS->CurState = 0; - FlushInput (); - UnlockMutex (GraphicsLock); - break; - } - - if (GLOBAL (CurrentActivity) & CHECK_ABORT) - ; - else if (pMS->CurState) - { - LockMutex (GraphicsLock); - SetFlashRect (SFR_MENU_3DO); - UnlockMutex (GraphicsLock); - if (select) - { - if (optWhichMenu != OPT_PC) - pMS->CurState = (NAVIGATION) + 1; - DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN), - pMS->CurState - 1); - } - } - else - { - LockMutex (GraphicsLock); - SetFlashRect (NULL); - UnlockMutex (GraphicsLock); - DrawMenuStateStrings (PM_STARMAP, -NAVIGATION); - } - } - } - } - } - - return (!(GLOBAL (CurrentActivity) - & (START_ENCOUNTER | END_INTERPLANETARY - | CHECK_ABORT | CHECK_LOAD)) - && GLOBAL_SIS (CrewEnlisted) != (COUNT)~0); -} - Modified: trunk/sc2/src/uqm/planets/roster.c =================================================================== --- trunk/sc2/src/uqm/planets/roster.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/roster.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -401,7 +401,7 @@ } BOOLEAN -Roster (void) +RosterMenu (void) { SIZE num_support_ships; Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/scan.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -667,8 +667,6 @@ // Set the current flash location setPlanetCursorLoc (planetLoc); savePlanetLocationImage (); - - SetFlashRect (NULL); UnlockMutex (GraphicsLock); InitLander (0); @@ -1001,15 +999,18 @@ UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); + SetFlashRect (NULL); SetContext (ScanContext); BatchGraphics (); DrawPlanet (0, 0, 0, BLACK_COLOR); DrawScannedObjects (FALSE); UnbatchGraphics (); UnlockMutex (GraphicsLock); - + pMS->Initialized = FALSE; pMS->CurFrame = 0; + // XXX: PickPlanetSide() will take over the InputFunc + // and later restore it when its done return PickPlanetSide (pMS); } @@ -1241,6 +1242,9 @@ } DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState); + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); if (optWhichCoarseScan == OPT_PC) PrintCoarseScanPC (); @@ -1250,6 +1254,10 @@ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); DoInput (&MenuState, FALSE); + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + if (ScanContext) { LockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/planets/scan.h =================================================================== --- trunk/sc2/src/uqm/planets/scan.h 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/scan.h 2009-11-30 21:57:13 UTC (rev 3378) @@ -43,6 +43,8 @@ SCAN_DESC *scan_base; }; +extern void ScanSystem (void); + extern void RepairBackRect (RECT *pRect); extern void GeneratePlanetSide (void); extern bool callGenerateForScanType (SOLARSYS_STATE *solarSys, Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -28,6 +28,8 @@ #include "../globdata.h" #include "../sis.h" #include "../init.h" +#include "../shipcont.h" +#include "../gameopt.h" #include "../nameref.h" #include "../resinst.h" #include "../settings.h" @@ -39,14 +41,19 @@ #include "../sounds.h" #include "../state.h" #include "../uqmdebug.h" +#include "options.h" #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" #include "libs/log.h" +#include "libs/misc.h" //#define DEBUG_SOLARSYS +static BOOLEAN DoIpFlight (MENU_STATE *pMS); +static void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem); + SOLARSYS_STATE *pSolarSysState; FRAME SISIPFrame; FRAME SunFrame; @@ -61,8 +68,11 @@ // last encountered group info #define DRAW_STARS (1 << 0) + // only ever cleared by DrawSimpleSystem() which is currently disabled #define DRAW_PLANETS (1 << 1) + // only ever cleared by DrawSimpleSystem() which is currently disabled #define DRAW_ORBITS (1 << 2) + // only ever cleared by DrawSimpleSystem() which is currently disabled #define DRAW_HYPER_COORDS (1 << 3) #define UNBATCH_SYS (1 << 4) #define DRAW_REFRESH (1 << 5) @@ -132,6 +142,16 @@ return true; } +// TODO: make code outside solarsys.c call a similar external version +static inline bool +inInnerSystem (void) +{ + assert (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc + || pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc); + return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc; +} + + static void GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet) { @@ -161,7 +181,7 @@ BYTE data_index; pMoonDesc->pPrevDesc = planet; - if (system->MenuState.Initialized > 1 || i >= planet->NumPlanets) + if (i >= planet->NumPlanets) continue; pMoonDesc->temp_color = planet->temp_color; @@ -177,7 +197,6 @@ } } - system->pBaseDesc = system->MoonDesc; TFB_SeedRandom (old_seed); } @@ -292,10 +311,11 @@ } } -void +static BOOLEAN LoadSolarSys (void) { COUNT i; + BOOLEAN orbital = FALSE; PLANET_DESC *pCurDesc; DWORD old_seed; #define NUM_TEMP_RANGES 5 @@ -308,18 +328,6 @@ BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x08, 0x00), 0x75), }; - pSolarSysState->MenuState.CurState = 0; - pSolarSysState->MenuState.Initialized = GLOBAL (in_orbit); - if (pSolarSysState->MenuState.Initialized) - { - GLOBAL (in_orbit) = 0; - ++pSolarSysState->MenuState.Initialized; - } - else - { -// LoadIPData (); - } - old_seed = TFB_SeedRandom (MAKE_DWORD (CurStarDescPtr->star_pt.x, CurStarDescPtr->star_pt.y)); @@ -347,9 +355,10 @@ { pCurDesc->pPrevDesc = &pSolarSysState->SunDesc[0]; pCurDesc->image.origin = pCurDesc->location; - if (pSolarSysState->MenuState.Initialized != 0 - || i >= pSolarSysState->SunDesc[0].NumPlanets) + if (i >= pSolarSysState->SunDesc[0].NumPlanets) + { pCurDesc->image.frame = 0; + } else { COUNT index; @@ -374,26 +383,26 @@ else { pSolarSysState->pOrbitalDesc = 0; - pSolarSysState->pBaseDesc = &pSolarSysState->PlanetDesc[i - 1]; pSolarSysState->SunDesc[0].location = GLOBAL (ip_location); - GenerateMoons (pSolarSysState, pSolarSysState->pBaseDesc); + GenerateMoons (pSolarSysState, &pSolarSysState->PlanetDesc[i - 1]); + pSolarSysState->pBaseDesc = pSolarSysState->MoonDesc; SET_GAME_STATE (PLANETARY_LANDING, 0); } initSolarSysSISCharacteristics (); - i = pSolarSysState->MenuState.Initialized; - if (i) - { - i -= 2; + if (GLOBAL (in_orbit)) + { // Only when loading a game into orbital + orbital = TRUE; + i = GLOBAL (in_orbit) - 1; 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 (in_orbit) = 0; } else { @@ -407,6 +416,8 @@ // Restore RNG state: TFB_SeedRandom (old_seed); + + return orbital; } static void @@ -414,22 +425,18 @@ { if (pSolarSysState->MenuState.flash_task) { - if (pSolarSysState->MenuState.Initialized >= 3) - FreePlanet (); - else - { - if (pSolarSysState->MenuState.flash_task != (Task)(~0)) - { - log_add (log_Warning, "DIAGNOSTIC: FreeSolarSys cancels a " - "flash_task that wasn't the placeholder for IP flight"); - ConcludeTask (pSolarSysState->MenuState.flash_task); - } - pSolarSysState->MenuState.flash_task = 0; - LockMutex (GraphicsLock); - if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) - SaveFlagshipState (); - UnlockMutex (GraphicsLock); + if (pSolarSysState->MenuState.flash_task != (Task)(~0)) + { + log_add (log_Warning, "DIAGNOSTIC: FreeSolarSys cancels a " + "flash_task that wasn't the placeholder for IP flight"); + ConcludeTask (pSolarSysState->MenuState.flash_task); } + pSolarSysState->MenuState.flash_task = 0; + + LockMutex (GraphicsLock); + if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) + SaveFlagshipState (); + UnlockMutex (GraphicsLock); } LockMutex (GraphicsLock); @@ -490,6 +497,8 @@ if (!just_checking) { ZeroVelocityComponents (&GLOBAL (velocity)); + // XXX: signal enter orbital + assert (pSolarSysState->MenuState.Initialized == 1); ++pSolarSysState->MenuState.Initialized; pSolarSysState->pOrbitalDesc = pCurDesc; } @@ -510,7 +519,7 @@ { PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin; PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin; - if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) + if (inInnerSystem ()) { PlanetOffset = pCurDesc->pPrevDesc - pSolarSysState->PlanetDesc; @@ -543,7 +552,7 @@ return; else if (pSolarSysState->WaitIntersect == NewWaitPlanet) continue; - else if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) + else if (inInnerSystem ()) goto ShowPlanet; else if (!just_checking) /* pBaseDesc == PlanetDesc */ { @@ -566,11 +575,11 @@ 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); ZeroVelocityComponents (&GLOBAL (velocity)); GenerateMoons (pSolarSysState, pCurDesc); + pSolarSysState->pBaseDesc = pSolarSysState->MoonDesc; NewWaitPlanet = 0; SetTransitionSource (NULL); @@ -637,6 +646,7 @@ if (draw_sys_flags & DRAW_ORBITS) { + // XXX: ValidateOrbits() sets pBaseDesc=0 if (pSolarSysState->pBaseDesc) { SetContextForeGroundColor (pPlanetDesc->temp_color); @@ -724,7 +734,8 @@ do { - if ((pSolarSysState->SunDesc[0].radius >>= 1) > MIN_ZOOM_RADIUS) + pSolarSysState->SunDesc[0].radius >>= 1; + if (pSolarSysState->SunDesc[0].radius > MIN_ZOOM_RADIUS) radius = pSolarSysState->SunDesc[0].radius >> 1; else radius = 0; @@ -746,7 +757,7 @@ && delta_y < pSolarSysState->MenuState.flash_rect0.extent.height); } -void +static void ZoomSystem (void) { RECT r; @@ -757,15 +768,10 @@ SetTransitionSource (&r); BatchGraphics (); - if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) + if (inInnerSystem ()) DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE); else - { - if (pSolarSysState->MenuState.CurState == 0) - FindRadius (); - DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE); - } ScreenTransition (3, &r); UnbatchGraphics (); LoadIntoExtraScreen (&r); @@ -904,7 +910,7 @@ || GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT) { // The ship leaves the screen. - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) + if (!inInnerSystem ()) { if (radius == MAX_ZOOM_RADIUS) { @@ -934,7 +940,7 @@ pSolarSysState->MenuState.flash_rect0.corner.x; delta_y = GLOBAL (ShipStamp.origin.y) - pSolarSysState->MenuState.flash_rect0.corner.y; - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc + if (!inInnerSystem () && (radius > MAX_ZOOM_RADIUS || (delta_x >= 0 && delta_y >= 0 && delta_x < pSolarSysState->MenuState.flash_rect0.extent.width @@ -985,6 +991,10 @@ ScaleSystem (void) { #if 0 + // XXX: This appears to have been an attempt to zoom the system view + // in a different way. This code would zoom gradually instead of + // doing crossfade from one zoom level to the other. + // Working state unknown. #define NUM_STEPS 8 COUNT num_steps; SIZE err, d, new_radius, step; @@ -1064,83 +1074,47 @@ #endif } -/* Constants and routines for handling interplanetary play. TODO: - this is NOT THREAD-SAFE; only one IP task may be active at any - given time. --Michael */ +static void +RestoreSystemView (void) +{ + CONTEXT oldContext; + RECT r; -#define IP_FRAME_RATE (ONE_SECOND / 30) + oldContext = SetContext (SpaceContext); + GetContextClipRect (&r); + DrawFromExtraScreen (&r); + SetContext (oldContext); +} -static UWORD IP_input_state; -static DWORD IP_next_time; +/* Constants and routines for handling interplanetary play. */ -void -IP_reset (void) -{ - DrawAutoPilotMessage (TRUE); +#define IP_FRAME_RATE (ONE_SECOND / 30) - if (LastActivity != CHECK_LOAD) - { - IP_input_state = 0; - } - else - { - IP_input_state = 2; /* CANCEL */ - } - - IP_next_time = GetTimeCounter (); -} - -void +// Normally called by DoIpFlight() to process a frame +static void IP_frame (void) { CONTEXT OldContext; - BOOLEAN InnerSystem; + BOOLEAN startedInInner; RECT r; - BOOLEAN select, cancel; - InnerSystem = FALSE; LockMutex (GraphicsLock); - if ((pSolarSysState->MenuState.Initialized > 1 - || (GLOBAL (CurrentActivity) - & (START_ENCOUNTER | END_INTERPLANETARY - | CHECK_ABORT | CHECK_LOAD)) - || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)) + OldContext = SetContext (StatusContext); { - UnlockMutex (GraphicsLock); - TaskSwitch (); - IP_input_state = 0; - IP_next_time = GetTimeCounter (); - return; - } - - cancel = ((IP_input_state) >> 1) & 1; - select = (IP_input_state) & 1; - OldContext = SetContext (StatusContext); - if (pSolarSysState->MenuState.CurState - || pSolarSysState->MenuState.Initialized == 0) - { - select = FALSE; - cancel = FALSE; - if (draw_sys_flags & DRAW_REFRESH) - goto TheMess; - } - else - { - TheMess: // this is a mess: // we have to treat things slightly differently depending on the - // situation (note that DRAW_REFRESH means we had gone to the - // menu) - InnerSystem = (BOOLEAN) (pSolarSysState->pBaseDesc != - pSolarSysState->PlanetDesc); - if (InnerSystem) + // situation (note that DRAW_REFRESH means entered a new system + // not from a load) + startedInInner = inInnerSystem (); + if (startedInInner) { SetTransitionSource (NULL); BatchGraphics (); + // XXX: this test is now invariant false if (draw_sys_flags & DRAW_REFRESH) { - InnerSystem = FALSE; + startedInInner = FALSE; DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE); } } @@ -1157,11 +1131,6 @@ ProcessShipControls (); } UndrawShip (); - if (pSolarSysState->MenuState.Initialized != 1) - { - select = FALSE; - cancel = FALSE; - } } if (old_radius) @@ -1171,27 +1140,18 @@ if (!(draw_sys_flags & DRAW_REFRESH)) // don't repair from Extra or draw ship if forcing repair { - CONTEXT OldContext; + RestoreSystemView (); - OldContext = SetContext (SpaceContext); - GetContextClipRect (&r); - DrawFromExtraScreen (&r); - SetContext (OldContext); - // Don't redraw if entering/exiting inner system // 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))) - ; - else + if (startedInInner == inInnerSystem ()) RedrawQueue (FALSE); } - if (InnerSystem) + if (startedInInner) { - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) + if (!inInnerSystem ()) { // transition screen if we left inner system (if going // from outer to inner, ScreenTransition happens elsewhere) @@ -1205,7 +1165,7 @@ } else if (draw_sys_flags & DRAW_REFRESH) { - // must set rect for LoadInto... below + // must set rect for LoadIntoExtraScreen below r.corner.x = SIS_ORG_X; r.corner.y = SIS_ORG_Y; r.extent.width = SIS_SCREEN_WIDTH; @@ -1220,14 +1180,14 @@ if (draw_sys_flags & UNBATCH_SYS) { - // means we're forcing a redraw/transition from Init- & ChangeSolarSys + // InitSolarSys() prepared a transition for us draw_sys_flags &= ~UNBATCH_SYS; UnbatchGraphics (); } - // LoadInto Extra if we left inner system, or we forced a redraw - if ((InnerSystem && pSolarSysState->pBaseDesc == - pSolarSysState->PlanetDesc) || (draw_sys_flags & DRAW_REFRESH)) + // Save the system image if we left inner system, or we forced a redraw + if ((startedInInner && !inInnerSystem ()) + || (draw_sys_flags & DRAW_REFRESH)) { LoadIntoExtraScreen (&r); draw_sys_flags &= ~DRAW_REFRESH; @@ -1235,48 +1195,6 @@ SetContext (OldContext); UnlockMutex (GraphicsLock); - - if (!cancel) - { - SleepThreadUntil (IP_next_time + IP_FRAME_RATE); - IP_next_time = GetTimeCounter (); - if (pSolarSysState->MenuState.CurState - || pSolarSysState->MenuState.Initialized != 1) - { - cancel = FALSE; - select = FALSE; - } - else - { - /* Updating the input state is handled by - * DoFlagshipCommands, which is running in - * parallel with us */ - // UpdateInputState (); - cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; - select = PulsedInputState.menu[KEY_MENU_SELECT]; - IP_input_state = (cancel << 1) | select; - } - } - else - { - LockMutex (GraphicsLock); - DrawStatusMessage (NULL); - if (LastActivity == CHECK_LOAD) - { // Selected LOAD from main menu - pSolarSysState->MenuState.CurState = (ROSTER + 1) + 1; - } - else - { - UnlockMutex (GraphicsLock); - DrawMenuStateStrings (PM_STARMAP, STARMAP); - LockMutex (GraphicsLock); - pSolarSysState->MenuState.CurState = STARMAP + 1; - IP_input_state = 0; - } - SetFlashRect (SFR_MENU_3DO); - FlushInput (); - UnlockMutex (GraphicsLock); - } } static void @@ -1288,7 +1206,7 @@ UnlockMutex (GraphicsLock); } -BOOLEAN +static BOOLEAN ValidateOrbits (void) { BYTE i; @@ -1296,8 +1214,7 @@ POINT old_pts[2] = { { 0, 0 }, { 0, 0 } }; PLANET_DESC *pCurDesc; - InnerSystem = (BOOLEAN)( - pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc); + InnerSystem = inInnerSystem (); if (InnerSystem) { old_pts[0] = GLOBAL (ShipStamp.origin); @@ -1308,6 +1225,7 @@ pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS << 1; FindRadius (); + // XXX: DrawOrbit() checks pBaseDesc for 0 pSolarSysState->pBaseDesc = 0; for (i = pSolarSysState->SunDesc[0].NumPlanets, pCurDesc = &pSolarSysState->PlanetDesc[0]; i; --i, ++pCurDesc) @@ -1329,118 +1247,114 @@ return (InnerSystem); } -void -ChangeSolarSys (void) +static void +ResetSolarSys (void) { - if (pSolarSysState->MenuState.Initialized == 0) - { -StartGroups: - ++pSolarSysState->MenuState.Initialized; - if (pSolarSysState->MenuState.flash_task == 0) - { - DrawMenuStateStrings (PM_STARMAP, -(PM_NAVIGATE - PM_SCAN)); + // Originally there was a flash_task test here, however, I found no cases + // where flash_task could be set at the time of call. The test was + // probably needed on 3DO when IP_frame() was a task. + assert (!pSolarSysState->MenuState.flash_task); - LockMutex (GraphicsLock); - RepairSISBorder (); + DrawMenuStateStrings (PM_STARMAP, -(PM_NAVIGATE - PM_SCAN)); - InitDisplayList (); - DoMissions (); + LockMutex (GraphicsLock); + RepairSISBorder (); - // if entering new system (NOT from load), - // force redraw and transition in IPtask_func - if ((draw_sys_flags & UNBATCH_SYS) - && LastActivity != (CHECK_LOAD | CHECK_RESTART)) - draw_sys_flags |= DRAW_REFRESH; - - CheckIntersect (TRUE); - - IP_reset (); - pSolarSysState->MenuState.flash_task = (Task)(~0); - /* - pSolarSysState->MenuState.flash_task = - AssignTask (IPtask_func, 6144, - "interplanetary task"); - */ - UnlockMutex (GraphicsLock); + InitDisplayList (); + DoMissions (); - if (!PLRPlaying ((MUSIC_REF)~0) && LastActivity != CHECK_LOAD) - { - PlayMusic (SpaceMusic, TRUE, 1); - if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) - { - BYTE clut_buf[] = {FadeAllToColor}; + // if entering new system (NOT from load), + // force redraw and transition in IP_frame() + if ((draw_sys_flags & UNBATCH_SYS) + && LastActivity != (CHECK_LOAD | CHECK_RESTART)) + draw_sys_flags |= DRAW_REFRESH; + + CheckIntersect (TRUE); + + pSolarSysState->MenuState.flash_task = (Task)(~0); + UnlockMutex (GraphicsLock); - LastActivity = 0; - if (draw_sys_flags & UNBATCH_SYS) - { - draw_sys_flags &= ~UNBATCH_SYS; - UnbatchGraphics (); - } - LockMutex (GraphicsLock); - while ((pSolarSysState->SunDesc[0].radius == - (MAX_ZOOM_RADIUS << 1)) && - !(GLOBAL(CurrentActivity) & CHECK_ABORT)) - { - UnlockMutex (GraphicsLock); - IP_frame (); - LockMutex (GraphicsLock); - } - UnlockMutex (GraphicsLock); - XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); - } - } - - SetGameClockRate (INTERPLANETARY_CLOCK_RATE); - } - } - else + if (!PLRPlaying ((MUSIC_REF)~0) && LastActivity != CHECK_LOAD) { - if (pSolarSysState->MenuState.flash_task) - { - FreeSolarSys (); + PlayMusic (SpaceMusic, TRUE, 1); + + // XXX: This is begging to be moved somewhere more appropriate + // This fades in the solar system view when a New game starts + if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) + { // Starting a new game, NOT from load! + BYTE clut_buf[] = {FadeAllToColor}; - if (pSolarSysState->pOrbitalDesc->pPrevDesc != - &pSolarSysState->SunDesc[0]) - GLOBAL (ShipStamp.origin) = - pSolarSysState->pOrbitalDesc->image.origin; - else + LastActivity = 0; + // XXX: this test is invariant true + if (draw_sys_flags & UNBATCH_SYS) { - GLOBAL (ShipStamp.origin.x) = SIS_SCREEN_WIDTH >> 1; - GLOBAL (ShipStamp.origin.y) = SIS_SCREEN_HEIGHT >> 1; + draw_sys_flags &= ~UNBATCH_SYS; + UnbatchGraphics (); } + XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); } + } +} - GetPlanetInfo (); - (*pSolarSysState->genFuncs->generateOrbital) (pSolarSysState, - pSolarSysState->pOrbitalDesc); - LastActivity &= ~(CHECK_LOAD | CHECK_RESTART); - if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD | - START_ENCOUNTER)) || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 - || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) - return; +static void +ReinitInnerSystem (void) +{ + LockMutex (GraphicsLock); + SetTransitionSource (NULL); + LoadSolarSys (); + ValidateOrbits (); + DrawInnerSystem (); + ScreenTransition (3, NULL); + UnlockMutex (GraphicsLock); +} - if (pSolarSysState->MenuState.flash_task == 0) - { - /* Note! This implies that our generateOrbital function started - a conversation; that is, that this is a homeworld */ - SetTransitionSource (NULL); - LoadSolarSys (); - ValidateOrbits (); - DrawInnerSystem (); - ScreenTransition (3, NULL); +static void +EnterPlanetOrbit (void) +{ + if (pSolarSysState->MenuState.flash_task) + { // This means we hit a planet in IP flight; not a Load into orbit + FreeSolarSys (); - goto StartGroups; + if (pSolarSysState->pOrbitalDesc->pPrevDesc != + &pSolarSysState->SunDesc[0]) + { // Moon -- use its origin + GLOBAL (ShipStamp.origin) = + pSolarSysState->pOrbitalDesc->image.origin; } else - { - DrawMenuStateStrings (PM_SCAN, SCAN); - LockMutex (GraphicsLock); - pSolarSysState->MenuState.CurState = SCAN + 1; - SetFlashRect (SFR_MENU_3DO); - FlushInput (); - UnlockMutex (GraphicsLock); + { // Planet -- its origin is for the outer view, so use mid-screen + GLOBAL (ShipStamp.origin.x) = SIS_SCREEN_WIDTH >> 1; + GLOBAL (ShipStamp.origin.y) = SIS_SCREEN_HEIGHT >> 1; } } + + GetPlanetInfo (); + (*pSolarSysState->genFuncs->generateOrbital) (pSolarSysState, + pSolarSysState->pOrbitalDesc); + LastActivity &= ~(CHECK_LOAD | CHECK_RESTART); + if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD | + START_ENCOUNTER)) || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 + || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) + return; + + if (pSolarSysState->MenuState.flash_task) + { // We've entered orbit; LoadPlanet() set flash_task to rotate planet + PlanetOrbitMenu (); + FreePlanet (); + } + // Otherwise, generateOrbital function started a homeworld conversation, + // and we did not get to the planet no matter what. + + // START_ENCOUNTER could be set by Devices menu a number of ways: + // Talking Pet, Sun Device or a Caster over Chmmr, or + // a Caster for Ilwrath + // Could also have blown self up with Utwig Bomb + if (!(GLOBAL (CurrentActivity) & (START_ENCOUNTER | + CHECK_ABORT | CHECK_LOAD)) + && GLOBAL_SIS (CrewEnlisted) != (COUNT)~0) + { + ReinitInnerSystem (); + } } void @@ -1448,6 +1362,7 @@ { BOOLEAN InnerSystem; BOOLEAN Reentry; + BOOLEAN orbital; LockMutex (GraphicsLock); @@ -1455,7 +1370,7 @@ LoadLanderData (); UnlockMutex (GraphicsLock); - pSolarSysState->MenuState.InputFunc = DoFlagshipCommands; + pSolarSysState->MenuState.InputFunc = DoIpFlight; Reentry = (GLOBAL (ShipFacing) != 0); if (!Reentry) @@ -1471,7 +1386,7 @@ XFormIPLoc (&GLOBAL (ShipStamp.origin), &GLOBAL (ip_location), FALSE); } - LoadSolarSys (); + orbital = LoadSolarSys (); InnerSystem = ValidateOrbits (); if (Reentry) @@ -1488,14 +1403,24 @@ (*pSolarSysState->genFuncs->initNpcs) (pSolarSysState); } - if (pSolarSysState->MenuState.Initialized == 0) + if (orbital) { + // XXX: signal enter orbital + pSolarSysState->MenuState.Initialized = 2; + } + else + { LockMutex (GraphicsLock); + // We draw the IP display here but do not flush it to the screen yet + // Whatever we have drawn will fade in in ResetSolarSys() or will + // get transitioned onto the screen in IP_frame() SetTransitionSource (NULL); BatchGraphics (); draw_sys_flags |= UNBATCH_SYS; + // XXX: This whole "maybe loaded a game or maybe starting a new game" + // mess is begging to be cleaned up. if (LastActivity & (CHECK_LOAD | CHECK_RESTART)) { if ((LastActivity & (CHECK_LOAD | CHECK_RESTART)) == @@ -1513,8 +1438,6 @@ } } - // Enabled graphics synchronization again, as in 3DO code originally. - // This should fix the 'entering star' lockup/messed graphics problems. DrawSISMessage (NULL); SetContext (SpaceContext); SetContextFGFrame (Screen); @@ -1523,16 +1446,11 @@ if (InnerSystem) { - SetGraphicGrabOther (1); // since Unbatch won't have flipped yet DrawInnerSystem (); - SetGraphicGrabOther (0); - if (draw_sys_flags & UNBATCH_SYS) - { - draw_sys_flags &= ~UNBATCH_SYS; - ScreenTransition (3, 0); - UnbatchGraphics (); - LoadIntoExtraScreen (0); - } + draw_sys_flags &= ~UNBATCH_SYS; + ScreenTransition (3, NULL); + UnbatchGraphics (); + LoadIntoExtraScreen (NULL); } else { @@ -1540,7 +1458,7 @@ DrawHyperCoords (CurStarDescPtr->star_pt); /* Adjust position */ UnlockMutex (GraphicsLock); - /* force a redraw */ + // force a redraw in UndrawShip() pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS << 1; } } @@ -1562,7 +1480,8 @@ // Find the closest planet to a point, in interplanetary. static PLANET_DESC * -closestPlanetInterPlanetary (const POINT *point) { +closestPlanetInterPlanetary (const POINT *point) +{ BYTE i; BYTE numPlanets; DWORD bestDistSquared; @@ -1612,16 +1531,16 @@ if (GLOBAL (ip_planet) == 0) { - pSolarSysState->pBaseDesc = + PLANET_DESC *planet = closestPlanetInterPlanetary (&GLOBAL (ShipStamp.origin)); (*pSolarSysState->genFuncs->generateName) ( - pSolarSysState, pSolarSysState->pBaseDesc); + pSolarSysState, planet); } } } -void +static void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem) { BYTE i; @@ -1704,7 +1623,7 @@ } } - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) + if (!inInnerSystem ()) XFormIPLoc (&GLOBAL (ip_location), &GLOBAL (ShipStamp.origin), TRUE); @@ -1841,20 +1760,16 @@ { pOut->x = (SIS_SCREEN_WIDTH >> 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) -// / (long)pSolarSysState->SunDesc[0].radius); / pSolarSysState->SunDesc[0].radius); } else { 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)) -// * (long)pSolarSysState->SunDesc[0].radius * pSolarSysState->SunDesc[0].radius / (DISPLAY_FACTOR >> 1)); } } @@ -1871,12 +1786,11 @@ universe.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)); universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); CurStarDescPtr = FindStar (0, &universe, 1, 1); - /* - // The following code used to be there, but the test is - // pointless. Maybe we should panic here? - if ((CurStarDescPtr = FindStar (0, &universe, 1, 1)) == 0) - ; - */ + if (!CurStarDescPtr) + { + log_add (log_Fatal, "ExploreSolarSys(): do not know where you are!"); + explode (); + } } GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (CurStarDescPtr->star_pt.x); GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (CurStarDescPtr->star_pt.y); @@ -1888,7 +1802,7 @@ SolarSysState.genFuncs = getGenerateFunctions (CurStarDescPtr->Index); InitSolarSys (); - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); DoInput (&SolarSysState.MenuState, FALSE); UninitSolarSys (); pSolarSysState = 0; @@ -2004,3 +1918,151 @@ } } +static BOOLEAN +DoSolarSysMenu (MENU_STATE *pMS) +{ + BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT]; + BOOLEAN handled; + + if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) + || GLOBAL_SIS (CrewEnlisted) == (COUNT)~0) + return FALSE; + + // XXX: pMS actually refers to pSolarSysState->MenuState + handled = DoMenuChooser (pMS, PM_STARMAP); + if (handled) + return TRUE; + + if (LastActivity == CHECK_LOAD) + select = TRUE; // Selected LOAD from main menu + + if (!select) + return TRUE; + + LockMutex (GraphicsLock); + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + + switch (pMS->CurState) + { + case EQUIP_DEVICE: + select = DevicesMenu (); + if (GLOBAL (CurrentActivity) & START_ENCOUNTER) + { // Invoked Talking Pet or a Caster for Ilwrath + // Going into conversation + return FALSE; + } + break; + case CARGO: + CargoMenu (); + break; + case ROSTER: + select = RosterMenu (); + break; + case GAME_MENU: + if (!GameOptions ()) + return FALSE; // abort or load + break; + case STARMAP: + StarMap (); + SetDefaultMenuRepeatDelay (); + + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + return FALSE; + + LockMutex (GraphicsLock); + ZoomSystem (); + UnlockMutex (GraphicsLock); + // Fall through !!! + case NAVIGATION: + // TODO: what's this? + //DrawMenuStateStrings (PM_STARMAP, -NAVIGATION); + return FALSE; + } + + if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) + { + if (select) + { // 3DO menu jumps to NAVIGATE after a successful submenu run + if (optWhichMenu != OPT_PC) + pMS->CurState = NAVIGATION; + DrawMenuStateStrings (PM_STARMAP, pMS->CurState); + } + LockMutex (GraphicsLock); + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + } + + return TRUE; +} + +static void +SolarSysMenu (void) +{ + void *oldInputFunc = pSolarSysState->MenuState.InputFunc; + + LockMutex (GraphicsLock); + DrawStatusMessage (NULL); + if (LastActivity == CHECK_LOAD) + { // Selected LOAD from main menu + pSolarSysState->MenuState.CurState = GAME_MENU; + } + else + { + UnlockMutex (GraphicsLock); + DrawMenuStateStrings (PM_STARMAP, STARMAP); + LockMutex (GraphicsLock); + pSolarSysState->MenuState.CurState = STARMAP; + } + SetFlashRect (SFR_MENU_3DO); + UnlockMutex (GraphicsLock); + + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + // XXX: temporary; will have an own MENU_STATE + pSolarSysState->MenuState.InputFunc = DoSolarSysMenu; + DoInput (&pSolarSysState->MenuState, TRUE); + pSolarSysState->MenuState.InputFunc = oldInputFunc; +} + +static BOOLEAN +DoIpFlight (MENU_STATE *pMS) +{ + static TimeCount NextTime; + BOOLEAN cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; + + if (!pMS->Initialized) + { + // This has some dependency on the IP_frame() + ResetSolarSys (); + // XXX: pMS refers to pSolarSysState->MenuState + pMS->Initialized = 1; + // XXX: InitSolarSys() leaves gfx batched so that IP_frame + // does a screen transition. It's currently easier to just + // call IP_frame() for loading a game from main menu. + IP_frame (); + } + else if (pMS->Initialized == 2) + { // CheckIntersect() or InitSolarSys() sent us to orbital + EnterPlanetOrbit (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + // Force a reset after orbital + // XXX: pMS refers to pSolarSysState->MenuState + pMS->Initialized = FALSE; + } + else if (cancel || LastActivity == CHECK_LOAD) + { + SolarSysMenu (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + } + else + { + IP_frame (); + SleepThreadUntil (NextTime); + NextTime = GetTimeCounter () + IP_FRAME_RATE; + } + + return (!(GLOBAL (CurrentActivity) + & (START_ENCOUNTER | END_INTERPLANETARY + | CHECK_ABORT | CHECK_LOAD)) + && GLOBAL_SIS (CrewEnlisted) != (COUNT)~0); +} Modified: trunk/sc2/src/uqm/shipcont.h =================================================================== --- trunk/sc2/src/uqm/shipcont.h 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/shipcont.h 2009-11-30 21:57:13 UTC (rev 3378) @@ -23,9 +23,10 @@ #define FIELD_WIDTH (STATUS_WIDTH - 5) -extern void Cargo (MENU_STATE *pMS); -extern BOOLEAN Roster (void); -extern BOOLEAN Devices (MENU_STATE *pMS); +extern void CargoMenu (void); +extern BOOLEAN RosterMenu (void); +extern BOOLEAN DevicesMenu (void); +extern BOOLEAN StarMap (void); extern void DrawCargoStrings (BYTE OldElement, BYTE NewElement); extern void ShowRemainingCapacity (void); Modified: trunk/sc2/src/uqm/shipyard.c =================================================================== --- trunk/sc2/src/uqm/shipyard.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/shipyard.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -1258,7 +1258,8 @@ } else { - if (GameOptions () == 0) + // Clearing FlashRect is not necessary + if (!GameOptions ()) goto ExitShipyard; DrawMenuStateStrings (PM_CREW, pMS->CurState); LockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/starcon.c =================================================================== --- trunk/sc2/src/uqm/starcon.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/starcon.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -253,6 +253,9 @@ else if (GLOBAL (CurrentActivity) & START_INTERPLANETARY) { GLOBAL (CurrentActivity) = MAKE_WORD (IN_INTERPLANETARY, 0); + + DrawAutoPilotMessage (TRUE); + SetGameClockRate (INTERPLANETARY_CLOCK_RATE); ExploreSolarSys (); } else Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2009-11-30 20:37:10 UTC (rev 3377) +++ trunk/sc2/src/uqm/uqmdebug.c 2009-11-30 21:57:13 UTC (rev 3378) @@ -584,7 +584,6 @@ COUNT i; assert(pSolarSysState == system); - assert(system->pBaseDesc == planet); for (i = 0; i < planet->NumPlanets; i++) callback (star, system, planet, &system->MoonDesc[i], arg); @@ -675,7 +674,6 @@ assert(CurStarDescPtr == star); assert(pSolarSysState == system); - system->pBaseDesc = planet; planet->pPrevDesc = &system->SunDesc[0]; if (universeRecurseArg->planetFuncPre != NULL) @@ -723,7 +721,6 @@ assert(CurStarDescPtr == star); assert(pSolarSysState == system); - assert(system->pBaseDesc == planet); moon->pPrevDesc = planet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-01 17:18:36
|
Revision: 3379 http://sc2.svn.sourceforge.net/sc2/?rev=3379&view=rev Author: avolkov Date: 2009-12-01 17:18:26 +0000 (Tue, 01 Dec 2009) Log Message: ----------- Cleanup of some of the pSolarSysState references Modified Paths: -------------- trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/hyper.h trunk/sc2/src/uqm/ipdisp.c trunk/sc2/src/uqm/planets/devices.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/save.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/sis.h Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/hyper.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -448,7 +448,7 @@ switch ((TRANSITION_TYPE) ElementPtr->turn_wait) { case RANDOM_ENCOUNTER_TRANSITION: - SaveFlagshipState (); + SaveSisHyperState (); GLOBAL (CurrentActivity) |= START_ENCOUNTER; break; case INTERPLANETARY_TRANSITION: @@ -880,6 +880,15 @@ hShip = StarShipPtr->hShip; UnlockStarShip (&race_q[RPG_PLAYER_NUM], hSis); +#ifdef DEBUG + { + ELEMENT *ElementPtr; + LockElement (hShip, &ElementPtr); + assert (ElementPtr->state_flags & PLAYER_SHIP); + UnlockElement (hShip); + } +#endif + return hShip; } @@ -1716,3 +1725,19 @@ BatchGraphics (); } +void +SaveSisHyperState (void) +{ + HELEMENT hSisElement; + ELEMENT *ElementPtr; + STARSHIP *StarShipPtr; + + // Update 'GLOBAL (ShipFacing)' to the direction the flagship is facing + hSisElement = getSisElement (); + //if (ElementPtr->state_flags & PLAYER_SHIP) + LockElement (hSisElement, &ElementPtr); + GetElementStarShip (ElementPtr, &StarShipPtr); + // XXX: Solar system reentry test depends on ShipFacing != 0 + GLOBAL (ShipFacing) = StarShipPtr->ShipFacing + 1; + UnlockElement (hSisElement); +} Modified: trunk/sc2/src/uqm/hyper.h =================================================================== --- trunk/sc2/src/uqm/hyper.h 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/hyper.h 2009-12-01 17:18:26 UTC (rev 3379) @@ -56,6 +56,7 @@ extern BOOLEAN hyper_transition (ELEMENT *ElementPtr); extern void HyperspaceMenu (void); +extern void SaveSisHyperState (void); #endif /* _HYPER_H */ Modified: trunk/sc2/src/uqm/ipdisp.c =================================================================== --- trunk/sc2/src/uqm/ipdisp.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/ipdisp.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -137,7 +137,7 @@ InitIntersectStartPoint (EPtr); - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) + if (!playerInInnerSystem ()) flagship_loc = 0; else flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc @@ -676,7 +676,7 @@ GetCurrentVelocityComponents (&GLOBAL (velocity), &vdx, &vdy); - if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) + if (playerInInnerSystem ()) { flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc - pSolarSysState->PlanetDesc + 2); @@ -767,7 +767,7 @@ LockElement (hFlagShipElement, &FlagShipElementPtr); FlagShipElementPtr->hit_points = 1; - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) + if (!playerInInnerSystem ()) FlagShipElementPtr->sys_loc = 1; else FlagShipElementPtr->sys_loc = Modified: trunk/sc2/src/uqm/planets/devices.c =================================================================== --- trunk/sc2/src/uqm/planets/devices.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/planets/devices.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -26,10 +26,14 @@ #include "../setup.h" #include "../state.h" #include "../sis.h" - // for ClearSISRect(), SaveFlagshipState() + // for ClearSISRect() #include "../grpinfo.h" #include "../sounds.h" #include "../util.h" +#include "../hyper.h" + // for SaveSisHyperState() +#include "planets.h" + // for SaveSolarSysLocation() and tests #include "libs/strlib.h" @@ -206,11 +210,11 @@ } if (LOBYTE (GLOBAL (CurrentActivity)) != IN_INTERPLANETARY - || pSolarSysState == NULL) + || !playerInSolarSystem ()) return FALSE; if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1] - && pSolarSysState->MenuState.Initialized == 3 + && playerInPlanetOrbit () && CurStarDescPtr->Index == CHMMR_DEFINED && !GET_GAME_STATE (CHMMR_UNLEASHED)) { @@ -224,7 +228,7 @@ assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); - SaveFlagshipState (); + SaveSolarSysLocation (); return TRUE; } @@ -267,8 +271,8 @@ SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 5); } - if (pSolarSysState->MenuState.Initialized >= 3) - SaveFlagshipState (); + if (playerInPlanetOrbit ()) + SaveSolarSysLocation (); return TRUE; } } @@ -300,9 +304,7 @@ break; case SUN_EFFICIENCY_DEVICE: if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY - && pSolarSysState - && pSolarSysState->pOrbitalDesc - && pSolarSysState->MenuState.Initialized == 3) + && playerInPlanetOrbit ()) { BYTE fade_buf[1]; @@ -361,6 +363,8 @@ SET_GAME_STATE (SHIP_TO_COMPEL, 1); } GLOBAL (CurrentActivity) &= ~IN_BATTLE; + + SaveSisHyperState (); } else { @@ -378,10 +382,9 @@ { SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1); } - if (pSolarSysState->MenuState.Initialized < 3) - return (FALSE); + if (playerInPlanetOrbit ()) + SaveSolarSysLocation (); } - SaveFlagshipState (); return (FALSE); case AQUA_HELIX_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/planets/planets.h 2009-12-01 17:18:26 UTC (rev 3379) @@ -219,6 +219,9 @@ extern SOLARSYS_STATE *pSolarSysState; extern MUSIC_REF SpaceMusic; +bool playerInSolarSystem (void); +bool playerInPlanetOrbit (void); +bool playerInInnerSystem (void); bool worldIsPlanet (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world); bool worldIsMoon (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world); COUNT planetIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world); @@ -255,6 +258,7 @@ extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize); extern void PlanetOrbitMenu (void); +extern void SaveSolarSysLocation (void); #endif /* _PLANETS_H */ Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -736,7 +736,7 @@ UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip); } - SaveFlagshipState (); + SaveSolarSysLocation (); return (FALSE); } Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -142,10 +142,24 @@ return true; } -// TODO: make code outside solarsys.c call a similar external version -static inline bool -inInnerSystem (void) +bool +playerInSolarSystem (void) { + return pSolarSysState != NULL; +} + +bool +playerInPlanetOrbit (void) +{ + return playerInSolarSystem () && + pSolarSysState->MenuState.Initialized >= 3; + // XXX: This test will change eventually +} + +bool +playerInInnerSystem (void) +{ + assert (playerInSolarSystem ()); assert (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc || pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc); return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc; @@ -433,10 +447,8 @@ } pSolarSysState->MenuState.flash_task = 0; - LockMutex (GraphicsLock); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) - SaveFlagshipState (); - UnlockMutex (GraphicsLock); + SaveSolarSysLocation (); } LockMutex (GraphicsLock); @@ -519,7 +531,7 @@ { PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin; PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin; - if (inInnerSystem ()) + if (playerInInnerSystem ()) { PlanetOffset = pCurDesc->pPrevDesc - pSolarSysState->PlanetDesc; @@ -552,7 +564,7 @@ return; else if (pSolarSysState->WaitIntersect == NewWaitPlanet) continue; - else if (inInnerSystem ()) + else if (playerInInnerSystem ()) goto ShowPlanet; else if (!just_checking) /* pBaseDesc == PlanetDesc */ { @@ -768,7 +780,7 @@ SetTransitionSource (&r); BatchGraphics (); - if (inInnerSystem ()) + if (playerInInnerSystem ()) DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE); else DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE); @@ -910,7 +922,7 @@ || GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT) { // The ship leaves the screen. - if (!inInnerSystem ()) + if (!playerInInnerSystem ()) { if (radius == MAX_ZOOM_RADIUS) { @@ -940,7 +952,7 @@ pSolarSysState->MenuState.flash_rect0.corner.x; delta_y = GLOBAL (ShipStamp.origin.y) - pSolarSysState->MenuState.flash_rect0.corner.y; - if (!inInnerSystem () + if (!playerInInnerSystem () && (radius > MAX_ZOOM_RADIUS || (delta_x >= 0 && delta_y >= 0 && delta_x < pSolarSysState->MenuState.flash_rect0.extent.width @@ -1106,7 +1118,7 @@ // we have to treat things slightly differently depending on the // situation (note that DRAW_REFRESH means entered a new system // not from a load) - startedInInner = inInnerSystem (); + startedInInner = playerInInnerSystem (); if (startedInInner) { SetTransitionSource (NULL); @@ -1145,13 +1157,13 @@ // Don't redraw if entering/exiting inner system // this screws up ScreenTransition by leaving an image of the // ship in the ExtraScreen (which we use for repair) - if (startedInInner == inInnerSystem ()) + if (startedInInner == playerInInnerSystem ()) RedrawQueue (FALSE); } if (startedInInner) { - if (!inInnerSystem ()) + if (!playerInInnerSystem ()) { // transition screen if we left inner system (if going // from outer to inner, ScreenTransition happens elsewhere) @@ -1186,7 +1198,7 @@ } // Save the system image if we left inner system, or we forced a redraw - if ((startedInInner && !inInnerSystem ()) + if ((startedInInner && !playerInInnerSystem ()) || (draw_sys_flags & DRAW_REFRESH)) { LoadIntoExtraScreen (&r); @@ -1214,7 +1226,7 @@ POINT old_pts[2] = { { 0, 0 }, { 0, 0 } }; PLANET_DESC *pCurDesc; - InnerSystem = inInnerSystem (); + InnerSystem = playerInInnerSystem (); if (InnerSystem) { old_pts[0] = GLOBAL (ShipStamp.origin); @@ -1623,7 +1635,7 @@ } } - if (!inInnerSystem ()) + if (!playerInInnerSystem ()) XFormIPLoc (&GLOBAL (ip_location), &GLOBAL (ShipStamp.origin), TRUE); @@ -1918,6 +1930,51 @@ } } +void +SaveSolarSysLocation (void) +{ + assert (playerInSolarSystem ()); + + if (!playerInPlanetOrbit ()) + { + // XXX: Solar system reentry test depends on ShipFacing != 0 + GLOBAL (ShipFacing) = GetFrameIndex (GLOBAL (ShipStamp.frame)) + 1; + GLOBAL (in_orbit) = 0; + if (!playerInInnerSystem ()) + { + GLOBAL (ip_planet) = 0; + } + else + { + // XXX: Is that even correct? pBaseDesc should point to PlanetDesc + GLOBAL (ip_planet) = pSolarSysState->pBaseDesc->pPrevDesc + - pSolarSysState->PlanetDesc + 1; + GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location; + } + } + else + { // In orbit around a planet. + BYTE moon; + + // Update the starinfo.dat file if necessary. + if (GET_GAME_STATE (PLANETARY_CHANGE)) + { + PutPlanetInfo (); + SET_GAME_STATE (PLANETARY_CHANGE, 0); + } + + // GLOBAL (ip_planet) is already set + moon = 1; /* the planet itself */ + // XXX: This test is convoluted, and we should come up with a + // better linking system + if (pSolarSysState->pOrbitalDesc != + pSolarSysState->pBaseDesc->pPrevDesc) + moon += pSolarSysState->pOrbitalDesc + - pSolarSysState->pBaseDesc + 1; + GLOBAL (in_orbit) = moon; + } +} + static BOOLEAN DoSolarSysMenu (MENU_STATE *pMS) { Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/save.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -21,7 +21,6 @@ #include "save.h" #include "build.h" -#include "libs/declib.h" #include "controls.h" #include "encount.h" #include "libs/file.h" @@ -34,9 +33,14 @@ #include "state.h" #include "grpinfo.h" #include "util.h" +#include "hyper.h" + // for SaveSisHyperState() +#include "planets/planets.h" + // for SaveSolarSysLocation() and tests #include "libs/inplib.h" #include "libs/log.h" #include "libs/memlib.h" +#include "libs/declib.h" // XXX: these should handle endian conversions later @@ -481,7 +485,7 @@ sizeof (SummPtr->SS.PlanetName)); if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) == (BYTE)~0) SummPtr->Activity = IN_STARBASE; - else if (pSolarSysState && pSolarSysState->MenuState.Initialized >= 3) + else if (playerInPlanetOrbit ()) SummPtr->Activity = IN_PLANET_ORBIT; break; case IN_LAST_BATTLE: @@ -617,6 +621,20 @@ UnlockMutex (GraphicsLock); } +static void +SaveFlagshipState (void) +{ + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) + { + // Player is in HyperSpace or QuasiSpace. + SaveSisHyperState (); + } + else if (playerInSolarSystem ()) + { + SaveSolarSysLocation (); + } +} + // This function first writes to a memory file, and then writes the whole // lot to the actual save file at once. BOOLEAN Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/sis.c 2009-12-01 17:18:26 UTC (rev 3379) @@ -1809,76 +1809,3 @@ SetContext (OldContext); } -void -SaveFlagshipState (void) -{ - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) - { - // Player is in HyperSpace or QuasiSpace. - // Update 'GLOBAL (ShipFacing)' to the direction the flagship - // is facing. - - HELEMENT hElement, hNextElement; - - // Find the flagship element. - for (hElement = GetHeadElement (); - hElement != 0; hElement = hNextElement) - { - ELEMENT *ElementPtr; - - LockElement (hElement, &ElementPtr); - hNextElement = GetSuccElement (ElementPtr); - if (ElementPtr->state_flags & PLAYER_SHIP) - { - STARSHIP *StarShipPtr; - - GetElementStarShip (ElementPtr, &StarShipPtr); - // XXX: Solar system reentry test depends on ShipFacing != 0 - GLOBAL (ShipFacing) = StarShipPtr->ShipFacing + 1; - hNextElement = 0; - } - UnlockElement (hElement); - } - } - else if (pSolarSysState) - { - // Player is in a solar system. - if (pSolarSysState->MenuState.Initialized < 3) - { - // XXX: Solar system reentry test depends on ShipFacing != 0 - GLOBAL (ShipFacing) = GetFrameIndex (GLOBAL (ShipStamp.frame)) + 1; - GLOBAL (in_orbit) = 0; - if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc) - { - GLOBAL (ip_planet) = 0; - } - else - { - GLOBAL (ip_planet) = pSolarSysState->pBaseDesc->pPrevDesc - - pSolarSysState->PlanetDesc + 1; - GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location; - } - } - else - { - // In orbit around a planet. - BYTE moon; - - // Update the starinfo.dat file if necessary. - if (GET_GAME_STATE (PLANETARY_CHANGE)) - { - PutPlanetInfo (); - SET_GAME_STATE (PLANETARY_CHANGE, 0); - } - - // GLOBAL (ip_planet) is already set - moon = 1; /* the planet itself */ - if (pSolarSysState->pOrbitalDesc != - pSolarSysState->pBaseDesc->pPrevDesc) - moon += pSolarSysState->pOrbitalDesc - - pSolarSysState->pBaseDesc + 1; - GLOBAL (in_orbit) = moon; - } - } -} - Modified: trunk/sc2/src/uqm/sis.h =================================================================== --- trunk/sc2/src/uqm/sis.h 2009-11-30 21:57:13 UTC (rev 3378) +++ trunk/sc2/src/uqm/sis.h 2009-12-01 17:18:26 UTC (rev 3379) @@ -202,7 +202,6 @@ extern void DrawStorageBays (BOOLEAN Refresh); extern void GetGaugeRect (RECT *pRect, BOOLEAN IsCrewRect); extern void DrawFlagshipStats (void); -extern void SaveFlagshipState (void); void DrawAutoPilotMessage (BOOLEAN Reset); extern void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-01 20:43:41
|
Revision: 3380 http://sc2.svn.sourceforge.net/sc2/?rev=3380&view=rev Author: avolkov Date: 2009-12-01 20:43:33 +0000 (Tue, 01 Dec 2009) Log Message: ----------- Smooth solar system zoom experiment fixed, uncomment #define SMOOTH_SYSTEM_ZOOM to try; some cleanups Modified Paths: -------------- trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/setup.h Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-12-01 17:18:26 UTC (rev 3379) +++ trunk/sc2/src/uqm/planets/lander.c 2009-12-01 20:43:33 UTC (rev 3380) @@ -1804,7 +1804,8 @@ SetTransitionSource (pRect); BatchGraphics (); - DrawStarBackGround (TRUE); + DrawStarBackGround (); + DrawPlanetSurfaceBorder (); RedrawSurfaceScan (NULL); ScreenTransition (3, pRect); UnbatchGraphics (); Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-12-01 17:18:26 UTC (rev 3379) +++ trunk/sc2/src/uqm/planets/planets.c 2009-12-01 20:43:33 UTC (rev 3380) @@ -66,6 +66,71 @@ } } +void +DrawPlanetSurfaceBorder (void) +{ +#define BORDER_HEIGHT 5 + CONTEXT oldContext; + RECT oldClipRect; + RECT clipRect; + RECT r; + + oldContext = SetContext (SpaceContext); + GetContextClipRect (&oldClipRect); + + // Expand the context clip-rect so that we can tweak the existing border + clipRect = oldClipRect; + clipRect.corner.x -= 1; + clipRect.extent.width += 2; + clipRect.extent.height += 1; + SetContextClipRect (&clipRect); + + BatchGraphics (); + + // Border bulk + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08)); + r.corner.x = 0; + r.corner.y = clipRect.extent.height - MAP_HEIGHT - BORDER_HEIGHT; + r.extent.width = clipRect.extent.width; + r.extent.height = BORDER_HEIGHT - 2; + DrawFilledRectangle (&r); + + SetContextForeGroundColor (SIS_BOTTOM_RIGHT_BORDER_COLOR); + + // Border top shadow line + r.extent.width -= 1; + r.extent.height = 1; + r.corner.x = 1; + r.corner.y -= 1; + DrawFilledRectangle (&r); + + // XXX: We will need bulk left and right rects here if MAP_WIDTH changes + + // Right shadow line + r.extent.width = 1; + r.extent.height = MAP_HEIGHT + 2; + r.corner.y += BORDER_HEIGHT - 1; + r.corner.x = clipRect.extent.width - 1; + DrawFilledRectangle (&r); + + SetContextForeGroundColor (SIS_LEFT_BORDER_COLOR); + + // Left shadow line + r.corner.x -= MAP_WIDTH + 1; + DrawFilledRectangle (&r); + + // Border bottom shadow line + r.extent.width = MAP_WIDTH + 2; + r.extent.height = 1; + DrawFilledRectangle (&r); + + UnbatchGraphics (); + + SetContextClipRect (&oldClipRect); + SetContext (oldContext); +} + typedef enum { DRAW_ORBITAL_FULL, @@ -89,7 +154,8 @@ DrawSISFrame (); DrawSISMessage (NULL); DrawSISTitle (GLOBAL_SIS (PlanetName)); - DrawStarBackGround (TRUE); + DrawStarBackGround (); + DrawPlanetSurfaceBorder (); } SetContext (SpaceContext); Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-12-01 17:18:26 UTC (rev 3379) +++ trunk/sc2/src/uqm/planets/planets.h 2009-12-01 20:43:33 UTC (rev 3380) @@ -237,7 +237,7 @@ extern void FreeLanderFont (PLANET_INFO *info); extern void ExploreSolarSys (void); -extern void DrawStarBackGround (BOOLEAN ForPlanet); +extern void DrawStarBackGround (void); extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay); extern PLAN_GEN_FUNC GenerateIP (BYTE Index); extern void DrawOval (RECT *pRect, BYTE num_off_pixels); @@ -254,6 +254,8 @@ extern void DeltaTopography (COUNT num_iterations, SBYTE *DepthArray, RECT *pRect, SIZE depth_delta); +extern void DrawPlanetSurfaceBorder (void); + extern UNICODE* GetNamedPlanetaryBody (void); extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize); Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-12-01 17:18:26 UTC (rev 3379) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-01 20:43:33 UTC (rev 3380) @@ -49,6 +49,7 @@ //#define DEBUG_SOLARSYS +//#define SMOOTH_SYSTEM_ZOOM 1 static BOOLEAN DoIpFlight (MENU_STATE *pMS); static void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem); @@ -451,15 +452,9 @@ SaveSolarSysLocation (); } - LockMutex (GraphicsLock); - - SetContext (SpaceContext); - StopMusic (); // FreeIPData (); - - UnlockMutex (GraphicsLock); } static void @@ -596,10 +591,8 @@ NewWaitPlanet = 0; SetTransitionSource (NULL); BatchGraphics (); - SetGraphicGrabOther (1); DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE); - SetGraphicGrabOther (0); r.corner.x = SIS_ORG_X; r.corner.y = SIS_ORG_Y; r.extent.width = SIS_SCREEN_WIDTH; @@ -773,11 +766,9 @@ ZoomSystem (void) { RECT r; - r.corner.x = SIS_ORG_X; - r.corner.y = SIS_ORG_Y; - r.extent.width = SIS_SCREEN_WIDTH; - r.extent.height = SIS_SCREEN_HEIGHT; + SetContext (SpaceContext); + GetContextClipRect (&r); SetTransitionSource (&r); BatchGraphics (); if (playerInInnerSystem ()) @@ -967,14 +958,11 @@ return; old_radius = 0; - if (LeavingInnerSystem) - SetGraphicGrabOther (1); DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE); if (LeavingInnerSystem) { COUNT OldWI; - SetGraphicGrabOther (0); OldWI = pSolarSysState->WaitIntersect; CheckIntersect (TRUE); if (pSolarSysState->WaitIntersect != OldWI) @@ -989,90 +977,76 @@ CheckIntersect (FALSE); } -#if 0 + static void -DrawSimpleSystem (SIZE radius, BYTE flags) +DrawSimpleSystem (SIZE radius, BYTE notFlags) { - draw_sys_flags &= ~flags; + BYTE oldFlags = draw_sys_flags; + draw_sys_flags &= notFlags; DrawSystem (radius, FALSE); - draw_sys_flags |= flags; + draw_sys_flags = oldFlags; } -#endif static void ScaleSystem (void) { -#if 0 +#ifdef SMOOTH_SYSTEM_ZOOM // XXX: This appears to have been an attempt to zoom the system view - // in a different way. This code would zoom gradually instead of - // doing crossfade from one zoom level to the other. - // Working state unknown. -#define NUM_STEPS 8 - COUNT num_steps; - SIZE err, d, new_radius, step; + // in a different way. This code zooms gradually instead of + // doing a crossfade from one zoom level to the other. +#define NUM_STEPS 10 + COUNT i; + SIZE new_radius; + SIZE d, step; RECT r; - BOOLEAN first_time; CONTEXT OldContext; + STAMP StarsStamp; - first_time = TRUE; new_radius = pSolarSysState->SunDesc[0].radius; - - BatchGraphics (); - DrawSimpleSystem (new_radius, DRAW_PLANETS | DRAW_ORBITS | GRAB_BKGND); + assert (old_radius != 0); + assert (old_radius != new_radius); + + GetContextClipRect (&r); + StarsStamp.origin.x = 0; + StarsStamp.origin.y = 0; + // Draw the stars background to off-screen frame + StarsStamp.frame = CaptureDrawable (CreateDrawable (WANT_PIXMAP, + r.extent.width, r.extent.height, 1)); + OldContext = SetContext (OffScreenContext); + SetContextFGFrame (StarsStamp.frame); + SetContextClipRect (NULL); + DrawStarBackGround (); + SetContext (OldContext); + pSolarSysState->SunDesc[0].radius = old_radius; - + d = new_radius - old_radius; step = d / NUM_STEPS; - if (d < 0) - d = -d; - num_steps = err = NUM_STEPS; - - OldContext = SetContext (SpaceContext); - GetContextClipRect (&r); - SetGraphicGrabOther (1); // to grab from hidden screen (since we haven't flipped yet) - LoadIntoExtraScreen (&r); - SetGraphicGrabOther (0); - SetContextFGFrame (Screen); - - do + for (i = 0; i < NUM_STEPS; ++i) { - err -= d; - if (err <= 0) - { - pSolarSysState->SunDesc[0].radius += step; + pSolarSysState->SunDesc[0].radius += step; - BatchGraphics (); + BatchGraphics (); + DrawStamp (&StarsStamp); + DrawSimpleSystem (pSolarSysState->SunDesc[0].radius, + ~(DRAW_STARS | GRAB_BKGND | DRAW_HYPER_COORDS)); + RedrawQueue (FALSE); + UnbatchGraphics (); - DrawFromExtraScreen (r.corner.x, r.corner.y); - - DrawSimpleSystem (pSolarSysState->SunDesc[0].radius, - DRAW_ORBITS | DRAW_STARS | GRAB_BKGND | DRAW_HYPER_COORDS); - - RedrawQueue (FALSE); - - if (first_time) - { - first_time = FALSE; - UnbatchGraphics (); // to balance out Batch before DrawSimpleSystem above - } - - UnbatchGraphics (); - - err += d; - } - } while (--num_steps); + SleepThread (ONE_SECOND / 30); + } - SetContext (OldContext); pSolarSysState->SunDesc[0].radius = new_radius; DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE); + + DestroyDrawable (ReleaseDrawable (StarsStamp.frame)); + old_radius = 0; -#else +#else // !SMOOTH_SYSTEM_ZOOM RECT r; - CONTEXT OldContext; - - OldContext = SetContext (SpaceContext); + GetContextClipRect (&r); SetTransitionSource (&r); BatchGraphics (); @@ -1080,10 +1054,9 @@ ScreenTransition (3, &r); UnbatchGraphics (); LoadIntoExtraScreen (&r); - SetContext (OldContext); old_radius = 0; -#endif +#endif // SMOOTH_SYSTEM_ZOOM } static void @@ -1106,12 +1079,11 @@ static void IP_frame (void) { - CONTEXT OldContext; BOOLEAN startedInInner; RECT r; LockMutex (GraphicsLock); - OldContext = SetContext (StatusContext); + SetContext (SpaceContext); { // this is a mess: @@ -1205,7 +1177,6 @@ draw_sys_flags &= ~DRAW_REFRESH; } - SetContext (OldContext); UnlockMutex (GraphicsLock); } @@ -1312,6 +1283,7 @@ ReinitInnerSystem (void) { LockMutex (GraphicsLock); + SetContext (SpaceContext); SetTransitionSource (NULL); LoadSolarSys (); ValidateOrbits (); @@ -1561,7 +1533,7 @@ BatchGraphics (); if (draw_sys_flags & DRAW_STARS) - DrawStarBackGround (FALSE); + DrawStarBackGround (); if (!IsInnerSystem) { @@ -1650,8 +1622,6 @@ UnbatchGraphics (); - SetContext (SpaceContext); - if (draw_sys_flags & GRAB_BKGND) { RECT r; @@ -1664,14 +1634,13 @@ } void -DrawStarBackGround (BOOLEAN ForPlanet) +DrawStarBackGround (void) { COUNT i, j; DWORD rand_val; STAMP s; DWORD old_seed; - SetContext (SpaceContext); SetContextBackGroundColor (BLACK_COLOR); ClearDrawable (); @@ -1710,58 +1679,6 @@ s.frame = IncFrameIndex (s.frame); } - if (ForPlanet) - { - RECT r; - - // 2002-12-13 PhracturedBlue's fix to planet changing color when - // using device problem - /*if (pSolarSysState->MenuState.flash_task - || (LastActivity & CHECK_LOAD)) - RenderTopography (TRUE);*/ - - BatchGraphics (); - - SetContext (ScreenContext); - - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 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 (0x08, 0x08, 0x08), 0x1F)); - r.extent.width = 1; - r.extent.height = MAP_HEIGHT + 1; - r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT; - r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH - 1; - DrawFilledRectangle (&r); - r.corner.x = SIS_ORG_X + SIS_SCREEN_WIDTH; - DrawFilledRectangle (&r); - r.extent.width = SIS_SCREEN_WIDTH + 1; - r.extent.height = 1; - r.corner.x = SIS_ORG_X; - r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 5; - DrawFilledRectangle (&r); - - 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; - DrawFilledRectangle (&r); - r.extent.width = 1; - r.extent.height = MAP_HEIGHT + 1; - r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT; - r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH - 1; - DrawFilledRectangle (&r); - - UnbatchGraphics (); - } - TFB_SeedRandom (old_seed); } Modified: trunk/sc2/src/uqm/setup.h =================================================================== --- trunk/sc2/src/uqm/setup.h 2009-12-01 17:18:26 UTC (rev 3379) +++ trunk/sc2/src/uqm/setup.h 2009-12-01 20:43:33 UTC (rev 3380) @@ -34,6 +34,9 @@ extern FRAME FontGradFrame; extern CONTEXT OffScreenContext; + // OffScreenContext can often refer to a deleted ForeGroundFrame + // Always call SetContextFGFrame() before drawing anything to it + // Neither is the state of its ClipRect guaranteed. extern CONTEXT ScreenContext; extern CONTEXT SpaceContext; extern CONTEXT StatusContext; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-03 21:36:39
|
Revision: 3385 http://sc2.svn.sourceforge.net/sc2/?rev=3385&view=rev Author: avolkov Date: 2009-12-03 21:36:32 +0000 (Thu, 03 Dec 2009) Log Message: ----------- Cleanup: use IP location<->display conversion functions; some ipdisp clarifications Modified Paths: -------------- trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/grpinfo.c trunk/sc2/src/uqm/ipdisp.c trunk/sc2/src/uqm/planets/generate/gensam.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/solarsys.c Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-12-03 03:54:12 UTC (rev 3384) +++ trunk/sc2/src/uqm/element.h 2009-12-03 21:36:32 UTC (rev 3385) @@ -134,11 +134,16 @@ * with CREATURE_AWARE * - for canned bio: value of creature */ - BYTE sys_loc; /* IP: location in system */ + // TODO: Use a different name for Planetside bio, like + // BYTE bio_state; }; - BYTE turn_wait; union { + BYTE turn_wait; + BYTE sys_loc; /* IP flagship: location in system */ + }; + union + { BYTE thrust_wait; BYTE blast_offset; BYTE next_turn; /* Battle: animation interframe for some elements */ Modified: trunk/sc2/src/uqm/grpinfo.c =================================================================== --- trunk/sc2/src/uqm/grpinfo.c 2009-12-03 03:54:12 UTC (rev 3384) +++ trunk/sc2/src/uqm/grpinfo.c 2009-12-03 21:36:32 UTC (rev 3385) @@ -656,8 +656,7 @@ COUNT angle; POINT org; - XFormIPLoc (&pSolarSysState->PlanetDesc[group_loc - 1] - .image.origin, &org, FALSE); + org = planetOuterLocation (group_loc - 1); angle = FACING_TO_ANGLE (GroupPtr->orbit_pos + 1); GroupPtr->loc.x = org.x + COSINE (angle, STATION_RADIUS); GroupPtr->loc.y = org.y + SINE (angle, STATION_RADIUS); Modified: trunk/sc2/src/uqm/ipdisp.c =================================================================== --- trunk/sc2/src/uqm/ipdisp.c 2009-12-03 03:54:12 UTC (rev 3384) +++ trunk/sc2/src/uqm/ipdisp.c 2009-12-03 21:36:32 UTC (rev 3385) @@ -97,6 +97,43 @@ } } +static SIZE +zoomRadiusForLocation (BYTE location) +{ + if (location == 0) + { // In outer system view; use current zoom radius + return pSolarSysState->SunDesc[0].radius; + } + else + { // In inner system view; always max zoom + return MAX_ZOOM_RADIUS; + } +} + +static inline void +adjustDeltaVforZoom (SIZE zoom, SIZE *dx, SIZE *dy) +{ + if (zoom == MIN_ZOOM_RADIUS) + { + *dx >>= 2; + *dy >>= 2; + } + else if (zoom < MAX_ZOOM_RADIUS) + { + *dx >>= 1; + *dy >>= 1; + } +} + +static BYTE +getFlagshipLocation (void) +{ + if (!playerInInnerSystem ()) + return 0; + else + return 1 + planetIndex (pSolarSysState, pSolarSysState->pOrbitalDesc); +} + static void ip_group_preprocess (ELEMENT *ElementPtr) { @@ -117,17 +154,8 @@ group_loc = GroupPtr->sys_loc; // save old location DisplayArray[EPtr->PrimIndex].Object.Point = GroupPtr->loc; - if (group_loc != 0) - radius = MAX_ZOOM_RADIUS; - else - radius = pSolarSysState->SunDesc[0].radius; - - dest_pt.x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)GroupPtr->loc.x - * (DISPLAY_FACTOR >> 1) / radius); - dest_pt.y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)GroupPtr->loc.y - * (DISPLAY_FACTOR >> 1) / radius); + radius = zoomRadiusForLocation (group_loc); + dest_pt = locationToDisplay (GroupPtr->loc, radius); EPtr->current.location.x = DISPLAY_TO_WORLD (dest_pt.x) + (COORD)(LOG_SPACE_WIDTH >> 1) - (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1)); @@ -137,11 +165,7 @@ InitIntersectStartPoint (EPtr); - if (!playerInInnerSystem ()) - flagship_loc = 0; - else - flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc - - pSolarSysState->PlanetDesc + 1); + flagship_loc = getFlagshipLocation (); task = GroupPtr->task; @@ -246,13 +270,7 @@ else { orbit_dist = STATION_RADIUS; - XFormIPLoc ( - &pSolarSysState->PlanetDesc[ - target_loc - 1 - ].image.origin, - &org, - FALSE - ); + org = planetOuterLocation (target_loc - 1); } angle = FACING_TO_ANGLE (GroupPtr->orbit_pos + 1); @@ -289,8 +307,7 @@ if (GroupPtr->dest_loc == 0) dest_pt = pSolarSysState->SunDesc[0].location; else - XFormIPLoc (&pSolarSysState->PlanetDesc[ - target_loc - 1].image.origin, &dest_pt, FALSE); + dest_pt = planetOuterLocation (target_loc - 1); } else { @@ -331,12 +348,13 @@ EPtr->thrust_wait = TRACK_WAIT; } - SetVelocityComponents (&EPtr->velocity, - vdx = COSINE (angle, speed), - vdy = SINE (angle, speed)); + vdx = COSINE (angle, speed); + vdy = SINE (angle, speed); + SetVelocityComponents (&EPtr->velocity, vdx, vdy); } - dx = vdx, dy = vdy; + dx = vdx; + dy = vdy; if (group_loc == target_loc) { if (target_loc == 0) @@ -351,7 +369,8 @@ >= (long)delta_x * delta_x + (long)delta_y * delta_y) { GroupPtr->loc = dest_pt; - vdx = vdy = 0; + vdx = 0; + vdy = 0; ZeroVelocityComponents (&EPtr->velocity); } } @@ -359,17 +378,8 @@ else { if (group_loc == 0) - { - if (pSolarSysState->SunDesc[0].radius < MAX_ZOOM_RADIUS) - { - dx >>= 1; - dy >>= 1; - if (pSolarSysState->SunDesc[0].radius == MIN_ZOOM_RADIUS) - { - dx >>= 1; - dy >>= 1; - } - } + { // In outer system + adjustDeltaVforZoom (radius, &dx, &dy); if (task == ON_STATION && GroupPtr->dest_loc) goto PartialRevolution; @@ -378,14 +388,9 @@ Transition = TRUE; } else - { + { // In inner system; also leaving outer CheckGetAway hack CheckGetAway: - dest_pt.x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)GroupPtr->loc.x - * (DISPLAY_FACTOR >> 1) / MAX_ZOOM_RADIUS); - dest_pt.y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)GroupPtr->loc.y - * (DISPLAY_FACTOR >> 1) / MAX_ZOOM_RADIUS); + dest_pt = locationToDisplay (GroupPtr->loc, radius); if (dest_pt.x < 0 || dest_pt.x >= SIS_SCREEN_WIDTH || dest_pt.y < 0 @@ -398,15 +403,12 @@ /* no collisions during transition */ EPtr->state_flags |= NONSOLID; - vdx = vdy = 0; + vdx = 0; + vdy = 0; ZeroVelocityComponents (&EPtr->velocity); if (group_loc != 0) { - PLANET_DESC *pCurDesc; - - pCurDesc = &pSolarSysState->PlanetDesc[group_loc - 1]; - XFormIPLoc (&pCurDesc->image.origin, &GroupPtr->loc, - FALSE); + GroupPtr->loc = planetOuterLocation (group_loc - 1); group_loc = 0; GroupPtr->sys_loc = 0; } @@ -420,6 +422,8 @@ } else { + POINT entryPt; + if (target_loc == GroupPtr->dest_loc) { GroupPtr->orbit_pos = NORMALIZE_FACING ( @@ -428,14 +432,17 @@ ((COUNT)TFB_Random () % MAX_REVOLUTIONS) << FACING_SHIFT; } - - GroupPtr->loc.x = -(SIZE)((long)COSINE ( - angle, SIS_SCREEN_WIDTH * 9 / 16 - ) * MAX_ZOOM_RADIUS / (DISPLAY_FACTOR >> 1)); - GroupPtr->loc.y = -(SIZE)((long)SINE ( - angle, SIS_SCREEN_WIDTH * 9 / 16 - ) * MAX_ZOOM_RADIUS / (DISPLAY_FACTOR >> 1)); - + // The group enters inner system exactly on the edge of a + // circle with radius = 9/16 * window-dim, which is + // different from how the flagship enters, but similar + // in the way that the group will never show up in any + // of the corners. + entryPt.x = (SIS_SCREEN_WIDTH >> 1) - COSINE (angle, + SIS_SCREEN_WIDTH * 9 / 16); + entryPt.y = (SIS_SCREEN_HEIGHT >> 1) - SINE (angle, + SIS_SCREEN_HEIGHT * 9 / 16); + GroupPtr->loc = displayToLocation (entryPt, + MAX_ZOOM_RADIUS); group_loc = target_loc; GroupPtr->sys_loc = target_loc; } @@ -443,32 +450,12 @@ } } - if (group_loc != 0) - radius = MAX_ZOOM_RADIUS; - else - { - radius = pSolarSysState->SunDesc[0].radius; - if (radius < MAX_ZOOM_RADIUS) - { - vdx >>= 1; - vdy >>= 1; - if (radius == MIN_ZOOM_RADIUS) - { - vdx >>= 1; - vdy >>= 1; - } - } - } + radius = zoomRadiusForLocation (group_loc); + adjustDeltaVforZoom (radius, &vdx, &vdy); GroupPtr->loc.x += vdx; GroupPtr->loc.y += vdy; - dest_pt.x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)GroupPtr->loc.x - * (DISPLAY_FACTOR >> 1) / radius); - dest_pt.y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)GroupPtr->loc.y - * (DISPLAY_FACTOR >> 1) / radius); - + dest_pt = locationToDisplay (GroupPtr->loc, radius); EPtr->next.location.x = DISPLAY_TO_WORLD (dest_pt.x) + (COORD)(LOG_SPACE_WIDTH >> 1) - (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1)); @@ -583,9 +570,8 @@ ELEMENT *IPSHIPElementPtr; LockElement (hIPSHIPElement, &IPSHIPElementPtr); - // XXX: turn_wait hack is not actually used anywhere - //IPSHIPElementPtr->turn_wait = GroupPtr->group_id; - IPSHIPElementPtr->sys_loc = 1; + // Must have mass_points for collisions to work + IPSHIPElementPtr->mass_points = 1; IPSHIPElementPtr->hit_points = 1; IPSHIPElementPtr->state_flags = CHANGING | FINITE_LIFE | IGNORE_VELOCITY; @@ -608,18 +594,9 @@ SIZE radius; POINT pt; - if (GroupPtr->sys_loc != 0) - radius = MAX_ZOOM_RADIUS; - else - radius = pSolarSysState->SunDesc[0].radius; + radius = zoomRadiusForLocation (GroupPtr->sys_loc); + pt = locationToDisplay (GroupPtr->loc, radius); - pt.x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)GroupPtr->loc.x - * DISPLAY_FACTOR / radius); - pt.y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)GroupPtr->loc.y - * (DISPLAY_FACTOR >> 1) / radius); - IPSHIPElementPtr->current.location.x = DISPLAY_TO_WORLD (pt.x) + (COORD)(LOG_SPACE_WIDTH >> 1) @@ -676,34 +653,11 @@ GetCurrentVelocityComponents (&GLOBAL (velocity), &vdx, &vdy); - if (playerInInnerSystem ()) - { - flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc - - pSolarSysState->PlanetDesc + 2); - radius = MAX_ZOOM_RADIUS; - } - else - { - flagship_loc = 1; - radius = pSolarSysState->SunDesc[0].radius; - if (radius < MAX_ZOOM_RADIUS) - { - vdx >>= 1; - vdy >>= 1; - if (radius == MIN_ZOOM_RADIUS) - { - vdx >>= 1; - vdy >>= 1; - } - } - } + flagship_loc = getFlagshipLocation (); + radius = zoomRadiusForLocation (flagship_loc); + adjustDeltaVforZoom (radius, &vdx, &vdy); - pt.x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)GLOBAL (ip_location.x) - * (DISPLAY_FACTOR >> 1) / radius); - pt.y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)GLOBAL (ip_location.y) - * (DISPLAY_FACTOR >> 1) / radius); + pt = locationToDisplay (GLOBAL (ip_location), radius); ElementPtr->current.location.x = DISPLAY_TO_WORLD (pt.x) + (COORD)(LOG_SPACE_WIDTH >> 1) - (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1)); @@ -715,12 +669,7 @@ GLOBAL (ip_location.x) += vdx; GLOBAL (ip_location.y) += vdy; - pt.x = (SIS_SCREEN_WIDTH >> 1) - + (SIZE)((long)GLOBAL (ip_location.x) - * (DISPLAY_FACTOR >> 1) / radius); - pt.y = (SIS_SCREEN_HEIGHT >> 1) - + (SIZE)((long)GLOBAL (ip_location.y) - * (DISPLAY_FACTOR >> 1) / radius); + pt = locationToDisplay (GLOBAL (ip_location), radius); ElementPtr->next.location.x = DISPLAY_TO_WORLD (pt.x) + (COORD)(LOG_SPACE_WIDTH >> 1) - (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1)); @@ -767,12 +716,9 @@ LockElement (hFlagShipElement, &FlagShipElementPtr); FlagShipElementPtr->hit_points = 1; - if (!playerInInnerSystem ()) - FlagShipElementPtr->sys_loc = 1; - else - FlagShipElementPtr->sys_loc = - (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc - - pSolarSysState->PlanetDesc + 2); + // Must have mass_points for collisions to work + FlagShipElementPtr->mass_points = 1; + FlagShipElementPtr->sys_loc = getFlagshipLocation (); FlagShipElementPtr->state_flags = APPEARING | IGNORE_VELOCITY; if (GET_GAME_STATE (ESCAPE_COUNTER)) FlagShipElementPtr->state_flags |= NONSOLID; Modified: trunk/sc2/src/uqm/planets/generate/gensam.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensam.c 2009-12-03 03:54:12 UTC (rev 3384) +++ trunk/sc2/src/uqm/planets/generate/gensam.c 2009-12-03 21:36:32 UTC (rev 3385) @@ -114,7 +114,7 @@ COUNT angle; POINT org; - XFormIPLoc (&solarSys->PlanetDesc[4].image.origin, &org, FALSE); + org = planetOuterLocation (4); angle = ARCTAN (GLOBAL (ip_location.x) - org.x, GLOBAL (ip_location.y) - org.y); GLOBAL (ip_location.x) = org.x + COSINE (angle, 3000); @@ -275,7 +275,7 @@ GetGroupInfo (GLOBAL (BattleGroupRef), GROUP_INIT_IP); - XFormIPLoc (&solarSys->PlanetDesc[4].image.origin, &org, FALSE); + org = planetOuterLocation (4); hGroup = GetHeadLink (&GLOBAL (ip_group_q)); for (b0 = 0, b1 = 0; b0 < NUM_URQUAN_GUARDS0; Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-12-03 03:54:12 UTC (rev 3384) +++ trunk/sc2/src/uqm/planets/planets.h 2009-12-03 21:36:32 UTC (rev 3385) @@ -236,6 +236,10 @@ bool matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world, BYTE planetI, BYTE moonI); +POINT locationToDisplay (POINT pt, SIZE scaleRadius); +POINT displayToLocation (POINT pt, SIZE scaleRadius); +POINT planetOuterLocation (COUNT planetI); + extern void LoadPlanet (FRAME SurfDefFrame); extern void DrawPlanet (int x, int y, int dy, Color rgb); extern void FreePlanet (void); Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-12-03 03:54:12 UTC (rev 3384) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-03 21:36:32 UTC (rev 3385) @@ -85,7 +85,7 @@ #define DISPLAY_TO_LOC (DISPLAY_FACTOR >> 1) -static POINT +POINT locationToDisplay (POINT pt, SIZE scaleRadius) { POINT out; @@ -98,7 +98,7 @@ return out; } -static POINT +POINT displayToLocation (POINT pt, SIZE scaleRadius) { POINT out; @@ -111,6 +111,14 @@ return out; } +POINT +planetOuterLocation (COUNT planetI) +{ + SIZE scaleRadius = pSolarSysState->SunDesc[0].radius; + return displayToLocation (pSolarSysState->PlanetDesc[planetI].image.origin, + scaleRadius); +} + bool worldIsPlanet (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world) { @@ -892,8 +900,8 @@ GLOBAL (ip_location) = displayToLocation ( GLOBAL (ShipStamp.origin), MAX_ZOOM_RADIUS); - XFormIPLoc (&planet->image.origin, &pSolarSysState->SunDesc[0].location, - FALSE); + pSolarSysState->SunDesc[0].location = + planetOuterLocation (planetIndex (pSolarSysState, planet)); ZeroVelocityComponents (&GLOBAL (velocity)); GenerateMoons (pSolarSysState, planet); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-04 00:42:48
|
Revision: 3388 http://sc2.svn.sourceforge.net/sc2/?rev=3388&view=rev Author: avolkov Date: 2009-12-04 00:12:12 +0000 (Fri, 04 Dec 2009) Log Message: ----------- Cleanup of key repeat set functions usage Modified Paths: -------------- trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/pickmele.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/pstarmap.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/restart.c Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/gameinp.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -34,7 +34,7 @@ #define ACCELERATION_INCREMENT (ONE_SECOND / 12) -#define MENU_REPEAT_DELAY (ONE_SECOND >> 1) +#define MENU_REPEAT_DELAY (ONE_SECOND / 2) typedef struct @@ -283,18 +283,18 @@ _max_accel = max; _step_accel = step; _gestalt_keys = gestalt; - _clear_menu_state (); + //_clear_menu_state (); ResetKeyRepeat (); } void -SetDefaultMenuRepeatDelay () +SetDefaultMenuRepeatDelay (void) { _min_accel = ACCELERATION_INCREMENT; _max_accel = MENU_REPEAT_DELAY; _step_accel = ACCELERATION_INCREMENT; _gestalt_keys = FALSE; - _clear_menu_state (); + //_clear_menu_state (); ResetKeyRepeat (); } @@ -340,8 +340,6 @@ void DoInput (void *pInputState, BOOLEAN resetInput) { - SetMenuRepeatDelay (ACCELERATION_INCREMENT, MENU_REPEAT_DELAY, - ACCELERATION_INCREMENT, FALSE); if (resetInput) FlushInput (); Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/hyper.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -1655,7 +1655,6 @@ break; case STARMAP: StarMap (); - SetDefaultMenuRepeatDelay (); return FALSE; case NAVIGATION: return FALSE; Modified: trunk/sc2/src/uqm/pickmele.c =================================================================== --- trunk/sc2/src/uqm/pickmele.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/pickmele.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -618,7 +618,7 @@ SetContext (OffScreenContext); UnlockMutex (GraphicsLock); - ResetKeyRepeat (); + DoInput (&gmstate, FALSE); WaitForSoundEnd (0); Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/planets/planets.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -424,7 +424,6 @@ TaskSwitch (); AutoPilotSet = StarMap (); - SetDefaultMenuRepeatDelay (); if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -1216,6 +1216,7 @@ tes.FrameCallback = OnStarNameFrame; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + SetDefaultMenuRepeatDelay (); success = DoTextEntry (&tes); LockMutex (GraphicsLock); @@ -1243,9 +1244,6 @@ pMS->Initialized = TRUE; pMS->InputFunc = DoMoveCursor; - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, TRUE); - if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE) universe = CurStarDescPtr->star_pt; else @@ -1636,8 +1634,12 @@ UnbatchGraphics (); UnlockMutex (GraphicsLock); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, + TRUE); DoInput (&MenuState, FALSE); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + SetDefaultMenuRepeatDelay (); LockMutex (GraphicsLock); DrawHyperCoords (universe); Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -656,7 +656,6 @@ if (!pMS->Initialized) { pMS->InputFunc = PickPlanetSide; - SetMenuRepeatDelay (0, 0, 0, FALSE); SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); if (!select) { @@ -756,7 +755,6 @@ pMS->InputFunc = DoScan; pMS->CurState = DISPATCH_SHUTTLE; - SetDefaultMenuRepeatDelay (); } else { @@ -766,13 +764,13 @@ new_pt = planetLoc; - if (PulsedInputState.menu[KEY_MENU_LEFT]) + if (CurrentInputState.menu[KEY_MENU_LEFT]) dx = -1; - if (PulsedInputState.menu[KEY_MENU_RIGHT]) + if (CurrentInputState.menu[KEY_MENU_RIGHT]) dx = 1; - if (PulsedInputState.menu[KEY_MENU_UP]) + if (CurrentInputState.menu[KEY_MENU_UP]) dy = -1; - if (PulsedInputState.menu[KEY_MENU_DOWN]) + if (CurrentInputState.menu[KEY_MENU_DOWN]) dy = 1; LockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -1960,8 +1960,6 @@ break; case STARMAP: StarMap (); - SetDefaultMenuRepeatDelay (); - if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; Modified: trunk/sc2/src/uqm/restart.c =================================================================== --- trunk/sc2/src/uqm/restart.c 2009-12-03 22:38:07 UTC (rev 3387) +++ trunk/sc2/src/uqm/restart.c 2009-12-04 00:12:12 UTC (rev 3388) @@ -318,6 +318,7 @@ DrawRestartMenuGraphic (pMS); GLOBAL (CurrentActivity) &= ~CHECK_ABORT; SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); + SetDefaultMenuRepeatDelay (); DoInput (pMS, TRUE); StopMusic (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-05 22:15:31
|
Revision: 3393 http://sc2.svn.sourceforge.net/sc2/?rev=3393&view=rev Author: avolkov Date: 2009-12-05 22:15:23 +0000 (Sat, 05 Dec 2009) Log Message: ----------- Planet rotation task retired; this introduces a DoInput frame callback and lays the foundation for the removal of credits task Modified Paths: -------------- trunk/sc2/src/uqm/confirm.c trunk/sc2/src/uqm/controls.h trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/planets/generate.h trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/pl_stuff.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/plangen.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/restart.c trunk/sc2/src/uqm/util.c Modified: trunk/sc2/src/uqm/confirm.c =================================================================== --- trunk/sc2/src/uqm/confirm.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/confirm.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -108,13 +108,7 @@ SetSystemRect (&r); DrawConfirmationWindow (response); - - // Releasing the lock lets the rotate_planet_task - // draw a frame. PauseRotate can still allow one more frame - // to be drawn, so it is safer to just not release the lock - //UnlockMutex (GraphicsLock); FlushGraphics (); - //LockMutex (GraphicsLock); FlushInput (); done = FALSE; @@ -188,7 +182,8 @@ (void)self; SleepThread (ONE_SECOND / 20); return !(PulsedInputState.menu[KEY_MENU_SELECT] || - PulsedInputState.menu[KEY_MENU_CANCEL]); + PulsedInputState.menu[KEY_MENU_CANCEL] || + (GLOBAL (CurrentActivity) & CHECK_ABORT)); } void @@ -205,7 +200,7 @@ RECT windowRect; POPUP_STATE state; MENU_SOUND_FLAGS s0, s1; - + InputFrameCallback *oldCallback; if (!bank) { @@ -247,10 +242,12 @@ GetMenuSounds (&s0, &s1); SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + oldCallback = SetInputCallback (NULL); state.InputFunc = DoPopup; DoInput (&state, TRUE); + SetInputCallback (oldCallback); ClearSystemRect (); DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); Modified: trunk/sc2/src/uqm/controls.h =================================================================== --- trunk/sc2/src/uqm/controls.h 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/controls.h 2009-12-05 22:15:23 UTC (rev 3393) @@ -113,6 +113,13 @@ BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); void DoPopupWindow(const char *msg); + +typedef void (InputFrameCallback) (void); +// Anything using input callbacks MUST NOT keep GraphicsLock across +// InputFunc executions. This also means NOT holding GraphicsLock +// when calling DoInput(). +InputFrameCallback* SetInputCallback (InputFrameCallback *); +// pInputState must point to a struct derived from INPUT_STATE_DESC void DoInput (void *pInputState, BOOLEAN resetInput); extern volatile BOOLEAN GamePaused; Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/gameinp.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -68,6 +68,8 @@ volatile BOOLEAN ExitRequested; volatile BOOLEAN GamePaused; +static InputFrameCallback *inputCallback; + static void _clear_menu_state (void) { @@ -275,7 +277,19 @@ ExitRequested = TRUE; } +InputFrameCallback * +SetInputCallback (InputFrameCallback *callback) +{ + InputFrameCallback *old = inputCallback; + + // Replacing an existing callback with another is not a problem, + // but currently this should never happen, which is why the assert. + assert (!old || !callback); + inputCallback = callback; + return old; +} + void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt) { @@ -384,6 +398,10 @@ PlaySoundEffect (S, 0, NotPositional (), NULL, 0); } + + if (inputCallback) + inputCallback (); + } while (((INPUT_STATE_DESC*)pInputState)->InputFunc (pInputState)); if (resetInput) Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/gameopt.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -1099,14 +1099,12 @@ RECT DlgRect; STAMP DlgStamp; TimeCount TimeOut; + InputFrameCallback *oldCallback; TimeOut = FadeMusic (0, ONE_SECOND / 2); - if (pSolarSysState) - { - pSolarSysState->PauseRotate = 1; - TaskSwitch (); - } + // Deactivate any background drawing, like planet rotation + oldCallback = SetInputCallback (NULL); LoadGameDescriptions (desc_array); @@ -1128,6 +1126,7 @@ FadeMusic (NORMAL_VOLUME, 0); DoInput (pMS, TRUE); + LockMutex (GraphicsLock); pMS->Initialized = FALSE; pMS->InputFunc = DoGameOptions; @@ -1148,9 +1147,6 @@ DrawStamp (&DlgStamp); ScreenTransition (3, &DlgRect); UnbatchGraphics (); - - if (pSolarSysState) - pSolarSysState->PauseRotate = 0; } DestroyDrawable (ReleaseDrawable (DlgStamp.frame)); @@ -1158,6 +1154,9 @@ SetContext (OldContext); UnlockMutex (GraphicsLock); + // Reactivate any background drawing, like planet rotation + SetInputCallback (oldCallback); + return (retval); } Modified: trunk/sc2/src/uqm/planets/generate.h =================================================================== --- trunk/sc2/src/uqm/planets/generate.h 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/generate.h 2009-12-05 22:15:23 UTC (rev 3393) @@ -28,6 +28,8 @@ * - split off pickupMineral, pickupEnergy, pickupLife from Generate* * - split off generateOrbital in a calculation and an activation * (graphics and music) part. + * - make generateOrbital return a meaningful value, specifically, whether + * or not the player is going into orbit * - for GenerateNameFunction, set the name in an argument, instead * of in GLOBAL_SYS(PlanetName) * - make generateName work for moons Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/lander.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -1312,52 +1312,78 @@ } static void +animationInterframe (TimeCount *TimeIn, COUNT periods) +{ +#define ANIM_FRAME_RATE (ONE_SECOND / 30) + + for ( ; periods; --periods) + { + LockMutex (GraphicsLock); + RotatePlanetSphere (TRUE); + UnlockMutex (GraphicsLock); + + SleepThreadUntil (*TimeIn + ANIM_FRAME_RATE); + *TimeIn = GetTimeCounter (); + } +} + +static void AnimateLaunch (FRAME farray) { RECT r; STAMP s; COUNT num_frames; - DWORD Time; + TimeCount NextTime; - Time = GetTimeCounter (); + LockMutex (GraphicsLock); + SetContext (SpaceContext); - s.origin.x = s.origin.y = 0; - s.frame = DecFrameIndex (farray); + r.corner.x = 0; + r.corner.y = 0; + r.extent.width = 0; + s.origin.x = 0; + s.origin.y = 0; + s.frame = farray; - num_frames = GetFrameCount (s.frame); - do + for (num_frames = GetFrameCount (s.frame); num_frames; --num_frames) { - GetFrameRect (s.frame, &r); - s.frame = IncFrameIndex (s.frame); + NextTime = GetTimeCounter () + (ONE_SECOND / 22); + + BatchGraphics (); RepairBackRect (&r); +#ifdef SPIN_ON_LAUNCH + RotatePlanetSphere (FALSE); +#else + DrawDefaultPlanetSphere (); +#endif DrawStamp (&s); - + UnbatchGraphics (); UnlockMutex (GraphicsLock); - SleepThreadUntil (Time + (ONE_SECOND / 22)); - Time = GetTimeCounter (); + GetFrameRect (s.frame, &r); + s.frame = IncFrameIndex (s.frame); + SleepThreadUntil (NextTime); + LockMutex (GraphicsLock); - } while (--num_frames); + } - GetFrameRect (s.frame, &r); RepairBackRect (&r); + UnlockMutex (GraphicsLock); } static void -InitPlanetSide (POINT pt) +AnimateLanderWarmup (void) { SIZE num_crew; STAMP s; CONTEXT OldContext; - DWORD Time; + TimeCount TimeIn = GetTimeCounter (); LockMutex (GraphicsLock); OldContext = SetContext (RadarContext); UnlockMutex (GraphicsLock); - Time = GetTimeCounter (); - s.origin.x = 0; s.origin.y = 0; s.frame = SetAbsFrameIndex (LanderFrame[0], @@ -1367,22 +1393,20 @@ DrawStamp (&s); UnlockMutex (GraphicsLock); - SleepThread (ONE_SECOND / 15); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); for (num_crew = 0; num_crew < (NUM_CREW_COLS * NUM_CREW_ROWS) && GLOBAL_SIS (CrewEnlisted); ++num_crew) { - SleepThreadUntil (Time + ONE_SECOND / 30); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 1); + LockMutex (GraphicsLock); DeltaSISGauges (-1, 0, 0); DeltaLanderCrew (1, 0); UnlockMutex (GraphicsLock); } - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); if (GET_GAME_STATE (IMPROVED_LANDER_SHOT)) s.frame = SetAbsFrameIndex (s.frame, 58); @@ -1393,8 +1417,7 @@ DrawStamp (&s); UnlockMutex (GraphicsLock); - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); if (GET_GAME_STATE (IMPROVED_LANDER_SPEED)) s.frame = SetAbsFrameIndex (s.frame, 57); @@ -1406,8 +1429,7 @@ DrawStamp (&s); UnlockMutex (GraphicsLock); - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); s.frame = IncFrameIndex (s.frame); } @@ -1417,31 +1439,23 @@ if (GET_GAME_STATE (IMPROVED_LANDER_CARGO)) { - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); s.frame = SetAbsFrameIndex (s.frame, 59); LockMutex (GraphicsLock); DrawStamp (&s); UnlockMutex (GraphicsLock); } -#ifndef SPIN_ON_LAUNCH - pSolarSysState->PauseRotate = 1; -#endif - SleepThreadUntil (Time + (ONE_SECOND / 15)); - LockMutex (GraphicsLock); + animationInterframe (&TimeIn, 2); + PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_DEPARTS), NotPositional (), NULL, GAME_SOUND_PRIORITY + 1); - SetContext (SpaceContext); - AnimateLaunch (LanderFrame[5]); -#ifdef SPIN_ON_LAUNCH - pSolarSysState->PauseRotate = 1; - UnlockMutex (GraphicsLock); - TaskSwitch (); - LockMutex (GraphicsLock); -#endif +} +static void +InitPlanetSide (POINT pt) +{ // Adjust landing location by a random jitter. #define RANDOM_MISS 64 // Jitter the X landing point. @@ -1460,6 +1474,7 @@ curLanderLoc = pt; + LockMutex (GraphicsLock); SetContext (SpaceContext); SetContextFont (TinyFont); @@ -1495,12 +1510,8 @@ ScreenTransition (3, &r); UnbatchGraphics (); - - LoadIntoExtraScreen (&r); } - SetContext (OldContext); - UnlockMutex (GraphicsLock); SET_GAME_STATE (PLANETARY_LANDING, 1); @@ -1810,7 +1821,6 @@ ScreenTransition (3, pRect); UnbatchGraphics (); - LoadIntoExtraScreen (pRect); SetContext (OldContext); UnlockMutex (GraphicsLock); } @@ -1960,8 +1970,9 @@ crew_left = 0; damage_index = 0; explosion_index = 0; - pSolarSysState->MenuState.Initialized += 4; + AnimateLanderWarmup (); + AnimateLaunch (LanderFrame[5]); InitPlanetSide (planetLoc); landerInputState.NextTime = GetTimeCounter () + PLANET_SIDE_RATE; @@ -1999,18 +2010,9 @@ LandingTakeoffSequence (&landerInputState, FALSE); ReturnToOrbit (&r); -#ifdef SPIN_ON_LAUNCH - // If PauseRotate is set to 2 the plaet will be displayed, but won't rotate - // Until the lander animation is complete - pSolarSysState->PauseRotate = 0; - // Give The RotatePlanet thread a slice to draw the planet - SleepThread (1); -#endif - - LockMutex (GraphicsLock); - SetContext (SpaceContext); - AnimateLaunch (LanderFrame[6]); + + LockMutex (GraphicsLock); DeltaSISGauges (crew_left, 0, 0); if (PSD.ElementLevel) @@ -2024,7 +2026,6 @@ } DrawStorageBays (FALSE); } - UnlockMutex (GraphicsLock); GLOBAL_SIS (TotalBioMass) += PSD.BiologicalLevel; @@ -2058,9 +2059,6 @@ ZeroVelocityComponents (&GLOBAL (velocity)); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - - pSolarSysState->MenuState.Initialized -= 4; - pSolarSysState->PauseRotate = 0; } void Modified: trunk/sc2/src/uqm/planets/pl_stuff.c =================================================================== --- trunk/sc2/src/uqm/planets/pl_stuff.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/pl_stuff.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -69,7 +69,16 @@ UnbatchGraphics (); } +void +DrawDefaultPlanetSphere (void) +{ + CONTEXT oldContext; + oldContext = SetContext (SpaceContext); + DrawPlanetSphere (SIS_SCREEN_WIDTH / 2, PLANET_ORG_Y); + SetContext (oldContext); +} + void InitSphereRotation (int direction, BOOLEAN shielded) { @@ -218,6 +227,21 @@ } } +void +RotatePlanetSphere (BOOLEAN keepRate) +{ + static TimeCount NextTime; + TimeCount Now = GetTimeCounter (); + + if (keepRate && Now < NextTime) + return; // not time yet + + NextTime = Now + PLANET_ROTATION_RATE; + DrawDefaultPlanetSphere (); + + PrepareNextRotationFrame (); +} + // rgb.a is ignored void DrawPlanet (int x, int y, int dy, Color rgb) Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/planets.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -35,9 +35,6 @@ #include "libs/graphics/gfx_common.h" -extern int rotate_planet_task (void *data); - - void DrawScannedObjects (BOOLEAN Reversed) { @@ -170,8 +167,13 @@ DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } - else + else if (Mode == DRAW_ORBITAL_FULL) { + DrawDefaultPlanetSphere (); + } + + if (Mode != DRAW_ORBITAL_WAIT) + { DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, BLACK_COLOR); } @@ -185,6 +187,7 @@ if (Mode != DRAW_ORBITAL_WAIT) { + // for later RepairBackRect() LoadIntoExtraScreen (&r); } } @@ -207,7 +210,7 @@ #endif WaitMode = !(LastActivity & CHECK_LOAD) && - (pSolarSysState->MenuState.Initialized <= 2); + (pSolarSysState->MenuState.Initialized != 3); if (WaitMode) { @@ -216,9 +219,11 @@ UnlockMutex (GraphicsLock); } - if (pSolarSysState->MenuState.flash_task == 0) + // TODO: split off the scan screen redraw code into a separate + // function so that we could lose this hack. + if (!pSolarSysState->TopoFrame) { - // The "rotate planets" task is not initialised yet. + // TopoFrame has not been initialised yet. // This means the call to LoadPlanet is made from some // GenerateFunctions.generateOribital() function. PLANET_DESC *pPlanetDesc; @@ -231,10 +236,6 @@ GeneratePlanetSurface (pPlanetDesc, SurfDefFrame); SetPlanetMusic (pPlanetDesc->data_index & ~PLANET_SHIELDED); - - if (pPlanetDesc->pPrevDesc != &pSolarSysState->SunDesc[0]) - pPlanetDesc = pPlanetDesc->pPrevDesc; - GeneratePlanetSide (); } @@ -245,20 +246,14 @@ if (!PLRPlaying ((MUSIC_REF)~0)) PlayMusic (LanderMusic, TRUE, 1); - if (pSolarSysState->MenuState.flash_task == 0) + if (WaitMode) { assert (pSolarSysState->MenuState.Initialized == 2); - // Only zoom when not already in orbit - if (!(LastActivity & CHECK_LOAD)) - ZoomInPlanetSphere (); + ZoomInPlanetSphere (); // XXX: Mark as in-orbit. This should go away eventually pSolarSysState->MenuState.Initialized = 3; - - pSolarSysState->MenuState.flash_task = - AssignTask (rotate_planet_task, 4096, - "rotate planets"); } } @@ -268,13 +263,6 @@ COUNT i; PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; - if (pSolarSysState->MenuState.flash_task) - { - ConcludeTask (pSolarSysState->MenuState.flash_task); -// Task_SetState (pSolarSysState->MenuState.flash_task, TASK_EXIT); - pSolarSysState->MenuState.flash_task = 0; - } - UninitSphereRotation (); StopMusic (); @@ -331,7 +319,6 @@ )); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - pSolarSysState->PauseRotate = 0; UnlockMutex (GraphicsLock); } @@ -402,24 +389,25 @@ case STARMAP: { BOOLEAN AutoPilotSet; + InputFrameCallback *oldCallback; + // Deactivate planet rotation + oldCallback = SetInputCallback (NULL); + LockMutex (GraphicsLock); - pSolarSysState->PauseRotate = 1; RepairSISBorder (); UnlockMutex (GraphicsLock); - TaskSwitch (); AutoPilotSet = StarMap (); - if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; + // Reactivate planet rotation + SetInputCallback (oldCallback); + if (!AutoPilotSet) { // Redraw the orbital display LoadPlanet (NULL); - LockMutex (GraphicsLock); - pSolarSysState->PauseRotate = 0; - UnlockMutex (GraphicsLock); break; } // Fall through !!! @@ -444,10 +432,19 @@ return TRUE; } +static void +on_input_frame (void) +{ + LockMutex (GraphicsLock); + RotatePlanetSphere (TRUE); + UnlockMutex (GraphicsLock); +} + void PlanetOrbitMenu (void) { void *oldInputFunc = pSolarSysState->MenuState.InputFunc; + InputFrameCallback *oldCallback; DrawMenuStateStrings (PM_SCAN, SCAN); LockMutex (GraphicsLock); @@ -456,12 +453,15 @@ pSolarSysState->MenuState.CurState = SCAN; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + oldCallback = SetInputCallback (on_input_frame); // XXX: temporary; will have an own MENU_STATE pSolarSysState->MenuState.InputFunc = DoPlanetOrbit; DoInput (&pSolarSysState->MenuState, TRUE); pSolarSysState->MenuState.InputFunc = oldInputFunc; + SetInputCallback (oldCallback); + LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/planets.h 2009-12-05 22:15:23 UTC (rev 3393) @@ -226,7 +226,6 @@ * [5] = bio 3 (world-specific) */ Color Tint_rgb; - UBYTE PauseRotate; FRAME TopoFrame; PLANET_ORBIT Orbit; }; @@ -269,10 +268,12 @@ extern void UninitSphereRotation (void); extern void PrepareNextRotationFrame (void); extern void DrawPlanetSphere (int x, int y); +extern void DrawDefaultPlanetSphere (void); extern void RenderPlanetSphere (FRAME Frame, int offset, BOOLEAN doThrob); extern void SetShieldThrobEffect (FRAME FromFrame, int offset, FRAME ToFrame); extern void ZoomInPlanetSphere (void); +extern void RotatePlanetSphere (BOOLEAN keepRate); extern void DrawScannedObjects (BOOLEAN Reversed); extern void GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, Modified: trunk/sc2/src/uqm/planets/plangen.c =================================================================== --- trunk/sc2/src/uqm/planets/plangen.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/plangen.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -1958,54 +1958,3 @@ TFB_SeedRandom (old_seed); } -int -rotate_planet_task (void *data) -{ - Task task = (Task) data; - DWORD TimeIn; - SOLARSYS_STATE *pSS; - - pSS = pSolarSysState; - - TimeIn = GetTimeCounter (); - while (!Task_ReadState (task, TASK_EXIT)) - { - CONTEXT oldContext; - - { - // This lock was placed before the RotatePlanet call - // To prevent the thread from being interrupted by the flash - // task while computing the Planet Frame. This should help - // to smooth out the planet rotation animation. - // The PauseRotate needs to be placed after the lock, - // to guarantee that PauseRotate doesn't change while waiting - // to acquire the graphics lock - LockMutex (GraphicsLock); - - if (*(volatile UBYTE *)&pSS->PauseRotate != 1 - && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) - { - //PauseRotate == 2 is a single-step - if (*(volatile UBYTE *)&pSS->PauseRotate == 2) - pSS->PauseRotate = 1; - - oldContext = SetContext (SpaceContext); - DrawPlanetSphere (SIS_SCREEN_WIDTH / 2, PLANET_ORG_Y); - SetContext (oldContext); - - PrepareNextRotationFrame (); - } - - UnlockMutex (GraphicsLock); - - SleepThreadUntil (TimeIn + PLANET_ROTATION_RATE); - TimeIn = GetTimeCounter (); - } - } - - FinishTask (task); - - return 0; -} - - Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -645,6 +645,7 @@ { DWORD TimeIn = GetTimeCounter (); BOOLEAN select, cancel; + select = PulsedInputState.menu[KEY_MENU_SELECT]; cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; @@ -689,6 +690,7 @@ } else { + InputFrameCallback *oldCallback; COUNT fuel_required; fuel_required = (COUNT)( @@ -698,6 +700,9 @@ EraseCoarseScan (); + // Deactivate planet rotation callback + oldCallback = SetInputCallback (NULL); + LockMutex (GraphicsLock); DeltaSISGauges (0, -(SIZE)fuel_required, 0); SetContext (ScanContext); @@ -743,6 +748,9 @@ PrintCoarseScanPC (); else PrintCoarseScan3DO (); + + // Reactivate planet rotation callback + SetInputCallback (oldCallback); } DrawMenuStateStrings (PM_MIN_SCAN, DISPATCH_SHUTTLE); @@ -1019,11 +1027,6 @@ return (TRUE); } - pSolarSysState->MenuState.Initialized += 4; -#ifndef SPIN_ON_SCAN - pSolarSysState->PauseRotate = 1; -#endif - min_scan = pMS->CurState; if (min_scan != AUTO_SCAN) max_scan = min_scan; @@ -1117,6 +1120,9 @@ DrawPlanet (0, 0, i, rgb); DrawScannedStuff (i, min_scan); UnbatchGraphics (); +#ifdef SPIN_ON_SCAN + RotatePlanetSphere (TRUE); +#endif UnlockMutex (GraphicsLock); } @@ -1157,8 +1163,6 @@ else UnlockMutex (GraphicsLock); - pSolarSysState->MenuState.Initialized -= 4; - pSolarSysState->PauseRotate = 0; FlushInput (); } else if (optWhichMenu == OPT_PC || Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -186,8 +186,10 @@ bool playerInPlanetOrbit (void) { + assert (!pSolarSysState || pSolarSysState->MenuState.Initialized < 4); + return playerInSolarSystem () && - pSolarSysState->MenuState.Initialized >= 3; + pSolarSysState->MenuState.Initialized == 3; // XXX: This test will change eventually } @@ -1275,8 +1277,9 @@ || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) return; - if (pSolarSysState->MenuState.flash_task) - { // We've entered orbit; LoadPlanet() set flash_task to rotate planet + // Implement a to-do in generate.h for a better test + if (pSolarSysState->TopoFrame) + { // We've entered orbit; LoadPlanet() called planet surface-gen code PlanetOrbitMenu (); FreePlanet (); } Modified: trunk/sc2/src/uqm/restart.c =================================================================== --- trunk/sc2/src/uqm/restart.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/restart.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -43,6 +43,10 @@ #include "libs/inplib.h" +// TODO: This entire module fails to uphold the GraphicsLock semantics +// This either has to be fixed, or GraphicsLock completely ignored, +// or will become irrelevant if GraphicsLock completely removed. + enum { START_NEW_GAME = 0, Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/util.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -172,9 +172,8 @@ SetSystemRect (&r); DrawStamp (&s); - // Releasing the lock lets the rotate_planet_task - // draw a frame. PauseRotate can still allow one more frame - // to be drawn, so it is safer to just not release the lock + // It is safer to just not release the lock so any graphics tasks + // would be blocked //UnlockMutex (GraphicsLock); FlushGraphics (); //LockMutex (GraphicsLock); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-12-07 21:56:30
|
Revision: 3399 http://sc2.svn.sourceforge.net/sc2/?rev=3399&view=rev Author: Meep-Eep Date: 2009-12-07 21:56:24 +0000 (Mon, 07 Dec 2009) Log Message: ----------- A few cleanups. Modified Paths: -------------- trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/hyper.h Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-12-07 21:54:22 UTC (rev 3398) +++ trunk/sc2/src/uqm/hyper.c 2009-12-07 21:56:24 UTC (rev 3399) @@ -56,7 +56,8 @@ SIZE new_dx, new_dy; new_dx = *pdx; - if ((GLOBAL_SIS (log_x) -= new_dx) < 0) + GLOBAL_SIS (log_x) -= new_dx; + if (GLOBAL_SIS (log_x) < 0) { new_dx += (SIZE)GLOBAL_SIS (log_x); GLOBAL_SIS (log_x) = 0; @@ -68,7 +69,8 @@ } new_dy = *pdy; - if ((GLOBAL_SIS (log_y) -= new_dy) < 0) + GLOBAL_SIS (log_y) -= new_dy; + if (GLOBAL_SIS (log_y) < 0) { new_dy += (SIZE)GLOBAL_SIS (log_y); GLOBAL_SIS (log_y) = 0; @@ -106,8 +108,7 @@ } } - if (GLOBAL_SIS (FuelOnBoard) - && GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) + if (GLOBAL_SIS (FuelOnBoard) && GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) { COUNT cur_fuel_ticks; COUNT hyper_dist; @@ -303,7 +304,9 @@ BOOLEAN LoadHyperspace (void) { - hyper_dx = hyper_dy = hyper_extra = 0; + hyper_dx = 0; + hyper_dy = 0; + hyper_extra = 0; fuel_ticks = 1; GLOBAL (ShipStamp.origin.x) = -MAX_X_UNIVERSE; @@ -357,7 +360,7 @@ ClearSISRect (CLEAR_SIS_RADAR); - return (TRUE); + return TRUE; } BOOLEAN @@ -372,7 +375,7 @@ } // FreeHyperData (); - return (TRUE); + return TRUE; } static void @@ -429,6 +432,87 @@ } TRANSITION_TYPE; static void +InterplanetaryTransition (ELEMENT *ElementPtr) +{ + GLOBAL (ip_planet) = 0; + GLOBAL (in_orbit) = 0; + GLOBAL (ShipFacing) = 0; /* Not reentering the system */ + SET_GAME_STATE (USED_BROADCASTER, 0); + if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) + { + // Enter a solar system from HyperSpace. + GLOBAL (CurrentActivity) |= START_INTERPLANETARY; + SET_GAME_STATE (ESCAPE_COUNTER, 0); + } + else + { + POINT pt; + + GLOBAL (autopilot.x) = ~0; + GLOBAL (autopilot.y) = ~0; + + ElementToUniverse (ElementPtr, &pt); + CurStarDescPtr = FindStar (NULL, &pt, 5, 5); + if (CurStarDescPtr->star_pt.x == ARILOU_HOME_X + && CurStarDescPtr->star_pt.y == ARILOU_HOME_Y) + { + // Meet the Arilou. + GLOBAL (CurrentActivity) |= START_ENCOUNTER; + } + else + { + // Transition from QuasiSpace to HyperSpace through + // one of the permanent portals. + COUNT index; + const POINT portal_pt[] = QUASISPACE_PORTALS_HYPERSPACE_ENDPOINTS; + + index = CurStarDescPtr - &star_array[NUM_SOLAR_SYSTEMS + 1]; + GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (portal_pt[index].x); + GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (portal_pt[index].y); + + SET_GAME_STATE (ARILOU_SPACE_SIDE, 0); + } + } +} + +/* Enter QuasiSpace from HyperSpace by any portal, or HyperSpace from + * QuasiSpace through the periodically opening portal. + */ +static void +ArilouSpaceTransition (void) +{ + GLOBAL (ShipFacing) = 0; /* Not reentering the system */ + SET_GAME_STATE (USED_BROADCASTER, 0); + GLOBAL (autopilot.x) = ~0; + GLOBAL (autopilot.y) = ~0; + if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) + { + // From HyperSpace to QuasiSpace. + GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (QUASI_SPACE_X); + GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (QUASI_SPACE_Y); + if (GET_GAME_STATE (PORTAL_COUNTER) == 0) + { + // Periodically appearing portal. + SET_GAME_STATE (ARILOU_SPACE_SIDE, 3); + } + else + { + // Player-induced portal. + SET_GAME_STATE (PORTAL_COUNTER, 0); + SET_GAME_STATE (ARILOU_SPACE_SIDE, 3); + } + } + else + { + // From QuasiSpace to HyperSpace through the periodically appearing + // portal. + GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (ARILOU_SPACE_X); + GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (ARILOU_SPACE_Y); + SET_GAME_STATE (ARILOU_SPACE_SIDE, 0); + } +} + +static void unhyper_transition (ELEMENT *ElementPtr) { COUNT frame_index; @@ -452,96 +536,10 @@ GLOBAL (CurrentActivity) |= START_ENCOUNTER; break; case INTERPLANETARY_TRANSITION: - GLOBAL (ip_planet) = 0; - GLOBAL (in_orbit) = 0; - GLOBAL (ShipFacing) = 0; /* Not reentering the system */ - SET_GAME_STATE (USED_BROADCASTER, 0); - if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) - { - GLOBAL (CurrentActivity) |= START_INTERPLANETARY; - SET_GAME_STATE (ESCAPE_COUNTER, 0); - } - else - { - POINT pt; - - GLOBAL (autopilot.x) = ~0; - GLOBAL (autopilot.y) = ~0; - - ElementToUniverse (ElementPtr, &pt); - CurStarDescPtr = FindStar (NULL, &pt, 5, 5); - if (CurStarDescPtr->star_pt.x == ARILOU_HOME_X - && CurStarDescPtr->star_pt.y == ARILOU_HOME_Y) - { - GLOBAL (CurrentActivity) |= START_ENCOUNTER; - } - else - { - COUNT index; - POINT portal_pt[] = - { - {4091, 7748}, - {3184, 4906}, - {9211, 6104}, - {5673, 1207}, - {1910, 926}, - {8607, 151}, - { 50, 1647}, - {6117, 4131}, - {5658, 9712}, - {2302, 3988}, - { 112, 9409}, - {7752, 8906}, - { 368, 6332}, - {9735, 3153}, - {5850, 6213}, - }; - - index = CurStarDescPtr - - &star_array[NUM_SOLAR_SYSTEMS + 1]; - GLOBAL_SIS (log_x) = - UNIVERSE_TO_LOGX (portal_pt[index].x); - GLOBAL_SIS (log_y) = - UNIVERSE_TO_LOGY (portal_pt[index].y); - - SET_GAME_STATE (ARILOU_SPACE_SIDE, 0); - } - } + InterplanetaryTransition (ElementPtr); break; case ARILOU_SPACE_TRANSITION: - /* Enter QuasiSpace from HyperSpace by any portal, - * or HyperSpace from QuasiSpace through the periodically - * opening portal. - */ - GLOBAL (ShipFacing) = 0; /* Not reentering the system */ - SET_GAME_STATE (USED_BROADCASTER, 0); - GLOBAL (autopilot.x) = ~0; - GLOBAL (autopilot.y) = ~0; - if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) - { - // From HyperSpace to QuasiSpace. - GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (QUASI_SPACE_X); - GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (QUASI_SPACE_Y); - if (GET_GAME_STATE (PORTAL_COUNTER) == 0) - { - // Periodically appearing portal. - SET_GAME_STATE (ARILOU_SPACE_SIDE, 3); - } - else - { - // Player-induced portal. - SET_GAME_STATE (PORTAL_COUNTER, 0); - SET_GAME_STATE (ARILOU_SPACE_SIDE, 3); - } - } - else - { - // From QuasiSpace to HyperSpace through the - // periodically appearing portal. - GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (ARILOU_SPACE_X); - GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (ARILOU_SPACE_Y); - SET_GAME_STATE (ARILOU_SPACE_SIDE, 0); - } + ArilouSpaceTransition (); break; } @@ -557,7 +555,8 @@ init_transition (ELEMENT *ElementPtr0, ELEMENT *ElementPtr1, TRANSITION_TYPE which_transition) { - SIZE dx, dy, num_turns; + SIZE dx, dy; + SIZE num_turns; STARSHIP *StarShipPtr; dx = WORLD_TO_VELOCITY (ElementPtr0->next.location.x @@ -571,10 +570,11 @@ ElementPtr1->turn_wait = (BYTE) which_transition; GetElementStarShip (ElementPtr1, &StarShipPtr); - if ((num_turns = GetFrameCount (ElementPtr1->next.image.frame) + num_turns = GetFrameCount (ElementPtr1->next.image.frame) - ANGLE_TO_FACING (FULL_CIRCLE) + NORMALIZE_FACING (ANGLE_TO_FACING (FULL_CIRCLE) - - StarShipPtr->ShipFacing)) == 0) + - StarShipPtr->ShipFacing); + if (num_turns == 0) num_turns = 1; SetVelocityComponents (&ElementPtr1->velocity, @@ -595,13 +595,12 @@ ElementPtr->state_flags |= DEFY_PHYSICS; - return (FALSE); + return FALSE; } else { ElementPtr->preprocess_func = - (void (*) (struct element - *ElementPtr))hyper_transition; + (void (*) (struct element *ElementPtr)) hyper_transition; ElementPtr->postprocess_func = NULL; ElementPtr->state_flags |= NONSOLID; ElementPtr->next.image.frame = @@ -646,7 +645,7 @@ } } - return (TRUE); + return TRUE; } static void @@ -735,7 +734,8 @@ } else { - init_transition (ElementPtr0, ElementPtr1, ARILOU_SPACE_TRANSITION); + init_transition (ElementPtr0, ElementPtr1, + ARILOU_SPACE_TRANSITION); } } @@ -764,24 +764,23 @@ long lx, ly; lx = UNIVERSE_TO_LOGX (SDPtr->star_pt.x) - + (LOG_SPACE_WIDTH >> 1) - - GLOBAL_SIS (log_x); + + (LOG_SPACE_WIDTH >> 1) - GLOBAL_SIS (log_x); HyperSpaceElementPtr->current.location.x = WRAP_X (lx); ly = UNIVERSE_TO_LOGY (SDPtr->star_pt.y) - + (LOG_SPACE_HEIGHT >> 1) - - GLOBAL_SIS (log_y); + + (LOG_SPACE_HEIGHT >> 1) - GLOBAL_SIS (log_y); HyperSpaceElementPtr->current.location.y = WRAP_Y (ly); } - SetPrimType (&DisplayArray[HyperSpaceElementPtr->PrimIndex], STAMP_PRIM); + SetPrimType (&DisplayArray[HyperSpaceElementPtr->PrimIndex], + STAMP_PRIM); HyperSpaceElementPtr->current.image.farray = &hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)]; UnlockElement (hHyperSpaceElement); } - return (hHyperSpaceElement); + return hHyperSpaceElement; } static void @@ -800,7 +799,8 @@ HyperSpaceElementPtr->playerNr = NEUTRAL_PLAYER_NUM; HyperSpaceElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; - SetPrimType (&DisplayArray[HyperSpaceElementPtr->PrimIndex], STAMP_PRIM); + SetPrimType (&DisplayArray[HyperSpaceElementPtr->PrimIndex], + STAMP_PRIM); HyperSpaceElementPtr->preprocess_func = animation_preprocess; rand_val = TFB_Random (); @@ -896,40 +896,39 @@ encounter_collision (ELEMENT *ElementPtr0, POINT *pPt0, ELEMENT *ElementPtr1, POINT *pPt1) { + HENCOUNTER hEncounter; + HENCOUNTER hNextEncounter; - if ((ElementPtr1->state_flags & PLAYER_SHIP) - && (GLOBAL (CurrentActivity) & IN_BATTLE)) - { - HENCOUNTER hEncounter, hNextEncounter; + if (!(ElementPtr1->state_flags & PLAYER_SHIP) + || !(GLOBAL (CurrentActivity) & IN_BATTLE)) + return; - init_transition (ElementPtr0, ElementPtr1, RANDOM_ENCOUNTER_TRANSITION); + init_transition (ElementPtr0, ElementPtr1, RANDOM_ENCOUNTER_TRANSITION); - for (hEncounter = GetHeadEncounter (); - hEncounter != 0; hEncounter = hNextEncounter) + for (hEncounter = GetHeadEncounter (); + hEncounter != 0; hEncounter = hNextEncounter) + { + ENCOUNTER *EncounterPtr; + + LockEncounter (hEncounter, &EncounterPtr); + hNextEncounter = GetSuccEncounter (EncounterPtr); + if (EncounterPtr->hElement) { - ENCOUNTER *EncounterPtr; + ELEMENT *ElementPtr; - LockEncounter (hEncounter, &EncounterPtr); - hNextEncounter = GetSuccEncounter (EncounterPtr); - if (EncounterPtr->hElement) - { - ELEMENT *ElementPtr; - - LockElement (EncounterPtr->hElement, &ElementPtr); - - ElementPtr->state_flags |= NONSOLID | IGNORE_SIMILAR; - - UnlockElement (EncounterPtr->hElement); - } - UnlockEncounter (hEncounter); + LockElement (EncounterPtr->hElement, &ElementPtr); + ElementPtr->state_flags |= NONSOLID | IGNORE_SIMILAR; + UnlockElement (EncounterPtr->hElement); } - - // Mark this element as collided with flagship - // XXX: We could simply set hTarget to 1 or to ElementPtr1, - // but that would be too hacky ;) - ElementPtr0->hTarget = getSisElement (); - ZeroVelocityComponents (&ElementPtr0->velocity); + UnlockEncounter (hEncounter); } + + // Mark this element as collided with flagship + // XXX: We could simply set hTarget to 1 or to ElementPtr1, + // but that would be too hacky ;) + ElementPtr0->hTarget = getSisElement (); + ZeroVelocityComponents (&ElementPtr0->velocity); + (void) pPt0; /* Satisfying compiler (unused parameter) */ (void) pPt1; /* Satisfying compiler (unused parameter) */ } @@ -941,9 +940,8 @@ HELEMENT hElement; STAR_DESC SD; - if (GET_GAME_STATE (ARILOU_SPACE_SIDE) >= 2) - return (0); + return 0; if (EncounterPtr->SD.Index & ENCOUNTER_REFORMING) { @@ -952,7 +950,7 @@ EncounterPtr->transition_state = 100; if ((EncounterPtr->SD.Index & ONE_SHOT_ENCOUNTER) || LONIBBLE (EncounterPtr->SD.Index) == 0) - return (0); + return 0; } if (LONIBBLE (EncounterPtr->SD.Index)) @@ -964,7 +962,8 @@ { BYTE Type; SIZE dx, dy; - COUNT i, NumShips; + COUNT i; + COUNT NumShips; DWORD radius_squared; BYTE EncounterMakeup[] = { @@ -987,16 +986,15 @@ NumShips = MAX_HYPER_SHIPS; - EncounterPtr->SD.Index = MAKE_BYTE ( - NumShips, HINIBBLE (EncounterPtr->SD.Index)); + EncounterPtr->SD.Index = + MAKE_BYTE (NumShips, HINIBBLE (EncounterPtr->SD.Index)); for (i = 0; i < NumShips; ++i) { - HFLEETINFO hStarShip; - FLEET_INFO *FleetPtr; BRIEF_SHIP_INFO *BSIPtr = &EncounterPtr->ShipList[i]; - - hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), Type); - FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); + HFLEETINFO hStarShip = + GetStarShipFromIndex (&GLOBAL (avail_race_q), Type); + FLEET_INFO *FleetPtr = + LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); BSIPtr->race_id = Type; BSIPtr->crew_level = FleetPtr->crew_level; BSIPtr->max_crew = FleetPtr->max_crew; @@ -1004,7 +1002,6 @@ UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip); } - do { DWORD rand_val; @@ -1041,7 +1038,8 @@ LockElement (hElement, &ElementPtr); - if ((i = EncounterPtr->transition_state) || NewEncounter) + i = EncounterPtr->transition_state; + if (i || NewEncounter) { if (i < 0) { @@ -1078,14 +1076,14 @@ InsertElement (hElement, GetTailElement ()); } - return (EncounterPtr->hElement = hElement); + EncounterPtr->hElement = hElement; + return hElement; } #define GRID_OFFSET 200 static void -DrawHyperGrid (COORD ux, COORD uy, COORD ox, - COORD oy) +DrawHyperGrid (COORD ux, COORD uy, COORD ox, COORD oy) { COORD sx, sy, ex, ey; RECT r; @@ -1094,18 +1092,22 @@ SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x6B)); - if ((sx = ux - (RADAR_SCAN_WIDTH >> 1)) < 0) + sx = ux - (RADAR_SCAN_WIDTH >> 1); + if (sx < 0) sx = 0; else sx -= sx % GRID_OFFSET; - if ((ex = ux + (RADAR_SCAN_WIDTH >> 1)) > MAX_X_UNIVERSE + 1) + ex = ux + (RADAR_SCAN_WIDTH >> 1); + if (ex > MAX_X_UNIVERSE + 1) ex = MAX_X_UNIVERSE + 1; - if ((sy = uy - (RADAR_SCAN_HEIGHT >> 1)) < 0) + sy = uy - (RADAR_SCAN_HEIGHT >> 1); + if (sy < 0) sy = 0; else sy -= sy % GRID_OFFSET; - if ((ey = uy + (RADAR_SCAN_HEIGHT >> 1)) > MAX_Y_UNIVERSE + 1) + ey = uy + (RADAR_SCAN_HEIGHT >> 1); + if (ey > MAX_Y_UNIVERSE + 1) ey = MAX_Y_UNIVERSE + 1; r.corner.y = (COORD) ((long)(MAX_Y_UNIVERSE - ey) @@ -1115,222 +1117,216 @@ * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy) - r.corner.y + 1; for (ux = sx; ux <= ex; ux += GRID_OFFSET) { - r.corner.x = (COORD) ((long)ux - * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox; + 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 - * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox) - - r.corner.x + 1; + r.extent.width = ((COORD) ((long)ex * RADAR_WIDTH / RADAR_SCAN_WIDTH) + - ox) - r.corner.x + 1; r.extent.height = 1; for (uy = sy; uy <= ey; uy += GRID_OFFSET) { r.corner.y = (COORD)((long)(MAX_Y_UNIVERSE - uy) * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy; DrawFilledRectangle (&r); - } while ((uy += GRID_OFFSET) < ey); + } } - -static void -ProcessEncounters (POINT *puniverse, COORD ox, COORD oy) +// Returns false iff the encounter is to be removed. +static bool +ProcessEncounter (ENCOUNTER *EncounterPtr, POINT *puniverse, + COORD ox, COORD oy, STAMP *stamp) { - STAMP s; - HENCOUNTER hEncounter, hNextEncounter; + ELEMENT *ElementPtr; + COORD ex, ey; - s.frame = SetAbsFrameIndex (stars_in_space, 91); - for (hEncounter = GetHeadEncounter (); - hEncounter; hEncounter = hNextEncounter) - { - COORD ex, ey; - ENCOUNTER *EncounterPtr; + if (EncounterPtr->hElement == 0 + && AddEncounterElement (EncounterPtr, puniverse) == 0) + return false; - LockEncounter (hEncounter, &EncounterPtr); - hNextEncounter = GetSuccEncounter (EncounterPtr); + LockElement (EncounterPtr->hElement, &ElementPtr); - if (EncounterPtr->hElement == 0 - && AddEncounterElement (EncounterPtr, puniverse) == 0) + if (ElementPtr->death_func) + { + if (EncounterPtr->transition_state && ElementPtr->turn_wait == 0) { -DeleteEncounter: - UnlockEncounter (hEncounter); - - RemoveEncounter (hEncounter); - FreeEncounter (hEncounter); - continue; + --EncounterPtr->transition_state; + if (EncounterPtr->transition_state >= NUM_VORTEX_TRANSITIONS) + ++ElementPtr->turn_wait; + else if (EncounterPtr->transition_state == + -NUM_VORTEX_TRANSITIONS) + { + ElementPtr->death_func = NULL; + UnlockElement (EncounterPtr->hElement); + return false; + } + else + SetPrimType (&DisplayArray[ElementPtr->PrimIndex], + STAMP_PRIM); } + } + else + { + SIZE delta_x, delta_y; + COUNT encounter_radius; - { - ELEMENT *ElementPtr; + ElementPtr->life_span = 1; + GetNextVelocityComponents (&ElementPtr->velocity, + &delta_x, &delta_y, 1); + if (ElementPtr->thrust_wait) + --ElementPtr->thrust_wait; + else if (!ElementPtr->hTarget) + { // This is an encounter that did not collide with flagship + // The colliding encounter does not move + COUNT cur_facing, delta_facing; - LockElement (EncounterPtr->hElement, &ElementPtr); - - if (ElementPtr->death_func) + cur_facing = ANGLE_TO_FACING ( + 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))); + if (delta_facing || (delta_x == 0 && delta_y == 0)) { - if (EncounterPtr->transition_state - && ElementPtr->turn_wait == 0) + SIZE speed; + const SIZE RaceHyperSpeed[] = { - --EncounterPtr->transition_state; - if (EncounterPtr->transition_state >= - NUM_VORTEX_TRANSITIONS) - ++ElementPtr->turn_wait; - else if (EncounterPtr->transition_state == - -NUM_VORTEX_TRANSITIONS) - { - ElementPtr->death_func = NULL; - UnlockElement (EncounterPtr->hElement); - goto DeleteEncounter; - } - else - SetPrimType (&DisplayArray[ElementPtr->PrimIndex], STAMP_PRIM); - } - } - else - { - SIZE delta_x, delta_y; - COUNT encounter_radius; + RACE_HYPER_SPEED + }; - ElementPtr->life_span = 1; - GetNextVelocityComponents (&ElementPtr->velocity, - &delta_x, &delta_y, 1); - if (ElementPtr->thrust_wait) - --ElementPtr->thrust_wait; - else if (!ElementPtr->hTarget) - { // This is an encounter that did not collide with flagship - // The colliding encounter does not move - COUNT cur_facing, delta_facing; - - cur_facing = ANGLE_TO_FACING ( - 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))); - if (delta_facing || (delta_x == 0 && delta_y == 0)) - { - SIZE s, RaceHyperSpeed[] = - { - RACE_HYPER_SPEED - }; - #define ENCOUNTER_TRACK_WAIT 3 - s = RaceHyperSpeed[EncounterPtr->SD.Type]; - if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) - --cur_facing; - else - ++cur_facing; - if (NORMALIZE_FACING (delta_facing - + ANGLE_TO_FACING (OCTANT)) > ANGLE_TO_FACING (QUADRANT)) - { - if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) - --cur_facing; - else - ++cur_facing; - s >>= 1; - } - cur_facing = FACING_TO_ANGLE (cur_facing); - SetVelocityComponents ( - &ElementPtr->velocity, - COSINE (cur_facing, s), - SINE (cur_facing, s) - ); - GetNextVelocityComponents (&ElementPtr->velocity, - &delta_x, &delta_y, 1); - - ElementPtr->thrust_wait = ENCOUNTER_TRACK_WAIT; - } - } - EncounterPtr->log_x += delta_x; - EncounterPtr->log_y -= delta_y; - EncounterPtr->SD.star_pt.x = - LOGX_TO_UNIVERSE (EncounterPtr->log_x); - EncounterPtr->SD.star_pt.y = - LOGY_TO_UNIVERSE (EncounterPtr->log_y); - - encounter_radius = EncounterPtr->radius + (GRID_OFFSET >> 1); - if ((delta_x = EncounterPtr->SD.star_pt.x - - EncounterPtr->origin.x) < 0) - delta_x = -delta_x; - if ((delta_y = EncounterPtr->SD.star_pt.y - - EncounterPtr->origin.y) < 0) - delta_y = -delta_y; - if ((COUNT)delta_x >= encounter_radius - || (COUNT)delta_y >= encounter_radius - || (DWORD)delta_x * delta_x + (DWORD)delta_y * delta_y >= - (DWORD)encounter_radius * encounter_radius) + speed = RaceHyperSpeed[EncounterPtr->SD.Type]; + if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) + --cur_facing; + else + ++cur_facing; + if (NORMALIZE_FACING (delta_facing + ANGLE_TO_FACING (OCTANT)) + > ANGLE_TO_FACING (QUADRANT)) { - ElementPtr->state_flags |= NONSOLID; - ElementPtr->life_span = 0; - - if (EncounterPtr->transition_state == 0) - { - ElementPtr->death_func = encounter_transition; - EncounterPtr->transition_state = -1; - ElementPtr->hit_points = 1; - } + if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) + --cur_facing; else - { - ElementPtr->death_func = NULL; - UnlockElement (EncounterPtr->hElement); - goto DeleteEncounter; - } + ++cur_facing; + speed >>= 1; } + cur_facing = FACING_TO_ANGLE (cur_facing); + SetVelocityComponents (&ElementPtr->velocity, + COSINE (cur_facing, speed), SINE (cur_facing, speed)); + GetNextVelocityComponents (&ElementPtr->velocity, + &delta_x, &delta_y, 1); + + ElementPtr->thrust_wait = ENCOUNTER_TRACK_WAIT; } + } + EncounterPtr->log_x += delta_x; + EncounterPtr->log_y -= delta_y; + EncounterPtr->SD.star_pt.x = LOGX_TO_UNIVERSE (EncounterPtr->log_x); + EncounterPtr->SD.star_pt.y = LOGY_TO_UNIVERSE (EncounterPtr->log_y); - ex = EncounterPtr->SD.star_pt.x; - ey = EncounterPtr->SD.star_pt.y; - if (ex - puniverse->x >= -UNIT_SCREEN_WIDTH - && ex - puniverse->x <= UNIT_SCREEN_WIDTH - && ey - puniverse->y >= -UNIT_SCREEN_HEIGHT - && ey - puniverse->y <= UNIT_SCREEN_HEIGHT) + encounter_radius = EncounterPtr->radius + (GRID_OFFSET >> 1); + delta_x = EncounterPtr->SD.star_pt.x - EncounterPtr->origin.x; + if (delta_x < 0) + delta_x = -delta_x; + delta_y = EncounterPtr->SD.star_pt.y - EncounterPtr->origin.y; + if (delta_y < 0) + delta_y = -delta_y; + if ((COUNT)delta_x >= encounter_radius + || (COUNT)delta_y >= encounter_radius + || (DWORD)delta_x * delta_x + (DWORD)delta_y * delta_y >= + (DWORD)encounter_radius * encounter_radius) + { + ElementPtr->state_flags |= NONSOLID; + ElementPtr->life_span = 0; + + if (EncounterPtr->transition_state == 0) { - ElementPtr->next.location.x = (SIZE)( - EncounterPtr->log_x - GLOBAL_SIS (log_x) - ) + (LOG_SPACE_WIDTH >> 1); - ElementPtr->next.location.y = (SIZE)( - EncounterPtr->log_y - GLOBAL_SIS (log_y) - ) + (LOG_SPACE_HEIGHT >> 1); - if ((ElementPtr->state_flags & NONSOLID) - && EncounterPtr->transition_state == 0) - { - ElementPtr->current.location = - ElementPtr->next.location; - SetPrimType (&DisplayArray[ElementPtr->PrimIndex], STAMP_PRIM); - if (ElementPtr->death_func == 0) - { - InitIntersectStartPoint (ElementPtr); - ElementPtr->state_flags &= ~NONSOLID; - } - } + ElementPtr->death_func = encounter_transition; + EncounterPtr->transition_state = -1; + ElementPtr->hit_points = 1; } else { - ElementPtr->state_flags |= NONSOLID; - if (ex - puniverse->x < -XOFFS - || ex - puniverse->x > XOFFS - || ey - puniverse->y < -YOFFS - || ey - puniverse->y > YOFFS) - { - ElementPtr->life_span = 0; - ElementPtr->death_func = NULL; - UnlockElement (EncounterPtr->hElement); - - goto DeleteEncounter; - } - - SetPrimType (&DisplayArray[ElementPtr->PrimIndex], NO_PRIM); + ElementPtr->death_func = NULL; + UnlockElement (EncounterPtr->hElement); + return false; } + } + } + ex = EncounterPtr->SD.star_pt.x; + ey = EncounterPtr->SD.star_pt.y; + if (ex - puniverse->x >= -UNIT_SCREEN_WIDTH + && ex - puniverse->x <= UNIT_SCREEN_WIDTH + && ey - puniverse->y >= -UNIT_SCREEN_HEIGHT + && ey - puniverse->y <= UNIT_SCREEN_HEIGHT) + { + ElementPtr->next.location.x = + (SIZE)(EncounterPtr->log_x - GLOBAL_SIS (log_x)) + + (LOG_SPACE_WIDTH >> 1); + ElementPtr->next.location.y = + (SIZE)(EncounterPtr->log_y - GLOBAL_SIS (log_y)) + + (LOG_SPACE_HEIGHT >> 1); + if ((ElementPtr->state_flags & NONSOLID) + && EncounterPtr->transition_state == 0) + { + ElementPtr->current.location = ElementPtr->next.location; + SetPrimType (&DisplayArray[ElementPtr->PrimIndex], + STAMP_PRIM); + if (ElementPtr->death_func == 0) + { + InitIntersectStartPoint (ElementPtr); + ElementPtr->state_flags &= ~NONSOLID; + } + } + } + else + { + ElementPtr->state_flags |= NONSOLID; + if (ex - puniverse->x < -XOFFS || ex - puniverse->x > XOFFS + || ey - puniverse->y < -YOFFS || ey - puniverse->y > YOFFS) + { + ElementPtr->life_span = 0; + ElementPtr->death_func = NULL; UnlockElement (EncounterPtr->hElement); + return false; } - s.origin.x = (COORD)((long)ex * RADAR_WIDTH - / RADAR_SCAN_WIDTH) - ox; - s.origin.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) * RADAR_HEIGHT - / RADAR_SCAN_HEIGHT) - oy; - DrawStamp (&s); + SetPrimType (&DisplayArray[ElementPtr->PrimIndex], NO_PRIM); + } + UnlockElement (EncounterPtr->hElement); + + stamp->origin.x = (COORD)((long)ex * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox; + stamp->origin.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) * RADAR_HEIGHT + / RADAR_SCAN_HEIGHT) - oy; + DrawStamp (stamp); + + return true; +} + +static void +ProcessEncounters (POINT *puniverse, COORD ox, COORD oy) +{ + STAMP stamp; + HENCOUNTER hEncounter, hNextEncounter; + + stamp.frame = SetAbsFrameIndex (stars_in_space, 91); + for (hEncounter = GetHeadEncounter (); + hEncounter; hEncounter = hNextEncounter) + { + ENCOUNTER *EncounterPtr; + + LockEncounter (hEncounter, &EncounterPtr); + hNextEncounter = GetSuccEncounter (EncounterPtr); + + if (!ProcessEncounter (EncounterPtr, puniverse, ox, oy, &stamp)) + { + UnlockEncounter (hEncounter); + RemoveEncounter (hEncounter); + FreeEncounter (hEncounter); + continue; + } + UnlockEncounter (hEncounter); } } @@ -1356,20 +1352,15 @@ SetContext (RadarContext); BatchGraphics (); - ox = (COORD)((long)universe.x - * RADAR_WIDTH / RADAR_SCAN_WIDTH) + ox = (COORD)((long)universe.x * RADAR_WIDTH / RADAR_SCAN_WIDTH) - (RADAR_WIDTH >> 1); oy = (COORD)((long)(MAX_Y_UNIVERSE - universe.y) - * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - - (RADAR_HEIGHT >> 1); + * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - (RADAR_HEIGHT >> 1); ex = (COORD)((long)GLOBAL (ShipStamp.origin.x) - * RADAR_WIDTH / RADAR_SCAN_WIDTH) - - (RADAR_WIDTH >> 1); - ey = (COORD)((long)(MAX_Y_UNIVERSE - - GLOBAL (ShipStamp.origin.y)) - * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - - (RADAR_HEIGHT >> 1); + * RADAR_WIDTH / RADAR_SCAN_WIDTH) - (RADAR_WIDTH >> 1); + ey = (COORD)((long)(MAX_Y_UNIVERSE - GLOBAL (ShipStamp.origin.y)) + * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - (RADAR_HEIGHT >> 1); arilouSpaceCounter = GET_GAME_STATE (ARILOU_SPACE_COUNTER); arilouSpaceSide = GET_GAME_STATE (ARILOU_SPACE_SIDE); @@ -1393,8 +1384,8 @@ s.origin.x = (COORD)((long)ex * RADAR_WIDTH / RADAR_SCAN_WIDTH) - ox; - s.origin.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) * RADAR_HEIGHT - / RADAR_SCAN_HEIGHT) - oy; + s.origin.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) + * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy; s.frame = SetRelFrameIndex (blip_frame, star_type + 2); DrawStamp (&s); @@ -1455,53 +1446,55 @@ --i; sx = SD[i].star_pt.x - universe.x + XOFFS; sy = SD[i].star_pt.y - universe.y + YOFFS; - if (sx >= 0 && sy >= 0 - && sx < (XOFFS << 1) && sy < (YOFFS << 1)) - { - ex = SD[i].star_pt.x; - ey = SD[i].star_pt.y; - s.origin.x = (COORD)((long)ex * RADAR_WIDTH - / RADAR_SCAN_WIDTH) - ox; - s.origin.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) - * RADAR_HEIGHT - / RADAR_SCAN_HEIGHT) - oy; - s.frame = SetAbsFrameIndex (stars_in_space, 95); - DrawStamp (&s); + if (sx < 0 || sy < 0 || sx >= (XOFFS << 1) || sy >= (YOFFS << 1)) + continue; - if ((ex -= universe.x) < 0) - ex = -ex; - if ((ey -= universe.y) < 0) - ey = -ey; - if (ex <= (XOFFS / NUM_RADAR_SCREENS) - && ey <= (YOFFS / NUM_RADAR_SCREENS) - && (hHyperSpaceElement = - AllocHyperElement (&SD[i])) != 0) - { - LockElement (hHyperSpaceElement, &HyperSpaceElementPtr); - HyperSpaceElementPtr->current.image.frame = SetAbsFrameIndex ( - hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)], - SD[i].Index - ); - HyperSpaceElementPtr->preprocess_func = - HyperSpaceElementPtr->postprocess_func = NULL; - HyperSpaceElementPtr->collision_func = arilou_space_collision; + ex = SD[i].star_pt.x; + ey = SD[i].star_pt.y; + s.origin.x = (COORD)((long)ex * RADAR_WIDTH / RADAR_SCAN_WIDTH) + - ox; + s.origin.y = (COORD)((long)(MAX_Y_UNIVERSE - ey) + * RADAR_HEIGHT / RADAR_SCAN_HEIGHT) - oy; + s.frame = SetAbsFrameIndex (stars_in_space, 95); + DrawStamp (&s); - SetUpElement (HyperSpaceElementPtr); + ex -= universe.x; + if (ex < 0) + ex = -ex; + ey -= universe.y; + if (ey < 0) + ey = -ey; - if (arilouSpaceSide == 1 || arilouSpaceSide == 2) - HyperSpaceElementPtr->death_func = arilou_space_death; - else - { - HyperSpaceElementPtr->death_func = NULL; - HyperSpaceElementPtr->IntersectControl.IntersectStamp.frame = - DecFrameIndex (stars_in_space); - } + if (ex > (XOFFS / NUM_RADAR_SCREENS) + || ey > (YOFFS / NUM_RADAR_SCREENS)) + continue; - UnlockElement (hHyperSpaceElement); + hHyperSpaceElement = AllocHyperElement (&SD[i]); + if (hHyperSpaceElement == 0) + continue; - InsertElement (hHyperSpaceElement, GetHeadElement ()); - } + LockElement (hHyperSpaceElement, &HyperSpaceElementPtr); + HyperSpaceElementPtr->current.image.frame = SetAbsFrameIndex ( + hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)], + SD[i].Index); + HyperSpaceElementPtr->preprocess_func = NULL; + HyperSpaceElementPtr->postprocess_func = NULL; + HyperSpaceElementPtr->collision_func = arilou_space_collision; + + SetUpElement (HyperSpaceElementPtr); + + if (arilouSpaceSide == 1 || arilouSpaceSide == 2) + HyperSpaceElementPtr->death_func = arilou_space_death; + else + { + HyperSpaceElementPtr->death_func = NULL; + HyperSpaceElementPtr->IntersectControl.IntersectStamp.frame = + DecFrameIndex (stars_in_space); } + + UnlockElement (hHyperSpaceElement); + + InsertElement (hHyperSpaceElement, GetHeadElement ()); } while (i); } @@ -1509,46 +1502,47 @@ SDPtr = 0; while ((SDPtr = FindStar (SDPtr, &universe, XOFFS, YOFFS))) { - ex = SDPtr->star_pt.x; - ey = SDPtr->star_pt.y; - if ((ex -= universe.x) < 0) + BYTE star_type; + + ex = SDPtr->star_pt.x - universe.x; + if (ex < 0) ex = -ex; - if ((ey -= universe.y) < 0) + ey = SDPtr->star_pt.y - universe.y; + if (ey < 0) ey = -ey; - if (ex <= (XOFFS / NUM_RADAR_SCREENS) - && ey <= (YOFFS / NUM_RADAR_SCREENS) - && (hHyperSpaceElement = AllocHyperElement (SDPtr)) != 0) - { - BYTE star_type; + if (ex > (XOFFS / NUM_RADAR_SCREENS) + || ey > (YOFFS / NUM_RADAR_SCREENS)) + continue; - star_type = SDPtr->Type; + hHyperSpaceElement = AllocHyperElement (SDPtr); + if (hHyperSpaceElement == 0) + continue; - LockElement (hHyperSpaceElement, &HyperSpaceElementPtr); - HyperSpaceElementPtr->current.image.frame = SetAbsFrameIndex ( - hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)], - STAR_TYPE (star_type) - * NUM_STAR_COLORS - + STAR_COLOR (star_type) - ); - HyperSpaceElementPtr->preprocess_func = - HyperSpaceElementPtr->postprocess_func = NULL; - HyperSpaceElementPtr->collision_func = hyper_collision; + star_type = SDPtr->Type; - SetUpElement (HyperSpaceElementPtr); + LockElement (hHyperSpaceElement, &HyperSpaceElementPtr); + HyperSpaceElementPtr->current.image.frame = SetAbsFrameIndex ( + hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)], + STAR_TYPE (star_type) * NUM_STAR_COLORS + + STAR_COLOR (star_type)); + HyperSpaceElementPtr->preprocess_func = NULL; + HyperSpaceElementPtr->postprocess_func = NULL; + HyperSpaceElementPtr->collision_func = hyper_collision; - if (SDPtr == CurStarDescPtr - && GET_GAME_STATE (PORTAL_COUNTER) == 0) - HyperSpaceElementPtr->death_func = hyper_death; - else - { - HyperSpaceElementPtr->death_func = NULL; - HyperSpaceElementPtr->IntersectControl.IntersectStamp.frame = - DecFrameIndex (stars_in_space); - } - UnlockElement (hHyperSpaceElement); + SetUpElement (HyperSpaceElementPtr); - InsertElement (hHyperSpaceElement, GetHeadElement ()); + if (SDPtr == CurStarDescPtr + && GET_GAME_STATE (PORTAL_COUNTER) == 0) + HyperSpaceElementPtr->death_func = hyper_death; + else + { + HyperSpaceElementPtr->death_func = NULL; + HyperSpaceElementPtr->IntersectControl.IntersectStamp.frame = + DecFrameIndex (stars_in_space); } + UnlockElement (hHyperSpaceElement); + + InsertElement (hHyperSpaceElement, GetHeadElement ()); } ProcessEncounters (&universe, ox, oy); } @@ -1740,3 +1734,4 @@ GLOBAL (ShipFacing) = StarShipPtr->ShipFacing + 1; UnlockElement (hSisElement); } + Modified: trunk/sc2/src/uqm/hyper.h =================================================================== --- trunk/sc2/src/uqm/hyper.h 2009-12-07 21:54:22 UTC (rev 3398) +++ trunk/sc2/src/uqm/hyper.h 2009-12-07 21:56:24 UTC (rev 3399) @@ -40,6 +40,27 @@ #define ARILOU_HOME_X (QUASI_SPACE_X + ((RADAR_SCAN_WIDTH >> 1) * 3)) #define ARILOU_HOME_Y (QUASI_SPACE_Y + ((RADAR_SCAN_HEIGHT >> 1) * 3)) +// HyperSpace coordinates of the locations where the QuasiSpace portals +// take you. +#define QUASISPACE_PORTALS_HYPERSPACE_ENDPOINTS \ + { \ + {4091, 7748}, \ + {3184, 4906}, \ + {9211, 6104}, \ + {5673, 1207}, \ + {1910, 926}, \ + {8607, 151}, \ + { 50, 1647}, \ + {6117, 4131}, \ + {5658, 9712}, \ + {2302, 3988}, \ + { 112, 9409}, \ + {7752, 8906}, \ + { 368, 6332}, \ + {9735, 3153}, \ + {5850, 6213}, \ + } + // Hyperspace coordinates of the Sol system // Should be the same as in plandata.c #define SOL_X 1752 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-08 22:46:22
|
Revision: 3408 http://sc2.svn.sourceforge.net/sc2/?rev=3408&view=rev Author: avolkov Date: 2009-12-08 22:46:15 +0000 (Tue, 08 Dec 2009) Log Message: ----------- Use SaveContextFrame() where appropriate Modified Paths: -------------- trunk/sc2/src/uqm/confirm.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/save.c trunk/sc2/src/uqm/util.c Modified: trunk/sc2/src/uqm/confirm.c =================================================================== --- trunk/sc2/src/uqm/confirm.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/confirm.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -22,6 +22,7 @@ #include "setup.h" #include "sounds.h" #include "gamestr.h" +#include "util.h" #include "libs/graphics/widgets.h" #include "libs/sound/trackplayer.h" #include "libs/log.h" @@ -89,7 +90,7 @@ { RECT r; STAMP s; - FRAME F; + RECT ctxRect; CONTEXT oldContext; RECT oldRect; BOOLEAN response = FALSE, done; @@ -98,13 +99,12 @@ GetContextClipRect (&oldRect); SetContextClipRect (NULL); + GetContextClipRect (&ctxRect); r.extent.width = CONFIRM_WIN_WIDTH + 4; r.extent.height = CONFIRM_WIN_HEIGHT + 4; - r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; - r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; - s.origin = r.corner; - F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); - + r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1; + r.corner.y = (ctxRect.extent.height - r.extent.height) >> 1; + s = SaveContextFrame (&r); SetSystemRect (&r); DrawConfirmationWindow (response); @@ -142,7 +142,7 @@ SleepThread (ONE_SECOND / 30); } while (!done); - s.frame = F; + // Restore the screen under the confirmation window DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); ClearSystemRect (); @@ -192,9 +192,7 @@ stringbank *bank = StringBank_Create (); const char *lines[30]; WIDGET_LABEL label; - RECT r; STAMP s; - FRAME F; CONTEXT oldContext; RECT oldRect; RECT windowRect; @@ -224,16 +222,10 @@ GetContextClipRect (&oldRect); SetContextClipRect (NULL); - /* TODO: Better measure of dimensions than this */ - r.extent.width = SCREEN_WIDTH; - r.extent.height = SCREEN_HEIGHT; - r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; - r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; - F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); + // TODO: Maybe DrawLabelAsWindow() should return a saved STAMP? + // We do not know the dimensions here, and so save the whole context + s = SaveContextFrame (NULL); - s.origin = r.corner; - s.frame = F; - Widget_SetFont (StarConFont); Widget_SetWindowColors (SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/gameopt.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -78,12 +78,7 @@ r.extent.height += 8; if (MsgStamp) { - MsgStamp->origin = r.corner; - r.corner.x += clip_r.corner.x; - r.corner.y += clip_r.corner.y; - MsgStamp->frame = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); - r.corner.x -= clip_r.corner.x; - r.corner.y -= clip_r.corner.y; + *MsgStamp = SaveContextFrame (&r); } DrawStarConBox (&r, 2, BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19), Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/save.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -536,6 +536,8 @@ TEXT t; UNICODE *ppStr[MAX_MSG_LINES]; + // TODO: This should probably just use DoPopupWindow() + ppStr[0] = GAME_STRING (SAVEGAME_STRING_BASE + 2); SetContextFont (StarConFont); @@ -566,17 +568,7 @@ r.extent.width += 8; r.extent.height += 8; - { - RECT clip_r; - - GetContextClipRect (&clip_r); - MsgStamp->origin = r.corner; - r.corner.x += clip_r.corner.x; - r.corner.y += clip_r.corner.y; - MsgStamp->frame = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); - r.corner.x -= clip_r.corner.x; - r.corner.y -= clip_r.corner.y; - } + *MsgStamp = SaveContextFrame (&r); BatchGraphics (); DrawStarConBox (&r, 2, @@ -613,9 +605,8 @@ WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE); LockMutex (GraphicsLock); - BatchGraphics (); + // Restore the screen under the message DrawStamp (&s); - UnbatchGraphics (); SetContext (OldContext); DestroyDrawable (ReleaseDrawable (s.frame)); UnlockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/util.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -143,7 +143,8 @@ RECT r; STAMP s; CONTEXT OldContext; - FRAME F; + STAMP saveStamp; + RECT ctxRect; POINT oldOrigin; RECT OldRect; @@ -163,12 +164,15 @@ GetContextClipRect (&OldRect); SetContextClipRect (NULL); + GetContextClipRect (&ctxRect); GetFrameRect (ActivityFrame, &r); - r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; - r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; + r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1; + r.corner.y = (ctxRect.extent.height - r.extent.height) >> 1; + saveStamp = SaveContextFrame (&r); + + // TODO: This should draw a localizable text message instead s.origin = r.corner; s.frame = ActivityFrame; - F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); SetSystemRect (&r); DrawStamp (&s); @@ -198,9 +202,8 @@ GamePaused = FALSE; - s.frame = F; - DrawStamp (&s); - DestroyDrawable (ReleaseDrawable (s.frame)); + DrawStamp (&saveStamp); + DestroyDrawable (ReleaseDrawable (saveStamp.frame)); ClearSystemRect (); SetContextClipRect (&OldRect); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-09 23:43:47
|
Revision: 3410 http://sc2.svn.sourceforge.net/sc2/?rev=3410&view=rev Author: avolkov Date: 2009-12-09 23:43:40 +0000 (Wed, 09 Dec 2009) Log Message: ----------- Credits task retired; credits drawing is now a callback of DoInput Modified Paths: -------------- trunk/sc2/src/uqm/colors.h trunk/sc2/src/uqm/credits.c Modified: trunk/sc2/src/uqm/colors.h =================================================================== --- trunk/sc2/src/uqm/colors.h 2009-12-08 22:59:23 UTC (rev 3409) +++ trunk/sc2/src/uqm/colors.h 2009-12-09 23:43:40 UTC (rev 3410) @@ -68,6 +68,8 @@ BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x00) #define WHITE_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) +#define BLUE_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x1F), 0x01) #define NORMAL_ILLUMINATED_COLOR \ WHITE_COLOR @@ -340,6 +342,9 @@ #define THREEDOMENU_TEXT_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x00) +// === Credits === +#define CREDITS_TEXT_COLOR \ + WHITE_COLOR // Temporary, until we can use C'99 features: #define BLACK_COLOR_INIT \ Modified: trunk/sc2/src/uqm/credits.c =================================================================== --- trunk/sc2/src/uqm/credits.c 2009-12-08 22:59:23 UTC (rev 3409) +++ trunk/sc2/src/uqm/credits.c 2009-12-09 23:43:40 UTC (rev 3410) @@ -19,6 +19,7 @@ #include "credits.h" #include "controls.h" +#include "colors.h" #include "options.h" #include "oscill.h" #include "comm.h" @@ -27,8 +28,7 @@ #include "settings.h" #include "sounds.h" #include "setup.h" -#include "libs/graphics/gfx_common.h" -#include "libs/sound/sound.h" +#include "libs/graphics/drawable.h" #include <math.h> // Rates in pixel lines per second @@ -39,14 +39,48 @@ #define CREDITS_TIMEOUT (ONE_SECOND * 5) -static volatile int CreditsRate; -static volatile BOOLEAN OutTakesRunning; -static volatile BOOLEAN CreditsRunning; +#define TRANS_COLOR BLUE_COLOR + +// Positive or negative scroll rate in pixel lines per second +static int CreditsRate; + +static BOOLEAN OutTakesRunning; +static BOOLEAN CreditsRunning; static STRING CreditsTab; static FRAME CreditsBack; +// Context used for drawing to the screen +static CONTEXT DrawContext; +// Context used for pre-rendering a credits frame +static CONTEXT LocalContext; +// Pre-rendered frame, possibly with a cutout +static FRAME CreditsFrame; +// Size of the credits "window" (normally screen size) +static EXTENT CreditsExtent; + typedef struct { + FRAME frame; + int strIndex; +} CreditTextFrame; + +#define MAX_CREDIT_FRAMES 32 +// Circular text frame buffer for scrolling +// Text frames are generated as needed, and when a text frame scrolls +// of the screen, it is destroyed +static CreditTextFrame textFrames[MAX_CREDIT_FRAMES]; +// Index of first active frame in the circular buffer (the first frame +// is the one on top) +static int firstFrame; +// Index of last active frame in the circular buffer + 1 +static int lastFrame; +// Total height of all active frames in the circular buffer +static int totalHeight; +// Current vertical offset into the first text frame +static int curFrameOfs; + +typedef struct +{ int size; RESOURCE res; FONT font; @@ -62,7 +96,7 @@ static FRAME -Credits_MakeTextFrame (int w, int h, Color TransColor) +Credits_MakeTransFrame (int w, int h, Color TransColor) { FRAME OldFrame; FRAME f; @@ -191,7 +225,7 @@ for (i = 0; i < MAX_TEXT_COLS; ++i) { colfmt[i].align = ALIGN_LEFT; - colfmt[i].basex = SCREEN_WIDTH / 64; + colfmt[i].basex = CreditsExtent.width / 64; } // find the right font @@ -246,14 +280,14 @@ if (n >= 2) colfmt[i].basex = x; else - colfmt[i].basex = SCREEN_WIDTH / 2; + colfmt[i].basex = CreditsExtent.width / 2; break; case 'R': colfmt[i].align = ALIGN_RIGHT; if (n >= 2) colfmt[i].basex = x; else - colfmt[i].basex = SCREEN_WIDTH - r.extent.width; + colfmt[i].basex = CreditsExtent.width - r.extent.width; break; } } @@ -268,7 +302,7 @@ TextLines[i].baseline.y *= leading; } - f = Credits_MakeTextFrame (SCREEN_WIDTH, leading * rows + (leading >> 1), + f = Credits_MakeTransFrame (CreditsExtent.width, leading * rows + (leading >> 1), BackColor); OldFrame = SetContextFGFrame (f); // draw text @@ -283,87 +317,154 @@ return f; } -#define CREDIT_FRAMES 32 +static inline int +frameIndex (int index) +{ + // Make sure index is positive before % + return (index + MAX_CREDIT_FRAMES) % MAX_CREDIT_FRAMES; +} -static int -credit_roll_task (void *data) +static void +RenderCreditsScreen (CONTEXT targetContext) { - Task task = (Task) data; - CONTEXT OldContext; - DWORD TimeIn; - CONTEXT DrawContext; - CONTEXT LocalContext; - FRAME Frame; - Color TransColor, TextFore, TextBack; - STAMP TaskStamp; + CONTEXT oldContext; STAMP s; - FRAME cf[CREDIT_FRAMES]; // preped text frames - int ci[CREDIT_FRAMES]; // strtab indices - int first = 0, last; - int dy = 0, total_h, disp_h, deficit_h = 0; - int strcnt; + int i; - CreditsRunning = TRUE; + LockMutex (GraphicsLock); + oldContext = SetContext (targetContext); + // draw background + s.origin.x = 0; + s.origin.y = 0; + s.frame = CreditsBack; + DrawStamp (&s); + + // draw text frames + s.origin.y = -curFrameOfs; + for (i = firstFrame; i != lastFrame; i = frameIndex (i + 1)) + { + RECT fr; - memset(cf, 0, sizeof(cf)); + s.frame = textFrames[i].frame; + DrawStamp (&s); + GetFrameRect (s.frame, &fr); + s.origin.y += fr.extent.height; + } - strcnt = GetStringTableCount (CreditsTab); + if (OutTakesRunning) + { // Cut out the Outtakes rect + SetContextForeGroundColor (TRANS_COLOR); + DrawFilledRectangle (&CommWndRect); + } + + SetContext (oldContext); + UnlockMutex (GraphicsLock); +} - TransColor = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x10), 0x01); - TextBack = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00); - TextFore = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F); +static void +InitCredits (void) +{ + RECT ctxRect; + CONTEXT oldContext; + FRAME targetFrame; + memset (textFrames, 0, sizeof textFrames); + LocalContext = CreateContext ("Credits.LocalContext"); DrawContext = CreateContext ("Credits.DrawContext"); - - total_h = disp_h = SCREEN_HEIGHT; LockMutex (GraphicsLock); + targetFrame = GetContextFGFrame (); + GetContextClipRect (&ctxRect); + CreditsExtent = ctxRect.extent; + // prep our local context - OldContext = SetContext (LocalContext); + oldContext = SetContext (LocalContext); + // Local screen copy. We draw everything to this frame, then cut + // the Outtakes rect out and draw this frame to the screen. + CreditsFrame = Credits_MakeTransFrame (CreditsExtent.width, + CreditsExtent.height, TRANS_COLOR); + SetContextFGFrame (CreditsFrame); - // prep the first frame - cf[0] = Credits_MakeTextFrame (1, total_h, TransColor); - ci[0] = -1; - last = 1; - // prep the local screen copy - Frame = Credits_MakeTextFrame (SCREEN_WIDTH, disp_h, TransColor); - SetContextFGFrame (Frame); + // The first credits frame is fake, the height of the screen, + // so that the credits can roll in from the bottom + textFrames[0].frame = Credits_MakeTransFrame (1, CreditsExtent.height, + TRANS_COLOR); + textFrames[0].strIndex = -1; + firstFrame = 0; + lastFrame = firstFrame + 1; + + totalHeight = GetFrameHeight (textFrames[0].frame); + curFrameOfs = 0; - // prep our task context + // We use an own screen draw context to avoid collisions SetContext (DrawContext); - SetContextFGFrame (Screen); + SetContextFGFrame (targetFrame); - SetContext (OldContext); + SetContext (oldContext); UnlockMutex (GraphicsLock); - TaskStamp.origin.x = TaskStamp.origin.y = 0; - TaskStamp.frame = Frame; + // Prepare the first screen frame + RenderCreditsScreen (LocalContext); - // stary background is the first screen frame - LockMutex (GraphicsLock); - OldContext = SetContext (LocalContext); - // draw - s.origin.x = s.origin.y = 0; - s.frame = CreditsBack; - DrawStamp (&s); - // draw clipped rect, if any - if (OutTakesRunning) + CreditsRate = CREDITS_BASE_RATE; + CreditsRunning = TRUE; +} + +static void +freeCreditTextFrame (CreditTextFrame *tf) +{ + DestroyDrawable (ReleaseDrawable (tf->frame)); + tf->frame = NULL; +} + +static void +UninitCredits (void) +{ + DestroyContext (DrawContext); + DrawContext = NULL; + DestroyContext (LocalContext); + LocalContext = NULL; + + // free remaining frames + DestroyDrawable (ReleaseDrawable (CreditsFrame)); + CreditsFrame = NULL; + for ( ; firstFrame != lastFrame; firstFrame = frameIndex (firstFrame + 1)) + freeCreditTextFrame (&textFrames[firstFrame]); +} + +static int +calcDeficitHeight (void) +{ + int i; + int maxPos; + + maxPos = -curFrameOfs; + for (i = firstFrame; i != lastFrame; i = frameIndex (i + 1)) { - SetContextForeGroundColor (TransColor); - DrawFilledRectangle (&CommWndRect); + RECT fr; + + GetFrameRect (textFrames[i].frame, &fr); + maxPos += fr.extent.height; } - SetContext (OldContext); - UnlockMutex (GraphicsLock); - while (!Task_ReadState (task, TASK_EXIT)) + return CreditsExtent.height - maxPos; +} + +static void +processCreditsFrame (void) +{ + static TimeCount NextTime; + TimeCount Now = GetTimeCounter (); + + if (Now >= NextTime) { RECT fr; - int i; + CONTEXT OldContext; int rate, direction, dirstep; + int deficitHeight; + STAMP s; - TimeIn = GetTimeCounter (); - rate = abs (CreditsRate); if (rate != 0) { @@ -383,28 +484,33 @@ rate = ONE_SECOND; } + NextTime = GetTimeCounter () + rate; + // draw the credits // comm animations play with contexts so we need to make // sure the context is not desynced + s.origin.x = 0; + s.origin.y = 0; + s.frame = CreditsFrame; + LockMutex (GraphicsLock); OldContext = SetContext (DrawContext); - DrawStamp (&TaskStamp); + DrawStamp (&s); SetContext (OldContext); FlushGraphics (); UnlockMutex (GraphicsLock); // prepare next screen frame - dy += dirstep; + deficitHeight = calcDeficitHeight (); + curFrameOfs += dirstep; // cap scroll - if (dy < -(disp_h / 20)) - { // at the begining - // accelerated slow down + if (curFrameOfs < -(CreditsExtent.height / 20)) + { // at the begining, deceleration if (CreditsRate < 0) CreditsRate -= CreditsRate / 10 - 1; } - else if (deficit_h > disp_h / 25) - { // frame deficit -- task almost over - // accelerated slow down + else if (deficitHeight > CreditsExtent.height / 25) + { // frame deficit -- credits almost over, deceleration if (CreditsRate > 0) CreditsRate -= CreditsRate / 10 + 1; @@ -415,32 +521,32 @@ CreditsRunning = TRUE; } - if (first != last) + if (firstFrame != lastFrame) { // clean up frames that scrolled off the screen if (direction > 0) { // forward scroll - GetFrameRect (cf[first], &fr); - if (dy >= (int)fr.extent.height) + GetFrameRect (textFrames[firstFrame].frame, &fr); + if (curFrameOfs >= fr.extent.height) { // past this frame already - total_h -= fr.extent.height; - DestroyDrawable (ReleaseDrawable (cf[first])); - cf[first] = 0; + totalHeight -= fr.extent.height; + freeCreditTextFrame (&textFrames[firstFrame]); // next frame - first = (first + 1) % CREDIT_FRAMES; - dy = 0; + firstFrame = frameIndex (firstFrame + 1); + curFrameOfs -= fr.extent.height; } } else if (direction < 0) { // backward scroll - int index = (last - 1 + CREDIT_FRAMES) % CREDIT_FRAMES; - - GetFrameRect (cf[index], &fr); - if (total_h - dy - (int)fr.extent.height >= disp_h) + int index = frameIndex (lastFrame - 1); + int framePos; + + GetFrameRect (textFrames[index].frame, &fr); + framePos = totalHeight - curFrameOfs - fr.extent.height; + if (framePos >= CreditsExtent.height) { // past this frame already - last = index; - total_h -= fr.extent.height; - DestroyDrawable (ReleaseDrawable (cf[last])); - cf[last] = 0; + lastFrame = index; + totalHeight -= fr.extent.height; + freeCreditTextFrame (&textFrames[lastFrame]); } } } @@ -451,116 +557,72 @@ int next_s = 0; // get next string - if (first != last) - next_s = ci[(last - 1 + CREDIT_FRAMES) % CREDIT_FRAMES] + 1; + if (firstFrame != lastFrame) + next_s = textFrames[frameIndex (lastFrame - 1)].strIndex + 1; - while (total_h - dy < disp_h && next_s < strcnt) + while (totalHeight - curFrameOfs < CreditsExtent.height + && next_s < GetStringTableCount (CreditsTab)) { - cf[last] = Credits_RenderTextFrame (LocalContext, - &next_s, direction, TextBack, TextFore); - ci[last] = next_s - 1; - if (cf[last]) + CreditTextFrame *tf = &textFrames[lastFrame]; + + tf->frame = Credits_RenderTextFrame (LocalContext, &next_s, + direction, BLACK_COLOR, CREDITS_TEXT_COLOR); + tf->strIndex = next_s - 1; + if (tf->frame) { - GetFrameRect (cf[last], &fr); - total_h += fr.extent.height; + GetFrameRect (tf->frame, &fr); + totalHeight += fr.extent.height; - last = (last + 1) % CREDIT_FRAMES; + lastFrame = frameIndex (lastFrame + 1); } } } else if (direction < 0) { // backward scroll - int next_s = strcnt - 1; + int next_s = GetStringTableCount (CreditsTab) - 1; // get next string - if (first != last) - next_s = ci[first] - 1; + if (firstFrame != lastFrame) + next_s = textFrames[firstFrame].strIndex - 1; - while (dy < 0 && next_s >= 0) + while (curFrameOfs < 0 && next_s >= 0) { - int index = (first - 1 + CREDIT_FRAMES) % CREDIT_FRAMES; - cf[index] = Credits_RenderTextFrame (LocalContext, - &next_s, direction, TextBack, TextFore); - ci[index] = next_s + 1; - if (cf[index]) + int index = frameIndex (firstFrame - 1); + CreditTextFrame *tf = &textFrames[index]; + + tf->frame = Credits_RenderTextFrame (LocalContext, &next_s, + direction, BLACK_COLOR, CREDITS_TEXT_COLOR); + tf->strIndex = next_s + 1; + if (tf->frame) { - GetFrameRect (cf[index], &fr); - total_h += fr.extent.height; + GetFrameRect (tf->frame, &fr); + totalHeight += fr.extent.height; - first = index; - dy += fr.extent.height; + firstFrame = index; + curFrameOfs += fr.extent.height; } } } // draw next screen frame - LockMutex (GraphicsLock); - OldContext = SetContext (LocalContext); - // draw background - s.origin.x = s.origin.y = 0; - s.frame = CreditsBack; - DrawStamp (&s); - // draw text frames - s.origin.y = -dy; - for (i = first; i != last; i = (i + 1) % CREDIT_FRAMES) - { - s.frame = cf[i]; - DrawStamp (&s); - GetFrameRect (s.frame, &fr); - s.origin.y += fr.extent.height; - } - if (direction > 0) - deficit_h = disp_h - s.origin.y; - - // draw clipped rect, if any - if (OutTakesRunning) - { - SetContextForeGroundColor (TransColor); - DrawFilledRectangle (&CommWndRect); - } - SetContext (OldContext); - UnlockMutex (GraphicsLock); - - // wait till begining of next screen frame - while (GetTimeCounter () < TimeIn + rate - && !Task_ReadState (task, TASK_EXIT)) - { - SleepThreadUntil (ONE_SECOND / CREDITS_FRAME_RATE / 2); - } + RenderCreditsScreen (LocalContext); } - - DestroyContext (DrawContext); - DestroyContext (LocalContext); - - // free remaining frames - DestroyDrawable (ReleaseDrawable (Frame)); - for ( ; first != last; first = (first + 1) % CREDIT_FRAMES) - DestroyDrawable (ReleaseDrawable (cf[first])); - - FinishTask (task); - return 0; } -static Task -StartCredits (void) +static BOOLEAN +LoadCredits (void) { - Task task; FONT_SIZE_DEF *fdef; CreditsTab = CaptureStringTable (LoadStringTable (CREDITS_STRTAB)); if (!CreditsTab) - return 0; + return FALSE; CreditsBack = CaptureDrawable (LoadGraphic (CREDITS_BACK_ANIM)); // load fonts for (fdef = CreditsFont; fdef->size; ++fdef) fdef->font = LoadFont (fdef->res); - CreditsRate = CREDITS_BASE_RATE; - CreditsRunning = FALSE; - - task = AssignTask (credit_roll_task, 4096, "credit roll"); - - return task; + return TRUE; } static void @@ -569,16 +631,16 @@ FONT_SIZE_DEF *fdef; DestroyStringTable (ReleaseStringTable (CreditsTab)); - CreditsTab = 0; + CreditsTab = NULL; DestroyDrawable (ReleaseDrawable (CreditsBack)); - CreditsBack = 0; + CreditsBack = NULL; // free fonts for (fdef = CreditsFont; fdef->size; ++fdef) { DestroyFont (fdef->font); - fdef->font = 0; + fdef->font = NULL; } } @@ -608,6 +670,7 @@ BOOLEAN oldsubtitles = optSubtitles; int i = 0; + // Outtakes have no voice tracks, so the subtitles are always on optSubtitles = TRUE; sliderDisabled = TRUE; oscillDisabled = TRUE; @@ -699,44 +762,57 @@ return FALSE; } - SleepThread (ONE_SECOND / 30); + SleepThread (ONE_SECOND / CREDITS_FRAME_RATE); return TRUE; } +static void +on_input_frame (void) +{ + processCreditsFrame (); +} + void Credits (BOOLEAN WithOuttakes) { BYTE fade_buf[1]; MUSIC_REF hMusic; - Task CredTask; CREDITS_INPUT_STATE cis; + RECT screenRect; + STAMP s; hMusic = LoadMusic (CREDITS_MUSIC); LockMutex (GraphicsLock); SetContext (ScreenContext); SetContextClipRect (NULL); - SetContextBackGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); + GetContextClipRect (&screenRect); + SetContextBackGroundColor (BLACK_COLOR); ClearDrawable (); + UnlockMutex (GraphicsLock); + + if (!LoadCredits ()) + return; + + // Fade in the background + s.origin.x = 0; + s.origin.y = 0; + s.frame = CreditsBack; + LockMutex (GraphicsLock); + DrawStamp (&s); fade_buf[0] = FadeAllToColor; - XFormColorMap ((COLORMAPPTR)fade_buf, 0); + XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2); UnlockMutex (GraphicsLock); // set the position of outtakes comm - CommWndRect.corner.x = ((SCREEN_WIDTH - SIS_SCREEN_WIDTH) >> 1); + CommWndRect.corner.x = (screenRect.extent.width - CommWndRect.extent.width) + / 2; CommWndRect.corner.y = 5; - // launch credits and wait for the task to start up - CredTask = StartCredits (); - while (CredTask && !CreditsRunning - && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) - { - UpdateInputState (); - SleepThread(ONE_SECOND / 20); - } - + InitCredits (); + SetInputCallback (on_input_frame); + if (WithOuttakes) { OutTakesRunning = TRUE; @@ -760,10 +836,10 @@ DoInput (&cis, TRUE); } - if (CredTask) - ConcludeTask (CredTask); + SetInputCallback (NULL); + FadeMusic (0, ONE_SECOND / 2); + UninitCredits (); - FadeMusic (0, ONE_SECOND / 2); LockMutex (GraphicsLock); SetContext (ScreenContext); fade_buf[0] = FadeAllToBlack; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-10 09:41:39
|
Revision: 3416 http://sc2.svn.sourceforge.net/sc2/?rev=3416&view=rev Author: avolkov Date: 2009-12-10 09:41:31 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Cleanup: TaskContext removed; the only place using it now has an own context Modified Paths: -------------- trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/plangen.c trunk/sc2/src/uqm/setup.c trunk/sc2/src/uqm/setup.h Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-12-10 09:26:57 UTC (rev 3415) +++ trunk/sc2/src/uqm/planets/planets.c 2009-12-10 09:41:31 UTC (rev 3416) @@ -217,7 +217,6 @@ } StopMusic (); - TaskContext = CreateContext ("TaskContext"); pPlanetDesc = pSolarSysState->pOrbitalDesc; GeneratePlanetSurface (pPlanetDesc, SurfDefFrame); @@ -300,9 +299,6 @@ Orbit->ScratchArray = 0; } - DestroyContext (TaskContext); - TaskContext = 0; - DestroyStringTable (ReleaseStringTable ( pSolarSysState->SysInfo.PlanetInfo.DiscoveryString )); Modified: trunk/sc2/src/uqm/planets/plangen.c =================================================================== --- trunk/sc2/src/uqm/planets/plangen.c 2009-12-10 09:26:57 UTC (rev 3415) +++ trunk/sc2/src/uqm/planets/plangen.c 2009-12-10 09:41:31 UTC (rev 3416) @@ -104,10 +104,8 @@ static void RenderTopography (FRAME DstFrame, BYTE *pTopoData, int w, int h) { - CONTEXT OldContext; FRAME OldFrame; - OldContext = SetContext (TaskContext); OldFrame = SetContextFGFrame (DstFrame); if (pSolarSysState->XlatRef == 0) @@ -205,7 +203,6 @@ } SetContextFGFrame (OldFrame); - SetContext (OldContext); } static inline void @@ -1732,13 +1729,15 @@ COUNT i, y; POINT loc; CONTEXT OldContext; + CONTEXT TopoContext; PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; BYTE *pScaledTopo = 0; BOOLEAN shielded = (pPlanetDesc->data_index & PLANET_SHIELDED) != 0; old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed); - OldContext = SetContext (TaskContext); + TopoContext = CreateContext ("Plangen.TopoContext"); + OldContext = SetContext (TopoContext); planet_orbit_init (); PlanDataPtr = &PlanData[pPlanetDesc->data_index & ~PLANET_SHIELDED]; @@ -1952,6 +1951,7 @@ } SetContext (OldContext); + DestroyContext (TopoContext); TFB_SeedRandom (old_seed); } Modified: trunk/sc2/src/uqm/setup.c =================================================================== --- trunk/sc2/src/uqm/setup.c 2009-12-10 09:26:57 UTC (rev 3415) +++ trunk/sc2/src/uqm/setup.c 2009-12-10 09:41:31 UTC (rev 3416) @@ -54,7 +54,6 @@ CONTEXT SpaceContext; CONTEXT StatusContext; CONTEXT OffScreenContext; -CONTEXT TaskContext; SIZE screen_width, screen_height; FRAME Screen; FONT StarConFont; Modified: trunk/sc2/src/uqm/setup.h =================================================================== --- trunk/sc2/src/uqm/setup.h 2009-12-10 09:26:57 UTC (rev 3415) +++ trunk/sc2/src/uqm/setup.h 2009-12-10 09:41:31 UTC (rev 3416) @@ -40,7 +40,6 @@ extern CONTEXT ScreenContext; extern CONTEXT SpaceContext; extern CONTEXT StatusContext; -extern CONTEXT TaskContext; extern SIZE screen_width, screen_height; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-10 21:01:13
|
Revision: 3419 http://sc2.svn.sourceforge.net/sc2/?rev=3419&view=rev Author: avolkov Date: 2009-12-10 21:01:05 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Dead variable MENU_STATE.MenuRepeatDelay removed Modified Paths: -------------- trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/battle.h trunk/sc2/src/uqm/cnctdlg.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/confirm.c trunk/sc2/src/uqm/controls.h trunk/sc2/src/uqm/credits.c trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/intro.c trunk/sc2/src/uqm/melee.c trunk/sc2/src/uqm/melee.h trunk/sc2/src/uqm/menustat.h trunk/sc2/src/uqm/netplay/netmelee.c trunk/sc2/src/uqm/pickmele.h trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/pstarmap.c trunk/sc2/src/uqm/setupmenu.c trunk/sc2/src/uqm/uqmdebug.c Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/battle.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -266,7 +266,6 @@ RECT r; BYTE battle_speed; - bs->MenuRepeatDelay = 0; SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); #if defined (NETPLAY) && defined (NETPLAY_CHECKSUM) Modified: trunk/sc2/src/uqm/battle.h =================================================================== --- trunk/sc2/src/uqm/battle.h 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/battle.h 2009-12-10 21:01:05 UTC (rev 3419) @@ -33,7 +33,6 @@ typedef struct battlestate_struct { BOOLEAN (*InputFunc) (struct battlestate_struct *pInputState); - COUNT MenuRepeatDelay; BOOLEAN first_time; DWORD NextTime; BattleFrameCallback *frame_cb; Modified: trunk/sc2/src/uqm/cnctdlg.c =================================================================== --- trunk/sc2/src/uqm/cnctdlg.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/cnctdlg.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -37,7 +37,6 @@ typedef struct connect_dialog_state { BOOLEAN (*InputFunc) (struct connect_dialog_state *pInputState); - COUNT MenuRepeatDelay; DWORD NextTime; BOOLEAN Initialized; @@ -355,7 +354,6 @@ // text entry setup tes.Initialized = FALSE; - tes.MenuRepeatDelay = 0; tes.NextTime = GetTimeCounter () + MENU_FRAME_RATE; tes.BaseStr = widget->value; tes.MaxSize = widget->maxlen; Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/comm.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -82,7 +82,6 @@ typedef struct encounter_state { BOOLEAN (*InputFunc) (struct encounter_state *pES); - COUNT MenuRepeatDelay; COUNT Initialized; TimeCount NextTime; // framerate control @@ -561,7 +560,6 @@ { // Fields required by DoInput() BOOLEAN (*InputFunc) (struct talking_state *); - COUNT MenuRepeatDelay; TimeCount NextTime; // framerate control COUNT waitTrack; @@ -803,7 +801,6 @@ { // standard state required by DoInput BOOLEAN (*InputFunc) (struct summary_state *pSS); - COUNT MenuRepeatDelay; // extended state BOOLEAN Initialized; @@ -825,7 +822,6 @@ pSS->PrintNext = TRUE; pSS->NextSub = GetFirstTrackSubtitle (); pSS->LeftOver = NULL; - pSS->MenuRepeatDelay = 0; pSS->InputFunc = DoConvSummary; pSS->Initialized = TRUE; DoInput (pSS, FALSE); @@ -1079,7 +1075,6 @@ { // Fields required by DoInput() BOOLEAN (*InputFunc) (struct last_replay_state *); - COUNT MenuRepeatDelay; TimeCount NextTime; // framerate control TimeCount TimeOut; Modified: trunk/sc2/src/uqm/confirm.c =================================================================== --- trunk/sc2/src/uqm/confirm.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/confirm.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -173,7 +173,6 @@ { // standard state required by DoInput BOOLEAN (*InputFunc) (struct popup_state *self); - COUNT MenuRepeatDelay; } POPUP_STATE; static BOOLEAN Modified: trunk/sc2/src/uqm/controls.h =================================================================== --- trunk/sc2/src/uqm/controls.h 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/controls.h 2009-12-10 21:01:05 UTC (rev 3419) @@ -131,7 +131,6 @@ { // standard state required by DoInput BOOLEAN (*InputFunc) (struct textentry_state *pTES); - COUNT MenuRepeatDelay; // these are semi-private read-only BOOLEAN Initialized; Modified: trunk/sc2/src/uqm/credits.c =================================================================== --- trunk/sc2/src/uqm/credits.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/credits.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -691,7 +691,6 @@ { // standard state required by DoInput BOOLEAN (*InputFunc) (void *pInputState); - COUNT MenuRepeatDelay; BOOLEAN AllowCancel; BOOLEAN AllowSpeedChange; @@ -825,7 +824,6 @@ // nothing to do now but wait until credits // are done or canceled by user - cis.MenuRepeatDelay = 0; cis.InputFunc = DoCreditsInput; cis.AllowCancel = !WithOuttakes; cis.CloseWhenDone = !WithOuttakes; Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/gameinp.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -40,7 +40,6 @@ typedef struct { BOOLEAN (*InputFunc) (void *pInputState); - COUNT MenuRepeatDelay; } INPUT_STATE_DESC; /* These static variables are the values that are set by the controllers. */ Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/gameopt.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -337,7 +337,6 @@ // text entry setup tes.Initialized = FALSE; - tes.MenuRepeatDelay = 0; tes.BaseStr = buf; tes.CursorPos = 0; tes.CbParam = pMS; Modified: trunk/sc2/src/uqm/intro.c =================================================================== --- trunk/sc2/src/uqm/intro.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/intro.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -41,7 +41,6 @@ { /* standard state required by DoInput */ BOOLEAN (*InputFunc) (void *pInputState); - COUNT MenuRepeatDelay; /* Presentation state */ TimeCount StartTime; @@ -79,7 +78,6 @@ typedef struct { /* standard state required by DoInput */ BOOLEAN (*InputFunc) (void *pInputState); - COUNT MenuRepeatDelay; /* Spinanim state */ STAMP anim; @@ -91,7 +89,6 @@ { // standard state required by DoInput BOOLEAN (*InputFunc) (void *pInputState); - COUNT MenuRepeatDelay; LEGACY_VIDEO_REF CurVideo; @@ -778,7 +775,6 @@ UnlockMutex (GraphicsLock); SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - pis.MenuRepeatDelay = 0; pis.InputFunc = DoPresentation; pis.LastDrawKind = -1; pis.TextVPos = 'B'; @@ -874,7 +870,6 @@ if (!ref) return FALSE; - vis.MenuRepeatDelay = 0; vis.InputFunc = DoVideoInput; vis.CurVideo = ref; SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); Modified: trunk/sc2/src/uqm/melee.c =================================================================== --- trunk/sc2/src/uqm/melee.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/melee.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -1128,7 +1128,6 @@ UnlockMutex (GraphicsLock); tes.Initialized = FALSE; - tes.MenuRepeatDelay = 0; tes.BaseStr = pMS->SideState[pMS->side].TeamImage.TeamName; tes.CursorPos = 0; tes.MaxSize = MAX_TEAM_CHARS + 1; Modified: trunk/sc2/src/uqm/melee.h =================================================================== --- trunk/sc2/src/uqm/melee.h 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/melee.h 2009-12-10 21:01:05 UTC (rev 3419) @@ -103,7 +103,6 @@ struct melee_state { BOOLEAN (*InputFunc) (struct melee_state *pInputState); - COUNT MenuRepeatDelay; BOOLEAN Initialized; MELEE_OPTIONS MeleeOption; Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/menustat.h 2009-12-10 21:01:05 UTC (rev 3419) @@ -26,8 +26,8 @@ typedef struct menu_state { + // Standard field required by DoInput() BOOLEAN (*InputFunc) (struct menu_state *pMS); - COUNT MenuRepeatDelay; SIZE Initialized; Modified: trunk/sc2/src/uqm/netplay/netmelee.c =================================================================== --- trunk/sc2/src/uqm/netplay/netmelee.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/netplay/netmelee.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -550,7 +550,6 @@ // Common fields of INPUT_STATE_DESC, from which this structure // "inherits". BOOLEAN(*InputFunc)(void *pInputState); - COUNT MenuRepeatDelay; NetConnection *conn; NetState nextState; @@ -593,7 +592,6 @@ negotiateReady(NetConnection *conn, bool notifyRemote, NetState nextState) { NegotiateReadyState state; state.InputFunc = (BOOLEAN(*)(void *)) negotiateReadyInputFunc; - state.MenuRepeatDelay = 0; state.conn = conn; state.nextState = nextState; state.done = false; @@ -639,7 +637,6 @@ // Common fields of INPUT_STATE_DESC, from which this structure // "inherits". BOOLEAN(*InputFunc)(void *pInputState); - COUNT MenuRepeatDelay; NetConnection *conn; NetConnection_ReadyCallback readyCallback; @@ -677,7 +674,6 @@ waitReady(NetConnection *conn) { WaitReadyState state; state.InputFunc =(BOOLEAN(*)(void *)) waitReadyInputFunc; - state.MenuRepeatDelay = 0; state.conn = conn; state.readyCallback = NetConnection_getReadyCallback(conn); state.readyCallbackArg = NetConnection_getReadyCallbackArg(conn); @@ -698,7 +694,6 @@ // Common fields of INPUT_STATE_DESC, from which this structure // "inherits". BOOLEAN(*InputFunc)(void *pInputState); - COUNT MenuRepeatDelay; NetConnection *conn; NetState nextState; @@ -743,7 +738,6 @@ waitReset(NetConnection *conn, NetState nextState) { WaitResetState state; state.InputFunc = (BOOLEAN(*)(void *)) waitResetInputFunc; - state.MenuRepeatDelay = 0; state.conn = conn; state.nextState = nextState; state.done = false; Modified: trunk/sc2/src/uqm/pickmele.h =================================================================== --- trunk/sc2/src/uqm/pickmele.h 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/pickmele.h 2009-12-10 21:01:05 UTC (rev 3419) @@ -45,7 +45,7 @@ struct getmelee_struct { BOOLEAN (*InputFunc) (struct getmelee_struct *pInputState); - COUNT MenuRepeatDelay; + BOOLEAN Initialized; struct { Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/planets/lander.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -56,7 +56,6 @@ struct LanderInputState { // Fields required by DoInput() BOOLEAN (*InputFunc) (LanderInputState *pMS); - COUNT MenuRepeatDelay; BOOLEAN Initialized; TimeCount NextTime; @@ -1614,7 +1613,6 @@ if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); - pMS->MenuRepeatDelay = 0; if (!pMS->Initialized) { COUNT landerSpeedNumer; Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -1209,7 +1209,6 @@ // text entry setup tes.Initialized = FALSE; - tes.MenuRepeatDelay = 0; tes.BaseStr = pss->Text; tes.MaxSize = sizeof (pss->Text); tes.CursorPos = 0; Modified: trunk/sc2/src/uqm/setupmenu.c =================================================================== --- trunk/sc2/src/uqm/setupmenu.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/setupmenu.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -42,7 +42,7 @@ typedef struct setup_menu_state { BOOLEAN (*InputFunc) (struct setup_menu_state *pInputState); - COUNT MenuRepeatDelay; + BOOLEAN initialized; int anim_frame_count; DWORD NextTime; @@ -550,7 +550,6 @@ // text entry setup tes.Initialized = FALSE; - tes.MenuRepeatDelay = 0; tes.NextTime = GetTimeCounter () + MENU_FRAME_RATE; tes.BaseStr = widget->value; tes.MaxSize = widget->maxlen; Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2009-12-10 20:52:20 UTC (rev 3418) +++ trunk/sc2/src/uqm/uqmdebug.c 2009-12-10 21:01:05 UTC (rev 3419) @@ -1838,7 +1838,6 @@ { // standard state required by DoInput BOOLEAN (*InputFunc) (struct wait_state *self); - COUNT MenuRepeatDelay; } WAIT_STATE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-10 21:44:29
|
Revision: 3421 http://sc2.svn.sourceforge.net/sc2/?rev=3421&view=rev Author: avolkov Date: 2009-12-10 21:44:21 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Cleanup: remove MENU_STATE.flash_task completely Modified Paths: -------------- trunk/sc2/src/uqm/menustat.h trunk/sc2/src/uqm/pickship.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/starbase.c Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2009-12-10 21:34:12 UTC (rev 3420) +++ trunk/sc2/src/uqm/menustat.h 2009-12-10 21:44:21 UTC (rev 3421) @@ -21,7 +21,6 @@ #include "libs/gfxlib.h" #include "libs/sndlib.h" -#include "libs/tasklib.h" #include "flash.h" typedef struct menu_state @@ -38,7 +37,6 @@ SIZE delta_item; FRAME ModuleFrame; - Task flash_task; RECT flash_rect0, flash_rect1; FRAME flash_frame0, flash_frame1; FlashContext *flashContext; Modified: trunk/sc2/src/uqm/pickship.c =================================================================== --- trunk/sc2/src/uqm/pickship.c 2009-12-10 21:34:12 UTC (rev 3420) +++ trunk/sc2/src/uqm/pickship.c 2009-12-10 21:44:21 UTC (rev 3421) @@ -273,7 +273,6 @@ MenuState.Initialized = FALSE; MenuState.first_item.x = NUM_PICK_SHIP_COLUMNS >> 1; MenuState.first_item.y = 0; - MenuState.flash_task = 0; MenuState.CurFrame = 0; MenuState.flash_rect1.corner = pick_r.corner; MenuState.flash_rect1.extent.width = 0; Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-12-10 21:34:12 UTC (rev 3420) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-10 21:44:21 UTC (rev 3421) @@ -1207,9 +1207,9 @@ { MENU_STATE MenuState; + memset (&MenuState, 0, sizeof MenuState); + MenuState.InputFunc = DoScan; - MenuState.Initialized = FALSE; - MenuState.flash_task = 0; if (optWhichMenu == OPT_3DO && ((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) Modified: trunk/sc2/src/uqm/starbase.c =================================================================== --- trunk/sc2/src/uqm/starbase.c 2009-12-10 21:34:12 UTC (rev 3420) +++ trunk/sc2/src/uqm/starbase.c 2009-12-10 21:44:21 UTC (rev 3421) @@ -317,12 +317,6 @@ pMS->hMusic = 0; } - if (pMS->flash_task) - { - Task_SetState (pMS->flash_task, TASK_EXIT); - pMS->flash_task = 0; - } - pMS->Initialized = TRUE; UnlockMutex (GraphicsLock); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-11 18:46:16
|
Revision: 3423 http://sc2.svn.sourceforge.net/sc2/?rev=3423&view=rev Author: avolkov Date: 2009-12-11 18:46:09 +0000 (Fri, 11 Dec 2009) Log Message: ----------- Full screen transitions do not need to specify a rect Modified Paths: -------------- trunk/sc2/src/uqm/outfit.c trunk/sc2/src/uqm/starbase.c Modified: trunk/sc2/src/uqm/outfit.c =================================================================== --- trunk/sc2/src/uqm/outfit.c 2009-12-11 18:21:52 UTC (rev 3422) +++ trunk/sc2/src/uqm/outfit.c 2009-12-11 18:46:09 UTC (rev 3423) @@ -719,15 +719,7 @@ DrawFlagshipStats (); UnlockMutex (GraphicsLock); - { - RECT r; - - r.corner.x = 0; - r.corner.y = 0; - r.extent.width = SCREEN_WIDTH; - r.extent.height = SCREEN_HEIGHT; - ScreenTransition (3, &r); - } + ScreenTransition (3, NULL); PlayMusic (pMS->hMusic, TRUE, 1); UnbatchGraphics (); Modified: trunk/sc2/src/uqm/starbase.c =================================================================== --- trunk/sc2/src/uqm/starbase.c 2009-12-11 18:21:52 UTC (rev 3422) +++ trunk/sc2/src/uqm/starbase.c 2009-12-11 18:46:09 UTC (rev 3423) @@ -331,15 +331,7 @@ ClearDrawable (); rotateStarbase (pMS, pMS->CurFrame); DrawBaseStateStrings ((STARBASE_STATE)~0, pMS->CurState); - { - RECT r; - - r.corner.x = 0; - r.corner.y = 0; - r.extent.width = SCREEN_WIDTH; - r.extent.height = SCREEN_HEIGHT; - ScreenTransition (3, &r); - } + ScreenTransition (3, NULL); PlayMusic (pMS->hMusic, TRUE, 1); UnbatchGraphics (); UnlockMutex (GraphicsLock); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |