[Scummvm-cvs-logs] CVS: scummvm/bs2 icons.cpp,1.6,1.7 icons.h,1.1,1.2

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Wed Sep 17 10:17:35 CEST 2003


Update of /cvsroot/scummvm/scummvm/bs2
In directory sc8-pr-cvs1:/tmp/cvs-serv29504

Modified Files:
	icons.cpp icons.h 
Log Message:
cleanup


Index: icons.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/icons.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- icons.cpp	13 Sep 2003 12:03:29 -0000	1.6
+++ icons.cpp	17 Sep 2003 16:59:12 -0000	1.7
@@ -17,206 +17,212 @@
  * $Header$
  */
 
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "stdafx.h"
-#include "driver/driver96.h"
-#include "console.h"
+#include "defs.h"
 #include "icons.h"
 #include "interpreter.h"
-#include "logic.h"
 #include "mouse.h"
-#include "object.h"
 
-//------------------------------------------------------------------------------------
+// tempory list
 menu_object temp_list[TOTAL_engine_pockets];
-uint32	total_temp=0;	//tempory list
+uint32 total_temp = 0;
 
 menu_object master_menu_list[TOTAL_engine_pockets];
-uint32	total_masters=0;
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------
-int32 FN_add_menu_object(int32 *params)	//Tony1Oct96
-{
-//param	0 pointer to a menu_object structure to copy down
+uint32 total_masters=0;
 
-//	Zdebug("FN_add_menu_object icon res");
+int32 FN_add_menu_object(int32 *params) {	// Tony1Oct96
+	// param	0 pointer to a menu_object structure to copy down
+
+	// Zdebug("FN_add_menu_object icon res");
 
 #ifdef _SWORD2_DEBUG
 	if (total_temp == TOTAL_engine_pockets)
-		Con_fatal_error("TOTAL_engine_pockets exceeded! (%s line %u)",__FILE__,__LINE__);
+		Con_fatal_error("TOTAL_engine_pockets exceeded! (%s line %u)", __FILE__, __LINE__);
 #endif
 
-//	copy the structure to our in-the-engine list
-	memcpy( &temp_list[total_temp], (uint8*) *params, sizeof(menu_object));	//
+	// copy the structure to our in-the-engine list
+	memcpy(&temp_list[total_temp], (uint8 *) params[0], sizeof(menu_object));
 	total_temp++;
 
-	return(IR_CONT);	// script continue
+	// script continue
+	return IR_CONT;
 }
-//------------------------------------------------------------------------------------
-int32 FN_refresh_inventory(int32 *params)	// (James28aug97)
-{
+
+int32 FN_refresh_inventory(int32 *params) {	// (James28aug97)
 	// called from 'menu_look_or_combine' script in 'menu_master' object
-	// to update the menu to display a combined object while George runs voice-over
-	// Note that 'object_held' must be set to the graphic of the combined object
+	// to update the menu to display a combined object while George runs
+	// voice-over. Note that 'object_held' must be set to the graphic of
+	// the combined object
 
-	COMBINE_BASE=0;			// can reset this now
+	// can reset this now
+	COMBINE_BASE = 0;
 
-	examining_menu_icon=1;	// so that the icon in 'object_held' is coloured while the rest are grey
+	// so that the icon in 'object_held' is coloured while the rest are
+	// grey
+	examining_menu_icon = 1;
 	Build_top_menu();
- 	examining_menu_icon=0;
+ 	examining_menu_icon = 0;
 
-	return(IR_CONT);	// script continue
+	// script continue
+	return IR_CONT;
 }
-//------------------------------------------------------------------------------------
-void	Build_top_menu(void)	//Tony19Nov96
-{
- // create and start the inventory menu - NOW AT THE BOTTOM OF THE SCREEN!
-
-	uint32	null_pc=0;
-	uint32	j,k;
-	uint8	icon_coloured;
-	uint8	*icon;
-	uint8	*head;
-	uint32	res;
 
-	total_temp=0;	//reset temp list which will be totally rebuilt
+void Build_top_menu(void) {	// Tony19Nov96
+	// create and start the inventory menu - NOW AT THE BOTTOM OF THE
+	// SCREEN!
 
+	uint32 null_pc = 0;
+	uint32 j, k;
+	uint8 icon_coloured;
+	uint8 *icon;
+	uint8 *head;
+	uint32 res;
 
+	// reset temp list which will be totally rebuilt
+	total_temp = 0;
 
-//	Zdebug("\nbuild top menu %d", total_masters);
+	// Zdebug("\nbuild top menu %d", total_masters);
 
+	// clear the temp list before building a new temp list in-case list
+	// gets smaller. check each master
 
-//clear the temp list before building a new temp list in-case list gets smaller
-	for	(j=0;j<TOTAL_engine_pockets;j++)	//check each master
-		temp_list[j].icon_resource=0;	//
+	for (j = 0; j < TOTAL_engine_pockets; j++)
+		temp_list[j].icon_resource = 0;
 
+	// Call menu builder script which will register all carried menu
+	// objects. Run the 'build_menu' script in the 'menu_master' object
 
-//call menu builder script which will register all carried menu objects
 	head = res_man.Res_open(MENU_MASTER_OBJECT);
-	RunScript( (char*)head, (char*)head, &null_pc );	// run the 'build_menu' script in the 'menu_master' object
+	RunScript((char*) head, (char*) head, &null_pc);
 	res_man.Res_close(MENU_MASTER_OBJECT);
 
-//compare new with old
-//anything in master thats not in new gets removed from master - if found in new too, remove from temp
+	// Compare new with old. Anything in master thats not in new gets
+	// removed from master - if found in new too, remove from temp
 
-	if	(total_masters)
-	{
-		for	(j=0;j<total_masters;j++)	//check each master
-		{
-			for	(k=0;k<TOTAL_engine_pockets;k++)
-			{
-				res=0;
-				if	(master_menu_list[j].icon_resource == temp_list[k].icon_resource)	//if master is in temp
-				{
-					temp_list[k].icon_resource=0;	//kill it in the temp
-					res=1;
+	if (total_masters) {
+		// check each master
+
+		for (j = 0; j < total_masters; j++) {
+			for (k = 0; k < TOTAL_engine_pockets; k++) {
+				res = 0;
+				// if master is in temp
+				if (master_menu_list[j].icon_resource == temp_list[k].icon_resource) {
+					// kill it in the temp
+					temp_list[k].icon_resource = 0;
+					res = 1;
 					break;
 				}
 			}
-			if	(!res)
-			{	master_menu_list[j].icon_resource=0;	//otherwise not in temp so kill in main
-//				Zdebug("Killed menu %d",j);
+			if (!res) {
+				// otherwise not in temp so kill in main
+				master_menu_list[j].icon_resource = 0;
+				// Zdebug("Killed menu %d",j);
 			}
 		}
 	}
 
-//merge master downwards
+	// merge master downwards
 
-	total_masters=0;
-	for	(j=0;j<TOTAL_engine_pockets;j++)	//check each master slot
-	{
-		if	((master_menu_list[j].icon_resource)&&(j!=total_masters))	//not current end - meaning out over the end so move down
-		{
-			memcpy( &master_menu_list[total_masters++], &master_menu_list[j], sizeof(menu_object));	//
-			master_menu_list[j].icon_resource=0;	//moved down now so kill here
-		}
-		else if (master_menu_list[j].icon_resource)	//skip full slots
+	total_masters = 0;
+
+	//check each master slot
+
+	for (j = 0; j < TOTAL_engine_pockets; j++) {
+		// not current end - meaning out over the end so move down
+		if (master_menu_list[j].icon_resource && j != total_masters) {
+			memcpy(&master_menu_list[total_masters++], &master_menu_list[j], sizeof(menu_object));
+
+			// moved down now so kill here
+			master_menu_list[j].icon_resource = 0;
+		} else if (master_menu_list[j].icon_resource) {
+			// skip full slots
 			total_masters++;
+		}
 	}
 
-//add those new to menu still in temp but not yet in master to the end of the master
-	for	(j=0;j<TOTAL_engine_pockets;j++)	//check each master slot
-		if	(temp_list[j].icon_resource)	//here's a new temp
-			memcpy( &master_menu_list[total_masters++], &temp_list[j], sizeof(menu_object));	//
+	// add those new to menu still in temp but not yet in master to the
+	// end of the master
 
+	// check each master slot
 
-//init top menu from master list
-	for	(j=0;j<15;j++)
-	{
-		if	(master_menu_list[j].icon_resource)
-		{
-			res = master_menu_list[j].icon_resource;	// 'res' is now the resource id of the icon
+	for (j = 0; j < TOTAL_engine_pockets; j++) {
+		if (temp_list[j].icon_resource) {
+			// here's a new temp
+			memcpy(&master_menu_list[total_masters++], &temp_list[j], sizeof(menu_object));
+		}
+	}
 
-			//-----------------------------------------------------------------------------------------------------
-			// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR 'EXAMINE' - SELECTION COLOURED, THE REST GREYED OUT
+	// init top menu from master list
 
-			if (examining_menu_icon)		// '1' when examining a menu-icon ('OBJECT_HELD' is the resource of the icon being examined)
-			{
-				if (res == OBJECT_HELD)		// if this is the icon being examined, make it coloured
-					icon_coloured=1;
-				else						// if not, grey this one out
-					icon_coloured=0;
-			}
-			//-----------------------------------------------------------------------------------------------------
-			// WHEN ONE MENU OBJECT IS BEING USED WITH ANOTHER - BOTH TO BE COLOURED, THE REST GREYED OUT
+	for (j = 0; j < 15; j++) {
+		if (master_menu_list[j].icon_resource) {
+			// 'res' is now the resource id of the icon
+			res = master_menu_list[j].icon_resource;
 
-			else if (COMBINE_BASE)	// resource of second icon clicked
-			{
-				if ((res == OBJECT_HELD)||(res == COMBINE_BASE))	// if this if either of the icons being combined...
-					icon_coloured=1;
+			if (examining_menu_icon) {
+				// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR
+				// 'EXAMINE' - SELECTION COLOURED, THE REST
+				// GREYED OUT
+
+				// If this is the icon being examined, make
+				// it coloured. If not, grey this one out.
+
+				if (res == OBJECT_HELD)
+					icon_coloured = 1;
 				else
-					icon_coloured=0;
-			}
-			//-----------------------------------------------------------------------------------------------------
-			// NORMAL ICON SELECTION - SELECTION GREYED OUT, THE REST COLOURED
+					icon_coloured = 0;
+			} else if (COMBINE_BASE) {
+				// WHEN ONE MENU OBJECT IS BEING USED WITH
+				// ANOTHER - BOTH TO BE COLOURED, THE REST
+				// GREYED OUT
 
-			else
-			{
-  				if (res == OBJECT_HELD)	// if this is the selction, grey it out
-					icon_coloured=0;
-				else						// if not, make it coloured
-					icon_coloured=1;
+				// if this if either of the icons being
+				// combined...
+
+				if (res == OBJECT_HELD || res == COMBINE_BASE)
+					icon_coloured = 1;
+				else
+					icon_coloured = 0;
+			} else {
+				// NORMAL ICON SELECTION - SELECTION GREYED
+				// OUT, THE REST COLOURED
+
+				// If this is the selction, grey it out. If
+				// not, make it coloured.
+
+  				if (res == OBJECT_HELD)
+					icon_coloured = 0;
+				else
+					icon_coloured = 1;
 			}
-		 
- 			//-----------------------------------------------------------------------------------------------------
 
+			icon = res_man.Res_open(master_menu_list[j].icon_resource) + sizeof(_standardHeader);
 
-			if (icon_coloured)	// coloured
-				icon = res_man.Res_open( master_menu_list[j].icon_resource ) + sizeof(_standardHeader) + RDMENU_ICONWIDE*RDMENU_ICONDEEP;
-			else				// greyed out
-				icon = res_man.Res_open( master_menu_list[j].icon_resource ) + sizeof(_standardHeader);
+			// The coloured icon is stored directly after the
+			// greyed out one.
+
+			if (icon_coloured)
+				icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
 
 			SetMenuIcon(RDMENU_BOTTOM, j, icon);
-			res_man.Res_close( res );
-		}
-		else
-		{
-			SetMenuIcon(RDMENU_BOTTOM, j, NULL);	//no icon here
-			//Zdebug(" NULL for %d", j);
+			res_man.Res_close(res);
+		} else {
+			// no icon here
+			SetMenuIcon(RDMENU_BOTTOM, j, NULL);
+			// Zdebug(" NULL for %d", j);
 		}
 	}
 
 	ShowMenu(RDMENU_BOTTOM);
-
 }
 
+void Build_system_menu(void) {	// Tony19Mar97
+	// start a fresh top system menu
 
+	uint8 *icon;
+	int j;
 
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------
-void	Build_system_menu(void)	//Tony19Mar97
-{
-//start a fresh top system menu
-
-	uint8	*icon;
-	int	j;
-
-	uint32	icon_list[5] =
-	{
+	uint32 icon_list[5] = {
 		OPTIONS_ICON,
 		QUIT_ICON,
 		SAVE_ICON,
@@ -224,22 +230,21 @@
 		RESTART_ICON
 	};
 
+	// build them all high in full colour - when one is clicked on all the
+	// rest will grey out
 
-	for	(j=0;j<5;j++)	//build them all high in full colour - when one is clicked on all the rest will grey out
-	{
-		if	((DEAD)&&(j==2))	//dead then SAVE not available
-			icon = res_man.Res_open( icon_list[j] ) + sizeof(_standardHeader);
+	for (j = 0; j < ARRAYSIZE(icon_list); j++) {
+		icon = res_man.Res_open(icon_list[j]) + sizeof(_standardHeader);
+		
+		// The only case when an icon is grayed is when the player
+		// is dead. Then SAVE is not available.
+
+		if (!DEAD || icon_list[j] != SAVE_ICON)
+			icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
 
-		else	icon = res_man.Res_open( icon_list[j] ) + sizeof(_standardHeader) + RDMENU_ICONWIDE*RDMENU_ICONDEEP;
 		SetMenuIcon(RDMENU_TOP, j, icon);
-		res_man.Res_close( icon_list[j] );
+		res_man.Res_close(icon_list[j]);
 	}
 
-
 	ShowMenu(RDMENU_TOP);
 }
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------
-//------------------------------------------------------------------------------------

Index: icons.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/icons.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- icons.h	28 Jul 2003 01:44:37 -0000	1.1
+++ icons.h	17 Sep 2003 16:59:12 -0000	1.2
@@ -20,23 +20,21 @@
 #ifndef	_ICONS
 #define	_ICONS
 
+#include "object.h"
 
-//#include	"src\driver96.h"
-#include	"object.h"
-
-#define	MENU_MASTER_OBJECT	44
-#define	TOTAL_subjects	375-256+1	//the speech subject bar
-#define	TOTAL_engine_pockets	15+10	// +10 for overflow
+#define MENU_MASTER_OBJECT	44
+#define TOTAL_subjects		(375 - 256 + 1)	// the speech subject bar
+#define TOTAL_engine_pockets	(15 + 10)	// +10 for overflow
 
-typedef	struct
-{
-	int32	icon_resource;		// icon graphic graphic
-	int32	luggage_resource;	// luggage icon resource (for attaching to mouse pointer)
-} menu_object;	//define these in a script and then register them with the system
+// define these in a script and then register them with the system
+typedef	struct {
+	int32 icon_resource;	// icon graphic graphic
+	int32 luggage_resource;	// luggage icon resource (for attaching to mouse pointer)
+} menu_object;
 
-extern	menu_object master_menu_list[TOTAL_engine_pockets];
+extern menu_object master_menu_list[TOTAL_engine_pockets];
 
-void	Build_top_menu(void);	//Tony19Nov96
-void	Build_system_menu(void);	//Tony19Mar97
+void Build_top_menu(void);	// Tony19Nov96
+void Build_system_menu(void);	// Tony19Mar97
 
 #endif





More information about the Scummvm-git-logs mailing list