From: <av...@us...> - 2009-10-29 00:40:42
|
Revision: 3262 http://sc2.svn.sourceforge.net/sc2/?rev=3262&view=rev Author: avolkov Date: 2009-10-29 00:40:35 +0000 (Thu, 29 Oct 2009) Log Message: ----------- Fixed Melee menu timeouts after Load team and NET dialogs; bug #1067 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/loadmele.c trunk/sc2/src/uqm/melee.c trunk/sc2/src/uqm/melee.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-10-28 22:58:50 UTC (rev 3261) +++ trunk/sc2/ChangeLog 2009-10-29 00:40:35 UTC (rev 3262) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed Melee menu timeout when both sides are Cyborgs (bug #1067) - Alex - Fixed AI ship not moving on warp in (bug #648) - Alex - Revert gfx settings entirely when a mode switch fails (bug #1056) - Alex - Fixed the Syreen lights-out scene timing (bug #1011) - Alex Modified: trunk/sc2/src/uqm/loadmele.c =================================================================== --- trunk/sc2/src/uqm/loadmele.c 2009-10-28 22:58:50 UTC (rev 3261) +++ trunk/sc2/src/uqm/loadmele.c 2009-10-29 00:40:35 UTC (rev 3262) @@ -365,6 +365,7 @@ } pMS->InputFunc = DoMelee; + pMS->LastInputTime = GetTimeCounter (); { RECT r; Modified: trunk/sc2/src/uqm/melee.c =================================================================== --- trunk/sc2/src/uqm/melee.c 2009-10-28 22:58:50 UTC (rev 3261) +++ trunk/sc2/src/uqm/melee.c 2009-10-29 00:40:35 UTC (rev 3262) @@ -188,7 +188,6 @@ // Loaded from melee/melebkgd.ani static FRAME BuildPickFrame; // Constructed. -DWORD LastInputTime; MELEE_STATE *pMeleeState; BOOLEAN DoMelee (MELEE_STATE *pMS); @@ -1086,7 +1085,7 @@ pMS->MeleeOption = START_MELEE; pMS->InputFunc = DoMelee; UnlockMutex (GraphicsLock); - LastInputTime = GetTimeCounter (); + pMS->LastInputTime = GetTimeCounter (); } else if (pMS->row < NUM_MELEE_ROWS && (PulsedInputState.menu[KEY_MENU_SELECT] || @@ -1936,6 +1935,7 @@ } RedrawMeleeFrame (); pMS->InputFunc = DoMelee; + pMS->LastInputTime = GetTimeCounter (); if (!pMS->flash_task) { pMS->flash_task = AssignTask (flash_selection_func, 2048, @@ -1962,6 +1962,7 @@ UpdateMeleeStatusMessage (which_side); pMS->InputFunc = DoMelee; + pMS->LastInputTime = GetTimeCounter (); Deselect (pMS->MeleeOption); pMS->MeleeOption = START_MELEE; if (!pMS->flash_task) @@ -2073,7 +2074,6 @@ pMS->Initialized = FALSE; pMS->side = pMS->MeleeOption == LOAD_TOP ? 0 : 1; DoLoadTeam (pMS); - LastInputTime = GetTimeCounter (); break; case SAVE_TOP: case SAVE_BOT: @@ -2102,6 +2102,7 @@ which_side = pMS->MeleeOption == NET_TOP ? 1 : 0; confirmed = MeleeConnectDialog (which_side); RedrawMeleeFrame (); + pMS->LastInputTime = GetTimeCounter (); if (confirmed) { pMS->Initialized = FALSE; @@ -2163,7 +2164,7 @@ XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); } - LastInputTime = GetTimeCounter (); + pMS->LastInputTime = GetTimeCounter (); return TRUE; } @@ -2176,7 +2177,7 @@ { // Start editing the teams. LockMutex (GraphicsLock); - LastInputTime = GetTimeCounter (); + pMS->LastInputTime = GetTimeCounter (); Deselect (pMS->MeleeOption); UnlockMutex (GraphicsLock); pMS->MeleeOption = EDIT_MELEE; @@ -2202,17 +2203,17 @@ NewMeleeOption = pMS->MeleeOption; if (PulsedInputState.menu[KEY_MENU_UP]) { - LastInputTime = GetTimeCounter (); + pMS->LastInputTime = GetTimeCounter (); NewMeleeOption = MeleeOptionUp (pMS->MeleeOption); } else if (PulsedInputState.menu[KEY_MENU_DOWN]) { - LastInputTime = GetTimeCounter (); + pMS->LastInputTime = GetTimeCounter (); NewMeleeOption = MeleeOptionDown (pMS->MeleeOption); } if ((PlayerControl[0] & PlayerControl[1] & PSYTRON_CONTROL) - && GetTimeCounter () - LastInputTime > ONE_SECOND * 10) + && GetTimeCounter () - pMS->LastInputTime > ONE_SECOND * 10) { force_select = TRUE; NewMeleeOption = START_MELEE; Modified: trunk/sc2/src/uqm/melee.h =================================================================== --- trunk/sc2/src/uqm/melee.h 2009-10-28 22:58:50 UTC (rev 3261) +++ trunk/sc2/src/uqm/melee.h 2009-10-29 00:40:35 UTC (rev 3262) @@ -24,6 +24,7 @@ #include "libs/gfxlib.h" #include "libs/mathlib.h" #include "libs/sndlib.h" +#include "libs/timelib.h" #include "libs/reslib.h" #include "netplay/packet.h" // for NetplayAbortReason and NetplayResetReason. @@ -115,6 +116,7 @@ RandomContext *randomContext; /* RNG state for all local random decisions, i.e. those * decisions that are not shared among network parties. */ + TimeCount LastInputTime; MUSIC_REF hMusic; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-05 03:27:49
|
Revision: 3275 http://sc2.svn.sourceforge.net/sc2/?rev=3275&view=rev Author: avolkov Date: 2009-11-05 03:27:36 +0000 (Thu, 05 Nov 2009) Log Message: ----------- Final GOOD_GUY/BAD_GUY cleanup, now enumerated Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/build.c trunk/sc2/src/uqm/comm/chmmr/chmmrc.c trunk/sc2/src/uqm/comm/orz/orzc.c trunk/sc2/src/uqm/comm/spahome/spahome.c trunk/sc2/src/uqm/comm/spathi/spathic.c trunk/sc2/src/uqm/comm/starbas/starbas.c trunk/sc2/src/uqm/comm/supox/supoxc.c trunk/sc2/src/uqm/comm/utwig/utwigc.c trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/cons_res.c trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/gameev.c trunk/sc2/src/uqm/grpinfo.c trunk/sc2/src/uqm/grpinfo.h trunk/sc2/src/uqm/load.c trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/save.c trunk/sc2/src/uqm/shipyard.c trunk/sc2/src/uqm/uqmdebug.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/ChangeLog 2009-11-05 03:27:36 UTC (rev 3275) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Internal changes: GOOD_GUY/BAD_GUY ship flags retired - Alex - Fixed Melee menu timeout when both sides are Cyborgs (bug #1067) - Alex - Fixed AI ship not moving on warp in (bug #648) - Alex - Revert gfx settings entirely when a mode switch fails (bug #1056) - Alex Modified: trunk/sc2/src/uqm/build.c =================================================================== --- trunk/sc2/src/uqm/build.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/build.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -123,7 +123,7 @@ which_ship = FleetPtr->known_strength; else if (FleetPtr->actual_strength == 0) { - if (!(FleetPtr->allied_state & (GOOD_GUY | BAD_GUY))) + if (FleetPtr->allied_state == DEAD_GUY) which_ship = 0; } else if (FleetPtr->known_strength == 0 @@ -182,10 +182,10 @@ } case CHECK_ALLIANCE: { - COUNT flags; + UWORD flags; FLEET_INFO *FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); - flags = FleetPtr->allied_state & (GOOD_GUY | BAD_GUY); + flags = FleetPtr->allied_state; UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); return flags; } @@ -195,17 +195,16 @@ FLEET_INFO *FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); - if (!(FleetPtr->allied_state & (GOOD_GUY | BAD_GUY))) + if (FleetPtr->allied_state == DEAD_GUY) { /* Strange request, silently ignore it */ UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); break; } - FleetPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); if (state == SET_ALLIED) - FleetPtr->allied_state |= GOOD_GUY; + FleetPtr->allied_state = GOOD_GUY; else - FleetPtr->allied_state |= BAD_GUY; + FleetPtr->allied_state = BAD_GUY; UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); break; @@ -381,8 +380,6 @@ SHIP_FRAGMENT *ShipFragPtr; ShipFragPtr = LockShipFrag (pDstQueue, hBuiltShip); - ShipFragPtr->which_side = TemplatePtr->allied_state & - (GOOD_GUY | BAD_GUY); ShipFragPtr->captains_name_index = captains_name_index; ShipFragPtr->race_strings = TemplatePtr->race_strings; ShipFragPtr->icons = TemplatePtr->icons; Modified: trunk/sc2/src/uqm/comm/chmmr/chmmrc.c =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -261,7 +261,7 @@ DISABLE_PHRASE (where_distraction); } - if (!(ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) & GOOD_GUY)) + if (ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) != GOOD_GUY) Response (tech_help, NotReady); else if (PHRASE_ENABLED (further_assistance)) Response (further_assistance, NotReady); @@ -308,7 +308,7 @@ Response (wont_hurt_my_ship, ImproveBomb); else if (PHRASE_ENABLED (bummer_about_my_ship)) Response (bummer_about_my_ship, ImproveBomb); - if (!(ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) & GOOD_GUY)) + if (ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) != GOOD_GUY) Response (other_assistance, ImproveBomb); Response (proceed, ExitConversation); } Modified: trunk/sc2/src/uqm/comm/orz/orzc.c =================================================================== --- trunk/sc2/src/uqm/comm/orz/orzc.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/orz/orzc.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -322,8 +322,8 @@ if (PHRASE_ENABLED (may_we_land)) { - if (Manner == 3 && (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) - & GOOD_GUY)) + if (Manner == 3 && + ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) == GOOD_GUY) Response (may_we_land, ExitConversation); else Response (may_we_land, TaaloWorld); @@ -705,8 +705,8 @@ TaaloWorld ((RESPONSE_REF)0); } - else if (Manner == 3 && (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) - & GOOD_GUY)) + else if (Manner == 3 && + ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) == GOOD_GUY) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { Modified: trunk/sc2/src/uqm/comm/spahome/spahome.c =================================================================== --- trunk/sc2/src/uqm/comm/spahome/spahome.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/spahome/spahome.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -915,7 +915,7 @@ { SpathiAngry ((RESPONSE_REF)0); } - else if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) & GOOD_GUY) + else if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) == GOOD_GUY) { CommData.AlienColorMap = SetAbsColorMapIndex (CommData.AlienColorMap, 1); Modified: trunk/sc2/src/uqm/comm/spathi/spathic.c =================================================================== --- trunk/sc2/src/uqm/comm/spathi/spathic.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/spathi/spathic.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -750,7 +750,7 @@ Response (we_fight_again_space, ExitConversation); Response (bye_angry_space, ExitConversation); } - else if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) & GOOD_GUY) + else if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) == GOOD_GUY) { SpathiAllies ((RESPONSE_REF)0); } Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -692,7 +692,7 @@ for (i = 0; i < NUM_AVAILABLE_RACES; ++i) { if (i != HUMAN_SHIP - && (ActivateStarShip (i, CHECK_ALLIANCE) & GOOD_GUY)) + && ActivateStarShip (i, CHECK_ALLIANCE) == GOOD_GUY) ++num_aliens; } @@ -1361,35 +1361,35 @@ { case 0: if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_1; } break; case 1: if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_2; } break; case 2: if (ActivateStarShip (SUPOX_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_3; } break; case 3: if (ActivateStarShip (UTWIG_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_4; } break; case 4: if (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_5; } @@ -1455,14 +1455,14 @@ break; case 12: if (ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_13; } break; case 13: if (ActivateStarShip (SHOFIXTI_SHIP, CHECK_ALLIANCE) - & GOOD_GUY) + == GOOD_GUY) { pStr = STARBASE_BULLETIN_14; } Modified: trunk/sc2/src/uqm/comm/supox/supoxc.c =================================================================== --- trunk/sc2/src/uqm/comm/supox/supoxc.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/supox/supoxc.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -552,7 +552,7 @@ SET_GAME_STATE (BATTLE_SEGUE, 0); } - else if (ActivateStarShip (SUPOX_SHIP, CHECK_ALLIANCE) & GOOD_GUY) + else if (ActivateStarShip (SUPOX_SHIP, CHECK_ALLIANCE) == GOOD_GUY) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { Modified: trunk/sc2/src/uqm/comm/utwig/utwigc.c =================================================================== --- trunk/sc2/src/uqm/comm/utwig/utwigc.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/utwig/utwigc.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -807,7 +807,7 @@ Response (hey_wait_got_ultron, ExitConversation); } } - else if (ActivateStarShip (UTWIG_SHIP, CHECK_ALLIANCE) & GOOD_GUY) + else if (ActivateStarShip (UTWIG_SHIP, CHECK_ALLIANCE) == GOOD_GUY) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { Modified: trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c =================================================================== --- trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -734,7 +734,7 @@ Response (whats_up_homeworld, ZoqFotHome); if (PHRASE_ENABLED (any_war_news)) Response (any_war_news, ZoqFotHome); - if (!(ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) & GOOD_GUY)) + if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) != GOOD_GUY) Response (i_want_alliance, ZoqFotHome); else if (PHRASE_ENABLED (want_specific_info)) { @@ -861,7 +861,7 @@ else { NumVisits = GET_GAME_STATE (ZOQFOT_HOME_VISITS); - if (!(ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) & GOOD_GUY)) + if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) != GOOD_GUY) { switch (NumVisits++) { @@ -946,7 +946,7 @@ zoqfot_desc.AlienTextWidth = (SIS_TEXT_WIDTH >> 1) - TEXT_X_OFFS; - if ((ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) & GOOD_GUY) + if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) == GOOD_GUY || LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE) { SET_GAME_STATE (BATTLE_SEGUE, 0); Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/comm.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -1435,7 +1435,7 @@ || LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)) || (which_comm != CHMMR_CONVERSATION && which_comm != SYREEN_CONVERSATION - ))//&& (ActivateStarShip (status, CHECK_ALLIANCE) & BAD_GUY))) + ))//&& ActivateStarShip (status, CHECK_ALLIANCE) == BAD_GUY)) BuildBattle (NPC_PLAYER_NUM); } Modified: trunk/sc2/src/uqm/cons_res.c =================================================================== --- trunk/sc2/src/uqm/cons_res.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/cons_res.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -19,7 +19,6 @@ #include <stdio.h> #include "cons_res.h" -#include "element.h" #include "resinst.h" #include "nameref.h" #include "setup.h" Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/element.h 2009-11-05 03:27:36 UTC (rev 3275) @@ -30,8 +30,7 @@ typedef HLINK HELEMENT; // Bits for ELEMENT_FLAGS: -#define GOOD_GUY (1 << 0) -#define BAD_GUY (1 << 1) +// bits 0 and 1 are now available #define PLAYER_SHIP (1 << 2) // The ELEMENT is a player controlable ship, and not some bullet, // crew, asteroid, fighter, etc. This does not mean that the ship Modified: trunk/sc2/src/uqm/gameev.c =================================================================== --- trunk/sc2/src/uqm/gameev.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/gameev.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -112,7 +112,7 @@ ZOQFOTPIK_SHIP); ZoqFotPtr = LockFleetInfo (&GLOBAL (avail_race_q), hZoqFot); ZoqFotPtr->actual_strength = 0; - ZoqFotPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); + ZoqFotPtr->allied_state = DEAD_GUY; UnlockFleetInfo (&GLOBAL (avail_race_q), hZoqFot); SET_GAME_STATE (ZOQFOT_DISTRESS, 2); @@ -283,7 +283,7 @@ if (delta_strength <= 0) { delta_strength = 0; - FleetPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); + FleetPtr->allied_state = DEAD_GUY; } else if (delta_strength > MAX_FLEET_STRENGTH) delta_strength = MAX_FLEET_STRENGTH; @@ -342,7 +342,7 @@ if (dx == 0 && dy == 0) { // Arrived at the victim's home world. Cleanse it. - FleetPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); + FleetPtr->allied_state = DEAD_GUY; FleetPtr->actual_strength = 0; } else if (FleetPtr->actual_strength) @@ -437,7 +437,7 @@ if (PkunkPtr->actual_strength == 0) { SET_GAME_STATE (YEHAT_ABSORBED_PKUNK, 1); - PkunkPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); + PkunkPtr->allied_state = DEAD_GUY; ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING); } else @@ -540,8 +540,8 @@ { IlwrathPtr->actual_strength = 0; ThraddPtr->actual_strength = 0; - IlwrathPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); - ThraddPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); + IlwrathPtr->allied_state = DEAD_GUY; + ThraddPtr->allied_state = DEAD_GUY; } else if (IlwrathPtr->actual_strength) { @@ -575,7 +575,7 @@ (BYTE)(((strength_loss % MADD_LENGTH) << 8) / MADD_LENGTH); SET_GAME_STATE (THRADD_VISITS, 0); - if (ThraddPtr->allied_state & GOOD_GUY) + if (ThraddPtr->allied_state == GOOD_GUY) ActivateStarShip (THRADDASH_SHIP, SET_NOT_ALLIED); } Modified: trunk/sc2/src/uqm/grpinfo.c =================================================================== --- trunk/sc2/src/uqm/grpinfo.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/grpinfo.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -99,7 +99,7 @@ { BYTE tmpb; - sread_16 (fp, &FragPtr->which_side); + sread_16 (fp, NULL); /* unused: was which_side */ sread_8 (fp, &FragPtr->captains_name_index); sread_8 (fp, NULL); /* padding; for savegame compat */ sread_16 (fp, NULL); /* unused: was ship_flags */ @@ -119,7 +119,7 @@ static void WriteShipFragment (void *fp, const SHIP_FRAGMENT *FragPtr) { - swrite_16 (fp, FragPtr->which_side); + swrite_16 (fp, 0); /* unused: was which_side */ swrite_8 (fp, FragPtr->captains_name_index); swrite_8 (fp, 0); /* padding; for savegame compat */ swrite_16 (fp, 0); /* unused: was ship_flags */ @@ -626,8 +626,6 @@ hGroup = BuildGroup (&GLOBAL (ip_group_q), RaceType); GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup); - // XXX: which_side is unused, other than this assign - //GroupPtr->which_side = BAD_GUY; GroupPtr->group_id = which_group; GroupPtr->in_system = 1; Modified: trunk/sc2/src/uqm/grpinfo.h =================================================================== --- trunk/sc2/src/uqm/grpinfo.h 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/grpinfo.h 2009-11-05 03:27:36 UTC (rev 3275) @@ -32,8 +32,6 @@ HIPGROUP pred; HIPGROUP succ; - /* unused: COUNT which_side; */ - UWORD group_counter; BYTE race_id; BYTE sys_loc; Modified: trunk/sc2/src/uqm/load.c =================================================================== --- trunk/sc2/src/uqm/load.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/load.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -170,7 +170,7 @@ FragPtr = LockShipFrag (pQueue, hStarShip); // Read SHIP_FRAGMENT elements - cread_16 (fh, &FragPtr->which_side); + cread_16 (fh, NULL); /* unused: was which_side */ cread_8 (fh, &FragPtr->captains_name_index); cread_8 (fh, NULL); /* padding */ cread_16 (fh, NULL); /* unused: was ship_flags */ Modified: trunk/sc2/src/uqm/races.h =================================================================== --- trunk/sc2/src/uqm/races.h 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/races.h 2009-11-05 03:27:36 UTC (rev 3275) @@ -297,8 +297,6 @@ { SHIP_BASE_COMMON; - COUNT which_side; - BYTE race_id; BYTE index; COUNT crew_level; @@ -339,7 +337,7 @@ SPECIES_ID SpeciesID; - UWORD allied_state; /* 0, GOOD_GUY, or BAD_GUY */ + UWORD allied_state; /* GOOD_GUY, BAD_GUY or DEAD_GUY */ BYTE days_left; /* Days left before the fleet reachers 'dest_loc'. */ BYTE growth_fract; COUNT crew_level; @@ -376,6 +374,14 @@ } FLEET_INFO; +// Values for FLEET_INFO.allied_state +enum +{ + DEAD_GUY = 0, + GOOD_GUY, + BAD_GUY, +}; + static inline FLEET_INFO * LockFleetInfo (const QUEUE *pq, HFLEETINFO h) { Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/save.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -146,7 +146,7 @@ cwrite_16 (fh, Index); // Write SHIP_FRAGMENT elements - cwrite_16 (fh, FragPtr->which_side); + cwrite_16 (fh, 0); /* unused; was which_side */ cwrite_8 (fh, FragPtr->captains_name_index); cwrite_8 (fh, 0); /* padding */ cwrite_16 (fh, 0); /* unused: was ship_flags */ Modified: trunk/sc2/src/uqm/shipyard.c =================================================================== --- trunk/sc2/src/uqm/shipyard.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/shipyard.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -156,7 +156,7 @@ FLEET_INFO *FleetPtr; FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); - if (FleetPtr->allied_state & GOOD_GUY) + if (FleetPtr->allied_state == GOOD_GUY) ++Index; hNextShip = _GetSuccLink (FleetPtr); @@ -177,7 +177,7 @@ FLEET_INFO *FleetPtr; FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); - if ((FleetPtr->allied_state & GOOD_GUY) && Index-- == 0) + if (FleetPtr->allied_state == GOOD_GUY && Index-- == 0) { UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip); return hStarShip; @@ -534,7 +534,7 @@ LockMutex (GraphicsLock); } } - if (!(ActivateStarShip (SHOFIXTI_SHIP, CHECK_ALLIANCE) & GOOD_GUY)) + if (ActivateStarShip (SHOFIXTI_SHIP, CHECK_ALLIANCE) != GOOD_GUY) { SET_GAME_STATE (CREW_PURCHASED0, LOBYTE (crew_bought)); SET_GAME_STATE (CREW_PURCHASED1, HIBYTE (crew_bought)); Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2009-11-04 23:51:26 UTC (rev 3274) +++ trunk/sc2/src/uqm/uqmdebug.c 2009-11-05 03:27:36 UTC (rev 3275) @@ -541,8 +541,7 @@ if (FleetPtr->icons != NULL) // Skip the Ur-Quan probe. { - FleetPtr->allied_state &= ~(GOOD_GUY | BAD_GUY); - FleetPtr->allied_state |= GOOD_GUY; + FleetPtr->allied_state = GOOD_GUY; } UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-05 23:53:55
|
Revision: 3284 http://sc2.svn.sourceforge.net/sc2/?rev=3284&view=rev Author: avolkov Date: 2009-11-05 23:53:43 +0000 (Thu, 05 Nov 2009) Log Message: ----------- Main and stream decored thread down-throttling, and game sleep when inactive (intended for portables and currently disabled in mainline); bug #1070; from Flandry Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/graphics/sdl/sdl_common.c trunk/sc2/src/libs/inplib.h trunk/sc2/src/libs/sound/stream.c trunk/sc2/src/uqm/controls.h trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/starcon.c trunk/sc2/src/uqm/util.c trunk/sc2/src/uqm.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/ChangeLog 2009-11-05 23:53:43 UTC (rev 3284) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Thread down-throttling and game sleep when inactive (currently disabled), + (bug #1070), from Flandry - Internal changes: GOOD_GUY/BAD_GUY ship flags retired - Alex - Fixed Melee menu timeout when both sides are Cyborgs (bug #1067) - Alex - Fixed AI ship not moving on warp in (bug #648) - Alex Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-11-05 23:53:43 UTC (rev 3284) @@ -56,6 +56,7 @@ int RenderedFrames = 0; volatile int QuitPosted = 0; +volatile int GameActive = 1; // Track the SDL_ACTIVEEVENT state SDL_APPACTIVE void TFB_PreInit (void) @@ -198,10 +199,19 @@ { /* Run through the InputEvent filter. */ ProcessInputEvent (&Event); - /* Handle Graphics events. */ + /* Handle graphics and exposure events. */ switch (Event.type) { - case SDL_ACTIVEEVENT: /* Lose/gain visibility */ - // TODO + case SDL_ACTIVEEVENT: /* Lose/gain visibility or focus */ + /* Up to three different state changes can occur in one event. */ + /* Here, disregard least significant change (mouse focus). */ +#if 0 /* Currently disabled in mainline */ + // This controls the automatic sleep/pause when minimized. + // On small displays (e.g. mobile devices), APPINPUTFOCUS would + // be an appropriate substitution for APPACTIVE: + // if (Event.active.state & SDL_APPINPUTFOCUS) + if (Event.active.state & SDL_APPACTIVE) + GameActive = Event.active.gain; +#endif break; case SDL_QUIT: QuitPosted = 1; Modified: trunk/sc2/src/libs/inplib.h =================================================================== --- trunk/sc2/src/libs/inplib.h 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/libs/inplib.h 2009-11-05 23:53:43 UTC (rev 3284) @@ -37,6 +37,7 @@ extern volatile int MouseButtonDown; extern volatile int QuitPosted; +extern volatile int GameActive; /* Functions for dealing with Character Mode */ Modified: trunk/sc2/src/libs/sound/stream.c =================================================================== --- trunk/sc2/src/libs/sound/stream.c 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/libs/sound/stream.c 2009-11-05 23:53:43 UTC (rev 3284) @@ -495,11 +495,12 @@ StreamDecoderTaskFunc (void *data) { Task task = (Task)data; + int active_streams; int i; while (!Task_ReadState (task, TASK_EXIT)) { - TaskSwitch (); + active_streams = 0; for (i = MUSIC_SOURCE; i < NUM_SOUNDSOURCES; ++i) { @@ -517,9 +518,17 @@ } process_stream (source); + active_streams++; UnlockMutex (source->stream_mutex); } + + if (active_streams == 0) + { // Throttle down the thread when there are no active streams + SleepThread (ONE_SECOND / 10); + } + else + TaskSwitch (); } FinishTask (task); Modified: trunk/sc2/src/uqm/controls.h =================================================================== --- trunk/sc2/src/uqm/controls.h 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/uqm/controls.h 2009-11-05 23:53:43 UTC (rev 3284) @@ -100,6 +100,7 @@ void SetDefaultMenuRepeatDelay (void); void ResetKeyRepeat (void); BOOLEAN PauseGame (void); +void SleepGame (void); BOOLEAN DoConfirmExit (void); BOOLEAN WaitAnyButtonOrQuit (BOOLEAN CheckSpecial); void WaitForNoInput (SIZE Duration); Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/uqm/gameinp.c 2009-11-05 23:53:43 UTC (rev 3284) @@ -228,6 +228,11 @@ * UpdateInputState routinely, so we handle pause and exit * state updates here. */ + // Automatically pause and enter low-activity state while inactive, + // for example, window minimized. + if (!GameActive) + SleepGame (); + if (GamePaused) PauseGame (); Modified: trunk/sc2/src/uqm/starcon.c =================================================================== --- trunk/sc2/src/uqm/starcon.c 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/uqm/starcon.c 2009-11-05 23:53:43 UTC (rev 3284) @@ -106,6 +106,7 @@ { GamePaused = FALSE; GLOBAL (CurrentActivity) |= CHECK_ABORT; + TaskSwitch (); } void Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/uqm/util.c 2009-11-05 23:53:43 UTC (rev 3284) @@ -20,9 +20,11 @@ #include "controls.h" #include "util.h" #include "setup.h" +#include "settings.h" #include "libs/inplib.h" #include "libs/sound/trackplayer.h" #include "libs/mathlib.h" +#include "libs/log.h" void @@ -250,3 +252,43 @@ return (GLOBAL (CurrentActivity) & CHECK_ABORT) != 0; } +// 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() +void +SleepGame (void) +{ + if (QuitPosted) + return; // Do not sleep the game when already asked to quit + + log_add (log_Debug, "Game is going to sleep"); + + if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE && + LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE) + SuspendGameClock (); + if (CommData.ConversationPhrases && PlayingTrack ()) + PauseTrack (); + PauseMusic (); + + LockMutex (GraphicsLock); + + while (!GameActive && !QuitPosted) + SleepThread (ONE_SECOND / 2); + + log_add (log_Debug, "Game is waking up"); + + WaitForNoInput (ONE_SECOND / 10); + FlushInput (); + + ResumeMusic (); + + if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE && + LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE) + ResumeGameClock (); + if (CommData.ConversationPhrases && PlayingTrack ()) + ResumeTrack (); + + UnlockMutex (GraphicsLock); + + TaskSwitch (); +} Modified: trunk/sc2/src/uqm.c =================================================================== --- trunk/sc2/src/uqm.c 2009-11-05 22:10:41 UTC (rev 3283) +++ trunk/sc2/src/uqm.c 2009-11-05 23:53:43 UTC (rev 3284) @@ -433,6 +433,10 @@ SignalStopMainThread (); ++i; } + else if (!GameActive) + { // Throttle down the main loop when game is inactive + SleepThread (ONE_SECOND / 4); + } TFB_ProcessEvents (); ProcessUtilityKeys (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-14 22:17:35
|
Revision: 3302 http://sc2.svn.sourceforge.net/sc2/?rev=3302&view=rev Author: Meep-Eep Date: 2009-11-14 22:17:24 +0000 (Sat, 14 Nov 2009) Log Message: ----------- Added graphics context debugging function. Plus small cleanups. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/doc/devel/debug trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/graphics/context.c trunk/sc2/src/libs/graphics/context.h trunk/sc2/src/libs/graphics/drawable.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/credits.c trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/globdata.c trunk/sc2/src/uqm/planets/genchmmr.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/setup.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/uqmdebug.c trunk/sc2/src/uqm/uqmdebug.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/ChangeLog 2009-11-14 22:17:24 UTC (rev 3302) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Added graphics context debugging function - SvdB - Thread down-throttling and game sleep when inactive (currently disabled), (bug #1070), from Flandry - Internal changes: GOOD_GUY/BAD_GUY ship flags retired - Alex Modified: trunk/sc2/doc/devel/debug =================================================================== --- trunk/sc2/doc/devel/debug 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/doc/devel/debug 2009-11-14 22:17:24 UTC (rev 3302) @@ -6,11 +6,15 @@ The function debugKeyPressed() in uqmdebug.c is called when the debug key is pressed. This function is a suitable place to put various debugging calls. -There is also a global variable 'debugHook', which can be set to a function -to be called the next iteration of the main game loop (which will occur -when the current activity (IP, HyperSpace, Communication, Battle) changes. -By setting this, a function can be called from the main loop, thereby -eliminating threading issues that may otherwise arrise. +There are also global variables 'debugHook' and 'doInputDebugHook', +which can be set to a function to be called from the Starcon2Main thread. +If if is set, 'debugHook' is called the next iteration of the main game loop +(which will occur when the current activity (IP, HyperSpace, Communication, +Battle) changes. The game will be in a well defined state here. +If 'doInputDebugHook' is set, the function it is set to is called from +doInput(), which is called all throughout the game. +By setting one of these hooks, a function can be called from the Starcon2Main +thread, thereby eliminating threading issues that may otherwise arrise. The debug key can be specified in user's override.cfg by adding a line with a text similar to "debug.1 = STRING:key F12". An interactive way to access various debugging code, similar to @@ -56,6 +60,13 @@ This function is not defined in sc2code/uqmdebug.h, but in libs/uio.h. This function can interactively (tty-based) display information on the state of the uio file system, and modifications can be made. +- the function dumpStrings() + This function prints all the game strings, and is useful to check whether + the various string bases, as defined in gamestr.h, are correct. +- the function debugContexts() + Prints and visually displays the various graphics contexts. + This function should only be called from doInputDebugHook(), as threading + issues would otherwise arrise. The first version of this document was created by Serge van den Boom, Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/libs/gfxlib.h 2009-11-14 22:17:24 UTC (rev 3302) @@ -169,8 +169,11 @@ extern CONTEXT SetContext (CONTEXT Context); extern COLOR SetContextForeGroundColor (COLOR Color); +extern COLOR GetContextForeGroundColor (void); extern COLOR SetContextBackGroundColor (COLOR Color); +extern COLOR GetContextBackGroundColor (void); extern FRAME SetContextFGFrame (FRAME Frame); +extern FRAME GetContextFGFrame (void); extern BOOLEAN SetContextClipping (BOOLEAN ClipStatus); extern BOOLEAN SetContextClipRect (RECT *pRect); extern BOOLEAN GetContextClipRect (RECT *pRect); @@ -191,7 +194,13 @@ extern void FlushGraphics (void); extern void ClearBackGround (RECT *pClipRect); extern void ClearDrawable (void); -extern CONTEXT CreateContext (void); +#ifdef DEBUG +extern CONTEXT CreateContextAux (const char *name); +#define CreateContext(name) CreateContextAux((name)) +#else /* if !defined(DEBUG) */ +extern CONTEXT CreateContextAux (void); +#define CreateContext(name) CreateContextAux() +#endif /* !defined(DEBUG) */ extern BOOLEAN DestroyContext (CONTEXT ContextRef); extern DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth, SIZE *pheight); @@ -199,6 +208,12 @@ SIZE height, COUNT num_frames); extern BOOLEAN DestroyDrawable (DRAWABLE Drawable); extern BOOLEAN GetFrameRect (FRAME Frame, RECT *pRect); +#ifdef DEBUG +extern const char *GetContextName (CONTEXT context); +extern CONTEXT GetFirstContext (void); +extern CONTEXT GetNextContext (CONTEXT context); +extern size_t GetContextCount (void); +#endif /* DEBUG */ extern HOT_SPOT SetFrameHot (FRAME Frame, HOT_SPOT HotSpot); extern HOT_SPOT GetFrameHot (FRAME Frame); Modified: trunk/sc2/src/libs/graphics/context.c =================================================================== --- trunk/sc2/src/libs/graphics/context.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/libs/graphics/context.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -22,6 +22,14 @@ GRAPHICS_STATUS _GraphicsStatusFlags; CONTEXT _pCurContext; +#ifdef DEBUG +// We keep track of all contexts +CONTEXT firstContext; + // The first one in the list. +CONTEXT *contextEnd = &firstContext; + // Where to put the next context. +#endif + PRIMITIVE _locPrim; FONT _CurFontPtr; @@ -37,12 +45,10 @@ if (LastContext) { UnsetContextFlags ( - MAKE_WORD (0, GRAPHICS_ACTIVE | DRAWABLE_ACTIVE) - ); + MAKE_WORD (0, GRAPHICS_ACTIVE | DRAWABLE_ACTIVE)); SetContextFlags ( MAKE_WORD (0, _GraphicsStatusFlags - & (GRAPHICS_ACTIVE | DRAWABLE_ACTIVE)) - ); + & (GRAPHICS_ACTIVE | DRAWABLE_ACTIVE))); DeactivateContext (); } @@ -65,17 +71,29 @@ return (LastContext); } +#ifdef DEBUG CONTEXT -CreateContext (void) +CreateContextAux (const char *name) +#else /* if !defined(DEBUG) */ +CONTEXT +CreateContextAux (void) +#endif /* !defined(DEBUG) */ { CONTEXT NewContext; NewContext = AllocContext (); if (NewContext) { + /* initialize context */ CONTEXT OldContext; - /* initialize context */ +#ifdef DEBUG + NewContext->name = name; + NewContext->next = NULL; + *contextEnd = NewContext; + contextEnd = &NewContext->next; +#endif /* DEBUG */ + OldContext = SetContext (NewContext); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); @@ -85,9 +103,25 @@ SetContext (OldContext); } - return (NewContext); + return NewContext; } +#ifdef DEBUG +// Loop through the list of context to the pointer which points to the +// specified context. This is either 'firstContext' or the address of +// the 'next' field of some other context. +static CONTEXT * +FindContextPtr (CONTEXT context) { + CONTEXT *ptr; + + for (ptr = &firstContext; *ptr != NULL; ptr = &(*ptr)->next) { + if (*ptr == context) + break; + } + return ptr; +} +#endif /* DEBUG */ + BOOLEAN DestroyContext (CONTEXT ContextRef) { @@ -97,6 +131,16 @@ if (_pCurContext && _pCurContext == ContextRef) SetContext ((CONTEXT)0); +#ifdef DEBUG + // Unlink the context. + { + CONTEXT *contextPtr = FindContextPtr (ContextRef); + if (contextEnd == &ContextRef->next) + contextEnd = contextPtr; + *contextPtr = ContextRef->next; + } +#endif /* DEBUG */ + FreeContext (ContextRef); return TRUE; } @@ -109,7 +153,8 @@ if (!ContextActive ()) return (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); - if ((oldColor = _get_context_fg_color ()) != Color) + oldColor = _get_context_fg_color (); + if (oldColor != Color) { SwitchContextForeGroundColor (Color); @@ -124,6 +169,15 @@ } COLOR +GetContextForeGroundColor (void) +{ + if (!ContextActive ()) + return (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); + + return _get_context_fg_color (); +} + +COLOR SetContextBackGroundColor (COLOR Color) { COLOR oldColor; @@ -131,14 +185,22 @@ if (!ContextActive ()) return (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); - if ((oldColor = _get_context_bg_color ()) != Color) - { + oldColor = _get_context_bg_color (); + if (oldColor != Color) SwitchContextBackGroundColor (Color); - } return (oldColor); } +COLOR +GetContextBackGroundColor (void) +{ + if (!ContextActive ()) + return (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); + + return _get_context_bg_color (); +} + BOOLEAN SetContextClipping (BOOLEAN ClipStatus) { @@ -249,3 +311,24 @@ _pCurContext->FontBacking = img; UnsetContextFBkFlags (FBK_DIRTY); } + +#ifdef DEBUG +const char * +GetContextName (CONTEXT context) +{ + return context->name; +} + +CONTEXT +GetFirstContext (void) +{ + return firstContext; +} + +CONTEXT +GetNextContext (CONTEXT context) +{ + return context->next; +} +#endif /* DEBUG */ + Modified: trunk/sc2/src/libs/graphics/context.h =================================================================== --- trunk/sc2/src/libs/graphics/context.h 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/libs/graphics/context.h 2009-11-14 22:17:24 UTC (rev 3302) @@ -40,6 +40,10 @@ TFB_Image *FontBacking; FBK_FLAGS BackingFlags; +#ifdef DEBUG + const char *name; + CONTEXT next; +#endif }; #define AllocContext() HCalloc (sizeof (CONTEXT_DESC)) Modified: trunk/sc2/src/libs/graphics/drawable.c =================================================================== --- trunk/sc2/src/libs/graphics/drawable.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/libs/graphics/drawable.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -51,6 +51,12 @@ return (LastFrame); } +FRAME +GetContextFGFrame (void) +{ + return _CurFramePtr; +} + DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth, SIZE *pheight) { Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/comm.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -1266,7 +1266,7 @@ SubtitleText.align = CommData.AlienTextAlign; // init subtitle cache context - TextCacheContext = CreateContext (); + TextCacheContext = CreateContext ("TextCacheContext"); TextCacheFrame = CaptureDrawable ( CreateDrawable (WANT_PIXMAP, SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT + 2, 1)); @@ -1287,7 +1287,7 @@ { RECT r; - TaskContext = CreateContext (); + TaskContext = CreateContext ("TaskContext"); SetContext (TaskContext); SetContextFGFrame (Screen); GetFrameRect (CommData.AlienFrame, &r); Modified: trunk/sc2/src/uqm/credits.c =================================================================== --- trunk/sc2/src/uqm/credits.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/credits.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -315,8 +315,8 @@ TextBack = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00); TextFore = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F); - LocalContext = CreateContext (); - DrawContext = CreateContext (); + LocalContext = CreateContext ("Credits.LocalContext"); + DrawContext = CreateContext ("Credits.DrawContext"); total_h = disp_h = SCREEN_HEIGHT; Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/gameinp.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -28,6 +28,7 @@ #include "settings.h" #include "sounds.h" #include "tactrans.h" +#include "uqmdebug.h" #include "libs/inplib.h" #include "libs/timelib.h" #include "libs/threadlib.h" @@ -352,6 +353,19 @@ UpdateInputState (); +#ifdef DEBUG + if (doInputDebugHook != NULL) + { + void (*saveDebugHook) (void); + saveDebugHook = doInputDebugHook; + doInputDebugHook = NULL; + // No further debugHook calls unless the called + // function resets doInputDebugHook. + (*saveDebugHook) (); + continue; + } +#endif + #if DEMO_MODE || CREATE_JOURNAL if (ArrowInput != DemoInput) #endif Modified: trunk/sc2/src/uqm/globdata.c =================================================================== --- trunk/sc2/src/uqm/globdata.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/globdata.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -125,7 +125,7 @@ RECT r; CONTEXT OldContext; - RadarContext = CreateContext (); + RadarContext = CreateContext ("RadarContext"); OldContext = SetContext (RadarContext); SetContextFGFrame (Screen); r.corner.x = RADAR_X; Modified: trunk/sc2/src/uqm/planets/genchmmr.c =================================================================== --- trunk/sc2/src/uqm/planets/genchmmr.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/planets/genchmmr.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -110,7 +110,7 @@ CaptureStringTable ( LoadStringTable (CHMMR_BASE_STRTAB)); - ScanContext = CreateContext (); + ScanContext = CreateContext ("genchmmr.ScanContext"); SetContext (ScanContext); SetContextFGFrame (Screen); r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH; Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/planets/planets.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -152,7 +152,7 @@ StopMusic (); - TaskContext = CreateContext (); + TaskContext = CreateContext ("TaskContext"); pPlanetDesc = pSolarSysState->pOrbitalDesc; Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/planets/scan.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -1164,7 +1164,7 @@ (MAP_HEIGHT >> 1) << MAG_SHIFT; LockMutex (GraphicsLock); - ScanContext = CreateContext (); + ScanContext = CreateContext ("ScanContext"); SetContext (ScanContext); initPlanetLocationImage (&MenuState); Modified: trunk/sc2/src/uqm/setup.c =================================================================== --- trunk/sc2/src/uqm/setup.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/setup.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -96,7 +96,7 @@ InitSound (argc, argv); InitVideoPlayer (TRUE); - ScreenContext = CreateContext (); + ScreenContext = CreateContext ("ScreenContext"); if (ScreenContext == NULL) return FALSE; @@ -158,7 +158,7 @@ { RECT r; - StatusContext = CreateContext (); + StatusContext = CreateContext ("StatusContext"); if (StatusContext == NULL) return FALSE; @@ -170,11 +170,11 @@ r.extent.height = STATUS_HEIGHT; SetContextClipRect (&r); - SpaceContext = CreateContext (); + SpaceContext = CreateContext ("SpaceContext"); if (SpaceContext == NULL) return FALSE; - OffScreenContext = CreateContext (); + OffScreenContext = CreateContext ("OffScreenContext"); if (OffScreenContext == NULL) return FALSE; Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/sis.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -761,7 +761,8 @@ --i; } - r.extent.height = (4 * j + (STORAGE_BAY_CAPACITY - 1)) / STORAGE_BAY_CAPACITY; + r.extent.height = (4 * j + (STORAGE_BAY_CAPACITY - 1)) / + STORAGE_BAY_CAPACITY; if (r.extent.height) { r.corner.y += 4 - r.extent.height; @@ -876,14 +877,11 @@ s.origin.y = 0; for (i = 0; i < NUM_DRIVE_SLOTS; ++i) { - BYTE which_piece; - - if ((which_piece = - GLOBAL_SIS (DriveSlots[i])) < EMPTY_SLOT) + BYTE which_piece = GLOBAL_SIS (DriveSlots[i]); + if (which_piece < EMPTY_SLOT) { s.frame = SetAbsFrameIndex ( - FlagStatFrame, which_piece + 1 + 0 - ); + FlagStatFrame, which_piece + 1 + 0); DrawStamp (&s); s.frame = IncFrameIndex (s.frame); DrawStamp (&s); @@ -894,14 +892,11 @@ s.origin.y = 0; for (i = 0; i < NUM_JET_SLOTS; ++i) { - BYTE which_piece; - - if ((which_piece = - GLOBAL_SIS (JetSlots[i])) < EMPTY_SLOT) + BYTE which_piece = GLOBAL_SIS (JetSlots[i]); + if (which_piece < EMPTY_SLOT) { s.frame = SetAbsFrameIndex ( - FlagStatFrame, which_piece + 1 + 1 - ); + FlagStatFrame, which_piece + 1 + 1); DrawStamp (&s); s.frame = IncFrameIndex (s.frame); DrawStamp (&s); @@ -913,14 +908,11 @@ s.origin.x = 1; // This properly centers the modules. for (i = 0; i < NUM_MODULE_SLOTS; ++i) { - BYTE which_piece; - - if ((which_piece = - GLOBAL_SIS (ModuleSlots[i])) < EMPTY_SLOT) + BYTE which_piece = GLOBAL_SIS (ModuleSlots[i]); + if (which_piece < EMPTY_SLOT) { s.frame = SetAbsFrameIndex ( - FlagStatFrame, which_piece + 1 + 2 - ); + FlagStatFrame, which_piece + 1 + 2); DrawStamp (&s); } @@ -996,22 +988,25 @@ old_coarse_fuel = (COUNT)~0; else { - DWORD FuelCapacity; old_coarse_fuel = (COUNT)( - GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE - ); + GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE); if (fuel_delta < 0 && GLOBAL_SIS (FuelOnBoard) <= (DWORD)-fuel_delta) + { GLOBAL_SIS (FuelOnBoard) = 0; - else if ((GLOBAL_SIS (FuelOnBoard) += fuel_delta) > - (FuelCapacity = GetFTankCapacity (NULL))) - GLOBAL_SIS (FuelOnBoard) = FuelCapacity; + } + else + { + DWORD FuelCapacity = GetFTankCapacity (NULL); + GLOBAL_SIS (FuelOnBoard) += fuel_delta; + if (GLOBAL_SIS (FuelOnBoard) > FuelCapacity) + GLOBAL_SIS (FuelOnBoard) = FuelCapacity; + } } new_coarse_fuel = (COUNT)( - GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE - ); + GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE); if (new_coarse_fuel != old_coarse_fuel) { sprintf (buf, "%u", new_coarse_fuel); @@ -1122,8 +1117,7 @@ SetContextForeGroundColor (crew_rows[which_row]); else SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x05, 0x10, 0x05), 0x65) - ); + BUILD_COLOR (MAKE_RGB15 (0x05, 0x10, 0x05), 0x65)); } capacity += CREW_POD_CAPACITY; @@ -1169,7 +1163,8 @@ }; bay_remainder = GLOBAL_SIS (TotalElementMass) - capacity; - if ((which_row = bay_remainder / SBAY_MASS_PER_ROW) == 0) + which_row = bay_remainder / SBAY_MASS_PER_ROW; + if (which_row == 0) SetContextForeGroundColor (BLACK_COLOR); else SetContextForeGroundColor (color_bars[--which_row]); @@ -1184,7 +1179,7 @@ x -= SHIP_PIECE_OFFSET; } while (slot--); - return (capacity); + return capacity; } DWORD @@ -1229,8 +1224,7 @@ which_row = (COUNT)( (GLOBAL_SIS (FuelOnBoard) - capacity) - * MAX_FUEL_BARS / HEFUEL_TANK_CAPACITY - ); + * MAX_FUEL_BARS / HEFUEL_TANK_CAPACITY); ppt->x = x + 1; if (volume == FUEL_TANK_CAPACITY) ppt->y = 27 - which_row; @@ -1247,7 +1241,7 @@ x -= SHIP_PIECE_OFFSET; } while (slot--); - return (capacity); + return capacity; } COUNT @@ -1281,7 +1275,7 @@ } } - return (num_pieces); + return num_pieces; } void @@ -1356,6 +1350,7 @@ Task flash_task = 0; RECT flash_rect; static FRAME flash_screen_frame = 0; + // The original contents of the flash rectangle. static int flash_changed; Mutex flash_mutex = 0; // XXX: these are currently defined in libs/graphics/sdl/3do_getbody.c @@ -1369,25 +1364,25 @@ #define NORMAL_STRENGTH 4 #define NORMAL_F_STRENGTH 0 #define CACHE_SIZE 10 - DWORD TimeIn, WaitTime; - SIZE strength, fstrength, incr; + DWORD TimeIn; + const DWORD WaitTime = ONE_SECOND / 16; + SIZE strength; RECT cached_rect; FRAME cached_screen_frame = 0; Task task = (Task)data; - int cached[CACHE_SIZE]; + bool cached[CACHE_SIZE]; STAMP cached_stamp[CACHE_SIZE]; int i; + // Init cache for (i = 0; i < CACHE_SIZE; i++) { - cached[i] = 0; + cached[i] = false; cached_stamp[i].frame = 0; } - fstrength = NORMAL_F_STRENGTH; - incr = 1; + strength = NORMAL_STRENGTH; TimeIn = GetTimeCounter (); - WaitTime = ONE_SECOND / 16; while (!Task_ReadState(task, TASK_EXIT)) { CONTEXT OldContext; @@ -1411,10 +1406,12 @@ arith_frame_blit (flash_screen_frame, &screen_rect, cached_screen_frame, NULL, 0, 0); UnlockMutex (flash_mutex); + + // Clear the cache. for (i = 0; i < CACHE_SIZE; i++) { - cached[i] = 0; - if(cached_stamp[i].frame) + cached[i] = false; + if (cached_stamp[i].frame) DestroyDrawable (ReleaseDrawable (cached_stamp[i].frame)); cached_stamp[i].frame = 0; } @@ -1436,7 +1433,7 @@ { RECT tmp_rect = cached_rect; pStamp = &cached_stamp[strength - MIN_STRENGTH]; - cached[strength - MIN_STRENGTH] = 1; + cached[strength - MIN_STRENGTH] = true; pStamp->frame = CaptureDrawable (CreateDrawable (WANT_PIXMAP, cached_rect.extent.width, cached_rect.extent.height, 1)); @@ -1451,11 +1448,12 @@ arith_frame_blit (cached_screen_frame, &tmp_rect, pStamp->frame, &tmp_rect, strength, 4); } + LockMutex (GraphicsLock); OldContext = SetContext (ScreenContext); SetContextClipRect (&cached_rect); // flash changed_can't be modified while GraphicSem is held - if (! flash_changed) + if (!flash_changed) DrawStamp (pStamp); SetContextClipRect (NULL); // this will flush whatever SetContext (OldContext); @@ -1465,6 +1463,8 @@ SleepThreadUntil (TimeIn + WaitTime); TimeIn = GetTimeCounter (); } + + // Clear cache { if (cached_screen_frame) DestroyDrawable (ReleaseDrawable (cached_screen_frame)); @@ -1480,7 +1480,7 @@ UnlockMutex (flash_mutex); FinishTask (task); - return(0); + return 0; } void @@ -1490,7 +1490,7 @@ CONTEXT OldContext; int create_flash = 0; - if (! flash_mutex) + if (!flash_mutex) flash_mutex = CreateMutex ("FlashRect Lock", SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); @@ -1525,6 +1525,7 @@ if (pRect == 0 || pRect->extent.width == 0) { + // End the flashing. flash_rect1.extent.width = 0; if (flash_task) { @@ -1550,8 +1551,10 @@ || old_r.corner.x != flash_rect.corner.x || old_r.corner.y != flash_rect.corner.y)) { + // We had a flash rectangle, and now a different one is set. if (flash_screen_frame) { + // The screen contents may have changed; we grab a new copy. STAMP old_s; old_s.origin.x = old_r.corner.x; old_s.origin.y = old_r.corner.y; @@ -1566,6 +1569,7 @@ if (flash_rect.extent.width) { + // A new flash rectangle is set. // Copy the original contents of the rectangle from the screen. if (flash_screen_frame) DestroyDrawable (ReleaseDrawable (flash_screen_frame)); Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/uqmdebug.c 2009-11-14 22:17:24 UTC (rev 3302) @@ -20,6 +20,7 @@ #include "build.h" #include "colors.h" +#include "controls.h" #include "clock.h" #include "encount.h" #include "element.h" @@ -68,6 +69,7 @@ BOOLEAN instantMove = FALSE; BOOLEAN disableInteractivity = FALSE; void (* volatile debugHook) (void) = NULL; +void (* volatile doInputDebugHook) (void) = NULL; void @@ -118,6 +120,12 @@ // main loop. Calling it from here would give threading // problems. + // Graphical and textual: + //doInputDebugHook = debugContexts; + // This will cause debugContexts to be called from the + // Starcon2Main thread, from DoInput(). Calling it from here + // would give threading problems. + // Interactive: // uio_debugInteractive(stdin, stdout, stderr); } @@ -755,6 +763,7 @@ UniverseRecurse (&universeRecurseArg); } +// Must be called from the main thread. void dumpUniverseToFile (void) { @@ -1162,6 +1171,7 @@ UniverseRecurse (&universeRecurseArg); } +// Must be called from the main thread. void tallyResourcesToFile (void) { @@ -1459,7 +1469,8 @@ // playerNr should be 0 or 1 STARSHIP* -findPlayerShip (SIZE playerNr) { +findPlayerShip (SIZE playerNr) +{ HELEMENT hElement, hNextElement; for (hElement = GetHeadElement (); hElement; hElement = hNextElement) @@ -1486,7 +1497,8 @@ //////////////////////////////////////////////////////////////////////////// void -resetCrewBattle(void) { +resetCrewBattle (void) +{ STARSHIP *StarShipPtr; COUNT delta; CONTEXT OldContext; @@ -1508,7 +1520,8 @@ } void -resetEnergyBattle(void) { +resetEnergyBattle (void) +{ STARSHIP *StarShipPtr; COUNT delta; CONTEXT OldContext; @@ -1534,7 +1547,8 @@ // This function should help in making sure that gamestr.h matches // gamestrings.txt. void -dumpStrings(FILE *out) { +dumpStrings (FILE *out) +{ #define STRINGIZE(a) #a #define MAKE_STRING_CATEGORY(prefix) \ { \ @@ -1603,6 +1617,409 @@ } } +//////////////////////////////////////////////////////////////////////////// + + +static COLOR +hsvaToRgba (double hue, double sat, double val, BYTE alpha) { + assert (hue >= 0.0 && hue < 360.0); + assert (sat >= 0 && sat <= 1.0); + assert (val >= 0 && val <= 1.0); + /*fprintf(stderr, "hsva = (%.1f, %.2f, %.2f, %.2d)\n", + hue, sat, val, alpha);*/ + + unsigned int hi = (int) (hue / 60.0); + double f = (hue / 60.0) - ((int) (hue / 60.0)); + double p = val * (1.0 - sat); + double q = val * (1.0 - f * sat); + double t = val * (1.0 - (1.0 - f * sat)); + + // Convert p, q, t, and v from [0..1] to [0..255] + BYTE pb = (BYTE) (p * 255.0 + 0.5); + BYTE qb = (BYTE) (q * 255.0 + 0.5); + BYTE tb = (BYTE) (t * 255.0 + 0.5); + BYTE vb = (BYTE) (val * 255.0 + 0.5); + + assert (hi < 6); + switch (hi) { + case 0: return BUILD_COLOR_RGBA (vb, tb, pb, alpha); + case 1: return BUILD_COLOR_RGBA (qb, vb, pb, alpha); + case 2: return BUILD_COLOR_RGBA (pb, vb, tb, alpha); + case 3: return BUILD_COLOR_RGBA (pb, qb, vb, alpha); + case 4: return BUILD_COLOR_RGBA (tb, pb, vb, alpha); + case 5: return BUILD_COLOR_RGBA (vb, pb, qb, alpha); + } + + // Should not happen. + return BUILD_COLOR_RGBA (0, 0, 0, alpha); +} + +// Work-around: colors returned by BUILD_COLOR_RGBA are not usable to draw +// with. +static DWORD +fixColorRgba (FRAME frame, COLOR col) +{ +#if 0 + extern DWORD frame_mapRGBA (FRAME FramePtr, BYTE r, BYTE g, BYTE b, + BYTE a); + + BYTE r = (col & 0xff000000) >> 24; + BYTE g = (col & 0x00ff0000) >> 16; + BYTE b = (col & 0x0000ff00) >> 8; + BYTE a = (col & 0x000000ff) >> 0; + + return (DWORD) frame_mapRGBA (frame, r, g, b, a); +#endif + + BYTE r = (col & 0xff000000) >> 24; + BYTE g = (col & 0x00ff0000) >> 16; + BYTE b = (col & 0x0000ff00) >> 8; + + (void) frame; + return BUILD_COLOR (MAKE_RGB15 (r >> 3, g >> 3, b >> 3) ,0); +} + +// Workaround. DrawFilledRectangle() doesn't handle transparency. +// We use a temporary frame to achieve the same thing. +static void +DrawFilledRectangleTransparent (RECT *rect, BYTE alpha) +{ + extern void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, + FRAME dstFrame, const RECT *rdst, int num, int denom); + + RECT absRect; + FRAME orgRectFrame; + COLOR fillColor; + + // Create a rectangle from 'rect', but with (0, 0) as origin. + absRect.corner.x = 0; + absRect.corner.y = 0; + absRect.extent = rect->extent; + + // Create a new temporary FRAME to store the contents of the original + // rectangle in. + orgRectFrame = CaptureDrawable (CreateDrawable ( + WANT_PIXMAP, rect->extent.width, rect->extent.height, 1)); + + // Copy the original rectangle, faded. + arith_frame_blit (GetContextFGFrame (), rect, orgRectFrame, &absRect, + 255 - alpha, 255); + + // Apply the transparency to the colour. + fillColor = GetContextForeGroundColor (); +#if 0 /* 32 bits RGBA */ + fillColor = + (((((fillColor & 0xff000000) >> 24) * alpha + 127) / 255) << 24) | + (((((fillColor & 0x00ff0000) >> 16) * alpha + 127) / 255) << 16) | + (((((fillColor & 0x0000ff00) >> 8) * alpha + 127) / 255) << 8); + */ +#endif + /* 15 bits RGB + index: */ + fillColor = + (((((fillColor & 0x007c0000) >> 18) * alpha + 15) / 31) << 18) | + (((((fillColor & 0x0003e000) >> 13) * alpha + 15) / 31) << 13) | + (((((fillColor & 0x00001f00) >> 8) * alpha + 15) / 31) << 8) | + (fillColor & 0x000000ff); + + // Fill the frame with fillColor + { + COLOR oldFgColor = SetContextForeGroundColor (fillColor); + DrawFilledRectangle (rect); + SetContextForeGroundColor (oldFgColor); + FlushGraphics (); + // Not really necessary for the Context for which this + // function is called, but if this function is ever used + // to draw directly to the screen, this will be needed + // to make sure the rectangle is drawn before the + // arith_frame_blit() call, which is immediate. + } + + // Blend in the original rectangle. + arith_frame_blit (orgRectFrame, &absRect, GetContextFGFrame (), rect, + 1, -1); + + // Destroy the temporary frame + DestroyDrawable (ReleaseDrawable (orgRectFrame)); +} + +// Returns true iff this context has a visible FRAME. +static bool +isContextVisible (CONTEXT context) +{ + FRAME contextFrame; + + // Save the original context. + CONTEXT oldContext = SetContext (context); + + // Get the frame of the specified context. + contextFrame = GetContextFGFrame (); + + // Restore the original context. + SetContext (oldContext); + + return contextFrame == Screen; +} + +static size_t +countVisibleContexts (void) +{ + size_t contextCount; + CONTEXT context; + + contextCount = 0; + for (context = GetFirstContext (); context != NULL; + context = GetNextContext (context)) + { + if (!isContextVisible (context)) + continue; + + contextCount++; + } + + return contextCount; +} + +static void +drawContext (CONTEXT context, double hue /* no pun intended */) +{ + FRAME drawFrame; + CONTEXT oldContext; + FONT oldFont; + COLOR oldFgCol; + COLOR rectCol; + COLOR lineCol; + COLOR textCol; + bool haveClippingRect; + RECT rect; + LINE line; + TEXT text; + POINT p1, p2, p3, p4; + + drawFrame = GetContextFGFrame (); + rectCol = (COLOR) fixColorRgba (drawFrame, + hsvaToRgba (hue, 1.0, 0.5, 127)); + lineCol = (COLOR) fixColorRgba (drawFrame, + hsvaToRgba (hue, 1.0, 1.0, 0)); + textCol = lineCol; + + // Save the original context. + oldContext = SetContext (context); + + // Get the clipping rectangle of the specified context. + haveClippingRect = GetContextClipRect (&rect); + + // Switch back the old context; we're going to draw in it. + (void) SetContext (oldContext); + + if (!haveClippingRect) + { + rect.corner.x = 0; + rect.corner.y = 0; + rect.extent.width = ScreenWidth; + rect.extent.height = ScreenHeight; + } + + p1 = rect.corner; + p2.x = rect.corner.x + rect.extent.width - 1; + p2.y = rect.corner.y; + p3.x = rect.corner.x; + p3.y = rect.corner.y + rect.extent.height - 1; + p4.x = rect.corner.x + rect.extent.width - 1; + p4.y = rect.corner.y + rect.extent.height - 1; + + oldFgCol = SetContextForeGroundColor (rectCol); + DrawFilledRectangleTransparent (&rect, 63); + + SetContextForeGroundColor (lineCol); + line.first = p1; line.second = p2; DrawLine (&line); + line.first = p2; line.second = p4; DrawLine (&line); + line.first = p1; line.second = p3; DrawLine (&line); + line.first = p3; line.second = p4; DrawLine (&line); + line.first = p1; line.second = p4; DrawLine (&line); + line.first = p2; line.second = p3; DrawLine (&line); + // Gimme C'99! So I can do: + // DrawLine ((LINE) { .first = p1, .second = p2 }) + + oldFont = SetContextFont (TinyFont); + SetContextForeGroundColor (textCol); + text.baseline.x = (p1.x + (p2.x + 1)) / 2; + text.baseline.y = p1.y + 8; + text.pStr = GetContextName (context); + text.align = ALIGN_CENTER; + text.CharCount = (COUNT) ~0; + font_DrawText (&text); + + (void) SetContextForeGroundColor (oldFgCol); + (void) SetContextFont (oldFont); +} + +static void +describeContext (FILE *out, const CONTEXT context) { + RECT rect; + CONTEXT oldContext = SetContext (context); + + GetContextClipRect (&rect); + fprintf(out, "Context '%s':\n" + "\tClipRect = (%d, %d)-(%d, %d) (%d x %d)\n", + GetContextName (context), + rect.corner.x, rect.corner.y, + rect.corner.x + rect.extent.width, + rect.corner.y + rect.extent.height, + rect.extent.width, rect.extent.height); + + SetContext (oldContext); +} + + +typedef struct wait_state +{ + // standard state required by DoInput + BOOLEAN (*InputFunc) (struct wait_state *self); + COUNT MenuRepeatDelay; +} WAIT_STATE; + + +// Maybe move to elsewhere, where it can be reused? +static BOOLEAN +waitForKey (struct wait_state *self) { + if (PulsedInputState.menu[KEY_MENU_SELECT] || + PulsedInputState.menu[KEY_MENU_CANCEL]) + return FALSE; + + SleepThread (ONE_SECOND / 20); + + (void) self; + return TRUE; +} + +// Maybe move to elsewhere, where it can be reused? +static FRAME +getScreen (void) +{ + CONTEXT oldContext = SetContext (ScreenContext); + FRAME savedFrame; + RECT screenRect; + + screenRect.corner.x = 0; + screenRect.corner.y = 0; + screenRect.extent.width = ScreenWidth; + screenRect.extent.height = ScreenHeight; + savedFrame = CaptureDrawable (LoadDisplayPixmap (&screenRect, (FRAME) 0)); + + (void) SetContext (oldContext); + return savedFrame; +} + +static void +putScreen (FRAME savedFrame) { + STAMP stamp; + + CONTEXT oldContext = SetContext (ScreenContext); + + stamp.origin.x = 0; + stamp.origin.y = 0; + stamp.frame = savedFrame; + DrawStamp (&stamp); + + (void) SetContext (oldContext); +} + +// Show the contexts on the screen. +// Must be called from the main thread. +void +debugContexts (void) +{ + extern void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, + FRAME dstFrame, const RECT *rdst, int num, int denom); + static volatile bool inDebugContexts = false; + // Prevent this function from being called from within itself. + + CONTEXT orgContext; + CONTEXT debugDrawContext; + // We're going to use this context to draw in. + FRAME debugDrawFrame; + double hueIncrement; + size_t visibleContextI; + CONTEXT context; + size_t contextCount; + FRAME savedScreen; + + // Prevent this function from being called from within itself. + if (inDebugContexts) + return; + inDebugContexts = true; + + contextCount = countVisibleContexts (); + if (contextCount == 0) + goto out; + + LockMutex (GraphicsLock); + savedScreen = getScreen (); + //UnlockMutex (GraphicsLock); + FlushGraphics (); + // Make sure that the screen has actually been captured, + // before we use the frame. + + // Create a new frame to draw on. + debugDrawContext = CreateContext ("debugDrawContext"); + debugDrawFrame = CaptureDrawable (CreateDrawable ( + WANT_PIXMAP /*| WANT_ALPHA*/, ScreenWidth, ScreenHeight, 1)); + orgContext = SetContext (debugDrawContext); + SetContextFGFrame (debugDrawFrame); + + // Fill the new frame with a copy of the original. + arith_frame_blit (savedScreen, NULL, debugDrawFrame, NULL, 1, 1); + + hueIncrement = 360.0 / contextCount; + + //LockMutex (GraphicsLock); + visibleContextI = 0; + for (context = GetFirstContext (); context != NULL; + context = GetNextContext (context)) + { + if (context == debugDrawContext) { + // Skip our own context. + continue; + } + + if (isContextVisible (context)) + { + // Only draw the visible contexts. + drawContext (context, visibleContextI * hueIncrement); + visibleContextI++; + } + + describeContext (stderr, context); + } + + // Blit the final debugging frame to the screen. + putScreen (debugDrawFrame); + UnlockMutex (GraphicsLock); + + // Wait for a key: + { + WAIT_STATE state; + state.InputFunc = waitForKey; + DoInput(&state, TRUE); + } + + SetContext (orgContext); + + // Destroy the debugging frame and context. + DestroyContext (debugDrawContext); + // This does nothing with the drawable set with + // SetContextFGFrame(). + DestroyDrawable (ReleaseDrawable (debugDrawFrame)); + + LockMutex (GraphicsLock); + putScreen (savedScreen); + UnlockMutex (GraphicsLock); + + DestroyDrawable (ReleaseDrawable (savedScreen)); + +out: + inDebugContexts = false; +} + #endif /* DEBUG */ - Modified: trunk/sc2/src/uqm/uqmdebug.h =================================================================== --- trunk/sc2/src/uqm/uqmdebug.h 2009-11-14 18:44:33 UTC (rev 3301) +++ trunk/sc2/src/uqm/uqmdebug.h 2009-11-14 22:17:24 UTC (rev 3302) @@ -29,10 +29,15 @@ // functions are a no-op. extern BOOLEAN disableInteractivity; -// If a function is assigned to this, it will be called from the main loop. +// If a function is assigned to this, it will be called from the +// Starcon2Main thread, in the main game loop. extern void (* volatile debugHook) (void); +// If a function is assigned to this, it will be called from the +// Starcon2Main thread, in doInput(). +extern void (* volatile doInputDebugHook) (void); + // Called when the debug key (symbol 'Debug' in the keys.cfg) is pressed. void debugKeyPressed (void); @@ -180,6 +185,11 @@ void dumpStrings(FILE *out); +// Graphically and textually show all the contexts. +// Should be called from debugHook. +void debugContexts (void); + + // To add some day: // - a function to fast forward the game clock to a specifiable time. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-11-15 06:43:12
|
Revision: 3305 http://sc2.svn.sourceforge.net/sc2/?rev=3305&view=rev Author: avolkov Date: 2009-11-15 06:43:03 +0000 (Sun, 15 Nov 2009) Log Message: ----------- Comm animation processing rewrite; cleaner and meaner; a bunch of bugs fixed, and some probably added ;) Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/comm/orz/orzc.c trunk/sc2/src/uqm/comm/starbas/starbas.c trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.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/globdata.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/ChangeLog 2009-11-15 06:43:03 UTC (rev 3305) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Comm animation processing rewrite, bugs fixed - Alex - Added graphics context debugging function - SvdB - Thread down-throttling and game sleep when inactive (currently disabled), (bug #1070), from Flandry Modified: trunk/sc2/src/uqm/comm/orz/orzc.c =================================================================== --- trunk/sc2/src/uqm/comm/orz/orzc.c 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/comm/orz/orzc.c 2009-11-15 06:43:03 UTC (rev 3305) @@ -838,14 +838,13 @@ if (!GET_GAME_STATE (MET_ORZ_BEFORE)) { - BYTE N; - SET_GAME_STATE (MET_ORZ_BEFORE, 1); - N = CommData.AlienTalkDesc.NumFrames; - CommData.AlienTalkDesc.NumFrames = 0; + // Disable talking anim and run the computer report + EnableTalkingAnim (FALSE); AlienTalkSegue (1); - CommData.AlienTalkDesc.NumFrames = N; + // Run whatever is left with talking anim + EnableTalkingAnim (TRUE); } } Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-15 06:43:03 UTC (rev 3305) @@ -1291,11 +1291,10 @@ // Run all tracks upto the Vux Beast scientist's report AlienTalkSegue (VuxBeastIndex - 1); // Disable Commander's speech animation and run the report - i = CommData.AlienTalkDesc.NumFrames; - CommData.AlienTalkDesc.NumFrames = 0; + EnableTalkingAnim (FALSE); AlienTalkSegue (VuxBeastIndex); // Enable Commander's speech animation and run the rest - CommData.AlienTalkDesc.NumFrames = i; + EnableTalkingAnim (TRUE); AlienTalkSegue ((COUNT)~0); } } Modified: trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c =================================================================== --- trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2009-11-15 06:43:03 UTC (rev 3305) @@ -123,9 +123,12 @@ { if (LastAlien != ZOQ_ALIEN) { + // Transition to neutral state first if Pik was talking + if (LastAlien != FOT_ALIEN) + CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; LastAlien = ZOQ_ALIEN; + CommData.AlienTransitionDesc.AnimFlags |= TALK_INTRO; CommData.AlienTransitionDesc.StartIndex = FOT_TO_ZOQ; - CommData.AlienTalkDesc.AnimFlags |= TALK_INTRO; CommData.AlienTalkDesc.StartIndex = ZOQ_TALK_INDEX; CommData.AlienTalkDesc.NumFrames = ZOQ_TALK_FRAMES; CommData.AlienAmbientArray[1].AnimFlags &= ~WAIT_TALKING; @@ -142,9 +145,12 @@ { if (LastAlien != PIK_ALIEN) { + // Transition to neutral state first if Zoq was talking + if (LastAlien != FOT_ALIEN) + CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; LastAlien = PIK_ALIEN; + CommData.AlienTransitionDesc.AnimFlags |= TALK_INTRO; CommData.AlienTransitionDesc.StartIndex = FOT_TO_PIK; - CommData.AlienTalkDesc.AnimFlags |= TALK_INTRO; CommData.AlienTalkDesc.StartIndex = PIK_TALK_INDEX; CommData.AlienTalkDesc.NumFrames = PIK_TALK_FRAMES; CommData.AlienAmbientArray[1].AnimFlags |= WAIT_TALKING; Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/comm.c 2009-11-15 06:43:03 UTC (rev 3305) @@ -53,6 +53,8 @@ int cur_comm; UNICODE shared_phrase_buf[2048]; +static BOOLEAN TalkingFinished; + typedef struct response_entry { RESPONSE_REF response_ref; @@ -87,7 +89,6 @@ static CONTEXT TextCacheContext; static FRAME TextCacheFrame; -volatile BOOLEAN ClearSummary; RECT CommWndRect = { // default values; actually inited by HailAlien() @@ -383,51 +384,6 @@ } void -DrawAlienFrame (FRAME aframe, SEQUENCE *pSeq) -{ - COUNT i; - STAMP s; - ANIMATION_DESC *ADPtr; - - s.origin.x = -SAFE_X; - s.origin.y = 0; - s.frame = CommData.AlienFrame; - if (s.frame == 0) - s.frame = aframe; - - BatchGraphics (); - DrawStamp (&s); - i = CommData.NumAnimations; - ADPtr = &CommData.AlienAmbientArray[i]; - while (i--) - { - --ADPtr; - - if (!(ADPtr->AnimFlags & ANIM_MASK)) - { - s.frame = SetAbsFrameIndex (s.frame, ADPtr->StartIndex); - DrawStamp (&s); - ADPtr->AnimFlags |= ANIM_DISABLED; - } - else if (pSeq) - { - if (pSeq->AnimType == PICTURE_ANIM) - { - s.frame = pSeq->AnimObj.CurFrame; - DrawStamp (&s); - } - --pSeq; - } - } - if (aframe && CommData.AlienFrame && aframe != CommData.AlienFrame) - { - s.frame = aframe; - DrawStamp (&s); - } - UnbatchGraphics (); -} - -void init_communication (void) { subtitle_mutex = CreateMutex ("Subtitle Lock", @@ -553,13 +509,11 @@ BOOLEAN ContinuityBreak; DWORD TimeIn; COUNT which_track; - FRAME F; BOOLEAN rewind = FALSE; TimeIn = GetTimeCounter (); ContinuityBreak = FALSE; - F = CommData.AlienFrame; if (wait_track == 0) { // Restarting with a rewind wait_track = (COUNT)~0; @@ -636,12 +590,10 @@ else if (optSmoothScroll == OPT_3DO) FastForward_Smooth (); ContinuityBreak = TRUE; - // XXX: Ugly hack: This causes all animations (talking and ambient) + // 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. This hack has - // spawned a multitude of workarounds in the comm code, and IMHO - // should be removed. - CommData.AlienFrame = 0; + // the animations cannot continue while seeking. + PauseAnimTask = TRUE; } else if (left || rewind) { @@ -652,8 +604,8 @@ else if (optSmoothScroll == OPT_3DO) FastReverse_Smooth (); ContinuityBreak = TRUE; - // XXX: See ugly hack discussion above - CommData.AlienFrame = 0; + // XXX: See pause discussion above + PauseAnimTask = TRUE; } else if (ContinuityBreak) { @@ -663,20 +615,20 @@ SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2)); } else - { // XXX: See ugly hack discussion above + { // XXX: See pause discussion above // Additionally, 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. - CommData.AlienFrame = F; + PauseAnimTask = FALSE; } which_track = PlayingTrack (); } while (ContinuityBreak || (which_track && which_track <= wait_track)); - CommData.AlienFrame = F; + PauseAnimTask = FALSE; ClearSubtitles (); if (!which_track || wait_track == (COUNT)~0) @@ -696,22 +648,17 @@ BOOLEAN done; // Transition animation to talking state, if necessary - if (CommData.AlienTalkDesc.NumFrames) - { - if (!(CommData.AlienTransitionDesc.AnimFlags & TALK_INTRO)) - { - CommData.AlienTransitionDesc.AnimFlags |= TALK_INTRO; - if (CommData.AlienTransitionDesc.NumFrames) - CommData.AlienTalkDesc.AnimFlags |= TALK_INTRO; - } + if (wantTalkingAnim () && haveTalkingAnim ()) + { + if (haveTransitionAnim ()) + setRunIntroAnim (); - CommData.AlienTransitionDesc.AnimFlags &= ~PAUSE_TALKING; - if (CommData.AlienTalkDesc.NumFrames) - CommData.AlienTalkDesc.AnimFlags |= WAIT_TALKING; - while (CommData.AlienTalkDesc.AnimFlags & TALK_INTRO) + setRunTalkingAnim (); + + while (runningIntroAnim ()) { // wait until the transition finishes UnlockMutex (GraphicsLock); - TaskSwitch (); + SleepThread (ONE_SECOND / 30); LockMutex (GraphicsLock); } } @@ -719,14 +666,8 @@ done = !SpewPhrases (wait_track); // transition back to silent, if necessary - if (CommData.AlienTalkDesc.NumFrames) - { - // must set the TALK_DONE flag so that the animation task - // releases WAIT_TALKING from AlienTalkDesc - CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; - if ((CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING)) - CommData.AlienTalkDesc.AnimFlags |= PAUSE_TALKING; - } + if (runningTalkingAnim ()) + setStopTalkingAnim (); return done; } @@ -734,13 +675,15 @@ static void FlushTalkSegue (void) { + WaitForNoInput (ONE_SECOND / 2); FlushInput (); - while (AnyButtonPress (TRUE)) - TaskSwitch (); + // Wait until the animation task stops "talking" do - TaskSwitch (); - while (CommData.AlienTalkDesc.AnimFlags & PAUSE_TALKING); + SleepThread (ONE_SECOND / 30); + while (runningTalkingAnim ()); + + TalkingFinished = TRUE; } void @@ -749,8 +692,7 @@ BOOLEAN done; // this skips any talk segues that follow an aborted one - if ((GLOBAL (CurrentActivity) & CHECK_ABORT) - || (CommData.AlienTransitionDesc.AnimFlags & TALK_DONE)) + if ((GLOBAL (CurrentActivity) & CHECK_ABORT) || TalkingFinished) return; LockMutex (GraphicsLock); @@ -758,7 +700,7 @@ if (!pCurInputState->Initialized) { SetColorMap (GetColorMapAddress (CommData.AlienColorMap)); - DrawAlienFrame (CommData.AlienFrame, NULL); + DrawAlienFrame (NULL, 0, TRUE); UpdateSpeechGraphics (TRUE); if (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE @@ -807,8 +749,9 @@ DWORD TimeOut; TimeOut = GetTimeCounter () + (ONE_SECOND >> 1); -/* if (CommData.NumAnimations) */ - pCurInputState->AnimTask = StartCommAnimTask (); + // Anim task processes not only ambient animations, but also + // talking animations and subtitles + pCurInputState->AnimTask = StartCommAnimTask (); UnlockMutex (GraphicsLock); SleepThreadUntil (TimeOut); @@ -825,15 +768,9 @@ UnlockMutex (GraphicsLock); FlushTalkSegue (); - if (done || wait_track == (COUNT)~0) - { // all done talking here - CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; - } - else + if (!done && wait_track != (COUNT)~0) { // there is more to come - CommData.AlienTransitionDesc.AnimFlags &= ~TALK_DONE; - // allow a transition to talking state again later - CommData.AlienTransitionDesc.AnimFlags &= ~TALK_INTRO; + TalkingFinished = FALSE; } } @@ -1000,7 +937,7 @@ FadeMusic (BACKGROUND_VOL, ONE_SECOND); - CommData.AlienTransitionDesc.AnimFlags &= ~(TALK_INTRO | TALK_DONE); + TalkingFinished = FALSE; pES->num_responses = 0; (*pES->response_list[pES->cur_response].response_func) (pES->response_list[pES->cur_response].response_ref); @@ -1024,7 +961,7 @@ LockMutex (GraphicsLock); RefreshResponses (pES); - ClearSummary = TRUE; + clear_subtitles = TRUE; PauseAnimTask = FALSE; UnlockMutex (GraphicsLock); } @@ -1060,9 +997,7 @@ FadeMusic (BACKGROUND_VOL, ONE_SECOND); LockMutex (GraphicsLock); FeedbackPlayerPhrase (pES->phrase_buf); - // reset transition state - CommData.AlienTransitionDesc.AnimFlags &= - ~(TALK_INTRO | TALK_DONE); + TalkingFinished = FALSE; DoTalkSegue (0); if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) @@ -1073,9 +1008,6 @@ UnlockMutex (GraphicsLock); FlushTalkSegue (); - // done one way or the other - CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; - } else if (PulsedInputState.menu[KEY_MENU_UP]) response = (BYTE)((response + (BYTE)(pES->num_responses - 1)) @@ -1119,7 +1051,8 @@ { SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); - if (!(CommData.AlienTransitionDesc.AnimFlags & TALK_DONE)) + // First, finish playing all queued tracks if not done yet + if (!TalkingFinished) AlienTalkSegue ((COUNT)~0); if (GLOBAL (CurrentActivity) & CHECK_ABORT) @@ -1141,14 +1074,10 @@ { FadeMusic (BACKGROUND_VOL, ONE_SECOND); LockMutex (GraphicsLock); - // reset transition state - CommData.AlienTransitionDesc.AnimFlags &= - ~(TALK_INTRO | TALK_DONE); + TalkingFinished = FALSE; DoTalkSegue (0); UnlockMutex (GraphicsLock); FlushTalkSegue (); - // done one way or the other - CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; if (GLOBAL (CurrentActivity) & CHECK_ABORT) break; @@ -1172,7 +1101,6 @@ LockMutex (GraphicsLock); pES->AnimTask = 0; } - CommData.AlienTransitionDesc.AnimFlags &= ~(TALK_INTRO | TALK_DONE); SetContext (SpaceContext); DestroyContext (TaskContext); @@ -1243,6 +1171,8 @@ pCurInputState = &ES; memset (pCurInputState, 0, sizeof (*pCurInputState)); + TalkingFinished = FALSE; + ES.InputFunc = DoCommunication; PlayerFont = LoadFont (PLAYER_FONT); @@ -1443,7 +1373,9 @@ status != YEHAT_REBEL_SHIP ? which_comm : YEHAT_REBEL_CONVERSATION); if (LocDataPtr) + { // We make a copy here CommData = *LocDataPtr; + } UnlockMutex (GraphicsLock); @@ -1717,3 +1649,12 @@ } UnlockMutex (subtitle_mutex); } + +void +EnableTalkingAnim (BOOLEAN enable) +{ + if (enable) + CommData.AlienTalkDesc.AnimFlags &= ~PAUSE_TALKING; + else + CommData.AlienTalkDesc.AnimFlags |= PAUSE_TALKING; +} Modified: trunk/sc2/src/uqm/comm.h =================================================================== --- trunk/sc2/src/uqm/comm.h 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/comm.h 2009-11-15 06:43:03 UTC (rev 3305) @@ -28,11 +28,74 @@ #include "commanim.h" -extern void DrawAlienFrame (FRAME aframe, SEQUENCE *pSeq); - extern LOCDATA CommData; -extern volatile BOOLEAN ClearSummary; +static inline BOOLEAN +haveTalkingAnim (void) +{ + return CommData.AlienTalkDesc.NumFrames > 0; +} + +static inline BOOLEAN +haveTransitionAnim (void) +{ + return CommData.AlienTransitionDesc.NumFrames > 0; +} + +static inline BOOLEAN +wantTalkingAnim (void) +{ + return !(CommData.AlienTalkDesc.AnimFlags & PAUSE_TALKING); +} + +static inline void +setRunTalkingAnim (void) +{ + CommData.AlienTalkDesc.AnimFlags |= WAIT_TALKING; +} + +static inline void +clearRunTalkingAnim (void) +{ + CommData.AlienTalkDesc.AnimFlags &= ~WAIT_TALKING; +} + +static inline BOOLEAN +runningTalkingAnim (void) +{ + return (CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING); +} + +static inline void +setRunIntroAnim (void) +{ + CommData.AlienTransitionDesc.AnimFlags |= TALK_INTRO; +} + +static inline BOOLEAN +runningIntroAnim (void) +{ + return (CommData.AlienTransitionDesc.AnimFlags & TALK_INTRO); +} + +static inline void +setStopTalkingAnim (void) +{ + CommData.AlienTalkDesc.AnimFlags |= TALK_DONE; +} + +static inline void +clearStopTalkingAnim (void) +{ + CommData.AlienTalkDesc.AnimFlags &= ~TALK_DONE; +} + +static inline BOOLEAN +signaledStopTalkingAnim (void) +{ + return CommData.AlienTalkDesc.AnimFlags & TALK_DONE; +} + #endif extern void init_communication (void); @@ -45,6 +108,8 @@ extern RECT CommWndRect; /* comm window rect */ +extern void EnableTalkingAnim (BOOLEAN enable); + #endif /* _COMM_H */ Modified: trunk/sc2/src/uqm/commanim.c =================================================================== --- trunk/sc2/src/uqm/commanim.c 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/commanim.c 2009-11-15 06:43:03 UTC (rev 3305) @@ -44,118 +44,371 @@ volatile BOOLEAN PauseAnimTask = FALSE; +static inline DWORD +randomFrameRate (SEQUENCE *pSeq) +{ + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + return ADPtr->BaseFrameRate + + TFB_Random () % (ADPtr->RandomFrameRate + 1); +} + +static inline DWORD +randomRestartRate (SEQUENCE *pSeq) +{ + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + return ADPtr->BaseRestartRate + + TFB_Random () % (ADPtr->RandomRestartRate + 1); +} + +static inline COUNT +randomFrameIndex (SEQUENCE *pSeq, COUNT from) +{ + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + return from + TFB_Random () % (ADPtr->NumFrames - from); +} + static void -SetUpSequence (SEQUENCE *pSeq) +SetupAmbientSequences (SEQUENCE *pSeq, COUNT Num) { COUNT i; - ANIMATION_DESC *ADPtr; - - i = CommData.NumAnimations; - pSeq = &pSeq[i]; - ADPtr = &CommData.AlienAmbientArray[i]; - while (i--) + + for (i = 0; i < Num; ++i, ++pSeq) { - --ADPtr; - --pSeq; + ANIMATION_DESC *ADPtr = &CommData.AlienAmbientArray[i]; + memset (pSeq, 0, sizeof (*pSeq)); + + pSeq->ADPtr = ADPtr; if (ADPtr->AnimFlags & COLORXFORM_ANIM) pSeq->AnimType = COLOR_ANIM; else pSeq->AnimType = PICTURE_ANIM; pSeq->Direction = UP_DIR; pSeq->FramesLeft = ADPtr->NumFrames; - if (pSeq->AnimType == COLOR_ANIM) - pSeq->AnimObj.CurCMap = SetAbsColorMapIndex ( - CommData.AlienColorMap, ADPtr->StartIndex); - else - pSeq->AnimObj.CurFrame = SetAbsFrameIndex ( - CommData.AlienFrame, ADPtr->StartIndex); - + // Default: first frame is neutral if (ADPtr->AnimFlags & RANDOM_ANIM) - { - if (pSeq->AnimType == COLOR_ANIM) - pSeq->AnimObj.CurCMap = - SetRelColorMapIndex (pSeq->AnimObj.CurCMap, - (COUNT)((COUNT)TFB_Random () % pSeq->FramesLeft)); - else - pSeq->AnimObj.CurFrame = - SetRelFrameIndex (pSeq->AnimObj.CurFrame, - (COUNT)((COUNT)TFB_Random () % pSeq->FramesLeft)); + { // Set a random frame/colormap + pSeq->NextIndex = TFB_Random () % ADPtr->NumFrames; } else if (ADPtr->AnimFlags & YOYO_ANIM) - { + { // Skip the first frame/colormap (it's neutral) + pSeq->NextIndex = 1; --pSeq->FramesLeft; - if (pSeq->AnimType == COLOR_ANIM) - pSeq->AnimObj.CurCMap = - SetRelColorMapIndex (pSeq->AnimObj.CurCMap, 1); - else - pSeq->AnimObj.CurFrame = - IncFrameIndex (pSeq->AnimObj.CurFrame); } + else if (ADPtr->AnimFlags & CIRCULAR_ANIM) + { // Exception that makes everything more painful: + // *Last* frame is neutral + pSeq->CurIndex = ADPtr->NumFrames - 1; + pSeq->NextIndex = 0; + } - pSeq->Alarm = ADPtr->BaseRestartRate - + ((COUNT)TFB_Random () % (ADPtr->RandomRestartRate + 1)) + 1; + pSeq->Alarm = randomRestartRate (pSeq) + 1; } } +static void +SetupTalkSequence (SEQUENCE *pSeq, ANIMATION_DESC *ADPtr) +{ + memset (pSeq, 0, sizeof (*pSeq)); + // Initially disabled, and until needed + ADPtr->AnimFlags |= ANIM_DISABLED; + pSeq->ADPtr = ADPtr; + pSeq->AnimType = PICTURE_ANIM; +} + +static inline BOOLEAN +animAtNeutralIndex (SEQUENCE *pSeq) +{ + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + if (ADPtr->AnimFlags & CIRCULAR_ANIM) + { // CIRCULAR_ANIM's neutral frame is the last + return pSeq->NextIndex == 0; + } + else + { // All others, neutral frame is the first + return pSeq->CurIndex == 0; + } +} + +static inline BOOLEAN +conflictsWithTalkingAnim (SEQUENCE *pSeq) +{ + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + return ADPtr->AnimFlags & CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING; +} + +static void +ProcessColormapAnims (SEQUENCE *pSeq, COUNT Num) +{ + COUNT i; + + for (i = 0; i < Num; ++i, ++pSeq) + { + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + if ((ADPtr->AnimFlags & ANIM_DISABLED) + || pSeq->AnimType != COLOR_ANIM + || !pSeq->Change) + continue; + + XFormColorMap (GetColorMapAddress ( + SetAbsColorMapIndex (CommData.AlienColorMap, + ADPtr->StartIndex + pSeq->CurIndex)), + pSeq->Alarm - 1); + pSeq->Change = FALSE; + } +} + +static BOOLEAN +AdvanceAmbientSequence (SEQUENCE *pSeq) +{ + BOOLEAN active; + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + --pSeq->FramesLeft; + // YOYO_ANIM does not actually end until it comes back + // in reverse direction, even if FramesLeft gets to 0 here + if (pSeq->FramesLeft + || ((ADPtr->AnimFlags & YOYO_ANIM) && pSeq->NextIndex != 0)) + { + active = TRUE; + pSeq->Alarm = randomFrameRate (pSeq) + 1; + } + else + { // animation ended + active = FALSE; + pSeq->Alarm = randomRestartRate (pSeq) + 1; + } + + // Will draw the next frame or change to next colormap + pSeq->CurIndex = pSeq->NextIndex; + pSeq->Change = TRUE; + + if (pSeq->FramesLeft == 0) + { // Animation ended + // Set it up for the next round + pSeq->FramesLeft = ADPtr->NumFrames; + + if (ADPtr->AnimFlags & YOYO_ANIM) + { // YOYO_ANIM never draws the first frame + // ("first" depends on direction) + --pSeq->FramesLeft; + pSeq->Direction = -pSeq->Direction; + } + else if (ADPtr->AnimFlags & CIRCULAR_ANIM) + { // Rewind the CIRCULAR_ANIM + // NextIndex will be brought to 0 just below + pSeq->NextIndex = -1; + } + // RANDOM_ANIM is setup just below + } + + if (ADPtr->AnimFlags & RANDOM_ANIM) + pSeq->NextIndex = randomFrameIndex (pSeq, 0); + else + pSeq->NextIndex += pSeq->Direction; + + return active; +} + +static void +ResetSequence (SEQUENCE *pSeq) +{ + // Reset the animation and cause a redraw of the neutral frame, + // assuming it is not ANIM_DISABLED + // NOTE: This does not handle CIRCULAR_ANIM properly + pSeq->Direction = NO_DIR; + pSeq->CurIndex = 0; + pSeq->Change = TRUE; +} + +static void +AdvanceTalkingSequence (SEQUENCE *pSeq, DWORD ElapsedTicks) +{ + // We use the actual descriptor for flags processing and + // a copied one for drawing. A copied one is updated only + // when it is safe to do so. + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + if (pSeq->Direction == NO_DIR) + { // just starting now + pSeq->Direction = UP_DIR; + // It's now safe to pick up new Talk descriptor if changed + // (e.g. Zoq and Pik taking turns to talk) + if (CommData.AlienTalkDesc.StartIndex != ADPtr->StartIndex) + { // copy the new one + *ADPtr = CommData.AlienTalkDesc; + } + + assert (pSeq->CurIndex == 0); + pSeq->Alarm = 0; // now! + ADPtr->AnimFlags &= ~ANIM_DISABLED; + } + + if (pSeq->Alarm > ElapsedTicks) + { // Not time yet + pSeq->Alarm -= ElapsedTicks; + return; + } + + // Time to start or advance the animation + pSeq->Alarm = randomFrameRate (pSeq); + pSeq->Change = TRUE; + // Talking animation is like RANDOM_ANIM, except that + // random frames always alternate with the neutral one + // The animation does not stop until we reset it + if (pSeq->CurIndex == 0) + { // random frame next + pSeq->CurIndex = randomFrameIndex (pSeq, 1); + pSeq->Alarm += randomRestartRate (pSeq); + } + else + { // neutral frame next + pSeq->CurIndex = 0; + } +} + +static BOOLEAN +AdvanceTransitSequence (SEQUENCE *pSeq, DWORD ElapsedTicks) +{ + BOOLEAN done = FALSE; + // We use the actual descriptor for flags processing and + // a copied one for drawing. A copied one is updated only + // when it is safe to do so. + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + if (pSeq->Direction == NO_DIR) + { // just starting now + pSeq->Alarm = 0; // now! + ADPtr->AnimFlags &= ~ANIM_DISABLED; + } + + if (pSeq->Alarm > ElapsedTicks) + { // Not time yet + pSeq->Alarm -= ElapsedTicks; + return FALSE; + } + + // Time to start or advance the animation + pSeq->Change = TRUE; + + if (pSeq->Direction == NO_DIR) + { // just starting now + pSeq->FramesLeft = ADPtr->NumFrames; + // Both INTRO and DONE may be set at the same time, + // when e.g. Zoq and Pik are taking turns to talk + // Process the DONE transition first to go into + // a neutral state before switching over. + if (CommData.AlienTransitionDesc.AnimFlags & TALK_DONE) + { + pSeq->Direction = DOWN_DIR; + pSeq->CurIndex = ADPtr->NumFrames - 1; + } + else if (CommData.AlienTransitionDesc.AnimFlags & TALK_INTRO) + { + pSeq->Direction = UP_DIR; + // It's now safe to pick up new Transition descriptor if changed + // (e.g. Zoq and Pik taking turns to talk) + if (CommData.AlienTransitionDesc.StartIndex + != ADPtr->StartIndex) + { // copy the new one + *ADPtr = CommData.AlienTransitionDesc; + } + + pSeq->CurIndex = 0; + } + } + + --pSeq->FramesLeft; + if (pSeq->FramesLeft == 0) + { // animation is done + if (pSeq->Direction == UP_DIR) + { // done with TALK_INTRO transition + CommData.AlienTransitionDesc.AnimFlags &= ~TALK_INTRO; + } + else if (pSeq->Direction == DOWN_DIR) + { // done with TALK_DONE transition + CommData.AlienTransitionDesc.AnimFlags &= ~TALK_DONE; + + // Done with all transition frames + ADPtr->AnimFlags |= ANIM_DISABLED; + done = TRUE; + } + pSeq->Direction = NO_DIR; + } + else + { // next frame + pSeq->Alarm = randomFrameRate (pSeq); + pSeq->CurIndex += pSeq->Direction; + } + + return done; +} + static int ambient_anim_task (void *data) { - SIZE TalkAlarm; - FRAME TalkFrame; - FRAME ResetTalkFrame = NULL; - FRAME TransitionFrame = NULL; - FRAME AnimFrame[MAX_ANIMATIONS]; COUNT i; - DWORD LastTime; - FRAME CommFrame; - SEQUENCE Sequencer[MAX_ANIMATIONS]; - ANIMATION_DESC TalkBuffer = CommData.AlienTalkDesc; + TimeCount LastTime; + SEQUENCE Sequences[MAX_ANIMATIONS + 2]; + // 2 extra for Talk and Transition animations SEQUENCE *pSeq; - ANIMATION_DESC *ADPtr; 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 TransitionDone = FALSE; - BOOLEAN TalkFrameChanged = FALSE; - BOOLEAN FrameChanged[MAX_ANIMATIONS]; BOOLEAN ColorChange = FALSE; - while ((CommFrame = CommData.AlienFrame) == 0 - && !Task_ReadState (task, TASK_EXIT)) + 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)); - SetUpSequence (Sequencer); + TalkDesc = CommData.AlienTalkDesc; + TransitDesc = CommData.AlienTransitionDesc; + + // Animation sequences have to be drawn in reverse, and + // talk animations have to be drawn last (so we add them first) + TotalSequences = 0; + // Transition animation last + Transit = Sequences + TotalSequences; + SetupTalkSequence (Transit, &TransitDesc); + ++TotalSequences; + // Talk animation second last + Talk = Sequences + TotalSequences; + SetupTalkSequence (Talk, &TalkDesc); + ++TotalSequences; + FirstAmbient = TotalSequences; + SetupAmbientSequences (Sequences + FirstAmbient, CommData.NumAnimations); + TotalSequences += CommData.NumAnimations; + UnlockMutex (GraphicsLock); - - ActiveMask = 0; - TalkAlarm = 0; - TalkFrame = 0; + LastTime = GetTimeCounter (); LastOscillTime = LastTime; - memset (FrameChanged, 0, sizeof (FrameChanged)); - memset (AnimFrame, 0, sizeof (AnimFrame)); - for (i = 0; i < CommData.NumAnimations; i++) - { - COUNT nextIndex; - if (CommData.AlienAmbientArray[i].AnimFlags & YOYO_ANIM) - nextIndex = CommData.AlienAmbientArray[i].StartIndex; - else - nextIndex = (CommData.AlienAmbientArray[i].StartIndex - + CommData.AlienAmbientArray[i].NumFrames - 1); - AnimFrame[i] = SetAbsFrameIndex (CommFrame, nextIndex); - } - while (!Task_ReadState (task, TASK_EXIT)) { - BOOLEAN Change, CanTalk; - DWORD CurTime, ElapsedTicks; + BOOLEAN CanTalk; + TimeCount CurTime; + DWORD ElapsedTicks; SleepThreadUntil (LastTime + ONE_SECOND / AMBIENT_ANIM_RATE); @@ -165,368 +418,153 @@ ElapsedTicks = CurTime - LastTime; LastTime = CurTime; - Change = FALSE; - i = CommData.NumAnimations; - if (CommData.AlienFrame) - CanTalk = TRUE; + if (PauseAnimTask) + { // anims not processed + i = CommData.NumAnimations; + CanTalk = FALSE; + } else { i = 0; - CanTalk = FALSE; + CanTalk = TRUE; } - pSeq = &Sequencer[i]; - ADPtr = &CommData.AlienAmbientArray[i]; - while (i-- && !Task_ReadState (task, TASK_EXIT)) + // Process ambient animations + pSeq = Sequences + FirstAmbient; + for ( ; i < CommData.NumAnimations; ++i, ++pSeq) { - --ADPtr; - --pSeq; + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + DWORD ActiveBit = 1L << i; + if (ADPtr->AnimFlags & ANIM_DISABLED) continue; + if (pSeq->Direction == NO_DIR) - { - if (!(ADPtr->AnimFlags - & CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING)) - { - // This animation does not conflict with the talking - // animation right now. + { // animation is paused + if (!conflictsWithTalkingAnim (pSeq)) + { // start it up pSeq->Direction = UP_DIR; } } - else if ((DWORD)pSeq->Alarm > ElapsedTicks) - pSeq->Alarm -= (COUNT)ElapsedTicks; + else if (pSeq->Alarm > ElapsedTicks) + { // not time yet + pSeq->Alarm -= ElapsedTicks; + } + else if (ActiveMask & ADPtr->BlockMask) + { // animation is blocked + assert (!(ActiveMask & ActiveBit)); + assert (animAtNeutralIndex (pSeq)); + // reschedule + pSeq->Alarm = randomRestartRate (pSeq) + 1; + continue; + } else - { - if (!(ActiveMask & ADPtr->BlockMask) - && (--pSeq->FramesLeft - || ((ADPtr->AnimFlags & YOYO_ANIM) - && pSeq->Direction == UP_DIR))) - { - ActiveMask |= 1L << i; - pSeq->Alarm = ADPtr->BaseFrameRate - + ((COUNT)TFB_Random () - % (ADPtr->RandomFrameRate + 1)) + 1; - } + { // Time to start or advance the animation + if (AdvanceAmbientSequence (pSeq)) + ActiveMask |= ActiveBit; else - { - ActiveMask &= ~(1L << i); - pSeq->Alarm = ADPtr->BaseRestartRate - + ((COUNT)TFB_Random () - % (ADPtr->RandomRestartRate + 1)) + 1; - if (ActiveMask & ADPtr->BlockMask) - continue; - } + ActiveMask &= ~ActiveBit; + } - if (pSeq->AnimType == COLOR_ANIM) - { - XFormColorMap (GetColorMapAddress (pSeq->AnimObj.CurCMap), - (COUNT) (pSeq->Alarm - 1)); + if (pSeq->AnimType == PICTURE_ANIM && pSeq->Direction != NO_DIR + && conflictsWithTalkingAnim (pSeq)) + { + // We want to talk, but this is a running picture animation + // which conflicts with the talking animation + // See if it is safe to stop it now. + if (animAtNeutralIndex (pSeq)) + { // pause the animation + pSeq->Direction = NO_DIR; + ActiveMask &= ~ActiveBit; } else - { - Change = TRUE; - AnimFrame[i] = pSeq->AnimObj.CurFrame; - FrameChanged[i] = 1; + { // Otherwise, let the animation run until it's safe + CanTalk = FALSE; } - - if (pSeq->FramesLeft == 0) - { - pSeq->FramesLeft = (BYTE)(ADPtr->NumFrames - 1); - - if (pSeq->Direction == DOWN_DIR) - pSeq->Direction = UP_DIR; - else if (ADPtr->AnimFlags & YOYO_ANIM) - pSeq->Direction = DOWN_DIR; - else - { - ++pSeq->FramesLeft; - if (pSeq->AnimType == COLOR_ANIM) - pSeq->AnimObj.CurCMap = SetRelColorMapIndex ( - pSeq->AnimObj.CurCMap, - (SWORD) (-pSeq->FramesLeft)); - else - { - pSeq->AnimObj.CurFrame = SetRelFrameIndex ( - pSeq->AnimObj.CurFrame, - (SWORD) (-pSeq->FramesLeft)); - } - } - } - - if (ADPtr->AnimFlags & RANDOM_ANIM) - { - COUNT nextIndex = ADPtr->StartIndex + - (TFB_Random () % ADPtr->NumFrames); - - if (pSeq->AnimType == COLOR_ANIM) - pSeq->AnimObj.CurCMap = SetAbsColorMapIndex ( - pSeq->AnimObj.CurCMap, nextIndex); - else - pSeq->AnimObj.CurFrame = SetAbsFrameIndex ( - pSeq->AnimObj.CurFrame, nextIndex); - } - else if (pSeq->AnimType == COLOR_ANIM) - { - if (pSeq->Direction == UP_DIR) - pSeq->AnimObj.CurCMap = SetRelColorMapIndex ( - pSeq->AnimObj.CurCMap, 1); - else - pSeq->AnimObj.CurCMap = SetRelColorMapIndex ( - pSeq->AnimObj.CurCMap, -1); - } - else - { - if (pSeq->Direction == UP_DIR) - pSeq->AnimObj.CurFrame = - IncFrameIndex (pSeq->AnimObj.CurFrame); - else - pSeq->AnimObj.CurFrame = - DecFrameIndex (pSeq->AnimObj.CurFrame); - } } - - if (pSeq->AnimType == PICTURE_ANIM - && (ADPtr->AnimFlags - & CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING) - && pSeq->Direction != NO_DIR) - { - // This is a picture animation which would conflict with - // the talking animation, and it is not stopped yet. - COUNT index; - - CanTalk = FALSE; - if (!(pSeq->Direction != UP_DIR - || (index = GetFrameIndex (pSeq->AnimObj.CurFrame)) > - ADPtr->StartIndex + 1 - || (index == ADPtr->StartIndex + 1 - && (ADPtr->AnimFlags & CIRCULAR_ANIM)))) - pSeq->Direction = NO_DIR; - } } - ADPtr = &CommData.AlienTalkDesc; - if (CanTalk - && ADPtr->NumFrames - && (ADPtr->AnimFlags & WAIT_TALKING) - && !(CommData.AlienTransitionDesc.AnimFlags & PAUSE_TALKING)) + // Process the talking and transition animations + if (CanTalk && haveTalkingAnim () && runningTalkingAnim ()) { BOOLEAN done = FALSE; - for (i = 0; i < CommData.NumAnimations; i++) - if (ActiveMask & (1L << i) - && CommData.AlienAmbientArray[i].AnimFlags & WAIT_TALKING) - done = TRUE; - if (!done) - { - if (ADPtr->StartIndex != TalkBuffer.StartIndex) - { - Change = TRUE; - ResetTalkFrame = SetAbsFrameIndex (CommFrame, - TalkBuffer.StartIndex); - TalkBuffer = CommData.AlienTalkDesc; - } + if (signaledStopTalkingAnim () && haveTransitionAnim ()) + { // Run the transition. We will clear everything + // when it is done + CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; + } - if ((long)TalkAlarm > (long)ElapsedTicks) - TalkAlarm -= (SIZE)ElapsedTicks; - else - { - BYTE AFlags; - SIZE FrameRate; - - if (TalkAlarm > 0) - TalkAlarm = 0; - else - TalkAlarm = -1; - - AFlags = ADPtr->AnimFlags; - if (!(AFlags & (TALK_INTRO | TALK_DONE))) - { - FrameRate = - ADPtr->BaseFrameRate - + ((COUNT)TFB_Random () - % (ADPtr->RandomFrameRate + 1)); - if (TalkAlarm < 0 - || GetFrameIndex (TalkFrame) == - ADPtr->StartIndex) - { - TalkFrame = SetAbsFrameIndex (CommFrame, - (COUNT) (ADPtr->StartIndex + 1 - + ((COUNT)TFB_Random () - % (ADPtr->NumFrames - 1)))); - FrameRate += ADPtr->BaseRestartRate - + ((COUNT)TFB_Random () - % (ADPtr->RandomRestartRate + 1)); - } - else - { - TalkFrame = SetAbsFrameIndex (CommFrame, - ADPtr->StartIndex); - if (ADPtr->AnimFlags & PAUSE_TALKING) - { - if (!(CommData.AlienTransitionDesc.AnimFlags - & TALK_DONE)) - { - CommData.AlienTransitionDesc.AnimFlags |= - PAUSE_TALKING; - ADPtr->AnimFlags &= ~PAUSE_TALKING; - } - else if (CommData.AlienTransitionDesc.NumFrames) - ADPtr->AnimFlags |= TALK_DONE; - else - ADPtr->AnimFlags &= - ~(WAIT_TALKING | PAUSE_TALKING); - - FrameRate = 0; - } - } - } - else - { - ADPtr = &CommData.AlienTransitionDesc; - if (AFlags & TALK_INTRO) - { - FrameRate = ADPtr->BaseFrameRate - + ((COUNT)TFB_Random () - % (ADPtr->RandomFrameRate + 1)); - if (TalkAlarm < 0 || TransitionDone) - { - TalkFrame = SetAbsFrameIndex (CommFrame, - ADPtr->StartIndex); - TransitionDone = FALSE; - } - else - TalkFrame = IncFrameIndex (TalkFrame); - - if ((BYTE)(GetFrameIndex (TalkFrame) - - ADPtr->StartIndex + 1) == - ADPtr->NumFrames) - { - CommData.AlienTalkDesc.AnimFlags &= - ~TALK_INTRO; - TransitionDone = TRUE; - } - TransitionFrame = TalkFrame; - } - else /* if (AFlags & TALK_DONE) */ - { - FrameRate = ADPtr->BaseFrameRate - + ((COUNT)TFB_Random () - % (ADPtr->RandomFrameRate + 1)); - if (TalkAlarm < 0) - TalkFrame = SetAbsFrameIndex (CommFrame, - (COUNT) (ADPtr->StartIndex - + ADPtr->NumFrames - 1)); - else - TalkFrame = DecFrameIndex (TalkFrame); - - if (GetFrameIndex (TalkFrame) == - ADPtr->StartIndex) - { - CommData.AlienTalkDesc.AnimFlags &= - ~(PAUSE_TALKING | TALK_DONE); - if (ADPtr->AnimFlags & TALK_INTRO) - CommData.AlienTalkDesc.AnimFlags &= - ~WAIT_TALKING; - else - { - ADPtr->AnimFlags |= PAUSE_TALKING; - ADPtr->AnimFlags &= ~TALK_DONE; - } - FrameRate = 0; - } - TransitionFrame = NULL; - } - } - TalkFrameChanged = TRUE; - - Change = TRUE; - - TalkAlarm = FrameRate; + if (CommData.AlienTransitionDesc.AnimFlags + & (TALK_INTRO | TALK_DONE)) + { // Transitioning in or out of talking + if ((CommData.AlienTransitionDesc.AnimFlags & TALK_DONE) + && Transit->Direction == NO_DIR) + { // This is needed when switching talking anims + ResetSequence (Talk); } + done = AdvanceTransitSequence (Transit, ElapsedTicks); } - else if (done && (ADPtr->AnimFlags & PAUSE_TALKING)) + else if (!signaledStopTalkingAnim ()) + { // Talking, transition is done + AdvanceTalkingSequence (Talk, ElapsedTicks); + } + else + { // Not talking + ResetSequence (Talk); + done = TRUE; + } + + if (signaledStopTalkingAnim () && done) { - ADPtr->AnimFlags &= ~(WAIT_TALKING | PAUSE_TALKING); + clearRunTalkingAnim (); + clearStopTalkingAnim (); } } + else + { // Not talking (task may be paused) + // Disable talking anim if it is done + if (Talk->Direction == NO_DIR) + TalkDesc.AnimFlags |= ANIM_DISABLED; + } + // Draw all animations if (!PauseAnimTask) { CONTEXT OldContext; - BOOLEAN CheckSub = FALSE; BOOLEAN SubtitleChange; + BOOLEAN FullRedraw; + BOOLEAN Change; // Clearing any active subtitles counts as 'change' SubtitleChange = HaveSubtitlesChanged (); + FullRedraw = ColorChange || SubtitleChange; OldContext = SetContext (TaskContext); - if (ColorChange || ClearSummary) - { // Redraw the whole comm screen - FRAME F; - F = CommData.AlienFrame; - CommData.AlienFrame = CommFrame; - DrawAlienFrame (TalkFrame, - &Sequencer[CommData.NumAnimations - 1]); - CommData.AlienFrame = F; - CheckSub = TRUE; - SubtitleChange = ClearSummary; - ColorChange = FALSE; - ClearSummary = FALSE; - } - if (Change || SubtitleChange) - { - STAMP s; - s.origin.x = -SAFE_X; - s.origin.y = 0; - if (SubtitleChange) - { - s.frame = CommFrame; - DrawStamp (&s); - } - i = CommData.NumAnimations; - while (i--) - { - if (SubtitleChange || FrameChanged[i]) - { - s.frame = AnimFrame[i]; - DrawStamp (&s); - FrameChanged[i] = 0; - } - } - if (SubtitleChange && TransitionFrame) - { - s.frame = TransitionFrame; - DrawStamp (&s); - } - if (ResetTalkFrame) - { - s.frame = ResetTalkFrame; - DrawStamp (&s); - ResetTalkFrame = NULL; - } - if (TalkFrame && TalkFrameChanged) - { - s.frame = TalkFrame; - DrawStamp (&s); - TalkFrameChanged = FALSE; - } - Change = FALSE; - CheckSub = TRUE; - } + // Colormap animations are processed separately + // from picture anims (see XFormColorMap_step) + ProcessColormapAnims (Sequences + FirstAmbient, + CommData.NumAnimations); - if (CheckSub) + Change = DrawAlienFrame (Sequences, TotalSequences, FullRedraw); + if (FullRedraw || Change) RedrawSubtitles (); SetContext (OldContext); + + ColorChange = FALSE; } + if (LastOscillTime + (ONE_SECOND / OSCILLOSCOPE_RATE) < CurTime) { LastOscillTime = CurTime; UpdateSpeechGraphics (FALSE); } + UnbatchGraphics (); UnlockMutex (GraphicsLock); + ColorChange = XFormColorMap_step (); } FinishTask (task); @@ -539,4 +577,68 @@ return AssignTask (ambient_anim_task, 3072, "ambient animations"); } +BOOLEAN +DrawAlienFrame (SEQUENCE *Sequences, COUNT Num, BOOLEAN fullRedraw) +{ + int i; + STAMP s; + BOOLEAN Change = FALSE; + BatchGraphics (); + + s.origin.x = -SAFE_X; + s.origin.y = 0; + + if (fullRedraw) + { + // Draw the main frame + s.frame = CommData.AlienFrame; + DrawStamp (&s); + + // Draw any static frames (has to be in reverse) + for (i = CommData.NumAnimations - 1; i >= 0; --i) + { + ANIMATION_DESC *ADPtr = &CommData.AlienAmbientArray[i]; + + if (ADPtr->AnimFlags & ANIM_MASK) + continue; + + ADPtr->AnimFlags |= ANIM_DISABLED; + + if (!(ADPtr->AnimFlags & COLORXFORM_ANIM)) + { // It's a static frame (e.g. Flagship picture at Starbase) + s.frame = SetAbsFrameIndex (CommData.AlienFrame, + ADPtr->StartIndex); + DrawStamp (&s); + } + } + } + + if (Sequences) + { // Draw the animation sequences (has to be in reverse) + for (i = Num - 1; i >= 0; --i) + { + SEQUENCE *pSeq = &Sequences[i]; + ANIMATION_DESC *ADPtr = pSeq->ADPtr; + + if ((ADPtr->AnimFlags & ANIM_DISABLED) + || pSeq->AnimType != PICTURE_ANIM) + continue; + + // Draw current animation frame only if changed + if (!fullRedraw && !pSeq->Change) + continue; + + s.frame = SetAbsFrameIndex (CommData.AlienFrame, + ADPtr->StartIndex + pSeq->CurIndex); + DrawStamp (&s); + pSeq->Change = FALSE; + + Change = TRUE; + } + } + + UnbatchGraphics (); + + return Change; +} Modified: trunk/sc2/src/uqm/commanim.h =================================================================== --- trunk/sc2/src/uqm/commanim.h 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/commanim.h 2009-11-15 06:43:03 UTC (rev 3305) @@ -21,14 +21,81 @@ #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 +// frame is neutral depends on the animation type. +// Animation types: +#define RANDOM_ANIM (1 << 0) + // The next index is randomly chosen. + // The first frame is neutral +#define CIRCULAR_ANIM (1 << 1) + // After the last index has been reached, the animation starts over. + // The last frame is neutral. This complicates the animation task. +#define YOYO_ANIM (1 << 2) + // After the last index has been reached, the order that the + // animation frames are used is reversed. + // The first frame is neutral +#define ANIM_MASK (RANDOM_ANIM | CIRCULAR_ANIM | YOYO_ANIM) + // Mask of all animation types. + // Static frames do not have any of these flags set. + +#define WAIT_TALKING (1 << 3) + // This is set in AlienTalkDesc when the talking animation is active + // or should be active. + // In AlienAmbientArray, this is set for those ambient animations + // which can not be active while the talking animation is active. + // Such animations stop at the end of the current animation cycle + // when the talking animation activates. +#define PAUSE_TALKING (1 << 4) + // Set in AlienTalkDesc when we do not want the talking animation +#define TALK_INTRO (1 << 5) + // In AlienTransitionDesc: indicates a transition to talking state +#define TALK_DONE (1 << 6) + // In AlienTransitionDesc: indicates a transition to silent state + // In AlienTalkDesc: signals the end of talking animation +#define ANIM_DISABLED (1 << 7) + +#define COLORXFORM_ANIM PAUSE_TALKING + +typedef struct +{ + COUNT StartIndex; + // Index of the first image (for image animation) or + // index of the first color map (for palette animation) + BYTE NumFrames; + // Number of frames in the animation. + + BYTE AnimFlags; + // One of RANDOM_ANIM, CIRCULAR_ANIM, or YOYO_ANIM + // plus flags (WAIT_TALKING, ANIM_DISABLED) + + COUNT BaseFrameRate; + // Minimum interframe delay + COUNT RandomFrameRate; + // Maximum additional interframe delay + // Actual delay: BaseFrameRate + Random(0..RandomFrameRate) + COUNT BaseRestartRate; + // Minimum delay before restarting animation + COUNT RandomRestartRate; + // Maximum additional delay before restarting animation + // Actual delay: BaseRestartRate + Random(0..RandomRestartRate) + + DWORD BlockMask; + // Bit mask of the indices of all animations that can not + // be active at the same time as this animation, usually, + // due to the image overlap conflicts. +} ANIMATION_DESC; + +#define MAX_ANIMATIONS 20 + + #ifdef COMM_INTERNAL + typedef enum { - UP_DIR, - // Animation indices are increasing - DOWN_DIR, - // Animation indices are decreasing - NO_DIR + DOWN_DIR = -1, // Animation indices are decreasing + NO_DIR = 0, + UP_DIR = 1, // Animation indices are increasing } ANIM_DIR; typedef enum @@ -42,20 +109,22 @@ // Describes an active animation. struct SEQUENCE { - COUNT Alarm; + ANIMATION_DESC *ADPtr; + DWORD Alarm; ANIM_DIR Direction; - BYTE FramesLeft; + COUNT CurIndex; + COUNT NextIndex; + COUNT FramesLeft; ANIM_TYPE AnimType; - union - { - FRAME CurFrame; - COLORMAP CurCMap; - } AnimObj; + BOOLEAN Change; }; #endif typedef struct SEQUENCE SEQUENCE; +// Returns TRUE if there was an animation change +extern BOOLEAN DrawAlienFrame (SEQUENCE *pSeq, COUNT Num, BOOLEAN fullRedraw); + void UpdateSpeechGraphics (BOOLEAN Initialize); Task StartCommAnimTask(void); Modified: trunk/sc2/src/uqm/globdata.h =================================================================== --- trunk/sc2/src/uqm/globdata.h 2009-11-15 04:20:15 UTC (rev 3304) +++ trunk/sc2/src/uqm/globdata.h 2009-11-15 06:43:03 UTC (rev 3305) @@ -24,56 +24,9 @@ #include "libs/reslib.h" #include "sis.h" #include "velocity.h" +#include "commanim.h" -// XXX: the following should be moved to commanim.h -// Animation types: -#define RANDOM_ANIM (1 << 0) - // The next index is randomly chosen. -#define CIRCULAR_ANIM (1 << 1) - // After the last index has been reached, the animation starts over. -#define YOYO_ANIM (1 << 2) - // After the last index has been reached, the order that the - // animation frames are used is reversed. -#define ANIM_MASK (RANDOM_ANIM | CIRCULAR_ANIM | YOYO_ANIM) - // Mask of all animation types. - -#define WAIT_TALKING (1 << 3) - // This is set in AlienTalkDesc when the ambient animations should - // stop at the end of the current animation cycle. - // In AlienAmbientArray, this is set for those ambient animations - // which can not be active while the talking animation is active. -#define PAUSE_TALKING (1 << 4) -#define TALK_INTRO (1 << 5) -#define TALK_DONE (1 << 6) - -#define ANIM_DISABLED (1 << 7) - -#define COLORXFORM_ANIM PAUSE_TALKING - -typedef struct -{ - COUNT StartIndex; - // Index of the first image (for image animation) or - // index of the first color map (for palette animation) - BYTE NumFrames; - // Number of frames in the animation. - - BYTE AnimFlags; - // One of RANDOM_ANIM, CIRCULAR_ANIM, or YOYO_ANIM - - COUNT BaseFrameRate; - COUNT RandomFrameRate; - COUNT BaseRestartRate; - COUNT RandomRestartRate; - - DWORD BlockMask; - // Bit mask of the indices of all animations that can not - // be active at the same time as this animation. -} ANIMATION_DESC; - -#define MAX_ANIMATIONS 20 - // general numbers-speech generator info // should accomodate most common base-10 languages // many languages require various plural forms @@ -160,7 +113,12 @@ COUNT NumAnimations; ANIMATION_DESC AlienAmbientArray[MAX_ANIMATIONS]; + // Transition animation to/from talking state; + // the first frame is neutral (sort of like YOYO_ANIM) ANIMATION_DESC AlienTransitionDesc; + // Talking animation, like RANDOM_ANIM, except random frames + // always alternate with a neutral frame; + // the first frame is neutral ANIMATION_DESC AlienTalkDesc; NUMBER_SPEECH AlienNumberSpeech; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-21 21:04:58
|
Revision: 3334 http://sc2.svn.sourceforge.net/sc2/?rev=3334&view=rev Author: Meep-Eep Date: 2009-11-21 21:04:45 +0000 (Sat, 21 Nov 2009) Log Message: ----------- Refactoring the universe generation code. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/doc/devel/generate trunk/sc2/src/uqm/encount.h trunk/sc2/src/uqm/gendef.c trunk/sc2/src/uqm/load.c trunk/sc2/src/uqm/melee.c trunk/sc2/src/uqm/planets/Makeinfo 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/pstarmap.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/save.c trunk/sc2/src/uqm/uqmdebug.c trunk/sc2/src/uqmversion.h Added Paths: ----------- trunk/sc2/doc/devel/orggenerate trunk/sc2/src/uqm/gendef.h trunk/sc2/src/uqm/planets/generate/ trunk/sc2/src/uqm/planets/generate/Makeinfo trunk/sc2/src/uqm/planets/generate/genall.h trunk/sc2/src/uqm/planets/generate/genand.c trunk/sc2/src/uqm/planets/generate/genburv.c trunk/sc2/src/uqm/planets/generate/genchmmr.c trunk/sc2/src/uqm/planets/generate/gencol.c trunk/sc2/src/uqm/planets/generate/gendefault.c trunk/sc2/src/uqm/planets/generate/gendefault.h trunk/sc2/src/uqm/planets/generate/gendru.c trunk/sc2/src/uqm/planets/generate/genilw.c trunk/sc2/src/uqm/planets/generate/genmel.c trunk/sc2/src/uqm/planets/generate/genmyc.c trunk/sc2/src/uqm/planets/generate/genorz.c trunk/sc2/src/uqm/planets/generate/genpet.c trunk/sc2/src/uqm/planets/generate/genpku.c trunk/sc2/src/uqm/planets/generate/genrain.c trunk/sc2/src/uqm/planets/generate/gensam.c trunk/sc2/src/uqm/planets/generate/genshof.c trunk/sc2/src/uqm/planets/generate/gensly.c trunk/sc2/src/uqm/planets/generate/gensol.c trunk/sc2/src/uqm/planets/generate/genspa.c trunk/sc2/src/uqm/planets/generate/gensup.c trunk/sc2/src/uqm/planets/generate/gensyr.c trunk/sc2/src/uqm/planets/generate/genthrad.c trunk/sc2/src/uqm/planets/generate/gentrap.c trunk/sc2/src/uqm/planets/generate/genutw.c trunk/sc2/src/uqm/planets/generate/genvault.c trunk/sc2/src/uqm/planets/generate/genvux.c trunk/sc2/src/uqm/planets/generate/genwreck.c trunk/sc2/src/uqm/planets/generate/genyeh.c trunk/sc2/src/uqm/planets/generate/genzfpscout.c trunk/sc2/src/uqm/planets/generate/genzoq.c trunk/sc2/src/uqm/planets/generate.h Removed Paths: ------------- trunk/sc2/src/uqm/planets/genall.h trunk/sc2/src/uqm/planets/genburv.c trunk/sc2/src/uqm/planets/genchmmr.c trunk/sc2/src/uqm/planets/gencol.c trunk/sc2/src/uqm/planets/gendru.c trunk/sc2/src/uqm/planets/genilw.c trunk/sc2/src/uqm/planets/genmel.c trunk/sc2/src/uqm/planets/genmyc.c trunk/sc2/src/uqm/planets/genorz.c trunk/sc2/src/uqm/planets/genpet.c trunk/sc2/src/uqm/planets/genpku.c trunk/sc2/src/uqm/planets/genrain.c trunk/sc2/src/uqm/planets/gensam.c trunk/sc2/src/uqm/planets/genshof.c trunk/sc2/src/uqm/planets/gensly.c trunk/sc2/src/uqm/planets/gensol.c trunk/sc2/src/uqm/planets/genspa.c trunk/sc2/src/uqm/planets/gensup.c trunk/sc2/src/uqm/planets/gensyr.c trunk/sc2/src/uqm/planets/genthrad.c trunk/sc2/src/uqm/planets/genutw.c trunk/sc2/src/uqm/planets/genvault.c trunk/sc2/src/uqm/planets/genvux.c trunk/sc2/src/uqm/planets/genwreck.c trunk/sc2/src/uqm/planets/genyeh.c trunk/sc2/src/uqm/planets/genzoq.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/ChangeLog 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Refactored universe generation - SvdB - Comm animation processing rewrite, bugs fixed - Alex - Added graphics context debugging function - SvdB - Thread down-throttling and game sleep when inactive (currently disabled), Modified: trunk/sc2/doc/devel/generate =================================================================== --- trunk/sc2/doc/devel/generate 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/doc/devel/generate 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,3 +1,30 @@ +Note: this file (still) describes the way in which various things were +generated in the original source. It is still useful, but there are some +changes: +- all of this functionality used to be handled through a single function, + either the function returned by GenerateIP(), or GenerateRandomIP(). + Now, there is a structure GenerateFunctions, which contains a function + for each of the type of generation. See generate.h. +- most functions don't use the global variables pSolarSysState, pOrbitalDesc, + and pPlanetDesc anymore. Instead, where these are needed, they are passed + along through a parameter. + +Files related to this system: +- planets/generate.h + Defines GenerateFunctions. +- planets/generate/gendefault.c + Default generation functions for when no specific one is specified. +- planets/generate/gen*.c + Specific generation functions. +- gendef.c + Glue code. + +This file should eventually be updated to reflect the new system. +See the file 'orggenerate' for a description on how the system originally +worked. + +============================================================================ + The various universe related game data is generated through a call to a solar system dependant generation function. This function is of type PLAN_GEN_FUNC, which is a typedef to Copied: trunk/sc2/doc/devel/orggenerate (from rev 3267, trunk/sc2/doc/devel/generate) =================================================================== --- trunk/sc2/doc/devel/orggenerate (rev 0) +++ trunk/sc2/doc/devel/orggenerate 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,133 @@ +Note: this file describes the way in which various things were generated +in the original source. See the file 'generate' for the current system. + +============================================================================ + +The various universe related game data is generated through a call +to a solar system dependant generation function. +This function is of type PLAN_GEN_FUNC, which is a typedef to + void (*PLAN_GEN_FUNC) (BYTE control) +, where the 'control' argument specifies what type of data needs to be +generated (one of GENERATE_PLANETS, GENERATE_MOONS, GENERATE_ORBITAL, +INIT_NPCS, REINIT_NPCS, UNINIT_NPCS, GENERATE_MINERAL, GENERATE_ENERGY, +GENERATE_LIFE, or GENERATE_NAME). + +The generation function for a solar system is kept in the 'GenFunc' +field of the SOLARSYS_STATE structure. +The SOLARSYS_STATE structure contains the data for a solar system. +Currently, only one SOLARSYS_STATE structure is used at once, and +the global variable pSolarSysState points to the current one. +The GenFunc field is initialised in ExploreSolarSys(), to the value +returned by GenerateIP() in sc2code/gendef.c. Usually, this will be +'GenerateRandomIP', but for some specific solar systems a (pointer to a) +custom generation function is returned. This depends on the value of +CurStarDescPtr->Index, which contains values such as SOL_DEFINED, +MELNORME0_DEFINED, AQUA_HELIX_DEFINED, etc (see sc2code/encount.h +for the complete list). +The starmap_array in sc2code/plandata.c specifies Index for all +the solar systems in the game. + +Following are the possible values of the 'control' argument to the +generation function, with the description of how the generation function +acts on this. As the custom generation functions often only need to +change one specific aspect of this game data generation, they will +often call GenerateRandomIP() for the rest. +StarBases are handled as if they were moons. + +GENERATE_PLANETS +Pre: the global variable pSolarSysState points to the relevant solar system. +Pre: the RNG is initialised with a seed to be used for the generation. + In practice, this seed is generated from the HyperSpace coordinates + of the solar system (which are hardcoded in sc2code/plandata.c), + followed by exactly one call to TFB_Random(). +Post: the RNG is in an undefined state. +This function determines how many planets the system has, and fills in +pSolarSysState->PlanetDesc[] for all planets, including the NumPlanets +field, which determines how many moons the planet will have. +It also sets the random seed that is used for data generated for this planet +(including the number of moons), based on its coordinates (which are in the +general case randomly determined themselves). + +GENERATE_MOONS +Pre: the global variable pSolarSysState points to the relevant solar system, + which is initialised by a GENERATE_PLANETS call. +Pre: the RNG is initialised with a seed to be used for the generation. + In practice, this seed is the seed stored by GENERATE_PLANETS + in the rand_seed field for the planet around which the moon(s) orbit. +Pre: pSolarSysState->pBaseDesc points to the the relevant planet + of pSolarSysState->PlanetDesc[]. +Post: The RNG is in an undefined state. +This function fills in pSolarSysState->MoonDesc[] for all moons around +the planet pointed to by pSolarSysState->pBaseDesc. +It also sets the random seed that is used for data generated for the moon +based on its coordinates (which are in the general case randomly determined +themselves). + +GENERATE_ORBITAL +Pre: the global variable pSolarSysState points to the relevant solar system, + which is initialised by a GENERATE_PLANETS call. +Pre: pSolarSysState->pOrbitalDesc points to the relevant planet or moon from + pSolarSysState->PlanetDesc[] or pSolarSysState->moonDesc[] +Pre: the planet or moon that pSolarSysState->pOrbitalDesc points to + is initialised by a GENERATE_PLANETS or GENERATE_MOONS call. +This function fills in pSolarSysState->SysInfo with the characteristics +of the planet or moon, as seen from orbit. +It also initialises the random seeds used for the generation of bio, +minerals, and energy nodes on the surface. +It also sets the discovery report string (if appropriate), initialises +the surface graphics, and start the planet music. +For specific planets, it may initiate race communication and possibly combat, +and will only return once these are over. +NB. The GENERATE_ORBITAL code should be split up into separate calculation +and activation (graphics and music) parts. + +GENERATE_MINERAL, GENERATE_ENERGY, GENERATE_LIFE +Pre: the global variable pSolarSysState points to the relevant solar system, + which is initialised by a GENERATE_PLANETS call. +Pre: pSolarSysState->pOrbitalDesc points to the relevant planet or moon from + pSolarSysState->PlanetDesc[] or pSolarSysState->moonDesc[] +Pre: the planet or moon that pSolarSysState->pOrbitalDesc points to + is initialised by a GENERATE_PLANETS or GENERATE_MOONS call. +Pre: pSolarSysState->SysInfo is filled in by a GENERATE_ORBITAL call +This function determines the properties of one mineral deposit, energy node, +or life form on a planet or moon. On entry the caller sets +pSolarSysState->CurNode to the index of the requested item. This function +will then fill in pSolarSysState->SysInfo.PlanetInfo.CurPt, +pSolarSysState->SysInfo.PlanetInfo.CurType, and in the case of minerals also +pSolarSysState->SysInfo.PlanetInfo.CurDensity. +In case pSolarSysState->CurNode is set to a value larger than or equal to +the number of items of the requested kind ((COUNT) ~0 in practice), it is +set to the real number of nodes. In this case the CurXXX fields of +pSolarSysState->SysInfo.PlanetInfo are set to the values corresponding to +the largest valid CurNode index, but should probably be considered to be +undefined. +These functions may also change the game state, cause the lander +to take off (by setting InTransit to true in the active PLANETSIDE_DESC +structure), or mark an energy node as not retrieved, usually in response +to an item having been picked up since the last call. The game makes +a GENERATE_MINERAL, GENERATE_ENERGY or GENERATE_LIFE call (whatever +is relevant) for each item right after it is picked up. + +GENERATE_NAME +Pre: pSolarSysState is set to the relevant solar system. +Pre: The planet is initialised by GENERATE_PLANETS. +Pre: pSolarSysState->pBaseDesc points to the relevant planet, which should + be in the system. +This function fills GLOBAL_SIS (PlanetName) with the name of the planet +pointed to by pSolarSysState->pBaseDesc. +It also sets the GAME_STATE flag BATTLE_PLANET to the type of this planet, +so that it will be shown appropriately in melee if combat follows. +There is no generate function for the names of moons. The few moons that +are named (those in the Sol system), are handled as a special case of +the routines that prints these names (PrintCoarseScan3DO and +PrintCoraseScanPC). + +INIT_NPCS +REINIT_NPCS +UNINIT_NPCS +[TODO] + + +Initial version of this document created by Serge van den Boom, on 2005-07-11. + + Modified: trunk/sc2/src/uqm/encount.h =================================================================== --- trunk/sc2/src/uqm/encount.h 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/encount.h 2009-11-21 21:04:45 UTC (rev 3334) @@ -19,6 +19,9 @@ #ifndef _ENCOUNT_H #define _ENCOUNT_H +typedef struct brief_ship_info BRIEF_SHIP_INFO; +typedef struct encounter ENCOUNTER; + // XXX: temporary, for CONVERSATION #include "commglue.h" #include "displist.h" @@ -33,7 +36,7 @@ #define ONE_SHOT_ENCOUNTER (1 << 7) #define ENCOUNTER_REFORMING (1 << 6) -typedef struct +struct brief_ship_info { // The only field actually used right now is crew_level BYTE race_id; @@ -41,9 +44,9 @@ COUNT max_crew; BYTE max_energy; -} BRIEF_SHIP_INFO; +}; -typedef struct +struct encounter { // LINK elements; must be first HENCOUNTER pred, succ; @@ -58,7 +61,7 @@ BRIEF_SHIP_INFO ShipList[MAX_HYPER_SHIPS]; SDWORD log_x, log_y; -} ENCOUNTER; +}; #define AllocEncounter() AllocLink (&GLOBAL (encounter_q)) #define PutEncounter(h) PutQueue (&GLOBAL (encounter_q), h) Modified: trunk/sc2/src/uqm/gendef.c =================================================================== --- trunk/sc2/src/uqm/gendef.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/gendef.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -17,26 +17,54 @@ */ #include "encount.h" +#include "planets/generate.h" -PLAN_GEN_FUNC -GenerateIP (BYTE Index) + +extern GenerateFunctions generateDefaultFunctions; + +extern GenerateFunctions generateAndrosynthFunctions; +extern GenerateFunctions generateBurvixeseFunctions; +extern GenerateFunctions generateChmmrFunctions; +extern GenerateFunctions generateColonyFunctions; +extern GenerateFunctions generateDruugeFunctions; +extern GenerateFunctions generateIlwrathFunctions; +extern GenerateFunctions generateMelnormeFunctions; +extern GenerateFunctions generateMyconFunctions; +extern GenerateFunctions generateOrzFunctions; +extern GenerateFunctions generatePkunkFunctions; +extern GenerateFunctions generateRainbowWorldFunctions; +extern GenerateFunctions generateSaMatraFunctions; +extern GenerateFunctions generateShofixtiFunctions; +extern GenerateFunctions generateSlylandroFunctions; +extern GenerateFunctions generateSolFunctions; +extern GenerateFunctions generateSpathiFunctions; +extern GenerateFunctions generateSupoxFunctions; +extern GenerateFunctions generateSyreenFunctions; +extern GenerateFunctions generateTalkingPetFunctions; +extern GenerateFunctions generateThraddashFunctions; +extern GenerateFunctions generateTrapFunctions; +extern GenerateFunctions generateUtwigFunctions; +extern GenerateFunctions generateVaultFunctions; +extern GenerateFunctions generateVuxFunctions; +extern GenerateFunctions generateWreckFunctions; +extern GenerateFunctions generateYehatFunctions; +extern GenerateFunctions generateZoqFotPikFunctions; +extern GenerateFunctions generateZoqFotPikScoutFunctions; + + +const GenerateFunctions * +getGenerateFunctions (BYTE Index) { - PLAN_GEN_FUNC GenFunc; - switch (Index) { case SOL_DEFINED: - GenFunc = GenerateSOL; - break; + return &generateSolFunctions; case SHOFIXTI_DEFINED: - GenFunc = GenerateShofixti; - break; + return &generateShofixtiFunctions; case START_COLONY_DEFINED: - GenFunc = GenerateColony; - break; + return &generateColonyFunctions; case SPATHI_DEFINED: - GenFunc = GenerateSpathi; - break; + return &generateSpathiFunctions; case MELNORME0_DEFINED: case MELNORME1_DEFINED: case MELNORME2_DEFINED: @@ -46,86 +74,64 @@ case MELNORME6_DEFINED: case MELNORME7_DEFINED: case MELNORME8_DEFINED: - GenFunc = GenerateMelnorme; - break; + return &generateMelnormeFunctions; case TALKING_PET_DEFINED: - GenFunc = GenerateTalkingPet; - break; + return &generateTalkingPetFunctions; case CHMMR_DEFINED: - GenFunc = GenerateChmmr; - break; + return &generateChmmrFunctions; case SYREEN_DEFINED: + return &generateSyreenFunctions; case MYCON_TRAP_DEFINED: - GenFunc = GenerateSyreen; - break; + return &generateTrapFunctions; case BURVIXESE_DEFINED: - GenFunc = GenerateBurvixes; - break; + return &generateBurvixeseFunctions; case SLYLANDRO_DEFINED: - GenFunc = GenerateSlylandro; - break; + return &generateSlylandroFunctions; case DRUUGE_DEFINED: - GenFunc = GenerateDruuge; - break; + return &generateDruugeFunctions; case BOMB_DEFINED: case UTWIG_DEFINED: - GenFunc = GenerateUtwig; - break; + return &generateUtwigFunctions; case AQUA_HELIX_DEFINED: case THRADD_DEFINED: - GenFunc = GenerateThradd; - break; + return &generateThraddashFunctions; case SUN_DEVICE_DEFINED: case MYCON_DEFINED: case EGG_CASE0_DEFINED: case EGG_CASE1_DEFINED: case EGG_CASE2_DEFINED: - GenFunc = GenerateMycon; - break; + return &generateMyconFunctions; case ANDROSYNTH_DEFINED: + return &generateAndrosynthFunctions; case TAALO_PROTECTOR_DEFINED: case ORZ_DEFINED: - GenFunc = GenerateOrz; - break; + return &generateOrzFunctions; case SHIP_VAULT_DEFINED: - GenFunc = GenerateShipVault; - break; + return &generateVaultFunctions; case URQUAN_WRECK_DEFINED: - GenFunc = GenerateUrquanWreck; - break; + return &generateWreckFunctions; case MAIDENS_DEFINED: case VUX_BEAST_DEFINED: case VUX_DEFINED: - GenFunc = GenerateVUX; - break; + return &generateVuxFunctions; case SAMATRA_DEFINED: - GenFunc = GenerateSamatra; - break; + return &generateSaMatraFunctions; case ZOQFOT_DEFINED: + return &generateZoqFotPikFunctions; case ZOQ_SCOUT_DEFINED: - GenFunc = GenerateZoqFotPik; - break; + return &generateZoqFotPikScoutFunctions; case YEHAT_DEFINED: - GenFunc = GenerateYehat; - break; + return &generateYehatFunctions; case PKUNK_DEFINED: - GenFunc = GeneratePkunk; - break; + return &generatePkunkFunctions; case SUPOX_DEFINED: - GenFunc = GenerateSupox; - break; + return &generateSupoxFunctions; case RAINBOW_DEFINED: - GenFunc = GenerateRainbow; - break; + return &generateRainbowWorldFunctions; case ILWRATH_DEFINED: - GenFunc = GenerateIlwrath; - break; + return &generateIlwrathFunctions; default: - GenFunc = GenerateRandomIP; - break; + return &generateDefaultFunctions; } - - return (GenFunc); } - Added: trunk/sc2/src/uqm/gendef.h =================================================================== --- trunk/sc2/src/uqm/gendef.h (rev 0) +++ trunk/sc2/src/uqm/gendef.h 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,10 @@ +#ifndef GENDEF_H +#define GENDEF_H + +#include "planets/generate.h" +#include "libs/compiler.h" + +const GenerateFunctions *getGenerateFunctions (BYTE Index); + +#endif /* GENDEF_H */ + Modified: trunk/sc2/src/uqm/load.c =================================================================== --- trunk/sc2/src/uqm/load.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/load.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -568,7 +568,8 @@ LoadRaceQueue (fh, &GLOBAL (avail_race_q)); // START_INTERPLANETARY is only set when saving from Homeworld - // encounter screen. When the game is loaded, GENERATE_ORBITAL will + // encounter screen. When the game is loaded, the + // GenerateOrbitalFunction for the current star system will // create the encounter anew and populate the npc queue. if (!(NextActivity & START_INTERPLANETARY)) { Modified: trunk/sc2/src/uqm/melee.c =================================================================== --- trunk/sc2/src/uqm/melee.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/melee.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -852,6 +852,8 @@ r.corner.x = r.corner.y = 0; RedrawMeleeFrame (); + + (void) pMS; } static void Modified: trunk/sc2/src/uqm/planets/Makeinfo =================================================================== --- trunk/sc2/src/uqm/planets/Makeinfo 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/planets/Makeinfo 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,7 +1,4 @@ -uqm_CFILES="calc.c cargo.c devices.c genburv.c genchmmr.c gencol.c - gendru.c genilw.c genmel.c genmyc.c genorz.c genpet.c genpku.c - genrain.c gensam.c genshof.c gensly.c gensol.c genspa.c gensup.c - gensyr.c genthrad.c gentopo.c genutw.c genvault.c genvux.c - genwreck.c genyeh.c genzoq.c lander.c orbits.c oval.c pl_stuff.c - planets.c plangen.c pstarmap.c report.c +uqm_SUBDIRS="generate" +uqm_CFILES="calc.c cargo.c devices.c gentopo.c lander.c orbits.c + oval.c pl_stuff.c planets.c plangen.c pstarmap.c report.c roster.c scan.c solarsys.c surface.c" Deleted: trunk/sc2/src/uqm/planets/genall.h =================================================================== --- trunk/sc2/src/uqm/planets/genall.h 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/planets/genall.h 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,28 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GENALL_H -#define _GENALL_H - -#include "planets.h" -#include "libs/compiler.h" -#include "../globdata.h" -#include "../nameref.h" -#include "../resinst.h" - - -#endif /* _GENALL_H */ - Deleted: trunk/sc2/src/uqm/planets/genburv.c =================================================================== --- trunk/sc2/src/uqm/planets/genburv.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/planets/genburv.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,183 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "genall.h" -#include "libs/mathlib.h" - - -void -GenerateBurvixes (BYTE control) -{ - COUNT i; - DWORD rand_val; - - switch (control) - { - case GENERATE_ENERGY: - { - DWORD rand_val, old_rand; - - if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) - { - COUNT which_node; - - old_rand = TFB_SeedRandom ( - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] - ); - - which_node = i = 0; - do - { - rand_val = TFB_Random (); - pSolarSysState->SysInfo.PlanetInfo.CurPt.x = - (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; - pSolarSysState->SysInfo.PlanetInfo.CurPt.y = - (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; - pSolarSysState->SysInfo.PlanetInfo.CurType = 1; - pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; - if (which_node >= pSolarSysState->CurNode - && !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i))) - break; - ++which_node; - } while (++i < 16); - pSolarSysState->CurNode = which_node; - - TFB_SeedRandom (old_rand); - break; - } - else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0] - && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0] - && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) - { - old_rand = TFB_SeedRandom ( - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] - ); - - rand_val = TFB_Random (); - pSolarSysState->SysInfo.PlanetInfo.CurPt.x = - (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; - pSolarSysState->SysInfo.PlanetInfo.CurPt.y = - (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; - pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; - pSolarSysState->SysInfo.PlanetInfo.CurType = 0; - if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) - && pSolarSysState->CurNode == (COUNT)~0) - pSolarSysState->CurNode = 1; - else - { - pSolarSysState->CurNode = 0; - if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) - { - SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1); - SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1); - } - } - - TFB_SeedRandom (old_rand); - break; - } - pSolarSysState->CurNode = 0; - break; - } - case GENERATE_MOONS: - GenerateRandomIP (GENERATE_MOONS); - if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0]) - { - COUNT angle; - - pSolarSysState->MoonDesc[0].data_index = SELENIC_WORLD; - pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS - + (MAX_MOONS - 1) * MOON_DELTA; - rand_val = TFB_Random (); - angle = NORMALIZE_ANGLE (LOWORD (rand_val)); - pSolarSysState->MoonDesc[0].location.x = - COSINE (angle, pSolarSysState->MoonDesc[0].radius); - pSolarSysState->MoonDesc[0].location.y = - SINE (angle, pSolarSysState->MoonDesc[0].radius); - } - break; - case GENERATE_PLANETS: - { - COUNT angle; - - GenerateRandomIP (GENERATE_PLANETS); - - pSolarSysState->PlanetDesc[0].data_index = REDUX_WORLD; - pSolarSysState->PlanetDesc[0].NumPlanets = 1; - pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 39L / 100; - angle = ARCTAN ( - pSolarSysState->PlanetDesc[0].location.x, - pSolarSysState->PlanetDesc[0].location.y - ); - pSolarSysState->PlanetDesc[0].location.x = - COSINE (angle, pSolarSysState->PlanetDesc[0].radius); - pSolarSysState->PlanetDesc[0].location.y = - SINE (angle, pSolarSysState->PlanetDesc[0].radius); - break; - } - case GENERATE_ORBITAL: - { - rand_val = DoPlanetaryAnalysis ( - &pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc - ); - - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - i = (COUNT)~0; - rand_val = GenerateLifeForms (&pSolarSysState->SysInfo, &i); - - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - i = (COUNT)~0; - GenerateMineralDeposits (&pSolarSysState->SysInfo, &i); - - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; - if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) - { - LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - pSolarSysState->PlanetSideFrame[1] = - CaptureDrawable ( - LoadGraphic (RUINS_MASK_PMAP_ANIM)); - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = - CaptureStringTable ( - LoadStringTable (BURV_RUINS_STRTAB)); - pSolarSysState->SysInfo.PlanetInfo.Weather = 0; - pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0; - } - else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0] - && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0] - && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) - { - LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - pSolarSysState->PlanetSideFrame[1] = - CaptureDrawable ( - LoadGraphic (BURV_BCS_MASK_PMAP_ANIM)); - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = - CaptureStringTable ( - LoadStringTable (BURV_BCS_STRTAB)); - } - LoadPlanet (NULL); - break; - } - default: - GenerateRandomIP (control); - break; - } -} - Deleted: trunk/sc2/src/uqm/planets/genchmmr.c =================================================================== --- trunk/sc2/src/uqm/planets/genchmmr.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/planets/genchmmr.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,142 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "genall.h" -#include "lander.h" -#include "../build.h" -#include "../encount.h" -#include "../setup.h" -#include "../state.h" -#include "../sounds.h" -#include "libs/mathlib.h" - - -void -GenerateChmmr (BYTE control) -{ - switch (control) - { - case GENERATE_MOONS: - GenerateRandomIP (GENERATE_MOONS); - if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[1]) - { - COUNT angle; - DWORD rand_val; - - pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE; - pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS; - rand_val = TFB_Random (); - angle = NORMALIZE_ANGLE (LOWORD (rand_val)); - pSolarSysState->MoonDesc[0].location.x = - COSINE (angle, pSolarSysState->MoonDesc[0].radius); - pSolarSysState->MoonDesc[0].location.y = - SINE (angle, pSolarSysState->MoonDesc[0].radius); - } - break; - case GENERATE_PLANETS: - GenerateRandomIP (GENERATE_PLANETS); - pSolarSysState->PlanetDesc[1].data_index = SAPPHIRE_WORLD; - if (!GET_GAME_STATE (CHMMR_UNLEASHED)) - pSolarSysState->PlanetDesc[1].data_index |= PLANET_SHIELDED; - pSolarSysState->PlanetDesc[1].NumPlanets = 1; - break; - case GENERATE_ORBITAL: - if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1]) - { - if (GET_GAME_STATE (CHMMR_UNLEASHED)) - { - pSolarSysState->MenuState.Initialized += 2; - SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); - InitCommunication (CHMMR_CONVERSATION); - pSolarSysState->MenuState.Initialized -= 2; - - if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) - { - GLOBAL (CurrentActivity) |= END_INTERPLANETARY; - } - break; - } - else if (GET_GAME_STATE (SUN_DEVICE_ON_SHIP) - && !GET_GAME_STATE (ILWRATH_DECEIVED) - && ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING)) - { - PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); - ReinitQueue (&GLOBAL (ip_group_q)); - assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); - - CloneShipFragment (ILWRATH_SHIP, - &GLOBAL (npc_built_ship_q), INFINITE_FLEET); - - pSolarSysState->MenuState.Initialized += 2; - SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 6); - GLOBAL (CurrentActivity) |= START_INTERPLANETARY; - InitCommunication (ILWRATH_CONVERSATION); - pSolarSysState->MenuState.Initialized -= 2; - - if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) - { - GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; - ReinitQueue (&GLOBAL (npc_built_ship_q)); - GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); - } - break; - } - } - /* Starbase */ - else if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[1] - && pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]) - { - RECT r; - - LockMutex (GraphicsLock); - - LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = - CaptureStringTable ( - LoadStringTable (CHMMR_BASE_STRTAB)); - - ScanContext = CreateContext ("genchmmr.ScanContext"); - SetContext (ScanContext); - SetContextFGFrame (Screen); - r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH; - r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT; - r.extent.width = MAP_WIDTH; - r.extent.height = MAP_HEIGHT; - SetContextClipRect (&r); - - DoDiscoveryReport (MenuSounds); - - SetContext (SpaceContext); - DestroyContext (ScanContext); - ScanContext = 0; - - DestroyStringTable (ReleaseStringTable ( - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString - )); - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; - FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - - UnlockMutex (GraphicsLock); - break; - } - default: - GenerateRandomIP (control); - break; - } -} - Deleted: trunk/sc2/src/uqm/planets/gencol.c =================================================================== --- trunk/sc2/src/uqm/planets/gencol.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/planets/gencol.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,101 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "genall.h" -#include "../build.h" -#include "../state.h" -#include "../grpinfo.h" - - -void -GenerateColony (BYTE control) -{ - switch (control) - { - case INIT_NPCS: - { - HIPGROUP hGroup; - - GLOBAL (BattleGroupRef) = GET_GAME_STATE_32 (COLONY_GRPOFFS0); - if (GLOBAL (BattleGroupRef) == 0) - { - CloneShipFragment (URQUAN_SHIP, - &GLOBAL (npc_built_ship_q), 0); - GLOBAL (BattleGroupRef) = PutGroupInfo (GROUPS_ADD_NEW, 1); - ReinitQueue (&GLOBAL (npc_built_ship_q)); - SET_GAME_STATE_32 (COLONY_GRPOFFS0, GLOBAL (BattleGroupRef)); - } - - GenerateRandomIP (INIT_NPCS); - - if (GLOBAL (BattleGroupRef) - && (hGroup = GetHeadLink (&GLOBAL (ip_group_q)))) - { - IP_GROUP *GroupPtr; - - GroupPtr = LockIpGroup (&GLOBAL (ip_group_q), hGroup); - GroupPtr->task = IN_ORBIT; - GroupPtr->sys_loc = 0 + 1; /* orbitting colony */ - GroupPtr->dest_loc = 0 + 1; /* orbitting colony */ - GroupPtr->loc.x = 0; - GroupPtr->loc.y = 0; - GroupPtr->group_counter = 0; - UnlockIpGroup (&GLOBAL (ip_group_q), hGroup); - } - break; - } - case GENERATE_PLANETS: - { - COUNT angle; - PLANET_DESC *pMinPlanet; - - pMinPlanet = &pSolarSysState->PlanetDesc[0]; - FillOrbits (pSolarSysState, (BYTE)~0, pMinPlanet, FALSE); - - pMinPlanet->radius = EARTH_RADIUS * 115L / 100; - angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y); - pMinPlanet->location.x = - COSINE (angle, pMinPlanet->radius); - pMinPlanet->location.y = - SINE (angle, pMinPlanet->radius); - pMinPlanet->data_index = WATER_WORLD | PLANET_SHIELDED; - break; - } - case GENERATE_ORBITAL: - if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) - { - DoPlanetaryAnalysis ( - &pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc - ); - - pSolarSysState->SysInfo.PlanetInfo.AtmoDensity = - EARTH_ATMOSPHERE * 98 / 100; - pSolarSysState->SysInfo.PlanetInfo.Weather = 0; - pSolarSysState->SysInfo.PlanetInfo.Tectonics = 0; - pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 28; - - LoadPlanet (NULL); - break; - } - default: - GenerateRandomIP (control); - break; - } -} - - Deleted: trunk/sc2/src/uqm/planets/gendru.c =================================================================== --- trunk/sc2/src/uqm/planets/gendru.c 2009-11-21 01:15:21 UTC (rev 3333) +++ trunk/sc2/src/uqm/planets/gendru.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -1,159 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "genall.h" -#include "lander.h" -#include "../build.h" -#include "../encount.h" -#include "../ipdisp.h" -#include "../state.h" -#include "libs/mathlib.h" - - -void -GenerateDruuge (BYTE control) -{ - switch (control) - { - case GENERATE_ENERGY: - if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) - { - COUNT i, which_node; - DWORD rand_val, old_rand; - - old_rand = TFB_SeedRandom ( - pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] - ); - - which_node = i = 0; - do - { - rand_val = TFB_Random (); - pSolarSysState->SysInfo.PlanetInfo.CurPt.x = - (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; - pSolarSysState->SysInfo.PlanetInfo.CurPt.y = - (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; - if (!GET_GAME_STATE (ROSY_SPHERE)) - pSolarSysState->SysInfo.PlanetInfo.CurType = 0; - else - pSolarSysState->SysInfo.PlanetInfo.CurType = 1; - pSolarSysState->SysInfo.PlanetInfo.CurDensity = 0; - if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i)) - { - pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << i); - - if (!GET_GAME_STATE (ROSY_SPHERE)) - { - pLanderInputState->planetSideDesc->InTransit = TRUE; - - SET_GAME_STATE (ROSY_SPHERE, 1); - SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1); - } - } - if (which_node >= pSolarSysState->CurNode - && !(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i))) - break; - ++which_node; - } while (++i < 16); - pSolarSysState->CurNode = which_node; - - TFB_SeedRandom (old_rand); - break; - } - pSolarSysState->CurNode = 0; - break; - case GENERATE_PLANETS: - { - COUNT angle; - - GenerateRandomIP (GENERATE_PLANETS); - - memmove (&pSolarSysState->PlanetDesc[1], - &pSolarSysState->PlanetDesc[0], - sizeof (pSolarSysState->PlanetDesc[0]) - * pSolarSysState->SunDesc[0].NumPlanets); - ++pSolarSysState->SunDesc[0].NumPlanets; - - pSolarSysState->PlanetDesc[0].data_index = DUST_WORLD; - pSolarSysState->PlanetDesc[0].radius = EARTH_RADIUS * 50L / 100; - pSolarSysState->PlanetDesc[0].NumPlanets = 0; - angle = HALF_CIRCLE - OCTANT; - pSolarSysState->PlanetDesc[0].location.x = - COSINE (angle, pSolarSysState->PlanetDesc[0].radius); - pSolarSysState->PlanetDesc[0].location.y = - SINE (angle, pSolarSysState->PlanetDesc[0].radius); - pSolarSysState->PlanetDesc[0].rand_seed = MAKE_DWORD ( - pSolarSysState->PlanetDesc[0].location.x, - pSolarSysState->PlanetDesc[0].location.y - ); - break; - } - case GENERATE_ORBITAL: - if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0]) - { - if (ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING)) - { - NotifyOthers (DRUUGE_SHIP, IPNL_ALL_CLEAR); - PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); - ReinitQueue (&GLOBAL (ip_group_q)); - assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); - - CloneShipFragment (DRUUGE_SHIP, - &GLOBAL (npc_built_ship_q), INFINITE_FLEET); - - pSolarSysState->MenuState.Initialized += 2; - GLOBAL (CurrentActivity) |= START_INTERPLANETARY; - SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); - InitCommunication (DRUUGE_CONVERSATION); - pSolarSysState->MenuState.Initialized -= 2; - if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) - { - GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY; - ReinitQueue (&GLOBAL (npc_built_ship_q)); - GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP); - } - break; - } - else - { - LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - pSolarSysState->PlanetSideFrame[1] = - CaptureDrawable ( - LoadGraphic (RUINS_MASK_PMAP_ANIM) - ); - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = - CaptureStringTable ( - LoadStringTable (DRUUGE_RUINS_STRTAB) - ); - if (GET_GAME_STATE (ROSY_SPHERE)) - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = - SetAbsStringTableIndex ( - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString, - 1 - ); - } - } - default: - GenerateRandomIP (control); - break; - } -} - Added: trunk/sc2/src/uqm/planets/generate/Makeinfo =================================================================== --- trunk/sc2/src/uqm/planets/generate/Makeinfo (rev 0) +++ trunk/sc2/src/uqm/planets/generate/Makeinfo 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,5 @@ +uqm_CFILES="gendefault.c genand.c genburv.c genchmmr.c gencol.c gendru.c + genilw.c genmel.c genmyc.c genorz.c genpet.c genpku.c genrain.c + gensam.c genshof.c gensly.c gensol.c genspa.c gensup.c gensyr.c + genthrad.c gentrap.c genutw.c genvault.c genvux.c genwreck.c + genyeh.c genzfpscout.c genzoq.c" Copied: trunk/sc2/src/uqm/planets/generate/genall.h (from rev 3299, trunk/sc2/src/uqm/planets/genall.h) =================================================================== --- trunk/sc2/src/uqm/planets/generate/genall.h (rev 0) +++ trunk/sc2/src/uqm/planets/generate/genall.h 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,27 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GENALL_H +#define _GENALL_H + +#include "gendefault.h" +#include "types.h" +#include "../generate.h" +#include "libs/compiler.h" + + +#endif /* _GENALL_H */ + Added: trunk/sc2/src/uqm/planets/generate/genand.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genand.c (rev 0) +++ trunk/sc2/src/uqm/planets/generate/genand.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,185 @@ +//Copyright Paul Reiche, Fred Ford. 1992-2002 + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "genall.h" +#include "../lander.h" +#include "../planets.h" +#include "../../globdata.h" +#include "../../nameref.h" +#include "../../resinst.h" +#include "../../sounds.h" +#include "libs/mathlib.h" + + +static bool GenerateAndrosynth_generatePlanets (SOLARSYS_STATE *solarSys); +static bool GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys, + PLANET_DESC *world); +static bool GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, + PLANET_DESC *world, COUNT *whichNode); + + +const GenerateFunctions generateAndrosynthFunctions = { + /* .initNpcs = */ GenerateDefault_initNpcs, + /* .reinitNpcs = */ GenerateDefault_reinitNpcs, + /* .uninitNpcs = */ GenerateDefault_uninitNpcs, + /* .generatePlanets = */ GenerateAndrosynth_generatePlanets, + /* .generateMoons = */ GenerateDefault_generateMoons, + /* .generateName = */ GenerateDefault_generateName, + /* .generateOrbital = */ GenerateAndrosynth_generateOrbital, + /* .generateMinerals = */ GenerateDefault_generateMinerals, + /* .generateEnergy = */ GenerateAndrosynth_generateEnergy, + /* .generateLife = */ GenerateDefault_generateLife, +}; + + +static bool +GenerateAndrosynth_generatePlanets (SOLARSYS_STATE *solarSys) +{ + COUNT angle; + + GenerateDefault_generatePlanets (solarSys); + + solarSys->PlanetDesc[1].data_index = TELLURIC_WORLD; + solarSys->PlanetDesc[1].radius = EARTH_RADIUS * 204L / 100; + angle = ARCTAN (solarSys->PlanetDesc[1].location.x, + solarSys->PlanetDesc[1].location.y); + solarSys->PlanetDesc[1].location.x = + COSINE (angle, solarSys->PlanetDesc[1].radius); + solarSys->PlanetDesc[1].location.y = + SINE (angle, solarSys->PlanetDesc[1].radius); + + return true; +} + +static bool +GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) +{ + if (matchWorld (solarSys, world, 1, MATCH_PLANET)) + { + UWORD retval; + + LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); + solarSys->PlanetSideFrame[1] = + CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); + solarSys->SysInfo.PlanetInfo.DiscoveryString = + CaptureStringTable ( + LoadStringTable (ANDROSYNTH_RUINS_STRTAB)); + retval = HIWORD ( + solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]); + while (retval) + { + if (retval & 1) + { + solarSys->SysInfo.PlanetInfo.DiscoveryString = + SetRelStringTableIndex ( + solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); + if (GetStringTableIndex ( + solarSys->SysInfo.PlanetInfo.DiscoveryString) == 0) + { + DestroyStringTable (ReleaseStringTable ( + solarSys->SysInfo.PlanetInfo.DiscoveryString)); + solarSys->SysInfo.PlanetInfo.DiscoveryString = 0; + } + } + + retval >>= 1; + } + } + + GenerateDefault_generateOrbital (solarSys, world); + + if (matchWorld (solarSys, world, 1, MATCH_PLANET)) + { + solarSys->SysInfo.PlanetInfo.AtmoDensity = + EARTH_ATMOSPHERE * 144 / 100; + solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 28; + solarSys->SysInfo.PlanetInfo.Weather = 1; + solarSys->SysInfo.PlanetInfo.Tectonics = 1; + } + + return true; +} + +static bool +GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, + COUNT *whichNode) +{ + DWORD rand_val; + DWORD old_rand; + + if (matchWorld (solarSys, world, 1, MATCH_PLANET)) + { + COUNT i; + COUNT nodeI; + + old_rand = TFB_SeedRandom ( + solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + + nodeI = 0; + i = 0; + do + { + rand_val = TFB_Random (); + solarSys->SysInfo.PlanetInfo.CurPt.x = + (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; + solarSys->SysInfo.PlanetInfo.CurPt.y = + (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; + solarSys->SysInfo.PlanetInfo.CurType = 0; + solarSys->SysInfo.PlanetInfo.CurDensity = 0; + + if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + & (1L << i)) + { + solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + &= ~(1L << i); + if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + & (1L << (i + 16)))) + { + SET_GAME_STATE (PLANETARY_CHANGE, 1); + + solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + |= (1L << (i + 16)); + if (solarSys->SysInfo.PlanetInfo.DiscoveryString) + { + UnbatchGraphics (); + DoDiscoveryReport (MenuSounds); + BatchGraphics (); + solarSys->SysInfo.PlanetInfo.DiscoveryString = + SetRelStringTableIndex ( + solarSys->SysInfo.PlanetInfo.DiscoveryString, + 1); + } + } + } + + if (nodeI >= *whichNode + && !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + & (1L << i))) + break; + ++nodeI; + } while (++i < 16); + *whichNode = nodeI; + + TFB_SeedRandom (old_rand); + return true; + } + + *whichNode = 0; + return true; +} + Copied: trunk/sc2/src/uqm/planets/generate/genburv.c (from rev 3299, trunk/sc2/src/uqm/planets/genburv.c) =================================================================== --- trunk/sc2/src/uqm/planets/generate/genburv.c (rev 0) +++ trunk/sc2/src/uqm/planets/generate/genburv.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,210 @@ +//Copyright Paul Reiche, Fred Ford. 1992-2002 + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "genall.h" +#include "../planets.h" +#include "../../globdata.h" +#include "../../nameref.h" +#include "../../resinst.h" +#include "libs/mathlib.h" + + +static bool GenerateBurvixese_generatePlanets (SOLARSYS_STATE *solarSys); +static bool GenerateBurvixese_generateMoons (SOLARSYS_STATE *solarSys, + PLANET_DESC *planet); +static bool GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, + PLANET_DESC *world); +static bool GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, + PLANET_DESC *world, COUNT *whichNode); + + +const GenerateFunctions generateBurvixeseFunctions = { + /* .initNpcs = */ GenerateDefault_initNpcs, + /* .reinitNpcs = */ GenerateDefault_reinitNpcs, + /* .uninitNpcs = */ GenerateDefault_uninitNpcs, + /* .generatePlanets = */ GenerateBurvixese_generatePlanets, + /* .generateMoons = */ GenerateBurvixese_generateMoons, + /* .generateName = */ GenerateDefault_generateName, + /* .generateOrbital = */ GenerateBurvixese_generateOrbital, + /* .generateMinerals = */ GenerateDefault_generateMinerals, + /* .generateEnergy = */ GenerateBurvixese_generateEnergy, + /* .generateLife = */ GenerateDefault_generateLife, +}; + + +static bool +GenerateBurvixese_generatePlanets (SOLARSYS_STATE *solarSys) +{ + COUNT angle; + + GenerateDefault_generatePlanets (solarSys); + + solarSys->PlanetDesc[0].data_index = REDUX_WORLD; + solarSys->PlanetDesc[0].NumPlanets = 1; + solarSys->PlanetDesc[0].radius = EARTH_RADIUS * 39L / 100; + angle = ARCTAN (solarSys->PlanetDesc[0].location.x, + solarSys->PlanetDesc[0].location.y); + solarSys->PlanetDesc[0].location.x = + COSINE (angle, solarSys->PlanetDesc[0].radius); + solarSys->PlanetDesc[0].location.y = + SINE (angle, solarSys->PlanetDesc[0].radius); + return true; +} + +static bool +GenerateBurvixese_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet) +{ + GenerateDefault_generateMoons (solarSys, planet); + + if (matchWorld (solarSys, planet, 0, MATCH_PLANET)) + { + COUNT angle; + DWORD rand_val; + + solarSys->MoonDesc[0].data_index = SELENIC_WORLD; + solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + + (MAX_MOONS - 1) * MOON_DELTA; + rand_val = TFB_Random (); + angle = NORMALIZE_ANGLE (LOWORD (rand_val)); + solarSys->MoonDesc[0].location.x = + COSINE (angle, solarSys->MoonDesc[0].radius); + solarSys->MoonDesc[0].location.y = + SINE (angle, solarSys->MoonDesc[0].radius); + } + return true; +} + +static bool +GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) +{ + COUNT i; + DWORD rand_val; + + rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world); + + solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; + i = (COUNT)~0; + rand_val = GenerateLifeForms (&solarSys->SysInfo, &i); + + solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; + i = (COUNT)~0; + GenerateMineralDeposits (&solarSys->SysInfo, &i); + + solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; + + if (matchWorld (solarSys, world, 0, MATCH_PLANET)) + { + LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); + solarSys->PlanetSideFrame[1] = + CaptureDrawable ( + LoadGraphic (RUINS_MASK_PMAP_ANIM)); + solarSys->SysInfo.PlanetInfo.DiscoveryString = + CaptureStringTable ( + LoadStringTable (BURV_RUINS_STRTAB)); + solarSys->SysInfo.PlanetInfo.Weather = 0; + solarSys->SysInfo.PlanetInfo.Tectonics = 0; + } + else if (matchWorld (solarSys, world, 0, 0) + && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) + { + LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); + solarSys->PlanetSideFrame[1] = CaptureDrawable ( + LoadGraphic (BURV_BCS_MASK_PMAP_ANIM)); + solarSys->SysInfo.PlanetInfo.DiscoveryString = + CaptureStringTable (LoadStringTable (BURV_BCS_STRTAB)); + } + + LoadPlanet (NULL); + + return true; +} + +static bool +GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, + COUNT *whichNode) +{ + DWORD rand_val; + DWORD old_rand; + + if (matchWorld (solarSys, world, 0, MATCH_PLANET)) + { + COUNT nodeI; + COUNT i; + + old_rand = TFB_SeedRandom ( + solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + + nodeI = 0; + i = 0; + do + { + rand_val = TFB_Random (); + solarSys->SysInfo.PlanetInfo.CurPt.x = + (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; + solarSys->SysInfo.PlanetInfo.CurPt.y = + (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; + solarSys->SysInfo.PlanetInfo.CurType = 1; + solarSys->SysInfo.PlanetInfo.CurDensity = 0; + if (nodeI >= *whichNode + && !(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + & (1L << i))) + break; + ++nodeI; + } while (++i < 16); + *whichNode = nodeI; + + TFB_SeedRandom (old_rand); + return true; + } + + if (matchWorld (solarSys, world, 0, 0) + && !GET_GAME_STATE (BURVIXESE_BROADCASTERS)) + { + old_rand = TFB_SeedRandom ( + solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + + rand_val = TFB_Random (); + solarSys->SysInfo.PlanetInfo.CurPt.x = + (LOBYTE (LOWORD (rand_val)) % (MAP_WIDTH - (8 << 1))) + 8; + solarSys->SysInfo.PlanetInfo.CurPt.y = + (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; + solarSys->SysInfo.PlanetInfo.CurDensity = 0; + solarSys->SysInfo.PlanetInfo.CurType = 0; + if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + & (1L << 0)) + && *whichNode == (COUNT)~0) + *whichNode = 1; + else + { + *whichNode = 0; + if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] + & (1L << 0)) + { + SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1); + SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1); + } + } + + TFB_SeedRandom (old_rand); + return true; + } + + *whichNode = 0; + return true; +} + Copied: trunk/sc2/src/uqm/planets/generate/genchmmr.c (from rev 3302, trunk/sc2/src/uqm/planets/genchmmr.c) =================================================================== --- trunk/sc2/src/uqm/planets/generate/genchmmr.c (rev 0) +++ trunk/sc2/src/uqm/planets/generate/genchmmr.c 2009-11-21 21:04:45 UTC (rev 3334) @@ -0,0 +1,174 @@ +//Copyright Paul Reiche, Fred Ford. 1992-2002 + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "genall.h" +#include "../lander.h" +#include "../planets.h" +#include "../../build.h" +#include "../../comm.h" +#include "../../globdata.h" +#include "../../nameref.h" +#include "../../setup.h" +#include "../../sounds.h" +#include "../../state.h" +#include "libs/mathlib.h" + +static bool GenerateChmmr_generatePlanets (SOLARSYS_STATE *solarSys); +static bool GenerateChmmr_generateMoons (SOLARSYS_STATE *solarSys, + PLANET_DESC *planet); +static bool GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys, + PLANET_DESC *world); + + +const GenerateFunctions generateChmmrFunctions = { + /* .initNpcs = */ GenerateDefault_initNpcs, + /* .reinitNpcs = */ GenerateDefault_reinitNpcs, + /* .uninitNpcs = */ GenerateDefault_uninitNpcs, + /* .generatePlanets = */ GenerateChmmr_generatePlanets, + /* .generateMoons = */ GenerateChmmr_generateMoons, + /* .generateName = */ GenerateDefault_generateName, + /* .generateOrbital = */ GenerateChmmr_generateOrbital, + /* .generateMinerals = */ GenerateDefault_generateMinerals, + /* .generateEnergy = */ GenerateDefault_generateEnergy, + /* .generateLife = */ GenerateDefault_generateLife, +}; + + +static bool +GenerateChmmr_generatePlanets (SOLARSYS_STATE *solarSys) +{ + GenerateDefault_generatePlanets (solarSys); + + solarSys->PlanetDesc[1].data_index = SAPPHIRE_WORLD; + if (!GET_GAME_STATE (CHMMR_UNLEASHED)) + solarSys->PlanetDesc[1].data_index |= PLANET_SHIELDED; + solarSys->PlanetDesc[1].NumPlanets = 1; + + return true; +} + +static bool +GenerateChmmr_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet) +{ + GenerateDefault_generateMoons (solarSys, planet); + + if (ma... [truncated message content] |
From: <av...@us...> - 2009-11-23 09:50:49
|
Revision: 3344 http://sc2.svn.sourceforge.net/sc2/?rev=3344&view=rev Author: avolkov Date: 2009-11-23 09:50:33 +0000 (Mon, 23 Nov 2009) Log Message: ----------- Correct Chmmr response for what_about_samatra question; bug #1073 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/comm/chmmr/chmmrc.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-22 23:40:56 UTC (rev 3343) +++ trunk/sc2/ChangeLog 2009-11-23 09:50:33 UTC (rev 3344) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Correct Chmmr response when asking about Sa-Matra (bug #1073) - Alex - Refactored universe generation - SvdB - Comm animation processing rewrite, bugs fixed - Alex - Added graphics context debugging function - SvdB Modified: trunk/sc2/src/uqm/comm/chmmr/chmmrc.c =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-22 23:40:56 UTC (rev 3343) +++ trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-23 09:50:33 UTC (rev 3344) @@ -398,7 +398,7 @@ } else if (PLAYER_SAID (R, what_about_samatra)) { - NPCPhrase (ABOUT_SUN_DEVICE); + NPCPhrase (ABOUT_SAMATRA); DISABLE_PHRASE (what_about_samatra); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2009-11-25 03:40:58
|
Revision: 3350 http://sc2.svn.sourceforge.net/sc2/?rev=3350&view=rev Author: mcmartin Date: 2009-11-25 03:40:49 +0000 (Wed, 25 Nov 2009) Log Message: ----------- Improved safemode; --safe option now ignores uqm.cfg entirely. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/build/win32_install/uqm-installer.nsi trunk/sc2/src/uqm.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-25 03:38:49 UTC (rev 3349) +++ trunk/sc2/ChangeLog 2009-11-25 03:40:49 UTC (rev 3350) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Cross-platform safemode (ignores uqm.cfg, bug #946) - Michael - Correct Chmmr response when asking about Sa-Matra (bug #1073) - Alex - Refactored universe generation - SvdB - Comm animation processing rewrite, bugs fixed - Alex Modified: trunk/sc2/build/win32_install/uqm-installer.nsi =================================================================== --- trunk/sc2/build/win32_install/uqm-installer.nsi 2009-11-25 03:38:49 UTC (rev 3349) +++ trunk/sc2/build/win32_install/uqm-installer.nsi 2009-11-25 03:40:49 UTC (rev 3350) @@ -438,8 +438,8 @@ !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory "$SMPROGRAMS\$ICONS_GROUP" CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\The Ur-Quan Masters.lnk" "$INSTDIR\uqm.exe" $UQMARGS - CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\UQM (Safe Mode).lnk" "$INSTDIR\uqm.exe" "-wx -r 640x480 -c none --sound=none -g 1.0 -M 100 -S 100 -T 100 -q medium" - CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\UQM (Safe OpenGL).lnk" "$INSTDIR\uqm.exe" "-wo -r 640x480 -c none --sound=none -g 1.0 -M 100 -S 100 -T 100 -q medium" + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\UQM (Safe Mode).lnk" "$INSTDIR\uqm.exe" "-x --safe" + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\UQM (Safe OpenGL).lnk" "$INSTDIR\uqm.exe" "-o --safe" CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\Documentation" CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Documentation\AUTHORS.lnk" "$INSTDIR\AUTHORS.txt" CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Documentation\COPYING.lnk" "$INSTDIR\COPYING.txt" Modified: trunk/sc2/src/uqm.c =================================================================== --- trunk/sc2/src/uqm.c 2009-11-25 03:38:49 UTC (rev 3349) +++ trunk/sc2/src/uqm.c 2009-11-25 03:40:49 UTC (rev 3350) @@ -125,6 +125,7 @@ DECL_CONFIG_OPTION(float, musicVolumeScale); DECL_CONFIG_OPTION(float, sfxVolumeScale); DECL_CONFIG_OPTION(float, speechVolumeScale); + DECL_CONFIG_OPTION(bool, safeMode); #define INIT_CONFIG_OPTION(name, val) \ { val, false } @@ -257,6 +258,7 @@ INIT_CONFIG_OPTION( musicVolumeScale, 1.0f ), INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ), INIT_CONFIG_OPTION( speechVolumeScale, 1.0f ), + INIT_CONFIG_OPTION( safeMode, false ), }; struct options_struct defaults = options; int optionsResult; @@ -334,8 +336,11 @@ PlayerControls[1] = CONTROL_TEMPLATE_JOY_1; // Fill in the options struct based on uqm.cfg - LoadResourceIndex (configDir, "uqm.cfg", "config."); - getUserConfigOptions (&options); + if (!options.safeMode.value) + { + LoadResourceIndex (configDir, "uqm.cfg", "config."); + getUserConfigOptions (&options); + } { /* remove old control template names */ int i; @@ -673,6 +678,7 @@ ADDON_OPT, ADDONDIR_OPT, ACCEL_OPT, + SAFEMODE_OPT, #ifdef NETPLAY NETHOST1_OPT, NETPORT1_OPT, @@ -719,6 +725,7 @@ {"addon", 1, NULL, ADDON_OPT}, {"addondir", 1, NULL, ADDONDIR_OPT}, {"accel", 1, NULL, ACCEL_OPT}, + {"safe", 0, NULL, SAFEMODE_OPT}, #ifdef NETPLAY {"nethost1", 1, NULL, NETHOST1_OPT}, {"netport1", 1, NULL, NETPORT1_OPT}, @@ -1007,6 +1014,9 @@ } break; } + case SAFEMODE_OPT: + setBoolOption (&options->safeMode, true); + break; #ifdef NETPLAY case NETHOST1_OPT: netplayOptions.peer[0].isServer = false; @@ -1169,6 +1179,7 @@ "mixsdl)"); log_add (log_User, " --stereosfx (enables positional sound effects, " "currently only for openal)"); + log_add (log_User, " --safe (start in safe mode)"); #ifdef NETPLAY log_add (log_User, " --nethostN=HOSTNAME (server to connect to for " "player N (1=bottom, 2=top)"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-29 15:29:46
|
Revision: 3367 http://sc2.svn.sourceforge.net/sc2/?rev=3367&view=rev Author: Meep-Eep Date: 2009-11-29 15:29:38 +0000 (Sun, 29 Nov 2009) Log Message: ----------- All graphics operations use 24-bits colors at the game level too now, instead of 16 bits colors. Using a structure 'Color' instead of 'COLOR' and 'TFB_Palette' now. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/graphics/cmap.c trunk/sc2/src/libs/graphics/cmap.h trunk/sc2/src/libs/graphics/context.c trunk/sc2/src/libs/graphics/context.h trunk/sc2/src/libs/graphics/drawable.c trunk/sc2/src/libs/graphics/font.c trunk/sc2/src/libs/graphics/frame.c trunk/sc2/src/libs/graphics/prim.h trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/tfb_draw.h trunk/sc2/src/libs/graphics/tfb_prim.c trunk/sc2/src/libs/graphics/tfb_prim.h trunk/sc2/src/libs/graphics/widgets.c trunk/sc2/src/libs/graphics/widgets.h trunk/sc2/src/uqm/cnctdlg.c trunk/sc2/src/uqm/colors.h trunk/sc2/src/uqm/comm/arilou/arilouc.c trunk/sc2/src/uqm/comm/blackur/blackurc.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/ilwrath/ilwrathc.c trunk/sc2/src/uqm/comm/melnorm/melnorm.c trunk/sc2/src/uqm/comm/mycon/myconc.c trunk/sc2/src/uqm/comm/orz/orzc.c trunk/sc2/src/uqm/comm/pkunk/pkunkc.c trunk/sc2/src/uqm/comm/rebel/rebel.c trunk/sc2/src/uqm/comm/shofixt/shofixt.c trunk/sc2/src/uqm/comm/slyhome/slyhome.c trunk/sc2/src/uqm/comm/slyland/slyland.c trunk/sc2/src/uqm/comm/spahome/spahome.c trunk/sc2/src/uqm/comm/spathi/spathic.c trunk/sc2/src/uqm/comm/starbas/starbas.c trunk/sc2/src/uqm/comm/supox/supoxc.c trunk/sc2/src/uqm/comm/syreen/syreenc.c trunk/sc2/src/uqm/comm/talkpet/talkpet.c trunk/sc2/src/uqm/comm/thradd/thraddc.c trunk/sc2/src/uqm/comm/umgah/umgahc.c trunk/sc2/src/uqm/comm/urquan/urquanc.c trunk/sc2/src/uqm/comm/utwig/utwigc.c trunk/sc2/src/uqm/comm/vux/vuxc.c trunk/sc2/src/uqm/comm/yehat/yehatc.c trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/confirm.c trunk/sc2/src/uqm/credits.c trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/globdata.h trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/intro.c trunk/sc2/src/uqm/melee.c trunk/sc2/src/uqm/misc.c trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/lander.h 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/pstarmap.c trunk/sc2/src/uqm/planets/roster.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/ships/chmmr/chmmr.c trunk/sc2/src/uqm/ships/ilwrath/ilwrath.c trunk/sc2/src/uqm/ships/orz/orz.c trunk/sc2/src/uqm/ships/pkunk/pkunk.c trunk/sc2/src/uqm/ships/shofixti/shofixti.c trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c trunk/sc2/src/uqm/ships/utwig/utwig.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/starbase.c trunk/sc2/src/uqm/status.c trunk/sc2/src/uqm/tactrans.c trunk/sc2/src/uqm/uqmdebug.c trunk/sc2/src/uqm/util.c trunk/sc2/src/uqm/util.h trunk/sc2/src/uqm/weapon.h Removed Paths: ------------- trunk/sc2/src/libs/graphics/gfxother.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/ChangeLog 2009-11-29 15:29:38 UTC (rev 3367) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- All graphics operations use 24-bits colors at the game level too now, + instead of 16 bits colors. - SvdB - Cross-platform safemode (ignores uqm.cfg, bug #946) - Michael - Correct Chmmr response when asking about Sa-Matra (bug #1073) - Alex - Refactored universe generation - SvdB Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-11-29 15:29:38 UTC (rev 3367) @@ -481,10 +481,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\gfxother.h -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\intersec.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/gfxlib.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -38,12 +38,36 @@ #define MAX_TIME_VALUE ((1 << TIME_SHIFT) + 1) typedef SWORD COORD; -typedef DWORD COLOR; -#define BUILD_COLOR(c32k,c256) \ - (COLOR)(((DWORD)(c32k)<<8)|(BYTE)(c256)) - // BUILD_COLOR combines a 15-bit RGB color tripple with a +typedef struct Color { + BYTE r; + BYTE g; + BYTE b; + BYTE a; // Currently unused +} Color; + +static inline bool +sameColor(Color c1, Color c2) +{ + return c1.r == c2.r && + c1.g == c2.g && + c1.b == c2.b && + c1.a == c2.a; +} + +// Transform a 5-bits color component to an 8-bits color component. +// Form 1, calculates '(r5 / 31.0) * 255.0, highest value is 0xff: +#define CC5TO8(c) (((c) << 3) | ((c) >> 2)) +// Form 2, calculates '(r5 / 32.0) * 256.0, highest value is 0xf8: +//#define CC5TO8(c) ((c) << 3) + +#define BUILD_COLOR(col, c256) col + // BUILD_COLOR used to combine a 15-bit RGB color tripple with a // destination VGA palette index into a 32-bit value. + // Now, it is an empty wrapper which returns the first argument, + // which is of type Color, and ignores the second argument, + // the palette index. + // // It is a remnant of 8bpp hardware paletted display (VGA). // The palette index would be overwritten with the RGB value // and the drawing op would use this index on screen. @@ -54,11 +78,57 @@ // the standard ones (see colors.h; most likely unchanged from SC1) // The palette index is meaningless in UQM for the most part. // New code should just use index 0. -#define COLOR_32k(c) (UWORD)((COLOR)(c)>>8) -#define COLOR_256(c) LOBYTE((COLOR)c) -#define MAKE_RGB15(r,g,b) (UWORD)(((r)<<10)|((g)<<5)|(b)) -#define BUILD_COLOR_RGBA(r,g,b,a) (DWORD)(((r)<<24)|((g)<<16)|((b)<<8)|(a)) +// Turn a 15 bits color into a 24-bits color. +// r, g, and b are each 5-bits color components. +static inline Color +colorFromRgb15 (BYTE r, BYTE g, BYTE b) +{ + Color c; + c.r = CC5TO8 (r); + c.g = CC5TO8 (g); + c.b = CC5TO8 (b); + c.a = 0; + + return c; +} +#define MAKE_RGB15(r, g, b) colorFromRgb15 ((r), (g), (b)) + +#ifdef NOTYET /* Need C'99 support */ +#define MAKE_RGB15(r, g, b) (Color) { \ + .r = CC5TO8 (r), \ + .g = CC5TO8 (g), \ + .b = CC5TO8 (b), \ + .a = 0 \ + } +#endif + +// Temporary, until we can use C'99 features. Then MAKE_RGB15 will be usable +// anywhere. +// This define is intended for global initialisations, where the +// expression must be constant. +#define MAKE_RGB15_INIT(r, g, b) { \ + CC5TO8 (r), \ + CC5TO8 (g), \ + CC5TO8 (b), \ + 0 \ + } + +static inline Color +buildColorRgba (BYTE r, BYTE g, BYTE b, BYTE a) +{ + Color c; + c.r = r; + c.g = g; + c.b = b; + c.a = a; + + return c; +} +#define BUILD_COLOR_RGBA(r, g, b, a) \ + buildColorRgba ((r), (g), (b), (a)) + + typedef BYTE CREATE_FLAGS; #define WANT_MASK (CREATE_FLAGS)(1 << 0) #define WANT_PIXMAP (CREATE_FLAGS)(1 << 1) @@ -168,10 +238,10 @@ extern void UninitGraphics (void); extern CONTEXT SetContext (CONTEXT Context); -extern COLOR SetContextForeGroundColor (COLOR Color); -extern COLOR GetContextForeGroundColor (void); -extern COLOR SetContextBackGroundColor (COLOR Color); -extern COLOR GetContextBackGroundColor (void); +extern Color SetContextForeGroundColor (Color Color); +extern Color GetContextForeGroundColor (void); +extern Color SetContextBackGroundColor (Color Color); +extern Color GetContextBackGroundColor (void); extern FRAME SetContextFGFrame (FRAME Frame); extern FRAME GetContextFGFrame (void); extern BOOLEAN SetContextClipping (BOOLEAN ClipStatus); @@ -186,7 +256,7 @@ extern void DrawFilledRectangle (RECT *pRect); extern void DrawLine (LINE *pLine); extern void font_DrawText (TEXT *pText); -extern void font_DrawTracedText (TEXT *pText, COLOR text, COLOR trace); +extern void font_DrawTracedText (TEXT *pText, Color text, Color trace); extern void DrawBatch (PRIMITIVE *pBasePrim, PRIM_LINKS PrimLinks, BATCH_FLAGS BatchFlags); extern void BatchGraphics (void); @@ -236,7 +306,7 @@ extern FRAME IncFrameIndex (FRAME Frame); extern FRAME DecFrameIndex (FRAME Frame); extern DRAWABLE RotateFrame (FRAME Frame, int angle_deg); -extern void SetFrameTransparentColor (FRAME Frame, COLOR c32k); +extern void SetFrameTransparentColor (FRAME Frame, Color c32k); extern FRAME CaptureDrawable (DRAWABLE Drawable); extern DRAWABLE ReleaseDrawable (FRAME Frame); Modified: trunk/sc2/src/libs/graphics/cmap.c =================================================================== --- trunk/sc2/src/libs/graphics/cmap.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/cmap.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -41,7 +41,7 @@ SIZE Ticks; DWORD StartTime; DWORD EndTime; - TFB_Palette OldCMap[NUMBER_OF_PLUTVALS]; + Color OldCMap[NUMBER_OF_PLUTVALS]; } XFORM_CONTROL; #define MAX_XFORMS 16 @@ -225,7 +225,7 @@ } void -TFB_ColorMapToRGB (TFB_Palette *pal, int index) +TFB_ColorMapToRGB (Color *pal, int index) { TFB_ColorMap *map = NULL; @@ -239,7 +239,7 @@ return; } - memcpy (pal, map->colors, sizeof (map->colors)); + memcpy (pal, map->colors, sizeof map->colors); } BOOLEAN @@ -288,7 +288,7 @@ for (mpp = colormaps + start; start <= end; ++start, ++mpp) { int i; - TFB_Palette *pal; + Color *pal; TFB_ColorMap *newmap; TFB_ColorMap *oldmap; @@ -464,7 +464,7 @@ #define XFORM_SCALE 0x10000 TFB_ColorMap *newmap = NULL; UBYTE *pNewCMap; - TFB_Palette *pCurCMap, *pOldCMap; + Color *pCurCMap, *pOldCMap; int frac; int i; @@ -480,16 +480,16 @@ for (i = 0; i < NUMBER_OF_PLUTVALS; i++, ++pCurCMap, ++pOldCMap) { - pCurCMap->r = (UBYTE)(pOldCMap->r + ((int)*pNewCMap - pOldCMap->r) - * frac / XFORM_SCALE); + pCurCMap->r = (UBYTE)(pOldCMap->r + + ((int)*pNewCMap - pOldCMap->r) * frac / XFORM_SCALE); pNewCMap++; - pCurCMap->g = (UBYTE)(pOldCMap->g + ((int)*pNewCMap - pOldCMap->g) - * frac / XFORM_SCALE); + pCurCMap->g = (UBYTE)(pOldCMap->g + + ((int)*pNewCMap - pOldCMap->g) * frac / XFORM_SCALE); pNewCMap++; - pCurCMap->b = (UBYTE)(pOldCMap->b + ((int)*pNewCMap - pOldCMap->b) - * frac / XFORM_SCALE); + pCurCMap->b = (UBYTE)(pOldCMap->b + + ((int)*pNewCMap - pOldCMap->b) * frac / XFORM_SCALE); pNewCMap++; } Modified: trunk/sc2/src/libs/graphics/cmap.h =================================================================== --- trunk/sc2/src/libs/graphics/cmap.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/cmap.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -40,7 +40,7 @@ typedef struct tfb_colormap { - TFB_Palette colors[NUMBER_OF_PLUTVALS]; + Color colors[NUMBER_OF_PLUTVALS]; int index; int version; int refcount; @@ -52,7 +52,7 @@ extern void InitColorMaps (void); extern void UninitColorMaps (void); -extern void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index); +extern void TFB_ColorMapToRGB (Color *pal, int colormap_index); extern TFB_ColorMap * TFB_GetColorMap (int index); extern void TFB_ReturnColorMap (TFB_ColorMap *map); Modified: trunk/sc2/src/libs/graphics/context.c =================================================================== --- trunk/sc2/src/libs/graphics/context.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/context.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -17,7 +17,6 @@ */ #include "gfxintrn.h" -#include "gfxother.h" GRAPHICS_STATUS _GraphicsStatusFlags; CONTEXT _pCurContext; @@ -145,30 +144,30 @@ return TRUE; } -COLOR -SetContextForeGroundColor (COLOR Color) +Color +SetContextForeGroundColor (Color color) { - COLOR oldColor; + Color oldColor; if (!ContextActive ()) return (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); oldColor = _get_context_fg_color (); - if (oldColor != Color) + if (!sameColor(oldColor, color)) { - SwitchContextForeGroundColor (Color); + SwitchContextForeGroundColor (color); if (!(_get_context_fbk_flags () & FBK_IMAGE)) { SetContextFBkFlags (FBK_DIRTY); } } - SetPrimColor (&_locPrim, Color); + SetPrimColor (&_locPrim, color); return (oldColor); } -COLOR +Color GetContextForeGroundColor (void) { if (!ContextActive ()) @@ -177,22 +176,22 @@ return _get_context_fg_color (); } -COLOR -SetContextBackGroundColor (COLOR Color) +Color +SetContextBackGroundColor (Color color) { - COLOR oldColor; + Color oldColor; if (!ContextActive ()) return (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); oldColor = _get_context_bg_color (); - if (oldColor != Color) - SwitchContextBackGroundColor (Color); + if (!sameColor(oldColor, color)) + SwitchContextBackGroundColor (color); - return (oldColor); + return oldColor; } -COLOR +Color GetContextBackGroundColor (void) { if (!ContextActive ()) @@ -301,10 +300,9 @@ } else { // solid color backing - TFB_Palette color; RECT r = { {0, 0}, {w, h} }; + Color color = _get_context_fg_color (); - COLORtoPalette (_get_context_fg_color (), &color); TFB_DrawImage_Rect (&r, color.r, color.g, color.b, img); } Modified: trunk/sc2/src/libs/graphics/context.h =================================================================== --- trunk/sc2/src/libs/graphics/context.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/context.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,7 +30,7 @@ { UWORD Flags; - COLOR ForeGroundColor, BackGroundColor; + Color ForeGroundColor, BackGroundColor; FRAME ForeGroundFrame; FONT Font; Modified: trunk/sc2/src/libs/graphics/drawable.c =================================================================== --- trunk/sc2/src/libs/graphics/drawable.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/drawable.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -19,7 +19,6 @@ #include "gfxintrn.h" #include "libs/memlib.h" #include "tfb_draw.h" -#include "gfxother.h" #include <math.h> #ifndef M_PI @@ -251,12 +250,10 @@ return Drawable; } +// color.a is ignored void -SetFrameTransparentColor (FRAME Frame, COLOR c32k) +SetFrameTransparentColor (FRAME Frame, Color color) { - TFB_Palette color; - - COLORtoPalette (c32k, &color); TFB_DrawCanvas_SetTransparentColor (Frame->image->NormalImg, color.r, color.g, color.b, FALSE); } Modified: trunk/sc2/src/libs/graphics/font.c =================================================================== --- trunk/sc2/src/libs/graphics/font.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/font.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -18,7 +18,6 @@ #include "gfxintrn.h" #include "tfb_prim.h" -#include "gfxother.h" #include "libs/log.h" extern void FixContextFontEffect (void); @@ -64,10 +63,10 @@ * background color one pixel shifted to all 4 directions. */ void -font_DrawTracedText (TEXT *pText, COLOR text, COLOR trace) +font_DrawTracedText (TEXT *pText, Color text, Color trace) { // Preserve current foreground color for full correctness - COLOR oldfg = SetContextForeGroundColor (trace); + Color oldfg = SetContextForeGroundColor (trace); pText->baseline.x--; font_DrawText (pText); pText->baseline.x += 2; @@ -235,7 +234,6 @@ const unsigned char *pStr; TEXT *TextPtr; POINT origin; - TFB_Palette color; TFB_Image *backing; FontPtr = _CurFontPtr; @@ -245,8 +243,6 @@ if (!backing) return; - COLORtoPalette (_get_context_fg_color (), &color); - TextPtr = &PrimPtr->Object.Text; origin.x = _save_stamp.origin.x; origin.y = TextPtr->baseline.y; Modified: trunk/sc2/src/libs/graphics/frame.c =================================================================== --- trunk/sc2/src/libs/graphics/frame.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/frame.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -20,7 +20,6 @@ #include "gfx_common.h" #include "tfb_draw.h" #include "tfb_prim.h" -#include "gfxother.h" HOT_SPOT MAKE_HOT_SPOT (COORD x, COORD y) @@ -45,7 +44,7 @@ { PRIM_LINKS Links; GRAPHICS_PRIM Type; - COLOR Color; + Color Color; INTERNAL_PRIM_DESC Object; } INTERNAL_PRIMITIVE; @@ -84,10 +83,8 @@ void ClearBackGround (RECT *pClipRect) { - TFB_Palette color; - - COLORtoPalette (_get_context_bg_color (), &color); - TFB_Prim_FillRect (pClipRect, &color); + Color color = _get_context_bg_color (); + TFB_Prim_FillRect (pClipRect, color); } void @@ -103,9 +100,7 @@ PRIM_LINKS OldLinks; PRIMITIVE *lpPrim; - BatchFlags &= BATCH_SINGLE - | BATCH_BUILD_PAGE - | BATCH_XFORM; + BatchFlags &= BATCH_SINGLE | BATCH_BUILD_PAGE | BATCH_XFORM; BatchFlags |= _get_context_flags () & BATCH_CLIP_GRAPHICS; @@ -131,12 +126,13 @@ } } - for (; CurIndex != END_OF_LIST; CurIndex = GetSuccLink (GetPrimLinks (lpPrim))) + for (; CurIndex != END_OF_LIST; + CurIndex = GetSuccLink (GetPrimLinks (lpPrim))) { GRAPHICS_PRIM PrimType; PRIMITIVE *lpWorkPrim; RECT ClipRect; - TFB_Palette color; + Color color; lpPrim = &lpBasePrim[CurIndex]; PrimType = GetPrimType (lpPrim); @@ -148,19 +144,19 @@ switch (PrimType) { case POINT_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_Point (&lpWorkPrim->Object.Point, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_Point (&lpWorkPrim->Object.Point, color); break; case STAMP_PRIM: TFB_Prim_Stamp (&lpWorkPrim->Object.Stamp); break; case STAMPFILL_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_StampFill (&lpWorkPrim->Object.Stamp, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_StampFill (&lpWorkPrim->Object.Stamp, color); break; case LINE_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_Line (&lpWorkPrim->Object.Line, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_Line (&lpWorkPrim->Object.Line, color); break; case TEXT_PRIM: if (!TextRect (&lpWorkPrim->Object.Text, @@ -172,12 +168,12 @@ _text_blt (&ClipRect, lpWorkPrim); break; case RECT_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_Rect (&lpWorkPrim->Object.Rect, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_Rect (&lpWorkPrim->Object.Rect, color); break; case RECTFILL_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, color); break; } } @@ -188,9 +184,7 @@ if (BatchFlags & BATCH_SINGLE) SetPrimLinks (lpBasePrim, - GetPredLink (OldLinks), - GetSuccLink (OldLinks)); - + GetPredLink (OldLinks), GetSuccLink (OldLinks)); } } @@ -218,10 +212,8 @@ if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_Point (lpPoint, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_Point (lpPoint, color); _CurFramePtr->HotSpot = OldHot; } } @@ -234,10 +226,8 @@ if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_Rect (lpRect, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_Rect (lpRect, color); _CurFramePtr->HotSpot = OldHot; } } @@ -250,10 +240,8 @@ if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_FillRect (lpRect, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_FillRect (lpRect, color); _CurFramePtr->HotSpot = OldHot; } } @@ -266,12 +254,10 @@ if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_Line (lpLine, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_Line (lpLine, color); _CurFramePtr->HotSpot = OldHot; - } + } } void @@ -295,10 +281,9 @@ if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_StampFill (stmp, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_StampFill (stmp, color); _CurFramePtr->HotSpot = OldHot; } } + Deleted: trunk/sc2/src/libs/graphics/gfxother.h =================================================================== --- trunk/sc2/src/libs/graphics/gfxother.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/gfxother.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -1,32 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef GFXOTHER_H -#define GFXOTHER_H - -#include "gfxintrn.h" -#include "tfb_draw.h" - -static inline void -COLORtoPalette (DWORD c32k, TFB_Palette* color) -{ - c32k >>= 8; // shift out color index - color->r = (UBYTE)((c32k >> (10 - (8 - 5))) & 0xF8); - color->g = (UBYTE)((c32k >> (5 - (8 - 5))) & 0xF8); - color->b = (UBYTE)((c32k << (8 - 5)) & 0xF8); -} - -#endif /* GFXOTHER */ Modified: trunk/sc2/src/libs/graphics/prim.h =================================================================== --- trunk/sc2/src/libs/graphics/prim.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/prim.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -45,7 +45,7 @@ { PRIM_LINKS Links; GRAPHICS_PRIM Type; - COLOR Color; + Color color; PRIM_DESC Object; } PRIMITIVE; @@ -58,8 +58,8 @@ #define GetPrimLinks(pPrim) ((pPrim)->Links) #define SetPrimType(pPrim,t) ((pPrim)->Type = t) #define GetPrimType(pPrim) ((pPrim)->Type) -#define SetPrimColor(pPrim,c) ((pPrim)->Color = c) -#define GetPrimColor(pPrim) ((pPrim)->Color) +#define SetPrimColor(pPrim,c) ((pPrim)->color = c) +#define GetPrimColor(pPrim) ((pPrim)->color) static inline void SetPrimNextLink (PRIMITIVE *pPrim, COUNT Link) Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -84,7 +84,7 @@ { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; - TFB_Palette* palette; + Color *palette; if (img == 0) { @@ -483,7 +483,8 @@ } TFB_Canvas -TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index) +TFB_DrawCanvas_New_Paletted (int w, int h, Color *palette, + int transparent_index) { SDL_Surface *new_surf; new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 8, 0, 0, 0, 0); @@ -589,7 +590,7 @@ log_add (log_Warning, "INTERNAL PANIC: Attempted" " to delete a NULL canvas!"); /* Should we actually die here? */ - } + } else { SDL_FreeSurface ((SDL_Surface *) canvas); @@ -597,11 +598,11 @@ } -TFB_Palette * +Color * TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas) { int i; - TFB_Palette *result; + Color *result; SDL_Surface *surf = (SDL_Surface *)canvas; @@ -610,7 +611,7 @@ return NULL; } - result = (TFB_Palette*) HMalloc (sizeof (TFB_Palette) * 256); + result = (Color *) HMalloc (sizeof (Color) * 256); for (i = 0; i < 256; ++i) { result[i].r = surf->format->palette->colors[i].r; @@ -650,7 +651,7 @@ } void -TFB_DrawCanvas_SetPalette (TFB_Canvas target, TFB_Palette *palette) +TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color *palette) { SDL_SetColors ((SDL_Surface *)target, (SDL_Color *)palette, 0, 256); } @@ -722,7 +723,8 @@ } void -TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, BOOLEAN rleaccel) +TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, + BOOLEAN rleaccel) { Uint32 color; int flags = SDL_SRCCOLORKEY; Modified: trunk/sc2/src/libs/graphics/tfb_draw.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/tfb_draw.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -32,14 +32,6 @@ TFB_GFX_NUMSCREENS } SCREEN; -typedef struct tfb_palette -{ - UBYTE r; - UBYTE g; - UBYTE b; - UBYTE unused; -} TFB_Palette; - #include "libs/graphics/gfx_common.h" #include "cmap.h" @@ -49,7 +41,7 @@ TFB_Canvas ScaledImg; TFB_Canvas MipmapImg; TFB_Canvas FilledImg; - TFB_Palette *Palette; + Color *Palette; int colormap_index; int colormap_version; HOT_SPOT NormalHs; @@ -57,7 +49,7 @@ HOT_SPOT last_scale_hs; int last_scale; int last_scale_type; - TFB_Palette last_fill; + Color last_fill; EXTENT extent; Mutex mutex; BOOLEAN dirty; @@ -87,15 +79,20 @@ // Drawing commands -void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest); +void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + SCREEN dest); void TFB_DrawScreen_Rect (RECT *rect, int r, int g, int b, SCREEN dest); -void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, SCREEN dest); +void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, + TFB_ColorMap *cmap, SCREEN dest); void TFB_DrawScreen_Copy (RECT *r, SCREEN src, SCREEN dest); -void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, SCREEN dest); -void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, SCREEN dest); +void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, + int r, int g, int b, SCREEN dest); +void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, + SCREEN dest); void TFB_DrawScreen_CopyToImage (TFB_Image *img, RECT *lpRect, SCREEN src); -void TFB_DrawScreen_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, int hoty); +void TFB_DrawScreen_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, + int hoty); void TFB_DrawScreen_DeleteImage (TFB_Image *img); void TFB_DrawScreen_DeleteData (void *); void TFB_DrawScreen_WaitForSignal (void); @@ -105,20 +102,27 @@ TFB_Image *TFB_DrawImage_New (TFB_Canvas canvas); TFB_Image *TFB_DrawImage_CreateForScreen (int w, int h, BOOLEAN withalpha); TFB_Image *TFB_DrawImage_New_Rotated (TFB_Image *img, int angle); -void TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, int hoty); +void TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, + int hoty); void TFB_DrawImage_Delete (TFB_Image *image); void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type); -void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Image *dest); +void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + TFB_Image *dest); void TFB_DrawImage_Rect (RECT *rect, int r, int g, int b, TFB_Image *image); -void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, TFB_Image *target); -void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Image *target); -void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Image *target); +void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, + TFB_ColorMap *cmap, TFB_Image *target); +void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, + int r, int g, int b, TFB_Image *target); +void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, + TFB_Image *target); TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha); TFB_Canvas TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha); -TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index); -TFB_Canvas TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, TFB_Canvas oldcanvas, int type, int last_type); +TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, Color *palette, + int transparent_index); +TFB_Canvas TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, + TFB_Canvas oldcanvas, int type, int last_type); TFB_Canvas TFB_DrawCanvas_New_RotationTarget (TFB_Canvas src, int angle); TFB_Canvas TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas); BOOLEAN TFB_DrawCanvas_IsPaletted (TFB_Canvas canvas); @@ -132,24 +136,32 @@ void TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, HOT_SPOT* src_hs, TFB_Canvas src_mipmap, HOT_SPOT* mm_hs, int scale, int type, EXTENT *size, HOT_SPOT *hs); -void TFB_DrawCanvas_Rotate (TFB_Canvas src, TFB_Canvas dst, int angle, EXTENT size); +void TFB_DrawCanvas_Rotate (TFB_Canvas src, TFB_Canvas dst, int angle, + EXTENT size); void TFB_DrawCanvas_GetRotatedExtent (TFB_Canvas src, int angle, EXTENT *size); void TFB_DrawCanvas_GetExtent (TFB_Canvas canvas, EXTENT *size); void TFB_DrawCanvas_Delete (TFB_Canvas canvas); -void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Canvas dest); +void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + TFB_Canvas dest); void TFB_DrawCanvas_Rect (RECT *rect, int r, int g, int b, TFB_Canvas image); -void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, TFB_Canvas target); -void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Canvas target); -void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Canvas target); +void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, + TFB_ColorMap *cmap, TFB_Canvas target); +void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, + int r, int g, int b, TFB_Canvas target); +void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, + TFB_Canvas target); -TFB_Palette *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas); -void TFB_DrawCanvas_SetPalette (TFB_Canvas target, TFB_Palette *palette); +Color *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas); +void TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color *palette); int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas); -void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, BOOLEAN rleaccel); -BOOLEAN TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, int *r, int *g, int *b); -void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, BOOLEAN rleaccel); +void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, + BOOLEAN rleaccel); +BOOLEAN TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, + int *r, int *g, int *b); +void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, + int r, int g, int b, BOOLEAN rleaccel); void TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src, TFB_Canvas dst); void TFB_DrawCanvas_Initialize (void); void TFB_DrawCanvas_Lock (TFB_Canvas canvas); @@ -157,8 +169,10 @@ void TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt); int TFB_DrawCanvas_GetStride (TFB_Canvas canvas); void *TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line); -void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, int *r, int *g, int *b); +void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, + int *r, int *g, int *b); TFB_Canvas TFB_GetScreenCanvas (SCREEN screen); #endif + Modified: trunk/sc2/src/libs/graphics/tfb_prim.c =================================================================== --- trunk/sc2/src/libs/graphics/tfb_prim.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/tfb_prim.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -29,7 +29,7 @@ #include "libs/log.h" void -TFB_Prim_Point (POINT *p, TFB_Palette *color) +TFB_Prim_Point (POINT *p, Color color) { RECT r; @@ -38,13 +38,14 @@ r.extent.width = r.extent.height = 1; if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Rect (&r, color->r, color->g, color->b, TFB_SCREEN_MAIN); + TFB_DrawScreen_Rect (&r, color.r, color.g, color.b, TFB_SCREEN_MAIN); else - TFB_DrawImage_Rect (&r, color->r, color->g, color->b, _CurFramePtr->image); + TFB_DrawImage_Rect (&r, color.r, color.g, color.b, + _CurFramePtr->image); } void -TFB_Prim_Rect (RECT *r, TFB_Palette *color) +TFB_Prim_Rect (RECT *r, Color color) { RECT arm; int gscale; @@ -69,7 +70,7 @@ } void -TFB_Prim_FillRect (RECT *r, TFB_Palette *color) +TFB_Prim_FillRect (RECT *r, Color color) { RECT rect; int gscale; @@ -93,13 +94,15 @@ } if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Rect (&rect, color->r, color->g, color->b, TFB_SCREEN_MAIN); + TFB_DrawScreen_Rect (&rect, color.r, color.g, color.b, + TFB_SCREEN_MAIN); else - TFB_DrawImage_Rect (&rect, color->r, color->g, color->b, _CurFramePtr->image); + TFB_DrawImage_Rect (&rect, color.r, color.g, color.b, + _CurFramePtr->image); } void -TFB_Prim_Line (LINE *line, TFB_Palette *color) +TFB_Prim_Line (LINE *line, Color color) { int x1, y1, x2, y2; @@ -109,9 +112,11 @@ y2=line->second.y - _CurFramePtr->HotSpot.y; if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Line (x1, y1, x2, y2, color->r, color->g, color->b, TFB_SCREEN_MAIN); + TFB_DrawScreen_Line (x1, y1, x2, y2, color.r, color.g, color.b, + TFB_SCREEN_MAIN); else - TFB_DrawImage_Line (x1, y1, x2, y2, color->r, color->g, color->b, _CurFramePtr->image); + TFB_DrawImage_Line (x1, y1, x2, y2, color.r, color.g, color.b, + _CurFramePtr->image); } void @@ -164,7 +169,7 @@ } void -TFB_Prim_StampFill (STAMP *stmp, TFB_Palette *color) +TFB_Prim_StampFill (STAMP *stmp, Color color) { int x, y; FRAME SrcFramePtr; @@ -194,9 +199,9 @@ x = stmp->origin.x - _CurFramePtr->HotSpot.x; y = stmp->origin.y - _CurFramePtr->HotSpot.y; - r = color->r; - g = color->g; - b = color->b; + r = color.r; + g = color.g; + b = color.b; UnlockMutex (img->mutex); Modified: trunk/sc2/src/libs/graphics/tfb_prim.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_prim.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/tfb_prim.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -20,10 +20,11 @@ #include "tfb_draw.h" -void TFB_Prim_Line (LINE *line, TFB_Palette *color); -void TFB_Prim_Point (POINT *p, TFB_Palette *color); -void TFB_Prim_Rect (RECT *r, TFB_Palette *color); -void TFB_Prim_FillRect (RECT *r, TFB_Palette *color); +void TFB_Prim_Line (LINE *line, Color color); +void TFB_Prim_Point (POINT *p, Color color); +void TFB_Prim_Rect (RECT *r, Color color); +void TFB_Prim_FillRect (RECT *r, Color color); void TFB_Prim_Stamp (STAMP *stamp); -void TFB_Prim_StampFill (STAMP *stamp, TFB_Palette *color); -void TFB_Prim_FontChar (POINT *origin, TFB_Char *, TFB_Image *backing); +void TFB_Prim_StampFill (STAMP *stamp, Color color); +void TFB_Prim_FontChar (POINT *origin, TFB_Char *fontChar, + TFB_Image *backing); Modified: trunk/sc2/src/libs/graphics/widgets.c =================================================================== --- trunk/sc2/src/libs/graphics/widgets.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/widgets.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -34,17 +34,20 @@ #define WIDGET_DIALOG_TEXT_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) -static COLOR win_bg_clr = BUILD_COLOR (MAKE_RGB15 (0x18, 0x18, 0x1F), 0x00); -static COLOR win_medium_clr = BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x18), 0x00); -static COLOR win_dark_clr = BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x10), 0x00); +static Color win_bg_clr = + BUILD_COLOR (MAKE_RGB15_INIT (0x18, 0x18, 0x1F), 0x00); +static Color win_medium_clr = + BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x18), 0x00); +static Color win_dark_clr = + BUILD_COLOR (MAKE_RGB15_INIT (0x08, 0x08, 0x10), 0x00); static FONT cur_font; void -DrawShadowedBox (RECT *r, COLOR bg, COLOR dark, COLOR medium) +DrawShadowedBox (RECT *r, Color bg, Color dark, Color medium) { RECT t; - COLOR oldcolor; + Color oldcolor; BatchGraphics (); @@ -84,7 +87,7 @@ void DrawLabelAsWindow (WIDGET_LABEL *label, RECT *windowRect) { - COLOR oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); + Color oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; @@ -144,7 +147,7 @@ } void -Widget_SetWindowColors (COLOR bg, COLOR dark, COLOR medium) +Widget_SetWindowColors (Color bg, Color dark, Color medium) { win_bg_clr = bg; win_dark_clr = dark; @@ -165,7 +168,7 @@ RECT r; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); - COLOR oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); + Color oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); TEXT t; int i; @@ -199,8 +202,8 @@ Widget_DrawMenuScreen (WIDGET *_self, int x, int y) { RECT r; - COLOR title, oldtext; - COLOR inactive, default_color, selected; + Color title, oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -265,8 +268,8 @@ Widget_DrawChoice (WIDGET *_self, int x, int y) { WIDGET_CHOICE *self = (WIDGET_CHOICE *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -299,7 +302,8 @@ t.align = ALIGN_CENTER; for (i = 0; i < self->numopts; i++) { - t.baseline.x = home_x + ((i % 3) * (ScreenWidth / (self->maxcolumns + 1))); + t.baseline.x = home_x + ((i % 3) * + (ScreenWidth / (self->maxcolumns + 1))); t.baseline.y = home_y + (8 * (i / 3)); t.pStr = self->options[i].optname; if ((widget_focus == _self) && @@ -307,7 +311,7 @@ { SetContextForeGroundColor (selected); Widget_DrawToolTips (3, self->options[i].tooltip); - } + } else if (i == self->selected) { SetContextForeGroundColor (default_color); @@ -328,8 +332,8 @@ Widget_DrawButton (WIDGET *_self, int x, int y) { WIDGET_BUTTON *self = (WIDGET_BUTTON *)_self; - COLOR oldtext; - COLOR inactive, selected; + Color oldtext; + Color inactive, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -366,7 +370,7 @@ Widget_DrawLabel (WIDGET *_self, int x, int y) { WIDGET_LABEL *self = (WIDGET_LABEL *)_self; - COLOR oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); + Color oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -397,8 +401,8 @@ Widget_DrawSlider(WIDGET *_self, int x, int y) { WIDGET_SLIDER *self = (WIDGET_SLIDER *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -470,8 +474,8 @@ Widget_DrawTextEntry (WIDGET *_self, int x, int y) { WIDGET_TEXTENTRY *self = (WIDGET_TEXTENTRY *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -607,8 +611,8 @@ Widget_DrawControlEntry (WIDGET *_self, int x, int y) { WIDGET_CONTROLENTRY *self = (WIDGET_CONTROLENTRY *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; Modified: trunk/sc2/src/libs/graphics/widgets.h =================================================================== --- trunk/sc2/src/libs/graphics/widgets.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/libs/graphics/widgets.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -175,9 +175,9 @@ char controlname[2][WIDGET_CONTROLENTRY_WIDTH]; } WIDGET_CONTROLENTRY; -void DrawShadowedBox (RECT *r, COLOR bg, COLOR dark, COLOR medium); +void DrawShadowedBox (RECT *r, Color bg, Color dark, Color medium); void DrawLabelAsWindow (WIDGET_LABEL *label, RECT *windowRect); -void Widget_SetWindowColors (COLOR bg, COLOR dark, COLOR medium); +void Widget_SetWindowColors (Color bg, Color dark, Color medium); FONT Widget_SetFont (FONT newFont); Modified: trunk/sc2/src/uqm/cnctdlg.c =================================================================== --- trunk/sc2/src/uqm/cnctdlg.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/cnctdlg.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -94,8 +94,8 @@ MCD_DrawButton (WIDGET *_self, int x, int y) { WIDGET_BUTTON *self = (WIDGET_BUTTON *)_self; - COLOR oldtext; - COLOR inactive, selected; + Color oldtext; + Color inactive, selected; FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -127,8 +127,8 @@ MCD_DrawSlider (WIDGET *_self, int x, int y) { WIDGET_SLIDER *self = (WIDGET_SLIDER *)_self; - COLOR oldtext; - COLOR default_color, selected; + Color oldtext; + Color default_color, selected; FONT oldfont = SetContextFont (PlayerFont); FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -177,8 +177,8 @@ MCD_DrawTextEntry (WIDGET *_self, int x, int y) { WIDGET_TEXTENTRY *self = (WIDGET_TEXTENTRY *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = SetContextFont (PlayerFont); FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; Modified: trunk/sc2/src/uqm/colors.h =================================================================== --- trunk/sc2/src/uqm/colors.h 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/colors.h 2009-11-29 15:29:38 UTC (rev 3367) @@ -16,6 +16,12 @@ #ifndef _COLORS_H #define _COLORS_H +// To be used as an indicator that the actual value of the color does not +// matter, for instance in structure initialisations for fields which +// are irrelevant in the context. +#define UNDEFINED_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) + #if 0 #define DEFAULT_COLOR_00 \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) @@ -230,46 +236,46 @@ // 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), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x14, 0x18), 0x5B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x06, 0x10, 0x16), 0x5C), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x03, 0x0E, 0x14), 0x5D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x02, 0x0C, 0x11), 0x5E), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x01, 0x0B, 0x0F), 0x5F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x01, 0x09, 0x0D), 0x60), \ + BUILD_COLOR (MAKE_RGB15_INIT (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), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2C), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7E), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7C), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7A), \ + BUILD_COLOR (MAKE_RGB15_INIT (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), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x1E, 0x09), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x1E, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x1B, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x18, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x15, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x12, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x10, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x0D, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x0A, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x07, 0x00), 0x65), \ } // Colors for the crew in the crew pods as they are filled up, @@ -281,16 +287,16 @@ // 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), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1C, 0x1C, 0x1C), 0x11), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x18, 0x18, 0x18), 0x13), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x15, 0x15, 0x15), 0x15), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x12, 0x12, 0x12), 0x17), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x10), 0x19), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0D, 0x0D, 0x0D), 0x1B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x0A, 0x0A), 0x1D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x08, 0x08, 0x08), 0x1F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x05, 0x05, 0x05), 0x21), \ } // Color of the storage bay indicator, as shown beneath the flagship, @@ -335,5 +341,14 @@ BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x00) +// Temporary, until we can use C'99 features: +#define BLACK_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00) +#define WHITE_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F) +#define UNDEFINED_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00) + + #endif /* _COLORS_H */ Modified: trunk/sc2/src/uqm/comm/arilou/arilouc.c =================================================================== --- trunk/sc2/src/uqm/comm/arilou/arilouc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/arilou/arilouc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ ARILOU_PMAP_ANIM, /* AlienFrame */ ARILOU_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/blackur/blackurc.c =================================================================== --- trunk/sc2/src/uqm/comm/blackur/blackurc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/blackur/blackurc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -27,8 +27,8 @@ NULL, /* uninit_encounter_func */ BLACKURQ_PMAP_ANIM, /* AlienFrame */ BLACKURQ_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/chmmr/chmmrc.c =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -32,8 +32,8 @@ NULL, /* uninit_encounter_func */ CHMMR_PMAP_ANIM, /* AlienFrame */ CHMMR_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/comandr/comandr.c =================================================================== --- trunk/sc2/src/uqm/comm/comandr/comandr.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/comandr/comandr.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -32,8 +32,8 @@ NULL, /* uninit_encounter_func */ COMMANDER_PMAP_ANIM, /* AlienFrame */ COMMANDER_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/druuge/druugec.c =================================================================== --- trunk/sc2/src/uqm/comm/druuge/druugec.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/druuge/druugec.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -33,8 +33,8 @@ NULL, /* uninit_encounter_func */ DRUUGE_PMAP_ANIM, /* AlienFrame */ DRUUGE_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/ilwrath/ilwrathc.c =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/ilwrathc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/ilwrath/ilwrathc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ ILWRATH_PMAP_ANIM, /* AlienFrame */ ILWRATH_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -48,8 +48,8 @@ NULL, /* uninit_encounter_func */ MELNORME_PMAP_ANIM, /* AlienFrame */ MELNORME_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/mycon/myconc.c =================================================================== --- trunk/sc2/src/uqm/comm/mycon/myconc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/mycon/myconc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -31,8 +31,8 @@ NULL, /* uninit_encounter_func */ MYCON_PMAP_ANIM, /* AlienFrame */ MYCON_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/orz/orzc.c =================================================================== --- trunk/sc2/src/uqm/comm/orz/orzc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/orz/orzc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ ORZ_PMAP_ANIM, /* AlienFrame */ ORZ_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/pkunk/pkunkc.c =================================================================== --- trunk/sc2/src/uqm/comm/pkunk/pkunkc.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/pkunk/pkunkc.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -31,8 +31,8 @@ NULL, /* uninit_encounter_func */ PKUNK_PMAP_ANIM, /* AlienFrame */ PKUNK_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/rebel/rebel.c =================================================================== --- trunk/sc2/src/uqm/comm/rebel/rebel.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/rebel/rebel.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ YEHAT_PMAP_ANIM, /* AlienFrame */ YEHAT_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* (SIS_TEXT_WIDTH - 16) * 2 / 3, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/shofixt/shofixt.c =================================================================== --- trunk/sc2/src/uqm/comm/shofixt/shofixt.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/shofixt/shofixt.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ SHOFIXTI_PMAP_ANIM, /* AlienFrame */ SHOFIXTI_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/slyhome/slyhome.c =================================================================== --- trunk/sc2/src/uqm/comm/slyhome/slyhome.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/slyhome/slyhome.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ SLYLANDRO_PMAP_ANIM, /* AlienFrame */ SLYLANDRO_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/slyland/slyland.c =================================================================== --- trunk/sc2/src/uqm/comm/slyland/slyland.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/slyland/slyland.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -32,8 +32,8 @@ NULL, /* uninit_encounter_func */ SLYLAND_PMAP_ANIM, /* AlienFrame */ SLYLAND_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/spahome/spahome.c =================================================================== --- trunk/sc2/src/uqm/comm/spahome/spahome.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/spahome/spahome.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -31,8 +31,8 @@ NULL, /* uninit_encounter_func */ SPATHI_HOME_PMAP_ANIM, /* AlienFrame */ SPATHI_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/spathi/spathic.c =================================================================== --- trunk/sc2/src/uqm/comm/spathi/spathic.c 2009-11-28 22:06:18 UTC (rev 3366) +++ trunk/sc2/src/uqm/comm/spathi/spathic.c 2009-11-29 15:29:38 UTC (rev 3367) @@ -30,8 +30,8 @@ NULL, /* uninit_encounter_func */ SPATHI_PMAP_ANIM, /* AlienFrame */ SPATHI_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2009-11-28 22:06:18 UTC (rev 3366) +... [truncated message content] |
From: <Mee...@us...> - 2009-11-29 23:32:35
|
Revision: 3370 http://sc2.svn.sourceforge.net/sc2/?rev=3370&view=rev Author: Meep-Eep Date: 2009-11-29 23:32:02 +0000 (Sun, 29 Nov 2009) Log Message: ----------- Added 'COLOR' resource type. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/reslib.h trunk/sc2/src/libs/resource/resinit.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-11-29 19:54:51 UTC (rev 3369) +++ trunk/sc2/ChangeLog 2009-11-29 23:32:02 UTC (rev 3370) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Added 'COLOR' resource type - SvdB - All graphics operations use 24-bits colors at the game level too now, instead of 16 bits colors. - SvdB - Cross-platform safemode (ignores uqm.cfg, bug #946) - Michael Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2009-11-29 19:54:51 UTC (rev 3369) +++ trunk/sc2/src/libs/gfxlib.h 2009-11-29 23:32:02 UTC (rev 3370) @@ -20,6 +20,9 @@ #define _GFXLIB_H #include "libs/compiler.h" + +typedef struct Color Color; + #include "libs/reslib.h" typedef struct context_desc CONTEXT_DESC; @@ -39,12 +42,12 @@ typedef SWORD COORD; -typedef struct Color { +struct Color { BYTE r; BYTE g; BYTE b; BYTE a; // Currently unused -} Color; +}; static inline bool sameColor(Color c1, Color c2) Modified: trunk/sc2/src/libs/reslib.h =================================================================== --- trunk/sc2/src/libs/reslib.h 2009-11-29 19:54:51 UTC (rev 3369) +++ trunk/sc2/src/libs/reslib.h 2009-11-29 23:32:02 UTC (rev 3370) @@ -79,6 +79,8 @@ BOOLEAN FreeResourceData (void *); #include "strlib.h" +#include "gfxlib.h" + // For Color typedef STRING_TABLE DIRENTRY_REF; typedef STRING DIRENTRY; @@ -114,6 +116,10 @@ BOOLEAN res_GetBoolean (const char *key); void res_PutBoolean (const char *key, BOOLEAN value); +BOOLEAN res_IsColor (const char *key); +Color res_GetColor (const char *key); +void res_PutColor (const char *key, Color value); + BOOLEAN res_Remove (const char *key); #endif /* _RESLIB_H */ Modified: trunk/sc2/src/libs/resource/resinit.c =================================================================== --- trunk/sc2/src/libs/resource/resinit.c 2009-11-29 19:54:51 UTC (rev 3369) +++ trunk/sc2/src/libs/resource/resinit.c 2009-11-29 23:32:02 UTC (rev 3370) @@ -160,7 +160,129 @@ } } +static inline size_t +skipWhiteSpace (const char *start) +{ + const char *ptr = start; + while (isspace (*ptr)) + ptr++; + return (ptr - start); +} + +// On success, resdata->num will be filled with a 32-bits RGBA value. static void +DescriptorToColor (const char *descriptor, RESOURCE_DATA *resdata) +{ + int bytesParsed; + int componentBits; + int maxComponentValue; + size_t componentCount; + size_t compI;; + int comps[4]; + // One element for each of r, g, b, a. + + descriptor += skipWhiteSpace (descriptor); + +#if 0 + // Can't use this; '#' starts a comment. + if (*descriptor == '#') + { + // "#rrggbb" + int i; + DWORD value = 0; + + descriptor++; + for (i = 0; i < 6; i++) + { + BYTE nibbleValue; + if (*descriptor >= '0' && *descriptor <= '9') + nibbleValue = *descriptor - '0'; + else if (*descriptor >= 'a' && *descriptor <= 'f') + nibbleValue = 0xa + *descriptor - 'a'; + else if (*descriptor >= 'A' && *descriptor <= 'F') + nibbleValue = 0xa + *descriptor - 'A'; + else + goto fail; + + value = (value * 16) + nibbleValue; + descriptor++; + } + + descriptor += skipWhiteSpace (descriptor); + + if (*descriptor != '\0') + log_add (log_Warning, "Junk after color resource string."); + + resdata->num = (value << 8) | 0xff; + return; + } +#endif + + // Color is of the form "rgb(r, g, b)", "rgba(r, g, b, a)", + // or "rgb15(r, g, b)". + + if (sscanf (descriptor, "rgb ( %i , %i , %i ) %n", + &comps[0], &comps[1], &comps[2], &bytesParsed) >= 3) + { + componentBits = 8; + componentCount = 3; + comps[3] = 0xff; + } + else if (sscanf (descriptor, "rgba ( %i , %i , %i , %i ) %n", + &comps[0], &comps[1], &comps[2], &comps[3], &bytesParsed) >= 4) + { + componentBits = 8; + componentCount = 4; + } + else if (sscanf (descriptor, "rgb15 ( %i , %i , %i ) %n", + &comps[0], &comps[1], &comps[2], &bytesParsed) >= 3) + { + componentBits = 5; + componentCount = 3; + comps[3] = 0xff; + } + else + goto fail; + + if (descriptor[bytesParsed] != '\0') + log_add (log_Warning, "Junk after color resource string."); + + maxComponentValue = (1 << componentBits) - 1; + + // Check the range of the components. + for (compI = 0; compI < componentCount; compI++) + { + if (comps[compI] < 0) + { + comps[compI] = 0; + log_add (log_Warning, "Color component value too small; " + "value clipped."); + } + + if (comps[compI] > (long) maxComponentValue) + { + comps[compI] = maxComponentValue; + log_add (log_Warning, "Color component value too large; " + "value clipped."); + } + } + + if (componentBits == 5) + resdata->num = ((CC5TO8 (comps[0]) << 24) | + (CC5TO8 (comps[1]) << 16) | (CC5TO8 (comps[2]) << 8) | + comps[3]); + else + resdata->num = ((comps[0] << 24) | (comps[1] << 16) | + (comps[2] << 8) | comps[3]); + + return; + +fail: + log_add (log_Error, "Invalid color description string for resource.\n"); + resdata->num = 0x00000000; +} + +static void RawDescriptor (RESOURCE_DATA *resdata, char *buf, unsigned int size) { snprintf (buf, size, "%s", (char *)resdata->ptr); @@ -179,6 +301,25 @@ snprintf (buf, size, "%s", resdata->num ? "true" : "false"); } +static void +ColorToString (RESOURCE_DATA *resdata, char *buf, unsigned int size) +{ + if ((resdata->num & 0xff) == 0xff) + { + // Opaque color, save as "rgb". + snprintf (buf, size, "rgb(0x%02x, 0x%02x, 0x%02x)", + (resdata->num >> 24), (resdata->num >> 16) & 0xff, + (resdata->num >> 8) & 0xff); + } + else + { + // (Partially) transparent color, save as "rgba". + snprintf (buf, size, "rgba(0x%02x, 0x%02x, 0x%02x, 0x%02x)", + (resdata->num >> 24), (resdata->num >> 16) & 0xff, + (resdata->num >> 8) & 0xff, resdata->num & 0xff); + } +} + static RESOURCE_INDEX curResourceIndex; void @@ -201,7 +342,9 @@ InstallResTypeVectors ("UNKNOWNRES", UseDescriptorAsRes, NULL, NULL); InstallResTypeVectors ("STRING", UseDescriptorAsRes, NULL, RawDescriptor); InstallResTypeVectors ("INT32", DescriptorToInt, NULL, IntToString); - InstallResTypeVectors ("BOOLEAN", DescriptorToBoolean, NULL, BooleanToString); + InstallResTypeVectors ("BOOLEAN", DescriptorToBoolean, NULL, + BooleanToString); + InstallResTypeVectors ("COLOR", DescriptorToColor, NULL, ColorToString); InstallGraphicResTypes (); InstallStringTableResType (); InstallAudioResTypes (); @@ -437,6 +580,47 @@ } BOOLEAN +res_IsColor (const char *key) +{ + RESOURCE_INDEX idx = _get_current_index_header (); + ResourceDesc *desc = lookupResourceDesc (idx, key); + return desc && !strcmp(desc->vtable->resType, "COLOR"); +} + +Color +res_GetColor (const char *key) +{ + RESOURCE_INDEX idx = _get_current_index_header (); + ResourceDesc *desc = lookupResourceDesc (idx, key); + DWORD num; + if (!desc || strcmp(desc->vtable->resType, "COLOR")) + { + // TODO: Better error handling + return buildColorRgba (0, 0, 0, 0); + } + + num = desc->resdata.num; + return buildColorRgba (num >> 24, (num >> 16) & 0xff, + (desc->resdata.num >> 8) & 0xff, num & 0xff); +} + +void +res_PutColor (const char *key, Color value) +{ + RESOURCE_INDEX idx = _get_current_index_header (); + ResourceDesc *desc = lookupResourceDesc (idx, key); + if (!desc || strcmp(desc->vtable->resType, "COLOR")) + { + /* TODO: This is kind of roundabout. We can do better by refactoring + * newResourceDesc */ + process_resource_desc(key, "COLOR:#000000"); + desc = lookupResourceDesc (idx, key); + } + desc->resdata.num = + (value.r << 24) | (value.g << 16) | (value.b << 8) | value.a; +} + +BOOLEAN res_HasKey (const char *key) { RESOURCE_INDEX idx = _get_current_index_header (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-11-30 20:10:09
|
Revision: 3375 http://sc2.svn.sourceforge.net/sc2/?rev=3375&view=rev Author: Meep-Eep Date: 2009-11-30 20:09:57 +0000 (Mon, 30 Nov 2009) Log Message: ----------- Use an own 'UniChar' rather than 'wchar_t', which may not be large enough, depending on the platform. Also split off UNICODE functionality from strlib.h into unicode.h. Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/graphics/font.c trunk/sc2/src/libs/graphics/font.h trunk/sc2/src/libs/graphics/sdl/3do_getbody.c trunk/sc2/src/libs/inplib.h trunk/sc2/src/libs/input/sdl/input.c trunk/sc2/src/libs/strings/unicode.c trunk/sc2/src/libs/strlib.h trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/getchar.c trunk/sc2/src/uqm/planets/pstarmap.c trunk/sc2/src/uqm/planets/report.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-11-30 20:09:57 UTC (rev 3375) @@ -1568,6 +1568,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\libs\unicode.h +# End Source File +# Begin Source File + SOURCE=..\..\src\libs\vidlib.h # End Source File # End Group Modified: trunk/sc2/src/libs/graphics/font.c =================================================================== --- trunk/sc2/src/libs/graphics/font.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/graphics/font.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -21,7 +21,7 @@ #include "libs/log.h" extern void FixContextFontEffect (void); -static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, wchar_t ch); +static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, UniChar ch); FONT @@ -119,7 +119,7 @@ { COORD top_y, bot_y; SIZE width; - wchar_t next_ch; + UniChar next_ch; const unsigned char *pStr; COUNT num_chars; @@ -150,7 +150,7 @@ } while (num_chars--) { - wchar_t ch; + UniChar ch; SIZE last_width; TFB_Char *charFrame; @@ -230,7 +230,7 @@ FONT FontPtr; COUNT num_chars; - wchar_t next_ch; + UniChar next_ch; const unsigned char *pStr; TEXT *TextPtr; POINT origin; @@ -257,7 +257,7 @@ num_chars = 0; while (num_chars--) { - wchar_t ch; + UniChar ch; TFB_Char* fontChar; ch = next_ch; @@ -295,9 +295,9 @@ } static inline TFB_Char * -getCharFrame (FONT_DESC *fontPtr, wchar_t ch) +getCharFrame (FONT_DESC *fontPtr, UniChar ch) { - wchar_t pageStart = ch & CHARACTER_PAGE_MASK; + UniChar pageStart = ch & CHARACTER_PAGE_MASK; size_t charIndex; FONT_PAGE *page = fontPtr->fontPages; Modified: trunk/sc2/src/libs/graphics/font.h =================================================================== --- trunk/sc2/src/libs/graphics/font.h 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/graphics/font.h 2009-11-30 20:09:57 UTC (rev 3375) @@ -26,9 +26,9 @@ typedef struct FontPage { struct FontPage *next; - wchar_t pageStart; + UniChar pageStart; #define CHARACTER_PAGE_MASK 0xff800 - wchar_t firstChar; + UniChar firstChar; size_t numChars; TFB_Char *charDesc; } FONT_PAGE; Modified: trunk/sc2/src/libs/graphics/sdl/3do_getbody.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -581,7 +581,7 @@ typedef struct BuildCharDesc { SDL_Surface *surface; - wchar_t index; + UniChar index; } BuildCharDesc; int Modified: trunk/sc2/src/libs/inplib.h =================================================================== --- trunk/sc2/src/libs/inplib.h 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/inplib.h 2009-11-30 20:09:57 UTC (rev 3375) @@ -22,6 +22,7 @@ #include <stddef.h> #include "libs/compiler.h" #include "libs/uio.h" +#include "libs/unicode.h" extern BOOLEAN AnyButtonPress (BOOLEAN DetectSpecial); @@ -43,8 +44,8 @@ void EnterCharacterMode (void); void ExitCharacterMode (void); -wchar_t GetNextCharacter (void); -wchar_t GetLastCharacter (void); +UniChar GetNextCharacter (void); +UniChar GetLastCharacter (void); /* Interrogating the current key configuration */ Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/input/sdl/input.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -33,8 +33,8 @@ #define KBDBUFSIZE (1 << 8) static int kbdhead=0, kbdtail=0; -static wchar_t kbdbuf[KBDBUFSIZE]; -static wchar_t lastchar; +static UniChar kbdbuf[KBDBUFSIZE]; +static UniChar lastchar; static int num_keys = 0; static int *kbdstate = NULL; // Holds all SDL keys +1 for holding invalid values @@ -291,10 +291,10 @@ lastchar = 0; } -wchar_t +UniChar GetNextCharacter (void) { - wchar_t result; + UniChar result; if (kbdhead == kbdtail) return 0; result = kbdbuf[kbdhead]; @@ -302,7 +302,7 @@ return result; } -wchar_t +UniChar GetLastCharacter (void) { return lastchar; @@ -353,7 +353,7 @@ if (Event->type == SDL_KEYDOWN || Event->type == SDL_KEYUP) { // process character input event, if any SDLKey k = Event->key.keysym.sym; - wchar_t map_key = Event->key.keysym.unicode; + UniChar map_key = Event->key.keysym.unicode; if (k < 0 || k > num_keys) k = num_keys; // for unknown keys Modified: trunk/sc2/src/libs/strings/unicode.c =================================================================== --- trunk/sc2/src/libs/strings/unicode.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/strings/unicode.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -36,9 +36,9 @@ // Returns 0 if the encoding is bad. This can be distinguished from the // '\0' character by checking whether **ptr == '\0' before calling this // function. -wchar_t +UniChar getCharFromString(const unsigned char **ptr) { - wchar_t result; + UniChar result; if (**ptr < 0x80) { // 0xxxxxxx, regular ASCII @@ -126,7 +126,7 @@ return 0; } -wchar_t +UniChar getCharFromStringN(const unsigned char **ptr, const unsigned char *end) { size_t numBytes; @@ -167,7 +167,7 @@ const unsigned char **startNext) { const unsigned char *ptr = start; const unsigned char *lastPtr; - wchar_t ch; + UniChar ch; // Search for the first newline. for (;;) { @@ -215,7 +215,7 @@ size_t utf8StringCount(const unsigned char *start) { size_t count = 0; - wchar_t ch; + UniChar ch; for (;;) { ch = getCharFromString(&start); @@ -228,7 +228,7 @@ size_t utf8StringCountN(const unsigned char *start, const unsigned char *end) { size_t count = 0; - wchar_t ch; + UniChar ch; for (;;) { ch = getCharFromStringN(&start, end); @@ -238,11 +238,11 @@ } } -// Locates a wide char (ch) in a UTF-8 string (pStr) +// Locates a unicode character (ch) in a UTF-8 string (pStr) // returns the char positions when found // -1 when not found int -utf8StringPos (const unsigned char *pStr, wchar_t ch) +utf8StringPos (const unsigned char *pStr, UniChar ch) { int pos; @@ -278,9 +278,9 @@ utf8StringCompare (const unsigned char *str1, const unsigned char *str2) { #if 0 - // wchar_t comparing version - wchar_t ch1; - wchar_t ch2; + // UniChar comparing version + UniChar ch1; + UniChar ch2; for (;;) { @@ -321,7 +321,7 @@ unsigned char * skipUTF8Chars(const unsigned char *ptr, size_t num) { - wchar_t ch; + UniChar ch; const unsigned char *oldPtr; while (num--) { @@ -333,16 +333,16 @@ return (unsigned char *) ptr; } -// Decodes a UTF-8 string (start) into a wide char string (wstr) +// Decodes a UTF-8 string (start) into a unicode character string (wstr) // returns number of chars decoded and stored, not counting 0-term // any chars that do not fit are truncated // wide string term 0 is always appended, unless the destination // buffer is 0 chars long size_t -getWideFromStringN(wchar_t *wstr, size_t maxcount, +getUniCharFromStringN(UniChar *wstr, size_t maxcount, const unsigned char *start, const unsigned char *end) { - wchar_t *next; + UniChar *next; if (maxcount == 0) return 0; @@ -366,9 +366,10 @@ // the only difference is that the source string (start) length is // calculated by searching for 0-term size_t -getWideFromString(wchar_t *wstr, size_t maxcount, const unsigned char *start) +getUniCharFromString(UniChar *wstr, size_t maxcount, + const unsigned char *start) { - wchar_t *next; + UniChar *next; if (maxcount == 0) return 0; @@ -394,12 +395,12 @@ // <0 : negative of bytes needed if buffer too small // string term '\0' is *not* appended or counted int -getStringFromChar(unsigned char *ptr, size_t size, wchar_t ch) +getStringFromChar(unsigned char *ptr, size_t size, UniChar ch) { int i; static const struct range_def { - wchar_t lim; + UniChar lim; int marker; int mask; } @@ -420,8 +421,8 @@ ; if (def->mask == 0) { // invalid or unsupported char - log_add(log_Warning, "Warning: Invalid or unsupported wide char (%lu)", - (unsigned long)ch); + log_add(log_Warning, "Warning: Invalid or unsupported unicode " + "char (%lu)", (unsigned long) ch); return 0; } @@ -454,7 +455,7 @@ // buffer is 0 bytes long size_t getStringFromWideN(unsigned char *ptr, size_t size, - const wchar_t *wstr, size_t count) + const UniChar *wstr, size_t count) { unsigned char *next; int used; @@ -487,9 +488,9 @@ // the only difference is that the source string (wstr) length is // calculated by searching for 0-term size_t -getStringFromWide(unsigned char *ptr, size_t size, const wchar_t *wstr) +getStringFromWide(unsigned char *ptr, size_t size, const UniChar *wstr) { - const wchar_t *end; + const UniChar *end; for (end = wstr; *end != 0; ++end) ; @@ -498,7 +499,7 @@ } int -isWideGraphChar(wchar_t ch) +UniChar_isGraph(UniChar ch) { // this is not technically sufficient, but close enough for us // we'll consider all non-control (CO and C1) chars in 'graph' class // except for the "Private Use Area" (0xE000 - 0xF8FF) @@ -512,23 +513,24 @@ } int -isWidePrintChar(wchar_t ch) +UniChar_isPrint(UniChar ch) { // this is not technically sufficient, but close enough for us // chars in 'print' class are 'graph' + 'space' classes // the only space we currently have defined is 0x20 - return (ch == 0x20) || isWideGraphChar(ch); + return (ch == 0x20) || UniChar_isGraph(ch); } -wchar_t -toWideUpper(wchar_t ch) +UniChar +UniChar_toUpper(UniChar ch) { // this is a very basic Latin-1 implementation // just to get things going - return (ch < 0x100) ? toupper(ch) : ch; + return (ch < 0x100) ? (UniChar) toupper((int) ch) : ch; } -wchar_t -toWideLower(wchar_t ch) +UniChar +UniChar_toLower(UniChar ch) { // this is a very basic Latin-1 implementation // just to get things going - return (ch < 0x100) ? tolower(ch) : ch; + return (ch < 0x100) ? (UniChar) tolower((int) ch) : ch; } + Modified: trunk/sc2/src/libs/strlib.h =================================================================== --- trunk/sc2/src/libs/strlib.h 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/libs/strlib.h 2009-11-30 20:09:57 UTC (rev 3375) @@ -22,6 +22,7 @@ #include "libs/compiler.h" #include "port.h" #include "libs/uio.h" +#include "libs/unicode.h" #include <stddef.h> @@ -57,42 +58,15 @@ extern BOOLEAN GetStringContents (STRING String, STRINGPTR StringBuf, BOOLEAN AppendSpace); -wchar_t getCharFromString(const unsigned char **ptr); -wchar_t getCharFromStringN(const unsigned char **ptr, - const unsigned char *end); -unsigned char *getLineFromString(const unsigned char *start, - const unsigned char **end, const unsigned char **startNext); -size_t utf8StringCount(const unsigned char *start); -size_t utf8StringCountN(const unsigned char *start, - const unsigned char *end); -int utf8StringPos (const unsigned char *pStr, wchar_t ch); -unsigned char *utf8StringCopy (unsigned char *dst, size_t size, - const unsigned char *src); -int utf8StringCompare (const unsigned char *str1, const unsigned char *str2); -unsigned char *skipUTF8Chars(const unsigned char *ptr, size_t num); -size_t getWideFromString(wchar_t *wstr, size_t maxcount, - const unsigned char *start); -size_t getWideFromStringN(wchar_t *wstr, size_t maxcount, - const unsigned char *start, const unsigned char *end); -int getStringFromChar(unsigned char *ptr, size_t size, wchar_t ch); -size_t getStringFromWideN(unsigned char *ptr, size_t size, - const wchar_t *wstr, size_t count); -size_t getStringFromWide(unsigned char *ptr, size_t size, - const wchar_t *wstr); -int isWideGraphChar(wchar_t ch); -int isWidePrintChar(wchar_t ch); -wchar_t toWideUpper(wchar_t ch); -wchar_t toWideLower(wchar_t ch); - -#define WCHAR_DEGREE_SIGN 0x00b0 +#define UNICHAR_DEGREE_SIGN 0x00b0 #define STR_DEGREE_SIGN "\xC2\xB0" -#define WCHAR_INFINITY_SIGN 0x221e +#define UNICHAR_INFINITY_SIGN 0x221e #define STR_INFINITY_SIGN "\xE2\x88\x9E" -#define WCHAR_EARTH_SIGN 0x2641 +#define UNICHAR_EARTH_SIGN 0x2641 #define STR_EARTH_SIGN "\xE2\x99\x81" -#define WCHAR_MIDDLE_DOT 0x00b7 +#define UNICHAR_MIDDLE_DOT 0x00b7 #define STR_MIDDLE_DOT "\xC2\xB7" -#define WCHAR_BULLET 0x2022 +#define UNICHAR_BULLET 0x2022 #define STR_BULLET "\xE2\x80\xA2" #endif /* _STRLIB_H */ Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/uqm/comm.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -323,7 +323,7 @@ COUNT oldCount; const unsigned char *ptr; const unsigned char *wordStart; - wchar_t ch; + UniChar ch; COUNT charCount; //GetContextClipRect (&rect); Modified: trunk/sc2/src/uqm/getchar.c =================================================================== --- trunk/sc2/src/uqm/getchar.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/uqm/getchar.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -123,7 +123,7 @@ BOOLEAN DoTextEntry (TEXTENTRY_STATE *pTES) { - wchar_t ch; + UniChar ch; UNICODE *pStr; UNICODE *CacheInsPt; int CacheCursorPos; @@ -209,7 +209,7 @@ pTES->JoystickMode = FALSE; chsize = getStringFromChar (chbuf, sizeof (chbuf), ch); - if (isWidePrintChar (ch) && chsize > 0) + if (UniChar_isPrint (ch) && chsize > 0) { if (pStr + len - pTES->BaseStr + chsize < pTES->MaxSize) { // insert character, when fits Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -968,10 +968,10 @@ for (c = 0, sptr = pSS->Cluster, dptr = ClusterName; c < pSS->ClusterLen; ++c) { - wchar_t sc = getCharFromString (&sptr); - wchar_t dc = getCharFromString (&dptr); + UniChar sc = getCharFromString (&sptr); + UniChar dc = getCharFromString (&dptr); - if (toWideUpper (sc) != toWideUpper (dc)) + if (UniChar_toUpper (sc) != UniChar_toUpper (dc)) break; } @@ -1010,10 +1010,10 @@ for (c = 0, sptr = pSS->Prefix, dptr = FullName; c < pSS->PrefixLen; ++c) { - wchar_t sc = getCharFromString (&sptr); - wchar_t dc = getCharFromString (&dptr); + UniChar sc = getCharFromString (&sptr); + UniChar dc = getCharFromString (&dptr); - if (toWideUpper (sc) != toWideUpper (dc)) + if (UniChar_toUpper (sc) != UniChar_toUpper (dc)) break; } Modified: trunk/sc2/src/uqm/planets/report.c =================================================================== --- trunk/sc2/src/uqm/planets/report.c 2009-11-30 18:52:15 UTC (rev 3374) +++ trunk/sc2/src/uqm/planets/report.c 2009-11-30 20:09:57 UTC (rev 3375) @@ -89,7 +89,7 @@ BYTE ButtonState; int end_page_len; UNICODE end_page_buf[200]; - wchar_t last_c; + UniChar last_c; COUNT row_cells; BOOLEAN Sleepy; RECT r; @@ -142,11 +142,11 @@ { COUNT word_chars; const UNICODE *pStr; - wchar_t c; + UniChar c; pStr = t.pStr; pNextStr = t.pStr; - while (isWideGraphChar (getCharFromString (&pNextStr))) + while (UniChar_isGraph (getCharFromString (&pNextStr))) pStr = pNextStr; word_chars = utf8StringCountN (t.pStr, pStr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-04 18:24:23
|
Revision: 3389 http://sc2.svn.sourceforge.net/sc2/?rev=3389&view=rev Author: avolkov Date: 2009-12-04 18:24:15 +0000 (Fri, 04 Dec 2009) Log Message: ----------- Restore arrow menu sounds after editing a control set name; bug #1066 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/setupmenu.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-04 00:12:12 UTC (rev 3388) +++ trunk/sc2/ChangeLog 2009-12-04 18:24:15 UTC (rev 3389) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Restore menu sounds after editing a control set name (bug #1066) - Alex - Added 'COLOR' resource type - SvdB - All graphics operations use 24-bits colors at the game level too now, instead of 16 bits colors. - SvdB Modified: trunk/sc2/src/uqm/setupmenu.c =================================================================== --- trunk/sc2/src/uqm/setupmenu.c 2009-12-04 00:12:12 UTC (rev 3388) +++ trunk/sc2/src/uqm/setupmenu.c 2009-12-04 18:24:15 UTC (rev 3389) @@ -571,6 +571,7 @@ (*(widget->onChange))(widget); } } + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); widget->state = WTE_NORMAL; redraw_menu (); 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:38:44
|
Revision: 3394 http://sc2.svn.sourceforge.net/sc2/?rev=3394&view=rev Author: avolkov Date: 2009-12-05 22:38:37 +0000 (Sat, 05 Dec 2009) Log Message: ----------- Fixed planet blinking when exiting scan; bug #799 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/planets/scan.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-05 22:15:23 UTC (rev 3393) +++ trunk/sc2/ChangeLog 2009-12-05 22:38:37 UTC (rev 3394) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed planet blinking when exiting scan (bug #799) - Alex - Restore menu sounds after editing a control set name (bug #1066) - Alex - Added 'COLOR' resource type - SvdB - All graphics operations use 24-bits colors at the game level too now, Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-12-05 22:15:23 UTC (rev 3393) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-05 22:38:37 UTC (rev 3394) @@ -76,33 +76,23 @@ static void EraseCoarseScan (void) { - RECT r, tr; - const int leftScanWidth = 80; - const int rightScanWidth = 80; - const int leftScanOffset = 5; - const int rightScanOffset = 50; - const int nameEraseWidth = SIS_SCREEN_WIDTH - 2; + RECT oldClipRect; + RECT clipRect; LockMutex (GraphicsLock); SetContext (SpaceContext); - - r.corner.x = (SIS_SCREEN_WIDTH >> 1) - (nameEraseWidth >> 1); - r.corner.y = 13 - 10; - r.extent.width = nameEraseWidth; - r.extent.height = 14; - RepairBackRect (&r); - - GetFrameRect (SetAbsFrameIndex (SpaceJunkFrame, 20), &tr); - r = tr; - r.corner.x += leftScanOffset; - r.extent.width = leftScanWidth; - RepairBackRect (&r); - - r = tr; - r.corner.x += (r.extent.width - rightScanOffset); - r.extent.width = rightScanWidth; - RepairBackRect (&r); - + // TODO: Give coarse scan an own context + GetContextClipRect (&oldClipRect); + clipRect = oldClipRect; + clipRect.extent.height = SCAN_SCREEN_HEIGHT; + SetContextClipRect (&clipRect); + + BatchGraphics (); + DrawStarBackGround (); + DrawDefaultPlanetSphere (); + UnbatchGraphics (); + + SetContextClipRect (&oldClipRect); 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-12 00:34:15
|
Revision: 3425 http://sc2.svn.sourceforge.net/sc2/?rev=3425&view=rev Author: avolkov Date: 2009-12-12 00:34:07 +0000 (Sat, 12 Dec 2009) Log Message: ----------- Save/load UI cleanup: own MENU_STATE; MENU_STATE hacks removed; fully redrawing the summary every time for simplicity and better color-matching Modified Paths: -------------- trunk/sc2/content/base/ui/playmenu-063.png trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/menustat.h Modified: trunk/sc2/content/base/ui/playmenu-063.png =================================================================== (Binary files differ) Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-12-11 23:19:36 UTC (rev 3424) +++ trunk/sc2/src/uqm/gameopt.c 2009-12-12 00:34:07 UTC (rev 3425) @@ -38,6 +38,7 @@ #include <ctype.h> +extern FRAME PlayFrame; #define MAX_SAVED_GAMES 50 #define SUMMARY_X_OFFS 14 @@ -49,7 +50,6 @@ static BOOLEAN DoSettings (MENU_STATE *pMS); static BOOLEAN DoNaming (MENU_STATE *pMS); -static MENU_STATE *pLocMenuState; static BYTE prev_save; //keeps track of the last slot that was saved or loaded static NamingCallback *namingCB; @@ -399,7 +399,7 @@ pMS->CurState = SETTINGS; pMS->InputFunc = DoGameOptions; - pMS->Initialized = 0; + pMS->Initialized = FALSE; } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { @@ -445,179 +445,157 @@ return (TRUE); } +typedef struct +{ + SUMMARY_DESC summary[MAX_SAVED_GAMES]; + BOOLEAN saving; + // TRUE when saving, FALSE when loading + BOOLEAN abortOnCancel; + // TRUE when loading from the Main menu so that + // we do not end up in a newly started game + FRAME SummaryFrame; + +} PICK_GAME_STATE; + static void -DrawCargo (COUNT redraw_state) +DrawBlankSavegameDisplay (PICK_GAME_STATE *pickState) { - BYTE i; - RECT r; + STAMP s; - SetContext (SpaceContext); - if (redraw_state) + s.origin.x = 0; + s.origin.y = 0; + s.frame = SetAbsFrameIndex (pickState->SummaryFrame, + GetFrameCount (pickState->SummaryFrame) - 1); + DrawStamp (&s); +} + +static void +DrawSaveLoad (PICK_GAME_STATE *pickState) +{ + STAMP s; + + s.origin.x = SUMMARY_X_OFFS + 1; + s.origin.y = 0; + s.frame = SetAbsFrameIndex (pickState->SummaryFrame, + GetFrameCount (pickState->SummaryFrame) - 2); + if (pickState->saving) + s.frame = DecFrameIndex (s.frame); + DrawStamp (&s); +} + +static void +DrawSavegameCargo (PICK_GAME_STATE *pickState, COUNT gameIndex) +{ + COUNT i; + STAMP s; + TEXT t; + UNICODE buf[40]; + static const Color cargo_color[] = { - STAMP s; + BUILD_COLOR (MAKE_RGB15_INIT (0x02, 0x0E, 0x13), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x19, 0x00, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x10), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x03, 0x05, 0x1E), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x18, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x1B, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x1E, 0x0D, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x14, 0x00, 0x14), 0x05), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x19), 0x00), + }; +#define ELEMENT_ORG_Y 17 +#define ELEMENT_SPACING_Y 12 +#define ELEMENT_SPACING_X 36 - if (redraw_state == 2) - { - SetContextForeGroundColor (BLACK_COLOR); - r.corner.x = 1 + SUMMARY_X_OFFS; - r.corner.y = 12; - r.extent.width = ((SIS_SCREEN_WIDTH - STATUS_WIDTH) >> 1) - r.corner.x; - r.extent.height = 62 - r.corner.y; - DrawFilledRectangle (&r); - GetFrameRect (SetRelFrameIndex ( - pLocMenuState->ModuleFrame, 1), &r); - r.extent.width += SUMMARY_X_OFFS + SUMMARY_SIDE_OFFS; - DrawFilledRectangle (&r); - } - else - { - s.origin.x = 0; - s.origin.y = 0; - s.frame = SetAbsFrameIndex (pLocMenuState->ModuleFrame, - GetFrameCount (pLocMenuState->ModuleFrame) - 1); - if (!pLocMenuState->Initialized) - { - DrawStamp (&s); - s.origin.x = SUMMARY_X_OFFS + 1; - s.frame = DecFrameIndex (s.frame); - if (pLocMenuState->delta_item == SAVE_GAME) - s.frame = DecFrameIndex (s.frame); - DrawStamp (&s); - if (((SUMMARY_DESC *)pLocMenuState->Extra) - [pLocMenuState->CurState].year_index == 0) - return; - } - else - { - GetContextClipRect (&r); - r.extent.height = 136; - SetContextClipRect (&r); - DrawStamp (&s); - r.extent.height = SIS_SCREEN_HEIGHT; - SetContextClipRect (&r); - } - } + SetContext (SpaceContext); + BatchGraphics (); + SetContextFont (StarConFont); - s.frame = SetAbsFrameIndex ( - MiscDataFrame, - (NUM_SCANDOT_TRANSITIONS << 1) + 3 - ); - if (redraw_state == 2 - || (redraw_state == 1 - /*&& !(((SUMMARY_DESC *)pLocMenuState->Extra) - [pLocMenuState->CurState].Flags & AFTER_BOMB_INSTALLED)*/)) - { - s.origin.x = 7 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS + 3; - s.origin.y = 17; - for (i = 0; i < NUM_ELEMENT_CATEGORIES; ++i) - { - if (i == NUM_ELEMENT_CATEGORIES >> 1) - { - s.origin.x += 36; - s.origin.y = 17; - } - DrawStamp (&s); - s.frame = SetRelFrameIndex (s.frame, 5); - s.origin.y += 12; - } - } - s.origin.x = 24 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS; - s.origin.y = 68; - s.frame = SetAbsFrameIndex (s.frame, 68); - DrawStamp (&s); - } - else + // setup element icons + s.frame = SetAbsFrameIndex (MiscDataFrame, + (NUM_SCANDOT_TRANSITIONS << 1) + 3); + s.origin.x = 7 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS + 3; + s.origin.y = ELEMENT_ORG_Y; + // setup element amounts + t.baseline.x = 33 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS + 3; + t.baseline.y = ELEMENT_ORG_Y + 3; + t.align = ALIGN_RIGHT; + t.pStr = buf; + + // draw element icons and amounts + for (i = 0; i < NUM_ELEMENT_CATEGORIES; ++i) { - TEXT t; - UNICODE buf[40]; - static const Color cargo_color[] = + if (i == NUM_ELEMENT_CATEGORIES / 2) { - BUILD_COLOR (MAKE_RGB15_INIT (0x02, 0x0E, 0x13), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x19, 0x00, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x10), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x03, 0x05, 0x1E), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x18, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x1B, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x1E, 0x0D, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15_INIT (0x14, 0x00, 0x14), 0x05), - BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x19), 0x00), - }; - - r.extent.width = 23; - r.extent.height = SHIP_NAME_HEIGHT; - SetContextFont (StarConFont); - t.baseline.x = 33 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS + 3; - t.baseline.y = 20; - t.align = ALIGN_RIGHT; - t.pStr = buf; - for (i = 0; i < NUM_ELEMENT_CATEGORIES; ++i) - { - if (i == NUM_ELEMENT_CATEGORIES >> 1) - { - t.baseline.x += 36; - t.baseline.y = 20; - } - SetContextForeGroundColor (BLACK_COLOR); - r.corner.x = t.baseline.x - r.extent.width + 1; - r.corner.y = t.baseline.y - r.extent.height + 1; - DrawFilledRectangle (&r); - SetContextForeGroundColor (cargo_color[i]); - sprintf (buf, "%u", GLOBAL_SIS (ElementAmounts[i])); - t.CharCount = (COUNT)~0; - font_DrawText (&t); - t.baseline.y += 12; + s.origin.x += ELEMENT_SPACING_X; + s.origin.y = ELEMENT_ORG_Y; + t.baseline.x += ELEMENT_SPACING_X; + t.baseline.y = ELEMENT_ORG_Y + 3; } - t.baseline.x = 50 + SUMMARY_X_OFFS; - t.baseline.y = 71; - SetContextForeGroundColor (BLACK_COLOR); - r.corner.x = t.baseline.x - r.extent.width + 1; - r.corner.y = t.baseline.y - r.extent.height + 1; - DrawFilledRectangle (&r); + // draw element icon + DrawStamp (&s); + s.frame = SetRelFrameIndex (s.frame, 5); + s.origin.y += ELEMENT_SPACING_Y; + // print element amount SetContextForeGroundColor (cargo_color[i]); - sprintf (buf, "%u", GLOBAL_SIS (TotalBioMass)); + snprintf (buf, sizeof buf, "%u", GLOBAL_SIS (ElementAmounts[i])); t.CharCount = (COUNT)~0; font_DrawText (&t); + t.baseline.y += ELEMENT_SPACING_Y; } + + // draw Bio icon + s.origin.x = 24 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS; + s.origin.y = 68; + s.frame = SetAbsFrameIndex (s.frame, 68); + DrawStamp (&s); + // print Bio amount + t.baseline.x = 50 + SUMMARY_X_OFFS; + t.baseline.y = s.origin.y + 3; + SetContextForeGroundColor (cargo_color[i]); + snprintf (buf, sizeof buf, "%u", GLOBAL_SIS (TotalBioMass)); + t.CharCount = (COUNT)~0; + font_DrawText (&t); + + UnbatchGraphics (); } static void -ShowSummary (SUMMARY_DESC *pSD) +DrawSavegameSummary (PICK_GAME_STATE *pickState, COUNT gameIndex) { + SUMMARY_DESC *pSD = pickState->summary + gameIndex; RECT r; STAMP s; + BatchGraphics (); + if (pSD->year_index == 0) { // Unused save slot, draw 'Empty Game' message. - s.origin.x = s.origin.y = 0; - s.frame = SetAbsFrameIndex (pLocMenuState->ModuleFrame, - GetFrameCount (pLocMenuState->ModuleFrame) - 4); + s.origin.x = 0; + s.origin.y = 0; + s.frame = SetAbsFrameIndex (pickState->SummaryFrame, + GetFrameCount (pickState->SummaryFrame) - 4); DrawStamp (&s); - r.corner.x = 2; - r.corner.y = 139; - r.extent.width = SIS_SCREEN_WIDTH - 4; - r.extent.height = 7; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); - DrawFilledRectangle (&r); } else { // Game slot used, draw information about save game. - BYTE i; + COUNT i; RECT OldRect; TEXT t; QUEUE player_q; CONTEXT OldContext; SIS_STATE SaveSS; UNICODE buf[256]; + POINT starPt; + // Save the states because we will hack them SaveSS = GlobData.SIS_state; player_q = GLOBAL (built_ship_q); OldContext = SetContext (StatusContext); + // Hack StatusContext so we can use standard SIS display funcs GetContextClipRect (&OldRect); - r.corner.x = SIS_ORG_X + ((SIS_SCREEN_WIDTH - STATUS_WIDTH) >> 1) + SAFE_X - 16 + SUMMARY_X_OFFS; // r.corner.x = SIS_ORG_X + ((SIS_SCREEN_WIDTH - STATUS_WIDTH) >> 1); @@ -626,6 +604,7 @@ r.extent.height = STATUS_HEIGHT; SetContextClipRect (&r); + // Hack the states so that we can use standard SIS display funcs GlobData.SIS_state = pSD->SS; InitQueue (&GLOBAL (built_ship_q), MAX_BUILT_SHIPS, sizeof (SHIP_FRAGMENT)); @@ -638,36 +617,28 @@ UninitQueue (&GLOBAL (built_ship_q)); SetContextClipRect (&OldRect); + SetContext (SpaceContext); - BatchGraphics (); - DrawCargo (0); + // draw devices s.origin.y = 13; - r.extent.width = r.extent.height = 16; - SetContextForeGroundColor (BLACK_COLOR); for (i = 0; i < 4; ++i) { - BYTE j; + COUNT j; s.origin.x = 140 + SUMMARY_X_OFFS + SUMMARY_SIDE_OFFS; for (j = 0; j < 4; ++j) { - if ((i << 2) + j >= pSD->NumDevices) + COUNT devIndex = (i * 4) + j; + if (devIndex < pSD->NumDevices) { - r.corner = s.origin; - DrawFilledRectangle (&r); - } - else - { - s.frame = SetAbsFrameIndex ( - MiscDataFrame, 77 + pSD->DeviceList[(i << 2) + j] - ); + s.frame = SetAbsFrameIndex (MiscDataFrame, 77 + + pSD->DeviceList[devIndex]); DrawStamp (&s); } s.origin.x += 18; } s.origin.y += 18; } - UnbatchGraphics (); SetContextFont (StarConFont); t.baseline.x = 173 + SUMMARY_X_OFFS + SUMMARY_SIDE_OFFS; @@ -676,66 +647,55 @@ t.pStr = buf; if (pSD->Flags & AFTER_BOMB_INSTALLED) { + // draw the bomb and the escape pod s.origin.x = SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS + 6; s.origin.y = 0; - s.frame = SetRelFrameIndex (pLocMenuState->ModuleFrame, 0); + s.frame = SetRelFrameIndex (pickState->SummaryFrame, 0); DrawStamp (&s); + // draw RU "NO LIMIT" s.origin.x = SUMMARY_X_OFFS + SUMMARY_SIDE_OFFS; s.frame = IncFrameIndex (s.frame); DrawStamp (&s); } else { + DrawSavegameCargo (pickState, gameIndex); + SetContext (RadarContext); + // Hack RadarContext so we can use standard Lander display funcs GetContextClipRect (&OldRect); r.corner.x = SIS_ORG_X + 10 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS; r.corner.y = SIS_ORG_Y + 84; r.extent = OldRect.extent; SetContextClipRect (&r); UnlockMutex (GraphicsLock); - InitLander ((unsigned char)(pSD->Flags | OVERRIDE_LANDER_FLAGS)); + // draw the lander with upgrades + InitLander (pSD->Flags | OVERRIDE_LANDER_FLAGS); LockMutex (GraphicsLock); SetContextClipRect (&OldRect); SetContext (SpaceContext); - sprintf (buf, "%u", GLOBAL_SIS (ResUnits)); + snprintf (buf, sizeof buf, "%u", GLOBAL_SIS (ResUnits)); t.baseline.y = 102; - r.extent.width = 76; - r.extent.height = SHIP_NAME_HEIGHT; - r.corner.x = t.baseline.x - (r.extent.width >> 1); - r.corner.y = t.baseline.y - SHIP_NAME_HEIGHT + 1; - SetContextForeGroundColor (BLACK_COLOR); - DrawFilledRectangle (&r); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x00, 0x10), 0x01)); font_DrawText (&t); t.CharCount = (COUNT)~0; } t.baseline.y = 126; - sprintf (buf, "%u", MAKE_WORD (pSD->MCreditLo, pSD->MCreditHi)); - r.extent.width = 30; - r.extent.height = SHIP_NAME_HEIGHT; - r.corner.x = t.baseline.x - (r.extent.width >> 1); - r.corner.y = t.baseline.y - SHIP_NAME_HEIGHT + 1; - SetContextForeGroundColor (BLACK_COLOR); - DrawFilledRectangle (&r); + snprintf (buf, sizeof buf, "%u", + MAKE_WORD (pSD->MCreditLo, pSD->MCreditHi)); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x00, 0x10), 0x01)); font_DrawText (&t); - r.corner.x = 2; - r.corner.y = 139; - r.extent.width = SIS_SCREEN_WIDTH - 4; - r.extent.height = 7; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); - DrawFilledRectangle (&r); - t.baseline.x = /*r.corner.x + (SIS_MESSAGE_WIDTH >> 1)*/ 6; - t.baseline.y = r.corner.y + (r.extent.height - 1); + // print the location + t.baseline.x = 6; + t.baseline.y = 139 + 6; t.align = ALIGN_LEFT; t.pStr = buf; - r.corner.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)); - r.corner.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); + starPt.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)); + starPt.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); switch (pSD->Activity) { case IN_LAST_BATTLE: @@ -748,12 +708,12 @@ QuasiState = GET_GAME_STATE (ARILOU_SPACE_SIDE); SET_GAME_STATE (ARILOU_SPACE_SIDE, 0); - SDPtr = FindStar (NULL, &r.corner, 1, 1); + SDPtr = FindStar (NULL, &starPt, 1, 1); SET_GAME_STATE (ARILOU_SPACE_SIDE, QuasiState); if (SDPtr) { GetClusterName (SDPtr, buf); - r.corner = SDPtr->star_pt; + starPt = SDPtr->star_pt; break; } } @@ -792,21 +752,108 @@ utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName)); break; default: - sprintf (buf, "%03u.%01u : %03u.%01u", - r.corner.x / 10, r.corner.x % 10, - r.corner.y / 10, r.corner.y % 10); + snprintf (buf, sizeof buf, "%03u.%01u : %03u.%01u", + starPt.x / 10, starPt.x % 10, + starPt.y / 10, starPt.y % 10); } t.CharCount = (COUNT)~0; font_DrawText (&t); SetContext (OldContext); + // Restore the states because we hacked them GLOBAL (built_ship_q) = player_q; GlobData.SIS_state = SaveSS; } + + UnbatchGraphics (); } static void +DrawGameSelection (PICK_GAME_STATE *pickState, COUNT selSlot) +{ + RECT r; + TEXT t; + COUNT i; + COUNT curSlot; + UNICODE buf[256]; + UNICODE buf2[80]; + + BatchGraphics (); + + SetContextFont (TinyFont); + + // Erase the selection menu + r.extent.width = 240; + r.extent.height = 65; + r.corner.x = 1; + r.corner.y = 160; + SetContextForeGroundColor (BLACK_COLOR); + DrawFilledRectangle (&r); + + t.CharCount = (COUNT)~0; + t.pStr = buf; + t.align = ALIGN_LEFT; + + // Draw savegame slots info + curSlot = selSlot - (selSlot % SAVES_PER_PAGE); + for (i = 0; i < SAVES_PER_PAGE && curSlot < MAX_SAVED_GAMES; + ++i, ++curSlot) + { + SUMMARY_DESC *desc = &pickState->summary[curSlot]; + + SetContextForeGroundColor ((curSlot == selSlot) ? + (BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33)): + (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01))); + r.extent.width = 15; + if (MAX_SAVED_GAMES > 99) + r.extent.width += 5; + r.extent.height = 11; + r.corner.x = 8; + r.corner.y = 160 + (i * 13); + DrawRectangle (&r); + + t.baseline.x = r.corner.x + 3; + t.baseline.y = r.corner.y + 8; + snprintf (buf, sizeof buf, (MAX_SAVED_GAMES > 99) ? "%03u" : "%02u", + curSlot); + font_DrawText (&t); + + r.extent.width = 204 - SAFE_X; + r.corner.x = 30 + SAFE_X; + DrawRectangle (&r); + + t.baseline.x = r.corner.x + 3; + if (desc->year_index == 0) + { + utf8StringCopy (buf, sizeof buf, + GAME_STRING (SAVEGAME_STRING_BASE + 3)); // "Empty Slot" + } + else + { + DateToString (buf2, sizeof buf2, desc->month_index, + desc->day_index, desc->year_index); + snprintf (buf, sizeof buf, "%s %s", + GAME_STRING (SAVEGAME_STRING_BASE + 4), buf2); + // "Saved Game - Date:" + } + font_DrawText (&t); + } + + UnbatchGraphics (); +} + +static void +RedrawPickDisplay (PICK_GAME_STATE *pickState, COUNT selSlot) +{ + BatchGraphics (); + DrawBlankSavegameDisplay (pickState); + DrawSavegameSummary (pickState, selSlot); + DrawGameSelection (pickState, selSlot); + UnbatchGraphics (); +} + +static void LoadGameDescriptions (SUMMARY_DESC *pSD) { COUNT i; @@ -821,106 +868,80 @@ static BOOLEAN DoPickGame (MENU_STATE *pMS) { + PICK_GAME_STATE *pickState = pMS->privData; BYTE NewState; SUMMARY_DESC *pSD; - BOOLEAN first_time; DWORD TimeIn = GetTimeCounter (); if (GLOBAL (CurrentActivity) & CHECK_ABORT) - { - pMS->ModuleFrame = 0; - - return (FALSE); - } - first_time = !pMS->Initialized; - SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); + return FALSE; - if (!pMS->Initialized) + if (PulsedInputState.menu[KEY_MENU_CANCEL]) { - // XXX: Save DoGameOptions() state - pMS->delta_item = (SIZE)pMS->CurState; - pMS->CurState = NewState = prev_save; - pMS->InputFunc = DoPickGame; - - { - extern FRAME PlayFrame; - - pMS->ModuleFrame = SetAbsFrameIndex (PlayFrame, 39); - } - - LockMutex (GraphicsLock); - SetTransitionSource (NULL); - BatchGraphics (); -Restart: - SetContext (SpaceContext); - DrawCargo (1); - pMS->Initialized = TRUE; - goto ChangeGameSelection; - } - else if (PulsedInputState.menu[KEY_MENU_CANCEL]) - { - pMS->ModuleFrame = 0; - // XXX: Restore DoGameOptions() state - pMS->CurState = (BYTE)pMS->delta_item; ResumeMusic (); - if (LastActivity == CHECK_LOAD) + if (pickState->abortOnCancel) { // Selected LOAD from main menu, and now canceled GLOBAL (CurrentActivity) |= CHECK_ABORT; } - return (FALSE); + return FALSE; } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { - pSD = &((SUMMARY_DESC *)pMS->Extra)[pMS->CurState]; + pSD = &pickState->summary[pMS->CurState]; prev_save = pMS->CurState; - if (pMS->delta_item == SAVE_GAME || pSD->year_index) + if (pickState->saving || pSD->year_index) { - LockMutex (GraphicsLock); - if (pMS->delta_item == SAVE_GAME) + if (pickState->saving) { STAMP MsgStamp; + LockMutex (GraphicsLock); ConfirmSaveLoad (&MsgStamp); - if (SaveGame ((COUNT)pMS->CurState, pSD)) + UnlockMutex (GraphicsLock); + + if (SaveGame (pMS->CurState, pSD)) { DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); GLOBAL (CurrentActivity) |= CHECK_LOAD; } else { + LockMutex (GraphicsLock); DrawStamp (&MsgStamp); DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); UnlockMutex (GraphicsLock); SaveProblem (); - pMS->Initialized = FALSE; - LoadGameDescriptions ((SUMMARY_DESC *)pMS->Extra); - NewState = pMS->CurState; + // reload and redraw everything + LoadGameDescriptions (pickState->summary); LockMutex (GraphicsLock); - BatchGraphics (); - goto Restart; + SetContext (SpaceContext); + RedrawPickDisplay (pickState, pMS->CurState); + UnlockMutex (GraphicsLock); + + return TRUE; } ResumeMusic (); } else { - ConfirmSaveLoad (0); - if (LoadGame ((COUNT)pMS->CurState, NULL)) + LockMutex (GraphicsLock); + ConfirmSaveLoad (NULL); + UnlockMutex (GraphicsLock); + + if (LoadGame (pMS->CurState, NULL)) GLOBAL (CurrentActivity) |= CHECK_LOAD; } - UnlockMutex (GraphicsLock); - pMS->ModuleFrame = 0; - // XXX: Restore DoGameOptions() state - pMS->CurState = (BYTE)pMS->delta_item; - return (FALSE); + return FALSE; } } else { NewState = pMS->CurState; - if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_PAGE_UP]) + if (PulsedInputState.menu[KEY_MENU_LEFT] + || PulsedInputState.menu[KEY_MENU_PAGE_UP]) { if (NewState == 0) NewState = MAX_SAVED_GAMES - 1; @@ -929,7 +950,8 @@ else NewState = 0; } - else if (PulsedInputState.menu[KEY_MENU_RIGHT] || PulsedInputState.menu[KEY_MENU_PAGE_DOWN]) + else if (PulsedInputState.menu[KEY_MENU_RIGHT] + || PulsedInputState.menu[KEY_MENU_PAGE_DOWN]) { if (NewState == MAX_SAVED_GAMES - 1) NewState = 0; @@ -955,155 +977,54 @@ if (NewState != pMS->CurState) { - RECT r; - TEXT t; - BYTE i, SHIFT; - UNICODE buf[256]; - UNICODE buf2[80]; LockMutex (GraphicsLock); - - BatchGraphics (); - if (((SUMMARY_DESC *)pMS->Extra)[NewState].year_index != 0) - { - if (!(((SUMMARY_DESC *)pMS->Extra)[NewState].Flags - & AFTER_BOMB_INSTALLED)) - { - if (((SUMMARY_DESC *)pMS->Extra)[pMS->CurState].year_index == 0) - DrawCargo (1); - else if (((SUMMARY_DESC *)pMS->Extra)[pMS->CurState].Flags - & AFTER_BOMB_INSTALLED) - DrawCargo (2); - } - else if (((SUMMARY_DESC *)pMS->Extra)[pMS->CurState].year_index == 0) - DrawCargo (3); - } - -ChangeGameSelection: pMS->CurState = NewState; - ShowSummary (&((SUMMARY_DESC *)pMS->Extra)[pMS->CurState]); - - SetContextFont (TinyFont); - r.extent.width = 240; - r.extent.height = 65; - r.corner.x = 1; - r.corner.y = 160; - SetContextForeGroundColor (BLACK_COLOR); - DrawFilledRectangle (&r); - - t.CharCount = (COUNT)~0; - t.pStr = buf; - t.align = ALIGN_LEFT; -#if 0 - /* This code will return in modified form later. */ - if (optSmoothScroll == OPT_3DO) // 'Smooth' Scrolling - { - if (NewState <= (SAVES_PER_PAGE / 2)) - SHIFT = NewState; - else if ((NewState > (SAVES_PER_PAGE / 2)) && - (NewState < (MAX_SAVED_GAMES - (SAVES_PER_PAGE / 2)))) - SHIFT = (SAVES_PER_PAGE / 2); - else //if (NewState >= (MAX_SAVED_GAMES - (SAVES_PER_PAGE / 2))) - SHIFT = SAVES_PER_PAGE - (MAX_SAVED_GAMES - NewState) ; - } - else // 'Per-Page' Scrolling -#endif - SHIFT = NewState - ((NewState / SAVES_PER_PAGE) * SAVES_PER_PAGE); - for (i = 0; i < SAVES_PER_PAGE && NewState - SHIFT + i < MAX_SAVED_GAMES; i++) - { - SetContextForeGroundColor ((i == SHIFT) ? - (BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33)): - (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01))); - r.extent.width = 15; - if (MAX_SAVED_GAMES > 99) - r.extent.width += 5; - r.extent.height = 11; - r.corner.x = 8; - r.corner.y = 160 + (i * 13); - DrawRectangle (&r); - - t.baseline.x = r.corner.x + 3; - t.baseline.y = r.corner.y + 8; - sprintf (buf, "%02i", NewState - SHIFT + i); - if (MAX_SAVED_GAMES > 99) - sprintf (buf, "%03i", NewState - SHIFT + i); - font_DrawText (&t); - - r.extent.width = 204 - SAFE_X; - r.corner.x = 30 + SAFE_X; - DrawRectangle (&r); - - t.baseline.x = r.corner.x + 3; - if (((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].year_index == 0) - { - utf8StringCopy (buf, sizeof buf, - GAME_STRING (SAVEGAME_STRING_BASE + 3)); // "Empty Slot" - } - else - { - DateToString (buf2, sizeof buf2, - ((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].month_index, - ((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].day_index, - ((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].year_index); - snprintf (buf, sizeof buf, "%s %s", - GAME_STRING (SAVEGAME_STRING_BASE + 4), buf2); // "Saved Game - Date:" - } - font_DrawText (&t); - } - if (LastActivity == CHECK_LOAD && first_time) - { - UnbatchGraphics (); - FadeScreen (FadeAllToColor, ONE_SECOND / 2); - } - else - { - if (first_time) - { - r.corner.x = SIS_ORG_X; - r.corner.y = SIS_ORG_Y; - r.extent.width = SIS_SCREEN_WIDTH; - r.extent.height = SIS_SCREEN_HEIGHT; - - ScreenTransition (3, &r); - } - UnbatchGraphics (); - } + SetContext (SpaceContext); + RedrawPickDisplay (pickState, pMS->CurState); UnlockMutex (GraphicsLock); } SleepThreadUntil (TimeIn + ONE_SECOND / 30); } - return (TRUE); + return TRUE; } static BOOLEAN -PickGame (MENU_STATE *pMS) +PickGame (BOOLEAN saving) { BOOLEAN retval; CONTEXT OldContext; - SUMMARY_DESC desc_array[MAX_SAVED_GAMES]; + MENU_STATE MenuState; + PICK_GAME_STATE pickState; RECT DlgRect; STAMP DlgStamp; TimeCount TimeOut; InputFrameCallback *oldCallback; + memset (&pickState, 0, sizeof pickState); + pickState.saving = saving; + pickState.SummaryFrame = SetAbsFrameIndex (PlayFrame, 39); + if (LastActivity == CHECK_LOAD) + pickState.abortOnCancel = TRUE; + + memset (&MenuState, 0, sizeof MenuState); + MenuState.privData = &pickState; + // select the last used slot + MenuState.CurState = prev_save; + TimeOut = FadeMusic (0, ONE_SECOND / 2); // Deactivate any background drawing, like planet rotation oldCallback = SetInputCallback (NULL); - LoadGameDescriptions (desc_array); + LoadGameDescriptions (pickState.summary); LockMutex (GraphicsLock); OldContext = SetContext (SpaceContext); - // Save the current state of the screen for later restoration DlgStamp = SaveContextFrame (NULL); GetContextClipRect (&DlgRect); - - pMS->Initialized = FALSE; - pMS->InputFunc = DoPickGame; - pMS->Extra = desc_array; UnlockMutex (GraphicsLock); SleepThreadUntil (TimeOut); @@ -1111,16 +1032,43 @@ StopSound (); FadeMusic (NORMAL_VOLUME, 0); - DoInput (pMS, TRUE); + // draw the current savegame and fade in + LockMutex (GraphicsLock); + SetTransitionSource (NULL); + BatchGraphics (); + + SetContextBackGroundColor (BLACK_COLOR); + ClearDrawable (); + RedrawPickDisplay (&pickState, MenuState.CurState); + DrawSaveLoad (&pickState); + + if (pickState.abortOnCancel) + { + UnbatchGraphics (); + FadeScreen (FadeAllToColor, ONE_SECOND / 2); + } + else + { + RECT ctxRect; + GetContextClipRect (&ctxRect); + ScreenTransition (3, &ctxRect); + UnbatchGraphics (); + } + UnlockMutex (GraphicsLock); + + SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, + MENU_SOUND_SELECT); + MenuState.InputFunc = DoPickGame; + MenuState.Initialized = TRUE; + DoInput (&MenuState, TRUE); + LockMutex (GraphicsLock); - pMS->Initialized = FALSE; - pMS->InputFunc = DoGameOptions; retval = TRUE; if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) { - if (pMS->CurState == SAVE_GAME) + if (saving) GLOBAL (CurrentActivity) &= ~CHECK_LOAD; retval = FALSE; @@ -1143,7 +1091,7 @@ // Reactivate any background drawing, like planet rotation SetInputCallback (oldCallback); - return (retval); + return retval; } static BOOLEAN @@ -1165,7 +1113,6 @@ DrawMenuStateStrings (PM_SAVE_GAME, pMS->CurState); pMS->Initialized = TRUE; - pMS->InputFunc = DoGameOptions; } else if (PulsedInputState.menu[KEY_MENU_CANCEL] || (PulsedInputState.menu[KEY_MENU_SELECT] @@ -1183,7 +1130,7 @@ LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); - if (!PickGame (pMS)) + if (!PickGame (pMS->CurState == SAVE_GAME)) return FALSE; LockMutex (GraphicsLock); SetFlashRect (SFR_MENU_3DO); @@ -1211,10 +1158,8 @@ { MENU_STATE MenuState; - pLocMenuState = &MenuState; + memset (&MenuState, 0, sizeof MenuState); - memset (pLocMenuState, 0, sizeof (MenuState)); - MenuState.InputFunc = DoGameOptions; MenuState.CurState = SAVE_GAME; @@ -1229,8 +1174,6 @@ SetFlashRect (NULL); UnlockMutex (GraphicsLock); - pLocMenuState = 0; - return ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) ? FALSE : TRUE); } Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2009-12-11 23:19:36 UTC (rev 3424) +++ trunk/sc2/src/uqm/menustat.h 2009-12-12 00:34:07 UTC (rev 3425) @@ -43,7 +43,10 @@ MUSIC_REF hMusic; - void *Extra; + // For private use by various menus + // Usually, a menu associates its internal data struct using this + void *privData; + } MENU_STATE; // XXX: Should probably go to menu.h (does not yet exist) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-17 01:24:10
|
Revision: 3433 http://sc2.svn.sourceforge.net/sc2/?rev=3433&view=rev Author: avolkov Date: 2009-12-17 01:24:02 +0000 (Thu, 17 Dec 2009) Log Message: ----------- Split off SDL-specific colormap bits into SDL domain; fixed minor SDL_Palette access bug; some colormap processing cleanups Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/graphics/cmap.c trunk/sc2/src/libs/graphics/cmap.h trunk/sc2/src/libs/graphics/gfx_common.h trunk/sc2/src/libs/graphics/sdl/Makeinfo trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/sdl/sdl_common.c trunk/sc2/src/libs/graphics/sdl/sdl_common.h trunk/sc2/src/libs/graphics/tfb_draw.h trunk/sc2/src/uqm/commanim.c trunk/sc2/src/uqm/oscill.c trunk/sc2/src/uqm/starcon.c trunk/sc2/src/uqm.c Added Paths: ----------- trunk/sc2/src/libs/graphics/sdl/palette.c trunk/sc2/src/libs/graphics/sdl/palette.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/ChangeLog 2009-12-17 01:24:02 UTC (rev 3433) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Split off SDL-specific colormap bits into SDL domain - Alex - Fixed planet blinking when exiting scan (bug #799) - Alex - Restore menu sounds after editing a control set name (bug #1066) - Alex - Use an own 'UniChar' rather than 'wchar_t', which may not be large Modified: trunk/sc2/src/libs/graphics/cmap.c =================================================================== --- trunk/sc2/src/libs/graphics/cmap.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/cmap.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -16,7 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gfx_common.h" +#include "libs/graphics/cmap.h" +#include "libs/threadlib.h" #include "libs/timelib.h" #include "libs/inplib.h" #include "libs/log.h" @@ -48,10 +49,11 @@ static sint32 fadeInterval; #define SPARE_COLORMAPS 20 -#define MAP_POOL_SIZE (MAX_COLORMAPS + SPARE_COLORMAPS) -static TFB_ColorMap mappool[MAP_POOL_SIZE]; +// Colormaps are rapidly replaced in some parts of the game, so +// it pays to have some spares on hand static TFB_ColorMap *poolhead; +static int poolcount; static TFB_ColorMap * colormaps[MAX_COLORMAPS]; static int mapcount; @@ -65,11 +67,6 @@ // init colormaps maplock = CreateMutex ("Colormaps Lock", SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); - // init static pool - for (i = 0; i < MAP_POOL_SIZE - 1; ++i) - mappool[i].next = mappool + i + 1; - mappool[i].next = NULL; - poolhead = mappool; // init xform control XFormControl.Highest = -1; @@ -81,6 +78,15 @@ void UninitColorMaps (void) { + TFB_ColorMap *next; + + // free spares + for ( ; poolhead; poolhead = next) + { + next = poolhead->next; + HFree (poolhead); + } + // uninit xform control DestroyMutex (XFormControl.Lock); @@ -94,12 +100,22 @@ { TFB_ColorMap *map; - if (!poolhead) - return NULL; - - map = poolhead; - poolhead = map->next; - + if (poolhead) + { // have some spares + map = poolhead; + poolhead = map->next; + --poolcount; + } + else + { // no spares, need a new one + map = HMalloc (sizeof (*map)); + map->palette = AllocNativePalette (); + if (!map->palette) + { + HFree (map); + return NULL; + } + } map->next = NULL; map->index = -1; map->refcount = 1; @@ -117,26 +133,9 @@ map = alloc_colormap (); if (!map) { - static DWORD NextTime = 0; - DWORD Now; - - if (!from) - { - log_add (log_Warning, "FATAL: clone_colormap(): " - "no maps available"); - exit (EXIT_FAILURE); - } - - Now = GetTimeCounter (); - if (Now >= NextTime) - { - log_add (log_Warning, "clone_colormap(): static pool exhausted"); - NextTime = Now + ONE_SECOND; - } - - // just overwrite the current one -- better than aborting - map = from; - from->refcount++; + log_add (log_Warning, "FATAL: clone_colormap(): " + "could not allocate a map"); + exit (EXIT_FAILURE); } else { // fresh new map @@ -158,8 +157,17 @@ return; } - map->next = poolhead; - poolhead = map; + if (poolcount < SPARE_COLORMAPS) + { // return to the spare pool + map->next = poolhead; + poolhead = map; + ++poolcount; + } + else + { // don't need any more spares + FreeNativePalette (map->palette); + HFree (map); + } } static inline TFB_ColorMap * @@ -216,21 +224,15 @@ } void -TFB_ColorMapToRGB (Color *pal, int index) +GetColorMapColors (Color *colors, TFB_ColorMap *map) { - TFB_ColorMap *map = NULL; + int i; - if (index < mapcount) - map = colormaps[index]; - if (!map) - { - log_add (log_Warning, "TFB_ColorMapToRGB(): " - "requested non-present colormap %d", index); return; - } - memcpy (pal, map->colors, sizeof map->colors); + for (i = 0; i < NUMBER_OF_PLUTVALS; ++i) + colors[i] = GetNativePaletteColor (map->palette, i); } BOOLEAN @@ -279,18 +281,21 @@ for (mpp = colormaps + start; start <= end; ++start, ++mpp) { int i; - Color *pal; TFB_ColorMap *newmap; TFB_ColorMap *oldmap; oldmap = *mpp; newmap = clone_colormap (oldmap, start); - for (i = 0, pal = newmap->colors; i < NUMBER_OF_PLUTVALS; ++i, ++pal) + for (i = 0; i < NUMBER_OF_PLUTVALS; ++i, colors += PLUTVAL_BYTE_SIZE) { - pal->r = *colors++; - pal->g = *colors++; - pal->b = *colors++; + Color color; + + color.a = 0xff; + color.r = colors[PLUTVAL_RED]; + color.g = colors[PLUTVAL_GREEN]; + color.b = colors[PLUTVAL_BLUE]; + SetNativePaletteColor (newmap->palette, i, color); } *mpp = newmap; @@ -418,6 +423,11 @@ } } +static inline BYTE +blendChan (BYTE c1, BYTE c2, int weight, int scale) +{ + return c1 + ((int)c2 - c1) * weight / scale; +} /* This gives the XFormColorMap task a timeslice to do its thing * Only one thread should ever be allowed to be calling this at any time @@ -456,34 +466,32 @@ { #define XFORM_SCALE 0x10000 TFB_ColorMap *newmap = NULL; - UBYTE *pNewCMap; - Color *pCurCMap, *pOldCMap; + UBYTE *newClr; + Color *oldClr; int frac; int i; newmap = clone_colormap (curmap, index); - pCurCMap = newmap->colors; - pOldCMap = control->OldCMap; - pNewCMap = (UBYTE*)control->CMapPtr + 2; + oldClr = control->OldCMap; + newClr = (UBYTE*)control->CMapPtr + 2; frac = (int)(control->Ticks - TicksLeft) * XFORM_SCALE / control->Ticks; - for (i = 0; i < NUMBER_OF_PLUTVALS; i++, ++pCurCMap, ++pOldCMap) + for (i = 0; i < NUMBER_OF_PLUTVALS; ++i, ++oldClr, + newClr += PLUTVAL_BYTE_SIZE) { - - pCurCMap->r = (UBYTE)(pOldCMap->r + - ((int)*pNewCMap - pOldCMap->r) * frac / XFORM_SCALE); - pNewCMap++; + Color color; - pCurCMap->g = (UBYTE)(pOldCMap->g + - ((int)*pNewCMap - pOldCMap->g) * frac / XFORM_SCALE); - pNewCMap++; - - pCurCMap->b = (UBYTE)(pOldCMap->b + - ((int)*pNewCMap - pOldCMap->b) * frac / XFORM_SCALE); - pNewCMap++; + color.a = 0xff; + color.r = blendChan (oldClr->r, newClr[PLUTVAL_RED], + frac, XFORM_SCALE); + color.g = blendChan (oldClr->g, newClr[PLUTVAL_GREEN], + frac, XFORM_SCALE); + color.b = blendChan (oldClr->b, newClr[PLUTVAL_BLUE], + frac, XFORM_SCALE); + SetNativePaletteColor (newmap->palette, i, color); } colormaps[index] = newmap; @@ -575,7 +583,7 @@ log_add (log_Warning, "BUG: XFormPLUT(): no current map"); return (0); } - memcpy (control->OldCMap, map->colors, sizeof (map->colors)); + GetColorMapColors (control->OldCMap, map); UnlockMutex (maplock); control->CMapIndex = index; Modified: trunk/sc2/src/libs/graphics/cmap.h =================================================================== --- trunk/sc2/src/libs/graphics/cmap.h 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/cmap.h 2009-12-17 01:24:02 UTC (rev 3433) @@ -16,27 +16,44 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "tfb_draw.h" - #ifndef CMAP_H #define CMAP_H +#include "libs/gfxlib.h" + #define MAX_COLORMAPS 250 + +// These are pertinent to colortable file format +// We load colormaps as binary and parse them when needed #define PLUTVAL_BYTE_SIZE 3 +// Channel order in colormap tables +#define PLUTVAL_RED 0 +#define PLUTVAL_GREEN 1 +#define PLUTVAL_BLUE 2 + #define NUMBER_OF_PLUTVALS 256 +// Size of the colormap in a colortable file #define PLUT_BYTE_SIZE (PLUTVAL_BYTE_SIZE * NUMBER_OF_PLUTVALS) #define FADE_NO_INTENSITY 0 #define FADE_NORMAL_INTENSITY 255 #define FADE_FULL_INTENSITY 510 +typedef struct NativePalette NativePalette; + typedef struct tfb_colormap { - Color colors[NUMBER_OF_PLUTVALS]; int index; + // Colormap index as the game sees it int version; + // Version goes up every time the colormap changes. This may + // be due to SetColorMap() or at every transformation step + // of XFormColorMap(). Paletted TFB_Images track the last + // colormap version they were drawn with for optimization. int refcount; struct tfb_colormap *next; + // for spares linking + NativePalette *palette; } TFB_ColorMap; extern int GetFadeAmount (void); @@ -44,11 +61,17 @@ extern void InitColorMaps (void); extern void UninitColorMaps (void); -extern void TFB_ColorMapToRGB (Color *pal, int colormap_index); +extern void GetColorMapColors (Color *colors, TFB_ColorMap *); + extern TFB_ColorMap * TFB_GetColorMap (int index); extern void TFB_ReturnColorMap (TFB_ColorMap *map); extern BOOLEAN XFormColorMap_step (void); +// Native +NativePalette* AllocNativePalette (void); +void FreeNativePalette (NativePalette *); +void SetNativePaletteColor (NativePalette *, int index, Color); +Color GetNativePaletteColor (NativePalette *, int index); -#endif +#endif /* CMAP_H */ Modified: trunk/sc2/src/libs/graphics/gfx_common.h =================================================================== --- trunk/sc2/src/libs/graphics/gfx_common.h 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/gfx_common.h 2009-12-17 01:24:02 UTC (rev 3433) @@ -99,6 +99,4 @@ extern int ScreenColorDepth; extern int GraphicsDriver; -#include "cmap.h" - #endif Modified: trunk/sc2/src/libs/graphics/sdl/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-17 01:24:02 UTC (rev 3433) @@ -1,4 +1,5 @@ uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c + palette.c primitives.c pure.c rndzoom.c sdl_common.c scalers.c 2xscalers.c 2xscalers_mmx.c 2xscalers_sse.c 2xscalers_3dnow.c Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -18,10 +18,12 @@ #include SDL_INCLUDE(SDL.h) #include "sdl_common.h" #include "libs/graphics/gfx_common.h" -#include "libs/graphics/sdl/primitives.h" #include "libs/graphics/tfb_draw.h" +#include "libs/graphics/cmap.h" #include "libs/log.h" #include "libs/memlib.h" +#include "primitives.h" +#include "palette.h" #include "rotozoom.h" #include "options.h" #include "types.h" @@ -80,13 +82,15 @@ SDL_FillRect (dst, &sr, sdlColor); } +// XXX: If a colormap is passed in, it has to have been acquired via +// TFB_GetColorMap(). We release the colormap at the end. void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, TFB_Canvas target) { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; - Color *palette; + SDL_Palette *NormalPal; if (img == 0) { @@ -97,15 +101,10 @@ LockMutex (img->mutex); - if (cmap) - palette = cmap->colors; - else - palette = img->Palette; - + NormalPal = ((SDL_Surface *)img->NormalImg)->format->palette; // only set the new palette if it changed - if (((SDL_Surface *)img->NormalImg)->format->palette - && cmap && img->colormap_version != cmap->version) - SDL_SetColors (img->NormalImg, (SDL_Color*)palette, 0, 256); + if (NormalPal && cmap && img->colormap_version != cmap->version) + SDL_SetColors (img->NormalImg, cmap->palette->colors, 0, 256); if (scale != 0 && scale != GSCALE_IDENTITY) { @@ -114,9 +113,9 @@ if (type == TFB_SCALE_TRILINEAR && img->MipmapImg) { // only set the new palette if it changed - if (((SDL_Surface *)img->MipmapImg)->format->palette + if (TFB_DrawCanvas_IsPaletted (img->MipmapImg) && cmap && img->colormap_version != cmap->version) - SDL_SetColors (img->MipmapImg, (SDL_Color*)palette, 0, 256); + SDL_SetColors (img->MipmapImg, cmap->palette->colors, 0, 256); } else if (type == TFB_SCALE_TRILINEAR && !img->MipmapImg) { @@ -125,8 +124,13 @@ TFB_DrawImage_FixScaling (img, scale, type); surf = img->ScaledImg; - if (surf->format->palette) - SDL_SetColors (surf, (SDL_Color*)palette, 0, 256); + if (TFB_DrawCanvas_IsPaletted (surf)) + { + // We may only get a paletted scaled image if the source is + // paletted. Currently, all scaling targets are truecolor. + assert (NormalPal && NormalPal->colors); + SDL_SetColors (surf, NormalPal->colors, 0, NormalPal->ncolors); + } srcRect.x = 0; srcRect.y = 0; @@ -149,6 +153,9 @@ if (cmap) { img->colormap_version = cmap->version; + // TODO: Technically, this is not a proper place to release a + // colormap. As it stands now, the colormap must have been + // addrefed when passed to us. TFB_ReturnColorMap (cmap); } @@ -248,6 +255,7 @@ { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; + SDL_Palette *palette; int i; bool force_fill = false; @@ -299,7 +307,8 @@ targetRect.y = y - img->NormalHs.y; } - if (surf->format->palette) + palette = surf->format->palette; + if (palette) { // set palette for fill-stamp // Calling SDL_SetColors() results in an expensive src -> dst // color-mapping operation for an SDL blit, following the call. @@ -307,15 +316,13 @@ // TODO: generate a 32bpp filled image? - SDL_Color pal[256]; + SDL_Color colors[256]; - for (i = 0; i < 256; i++) - { - pal[i].r = color.r; - pal[i].g = color.g; - pal[i].b = color.b; - } - SDL_SetColors (surf, pal, 0, 256); + colors[0] = ColorToNative (color); + for (i = 1; i < palette->ncolors; i++) + colors[i] = colors[0]; + + SDL_SetColors (surf, colors, 0, palette->ncolors); // reflect the change in *actual* image palette img->colormap_version--; } @@ -488,7 +495,7 @@ } TFB_Canvas -TFB_DrawCanvas_New_Paletted (int w, int h, Color *palette, +TFB_DrawCanvas_New_Paletted (int w, int h, Color palette[256], int transparent_index) { SDL_Surface *new_surf; @@ -501,7 +508,7 @@ } if (palette != NULL) { - SDL_SetColors(new_surf, (SDL_Color *)palette, 0, 256); + TFB_DrawCanvas_SetPalette (new_surf, palette); } if (transparent_index >= 0) { @@ -608,21 +615,18 @@ { int i; Color *result; - SDL_Surface *surf = (SDL_Surface *)canvas; + SDL_Palette *palette = surf->format->palette; - if (!surf->format->palette) - { + if (!palette) return NULL; - } - result = (Color *) HMalloc (sizeof (Color) * 256); - for (i = 0; i < 256; ++i) - { - result[i].r = surf->format->palette->colors[i].r; - result[i].g = surf->format->palette->colors[i].g; - result[i].b = surf->format->palette->colors[i].b; - } + // There may be less colors in the surface than 256. Init to 0 first. + result = HCalloc (sizeof (Color) * 256); + assert (palette->ncolors <= 256); + for (i = 0; i < palette->ncolors; ++i) + result[i] = NativeToColor (palette->colors[i]); + return result; } @@ -656,9 +660,15 @@ } void -TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color *palette) +TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color palette[256]) { - SDL_SetColors ((SDL_Surface *)target, (SDL_Color *)palette, 0, 256); + SDL_Color colors[256]; + int i; + + for (i = 0; i < 256; ++i) + colors[i] = ColorToNative (palette[i]); + + SDL_SetColors ((SDL_Surface *)target, colors, 0, 256); } int Added: trunk/sc2/src/libs/graphics/sdl/palette.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/palette.c (rev 0) +++ trunk/sc2/src/libs/graphics/sdl/palette.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -0,0 +1,47 @@ +/* + * Copyright 2009 Alex Volkov <co...@us...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "palette.h" +#include "libs/memlib.h" +#include "libs/log.h" + +NativePalette * +AllocNativePalette (void) +{ + return HCalloc (sizeof (NativePalette)); +} + +void +FreeNativePalette (NativePalette *palette) +{ + HFree (palette); +} + +void +SetNativePaletteColor (NativePalette *palette, int index, Color color) +{ + assert (index < NUMBER_OF_PLUTVALS); + palette->colors[index] = ColorToNative (color); +} + +Color +GetNativePaletteColor (NativePalette *palette, int index) +{ + assert (index < NUMBER_OF_PLUTVALS); + return NativeToColor (palette->colors[index]); +} Property changes on: trunk/sc2/src/libs/graphics/sdl/palette.c ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/sc2/src/libs/graphics/sdl/palette.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/palette.h (rev 0) +++ trunk/sc2/src/libs/graphics/sdl/palette.h 2009-12-17 01:24:02 UTC (rev 3433) @@ -0,0 +1,53 @@ +/* + * Copyright 2009 Alex Volkov <co...@us...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PALETTE_H_INCL__ +#define PALETTE_H_INCL__ + +#include "port.h" +#include SDL_INCLUDE(SDL.h) +#include "libs/graphics/cmap.h" + +struct NativePalette +{ + SDL_Color colors[NUMBER_OF_PLUTVALS]; +}; + +static inline Color +NativeToColor (SDL_Color native) +{ + Color color; + color.r = native.r; + color.g = native.g; + color.b = native.b; + color.a = 0xff; // fully opaque + return color; +} + +static inline SDL_Color +ColorToNative (Color color) +{ + SDL_Color native; + native.r = color.r; + native.g = color.g; + native.b = color.b; + native.unused = 0; + return native; +} + +#endif /* PALETTE_H_INCL__ */ Property changes on: trunk/sc2/src/libs/graphics/sdl/palette.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -26,6 +26,7 @@ #include "options.h" #include "uqmversion.h" #include "libs/graphics/drawcmd.h" +#include "libs/graphics/cmap.h" #include "libs/input/sdl/input.h" // for ProcessInputEvent() #include "bbox.h" Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.h 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.h 2009-12-17 01:24:02 UTC (rev 3433) @@ -38,8 +38,6 @@ extern TFB_GRAPHICS_BACKEND *graphics_backend; -// constants for TFB_InitGraphics - extern SDL_Surface *SDL_Video; extern SDL_Surface *SDL_Screen; extern SDL_Surface *TransitionScreen; Modified: trunk/sc2/src/libs/graphics/tfb_draw.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-17 01:24:02 UTC (rev 3433) @@ -33,7 +33,7 @@ } SCREEN; #include "libs/graphics/gfx_common.h" -#include "cmap.h" +#include "libs/graphics/cmap.h" typedef struct tfb_image { @@ -119,7 +119,7 @@ TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha); TFB_Canvas TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha); -TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, Color *palette, +TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, Color palette[256], int transparent_index); TFB_Canvas TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, TFB_Canvas oldcanvas, int type, int last_type); @@ -154,7 +154,7 @@ TFB_Canvas target); Color *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas); -void TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color *palette); +void TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color palette[256]); int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas); void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, BOOLEAN rleaccel); Modified: trunk/sc2/src/uqm/commanim.c =================================================================== --- trunk/sc2/src/uqm/commanim.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/uqm/commanim.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -23,7 +23,7 @@ #include "element.h" #include "setup.h" #include "libs/compiler.h" -#include "libs/graphics/gfx_common.h" +#include "libs/graphics/cmap.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/oscill.c =================================================================== --- trunk/sc2/src/uqm/oscill.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/uqm/oscill.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -41,6 +41,8 @@ if (!scope_init) { TFB_Canvas scope_bg_canvas, scope_surf_canvas; + // TODO: this scope image copying does not properly account for + // the loaded colormaps. This should use regular primitives. if (TFB_DrawCanvas_IsPaletted (scope_frame->image->NormalImg)) { scope_bg_canvas = TFB_DrawCanvas_New_Paletted (width, height, Modified: trunk/sc2/src/uqm/starcon.c =================================================================== --- trunk/sc2/src/uqm/starcon.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/uqm/starcon.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -43,6 +43,7 @@ #include "libs/log.h" #include "libs/gfxlib.h" #include "libs/graphics/gfx_common.h" +#include "libs/graphics/tfb_draw.h" #include "libs/misc.h" #include "uqmversion.h" Modified: trunk/sc2/src/uqm.c =================================================================== --- trunk/sc2/src/uqm.c 2009-12-16 05:23:28 UTC (rev 3432) +++ trunk/sc2/src/uqm.c 2009-12-17 01:24:02 UTC (rev 3433) @@ -28,6 +28,7 @@ #include <stdarg.h> #include "libs/graphics/gfx_common.h" +#include "libs/graphics/cmap.h" #include "libs/sound/sound.h" #include "libs/input/input_common.h" #include "libs/inplib.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-18 23:20:36
|
Revision: 3440 http://sc2.svn.sourceforge.net/sc2/?rev=3440&view=rev Author: avolkov Date: 2009-12-18 23:20:29 +0000 (Fri, 18 Dec 2009) Log Message: ----------- Cleanup: removed unused graphics/sdl/rndzoom.c Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/graphics/sdl/Makeinfo Removed Paths: ------------- trunk/sc2/src/libs/graphics/sdl/rndzoom.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-18 23:18:28 UTC (rev 3439) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-18 23:20:29 UTC (rev 3440) @@ -372,10 +372,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\sdl\rndzoom.c -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\sdl\rotozoom.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/graphics/sdl/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-18 23:18:28 UTC (rev 3439) +++ trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-18 23:20:29 UTC (rev 3440) @@ -1,6 +1,6 @@ uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c palette.c - primitives.c pure.c rndzoom.c sdl_common.c + primitives.c pure.c sdl_common.c scalers.c 2xscalers.c 2xscalers_mmx.c 2xscalers_sse.c 2xscalers_3dnow.c nearest2x.c bilinear2x.c biadv2x.c triscan2x.c hq2x.c Deleted: trunk/sc2/src/libs/graphics/sdl/rndzoom.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/rndzoom.c 2009-12-18 23:18:28 UTC (rev 3439) +++ trunk/sc2/src/libs/graphics/sdl/rndzoom.c 2009-12-18 23:20:29 UTC (rev 3440) @@ -1,555 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* - The adjustments are as follows: - BLUR_TYPE: - 0: No blur - 1: A fast but very blurry convolution - 2: A fast implementation of gaussian_blur with R0 = 0.8 - 3: Full 7x7 gaussian blur. use R0 to control how blurry to get - larger R0 numbers == more blurry. - RANDOM_METHOD: - 0: Use standard RotoZoom without interpolation - 1: Use standard RotoZoom with interpolationn - 2: Choose at random from nearest neighors - 3: Choose from nearest-neighbors with probability based on - distance from each pixel - 4: Use the 'smart' random method, which gaurantees a path of - constant color from a given pixel to one of the nearest - neighbors. Randomization is based on a weighted average of - distance to each nearest neighbor. -*/ -#define BLUR_TYPE 2 -#define R0 0.8 -#define RANDOM_METHOD 3 - -#ifdef GFXMODULE_SDL - -#ifdef WIN32 -#include <io.h> -#endif -#include <fcntl.h> - -#include "sdl_common.h" -#include "primitives.h" -#include "libs/log.h" - -#ifndef MAX -#define MAX(x,y) ((x) < (y) ? (y) : (x)) -#endif -#ifndef MIN -#define MIN(x,y) ((x) > (y) ? (y) : (x)) -#endif -#if 0 -int MAX(int x, int y) -{ - return ((x) < (y) ? (y) : (x)); -} - -int MIN (int x, int y) -{ - return ((x) > (y) ? (y) : (x)); -} -#endif - -void blurSurface32 (SDL_Surface *src) -{ - typedef struct - { - Uint32 r, g, b; - } color; - GetPixelFn getpix; - Uint32 *ptr; - int y, x, yy, xx; - Uint32 i, offset, ypos, yof; -#if BLUR_TYPE == 1 - #define MWID 3 - #define ARRAY_SIZE 4 - #define BLUR_NORM(f) MIN (255, (f) >> 2) - #define BLUR_SHIFT(x,f) ((x) << shift[f]) - #define NEED_ZERO_SHIFT - unsigned char idx[MWID * MWID] = - { - 0, 1, 0, - 1, 1, 1, - 0, 1, 0 - }; - int shift[ARRAY_SIZE] = {0, 0, 1, 3}; - color *blur_array[ARRAY_SIZE]; -#elif BLUR_TYPE == 2 - #define MWID 3 - #define ARRAY_SIZE 3 - #define BLUR_NORM(f) MIN (255, (f) >> 9) - #define BLUR_SHIFT(x,f) ((x) * shift[f]) - unsigned char idx[MWID * MWID] = - { - 0, 1, 0, - 1, 2, 1, - 0, 1, 0 - }; - int shift[ARRAY_SIZE] = {21, 62, 182}; - color *blur_array[ARRAY_SIZE]; -#elif BLUR_TYPE == 3 - #define MWID 7 - #define BLUR_NORM(f) MIN (255, (int)((f) / sum)) - #define BLUR_SHIFT(x,f) ((Uint32)((x) * shift[f])) - // array-size is the triangular number of (MWID+1)/2 - #define ARRAY_SIZE ((((MWID + 1) >> 1) * (((MWID + 1) >> 1) + 1)) >> 1) - float sum = 0.0; - float shift[ARRAY_SIZE]; - color *blur_array[ARRAY_SIZE]; - unsigned char idx[MWID * MWID]; - { - // Build th eidx and shift arrays using the gaussian function - unsigned int i, j, k = 0; - unsigned int r_2; - for (i = 0; i <= (MWID >> 1); i++) - { - for (j = 0; j <= i; j++) - { - r_2 = i * i + j * j; - shift[k] = 1000 * (float)exp (- log (2) * r_2 / (R0 * R0)); - if (i == 0 && j == 0) - sum += shift[k]; - else if (j == 0 || i == j) - sum += 4 * shift[k]; - else - sum += 8 * shift[k]; - y = (MWID >> 1) - i; - x = (MWID >> 1) - j; - idx[y * MWID + x] = k; - idx[y * MWID + MWID - x - 1] = k; - idx[(MWID - y - 1) * MWID + x] = k; - idx[(MWID - y - 1) * MWID + MWID - x - 1] = k; - idx[x * MWID + y] = k; - idx[x * MWID + MWID - y - 1] = k; - idx[(MWID - x - 1) * MWID + y] = k; - idx[(MWID - x - 1) * MWID + MWID - y - 1] = k; - k++; - } - } -// printf ("sum is: %f\n", sum); -// i = 0; -// for(y = 0; y < MWID; y++) -// { -// for (x = 0; x< MWID; x++) -// printf(" %f", shift[idx[i++]]); -// printf("\n"); -// } - } -#else - #define MWID 3 - #define ARRAY_SIZE 1 - #define BLUR_NORM(f) MIN (255, (f) >> 2) - #define BLUR_SHIFT(x,f) ((x) << shift[f]) - unsigned char idx[1]; - int shift[1]; - color *blur_array[1]; - return; -#endif - - if (src->format->BitsPerPixel != 32) - { - log_add (log_Debug, "blurSurface32 requires a 32bit Surface, but surface is %d bits!\n", - src->format->BitsPerPixel); - return; - } - SDL_LockSurface (src); - getpix = getpixel_for (src); - - // Make ARRAY_SIZE copies of the surface, each multiplied by a constant in 'shift' - for(i = 0; i < ARRAY_SIZE; i++) - blur_array[i] = (color *)HMalloc (sizeof(color) * - (src->w + MWID - 1) * (src->h + MWID - 1)); - offset = 0; - ptr = src->pixels; - // the blur_array matrices are larger than the target surface by MWID - 1 - // this is to allow convolving to work at the image edges. - // note that the convolution 'wraps' around on the x coordinate, butnot the y - for (y = -(MWID >> 1); y < src->h + (MWID >> 1); y++) - { - for (x = - (MWID >> 1); x < src->w + (MWID >> 1); x++) - { - unsigned char r, g, b; - Uint32 pixel; - i = 0; - if (x < 0) - pixel = getpix (src, x + src->w, MIN (src->h - 1, MAX (0, y))); - else if (x >= src->w) - pixel = getpix (src, x - src->w, MIN (src->h - 1, MAX (0, y))); - else if (y < 0 || y >= src->h) - pixel = getpix (src, x, MIN (src->h - 1, MAX (0, y))); - else - pixel = *ptr++; - SDL_GetRGB (pixel, src->format, &r, &g, &b); -#ifdef NEED_ZERO_SHIFT - blur_array[i][offset].r = 0; - blur_array[i][offset].g = 0; - blur_array[i][offset].b = 0; - i++; -#endif - for (; i < ARRAY_SIZE; i++) { - blur_array[i][offset].r = BLUR_SHIFT((Uint32)r,i); - blur_array[i][offset].g = BLUR_SHIFT((Uint32)g,i); - blur_array[i][offset].b = BLUR_SHIFT((Uint32)b,i); - } - offset++; - } - } - ptr = src->pixels; - ypos =0; - // actually do theconvolving here. - for (y = 0; y < src->h; y++, ypos += src->w + (MWID - 1)) - { - for (x = 0; x < src->w; x++) - { - Uint32 pixel; - Uint32 bluroff, idxoff; - color p; - p.r =0; - p.g =0; - p.b =0; - idxoff = 0; - yof = ypos; - for (yy = - (MWID >> 1); yy <= (MWID >> 1); yy++) - { - bluroff = yof + x; - for (xx = - (MWID >> 1); xx <= (MWID >> 1); xx++) - { - p.r+=blur_array[idx[idxoff]][bluroff].r; - p.g+=blur_array[idx[idxoff]][bluroff].g; - p.b+=blur_array[idx[idxoff]][bluroff].b; - idxoff++; - bluroff++; - } - yof += src->w + (MWID - 1); - } - p.r = BLUR_NORM(p.r); - p.g = BLUR_NORM(p.g); - p.b = BLUR_NORM(p.b); - pixel = SDL_MapRGB (src->format, (Uint8)p.r, (Uint8)p.g, (Uint8)p.b); - *ptr++ = pixel; - } - } - SDL_UnlockSurface (src); - for(i = 0; i < ARRAY_SIZE; i++) - HFree (blur_array[i]); -} - -/* the rZF_nearestneighbor method fills the 'dst' image with the 'src' image - (performing a 16x zoom). The interior points are generated by randomly choosing - the color of one of the 4 nearest neighbors. The randomization method is either - an even probability i.e 1/4, or a weighted probabliliity based on the distance - from each of the neighbors -*/ -void rZF_nearestneighbor (SDL_Surface *src, SDL_Surface *dst, int use_weight) -{ - int x, y; - Uint32 p00, p01, p10, p11; - Uint32 *yptr, *y1ptr, *dstptr; - UBYTE rand2; - UWORD prob_even[] = {64, 128, 192}; - UWORD prob_weight[] = { - 256, 256, 256, 144, 178, 127, 88, 127, 215, 48, 76, 220, - 144, 192, 226, 114, 165, 216, 79, 127, 206, 51, 89, 203, - 88, 176, 215, 79, 158, 206, 64, 128, 192, 48, 96, 175, - 48, 192, 220, 51, 165, 203, 48, 127, 175, 38, 89, 140 - }; - UWORD *pry = prob_weight, *pr; - if (!use_weight) - pr = prob_even; - yptr = src->pixels; - y1ptr= yptr + src->w; - dstptr = dst->pixels; - for (y = 0; y < dst->h; y++) - { - if (y) - { - if (!(y & 0x03)) - { - yptr += src->w; - if (y >> 2 < src->h - 1) - y1ptr += src->w; - if (use_weight) - pry = prob_weight; - } - else if (use_weight) - pry += 12; - } - for (x = 0; x < dst->w; x++) - { - Uint32 p; - if (! (x & 0x03)) - { - int x0 = x >> 2; - p00 = *(yptr + x0); - p01 = *(y1ptr + x0); - if(x0 < src->w - 1) - { - p10 = *(yptr + x0 + 1); - p11 = *(y1ptr + x0 + 1); - } - else - { - p10 = *yptr; - p11 = *y1ptr; - } - if (use_weight) - pr = pry; - } - else - { - if (use_weight) - pr += 3; - } - rand2 = rand() & 0xff; - if (rand2 < pr[0]) - p =p00; - else if (rand2 < pr[1]) - p = p01; - else if (rand2 < pr[2]) - p = p10; - else - p = p11; - *dstptr++ = p; - } - } -} - -/* the rZF_continuous method fills the 'dst' image with the 'src' image - (performing a 16x zoom). The interior points are generated by randomly choosing - the color of one of the 4 nearest neighbors. However, it is gauranteed that there - will bbe a path of constant color from the current pixel to the nearest-neighbor - that was chosen. The randomization function is biased by the pixel's distance - fromit's neighbors -*/ -void rZF_continuous (SDL_Surface *src, SDL_Surface *dst) -{ - int rnd[] = {192, 171, 128, 0}; - GetPixelFn getpix; - PutPixelFn putpix; - int rand2, dx, dy; - Uint32 pnew; - int x, y, x1, y1; - Uint32 p01, p10, p11; - int rand1; - getpix = getpixel_for (src); - putpix = putpixel_for (dst); - putpix (dst, 0, 0, getpix (src, 0, 0)); - for (y = 0; y < src->h; y++) - { - p10 = getpix (src, 0, y); - if (y == src->h - 1) - p11 = getpix (src, 0, y); - else - p11 = getpix (src, 0, y + 1); - for (y1 = 0; y1 < 4; y1++) - { - dy = (y << 2) + y1; - rand1 = rand () & 0xff; - if (rand1 < rnd[y1]) - pnew = p10; - else - { - pnew = p11; - p10 = p11; - } - putpix (dst, 0, dy, pnew); - } - } - for (x = 0; x < src->w; x++) - { - p10 = getpix (src, x, 0); - if (x == src->w - 1) - p11 = getpix (src, 0, 0); - else - p11 = getpix (src, x + 1, 0); - for (x1 = 0; x1 < 4; x1++) - { - dx = (x << 2) + x1; - rand1 = rand () & 0xff; - if (rand1 < rnd[x1]) - pnew = p10; - else - { - pnew = p11; - p10 = p11; - } - putpix (dst, dx, 0, pnew); - } - } - - for (y = 1; y <= src->h; y++) - { - int fromy, fromy4; - if (y == src->h) - fromy = y - 1; - else - fromy = y; - fromy4 = fromy << 2; - for(x = 1; x <= src->w; x++) - { - int fromx, fromx4; - int dy1; - Uint32 p00; - char cpl[3][3] = {{0,0,0},{0,0,0},{0,0,0}}; - if (x == src->w) - fromx = 0; - else - fromx = x; - fromx4 = fromx << 2; - dx = x << 2; - p00 = getpix (src, x - 1, y - 1); - p10 = getpix (src, fromx, y - 1); - p01 = getpix (src, x - 1, fromy); - p11 = getpix (src, fromx, fromy); - if (x != src->w) { - for (y1 = 0; y1 < 4; y1++) - { - if (y == src->h && y1 == 3) - continue; - dy = ((y - 1) << 2) + y1 + 1; - rand1 = rand () & 0xff; - if (rand1 < rnd[y1]) - pnew = p01; - else - { - pnew = p11; - p01 = p11; - } - putpix (dst, dx, dy, pnew); - } - } - if (y != src->h) - { - dy = y << 2; - for (x1 = 0; x1 < 3; x1++) - { - dx = ((x - 1) << 2) + x1 + 1; - rand1 = rand () & 0xff; - if (rand1 < rnd[x1]) - pnew = p10; - else - { - pnew = p11; - p10 = p11; - } - putpix (dst, dx, dy, pnew); - } - } - for (y1 = 0; y1 < 3; y1++) - { - for (x1 = 0; x1 < 3; x1++) - { - int dxx, dyy; - if (cpl[x1][y1]) - continue; - dyy=dy = ((y - 1) << 2) + y1 + 1; - dxx=dx = ((x - 1) << 2) + x1 + 1; - rand1 = rand () & 0xff; - rand2 = rand () & 0xff; - if (rand1 < 128) - { - if (rand2 < rnd[x1]) - { - putpix (dst, dx, dy, getpix (dst, dx - 1, dy)); - } - else - { - p00 = getpix (dst, fromx4, dy); - while (dx < x <<2) - { - putpix (dst, dx, dy, p00); - dx++; - x1++; - } - } - } - else - { - if (rand2 < rnd[y1]) - { - putpix (dst, dx, dy, getpix (dst, dx, dy - 1)); - } - else - { - p00 = getpix (dst, dx, fromy4); - dy1 = y1; - while (dy < y << 2) - { - putpix (dst, dx, dy, p00); - dy++; - cpl[x1][dy1] = 1; - dy1++; - } - } - } - if(getpix(dst,dxx,dyy) == 0) - printf ("wtf\n"); - } - } - } - } -} - -/* perform a 16x zoom, and then apply a blur filter to the result */ -void random16xZoomSurfaceRGBA (SDL_Surface *src, SDL_Surface *dst) -{ - /* - * Alloc space to completely contain the zoomed surface - */ - SDL_LockSurface (src); - SDL_LockSurface (dst); -#if RANDOM_METHOD == 0 - zoomSurfaceRGBA (src, dst, 0); -#elif RANDOM_METHOD == 1 - zoomSurfaceRGBA (src, dst, 1); -#elif RANDOM_METHOD == 2 - rZF_nearestneighbor (src, dst, 0); -#elif RANDOM_METHOD == 3 - rZF_nearestneighbor (src, dst, 1); -#else - rZF_continuous(src, dst); -#endif - SDL_UnlockSurface (src); - SDL_UnlockSurface (dst); - SDL_SetAlpha(dst, SDL_SRCALPHA, 255); - blurSurface32 (dst); -} - -FRAME scale16xRandomizeFrame (FRAME NewFrame, FRAME FramePtr) -{ - TFB_Image *origImg, *newImg; - CREATE_FLAGS flags; - - if (NewFrame == NULL) - { - flags = GetFrameParentDrawable (FramePtr)->Flags; - NewFrame = CaptureDrawable ( - CreateDrawable (flags, - GetFrameWidth (FramePtr) << 2, - GetFrameHeight (FramePtr) << 2, 1)); - } - - newImg = NewFrame->image; - origImg = FramePtr->image; - LockMutex (origImg->mutex); - random16xZoomSurfaceRGBA (origImg->NormalImg, newImg->NormalImg); - UnlockMutex (origImg->mutex); - return (NewFrame); -} -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-19 03:06:47
|
Revision: 3447 http://sc2.svn.sourceforge.net/sc2/?rev=3447&view=rev Author: avolkov Date: 2009-12-19 03:06:37 +0000 (Sat, 19 Dec 2009) Log Message: ----------- Match warnings between GCC and MSVC reasonably closely Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/port.h Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-19 02:18:43 UTC (rev 3446) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-19 03:06:37 UTC (rev 3447) @@ -44,7 +44,7 @@ # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\src" /I "..\..\src\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "THREADLIB_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "HAVE_JOYSTICK" /D "NETPLAY" /D "ZLIB_DLL" /D "USE_INTERNAL_MIKMOD" /D "USE_PLATFORM_ACCEL" /FD /c +# ADD CPP /nologo /MD /W2 /GX /Zi /O2 /I "..\..\src" /I "..\..\src\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "THREADLIB_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "HAVE_JOYSTICK" /D "NETPLAY" /D "ZLIB_DLL" /D "USE_INTERNAL_MIKMOD" /D "USE_PLATFORM_ACCEL" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -100,8 +100,7 @@ # PROP Intermediate_Dir "Debug_NoAccel" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT BASE CPP /YX +# ADD BASE CPP /nologo /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "..\..\src" /I "..\..\src\regex" /D "DEBUG" /D "_DEBUG" /D "DEBUG_TRACK_SEM" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "THREADLIB_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "HAVE_JOYSTICK" /D "NETPLAY" /D "ZLIB_DLL" /D "USE_INTERNAL_MIKMOD" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -128,9 +127,8 @@ # PROP Intermediate_Dir "Release_NoAccel" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\src" /I "..\..\src\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "THREADLIB_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "HAVE_JOYSTICK" /D "NETPLAY" /D "ZLIB_DLL" /D "USE_INTERNAL_MIKMOD" /FR /FD /c +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W2 /GX /Zi /O2 /I "..\..\src" /I "..\..\src\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "THREADLIB_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "HAVE_JOYSTICK" /D "NETPLAY" /D "ZLIB_DLL" /D "USE_INTERNAL_MIKMOD" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" Modified: trunk/sc2/src/port.h =================================================================== --- trunk/sc2/src/port.h 2009-12-19 02:18:43 UTC (rev 3446) +++ trunk/sc2/src/port.h 2009-12-19 03:06:37 UTC (rev 3447) @@ -33,14 +33,29 @@ # endif #endif + // Compilation warnings: -// UQM uses a lot of functions that can be used unsafely, but it uses them -// in a safe way. The warnings about these functions however may drown out -// serious warnings, so we turn them off. #ifdef _MSC_VER + // UQM uses a lot of functions that can be used unsafely, but it uses them + // in a safe way. The warnings about these functions however may drown out + // serious warnings, so we turn them off. # define _CRT_SECURE_NO_DEPRECATE + + // Escalate some warnings we consider important + // "'operator' : 'identifier1' indirection to slightly different base + // types from 'identifier2' +# pragma warning( 3 : 4057 ) + // "unreferenced formal parameter" +# pragma warning( 3 : 4100 ) + // "local variable 'name' may be used without having been initialized" +# pragma warning( 3 : 4701 ) + + // Downgrade some warnings we consider unimportant + // "'operator' conversion from 'type1' to 'type2', possible loss of data" +# pragma warning( 4 : 4244) #endif + #ifdef _MSC_VER # include <io.h> #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-22 02:35:24
|
Revision: 3463 http://sc2.svn.sourceforge.net/sc2/?rev=3463&view=rev Author: avolkov Date: 2009-12-22 02:35:16 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Pass graphics scaling mode properly through DCQ; fixes black pixel gaps between the planet and shield when entering orbit Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/graphics/context.c trunk/sc2/src/libs/graphics/drawcmd.h trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/sdl/sdl_common.c trunk/sc2/src/libs/graphics/tfb_draw.c trunk/sc2/src/libs/graphics/tfb_draw.h trunk/sc2/src/libs/graphics/tfb_prim.c trunk/sc2/src/libs/video/vidplayer.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/ChangeLog 2009-12-22 02:35:16 UTC (rev 3463) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Fixed black pixel gaps between the planet and shield when entering the + orbit of a shielded planet (bug #32) - Alex - Split off SDL-specific colormap bits into SDL domain - Alex - Fixed planet blinking when exiting scan (bug #799) - Alex - Restore menu sounds after editing a control set name (bug #1066) - Alex Modified: trunk/sc2/src/libs/graphics/context.c =================================================================== --- trunk/sc2/src/libs/graphics/context.c 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/context.c 2009-12-22 02:35:16 UTC (rev 3463) @@ -306,7 +306,7 @@ TFB_DrawImage_Image (EffectFrame->image, -EffectFrame->HotSpot.x, -EffectFrame->HotSpot.y, - 0, NULL, img); + 0, 0, NULL, img); } else { // solid color backing Modified: trunk/sc2/src/libs/graphics/drawcmd.h =================================================================== --- trunk/sc2/src/libs/graphics/drawcmd.h 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/drawcmd.h 2009-12-22 02:35:16 UTC (rev 3463) @@ -64,6 +64,7 @@ SCREEN destBuffer; TFB_ColorMap *colormap; int scale; + int scaleMode; } TFB_DrawCommand_Image; typedef struct tfb_dc_filledimg @@ -73,6 +74,7 @@ Color color; SCREEN destBuffer; int scale; + int scaleMode; } TFB_DrawCommand_FilledImage; typedef struct tfb_dc_fontchar Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-22 02:35:16 UTC (rev 3463) @@ -86,7 +86,7 @@ // TFB_GetColorMap(). We release the colormap at the end. void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, - TFB_ColorMap *cmap, TFB_Canvas target) + int scaleMode, TFB_ColorMap *cmap, TFB_Canvas target) { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; @@ -108,21 +108,19 @@ if (scale != 0 && scale != GSCALE_IDENTITY) { - int type = GetGraphicScaleMode (); - - if (type == TFB_SCALE_TRILINEAR && img->MipmapImg) + if (scaleMode == TFB_SCALE_TRILINEAR && img->MipmapImg) { // only set the new palette if it changed if (TFB_DrawCanvas_IsPaletted (img->MipmapImg) && cmap && img->colormap_version != cmap->version) SDL_SetColors (img->MipmapImg, cmap->palette->colors, 0, 256); } - else if (type == TFB_SCALE_TRILINEAR && !img->MipmapImg) - { - type = TFB_SCALE_BILINEAR; + else if (scaleMode == TFB_SCALE_TRILINEAR && !img->MipmapImg) + { // Do bilinear scaling instead when mipmap is unavailable + scaleMode = TFB_SCALE_BILINEAR; } - TFB_DrawImage_FixScaling (img, scale, type); + TFB_DrawImage_FixScaling (img, scale, scaleMode); surf = img->ScaledImg; if (TFB_DrawCanvas_IsPaletted (surf)) { @@ -251,7 +249,7 @@ void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, - Color color, TFB_Canvas target) + int scaleMode, Color color, TFB_Canvas target) { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; @@ -270,16 +268,14 @@ if (scale != 0 && scale != GSCALE_IDENTITY) { - int type = GetGraphicScaleMode (); - - if (type == TFB_SCALE_TRILINEAR) - type = TFB_SCALE_BILINEAR; + if (scaleMode == TFB_SCALE_TRILINEAR) + scaleMode = TFB_SCALE_BILINEAR; // no point in trilinear for filled images - if (scale != img->last_scale || type != img->last_scale_type) + if (scale != img->last_scale || scaleMode != img->last_scale_type) force_fill = true; - TFB_DrawImage_FixScaling (img, scale, type); + TFB_DrawImage_FixScaling (img, scale, scaleMode); surf = img->ScaledImg; srcRect.x = 0; srcRect.y = 0; Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-12-22 02:35:16 UTC (rev 3463) @@ -692,16 +692,16 @@ break; case TFB_DRAWCOMMANDTYPE_IMAGE: { - TFB_Image *DC_image = DC.data.image.image; - TFB_ColorMap *cmap = DC.data.image.colormap; - int x = DC.data.image.x; - int y = DC.data.image.y; + TFB_DrawCommand_Image *cmd = &DC.data.image; + TFB_Image *DC_image = cmd->image; + int x = cmd->x; + int y = cmd->y; TFB_DrawCanvas_Image (DC_image, x, y, - DC.data.image.scale, cmap, - SDL_Screens[DC.data.image.destBuffer]); + cmd->scale, cmd->scaleMode, cmd->colormap, + SDL_Screens[cmd->destBuffer]); - if (DC.data.image.destBuffer == 0) + if (cmd->destBuffer == 0) { LockMutex (DC_image->mutex); if (DC.data.image.scale) @@ -719,16 +719,16 @@ } case TFB_DRAWCOMMANDTYPE_FILLEDIMAGE: { - TFB_Image *DC_image = DC.data.filledimage.image; - int x = DC.data.filledimage.x; - int y = DC.data.filledimage.y; + TFB_DrawCommand_FilledImage *cmd = &DC.data.filledimage; + TFB_Image *DC_image = cmd->image; + int x = cmd->x; + int y = cmd->y; - TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, - DC.data.filledimage.x, DC.data.filledimage.y, - DC.data.filledimage.scale, DC.data.filledimage.color, - SDL_Screens[DC.data.filledimage.destBuffer]); + TFB_DrawCanvas_FilledImage (DC_image, x, y, + cmd->scale, cmd->scaleMode, cmd->color, + SDL_Screens[cmd->destBuffer]); - if (DC.data.filledimage.destBuffer == 0) + if (cmd->destBuffer == 0) { LockMutex (DC_image->mutex); if (DC.data.filledimage.scale) Modified: trunk/sc2/src/libs/graphics/tfb_draw.c =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.c 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/tfb_draw.c 2009-12-22 02:35:16 UTC (rev 3463) @@ -63,7 +63,7 @@ void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, - TFB_ColorMap *cmap, SCREEN dest) + int scaleMode, TFB_ColorMap *cmap, SCREEN dest) { TFB_DrawCommand DC; @@ -73,6 +73,7 @@ DC.data.image.x = x; DC.data.image.y = y; DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; + DC.data.image.scaleMode = scaleMode; DC.data.image.destBuffer = dest; TFB_EnqueueDrawCommand (&DC); @@ -80,7 +81,7 @@ void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, - Color color, SCREEN dest) + int scaleMode, Color color, SCREEN dest) { TFB_DrawCommand DC; @@ -89,6 +90,7 @@ DC.data.filledimage.x = x; DC.data.filledimage.y = y; DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; + DC.data.filledimage.scaleMode = scaleMode; DC.data.filledimage.color = color; DC.data.filledimage.destBuffer = dest; @@ -253,20 +255,22 @@ void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, - TFB_ColorMap *cmap, TFB_Image *target) + int scaleMode, TFB_ColorMap *cmap, TFB_Image *target) { LockMutex (target->mutex); - TFB_DrawCanvas_Image (img, x, y, scale, cmap, target->NormalImg); + TFB_DrawCanvas_Image (img, x, y, scale, scaleMode, cmap, + target->NormalImg); target->dirty = TRUE; UnlockMutex (target->mutex); } void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, - Color color, TFB_Image *target) + int scaleMode, Color color, TFB_Image *target) { LockMutex (target->mutex); - TFB_DrawCanvas_FilledImage (img, x, y, scale, color, target->NormalImg); + TFB_DrawCanvas_FilledImage (img, x, y, scale, scaleMode, color, + target->NormalImg); target->dirty = TRUE; UnlockMutex (target->mutex); } Modified: trunk/sc2/src/libs/graphics/tfb_draw.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-22 02:35:16 UTC (rev 3463) @@ -82,10 +82,10 @@ SCREEN dest); void TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest); void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, - TFB_ColorMap *cmap, SCREEN dest); + int scaleMode, TFB_ColorMap *cmap, SCREEN dest); void TFB_DrawScreen_Copy (RECT *r, SCREEN src, SCREEN dest); void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, - Color color, SCREEN dest); + int scaleMode, Color color, SCREEN dest); void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, SCREEN dest); @@ -110,9 +110,9 @@ TFB_Image *dest); void TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image); void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, - TFB_ColorMap *cmap, TFB_Image *target); + int scaleMode, TFB_ColorMap *cmap, TFB_Image *target); void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, - Color color, TFB_Image *target); + int scaleMode, Color color, TFB_Image *target); void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Image *target); @@ -146,9 +146,9 @@ TFB_Canvas dest); void TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas image); void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, - TFB_ColorMap *cmap, TFB_Canvas target); + int scaleMode, TFB_ColorMap *cmap, TFB_Canvas target); void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, - Color color, TFB_Canvas target); + int scaleMode, Color color, TFB_Canvas target); void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Canvas target); Modified: trunk/sc2/src/libs/graphics/tfb_prim.c =================================================================== --- trunk/sc2/src/libs/graphics/tfb_prim.c 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/graphics/tfb_prim.c 2009-12-22 02:35:16 UTC (rev 3463) @@ -126,7 +126,6 @@ FRAME SrcFramePtr; TFB_Image *img; TFB_ColorMap *cmap = NULL; - int gscale; SrcFramePtr = stmp->frame; if (!SrcFramePtr) @@ -136,7 +135,6 @@ return; } img = SrcFramePtr->image; - gscale = GetGraphicScale (); if (!img) { @@ -161,11 +159,13 @@ if (_CurFramePtr->Type == SCREEN_DRAWABLE) { - TFB_DrawScreen_Image (img, x, y, gscale, cmap, TFB_SCREEN_MAIN); + TFB_DrawScreen_Image (img, x, y, GetGraphicScale (), + GetGraphicScaleMode (), cmap, TFB_SCREEN_MAIN); } else { - TFB_DrawImage_Image (img, x, y, gscale, cmap, _CurFramePtr->image); + TFB_DrawImage_Image (img, x, y, GetGraphicScale (), + GetGraphicScaleMode (), cmap, _CurFramePtr->image); } } @@ -175,7 +175,6 @@ int x, y; FRAME SrcFramePtr; TFB_Image *img; - int gscale; SrcFramePtr = stmp->frame; if (!SrcFramePtr) @@ -185,7 +184,6 @@ return; } img = SrcFramePtr->image; - gscale = GetGraphicScale (); if (!img) { @@ -204,12 +202,13 @@ if (_CurFramePtr->Type == SCREEN_DRAWABLE) { - TFB_DrawScreen_FilledImage (img, x, y, gscale, color, TFB_SCREEN_MAIN); + TFB_DrawScreen_FilledImage (img, x, y, GetGraphicScale (), + GetGraphicScaleMode (), color, TFB_SCREEN_MAIN); } else { - TFB_DrawImage_FilledImage (img, x, y, gscale, color, - _CurFramePtr->image); + TFB_DrawImage_FilledImage (img, x, y, GetGraphicScale (), + GetGraphicScaleMode (), color, _CurFramePtr->image); } } Modified: trunk/sc2/src/libs/video/vidplayer.c =================================================================== --- trunk/sc2/src/libs/video/vidplayer.c 2009-12-21 23:30:21 UTC (rev 3462) +++ trunk/sc2/src/libs/video/vidplayer.c 2009-12-22 02:35:16 UTC (rev 3463) @@ -148,7 +148,7 @@ oldContext = SetContext (NULL); TFB_DrawScreen_Image (vid->frame, vid->dst_rect.corner.x, vid->dst_rect.corner.y, - GSCALE_IDENTITY, NULL, TFB_SCREEN_MAIN); + 0, 0, NULL, TFB_SCREEN_MAIN); SetContext (oldContext); UnlockMutex (GraphicsLock); FlushGraphics (); // needed to prevent half-frame updates @@ -200,7 +200,7 @@ oldContext = SetContext (NULL); TFB_DrawScreen_Image (vid->frame, vid->dst_rect.corner.x, vid->dst_rect.corner.y, - GSCALE_IDENTITY, NULL, TFB_SCREEN_MAIN); + 0, 0, NULL, TFB_SCREEN_MAIN); SetContext (oldContext); UnlockMutex (GraphicsLock); FlushGraphics (); // needed to prevent half-frame updates This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-22 18:55:53
|
Revision: 3464 http://sc2.svn.sourceforge.net/sc2/?rev=3464&view=rev Author: avolkov Date: 2009-12-22 18:55:41 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Move TFB_BoundingBox out of SDL domain Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/graphics/Makeinfo trunk/sc2/src/libs/graphics/dcqueue.c trunk/sc2/src/libs/graphics/drawcmd.h trunk/sc2/src/libs/graphics/sdl/Makeinfo trunk/sc2/src/libs/graphics/sdl/opengl.c trunk/sc2/src/libs/graphics/sdl/pure.c trunk/sc2/src/libs/graphics/sdl/sdl_common.c Added Paths: ----------- trunk/sc2/src/libs/graphics/bbox.c trunk/sc2/src/libs/graphics/bbox.h Removed Paths: ------------- trunk/sc2/src/libs/graphics/sdl/bbox.c trunk/sc2/src/libs/graphics/sdl/bbox.h Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-22 18:55:41 UTC (rev 3464) @@ -302,14 +302,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\sdl\bbox.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\libs\graphics\sdl\bbox.h -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\sdl\biadv2x.c # End Source File # Begin Source File @@ -407,6 +399,14 @@ # End Group # Begin Source File +SOURCE=..\..\src\libs\graphics\bbox.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\libs\graphics\bbox.h +# End Source File +# Begin Source File + SOURCE=..\..\src\libs\graphics\boxint.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/graphics/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/Makeinfo 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/Makeinfo 2009-12-22 18:55:41 UTC (rev 3464) @@ -1,5 +1,5 @@ uqm_SUBDIRS="sdl" uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c - dcqueue.c + bbox.c dcqueue.c font.c frame.c gfx_common.c intersec.c loaddisp.c pixmap.c resgfx.c tfb_draw.c tfb_prim.c widgets.c" Copied: trunk/sc2/src/libs/graphics/bbox.c (from rev 3459, trunk/sc2/src/libs/graphics/sdl/bbox.c) =================================================================== --- trunk/sc2/src/libs/graphics/bbox.c (rev 0) +++ trunk/sc2/src/libs/graphics/bbox.c 2009-12-22 18:55:41 UTC (rev 3464) @@ -0,0 +1,133 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "port.h" +#include "libs/graphics/bbox.h" + +TFB_BoundingBox TFB_BBox; +int maxWidth; +int maxHeight; + +void +TFB_BBox_Init (int width, int height) +{ + maxWidth = width; + maxHeight = height; + TFB_BBox.clip.extent.width = width; + TFB_BBox.clip.extent.height = height; +} + +void +TFB_BBox_Reset (void) +{ + TFB_BBox.valid = 0; +} + +void +TFB_BBox_SetClipRect (const RECT *r) +{ + if (!r) + { /* No clipping -- full rect */ + TFB_BBox.clip.corner.x = 0; + TFB_BBox.clip.corner.y = 0; + TFB_BBox.clip.extent.width = maxWidth; + TFB_BBox.clip.extent.height = maxHeight; + return; + } + + TFB_BBox.clip = *r; + + /* Make sure the cliprect is sane */ + if (TFB_BBox.clip.corner.x < 0) + TFB_BBox.clip.corner.x = 0; + + if (TFB_BBox.clip.corner.y < 0) + TFB_BBox.clip.corner.y = 0; + + if (TFB_BBox.clip.corner.x + TFB_BBox.clip.extent.width > maxWidth) + TFB_BBox.clip.extent.width = maxWidth - TFB_BBox.clip.corner.x; + + if (TFB_BBox.clip.corner.y + TFB_BBox.clip.extent.height > maxHeight) + TFB_BBox.clip.extent.height = maxHeight - TFB_BBox.clip.corner.y; +} + +void +TFB_BBox_RegisterPoint (int x, int y) +{ + int x1 = TFB_BBox.clip.corner.x; + int y1 = TFB_BBox.clip.corner.y; + int x2 = TFB_BBox.clip.corner.x + TFB_BBox.clip.extent.width - 1; + int y2 = TFB_BBox.clip.corner.y + TFB_BBox.clip.extent.height - 1; + + /* Constrain coordinates */ + if (x < x1) x = x1; + if (x >= x2) x = x2; + if (y < y1) y = y1; + if (y >= y2) y = y2; + + /* Is this the first point? If so, set a pixel-region and return. */ + if (!TFB_BBox.valid) + { + TFB_BBox.valid = 1; + TFB_BBox.region.corner.x = x; + TFB_BBox.region.corner.y = y; + TFB_BBox.region.extent.width = 1; + TFB_BBox.region.extent.height = 1; + return; + } + + /* Otherwise expand the rectangle if necessary. */ + x1 = TFB_BBox.region.corner.x; + y1 = TFB_BBox.region.corner.y; + x2 = TFB_BBox.region.corner.x + TFB_BBox.region.extent.width - 1; + y2 = TFB_BBox.region.corner.y + TFB_BBox.region.extent.height - 1; + + if (x < x1) { + TFB_BBox.region.corner.x = x; + TFB_BBox.region.extent.width += x1 - x; + } + if (y < y1) { + TFB_BBox.region.corner.y = y; + TFB_BBox.region.extent.height += y1 - y; + } + if (x > x2) { + TFB_BBox.region.extent.width += x - x2; + } + if (y > y2) { + TFB_BBox.region.extent.height += y - y2; + } +} + +void +TFB_BBox_RegisterRect (const RECT *r) +{ + /* RECT will still register as a corner point of the cliprect even + * if it does not intersect with the cliprect at all. This is not + * a problem, as more is not less. */ + TFB_BBox_RegisterPoint (r->corner.x, r->corner.y); + TFB_BBox_RegisterPoint (r->corner.x + r->extent.width - 1, + r->corner.y + r->extent.height - 1); +} + +void +TFB_BBox_RegisterCanvas (TFB_Canvas c, int x, int y) +{ + RECT r; + r.corner.x = x; + r.corner.y = y; + TFB_DrawCanvas_GetExtent (c, &r.extent); + TFB_BBox_RegisterRect (&r); +} Copied: trunk/sc2/src/libs/graphics/bbox.h (from rev 3459, trunk/sc2/src/libs/graphics/sdl/bbox.h) =================================================================== --- trunk/sc2/src/libs/graphics/bbox.h (rev 0) +++ trunk/sc2/src/libs/graphics/bbox.h 2009-12-22 18:55:41 UTC (rev 3464) @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef BBOX_H_INCL__ +#define BBOX_H_INCL__ + +#include "libs/gfxlib.h" +#include "libs/graphics/tfb_draw.h" + +/* Bounding Box operations. These operations are NOT synchronized. + * However, they should only be accessed by TFB_FlushGraphics and + * TFB_SwapBuffers, or the routines that they exclusively call -- all + * of which are only callable by the thread that is permitted to touch + * the screen. No explicit locks should therefore be required. */ + +typedef struct { + int valid; // If zero, the next point registered becomes the region + RECT region; // The actual modified rectangle + RECT clip; // Points outside of this rectangle are pushed to + // the closest border point +} TFB_BoundingBox; + +extern TFB_BoundingBox TFB_BBox; + +void TFB_BBox_RegisterPoint (int x, int y); +void TFB_BBox_RegisterRect (const RECT *r); +void TFB_BBox_RegisterCanvas (TFB_Canvas c, int x, int y); + +void TFB_BBox_Init (int width, int height); +void TFB_BBox_Reset (void); +void TFB_BBox_SetClipRect (const RECT *r); + +#endif /* BBOX_H_INCL__ */ Modified: trunk/sc2/src/libs/graphics/dcqueue.c =================================================================== --- trunk/sc2/src/libs/graphics/dcqueue.c 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/dcqueue.c 2009-12-22 18:55:41 UTC (rev 3464) @@ -231,10 +231,7 @@ if (scissor_rect.extent.width) { DC.Type = TFB_DRAWCOMMANDTYPE_SCISSORENABLE; - DC.data.scissor.x = scissor_rect.corner.x; - DC.data.scissor.y = scissor_rect.corner.y; - DC.data.scissor.w = scissor_rect.extent.width; - DC.data.scissor.h = scissor_rect.extent.height; + DC.data.scissor.rect = scissor_rect; } else { Modified: trunk/sc2/src/libs/graphics/drawcmd.h =================================================================== --- trunk/sc2/src/libs/graphics/drawcmd.h 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/drawcmd.h 2009-12-22 18:55:41 UTC (rev 3464) @@ -100,7 +100,7 @@ typedef struct tfb_dc_scissor { - int x, y, w, h; + RECT rect; } TFB_DrawCommand_Scissor; typedef struct tfb_dc_setmip Modified: trunk/sc2/src/libs/graphics/sdl/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-22 18:55:41 UTC (rev 3464) @@ -4,4 +4,4 @@ scalers.c 2xscalers.c 2xscalers_mmx.c 2xscalers_sse.c 2xscalers_3dnow.c nearest2x.c bilinear2x.c biadv2x.c triscan2x.c hq2x.c - canvas.c bbox.c sdluio.c rotozoom.c" + canvas.c sdluio.c rotozoom.c" Deleted: trunk/sc2/src/libs/graphics/sdl/bbox.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/bbox.c 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/sdl/bbox.c 2009-12-22 18:55:41 UTC (rev 3464) @@ -1,120 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "port.h" -#include SDL_INCLUDE(SDL.h) -#include "bbox.h" - -TFB_BoundingBox TFB_BBox; - -void -TFB_BBox_Reset (void) -{ - TFB_BBox.valid = 0; - TFB_BBox.clip.corner.x = 0; - TFB_BBox.clip.corner.y = 0; - TFB_BBox.clip.extent.width = ScreenWidth; - TFB_BBox.clip.extent.height = ScreenHeight; -} - -void -TFB_BBox_GetClipRect (TFB_Canvas c) -{ - SDL_Rect r; - SDL_GetClipRect ((SDL_Surface *)c, &r); - TFB_BBox.clip.corner.x = r.x; - TFB_BBox.clip.corner.y = r.y; - TFB_BBox.clip.extent.width = r.w; - TFB_BBox.clip.extent.height = r.h; -} - -void -TFB_BBox_RegisterPoint (int x, int y) -{ - int x1 = TFB_BBox.clip.corner.x; - int y1 = TFB_BBox.clip.corner.y; - int x2 = TFB_BBox.clip.corner.x + TFB_BBox.clip.extent.width - 1; - int y2 = TFB_BBox.clip.corner.y + TFB_BBox.clip.extent.height - 1; - - /* Make sure the cliprect is sane */ - - if (x1 < 0) x1 = TFB_BBox.clip.corner.x = 0; - if (y1 < 0) y1 = TFB_BBox.clip.corner.y = 0; - if (x2 >= ScreenWidth) - { - TFB_BBox.clip.extent.width = ScreenWidth - x1; - x2 = ScreenWidth - 1; - } - if (y2 >= ScreenHeight) - { - TFB_BBox.clip.extent.height = ScreenHeight - y1; - y2 = ScreenHeight - 1; - } - - - /* Constrain coordinates */ - if (x < x1) x = x1; - if (x >= x2) x = x2; - if (y < y1) y = y1; - if (y >= y2) y = y2; - - /* Is this the first point? If so, set a pixel-region and return. */ - if (!TFB_BBox.valid) - { - TFB_BBox.valid = 1; - TFB_BBox.region.corner.x = x; - TFB_BBox.region.corner.y = y; - TFB_BBox.region.extent.width = 1; - TFB_BBox.region.extent.height = 1; - return; - } - - /* Otherwise expand the rectangle if necessary. */ - x1 = TFB_BBox.region.corner.x; - y1 = TFB_BBox.region.corner.y; - x2 = TFB_BBox.region.corner.x + TFB_BBox.region.extent.width - 1; - y2 = TFB_BBox.region.corner.y + TFB_BBox.region.extent.height - 1; - - if (x < x1) { - TFB_BBox.region.corner.x = x; - TFB_BBox.region.extent.width += x1 - x; - } - if (y < y1) { - TFB_BBox.region.corner.y = y; - TFB_BBox.region.extent.height += y1 - y; - } - if (x > x2) { - TFB_BBox.region.extent.width += x - x2; - } - if (y > y2) { - TFB_BBox.region.extent.height += y - y2; - } -} - -void -TFB_BBox_RegisterRect (RECT *r) -{ - TFB_BBox_RegisterPoint (r->corner.x, r->corner.y); - TFB_BBox_RegisterPoint (r->corner.x + r->extent.width, r->corner.y + r->extent.height); -} - -void -TFB_BBox_RegisterCanvas (TFB_Canvas c, int x, int y) -{ - SDL_Surface *s = (SDL_Surface *)c; - TFB_BBox_RegisterPoint (x, y); - TFB_BBox_RegisterPoint (x + s->w, y + s->h); -} Deleted: trunk/sc2/src/libs/graphics/sdl/bbox.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/bbox.h 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/sdl/bbox.h 2009-12-22 18:55:41 UTC (rev 3464) @@ -1,46 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "libs/gfxlib.h" -#include "libs/graphics/tfb_draw.h" -#include "libs/graphics/gfx_common.h" - -#ifndef _BBOX_H_ -#define _BBOX_H_ - -/* Bounding Box operations. These operations are NOT synchronized. - * However, they should only be accessed by TFB_FlushGraphics and - * TFB_SwapBuffers, or the routines that they exclusively call -- all - * of which are only callable by the thread that is permitted to touch - * the screen. No explicit locks should therefore be required. */ - -typedef struct { - int valid; // If zero, the next point registered becomes the region - RECT region; // The actual modified rectangle - RECT clip; // Points outside of this rectangle are pushed to - // the closest border point -} TFB_BoundingBox; - -extern TFB_BoundingBox TFB_BBox; - -void TFB_BBox_RegisterPoint (int x, int y); -void TFB_BBox_RegisterRect (RECT *r); -void TFB_BBox_RegisterCanvas (TFB_Canvas c, int x, int y); - -void TFB_BBox_Reset (void); -void TFB_BBox_GetClipRect (TFB_Canvas c); - -#endif Modified: trunk/sc2/src/libs/graphics/sdl/opengl.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/opengl.c 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/sdl/opengl.c 2009-12-22 18:55:41 UTC (rev 3464) @@ -19,7 +19,7 @@ #if defined (GFXMODULE_SDL) && defined (HAVE_OPENGL) #include "libs/graphics/sdl/opengl.h" -#include "bbox.h" +#include "libs/graphics/bbox.h" #include "scalers.h" #include "options.h" #include "libs/log.h" Modified: trunk/sc2/src/libs/graphics/sdl/pure.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/pure.c 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/sdl/pure.c 2009-12-22 18:55:41 UTC (rev 3464) @@ -18,7 +18,7 @@ #ifdef GFXMODULE_SDL #include "pure.h" -#include "bbox.h" +#include "libs/graphics/bbox.h" #include "scalers.h" #include "libs/log.h" Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-12-22 02:35:16 UTC (rev 3463) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2009-12-22 18:55:41 UTC (rev 3464) @@ -29,7 +29,7 @@ #include "libs/graphics/cmap.h" #include "libs/input/sdl/input.h" // for ProcessInputEvent() -#include "bbox.h" +#include "libs/graphics/bbox.h" #include "port.h" #include "libs/uio.h" #include "libs/log.h" @@ -174,6 +174,7 @@ Init_DrawCommandQueue (); TFB_DrawCanvas_Initialize (); + TFB_BBox_Init (ScreenWidth, ScreenHeight); RenderingCond = CreateCondVar ("DCQ empty", SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); @@ -660,7 +661,6 @@ } TFB_BBox_Reset (); - TFB_BBox_GetClipRect (SDL_Screens[0]); done = FALSE; while (!done) @@ -794,19 +794,17 @@ case TFB_DRAWCOMMANDTYPE_SCISSORENABLE: { SDL_Rect r; - r.x = TFB_BBox.clip.corner.x = DC.data.scissor.x; - r.y = TFB_BBox.clip.corner.y = DC.data.scissor.y; - r.w = TFB_BBox.clip.extent.width = DC.data.scissor.w; - r.h = TFB_BBox.clip.extent.height = DC.data.scissor.h; + r.x = DC.data.scissor.rect.corner.x; + r.y = DC.data.scissor.rect.corner.y; + r.w = DC.data.scissor.rect.extent.width; + r.h = DC.data.scissor.rect.extent.height; SDL_SetClipRect (SDL_Screens[0], &r); + TFB_BBox_SetClipRect (&DC.data.scissor.rect); break; } case TFB_DRAWCOMMANDTYPE_SCISSORDISABLE: SDL_SetClipRect (SDL_Screens[0], NULL); - TFB_BBox.clip.corner.x = 0; - TFB_BBox.clip.corner.y = 0; - TFB_BBox.clip.extent.width = ScreenWidth; - TFB_BBox.clip.extent.height = ScreenHeight; + TFB_BBox_SetClipRect (NULL); break; case TFB_DRAWCOMMANDTYPE_COPYTOIMAGE: { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-24 21:35:54
|
Revision: 3466 http://sc2.svn.sourceforge.net/sc2/?rev=3466&view=rev Author: avolkov Date: 2009-12-24 21:35:45 +0000 (Thu, 24 Dec 2009) Log Message: ----------- Gfxlib cleanup: DISPLAY_INTERFACE removed Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/graphics/context.h trunk/sc2/src/libs/graphics/drawable.c trunk/sc2/src/libs/graphics/gfx_common.c trunk/sc2/src/libs/graphics/gfxintrn.h trunk/sc2/src/libs/graphics/loaddisp.c trunk/sc2/src/libs/graphics/sdl/3do_funcs.c trunk/sc2/src/libs/graphics/sdl/3do_getbody.c trunk/sc2/src/libs/graphics/sdl/Makeinfo trunk/sc2/src/libs/graphics/sdl/sdl_common.h Removed Paths: ------------- trunk/sc2/src/libs/graphics/display.h trunk/sc2/src/libs/graphics/sdl/3do_blt.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-24 21:35:45 UTC (rev 3466) @@ -290,10 +290,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\sdl\3do_blt.c -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\sdl\3do_funcs.c # End Source File # Begin Source File @@ -439,10 +435,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\display.h -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\drawable.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/gfxlib.h 2009-12-24 21:35:45 UTC (rev 3466) @@ -133,8 +133,14 @@ typedef BYTE CREATE_FLAGS; +// WANT_MASK is deprecated (and non-functional). It used to generate a bitmap +// of changed pixels for a target DRAWABLE, so that DRAW_SUBTRACTIVE could +// paint background pixels over them, i.e. a revert draw. The backgrounds +// are fully erased now instead. #define WANT_MASK (CREATE_FLAGS)(1 << 0) #define WANT_PIXMAP (CREATE_FLAGS)(1 << 1) +// MAPPED_TO_DISPLAY is deprecated but still checked by LoadDisplayPixmap(). +// Its former use was to indicate a pre-scaled graphic for the display. #define MAPPED_TO_DISPLAY (CREATE_FLAGS)(1 << 2) #define WANT_ALPHA (CREATE_FLAGS)(1 << 3) @@ -334,7 +340,7 @@ extern DRAWABLE LoadGraphicFile (const char *pStr); extern FONT LoadFontFile (const char *pStr); extern void *LoadGraphicInstance (RESOURCE res); -extern DRAWABLE LoadDisplayPixmap (RECT *area, FRAME frame); +extern DRAWABLE LoadDisplayPixmap (const RECT *area, FRAME frame); extern FRAME SetContextFontEffect (FRAME EffectFrame); extern FONT SetContextFont (FONT Font); extern BOOLEAN DestroyFont (FONT FontRef); Modified: trunk/sc2/src/libs/graphics/context.h =================================================================== --- trunk/sc2/src/libs/graphics/context.h 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/context.h 2009-12-24 21:35:45 UTC (rev 3466) @@ -117,15 +117,11 @@ #define GRAPHICS_VISIBLE (GRAPHICS_STATUS)(1 << 1) #define CONTEXT_ACTIVE (GRAPHICS_STATUS)(1 << 2) #define DRAWABLE_ACTIVE (GRAPHICS_STATUS)(1 << 3) -#define DISPLAY_ACTIVE (GRAPHICS_STATUS)(1 << 5) #define DeactivateGraphics() (_GraphicsStatusFlags &= ~GRAPHICS_ACTIVE) #define ActivateGraphics() (_GraphicsStatusFlags |= GRAPHICS_ACTIVE) #define GraphicsActive() (_GraphicsStatusFlags & GRAPHICS_ACTIVE) #define DeactivateVisible() (_GraphicsStatusFlags &= ~GRAPHICS_VISIBLE) #define ActivateVisible() (_GraphicsStatusFlags |= GRAPHICS_VISIBLE) -#define DeactivateDisplay() (_GraphicsStatusFlags &= ~DISPLAY_ACTIVE) -#define ActivateDisplay() (_GraphicsStatusFlags |= DISPLAY_ACTIVE) -#define DisplayActive() (_GraphicsStatusFlags & DISPLAY_ACTIVE) #define DeactivateContext() (_GraphicsStatusFlags &= ~CONTEXT_ACTIVE) #define ActivateContext() (_GraphicsStatusFlags |= CONTEXT_ACTIVE) #define ContextActive() (_GraphicsStatusFlags & CONTEXT_ACTIVE) @@ -133,10 +129,8 @@ #define ActivateDrawable() (_GraphicsStatusFlags |= DRAWABLE_ACTIVE) #define DrawableActive() (_GraphicsStatusFlags & DRAWABLE_ACTIVE) -#define SYSTEM_ACTIVE (GRAPHICS_STATUS)( \ - DISPLAY_ACTIVE | CONTEXT_ACTIVE | \ - DRAWABLE_ACTIVE \ - ) +#define SYSTEM_ACTIVE (GRAPHICS_STATUS)(CONTEXT_ACTIVE | DRAWABLE_ACTIVE) + #define GraphicsSystemActive() \ ((_GraphicsStatusFlags & SYSTEM_ACTIVE) == SYSTEM_ACTIVE) #define GraphicsStatus() \ Deleted: trunk/sc2/src/libs/graphics/display.h =================================================================== --- trunk/sc2/src/libs/graphics/display.h 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/display.h 2009-12-24 21:35:45 UTC (rev 3466) @@ -1,50 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DISPLAY_H -#define _DISPLAY_H - -typedef struct -{ - CREATE_FLAGS DisplayFlags; - - BYTE DisplayDepth; - COUNT DisplayWidth; - COUNT DisplayHeight; - - DRAWABLE (*alloc_image) (COUNT NumFrames, DRAWABLE_TYPE DrawableType, - CREATE_FLAGS flags, SIZE width, SIZE height); - - void (*read_display) (RECT *pRect, FRAME DstFramePtr); - -} DISPLAY_INTERFACE; - -extern DISPLAY_INTERFACE *_pCurDisplay; - -extern void (* mask_func_array[]) (RECT *pClipRect, PRIMITIVE *PrimPtr); - -#define AllocDrawableImage (*_pCurDisplay->alloc_image) -#define ReadDisplay (*_pCurDisplay->read_display) - -#define GetDisplayFlags() (_pCurDisplay->DisplayFlags) -#define GetDisplayDepth() (_pCurDisplay->DisplayDepth) -#define GetDisplayWidth() (_pCurDisplay->DisplayWidth) -#define GetDisplayHeight() (_pCurDisplay->DisplayHeight) - -#endif /* _DISPLAY_H */ - Modified: trunk/sc2/src/libs/graphics/drawable.c =================================================================== --- trunk/sc2/src/libs/graphics/drawable.c 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/drawable.c 2009-12-24 21:35:45 UTC (rev 3466) @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gfxintrn.h" +#include "libs/gfxlib.h" +#include "libs/graphics/context.h" +#include "libs/graphics/drawable.h" #include "libs/memlib.h" #include "tfb_draw.h" #include <math.h> @@ -61,17 +63,17 @@ { DRAWABLE Drawable; - if (!DisplayActive ()) - return (0); - + // TODO: ScreenWidth and ScreenHeight should be passed in + // instead of returned. Drawable = _request_drawable (1, SCREEN_DRAWABLE, - (CreateFlags & (WANT_PIXMAP | (GetDisplayFlags () & WANT_MASK))), - GetDisplayWidth (), GetDisplayHeight ()); + (CreateFlags & (WANT_PIXMAP | WANT_MASK)), + ScreenWidth, ScreenHeight); if (Drawable) { FRAME F; - if ((F = CaptureDrawable (Drawable)) == 0) + F = CaptureDrawable (Drawable); + if (F == 0) DestroyDrawable (Drawable); else { @@ -126,9 +128,6 @@ { DRAWABLE Drawable; - if (!DisplayActive ()) - return (0); - Drawable = _request_drawable (num_frames, RAM_DRAWABLE, (CreateFlags & (WANT_MASK | WANT_PIXMAP | WANT_ALPHA | MAPPED_TO_DISPLAY)), Modified: trunk/sc2/src/libs/graphics/gfx_common.c =================================================================== --- trunk/sc2/src/libs/graphics/gfx_common.c 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/gfx_common.c 2009-12-24 21:35:45 UTC (rev 3466) @@ -23,11 +23,7 @@ #include "libs/misc.h" // for TFB_DEBUG_HALT -DISPLAY_INTERFACE *_pCurDisplay; //Not a function. Probably has to be initialized... -void (*mask_func_array[]) (RECT *pClipRect, PRIMITIVE *PrimPtr) - = { 0 }; - int ScreenWidth; int ScreenHeight; int ScreenWidthActual; Modified: trunk/sc2/src/libs/graphics/gfxintrn.h =================================================================== --- trunk/sc2/src/libs/graphics/gfxintrn.h 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/gfxintrn.h 2009-12-24 21:35:45 UTC (rev 3466) @@ -27,7 +27,6 @@ #include "context.h" #include "drawable.h" #include "font.h" -#include "display.h" #endif /* _GFXINTRN_H */ Modified: trunk/sc2/src/libs/graphics/loaddisp.c =================================================================== --- trunk/sc2/src/libs/graphics/loaddisp.c 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/loaddisp.c 2009-12-24 21:35:45 UTC (rev 3466) @@ -16,42 +16,50 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gfxintrn.h" +#include "libs/gfxlib.h" +#include "libs/graphics/drawable.h" +#include "libs/log.h" -/* - LoadDisplay---Drawable - - Allocate a chunk of memory and read from the display into that - chunk of memory. - - - LoadDisplayPixmapDrawable() - LoadDisplayMaskDrawable() - LoadDisplayPixmapMaskDrawable() - -*/ - - +// Reads a piece of screen into a passed FRAME or a newly created one DRAWABLE -LoadDisplayPixmap (RECT *area, FRAME frame) +LoadDisplayPixmap (const RECT *area, FRAME frame) { + // TODO: This should just return a FRAME instead of DRAWABLE DRAWABLE buffer = GetFrameParentDrawable (frame); - COUNT index = GetFrameIndex (frame); + COUNT index; - if (buffer || (buffer = CreateDrawable ( - WANT_PIXMAP | MAPPED_TO_DISPLAY, - area->extent.width, - area->extent.height, - 1)) - ) + if (!buffer) + { // asked to create a new DRAWABLE instead + buffer = CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY, + area->extent.width, area->extent.height, 1); + if (!buffer) + return NULL; + + index = 0; + } + else { - frame = SetAbsFrameIndex (CaptureDrawable (buffer), index); - ReadDisplay (area, frame); - ReleaseDrawable (frame); + index = GetFrameIndex (frame); } - return (buffer); + frame = SetAbsFrameIndex (CaptureDrawable (buffer), index); + + if (_CurFramePtr->Type != SCREEN_DRAWABLE + || frame->Type == SCREEN_DRAWABLE + || !(GetFrameParentDrawable (frame)->Flags & MAPPED_TO_DISPLAY)) + { + log_add (log_Warning, "Unimplemented function activated: " + "LoadDisplayPixmap()"); + } + else + { + TFB_Image *img = frame->image; + TFB_DrawScreen_CopyToImage (img, area, TFB_SCREEN_MAIN); + } + + ReleaseDrawable (frame); + + return buffer; } - Deleted: trunk/sc2/src/libs/graphics/sdl/3do_blt.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_blt.c 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/sdl/3do_blt.c 2009-12-24 21:35:45 UTC (rev 3466) @@ -1,74 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef GFXMODULE_SDL - -#include "sdl_common.h" -#include "libs/graphics/tfb_draw.h" -#include "libs/log.h" - -static void -read_screen (RECT *lpRect, FRAME DstFramePtr) -{ - if (_CurFramePtr->Type != SCREEN_DRAWABLE - || DstFramePtr->Type == SCREEN_DRAWABLE - || !(GetFrameParentDrawable (DstFramePtr)->Flags - & MAPPED_TO_DISPLAY)) - { - log_add (log_Warning, "Unimplemented function activated: " - "read_screen()"); - } - else - { - TFB_Image *img = DstFramePtr->image; - TFB_DrawScreen_CopyToImage (img, lpRect, TFB_SCREEN_MAIN); - } -} - -static DRAWABLE -alloc_image (COUNT NumFrames, DRAWABLE_TYPE DrawableType, CREATE_FLAGS - flags, SIZE width, SIZE height) -{ - /* dodge compiler warnings */ - (void)DrawableType; - (void)flags; - (void)width; - (void)height; - return AllocDrawable (NumFrames); -} - -static DISPLAY_INTERFACE DisplayInterface = -{ - /* .DisplayFlags = */ WANT_MASK, - - /* .DisplayDepth = */ 16, - /* .DisplayWidth = */ 320, - /* .DisplayHeight = */ 240, - - /* .alloc_iamge = */ alloc_image, - /* .read_display = */ read_screen, -}; - -void -LoadDisplay (DISPLAY_INTERFACE **pDisplay) -{ - *pDisplay = &DisplayInterface; -} - -#endif - Modified: trunk/sc2/src/libs/graphics/sdl/3do_funcs.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_funcs.c 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/sdl/3do_funcs.c 2009-12-24 21:35:45 UTC (rev 3466) @@ -26,23 +26,17 @@ #include "libs/graphics/tfb_draw.h" -//Status: Not entirely unimplemented! +// Status: Ignored BOOLEAN InitGraphics (int argc, char* argv[], COUNT KbytesRequired) // Kbytes should only matter if we wanted to port Starcon2 to the // hand-helds... { - BOOLEAN ret; - - LoadDisplay (&_pCurDisplay); - ActivateDisplay (); - (void) argc; /* lint */ (void) argv; /* lint */ (void) KbytesRequired; /* lint */ - ret = TRUE; - return (ret); + return TRUE; } // Status: Unimplemented Modified: trunk/sc2/src/libs/graphics/sdl/3do_getbody.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-12-24 21:35:45 UTC (rev 3466) @@ -835,9 +835,7 @@ { DRAWABLE Drawable; - Drawable = AllocDrawableImage ( - NumFrames, DrawableType, flags, width, height - ); + Drawable = AllocDrawable (NumFrames); if (Drawable) { int imgw, imgh; Modified: trunk/sc2/src/libs/graphics/sdl/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-24 21:35:45 UTC (rev 3466) @@ -1,4 +1,4 @@ -uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c opengl.c +uqm_CFILES="3do_funcs.c 3do_getbody.c opengl.c palette.c primitives.c pure.c sdl_common.c scalers.c 2xscalers.c Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.h 2009-12-23 15:26:53 UTC (rev 3465) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.h 2009-12-24 21:35:45 UTC (rev 3466) @@ -46,9 +46,6 @@ extern SDL_Surface *format_conv_surf; -void ScreenOrigin (FRAME Display, COORD sx, COORD sy); -void LoadDisplay (DISPLAY_INTERFACE **pDisplay); - SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface); void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, int blend_numer, int blend_denom); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-24 22:55:04
|
Revision: 3467 http://sc2.svn.sourceforge.net/sc2/?rev=3467&view=rev Author: avolkov Date: 2009-12-24 22:54:54 +0000 (Thu, 24 Dec 2009) Log Message: ----------- Gfxlib cleanup: move some functions out of SDL domain; SDL-specific bits split off into TFB_Canvas domain Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/graphics/drawable.c trunk/sc2/src/libs/graphics/drawable.h trunk/sc2/src/libs/graphics/intersec.c trunk/sc2/src/libs/graphics/sdl/3do_getbody.c trunk/sc2/src/libs/graphics/sdl/Makeinfo trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/tfb_draw.c trunk/sc2/src/libs/graphics/tfb_draw.h trunk/sc2/src/uqm/cleanup.c trunk/sc2/src/uqm/setup.c Removed Paths: ------------- trunk/sc2/src/libs/graphics/sdl/3do_funcs.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-24 22:54:54 UTC (rev 3467) @@ -290,10 +290,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\sdl\3do_funcs.c -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\sdl\3do_getbody.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/gfxlib.h 2009-12-24 22:54:54 UTC (rev 3467) @@ -277,10 +277,6 @@ FadeSomeToColor } ScreenFadeType; -extern BOOLEAN InitGraphics (int argc, char *argv[], COUNT - KbytesRequired); -extern void UninitGraphics (void); - extern CONTEXT SetContext (CONTEXT Context); extern Color SetContextForeGroundColor (Color Color); extern Color GetContextForeGroundColor (void); Modified: trunk/sc2/src/libs/graphics/drawable.c =================================================================== --- trunk/sc2/src/libs/graphics/drawable.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/drawable.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -19,6 +19,7 @@ #include "libs/gfxlib.h" #include "libs/graphics/context.h" #include "libs/graphics/drawable.h" +#include "libs/graphics/tfb_draw.h" #include "libs/memlib.h" #include "tfb_draw.h" #include <math.h> @@ -58,6 +59,38 @@ return _CurFramePtr; } +static DRAWABLE +request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType, + CREATE_FLAGS flags, SIZE width, SIZE height) +{ + DRAWABLE Drawable; + COUNT i; + + Drawable = AllocDrawable (NumFrames); + if (!Drawable) + return NULL; + + Drawable->Flags = flags; + Drawable->MaxIndex = NumFrames - 1; + + for (i = 0; i < NumFrames; ++i) + { + FRAME FramePtr = &Drawable->Frame[i]; + + if (DrawableType == RAM_DRAWABLE && width > 0 && height > 0) + { + FramePtr->image = TFB_DrawImage_New (TFB_DrawCanvas_New_TrueColor ( + width, height, (flags & WANT_ALPHA) ? TRUE : FALSE)); + } + + FramePtr->Type = DrawableType; + FramePtr->Index = NumFrames; + SetFrameBounds (FramePtr, width, height); + } + + return Drawable; +} + DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth, SIZE *pheight) { @@ -65,7 +98,7 @@ // TODO: ScreenWidth and ScreenHeight should be passed in // instead of returned. - Drawable = _request_drawable (1, SCREEN_DRAWABLE, + Drawable = request_drawable (1, SCREEN_DRAWABLE, (CreateFlags & (WANT_PIXMAP | WANT_MASK)), ScreenWidth, ScreenHeight); if (Drawable) @@ -128,7 +161,7 @@ { DRAWABLE Drawable; - Drawable = _request_drawable (num_frames, RAM_DRAWABLE, + Drawable = request_drawable (num_frames, RAM_DRAWABLE, (CreateFlags & (WANT_MASK | WANT_PIXMAP | WANT_ALPHA | MAPPED_TO_DISPLAY)), width, height); @@ -215,7 +248,7 @@ double d; double angle = angle_deg * M_PI / 180; - Drawable = _request_drawable (1, RAM_DRAWABLE, WANT_PIXMAP, 0, 0); + Drawable = request_drawable (1, RAM_DRAWABLE, WANT_PIXMAP, 0, 0); if (!Drawable) return 0; RotFramePtr = CaptureDrawable (Drawable); @@ -262,3 +295,4 @@ return TFB_DrawCanvas_GetPixel (frame->image->NormalImg, pixelPt.x, pixelPt.y); } + Modified: trunk/sc2/src/libs/graphics/drawable.h =================================================================== --- trunk/sc2/src/libs/graphics/drawable.h 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/drawable.h 2009-12-24 22:54:54 UTC (rev 3467) @@ -67,19 +67,12 @@ extern DRAWABLE AllocDrawable (COUNT num_frames); #define FreeDrawable(D) _ReleaseCelData (D) -#define TYPE_GET(f) ((f) & FTYPE_MASK) -#define INDEX_GET(f) ((f) & FINDEX_MASK) -#define TYPE_SET(f,t) ((f)|=t) -#define INDEX_SET(f,i) ((f)|=i) - typedef struct { RECT Box; FRAME FramePtr; } IMAGE_BOX; -extern DRAWABLE _request_drawable (COUNT NumFrames, DRAWABLE_TYPE - DrawableType, CREATE_FLAGS flags, SIZE width, SIZE height); extern INTERSECT_CODE _clip_line (const RECT *pClipRect, BRESENHAM_LINE *pLine); Modified: trunk/sc2/src/libs/graphics/intersec.c =================================================================== --- trunk/sc2/src/libs/graphics/intersec.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/intersec.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -16,11 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gfxintrn.h" +#include "libs/graphics/context.h" +#include "libs/graphics/drawable.h" +#include "libs/graphics/tfb_draw.h" #include "libs/log.h" //#define DEBUG_INTERSEC +static inline BOOLEAN +images_intersect (IMAGE_BOX *box1, IMAGE_BOX *box2, const RECT *rect) +{ + return TFB_DrawImage_Intersect (box1->FramePtr->image, box1->Box.corner, + box2->FramePtr->image, box2->Box.corner, rect); +} + static TIME_VALUE frame_intersect (INTERSECT_CONTROL *pControl0, RECT *pr0, INTERSECT_CONTROL *pControl1, RECT *pr1, TIME_VALUE t0, @@ -201,12 +210,9 @@ * separated by a pixel, the shapes wouldn't be touching * each other. */ - extern BOOLEAN _image_intersect (IMAGE_BOX *pImageBox0, - IMAGE_BOX *pImageBox1, RECT *pIRect); - CheckFirstIntersection: if (BoxIntersect (&IB0.Box, &IB1.Box, &r_intersect) - && _image_intersect (&IB0, &IB1, &r_intersect)) + && images_intersect (&IB0, &IB1, &r_intersect)) return (t0); if (check0) Deleted: trunk/sc2/src/libs/graphics/sdl/3do_funcs.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_funcs.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/sdl/3do_funcs.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -1,119 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef GFXMODULE_SDL - -#include "sdl_common.h" -#include "pure.h" -#include "opengl.h" -#include "primitives.h" -#include "libs/graphics/drawcmd.h" -#include "libs/graphics/tfb_draw.h" - - -// Status: Ignored -BOOLEAN -InitGraphics (int argc, char* argv[], COUNT KbytesRequired) - // Kbytes should only matter if we wanted to port Starcon2 to the - // hand-helds... -{ - (void) argc; /* lint */ - (void) argv; /* lint */ - (void) KbytesRequired; /* lint */ - - return TRUE; -} - -// Status: Unimplemented -void -UninitGraphics () // Also probably empty -{ - // HFree (DrawCommandQueue); This is static now! - - //mem_uninit (); -} - -BOOLEAN -_image_intersect (IMAGE_BOX *box1, IMAGE_BOX *box2, RECT *rect) -{ - BOOLEAN ret; - SDL_Surface *img1, *img2; - int img1w, img1xpos, img1ypos, img2w, img2xpos, img2ypos; - int x,y; - Uint32 img1key, img2key; - Uint32 img1mask, img2mask; - GetPixelFn getpixel1, getpixel2; - - img1 = (SDL_Surface *)box1->FramePtr->image->NormalImg; - img2 = (SDL_Surface *)box2->FramePtr->image->NormalImg; - - getpixel1 = getpixel_for(img1); - getpixel2 = getpixel_for(img2); - - img1w = img1->w; - img1xpos = box1->Box.corner.x; - img1ypos = box1->Box.corner.y; - if (img1->format->Amask) - { // use alpha transparency info - img1mask = img1->format->Amask; - // consider any not fully transparent pixel collidable - img1key = 0; - } - else - { // colorkey transparency - img1mask = ~img1->format->Amask; - img1key = img1->format->colorkey & img1mask; - } - - img2w = img2->w; - img2xpos = box2->Box.corner.x; - img2ypos = box2->Box.corner.y; - if (img2->format->Amask) - { // use alpha transparency info - img2mask = img2->format->Amask; - // consider any not fully transparent pixel collidable - img2key = 0; - } - else - { // colorkey transparency - img2mask = ~img2->format->Amask; - img2key = img2->format->colorkey & img2mask; - } - - for (y = rect->corner.y; y < rect->corner.y + rect->extent.height; ++y) - { - for (x = rect->corner.x; x < rect->corner.x + rect->extent.width; ++x) - { - Uint32 p1 = getpixel1(img1, x - img1xpos, y - img1ypos) - & img1mask; - Uint32 p2 = getpixel2(img2, x - img2xpos, y - img2ypos) - & img2mask; - - if ((p1 != img1key) && (p2 != img2key)) - { - return TRUE; - } - } - } - ret = FALSE; - - return (ret); -} - - -#endif Modified: trunk/sc2/src/libs/graphics/sdl/3do_getbody.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -827,46 +827,4 @@ return TRUE; } -// _request_drawable was in libs/graphics/drawable.c before modularization - -DRAWABLE -_request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType, - CREATE_FLAGS flags, SIZE width, SIZE height) -{ - DRAWABLE Drawable; - - Drawable = AllocDrawable (NumFrames); - if (Drawable) - { - int imgw, imgh; - FRAME FramePtr; - - Drawable->Flags = flags; - Drawable->MaxIndex = NumFrames - 1; - - imgw = width; - imgh = height; - - FramePtr = &Drawable->Frame[NumFrames - 1]; - while (NumFrames--) - { - TFB_Image *Image; - - if (DrawableType == RAM_DRAWABLE && imgw > 0 && imgh > 0 - && (Image = TFB_DrawImage_New (TFB_DrawCanvas_New_TrueColor ( - imgw, imgh, (flags & WANT_ALPHA) ? TRUE : FALSE)))) - { - FramePtr->image = Image; - } - - FramePtr->Type = DrawableType; - FramePtr->Index = NumFrames; - SetFrameBounds (FramePtr, width, height); - --FramePtr; - } - } - - return (Drawable); -} - #endif Modified: trunk/sc2/src/libs/graphics/sdl/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/sdl/Makeinfo 2009-12-24 22:54:54 UTC (rev 3467) @@ -1,4 +1,4 @@ -uqm_CFILES="3do_funcs.c 3do_getbody.c opengl.c +uqm_CFILES="3do_getbody.c opengl.c palette.c primitives.c pure.c sdl_common.c scalers.c 2xscalers.c Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -1721,3 +1721,63 @@ SDL_SetClipRect (canvas, &r); } } + +BOOLEAN +TFB_DrawCanvas_Intersect (TFB_Canvas canvas1, POINT c1org, + TFB_Canvas canvas2, POINT c2org, const RECT *interRect) +{ + SDL_Surface *surf1 = canvas1; + SDL_Surface *surf2 = canvas2; + int x, y; + Uint32 s1key, s2key; + Uint32 s1mask, s2mask; + GetPixelFn getpixel1, getpixel2; + + getpixel1 = getpixel_for (surf1); + getpixel2 = getpixel_for (surf2); + + if (surf1->format->Amask) + { // use alpha transparency info + s1mask = surf1->format->Amask; + // consider any not fully transparent pixel collidable + s1key = 0; + } + else + { // colorkey transparency + s1mask = ~surf1->format->Amask; + s1key = surf1->format->colorkey & s1mask; + } + + if (surf2->format->Amask) + { // use alpha transparency info + s2mask = surf2->format->Amask; + // consider any not fully transparent pixel collidable + s2key = 0; + } + else + { // colorkey transparency + s2mask = ~surf2->format->Amask; + s2key = surf2->format->colorkey & s2mask; + } + + // convert surface origins to pixel offsets within + c1org.x = interRect->corner.x - c1org.x; + c1org.y = interRect->corner.y - c1org.y; + c2org.x = interRect->corner.x - c2org.x; + c2org.y = interRect->corner.y - c2org.y; + + for (y = 0; y < interRect->extent.height; ++y) + { + for (x = 0; x < interRect->extent.width; ++x) + { + Uint32 p1 = getpixel1 (surf1, x + c1org.x, y + c1org.y) & s1mask; + Uint32 p2 = getpixel2 (surf2, x + c2org.x, y + c2org.y) & s2mask; + + if (p1 != s1key && p2 != s2key) + return TRUE; // pixel collision + } + } + + // no pixel collision + return FALSE; +} Modified: trunk/sc2/src/libs/graphics/tfb_draw.c =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/tfb_draw.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -448,3 +448,10 @@ } } +BOOLEAN +TFB_DrawImage_Intersect (TFB_Image *img1, POINT img1org, + TFB_Image *img2, POINT img2org, const RECT *interRect) +{ + return TFB_DrawCanvas_Intersect (img1->NormalImg, img1org, + img2->NormalImg, img2org, interRect); +} Modified: trunk/sc2/src/libs/graphics/tfb_draw.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-24 22:54:54 UTC (rev 3467) @@ -105,6 +105,8 @@ int hoty); void TFB_DrawImage_Delete (TFB_Image *image); void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type); +BOOLEAN TFB_DrawImage_Intersect (TFB_Image *img1, POINT img1org, + TFB_Image *img2, POINT img2org, const RECT *interRect); void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color, TFB_Image *dest); @@ -172,6 +174,8 @@ int TFB_DrawCanvas_GetStride (TFB_Canvas canvas); void *TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line); Color TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y); +BOOLEAN TFB_DrawCanvas_Intersect (TFB_Canvas canvas1, POINT c1org, + TFB_Canvas canvas2, POINT c2org, const RECT *interRect); TFB_Canvas TFB_GetScreenCanvas (SCREEN screen); Modified: trunk/sc2/src/uqm/cleanup.c =================================================================== --- trunk/sc2/src/uqm/cleanup.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/uqm/cleanup.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -46,7 +46,6 @@ UninitVideoPlayer (); UninitSound (); - UninitGraphics (); } static void Modified: trunk/sc2/src/uqm/setup.c =================================================================== --- trunk/sc2/src/uqm/setup.c 2009-12-24 21:35:45 UTC (rev 3466) +++ trunk/sc2/src/uqm/setup.c 2009-12-24 22:54:54 UTC (rev 3467) @@ -89,9 +89,6 @@ BOOLEAN LoadKernel (int argc, char *argv[]) { -#define MIN_K_REQUIRED (580000L / 1024) - if (!InitGraphics (argc, argv, MIN_K_REQUIRED)) - return FALSE; InitSound (argc, argv); InitVideoPlayer (TRUE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-25 04:19:01
|
Revision: 3469 http://sc2.svn.sourceforge.net/sc2/?rev=3469&view=rev Author: avolkov Date: 2009-12-25 04:18:45 +0000 (Fri, 25 Dec 2009) Log Message: ----------- Gfxlib cleanup: move ani and font loading functions out of SDL domain; SDL-specific bits split off into TFB_Canvas functions Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/graphics/Makeinfo trunk/sc2/src/libs/graphics/sdl/3do_getbody.c trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/tfb_draw.h Added Paths: ----------- trunk/sc2/src/libs/graphics/gfxload.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-25 02:09:07 UTC (rev 3468) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-25 04:18:45 UTC (rev 3469) @@ -471,6 +471,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\libs\graphics\gfxload.c +# End Source File +# Begin Source File + SOURCE=..\..\src\libs\graphics\intersec.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/graphics/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/Makeinfo 2009-12-25 02:09:07 UTC (rev 3468) +++ trunk/sc2/src/libs/graphics/Makeinfo 2009-12-25 04:18:45 UTC (rev 3469) @@ -1,5 +1,5 @@ uqm_SUBDIRS="sdl" uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c - bbox.c dcqueue.c + bbox.c dcqueue.c gfxload.c font.c frame.c gfx_common.c intersec.c loaddisp.c pixmap.c resgfx.c tfb_draw.c tfb_prim.c widgets.c" Copied: trunk/sc2/src/libs/graphics/gfxload.c (from rev 3467, trunk/sc2/src/libs/graphics/sdl/3do_getbody.c) =================================================================== --- trunk/sc2/src/libs/graphics/gfxload.c (rev 0) +++ trunk/sc2/src/libs/graphics/gfxload.c 2009-12-25 04:18:45 UTC (rev 3469) @@ -0,0 +1,603 @@ +//Copyright Paul Reiche, Fred Ford. 1992-2002 + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <string.h> +#include <stdio.h> + +#include "options.h" +#include "port.h" +#include "libs/uio.h" +#include "libs/reslib.h" + // for _cur_resfile_name +#include "libs/log.h" +#include "libs/memlib.h" +#include "libs/graphics/tfb_draw.h" +#include "libs/graphics/drawable.h" +#include "libs/graphics/font.h" + + +typedef struct anidata +{ + int transparent_color; + int colormap_index; + int hotspot_x; + int hotspot_y; +} AniData; + +extern uio_Repository *repository; +static uio_AutoMount *autoMount[] = { NULL }; + +static void +process_image (FRAME FramePtr, TFB_Canvas img[], AniData *ani, int cel_ct) +{ + TFB_Image *tfbimg; + int hx, hy; + + FramePtr->Type = ROM_DRAWABLE; + FramePtr->Index = cel_ct; + + // handle transparency cases + if (TFB_DrawCanvas_IsPaletted (img[cel_ct])) + { // indexed color image + if (ani[cel_ct].transparent_color >= 0) + { + TFB_DrawCanvas_SetTransparentIndex (img[cel_ct], + ani[cel_ct].transparent_color, FALSE); + } + } + else + { // special transparency cases for truecolor images + if (ani[cel_ct].transparent_color == 0) + { // make RGB=0,0,0 transparent + Color color = {0, 0, 0, 0}; + TFB_DrawCanvas_SetTransparentColor (img[cel_ct], color, FALSE); + } + } + if (ani[cel_ct].transparent_color == -1) + { // enforce -1 to mean 'no transparency' + TFB_DrawCanvas_SetTransparentIndex (img[cel_ct], -1, FALSE); + // set transparent_color == -2 to use PNG tRNS transparency + } + + hx = ani[cel_ct].hotspot_x; + hy = ani[cel_ct].hotspot_y; + + FramePtr->image = TFB_DrawImage_New (img[cel_ct]); + + tfbimg = FramePtr->image; + tfbimg->colormap_index = ani[cel_ct].colormap_index; + img[cel_ct] = tfbimg->NormalImg; + + FramePtr->HotSpot = MAKE_HOT_SPOT (hx, hy); + SetFrameBounds (FramePtr, tfbimg->extent.width, tfbimg->extent.height); + +#ifdef CLIPDEBUG + { + /* for debugging clipping: + draws white (or most matching color from palette) pixels to + every corner of the image + */ + Color color = {0xff, 0xff, 0xff, 0xff}; + RECT r = {{0, 0}, {1, 1}}; + if (tfbimg->extent.width > 2 && tfbimg->extent.height > 2) + { + TFB_DrawImage_Rect (&r, color, tfbimg); + r.corner.x = tfbimg->extent.width - 1; + TFB_DrawImage_Rect (&r, color, tfbimg); + r.corner.y = tfbimg->extent.height - 1; + TFB_DrawImage_Rect (&r, color, tfbimg); + r.corner.x = 0; + TFB_DrawImage_Rect (&r, color, tfbimg); + } + } +#endif +} + +static void +processFontChar (TFB_Char* CharPtr, TFB_Canvas canvas) +{ + BYTE* newdata; + size_t dpitch; + + TFB_DrawCanvas_GetExtent (canvas, &CharPtr->extent); + + // Currently, each font char has its own separate data + // but that can change to common mem area + dpitch = CharPtr->extent.width; + newdata = HMalloc (dpitch * CharPtr->extent.height * sizeof (BYTE)); + TFB_DrawCanvas_GetFontCharData (canvas, newdata, dpitch); + + CharPtr->data = newdata; + CharPtr->pitch = dpitch; + CharPtr->disp.width = CharPtr->extent.width + 1; + CharPtr->disp.height = CharPtr->extent.height + 1; + // XXX: why the +1? + // I brought it into this function from the only calling + // function, but I don't know why it was there in the first + // place. + // XXX: the +1 appears to be for character and line spacing + // text_blt just adds the frame width to move to the next char + + { + // This tunes the font positioning to be about what it should + // TODO: prolly needs a little tweaking still + + int tune_amount = 0; + + if (CharPtr->extent.height == 8) + tune_amount = -1; + else if (CharPtr->extent.height == 9) + tune_amount = -2; + else if (CharPtr->extent.height > 9) + tune_amount = -3; + + CharPtr->HotSpot = MAKE_HOT_SPOT (0, + CharPtr->extent.height + tune_amount); + } +} + +void * +_GetCelData (uio_Stream *fp, DWORD length) +{ + int cel_total, cel_index, n; + DWORD opos; + char CurrentLine[1024], filename[PATH_MAX]; + TFB_Canvas *img; + AniData *ani; + DRAWABLE Drawable; + uio_MountHandle *aniMount = 0; + uio_DirHandle *aniDir = 0; + uio_Stream *aniFile = 0; + + opos = uio_ftell (fp); + + { + char *s1, *s2; + char aniDirName[PATH_MAX]; + const char *aniFileName; + uint8 buf[4] = { 0, 0, 0, 0 }; + uint32 header; + + if (_cur_resfile_name == 0 + || (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0) + && (s2 = strrchr (_cur_resfile_name, '\\')) == 0)) + { + n = 0; + } + else + { + if (s2 > s1) + s1 = s2; + n = s1 - _cur_resfile_name + 1; + } + + uio_fread(buf, 4, 1, fp); + header = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); + if (_cur_resfile_name && header == 0x04034b50) + { + // zipped ani file + if (n) + { + strncpy (aniDirName, _cur_resfile_name, n - 1); + aniDirName[n - 1] = 0; + aniFileName = _cur_resfile_name + n; + } + else + { + strcpy(aniDirName, "."); + aniFileName = _cur_resfile_name; + } + aniDir = uio_openDir (repository, aniDirName, 0); + aniMount = uio_mountDir (repository, aniDirName, uio_FSTYPE_ZIP, + aniDir, aniFileName, "/", autoMount, + uio_MOUNT_RDONLY | uio_MOUNT_TOP, + NULL); + aniFile = uio_fopen (aniDir, aniFileName, "r"); + opos = 0; + n = 0; + } + else + { + // unpacked ani file + strncpy (filename, _cur_resfile_name, n); + aniFile = fp; + aniDir = contentDir; + } + } + + cel_total = 0; + uio_fseek (aniFile, opos, SEEK_SET); + while (uio_fgets (CurrentLine, sizeof (CurrentLine), aniFile)) + { + ++cel_total; + } + + img = HMalloc (sizeof (TFB_Canvas) * cel_total); + ani = HMalloc (sizeof (AniData) * cel_total); + if (!img || !ani) + { + log_add (log_Warning, "Couldn't allocate space for '%s'", _cur_resfile_name); + if (aniMount) + { + uio_fclose(aniFile); + uio_closeDir(aniDir); + uio_unmountDir(aniMount); + } + HFree (img); + HFree (ani); + return NULL; + } + + cel_index = 0; + uio_fseek (aniFile, opos, SEEK_SET); + while (uio_fgets (CurrentLine, sizeof (CurrentLine), aniFile) && cel_index < cel_total) + { + sscanf (CurrentLine, "%s %d %d %d %d", &filename[n], + &ani[cel_index].transparent_color, &ani[cel_index].colormap_index, + &ani[cel_index].hotspot_x, &ani[cel_index].hotspot_y); + + img[cel_index] = TFB_DrawCanvas_LoadFromFile (aniDir, filename); + if (img[cel_index] == NULL) + { + const char *err; + + err = TFB_DrawCanvas_GetError (); + log_add (log_Warning, "_GetCelData: Unable to load image!"); + if (err != NULL) + log_add (log_Warning, "Gfx Driver reports: %s", err); + } + else + { + ++cel_index; + } + + if ((int)uio_ftell (aniFile) - (int)opos >= (int)length) + break; + } + + Drawable = NULL; + if (cel_index && (Drawable = AllocDrawable (cel_index))) + { + if (!Drawable) + { + while (cel_index--) + TFB_DrawCanvas_Delete (img[cel_index]); + + HFree (Drawable); + Drawable = NULL; + } + else + { + FRAME FramePtr; + + Drawable->Flags = WANT_PIXMAP; + Drawable->MaxIndex = cel_index - 1; + + FramePtr = &Drawable->Frame[cel_index]; + while (--FramePtr, cel_index--) + process_image (FramePtr, img, ani, cel_index); + } + } + + if (Drawable == NULL) + log_add (log_Warning, "Couldn't get cel data for '%s'", + _cur_resfile_name); + + if (aniMount) + { + uio_fclose(aniFile); + uio_closeDir(aniDir); + uio_unmountDir(aniMount); + } + + HFree (img); + HFree (ani); + return Drawable; +} + +BOOLEAN +_ReleaseCelData (void *handle) +{ + DRAWABLE DrawablePtr; + int cel_ct; + FRAME FramePtr = NULL; + + if ((DrawablePtr = handle) == 0) + return (FALSE); + + cel_ct = DrawablePtr->MaxIndex + 1; + + if (DrawablePtr->Frame) + { + FramePtr = DrawablePtr->Frame; + if (FramePtr->Type == SCREEN_DRAWABLE) + { + FramePtr = NULL; + } + } + + HFree (handle); + if (FramePtr) + { + int i; + for (i = 0; i < cel_ct; i++) + { + TFB_Image *img = FramePtr[i].image; + if (img) + { + FramePtr[i].image = NULL; + TFB_DrawScreen_DeleteImage (img); + } + } + HFree (FramePtr); + } + + return (TRUE); +} + +typedef struct BuildCharDesc +{ + TFB_Canvas canvas; + UniChar index; +} BuildCharDesc; + +int +compareBCDIndex (const BuildCharDesc *bcd1, const BuildCharDesc *bcd2) +{ + return (int) bcd1->index - (int) bcd2->index; +} + +void * +_GetFontData (uio_Stream *fp, DWORD length) +{ + COUNT numDirEntries; + DIRENTRY fontDir = NULL; + BuildCharDesc *bcds = NULL; + size_t numBCDs = 0; + int dirEntryI; + uio_DirHandle *fontDirHandle = NULL; + uio_MountHandle *fontMount = NULL; + FONT fontPtr = NULL; + + if (_cur_resfile_name == 0) + goto err; + + if (fp != (uio_Stream*)~0) + { + // font is zipped instead of being in a directory + + char *s1, *s2; + int n; + const char *fontZipName; + char fontDirName[PATH_MAX]; + + if ((((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0) + && (s2 = strrchr (_cur_resfile_name, '\\')) == 0)) + { + strcpy(fontDirName, "."); + fontZipName = _cur_resfile_name; + } + else + { + if (s2 > s1) + s1 = s2; + n = s1 - _cur_resfile_name + 1; + strncpy (fontDirName, _cur_resfile_name, n - 1); + fontDirName[n - 1] = 0; + fontZipName = _cur_resfile_name + n; + } + + fontDirHandle = uio_openDir (repository, fontDirName, 0); + fontMount = uio_mountDir (repository, _cur_resfile_name, uio_FSTYPE_ZIP, + fontDirHandle, fontZipName, "/", autoMount, + uio_MOUNT_RDONLY | uio_MOUNT_TOP, + NULL); + uio_closeDir (fontDirHandle); + } + + fontDir = CaptureDirEntryTable (LoadDirEntryTable (contentDir, + _cur_resfile_name, ".", match_MATCH_SUBSTRING)); + if (fontDir == 0) + goto err; + numDirEntries = GetDirEntryTableCount (fontDir); + + fontDirHandle = uio_openDirRelative (contentDir, _cur_resfile_name, 0); + if (fontDirHandle == NULL) + goto err; + + bcds = HMalloc (numDirEntries * sizeof (BuildCharDesc)); + if (bcds == NULL) + goto err; + + // Load the surfaces for all dir Entries + for (dirEntryI = 0; dirEntryI < numDirEntries; dirEntryI++) + { + char *char_name; + unsigned int charIndex; + TFB_Canvas canvas; + EXTENT size; + + char_name = GetDirEntryAddress (SetAbsDirEntryTableIndex ( + fontDir, dirEntryI)); + if (sscanf (char_name, "%x.", &charIndex) != 1) + continue; + + if (charIndex > 0xffff) + continue; + + canvas = TFB_DrawCanvas_LoadFromFile (fontDirHandle, char_name); + if (canvas == NULL) + continue; + + TFB_DrawCanvas_GetExtent (canvas, &size); + if (size.width == 0 || size.height == 0) + { + TFB_DrawCanvas_Delete (canvas); + continue; + } + + bcds[numBCDs].canvas = canvas; + bcds[numBCDs].index = charIndex; + numBCDs++; + } + uio_closeDir (fontDirHandle); + DestroyDirEntryTable (ReleaseDirEntryTable (fontDir)); + if (fontMount != 0) + uio_unmountDir(fontMount); + +#if 0 + if (numBCDs == 0) + goto err; +#endif + + // sort on the character index + qsort (bcds, numBCDs, sizeof (BuildCharDesc), + (int (*)(const void *, const void *)) compareBCDIndex); + + fontPtr = AllocFont (0); + if (fontPtr == NULL) + goto err; + + fontPtr->Leading = 0; + fontPtr->LeadingWidth = 0; + + { + size_t startBCD = 0; + UniChar pageStart; + FONT_PAGE **pageEndPtr = &fontPtr->fontPages; + while (startBCD < numBCDs) + { + // Process one character page. + size_t endBCD; + pageStart = bcds[startBCD].index & CHARACTER_PAGE_MASK; + + endBCD = startBCD; + while (endBCD < numBCDs && + (bcds[endBCD].index & CHARACTER_PAGE_MASK) == pageStart) + endBCD++; + + { + size_t bcdI; + int numChars = bcds[endBCD - 1].index + 1 + - bcds[startBCD].index; + FONT_PAGE *page = AllocFontPage (numChars); + page->pageStart = pageStart; + page->firstChar = bcds[startBCD].index; + page->numChars = numChars; + *pageEndPtr = page; + pageEndPtr = &page->next; + + for (bcdI = startBCD; bcdI < endBCD; bcdI++) + { + // Process one character. + BuildCharDesc *bcd = &bcds[bcdI]; + TFB_Char *destChar = + &page->charDesc[bcd->index - page->firstChar]; + + if (destChar->data != NULL) + { + // There's already an image for this character. + log_add (log_Debug, "Duplicate image for character %d " + "for font %s.", (int) bcd->index, + _cur_resfile_name); + TFB_DrawCanvas_Delete (bcd->canvas); + continue; + } + + processFontChar (destChar, bcd->canvas); + TFB_DrawCanvas_Delete (bcd->canvas); + + if (destChar->disp.height > fontPtr->Leading) + fontPtr->Leading = destChar->disp.height; + if (destChar->disp.width > fontPtr->LeadingWidth) + fontPtr->LeadingWidth = destChar->disp.width; + } + } + + startBCD = endBCD; + } + *pageEndPtr = NULL; + } + + fontPtr->Leading++; + + HFree (bcds); + + (void) fp; /* Satisfying compiler (unused parameter) */ + (void) length; /* Satisfying compiler (unused parameter) */ + return fontPtr; + +err: + if (fontPtr != 0) + HFree (fontPtr); + + if (bcds != NULL) + { + size_t bcdI; + for (bcdI = 0; bcdI < numBCDs; bcdI++) + TFB_DrawCanvas_Delete (bcds[bcdI].canvas); + HFree (bcds); + } + + if (fontDirHandle != NULL) + uio_closeDir (fontDirHandle); + + if (fontDir != 0) + DestroyDirEntryTable (ReleaseDirEntryTable (fontDir)); + + if (fontMount != 0) + uio_unmountDir(fontMount); + + return 0; +} + +BOOLEAN +_ReleaseFontData (void *handle) +{ + FONT font = (FONT) handle; + if (font == NULL) + return FALSE; + + { + FONT_PAGE *page; + FONT_PAGE *nextPage; + + for (page = font->fontPages; page != NULL; page = nextPage) + { + size_t charI; + for (charI = 0; charI < page->numChars; charI++) + { + TFB_Char *c = &page->charDesc[charI]; + + if (c->data == NULL) + continue; + + // XXX: fix this if fonts get per-page data + // rather than per-char + TFB_DrawScreen_DeleteData (c->data); + } + + nextPage = page->next; + FreeFontPage (page); + } + } + + HFree (font); + + return TRUE; +} Modified: trunk/sc2/src/libs/graphics/sdl/3do_getbody.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-12-25 02:09:07 UTC (rev 3468) +++ trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2009-12-25 04:18:45 UTC (rev 3469) @@ -18,172 +18,13 @@ #ifdef GFXMODULE_SDL -#ifdef WIN32 -#include <io.h> -#endif -#include <fcntl.h> - -#include "options.h" #include "port.h" +#include "libs/gfxlib.h" +#include "libs/graphics/tfb_draw.h" #include "sdl_common.h" -#include "sdluio.h" -#include "libs/file.h" -#include "libs/reslib.h" -#include "libs/log.h" -#include "libs/memlib.h" -#include "../font.h" #include "primitives.h" -typedef struct anidata -{ - int transparent_color; - int colormap_index; - int hotspot_x; - int hotspot_y; -} AniData; - -extern uio_Repository *repository; -static uio_AutoMount *autoMount[] = { NULL }; - -static void -process_image (FRAME FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct) -{ - TFB_Image *tfbimg; - int hx, hy; - - FramePtr->Type = ROM_DRAWABLE; - FramePtr->Index = cel_ct; - - // handle transparency cases - if (img[cel_ct]->format->palette) - { // indexed color image - if (ani[cel_ct].transparent_color >= 0) - SDL_SetColorKey (img[cel_ct], SDL_SRCCOLORKEY, - ani[cel_ct].transparent_color); - } - else if (img[cel_ct]->format->BitsPerPixel > 8) - { // special transparency cases for truecolor images - if (ani[cel_ct].transparent_color == 0) - // make RGB=0,0,0 transparent - SDL_SetColorKey (img[cel_ct], SDL_SRCCOLORKEY, - SDL_MapRGBA (img[cel_ct]->format, 0, 0, 0, 0)); - } - if (ani[cel_ct].transparent_color == -1) - { // enforce -1 to mean 'no transparency' - SDL_SetColorKey (img[cel_ct], 0, 0); - // set transparent_color == -2 to use PNG tRNS transparency - } - - hx = ani[cel_ct].hotspot_x; - hy = ani[cel_ct].hotspot_y; - - FramePtr->image = TFB_DrawImage_New (img[cel_ct]); - - tfbimg = FramePtr->image; - tfbimg->colormap_index = ani[cel_ct].colormap_index; - img[cel_ct] = (SDL_Surface *)tfbimg->NormalImg; - - FramePtr->HotSpot = MAKE_HOT_SPOT (hx, hy); - SetFrameBounds (FramePtr, img[cel_ct]->w, img[cel_ct]->h); - -#ifdef CLIPDEBUG - { - /* for debugging clipping: - draws white (or most matching color from palette) pixels to - every corner of the image - */ - Uint32 color = SDL_MapRGB (img[cel_ct]->format, 255, 255, 255); - SDL_Rect r = {0, 0, 1, 1}; - if (img[cel_ct]->w > 2 && img[cel_ct]->h > 2) - { - SDL_FillRect (img[cel_ct], &r, color); - r.x = img[cel_ct]->w - 1; - SDL_FillRect (img[cel_ct], &r, color); - r.y = img[cel_ct]->h - 1; - SDL_FillRect (img[cel_ct], &r, color); - r.x = 0; - SDL_FillRect (img[cel_ct], &r, color); - } - } -#endif -} - -static void -processFontChar (TFB_Char* CharPtr, SDL_Surface *surf) -{ - int x,y; - Uint8 r,g,b,a; - Uint32 p; - SDL_PixelFormat* srcfmt = surf->format; - GetPixelFn getpix; - BYTE* newdata; - Uint32 dpitch; - - // Currently, each font char has its own separate data - // but that can change to common mem area - newdata = HMalloc (surf->w * surf->h * sizeof(BYTE)); - dpitch = surf->w; - - SDL_LockSurface (surf); - - getpix = getpixel_for (surf); - - // produce an alpha-only image in internal BYTE[] format - // from the SDL surface - for (y = 0; y < surf->h; ++y) - { - BYTE* dst = newdata + dpitch * y; - - for (x = 0; x < surf->w; ++x, ++dst) - { - p = getpix (surf, x, y); - SDL_GetRGBA (p, srcfmt, &r, &g, &b, &a); - - if (!srcfmt->Amask) - { // produce alpha from intensity (Y component) - // using a fast approximation - // contributions to Y are: R=2, G=4, B=1 - a = (((int)r << 1) + ((int)g << 2) + b) / 7; - } - - *dst = a; - } - } - - SDL_UnlockSurface (surf); - - CharPtr->data = newdata; - CharPtr->pitch = dpitch; - CharPtr->extent.width = surf->w; - CharPtr->extent.height = surf->h; - CharPtr->disp.width = surf->w + 1; - CharPtr->disp.height = surf->h + 1; - // XXX: why the +1? - // I brought it into this function from the only calling - // function, but I don't know why it was there in the first - // place. - // XXX: the +1 appears to be for character and line spacing - // text_blt just adds the frame width to move to the next char - - { - // This tunes the font positioning to be about what it should - // TODO: prolly needs a little tweaking still - - int tune_amount = 0; - - if (CharPtr->extent.height == 8) - tune_amount = -1; - else if (CharPtr->extent.height == 9) - tune_amount = -2; - else if (CharPtr->extent.height > 9) - tune_amount = -3; - - CharPtr->HotSpot = MAKE_HOT_SPOT (0, - CharPtr->extent.height + tune_amount); - } -} - // stretch_frame // create a new frame of size neww x newh, and blit a scaled version FramePtr // into it. @@ -373,458 +214,4 @@ return (SDL_MapRGBA (img->format, r, g, b, a)); } -void * -_GetCelData (uio_Stream *fp, DWORD length) -{ - int cel_total, cel_index, n; - DWORD opos; - char CurrentLine[1024], filename[PATH_MAX]; - SDL_Surface **img; - AniData *ani; - DRAWABLE Drawable; - uio_MountHandle *aniMount = 0; - uio_DirHandle *aniDir = 0; - uio_Stream *aniFile = 0; - - opos = uio_ftell (fp); - - { - char *s1, *s2; - char aniDirName[PATH_MAX]; - const char *aniFileName; - uint8 buf[4] = { 0, 0, 0, 0 }; - uint32 header; - - if (_cur_resfile_name == 0 - || (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0) - && (s2 = strrchr (_cur_resfile_name, '\\')) == 0)) - { - n = 0; - } - else - { - if (s2 > s1) - s1 = s2; - n = s1 - _cur_resfile_name + 1; - } - - uio_fread(buf, 4, 1, fp); - header = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); - if (_cur_resfile_name && header == 0x04034b50) - { - // zipped ani file - if (n) - { - strncpy (aniDirName, _cur_resfile_name, n - 1); - aniDirName[n - 1] = 0; - aniFileName = _cur_resfile_name + n; - } - else - { - strcpy(aniDirName, "."); - aniFileName = _cur_resfile_name; - } - aniDir = uio_openDir (repository, aniDirName, 0); - aniMount = uio_mountDir (repository, aniDirName, uio_FSTYPE_ZIP, - aniDir, aniFileName, "/", autoMount, - uio_MOUNT_RDONLY | uio_MOUNT_TOP, - NULL); - aniFile = uio_fopen (aniDir, aniFileName, "r"); - opos = 0; - n = 0; - } - else - { - // unpacked ani file - strncpy (filename, _cur_resfile_name, n); - aniFile = fp; - aniDir = contentDir; - } - } - - cel_total = 0; - uio_fseek (aniFile, opos, SEEK_SET); - while (uio_fgets (CurrentLine, sizeof (CurrentLine), aniFile)) - { - ++cel_total; - } - - img = HMalloc (sizeof (SDL_Surface *) * cel_total); - ani = HMalloc (sizeof (AniData) * cel_total); - if (!img || !ani) - { - log_add (log_Warning, "Couldn't allocate space for '%s'", _cur_resfile_name); - if (aniMount) - { - uio_fclose(aniFile); - uio_closeDir(aniDir); - uio_unmountDir(aniMount); - } - HFree (img); - HFree (ani); - return NULL; - } - - cel_index = 0; - uio_fseek (aniFile, opos, SEEK_SET); - while (uio_fgets (CurrentLine, sizeof (CurrentLine), aniFile) && cel_index < cel_total) - { - sscanf (CurrentLine, "%s %d %d %d %d", &filename[n], - &ani[cel_index].transparent_color, &ani[cel_index].colormap_index, - &ani[cel_index].hotspot_x, &ani[cel_index].hotspot_y); - - img[cel_index] = sdluio_loadImage (aniDir, filename); - if (img[cel_index] == NULL) - { - const char *err; - - err = SDL_GetError(); - log_add (log_Warning, "_GetCelData: Unable to load image!"); - if (err != NULL) - log_add (log_Warning, "SDL reports: %s", err); - SDL_FreeSurface (img[cel_index]); - } - else if (img[cel_index]->w < 0 || img[cel_index]->h < 0 || - img[cel_index]->format->BitsPerPixel < 8) - { - log_add (log_Warning, "_GetCelData: Bad file!"); - SDL_FreeSurface (img[cel_index]); - } - else - { - ++cel_index; - } - - if ((int)uio_ftell (aniFile) - (int)opos >= (int)length) - break; - } - - Drawable = NULL; - if (cel_index && (Drawable = AllocDrawable (cel_index))) - { - if (!Drawable) - { - while (cel_index--) - SDL_FreeSurface (img[cel_index]); - - HFree (Drawable); - Drawable = NULL; - } - else - { - FRAME FramePtr; - - Drawable->Flags = WANT_PIXMAP; - Drawable->MaxIndex = cel_index - 1; - - FramePtr = &Drawable->Frame[cel_index]; - while (--FramePtr, cel_index--) - process_image (FramePtr, img, ani, cel_index); - } - } - - if (Drawable == NULL) - log_add (log_Warning, "Couldn't get cel data for '%s'", - _cur_resfile_name); - - if (aniMount) - { - uio_fclose(aniFile); - uio_closeDir(aniDir); - uio_unmountDir(aniMount); - } - - HFree (img); - HFree (ani); - return Drawable; -} - -BOOLEAN -_ReleaseCelData (void *handle) -{ - DRAWABLE DrawablePtr; - int cel_ct; - FRAME FramePtr = NULL; - - if ((DrawablePtr = handle) == 0) - return (FALSE); - - cel_ct = DrawablePtr->MaxIndex + 1; - - if (DrawablePtr->Frame) - { - FramePtr = DrawablePtr->Frame; - if (FramePtr->Type == SCREEN_DRAWABLE) - { - FramePtr = NULL; - } - } - - HFree (handle); - if (FramePtr) - { - int i; - for (i = 0; i < cel_ct; i++) - { - TFB_Image *img = FramePtr[i].image; - if (img) - { - FramePtr[i].image = NULL; - TFB_DrawScreen_DeleteImage (img); - } - } - HFree (FramePtr); - } - - return (TRUE); -} - -typedef struct BuildCharDesc { - SDL_Surface *surface; - UniChar index; -} BuildCharDesc; - -int -compareBCDIndex(const BuildCharDesc *bcd1, const BuildCharDesc *bcd2) { - return (int) bcd1->index - (int) bcd2->index; -} - -void * -_GetFontData (uio_Stream *fp, DWORD length) -{ - COUNT numDirEntries; - DIRENTRY fontDir = NULL; - BuildCharDesc *bcds = NULL; - size_t numBCDs = 0; - int dirEntryI; - uio_DirHandle *fontDirHandle = NULL; - uio_MountHandle *fontMount = NULL; - FONT fontPtr = NULL; - - if (_cur_resfile_name == 0) - goto err; - - if (fp != (uio_Stream*)~0) - { - // font is zipped instead of being in a directory - - char *s1, *s2; - int n; - const char *fontZipName; - char fontDirName[PATH_MAX]; - - if ((((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0) - && (s2 = strrchr (_cur_resfile_name, '\\')) == 0)) - { - strcpy(fontDirName, "."); - fontZipName = _cur_resfile_name; - } - else - { - if (s2 > s1) - s1 = s2; - n = s1 - _cur_resfile_name + 1; - strncpy (fontDirName, _cur_resfile_name, n - 1); - fontDirName[n - 1] = 0; - fontZipName = _cur_resfile_name + n; - } - - fontDirHandle = uio_openDir (repository, fontDirName, 0); - fontMount = uio_mountDir (repository, _cur_resfile_name, uio_FSTYPE_ZIP, - fontDirHandle, fontZipName, "/", autoMount, - uio_MOUNT_RDONLY | uio_MOUNT_TOP, - NULL); - uio_closeDir (fontDirHandle); - } - - fontDir = CaptureDirEntryTable (LoadDirEntryTable (contentDir, - _cur_resfile_name, ".", match_MATCH_SUBSTRING)); - if (fontDir == 0) - goto err; - numDirEntries = GetDirEntryTableCount (fontDir); - - fontDirHandle = uio_openDirRelative (contentDir, _cur_resfile_name, 0); - if (fontDirHandle == NULL) - goto err; - - bcds = HMalloc (numDirEntries * sizeof (BuildCharDesc)); - if (bcds == NULL) - goto err; - - // Load the surfaces for all dir Entries - for (dirEntryI = 0; dirEntryI < numDirEntries; dirEntryI++) - { - char *char_name; - unsigned int charIndex; - SDL_Surface *surface; - - char_name = GetDirEntryAddress (SetAbsDirEntryTableIndex ( - fontDir, dirEntryI)); - if (sscanf (char_name, "%x.", &charIndex) != 1) - continue; - - if (charIndex > 0xffff) - continue; - - surface = sdluio_loadImage (fontDirHandle, char_name); - if (surface == NULL) - continue; - - if (surface->w == 0 || surface->h == 0 || - surface->format->BitsPerPixel < 8) { - SDL_FreeSurface (surface); - continue; - } - - bcds[numBCDs].surface = surface; - bcds[numBCDs].index = charIndex; - numBCDs++; - } - uio_closeDir (fontDirHandle); - DestroyDirEntryTable (ReleaseDirEntryTable (fontDir)); - if (fontMount != 0) - uio_unmountDir(fontMount); - -#if 0 - if (numBCDs == 0) - goto err; #endif - - // sort on the character index - qsort (bcds, numBCDs, sizeof (BuildCharDesc), - (int (*)(const void *, const void *)) compareBCDIndex); - - fontPtr = AllocFont (0); - if (fontPtr == NULL) - goto err; - - fontPtr->Leading = 0; - fontPtr->LeadingWidth = 0; - - { - size_t startBCD = 0; - UniChar pageStart; - FONT_PAGE **pageEndPtr = &fontPtr->fontPages; - while (startBCD < numBCDs) - { - // Process one character page. - size_t endBCD; - pageStart = bcds[startBCD].index & CHARACTER_PAGE_MASK; - - endBCD = startBCD; - while (endBCD < numBCDs && - (bcds[endBCD].index & CHARACTER_PAGE_MASK) == pageStart) - endBCD++; - - { - size_t bcdI; - int numChars = bcds[endBCD - 1].index + 1 - - bcds[startBCD].index; - FONT_PAGE *page = AllocFontPage (numChars); - page->pageStart = pageStart; - page->firstChar = bcds[startBCD].index; - page->numChars = numChars; - *pageEndPtr = page; - pageEndPtr = &page->next; - - for (bcdI = startBCD; bcdI < endBCD; bcdI++) - { - // Process one character. - BuildCharDesc *bcd = &bcds[bcdI]; - TFB_Char *destChar = - &page->charDesc[bcd->index - page->firstChar]; - - if (destChar->data != NULL) - { - // There's already an image for this character. - log_add (log_Debug, "Duplicate image for character %d " - "for font %s.", (int) bcd->index, - _cur_resfile_name); - SDL_FreeSurface (bcd->surface); - continue; - } - - processFontChar (destChar, bcd->surface); - SDL_FreeSurface (bcd->surface); - - if (destChar->disp.height > fontPtr->Leading) - fontPtr->Leading = destChar->disp.height; - if (destChar->disp.width > fontPtr->LeadingWidth) - fontPtr->LeadingWidth = destChar->disp.width; - } - } - - startBCD = endBCD; - } - *pageEndPtr = NULL; - } - - fontPtr->Leading++; - - HFree (bcds); - - (void) fp; /* Satisfying compiler (unused parameter) */ - (void) length; /* Satisfying compiler (unused parameter) */ - return fontPtr; - -err: - if (fontPtr != 0) - HFree (fontPtr); - - if (bcds != NULL) - { - size_t bcdI; - for (bcdI = 0; bcdI < numBCDs; bcdI++) - SDL_FreeSurface (bcds[bcdI].surface); - HFree (bcds); - } - - if (fontDirHandle != NULL) - uio_closeDir (fontDirHandle); - - if (fontDir != 0) - DestroyDirEntryTable (ReleaseDirEntryTable (fontDir)); - - if (fontMount != 0) - uio_unmountDir(fontMount); - - return 0; -} - -BOOLEAN -_ReleaseFontData (void *handle) -{ - FONT font = (FONT) handle; - if (font == NULL) - return FALSE; - - { - FONT_PAGE *page; - FONT_PAGE *nextPage; - - for (page = font->fontPages; page != NULL; page = nextPage) - { - size_t charI; - for (charI = 0; charI < page->numChars; charI++) - { - TFB_Char *c = &page->charDesc[charI]; - - if (c->data == NULL) - continue; - - // XXX: fix this if fonts get per-page data - // rather than per-char - TFB_DrawScreen_DeleteData (c->data); - } - - nextPage = page->next; - FreeFontPage (page); - } - } - - HFree (font); - - return TRUE; -} - -#endif Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-25 02:09:07 UTC (rev 3468) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-25 04:18:45 UTC (rev 3469) @@ -24,6 +24,7 @@ #include "libs/memlib.h" #include "primitives.h" #include "palette.h" +#include "sdluio.h" #include "rotozoom.h" #include "options.h" #include "types.h" @@ -43,6 +44,15 @@ // need error correction here } +const char * +TFB_DrawCanvas_GetError (void) +{ + const char *err = SDL_GetError (); + // TODO: Should we call SDL_ClearError() here so that it is not + // returned again later? + return err; +} + void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color, TFB_Canvas target) @@ -590,6 +600,23 @@ return newsurf; } +TFB_Canvas +TFB_DrawCanvas_LoadFromFile (void *dir, const char *fileName) +{ + SDL_Surface *surf = sdluio_loadImage (dir, fileName); + if (!surf) + return NULL; + + if (surf->format->BitsPerPixel < 8) + { + SDL_SetError ("unsupported image format (min 8bpp)"); + SDL_FreeSurface (surf); + surf = NULL; + } + + return surf; +} + void TFB_DrawCanvas_Delete (TFB_Canvas canvas) { @@ -603,7 +630,51 @@ { SDL_FreeSurface (canvas); } +} +BOOLEAN +TFB_DrawCanvas_GetFontCharData (TFB_Canvas canvas, BYTE *outData, + unsigned dataPitch) +{ + SDL_Surface *surf = canvas; + int x, y; + Uint8 r, g, b, a; + Uint32 p; + SDL_PixelFormat *fmt = surf->format; + GetPixelFn getpix; + + if (!surf || !outData) + return FALSE; + + SDL_LockSurface (surf); + + getpix = getpixel_for (surf); + + // produce an alpha-only image in internal BYTE[] format + // from the SDL surface + for (y = 0; y < surf->h; ++y) + { + BYTE *dst = outData + dataPitch * y; + + for (x = 0; x < surf->w; ++x, ++dst) + { + p = getpix (surf, x, y); + SDL_GetRGBA (p, fmt, &r, &g, &b, &a); + + if (!fmt->Amask) + { // produce alpha from intensity (Y component) + // using a fast approximation + // contributions to Y are: R=2, G=4, B=1 + a = ((r * 2) + (g * 4) + b) / 7; + } + + *dst = a; + } + } + + SDL_UnlockSurface (surf); + + return TRUE; } Color * @@ -1617,10 +1688,14 @@ return c; } + SDL_LockSurface (surf); + getpixel = getpixel_for(surf); pixel = (*getpixel)(surf, x, y); SDL_GetRGBA (pixel, surf->format, &c.r, &c.g, &c.b, &c.a); + SDL_UnlockSurface (surf); + return c; } @@ -1726,6 +1801,7 @@ TFB_DrawCanvas_Intersect (TFB_Canvas canvas1, POINT c1org, TFB_Canvas canvas2, POINT c2org, const RECT *interRect) { + BOOLEAN ret = FALSE; SDL_Surface *surf1 = canvas1; SDL_Surface *surf2 = canvas2; int x, y; @@ -1733,6 +1809,9 @@ Uint32 s1mask, s2mask; GetPixelFn getpixel1, getpixel2; + SDL_LockSurface (surf1); + SDL_LockSurface (surf2); + getpixel1 = getpixel_for (surf1); getpixel2 = getpixel_for (surf2); @@ -1774,10 +1853,15 @@ Uint32 p2 = getpixel2 (surf2, x + c2org.x, y + c2org.y) & s2mask; if (p1 != s1key && p2 != s2key) - return TRUE; // pixel collision + { // pixel collision + ret = TRUE; + break; + } } } - // no pixel collision - return FALSE; + SDL_UnlockSurface (surf2); + SDL_UnlockSurface (surf1); + + return ret; } Modified: trunk/sc2/src/libs/graphics/tfb_draw.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-25 02:09:07 UTC (rev 3468) +++ trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-25 04:18:45 UTC (rev 3469) @@ -118,6 +118,7 @@ void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Image *target); +TFB_Canvas TFB_DrawCanvas_LoadFromFile (void *dir, const char *fileName); TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha); TFB_Canvas TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha); TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, Color palette[256], @@ -157,6 +158,8 @@ void TFB_DrawCanvas_CopyRect (TFB_Canvas source, const RECT *srcRect, TFB_Canvas target, POINT dstPt); +BOOLEAN TFB_DrawCanvas_GetFontCharData (TFB_Canvas canvas, BYTE *outData, + unsigned dataPitch); Color *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas); void TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color palette[256]); int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas); @@ -177,6 +180,8 @@ BOOLEAN TFB_DrawCanvas_Intersect (TFB_Canvas canvas1, POINT c1org, TFB_Canvas canvas2, POINT c2org, const RECT *interRect); +const char *TFB_DrawCanvas_GetError (void); + TFB_Canvas TFB_GetScreenCanvas (SCREEN screen); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2009-12-27 04:42:58
|
Revision: 3475 http://sc2.svn.sourceforge.net/sc2/?rev=3475&view=rev Author: avolkov Date: 2009-12-27 04:42:50 +0000 (Sun, 27 Dec 2009) Log Message: ----------- Added additive and alpha drawing mode to gfxlib proper (TFB_Draw/TFB_Canvas/Color); this is to replace arith_frame_blit()/TFB_BlitSurface() Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/graphics/context.c trunk/sc2/src/libs/graphics/context.h trunk/sc2/src/libs/graphics/dcqueue.c trunk/sc2/src/libs/graphics/drawcmd.h trunk/sc2/src/libs/graphics/font.c trunk/sc2/src/libs/graphics/frame.c trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/sdl/primitives.c trunk/sc2/src/libs/graphics/sdl/primitives.h trunk/sc2/src/libs/graphics/tfb_draw.c trunk/sc2/src/libs/graphics/tfb_draw.h trunk/sc2/src/libs/graphics/tfb_prim.c trunk/sc2/src/libs/graphics/tfb_prim.h trunk/sc2/src/libs/video/vidplayer.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/ChangeLog 2009-12-27 04:42:50 UTC (rev 3475) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Added additive and alpha drawing modes to graphics lib - Alex - Fixed black pixel gaps between the planet and shield when entering the orbit of a shielded planet (bug #32) - Alex - Split off SDL-specific colormap bits into SDL domain - Alex Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/gfxlib.h 2009-12-27 04:42:50 UTC (rev 3475) @@ -277,6 +277,56 @@ FadeSomeToColor } ScreenFadeType; +typedef enum +{ + DRAW_REPLACE = 0, + // Pixels in the target FRAME are replaced entirely. + // Non-stamp primitives with Color.a < 255 to RGB targets are + // equivalent to DRAW_ALPHA with (DrawMode.factor = Color.a), + // except the Text primitives. + // DrawMode.factor: ignored + // Text: supported (except DRAW_ALPHA via Color.a) + // RGBA sources (WANT_ALPHA): per-pixel alpha blending performed + // RGBA targets (WANT_ALPHA): replace directly supported + DRAW_ADDITIVE, + // Pixel channels of the source FRAME or Color channels of + // a primitive are modulated by (DrawMode.factor / 255) and added + // to the pixel channels of the target FRAME. + // DrawMode.factor range: -32767..32767 (negative values make + // draw subtractive); 255 = 1:1 ratio + // Text: not yet supported + // RGBA sources (WANT_ALPHA): alpha channel ignored + // RGBA targets (WANT_ALPHA): not yet supported + DRAW_ALPHA, + // Pixel channels of the source FRAME or Color channels of + // a primitive are modulated by (DrawMode.factor / 255) and added + // to the pixel channels of the target FRAME, modulated by + // (1 - DrawMode.factor / 255) + // DrawMode.factor range: 0..255; 255 = fully opaque + // Text: supported + // RGBA sources (WANT_ALPHA): alpha channel ignored + // RGBA targets (WANT_ALPHA): not yet supported + + DRAW_DEFAULT = DRAW_REPLACE, +} DrawKind; + +typedef struct +{ + BYTE kind; + SWORD factor; +} DrawMode; + +#define DRAW_REPLACE_MODE MAKE_DRAW_MODE (DRAW_REPLACE, 0) + +static inline DrawMode +MAKE_DRAW_MODE (DrawKind kind, SWORD factor) +{ + DrawMode mode; + mode.kind = kind; + mode.factor = factor; + return mode; +} + extern CONTEXT SetContext (CONTEXT Context); extern Color SetContextForeGroundColor (Color Color); extern Color GetContextForeGroundColor (void); @@ -292,6 +342,8 @@ extern BOOLEAN GetContextClipRect (RECT *pRect); // The actual origin will be orgOffset + context ClipRect.corner extern POINT SetContextOrigin (POINT orgOffset); +extern DrawMode SetContextDrawMode (DrawMode); +extern DrawMode GetContextDrawMode (void); extern TIME_VALUE DrawablesIntersect (INTERSECT_CONTROL *pControl0, INTERSECT_CONTROL *pControl1, TIME_VALUE max_time_val); Modified: trunk/sc2/src/libs/graphics/context.c =================================================================== --- trunk/sc2/src/libs/graphics/context.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/context.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -33,6 +33,11 @@ FONT _CurFontPtr; +#define DEFAULT_FORE_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) +#define DEFAULT_BACK_COLOR BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) + +#define DEFAULT_DRAW_MODE MAKE_DRAW_MODE (DRAW_DEFAULT, 255) + CONTEXT SetContext (CONTEXT Context) { @@ -84,8 +89,6 @@ if (NewContext) { /* initialize context */ - CONTEXT OldContext; - #ifdef DEBUG NewContext->name = name; NewContext->next = NULL; @@ -93,12 +96,9 @@ contextEnd = &NewContext->next; #endif /* DEBUG */ - OldContext = SetContext (NewContext); - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); - SetContextBackGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); - SetContext (OldContext); + NewContext->Mode = DEFAULT_DRAW_MODE; + NewContext->ForeGroundColor = DEFAULT_FORE_COLOR; + NewContext->BackGroundColor = DEFAULT_BACK_COLOR; } return NewContext; @@ -149,7 +149,7 @@ Color oldColor; if (!ContextActive ()) - return (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); + return DEFAULT_FORE_COLOR; oldColor = _get_context_fg_color (); if (!sameColor(oldColor, color)) @@ -170,7 +170,7 @@ GetContextForeGroundColor (void) { if (!ContextActive ()) - return (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); + return DEFAULT_FORE_COLOR; return _get_context_fg_color (); } @@ -181,7 +181,7 @@ Color oldColor; if (!ContextActive ()) - return (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); + return DEFAULT_BACK_COLOR; oldColor = _get_context_bg_color (); if (!sameColor(oldColor, color)) @@ -194,11 +194,34 @@ GetContextBackGroundColor (void) { if (!ContextActive ()) - return (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); + return DEFAULT_BACK_COLOR; return _get_context_bg_color (); } +DrawMode +SetContextDrawMode (DrawMode mode) +{ + DrawMode oldMode; + + if (!ContextActive ()) + return DEFAULT_DRAW_MODE; + + oldMode = _get_context_draw_mode (); + SwitchContextDrawMode (mode); + + return oldMode; +} + +DrawMode +GetContextDrawMode (void) +{ + if (!ContextActive ()) + return DEFAULT_DRAW_MODE; + + return _get_context_draw_mode (); +} + // Returns a rect based at 0,0 and the size of context foreground frame static inline RECT _get_context_fg_rect (void) @@ -306,14 +329,14 @@ TFB_DrawImage_Image (EffectFrame->image, -EffectFrame->HotSpot.x, -EffectFrame->HotSpot.y, - 0, 0, NULL, img); + 0, 0, NULL, DRAW_REPLACE_MODE, img); } else { // solid color backing RECT r = { {0, 0}, {w, h} }; Color color = _get_context_fg_color (); - TFB_DrawImage_Rect (&r, color, img); + TFB_DrawImage_Rect (&r, color, DRAW_REPLACE_MODE, img); } _pCurContext->FontBacking = img; Modified: trunk/sc2/src/libs/graphics/context.h =================================================================== --- trunk/sc2/src/libs/graphics/context.h 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/context.h 2009-12-27 04:42:50 UTC (rev 3475) @@ -33,6 +33,7 @@ // High nibble contains GRAPHICS_STATUS Color ForeGroundColor, BackGroundColor; + DrawMode Mode; FRAME ForeGroundFrame; FONT Font; @@ -62,10 +63,11 @@ #define _get_context_fbk_flags() (_pCurContext->BackingFlags) #define _get_context_fonteff() (_pCurContext->FontEffect) #define _get_context_font_backing() (_pCurContext->FontBacking) +#define _get_context_draw_mode() (_pCurContext->Mode) -#define SwitchContextDrawState(s) \ +#define SwitchContextDrawMode(m) \ { \ - _pCurContext->DrawState = (s); \ + _pCurContext->Mode = (m); \ } #define SwitchContextForeGroundColor(c) \ { \ Modified: trunk/sc2/src/libs/graphics/dcqueue.c =================================================================== --- trunk/sc2/src/libs/graphics/dcqueue.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/dcqueue.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -377,6 +377,7 @@ TFB_DrawCanvas_Image (DC_image, x, y, cmd->scale, cmd->scaleMode, cmd->colormap, + cmd->drawMode, TFB_GetScreenCanvas (cmd->destBuffer)); if (cmd->destBuffer == TFB_SCREEN_MAIN) @@ -405,6 +406,7 @@ TFB_DrawCanvas_FilledImage (DC_image, x, y, cmd->scale, cmd->scaleMode, cmd->color, + cmd->drawMode, TFB_GetScreenCanvas (cmd->destBuffer)); if (cmd->destBuffer == TFB_SCREEN_MAIN) @@ -432,7 +434,7 @@ const int y = cmd->y; TFB_DrawCanvas_FontChar (DC_char, cmd->backing, x, y, - TFB_GetScreenCanvas (cmd->destBuffer)); + cmd->drawMode, TFB_GetScreenCanvas (cmd->destBuffer)); if (cmd->destBuffer == TFB_SCREEN_MAIN) { @@ -459,7 +461,8 @@ TFB_BBox_RegisterPoint (cmd->x2, cmd->y2); } TFB_DrawCanvas_Line (cmd->x1, cmd->y1, cmd->x2, cmd->y2, - cmd->color, TFB_GetScreenCanvas (cmd->destBuffer)); + cmd->color, cmd->drawMode, + TFB_GetScreenCanvas (cmd->destBuffer)); break; } @@ -469,7 +472,7 @@ if (cmd->destBuffer == TFB_SCREEN_MAIN) TFB_BBox_RegisterRect (&cmd->rect); - TFB_DrawCanvas_Rect (&cmd->rect, cmd->color, + TFB_DrawCanvas_Rect (&cmd->rect, cmd->color, cmd->drawMode, TFB_GetScreenCanvas (cmd->destBuffer)); break; Modified: trunk/sc2/src/libs/graphics/drawcmd.h =================================================================== --- trunk/sc2/src/libs/graphics/drawcmd.h 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/drawcmd.h 2009-12-27 04:42:50 UTC (rev 3475) @@ -47,6 +47,7 @@ { int x1, y1, x2, y2; Color color; + DrawMode drawMode; SCREEN destBuffer; } TFB_DrawCommand_Line; @@ -54,6 +55,7 @@ { RECT rect; Color color; + DrawMode drawMode; SCREEN destBuffer; } TFB_DrawCommand_Rect; @@ -63,6 +65,7 @@ int x, y; SCREEN destBuffer; TFB_ColorMap *colormap; + DrawMode drawMode; int scale; int scaleMode; } TFB_DrawCommand_Image; @@ -73,6 +76,7 @@ int x, y; Color color; SCREEN destBuffer; + DrawMode drawMode; int scale; int scaleMode; } TFB_DrawCommand_FilledImage; @@ -82,6 +86,7 @@ TFB_Char *fontchar; TFB_Image *backing; int x, y; + DrawMode drawMode; SCREEN destBuffer; } TFB_DrawCommand_FontChar; Modified: trunk/sc2/src/libs/graphics/font.c =================================================================== --- trunk/sc2/src/libs/graphics/font.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/font.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -243,6 +243,7 @@ const char *pStr; POINT origin; TFB_Image *backing; + DrawMode mode = _get_context_draw_mode (); FontPtr = _CurFontPtr; if (FontPtr == NULL) @@ -286,7 +287,8 @@ r.extent.height = fontChar->disp.height; if (BoxIntersect (&r, pClipRect, &r)) { - TFB_Prim_FontChar (origin, fontChar, backing, ctxOrigin); + TFB_Prim_FontChar (origin, fontChar, backing, mode, + ctxOrigin); } origin.x += fontChar->disp.width; Modified: trunk/sc2/src/libs/graphics/frame.c =================================================================== --- trunk/sc2/src/libs/graphics/frame.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/frame.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -92,7 +92,8 @@ clearRect.corner.x = 0; clearRect.corner.y = 0; clearRect.extent = pClipRect->extent; - TFB_Prim_FillRect (&clearRect, color, pClipRect->corner); + TFB_Prim_FillRect (&clearRect, color, DRAW_REPLACE_MODE, + pClipRect->corner); } void @@ -106,6 +107,7 @@ { COUNT CurIndex; PRIMITIVE *lpPrim; + DrawMode mode = _get_context_draw_mode (); BatchGraphics (); @@ -135,19 +137,21 @@ { case POINT_PRIM: color = GetPrimColor (lpWorkPrim); - TFB_Prim_Point (&lpWorkPrim->Object.Point, color, origin); + TFB_Prim_Point (&lpWorkPrim->Object.Point, color, + mode, origin); break; case STAMP_PRIM: - TFB_Prim_Stamp (&lpWorkPrim->Object.Stamp, origin); + TFB_Prim_Stamp (&lpWorkPrim->Object.Stamp, mode, origin); break; case STAMPFILL_PRIM: color = GetPrimColor (lpWorkPrim); TFB_Prim_StampFill (&lpWorkPrim->Object.Stamp, color, - origin); + mode, origin); break; case LINE_PRIM: color = GetPrimColor (lpWorkPrim); - TFB_Prim_Line (&lpWorkPrim->Object.Line, color, origin); + TFB_Prim_Line (&lpWorkPrim->Object.Line, color, + mode, origin); break; case TEXT_PRIM: if (!TextRect (&lpWorkPrim->Object.Text, &ClipRect, NULL)) @@ -157,11 +161,13 @@ break; case RECT_PRIM: color = GetPrimColor (lpWorkPrim); - TFB_Prim_Rect (&lpWorkPrim->Object.Rect, color, origin); + TFB_Prim_Rect (&lpWorkPrim->Object.Rect, color, + mode, origin); break; case RECTFILL_PRIM: color = GetPrimColor (lpWorkPrim); - TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, color, origin); + TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, color, + mode, origin); break; } } @@ -189,7 +195,8 @@ if (GraphicsSystemActive () && GetContextValidRect (NULL, &origin)) { Color color = GetPrimColor (&_locPrim); - TFB_Prim_Point (lpPoint, color, origin); + DrawMode mode = _get_context_draw_mode (); + TFB_Prim_Point (lpPoint, color, mode, origin); } } @@ -201,7 +208,8 @@ if (GraphicsSystemActive () && GetContextValidRect (NULL, &origin)) { Color color = GetPrimColor (&_locPrim); - TFB_Prim_Rect (lpRect, color, origin); + DrawMode mode = _get_context_draw_mode (); + TFB_Prim_Rect (lpRect, color, mode, origin); } } @@ -213,7 +221,8 @@ if (GraphicsSystemActive () && GetContextValidRect (NULL, &origin)) { Color color = GetPrimColor (&_locPrim); - TFB_Prim_FillRect (lpRect, color, origin); + DrawMode mode = _get_context_draw_mode (); + TFB_Prim_FillRect (lpRect, color, mode, origin); } } @@ -225,7 +234,8 @@ if (GraphicsSystemActive () && GetContextValidRect (NULL, &origin)) { Color color = GetPrimColor (&_locPrim); - TFB_Prim_Line (lpLine, color, origin); + DrawMode mode = _get_context_draw_mode (); + TFB_Prim_Line (lpLine, color, mode, origin); } } @@ -236,7 +246,8 @@ if (GraphicsSystemActive () && GetContextValidRect (NULL, &origin)) { - TFB_Prim_Stamp (stmp, origin); + DrawMode mode = _get_context_draw_mode (); + TFB_Prim_Stamp (stmp, mode, origin); } } @@ -248,7 +259,8 @@ if (GraphicsSystemActive () && GetContextValidRect (NULL, &origin)) { Color color = GetPrimColor (&_locPrim); - TFB_Prim_StampFill (stmp, color, origin); + DrawMode mode = _get_context_draw_mode (); + TFB_Prim_StampFill (stmp, color, mode, origin); } } Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -57,23 +57,46 @@ } void +checkPrimitiveMode (SDL_Surface *surf, Color *color, DrawMode *mode) +{ + const SDL_PixelFormat *fmt = surf->format; + // Special case: We support DRAW_ALPHA mode to non-alpha surfaces + // for primitives via Color.a + if (mode->kind == DRAW_REPLACE && fmt->Amask == 0 && color->a != 0xff) + { + mode->kind = DRAW_ALPHA; + mode->factor = color->a; + color->a = 0xff; + } +} + +void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color, - TFB_Canvas target) + DrawMode mode, TFB_Canvas target) { + SDL_Surface *dst = target; + SDL_PixelFormat *fmt = dst->format; Uint32 sdlColor; - PutPixelFn screen_plot; - - screen_plot = putpixel_for (target); - sdlColor = SDL_MapRGB (((NativeCanvas) target)->format, - color.r, color.g, color.b); + RenderPixelFn plotFn; - SDL_LockSurface (target); - line (x1, y1, x2, y2, sdlColor, screen_plot, target); - SDL_UnlockSurface (target); + checkPrimitiveMode (dst, &color, &mode); + sdlColor = SDL_MapRGBA (fmt, color.r, color.g, color.b, color.a); + + plotFn = renderpixel_for (target, mode.kind); + if (!plotFn) + { + log_add (log_Warning, "ERROR: TFB_DrawCanvas_Line " + "unsupported draw mode (%d)", (int)mode.kind); + return; + } + + SDL_LockSurface (dst); + line_prim (x1, y1, x2, y2, sdlColor, plotFn, mode.factor, dst); + SDL_UnlockSurface (dst); } void -TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas target) +TFB_DrawCanvas_Rect (RECT *rect, Color color, DrawMode mode, TFB_Canvas target) { SDL_Surface *dst = target; SDL_PixelFormat *fmt = dst->format; @@ -84,22 +107,95 @@ sr.w = rect->extent.width; sr.h = rect->extent.height; - sdlColor = SDL_MapRGB (fmt, color.r, color.g, color.b); - if (fmt->Amask && (dst->flags & SDL_SRCCOLORKEY)) - { // special case -- alpha surface with colorkey - // colorkey rects are transparent - if ((sdlColor & ~fmt->Amask) == (fmt->colorkey & ~fmt->Amask)) - sdlColor &= ~fmt->Amask; // make transparent + checkPrimitiveMode (dst, &color, &mode); + sdlColor = SDL_MapRGBA (fmt, color.r, color.g, color.b, color.a); + + if (mode.kind == DRAW_REPLACE) + { // Standard SDL fillrect rendering + if (fmt->Amask && (dst->flags & SDL_SRCCOLORKEY)) + { // special case -- alpha surface with colorkey + // colorkey rects are transparent + if ((sdlColor & ~fmt->Amask) == (fmt->colorkey & ~fmt->Amask)) + sdlColor &= ~fmt->Amask; // make transparent + } + SDL_FillRect (dst, &sr, sdlColor); } - - SDL_FillRect (dst, &sr, sdlColor); + else + { // Custom fillrect rendering + RenderPixelFn plotFn = renderpixel_for (target, mode.kind); + if (!plotFn) + { + log_add (log_Warning, "ERROR: TFB_DrawCanvas_Rect " + "unsupported draw mode (%d)", (int)mode.kind); + return; + } + + SDL_LockSurface (dst); + fillrect_prim (sr, sdlColor, plotFn, mode.factor, dst); + SDL_UnlockSurface (dst); + } } +static void +TFB_DrawCanvas_Blit (SDL_Surface *src, SDL_Rect *src_r, + SDL_Surface *dst, SDL_Rect *dst_r, DrawMode mode) +{ + SDL_PixelFormat *srcfmt = src->format; + + if (mode.kind == DRAW_REPLACE) + { // Standard SDL simple blit + SDL_BlitSurface (src, src_r, dst, dst_r); + } + else if (mode.kind == DRAW_ALPHA && srcfmt->Amask == 0) + { // Standard SDL surface-alpha blit + // Note that surface alpha and per-pixel alpha cannot work + // at the same time, which is why the Amask test + assert (!(src->flags & SDL_SRCALPHA)); + // Set surface alpha temporarily + SDL_SetAlpha (src, SDL_SRCALPHA, mode.factor); + SDL_BlitSurface (src, src_r, dst, dst_r); + SDL_SetAlpha (src, 0, 255); + } + else + { // Custom blit + SDL_Rect loc_src_r, loc_dst_r; + RenderPixelFn plotFn = renderpixel_for (dst, mode.kind); + if (!plotFn) + { + log_add (log_Warning, "ERROR: TFB_DrawCanvas_Blit " + "unsupported draw mode (%d)", (int)mode.kind); + return; + } + + if (!src_r) + { // blit whole image; generate rect + loc_src_r.x = 0; + loc_src_r.y = 0; + loc_src_r.w = src->w; + loc_src_r.h = src->h; + src_r = &loc_src_r; + } + + if (!dst_r) + { // blit to 0,0; generate rect + loc_dst_r.x = 0; + loc_dst_r.y = 0; + loc_dst_r.w = dst->w; + loc_dst_r.h = dst->h; + dst_r = &loc_dst_r; + } + + SDL_LockSurface (dst); + blt_prim (src, *src_r, plotFn, mode.factor, dst, *dst_r); + SDL_UnlockSurface (dst); + } +} + // XXX: If a colormap is passed in, it has to have been acquired via // TFB_GetColorMap(). We release the colormap at the end. void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, - int scaleMode, TFB_ColorMap *cmap, TFB_Canvas target) + int scaleMode, TFB_ColorMap *cmap, DrawMode mode, TFB_Canvas target) { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; @@ -170,18 +266,18 @@ TFB_ReturnColorMap (cmap); } - SDL_BlitSurface (surf, pSrcRect, target, &targetRect); + TFB_DrawCanvas_Blit (surf, pSrcRect, target, &targetRect, mode); UnlockMutex (img->mutex); } -void -TFB_DrawCanvas_Fill (TFB_Canvas source, int width, int height, - Uint32 fillcolor, TFB_Canvas target) +// Assumes the source and destination surfaces are in the same format +static void +TFB_DrawCanvas_Fill (SDL_Surface *src, Uint32 fillcolor, SDL_Surface *dst) { - SDL_Surface *src = source; - SDL_Surface *dst = target; const SDL_PixelFormat *srcfmt = src->format; SDL_PixelFormat *dstfmt = dst->format; + const int width = src->w; + const int height = src->h; const int bpp = dstfmt->BytesPerPixel; const int sp = src->pitch, dp = dst->pitch; const int slen = sp / bpp, dlen = dp / bpp; @@ -190,6 +286,8 @@ Uint32 *dst_p; int x, y; Uint32 dstkey = 0; // 0 means alpha=0 too + Uint32 amask = srcfmt->Amask; + int alpha = (fillcolor & amask) >> srcfmt->Ashift; if (srcfmt->BytesPerPixel != 4 || dstfmt->BytesPerPixel != 4) { @@ -199,6 +297,10 @@ return; } + // Strip the alpha channel from fillcolor because we process the + // alpha separately + fillcolor &= ~amask; + SDL_LockSurface(src); SDL_LockSurface(dst); @@ -213,35 +315,42 @@ if (srcfmt->Amask) { // alpha-based fill - Uint32 amask = srcfmt->Amask; - - for (y = 0; y < height; ++y) + for (y = 0; y < height; ++y, dst_p += ddst, src_p += dsrc) { for (x = 0; x < width; ++x, ++src_p, ++dst_p) { Uint32 p = *src_p & amask; - - *dst_p = (p == 0) ? dstkey : (p | fillcolor); + + if (p == 0) + { // fully transparent pixel + *dst_p = dstkey; + } + else if (alpha == 0xff) + { // not for DRAW_ALPHA; use alpha chan directly + *dst_p = p | fillcolor; + } + else + { // for DRAW_ALPHA; modulate the alpha channel + p >>= srcfmt->Ashift; + p = (p * alpha) >> 8; + p <<= srcfmt->Ashift; + *dst_p = p | fillcolor; + } } - dst_p += ddst; - src_p += dsrc; } } else if (src->flags & SDL_SRCCOLORKEY) { // colorkey-based fill Uint32 srckey = srcfmt->colorkey; - Uint32 notmask = ~srcfmt->Amask; - for (y = 0; y < height; ++y) + for (y = 0; y < height; ++y, dst_p += ddst, src_p += dsrc) { for (x = 0; x < width; ++x, ++src_p, ++dst_p) { - Uint32 p = *src_p & notmask; + Uint32 p = *src_p; *dst_p = (p == srckey) ? dstkey : fillcolor; } - dst_p += ddst; - src_p += dsrc; } } else @@ -262,8 +371,9 @@ void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, - int scaleMode, Color color, TFB_Canvas target) + int scaleMode, Color color, DrawMode mode, TFB_Canvas target) { + SDL_Surface *dst = target; SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; SDL_Palette *palette; @@ -277,6 +387,8 @@ return; } + checkPrimitiveMode (dst, &color, &mode); + LockMutex (img->mutex); if (scale != 0 && scale != GSCALE_IDENTITY) @@ -338,6 +450,7 @@ else { // fill the non-transparent parts of the image with fillcolor SDL_Surface *newfill = img->FilledImg; + SDL_PixelFormat *fillfmt; if (newfill && (newfill->w < surf->w || newfill->h < surf->h)) { @@ -357,35 +470,43 @@ surf->format->Amask); force_fill = true; } + fillfmt = newfill->format; - if (force_fill || - img->last_fill.r != color.r || - img->last_fill.g != color.g || - img->last_fill.b != color.b) + if (force_fill || !sameColor (img->last_fill, color)) { // image or fillcolor changed - regenerate - TFB_DrawCanvas_Fill (surf, surf->w, surf->h, SDL_MapRGBA ( - newfill->format, color.r, color.g, color.b, 0), newfill); - // important to keep alpha=0 in fillcolor - // -- we process alpha ourselves + Uint32 fillColor; + if (mode.kind == DRAW_ALPHA && fillfmt->Amask) + { // Per-pixel alpha and surface alpha will not work together + // We have to handle DRAW_ALPHA differently by modulating + // the surface alpha channel ourselves. + color.a = mode.factor; + mode.kind = DRAW_REPLACE; + } + else + { // Make sure we do not modulate the alpha channel + color.a = 0xff; + } + fillColor = SDL_MapRGBA (newfill->format, color.r, color.g, + color.b, color.a); + TFB_DrawCanvas_Fill (surf, fillColor, newfill); // cache filled image if possible - img->last_fill.r = color.r; - img->last_fill.g = color.g; - img->last_fill.b = color.b; + img->last_fill = color; } img->FilledImg = newfill; surf = newfill; } - SDL_BlitSurface (surf, pSrcRect, target, &targetRect); + TFB_DrawCanvas_Blit (surf, pSrcRect, dst, &targetRect, mode); UnlockMutex (img->mutex); } void TFB_DrawCanvas_FontChar (TFB_Char *fontChar, TFB_Image *backing, - int x, int y, TFB_Canvas target) + int x, int y, DrawMode mode, TFB_Canvas target) { + SDL_Surface *dst = target; SDL_Rect srcRect, targetRect; SDL_Surface *surf; int w, h; @@ -439,17 +560,46 @@ Uint8 *src_p = fontChar->data; Uint32 *dst_p = (Uint32 *)surf->pixels; - for (y = 0; y < h; ++y, src_p += sskip, dst_p += dskip) - { - for (x = 0; x < w; ++x, ++src_p, ++dst_p) + if (mode.kind == DRAW_ALPHA) + { // Per-pixel alpha and surface alpha will not work together + // We have to handle DRAW_ALPHA differently by modulating + // the backing surface alpha channel ourselves. + // The existing backing surface alpha channel is ignored. + int alpha = mode.factor; + mode.kind = DRAW_REPLACE; + + for (y = 0; y < h; ++y, src_p += sskip, dst_p += dskip) { - *dst_p = (*dst_p & dmask) | (((Uint32)*src_p) << ashift); + for (x = 0; x < w; ++x, ++src_p, ++dst_p) + { + Uint32 p = *dst_p & dmask; + Uint32 a = *src_p; + + // we use >> 8 instead of / 255, and it does not handle + // alpha == 255 correctly + if (alpha != 0xff) + { // modulate the alpha channel + a = (a * alpha) >> 8; + } + *dst_p = p | (a << ashift); + } } } + else /* if (mode.kind != DRAW_ALPHA) */ + { // Transfer the alpha channel to the backing surface + // DRAW_REPLACE + Color.a is NOT supported right now + for (y = 0; y < h; ++y, src_p += sskip, dst_p += dskip) + { + for (x = 0; x < w; ++x, ++src_p, ++dst_p) + { + *dst_p = (*dst_p & dmask) | ((Uint32)*src_p << ashift); + } + } + } } SDL_UnlockSurface (surf); - SDL_BlitSurface (surf, &srcRect, target, &targetRect); + TFB_DrawCanvas_Blit (surf, &srcRect, dst, &targetRect, mode); UnlockMutex (backing->mutex); } @@ -1090,6 +1240,7 @@ #if 0 SDL_GetRGBA (c, fmt, &p.c.r, &p.c.g, &p.c.b, &p.c.a); #else + // Assume 8 bits/channel; a safe assumption with 32bpp surfaces p.c.r = (c >> fmt->Rshift) & 0xff; p.c.g = (c >> fmt->Gshift) & 0xff; p.c.b = (c >> fmt->Bshift) & 0xff; Modified: trunk/sc2/src/libs/graphics/sdl/primitives.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/primitives.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/sdl/primitives.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -18,6 +18,7 @@ #ifdef GFXMODULE_SDL +#include "port.h" #include "sdl_common.h" #include "primitives.h" @@ -104,20 +105,16 @@ switch (bpp) { case 1: return &getpixel_8; - break; case 2: return &getpixel_16; - break; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { return &getpixel_24_be; } else { return &getpixel_24_le; } - break; case 4: return &getpixel_32; - break; } return NULL; } @@ -128,36 +125,167 @@ switch (bpp) { case 1: return &putpixel_8; - break; case 2: return &putpixel_16; - break; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { return &putpixel_24_be; } else { return &putpixel_24_le; } - break; case 4: return &putpixel_32; - break; } return NULL; } +static void renderpixel_replace(SDL_Surface *surface, int x, int y, + Uint32 pixel, int factor) +{ + (void) factor; // ignored + putpixel_32(surface, x, y, pixel); +} + +static inline Uint8 clip_channel(int c) +{ + if (c < 0) + c = 0; + else if (c > 255) + c = 255; + return c; +} + +static inline Uint8 modulated_sum(Uint8 dc, Uint8 sc, int factor) +{ + // We use >> 8 instead of / 255 because it is faster, but it does + // not work 100% correctly. It should be safe because this should + // not be called for factor==255 + int b = dc + ((sc * factor) >> 8); + return clip_channel(b); +} + +static inline Uint8 alpha_blend(Uint8 dc, Uint8 sc, int alpha) +{ + // We use >> 8 instead of / 255 because it is faster, but it does + // not work 100% correctly. It should be safe because this should + // not be called for alpha==255 + // No need to clip since we should never get values outside of 0..255 + // range, unless alpha is over 255, which is not supported. + return (((sc - dc) * alpha) >> 8) + dc; +} + +// Assumes 8 bits/channel, a safe assumption for 32bpp surfaces +#define UNPACK_PIXEL_32(p, fmt, r, g, b) \ + do { \ + (r) = ((p) >> (fmt)->Rshift) & 0xff; \ + (g) = ((p) >> (fmt)->Gshift) & 0xff; \ + (b) = ((p) >> (fmt)->Bshift) & 0xff; \ + } while (0) + +// Assumes the channels already clipped to 8 bits +static inline Uint32 PACK_PIXEL_32(const SDL_PixelFormat *fmt, + Uint8 r, Uint8 g, Uint8 b) +{ + return ((Uint32)r << fmt->Rshift) | ((Uint32)g << fmt->Gshift) + | ((Uint32)b << fmt->Bshift); +} + +static void renderpixel_additive(SDL_Surface *surface, int x, int y, + Uint32 pixel, int factor) +{ + const SDL_PixelFormat *fmt = surface->format; + Uint32 *p; + Uint32 sp; + Uint8 sr, sg, sb; + int r, g, b; + + p = (Uint32 *) ((Uint8 *)surface->pixels + y * surface->pitch + x * 4); + sp = *p; + UNPACK_PIXEL_32(sp, fmt, sr, sg, sb); + UNPACK_PIXEL_32(pixel, fmt, r, g, b); + + // TODO: We may need a special case for factor == -ADDITIVE_FACTOR_1 too, + // but it is not important enough right now to care ;) + if (factor == ADDITIVE_FACTOR_1) + { // no need to modulate the 'pixel', and modulation does not + // work correctly with factor==255 anyway + sr = clip_channel(sr + r); + sg = clip_channel(sg + g); + sb = clip_channel(sb + b); + } + else + { + sr = modulated_sum(sr, r, factor); + sg = modulated_sum(sg, g, factor); + sb = modulated_sum(sb, b, factor); + } + + *p = PACK_PIXEL_32(fmt, sr, sg, sb); +} + +static void renderpixel_alpha(SDL_Surface *surface, int x, int y, + Uint32 pixel, int factor) +{ + const SDL_PixelFormat *fmt = surface->format; + Uint32 *p; + Uint32 sp; + Uint8 sr, sg, sb; + int r, g, b; + + if (factor == FULLY_OPAQUE_ALPHA) + { // alpha == 255 is equivalent to 'replace' and blending does not + // work correctly anyway because we use >> 8 instead of / 255 + putpixel_32(surface, x, y, pixel); + return; + } + + p = (Uint32 *) ((Uint8 *)surface->pixels + y * surface->pitch + x * 4); + sp = *p; + UNPACK_PIXEL_32(sp, fmt, sr, sg, sb); + UNPACK_PIXEL_32(pixel, fmt, r, g, b); + sr = alpha_blend(sr, r, factor); + sg = alpha_blend(sg, g, factor); + sb = alpha_blend(sb, b, factor); + *p = PACK_PIXEL_32(fmt, sr, sg, sb); +} + +RenderPixelFn renderpixel_for(SDL_Surface *surface, RenderKind kind) +{ + const SDL_PixelFormat *fmt = surface->format; + + // The only supported rendering is to 32bpp surfaces + if (fmt->BytesPerPixel != 4) + return NULL; + + // Rendering other than REPLACE is not supported on RGBA surfaces + if (fmt->Amask != 0 && kind != renderReplace) + return NULL; + + switch (kind) + { + case renderReplace: + return &renderpixel_replace; + case renderAdditive: + return &renderpixel_additive; + case renderAlpha: + return &renderpixel_alpha; + } + // should not ever get here + return NULL; +} + /* Line drawing routine * Adapted from Paul Heckbert's implementation of Bresenham's algorithm, * 3 Sep 85; taken from Graphics Gems I */ -void line(int x1, int y1, int x2, int y2, Uint32 color, PutPixelFn plot, - SDL_Surface *surface) +void line_prim(int x1, int y1, int x2, int y2, Uint32 color, + RenderPixelFn plot, int factor, SDL_Surface *dst) { int d, x, y, ax, ay, sx, sy, dx, dy; - SDL_Rect r; + SDL_Rect clip_r; - SDL_GetClipRect (surface, &r); - if (!clip_line (&x1, &y1, &x2, &y2, &r)) + SDL_GetClipRect (dst, &clip_r); + if (!clip_line (&x1, &y1, &x2, &y2, &clip_r)) return; // line is completely outside clipping rectangle dx = x2-x1; @@ -172,7 +300,7 @@ if (ax > ay) { d = ay - (ax >> 1); for (;;) { - (*plot)(surface, x, y, color); + (*plot)(dst, x, y, color, factor); if (x == x2) return; if (d >= 0) { @@ -185,7 +313,7 @@ } else { d = ax - (ay >> 1); for (;;) { - (*plot)(surface, x, y, color); + (*plot)(dst, x, y, color, factor); if (y == y2) return; if (d >= 0) { @@ -219,7 +347,7 @@ } int -clip_line (int *lx1, int *ly1, int *lx2, int *ly2, SDL_Rect *r) +clip_line (int *lx1, int *ly1, int *lx2, int *ly2, const SDL_Rect *r) { int C0, C1, C; float x, y, x0, y0, x1, y1, xmin, ymin, xmax, ymax; @@ -289,4 +417,191 @@ } } +void fillrect_prim(SDL_Rect r, Uint32 color, + RenderPixelFn plot, int factor, SDL_Surface *dst) +{ + int x, y; + int x1, y1; + SDL_Rect clip_r; + + SDL_GetClipRect (dst, &clip_r); + if (!clip_rect (&r, &clip_r)) + return; // rect is completely outside clipping rectangle + + // TODO: calculate destination pointer directly instead of + // using the plot(x,y) version + x1 = r.x + r.w; + y1 = r.y + r.h; + for (y = r.y; y < y1; ++y) + { + for (x = r.x; x < x1; ++x) + plot(dst, x, y, color, factor); + } +} + +// clip the rectangle against the clip rectangle +int clip_rect(SDL_Rect *r, const SDL_Rect *clip_r) +{ + // NOTE: the following clipping code is copied in part + // from SDL-1.2.4 sources + int dx, dy; + + dx = clip_r->x - r->x; + if (dx > 0) + { + r->w -= dx; + r->x += dx; + } + dx = r->x + r->w - clip_r->x - clip_r->w; + if (dx > 0) + r->w -= dx; + + dy = clip_r->y - r->y; + if (dy > 0) + { + r->h -= dy; + r->y += dy; + } + dy = r->y + r->h - clip_r->y - clip_r->h; + if (dy > 0) + r->h -= dy; + + if (r->w <= 0 || r->h <= 0) + { + r->w = 0; + r->h = 0; + return 0; + } + return 1; +} + +void blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, + SDL_Surface *dst, SDL_Rect dst_r) +{ + SDL_PixelFormat *srcfmt = src->format; + SDL_Palette *srcpal = srcfmt->palette; + SDL_PixelFormat *dstfmt = dst->format; + Uint32 mask = 0; + Uint32 key = ~0; + GetPixelFn getpix = getpixel_for(src); + SDL_Rect clip_r; + int x, y; + + SDL_GetClipRect (dst, &clip_r); + if (!clip_blt_rects (&src_r, &dst_r, &clip_r)) + return; // rect is completely outside clipping rectangle + + if (src_r.x >= src->w || src_r.y >= src->h) + return; // rect is completely outside source bounds + + if (src_r.x + src_r.w > src->w) + src_r.w = src->w - src_r.x; + if (src_r.y + src_r.h > src->h) + src_r.h = src->h - src_r.y; + + // use colorkeys where appropriate + if (srcfmt->Amask) + { // alpha transparency + mask = srcfmt->Amask; + key = 0; + } + else if (src->flags & SDL_SRCCOLORKEY) + { // colorkey transparency + mask = ~srcfmt->Amask; + key = srcfmt->colorkey & mask; + } + + // TODO: calculate the source and destination pointers directly + // instead of using the plot(x,y) version + for (y = 0; y < src_r.h; ++y) + { + for (x = 0; x < src_r.w; ++x) + { + Uint8 r, g, b, a; + Uint32 p; + + p = getpix(src, src_r.x + x, src_r.y + y); + if (srcpal) + { // source is paletted, colorkey does not use mask + if (p == key) + continue; // transparent pixel + } + else + { // source is RGB(A), colorkey uses mask + if ((p & mask) == key) + continue; // transparent pixel + } + + // convert pixel format to destination + SDL_GetRGBA(p, srcfmt, &r, &g, &b, &a); + // TODO: handle source pixel alpha; plot() should probably + // get a source alpha parameter + p = SDL_MapRGBA(dstfmt, r, g, b, a); + + plot(dst, dst_r.x + x, dst_r.y + y, p, factor); + } + } +} + +// clip the source and destination rectangles against the clip rectangle +int clip_blt_rects(SDL_Rect *src_r, SDL_Rect *dst_r, const SDL_Rect *clip_r) +{ + // NOTE: the following clipping code is copied in part + // from SDL-1.2.4 sources + int w, h; + int dx, dy; + + // clip the source rectangle to the source surface + w = src_r->w; + if (src_r->x < 0) + { + w += src_r->x; + dst_r->x -= src_r->x; + src_r->x = 0; + } + + h = src_r->h; + if (src_r->y < 0) + { + h += src_r->y; + dst_r->y -= src_r->y; + src_r->y = 0; + } + + // clip the destination rectangle against the clip rectangle, + // minding the source rectangle in the process + dx = clip_r->x - dst_r->x; + if (dx > 0) + { + w -= dx; + dst_r->x += dx; + src_r->x += dx; + } + dx = dst_r->x + w - clip_r->x - clip_r->w; + if (dx > 0) + w -= dx; + + dy = clip_r->y - dst_r->y; + if (dy > 0) + { + h -= dy; + dst_r->y += dy; + src_r->y += dy; + } + dy = dst_r->y + h - clip_r->y - clip_r->h; + if (dy > 0) + h -= dy; + + if (w <= 0 || h <= 0) + { + src_r->w = 0; + src_r->h = 0; + return 0; + } + + src_r->w = w; + src_r->h = h; + return 1; +} + #endif Modified: trunk/sc2/src/libs/graphics/sdl/primitives.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/primitives.h 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/sdl/primitives.h 2009-12-27 04:42:50 UTC (rev 3475) @@ -21,13 +21,42 @@ /* Function types for the pixel functions */ -typedef Uint32 (*GetPixelFn)(SDL_Surface *, int, int); -typedef void (*PutPixelFn)(SDL_Surface *, int, int, Uint32); +typedef Uint32 (*GetPixelFn)(SDL_Surface *, int x, int y); +// 'pixel' is in destination surface format +typedef void (*PutPixelFn)(SDL_Surface *, int x, int y, Uint32 pixel); GetPixelFn getpixel_for(SDL_Surface *surface); PutPixelFn putpixel_for(SDL_Surface *surface); -void line(int x1, int y1, int x2, int y2, Uint32 color, PutPixelFn plot, - SDL_Surface *surface); -int clip_line(int *lx1, int *ly1, int *lx2, int *ly2, SDL_Rect *r); -#endif +// This currently matches gfxlib.h:DrawKind for simplicity +typedef enum +{ + renderReplace = 0, + renderAdditive, + renderAlpha, +} RenderKind; + +#define FULLY_OPAQUE_ALPHA 255 +#define ADDITIVE_FACTOR_1 255 + +// 'pixel' is in destination surface format +// See gfxlib.h:DrawKind for 'factor' spec +typedef void (*RenderPixelFn)(SDL_Surface *, int x, int y, Uint32 pixel, + int factor); + +RenderPixelFn renderpixel_for(SDL_Surface *surface, RenderKind); + +void line_prim(int x1, int y1, int x2, int y2, Uint32 color, + RenderPixelFn plot, int factor, SDL_Surface *dst); +void fillrect_prim(SDL_Rect r, Uint32 color, + RenderPixelFn plot, int factor, SDL_Surface *dst); +void blt_prim(SDL_Surface *src, SDL_Rect src_r, + RenderPixelFn plot, int factor, + SDL_Surface *dst, SDL_Rect dst_r); + +int clip_line(int *lx1, int *ly1, int *lx2, int *ly2, const SDL_Rect *clip_r); +int clip_rect(SDL_Rect *r, const SDL_Rect *clip_r); +int clip_blt_rects(SDL_Rect *src_r, SDL_Rect *dst_r, const SDL_Rect *clip_r); + + +#endif /* PRIMITIVES_H */ Modified: trunk/sc2/src/libs/graphics/tfb_draw.c =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/tfb_draw.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -24,7 +24,8 @@ static const HOT_SPOT NullHs = {0, 0}; void -TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, Color color, SCREEN dest) +TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, Color color, + DrawMode mode, SCREEN dest) { TFB_DrawCommand DC; @@ -34,13 +35,14 @@ DC.data.line.x2 = x2; DC.data.line.y2 = y2; DC.data.line.color = color; + DC.data.line.drawMode = mode; DC.data.line.destBuffer = dest; TFB_EnqueueDrawCommand (&DC); } void -TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest) +TFB_DrawScreen_Rect (RECT *rect, Color color, DrawMode mode, SCREEN dest) { RECT locRect; TFB_DrawCommand DC; @@ -56,6 +58,7 @@ DC.Type = TFB_DRAWCOMMANDTYPE_RECTANGLE; DC.data.rect.rect = *rect; DC.data.rect.color = color; + DC.data.rect.drawMode = mode; DC.data.rect.destBuffer = dest; TFB_EnqueueDrawCommand (&DC); @@ -63,7 +66,7 @@ void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, - int scaleMode, TFB_ColorMap *cmap, SCREEN dest) + int scaleMode, TFB_ColorMap *cmap, DrawMode mode, SCREEN dest) { TFB_DrawCommand DC; @@ -74,6 +77,7 @@ DC.data.image.y = y; DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; DC.data.image.scaleMode = scaleMode; + DC.data.image.drawMode = mode; DC.data.image.destBuffer = dest; TFB_EnqueueDrawCommand (&DC); @@ -81,7 +85,7 @@ void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, - int scaleMode, Color color, SCREEN dest) + int scaleMode, Color color, DrawMode mode, SCREEN dest) { TFB_DrawCommand DC; @@ -92,6 +96,7 @@ DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; DC.data.filledimage.scaleMode = scaleMode; DC.data.filledimage.color = color; + DC.data.filledimage.drawMode = mode; DC.data.filledimage.destBuffer = dest; TFB_EnqueueDrawCommand (&DC); @@ -99,7 +104,7 @@ void TFB_DrawScreen_FontChar (TFB_Char *fontChar, TFB_Image *backing, - int x, int y, SCREEN dest) + int x, int y, DrawMode mode, SCREEN dest) { TFB_DrawCommand DC; @@ -108,6 +113,7 @@ DC.data.fontchar.backing = backing; DC.data.fontchar.x = x; DC.data.fontchar.y = y; + DC.data.fontchar.drawMode = mode; DC.data.fontchar.destBuffer = dest; TFB_EnqueueDrawCommand (&DC); @@ -230,51 +236,51 @@ void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color, - TFB_Image *dest) + DrawMode mode, TFB_Image *target) { - LockMutex (dest->mutex); - TFB_DrawCanvas_Line (x1, y1, x2, y2, color, dest->NormalImg); - dest->dirty = TRUE; - UnlockMutex (dest->mutex); + LockMutex (target->mutex); + TFB_DrawCanvas_Line (x1, y1, x2, y2, color, mode, target->NormalImg); + target->dirty = TRUE; + UnlockMutex (target->mutex); } void -TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image) +TFB_DrawImage_Rect (RECT *rect, Color color, DrawMode mode, TFB_Image *target) { - LockMutex (image->mutex); - TFB_DrawCanvas_Rect (rect, color, image->NormalImg); - image->dirty = TRUE; - UnlockMutex (image->mutex); + LockMutex (target->mutex); + TFB_DrawCanvas_Rect (rect, color, mode, target->NormalImg); + target->dirty = TRUE; + UnlockMutex (target->mutex); } void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, - int scaleMode, TFB_ColorMap *cmap, TFB_Image *target) + int scaleMode, TFB_ColorMap *cmap, DrawMode mode, TFB_Image *target) { LockMutex (target->mutex); TFB_DrawCanvas_Image (img, x, y, scale, scaleMode, cmap, - target->NormalImg); + mode, target->NormalImg); target->dirty = TRUE; UnlockMutex (target->mutex); } void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, - int scaleMode, Color color, TFB_Image *target) + int scaleMode, Color color, DrawMode mode, TFB_Image *target) { LockMutex (target->mutex); TFB_DrawCanvas_FilledImage (img, x, y, scale, scaleMode, color, - target->NormalImg); + mode, target->NormalImg); target->dirty = TRUE; UnlockMutex (target->mutex); } void TFB_DrawImage_FontChar (TFB_Char *fontChar, TFB_Image *backing, - int x, int y, TFB_Image *target) + int x, int y, DrawMode mode, TFB_Image *target) { LockMutex (target->mutex); - TFB_DrawCanvas_FontChar (fontChar, backing, x, y, target->NormalImg); + TFB_DrawCanvas_FontChar (fontChar, backing, x, y, mode, target->NormalImg); target->dirty = TRUE; UnlockMutex (target->mutex); } Modified: trunk/sc2/src/libs/graphics/tfb_draw.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/tfb_draw.h 2009-12-27 04:42:50 UTC (rev 3475) @@ -79,15 +79,15 @@ // Drawing commands void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, Color color, - SCREEN dest); -void TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest); + DrawMode, SCREEN dest); +void TFB_DrawScreen_Rect (RECT *rect, Color, DrawMode, SCREEN dest); void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, - int scaleMode, TFB_ColorMap *cmap, SCREEN dest); + int scaleMode, TFB_ColorMap *, DrawMode, SCREEN dest); void TFB_DrawScreen_Copy (const RECT *r, SCREEN src, SCREEN dest); void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, - int scaleMode, Color color, SCREEN dest); + int scaleMode, Color, DrawMode, SCREEN dest); void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, - SCREEN dest); + DrawMode, SCREEN dest); void TFB_DrawScreen_CopyToImage (TFB_Image *img, const RECT *r, SCREEN src); void TFB_DrawScreen_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, @@ -109,14 +109,14 @@ TFB_Image *img2, POINT img2org, const RECT *interRect); void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color, - TFB_Image *dest); -void TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image); + DrawMode, TFB_Image *target); +void TFB_DrawImage_Rect (RECT *rect, Color, DrawMode, TFB_Image *target); void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, - int scaleMode, TFB_ColorMap *cmap, TFB_Image *target); + int scaleMode, TFB_ColorMap *, DrawMode, TFB_Image *target); void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, - int scaleMode, Color color, TFB_Image *target); + int scaleMode, Color, DrawMode, TFB_Image *target); void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, - TFB_Image *target); + DrawMode, TFB_Image *target); TFB_Canvas TFB_DrawCanvas_LoadFromFile (void *dir, const char *fileName); TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha); @@ -147,14 +147,14 @@ void TFB_DrawCanvas_Delete (TFB_Canvas canvas); void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color, - TFB_Canvas dest); -void TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas image); + DrawMode, TFB_Canvas target); +void TFB_DrawCanvas_Rect (RECT *rect, Color, DrawMode, TFB_Canvas target); void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, - int scaleMode, TFB_ColorMap *cmap, TFB_Canvas target); + int scaleMode, TFB_ColorMap *, DrawMode, TFB_Canvas target); void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, - int scaleMode, Color color, TFB_Canvas target); + int scaleMode, Color, DrawMode, TFB_Canvas target); void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, - TFB_Canvas target); + DrawMode, TFB_Canvas target); void TFB_DrawCanvas_CopyRect (TFB_Canvas source, const RECT *srcRect, TFB_Canvas target, POINT dstPt); Modified: trunk/sc2/src/libs/graphics/tfb_prim.c =================================================================== --- trunk/sc2/src/libs/graphics/tfb_prim.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/tfb_prim.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -29,7 +29,7 @@ #include "libs/log.h" void -TFB_Prim_Point (POINT *p, Color color, POINT ctxOrigin) +TFB_Prim_Point (POINT *p, Color color, DrawMode mode, POINT ctxOrigin) { RECT r; @@ -39,13 +39,13 @@ r.extent.width = r.extent.height = 1; if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Rect (&r, color, TFB_SCREEN_MAIN); + TFB_DrawScreen_Rect (&r, color, mode, TFB_SCREEN_MAIN); else - TFB_DrawImage_Rect (&r, color, _CurFramePtr->image); + TFB_DrawImage_Rect (&r, color, mode, _CurFramePtr->image); } void -TFB_Prim_Rect (RECT *r, Color color, POINT ctxOrigin) +TFB_Prim_Rect (RECT *r, Color color, DrawMode mode, POINT ctxOrigin) { RECT arm; int gscale; @@ -57,24 +57,24 @@ arm = *r; arm.extent.width = r->extent.width; arm.extent.height = 1; - TFB_Prim_FillRect (&arm, color, ctxOrigin); + TFB_Prim_FillRect (&arm, color, mode, ctxOrigin); arm.extent.height = r->extent.height; arm.extent.width = 1; - TFB_Prim_FillRect (&arm, color, ctxOrigin); + TFB_Prim_FillRect (&arm, color, mode, ctxOrigin); // rounding error correction here arm.corner.x += ((r->extent.width * gscale + (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY) - 1; - TFB_Prim_FillRect (&arm, color, ctxOrigin); + TFB_Prim_FillRect (&arm, color, mode, ctxOrigin); arm.corner.x = r->corner.x; arm.corner.y += ((r->extent.height * gscale + (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY) - 1; arm.extent.width = r->extent.width; arm.extent.height = 1; - TFB_Prim_FillRect (&arm, color, ctxOrigin); + TFB_Prim_FillRect (&arm, color, mode, ctxOrigin); } void -TFB_Prim_FillRect (RECT *r, Color color, POINT ctxOrigin) +TFB_Prim_FillRect (RECT *r, Color color, DrawMode mode, POINT ctxOrigin) { RECT rect; int gscale; @@ -97,13 +97,13 @@ } if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Rect (&rect, color, TFB_SCREEN_MAIN); + TFB_DrawScreen_Rect (&rect, color, mode, TFB_SCREEN_MAIN); else - TFB_DrawImage_Rect (&rect, color, _CurFramePtr->image); + TFB_DrawImage_Rect (&rect, color, mode, _CurFramePtr->image); } void -TFB_Prim_Line (LINE *line, Color color, POINT ctxOrigin) +TFB_Prim_Line (LINE *line, Color color, DrawMode mode, POINT ctxOrigin) { int x1, y1, x2, y2; @@ -114,13 +114,13 @@ y2=line->second.y + ctxOrigin.y; if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Line (x1, y1, x2, y2, color, TFB_SCREEN_MAIN); + TFB_DrawScreen_Line (x1, y1, x2, y2, color, mode, TFB_SCREEN_MAIN); else - TFB_DrawImage_Line (x1, y1, x2, y2, color, _CurFramePtr->image); + TFB_DrawImage_Line (x1, y1, x2, y2, color, mode, _CurFramePtr->image); } void -TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin) +TFB_Prim_Stamp (STAMP *stmp, DrawMode mode, POINT ctxOrigin) { int x, y; FRAME SrcFramePtr; @@ -160,17 +160,17 @@ if (_CurFramePtr->Type == SCREEN_DRAWABLE) { TFB_DrawScreen_Image (img, x, y, GetGraphicScale (), - GetGraphicScaleMode (), cmap, TFB_SCREEN_MAIN); + GetGraphicScaleMode (), cmap, mode, TFB_SCREEN_MAIN); } else { TFB_DrawImage_Image (img, x, y, GetGraphicScale (), - GetGraphicScaleMode (), cmap, _CurFramePtr->image); + GetGraphicScaleMode (), cmap, mode, _CurFramePtr->image); } } void -TFB_Prim_StampFill (STAMP *stmp, Color color, POINT ctxOrigin) +TFB_Prim_StampFill (STAMP *stmp, Color color, DrawMode mode, POINT ctxOrigin) { int x, y; FRAME SrcFramePtr; @@ -203,18 +203,18 @@ if (_CurFramePtr->Type == SCREEN_DRAWABLE) { TFB_DrawScreen_FilledImage (img, x, y, GetGraphicScale (), - GetGraphicScaleMode (), color, TFB_SCREEN_MAIN); + GetGraphicScaleMode (), color, mode, TFB_SCREEN_MAIN); } else { TFB_DrawImage_FilledImage (img, x, y, GetGraphicScale (), - GetGraphicScaleMode (), color, _CurFramePtr->image); + GetGraphicScaleMode (), color, mode, _CurFramePtr->image); } } void TFB_Prim_FontChar (POINT charOrigin, TFB_Char *fontChar, TFB_Image *backing, - POINT ctxOrigin) + DrawMode mode, POINT ctxOrigin) { int x, y; @@ -224,11 +224,13 @@ if (_CurFramePtr->Type == SCREEN_DRAWABLE) { - TFB_DrawScreen_FontChar (fontChar, backing, x, y, TFB_SCREEN_MAIN); + TFB_DrawScreen_FontChar (fontChar, backing, x, y, mode, + TFB_SCREEN_MAIN); } else { - TFB_DrawImage_FontChar (fontChar, backing, x, y, _CurFramePtr->image); + TFB_DrawImage_FontChar (fontChar, backing, x, y, mode, + _CurFramePtr->image); } } Modified: trunk/sc2/src/libs/graphics/tfb_prim.h =================================================================== --- trunk/sc2/src/libs/graphics/tfb_prim.h 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/graphics/tfb_prim.h 2009-12-27 04:42:50 UTC (rev 3475) @@ -20,11 +20,11 @@ #include "tfb_draw.h" -void TFB_Prim_Line (LINE *line, Color color, POINT ctxOrigin); -void TFB_Prim_Point (POINT *p, Color color, POINT ctxOrigin); -void TFB_Prim_Rect (RECT *r, Color color, POINT ctxOrigin); -void TFB_Prim_FillRect (RECT *r, Color color, POINT ctxOrigin); -void TFB_Prim_Stamp (STAMP *stamp, POINT ctxOrigin); -void TFB_Prim_StampFill (STAMP *stamp, Color color, POINT ctxOrigin); +void TFB_Prim_Line (LINE *, Color, DrawMode, POINT ctxOrigin); +void TFB_Prim_Point (POINT *, Color, DrawMode, POINT ctxOrigin); +void TFB_Prim_Rect (RECT *, Color, DrawMode, POINT ctxOrigin); +void TFB_Prim_FillRect (RECT *, Color, DrawMode, POINT ctxOrigin); +void TFB_Prim_Stamp (STAMP *, DrawMode, POINT ctxOrigin); +void TFB_Prim_StampFill (STAMP *, Color, DrawMode, POINT ctxOrigin); void TFB_Prim_FontChar (POINT charOrigin, TFB_Char *fontChar, - TFB_Image *backing, POINT ctxOrigin); + TFB_Image *backing, DrawMode, POINT ctxOrigin); Modified: trunk/sc2/src/libs/video/vidplayer.c =================================================================== --- trunk/sc2/src/libs/video/vidplayer.c 2009-12-26 17:15:12 UTC (rev 3474) +++ trunk/sc2/src/libs/video/vidplayer.c 2009-12-27 04:42:50 UTC (rev 3475) @@ -147,8 +147,8 @@ // We have the cliprect precalculated and don't need the rest oldContext = SetContext (NULL); TFB_DrawScreen_Image (vid->frame, - vid->dst_rect.corner.x, vid->dst_rect.corner.y, - 0, 0, NULL, TFB_SCREEN_MAIN); + vid->dst_rect.corner.x, vid->dst_rect.corner.y, 0, 0, + NULL, DRAW_REPLACE_MODE, TFB_SCREEN_MAIN); SetContext (oldContext); UnlockMutex (GraphicsLock); FlushGraphics (); // needed to prevent half-frame updates @@ -199,8 +199,8 @@ // We have the cliprect precalculated and don't need the rest oldContext = SetContext (NULL); TFB_DrawScreen_Image (vid->frame, - vid->dst_rect.corner.x, vid->dst_rect.corner.y, - 0, 0, NULL, TFB_SCREEN_MAIN); + vid->dst_rect.corner.x, vid->dst_rect.corner.y, 0, 0, + NULL, DRAW_REPLACE_MODE, TFB_SCREEN_MAIN); SetContext (oldContext); UnlockMutex (GraphicsLock); FlushGraphics (); // needed to prevent half-frame updates This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2009-12-28 16:24:45
|
Revision: 3484 http://sc2.svn.sourceforge.net/sc2/?rev=3484&view=rev Author: Meep-Eep Date: 2009-12-28 16:24:23 +0000 (Mon, 28 Dec 2009) Log Message: ----------- Put SuperMelee source files in separate subdirectory. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/uqm/Makeinfo trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/battlecontrols.h trunk/sc2/src/uqm/master.c trunk/sc2/src/uqm/netplay/netmisc.c trunk/sc2/src/uqm/netplay/packethandlers.c trunk/sc2/src/uqm/netplay/proto/reset.c trunk/sc2/src/uqm/pickship.c trunk/sc2/src/uqm/restart.c trunk/sc2/src/uqm/ship.c trunk/sc2/src/uqm/shipyard.c Added Paths: ----------- trunk/sc2/src/uqm/supermelee/ trunk/sc2/src/uqm/supermelee/Makeinfo trunk/sc2/src/uqm/supermelee/loadmele.c trunk/sc2/src/uqm/supermelee/loadmele.h trunk/sc2/src/uqm/supermelee/melee.c trunk/sc2/src/uqm/supermelee/melee.h trunk/sc2/src/uqm/supermelee/pickmele.c trunk/sc2/src/uqm/supermelee/pickmele.h Removed Paths: ------------- trunk/sc2/src/uqm/loadmele.c trunk/sc2/src/uqm/loadmele.h trunk/sc2/src/uqm/melee.c trunk/sc2/src/uqm/melee.h trunk/sc2/src/uqm/pickmele.c trunk/sc2/src/uqm/pickmele.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/ChangeLog 2009-12-28 16:24:23 UTC (rev 3484) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Put SuperMelee source files in separate subdirectory - SvdB - Added additive and alpha drawing modes to graphics lib - Alex - Fixed black pixel gaps between the planet and shield when entering the orbit of a shielded planet (bug #32) - Alex Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2009-12-28 16:24:23 UTC (rev 3484) @@ -3892,8 +3892,36 @@ SOURCE=..\..\src\uqm\ships\ship.h # End Source File # End Group +# Begin Group "supermelee" + +# PROP Default_Filter "" # Begin Source File +SOURCE=..\..\src\uqm\loadmele.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\loadmele.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\melee.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\melee.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\pickmele.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\pickmele.h +# End Source File +# End Group +# Begin Source File + SOURCE=..\..\src\uqm\battle.c # End Source File # Begin Source File @@ -4178,14 +4206,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\uqm\loadmele.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\loadmele.h -# End Source File -# Begin Source File - SOURCE=..\..\src\uqm\loadship.c # End Source File # Begin Source File @@ -4198,14 +4218,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\uqm\melee.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\melee.h -# End Source File -# Begin Source File - SOURCE=..\..\src\uqm\menu.c # End Source File # Begin Source File @@ -4234,14 +4246,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\uqm\pickmele.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\pickmele.h -# End Source File -# Begin Source File - SOURCE=..\..\src\uqm\pickship.c # End Source File # Begin Source File Modified: trunk/sc2/src/uqm/Makeinfo =================================================================== --- trunk/sc2/src/uqm/Makeinfo 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/Makeinfo 2009-12-28 16:24:23 UTC (rev 3484) @@ -1,14 +1,14 @@ -uqm_SUBDIRS="comm planets ships" +uqm_SUBDIRS="comm planets ships supermelee" uqm_CFILES="battle.c battlecontrols.c border.c build.c cleanup.c clock.c cnctdlg.c collide.c comm.c commanim.c commglue.c confirm.c credits.c cyborg.c demo.c displist.c dummy.c encount.c flash.c fmv.c galaxy.c gameev.c gameinp.c gameopt.c gendef.c getchar.c globdata.c gravity.c cons_res.c grpinfo.c hyper.c init.c intel.c intro.c ipdisp.c load.c - loadmele.c loadship.c master.c melee.c menu.c misc.c oscill.c - outfit.c pickmele.c pickship.c plandata.c process.c restart.c save.c - settings.c setup.c setupmenu.c ship.c shipstat.c shipyard.c sis.c - sounds.c starbase.c starcon.c starmap.c state.c status.c tactrans.c - trans.c uqmdebug.c util.c velocity.c weapon.c" + loadship.c master.c menu.c misc.c oscill.c outfit.c pickship.c + plandata.c process.c restart.c save.c settings.c setup.c setupmenu.c + ship.c shipstat.c shipyard.c sis.c sounds.c starbase.c starcon.c + starmap.c state.c status.c tactrans.c trans.c uqmdebug.c util.c + velocity.c weapon.c" if [ -n "$uqm_NETPLAY" ]; then uqm_SUBDIRS="$uqm_SUBDIRS netplay" fi Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/battle.c 2009-12-28 16:24:23 UTC (rev 3484) @@ -33,7 +33,7 @@ # include "netplay/checksum.h" # endif #endif -#include "pickmele.h" +#include "supermelee/pickmele.h" #include "resinst.h" #include "nameref.h" #include "setup.h" Modified: trunk/sc2/src/uqm/battlecontrols.h =================================================================== --- trunk/sc2/src/uqm/battlecontrols.h 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/battlecontrols.h 2009-12-28 16:24:23 UTC (rev 3484) @@ -26,7 +26,7 @@ #endif /* NETPLAY */ #include "controls.h" -#include "pickmele.h" +#include "supermelee/pickmele.h" #include "races.h" #include "libs/compiler.h" Deleted: trunk/sc2/src/uqm/loadmele.c =================================================================== --- trunk/sc2/src/uqm/loadmele.c 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/loadmele.c 2009-12-28 16:24:23 UTC (rev 3484) @@ -1,867 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -// This file handles loading of teams, but the UI and the actual loading. - -#include "melee.h" - -#include "controls.h" -#include "gameopt.h" -#include "gamestr.h" -#include "globdata.h" -#include "master.h" -#include "save.h" -#include "setup.h" -#include "sounds.h" -#include "options.h" -#include "libs/log.h" -#include "libs/memlib.h" - - -#define LOAD_TEAM_NAME_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x10, 0x1B), 0x00) -#define LOAD_TEAM_NAME_TEXT_COLOR_HILITE \ - BUILD_COLOR (MAKE_RGB15 (0x17, 0x18, 0x1D), 0x00) - - -#define LOAD_MELEE_BOX_WIDTH 34 -#define LOAD_MELEE_BOX_HEIGHT 34 -#define LOAD_MELEE_BOX_SPACE 1 - - -static void DrawFileStrings (MELEE_STATE *pMS); -static bool FillFileView (MELEE_STATE *pMS); - - -bool -ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp) -{ - int status; - FleetShipIndex i; - - status = ReadResFile (pTI, sizeof (*pTI), 1, load_fp); - if (status != 1) - return false; - - // Sanity check on the entries. - for (i = 0; i < MELEE_FLEET_SIZE; i++) - { - BYTE StarShip = pTI->ShipList[i]; - - if (StarShip == MELEE_NONE) - continue; - - if (StarShip >= NUM_MELEE_SHIPS) - { - log_add (log_Warning, "Invalid ship type in loaded team (index " - "%d, ship type is %d, max valid is %d).", - i, StarShip, NUM_MELEE_SHIPS - 1); - pTI->ShipList[i] = MELEE_NONE; - } - } - - return true; -} - -static bool -LoadTeamImage (DIRENTRY DirEntry, TEAM_IMAGE *pTI) -{ - const BYTE *fileName; - uio_Stream *load_fp; - bool status; - - fileName = GetDirEntryAddress (DirEntry); - load_fp = res_OpenResFile (meleeDir, (const char *) fileName, "rb"); - if (load_fp == 0) - return false; - - if (LengthResFile (load_fp) != sizeof (*pTI)) - status = false; - else - status = ReadTeamImage (pTI, load_fp); - res_CloseResFile (load_fp); - - return status; -} - -#if 0 /* Not used */ -static void -UnindexFleet (MELEE_STATE *pMS, COUNT index) -{ - assert (index < pMS->load.numIndices); - pMS->load.numIndices--; - memmove (&pMS->load.entryIndices[index], - &pMS->load.entryIndices[index + 1], - (pMS->load.numIndices - index) * sizeof pMS->load.entryIndices[0]); -} -#endif - -static void -UnindexFleets (MELEE_STATE *pMS, COUNT index, COUNT count) -{ - assert (index + count <= pMS->load.numIndices); - - pMS->load.numIndices -= count; - memmove (&pMS->load.entryIndices[index], - &pMS->load.entryIndices[index + count], - (pMS->load.numIndices - index) * sizeof pMS->load.entryIndices[0]); -} - -static bool -GetFleetByIndex (MELEE_STATE *pMS, COUNT index, TEAM_IMAGE *result) -{ - COUNT firstIndex; - - if (index < pMS->load.preBuiltCount) - { - *result = pMS->load.preBuiltList[index]; - return true; - } - - index -= pMS->load.preBuiltCount; - firstIndex = index; - - for ( ; index < pMS->load.numIndices; index++) - { - DIRENTRY entry = SetAbsDirEntryTableIndex (pMS->load.dirEntries, - pMS->load.entryIndices[index]); - if (LoadTeamImage (entry, result)) - break; // Success - - { - const BYTE *fileName; - fileName = GetDirEntryAddress (entry); - log_add (log_Warning, "Warning: File '%s' is not a valid " - "SuperMelee team.", fileName); - } - } - - if (index != firstIndex) - UnindexFleets (pMS, firstIndex, index - firstIndex); - - return index < pMS->load.numIndices; -} - -// returns (COUNT) -1 if not found -static COUNT -GetFleetIndexByFileName (MELEE_STATE *pMS, const char *fileName) -{ - COUNT index; - - for (index = 0; index < pMS->load.numIndices; index++) - { - DIRENTRY entry = SetAbsDirEntryTableIndex (pMS->load.dirEntries, - pMS->load.entryIndices[index]); - const BYTE *entryName = GetDirEntryAddress (entry); - - if (strcasecmp ((const char *) entryName, fileName) == 0) - return pMS->load.preBuiltCount + index; - } - - return (COUNT) -1; -} - -// Auxiliary function for DrawFileStrings -// If drawShips is set the ships themselves are drawn, in addition to the -// fleet name and value; if not, only the fleet name and value are drawn. -// If highlite is set the text is drawn in the color used for highlighting. -static void -DrawFileString (TEAM_IMAGE *pTI, POINT *origin, BOOLEAN drawShips, - BOOLEAN highlite) -{ - SetContextForeGroundColor (highlite ? - LOAD_TEAM_NAME_TEXT_COLOR_HILITE : LOAD_TEAM_NAME_TEXT_COLOR); - - // Print the name of the fleet - { - TEXT Text; - - Text.baseline = *origin; - Text.align = ALIGN_LEFT; - Text.pStr = pTI->TeamName; - Text.CharCount = (COUNT)~0; - font_DrawText (&Text); - } - - // Print the value of the fleet - { - TEXT Text; - UNICODE buf[60]; - - sprintf (buf, "%u", GetTeamValue (pTI)); - Text.baseline = *origin; - Text.baseline.x += NUM_MELEE_COLUMNS * - (LOAD_MELEE_BOX_WIDTH + LOAD_MELEE_BOX_SPACE) - 1; - Text.align = ALIGN_RIGHT; - Text.pStr = buf; - Text.CharCount = (COUNT)~0; - font_DrawText (&Text); - } - - // Draw the ships for the fleet - if (drawShips) - { - STAMP s; - FleetShipIndex index; - - s.origin.x = origin->x + 1; - s.origin.y = origin->y + 4; - for (index = 0; index < MELEE_FLEET_SIZE; index++) - { - BYTE StarShip; - - StarShip = pTI->ShipList[index]; - if (StarShip != MELEE_NONE) - { - s.frame = GetShipIconsFromIndex (StarShip); - DrawStamp (&s); - s.origin.x += 17; - } - } - } -} - -// returns true if there are any entries in the view, in which case -// pMS->load.bot gets set to the index of the bottom entry in the view. -// returns false if not, in which case, the entire view remains unchanged. -static bool -FillFileView (MELEE_STATE *pMS) -{ - COUNT viewI; - - for (viewI = 0; viewI < LOAD_TEAM_VIEW_SIZE; viewI++) - { - bool success = GetFleetByIndex (pMS, pMS->load.top + viewI, - &pMS->load.view[viewI]); - if (!success) - break; - } - - if (viewI == 0) - return false; - - pMS->load.bot = pMS->load.top + viewI; - return true; -} - -#define FILE_STRING_ORIGIN_X 5 -#define FILE_STRING_ORIGIN_Y 34 -#define ENTRY_HEIGHT 32 - -static void -SelectFileString (MELEE_STATE *pMS, bool hilite) -{ - CONTEXT OldContext; - POINT origin; - COUNT viewI; - - viewI = pMS->load.cur - pMS->load.top; - - OldContext = SetContext (SpaceContext); - SetContextFont (MicroFont); - BatchGraphics (); - - origin.x = FILE_STRING_ORIGIN_X; - origin.y = FILE_STRING_ORIGIN_Y + viewI * ENTRY_HEIGHT; - DrawFileString (&pMS->load.view[viewI], &origin, FALSE, hilite); - - UnbatchGraphics (); - SetContext (OldContext); -} - -static void -DrawFileStrings (MELEE_STATE *pMS) -{ - POINT origin; - CONTEXT OldContext; - - origin.x = FILE_STRING_ORIGIN_X; - origin.y = FILE_STRING_ORIGIN_Y; - - OldContext = SetContext (SpaceContext); - SetContextFont (MicroFont); - BatchGraphics (); - - DrawMeleeIcon (28); /* The load team frame */ - - if (FillFileView (pMS)) - { - COUNT i; - for (i = pMS->load.top; i < pMS->load.bot; i++) { - DrawFileString (&pMS->load.view[i - pMS->load.top], &origin, - TRUE, FALSE); - origin.y += ENTRY_HEIGHT; - } - } - - UnbatchGraphics (); - SetContext (OldContext); -} - -static void -RefocusView (MELEE_STATE *pMS, COUNT index) -{ - assert (index < pMS->load.preBuiltCount + pMS->load.numIndices); - - pMS->load.cur = index; - if (index <= LOAD_TEAM_VIEW_SIZE / 2) - pMS->load.top = 0; - else - pMS->load.top = index - LOAD_TEAM_VIEW_SIZE / 2; -} - -static void -flashSelectedTeam (MELEE_STATE *pMS) -{ -#define FLASH_RATE (ONE_SECOND / 9) - static TimeCount NextTime = 0; - static int hilite = 0; - TimeCount Now = GetTimeCounter (); - - if (Now >= NextTime) - { - CONTEXT OldContext; - - NextTime = Now + FLASH_RATE; - hilite ^= 1; - - LockMutex (GraphicsLock); - OldContext = SetContext (SpaceContext); - SelectFileString (pMS, hilite); - SetContext (OldContext); - UnlockMutex (GraphicsLock); - } -} - -BOOLEAN -DoLoadTeam (MELEE_STATE *pMS) -{ - DWORD TimeIn = GetTimeCounter (); - - /* Cancel any presses of the Pause key. */ - GamePaused = FALSE; - - if (GLOBAL (CurrentActivity) & CHECK_ABORT) - return FALSE; - - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_PAGEUP | - MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); - - if (!pMS->Initialized) - { - LockMutex (GraphicsLock); - DrawFileStrings (pMS); - SelectFileString (pMS, true); - pMS->Initialized = TRUE; - pMS->InputFunc = DoLoadTeam; - UnlockMutex (GraphicsLock); - return TRUE; - } - - if (PulsedInputState.menu[KEY_MENU_SELECT] || - PulsedInputState.menu[KEY_MENU_CANCEL]) - { - if (PulsedInputState.menu[KEY_MENU_SELECT]) - { - // Copy the selected fleet to the player. - pMS->SideState[pMS->side].TeamImage = - pMS->load.view[pMS->load.cur - pMS->load.top]; - pMS->SideState[pMS->side].star_bucks = - GetTeamValue (&pMS->SideState[pMS->side].TeamImage); - entireFleetChanged (pMS, pMS->side); - teamStringChanged (pMS, pMS->side); - } - - pMS->InputFunc = DoMelee; - pMS->LastInputTime = GetTimeCounter (); - { - RECT r; - - GetFrameRect (SetAbsFrameIndex (MeleeFrame, 28), &r); - LockMutex (GraphicsLock); - RepairMeleeFrame (&r); - UnlockMutex (GraphicsLock); - } - return TRUE; - } - - { - COUNT newTop = pMS->load.top; - COUNT newIndex = pMS->load.cur; - - if (PulsedInputState.menu[KEY_MENU_UP]) - { - if (newIndex > 0) - { - newIndex--; - if (newIndex < newTop) - newTop = (newTop < LOAD_TEAM_VIEW_SIZE) ? - 0 : newTop - LOAD_TEAM_VIEW_SIZE; - } - } - else if (PulsedInputState.menu[KEY_MENU_DOWN]) - { - COUNT numEntries = pMS->load.numIndices + pMS->load.preBuiltCount; - if (newIndex + 1 < numEntries) - { - newIndex++; - if (newIndex >= pMS->load.bot) - newTop = pMS->load.bot; - } - } - else if (PulsedInputState.menu[KEY_MENU_PAGE_UP]) - { - newIndex = (newIndex < LOAD_TEAM_VIEW_SIZE) ? - 0 : newIndex - LOAD_TEAM_VIEW_SIZE; - newTop = (newTop < LOAD_TEAM_VIEW_SIZE) ? - 0 : newTop - LOAD_TEAM_VIEW_SIZE; - } - else if (PulsedInputState.menu[KEY_MENU_PAGE_DOWN]) - { - COUNT numEntries = pMS->load.numIndices + pMS->load.preBuiltCount; - if (newIndex + LOAD_TEAM_VIEW_SIZE < numEntries) - { - newIndex += LOAD_TEAM_VIEW_SIZE; - newTop += LOAD_TEAM_VIEW_SIZE; - } - else - { - newIndex = numEntries - 1; - if (newTop + LOAD_TEAM_VIEW_SIZE < numEntries && - numEntries > LOAD_TEAM_VIEW_SIZE) - newTop = numEntries - LOAD_TEAM_VIEW_SIZE; - } - } - - if (newIndex != pMS->load.cur) - { - LockMutex (GraphicsLock); - if (newTop == pMS->load.top) - SelectFileString (pMS, false); - else - { - pMS->load.top = newTop; - DrawFileStrings (pMS); - } - pMS->load.cur = newIndex; - UnlockMutex (GraphicsLock); - } - } - - flashSelectedTeam (pMS); - - SleepThreadUntil (TimeIn + ONE_SECOND / 30); - - return TRUE; -} - -int -WriteTeamImage (TEAM_IMAGE *pTI, uio_Stream *save_fp) -{ - return WriteResFile (pTI, sizeof (*pTI), 1, save_fp); -} - -void -SelectTeamByFileName (MELEE_STATE *pMS, const char *fileName) -{ - COUNT index = GetFleetIndexByFileName (pMS, fileName); - if (index == (COUNT) -1) - return; - - RefocusView (pMS, index); -} - -void -LoadTeamList (MELEE_STATE *pMS) -{ - COUNT i; - - DestroyDirEntryTable (ReleaseDirEntryTable (pMS->load.dirEntries)); - pMS->load.dirEntries = CaptureDirEntryTable ( - LoadDirEntryTable (meleeDir, "", ".mle", match_MATCH_SUFFIX)); - - if (pMS->load.entryIndices != NULL) - HFree (pMS->load.entryIndices); - pMS->load.numIndices = GetDirEntryTableCount (pMS->load.dirEntries); - pMS->load.entryIndices = HMalloc (pMS->load.numIndices * - sizeof pMS->load.entryIndices[0]); - for (i = 0; i < pMS->load.numIndices; i++) - pMS->load.entryIndices[i] = i; -} - -BOOLEAN -DoSaveTeam (MELEE_STATE *pMS) -{ - STAMP MsgStamp; - char file[NAME_MAX]; - uio_Stream *save_fp; - CONTEXT OldContext; - - sprintf (file, "%s.mle", pMS->SideState[pMS->side].TeamImage.TeamName); - - LockMutex (GraphicsLock); - OldContext = SetContext (ScreenContext); - ConfirmSaveLoad (&MsgStamp); - save_fp = res_OpenResFile (meleeDir, file, "wb"); - if (save_fp) - { - BOOLEAN err; - - err = (BOOLEAN)(WriteTeamImage ( - &pMS->SideState[pMS->side].TeamImage, save_fp) == 0); - if (res_CloseResFile (save_fp) == 0) - err = TRUE; - if (err) - save_fp = 0; - } - - pMS->load.top = 0; - pMS->load.cur = 0; - - if (save_fp == 0) - { - DrawStamp (&MsgStamp); - DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); - SetContext (OldContext); - UnlockMutex (GraphicsLock); - - DeleteResFile (meleeDir, file); - SaveProblem (); - } - - LoadTeamList (pMS); - SelectTeamByFileName (pMS, file); - - if (save_fp != 0) - { - DrawStamp (&MsgStamp); - DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); - SetContext (OldContext); - UnlockMutex (GraphicsLock); - } - - return (save_fp != 0); -} - -static void -InitPreBuilt (MELEE_STATE *pMS) -{ - TEAM_IMAGE *list; - -#define PREBUILT_COUNT 15 - pMS->load.preBuiltList = - HMalloc (PREBUILT_COUNT * sizeof pMS->load.preBuiltList[0]); - pMS->load.preBuiltCount = PREBUILT_COUNT; -#undef PREBUILT_COUNT - - { - FleetShipIndex shipI = 0; - int fleetI; - - for (fleetI = 0; fleetI < pMS->load.preBuiltCount; fleetI++) - for (shipI = 0; shipI < MELEE_FLEET_SIZE; shipI++) - pMS->load.preBuiltList[fleetI].ShipList[shipI] = MELEE_NONE; - } - - list = pMS->load.preBuiltList; - - { - /* "Balanced Team 1" */ - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 4)); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_UTWIG; - list++; - } - - { - /* "Balanced Team 2" */ - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 5)); - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_YEHAT; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_SHOFIXTI; - list++; - } - - { - /* "200 points" */ - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 6)); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_ILWRATH; - list->ShipList[i++] = MELEE_VUX; - list++; - } - - { - /* "Behemoth Zenith" */ - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 7)); - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_UTWIG; - list++; - } - - { - /* "The Peeled Eyes" */ - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 8)); - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_ORZ; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Ford's Fighters"); - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_UMGAH; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Leyland's Lashers"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_URQUAN; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "The Gregorizers 200"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SPATHI; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "300 point Armada!"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_YEHAT; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Little Dudes with Attitudes"); - list->ShipList[i++] = MELEE_UMGAH; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_VUX; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "New Alliance Ships"); - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_YEHAT; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_SPATHI; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Old Alliance Ships"); - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_MMRNMHRM; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_YEHAT; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Old Hierarchy Ships"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_ILWRATH; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_UMGAH; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_VUX; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Star Control 1"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_ILWRATH; - list->ShipList[i++] = MELEE_MMRNMHRM; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_UMGAH; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_VUX; - list->ShipList[i++] = MELEE_YEHAT; - list++; - } - - { - FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Star Control 2"); - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SLYLANDRO; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list++; - } - - assert (list == pMS->load.preBuiltList + pMS->load.preBuiltCount); -} - -static void -UninitPreBuilt (MELEE_STATE *pMS) { - HFree (pMS->load.preBuiltList); - pMS->load.preBuiltCount = 0; -} - -void -InitMeleeLoadState (MELEE_STATE *pMS) -{ - pMS->load.entryIndices = NULL; - InitPreBuilt (pMS); -} - -void -UninitMeleeLoadState (MELEE_STATE *pMS) -{ - UninitPreBuilt (pMS); - if (pMS->load.entryIndices != NULL) - HFree (pMS->load.entryIndices); -} - - Deleted: trunk/sc2/src/uqm/loadmele.h =================================================================== --- trunk/sc2/src/uqm/loadmele.h 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/loadmele.h 2009-12-28 16:24:23 UTC (rev 3484) @@ -1,60 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _LOADMELE_H -#define _LOADMELE_H - -#define LOAD_TEAM_VIEW_SIZE 5 - -struct melee_load_state; - -#include "melee.h" - -struct melee_load_state -{ - TEAM_IMAGE *preBuiltList; - COUNT preBuiltCount; - - DIRENTRY dirEntries; - COUNT *entryIndices; - COUNT numIndices; - - TEAM_IMAGE view[LOAD_TEAM_VIEW_SIZE]; - COUNT top; - // Index of the first entry for the view. - COUNT bot; - // Index of the first entry past the end of the view. - - COUNT cur; - // Index of the current position in the view. - COUNT viewSize; - // Number of entries in the view. -}; - -void InitMeleeLoadState (MELEE_STATE *pMS); -void UninitMeleeLoadState (MELEE_STATE *pMS); - -BOOLEAN DoLoadTeam (MELEE_STATE *pMS); -BOOLEAN DoSaveTeam (MELEE_STATE *pMS); -bool ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp); -int WriteTeamImage (TEAM_IMAGE *pTI, uio_Stream *save_fp); -void LoadTeamList (MELEE_STATE *pMS); - -#endif /* _LOADMELE_H */ - - Modified: trunk/sc2/src/uqm/master.c =================================================================== --- trunk/sc2/src/uqm/master.c 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/master.c 2009-12-28 16:24:23 UTC (rev 3484) @@ -21,7 +21,7 @@ #include "build.h" #include "resinst.h" #include "displist.h" -#include "melee.h" +#include "supermelee/melee.h" QUEUE master_q; Deleted: trunk/sc2/src/uqm/melee.c =================================================================== --- trunk/sc2/src/uqm/melee.c 2009-12-28 13:33:10 UTC (rev 3483) +++ trunk/sc2/src/uqm/melee.c 2009-12-28 16:24:23 UTC (rev 3484) @@ -1,2681 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "melee.h" - -#include "build.h" -#include "status.h" -#include "colors.h" -#include "comm.h" - // for getLineWithinWidth -#include "cons_res.h" -#include "controls.h" -#include "libs/file.h" -#include "fmv.h" -#include "gamestr.h" -#include "globdata.h" -#include "intel.h" -#include "master.h" -#include "nameref.h" -#ifdef NETPLAY -# include "netplay/netconnection.h" -# include "netplay/netmelee.h" -# include "netplay/notify.h" -# include "libs/graphics/widgets.h" -# include "cnctdlg.h" -#endif -#include "options.h" -#include "races.h" -#include "resinst.h" -#include "settings.h" -#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" -#include "libs/log.h" - - -#include <assert.h> -#include <ctype.h> -#include <string.h> -#include <errno.h> - - -static void DrawMeleeShipStrings (MELEE_STATE *pMS, BYTE NewStarShip); -static void StartMelee (MELEE_STATE *pMS); -static ssize_t numPlayersReady (void); - -enum -{ -#ifdef NETPLAY - NET_TOP, -#endif - CONTROLS_TOP, - SAVE_TOP, - LOAD_TOP, - START_MELEE, - LOAD_BOT, - SAVE_BOT, - CONTROLS_BOT, -#ifdef NETPLAY - NET_BOT, -#endif - QUIT_BOT, - EDIT_MELEE -}; - -#ifdef NETPLAY -#define TOP_ENTRY NET_TOP -#else -#define TOP_ENTRY CONTROLS_TOP -#endif - -#define MELEE_X_OFFS 2 -#define MELEE_Y_OFFS 21 -#define MELEE_BOX_WIDTH 34 -#define MELEE_BOX_HEIGHT 34 -#define MELEE_BOX_SPACE 1 - -#define MENU_X_OFFS 29 -#define NAME_AREA_HEIGHT 7 -#define MELEE_WIDTH 149 -#define MELEE_HEIGHT (48 + NAME_AREA_HEIGHT) - -#define INFO_ORIGIN_X 4 -#define INFO_WIDTH 58 -#define TEAM_INFO_ORIGIN_Y 3 -#define TEAM_INFO_HEIGHT (SHIP_INFO_HEIGHT + 75) -#define MODE_INFO_ORIGIN_Y (TEAM_INFO_HEIGHT + 6) -#define MODE_INFO_HEIGHT ((STATUS_HEIGHT - 3) - MODE_INFO_ORIGIN_Y) -#define RACE_INFO_ORIGIN_Y (SHIP_INFO_HEIGHT + 6) -#define RACE_INFO_HEIGHT ((STATUS_HEIGHT - 3) - RACE_INFO_ORIGIN_Y) - -#define MELEE_STATUS_X_OFFS 1 -#define MELEE_STATUS_Y_OFFS 201 -#define MELEE_STATUS_WIDTH (NUM_MELEE_COLUMNS * \ - (MELEE_BOX_WIDTH + MELEE_BOX_SPACE)) -#define MELEE_STATUS_HEIGHT 38 - -#define MELEE_BACKGROUND_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) -#define MELEE_TITLE_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) -#define MELEE_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C) -#define MELEE_TEAM_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E) - -#define STATE_BACKGROUND_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01) -#define STATE_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03) -#define ACTIVE_STATE_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) -#define UNAVAILABLE_STATE_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) -#define HI_STATE_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B) -#define HI_STATE_BACKGROUND_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) - -// XXX: The following entries are unused: -#define LIST_INFO_BACKGROUND_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05) -#define LIST_INFO_TITLE_COLOR \ - WHITE_COLOR -#define LIST_INFO_TEXT_COLOR \ - LT_GRAY_COLOR -#define LIST_INFO_CURENTRY_TEXT_COLOR \ - WHITE_COLOR -#define HI_LIST_INFO_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04) -#define HI_LIST_INFO_BACKGROUND_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x1F), 0x0D) - -#define TEAM_NAME_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x10, 0x1B), 0x00) -#define TEAM_NAME_EDIT_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x17, 0x18, 0x1D), 0x00) -#define TEAM_NAME_EDIT_RECT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05) -#define TEAM_NAME_EDIT_CURS_COLOR \ - WHITE_COLOR - -#define PICKSHIP_TEAM_NAME_TEXT_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09) -#define PICKSHIP_TEAM_START_VALUE_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x04, 0x05, 0x1F), 0x4B) - -#define SHIPBOX_TOPLEFT_COLOR_NORMAL \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x09), 0x56) -#define SHIPBOX_BOTTOMRIGHT_COLOR_NORMAL \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0E), 0x54) -#define SHIPBOX_INTERIOR_COLOR_NORMAL \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0C), 0x55) - -#define SHIPBOX_TOPLEFT_COLOR_HILITE \ - BUILD_COLOR (MAKE_RGB15 (0x07, 0x00, 0x0C), 0x3E) -#define SHIPBOX_BOTTOMRIGHT_COLOR_HILITE \ - BUILD_COLOR (MAKE_RGB15 (0x0C, 0x00, 0x14), 0x3C) -#define SHIPBOX_INTERIOR_COLOR_HILITE \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x00, 0x11), 0x3D) - -#define MELEE_STATUS_COLOR \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02) - - -FRAME PickMeleeFrame; -FRAME MeleeFrame; - // Loaded from melee/melebkgd.ani -static FRAME BuildPickFrame; - // Constructed. -MELEE_STATE *pMeleeState; - -BOOLEAN DoMelee (MELEE_STATE *pMS); -static BOOLEAN DoEdit (MELEE_STATE *pMS); -static BOOLEAN DoPickShip (MELEE_STATE *pMS); -static BOOLEAN DoConfirmSettings (MELEE_STATE *pMS); - -#define DTSHS_NORMAL 0 -#define DTSHS_EDIT 1 -#define DTSHS_SELECTED 2 -#define DTSHS_REPAIR 4 -#define DTSHS_BLOCKCUR 8 - -static BOOLEAN DrawTeamString (MELEE_STATE *pMS, COUNT side, - COUNT HiLiteState); - - -// These icons come from melee/melebkgd.ani -void -DrawMeleeIcon (COUNT which_icon) -{ - STAMP s; - - s.origin.x = 0; - s.origin.y = 0; - s.frame = SetAbsFrameIndex (MeleeFrame, which_icon); - DrawStamp (&s); -} - -static void -GetShipBox (RECT *pRect, COUNT side, COUNT row, COUNT col) -{ - pRect->corner.x = MELEE_X_OFFS - + (col * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE)); - pRect->corner.y = MELEE_Y_OFFS - + (side * (MELEE_Y_OFFS + MELEE_BOX_SPACE - + (NUM_MELEE_ROWS * (MELEE_BOX_HEIGHT + MELEE_BOX_SPACE)))) - + (row * (MELEE_BOX_HEIGHT + MELEE_BOX_SPACE)); - pRect->extent.width = MELEE_BOX_WIDTH; - pRect->extent.height = MELEE_BOX_HEIGHT; -} - -static FleetShipIndex -GetShipIndex (BYTE row, BYTE col) -{ - return row * NUM_MELEE_COLUMNS + col; -} - -static BYTE -GetShipRow (FleetShipIndex index) -{ - return index / NUM_MELEE_COLUMNS; -} - -static BYTE -GetShipColumn (int index) -{ - return index % NUM_MELEE_COLUMNS; -} - -static void -DrawShipBox (COUNT side, COUNT row, COUNT col, BYTE ship, BOOLEAN HiLite) -{ - RECT r; - - GetShipBox (&r, side, row, col); - - BatchGraphics (); - if (HiLite) - DrawStarConBox (&r, 1, - SHIPBOX_TOPLEFT_COLOR_HILITE, - SHIPBOX_BOTTOMRIGHT_COLOR_HILITE, - (BOOLEAN)(ship != MELEE_NONE), - SHIPBOX_INTERIOR_COLOR_HILITE); - else - DrawStarConBox (&r, 1, - SHIPBOX_TOPLEFT_COLOR_NORMAL, - SHIPBOX_BOTTOMRIGHT_COLOR_NORMAL, - (BOOLEAN)(ship != MELEE_NONE), - SHIPBOX_INTERIOR_COLOR_NORMAL); - - if (ship != MELEE_NONE) - { - STAMP s; - s.origin.x = r.corner.x + (r.extent.width >> 1); - s.origin.y = r.corner.y + (r.extent.height >> 1); - s.frame = GetShipMeleeIconsFromIndex (ship); - - DrawStamp (&s); - } - UnbatchGraphics (); -} - -static void -DrawShipBoxCurrent (MELEE_STATE *pMS, BOOLEAN HiLite) -{ - FleetShipIndex index = GetShipIndex (pMS->row, pMS->col); - BYTE ship = pMS->SideState[pMS->side].TeamImage.ShipList[index]; - DrawShipBox (pMS->side, pMS->row, pMS->col, ship, HiLite); -} - -// Draw an image for one of the control method selection buttons. -static void -DrawControls (COUNT which_side, BOOLEAN HiLite) -{ - COUNT which_icon; - - if (PlayerControl[which_side] & NETWORK_CONTROL) - { - DrawMeleeIcon (31 + (HiLite ? 1 : 0) + 2 * (1 - which_side)); - /* "Network Control" */ - return; - } - - if (PlayerControl[which_side] & HUMAN_CONTROL) - which_icon = 0; - else - { - switch (PlayerControl[which_side] - & (STANDARD_RATING | GOOD_RATING | AWESOME_RATING)) - { - case STANDARD_RATING: - which_icon = 1; - break; - case GOOD_RATING: - which_icon = 2; - break; - case AWESOME_RATING: - which_icon = 3; - break; - default: - // Should not happen. Satisfying compiler. - which_icon = 0; - break; - } - } - - DrawMeleeIcon (1 + (8 * (1 - which_side)) + (HiLite ? 4 : 0) + which_icon); -} - -static void -DrawPickFrame (MELEE_STATE *pMS) -{ - RECT r, r0, r1, ship_r; - STAMP s; - - GetShipBox (&r0, 0, 0, 0), - GetShipBox (&r1, 1, NUM_MELEE_ROWS - 1, NUM_MELEE_COLUMNS - 1), - BoxUnion (&r0, &r1, &ship_r); - - s.frame = SetAbsFrameIndex (BuildPickFrame, 0); - GetFrameRect (s.frame, &r); - r.corner.x = -(ship_r.corner.x - + ((ship_r.extent.width - r.extent.width) >> 1)); - if (pMS->side) - r.corner.y = -ship_r.corner.y; - else - r.corner.y = -(ship_r.corner.y - + (ship_r.extent.height - r.extent.height)); - SetFrameHot (s.frame, MAKE_HOT_SPOT (r.corner.x, r.corner.y)); - s.origin.x = 0; - s.origin.y = 0; - DrawStamp (&s); - - UnlockMutex (GraphicsLock); - DrawMeleeShipStrings (pMS, (BYTE)pMS->CurIndex); - LockMutex (GraphicsLock); -} - -void -RepairMeleeFrame (RECT *pRect) -{ - RECT r; - CONTEXT OldContext; - RECT OldRect; - POINT oldOrigin; - - r.corner.x = pRect->corner.x + SAFE_X; - r.corner.y = pRect->corner.y + SAFE_Y; - r.extent = pRect->extent; - if (r.corner.y & 1) - { - --r.corner.y; - ++r.extent.height; - } - - OldContext = SetContext (SpaceContext); - GetContextClipRect (&OldRect); - SetContextClipRect (&r); - // Offset the origin so that we draw the correct gfx in the cliprect - oldOrigin = SetContextOrigin (MAKE_POINT (-r.corner.x + SAFE_X, - -r.corner.y + SAFE_Y)); - BatchGraphics (); - - DrawMeleeIcon (0); /* Entire melee screen */ -#ifdef NETPLAY - DrawMeleeIcon (35); /* "Net..." (top, not highlighted) */ - DrawMeleeIcon (37); /* "Net..." (bottom, not highlighted) */ -#endif - DrawMeleeIcon (26); /* "Battle!" (highlighted) */ - { - COUNT side; - COUNT row; - COUNT col; - - for (side = 0; side < NUM_SIDES; side++) - { - DrawControls (side, FALSE); - for (row = 0; row < NUM_MELEE_ROWS; row++) - { - for (col = 0; col < NUM_MELEE_COLUMNS; col++) - { - FleetShipIndex index = GetShipIndex (row, col); - BYTE ship = pMeleeState->SideState[side].TeamImage. - ShipList[index]; - DrawShipBox (side, row, col, ship, FALSE); - } - } - - DrawTeamString (pMeleeState, side, DTSHS_NORMAL); - } - } - - if (pMeleeState->InputFunc == DoPickShip) - DrawPickFrame (pMeleeState); - - UnbatchGraphics (); - SetContextOrigin (oldOrigin); - SetContextClipRect (&OldRect); - SetContext (OldContext); -} - -static void -RedrawMeleeFrame (void) -{ - RECT r; - - r.corner.x = 0; - r.corner.y = 0; - r.extent.width = SCREEN_WIDTH; - r.extent.height = SCREEN_HEIGHT; - - RepairMeleeFrame (&r); -} - -static BOOLEAN -DrawTeamString (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState) -{ - RECT r; - TEXT lfText; - - r.corner.x = MELEE_X_OFFS - 1; - r.corner.y = (side + 1) * (MELEE_Y_OFFS - + ((MELEE_BOX_HEIGHT + MELEE_BOX_SPACE) * NUM_MELEE_ROWS + 2)); - r.extent.width = NUM_MELEE_COLUMNS * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE); - r.extent.height = 13; - if (HiLiteState == DTSHS_REPAIR) - { - RepairMeleeFrame (&r); - return (TRUE); - } - - SetContextFont (MicroFont); - - lfText.pStr = pMS->SideState[side].TeamImage.TeamName; - lfText.baseline.y = r.corner.y + r.extent.height - 3; - - lfText.baseline.x = r.corner.x + 1; - lfText.align = ALIGN_LEFT; - lfText.CharCount = strlen (lfText.pStr); - - BatchGraphics (); - if (!(HiLiteState & DTSHS_EDIT)) - { // normal or selected state - TEXT rtText; - UNICODE buf[30]; - - sprintf (buf, "%u", pMS->SideState[side].star_bucks); - rtText.pStr = buf; - rtText.align = ALIGN_RIGHT; - rtText.CharCount = (COUNT)~0; - rtText.baseline.y = lfText.baseline.y; - rtText.baseline.x = lfText.baseline.x + r.extent.width - 1; - - SetContextForeGroundColor (!(HiLiteState & DTSHS_SELECTED) - ? TEAM_NAME_TEXT_COLOR : TEAM_NAME_EDIT_TEXT_COLOR); - font_DrawText (&lfText); - font_DrawText (&rtText); - } - else - { // editing state - COUNT i; - RECT text_r; - BYTE char_deltas[MAX_TEAM_CHARS]; - BYTE *pchar_deltas; - - // not drawing team bucks - r.extent.width -= 29; - - TextRect (&lfText, &text_r, char_deltas); - if ((text_r.extent.width + 2) >= r.extent.width) - { // the text does not fit the input box size and so - // will not fit when displayed later - UnbatchGraphics (); - // disallow the change - return (FALSE); - } - - text_r = r; - SetContextForeGroundColor (TEAM_NAME_EDIT_RECT_COLOR); - DrawFilledRectangle (&text_r); - - // calculate the cursor position and draw it - pchar_deltas = char_deltas; - for (i = pMS->CurIndex; i > 0; --i) - text_r.corner.x += (SIZE)*pchar_deltas++; - if (pMS->CurIndex < lfText.CharCount) /* cursor mid-line */ - --text_r.corner.x; - if (HiLiteState & DTSHS_BLOCKCUR) - { // Use block cursor for keyboardless systems - if (pMS->CurIndex == lfText.CharCount) - { // cursor at end-line -- use insertion point - text_r.extent.width = 1; - } - else if (pMS->CurIndex + 1 == lfText.CharCount) - { // extra pixel for last char margin - text_r.extent.width = (SIZE)*pchar_deltas + 2; - } - else - { // normal mid-line char - text_r.extent.width = (SIZE)*pchar_deltas + 1; - } - } - else - { // Insertion point cursor - text_r.extent.width = 1; - } - // position cursor within input field rect - ++text_r.corner.x; - ++text_r.corner.y; - text_r.extent.height -= 2; - SetContextForeGroundColor (TEAM_NAME_EDIT_CURS_COLOR); - DrawFilledRectangle (&text_r); - - SetContextForeGroundColor (BLACK_COLOR); // TEAM_NAME_EDIT_TEXT_COLOR); - font_DrawText (&lfText); - } - UnbatchGraphics (); - - return (TRUE); -} - -// Draw a ship icon in the ship selection popup. -static void -DrawPickIcon (COUNT iship, BYTE DrawErase) -{ - STAMP s; - RECT r; - - GetFrameRect (BuildPickFrame, &r); - - s.origin.x = r.corner.x + 20 + (iship % NUM_PICK_COLS) * 18; - s.origin.y = r.corner.y + 5 + (iship / NUM_PICK_COLS) * 18; - s.frame = GetShipIconsFromIndex (iship); - if (DrawErase) - { // draw icon - DrawStamp (&s); - } - else - { // erase icon - Color OldColor; - - OldColor = SetContextForeGroundColor (BLACK_COLOR); - DrawFilledStamp (&s); - SetContextForeGroundColor (OldColor); - } -} - -#ifdef NETPLAY -// This function is generic. It should probably be moved to elsewhere. -// The caller should hold the GraphicsLock. -static void -multiLineDrawText (TEXT *textIn, RECT *clipRect) { - RECT oldRect; - - SIZE leading; - TEXT text; - SIZE lineWidth; - - GetContextClipRect (&oldRect); - - SetContextClipRect (clipRect); - GetContextFontLeading (&leading); - - text = *textIn; - text.baseline.x = 1; - text.baseline.y = 0; - - if (clipRect->extent.width <= text.baseline.x) - goto out; - - lineWidth = clipRect->extent.width - text.baseline.x; - - while (*text.pStr != '\0') { - const char *nextLine; - - text.baseline.y += leading; - text.CharCount = (COUNT) ~0; - getLineWithinWidth (&text, &nextLine, lineWidth, text.CharCount); - // This will also fill in text->CharCount. - - font_DrawText (&text); - - text.pStr = nextLine; - } - -out: - SetContextClipRect (&oldRect); -} - -// Use an empty string to clear the status area. -static void -DrawMeleeStatusMessage (const char *message) -{ - CONTEXT oldContext; - RECT r; - - LockMutex (GraphicsLock); - oldContext = SetContext (SpaceContext); - - r.corner.x = MELEE_STATUS_X_OFFS; - r.corner.y = MELEE_STATUS_Y_OFFS; - r.extent.width = MELEE_STATUS_WIDTH; - r.extent.height = MELEE_STATUS_HEIGHT; - - RepairMeleeFrame (&r); - - if (message[0] != '\0') - { - TEXT lfText; - lfText.pStr = message; - lfText.align = ALIGN_LEFT; - lfText.CharCount = (COUNT)~0; - - SetContextFont (MicroFont); - SetContextForeGroundColor (MELEE_STATUS_COLOR); - - BatchGraphics (); - multiLineDrawText (&lfText, &r); - UnbatchGraphics (); - } - - SetContext (oldContext); - UnlockMutex (GraphicsLock); -} - -static void -UpdateMeleeStatusMessage (ssize_t player) -{ - NetConnection *conn; - - assert (player == -1 || (player >= 0 && player < NUM_PLAYERS)); - - if (player == -1) - { - DrawMeleeStatusMessage (""); - return; - } - - conn = netConnections[player]; - if (conn == NULL) - { - DrawMeleeStatusMessage (GAME_STRING (NETMELEE_STRING_BASE + 0)); - // "Unconnected. Press LEFT to connect." - return; - } - - switch (NetConnection_getState (conn)) { - case NetState_unconnected: - DrawMeleeStatusMessage (GAME_STRING (NETMELEE_STRING_BASE + 0)); - // "Unconnected. Press LEFT to connect." - break; - case NetState_connecting: - if (NetConnection_getPeerOptions (conn)->isServer) - DrawMeleeStatusMessage ( - GAME_STRING (NETMELEE_STRING_BASE + 1)); - // "Awaiting incoming connection...\n" - // "Press RIGHT to cancel." - else - DrawMeleeStatusMessage ( - GAME_STRING (NETMELEE_STRING_BASE + 2)); - // "Attempting outgoing connection...\n" - // "Press RIGHT to cancel." - break; - case NetState_init: - case NetState_inSetup: - DrawMeleeStatusMessage (GAME_STRING (NETMELEE_STRING_BASE + 3)); - // "Connected. Press RIGHT to disconnect." - break; - default: - DrawMeleeStatusMessage (""); - break; - } -} -#endif /* NETPLAY */ - -// XXX: this function is called when the current selection is blinking off. -// The caller should hold the GraphicsLock. -static void -Deselect (BYTE opt) -{ - switch (opt) - { - case START_MELEE: - DrawMeleeIcon (25); /* "Battle!" (not highlighted) */ - break; - case LOAD_TOP: - DrawMeleeIcon (17); /* "Load" (top, not highlighted) */ - break; - case LOAD_BOT: - DrawMeleeIcon (22); /* "Load" (bottom, not highlighted) */ - break; - case SAVE_TOP: - DrawMeleeIcon (18); /* "Save" (top, not highlighted) */ - break; - case SAVE_BOT: - DrawMeleeIcon (21); /* "Save" (bottom, not highlighted) */ - break; -#ifdef NETPLAY - case NET_TOP: - DrawMeleeIcon (35); /* "Net..." (top, not highlighted) */ - break; - case NET_BOT: - DrawMeleeIcon (37); /* "Net..." (bottom, not highlighted) */ - break; -#endif - case QUIT_BOT: - DrawMeleeIcon (29); /* "Quit" (not highlighted) */ - break; - case CONTROLS_TOP: - case CONTROLS_BOT: - { - COUNT which_side; - - which_side = opt == CONTROLS_TOP ? 1 : 0; - DrawControls (which_side, FALSE); - break; - } - case EDIT_MELEE: - if (pMeleeState->InputFunc == DoEdit) - { - if (pMeleeState->row < NUM_MELEE_ROWS) - DrawShipBoxCurrent (pMeleeState, FALSE); - else if (pMeleeState->CurIndex == (BYTE)~0) - DrawTeamString (pMeleeState, pMeleeState->side, - DTSHS_NORMAL); - } - else if (pMeleeState->InputFunc == DoPickShip) - { - DrawPickIcon (pMeleeState->CurIndex, 1); - } - break; - } -} - -// XXX: this function is called when the current selection is blinking off. -// The caller should hold the GraphicsLock. -static void -Select (BYTE opt) -{ - switch (opt) - { - case START_MELEE: - DrawMeleeIcon (26); /* "Battle!" (highlighted) */ - break; - case LOAD_TOP: - DrawMeleeIcon (19); /* "Load" (top, highlighted) */ - break; - case LOAD_BOT: - DrawMeleeIcon (24); /* "Load" (bottom, highlighted) */ - break; - case SAVE_TOP: - DrawMeleeIcon (20); /* "Save" (top; highlighted) */ - break; - case SAVE_BOT: - DrawMeleeIcon (23); /* "Save" (bottom; highlighted) */ - break; -#ifdef NETPLAY - case NET_TOP: - DrawMeleeIcon (36); /* "Net..." (top; highlighted) */ - break; - case NET_BOT: - DrawMeleeIcon (38); /* "Net..." (bottom; highlighted) */ - break; -#endif - case QUIT_BOT: - DrawMeleeIcon (30); /* "Quit" (highlighted) */ - break; - case CONTROLS_TOP: - case CONTROLS_BOT: - { - COUNT which_side; - - which_side = opt == CONTROLS_TOP ? 1 : 0; - DrawControls (which_side, TRUE); - break; - } - case EDIT_MELEE: - if (pMeleeState->InputFunc == DoEdit) - { - if (pMeleeState->row < NUM_MELEE_ROWS) - DrawShipBoxCurrent (pMeleeState, TRUE); - else if (pMeleeState->CurIndex == (BYTE)~0) - DrawTeamString (pMeleeState, pMeleeState->side, - DTSHS_SELECTED); - } - else if (pMeleeState->InputFunc == DoPickShip) - DrawPickIcon (pMeleeState->CurIndex, 0); - break; - } -} - -static void -flashSelection (MELEE_STATE *pMS) -{ -#define FLASH_RATE (ONE_SECOND / 9) - static TimeCount NextTime = 0; - static bool select = false; - TimeCount Now = GetTimeCounter (); - - if (Now >= NextTime) - { - CONTEXT OldContext; - - NextTime = Now + FLASH_RATE; - select ^= true; - - LockMutex (GraphicsLock); - OldContext = SetContext (SpaceContext); - if (select) - Select (pMS->MeleeOption); - else - Deselect (pMS->MeleeOption); - SetContext (OldContext); - UnlockMutex (GraphicsLock); - } -} - -static void -InitMelee (MELEE_STATE *pMS) -{ - RECT r; - - SetContext (SpaceContext); - SetContextFGFrame (Screen); - SetContextClipRect (NULL); - SetContextBackGroundColor (BLACK_COLOR); - ClearDrawable (); - r.corner.x = SAFE_X; - r.corner.y = SAFE_Y; - r.extent.width = SCREEN_WIDTH - (SAFE_X * 2); - r.extent.height = SCREEN_HEIGHT - (SAFE_Y * 2); - SetContextClipRect (&r); - - r.corner.x = r.corner.y = 0; - RedrawMeleeFrame (); - - (void) pMS; -} - -static void -DrawMeleeShipStrings (MELEE_STATE *pMS, BYTE NewStarShip) -{ - RECT r, OldRect; - CONTEXT OldContext; - - LockMutex (GraphicsLock); - - OldContext = SetContext (StatusContext); - GetContextClipRect (&OldRect); - r = OldRect; - r.corner.x += ((SAFE_X << 1) - 32) + MENU_X_OFFS; - r.corner.y += 76; - r.extent.height = SHIP_INFO_HEIGHT; - SetContextClipRect (&r); - BatchGraphics (); - - if (NewStarShip == MELEE_NONE) - { - RECT r; - TEXT t; - - ClearShipStatus (0); - SetContextFont (StarConFont); - r.corner.x = 3; - r.corner.y = 4; - r.extent.width = 57; - r.extent.height = 60; - SetContextForeGroundColor (BLACK_COLOR); - DrawRectangle (&r); - t.baseline.x = STATUS_WIDTH >> 1; - t.baseline.y = 32; - t.align = ALIGN_CENTER; - if (pMS->row < NUM_MELEE_ROWS) - { - t.pStr = GAME_STRING (MELEE_STRING_BASE + 0); // "Empty" - t.CharCount = (COUNT)~0; - font_DrawText (&t); - t.pStr = GAME_STRING (MELEE_STRING_BASE + 1); // "Slot" - } - else - { - t.pStr = GAME_STRING (MELEE_STRING_BASE + 2); // "Team" - t.CharCount = (COUNT)~0; - font_DrawText (&t); - t.pStr = GAME_STRING (MELEE_STRING_BASE + 3); // "Name" - } - t.baseline.y += TINY_TEXT_HEIGHT; - t.CharCount = (COUNT)~0; - font_DrawText (&t); - } - else - { - HMASTERSHIP hMasterShip; - MASTER_SHIP_INFO *MasterPtr; - - hMasterShip = GetStarShipFromIndex (&master_q, NewStarShip); - MasterPtr = LockMasterShip (&master_q, hMasterShip); - - InitShipStatus (&MasterPtr->ShipInfo, NULL, NULL); - - UnlockMasterShip (&master_q, hMasterShip); - } - - UnbatchGraphics (); - SetContextClipRect (&OldRect); - SetContext (OldContext); - - UnlockMutex (GraphicsLock); -} - -static void -UpdateCurrentShip (MELEE_STATE *pMS) -{ - FleetShipIndex fleetShipIndex = GetShipIndex (pMS->row, pMS->col); - if (pMS->row == NUM_MELEE_ROWS) - pMS->CurIndex = MELEE_NONE; - else - pMS->CurIndex = - pMS->SideState[pMS->side].TeamImage.ShipList[fleetShipIndex]; - DrawMeleeShipStrings (pMS, (BYTE)(pMS->CurIndex)); -} - -// returns (COUNT) ~0 for an invalid ship. -static COUNT -GetShipValue (BYTE StarShip) -{ - COUNT val; - - if (StarShip == MELEE_NONE) - return 0; - - val = GetShipCostFromIndex (StarShip); - if (val == 0) - val = (COUNT)~0; - - return val; -} - -COUNT -GetTeamValue (TEAM_IMAGE *pTI) -{ - FleetShipIndex index; - COUNT val; - - val = 0; - for (index = 0; index < MELEE_FLEET_SIZE; index++) - { - BYTE StarShip = pTI->ShipList[index]; - COUNT shipVal = GetShipValue (StarShip); - if (shipVal == (COUNT)~0) - pTI->ShipList[index] = MELEE_NONE; - val += shipVal; - } - - return val; -} - -static void -DeleteCurrentShip (MELEE_STATE *pMS) -{ - RECT r; - FleetShipIndex fleetShipIndex; - int CurIndex; - - fleetShipIndex = GetShipIndex (pMS->row, pMS->col); - CurIndex = pMS->SideState[pMS->side].TeamImage.ShipList[fleetShipIndex]; - pMS->SideState[pMS->side].star_bucks -= GetShipCostFromIndex (CurIndex); - pMS->SideState[pMS->side].TeamImage.ShipList[fleetShipIndex] = MELEE_NONE; - - LockMutex (GraphicsLock); - GetShipBox (&r, pMS->side, pMS->row, pMS->col); - RepairMeleeFrame (&r); - - DrawTeamString (pMS, pMS->side, DTSHS_REPAIR); - UnlockMutex (GraphicsLock); -} - -static void -AdvanceCursor (MELEE_STATE *pMS) -{ - ++pMS->col; - if (pMS->col == NUM_MELEE_COLUMNS) - { - ++pMS->row; - if (pMS->row < NUM_MELEE_ROWS) - pMS->col = 0; - else - { - pMS->col = NUM_MELEE_COLUMNS - 1; - pMS->row = NUM_MELEE_ROWS - 1; - } - } -} - -static BOOLEAN -OnTeamNameChange (TEXTENTRY_STATE *pTES) -{ - MELEE_STATE *pMS = (MELEE_STATE*) pTES->CbParam; - BOOLEAN ret; - COUNT hl = DTSHS_EDIT; - - pMS->CurIndex = pTES->CursorPos; - if (pTES->JoystickMode) - hl |= DTSHS_BLOCKCUR; - - LockMutex (GraphicsLock); - ret = DrawTeamString (pMS, pMS->side, hl); - UnlockMutex (GraphicsLock); - - return ret; -} - -static BOOLEAN -DoEdit (MELEE_STATE *pMS) -{ - DWORD TimeIn = GetTimeCounter (); - - /* Cancel any presses of the Pause key. */ - GamePaused = FALSE; - - if (GLOBAL (CurrentActivity) & CHECK_ABORT) - return (FALSE); - - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT | MENU_SOUND_DELETE); - if (!pMS->Initialized) - { - FleetShipIndex fleetShipIndex = GetShipIndex (pMS->row, pMS->col); - pMS->CurIndex = - pMS->SideState[pMS->side].TeamImage.ShipList[fleetShipIndex]; - DrawMeleeShipStrings (pMS, (BYTE)pMS->CurIndex); - - pMS->Initialized = TRUE; - pMS->InputFunc = DoEdit; - return TRUE; - } - -#ifdef NETPLAY - netInput (); -#endif - if ((pMS->row < NUM_MELEE_ROWS || pMS->CurIndex == (BYTE)~0) - && (PulsedInputState.menu[KEY_MENU_CANCEL] - || (PulsedInputState.menu[KEY_MENU_RIGHT] - && (pMS->col == NUM_MELEE_COLUMNS - 1 - || pMS->row == NUM_MELEE_ROWS)))) - { - // Done editing the teams. - LockMutex (GraphicsLock); - Deselect (EDIT_MELEE); - pMS->CurIndex = (COUNT)~0; - pMS->MeleeOption = START_MELEE; - pMS->InputFunc = DoMelee; - UnlockMutex (GraphicsLock); - pMS->LastInputTime = GetTimeCounter (); - } - else if (pMS->row < NUM_MELEE_ROWS - && PulsedInputState.menu[KEY_MENU_SELECT]) - { - // Show a popup to add a new ship to the current team. - pMS->Initialized = 0; - FlushInput (); - DoPickShip (pMS); - } - else if (pMS->row < NUM_MELEE_ROWS - && PulsedInputState.menu[KEY_MENU_SPECIAL]) - { - // TODO: this is a stub; Should we display a ship spin? - LockMutex (GraphicsLock); - Deselect (EDIT_MELEE); - if (pMS->CurIndex != (BYTE)~0) - { - // Do something with pMS->CurIndex here - } - UnlockMutex (GraphicsLock); - } - else if (pMS->row < NUM_MELEE_ROWS && - PulsedInputState.menu[KEY_MENU_DELETE]) - { - // Remove the currently selected ship from the current team. - FleetShipIndex fleetShipIndex; - DeleteCurrentShip (pMS); - fleetShipIndex = GetShipIndex (pMS->row, pMS->col); - fleetShipChanged (pMS, pMS->side, fleetShipIndex); - AdvanceCursor (pMS); - UpdateCurrentShip (pMS); - } - else - { - COUNT side, row, col; - - side = pMS->side; - row = pMS->row; - col = pMS->col; - - if (row == NUM_MELEE_ROWS) - { - // Edit the name of the current team. - if (PulsedInputState.menu[KEY_MENU_SELECT]) - { - TEXTENTRY_STATE tes; - - // going to enter text - // XXX: CurIndex is abused here; DrawTeamString expects - // CurIndex to contain the current cursor position - pMS->CurIndex = 0; - LockMutex (GraphicsLock); - DrawTeamString (pMS, pMS->side, DTSHS_EDIT); - UnlockMutex (GraphicsLock); - - tes.Initialized = FALSE; - tes.BaseStr = pMS->SideState[pMS->side].TeamImage.TeamName; - tes.CursorPos = 0; - tes.MaxSize = MAX_TEAM_CHARS + 1; - tes.CbParam = pMS; - tes.ChangeCallback = OnTeamNameChange; - tes.FrameCallback = 0; - DoTextEntry (&tes); - - // done entering - pMS->CurIndex = (BYTE)~0; - LockMutex (GraphicsLock); - DrawTeamString (pMS, pMS->side, DTSHS_REPAIR); - UnlockMutex (GraphicsLock); - - teamStringChanged (pMS, pMS->side); - - return (TRUE); - } - } - - { - if (PulsedInputState.menu[KEY_MENU_LEFT]) - { - if (col > 0) - --col; - } - else if (PulsedInputState.menu[KEY_MENU_RIGHT]) - { - if (col < NUM_MELEE_COLUMNS - 1) - ++col; - } - - if (PulsedInputState.menu[KEY_MENU_UP]) - { - if (row-- == 0) - { - if (side == 0) - row = 0; - else - { - row = NUM_MELEE_ROWS; - side = !si... [truncated message content] |
From: <Mee...@us...> - 2009-12-30 01:00:24
|
Revision: 3494 http://sc2.svn.sourceforge.net/sc2/?rev=3494&view=rev Author: Meep-Eep Date: 2009-12-30 01:00:14 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Cleaned up some legacy source code files. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/comm/arilou/resinst.h trunk/sc2/src/uqm/comm/blackur/resinst.h trunk/sc2/src/uqm/comm/chmmr/resinst.h trunk/sc2/src/uqm/comm/comandr/resinst.h trunk/sc2/src/uqm/comm/druuge/resinst.h trunk/sc2/src/uqm/comm/ilwrath/resinst.h trunk/sc2/src/uqm/comm/melnorm/resinst.h trunk/sc2/src/uqm/comm/mycon/resinst.h trunk/sc2/src/uqm/comm/orz/resinst.h trunk/sc2/src/uqm/comm/pkunk/resinst.h trunk/sc2/src/uqm/comm/shofixt/resinst.h trunk/sc2/src/uqm/comm/slyhome/resinst.h trunk/sc2/src/uqm/comm/slyland/resinst.h trunk/sc2/src/uqm/comm/spathi/resinst.h trunk/sc2/src/uqm/comm/supox/resinst.h trunk/sc2/src/uqm/comm/syreen/resinst.h trunk/sc2/src/uqm/comm/talkpet/resinst.h trunk/sc2/src/uqm/comm/thradd/resinst.h trunk/sc2/src/uqm/comm/umgah/resinst.h trunk/sc2/src/uqm/comm/urquan/resinst.h trunk/sc2/src/uqm/comm/utwig/resinst.h trunk/sc2/src/uqm/comm/vux/resinst.h trunk/sc2/src/uqm/comm/yehat/resinst.h trunk/sc2/src/uqm/comm/zoqfot/resinst.h trunk/sc2/src/uqm/ships/androsyn/icode.h trunk/sc2/src/uqm/ships/androsyn/resinst.h trunk/sc2/src/uqm/ships/arilou/icode.h trunk/sc2/src/uqm/ships/arilou/resinst.h trunk/sc2/src/uqm/ships/blackurq/icode.h trunk/sc2/src/uqm/ships/blackurq/resinst.h trunk/sc2/src/uqm/ships/chenjesu/icode.h trunk/sc2/src/uqm/ships/chenjesu/resinst.h trunk/sc2/src/uqm/ships/chmmr/icode.h trunk/sc2/src/uqm/ships/chmmr/resinst.h trunk/sc2/src/uqm/ships/druuge/icode.h trunk/sc2/src/uqm/ships/druuge/resinst.h trunk/sc2/src/uqm/ships/human/icode.h trunk/sc2/src/uqm/ships/human/resinst.h trunk/sc2/src/uqm/ships/ilwrath/icode.h trunk/sc2/src/uqm/ships/ilwrath/resinst.h trunk/sc2/src/uqm/ships/lastbat/icode.h trunk/sc2/src/uqm/ships/lastbat/resinst.h trunk/sc2/src/uqm/ships/melnorme/icode.h trunk/sc2/src/uqm/ships/melnorme/resinst.h trunk/sc2/src/uqm/ships/mmrnmhrm/icode.h trunk/sc2/src/uqm/ships/mmrnmhrm/resinst.h trunk/sc2/src/uqm/ships/mycon/icode.h trunk/sc2/src/uqm/ships/mycon/resinst.h trunk/sc2/src/uqm/ships/orz/icode.h trunk/sc2/src/uqm/ships/orz/resinst.h trunk/sc2/src/uqm/ships/pkunk/icode.h trunk/sc2/src/uqm/ships/pkunk/resinst.h trunk/sc2/src/uqm/ships/probe/icode.h trunk/sc2/src/uqm/ships/probe/resinst.h trunk/sc2/src/uqm/ships/shofixti/icode.h trunk/sc2/src/uqm/ships/shofixti/resinst.h trunk/sc2/src/uqm/ships/sis_ship/icode.h trunk/sc2/src/uqm/ships/sis_ship/resinst.h trunk/sc2/src/uqm/ships/slylandr/icode.h trunk/sc2/src/uqm/ships/slylandr/resinst.h trunk/sc2/src/uqm/ships/spathi/icode.h trunk/sc2/src/uqm/ships/spathi/resinst.h trunk/sc2/src/uqm/ships/supox/icode.h trunk/sc2/src/uqm/ships/supox/resinst.h trunk/sc2/src/uqm/ships/syreen/icode.h trunk/sc2/src/uqm/ships/syreen/resinst.h trunk/sc2/src/uqm/ships/thradd/icode.h trunk/sc2/src/uqm/ships/thradd/resinst.h trunk/sc2/src/uqm/ships/umgah/icode.h trunk/sc2/src/uqm/ships/umgah/resinst.h trunk/sc2/src/uqm/ships/urquan/icode.h trunk/sc2/src/uqm/ships/urquan/resinst.h trunk/sc2/src/uqm/ships/utwig/icode.h trunk/sc2/src/uqm/ships/utwig/resinst.h trunk/sc2/src/uqm/ships/vux/icode.h trunk/sc2/src/uqm/ships/vux/resinst.h trunk/sc2/src/uqm/ships/yehat/icode.h trunk/sc2/src/uqm/ships/yehat/resinst.h trunk/sc2/src/uqm/ships/zoqfot/icode.h trunk/sc2/src/uqm/ships/zoqfot/resinst.h Added Paths: ----------- trunk/sc2/doc/devel/historical Removed Paths: ------------- trunk/sc2/src/uqm/comm/arilou/arilou.res trunk/sc2/src/uqm/comm/arilou/ifontres.h trunk/sc2/src/uqm/comm/arilou/igfxres.h trunk/sc2/src/uqm/comm/arilou/imusicre.h trunk/sc2/src/uqm/comm/arilou/istrtab.h trunk/sc2/src/uqm/comm/arilou/respkg.h trunk/sc2/src/uqm/comm/arilou/restypes.h trunk/sc2/src/uqm/comm/blackur/blackur.res trunk/sc2/src/uqm/comm/blackur/ifontres.h trunk/sc2/src/uqm/comm/blackur/igfxres.h trunk/sc2/src/uqm/comm/blackur/imusicre.h trunk/sc2/src/uqm/comm/blackur/istrtab.h trunk/sc2/src/uqm/comm/blackur/respkg.h trunk/sc2/src/uqm/comm/blackur/restypes.h trunk/sc2/src/uqm/comm/chmmr/chmmr.res trunk/sc2/src/uqm/comm/chmmr/ifontres.h trunk/sc2/src/uqm/comm/chmmr/igfxres.h trunk/sc2/src/uqm/comm/chmmr/imusicre.h trunk/sc2/src/uqm/comm/chmmr/istrtab.h trunk/sc2/src/uqm/comm/chmmr/respkg.h trunk/sc2/src/uqm/comm/chmmr/restypes.h trunk/sc2/src/uqm/comm/comandr/comandr.res trunk/sc2/src/uqm/comm/comandr/ifontres.h trunk/sc2/src/uqm/comm/comandr/igfxres.h trunk/sc2/src/uqm/comm/comandr/imusicre.h trunk/sc2/src/uqm/comm/comandr/istrtab.h trunk/sc2/src/uqm/comm/comandr/respkg.h trunk/sc2/src/uqm/comm/comandr/restypes.h trunk/sc2/src/uqm/comm/druuge/druuge.res trunk/sc2/src/uqm/comm/druuge/ifontres.h trunk/sc2/src/uqm/comm/druuge/igfxres.h trunk/sc2/src/uqm/comm/druuge/imusicre.h trunk/sc2/src/uqm/comm/druuge/istrtab.h trunk/sc2/src/uqm/comm/druuge/respkg.h trunk/sc2/src/uqm/comm/druuge/restypes.h trunk/sc2/src/uqm/comm/ilwrath/ifontres.h trunk/sc2/src/uqm/comm/ilwrath/igfxres.h trunk/sc2/src/uqm/comm/ilwrath/ilwrath.res trunk/sc2/src/uqm/comm/ilwrath/imusicre.h trunk/sc2/src/uqm/comm/ilwrath/istrtab.h trunk/sc2/src/uqm/comm/ilwrath/respkg.h trunk/sc2/src/uqm/comm/ilwrath/restypes.h trunk/sc2/src/uqm/comm/melnorm/ifontres.h trunk/sc2/src/uqm/comm/melnorm/igfxres.h trunk/sc2/src/uqm/comm/melnorm/imusicre.h trunk/sc2/src/uqm/comm/melnorm/istrtab.h trunk/sc2/src/uqm/comm/melnorm/melnorm.res trunk/sc2/src/uqm/comm/melnorm/respkg.h trunk/sc2/src/uqm/comm/melnorm/restypes.h trunk/sc2/src/uqm/comm/mycon/ifontres.h trunk/sc2/src/uqm/comm/mycon/igfxres.h trunk/sc2/src/uqm/comm/mycon/imusicre.h trunk/sc2/src/uqm/comm/mycon/istrtab.h trunk/sc2/src/uqm/comm/mycon/mycon.res trunk/sc2/src/uqm/comm/mycon/respkg.h trunk/sc2/src/uqm/comm/mycon/restypes.h trunk/sc2/src/uqm/comm/orz/ifontres.h trunk/sc2/src/uqm/comm/orz/igfxres.h trunk/sc2/src/uqm/comm/orz/imusicre.h trunk/sc2/src/uqm/comm/orz/istrtab.h trunk/sc2/src/uqm/comm/orz/orz.res trunk/sc2/src/uqm/comm/orz/respkg.h trunk/sc2/src/uqm/comm/orz/restypes.h trunk/sc2/src/uqm/comm/pkunk/ifontres.h trunk/sc2/src/uqm/comm/pkunk/igfxres.h trunk/sc2/src/uqm/comm/pkunk/imusicre.h trunk/sc2/src/uqm/comm/pkunk/istrtab.h trunk/sc2/src/uqm/comm/pkunk/pkunk.res trunk/sc2/src/uqm/comm/pkunk/respkg.h trunk/sc2/src/uqm/comm/pkunk/restypes.h trunk/sc2/src/uqm/comm/shofixt/ifontres.h trunk/sc2/src/uqm/comm/shofixt/igfxres.h trunk/sc2/src/uqm/comm/shofixt/imusicre.h trunk/sc2/src/uqm/comm/shofixt/istrtab.h trunk/sc2/src/uqm/comm/shofixt/respkg.h trunk/sc2/src/uqm/comm/shofixt/restypes.h trunk/sc2/src/uqm/comm/shofixt/shofixt.res trunk/sc2/src/uqm/comm/slyhome/ifontres.h trunk/sc2/src/uqm/comm/slyhome/igfxres.h trunk/sc2/src/uqm/comm/slyhome/imusicre.h trunk/sc2/src/uqm/comm/slyhome/istrtab.h trunk/sc2/src/uqm/comm/slyhome/respkg.h trunk/sc2/src/uqm/comm/slyhome/restypes.h trunk/sc2/src/uqm/comm/slyhome/slyhome.res trunk/sc2/src/uqm/comm/slyland/ifontres.h trunk/sc2/src/uqm/comm/slyland/igfxres.h trunk/sc2/src/uqm/comm/slyland/imusicre.h trunk/sc2/src/uqm/comm/slyland/istrtab.h trunk/sc2/src/uqm/comm/slyland/respkg.h trunk/sc2/src/uqm/comm/slyland/restypes.h trunk/sc2/src/uqm/comm/slyland/slyland.res trunk/sc2/src/uqm/comm/spathi/ifontres.h trunk/sc2/src/uqm/comm/spathi/igfxres.h trunk/sc2/src/uqm/comm/spathi/imusicre.h trunk/sc2/src/uqm/comm/spathi/istrtab.h trunk/sc2/src/uqm/comm/spathi/respkg.h trunk/sc2/src/uqm/comm/spathi/restypes.h trunk/sc2/src/uqm/comm/spathi/spathi.res trunk/sc2/src/uqm/comm/supox/ifontres.h trunk/sc2/src/uqm/comm/supox/igfxres.h trunk/sc2/src/uqm/comm/supox/imusicre.h trunk/sc2/src/uqm/comm/supox/istrtab.h trunk/sc2/src/uqm/comm/supox/respkg.h trunk/sc2/src/uqm/comm/supox/restypes.h trunk/sc2/src/uqm/comm/supox/supox.res trunk/sc2/src/uqm/comm/syreen/ifontres.h trunk/sc2/src/uqm/comm/syreen/igfxres.h trunk/sc2/src/uqm/comm/syreen/imusicre.h trunk/sc2/src/uqm/comm/syreen/istrtab.h trunk/sc2/src/uqm/comm/syreen/respkg.h trunk/sc2/src/uqm/comm/syreen/restypes.h trunk/sc2/src/uqm/comm/syreen/syreen.res trunk/sc2/src/uqm/comm/talkpet/ifontres.h trunk/sc2/src/uqm/comm/talkpet/igfxres.h trunk/sc2/src/uqm/comm/talkpet/imusicre.h trunk/sc2/src/uqm/comm/talkpet/istrtab.h trunk/sc2/src/uqm/comm/talkpet/respkg.h trunk/sc2/src/uqm/comm/talkpet/restypes.h trunk/sc2/src/uqm/comm/talkpet/talkpet.res trunk/sc2/src/uqm/comm/thradd/ifontres.h trunk/sc2/src/uqm/comm/thradd/igfxres.h trunk/sc2/src/uqm/comm/thradd/imusicre.h trunk/sc2/src/uqm/comm/thradd/istrtab.h trunk/sc2/src/uqm/comm/thradd/respkg.h trunk/sc2/src/uqm/comm/thradd/restypes.h trunk/sc2/src/uqm/comm/thradd/thradd.res trunk/sc2/src/uqm/comm/umgah/ifontres.h trunk/sc2/src/uqm/comm/umgah/igfxres.h trunk/sc2/src/uqm/comm/umgah/imusicre.h trunk/sc2/src/uqm/comm/umgah/istrtab.h trunk/sc2/src/uqm/comm/umgah/respkg.h trunk/sc2/src/uqm/comm/umgah/restypes.h trunk/sc2/src/uqm/comm/umgah/umgah.res trunk/sc2/src/uqm/comm/urquan/ifontres.h trunk/sc2/src/uqm/comm/urquan/igfxres.h trunk/sc2/src/uqm/comm/urquan/imusicre.h trunk/sc2/src/uqm/comm/urquan/istrtab.h trunk/sc2/src/uqm/comm/urquan/respkg.h trunk/sc2/src/uqm/comm/urquan/restypes.h trunk/sc2/src/uqm/comm/urquan/urquan.res trunk/sc2/src/uqm/comm/utwig/ifontres.h trunk/sc2/src/uqm/comm/utwig/igfxres.h trunk/sc2/src/uqm/comm/utwig/imusicre.h trunk/sc2/src/uqm/comm/utwig/istrtab.h trunk/sc2/src/uqm/comm/utwig/respkg.h trunk/sc2/src/uqm/comm/utwig/restypes.h trunk/sc2/src/uqm/comm/utwig/utwig.res trunk/sc2/src/uqm/comm/vux/ifontres.h trunk/sc2/src/uqm/comm/vux/igfxres.h trunk/sc2/src/uqm/comm/vux/imusicre.h trunk/sc2/src/uqm/comm/vux/istrtab.h trunk/sc2/src/uqm/comm/vux/respkg.h trunk/sc2/src/uqm/comm/vux/restypes.h trunk/sc2/src/uqm/comm/vux/vux.res trunk/sc2/src/uqm/comm/yehat/ifontres.h trunk/sc2/src/uqm/comm/yehat/igfxres.h trunk/sc2/src/uqm/comm/yehat/imusicre.h trunk/sc2/src/uqm/comm/yehat/istrtab.h trunk/sc2/src/uqm/comm/yehat/respkg.h trunk/sc2/src/uqm/comm/yehat/restypes.h trunk/sc2/src/uqm/comm/yehat/yehat.res trunk/sc2/src/uqm/comm/zoqfot/ifontres.h trunk/sc2/src/uqm/comm/zoqfot/igfxres.h trunk/sc2/src/uqm/comm/zoqfot/imusicre.h trunk/sc2/src/uqm/comm/zoqfot/istrtab.h trunk/sc2/src/uqm/comm/zoqfot/respkg.h trunk/sc2/src/uqm/comm/zoqfot/restypes.h trunk/sc2/src/uqm/comm/zoqfot/zoqfot.res trunk/sc2/src/uqm/ships/androsyn/androsyn.res trunk/sc2/src/uqm/ships/androsyn/igfxres.h trunk/sc2/src/uqm/ships/androsyn/imusicre.h trunk/sc2/src/uqm/ships/androsyn/isndres.h trunk/sc2/src/uqm/ships/androsyn/istrtab.h trunk/sc2/src/uqm/ships/androsyn/respkg.h trunk/sc2/src/uqm/ships/androsyn/restypes.h trunk/sc2/src/uqm/ships/arilou/arilou.res trunk/sc2/src/uqm/ships/arilou/igfxres.h trunk/sc2/src/uqm/ships/arilou/imusicre.h trunk/sc2/src/uqm/ships/arilou/isndres.h trunk/sc2/src/uqm/ships/arilou/istrtab.h trunk/sc2/src/uqm/ships/arilou/respkg.h trunk/sc2/src/uqm/ships/arilou/restypes.h trunk/sc2/src/uqm/ships/blackurq/blackurq.res trunk/sc2/src/uqm/ships/blackurq/igfxres.h trunk/sc2/src/uqm/ships/blackurq/imusicre.h trunk/sc2/src/uqm/ships/blackurq/isndres.h trunk/sc2/src/uqm/ships/blackurq/istrtab.h trunk/sc2/src/uqm/ships/blackurq/respkg.h trunk/sc2/src/uqm/ships/blackurq/restypes.h trunk/sc2/src/uqm/ships/chenjesu/chenjesu.res trunk/sc2/src/uqm/ships/chenjesu/igfxres.h trunk/sc2/src/uqm/ships/chenjesu/imusicre.h trunk/sc2/src/uqm/ships/chenjesu/isndres.h trunk/sc2/src/uqm/ships/chenjesu/istrtab.h trunk/sc2/src/uqm/ships/chenjesu/respkg.h trunk/sc2/src/uqm/ships/chenjesu/restypes.h trunk/sc2/src/uqm/ships/chmmr/chmmr.res trunk/sc2/src/uqm/ships/chmmr/igfxres.h trunk/sc2/src/uqm/ships/chmmr/imusicre.h trunk/sc2/src/uqm/ships/chmmr/isndres.h trunk/sc2/src/uqm/ships/chmmr/istrtab.h trunk/sc2/src/uqm/ships/chmmr/respkg.h trunk/sc2/src/uqm/ships/chmmr/restypes.h trunk/sc2/src/uqm/ships/druuge/druuge.res trunk/sc2/src/uqm/ships/druuge/igfxres.h trunk/sc2/src/uqm/ships/druuge/imusicre.h trunk/sc2/src/uqm/ships/druuge/isndres.h trunk/sc2/src/uqm/ships/druuge/istrtab.h trunk/sc2/src/uqm/ships/druuge/respkg.h trunk/sc2/src/uqm/ships/druuge/restypes.h trunk/sc2/src/uqm/ships/human/human.res trunk/sc2/src/uqm/ships/human/igfxres.h trunk/sc2/src/uqm/ships/human/imusicre.h trunk/sc2/src/uqm/ships/human/isndres.h trunk/sc2/src/uqm/ships/human/istrtab.h trunk/sc2/src/uqm/ships/human/respkg.h trunk/sc2/src/uqm/ships/human/restypes.h trunk/sc2/src/uqm/ships/ilwrath/igfxres.h trunk/sc2/src/uqm/ships/ilwrath/ilwrath.res trunk/sc2/src/uqm/ships/ilwrath/imusicre.h trunk/sc2/src/uqm/ships/ilwrath/isndres.h trunk/sc2/src/uqm/ships/ilwrath/istrtab.h trunk/sc2/src/uqm/ships/ilwrath/respkg.h trunk/sc2/src/uqm/ships/ilwrath/restypes.h trunk/sc2/src/uqm/ships/lastbat/igfxres.h trunk/sc2/src/uqm/ships/lastbat/imusicre.h trunk/sc2/src/uqm/ships/lastbat/isndres.h trunk/sc2/src/uqm/ships/lastbat/istrtab.h trunk/sc2/src/uqm/ships/lastbat/lastbat.res trunk/sc2/src/uqm/ships/lastbat/respkg.h trunk/sc2/src/uqm/ships/lastbat/restypes.h trunk/sc2/src/uqm/ships/melnorme/igfxres.h trunk/sc2/src/uqm/ships/melnorme/imusicre.h trunk/sc2/src/uqm/ships/melnorme/isndres.h trunk/sc2/src/uqm/ships/melnorme/istrtab.h trunk/sc2/src/uqm/ships/melnorme/melnorme.res trunk/sc2/src/uqm/ships/melnorme/respkg.h trunk/sc2/src/uqm/ships/melnorme/restypes.h trunk/sc2/src/uqm/ships/mmrnmhrm/igfxres.h trunk/sc2/src/uqm/ships/mmrnmhrm/imusicre.h trunk/sc2/src/uqm/ships/mmrnmhrm/isndres.h trunk/sc2/src/uqm/ships/mmrnmhrm/istrtab.h trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.res trunk/sc2/src/uqm/ships/mmrnmhrm/respkg.h trunk/sc2/src/uqm/ships/mmrnmhrm/restypes.h trunk/sc2/src/uqm/ships/mycon/igfxres.h trunk/sc2/src/uqm/ships/mycon/imusicre.h trunk/sc2/src/uqm/ships/mycon/isndres.h trunk/sc2/src/uqm/ships/mycon/istrtab.h trunk/sc2/src/uqm/ships/mycon/mycon.res trunk/sc2/src/uqm/ships/mycon/respkg.h trunk/sc2/src/uqm/ships/mycon/restypes.h trunk/sc2/src/uqm/ships/orz/igfxres.h trunk/sc2/src/uqm/ships/orz/imusicre.h trunk/sc2/src/uqm/ships/orz/isndres.h trunk/sc2/src/uqm/ships/orz/istrtab.h trunk/sc2/src/uqm/ships/orz/orz.res trunk/sc2/src/uqm/ships/orz/respkg.h trunk/sc2/src/uqm/ships/orz/restypes.h trunk/sc2/src/uqm/ships/pkunk/igfxres.h trunk/sc2/src/uqm/ships/pkunk/imusicre.h trunk/sc2/src/uqm/ships/pkunk/isndres.h trunk/sc2/src/uqm/ships/pkunk/istrtab.h trunk/sc2/src/uqm/ships/pkunk/pkunk.res trunk/sc2/src/uqm/ships/pkunk/respkg.h trunk/sc2/src/uqm/ships/pkunk/restypes.h trunk/sc2/src/uqm/ships/probe/igfxres.h trunk/sc2/src/uqm/ships/probe/istrtab.h trunk/sc2/src/uqm/ships/probe/probe.res trunk/sc2/src/uqm/ships/probe/respkg.h trunk/sc2/src/uqm/ships/probe/restypes.h trunk/sc2/src/uqm/ships/shofixti/igfxres.h trunk/sc2/src/uqm/ships/shofixti/imusicre.h trunk/sc2/src/uqm/ships/shofixti/isndres.h trunk/sc2/src/uqm/ships/shofixti/istrtab.h trunk/sc2/src/uqm/ships/shofixti/respkg.h trunk/sc2/src/uqm/ships/shofixti/restypes.h trunk/sc2/src/uqm/ships/shofixti/shofixti.res trunk/sc2/src/uqm/ships/sis_ship/igfxres.h trunk/sc2/src/uqm/ships/sis_ship/imusicre.h trunk/sc2/src/uqm/ships/sis_ship/isndres.h trunk/sc2/src/uqm/ships/sis_ship/respkg.h trunk/sc2/src/uqm/ships/sis_ship/restypes.h trunk/sc2/src/uqm/ships/sis_ship/sis.res trunk/sc2/src/uqm/ships/slylandr/igfxres.h trunk/sc2/src/uqm/ships/slylandr/imusicre.h trunk/sc2/src/uqm/ships/slylandr/isndres.h trunk/sc2/src/uqm/ships/slylandr/istrtab.h trunk/sc2/src/uqm/ships/slylandr/respkg.h trunk/sc2/src/uqm/ships/slylandr/restypes.h trunk/sc2/src/uqm/ships/slylandr/slylandr.res trunk/sc2/src/uqm/ships/spathi/igfxres.h trunk/sc2/src/uqm/ships/spathi/imusicre.h trunk/sc2/src/uqm/ships/spathi/isndres.h trunk/sc2/src/uqm/ships/spathi/istrtab.h trunk/sc2/src/uqm/ships/spathi/respkg.h trunk/sc2/src/uqm/ships/spathi/restypes.h trunk/sc2/src/uqm/ships/spathi/spathi.res trunk/sc2/src/uqm/ships/supox/igfxres.h trunk/sc2/src/uqm/ships/supox/imusicre.h trunk/sc2/src/uqm/ships/supox/isndres.h trunk/sc2/src/uqm/ships/supox/istrtab.h trunk/sc2/src/uqm/ships/supox/respkg.h trunk/sc2/src/uqm/ships/supox/restypes.h trunk/sc2/src/uqm/ships/supox/supox.res trunk/sc2/src/uqm/ships/syreen/igfxres.h trunk/sc2/src/uqm/ships/syreen/imusicre.h trunk/sc2/src/uqm/ships/syreen/isndres.h trunk/sc2/src/uqm/ships/syreen/istrtab.h trunk/sc2/src/uqm/ships/syreen/respkg.h trunk/sc2/src/uqm/ships/syreen/restypes.h trunk/sc2/src/uqm/ships/syreen/syreen.res trunk/sc2/src/uqm/ships/thradd/igfxres.h trunk/sc2/src/uqm/ships/thradd/imusicre.h trunk/sc2/src/uqm/ships/thradd/isndres.h trunk/sc2/src/uqm/ships/thradd/istrtab.h trunk/sc2/src/uqm/ships/thradd/respkg.h trunk/sc2/src/uqm/ships/thradd/restypes.h trunk/sc2/src/uqm/ships/thradd/thradd.res trunk/sc2/src/uqm/ships/umgah/igfxres.h trunk/sc2/src/uqm/ships/umgah/imusicre.h trunk/sc2/src/uqm/ships/umgah/isndres.h trunk/sc2/src/uqm/ships/umgah/istrtab.h trunk/sc2/src/uqm/ships/umgah/respkg.h trunk/sc2/src/uqm/ships/umgah/restypes.h trunk/sc2/src/uqm/ships/umgah/umgah.res trunk/sc2/src/uqm/ships/urquan/igfxres.h trunk/sc2/src/uqm/ships/urquan/imusicre.h trunk/sc2/src/uqm/ships/urquan/isndres.h trunk/sc2/src/uqm/ships/urquan/istrtab.h trunk/sc2/src/uqm/ships/urquan/respkg.h trunk/sc2/src/uqm/ships/urquan/restypes.h trunk/sc2/src/uqm/ships/urquan/urquan.res trunk/sc2/src/uqm/ships/utwig/igfxres.h trunk/sc2/src/uqm/ships/utwig/imusicre.h trunk/sc2/src/uqm/ships/utwig/isndres.h trunk/sc2/src/uqm/ships/utwig/istrtab.h trunk/sc2/src/uqm/ships/utwig/respkg.h trunk/sc2/src/uqm/ships/utwig/restypes.h trunk/sc2/src/uqm/ships/utwig/utwig.res trunk/sc2/src/uqm/ships/vux/igfxres.h trunk/sc2/src/uqm/ships/vux/imusicre.h trunk/sc2/src/uqm/ships/vux/isndres.h trunk/sc2/src/uqm/ships/vux/istrtab.h trunk/sc2/src/uqm/ships/vux/respkg.h trunk/sc2/src/uqm/ships/vux/restypes.h trunk/sc2/src/uqm/ships/vux/vux.res trunk/sc2/src/uqm/ships/yehat/igfxres.h trunk/sc2/src/uqm/ships/yehat/imusicre.h trunk/sc2/src/uqm/ships/yehat/isndres.h trunk/sc2/src/uqm/ships/yehat/istrtab.h trunk/sc2/src/uqm/ships/yehat/respkg.h trunk/sc2/src/uqm/ships/yehat/restypes.h trunk/sc2/src/uqm/ships/yehat/yehat.res trunk/sc2/src/uqm/ships/zoqfot/igfxres.h trunk/sc2/src/uqm/ships/zoqfot/imusicre.h trunk/sc2/src/uqm/ships/zoqfot/isndres.h trunk/sc2/src/uqm/ships/zoqfot/istrtab.h trunk/sc2/src/uqm/ships/zoqfot/respkg.h trunk/sc2/src/uqm/ships/zoqfot/restypes.h trunk/sc2/src/uqm/ships/zoqfot/zoqfot.res Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/ChangeLog 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Removed some legacy source code files related to resources - SvdB - Put SuperMelee source files in separate subdirectory - SvdB - Added additive and alpha drawing modes to graphics lib - Alex - Fixed black pixel gaps between the planet and shield when entering the Added: trunk/sc2/doc/devel/historical =================================================================== --- trunk/sc2/doc/devel/historical (rev 0) +++ trunk/sc2/doc/devel/historical 2009-12-30 01:00:14 UTC (rev 3494) @@ -0,0 +1,39 @@ +This file is intended as a place to document historically interesting +curiosities in the UQM source and content, which have been deleted from +the current source/content tree. + +This file is probably not complete. + + +== .res files === + +The Star Control source code contained files with the extension .res, which +contained a description of the packages (.pkg or .ndx) files to be generated. + +There were .res files for each ship and each race which you can communicate +with. These files 'included' the file 'star3do.res', which itself included +'star3do.typ'. + +There were also header files icode.h, igfxres.h, imusicre.h, isndres.h, +istrtab.h, resinst.h, respkg.h and restypes.h in each of the ship and comm +directories, which defined a few resource constants, which were presumably also +generated from these .res files. + + +== Outtake not taken out == + +There was an outtake accidentally left in the original speech for the Druuge. +It can still be found at + http://sc2.svn.sourceforge.net/viewvc/*checkout*/sc2/trunk/sc2/content/comm/druuge/druug011.ogg?revision=133&pathrev=1113 + + +== Original title screen and menu == + +The original title screen -- which included the text 'Star Control' and +'Accolade' and could hence not be used in UQM -- can be found at + http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/content/lbm/title.tga?revision=6&pathrev=6 +The original main menu (which did not include 'setup' or 'quit' options) +can be found at + http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/content/lbm/newgame0.tga?revision=6&pathrev=6 + + Deleted: trunk/sc2/src/uqm/comm/arilou/arilou.res =================================================================== --- trunk/sc2/src/uqm/comm/arilou/arilou.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/arilou.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/arilou - -PACKAGE ARILOU_PACKAGE arilou.con - GFXRES ARILOU_PMAP_ANIM arilou.ani - FONTRES ARILOU_FONT arilou.fon - MUSICRES ARILOU_MUSIC arilou.mod - STRTAB ARILOU_CONVERSATION_PHRASES arilou.txt - Deleted: trunk/sc2/src/uqm/comm/arilou/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ARILOU_FONT "comm.arilou.font" Deleted: trunk/sc2/src/uqm/comm/arilou/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ARILOU_COLOR_MAP "comm.arilou.colortable" -#define ARILOU_PMAP_ANIM "comm.arilou.graphics" Deleted: trunk/sc2/src/uqm/comm/arilou/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ARILOU_MUSIC "comm.arilou.music" Deleted: trunk/sc2/src/uqm/comm/arilou/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ARILOU_CONVERSATION_PHRASES "comm.arilou.dialogue" Modified: trunk/sc2/src/uqm/comm/arilou/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define ARILOU_COLOR_MAP "comm.arilou.colortable" +#define ARILOU_PMAP_ANIM "comm.arilou.graphics" +#define ARILOU_FONT "comm.arilou.font" +#define ARILOU_CONVERSATION_PHRASES "comm.arilou.dialogue" +#define ARILOU_MUSIC "comm.arilou.music" Deleted: trunk/sc2/src/uqm/comm/arilou/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - ARILOU_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/arilou/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/arilou/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/arilou/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/blackur/blackur.res =================================================================== --- trunk/sc2/src/uqm/comm/blackur/blackur.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/blackur.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/blackur - -PACKAGE BLACKURQ_PACKAGE blackur.con - GFXRES BLACKURQ_PMAP_ANIM blackur.ani - FONTRES BLACKURQ_FONT blackur.fon - MUSICRES BLACKURQ_MUSIC blackur.mod - STRTAB BLACKURQ_CONVERSATION_PHRASES blackur.txt - Deleted: trunk/sc2/src/uqm/comm/blackur/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define BLACKURQ_FONT "comm.kohrah.font" Deleted: trunk/sc2/src/uqm/comm/blackur/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define BLACKURQ_PMAP_ANIM "comm.kohrah.graphics" Deleted: trunk/sc2/src/uqm/comm/blackur/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define BLACKURQ_MUSIC "comm.kohrah.music" Deleted: trunk/sc2/src/uqm/comm/blackur/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define BLACKURQ_COLOR_MAP "comm.kohrah.colortable" -#define BLACKURQ_CONVERSATION_PHRASES "comm.kohrah.dialogue" Modified: trunk/sc2/src/uqm/comm/blackur/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define BLACKURQ_PMAP_ANIM "comm.kohrah.graphics" +#define BLACKURQ_FONT "comm.kohrah.font" +#define BLACKURQ_COLOR_MAP "comm.kohrah.colortable" +#define BLACKURQ_CONVERSATION_PHRASES "comm.kohrah.dialogue" +#define BLACKURQ_MUSIC "comm.kohrah.music" Deleted: trunk/sc2/src/uqm/comm/blackur/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - BLACKURQ_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/blackur/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/blackur/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/blackur/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/chmmr/chmmr.res =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/chmmr.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/chmmr.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/chmmr - -PACKAGE CHMMR_PACKAGE chmmr.con - GFXRES CHMMR_PMAP_ANIM chmmr.ani - FONTRES CHMMR_FONT chmmr.fon - MUSICRES CHMMR_MUSIC chmmr.mod - STRTAB CHMMR_CONVERSATION_PHRASES chmmr.txt - STRTAB CHMMR_COLOR_MAP chmmr.ct Deleted: trunk/sc2/src/uqm/comm/chmmr/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define CHMMR_FONT "comm.chmmr.font" Deleted: trunk/sc2/src/uqm/comm/chmmr/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define CHMMR_PMAP_ANIM "comm.chmmr.graphics" Deleted: trunk/sc2/src/uqm/comm/chmmr/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define CHMMR_MUSIC "comm.chmmr.music" Deleted: trunk/sc2/src/uqm/comm/chmmr/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define CHMMR_COLOR_MAP "comm.chmmr.colortable" -#define CHMMR_CONVERSATION_PHRASES "comm.chmmr.dialogue" Modified: trunk/sc2/src/uqm/comm/chmmr/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define CHMMR_PMAP_ANIM "comm.chmmr.graphics" +#define CHMMR_FONT "comm.chmmr.font" +#define CHMMR_COLOR_MAP "comm.chmmr.colortable" +#define CHMMR_CONVERSATION_PHRASES "comm.chmmr.dialogue" +#define CHMMR_MUSIC "comm.chmmr.music" Deleted: trunk/sc2/src/uqm/comm/chmmr/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - CHMMR_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/chmmr/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/chmmr/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/comandr/comandr.res =================================================================== --- trunk/sc2/src/uqm/comm/comandr/comandr.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/comandr.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,15 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/comandr -PACKAGE COMMANDER_PACKAGE comandr.con - GFXRES COMMANDER_PMAP_ANIM comandr.ani - FONTRES COMMANDER_FONT comandr.fon - MUSICRES COMMANDER_MUSIC comandr.mod - STRTAB COMMANDER_COLOR_MAP comandr.ct - -PACKAGE COMMANDER_PHRASE_PACKAGE comandr.con - STRTAB COMMANDER_CONVERSATION_PHRASES comandr.txt - -PATH comm/starbas -PACKAGE STARBASE_PHRASE_PACKAGE comandr.con - STRTAB STARBASE_CONVERSATION_PHRASES starbas.txt Deleted: trunk/sc2/src/uqm/comm/comandr/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define COMMANDER_FONT "comm.commander.font" Deleted: trunk/sc2/src/uqm/comm/comandr/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define COMMANDER_PMAP_ANIM "comm.commander.graphics" Deleted: trunk/sc2/src/uqm/comm/comandr/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,7 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define COMMANDER_LOWPOW_MUSIC "comm.commander.lowpower.music" -#define COMMANDER_MUSIC "comm.commander.music" -#define STARBASE_ALT_MUSIC "comm.starbase.music" Deleted: trunk/sc2/src/uqm/comm/comandr/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,7 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define COMMANDER_COLOR_MAP "comm.commander.colortable" -#define COMMANDER_CONVERSATION_PHRASES "comm.commander.dialogue" -#define STARBASE_CONVERSATION_PHRASES "comm.starbase.dialogue" Modified: trunk/sc2/src/uqm/comm/comandr/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,8 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define COMMANDER_PMAP_ANIM "comm.commander.graphics" +#define COMMANDER_FONT "comm.commander.font" +#define COMMANDER_COLOR_MAP "comm.commander.colortable" +#define COMMANDER_CONVERSATION_PHRASES "comm.commander.dialogue" +#define STARBASE_CONVERSATION_PHRASES "comm.starbase.dialogue" +#define COMMANDER_LOWPOW_MUSIC "comm.commander.lowpower.music" +#define COMMANDER_MUSIC "comm.commander.music" +#define STARBASE_ALT_MUSIC "comm.starbase.music" Deleted: trunk/sc2/src/uqm/comm/comandr/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,9 +0,0 @@ -enum -{ - COMMANDER_PACKAGE = 1, - COMMANDER_PHRASE_PACKAGE, - STARBASE_PHRASE_PACKAGE, - STARBASE_MUSIC_PACKAGE, - COMMANDER_LOWPOW_PACKAGE, -}; - Deleted: trunk/sc2/src/uqm/comm/comandr/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/comandr/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/comandr/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/druuge/druuge.res =================================================================== --- trunk/sc2/src/uqm/comm/druuge/druuge.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/druuge.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/druuge - -PACKAGE DRUUGE_PACKAGE druuge.con - GFXRES DRUUGE_PMAP_ANIM druuge.ani - FONTRES DRUUGE_FONT druuge.fon - MUSICRES DRUUGE_MUSIC druuge.mod - STRTAB DRUUGE_CONVERSATION_PHRASES druuge.txt - Deleted: trunk/sc2/src/uqm/comm/druuge/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define DRUUGE_FONT "comm.druuge.font" Deleted: trunk/sc2/src/uqm/comm/druuge/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define DRUUGE_PMAP_ANIM "comm.druuge.graphics" Deleted: trunk/sc2/src/uqm/comm/druuge/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define DRUUGE_MUSIC "comm.druuge.music" Deleted: trunk/sc2/src/uqm/comm/druuge/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define DRUUGE_COLOR_MAP "comm.druuge.colortable" -#define DRUUGE_CONVERSATION_PHRASES "comm.druuge.dialogue" Modified: trunk/sc2/src/uqm/comm/druuge/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define DRUUGE_PMAP_ANIM "comm.druuge.graphics" +#define DRUUGE_FONT "comm.druuge.font" +#define DRUUGE_COLOR_MAP "comm.druuge.colortable" +#define DRUUGE_CONVERSATION_PHRASES "comm.druuge.dialogue" +#define DRUUGE_MUSIC "comm.druuge.music" Deleted: trunk/sc2/src/uqm/comm/druuge/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - DRUUGE_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/druuge/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/druuge/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/druuge/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/ilwrath/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ILWRATH_FONT "comm.ilwrath.font" Deleted: trunk/sc2/src/uqm/comm/ilwrath/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ILWRATH_PMAP_ANIM "comm.ilwrath.graphics" Deleted: trunk/sc2/src/uqm/comm/ilwrath/ilwrath.res =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/ilwrath.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/ilwrath.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/ilwrath - -PACKAGE ILWRATH_PACKAGE ilwrath.con - GFXRES ILWRATH_PMAP_ANIM ilwrath.ani - FONTRES ILWRATH_FONT ilwrath.fon - MUSICRES ILWRATH_MUSIC ilwrath.mod - STRTAB ILWRATH_CONVERSATION_PHRASES ilwrath.txt - Deleted: trunk/sc2/src/uqm/comm/ilwrath/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ILWRATH_MUSIC "comm.ilwrath.music" Deleted: trunk/sc2/src/uqm/comm/ilwrath/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ILWRATH_COLOR_MAP "comm.ilwrath.colortable" -#define ILWRATH_CONVERSATION_PHRASES "comm.ilwrath.dialogue" Modified: trunk/sc2/src/uqm/comm/ilwrath/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define ILWRATH_PMAP_ANIM "comm.ilwrath.graphics" +#define ILWRATH_FONT "comm.ilwrath.font" +#define ILWRATH_COLOR_MAP "comm.ilwrath.colortable" +#define ILWRATH_CONVERSATION_PHRASES "comm.ilwrath.dialogue" +#define ILWRATH_MUSIC "comm.ilwrath.music" Deleted: trunk/sc2/src/uqm/comm/ilwrath/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - ILWRATH_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/ilwrath/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/ilwrath/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/ilwrath/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/melnorm/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MELNORME_FONT "comm.melnorme.font" Deleted: trunk/sc2/src/uqm/comm/melnorm/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MELNORME_PMAP_ANIM "comm.melnorme.graphics" Deleted: trunk/sc2/src/uqm/comm/melnorm/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MELNORME_MUSIC "comm.melnorme.music" Deleted: trunk/sc2/src/uqm/comm/melnorm/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MELNORME_COLOR_MAP "comm.melnorme.colortable" -#define MELNORME_CONVERSATION_PHRASES "comm.melnorme.dialogue" Deleted: trunk/sc2/src/uqm/comm/melnorm/melnorm.res =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/melnorm - -PACKAGE MELNORME_PACKAGE melnorm.con - GFXRES MELNORME_PMAP_ANIM melnorm.ani - FONTRES MELNORME_FONT melnorm.fon - MUSICRES MELNORME_MUSIC melnorm.mod - STRTAB MELNORME_CONVERSATION_PHRASES melnorm.txt - STRTAB MELNORME_COLOR_MAP melnorm.ct Modified: trunk/sc2/src/uqm/comm/melnorm/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define MELNORME_PMAP_ANIM "comm.melnorme.graphics" +#define MELNORME_FONT "comm.melnorme.font" +#define MELNORME_COLOR_MAP "comm.melnorme.colortable" +#define MELNORME_CONVERSATION_PHRASES "comm.melnorme.dialogue" +#define MELNORME_MUSIC "comm.melnorme.music" Deleted: trunk/sc2/src/uqm/comm/melnorm/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - MELNORME_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/melnorm/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/melnorm/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/mycon/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MYCON_FONT "comm.mycon.font" Deleted: trunk/sc2/src/uqm/comm/mycon/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MYCON_PMAP_ANIM "comm.mycon.graphics" Deleted: trunk/sc2/src/uqm/comm/mycon/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MYCON_MUSIC "comm.mycon.music" Deleted: trunk/sc2/src/uqm/comm/mycon/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define MYCON_COLOR_MAP "comm.mycon.colortable" -#define MYCON_CONVERSATION_PHRASES "comm.mycon.dialogue" Deleted: trunk/sc2/src/uqm/comm/mycon/mycon.res =================================================================== --- trunk/sc2/src/uqm/comm/mycon/mycon.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/mycon.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/mycon - -PACKAGE MYCON_PACKAGE mycon.con - GFXRES MYCON_PMAP_ANIM mycon.ani - FONTRES MYCON_FONT mycon.fon - MUSICRES MYCON_MUSIC mycon.mod - STRTAB MYCON_CONVERSATION_PHRASES mycon.txt - Modified: trunk/sc2/src/uqm/comm/mycon/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define MYCON_PMAP_ANIM "comm.mycon.graphics" +#define MYCON_FONT "comm.mycon.font" +#define MYCON_COLOR_MAP "comm.mycon.colortable" +#define MYCON_CONVERSATION_PHRASES "comm.mycon.dialogue" +#define MYCON_MUSIC "comm.mycon.music" Deleted: trunk/sc2/src/uqm/comm/mycon/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - MYCON_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/mycon/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/mycon/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/mycon/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/orz/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ORZ_FONT "comm.orz.font" Deleted: trunk/sc2/src/uqm/comm/orz/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ORZ_PMAP_ANIM "comm.orz.graphics" Deleted: trunk/sc2/src/uqm/comm/orz/imusicre.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/imusicre.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/imusicre.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ORZ_MUSIC "comm.orz.music" Deleted: trunk/sc2/src/uqm/comm/orz/istrtab.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/istrtab.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/istrtab.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,6 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define ORZ_COLOR_MAP "comm.orz.colortable" -#define ORZ_CONVERSATION_PHRASES "comm.orz.dialogue" Deleted: trunk/sc2/src/uqm/comm/orz/orz.res =================================================================== --- trunk/sc2/src/uqm/comm/orz/orz.res 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/orz.res 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,10 +0,0 @@ -INCLUDE ../../star3do.typ - -PATH comm/orz - -PACKAGE ORZ_PACKAGE orz.con - GFXRES ORZ_PMAP_ANIM orz.ani - FONTRES ORZ_FONT orz.fon - MUSICRES ORZ_MUSIC orz.mod - STRTAB ORZ_CONVERSATION_PHRASES orz.txt - STRTAB ORZ_COLOR_MAP orz.ct Modified: trunk/sc2/src/uqm/comm/orz/resinst.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/resinst.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/resinst.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,4 +1,5 @@ -#include "igfxres.h" -#include "ifontres.h" -#include "istrtab.h" -#include "imusicre.h" +#define ORZ_PMAP_ANIM "comm.orz.graphics" +#define ORZ_FONT "comm.orz.font" +#define ORZ_COLOR_MAP "comm.orz.colortable" +#define ORZ_CONVERSATION_PHRASES "comm.orz.dialogue" +#define ORZ_MUSIC "comm.orz.music" Deleted: trunk/sc2/src/uqm/comm/orz/respkg.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/respkg.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/respkg.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -enum -{ - ORZ_PACKAGE = 1 -}; - Deleted: trunk/sc2/src/uqm/comm/orz/restypes.h =================================================================== --- trunk/sc2/src/uqm/comm/orz/restypes.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/orz/restypes.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,17 +0,0 @@ -#ifndef _RESTYPES_H -#define _RESTYPES_H - -enum -{ - KEY_CONFIG = 1, - GFXRES, - FONTRES, - STRTAB, - SNDRES, - MUSICRES, - RES_INDEX, - CODE -}; - -#endif /* _RESTYPES_H */ - Deleted: trunk/sc2/src/uqm/comm/pkunk/ifontres.h =================================================================== --- trunk/sc2/src/uqm/comm/pkunk/ifontres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/pkunk/ifontres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define PKUNK_FONT "comm.pkunk.font" Deleted: trunk/sc2/src/uqm/comm/pkunk/igfxres.h =================================================================== --- trunk/sc2/src/uqm/comm/pkunk/igfxres.h 2009-12-29 20:20:27 UTC (rev 3493) +++ trunk/sc2/src/uqm/comm/pkunk/igfxres.h 2009-12-30 01:00:14 UTC (rev 3494) @@ -1,5 +0,0 @@ -/* This file was auto-generated by the gen_resfiles utility and - should not be edited directly. Modify the master resource list - instead and regenerate. */ - -#define PKUNK_PMAP_ANIM "comm.pkunk.gr... [truncated message content] |