[Scummvm-cvs-logs] SF.net SVN: scummvm:[38317] scummvm/trunk/engines/sci/engine

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Feb 15 23:28:13 CET 2009


Revision: 38317
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38317&view=rev
Author:   fingolfin
Date:     2009-02-15 22:28:12 +0000 (Sun, 15 Feb 2009)

Log Message:
-----------
SCI: Run astyle to make the code be more compliant with our Code Formatting Guidelines: engine dir

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/gc.cpp
    scummvm/trunk/engines/sci/engine/grammar.cpp
    scummvm/trunk/engines/sci/engine/heap.cpp
    scummvm/trunk/engines/sci/engine/heap.h
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel_compat.h
    scummvm/trunk/engines/sci/engine/kernel_types.h
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/klists.cpp
    scummvm/trunk/engines/sci/engine/kmath.cpp
    scummvm/trunk/engines/sci/engine/kmenu.cpp
    scummvm/trunk/engines/sci/engine/kmovement.cpp
    scummvm/trunk/engines/sci/engine/kpathing.cpp
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/engine/kstring.cpp
    scummvm/trunk/engines/sci/engine/message.cpp
    scummvm/trunk/engines/sci/engine/message.h
    scummvm/trunk/engines/sci/engine/said.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/scriptconsole.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/sys_strings.cpp
    scummvm/trunk/engines/sci/engine/vm.cpp

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -39,18 +39,17 @@
 
 
 static int
-_init_vocabulary(state_t *s) /* initialize vocabulary and related resources */
-{
+_init_vocabulary(state_t *s) { /* initialize vocabulary and related resources */
 	s->parser_lastmatch_word = SAID_NO_MATCH;
 	s->parser_rules = NULL;
 
-	sciprintf("Initializing vocabulary\n");	
-	
-	if ((s->resmgr->sci_version < SCI_VERSION_01_VGA)&&(s->parser_words = vocab_get_words(s->resmgr, &(s->parser_words_nr)))) {
+	sciprintf("Initializing vocabulary\n");
+
+	if ((s->resmgr->sci_version < SCI_VERSION_01_VGA) && (s->parser_words = vocab_get_words(s->resmgr, &(s->parser_words_nr)))) {
 		s->parser_suffices = vocab_get_suffices(s->resmgr, &(s->parser_suffices_nr));
 		if ((s->parser_branches = vocab_get_branches(s->resmgr, &(s->parser_branches_nr))))
-		    /* Now build a GNF grammar out of this */
-		    s->parser_rules = vocab_build_gnf(s->parser_branches, s->parser_branches_nr);
+			/* Now build a GNF grammar out of this */
+			s->parser_rules = vocab_build_gnf(s->parser_branches, s->parser_branches_nr);
 
 	} else {
 		sciprintf("Assuming that this game does not use a parser.\n");
@@ -76,8 +75,7 @@
 
 extern int _allocd_rules;
 static void
-_free_vocabulary(state_t *s)
-{
+_free_vocabulary(state_t *s) {
 	sciprintf("Freeing vocabulary\n");
 
 	if (s->parser_words) {
@@ -99,8 +97,7 @@
 
 
 static int
-_init_graphics_input(state_t *s)
-{
+_init_graphics_input(state_t *s) {
 	s->pic_priority_table = NULL;
 	s->pics = NULL;
 	s->pics_nr = 0;
@@ -108,8 +105,7 @@
 }
 
 static void
-_sci1_alloc_system_colors(state_t *s)
-{
+_sci1_alloc_system_colors(state_t *s) {
 	gfx_color_t white;
 	gfx_color_t black;
 
@@ -129,8 +125,7 @@
 }
 
 int
-_reset_graphics_input(state_t *s)
-{
+_reset_graphics_input(state_t *s) {
 	resource_t *resource;
 	int font_nr;
 	gfx_color_t transparent;
@@ -141,33 +136,32 @@
 
 		for (i = 0; i < 16; i++) {
 			if (gfxop_set_color(s->gfx_state, &(s->ega_colors[i]),
-					    gfx_sci0_image_colors[sci0_palette][i].r,
-					    gfx_sci0_image_colors[sci0_palette][i].g,
-					    gfx_sci0_image_colors[sci0_palette][i].b,
-					    0, -1, -1))
+			                    gfx_sci0_image_colors[sci0_palette][i].r,
+			                    gfx_sci0_image_colors[sci0_palette][i].g,
+			                    gfx_sci0_image_colors[sci0_palette][i].b,
+			                    0, -1, -1))
 				return 1;
 			gfxop_set_system_color(s->gfx_state, &(s->ega_colors[i]));
 		}
-	} else
-	{
+	} else {
 		/* Check for Amiga palette file. */
 		FILE *f = sci_fopen("spal", "rb");
 		if (f) {
-			s->gfx_state->resstate->static_palette = 
-			  gfxr_read_pal1_amiga(&s->gfx_state->resstate->static_palette_entries, f);
+			s->gfx_state->resstate->static_palette =
+			    gfxr_read_pal1_amiga(&s->gfx_state->resstate->static_palette_entries, f);
 			fclose(f);
 			_sci1_alloc_system_colors(s);
 		} else {
 			resource = scir_find_resource(s->resmgr, sci_palette, 999, 1);
 			if (resource) {
-				if (s->version < SCI_VERSION(1,001,000))
-					s->gfx_state->resstate->static_palette = 
-					  gfxr_read_pal1(999, &s->gfx_state->resstate->static_palette_entries, 
-							 resource->data, resource->size); 
-			    	else
-					s->gfx_state->resstate->static_palette = 
-					  gfxr_read_pal11(999, &s->gfx_state->resstate->static_palette_entries, 
-							    resource->data, resource->size); 
+				if (s->version < SCI_VERSION(1, 001, 000))
+					s->gfx_state->resstate->static_palette =
+					    gfxr_read_pal1(999, &s->gfx_state->resstate->static_palette_entries,
+					                   resource->data, resource->size);
+				else
+					s->gfx_state->resstate->static_palette =
+					    gfxr_read_pal11(999, &s->gfx_state->resstate->static_palette_entries,
+					                    resource->data, resource->size);
 				_sci1_alloc_system_colors(s);
 				scir_unlock_resource(s->resmgr, resource, sci_palette, 999);
 			} else
@@ -195,7 +189,8 @@
 	s->priority_first = 42; /* Priority zone 0 ends here */
 
 	if (s->version < SCI_VERSION_FTU_PRIORITY_14_ZONES)
-		s->priority_last = 200; else
+		s->priority_last = 200;
+	else
 		s->priority_last = 190;
 
 	font_nr = -1;
@@ -214,8 +209,7 @@
 	s->iconbar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 200), s->ega_colors[0], transparent);
 	s->iconbar_port->flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH;
 
-	if (s->resmgr->sci_version >= SCI_VERSION_01_VGA)
-	{
+	if (s->resmgr->sci_version >= SCI_VERSION_01_VGA) {
 		// This bit sets the foreground and background colors in VGA SCI games
 #if 0
 		gfx_color_t fgcolor;
@@ -225,12 +219,12 @@
 		fgcolor.mask = GFX_MASK_VISUAL;
 		bgcolor.visual = s->gfx_state->resstate->static_palette[255];
 		bgcolor.mask = GFX_MASK_VISUAL;
-		s->titlebar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 10), 
-						 fgcolor, bgcolor);
+		s->titlebar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 10),
+		                                 fgcolor, bgcolor);
 #endif
 	} else
-		s->titlebar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 10), 
-						 s->ega_colors[0], s->ega_colors[15]);
+		s->titlebar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 10),
+		                                 s->ega_colors[0], s->ega_colors[15]);
 	s->titlebar_port->color.mask |= GFX_MASK_PRIORITY;
 	s->titlebar_port->color.priority = 11;
 	s->titlebar_port->bgcolor.mask |= GFX_MASK_PRIORITY;
@@ -259,8 +253,7 @@
 }
 
 int
-game_init_graphics(state_t *s)
-{
+game_init_graphics(state_t *s) {
 #ifndef WITH_PIC_SCALING
 	if (s->gfx_state->options->pic0_unscaled == 0)
 		sciprintf("WARNING: Pic scaling was disabled; your version of FreeSCI has no support for scaled pic drawing built in.\n");
@@ -272,8 +265,7 @@
 
 
 static void
-_free_graphics_input(state_t *s)
-{
+_free_graphics_input(state_t *s) {
 	sciprintf("Freeing graphics\n");
 
 	s->visual->widfree(GFXW(s->visual));
@@ -291,8 +283,7 @@
 /*------------------------------------------------------------*/
 
 int
-game_init_sound(state_t *s, int sound_flags)
-{
+game_init_sound(state_t *s, int sound_flags) {
 	if (s->resmgr->sci_version >= SCI_VERSION_01)
 		sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
 
@@ -305,8 +296,7 @@
 /* Maps a class ID to the script the corresponding class is contained in */
 /* Returns the script number suggested by vocab.996, or -1 if there's none */
 static int
-suggested_script(resource_t *res, unsigned int classId)
-{
+suggested_script(resource_t *res, unsigned int classId) {
 	int offset;
 	if (!res || classId >= res->size >> 2)
 		return -1;
@@ -317,9 +307,8 @@
 }
 
 
-int 
-test_cursor_style(state_t *s)
-{
+int
+test_cursor_style(state_t *s) {
 	int resource_nr = 0;
 	int ok = 0;
 
@@ -331,8 +320,7 @@
 }
 
 int
-create_class_table_sci11(state_t *s)
-{
+create_class_table_sci11(state_t *s) {
 	int scriptnr;
 	unsigned int seeker_offset;
 	char *seeker_ptr;
@@ -349,24 +337,22 @@
 
 	for (scriptnr = 0; scriptnr < 1000; scriptnr++) {
 		resource_t *heap = scir_find_resource(s->resmgr, sci_heap,
-						      scriptnr, 0);
+		                                      scriptnr, 0);
 
 		if (heap) {
 			int global_vars = getUInt16(heap->data + 2);
 
-			seeker_ptr = (char*)heap->data + 4 + global_vars*2;
-			seeker_offset = 4 + global_vars*2;
+			seeker_ptr = (char*)heap->data + 4 + global_vars * 2;
+			seeker_offset = 4 + global_vars * 2;
 
-			while (getUInt16((byte*)seeker_ptr) == SCRIPT_OBJECT_MAGIC_NUMBER)
-			{
-				if (getUInt16((byte*)seeker_ptr + 14) & SCRIPT_INFO_CLASS)
-				{
+			while (getUInt16((byte*)seeker_ptr) == SCRIPT_OBJECT_MAGIC_NUMBER) {
+				if (getUInt16((byte*)seeker_ptr + 14) & SCRIPT_INFO_CLASS) {
 					classnr = getUInt16((byte*)seeker_ptr + 10);
 					if (classnr >= s->classtable_size) {
 
 						if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) {
-							fprintf(stderr,"Invalid class number 0x%x in script.%d(0x%x), offset %04x\n",
-								classnr, scriptnr, scriptnr, seeker_offset);
+							fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n",
+							        classnr, scriptnr, scriptnr, seeker_offset);
 							return 1;
 						}
 
@@ -376,7 +362,7 @@
 
 						s->classtable_size = classnr + 1; /* Adjust maximum number of entries */
 					}
-					
+
 					s->classtable[classnr].reg.offset = seeker_offset;
 					s->classtable[classnr].reg.segment = 0;
 					s->classtable[classnr].script = scriptnr;
@@ -391,8 +377,7 @@
 	return 0;
 }
 static int
-create_class_table_sci0(state_t *s)
-{
+create_class_table_sci0(state_t *s) {
 	int scriptnr;
 	unsigned int seeker;
 	int classnr;
@@ -410,7 +395,7 @@
 	for (scriptnr = 0; scriptnr < 1000; scriptnr++) {
 		int objtype = 0;
 		resource_t *script = scir_find_resource(s->resmgr, sci_script,
-							scriptnr, 0);
+		                                        scriptnr, 0);
 
 		if (script) {
 			if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
@@ -442,8 +427,8 @@
 					if (classnr >= s->classtable_size) {
 
 						if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) {
-							fprintf(stderr,"Invalid class number 0x%x in script.%d(0x%x), offset %04x\n",
-								classnr, scriptnr, scriptnr, seeker);
+							fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n",
+							        classnr, scriptnr, scriptnr, seeker);
 							return 1;
 						}
 
@@ -481,15 +466,14 @@
 
 /* Architectural stuff: Init/Unintialize engine */
 int
-script_init_engine(state_t *s, sci_version_t version)
-{
+script_init_engine(state_t *s, sci_version_t version) {
 	int result;
 
-	s->max_version = SCI_VERSION(9,999,999); /* :-) */
+	s->max_version = SCI_VERSION(9, 999, 999); /* :-) */
 	s->min_version = 0; /* Set no real limits */
 	s->version = SCI_VERSION_DEFAULT_SCI0;
 	s->kernel_opt_flags = 0;
-	
+
 	if (!version) {
 		s->version_lock_flag = 0;
 	} else {
@@ -499,16 +483,15 @@
 
 	script_detect_versions(s);
 
-        if (s->version >= SCI_VERSION(1,001,000))
-		result = create_class_table_sci11(s); 
+	if (s->version >= SCI_VERSION(1, 001, 000))
+		result = create_class_table_sci11(s);
 	else
 		result = create_class_table_sci0(s);
-	
-	sm_init(&s->seg_manager, s->version >= SCI_VERSION(1,001,000));
+
+	sm_init(&s->seg_manager, s->version >= SCI_VERSION(1, 001, 000));
 	s->gc_countdown = GC_INTERVAL - 1;
 
-	if (result)
-	{
+	if (result) {
 		sciprintf("Failed to initialize class table\n");
 		return 1;
 	}
@@ -524,7 +507,7 @@
 
 
 	s->sys_strings = sm_allocate_sys_strings(&s->seg_manager,
-						 &s->sys_strings_segment);
+	                 &s->sys_strings_segment);
 	/* Allocate static buffer for savegame and CWD directories */
 	sys_string_acquire(s->sys_strings, SYS_STRING_SAVEDIR, "savedir", MAX_SAVE_DIR_SIZE);
 
@@ -561,7 +544,7 @@
 	/* Those two are used by FileIO for FIND_FIRST, FIND_NEXT */
 
 	if (s->version >= SCI_VERSION_FTU_LOFS_ABSOLUTE &&
-	    s->version < SCI_VERSION(1,001,000))
+	        s->version < SCI_VERSION(1, 001, 000))
 		sm_set_export_width(&s->seg_manager, 1);
 	else
 		sm_set_export_width(&s->seg_manager, 0);
@@ -576,14 +559,12 @@
 
 
 void
-script_set_gamestate_save_dir(state_t *s, const char* path)
-{
+script_set_gamestate_save_dir(state_t *s, const char* path) {
 	sys_string_set(s->sys_strings, SYS_STRING_SAVEDIR, path);
 }
 
 void
-script_free_vm_memory(state_t *s)
-{
+script_free_vm_memory(state_t *s) {
 	int i;
 
 	sciprintf("Freeing VM memory\n");
@@ -605,12 +586,11 @@
 }
 
 extern void
-free_kfunct_tables(state_t *s);
+	free_kfunct_tables(state_t *s);
 /* From kernel.c */
 
 void
-script_free_engine(state_t *s)
-{
+script_free_engine(state_t *s) {
 	script_free_vm_memory(s);
 
 	sciprintf("Freeing state-dependant data\n");
@@ -622,16 +602,15 @@
 }
 
 void
-script_free_breakpoints(state_t *s)
-{
+script_free_breakpoints(state_t *s) {
 	breakpoint_t *bp, *bp_next;
 
 	/* Free breakpoint list */
 	bp = s->bp_list;
 	while (bp) {
 		bp_next = bp->next;
-		if (bp->type == BREAK_SELECTOR) sci_free (bp->data.name);
-		free (bp);
+		if (bp->type == BREAK_SELECTOR) sci_free(bp->data.name);
+		free(bp);
 		bp = bp_next;
 	}
 
@@ -644,8 +623,7 @@
 
 
 int
-game_init(state_t *s)
-{
+game_init(state_t *s) {
 #ifdef __GNUC__XX
 #  warning "Fixme: Use new VM instantiation code all over the place"
 #endif
@@ -653,7 +631,7 @@
 	dstack_t *stack;
 
 	stack = sm_allocate_stack(&s->seg_manager, VM_STACK_SIZE,
-					      &s->stack_segment);
+	                          &s->stack_segment);
 	s->stack_base = stack->entries;
 	s->stack_top = s->stack_base + VM_STACK_SIZE;
 
@@ -701,8 +679,8 @@
 
 	if (!s->game_name) {
 		sciprintf("Error: script.000, export 0 ("PREG") does not\n"
-			  "  yield an object with a name -> sanity check failed\n",
-			  PRINT_REG(game_obj));
+		          "  yield an object with a name -> sanity check failed\n",
+		          PRINT_REG(game_obj));
 		return 1;
 	}
 
@@ -726,18 +704,17 @@
 }
 
 int
-game_exit(state_t *s)
-{
+game_exit(state_t *s) {
 	if (s->execution_stack) {
 		sci_free(s->execution_stack);
 	}
 
 	sfx_exit(&s->sound);
-/* Reinit because some other code depends on having a valid state */
-	game_init_sound(s, SFX_STATE_FLAG_NOSOUND); 
+	/* Reinit because some other code depends on having a valid state */
+	game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
 
 	sm_destroy(&s->seg_manager);
-	
+
 	if (s->synonyms_nr) {
 		sci_free(s->synonyms);
 		s->synonyms = NULL;

Modified: scummvm/trunk/engines/sci/engine/gc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/gc.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/gc.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -32,8 +32,7 @@
 } worklist_t;
 
 static worklist_t *
-fresh_worklist(worklist_t *old)
-{
+fresh_worklist(worklist_t *old) {
 	worklist_t *retval = (worklist_t*)sci_malloc(sizeof(worklist_t));
 	retval->used = 0;
 	retval->next = old;
@@ -41,14 +40,12 @@
 }
 
 static worklist_t *
-new_worklist()
-{
+new_worklist() {
 	return fresh_worklist(NULL);
 }
 
 static void
-worklist_push(worklist_t **wlp, reg_t_hash_map_ptr hashmap, reg_t reg)
-{
+worklist_push(worklist_t **wlp, reg_t_hash_map_ptr hashmap, reg_t reg) {
 	worklist_t *wl = *wlp;
 	char added;
 
@@ -71,14 +68,12 @@
 }
 
 static int
-worklist_has_next(worklist_t *wl)
-{
+worklist_has_next(worklist_t *wl) {
 	return (wl && wl->used);
 }
 
 static reg_t
-worklist_pop(worklist_t **wlp)
-{
+worklist_pop(worklist_t **wlp) {
 	worklist_t *wl = *wlp;
 	reg_t retval;
 
@@ -98,8 +93,7 @@
 }
 
 static void
-free_worklist(worklist_t *wl)
-{
+free_worklist(worklist_t *wl) {
 	if (wl) {
 		if (wl->next)
 			free_worklist(wl->next);
@@ -114,13 +108,12 @@
 } normaliser_t;
 
 void
-store_normalised(void *pre_normaliser, reg_t reg, int _)
-{
+store_normalised(void *pre_normaliser, reg_t reg, int _) {
 	seg_interface_t *interfce;
 	normaliser_t *normaliser = (normaliser_t *) pre_normaliser;
 	interfce = (reg.segment < normaliser->interfaces_nr)
-		? normaliser->interfaces[reg.segment]
-		: NULL;
+	           ? normaliser->interfaces[reg.segment]
+	           : NULL;
 
 	if (interfce) {
 		reg = interfce->find_canonic_address(interfce, reg);
@@ -129,8 +122,7 @@
 }
 
 static reg_t_hash_map_ptr
-normalise_hashmap_ptrs(reg_t_hash_map_ptr nonnormal_map, seg_interface_t **interfaces, int interfaces_nr)
-{
+normalise_hashmap_ptrs(reg_t_hash_map_ptr nonnormal_map, seg_interface_t **interfaces, int interfaces_nr) {
 	normaliser_t normaliser;
 
 	normaliser.normal_map = new_reg_t_hash_map();
@@ -148,15 +140,13 @@
 } worklist_manager_t;
 
 void
-add_outgoing_refs(void *pre_wm, reg_t addr)
-{
+add_outgoing_refs(void *pre_wm, reg_t addr) {
 	worklist_manager_t *wm = (worklist_manager_t *) pre_wm;
 	worklist_push(wm->worklist_ref, wm->nonnormal_map, addr);
 }
 
 reg_t_hash_map_ptr
-find_all_used_references(state_t *s)
-{
+find_all_used_references(state_t *s) {
 	seg_manager_t *sm = &(s->seg_manager);
 	seg_interface_t **interfaces = (seg_interface_t**)sci_calloc(sizeof(seg_interface_t *), sm->heap_size);
 	reg_t_hash_map_ptr nonnormal_map = new_reg_t_hash_map();
@@ -210,7 +200,7 @@
 	/* Init: Explicitly loaded scripts */
 	for (i = 1; i < sm->heap_size; i++)
 		if (interfaces[i]
-		    && interfaces[i]->type_id == MEM_OBJ_SCRIPT) {
+		        && interfaces[i]->type_id == MEM_OBJ_SCRIPT) {
 			script_t *script = &(interfaces[i]->mobj->data.script);
 
 			if (script->lockers) { /* Explicitly loaded? */
@@ -223,8 +213,8 @@
 				for (obj_nr = 0; obj_nr < script->objects_nr; obj_nr++) {
 					object_t *obj = script->objects + obj_nr;
 					worklist_push(&worklist,
-						      nonnormal_map,
-						      obj->pos);
+					              nonnormal_map,
+					              obj->pos);
 				}
 			}
 		}
@@ -238,15 +228,15 @@
 		reg_t reg = worklist_pop(&worklist);
 		if (reg.segment != s->stack_segment) { /* No need to repeat this one */
 #ifdef DEBUG_GC_VERBOSE
-			sciprintf("[GC] Checking "PREG"\n", PRINT_REG(reg)); 
+			sciprintf("[GC] Checking "PREG"\n", PRINT_REG(reg));
 #endif
 			if (reg.segment < sm->heap_size
-			    && interfaces[reg.segment])
+			        && interfaces[reg.segment])
 				interfaces[reg.segment]->list_all_outgoing_references(interfaces[reg.segment],
-										      s,
-										      reg,
-										      &worklist_manager,
-										      add_outgoing_refs);
+				        s,
+				        reg,
+				        &worklist_manager,
+				        add_outgoing_refs);
 		}
 	}
 
@@ -273,8 +263,7 @@
 } deallocator_t;
 
 void
-free_unless_used (void *pre_use_map, reg_t addr)
-{
+free_unless_used(void *pre_use_map, reg_t addr) {
 	deallocator_t *deallocator = (deallocator_t *) pre_use_map;
 	reg_t_hash_map_ptr use_map = deallocator->use_map;
 
@@ -290,8 +279,7 @@
 }
 
 void
-run_gc(state_t *s)
-{
+run_gc(state_t *s) {
 	int seg_nr;
 	deallocator_t deallocator;
 	seg_manager_t *sm = &(s->seg_manager);
@@ -312,8 +300,8 @@
 #endif
 
 			deallocator.interfce->list_all_deallocatable(deallocator.interfce,
-								     &deallocator,
-								     free_unless_used);
+			        &deallocator,
+			        free_unless_used);
 
 			deallocator.interfce->deallocate_self(deallocator.interfce);
 		}
@@ -327,8 +315,8 @@
 		for (i = 0; i <= MEM_OBJ_MAX; i++)
 			if (deallocator.segcount[i])
 				sciprintf("\t%d\t* %s\n",
-					  deallocator.segcount[i],
-					  deallocator.segnames[i]);
+				          deallocator.segcount[i],
+				          deallocator.segnames[i]);
 	}
 #endif
 }

Modified: scummvm/trunk/engines/sci/engine/grammar.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/grammar.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/grammar.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -37,221 +37,213 @@
 #define TOKEN_NON_NT (TOKEN_OPAREN | TOKEN_TERMINAL_CLASS | TOKEN_TERMINAL_GROUP | TOKEN_STUFFING_WORD)
 #define TOKEN_TERMINAL (TOKEN_TERMINAL_CLASS | TOKEN_TERMINAL_GROUP)
 
- int _allocd_rules = 0;
+int _allocd_rules = 0;
 
 static void
-vocab_print_rule(parse_rule_t *rule)
-{
-  int i;
-  int wspace = 0;
+vocab_print_rule(parse_rule_t *rule) {
+	int i;
+	int wspace = 0;
 
-  if (!rule) {
-    sciprintf("NULL rule");
-    return;
-  }
+	if (!rule) {
+		sciprintf("NULL rule");
+		return;
+	}
 
-  sciprintf("[%03x] -> ", rule->id);
+	sciprintf("[%03x] -> ", rule->id);
 
-  if (!rule->length)
-    sciprintf("e");
+	if (!rule->length)
+		sciprintf("e");
 
-  for(i = 0; i < rule->length; i++) {
-    uint token = rule->data[i];
+	for (i = 0; i < rule->length; i++) {
+		uint token = rule->data[i];
 
-    if (token == TOKEN_OPAREN) {
+		if (token == TOKEN_OPAREN) {
 
-      if (i == rule->first_special)
-	sciprintf("_");
+			if (i == rule->first_special)
+				sciprintf("_");
 
-      sciprintf("(");
-      wspace = 0;
-    } else if (token == TOKEN_CPAREN) {
+			sciprintf("(");
+			wspace = 0;
+		} else if (token == TOKEN_CPAREN) {
 
-      if (i == rule->first_special)
-	sciprintf("_");
+			if (i == rule->first_special)
+				sciprintf("_");
 
-      sciprintf(")");
-      wspace = 0;
-    } else {
-      if (wspace)
-	sciprintf(" ");
+			sciprintf(")");
+			wspace = 0;
+		} else {
+			if (wspace)
+				sciprintf(" ");
 
-      if (i == rule->first_special)
-	sciprintf("_");
-      if (token & TOKEN_TERMINAL_CLASS)
-	sciprintf("C(%04x)", token & 0xffff);
-      else if (token & TOKEN_TERMINAL_GROUP)
-	sciprintf("G(%04x)", token & 0xffff);
-      else if (token & TOKEN_STUFFING_WORD)
-	sciprintf("%03x", token & 0xffff);
-      else
-	sciprintf("[%03x]", token); /* non-terminal */
-      wspace = 1;
-    }
+			if (i == rule->first_special)
+				sciprintf("_");
+			if (token & TOKEN_TERMINAL_CLASS)
+				sciprintf("C(%04x)", token & 0xffff);
+			else if (token & TOKEN_TERMINAL_GROUP)
+				sciprintf("G(%04x)", token & 0xffff);
+			else if (token & TOKEN_STUFFING_WORD)
+				sciprintf("%03x", token & 0xffff);
+			else
+				sciprintf("[%03x]", token); /* non-terminal */
+			wspace = 1;
+		}
 
-    if (i == rule->first_special)
-      sciprintf("_");
-  }
-  sciprintf(" [%d specials]", rule->specials_nr);
+		if (i == rule->first_special)
+			sciprintf("_");
+	}
+	sciprintf(" [%d specials]", rule->specials_nr);
 }
 
 
 static void
-_vfree(parse_rule_t *rule)
-{
-  free(rule);
-  --_allocd_rules;
-  rule = NULL;
+_vfree(parse_rule_t *rule) {
+	free(rule);
+	--_allocd_rules;
+	rule = NULL;
 }
 
 static parse_rule_t *
-_vdup(parse_rule_t *a)
-{
-  parse_rule_t *rule = (parse_rule_t*)sci_malloc(sizeof(int) * (a->length + 4));
+_vdup(parse_rule_t *a) {
+	parse_rule_t *rule = (parse_rule_t*)sci_malloc(sizeof(int) * (a->length + 4));
 
-  rule->id = a->id;
-  rule->length = a->length;
-  rule->specials_nr = a->specials_nr;
-  rule->first_special = a->first_special;
-  ++_allocd_rules;
+	rule->id = a->id;
+	rule->length = a->length;
+	rule->specials_nr = a->specials_nr;
+	rule->first_special = a->first_special;
+	++_allocd_rules;
 
-  memcpy(rule->data, a->data, sizeof(int) * a->length);
+	memcpy(rule->data, a->data, sizeof(int) * a->length);
 
-  return rule;
+	return rule;
 }
 
 static parse_rule_t *
-_vinsert(parse_rule_t *turkey, parse_rule_t *stuffing)
-{
-  int firstnt = turkey->first_special;
-  parse_rule_t *rule;
+_vinsert(parse_rule_t *turkey, parse_rule_t *stuffing) {
+	int firstnt = turkey->first_special;
+	parse_rule_t *rule;
 
-  while ((firstnt < turkey->length)
-	 && (turkey->data[firstnt] & TOKEN_NON_NT))
-    firstnt++;
+	while ((firstnt < turkey->length)
+	        && (turkey->data[firstnt] & TOKEN_NON_NT))
+		firstnt++;
 
-  if ((firstnt == turkey->length)
-      || (turkey->data[firstnt] != stuffing->id))
-    return NULL;
+	if ((firstnt == turkey->length)
+	        || (turkey->data[firstnt] != stuffing->id))
+		return NULL;
 
-  rule = (parse_rule_t*)sci_malloc(sizeof(int) * (turkey->length - 1 + stuffing->length + 4));
-  rule->id = turkey->id;
-  rule->specials_nr = turkey->specials_nr + stuffing->specials_nr - 1;
-  rule->first_special = firstnt + stuffing->first_special;
-  rule->length = turkey->length - 1 + stuffing->length;
-  ++_allocd_rules;
+	rule = (parse_rule_t*)sci_malloc(sizeof(int) * (turkey->length - 1 + stuffing->length + 4));
+	rule->id = turkey->id;
+	rule->specials_nr = turkey->specials_nr + stuffing->specials_nr - 1;
+	rule->first_special = firstnt + stuffing->first_special;
+	rule->length = turkey->length - 1 + stuffing->length;
+	++_allocd_rules;
 
-  if (firstnt > 0)
-    memcpy(rule->data, turkey->data, sizeof(int) * firstnt);
-  memcpy(&(rule->data[firstnt]), stuffing->data, sizeof(int) * stuffing->length);
-  if (firstnt < turkey->length - 1)
-    memcpy(&(rule->data[firstnt + stuffing->length]), &(turkey->data[firstnt + 1]),
-	   sizeof(int) * (turkey->length - firstnt - 1));
+	if (firstnt > 0)
+		memcpy(rule->data, turkey->data, sizeof(int) * firstnt);
+	memcpy(&(rule->data[firstnt]), stuffing->data, sizeof(int) * stuffing->length);
+	if (firstnt < turkey->length - 1)
+		memcpy(&(rule->data[firstnt + stuffing->length]), &(turkey->data[firstnt + 1]),
+		       sizeof(int) * (turkey->length - firstnt - 1));
 
-  return rule;
+	return rule;
 }
 
 static parse_rule_t *
-_vbuild_rule(parse_tree_branch_t *branch)
-{
-  parse_rule_t *rule;
-  int tokens = 0, tokenpos = 0, i;
+_vbuild_rule(parse_tree_branch_t *branch) {
+	parse_rule_t *rule;
+	int tokens = 0, tokenpos = 0, i;
 
-  while (tokenpos < 10 && branch->data[tokenpos]) {
-    int type = branch->data[tokenpos];
-    tokenpos += 2;
+	while (tokenpos < 10 && branch->data[tokenpos]) {
+		int type = branch->data[tokenpos];
+		tokenpos += 2;
 
-    if ((type == VOCAB_TREE_NODE_COMPARE_TYPE)
-	|| (type == VOCAB_TREE_NODE_COMPARE_GROUP)
-	|| (type == VOCAB_TREE_NODE_FORCE_STORAGE))
-      ++tokens;
-    else if (type > VOCAB_TREE_NODE_LAST_WORD_STORAGE)
-      tokens += 5;
-    else return NULL; /* invalid */
-  }
+		if ((type == VOCAB_TREE_NODE_COMPARE_TYPE)
+		        || (type == VOCAB_TREE_NODE_COMPARE_GROUP)
+		        || (type == VOCAB_TREE_NODE_FORCE_STORAGE))
+			++tokens;
+		else if (type > VOCAB_TREE_NODE_LAST_WORD_STORAGE)
+			tokens += 5;
+		else return NULL; /* invalid */
+	}
 
-  rule = (parse_rule_t*)sci_malloc(sizeof(int) * (4 + tokens));
+	rule = (parse_rule_t*)sci_malloc(sizeof(int) * (4 + tokens));
 
-  ++_allocd_rules;
-  rule->id = branch->id;
-  rule->specials_nr = tokenpos >> 1;
-  rule->length = tokens;
-  rule->first_special = 0;
+	++_allocd_rules;
+	rule->id = branch->id;
+	rule->specials_nr = tokenpos >> 1;
+	rule->length = tokens;
+	rule->first_special = 0;
 
-  tokens = 0;
-  for (i = 0; i < tokenpos; i += 2) {
-    int type = branch->data[i];
-    int value = branch->data[i + 1];
+	tokens = 0;
+	for (i = 0; i < tokenpos; i += 2) {
+		int type = branch->data[i];
+		int value = branch->data[i + 1];
 
-    if (type == VOCAB_TREE_NODE_COMPARE_TYPE)
-      rule->data[tokens++] = value | TOKEN_TERMINAL_CLASS;
-    else if (type == VOCAB_TREE_NODE_COMPARE_GROUP)
-      rule->data[tokens++] = value | TOKEN_TERMINAL_GROUP;
-    else if (type == VOCAB_TREE_NODE_FORCE_STORAGE)
-      rule->data[tokens++] = value | TOKEN_STUFFING_WORD;
-    else { /* normal inductive rule */
-      rule->data[tokens++] = TOKEN_OPAREN;
-      rule->data[tokens++] = type | TOKEN_STUFFING_WORD;
-      rule->data[tokens++] = value | TOKEN_STUFFING_WORD;
+		if (type == VOCAB_TREE_NODE_COMPARE_TYPE)
+			rule->data[tokens++] = value | TOKEN_TERMINAL_CLASS;
+		else if (type == VOCAB_TREE_NODE_COMPARE_GROUP)
+			rule->data[tokens++] = value | TOKEN_TERMINAL_GROUP;
+		else if (type == VOCAB_TREE_NODE_FORCE_STORAGE)
+			rule->data[tokens++] = value | TOKEN_STUFFING_WORD;
+		else { /* normal inductive rule */
+			rule->data[tokens++] = TOKEN_OPAREN;
+			rule->data[tokens++] = type | TOKEN_STUFFING_WORD;
+			rule->data[tokens++] = value | TOKEN_STUFFING_WORD;
 
-      if (i == 0)
-	rule->first_special = tokens;
+			if (i == 0)
+				rule->first_special = tokens;
 
-      rule->data[tokens++] = value; /* The non-terminal */
-      rule->data[tokens++] = TOKEN_CPAREN;
-    }
-  }
+			rule->data[tokens++] = value; /* The non-terminal */
+			rule->data[tokens++] = TOKEN_CPAREN;
+		}
+	}
 
-  return rule;
+	return rule;
 }
 
 
 static parse_rule_t *
-_vsatisfy_rule(parse_rule_t *rule, result_word_t *input)
-{
-  int dep;
+_vsatisfy_rule(parse_rule_t *rule, result_word_t *input) {
+	int dep;
 
-  if (!rule->specials_nr)
-    return NULL;
+	if (!rule->specials_nr)
+		return NULL;
 
-  dep = rule->data[rule->first_special];
+	dep = rule->data[rule->first_special];
 
-  if (((dep & TOKEN_TERMINAL_CLASS)
-       && ((dep & 0xffff) & input->w_class))
-      ||
-      ((dep & TOKEN_TERMINAL_GROUP)
-       && ((dep & 0xffff) & input->group))) {
-    parse_rule_t *retval = (parse_rule_t*)sci_malloc(sizeof(int) * (4 + rule->length));
-    ++_allocd_rules;
-    retval->id = rule->id;
-    retval->specials_nr = rule->specials_nr - 1;
-    retval->length = rule->length;
-    memcpy(retval->data, rule->data, sizeof(int) * retval->length);
-    retval->data[rule->first_special] = TOKEN_STUFFING_WORD | input->group;
-    retval->first_special = 0;
+	if (((dep & TOKEN_TERMINAL_CLASS)
+	        && ((dep & 0xffff) & input->w_class))
+	        ||
+	        ((dep & TOKEN_TERMINAL_GROUP)
+	         && ((dep & 0xffff) & input->group))) {
+		parse_rule_t *retval = (parse_rule_t*)sci_malloc(sizeof(int) * (4 + rule->length));
+		++_allocd_rules;
+		retval->id = rule->id;
+		retval->specials_nr = rule->specials_nr - 1;
+		retval->length = rule->length;
+		memcpy(retval->data, rule->data, sizeof(int) * retval->length);
+		retval->data[rule->first_special] = TOKEN_STUFFING_WORD | input->group;
+		retval->first_special = 0;
 
-    if (retval->specials_nr) { /* find first special, if it exists */
-      int tmp, i = rule->first_special;
+		if (retval->specials_nr) { /* find first special, if it exists */
+			int tmp, i = rule->first_special;
 
-      while ((i < rule->length)
-	     && ((tmp = retval->data[i]) & TOKEN_NON_NT)
-	     && !(tmp & TOKEN_TERMINAL))
-	++i;
+			while ((i < rule->length)
+			        && ((tmp = retval->data[i]) & TOKEN_NON_NT)
+			        && !(tmp & TOKEN_TERMINAL))
+				++i;
 
-      if (i < rule->length)
-	retval->first_special = i;
-    }
+			if (i < rule->length)
+				retval->first_special = i;
+		}
 
-    return retval;
-  }
-  else return NULL;
+		return retval;
+	} else return NULL;
 }
 
 /************** Rule lists **************/
 
 void
-vocab_free_rule_list(parse_rule_list_t *list)
-{
+vocab_free_rule_list(parse_rule_list_t *list) {
 	if (list) {
 		_vfree(list->rule);
 		vocab_free_rule_list(list->next); /* Yep, this is slow and memory-intensive. */
@@ -260,19 +252,17 @@
 }
 
 static inline int
-_rules_equal_p(parse_rule_t *r1, parse_rule_t *r2)
-{
+_rules_equal_p(parse_rule_t *r1, parse_rule_t *r2) {
 	if ((r1->id != r2->id)
-	    || (r1->length != r2->length)
-	    || (r1->first_special != r2->first_special))
+	        || (r1->length != r2->length)
+	        || (r1->first_special != r2->first_special))
 		return 0;
 
 	return !(memcmp(r1->data, r2->data, sizeof(int) * r1->length));
 }
 
 static parse_rule_list_t *
-_vocab_add_rule(parse_rule_list_t *list, parse_rule_t *rule)
-{
+_vocab_add_rule(parse_rule_list_t *list, parse_rule_t *rule) {
 	parse_rule_list_t *new_elem;
 	int term;
 
@@ -284,7 +274,7 @@
 
 	new_elem->rule = rule;
 	new_elem->next = NULL;
-	new_elem->terminal = term = ((term & TOKEN_TERMINAL)? term : 0);
+	new_elem->terminal = term = ((term & TOKEN_TERMINAL) ? term : 0);
 
 	if (!list)
 		return new_elem;
@@ -311,39 +301,34 @@
 }
 
 static void
-_vprl(parse_rule_list_t *list, int pos)
-{
+_vprl(parse_rule_list_t *list, int pos) {
 	if (list) {
 		sciprintf("R%03d: ", pos);
 		vocab_print_rule(list->rule);
 		sciprintf("\n");
-		_vprl(list->next, pos+1);
+		_vprl(list->next, pos + 1);
 	} else {
 		sciprintf("%d rules total.\n", pos);
 	}
 }
 
 void
-vocab_print_rule_list(parse_rule_list_t *list)
-{
+vocab_print_rule_list(parse_rule_list_t *list) {
 	_vprl(list, 0);
 }
 
 static parse_rule_list_t *
-_vocab_split_rule_list(parse_rule_list_t *list)
-{
+_vocab_split_rule_list(parse_rule_list_t *list) {
 	if (!list->next
-	    || (list->next->terminal)) {
+	        || (list->next->terminal)) {
 		parse_rule_list_t *tmp = list->next;
 		list->next = NULL;
 		return tmp;
-	}
-	else return _vocab_split_rule_list(list->next);
+	} else return _vocab_split_rule_list(list->next);
 }
 
 static void
-_vocab_free_empty_rule_list(parse_rule_list_t *list)
-{
+_vocab_free_empty_rule_list(parse_rule_list_t *list) {
 	if (list->next)
 		_vocab_free_empty_rule_list(list->next);
 
@@ -351,8 +336,7 @@
 }
 
 static parse_rule_list_t *
-_vocab_merge_rule_lists(parse_rule_list_t *l1, parse_rule_list_t *l2)
-{
+_vocab_merge_rule_lists(parse_rule_list_t *l1, parse_rule_list_t *l2) {
 	parse_rule_list_t *retval = l1, *seeker = l2;
 	while (seeker) {
 		retval = _vocab_add_rule(retval, seeker->rule);
@@ -364,15 +348,13 @@
 }
 
 static int
-_vocab_rule_list_length(parse_rule_list_t *list)
-{
-	return ((list)? _vocab_rule_list_length(list->next) + 1 : 0);
+_vocab_rule_list_length(parse_rule_list_t *list) {
+	return ((list) ? _vocab_rule_list_length(list->next) + 1 : 0);
 }
 
 
 static parse_rule_list_t *
-_vocab_clone_rule_list_by_id(parse_rule_list_t *list, int id)
-{
+_vocab_clone_rule_list_by_id(parse_rule_list_t *list, int id) {
 	parse_rule_list_t *result = NULL;
 	parse_rule_list_t *seeker = list;
 
@@ -388,8 +370,7 @@
 
 
 parse_rule_list_t *
-_vocab_build_gnf(parse_tree_branch_t *branches, int branches_nr, int verbose)
-{
+_vocab_build_gnf(parse_tree_branch_t *branches, int branches_nr, int verbose) {
 	int i;
 	int iterations = 0;
 	int last_termrules, termrules = 0;
@@ -453,27 +434,24 @@
 }
 
 parse_rule_list_t *
-vocab_build_gnf(parse_tree_branch_t *branches, int branches_nr)
-{
-  return _vocab_build_gnf(branches, branches_nr, 0);
+vocab_build_gnf(parse_tree_branch_t *branches, int branches_nr) {
+	return _vocab_build_gnf(branches, branches_nr, 0);
 }
 
 
 void
-vocab_gnf_dump(parse_tree_branch_t *branches, int branches_nr)
-{
-  parse_rule_list_t *tlist = _vocab_build_gnf(branches, branches_nr, 1);
+vocab_gnf_dump(parse_tree_branch_t *branches, int branches_nr) {
+	parse_rule_list_t *tlist = _vocab_build_gnf(branches, branches_nr, 1);
 
-  sciprintf("%d allocd rules\n", _allocd_rules);
-  vocab_free_rule_list(tlist);
+	sciprintf("%d allocd rules\n", _allocd_rules);
+	vocab_free_rule_list(tlist);
 }
 
 
 int
 vocab_build_parse_tree(parse_tree_node_t *nodes, result_word_t *words, int words_nr,
-		       parse_tree_branch_t *branch0, parse_rule_list_t *rules)
-{
-  return vocab_gnf_parse(nodes, words, words_nr, branch0, rules, 0);
+                       parse_tree_branch_t *branch0, parse_rule_list_t *rules) {
+	return vocab_gnf_parse(nodes, words, words_nr, branch0, rules, 0);
 }
 
 
@@ -481,11 +459,11 @@
 _vbpt_pareno(parse_tree_node_t *nodes, int *pos, int base)
 /* Opens parentheses */
 {
-  nodes[base].content.branches[0] = (*pos)+1;
-  nodes[++(*pos)].type = PARSE_TREE_NODE_BRANCH;
-  nodes[*pos].content.branches[0] = 0;
-  nodes[*pos].content.branches[1] = 0;
-  return *pos;
+	nodes[base].content.branches[0] = (*pos) + 1;
+	nodes[++(*pos)].type = PARSE_TREE_NODE_BRANCH;
+	nodes[*pos].content.branches[0] = 0;
+	nodes[*pos].content.branches[1] = 0;
+	return *pos;
 }
 
 
@@ -493,11 +471,11 @@
 _vbpt_parenc(parse_tree_node_t *nodes, int *pos, int paren)
 /* Closes parentheses for appending */
 {
-  nodes[paren].content.branches[1] = ++(*pos);
-  nodes[*pos].type = PARSE_TREE_NODE_BRANCH;
-  nodes[*pos].content.branches[0] = 0;
-  nodes[*pos].content.branches[1] = 0;
-  return *pos;
+	nodes[paren].content.branches[1] = ++(*pos);
+	nodes[*pos].type = PARSE_TREE_NODE_BRANCH;
+	nodes[*pos].content.branches[0] = 0;
+	nodes[*pos].content.branches[1] = 0;
+	return *pos;
 }
 
 
@@ -505,154 +483,152 @@
 _vbpt_append(parse_tree_node_t *nodes, int *pos, int base, int value)
 /* writes one value to an existing base node and creates a successor node for writing */
 {
-  nodes[base].content.branches[0] = ++(*pos);
-  nodes[*pos].type = PARSE_TREE_NODE_LEAF;
-  nodes[*pos].content.value = value;
-  nodes[base].content.branches[1] = ++(*pos);
-  nodes[*pos].type = PARSE_TREE_NODE_BRANCH;
-  nodes[*pos].content.branches[0] = 0;
-  nodes[*pos].content.branches[1] = 0;
-  return *pos;
+	nodes[base].content.branches[0] = ++(*pos);
+	nodes[*pos].type = PARSE_TREE_NODE_LEAF;
+	nodes[*pos].content.value = value;
+	nodes[base].content.branches[1] = ++(*pos);
+	nodes[*pos].type = PARSE_TREE_NODE_BRANCH;
+	nodes[*pos].content.branches[0] = 0;
+	nodes[*pos].content.branches[1] = 0;
+	return *pos;
 }
 
 
 static int
 _vbpt_terminate(parse_tree_node_t *nodes, int *pos, int base, int value)
-     /* Terminates, overwriting a nextwrite forknode */
+/* Terminates, overwriting a nextwrite forknode */
 {
-  nodes[base].type = PARSE_TREE_NODE_LEAF;
-  nodes[base].content.value = value;
-  return *pos;
+	nodes[base].type = PARSE_TREE_NODE_LEAF;
+	nodes[base].content.value = value;
+	return *pos;
 }
 
 static int
 _vbpt_write_subexpression(parse_tree_node_t *nodes, int *pos,
-			  parse_rule_t *rule, int rulepos, int writepos)
-{
-  uint token;
-  while ((token = ((rulepos < rule->length)? rule->data[rulepos++] : TOKEN_CPAREN)) != TOKEN_CPAREN) {
-    uint nexttoken = (rulepos < rule->length)? rule->data[rulepos] : TOKEN_CPAREN;
-    if (token == TOKEN_OPAREN) {
-      int wpold;
-      int writepos2 = _vbpt_pareno(nodes, pos, wpold = writepos);
-      rulepos = _vbpt_write_subexpression(nodes, pos, rule, rulepos, writepos2);
-      nexttoken = (rulepos < rule->length)? rule->data[rulepos] : TOKEN_CPAREN;
-      if (nexttoken != TOKEN_CPAREN)
-	writepos = _vbpt_parenc(nodes, pos, wpold);
-    } else if (token & TOKEN_STUFFING_WORD) {
-      if (nexttoken == TOKEN_CPAREN)
-	writepos = _vbpt_terminate(nodes, pos, writepos, token & 0xffff);
-      else
-	writepos = _vbpt_append(nodes, pos, writepos, token & 0xffff);
-    } else {
-      sciprintf("\nError in parser (grammar.c, _vbpt_write_subexpression()): Rule data broken in rule ");
-      vocab_print_rule(rule);
-      sciprintf(", at token position %d\n", *pos);
-      return rulepos;
-    }
-  }
+                          parse_rule_t *rule, int rulepos, int writepos) {
+	uint token;
+	while ((token = ((rulepos < rule->length) ? rule->data[rulepos++] : TOKEN_CPAREN)) != TOKEN_CPAREN) {
+		uint nexttoken = (rulepos < rule->length) ? rule->data[rulepos] : TOKEN_CPAREN;
+		if (token == TOKEN_OPAREN) {
+			int wpold;
+			int writepos2 = _vbpt_pareno(nodes, pos, wpold = writepos);
+			rulepos = _vbpt_write_subexpression(nodes, pos, rule, rulepos, writepos2);
+			nexttoken = (rulepos < rule->length) ? rule->data[rulepos] : TOKEN_CPAREN;
+			if (nexttoken != TOKEN_CPAREN)
+				writepos = _vbpt_parenc(nodes, pos, wpold);
+		} else if (token & TOKEN_STUFFING_WORD) {
+			if (nexttoken == TOKEN_CPAREN)
+				writepos = _vbpt_terminate(nodes, pos, writepos, token & 0xffff);
+			else
+				writepos = _vbpt_append(nodes, pos, writepos, token & 0xffff);
+		} else {
+			sciprintf("\nError in parser (grammar.c, _vbpt_write_subexpression()): Rule data broken in rule ");
+			vocab_print_rule(rule);
+			sciprintf(", at token position %d\n", *pos);
+			return rulepos;
+		}
+	}
 
-  return rulepos;
+	return rulepos;
 }
 
 int
 vocab_gnf_parse(parse_tree_node_t *nodes, result_word_t *words, int words_nr,
-		parse_tree_branch_t *branch0, parse_rule_list_t *tlist, int verbose)
-{
-  /* Get the start rules: */
-  parse_rule_list_t *work = _vocab_clone_rule_list_by_id(tlist, branch0->data[1]);
-  parse_rule_list_t *results = NULL;
-  int word;
+                parse_tree_branch_t *branch0, parse_rule_list_t *tlist, int verbose) {
+	/* Get the start rules: */
+	parse_rule_list_t *work = _vocab_clone_rule_list_by_id(tlist, branch0->data[1]);
+	parse_rule_list_t *results = NULL;
+	int word;
 
-  for (word = 0; word < words_nr; word++) {
-    parse_rule_list_t *new_work = NULL;
-    parse_rule_list_t *reduced_rules = NULL;
-    parse_rule_list_t *seeker, *subseeker;
+	for (word = 0; word < words_nr; word++) {
+		parse_rule_list_t *new_work = NULL;
+		parse_rule_list_t *reduced_rules = NULL;
+		parse_rule_list_t *seeker, *subseeker;
 
-    if (verbose)
-      sciprintf("Adding word %d...\n", word);
+		if (verbose)
+			sciprintf("Adding word %d...\n", word);
 
-    seeker = work;
-    while (seeker) {
+		seeker = work;
+		while (seeker) {
 
-      if (seeker->rule->specials_nr <= (words_nr - word))
-	reduced_rules = _vocab_add_rule(reduced_rules, _vsatisfy_rule(seeker->rule, words + word));
+			if (seeker->rule->specials_nr <= (words_nr - word))
+				reduced_rules = _vocab_add_rule(reduced_rules, _vsatisfy_rule(seeker->rule, words + word));
 
-      seeker = seeker->next;
-    }
+			seeker = seeker->next;
+		}
 
-    if (reduced_rules == NULL) {
-      vocab_free_rule_list(work);
-      if (verbose)
-	sciprintf("No results.\n");
-      return 1;
-    }
+		if (reduced_rules == NULL) {
+			vocab_free_rule_list(work);
+			if (verbose)
+				sciprintf("No results.\n");
+			return 1;
+		}
 
-    vocab_free_rule_list(work);
+		vocab_free_rule_list(work);
 
-    if (word +1 < words_nr) {
-      seeker = reduced_rules;
+		if (word + 1 < words_nr) {
+			seeker = reduced_rules;
 
-      while (seeker) {
-	if (seeker->rule->specials_nr) {
-	  int my_id = seeker->rule->data[seeker->rule->first_special];
+			while (seeker) {
+				if (seeker->rule->specials_nr) {
+					int my_id = seeker->rule->data[seeker->rule->first_special];
 
-	  subseeker = tlist;
-	  while (subseeker) {
-	    if (subseeker->rule->id == my_id)
-	      new_work = _vocab_add_rule(new_work, _vinsert(seeker->rule, subseeker->rule));
+					subseeker = tlist;
+					while (subseeker) {
+						if (subseeker->rule->id == my_id)
+							new_work = _vocab_add_rule(new_work, _vinsert(seeker->rule, subseeker->rule));
 
-	    subseeker = subseeker->next;
-	  }
-	}
+						subseeker = subseeker->next;
+					}
+				}
 
-	seeker = seeker->next;
-      }
-      vocab_free_rule_list(reduced_rules);
-    } else /* last word */
-      new_work = reduced_rules;
+				seeker = seeker->next;
+			}
+			vocab_free_rule_list(reduced_rules);
+		} else /* last word */
+			new_work = reduced_rules;
 
-    work = new_work;
-    if (verbose)
-      sciprintf("Now at %d candidates\n", _vocab_rule_list_length(work));
-    if (work == NULL) {
-      if (verbose)
-	sciprintf("No results.\n");
-      return 1;
-    }
-  }
+		work = new_work;
+		if (verbose)
+			sciprintf("Now at %d candidates\n", _vocab_rule_list_length(work));
+		if (work == NULL) {
+			if (verbose)
+				sciprintf("No results.\n");
+			return 1;
+		}
+	}
 
-  results = work;
+	results = work;
 
-  if (verbose) {
-    sciprintf("All results (excluding the surrounding '(141 %03x' and ')'):\n",
-	      branch0->id);
-    vocab_print_rule_list(results);
-    sciprintf("\n");
-  }
+	if (verbose) {
+		sciprintf("All results (excluding the surrounding '(141 %03x' and ')'):\n",
+		          branch0->id);
+		vocab_print_rule_list(results);
+		sciprintf("\n");
+	}
 
-  /* now use the first result */
-  {
-    int temp, pos;
+	/* now use the first result */
+	{
+		int temp, pos;
 
-    nodes[0].type = PARSE_TREE_NODE_BRANCH;
-    nodes[0].content.branches[0] = 1;
-    nodes[0].content.branches[1] = 2;
+		nodes[0].type = PARSE_TREE_NODE_BRANCH;
+		nodes[0].content.branches[0] = 1;
+		nodes[0].content.branches[1] = 2;
 
-    nodes[1].type = PARSE_TREE_NODE_LEAF;
-    nodes[1].content.value = 0x141;
+		nodes[1].type = PARSE_TREE_NODE_LEAF;
+		nodes[1].content.value = 0x141;
 
-    nodes[2].type = PARSE_TREE_NODE_BRANCH;
-    nodes[2].content.branches[0] = 0;
-    nodes[2].content.branches[1] = 0;
+		nodes[2].type = PARSE_TREE_NODE_BRANCH;
+		nodes[2].content.branches[0] = 0;
+		nodes[2].content.branches[1] = 0;
 
-    pos = 2;
+		pos = 2;
 
-    temp = _vbpt_append(nodes, &pos, 2, branch0->id);
-    /*    _vbpt_write_subexpression(nodes, &pos, results[_vocab_rule_list_length(results)].rule, 0, temp); */
-    _vbpt_write_subexpression(nodes, &pos, results->rule, 0, temp);
-  }
+		temp = _vbpt_append(nodes, &pos, 2, branch0->id);
+		/*    _vbpt_write_subexpression(nodes, &pos, results[_vocab_rule_list_length(results)].rule, 0, temp); */
+		_vbpt_write_subexpression(nodes, &pos, results->rule, 0, temp);
+	}
 
-  vocab_free_rule_list(results);
-  return 0;
+	vocab_free_rule_list(results);
+	return 0;
 }

Modified: scummvm/trunk/engines/sci/engine/heap.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/heap.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/heap.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -8,64 +8,56 @@
 
 #define assert_in_range(pos) assert(pos>=1000 && pos<=0xffff)
 
-static void set_size(heap_t *h, int block_pos, int size)
-{
+static void set_size(heap_t *h, int block_pos, int size) {
 	assert_in_range(block_pos);
-	assert(size<=0xffff-1000);
-	putInt16(h->start+block_pos, size);
+	assert(size <= 0xffff - 1000);
+	putInt16(h->start + block_pos, size);
 }
 
-static void set_next(heap_t* h, int block_pos, int next)
-{
+static void set_next(heap_t* h, int block_pos, int next) {
 	assert_in_range(block_pos);
 	assert_in_range(next);
-	putInt16(h->start+block_pos+2, next);
+	putInt16(h->start + block_pos + 2, next);
 }
 
 
-static unsigned int get_size(heap_t* h, int block_pos)
-{
+static unsigned int get_size(heap_t* h, int block_pos) {
 	assert_in_range(block_pos);
-	return (guint16)getInt16(h->start+block_pos);
+	return (guint16)getInt16(h->start + block_pos);
 }
 
-static unsigned int get_next(heap_t* h, int block_pos)
-{
+static unsigned int get_next(heap_t* h, int block_pos) {
 	assert_in_range(block_pos);
-	return (guint16)getInt16(h->start+block_pos+2);
+	return (guint16)getInt16(h->start + block_pos + 2);
 }
 
 /*Allocates a new heap*/
-heap_t* heap_new()
-{
+heap_t* heap_new() {
 	heap_t* h;
-	if((h= (heap_t*)sci_malloc(sizeof(heap_t)))==0) return 0;
+	if ((h = (heap_t*)sci_malloc(sizeof(heap_t))) == 0) return 0;
 
-	if((h->start= sci_calloc(SCI_HEAP_SIZE, 1))==0)
-	{
+	if ((h->start = sci_calloc(SCI_HEAP_SIZE, 1)) == 0) {
 		free(h);
 		return 0;
 	}
 
-	h->base=h->start+1000;
-	h->first_free=1000;
-	h->old_ff=-1;
-	set_size(h, 1000, 0xffff-1000);
+	h->base = h->start + 1000;
+	h->first_free = 1000;
+	h->old_ff = -1;
+	set_size(h, 1000, 0xffff - 1000);
 	set_next(h, 1000, 0xffff);
 
 	return h;
 }
 
 /*Deletes a heap*/
-void heap_del(heap_t* h)
-{
+void heap_del(heap_t* h) {
 	free(h->start);
 	free(h);
 }
 
 
-int heap_meminfo(heap_t* h)
-{
+int heap_meminfo(heap_t* h) {
 	heap_ptr current = h->first_free;
 	int total = 0;
 
@@ -78,160 +70,134 @@
 }
 
 
-int heap_largest(heap_t* h)
-{
-	int current=h->first_free;
-	int best_pos=-1, best_size=0;
+int heap_largest(heap_t* h) {
+	int current = h->first_free;
+	int best_pos = -1, best_size = 0;
 
-	while(current!=0xffff)
-	{
-		int size=get_size(h, current);
-		int next=get_next(h, current);
+	while (current != 0xffff) {
+		int size = get_size(h, current);
+		int next = get_next(h, current);
 
-		if(size>best_size)
-		{
-			best_pos=current;
-			best_size=size;
+		if (size > best_size) {
+			best_pos = current;
+			best_size = size;
 		}
 
-		current=next;
+		current = next;
 	}
 
 	return best_size;
 }
 
-heap_ptr heap_allocate(heap_t* h, int size)
-{
-	unsigned int previous=h->first_free;
-	unsigned int current=previous;
+heap_ptr heap_allocate(heap_t* h, int size) {
+	unsigned int previous = h->first_free;
+	unsigned int current = previous;
 
 	if (!size) {
-		fprintf(stderr,"Warning: heap_alloc'd zero bytes!\n");
+		fprintf(stderr, "Warning: heap_alloc'd zero bytes!\n");
 		size += 2;
 	}
 
-	size+=2+(size&1);
+	size += 2 + (size & 1);
 
-	while(current<0xffff)
-	{
-		int block_size=get_size(h, current);
-		int next=get_next(h, current);
+	while (current < 0xffff) {
+		int block_size = get_size(h, current);
+		int next = get_next(h, current);
 
 		/*Is this block large enough?*/
-		if(block_size>=size)
-		{
+		if (block_size >= size) {
 			/*Swallow the block whole*/
-			if(block_size<=size+4)
-			{
-				size=block_size;
+			if (block_size <= size + 4) {
+				size = block_size;
 				set_next(h, previous, next);
-			}
-			else {
+			} else {
 				/*Split the block*/
-				int rest=current+size;
+				int rest = current + size;
 
 				set_next(h, previous, rest);
-				set_size(h, rest, block_size-size);
+				set_size(h, rest, block_size - size);
 				set_next(h, rest, next);
-				next=rest;
+				next = rest;
 			}
 			set_size(h, current, size);
-			if(current==h->first_free) h->first_free=next;
+			if (current == h->first_free) h->first_free = next;
 			return current;
 		}
-		previous=current;
-		current=next;
+		previous = current;
+		current = next;
 	}
 
 	/*No large enough block was found.*/
 	return 0;
 }
 
-void heap_free(heap_t* h, unsigned int m)
-{
+void heap_free(heap_t* h, unsigned int m) {
 	unsigned int previous, next;
 	assert_in_range(m);
-	previous=next=h->first_free;
+	previous = next = h->first_free;
 
 	/*Find the previous and next blocks*/
-	while(next < m)
-	{
+	while (next < m) {
 		previous = next;
-		assert(previous<0xffff);
-		next=get_next(h, previous);
+		assert(previous < 0xffff);
+		next = get_next(h, previous);
 		if (next <= previous) {
-		  sciprintf("Heap corrupt. Aborting heap_free()...\n");
-		  return;
+			sciprintf("Heap corrupt. Aborting heap_free()...\n");
+			return;
 		}
 	}
 
 	if (h->first_free > m)
-	  h->first_free = m; /* Guarantee that first_free is correct */
+		h->first_free = m; /* Guarantee that first_free is correct */
 
-	if(previous==next)
-	{
-		if(m<previous)
-		{
-			h->first_free=m;
-			if(m+get_size(h, m)==previous)
-			{
-				set_size(h, m, get_size(h, m)+get_size(h, previous));
+	if (previous == next) {
+		if (m < previous) {
+			h->first_free = m;
+			if (m + get_size(h, m) == previous) {
+				set_size(h, m, get_size(h, m) + get_size(h, previous));
 				set_next(h, m, get_next(h, previous));
-			}
-			else set_next(h, m, previous);
-		}
-		else
-		{
-			if(previous+get_size(h, previous)==m)
-			{
-				set_size(h, previous, get_size(h, previous)+get_size(h, m));
+			} else set_next(h, m, previous);
+		} else {
+			if (previous + get_size(h, previous) == m) {
+				set_size(h, previous, get_size(h, previous) + get_size(h, m));
 				set_next(h, previous, 0xffff);
-			}
-			else
-			{
+			} else {
 				set_next(h, previous, m);
 				set_next(h, m, next);
 			}
 		}
-	}
-	else
-	{
+	} else {
 		set_next(h, previous, m);
 		set_next(h, m, next);
 
 		/*Try to merge with previous*/
-		if(previous+get_size(h, previous)==m)
-		{
-			set_size(h, previous, get_size(h, previous)+get_size(h, m));
+		if (previous + get_size(h, previous) == m) {
+			set_size(h, previous, get_size(h, previous) + get_size(h, m));
 			set_next(h, previous, next);
-			m=previous;
+			m = previous;
 		}
 
 		/*Try to merge with next*/
-		if(m+get_size(h, m)==next)
-		{
-			set_size(h, m, get_size(h, m)+get_size(h, next));
+		if (m + get_size(h, m) == next) {
+			set_size(h, m, get_size(h, m) + get_size(h, next));
 			set_next(h, m, get_next(h, next));
 		}
 	}
 }
 
-void save_ff(heap_t* h)
-{
-	h->old_ff=h->first_free;
+void save_ff(heap_t* h) {
+	h->old_ff = h->first_free;
 }
 
-void restore_ff(heap_t* h)
-{
-	h->first_free=h->old_ff;
-	set_size(h, h->first_free, 0xffff-h->first_free);
+void restore_ff(heap_t* h) {
+	h->first_free = h->old_ff;
+	set_size(h, h->first_free, 0xffff - h->first_free);
 	set_next(h, h->first_free, 0xffff);
 }
 
 
 
-void heap_dump_free(heap_t *h)
-{
+void heap_dump_free(heap_t *h) {
 	int freedomseeker;
 
 	printf("\tfirst_free= %#x (oldff= %#x)\n\tFree Blocks:\n", h->first_free, h->old_ff);
@@ -243,8 +209,7 @@
 	}
 }
 
-void heap_dump_all(heap_t *h)
-{
+void heap_dump_all(heap_t *h) {
 	int seeker = 1000;
 	int free_seeker = h->first_free;
 
@@ -255,7 +220,7 @@
 		if (is_free)
 			free_seeker = get_next(h, free_seeker);
 
-		printf("%04x\t%d\t%s\n", seeker, size, is_free? "FREE": "");
+		printf("%04x\t%d\t%s\n", seeker, size, is_free ? "FREE" : "");
 		seeker += size;
 	}
 }

Modified: scummvm/trunk/engines/sci/engine/heap.h
===================================================================
--- scummvm/trunk/engines/sci/engine/heap.h	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/heap.h	2009-02-15 22:28:12 UTC (rev 38317)
@@ -35,8 +35,7 @@
 typedef guint16 heap_ptr;
 
 
-typedef struct
-{
+typedef struct {
 	byte* start;
 	byte* base;
 	unsigned int first_free;

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -195,172 +195,171 @@
 #define NOFUN(nm) {KF_NONE, nm, {NULL, NULL, NULL}}
 
 sci_kernel_function_t kfunct_mappers[] = {
-/*00*/	DEFUN("Load", kLoad, "iii*"),
-/*01*/	DEFUN("UnLoad", kUnLoad, "i.*"),
-/*02*/	DEFUN("ScriptID", kScriptID, "Ioi*"),
-/*03*/	DEFUN("DisposeScript", kDisposeScript, "Oi"), /* Work around QfG1 bug */
-/*04*/	DEFUN("Clone", kClone, "o"),
-/*05*/	DEFUN("DisposeClone", kDisposeClone, "o"),
-/*06*/	DEFUN("IsObject", kIsObject, "."),
-/*07*/	DEFUN("RespondsTo", kRespondsTo, ".i"),
-/*08*/	DEFUN("DrawPic", kDrawPic, "i*"),
-/*09*/	DEFUN("Show", kShow, "i"),
-/*0a*/	DEFUN("PicNotValid", kPicNotValid, "i*"),
-/*0b*/	DEFUN("Animate", kAnimate, "LI*"), /* More like (li?)? */
-/*0c*/	DEFUN("SetNowSeen", kSetNowSeen, "oi*"), /* The second parameter is ignored */
-/*0d*/	DEFUN("NumLoops", kNumLoops, "o"),
-/*0e*/	DEFUN("NumCels", kNumCels, "o"),
-/*0f*/	DEFUN("CelWide", kCelWide, "iOiOi"),
-/*10*/	DEFUN("CelHigh", kCelHigh, "iOiOi"),
-/*11*/	DEFUN("DrawCel", kDrawCel, "iiiiii*"),
-/*12*/	DEFUN("AddToPic", kAddToPic, "Il*"),
-/*13*/	DEFUN("NewWindow", kNewWindow, "iiiiZRi*"),
-/*14*/	DEFUN("GetPort", kGetPort, ""),
-/*15*/	DEFUN("SetPort", kSetPort, "ii*"),
-/*16*/	DEFUN("DisposeWindow", kDisposeWindow, "ii*"),
-/*17*/	DEFUN("DrawControl", kDrawControl, "o"),
-/*18*/	DEFUN("HiliteControl", kHiliteControl, "o"),
-/*19*/	DEFUN("EditControl", kEditControl, "ZoZo"),
-/*1a*/	DEFUN("TextSize", kTextSize, "rZrii*r*"),
-/*1b*/	DEFUN("Display", kDisplay, ".*"),
-/*1c*/	DEFUN("GetEvent", kGetEvent, "io"),
-/*1d*/	DEFUN("GlobalToLocal", kGlobalToLocal, "o"),
-/*1e*/	DEFUN("LocalToGlobal", kLocalToGlobal, "o"),
-/*1f*/	DEFUN("MapKeyToDir", kMapKeyToDir, "o"),
-/*20*/	DEFUN("DrawMenuBar", kDrawMenuBar, "i"),
-/*21*/	DEFUN("MenuSelect", kMenuSelect, "oi*"),
-/*22*/	DEFUN("AddMenu", kAddMenu, "rr"),
-/*23*/	DEFUN("DrawStatus", kDrawStatus, "Zri*"),
-/*24*/	DEFUN("Parse", kParse, "ro"),
-/*25*/	DEFUN("Said", kSaid, "Zr"),
-/*26*/	DEFUN("SetSynonyms", kSetSynonyms, "o"),
-/*27*/	DEFUN("HaveMouse", kHaveMouse, ""),
-/*28*/	DEFUN("SetCursor", kSetCursor, "i*"),
-/*28*/	DEFUN("MoveCursor", kMoveCursor, "ii*"),
-/*29*/	DEFUN("FOpen", kFOpen, "ri"),
-/*2a*/	DEFUN("FPuts", kFPuts, "ir"),
-/*2b*/	DEFUN("FGets", kFGets, "rii"),
-/*2c*/	DEFUN("FClose", kFClose, "i"),
-/*2d*/	DEFUN("SaveGame", kSaveGame, "rirr*"),
-/*2e*/	DEFUN("RestoreGame", kRestoreGame, "rir*"),
-/*2f*/	DEFUN("RestartGame", kRestartGame, ""),
-/*30*/	DEFUN("GameIsRestarting", kGameIsRestarting, "i*"),
-/*31*/	DEFUN("DoSound", kDoSound, "iIo*"),
-/*32*/	DEFUN("NewList", kNewList, ""),
-/*33*/	DEFUN("DisposeList", kDisposeList, "l"),
-/*34*/	DEFUN("NewNode", kNewNode, ".."),
-/*35*/	DEFUN("FirstNode", kFirstNode, "Zl"),
-/*36*/	DEFUN("LastNode", kLastNode, "l"),
-/*37*/	DEFUN("EmptyList", kEmptyList, "l"),
-/*38*/	DEFUN("NextNode", kNextNode, "n!"),
-/*39*/	DEFUN("PrevNode", kPrevNode, "n"),
-/*3a*/	DEFUN("NodeValue", kNodeValue, "Zn!"),
-/*3b*/	DEFUN("AddAfter", kAddAfter, "lnn"),
-/*3c*/	DEFUN("AddToFront", kAddToFront, "ln"),
-/*3d*/	DEFUN("AddToEnd", kAddToEnd, "ln"),
-/*3e*/	DEFUN("FindKey", kFindKey, "l."),
-/*3f*/	DEFUN("DeleteKey", kDeleteKey, "l."),
-/*40*/	DEFUN("Random", kRandom, "i*"),
-/*41*/	DEFUN("Abs", kAbs, "Oi"),
-/*42*/	DEFUN("Sqrt", kSqrt, "i"),
-/*43*/	DEFUN("GetAngle", kGetAngle, "iiii"),
-/*44*/	DEFUN("GetDistance", kGetDistance, "iiiii*"),
-/*45*/	DEFUN("Wait", kWait, "i"),
-/*46*/	DEFUN("GetTime", kGetTime, "i*"),
-/*47*/	DEFUN("StrEnd", kStrEnd, "r"),
-/*48*/	DEFUN("StrCat", kStrCat, "rr"),
-/*49*/	DEFUN("StrCmp", kStrCmp, "rri*"),
-/*4a*/	DEFUN("StrLen", kStrLen, "r"),
-/*4b*/	DEFUN("StrCpy", kStrCpy, "rri*"),
-/*4c*/	DEFUN("Format", kFormat, "r.*"),
-/*4d*/	DEFUN("GetFarText", kGetFarText, "iir"),
-/*4e*/	DEFUN("ReadNumber", kReadNumber, "r"),
-/*4f*/	DEFUN("BaseSetter", kBaseSetter, "o"),
-/*50*/	DEFUN("DirLoop", kDirLoop, "oi"),
-/*51*/	DEFUN("CanBeHere", kCanBeHere, "ol*"),
-/*51*/	DEFUN("CantBeHere", kCanBeHere, "ol*"),
-/*52*/	DEFUN("OnControl", kOnControl, "i*"),
-/*53*/	DEFUN("InitBresen", kInitBresen, "oi*"),
-/*54*/	DEFUN("DoBresen", kDoBresen, "o"),
-/*55*/	DEFUN("DoAvoider", kDoAvoider, "o"),
-/*56*/	DEFUN("SetJump", kSetJump, "oiii"),
-/*57*/	DEFUN("SetDebug", kSetDebug, "i*"),
-/*58*/	NOFUN("InspectObj"),
-/*59*/	NOFUN("ShowSends"),
-/*5a*/	NOFUN("ShowObjs"),
-/*5b*/	NOFUN("ShowFree"),
-/*5c*/	DEFUN("MemoryInfo", kMemoryInfo, "i"),
-/*5d*/	NOFUN("StackUsage"),
-/*5e*/	NOFUN("Profiler"),
-/*5f*/	DEFUN("GetMenu", kGetMenu, "i."),
-/*60*/	DEFUN("SetMenu", kSetMenu, "i.*"),
-/*61*/	DEFUN("GetSaveFiles", kGetSaveFiles, "rrr"),
-/*62*/	DEFUN("GetCWD", kGetCWD, "r"),
-/*63*/	DEFUN("CheckFreeSpace", kCheckFreeSpace, "r"),
-/*64*/	DEFUN("ValidPath", kValidPath, "r"),
-/*65*/	DEFUN("CoordPri", kCoordPri, "i"),
-/*66*/	DEFUN("StrAt", kStrAt, "rii*"),
+	/*00*/	DEFUN("Load", kLoad, "iii*"),
+	/*01*/	DEFUN("UnLoad", kUnLoad, "i.*"),
+	/*02*/	DEFUN("ScriptID", kScriptID, "Ioi*"),
+	/*03*/	DEFUN("DisposeScript", kDisposeScript, "Oi"), /* Work around QfG1 bug */
+	/*04*/	DEFUN("Clone", kClone, "o"),
+	/*05*/	DEFUN("DisposeClone", kDisposeClone, "o"),
+	/*06*/	DEFUN("IsObject", kIsObject, "."),
+	/*07*/	DEFUN("RespondsTo", kRespondsTo, ".i"),
+	/*08*/	DEFUN("DrawPic", kDrawPic, "i*"),
+	/*09*/	DEFUN("Show", kShow, "i"),
+	/*0a*/	DEFUN("PicNotValid", kPicNotValid, "i*"),
+	/*0b*/	DEFUN("Animate", kAnimate, "LI*"), /* More like (li?)? */
+	/*0c*/	DEFUN("SetNowSeen", kSetNowSeen, "oi*"), /* The second parameter is ignored */
+	/*0d*/	DEFUN("NumLoops", kNumLoops, "o"),
+	/*0e*/	DEFUN("NumCels", kNumCels, "o"),
+	/*0f*/	DEFUN("CelWide", kCelWide, "iOiOi"),
+	/*10*/	DEFUN("CelHigh", kCelHigh, "iOiOi"),
+	/*11*/	DEFUN("DrawCel", kDrawCel, "iiiiii*"),
+	/*12*/	DEFUN("AddToPic", kAddToPic, "Il*"),
+	/*13*/	DEFUN("NewWindow", kNewWindow, "iiiiZRi*"),
+	/*14*/	DEFUN("GetPort", kGetPort, ""),
+	/*15*/	DEFUN("SetPort", kSetPort, "ii*"),
+	/*16*/	DEFUN("DisposeWindow", kDisposeWindow, "ii*"),
+	/*17*/	DEFUN("DrawControl", kDrawControl, "o"),
+	/*18*/	DEFUN("HiliteControl", kHiliteControl, "o"),
+	/*19*/	DEFUN("EditControl", kEditControl, "ZoZo"),
+	/*1a*/	DEFUN("TextSize", kTextSize, "rZrii*r*"),
+	/*1b*/	DEFUN("Display", kDisplay, ".*"),
+	/*1c*/	DEFUN("GetEvent", kGetEvent, "io"),
+	/*1d*/	DEFUN("GlobalToLocal", kGlobalToLocal, "o"),
+	/*1e*/	DEFUN("LocalToGlobal", kLocalToGlobal, "o"),
+	/*1f*/	DEFUN("MapKeyToDir", kMapKeyToDir, "o"),
+	/*20*/	DEFUN("DrawMenuBar", kDrawMenuBar, "i"),
+	/*21*/	DEFUN("MenuSelect", kMenuSelect, "oi*"),
+	/*22*/	DEFUN("AddMenu", kAddMenu, "rr"),
+	/*23*/	DEFUN("DrawStatus", kDrawStatus, "Zri*"),
+	/*24*/	DEFUN("Parse", kParse, "ro"),
+	/*25*/	DEFUN("Said", kSaid, "Zr"),
+	/*26*/	DEFUN("SetSynonyms", kSetSynonyms, "o"),
+	/*27*/	DEFUN("HaveMouse", kHaveMouse, ""),
+	/*28*/	DEFUN("SetCursor", kSetCursor, "i*"),
+	/*28*/	DEFUN("MoveCursor", kMoveCursor, "ii*"),
+	/*29*/	DEFUN("FOpen", kFOpen, "ri"),
+	/*2a*/	DEFUN("FPuts", kFPuts, "ir"),
+	/*2b*/	DEFUN("FGets", kFGets, "rii"),
+	/*2c*/	DEFUN("FClose", kFClose, "i"),
+	/*2d*/	DEFUN("SaveGame", kSaveGame, "rirr*"),
+	/*2e*/	DEFUN("RestoreGame", kRestoreGame, "rir*"),
+	/*2f*/	DEFUN("RestartGame", kRestartGame, ""),
+	/*30*/	DEFUN("GameIsRestarting", kGameIsRestarting, "i*"),
+	/*31*/	DEFUN("DoSound", kDoSound, "iIo*"),
+	/*32*/	DEFUN("NewList", kNewList, ""),
+	/*33*/	DEFUN("DisposeList", kDisposeList, "l"),
+	/*34*/	DEFUN("NewNode", kNewNode, ".."),
+	/*35*/	DEFUN("FirstNode", kFirstNode, "Zl"),
+	/*36*/	DEFUN("LastNode", kLastNode, "l"),
+	/*37*/	DEFUN("EmptyList", kEmptyList, "l"),
+	/*38*/	DEFUN("NextNode", kNextNode, "n!"),
+	/*39*/	DEFUN("PrevNode", kPrevNode, "n"),
+	/*3a*/	DEFUN("NodeValue", kNodeValue, "Zn!"),
+	/*3b*/	DEFUN("AddAfter", kAddAfter, "lnn"),
+	/*3c*/	DEFUN("AddToFront", kAddToFront, "ln"),
+	/*3d*/	DEFUN("AddToEnd", kAddToEnd, "ln"),
+	/*3e*/	DEFUN("FindKey", kFindKey, "l."),
+	/*3f*/	DEFUN("DeleteKey", kDeleteKey, "l."),
+	/*40*/	DEFUN("Random", kRandom, "i*"),
+	/*41*/	DEFUN("Abs", kAbs, "Oi"),
+	/*42*/	DEFUN("Sqrt", kSqrt, "i"),
+	/*43*/	DEFUN("GetAngle", kGetAngle, "iiii"),
+	/*44*/	DEFUN("GetDistance", kGetDistance, "iiiii*"),
+	/*45*/	DEFUN("Wait", kWait, "i"),
+	/*46*/	DEFUN("GetTime", kGetTime, "i*"),
+	/*47*/	DEFUN("StrEnd", kStrEnd, "r"),
+	/*48*/	DEFUN("StrCat", kStrCat, "rr"),
+	/*49*/	DEFUN("StrCmp", kStrCmp, "rri*"),
+	/*4a*/	DEFUN("StrLen", kStrLen, "r"),
+	/*4b*/	DEFUN("StrCpy", kStrCpy, "rri*"),
+	/*4c*/	DEFUN("Format", kFormat, "r.*"),
+	/*4d*/	DEFUN("GetFarText", kGetFarText, "iir"),
+	/*4e*/	DEFUN("ReadNumber", kReadNumber, "r"),
+	/*4f*/	DEFUN("BaseSetter", kBaseSetter, "o"),
+	/*50*/	DEFUN("DirLoop", kDirLoop, "oi"),
+	/*51*/	DEFUN("CanBeHere", kCanBeHere, "ol*"),
+	/*51*/	DEFUN("CantBeHere", kCanBeHere, "ol*"),
+	/*52*/	DEFUN("OnControl", kOnControl, "i*"),
+	/*53*/	DEFUN("InitBresen", kInitBresen, "oi*"),
+	/*54*/	DEFUN("DoBresen", kDoBresen, "o"),
+	/*55*/	DEFUN("DoAvoider", kDoAvoider, "o"),
+	/*56*/	DEFUN("SetJump", kSetJump, "oiii"),
+	/*57*/	DEFUN("SetDebug", kSetDebug, "i*"),
+	/*58*/	NOFUN("InspectObj"),
+	/*59*/	NOFUN("ShowSends"),
+	/*5a*/	NOFUN("ShowObjs"),
+	/*5b*/	NOFUN("ShowFree"),
+	/*5c*/	DEFUN("MemoryInfo", kMemoryInfo, "i"),
+	/*5d*/	NOFUN("StackUsage"),
+	/*5e*/	NOFUN("Profiler"),
+	/*5f*/	DEFUN("GetMenu", kGetMenu, "i."),
+	/*60*/	DEFUN("SetMenu", kSetMenu, "i.*"),
+	/*61*/	DEFUN("GetSaveFiles", kGetSaveFiles, "rrr"),
+	/*62*/	DEFUN("GetCWD", kGetCWD, "r"),
+	/*63*/	DEFUN("CheckFreeSpace", kCheckFreeSpace, "r"),
+	/*64*/	DEFUN("ValidPath", kValidPath, "r"),
+	/*65*/	DEFUN("CoordPri", kCoordPri, "i"),
+	/*66*/	DEFUN("StrAt", kStrAt, "rii*"),
 #ifdef WIN32
-/*67*/	DEFUN("DeviceInfo", kDeviceInfo_Win32, "i.*"),
+	/*67*/	DEFUN("DeviceInfo", kDeviceInfo_Win32, "i.*"),
 #else /* !WIN32 */
-/*67*/	DEFUN("DeviceInfo", kDeviceInfo_Unix, "i.*"),
+	/*67*/	DEFUN("DeviceInfo", kDeviceInfo_Unix, "i.*"),
 #endif
-/*68*/	DEFUN("GetSaveDir", kGetSaveDir, ""),
-/*69*/	DEFUN("CheckSaveGame", kCheckSaveGame, ".*"),
-/*6a*/	DEFUN("ShakeScreen", kShakeScreen, "ii*"),
-/*6b*/	DEFUN("FlushResources", kFlushResources, "i"),
-/*6c*/	DEFUN("TimesSin", kTimesSin, "ii"),
-/*6d*/	DEFUN("TimesCos", kTimesCos, "ii"),
+	/*68*/	DEFUN("GetSaveDir", kGetSaveDir, ""),
+	/*69*/	DEFUN("CheckSaveGame", kCheckSaveGame, ".*"),
+	/*6a*/	DEFUN("ShakeScreen", kShakeScreen, "ii*"),
+	/*6b*/	DEFUN("FlushResources", kFlushResources, "i"),
+	/*6c*/	DEFUN("TimesSin", kTimesSin, "ii"),
+	/*6d*/	DEFUN("TimesCos", kTimesCos, "ii"),
 #if 0
-/*6e*/	NOFUN(NULL),
-/*6f*/	NOFUN(NULL),
+	/*6e*/	NOFUN(NULL),
+	/*6f*/	NOFUN(NULL),
 #else
-/*6e*/	DEFUN("6e", kTimesSin, "ii"),
-/*6f*/	DEFUN("6f", kTimesCos, "ii"),
+	/*6e*/	DEFUN("6e", kTimesSin, "ii"),
+	/*6f*/	DEFUN("6f", kTimesCos, "ii"),
 #endif
-/*70*/	DEFUN("Graph", kGraph, ".*"),
-/*71*/	DEFUN("Joystick", kJoystick, ".*"),
-/*72*/	NOFUN(NULL),
-/*73*/	NOFUN(NULL),
+	/*70*/	DEFUN("Graph", kGraph, ".*"),
+	/*71*/	DEFUN("Joystick", kJoystick, ".*"),
+	/*72*/	NOFUN(NULL),
+	/*73*/	NOFUN(NULL),
 
-  /* Experimental functions */
-/*74*/	DEFUN("FileIO", kFileIO, "i.*"),
-/*(?)*/	DEFUN("Memory", kMemory, "i.*"),
-/*(?)*/	DEFUN("Sort", kSort, "ooo"),
-/*(?)*/	DEFUN("AvoidPath", kAvoidPath, "ii.*"),
-/*(?)*/	DEFUN("Lock", kLock, "iii*"),
-/*(?)*/	DEFUN("Palette", kPalette, "i*"),
-/*(?)*/	DEFUN("IsItSkip", kIsItSkip, "iiiii"),
+	/* Experimental functions */
+	/*74*/	DEFUN("FileIO", kFileIO, "i.*"),
+	/*(?)*/	DEFUN("Memory", kMemory, "i.*"),
+	/*(?)*/	DEFUN("Sort", kSort, "ooo"),
+	/*(?)*/	DEFUN("AvoidPath", kAvoidPath, "ii.*"),
+	/*(?)*/	DEFUN("Lock", kLock, "iii*"),
+	/*(?)*/	DEFUN("Palette", kPalette, "i*"),
+	/*(?)*/	DEFUN("IsItSkip", kIsItSkip, "iiiii"),
 
-  /* Non-experimental Functions without a fixed ID */
+	/* Non-experimental Functions without a fixed ID */
 
 	DEFUN("CosMult", kTimesCos, "ii"),
 	DEFUN("SinMult", kTimesSin, "ii"),
-/*(?)*/	DEFUN("CosDiv", kCosDiv, "ii"),
-/*(?)*/	DEFUN("PriCoord", kPriCoord, "i"),
-/*(?)*/	DEFUN("SinDiv", kSinDiv, "ii"),
-/*(?)*/	DEFUN("TimesCot", kTimesCot, "ii"),
-/*(?)*/	DEFUN("TimesTan", kTimesTan, "ii"),
-DEFUN("Message", kMessage, ".*"),
-DEFUN("DoAudio", kDoAudio, ".*"),
+	/*(?)*/	DEFUN("CosDiv", kCosDiv, "ii"),
+	/*(?)*/	DEFUN("PriCoord", kPriCoord, "i"),
+	/*(?)*/	DEFUN("SinDiv", kSinDiv, "ii"),
+	/*(?)*/	DEFUN("TimesCot", kTimesCot, "ii"),
+	/*(?)*/	DEFUN("TimesTan", kTimesTan, "ii"),
+	DEFUN("Message", kMessage, ".*"),
+	DEFUN("DoAudio", kDoAudio, ".*"),
 
 
-  /* Special and NOP stuff */
+	/* Special and NOP stuff */
 	{KF_NEW, NULL, {k_Unknown, NULL, NULL}},
 
 	{KF_TERMINATOR, NULL, {NULL, NULL, NULL}} /* Terminator */
 };
 
-static const char *argtype_description[] = {"Undetermined (WTF?)", "List","Node","Object","Reference","Arithmetic"};
+static const char *argtype_description[] = {"Undetermined (WTF?)", "List", "Node", "Object", "Reference", "Arithmetic"};
 
 
 /******************** Kernel Oops ********************/
 
 int
-kernel_oops(state_t *s, const char *file, int line, const char *reason)
-{
+kernel_oops(state_t *s, const char *file, int line, const char *reason) {
 	sciprintf("Kernel Oops in file %s, line %d: %s\n", file, line, reason);
-	fprintf(stderr,"Kernel Oops in file %s, line %d: %s\n", file, line, reason);
+	fprintf(stderr, "Kernel Oops in file %s, line %d: %s\n", file, line, reason);
 	script_debug_flag = script_error_flag = 1;
 	return 0;
 }
@@ -368,8 +367,7 @@
 
 /* Allocates a set amount of memory for a specified use and returns a handle to it. */
 reg_t
-kalloc(state_t *s, const char *type, int space)
-{
+kalloc(state_t *s, const char *type, int space) {
 	reg_t reg;
 
 	sm_alloc_hunk_entry(&s->seg_manager, type, space, &reg);
@@ -379,12 +377,10 @@
 }
 
 int
-has_kernel_function(state_t *s, const char *kname)
-{
+has_kernel_function(state_t *s, const char *kname) {
 	int i = 0;
 
-	while (s->kernel_names[i])
-	{
+	while (s->kernel_names[i]) {
 		if (!strcmp(s->kernel_names[i], kname))
 			return 1;
 		i++;
@@ -395,8 +391,7 @@
 
 /* Returns a pointer to the memory indicated by the specified handle */
 byte *
-kmem(state_t *s, reg_t handle)
-{
+kmem(state_t *s, reg_t handle) {
 	mem_obj_t *mobj = GET_SEGMENT(s->seg_manager, handle.segment, MEM_OBJ_HUNK);
 	hunk_table_t *ht = &(mobj->data.hunks);
 
@@ -410,8 +405,7 @@
 
 /* Frees the specified handle. Returns 0 on success, 1 otherwise. */
 int
-kfree(state_t *s, reg_t handle)
-{
+kfree(state_t *s, reg_t handle) {
 	sm_free_hunk_entry(&s->seg_manager, handle);
 
 	return 0;
@@ -425,8 +419,7 @@
 char *old_save_dir;
 
 reg_t
-kRestartGame(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kRestartGame(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	char *deref_save_dir = (char*)kernel_dereference_bulk_pointer(s, s->save_dir_copy, 1);
 
 	old_save_dir = strdup(deref_save_dir);
@@ -442,12 +435,10 @@
 ** Returns the restarting_flag in acc
 */
 reg_t
-kGameIsRestarting(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kGameIsRestarting(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	char *deref_save_dir = (char*)kernel_dereference_bulk_pointer(s, s->save_dir_copy, 1);
 
-	if (old_save_dir&&deref_save_dir)
-	{
+	if (old_save_dir && deref_save_dir) {
 		strcpy(deref_save_dir, old_save_dir);
 		free(old_save_dir);
 		old_save_dir = NULL;
@@ -464,18 +455,16 @@
 }
 
 reg_t
-kHaveMouse(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kHaveMouse(state_t *s, int funct_nr, int argc, reg_t *argv) {
 
-	return make_reg (0, (s->have_mouse_flag
-		  && gfxop_have_mouse(s->gfx_state))? -1 : 0);
+	return make_reg(0, (s->have_mouse_flag
+	                    && gfxop_have_mouse(s->gfx_state)) ? -1 : 0);
 }
 
 
 
 reg_t
-kMemoryInfo(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kMemoryInfo(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	switch (argv[0].offset) {
 	case 0: /* Total free heap memory */
 	case 1: /* Largest heap block available */
@@ -484,42 +473,40 @@
 	case 4: /* Amount of free DOS paragraphs- SCI01 */
 		return make_reg(0, 0x7fff); /* Must not be 0xffff, or some memory calculations will overflow */
 
-	default: SCIkwarn(SCIkWARNING, "Unknown MemoryInfo operation: %04x\n", argv[0].offset);
+	default:
+		SCIkwarn(SCIkWARNING, "Unknown MemoryInfo operation: %04x\n", argv[0].offset);
 	}
 	return NULL_REG;
 }
 
 
 reg_t
-k_Unknown(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+k_Unknown(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	if (funct_nr >= SCI_MAPPED_UNKNOWN_KFUNCTIONS_NR) {
 		SCIkwarn(SCIkSTUB, "Unhandled Unknown function %04x\n", funct_nr);
 		return NULL_REG;
-	} else switch(kfunct_mappers[funct_nr].type) {
+	} else switch (kfunct_mappers[funct_nr].type) {
 
-	case KF_NEW:
-		return kfunct_mappers[funct_nr].sig_pair.fun(s, funct_nr, argc, argv);
+		case KF_NEW:
+			return kfunct_mappers[funct_nr].sig_pair.fun(s, funct_nr, argc, argv);
 
-	case KF_NONE:
-	default:
-		SCIkwarn(SCIkSTUB, "Unhandled Unknown function %04x\n", funct_nr);
-		return NULL_REG;
-	}
+		case KF_NONE:
+		default:
+			SCIkwarn(SCIkSTUB, "Unhandled Unknown function %04x\n", funct_nr);
+			return NULL_REG;
+		}
 }
 
 
 reg_t
-kFlushResources(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kFlushResources(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	run_gc(s);
 	SCIkdebug(SCIkROOM, "Entering room number %d\n", UKPV(0));
 	return s->r_acc;
 }
 
 reg_t
-kSetDebug(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kSetDebug(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	sciprintf("Debug mode activated\n");
 
 	script_debug_flag = 1; /* Enter debug mode */
@@ -533,8 +520,7 @@
 #define _K_NEW_GETTIME_DATE 3
 
 reg_t
-kGetTime(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kGetTime(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	struct tm* loc_time;
 	GTimeVal time_prec;
 	time_t the_time;
@@ -544,12 +530,11 @@
 	/* Reset optimization flags: If this function is called,
 	** the game may be waiting for a timeout  */
 	s->kernel_opt_flags &= ~(KERNEL_OPT_FLAG_GOT_EVENT
-				 | KERNEL_OPT_FLAG_GOT_2NDEVENT);
+	                         | KERNEL_OPT_FLAG_GOT_2NDEVENT);
 #endif
 
 #ifdef WIN32
-	if (TIMERR_NOERROR != timeBeginPeriod(1))
-	{
+	if (TIMERR_NOERROR != timeBeginPeriod(1)) {
 		fprintf(stderr, "timeBeginPeriod(1) failed in kGetTime!\n");
 	}
 #endif /* WIN32 */
@@ -558,20 +543,19 @@
 	loc_time = localtime(&the_time);
 
 #ifdef WIN32
-	if (TIMERR_NOERROR != timeEndPeriod(1))
-	{
+	if (TIMERR_NOERROR != timeEndPeriod(1)) {
 		fprintf(stderr, "timeEndPeriod(1) failed in kGetTime!\n");
 	}
 #endif /* WIN32 */
 
-	if (s->version<SCI_VERSION_FTU_NEW_GETTIME) { /* Use old semantics */
+	if (s->version < SCI_VERSION_FTU_NEW_GETTIME) { /* Use old semantics */
 		if (argc) { /* Get seconds since last am/pm switch */
 			retval = loc_time->tm_sec + loc_time->tm_min * 60 + (loc_time->tm_hour % 12) * 3600;
 			SCIkdebug(SCIkTIME, "GetTime(timeofday) returns %d\n", retval);
 		} else { /* Get time since game started */
-			sci_get_current_time (&time_prec);
+			sci_get_current_time(&time_prec);
 			retval = ((time_prec.tv_usec - s->game_start_time.tv_usec) * 60 / 1000000) +
-				(time_prec.tv_sec - s->game_start_time.tv_sec) * 60;
+			         (time_prec.tv_sec - s->game_start_time.tv_sec) * 60;
 			SCIkdebug(SCIkTIME, "GetTime(elapsed) returns %d\n", retval);
 		}
 	} else {
@@ -579,25 +563,25 @@
 					         mode 0 and the others. We assume that this is safe, though */
 		switch (mode) {
 		case _K_NEW_GETTIME_TICKS : {
-			sci_get_current_time (&time_prec);
+			sci_get_current_time(&time_prec);
 			retval = ((time_prec.tv_usec - s->game_start_time.tv_usec) * 60 / 1000000) +
-				  (time_prec.tv_sec - s->game_start_time.tv_sec) * 60;
+			         (time_prec.tv_sec - s->game_start_time.tv_sec) * 60;
 			SCIkdebug(SCIkTIME, "GetTime(elapsed) returns %d\n", retval);
 			break;
 		}
 		case _K_NEW_GETTIME_TIME_12HOUR : {
 			loc_time->tm_hour %= 12;
-			retval=(loc_time->tm_min<<6)|(loc_time->tm_hour<<12)|(loc_time->tm_sec);
+			retval = (loc_time->tm_min << 6) | (loc_time->tm_hour << 12) | (loc_time->tm_sec);
 			SCIkdebug(SCIkTIME, "GetTime(12h) returns %d\n", retval);
 			break;
 		}
 		case _K_NEW_GETTIME_TIME_24HOUR : {
-			retval=(loc_time->tm_min<<5)|(loc_time->tm_sec>>1)|(loc_time->tm_hour<<11);
+			retval = (loc_time->tm_min << 5) | (loc_time->tm_sec >> 1) | (loc_time->tm_hour << 11);
 			SCIkdebug(SCIkTIME, "GetTime(24h) returns %d\n", retval);
 			break;
 		}
 		case _K_NEW_GETTIME_DATE : {
-			retval=(loc_time->tm_mon<<5)|loc_time->tm_mday|(loc_time->tm_year<<9);
+			retval = (loc_time->tm_mon << 5) | loc_time->tm_mday | (loc_time->tm_year << 9);
 			SCIkdebug(SCIkTIME, "GetTime(date) returns %d\n", retval);
 			break;
 		}
@@ -619,15 +603,14 @@
 #define K_MEMORY_POKE			6
 
 reg_t
-kMemory(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kMemory(state_t *s, int funct_nr, int argc, reg_t *argv) {
 
 	switch (UKPV(0)) {
 
 	case K_MEMORY_ALLOCATE_CRITICAL :
 
-		if (!sm_alloc_dynmem(&s->seg_manager, UKPV(1), 
-				     "kMemory() critical", &s->r_acc)) {
+		if (!sm_alloc_dynmem(&s->seg_manager, UKPV(1),
+		                     "kMemory() critical", &s->r_acc)) {
 			SCIkwarn(SCIkERROR, "Critical heap allocation failed\n");
 			script_error_flag = script_debug_flag = 1;
 		}
@@ -638,14 +621,14 @@
 	case K_MEMORY_ALLOCATE_NONCRITICAL :
 
 		sm_alloc_dynmem(&s->seg_manager, UKPV(1),
-				"kMemory() non-critical", &s->r_acc);
+		                "kMemory() non-critical", &s->r_acc);
 		break;
 
 	case K_MEMORY_FREE :
 
 		if (sm_free_dynmem(&s->seg_manager, argv[1])) {
 			SCIkwarn(SCIkERROR, "Attempt to kMemory::free() non-dynmem pointer "PREG"!\n",
-				 PRINT_REG(argv[1]));
+			         PRINT_REG(argv[1]));
 		}
 		break;
 
@@ -667,42 +650,43 @@
 		}
 
 		break;
-		}
+	}
 
 	case K_MEMORY_PEEK : {
 		byte *ref = kernel_dereference_bulk_pointer(s, argv[1], 2);
 
 		if (!ref) {
 			SCIkdebug(SCIkERROR, "Attempt to poke invalid memory at "PREG"!\n",
-				  PRINT_REG(argv[1]));
+			          PRINT_REG(argv[1]));
 			return s->r_acc;
 		}
 		if (s->seg_manager.heap[argv[1].segment]->type == MEM_OBJ_LOCALS)
-			return *((reg_t *) ref); else
+			return *((reg_t *) ref);
+		else
 			return make_reg(0, getInt16(ref));
 	}
-		break;
+	break;
 
 	case K_MEMORY_POKE : {
 		byte *ref = kernel_dereference_bulk_pointer(s, argv[1], 2);
 
 		if (!ref) {
 			SCIkdebug(SCIkERROR, "Attempt to poke invalid memory at "PREG"!\n",
-				  PRINT_REG(argv[1]));
+			          PRINT_REG(argv[1]));
 			return s->r_acc;
 		}
 
 		if (s->seg_manager.heap[argv[1].segment]->type == MEM_OBJ_LOCALS)
-			*((reg_t *) ref) = argv[2]; else
-			{
-				if (argv[2].segment) {
-					SCIkdebug(SCIkERROR, "Attempt to poke memory reference "PREG" to "PREG"!\n",
-						  PRINT_REG(argv[2]), PRINT_REG(argv[1]));
-					return s->r_acc;
-					putInt16(ref, argv[2].offset);
-				}
-				
+			*((reg_t *) ref) = argv[2];
+		else {
+			if (argv[2].segment) {
+				SCIkdebug(SCIkERROR, "Attempt to poke memory reference "PREG" to "PREG"!\n",
+				          PRINT_REG(argv[2]), PRINT_REG(argv[1]));
+				return s->r_acc;
+				putInt16(ref, argv[2].offset);
 			}
+
+		}
 		return s->r_acc;
 		break;
 
@@ -713,16 +697,15 @@
 }
 
 reg_t
-kstub(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kstub(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	int i;
 
 	SCIkwarn(SCIkWARNING, "Unimplemented syscall: %s[%x](",
-		 s->kernel_names[funct_nr], funct_nr);
+	         s->kernel_names[funct_nr], funct_nr);
 
 	for (i = 0; i < argc; i++) {
 		sciprintf(PREG, PRINT_REG(argv[i]));
-		if (i+1 < argc) sciprintf(", ");
+		if (i + 1 < argc) sciprintf(", ");
 	}
 	sciprintf(")\n");
 	return NULL_REG;
@@ -730,18 +713,16 @@
 
 
 reg_t
-kNOP(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kNOP(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	const char *problem = (const char*)(s->kfunct_table[funct_nr].orig_name ?
-		"unmapped" : "NOP");
+	                                    "unmapped" : "NOP");
 
 	SCIkwarn(SCIkWARNING, "Warning: Kernel function 0x%02x invoked: %s", funct_nr, problem);
 
 	if (s->kfunct_table[funct_nr].orig_name &&
-	    strcmp(s->kfunct_table[funct_nr].orig_name, SCRIPT_UNKNOWN_FUNCTION_STRING))
-	  {
-	    sciprintf(" (but its name is known to be %s)", s->kfunct_table[funct_nr].orig_name);
-	  }
+	        strcmp(s->kfunct_table[funct_nr].orig_name, SCRIPT_UNKNOWN_FUNCTION_STRING)) {
+		sciprintf(" (but its name is known to be %s)", s->kfunct_table[funct_nr].orig_name);
+	}
 
 	sciprintf("\n");
 	return NULL_REG;
@@ -750,8 +731,7 @@
 
 
 void
-kernel_compile_signature(const char **s)
-{
+kernel_compile_signature(const char **s) {
 	const char *src = *s;
 	char *result;
 	int ellipsis = 0;
@@ -769,8 +749,8 @@
 
 		if (ellipsis) {
 			sciprintf("INTERNAL ERROR when compiling kernel"
-				  " function signature '%s': non-terminal ellipsis\n", *s,
-				  *src);
+			          " function signature '%s': non-terminal ellipsis\n", *s,
+			          *src);
 			exit(1);
 		}
 
@@ -813,7 +793,7 @@
 			case KSIG_SPEC_ALLOW_INV:
 				v |= KSIG_ALLOW_INV;
 				break;
-			
+
 			case KSIG_SPEC_ELLIPSIS:
 				v |= KSIG_ELLIPSIS;
 				ellipsis = 1;
@@ -821,16 +801,16 @@
 
 			default: {
 				sciprintf("INTERNAL ERROR when compiling kernel"
-					  " function signature '%s': (%02x) not understood (aka"
-					  " '%c')\n",
-					  *s, c, c);
+				          " function signature '%s': (%02x) not understood (aka"
+				          " '%c')\n",
+				          *s, c, c);
 				exit(1);
 			}
 
 			}
-		} while (*src && (*src == KSIG_SPEC_ALLOW_INV || 
-				  *src == KSIG_SPEC_ELLIPSIS || 
-				  (c < 'a' && c != KSIG_SPEC_ANY)));
+		} while (*src && (*src == KSIG_SPEC_ALLOW_INV ||
+		                  *src == KSIG_SPEC_ELLIPSIS ||
+		                  (c < 'a' && c != KSIG_SPEC_ANY)));
 
 		/* To handle sum types */
 		result[index++] = v;
@@ -841,22 +821,21 @@
 }
 
 int
-script_map_kernel(state_t *s)
-{
+script_map_kernel(state_t *s) {
 	int functnr;
 	int mapped = 0;
 	int ignored = 0;
 	int functions_nr = s->kernel_names_nr;
 	int max_functions_nr
-		= sci_max_allowed_unknown_kernel_functions[s->resmgr
-							   ->sci_version];
+	= sci_max_allowed_unknown_kernel_functions[s->resmgr
+	        ->sci_version];
 
 	if (functions_nr < max_functions_nr) {
 		sciprintf("Warning: SCI version believed to have %d kernel"
-			  " functions, but only %d reported-- filling up"
-			  " remaining %d\n",
-			  max_functions_nr, functions_nr,
-			  max_functions_nr - functions_nr);
+		          " functions, but only %d reported-- filling up"
+		          " remaining %d\n",
+		          max_functions_nr, functions_nr,
+		          max_functions_nr - functions_nr);
 
 		functions_nr = max_functions_nr;
 	}
@@ -875,21 +854,19 @@
 
 		if (sought_name)
 			for (seeker = 0; (found == -1)
-				     && kfunct_mappers[seeker].type != KF_TERMINATOR; seeker++)
+			        && kfunct_mappers[seeker].type != KF_TERMINATOR; seeker++)
 				if (kfunct_mappers[seeker].name
-				    && strcmp(kfunct_mappers[seeker].name, sought_name) == 0)
+				        && strcmp(kfunct_mappers[seeker].name, sought_name) == 0)
 					found = seeker; /* Found a kernel function with the same name! */
 
 		if (found == -1) {
-			if (sought_name)
-			{
+			if (sought_name) {
 				sciprintf("Warning: Kernel function %s[%x] unmapped\n",
-					  s->kernel_names[functnr], functnr);
+				          s->kernel_names[functnr], functnr);
 				s->kfunct_table[functnr].fun = kNOP;
-			} else
-			{
+			} else {
 				sciprintf("Warning: Flagging kernel function %x as unknown\n",
-					  functnr);
+				          functnr);
 				s->kfunct_table[functnr].fun = k_Unknown;
 			}
 
@@ -897,26 +874,26 @@
 			s->kfunct_table[functnr].orig_name = sought_name;
 		} else switch (kfunct_mappers[found].type) {
 
-		case KF_OLD:
-			sciprintf("Emulated kernel function found.\nThis shouldn't happen anymore.");
-			return 1;
+			case KF_OLD:
+				sciprintf("Emulated kernel function found.\nThis shouldn't happen anymore.");
+				return 1;
 
-		case KF_NONE:
-			s->kfunct_table[functnr].signature = NULL;
-			++ignored;
-			break;
+			case KF_NONE:
+				s->kfunct_table[functnr].signature = NULL;
+				++ignored;
+				break;
 
-		case KF_NEW:
-			s->kfunct_table[functnr] = kfunct_mappers[found].sig_pair;
-			kernel_compile_signature(&(s->kfunct_table[functnr].signature));
-			++mapped;
-			break;
-		}
+			case KF_NEW:
+				s->kfunct_table[functnr] = kfunct_mappers[found].sig_pair;
+				kernel_compile_signature(&(s->kfunct_table[functnr].signature));
+				++mapped;
+				break;
+			}
 
 	} /* for all functions requesting to be mapped */
 
 	sciprintf("Handled %d/%d kernel functions, mapping %d",
-		  mapped+ignored, s->kernel_names_nr, mapped);
+	          mapped + ignored, s->kernel_names_nr, mapped);
 	if (ignored)
 		sciprintf(" and ignoring %d", ignored);
 	sciprintf(".\n");
@@ -924,15 +901,13 @@
 }
 
 void
-free_kfunct_tables(state_t *s)
-{
+free_kfunct_tables(state_t *s) {
 	sci_free(s->kfunct_table);
 	s->kfunct_table = NULL;
 
 }
 int
-determine_reg_type(state_t *s, reg_t reg, int allow_invalid)
-{
+determine_reg_type(state_t *s, reg_t reg, int allow_invalid) {
 	mem_obj_t *mobj;
 
 	if (!reg.segment) {
@@ -942,7 +917,7 @@
 	}
 
 	if ((reg.segment >= s->seg_manager.heap_size)
-	    || !s->seg_manager.heap[reg.segment])
+	        || !s->seg_manager.heap[reg.segment])
 		return 0; /* Invalid */
 
 	mobj = s->seg_manager.heap[reg.segment];
@@ -951,8 +926,8 @@
 
 	case MEM_OBJ_SCRIPT:
 		if (reg.offset <= mobj->data.script.buf_size
-		    && reg.offset >= -SCRIPT_OBJECT_MAGIC_OFFSET
-		    && RAW_IS_OBJECT(mobj->data.script.buf + reg.offset)) {
+		        && reg.offset >= -SCRIPT_OBJECT_MAGIC_OFFSET
+		        && RAW_IS_OBJECT(mobj->data.script.buf + reg.offset)) {
 			int idx = RAW_GET_CLASS_INDEX(&(mobj->data.script), reg);
 			if (idx >= 0 && idx < mobj->data.script.objects_nr)
 				return KSIG_OBJECT;
@@ -981,7 +956,7 @@
 
 	case MEM_OBJ_SYS_STRINGS:
 		if (allow_invalid || (reg.offset < SYS_STRINGS_MAX
-		    && mobj->data.sys_strings.strings[reg.offset].name))
+		                      && mobj->data.sys_strings.strings[reg.offset].name))
 			return KSIG_REF;
 		else
 			return KSIG_REF | KSIG_INVALID;
@@ -1011,16 +986,14 @@
 }
 
 const char *
-kernel_argtype_description(int type)
-{
-    type &= ~KSIG_INVALID;
-    
-    return argtype_description[sci_ffs(type)];
+kernel_argtype_description(int type) {
+	type &= ~KSIG_INVALID;
+
+	return argtype_description[sci_ffs(type)];
 }
 
 int
-kernel_matches_signature(state_t *s, const char *sig, int argc, reg_t *argv)
-{
+kernel_matches_signature(state_t *s, const char *sig, int argc, reg_t *argv) {
 	if (!sig)
 		return 1;
 
@@ -1030,15 +1003,15 @@
 
 			if (!type) {
 				sciprintf("[KERN] Could not determine type of ref "PREG";"
-					  " failing signature check\n",
-					  PRINT_REG(*argv));
+				          " failing signature check\n",
+				          PRINT_REG(*argv));
 				return 0;
 			}
-			
+
 			if (type & KSIG_INVALID) {
 				sciprintf("[KERN] ref "PREG" was determined to be a %s, "
-					  "but the reference itself is invalid\n",
-					  PRINT_REG(*argv), kernel_argtype_description(type));
+				          "but the reference itself is invalid\n",
+				          PRINT_REG(*argv), kernel_argtype_description(type));
 				return 0;
 			}
 
@@ -1059,35 +1032,32 @@
 }
 
 static inline void *
-_kernel_dereference_pointer(struct _state *s, reg_t pointer, int entries, int align)
-{
+_kernel_dereference_pointer(struct _state *s, reg_t pointer, int entries, int align) {
 	int maxsize;
-	void *retval = sm_dereference(&s->seg_manager, pointer, &maxsize); 
+	void *retval = sm_dereference(&s->seg_manager, pointer, &maxsize);
 
-	if (pointer.offset & (align-1)) {
+	if (pointer.offset & (align - 1)) {
 		SCIkdebug(SCIkERROR, "Unaligned pointer read: "PREG" expected with %d alignment!\n",
-			  PRINT_REG(pointer), align);
+		          PRINT_REG(pointer), align);
 		return NULL;
 	}
 
 	if (entries > maxsize) {
 		SCIkdebug(SCIkERROR, "Trying to dereference pointer "PREG" beyond end of segment!\n",
-			  PRINT_REG(pointer));
+		          PRINT_REG(pointer));
 		return NULL;
 	}
-		return retval;
+	return retval;
 
 }
 
 byte *
-kernel_dereference_bulk_pointer(struct _state *s, reg_t pointer, int entries)
-{
+kernel_dereference_bulk_pointer(struct _state *s, reg_t pointer, int entries) {
 	return (byte*)_kernel_dereference_pointer(s, pointer, entries, 1);
 }
 
 
 reg_t *
-kernel_dereference_reg_pointer(struct _state *s, reg_t pointer, int entries)
-{
+kernel_dereference_reg_pointer(struct _state *s, reg_t pointer, int entries) {
 	return (reg_t*)_kernel_dereference_pointer(s, pointer, entries, sizeof(reg_t));
 }

Modified: scummvm/trunk/engines/sci/engine/kernel_compat.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel_compat.h	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/kernel_compat.h	2009-02-15 22:28:12 UTC (rev 38317)
@@ -55,21 +55,19 @@
 /* Sets a heap value if allowed */
 
 static inline int
-getHeapInt16(unsigned char *base, int address)
-{
-  if (address & 1)
-    sciprintf("Warning: Unaligned read from %04x\n", (address) & 0xffff);
+getHeapInt16(unsigned char *base, int address) {
+	if (address & 1)
+		sciprintf("Warning: Unaligned read from %04x\n", (address) & 0xffff);
 
-  return getInt16(base + address);
+	return getInt16(base + address);
 }
 
 static inline unsigned int
-getHeapUInt16(unsigned char *base, int address)
-{
-  if (address & 1)
-    sciprintf("Warning: Unaligned unsigned read from %04x\n", (address) & 0xffff);
+getHeapUInt16(unsigned char *base, int address) {
+	if (address & 1)
+		sciprintf("Warning: Unaligned unsigned read from %04x\n", (address) & 0xffff);
 
-  return getUInt16(base + address);
+	return getUInt16(base + address);
 }
 
 

Modified: scummvm/trunk/engines/sci/engine/kernel_types.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel_types.h	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/kernel_types.h	2009-02-15 22:28:12 UTC (rev 38317)
@@ -81,7 +81,7 @@
 ** Parameters: (state_t *) s: The state to operate on
 **             (reg_t) reg: The register to check
 **	       (int) allow_invalid: Allow invalid pointer values
-** Returns   : one of KSIG_* below KSIG_NULL. 
+** Returns   : one of KSIG_* below KSIG_NULL.
 **	       KSIG_INVALID set if the type of reg can be determined, but is invalid.
 **	       0 on error.
 */

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -32,14 +32,13 @@
 #define SCI_VARIABLE_GAME_SPEED 3
 
 reg_t
-kGetEvent(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kGetEvent(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	int mask = UKPV(0);
 	reg_t obj = argv[1];
 	sci_event_t e;
 	int oldx, oldy;
-	int modifier_mask = SCI_VERSION_MAJOR(s->version)==0 ? SCI_EVM_ALL
-	                                                     : SCI_EVM_NO_FOOLOCK;
+	int modifier_mask = SCI_VERSION_MAJOR(s->version) == 0 ? SCI_EVM_ALL
+	                    : SCI_EVM_NO_FOOLOCK;
 
 	if (s->kernel_opt_flags & KERNEL_OPT_FLAG_GOT_2NDEVENT) {
 		/* Penalty time- too many requests to this function without
@@ -48,7 +47,7 @@
 
 		gfxop_usleep(s->gfx_state, (1000000 * delay) / 60);
 	}
-  
+
 	/*If there's a simkey pending, and the game wants a keyboard event, use the
 	 *simkey instead of a normal event*/
 	if (_kdebug_cheap_event_hack && (mask & SCI_EVT_KEYBOARD)) {
@@ -60,7 +59,7 @@
 		_kdebug_cheap_event_hack = 0;
 		return make_reg(0, 1);
 	}
-  
+
 	oldx = s->gfx_state->pointer_pos.x;
 	oldy = s->gfx_state->pointer_pos.y;
 	e = gfxop_get_event(s->gfx_state, mask);
@@ -75,7 +74,7 @@
 
 	if (e.type)
 		s->kernel_opt_flags &= ~(KERNEL_OPT_FLAG_GOT_EVENT
-					 | KERNEL_OPT_FLAG_GOT_2NDEVENT);
+		                         | KERNEL_OPT_FLAG_GOT_2NDEVENT);
 	else {
 		if (s->kernel_opt_flags & KERNEL_OPT_FLAG_GOT_EVENT)
 			s->kernel_opt_flags |= KERNEL_OPT_FLAG_GOT_2NDEVENT;
@@ -83,95 +82,118 @@
 			s->kernel_opt_flags |= KERNEL_OPT_FLAG_GOT_EVENT;
 	}
 
-	switch(e.type)
-		{
-		case SCI_EVT_QUIT:
-			quit_vm();
-			break;
+	switch (e.type) {
+	case SCI_EVT_QUIT:
+		quit_vm();
+		break;
 
-		case SCI_EVT_KEYBOARD: {
+	case SCI_EVT_KEYBOARD: {
 
-			if ((e.buckybits & SCI_EVM_LSHIFT) && (e.buckybits & SCI_EVM_RSHIFT)
-			    && (e.data == '-')) {
+		if ((e.buckybits & SCI_EVM_LSHIFT) && (e.buckybits & SCI_EVM_RSHIFT)
+		        && (e.data == '-')) {
 
-				sciprintf("Debug mode activated\n");
+			sciprintf("Debug mode activated\n");
 
-				script_debug_flag = 1; /* Enter debug mode */
-				_debug_seeking = _debug_step_running = 0;
-				s->onscreen_console = 0;
+			script_debug_flag = 1; /* Enter debug mode */
+			_debug_seeking = _debug_step_running = 0;
+			s->onscreen_console = 0;
 
-			} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) {
+		} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) {
 
-				script_debug_flag = 1; /* Enter debug mode */
-				_debug_seeking = _debug_step_running = 0;
-				s->onscreen_console = 1;
+			script_debug_flag = 1; /* Enter debug mode */
+			_debug_seeking = _debug_step_running = 0;
+			s->onscreen_console = 1;
 
-			} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '1')) {
+		} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '1')) {
 
-				if (s->visual)
-					s->visual->print(GFXW(s->visual), 0);
+			if (s->visual)
+				s->visual->print(GFXW(s->visual), 0);
 
-			} else {
-				PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); /*Keyboard event*/
-				s->r_acc=make_reg(0, 1);
-				PUT_SEL32V(obj, message, e.character);
-				/* We only care about the translated
-				** character  */
-				PUT_SEL32V(obj, modifiers, e.buckybits&modifier_mask);
+		} else {
+			PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); /*Keyboard event*/
+			s->r_acc = make_reg(0, 1);
+			PUT_SEL32V(obj, message, e.character);
+			/* We only care about the translated
+			** character  */
+			PUT_SEL32V(obj, modifiers, e.buckybits&modifier_mask);
 
-			}
-		} break;
+		}
+	}
+	break;
 
-		case SCI_EVT_MOUSE_RELEASE:
-		case SCI_EVT_MOUSE_PRESS: {
-			int extra_bits=0;
+	case SCI_EVT_MOUSE_RELEASE:
+	case SCI_EVT_MOUSE_PRESS: {
+		int extra_bits = 0;
 
-			if(mask & e.type) {
-				switch(e.data) {
-				case 2: extra_bits=SCI_EVM_LSHIFT|SCI_EVM_RSHIFT; break;
-				case 3: extra_bits=SCI_EVM_CTRL;
-				default:break;
-				}
-
-				PUT_SEL32V(obj, type, e.type);
-				PUT_SEL32V(obj, message, 1);
-				PUT_SEL32V(obj, modifiers, (e.buckybits|extra_bits)&modifier_mask);
-				s->r_acc = make_reg(0, 1);
+		if (mask & e.type) {
+			switch (e.data) {
+			case 2:
+				extra_bits = SCI_EVM_LSHIFT | SCI_EVM_RSHIFT;
+				break;
+			case 3:
+				extra_bits = SCI_EVM_CTRL;
+			default:
+				break;
 			}
-		} break;
 
-		default: {
-			s->r_acc = NULL_REG; /* Unknown or no event */
+			PUT_SEL32V(obj, type, e.type);
+			PUT_SEL32V(obj, message, 1);
+			PUT_SEL32V(obj, modifiers, (e.buckybits | extra_bits)&modifier_mask);
+			s->r_acc = make_reg(0, 1);
 		}
-		}
+	}
+	break;
 
+	default: {
+		s->r_acc = NULL_REG; /* Unknown or no event */
+	}
+	}
+
 	if ((s->r_acc.offset) && (stop_on_event)) {
 		stop_on_event = 0;
 		script_debug_flag = 1;
-	}  
+	}
 
 	return s->r_acc;
 }
 
 reg_t
-kMapKeyToDir(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kMapKeyToDir(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t obj = argv[0];
 
 	if (GET_SEL32V(obj, type) == SCI_EVT_KEYBOARD) { /* Keyboard */
 		int mover = -1;
 		switch (GET_SEL32V(obj, message)) {
-		case SCI_K_HOME: mover = 8; break;
-		case SCI_K_UP: mover = 1; break;
-		case SCI_K_PGUP: mover = 2; break;
-		case SCI_K_LEFT: mover = 7; break;
+		case SCI_K_HOME:
+			mover = 8;
+			break;
+		case SCI_K_UP:
+			mover = 1;
+			break;
+		case SCI_K_PGUP:
+			mover = 2;
+			break;
+		case SCI_K_LEFT:
+			mover = 7;
+			break;
 		case SCI_K_CENTER:
-		case 76: mover = 0; break;
-		case SCI_K_RIGHT: mover = 3; break;
-		case SCI_K_END: mover = 6; break;
-		case SCI_K_DOWN: mover = 5; break;
-		case SCI_K_PGDOWN: mover = 4; break;
-		default: break;
+		case 76:
+			mover = 0;
+			break;
+		case SCI_K_RIGHT:
+			mover = 3;
+			break;
+		case SCI_K_END:
+			mover = 6;
+			break;
+		case SCI_K_DOWN:
+			mover = 5;
+			break;
+		case SCI_K_PGDOWN:
+			mover = 4;
+			break;
+		default:
+			break;
 		}
 
 		if (mover >= 0) {
@@ -186,8 +208,7 @@
 
 
 reg_t
-kGlobalToLocal(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kGlobalToLocal(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t obj = argc ? argv[0] : NULL_REG; /* Can this really happen? Lars */
 
 	if (obj.segment) {
@@ -204,8 +225,7 @@
 
 
 reg_t
-kLocalToGlobal(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kLocalToGlobal(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t obj = argc ? argv[0] : NULL_REG; /* Can this really happen? Lars */
 
 	if (obj.segment) {
@@ -220,8 +240,7 @@
 }
 
 reg_t /* Not implemented */
-kJoystick(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kJoystick(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	SCIkdebug(SCIkSTUB, "Unimplemented syscall 'Joystick()'\n", funct_nr);
 	return NULL_REG;
 }

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2009-02-15 22:25:34 UTC (rev 38316)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2009-02-15 22:28:12 UTC (rev 38317)
@@ -58,8 +58,7 @@
 ** Otherwise, the new file is then opened for reading or writing.
 */
 static FILE *
-f_open_mirrored(state_t *s, char *fname)
-{
+f_open_mirrored(state_t *s, char *fname) {
 	int fd;
 	char *buf = NULL;
 	int fsize;
@@ -91,7 +90,7 @@
 	if (!IS_VALID_FD(fd) && buf) {
 		free(buf);
 		sciprintf("kfile.c: f_open_mirrored(): Warning: Could not create '%s' in '%s' (%d bytes to copy)\n",
-			  fname, s->work_dir, fsize);
+		          fname, s->work_dir, fsize);
 		return NULL;
 	}
 
@@ -100,7 +99,7 @@
 		ret = write(fd, buf, fsize);
 		if (ret < fsize) {
 			sciprintf("kfile.c: f_open_mirrored(): Warning: Could not write all %ld bytes to '%s' in '%s' (only wrote %ld)\n",
-				  (long)fsize, fname, s->work_dir, ret);
+			          (long)fsize, fname, s->work_dir, ret);
 		}
 
 		free(buf);
@@ -118,8 +117,7 @@
 
 
 void
-file_open(state_t *s, char *filename, int mode)
-{
+file_open(state_t *s, char *filename, int mode) {
 	int retval = 1; /* Ignore file_handles[0] */
 	FILE *file = NULL;
 
@@ -138,8 +136,8 @@
 	}
 
 	if ((!file) && ((mode == _K_FILE_MODE_OPEN_OR_CREATE) || (mode == _K_FILE_MODE_CREATE))) {
-			file = sci_fopen(filename, "w" FO_BINARY "+"); /* Attempt to create file */
-			SCIkdebug(SCIkFILE, "Creating file %s with mode %d\n", filename, mode);
+		file = sci_fopen(filename, "w" FO_BINARY "+"); /* Attempt to create file */
+		SCIkdebug(SCIkFILE, "Creating file %s with mode %d\n", filename, mode);
 	}
 	if (!file) { /* Failed */
 		SCIkdebug(SCIkFILE, "file_open() failed\n");
@@ -159,43 +157,39 @@
 }
 
 reg_t
-kFOpen(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
-  char *name = kernel_dereference_char_pointer(s, argv[0], 0);
-  int mode = UKPV(1);
+kFOpen(state_t *s, int funct_nr, int argc, reg_t *argv) {
+	char *name = kernel_dereference_char_pointer(s, argv[0], 0);
+	int mode = UKPV(1);
 
-  file_open(s, name, mode);
-  return s->r_acc;
+	file_open(s, name, mode);
+	return s->r_acc;
 }
 
-void file_close(state_t *s, int handle)
-{
-  SCIkdebug(SCIkFILE, "Closing file %d\n", handle);
+void file_close(state_t *s, int handle) {
+	SCIkdebug(SCIkFILE, "Closing file %d\n", handle);
 
-  if (handle == 0) {
-    SCIkwarn(SCIkERROR, "Attempt to close file handle 0\n");
-    return;
-  }
+	if (handle == 0) {
+		SCIkwarn(SCIkERROR, "Attempt to close file handle 0\n");
+		return;
+	}
 
-  if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
-    SCIkwarn(SCIkERROR, "Attempt to close invalid/unused file handle %d\n", handle);
-    return;
-  }
+	if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
+		SCIkwarn(SCIkERROR, "Attempt to close invalid/unused file handle %d\n", handle);
+		return;
+	}
 
-  fclose(s->file_handles[handle]);
+	fclose(s->file_handles[handle]);
 
-  s->file_handles[handle] = NULL;
+	s->file_handles[handle] = NULL;
 }
 
 reg_t
-kFClose(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
-  file_close(s, UKPV(0));
-  return s->r_acc;
+kFClose(state_t *s, int funct_nr, int argc, reg_t *argv) {
+	file_close(s, UKPV(0));
+	return s->r_acc;
 }
 
-void fputs_wrapper(state_t *s, int handle, int size, char *data)
-{
+void fputs_wrapper(state_t *s, int handle, int size, char *data) {
 	SCIkdebug(SCIkFILE, "FPuts'ing \"%s\" to handle %d\n", data, handle);
 
 	if (handle == 0) {
@@ -211,26 +205,24 @@
 	fwrite(data, 1, size, s->file_handles[handle]);
 }
 
-void fwrite_wrapper(state_t *s, int handle, char *data, int length)
-{
-  SCIkdebug(SCIkFILE, "fwrite()'ing \"%s\" to handle %d\n", data, handle);
+void fwrite_wrapper(state_t *s, int handle, char *data, int length) {
+	SCIkdebug(SCIkFILE, "fwrite()'ing \"%s\" to handle %d\n", data, handle);
 
-  if (handle == 0) {
-    SCIkwarn(SCIkERROR, "Attempt to write to file handle 0\n");
-    return;
-  }
+	if (handle == 0) {
+		SCIkwarn(SCIkERROR, "Attempt to write to file handle 0\n");
+		return;
+	}
 
-  if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
-    SCIkwarn(SCIkERROR, "Attempt to write to invalid/unused file handle %d\n", handle);
-    return;
-  }
+	if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
+		SCIkwarn(SCIkERROR, "Attempt to write to invalid/unused file handle %d\n", handle);
+		return;
+	}
 
-  fwrite(data, 1, length, s->file_handles[handle]);
+	fwrite(data, 1, length, s->file_handles[handle]);
 }
 
 
-reg_t kFPuts(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+reg_t kFPuts(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	int handle = UKPV(0);
 	char *data = kernel_dereference_char_pointer(s, argv[1], 0);
 
@@ -239,75 +231,71 @@
 }
 
 static void
-fgets_wrapper(state_t *s, char *dest, int maxsize, int handle)
-{
-  SCIkdebug(SCIkFILE, "FGets'ing %d bytes from handle %d\n", maxsize, handle);
+fgets_wrapper(state_t *s, char *dest, int maxsize, int handle) {
+	SCIkdebug(SCIkFILE, "FGets'ing %d bytes from handle %d\n", maxsize, handle);
 
 
-  if (handle == 0) {
-    SCIkwarn(SCIkERROR, "Attempt to read from file handle 0\n");
-    return;
-  }
+	if (handle == 0) {
+		SCIkwarn(SCIkERROR, "Attempt to read from file handle 0\n");
+		return;
+	}
 
-  if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
-    SCIkwarn(SCIkERROR, "Attempt to read from invalid/unused file handle %d\n", handle);
-    return;
-  }
+	if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
+		SCIkwarn(SCIkERROR, "Attempt to read from invalid/unused file handle %d\n", handle);
+		return;
+	}
 
-  fgets(dest, maxsize, s->file_handles[handle]);
+	fgets(dest, maxsize, s->file_handles[handle]);
 
-  SCIkdebug(SCIkFILE, "FGets'ed \"%s\"\n", dest);
+	SCIkdebug(SCIkFILE, "FGets'ed \"%s\"\n", dest);
 }
 
 
 static void
-fread_wrapper(state_t *s, char *dest, int bytes, int handle)
-{
-  SCIkdebug(SCIkFILE, "fread()'ing %d bytes from handle %d\n", bytes, handle);
+fread_wrapper(state_t *s, char *dest, int bytes, int handle) {
+	SCIkdebug(SCIkFILE, "fread()'ing %d bytes from handle %d\n", bytes, handle);
 
-  if (handle == 0) {
-    SCIkwarn(SCIkERROR, "Attempt to read from file handle 0\n");
-    return;
-  }
+	if (handle == 0) {
+		SCIkwarn(SCIkERROR, "Attempt to read from file handle 0\n");
+		return;
+	}
 
-  if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
-    SCIkwarn(SCIkERROR, "Attempt to read from invalid/unused file handle %d\n", handle);
-    return;
-  }
+	if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
+		SCIkwarn(SCIkERROR, "Attempt to read from invalid/unused file handle %d\n", handle);
+		return;
+	}
 
-  s->r_acc=make_reg(0,fread(dest, 1, bytes, s->file_handles[handle]));
+	s->r_acc = make_reg(0, fread(dest, 1, bytes, s->file_handles[handle]));
 }
 
 
 static void
-fseek_wrapper(state_t *s, int handle, int offset, int whence)
-{
+fseek_wrapper(state_t *s, int handle, int offset, int whence) {
 
-  if (handle == 0) {
-    SCIkwarn(SCIkERROR, "Attempt seek on file handle 0\n");
-    return;
-  }
+	if (handle == 0) {
+		SCIkwarn(SCIkERROR, "Attempt seek on file handle 0\n");
+		return;
+	}
 
-  if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
-    SCIkwarn(SCIkERROR, "Attempt seek on invalid/unused file handle %d\n", handle);
-    return;
-  }
+	if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) {
+		SCIkwarn(SCIkERROR, "Attempt seek on invalid/unused file handle %d\n", handle);
+		return;
+	}
 
-  s->r_acc=make_reg(0, fseek(s->file_handles[handle], offset, whence));
+	s->r_acc = make_reg(0, fseek(s->file_handles[handle], offset, whence));
 }
 
 
 static char *
-_chdir_savedir(state_t *s)
-{
+_chdir_savedir(state_t *s) {
 	char *cwd = sci_getcwd();
-	char *save_dir = kernel_dereference_char_pointer(s, 
-			make_reg(s->sys_strings_segment, SYS_STRING_SAVEDIR), 0);
+	char *save_dir = kernel_dereference_char_pointer(s,
+	                 make_reg(s->sys_strings_segment, SYS_STRING_SAVEDIR), 0);
 
 	if (chdir(save_dir) && sci_mkpath(save_dir)) {
 
 		sciprintf(__FILE__": Can't chdir to savegame dir '%s' or "
-			  "create it\n", save_dir);
+		          "create it\n", save_dir);
 
 		sci_free(cwd);
 		return NULL;
@@ -320,11 +308,10 @@
 }
 
 static void
-_chdir_restoredir(char *dir)
-{
+_chdir_restoredir(char *dir) {
 	if (chdir(dir)) {
 		sciprintf(__FILE__": Can't seem to return to previous homedir '%s'\n",
-			  dir);
+		          dir);
 	}
 	free(dir);
 }
@@ -332,14 +319,13 @@
 #define TEST_DIR_OR_QUIT(dir) if (!dir) { return NULL_REG; }
 
 reg_t
-kFGets(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
-  char *dest = kernel_dereference_char_pointer(s, argv[0], 0);
-  int maxsize = UKPV(1);
-  int handle = UKPV(2);
+kFGets(state_t *s, int funct_nr, int argc, reg_t *argv) {
+	char *dest = kernel_dereference_char_pointer(s, argv[0], 0);
+	int maxsize = UKPV(1);
+	int handle = UKPV(2);
 
-  fgets_wrapper(s, dest, maxsize, handle);
-  return argv[0];
+	fgets_wrapper(s, dest, maxsize, handle);
+	return argv[0];
 }
 
 
@@ -347,8 +333,7 @@
 ** Writes the cwd to the supplied address and returns the address in acc.
 */
 reg_t
-kGetCWD(state_t *s, int funct_nr, int argc, reg_t *argv)
-{
+kGetCWD(state_t *s, int funct_nr, int argc, reg_t *argv) {
 	char *wd = sci_getcwd();
 	char *targetaddr = kernel_dereference_char_pointer(s, argv[0], 0);
 
@@ -356,7 +341,7 @@
 	targetaddr[MAX_SAVE_DIR_SIZE - 1] = 0; /* Terminate */
 
 	SCIkdebug(SCIkFILE, "Copying cwd='%s'(%d chars) to %p",
-		  wd, strlen(wd), targetaddr);

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list