[Scummvm-cvs-logs] SF.net SVN: scummvm:[38214] scummvm/trunk/engines/sci
sev at users.sourceforge.net
sev at users.sourceforge.net
Sun Feb 15 11:10:23 CET 2009
Revision: 38214
http://scummvm.svn.sourceforge.net/scummvm/?rev=38214&view=rev
Author: sev
Date: 2009-02-15 10:10:23 +0000 (Sun, 15 Feb 2009)
Log Message:
-----------
- Remove unneeded files
- Make whole thing finally compilable
Modified Paths:
--------------
scummvm/trunk/engines/sci/module.mk
Removed Paths:
-------------
scummvm/trunk/engines/sci/engine/kemu_old.c
scummvm/trunk/engines/sci/engine/simplesaid.c
scummvm/trunk/engines/sci/gfx/gfx_console.c
scummvm/trunk/engines/sci/include/conf_summary.h
scummvm/trunk/engines/sci/include/modules.h
scummvm/trunk/engines/sci/include/sci_conf.h
scummvm/trunk/engines/sci/main.c
scummvm/trunk/engines/sci/scicore/sci_dos.c
scummvm/trunk/engines/sci/sfx/old/
scummvm/trunk/engines/sci/sfx/softseq/fmopl.c
scummvm/trunk/engines/sci/sfx/softseq/mt32/
Deleted: scummvm/trunk/engines/sci/engine/kemu_old.c
===================================================================
--- scummvm/trunk/engines/sci/engine/kemu_old.c 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/engine/kemu_old.c 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,330 +0,0 @@
-/***************************************************************************
- kemu_old.c Copyright (C) 2002 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-/* Emulation code for old kernel functions */
-
-#include <engine.h>
-#include "kernel_compat.h"
-#include "kernel_types.h"
-#include "heap.h"
-
-#define EMU_HEAP_START_ADDR 1000
-
-#define EMU_TYPE_VERBATIM 0 /* Arithmetic values */
-#define EMU_TYPE_REGISTERS 1 /* Must re-interpret afterwards. Also used for objects. */
-#define EMU_TYPE_BLOCK 2 /* Bulk data; string or similar. May physically point to stack */
-
-static int funct_nr;
-
-typedef struct {
- heap_ptr start; /* Beginning of the block */
- reg_t pos; /* Needed for resolving conflicts */
- int length; /* Number of bytes occupied on the heap */
- object_t *obj; /* For object types: Pointer to the physical object */
-
- /* Emulation data part */
- int emudat_type; /* EMU_TYPE_... */
- heap_ptr emudat_location; /* Only for 1 and 2 */
- union {
- reg_t *regs; /* registers, for type 1 */
- byte *block; /* Bulk data location, for type 2 */
- } emu_data;
- int emudat_size; /* Amount of bytes or number of entries */
-} emu_param_t;
-
-static inline emu_param_t
-identify_value(state_t *s, reg_t reg, heap_ptr firstfree)
-{
- emu_param_t retval;
- int type = determine_reg_type(s, reg);
-
- retval.start = firstfree;
- retval.pos = reg;
-
- retval.obj = NULL;
- retval.length = 0;
- retval.emudat_type = EMU_TYPE_VERBATIM; /* To allow error aborts */
-
- if (type & KSIG_NULL)
- type &= KSIG_ARITHMETIC;
-
- switch (type) {
-
- case KSIG_ARITHMETIC: /* trivial */
- retval.emudat_size = 0;
- break;
-
- case KSIG_OBJECT:
- retval.emudat_type = EMU_TYPE_REGISTERS;
- retval.obj = obj_get(s, reg);
- if (!retval.obj) { BREAKPOINT(); }
- retval.length = -SCRIPT_OBJECT_MAGIC_OFFSET
- + retval.obj->variables_nr * 4 /* values and selectors */
- + 2; /* Extra magic selector word (is this really needed?) */
- retval.emu_data.regs = retval.obj->variables;
- retval.emudat_size = retval.obj->variables_nr;
- retval.emudat_location = retval.start - SCRIPT_OBJECT_MAGIC_OFFSET;
- break;
-
- case KSIG_REF: {
- retval.emudat_type = EMU_TYPE_BLOCK;
-
- retval.emu_data.block =
- s->seg_manager.dereference(&s->seg_manager,
- reg, &retval.emudat_size);
-
- if (!retval.emu_data.block) {
- SCIkdebug(SCIkERROR, "Cannot handle references into segment type %02x"
- " (from "PREG") during emulation\n",
- type, PRINT_REG(reg));
- retval.emudat_type = EMU_TYPE_VERBATIM;
- retval.length = 0;
- }
-
- retval.length = retval.emudat_size;
- retval.emudat_location = retval.start;
-
- break;
- }
-
- default:
- SCIkdebug(SCIkERROR, "Cannot handle argument type %02x (from "PREG
- ") during emulation\n",
- type, PRINT_REG(reg));
- }
-
- return retval;
-}
-
-static inline void
-writeout_value(state_t *s, emu_param_t *p)
-{
- if (p->obj) /* First copy object; don't need to read back this part later */
- memcpy(s->heap + p->start, p->obj->base_obj + SCRIPT_OBJECT_MAGIC_OFFSET,
- p->length);
-
- switch (p->emudat_type) {
-
- case EMU_TYPE_VERBATIM:
- SCIkdebug(SCIkEMU, "\tVerbatim/Arithmetic\n");
- return;
-
- case EMU_TYPE_REGISTERS: {
- int i, max = p->emudat_size;
-
- SCIkdebug(SCIkEMU, "\tObject, %d selectors\n", max);
-
- for (i = 0; i < max; i++) {
- byte *dest = s->heap + p->emudat_location + (i << 1);
-
- dest[0] = p->emu_data.regs[i].offset & 0xff;
- dest[1] = (p->emu_data.regs[i].offset >> 8) & 0xff;
- /* Assume they're all numeric values */
- }
- return;
- }
-
- case EMU_TYPE_BLOCK:
- SCIkdebug(SCIkEMU, "\tBulk\n");
- memcpy(s->heap + p->emudat_location, p->emu_data.block, p->emudat_size);
- return;
-
- default:
- BREAKPOINT();
- }
-}
-
-static inline void
-recover_value(state_t *s, emu_param_t *p)
-{ /* Writes back the value */
- switch (p->emudat_type) {
-
- case EMU_TYPE_VERBATIM:
- return;
-
- case EMU_TYPE_REGISTERS: {
- int i, max = p->emudat_size;
- for (i = 0; i < max; i++) {
- int val = GET_HEAP(p->emudat_location + (i << 1));
- if (p->emu_data.regs[i].offset != val) {
- SCIkdebug(SCIkEMU, " Recovering property #%d from %04x: 0:%04x\n",
- i, p->emudat_location + (i << 1), val);
- p->emu_data.regs[i] = make_reg(0, val);
- } else {
- SCIkdebug(SCIkEMU, " Property #%d from %04x is unchanged (%04x vs "PREG")\n",
- i, p->emudat_location + (i << 1), val, PRINT_REG(p->emu_data.regs[i]));
- }
- /* Don't overwrite unless something changed, to preserve pointers */
- }
- return;
- }
-
- case EMU_TYPE_BLOCK:
- memcpy(p->emu_data.block, s->heap + p->emudat_location, p->emudat_size);
- SCIkdebug(SCIkEMU, " Recovering %d raw bytes from %04x\n",
- p->emudat_size, p->emudat_location);
- return;
-
- default:
- BREAKPOINT();
- }
-}
-
-static void
-_restrict_against(state_t *s, emu_param_t *self, emu_param_t *other)
-{
- if (self->pos.segment != other->pos.segment)
- return;
-
- if (self->pos.offset <= other->pos.offset
- && self->pos.offset + self->emudat_size > other->pos.offset) {
- mem_obj_t *mobj = GET_SEGMENT_ANY(s->seg_manager, self->pos.segment);
-
- self->emudat_size = other->pos.offset - self->pos.offset;
-
- if (mobj && mobj->type == MEM_OBJ_STACK)
- self->emudat_size *= sizeof(reg_t); /* Accomodate for size differences */
- }
-}
-
-static void
-resolve_conflicts(state_t *s, emu_param_t *params, int count)
-{
- int i, j;
- for (i = 0; i < count; i++)
- for (j = 0; j < count; j++)
- if (i != j)
- _restrict_against(s, params + i, params + j);
-}
-
-reg_t
-kFsciEmu(state_t *s, int _funct_nr, int argc, reg_t *argv)
-{
- emu_param_t *shadow_args;
- funct_nr = _funct_nr;
-
- if (!s->kfunct_emu_table[funct_nr]) {
- SCIkwarn(SCIkERROR, "Attempt to emulate unknown kernel function %x\n",
- funct_nr);
- return NULL_REG;
- } else {
- heap_ptr argp = EMU_HEAP_START_ADDR; /* arguments go here */
- heap_ptr datap = argp + argc * 2; /* copied stuff goes here */
- int i;
-
- shadow_args = sci_malloc(sizeof(emu_param_t) * (argc + 1
- /* Prevents stupid warning */));
- memset(shadow_args, 0, sizeof(emu_param_t) * (argc + 1));
-
- SCIkdebug(SCIkEMU, "Emulating kernel call %s[%x] w/ %d arguments at HP:%04x\n",
- s->kernel_names[funct_nr], funct_nr, argc, argp);
-
- for (i = 0; i < argc; i++) {
- int emu_value = argv[i].offset; /* Value we'll pass to the function */
-
- SCIkdebug(SCIkEMU, " %3d : ["PREG"] ->\n", i, PRINT_REG(argv[i]));
-
- shadow_args[i] = identify_value(s, argv[i], datap);
-
- switch (shadow_args[i].emudat_type) {
-
- case EMU_TYPE_VERBATIM:
- break;
-
- case EMU_TYPE_REGISTERS:
- case EMU_TYPE_BLOCK:
- emu_value = shadow_args[i].emudat_location;
- break;
-
- default:
- BREAKPOINT();
-
- }
-
- SCIkdebug(SCIkEMU, "\t%04x [%d at %04x]\n",
- emu_value, shadow_args[i].length, shadow_args[i].start);
-
- PUT_HEAP(argp, emu_value);
- argp += 2;
-
- if (0xffff - shadow_args[i].length < datap) {
- SCIkdebug(SCIkERROR, "Out of heap space while emulating!\n");
- return NULL_REG;
- }
- datap += shadow_args[i].length; /* Step over last block we wrote */
- }
-
- for (i = 0; i < argc; i++)
- writeout_value(s, shadow_args + i);
-
- resolve_conflicts(s, shadow_args, argc);
-
- s->kfunct_emu_table[funct_nr](s, funct_nr, argc, EMU_HEAP_START_ADDR);
-
- for (i = 0; i < argc; i++)
- recover_value(s, shadow_args + i);
- free(shadow_args);
- return make_reg(0, s->acc);
- }
-}
-
-
-int
-read_selector16(state_t *s, heap_ptr object, selector_t selector_id, const char *file, int line)
-{
- int slc_count = GET_HEAP(object + SCRIPT_SELECTORCTR_OFFSET);
- int i;
- heap_ptr slc_names = object + slc_count * 2;
-
- for (i = 0; i < slc_count; i++) {
- if (GET_HEAP(slc_names + (i<<1)) == selector_id)
- return GET_HEAP(object + (i<<1));
- }
-
- SCIkdebug(SCIkWARNING, "[EMU] Could not read selector %d from HP:%04x (%s, L%d)\n",
- selector_id, object, file, line);
- return 0;
-}
-
-void
-write_selector16(state_t *s, heap_ptr object, selector_t selector_id,
- int value, const char *fname, int line)
-{
- int slc_count = GET_HEAP(object + SCRIPT_SELECTORCTR_OFFSET);
- int i;
- heap_ptr slc_names = object + slc_count * 2;
-
- for (i = 0; i < slc_count; i++) {
- if (GET_HEAP(slc_names + (i<<1)) == selector_id) {
- PUT_HEAP(object + (i<<1), value);
- return;
- }
- }
-
- SCIkdebug(SCIkWARNING, "[EMU] Could not write selector %d from HP:%04x (%s, L%d)\n",
- selector_id, object, fname, line);
-}
-
Deleted: scummvm/trunk/engines/sci/engine/simplesaid.c
===================================================================
--- scummvm/trunk/engines/sci/engine/simplesaid.c 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/engine/simplesaid.c 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,312 +0,0 @@
-/***************************************************************************
- simplesaid.c Copyright (C) 2000 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-
-
-#ifdef SCI_SIMPLE_SAID_CODE
-
-#include <engine.h>
-#include <kdebug.h>
-
-static int current_pword;
-static int said_pos;
-static int refstart_pos, parse_pos;
-static parse_tree_node_t *words;
-static int dontclaim; /* Whether the Parse() event should be claimed */
-static int reached_end;
-
-static state_t *state;
-static heap_ptr addr;
-
-#define WORDP_MODE_STAY 0
-#define WORDP_MODE_NEXT 1
-#define WORDP_MODE_SEEK 2
-
-/* hack */
-#define s state
-
-static inline int /* Returns whether the specified word matches */
-word_p(int mode, int word)
-{
- int oldpp = parse_pos;
- do {
- if (mode)
- ++parse_pos;
-
- current_pword = words[parse_pos << 1].content.value;
- /* SDEBUG("Word at %d = %03x\n", parse_pos, current_pword); */
- if (current_pword == word) {
- /* ++matches; */
- SCIkdebug(SCIkSAID, "wordp(%d, %03x) from %d -> 1\n", mode, word, oldpp);
-
- reached_end |= (words[(parse_pos + 1) << 1].type == -1);
-
- return 1;
- }
-
- } while ((mode == WORDP_MODE_SEEK) && (words[parse_pos <<1].type != -1));
-
- if (words[parse_pos << 1].type == -1)
- --parse_pos;
-
- SCIkdebug(SCIkSAID, "wordp(%d, %03x) from %d -> 0\n", mode, word, oldpp);
-
- return 0;
-}
-
-
-
-static inline int /* End of input? */
-end_p()
-{
- int val = (words[(parse_pos + 1) << 1 ].type == -1) || reached_end;
-
- SCIkdebug(SCIkSAID, "endp(pp=%d) = %d\n", parse_pos, val);
-
- return val;
-}
-
-
-
-static inline int /* Returns whether the current_word references that specified word */
-reference_p(int referenced_word_index, int word)
-{
- int val = 0;
- int seeker = (refstart_pos << 1) + 2;
-
- while (words[seeker].type != -1) {
-
- if (words[seeker].content.value == word)
- if (((words[seeker + 1].content.branches[0] > -1)
- && (words[seeker + 1].content.branches[0] == referenced_word_index))
- || ((words[seeker + 1].content.branches[1] > -1)
- && (words[seeker + 1].content.branches[1] == referenced_word_index))) {
- val = 1;
- reached_end |= (words[seeker + 2].type == -1);
- break;
- }
-
- seeker += 2;
- }
-
- SCIkdebug(SCIkSAID, "%03x > pos[%d] = %d (start at %d)\n", word, referenced_word_index, val, refstart_pos);
-
- return val;
-}
-
-
-static inline int /* Checks whether the current word has trailing references */
-follows_p(void)
-{
- /* int val = (words[(parse_pos << 1) + 1].content.branches[1] > (parse_pos << 1));
-
- SDEBUG("follows-p(pp=%d) = %d\n", parse_pos, val);*/
-
- dontclaim = 1;
- return 1; /* appears to work best */
-}
-
-
-static inline int
-next_parse_token(int *token_is_op)
-{
- int item = state->heap[addr++];
-
- if (item < 0xf0) {
- item = item << 8 | state->heap[addr++];
- *token_is_op = 0;
- } else
- *token_is_op = 1;
-
- return item;
-}
-
-#define STATE_INITIAL 0
-#define STATE_OR 1
-#define STATE_SEEK 2
-#define STATE_REF 3
-
-static int
-simplesaid(int minor_state, int terminator)
-{
- int major_state = STATE_INITIAL;
- int refword = parse_pos; /* The word references apply to */
- int aspiring_refword = -1; /* in "a < b < c", c refers to b, and aspiring_refword will be b. */
- int truth = 1;
- int token_is_op;
- SCIkdebug(SCIkSAID, "simplesaid(%02x)\n", terminator);
-
- while (42) {
-
- int token = next_parse_token(&token_is_op);
- SCIkdebug(SCIkSAID, "Got token %03x on truth %d\n", token, truth);
-
- if (token_is_op && (token == terminator)) {
- if (terminator == SAID_TERM)
- truth = truth && end_p();
- SCIkdebug(SCIkSAID, "Terminator; returning %d\n", truth);
- return truth;
- }
-
- if (token_is_op) /* operator? */
- switch (token) {
-
- case SAID_COMMA:
- minor_state = STATE_OR;
- break;
-
- case SAID_SLASH:
- if (!truth) {
- while (((token = next_parse_token(&token_is_op)) != terminator)
- && (token != SAID_TERM)); /* Proceed to end of block */
- if (token != terminator)
- SCIkwarn(SCIkERROR, "Syntax error: Unexpected end of spec");
- return 0;
- }
-
- major_state = STATE_SEEK;
- minor_state = STATE_INITIAL;
- break;
-
- case SAID_PARENC:
- SCIkwarn(SCIkERROR, "')' without matching '('\n");
- return 0;
-
- case SAID_PARENO:
- switch (minor_state) {
-
- case STATE_OR:
- truth |= simplesaid(minor_state, SAID_PARENC);
- break;
-
- case STATE_INITIAL:
- truth = truth && simplesaid(minor_state, SAID_PARENC);
- break;
-
- default:
- SCIkwarn(SCIkERROR, "'(' in minor state %d\n", minor_state);
- }
- break;
-
- case SAID_BRACKC:
- SCIkwarn(SCIkERROR, "']' without matching '['\n");
- return 0;
-
- case SAID_BRACKO: {
- int parse_pos_old = parse_pos;
- int recurse = simplesaid(minor_state, SAID_BRACKC);
- if (!recurse)
- parse_pos = parse_pos_old;
- break;
- }
-
- case SAID_LT:
- if (aspiring_refword > -1) /* "a < b < c" */
- refword = aspiring_refword; /* refword = 'b' (in the case above) */
- major_state = STATE_REF;
- break;
-
- case SAID_GT:
- return truth && follows_p();
-
- case SAID_TERM:
- SCIkwarn(SCIkERROR, "Unexpected end of spec\n");
- return 0;
-
- default:
- SCIkwarn(SCIkERROR, "Syntax error: Unexpected token 0x%02x\n", token);
- return 0;
- } else {
- int tempresult;
-
- /* ++word_tokens_nr; /* Normal word token */
-
- switch(major_state) {
-
- case STATE_INITIAL:
- tempresult = word_p(((minor_state == STATE_OR)? WORDP_MODE_STAY : WORDP_MODE_NEXT), token);
- refword = parse_pos;
- break;
-
- case STATE_SEEK:
- tempresult = word_p(WORDP_MODE_SEEK, token);
- major_state = STATE_INITIAL;
- refword = parse_pos;
- break;
-
- case STATE_REF:
- tempresult = reference_p(refword, token);
- aspiring_refword = parse_pos;
- break;
-
- default:
- SCIkwarn(SCIkERROR, "Invalid major state!\n");
- return 0;
- }
-
- SCIkdebug(SCIkSAID, "state=(%d,%d), truth = %d * %d\n", major_state, minor_state, truth, tempresult);
-
- if (minor_state == STATE_OR)
- truth |= tempresult;
- else
- truth = truth && tempresult;
-
- minor_state = STATE_INITIAL;
- }
- }
-}
-
-#undef s
-
-int
-vocab_simple_said_test(state_t *s, heap_ptr address)
-{
- int matched;
- current_pword = reached_end = 0;
- dontclaim = 0;
- said_pos = 0;
- if (s->parser_lastmatch_word == SAID_NO_MATCH)
- SCIkdebug(SCIkSAID, "lastmatch_word: none\n");
- else
- SCIkdebug(SCIkSAID, "lastmatch_word=%d\n", s->parser_lastmatch_word);
- parse_pos = (s->parser_lastmatch_word == SAID_NO_MATCH)? -1 : s->parser_lastmatch_word;
- refstart_pos = parse_pos;
- state = s;
- addr = address;
- words = s->parser_nodes;
- matched = simplesaid(STATE_INITIAL, SAID_TERM);
- SCIkdebug(SCIkSAID, "Result: (matched,dontclaim)=(%d,%d)\n", matched, dontclaim);
-
- if (!matched)
- return SAID_NO_MATCH;
-
- if (dontclaim) /* partial match */
- return parse_pos; /* Return lastmatch word */
-
- return SAID_FULL_MATCH;
-}
-
-#endif /* SCI_SIMPLE_SAID_CODE */
Deleted: scummvm/trunk/engines/sci/gfx/gfx_console.c
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_console.c 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/gfx/gfx_console.c 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,1450 +0,0 @@
-/***************************************************************************
- gfx_console.c Copyright (C) 2002 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-/* Graphical on-screen console */
-
-
-#include <console.h>
-#include <ctype.h>
-
-#ifdef WANT_CONSOLE
-# define CON_MAX_CLUSTERS 16
-
-#define CON_CLUSTER_SIZE 64
-
-/* Number of console entries stored = CON_MAX_CLUSTERS * CON_CLUSTER_SIZE */
-
-#define CON_ENTRY_USED(e) ((e).height > 0)
-
-#define CON_INPUT_HISTORY_SIZE 64
-#define CON_BUILTIN_CHARS_NR 256
-#define CON_BUILTIN_CHARS_HEIGHT 8
-#define CON_BUILTIN_CHARS_WIDTH 8
-
-#define CON_OVERWRAP_SYMBOL 0x10
-
-#define CON_GFX_PROMPT "$ "
-
-extern byte con_builtin_font_data[];
-
-typedef struct {
- int height; /* Number of pixels occupied by this entry, or 0 if unused */
- int pixmaps_nr;
- gfx_pixmap_t **pixmaps;
- char *text; /* Dynamically allocated */
-} con_entry_t;
-
-
-typedef struct _con_buffer {
- con_entry_t entries[CON_CLUSTER_SIZE];
- struct _con_buffer *next;
- struct _con_buffer *prev;
-} con_buffer_t;
-
-typedef struct {
- con_buffer_t *buf;
- int entry;
- int offset; /* pixel offset relative to the bottom */
-} con_pos_t;
-
-typedef struct {
- int locked_to_end;
- con_pos_t pos;
- gfx_pixmap_t *background;
- gfx_color_t color_bg, color_transparent, color_cursor, color_text, color_input;
- gfx_pixmap_t *input_prompt;
- gfx_pixmap_t *input_precursor;
- gfx_pixmap_t *input_oncursor;
- gfx_pixmap_t *input_postcursor;
- int cursor_position;
- int input_window; /* First character to display, may be up to -2 to include prompt */
- char *input_text;
- int input_bufsize;
- int input_prompt_pos; /* -strlen(input prompt) */
- int input_history_pos;
- int partial_write;
- char *input_history[CON_INPUT_HISTORY_SIZE];
-} con_t;
-
-
-/* Visual options for the con */
-static int con_bg_red = 0;
-static int con_bg_green = 0;
-static int con_bg_blue = 64;
-static int con_bg_alpha = 64;
-static int con_displayed_lines = 180;
-static int con_border_width = 3;
-
-static int con_top_buffer_entry_nr = 0;
-static int con_buffer_clusters = 0;
-static con_buffer_t *con_buffer = NULL;
-static con_buffer_t *con_buffer_tail = NULL;
-static con_t con; /* The global con */
-static gfx_bitmap_font_t con_font;
-static int con_font_initialized = 0;
-static gfx_state_t *con_last_gfx_state = NULL;
-
-/*-- Forwards --*/
-static void
-_con_free_entry_pixmaps(gfx_state_t *state, con_entry_t *entry);
-/* Free all pixmaps from the specified entry
-** Parameters: (gfx_state_t *) state: The state to free from
-** (con_entry_t *) entry: The entry to liberate from its pixmaps
-*/
-
-static gfx_pixmap_t *
-_con_render_text(gfx_state_t *state, char *text, int len,
- gfx_color_t *color, gfx_color_t *bgcolor);
-/* Renders the specified text in the specified fg color
-** Parameters: (gfx_state_t *) state: The state to render in
-** (char *) text: The text to render
-** (int) len: Length of the text to render, or -1 for strlen
-** (gfx_color_t *) color: The fg color to choose
-** (gfx_color_t *) bgcolor: The bg color to choose
-** Returns : (gfx_pixmap_t *) An appropriate pixmap
-*/
-
-
-void
-con_jump_to_end(gfx_state_t *gfx);
-/* Makes the console jump to the logical end of its buffer and redraws
-** Parameters: (gfx_stat_t *) gfx: The graphics state to use fo rdrawing
-*/
-
-static void
-_con_redraw(gfx_state_t *state, int update_display_field, int update_input_field);
-/* Performs a (partial) redraw
-** Parameters: (gfx_state_t *) state: The graphical state to draw with
-** (int) update_display_field: Whether the upper part of the
-** console, used to display test, should be updated
-** (int) update_input_field: Whether the lower part of the
-** console, used to display the user input, should be
-** updated
-*/
-
-static void
-free_con_buffer(con_buffer_t *buf);
-/* Frees the specified con buffer and all of its predecessors
-** Parameters: (con_buffer_t *) buf: The buffer to free
-** Pixmaps are freed if neccessary, using the last used gfx state for con_gfx_show().
-*/
-
-void
-con_gfx_hide(gfx_state_t *state);
-/* Removes the console, restoring the background graphics
-** Parameters: (gfx_state_t *state: The graphics state to draw with
-*/
-
-static gfx_pixmap_t **
-_con_render_text_multiline(gfx_state_t *state, char *text, int maxchars, int *nr);
-/*-- code --*/
-
-static rect_t
-con_box()
-{
- return gfx_rect(0, 0, 320,
- con_displayed_lines
- + con_border_width);
-}
-
-void
-con_gfx_show(gfx_state_t *state)
-{
- gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
- con_last_gfx_state = state;
-
- con.locked_to_end = 1;
- con.background = gfxop_grab_pixmap(state, con_box());
-
- gfxop_set_color(state, &con.color_bg, con_bg_red, con_bg_green,
- con_bg_blue, con_bg_alpha, -1, -1);
- gfxop_set_color(state, &con.color_transparent, 0, 0, 0, 255, -1, -1);
- gfxop_set_color(state, &con.color_text, 255, 255, 255, 0, -1, -1);
- gfxop_set_color(state, &con.color_input, 255, 255, 0, 0, -1, -1);
- gfxop_set_color(state, &con.color_cursor, 255, 0, 0, 0, -1, -1);
-
- if (!con.input_prompt) {
- con.input_prompt = _con_render_text(state, CON_GFX_PROMPT, -1,
- &con.color_input, NULL);
- con.input_text = (char*)sci_malloc(con.input_bufsize = 64);
- con.input_text[0] = 0;
- con.input_history_pos = 0;
- con.partial_write = 0;
- memset(con.input_history, 0, sizeof(char *) * CON_INPUT_HISTORY_SIZE);
- }
-
- con_jump_to_end(state);
- _con_redraw(state, 0, 1);
-}
-
-static void
-_con_draw_bg_pic(gfx_state_t *state, rect_t zone)
-{
- gfxop_draw_pixmap(state, con.background, zone, gfx_point(zone.x,zone.y));
-}
-
-void
-con_jump_to_end(gfx_state_t *state)
-{
- con.locked_to_end = 1;
- _con_redraw(state, 1, 0);
-}
-
-
-void
-con_fold_text(gfx_state_t *state)
-{
- con_buffer_t *seeker = con_buffer;
-
- /* Fold all text pixmaps */
- while (seeker) {
- int i;
- for (i = 0; i < CON_CLUSTER_SIZE; i++)
- if (CON_ENTRY_USED(seeker->entries[i])
- && seeker->entries[i].text && seeker->entries[i].pixmaps_nr)
- _con_free_entry_pixmaps(state, &seeker->entries[i]);
-
- seeker = seeker->next;
- }
-}
-
-void
-con_gfx_hide(gfx_state_t *state)
-{
- /* Restore background */
- _con_draw_bg_pic(state, con_box());
-
- if (con.background)
- gfxop_free_pixmap(state, con.background);
- con.background = NULL;
-
- con_fold_text(state);
- gfxop_update(state);
-}
-
-static inline con_buffer_t *
-_create_con_buffer(con_buffer_t *prev)
-{
- con_buffer_t *buf = (con_buffer_t *)sci_malloc(sizeof (con_buffer_t));
- int i;
-
- for (i = 0; i < CON_CLUSTER_SIZE; i++)
- buf->entries[i].height = 0;
-
- buf->prev = prev;
- buf->next = NULL;
- if (prev)
- prev->next = buf;
-
- con_buffer_clusters++;
-
- return buf;
-}
-
-
-static inline void
-_add_into_con_buffer(gfx_pixmap_t *pixmap, char *text)
-{
- con_entry_t *target;
-
- if (!con_buffer) {
- con_buffer = con_buffer_tail = _create_con_buffer(NULL);
- con_top_buffer_entry_nr = 0;
- }
-
- if (con_top_buffer_entry_nr == CON_CLUSTER_SIZE) {
- /* Out of entries in this cluster */
- con_buffer = _create_con_buffer(con_buffer);
- con_top_buffer_entry_nr = 0;
- }
-
- target = con_buffer->entries + con_top_buffer_entry_nr;
-
- if (con.partial_write && text) {
- int real_entry = con_top_buffer_entry_nr - 1;
- int needlen = strlen(text);
- char *oldtext;
-
- if (real_entry < 0)
- target = con_buffer->prev->entries + CON_CLUSTER_SIZE - 1;
- else
- target = con_buffer->entries + real_entry;
-
- if (target->pixmaps)
- _con_free_entry_pixmaps(con_last_gfx_state, target);
-
- needlen += strlen(target->text);
- oldtext = target->text;
- target->text = (char *)sci_malloc(needlen+1);
- strcpy(target->text, oldtext);
- strcat(target->text, text);
- free(oldtext);
- free(text);
-
- con.partial_write = (target->text && *(target->text) &&
- target->text[strlen(target->text) - 1] != '\n');
-
- return;
- }
- else ++con_top_buffer_entry_nr;
-
-
- con.partial_write = (text && *(text) &&
- text[strlen(text) - 1] != '\n');
-
- if (pixmap)
- target->height = pixmap->index_yl;
- else
- target->height = 1; /* Will be calculated on demand */
-
- if (!pixmap) {
- target->pixmaps = NULL;
- target->pixmaps_nr = 0;
- } else {
- target->pixmaps = (gfx_pixmap_t **)sci_malloc(sizeof(gfx_pixmap_t *));
- target->pixmaps[0] = pixmap;
- target->pixmaps_nr = 1;
- }
- target->text = text;
-
- while (con_buffer_clusters > CON_MAX_CLUSTERS
- && con_buffer_tail) {
- if (con_buffer_tail->next) {
- con_buffer_tail = con_buffer_tail->next;
- free_con_buffer(con_buffer_tail->prev);
- } else {
- fprintf(stderr,"WARNING: During cleanup, con_buffer_tail ran out!\n");
- free_con_buffer(con_buffer_tail->prev);
- con_buffer_tail = con_buffer = NULL;
- }
- }
-}
-
-
-void
-con_gfx_insert_string(char *string)
-{
- if (string)
- _add_into_con_buffer(NULL, string);
-}
-
-void
-con_gfx_insert_pixmap(gfx_pixmap_t *pixmap)
-{
- if (pixmap)
- _add_into_con_buffer(pixmap, NULL);
-}
-
-static int
-_unfold_graphics(gfx_state_t *state, con_entry_t *drawme, int nr_chars)
- /* Returns whether unfolding was neccessary */
-{
- if (drawme->text && !drawme->pixmaps_nr) {
- int i;
- drawme->pixmaps = _con_render_text_multiline(state, drawme->text,
- nr_chars,
- &drawme->pixmaps_nr);
-
- drawme->height = 0;
- for (i = 0; i < drawme->pixmaps_nr; i++)
- drawme->height +=
- (drawme->pixmaps[i]->yl + state->driver->mode->yfact - 1)
- / state->driver->mode->yfact;
- /* Divide by scaler, round up */
- return 1;
- }
-
- return 0;
-}
-
-void
-con_scroll(gfx_state_t *state, int offset, int maxchars)
-{
- con_entry_t *next_entry;
- /* Scrolls within the display by the specified amount */
-
- if (con.locked_to_end) {
- con.pos.buf = con_buffer;
- con.pos.offset = 0;
- con.pos.entry = con_top_buffer_entry_nr - 1;
- }
-
- if (!con.pos.buf)
- return;
-
- con.locked_to_end = 0;
-
- con.pos.offset += offset; /* offset exceeds size -> Use PREVIOUS entry */
-
- while (con.pos.offset < 0 || con.pos.offset > con.pos.buf->entries[con.pos.entry].height) {
-
- if (con.pos.offset < 0) {
- if (++con.pos.entry == CON_CLUSTER_SIZE
- || ((con.pos.buf == con_buffer)
- && (con.pos.entry >= con_top_buffer_entry_nr))) {
- if (con.pos.buf->next) {
- con.pos.entry = 0;
- con.pos.buf = con.pos.buf->next;
- } else {
- con_jump_to_end(state);
- return;
- }
- }
-
- next_entry = con.pos.buf->entries + con.pos.entry;
-
- _unfold_graphics(state, next_entry, maxchars);
- con.pos.offset += next_entry->height;
- } else { /* offset too great ? */
-
- if (con.pos.entry == 0) {
- if (con.pos.buf->prev) {
- con.pos.entry = CON_CLUSTER_SIZE;
- con.pos.buf = con.pos.buf->prev;
- } else {
- con.pos.offset = con.pos.buf->entries[0].height - 1;
- return;
- }
- }
- --con.pos.entry;
-
- next_entry = con.pos.buf->entries + con.pos.entry;
-
- _unfold_graphics(state, next_entry, maxchars);
- con.pos.offset -= next_entry->height;
-
- if (con.pos.offset < 0)
- con.pos.offset = -con.pos.offset;
- }
- }
-}
-
-void
-con_gfx_init()
-{
- con_set_string_callback(con_gfx_insert_string);
- con_set_pixmap_callback(con_gfx_insert_pixmap);
- con.input_prompt = NULL;
- con.input_text = NULL;
- con.input_window = con.input_prompt_pos = -(int)strlen(CON_GFX_PROMPT);
- con.cursor_position = 0;
- con.input_precursor = NULL;
- con.input_postcursor = NULL;
- con.input_oncursor = NULL;
-}
-
-
-static void
-_init_con_font()
-{
- int i;
-
- con_font.ID = 0;
- con_font.chars_nr = CON_BUILTIN_CHARS_NR;
- con_font.widths = (int *)sci_malloc(sizeof(int) * CON_BUILTIN_CHARS_NR);
- for (i = 0; i < CON_BUILTIN_CHARS_NR; i++)
- con_font.widths[i] = CON_BUILTIN_CHARS_WIDTH;
- con_font.row_size = (CON_BUILTIN_CHARS_WIDTH + 7) >> 3;
- con_font.height = con_font.line_height = CON_BUILTIN_CHARS_HEIGHT;
- con_font.char_size = ((CON_BUILTIN_CHARS_WIDTH + 7) >> 3) * CON_BUILTIN_CHARS_HEIGHT;
- con_font.data = con_builtin_font_data;
-
- con_font_initialized = 1;
-}
-
-static gfx_pixmap_t **
-_con_render_text_multiline(gfx_state_t *state, char *text, int maxchars, int *nr)
-{
- int pixmaps_allocd = 1;
- gfx_pixmap_t **retval = (gfx_pixmap_t **)sci_malloc(sizeof(gfx_pixmap_t *) * pixmaps_allocd);
- char *printbuf = (char *)sci_malloc(maxchars + 8);
- int index = 0;
- int overwrap = 0;
-
- while (*text) {
- int len = 0;
-
- if (overwrap) {
- len = 2;
- printbuf[0] = ' ';
- printbuf[1] = CON_OVERWRAP_SYMBOL;
- overwrap = 0;
- }
-
- while (*text &&
- *text != '\n' && len < maxchars) {
- if (*text != '\t')
- printbuf[len++] = *text;
- else {
- int tabwidth = 8 - (len & 7);
- memset(printbuf + len, ' ', tabwidth);
- len += tabwidth;
- }
- text++;
- }
-
- if (*text && (*text != '\n'))
- overwrap = 1;
-
- if (index == pixmaps_allocd)
- retval = (gfx_pixmap_t **)sci_realloc(retval, sizeof(gfx_pixmap_t *) * (pixmaps_allocd+= 4));
-
- retval[index++] = _con_render_text(state, printbuf, len,
- &con.color_text, NULL);
- if (*text) text += (1 - overwrap);
- }
-
- *nr = index;
- sci_free(printbuf);
- return retval;
-}
-
-static gfx_pixmap_t *
-_con_render_text(gfx_state_t *state, char *text, int len,
- gfx_color_t *color, gfx_color_t *bgcolor)
-{
- gfx_pixmap_t *pxm;
-
- if (len < 0)
- len = strlen(text);
-
- if (!con_font_initialized)
- _init_con_font();
-
- pxm = gfxr_draw_font(&con_font, text, len,
- &color->visual,
- &color->visual,
- (bgcolor) ? &bgcolor->visual : NULL);
-
- pxm->flags |= GFX_PIXMAP_FLAG_SCALED_INDEX;
-
- gfx_xlate_pixmap(gfx_pixmap_alloc_data(pxm, state->driver->mode),
- state->driver->mode, GFX_XLATE_FILTER_NONE);
- return pxm;
-}
-
-static inline int
-_str_move_blank(char *data, int data_length, int initial_offset, int direction)
- /* Finds the next beginning or end of a word */
-{
- int offset = initial_offset;
- int abort = (direction < 0)? 0 : data_length;
- int lookahead = (direction < 0)? -1 : 0;
-
- if (offset != abort)
- offset += direction;
-
- while (offset != abort && isspace(data[offset]))
- offset += direction;
-
- while (offset != abort && !isspace(data[offset + lookahead]))
- offset += direction;
-
- return offset;
-}
-
-char *
-con_history_get_prev(int *handle) /* Should be -1 if not initialized yet */
-{
- int nexthandle;
-
- if (*handle == con.input_history_pos)
- return NULL;
-
- if (*handle == -1)
- *handle = con.input_history_pos;
-
- nexthandle = (*handle) - 1;
- if (nexthandle == -1)
- nexthandle = CON_INPUT_HISTORY_SIZE - 1;
-
- if (con.input_history[nexthandle])
- *handle = nexthandle;
-
- return con.input_history[nexthandle];
-}
-
-char *
-con_history_get_next(int *handle)
-{
- int last = (con.input_history_pos + CON_INPUT_HISTORY_SIZE - 1) % CON_INPUT_HISTORY_SIZE;
- int nexthandle;
-
- if (*handle < 0 || *handle > CON_INPUT_HISTORY_SIZE)
- return NULL;
-
- if (*handle == last) {
- *handle = -1;
- return NULL; /* End of history */
- }
-
- nexthandle = *handle + 1;
- if (nexthandle == CON_INPUT_HISTORY_SIZE)
- nexthandle = 0;
-
- if (con.input_history[nexthandle])
- *handle = nexthandle;
-
- return con.input_history[nexthandle];
-}
-
-void
-con_history_archive(char *msg)
-{
- char **writepos = &(con.input_history[con.input_history_pos]);
-
- if (*writepos)
- sci_free(*writepos);
-
- *writepos = msg;
-
- if (++con.input_history_pos >= CON_INPUT_HISTORY_SIZE)
- con.input_history_pos = 0;
-}
-
-char *
-con_gfx_read(gfx_state_t *state)
-{
- int chwidth = CON_BUILTIN_CHARS_WIDTH / state->driver->mode->xfact;
- int maxchars = 320 / chwidth;
- sci_event_t evt;
- char *retval;
- int done = 0;
- int slen = strlen(con.input_text);
- int history_handle = -1;
-
- do {
- int old_pos = con.cursor_position;
- int must_resize = 0; /* Have to re-calculate the strlen */
- int must_redraw = 0; /* Redraw input field */
- int must_rewin = 0; /* Re-calculate window */
- int must_redraw_text = 0; /* Redraw display field */
- if (slen+1 >= con.input_bufsize)
- con.input_text = (char *)sci_realloc(con.input_text, con.input_bufsize += 64);
-
- evt.type = 0;
- while (!evt.type)
- evt = gfxop_get_event(state, SCI_EVT_ANY);
-
- if (evt.type == SCI_EVT_KEYBOARD) {
-
- if (evt.buckybits & SCI_EVM_CTRL) {
- switch(evt.data) {
- case 'p':
- case 'P': {
- char *hist = con_history_get_prev(&history_handle);
-
- if (hist) {
- sci_free(con.input_text);
- con.input_text = sci_strdup(hist);
- }
- must_resize = must_redraw = must_rewin = 1;
- }
- break;
-
- case 'n':
- case 'N': {
- char *hist = con_history_get_next(&history_handle);
-
- if (hist) {
- sci_free(con.input_text);
- con.input_text = sci_strdup(hist);
- }
- must_resize = must_redraw = must_rewin = 1;
- }
- break;
-
- case 'a':
- case 'A': /* C-a */
- con.cursor_position = 0;
- break;
-
- case 'b':
- case 'B': /* C-b */
- if (con.cursor_position)
- --con.cursor_position;
- break;
-
- case 'e':
- case 'E': /* C-e */
- con.cursor_position = slen;
- break;
-
- case 'f':
- case 'F': /* C-f */
- if (con.cursor_position < slen)
- ++con.cursor_position;
- break;
-
- case 'd':
- case 'D':
- memmove(con.input_text + con.cursor_position,
- con.input_text + con.cursor_position + 1,
- slen - con.cursor_position);
- must_resize = must_redraw = 1;
- break;
-
- case 'h':
- case 'H':
- if (!con.cursor_position)
- break;
-
- memmove(con.input_text + con.cursor_position - 1,
- con.input_text + con.cursor_position,
- slen - con.cursor_position + 1);
- must_resize = must_redraw = 1;
- --con.cursor_position;
- break;
-
- case 'k':
- case 'K':
- con.input_text[con.cursor_position] = 0;
- must_resize = must_redraw = 1;
- break;
-
- case '`': return "go";
-
- default:
- break;
- }
- } else if (evt.buckybits & SCI_EVM_ALT) {
- switch(evt.data) {
- case 'b':
- case 'B':
- con.cursor_position = _str_move_blank(con.input_text,
- slen,
- con.cursor_position,
- -1);
- break;
-
- case 'f':
- case 'F':
- con.cursor_position = _str_move_blank(con.input_text,
- slen,
- con.cursor_position,
- 1);
- break;
-
- case 'd':
- case 'D': {
- int delpos = _str_move_blank(con.input_text, slen,
- con.cursor_position, 1);
-
- must_resize = must_redraw = 1;
- memmove(con.input_text + con.cursor_position,
- con.input_text + delpos,
- slen - delpos + 1);
- }
-
- default:
- break;
- }
- } else switch (evt.data) {
-
- case SCI_K_UP: {
- char *hist = con_history_get_prev(&history_handle);
-
- if (hist) {
- sci_free(con.input_text);
- con.input_text = sci_strdup(hist);
- }
- must_resize = must_redraw = must_rewin = 1;
- }
- break;
-
- case SCI_K_DOWN: {
- char *hist = con_history_get_next(&history_handle);
-
- if (hist) {
- sci_free(con.input_text);
- con.input_text = sci_strdup(hist);
- }
- must_resize = must_redraw = must_rewin = 1;
- }
- break;
-
-
- case SCI_K_LEFT:
- if (con.cursor_position)
- --con.cursor_position;
- break;
-
- case SCI_K_RIGHT:
- if (con.cursor_position < slen)
- ++con.cursor_position;
- break;
-
-
- case SCI_K_PGDOWN:
- must_redraw_text = 1;
- con_scroll(state, -75, maxchars);
- break;
-
- case SCI_K_PGUP:
- must_redraw_text = 1;
- con_scroll(state, 75, maxchars);
- break;
-
- case SCI_K_END:
- con_jump_to_end(state);
- must_redraw_text = 1;
- break;
-
- case SCI_K_DELETE:
- memmove(con.input_text + con.cursor_position,
- con.input_text + con.cursor_position + 1,
- slen - con.cursor_position);
- must_resize = must_redraw = 1;
- break;
-
- case SCI_K_BACKSPACE:
- if (!con.cursor_position)
- break;
-
- memmove(con.input_text + con.cursor_position - 1,
- con.input_text + con.cursor_position,
- slen - con.cursor_position + 1);
- must_resize = must_redraw = 1;
- --con.cursor_position;
- break;
-
-
- case SCI_K_ENTER:
- done = 1;
- break;
-
- default:
- if ((evt.character >= 32) && (evt.character <= 255)) {
- memmove(con.input_text + con.cursor_position + 1,
- con.input_text + con.cursor_position,
- slen - con.cursor_position + 1);
-
- con.input_text[con.cursor_position] = evt.character;
- ++con.cursor_position;
- ++slen;
- must_redraw = 1;
- }
- }
- }
-
- if (must_resize)
- slen = strlen(con.input_text);
-
- if (old_pos != con.cursor_position)
- must_redraw = 1;
-
- if (must_rewin) {
- int chwidth = CON_BUILTIN_CHARS_WIDTH / state->driver->mode->xfact;
- int nr_chars = 320 / chwidth;
-
- con.cursor_position = slen;
- con.input_window = slen - nr_chars + (nr_chars >> 3);
- }
-
- if (must_redraw || must_redraw_text) {
- _con_redraw(state, must_redraw_text, must_redraw);
- gfxop_update(state);
- }
- } while (!done);
-
- retval = con.input_text;
- con.input_text = (char *)sci_malloc(64);
- con.input_text[0] = 0;
- con.input_window = con.input_prompt_pos;
- con.cursor_position = 0;
-
- if (!*retval) {
- int hist = -1;
- sci_free(retval);
- return con_history_get_prev(&hist);
- }
- /* else */
- con_history_archive(retval);
- return retval;
-}
-
-static void
-_con_redraw(gfx_state_t *state, int update_display_field, int update_input_field)
-{
- int chwidth = CON_BUILTIN_CHARS_WIDTH / state->driver->mode->xfact;
- int nr_chars = 320 / chwidth;
- int offset = con_displayed_lines;
- int pixmap_index = -42;
- int must_recompute_pixmap_index = 1;
- int max_offset;
- con_pos_t pos = con.pos;
- rect_t fullbox = con_box();
- int yscale = state->driver->mode->yfact;
- int input_field_height = con.input_prompt ?
- (con.input_prompt->index_yl + yscale - 1) / yscale : 0;
- /* This delta is in "virtual" SCI pixels */
- int input_field_size = con_border_width + input_field_height;
- /* Let's consider the bottom padding to be part of the input field */
-
-
- if (!update_input_field && !update_display_field)
- return;
- if (!update_input_field)
- fullbox.yl -= input_field_size;
-
- if (!update_display_field) {
- fullbox.y = fullbox.yl - input_field_size;
- fullbox.yl = input_field_size;
- }
-
- if (con.color_bg.alpha)
- _con_draw_bg_pic(state, fullbox);
-
- /* Draw overlay box */
- gfxop_draw_box(state, fullbox, con.color_bg, con.color_bg,
- GFX_BOX_SHADE_FLAT);
-
- if (update_input_field) {
-
- if (con_border_width >= 2) {
- int y = con_displayed_lines + con_border_width - 2;
-
- gfxop_draw_line(state, gfx_point(0, y), gfx_point(319, y),
- con.color_input, GFX_LINE_MODE_FINE,
- GFX_LINE_STYLE_NORMAL);
- }
-
- if (con.input_prompt) {
- int promptlen = strlen(CON_GFX_PROMPT);
-
- if (con.cursor_position - con.input_window < (nr_chars >> 3))
- con.input_window -= (nr_chars >> 1);
- else if (con.cursor_position - con.input_window > (nr_chars - (nr_chars >> 3)))
- con.input_window += (nr_chars >> 1);
-
- if (con.input_window < con.input_prompt_pos)
- con.input_window = con.input_prompt_pos;
-
- offset -= input_field_height;
-
- if (con.input_oncursor) {
- gfxop_free_pixmap(state, con.input_oncursor);
- con.input_oncursor = NULL;
- }
-
- if (con.input_text) {
- char oncursorbuf[2];
- char *postcursor_text = con.input_text + con.cursor_position + 1;
- char temp_sep;
-
- oncursorbuf[1] = 0;
- oncursorbuf[0] = temp_sep = con.input_text[con.cursor_position];
-
- if (!temp_sep)
- oncursorbuf[0] = ' '; /* Draw at least a blank cursor */
-
- if (con.input_precursor) {
- gfxop_free_pixmap(state, con.input_precursor);
- con.input_precursor = NULL;
- }
- if (con.input_postcursor) {
- gfxop_free_pixmap(state, con.input_postcursor);
- con.input_postcursor = NULL;
- }
-
- con.input_oncursor = _con_render_text(state, oncursorbuf, -1,
- &con.color_input,
- &con.color_cursor);
- if (con.input_text[0])
- con.input_precursor = _con_render_text(state,
- con.input_text, -1,
- &con.color_input,
- NULL);
- if (postcursor_text[-1])
- con.input_postcursor = _con_render_text(state,
- postcursor_text,
- -1,
- &con.color_input,
- NULL);
-
- con.input_text[con.cursor_position] = temp_sep;
- } else {
- con.input_oncursor = _con_render_text(state, " ", -1,
- &con.color_input,
- &con.color_cursor);
- }
-
-
- if (con.input_window < 0) {
- con.input_prompt->xoffset = 0;
- con.input_prompt->yoffset = 0;
- gfxop_draw_pixmap(state, con.input_prompt,
- gfx_rect(0, 0,
- con.input_prompt->index_xl,
- con.input_prompt->index_yl),
- gfx_point(chwidth * (strlen(CON_GFX_PROMPT)
- + con.input_window),
- offset));
- }
-
- if (con.input_precursor && con.input_window < con.cursor_position)
- gfxop_draw_pixmap(state, con.input_precursor,
- gfx_rect(0, 0,
- con.input_precursor->index_xl,
- con.input_precursor->index_yl),
- gfx_point(chwidth * -con.input_window,
- offset));
-
- if (con.input_postcursor && con.input_window + nr_chars - 1 >
- con.cursor_position) {
- gfxop_draw_pixmap(state, con.input_postcursor,
- gfx_rect(0, 0,
- con.input_postcursor->index_xl,
- con.input_postcursor->index_yl),
- gfx_point(chwidth * (con.cursor_position + 1
- - con.input_window),
- offset));
- }
-
- if (con.input_oncursor)
- gfxop_draw_pixmap(state, con.input_oncursor,
- gfx_rect(0, 0,
- con.input_oncursor->index_xl,
- con.input_oncursor->index_yl),
- gfx_point(chwidth * (con.cursor_position
- - con.input_window),
- offset));
-
-
- }
- } else
- offset -= input_field_height;
-
- if (!update_display_field) {
- gfxop_update_box(state, fullbox);
- return;
- }
-
- max_offset = offset;
-
- if (con.locked_to_end) {
- pos.buf = con_buffer;
- pos.offset = 0;
- pos.entry = con_top_buffer_entry_nr - 1;
- }
-
- while (pos.buf && offset >= 0) {
- con_entry_t *drawme;
- int depth = pos.offset;
- int line_yl;
-
- pos.offset = 0;
-
- if (pos.entry < 0) {
- pos.entry = CON_CLUSTER_SIZE - 1;
- if (pos.buf)
- pos.buf = pos.buf->prev;
-
- if (!pos.buf)
- break;
- }
-
- drawme = &(pos.buf->entries[pos.entry]);
-
- if (_unfold_graphics(state, drawme, nr_chars))
- must_recompute_pixmap_index = 1;
-
- if (must_recompute_pixmap_index) {
- pixmap_index = drawme->pixmaps_nr - 1;
- must_recompute_pixmap_index = 0;
- }
-
- if (pixmap_index < 0) {
- pos.entry--;
- continue;
- }
-
- while (pixmap_index >= 0
- && depth > (drawme->pixmaps[pixmap_index]->yl + yscale - 1) / yscale)
- depth -= (drawme->pixmaps[pixmap_index--]->yl + yscale -1) / yscale;
-
- if (pixmap_index == -1) {
- fprintf(stderr, "ERROR: Offset too great! It was %d in a block of height %d\n",
- con.pos.offset, drawme->height);
- exit(1);
- continue;
- }
-
- line_yl = (drawme->pixmaps[pixmap_index]->yl + yscale - 1) / yscale;
-
- offset -= line_yl - depth;
- depth = line_yl;
-
- if (offset + depth > max_offset)
- depth = max_offset - offset;
-
- gfxop_draw_pixmap(state, drawme->pixmaps[pixmap_index],
- gfx_rect(0, 0,
- drawme->pixmaps[pixmap_index]->index_xl, depth),
- gfx_point(0, offset));
- /*
- ** TODO: Insert stuff into overwrapped lines **
- if (pixmap_index)
- gfxop_draw_line(state, gfx_rect(chwidth - 2, offset,
- chwidth - 2, offset + depth),
- con.color_text, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL);
- */
-
- if (!pixmap_index) {
- pos.entry--;
- must_recompute_pixmap_index = 1;
- } else
- --pixmap_index;
- }
-
- gfxop_update_box(state, fullbox);
-}
-
-static void
-_con_free_entry_pixmaps(gfx_state_t *state, con_entry_t *entry)
-{
- int j;
-
- if (entry->pixmaps) {
- for (j = 0; j < entry->pixmaps_nr; j++)
- gfxop_free_pixmap(state, entry->pixmaps[j]);
- sci_free(entry->pixmaps);
- entry->pixmaps_nr = 0;
- entry->pixmaps = NULL;
- }
-}
-
-
-static void
-_free_con_buffer(con_buffer_t *buf);
-
-static void
-free_con_buffer(con_buffer_t *buf)
-/* Frees a con buffer and all of its predecessors */
-{
- /* First, make sure we're not destroying the current display */
- if (!con.locked_to_end) {
- con_buffer_t *seeker = con.pos.buf;
- while (seeker && seeker != buf)
- seeker = seeker->prev;
-
- if (seeker) {
- if (seeker->prev)
- con.pos.buf = seeker->next;
- else
- con.locked_to_end = 1;
- }
- }
- _free_con_buffer(buf);
-}
-
-static void
-_free_con_buffer(con_buffer_t *buf)
-{
- int i;
-
- if (buf) {
- con_buffer_t *prev = buf->prev;
-
- if (buf->next)
- buf->next->prev = NULL;
- for (i = 0; i < CON_CLUSTER_SIZE; i++)
- if (CON_ENTRY_USED(buf->entries[i])) {
- if (buf->entries[i].text)
- sci_free(buf->entries[i].text);
- _con_free_entry_pixmaps(con_last_gfx_state, &buf->entries[i]);
-
- buf->entries[i].height = -1;
- }
- sci_free(buf);
- --con_buffer_clusters;
-
- if (prev)
- _free_con_buffer(prev);
- }
-}
-
-
-byte con_builtin_font_data[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
- 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
- 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
- 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00,
- 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0xd6, 0x10, 0x38,
- 0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x7c, 0x10, 0x38,
- 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00,
- 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff,
- 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,
- 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff,
- 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
- 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18,
- 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0,
- 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0,
- 0x18, 0xdb, 0x3c, 0xe7, 0xe7, 0x3c, 0xdb, 0x18,
- 0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00,
- 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
- 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18,
- 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
- 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00,
- 0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c,
- 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00,
- 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff,
- 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00,
- 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00,
- 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00,
- 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00,
- 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00,
- 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00,
- 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00,
- 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
- 0x18, 0x3e, 0x60, 0x3c, 0x06, 0x7c, 0x18, 0x00,
- 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00,
- 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00,
- 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00,
- 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00,
- 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00,
- 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30,
- 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
- 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00,
- 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
- 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00,
- 0x7c, 0xc6, 0x06, 0x1c, 0x30, 0x66, 0xfe, 0x00,
- 0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00,
- 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00,
- 0xfe, 0xc0, 0xc0, 0xfc, 0x06, 0xc6, 0x7c, 0x00,
- 0x38, 0x60, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00,
- 0xfe, 0xc6, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00,
- 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00,
- 0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00,
- 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
- 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30,
- 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00,
- 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00,
- 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00,
- 0x7c, 0xc6, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x00,
- 0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00,
- 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00,
- 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00,
- 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00,
- 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00,
- 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00,
- 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00,
- 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3a, 0x00,
- 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00,
- 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00,
- 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00,
- 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00,
- 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
- 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00,
- 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
- 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xce, 0x7c, 0x0e,
- 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00,
- 0x3c, 0x66, 0x30, 0x18, 0x0c, 0x66, 0x3c, 0x00,
- 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
- 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
- 0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00,
- 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x00,
- 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00,
- 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00,
- 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00,
- 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00,
- 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
- 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
- 0xe0, 0x60, 0x7c, 0x66, 0x66, 0x66, 0xdc, 0x00,
- 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x00,
- 0x1c, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
- 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
- 0x3c, 0x66, 0x60, 0xf8, 0x60, 0x60, 0xf0, 0x00,
- 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
- 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00,
- 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x06, 0x00, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c,
- 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00,
- 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0x00,
- 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00,
- 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0,
- 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
- 0x00, 0x00, 0xdc, 0x76, 0x60, 0x60, 0xf0, 0x00,
- 0x00, 0x00, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0x00,
- 0x30, 0x30, 0xfc, 0x30, 0x30, 0x36, 0x1c, 0x00,
- 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
- 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
- 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
- 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00,
- 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc,
- 0x00, 0x00, 0x7e, 0x4c, 0x18, 0x32, 0x7e, 0x00,
- 0x0e, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0e, 0x00,
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
- 0x70, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x70, 0x00,
- 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00,
- 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18,
- 0x38, 0x6c, 0x64, 0xf0, 0x60, 0x66, 0xfc, 0x00,
- 0x00, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0x00,
- 0x66, 0x66, 0x3c, 0x7e, 0x18, 0x7e, 0x18, 0x18,
- 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18,
- 0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c,
- 0x00, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7e, 0x81, 0x9d, 0xa1, 0xa1, 0x9d, 0x81, 0x7e,
- 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00,
- 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
- 0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
- 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00,
- 0x78, 0x0c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00,
- 0x78, 0x0c, 0x38, 0x0c, 0x78, 0x00, 0x00, 0x00,
- 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0xc0,
- 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00,
- 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x38,
- 0x18, 0x38, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
- 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
- 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00,
- 0x63, 0xe6, 0x6c, 0x7a, 0x36, 0x6a, 0xdf, 0x06,
- 0x63, 0xe6, 0x6c, 0x7e, 0x33, 0x66, 0xcc, 0x0f,
- 0xe1, 0x32, 0xe4, 0x3a, 0xf6, 0x2a, 0x5f, 0x86,
- 0x18, 0x00, 0x18, 0x18, 0x30, 0x63, 0x3e, 0x00,
- 0x18, 0x0c, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00,
- 0x30, 0x60, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00,
- 0x7c, 0x82, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00,
- 0x76, 0xdc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00,
- 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00,
- 0x38, 0x6c, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00,
- 0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00,
- 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x0c, 0x78,
- 0x30, 0x18, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00,
- 0x18, 0x30, 0xfe, 0xc0, 0xf8, 0xc0, 0xfe, 0x00,
- 0x7c, 0x82, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00,
- 0xc6, 0x00, 0xfe, 0xc0, 0xfc, 0xc0, 0xfe, 0x00,
- 0x30, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x0c, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x3c, 0x42, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x66, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0xf8, 0x6c, 0x66, 0xf6, 0x66, 0x6c, 0xf8, 0x00,
- 0x76, 0xdc, 0x00, 0xe6, 0xf6, 0xde, 0xce, 0x00,
- 0x0c, 0x06, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00,
- 0x30, 0x60, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00,
- 0x7c, 0x82, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00,
- 0x76, 0xdc, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00,
- 0xc6, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
- 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00,
- 0x3a, 0x6c, 0xce, 0xd6, 0xe6, 0x6c, 0xb8, 0x00,
- 0x60, 0x30, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x18, 0x30, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x7c, 0x82, 0x00, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x0c, 0x18, 0x66, 0x66, 0x3c, 0x18, 0x3c, 0x00,
- 0xf0, 0x60, 0x7c, 0x66, 0x7c, 0x60, 0xf0, 0x00,
- 0x78, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xcc, 0x00,
- 0x30, 0x18, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
- 0x18, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
- 0x7c, 0x82, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
- 0x76, 0xdc, 0x7c, 0x06, 0x7e, 0xc6, 0x7e, 0x00,
- 0xc6, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
- 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
- 0x00, 0x00, 0x7e, 0x12, 0xfe, 0x90, 0xfe, 0x00,
- 0x00, 0x00, 0x7e, 0xc0, 0xc0, 0x7e, 0x0c, 0x38,
- 0x30, 0x18, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
- 0x0c, 0x18, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
- 0x7c, 0x82, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
- 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
- 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00,
- 0x0c, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00,
- 0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
- 0x30, 0x7e, 0x0c, 0x7c, 0xcc, 0xcc, 0x78, 0x00,
- 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x00,
- 0x30, 0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x0c, 0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x7c, 0x82, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x76, 0xdc, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
- 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00,
- 0x00, 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80,
- 0x60, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
- 0x18, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
- 0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
- 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
- 0x18, 0x30, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc,
- 0xe0, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xf0,
- 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc
-};
-
-#endif /* !WANT_CONSOLE */
Deleted: scummvm/trunk/engines/sci/include/conf_summary.h
===================================================================
--- scummvm/trunk/engines/sci/include/conf_summary.h 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/include/conf_summary.h 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,106 +0,0 @@
-/***************************************************************************
- conf_summary.h Copyright (C) 2007 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-
-#ifndef CONF_SUMMARY_H_
-#define CONF_SUMMARY_H_
-
-#include<conf_parse.h>
-#include<conf_driver.h>
-
-typedef struct {
- conf_option_t *option; /* NULL if this is a terminator */
- conf_parse_t *parse; /* Source location we got this information from,
- ** or NULL for command-line or default */
- union { char *str;
- int nr } choice;
- int origin;
- int flags;
-} conf_option_choice_t;
-
-#define CONF_CHOICE_ORIGIN_DEFAULT 0 /* Built-in default */
-#define CONF_CHOICE_ORIGIN_CONFDEFAULT 1 /* Config file option */
-#define CONF_CHOICE_ORIGIN_CONFGAME 2 /* Game-specific option */
-#define CONF_CHOICE_ORIGIN_COMMANDLINE 3
-
-#define CONF_CHOICE_FLAG_WRITEABLE (1<<0) /* 'parse' can be written to */
-#define CONF_CHOICE_FLAG_DISABLED (1<<1) /* Option isn't set, only listed for completeness */
-
-typedef struct {
- conf_option_choice_t *options; /* Driver-specific */
- conf_driver_t *driver;
-} conf_driver_choice_t;
-
-typedef struct {
- conf_option_choice_t *options; /* Subsystem-specific */
- int driver_origin; /* CONF_CHOICE_ORIGIN_* */
- conf_driver_choice_t *driver; /* The particular driver selected */
- conf_driver_choice_t *drivers; /* All available drivers, with their options */
-} conf_subsystem_choice_t;
-
-typedef struct {
- char *game_id; /* NULL for default */
- conf_option_choice_t *options; /* Global */
- int flags;
- conf_parse_t **append_location; /* Into here we can add new configuration options to override */
-
- conf_subsystem_choice_t[CONF_SUBSYSTEMS_NR] subsystems;
-} conf_game_choice_t;
-
-#define CONF_GAME_CHOICE_FLAG_OVERRIDE_IN_SECTION (1<<0) /* Override section already exists, need not be re-created */
-
-typedef struct {
- conf_game_choice_t *default;
-
- int game_choices_nr;
- conf_game_choice_t *game_choices;
-} conf_summary_t;
-
-
-conf_summary_t *
-conf_summary(conf_parse_t *raw_config);
-/* Summarises a config parse in a conf_summary_t
-** Parameters: (conf_parse_t *) raw_config: The parse to summarise
-** Returns : (conf_summary_t *) A summarised configuration
-** The summary includes (default) values for all driver/subsystem options
-*/
-
-void
-conf_free_summary(conf_summary_t *summary);
-/* Deallocates a configuration summary
-** Parameters: (conf_summary_t *) summary: The summary to deallocate
-** This only affects the summary, not the underlying parse.
-*/
-
-conf_game_choice_t *
-conf_find_choice(conf_summary_t *choices, char *game_id);
-/* Finds the correct game choice by game ID
-** Parameters: (conf_summary_t *) summary: The summary to peruse
-** (char *) game_id: Identified game ID.
-** We search by exact match or otherwise default.
-*/
-
-#endif /* !defined (CONF_SUMMARY_H_) */
Deleted: scummvm/trunk/engines/sci/include/modules.h
===================================================================
--- scummvm/trunk/engines/sci/include/modules.h 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/include/modules.h 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,84 +0,0 @@
-/***************************************************************************
- modules.h Copyright (C) 2001 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-
-#ifndef _FREESCI_MODULES_H_
-#define _FREESCI_MODULES_H_
-
-#include <sciresource.h>
-
-#ifdef _WIN32
-# define MODULE_NAME_SUFFIX ".dll"
-#else
-# define MODULE_NAME_SUFFIX ".so"
-#endif
-
-
-/* Modules must sub-type this structure. Oh, wait, C doesn't do sub-typing.
-** Well, they have to start the same, anyway... */
-typedef struct {
- char *module_name; /* Module name */
- char *module_version; /* Module version */
- int class_magic; /* Magic ID to identify drivers of certain types */
- int class_version; /* Version of that particular driver class */
-
- /* More entries might be added later, but won't be checked if magic or
- ** version don't match. */
-
-} sci_module_t;
-
-
-void *
-sci_find_module(char *path, char *name, char *type, char *struct_prefix,
- char *file_suffix, int magic, int version, void **handle);
-/* Attempts to open a module with the specified parameters in the path
-** Parameters: (char *) path: The path to look in; supports several directories
-** (char *) name: Module name
-** (char *) type: Module type string (see below)
-** (char *) struct_prefix: see below
-** (char *) file_suffix: see below
-** (int) magic: Magic number to identify the module type
-** (int) version: The only version to support
-** (void **) handle: Pointer to a void * which a handle is written
-** to (for use with sci_close_module()).
-** Returns : (void *) NULL if no module was found, a pointer to the structure
-** otherwise
-** This function looks for the structure 'struct_prefix + name' in a file called
-** 'name + file_suffix + MODULE_NAME_SUFFIX' in the 'type' subdirectory.
-** It only success if both the magic and the version number match.
-*/
-
-void
-sci_close_module(void *module, char *type, char *name);
-/* Closes a previously found module
-** Parameters: (void *) module: Reference to the module to close
-** (char *) type: Type of the module (for debugging)
-** (char *) name: Module name (for debugging)
-** Returns : (void)
-*/
-
-
-#endif /* !_FREESCI_MODULES_H_ */
Deleted: scummvm/trunk/engines/sci/include/sci_conf.h
===================================================================
--- scummvm/trunk/engines/sci/include/sci_conf.h 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/include/sci_conf.h 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,187 +0,0 @@
-/***************************************************************************
- sci_conf.h Copyright (C) 1999,2000,01 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CJR) [jameson at linuxgames.com]
-
-***************************************************************************/
-/* Configuration and setup stuff for FreeSCI */
-
-#ifndef _SCI_CONFIG_H_
-#define _SCI_CONFIG_H_
-
-#include <versions.h>
-#include <gfx_options.h>
-
-#define FREESCI_DRIVER_SUBSYSTEMS_NR 1
-
-#define FREESCI_DRIVER_SUBSYSTEM_GFX 0
-#define FREESCI_DRIVER_SUBSYSTEM_PCM 1
-#define FREESCI_DRIVER_SUBSYSTEM_MIDIOUT 2
-
-#ifdef _WIN32
-# define SCI_DEFAULT_MODULE_PATH "."
-#else
-# define SCI_DEFAULT_MODULE_PATH "/usr/local/lib/freesci/:/usr/lib/freesci/"
-#endif
-
-typedef struct _driver_option {
- char *option;
- char *value;
- struct _driver_option *next;
-} driver_option_t;
-
-typedef struct _subsystem_options {
- char *name; /* Driver name */
- driver_option_t *options;
- struct _subsystem_options *next; /* next driver */
-} subsystem_options_t;
-
-typedef struct {
- /* IMPORTANT: these values correspond directly to what's specified in
- ** config.l. Where an option is of type OPTION_TYPE_NVP or
- ** OPTION_TYPE_INVERSE_NVP, it is cast as an _integer_. Therefore it
- ** should not be any other type except for int here.
- */
-
- char *name; /* Game identifier */
- sci_version_t version; /* The version to emulate */
-
- gfx_options_t gfx_options;
-
- subsystem_options_t *driver_options[FREESCI_DRIVER_SUBSYSTEMS_NR];
-
- int x_scale, y_scale, scale, color_depth; /* GFX subsystem initialization values */
-
- int animation_delay; /* Number of microseconds to wait between each pic transition animation cycle */
- int animation_granularity; /* Granularity for pic transition animations */
- int alpha_threshold; /* Crossblitting alpha threshold */
- int unknown_count; /* The number of "unknown" kernel functions */
- char *resource_dir; /* Resource directory */
- char *gfx_driver_name; /* The graphics driver to use */
- char *console_log; /* The file to which console output should be echoed */
- char *menu_dir; /* Directory where the game menu searches for games */
- char debug_mode [80]; /* Characters specifying areas for which debug output should be enabled */
- int mouse; /* Whether the mouse should be active */
- int reverse_stereo;
- int res_version;
-
-#ifdef __GNUC__
-# warning "Re-enable sound stuff"
-#endif
-#if 0
- midiout_driver_t *midiout_driver; /* the midiout method to use */
- midi_device_t *midi_device; /* the midi device to use */
-
- pcmout_driver_t *pcmout_driver; /* the pcm driver to use */
- sound_server_t *sound_server; /* The sound server */
-#endif
- guint16 pcmout_rate; /* Sample rate */
- guint8 pcmout_stereo; /* Stereo? */
-
- char *module_path; /* path to directories modules are loaded from */
- void *dummy; /* This is sad... */
-} config_entry_t;
-
-int
-config_init(config_entry_t **conf, char *conffil);
-/* Initializes the config entry structurre based on information found in the config file.
-** Parameters: (config_entry_t **) conf: See below
-** (char *) conffile: Filename of the config file, or NULL to use the default name
-** Returns : (int) The number of config file entries found
-** This function reads the ~/.freesci/config file, parses it, and inserts the appropriate
-** data into *conf. *conf will be malloc'd to be an array containing default information in [0]
-** and game-specific data in each of the subsequent record entries.
-** Not threadsafe. Uses flex-generated code.
-*/
-
-void
-config_free(config_entry_t **conf, int entries);
-/* Frees a config entry structure
-** Parameters: (config_entry_t **) conf: Pointer to the pointer to the first entry of the list
-** (int) entries: Number of entries to free
-** Returns : (void)
-*/
-
-
-void *
-parse_gfx_driver(char *driver_name);
-/* Parses a string and looks up an appropriate driver structure
-** Parameters: (char *) driver_name: Name of the driver to look up
-** Returns : (void *) A matching driver, or NULL on failure
-*/
-
-void *
-parse_midiout_driver(char *driver_name);
-/* Parses a string and looks up an appropriate driver structure
-** Parameters: (char *) driver_name: Name of the driver to look up
-** Returns : (void *) A matching driver, or NULL on failure
-*/
-
-void *
-parse_midi_device(char *driver_name);
-/* Parses a string and looks up an appropriate driver structure
-** Parameters: (char *) driver_name: Name of the driver to look up
-** Returns : (void *) A matching driver, or NULL on failure
-*/
-
-void *
-parse_pcmout_driver(char *driver_name);
-/* Parses a string and looks up an appropriate driver structure
-** Parameters: (char *) driver_name: Name of the driver to look up
-** Returns : (void *) A matching driver, or NULL on failure
-*/
-
-void *
-parse_sound_server(char *driver_name);
-/* Parses a string and looks up an appropriate driver structure
-** Parameters: (char *) driver_name: Name of the driver to look up
-** Returns : (void *) A matching sound server, or NULL on failure
-*/
-
-driver_option_t *
-get_driver_options(config_entry_t *config, int subsystem, const char *name);
-/* Retreives the driver options for one specific driver in a subsystem
-** Parameters: (config_entry_t *) config: The config entry to search in
-** (int) subsystem: Any of the FREESCI_DRIVER_SUBSYSTEMs
-** (const char *) name: Name of the driver to look for
-** Returns : (driver_option_t *) A pointer to the first option in
-** a singly-linked list of options, or NULL if none was
-** found
-*/
-
-#if 0
-void *
-find_module(char *path, char *module_name, char *module_suffix);
-/* Tries to find a module in the specified path
-** Parameters: (char *) path: The path to search in (specified in config)
-** (char *) module_name: Name of the module to look for
-** (char *) module_suffix: Module structure to look for
-** More precisely, the module "module_name" + MODULE_NAME_SUFFIX is
-** looked for in all members of the path. If it is found,
-
-** FIXME: First need to add generic module architecture
-
-*/
-#endif
-
-#endif /* !_SCI_CONFIG_H */
Deleted: scummvm/trunk/engines/sci/main.c
===================================================================
--- scummvm/trunk/engines/sci/main.c 2009-02-15 10:10:04 UTC (rev 38213)
+++ scummvm/trunk/engines/sci/main.c 2009-02-15 10:10:23 UTC (rev 38214)
@@ -1,1840 +0,0 @@
-/***************************************************************************
- main.c Copyright (C) 1999,2000,01,02 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
- Christoph Reichenbach (CJR) [jameson at linuxgames.com]
-
-***************************************************************************/
-
-#include <sciresource.h>
-#include <engine.h>
-#include <uinput.h>
-#include <console.h>
-#include <gfx_operations.h>
-#include <sci_conf.h>
-#include <kdebug.h>
-#include <sys/types.h>
-#include <game_select.h>
-#include "list.h"
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_FORK
-# include <sys/wait.h>
-#endif
-
-#if defined(HAVE_SDL) && defined(MACOSX)
-# include <SDL.h>
-/* On OS X, SDL must #define main to something else in order to function */
-#endif
-
-#ifdef _MSC_VER
-#define extern __declspec(dllimport) extern
-#include <win32/getopt.h>
-#endif
-
-#ifdef HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
-#ifdef HAVE_READLINE_HISTORY_H
-#include <readline/history.h>
-#endif /* HAVE_READLINE_HISTORY_H */
-#endif /* HAVE_READLINE_READLINE_H */
-
-#ifdef HAVE_GETOPT_H
-# ifndef _MSC_VER
-# include <getopt.h>
-# else
-# include <win32\getopt.h>
-# endif
-#endif /* HAVE_GETOPT_H */
-
-#ifdef HAVE_GETOPT_LONG
-#define EXPLAIN_OPTION(longopt, shortopt, description) " " longopt "\t" shortopt "\t" description "\n"
-#else /* !HAVE_GETOPT_H */
-#define EXPLAIN_OPTION(longopt, shortopt, description) " " shortopt "\t" description "\n"
-#endif /* !HAVE_GETOPT_H */
-
-
-#ifdef _WIN32
-# ifdef _MSC_VER
-# include <direct.h>
-# define PATH_MAX 255
-# endif
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-#endif
-
-#ifdef _DREAMCAST
-# include <selectgame.h>
-#endif
-
-#ifdef _MSC_VER
-# define MSVC_FUNCTYPECAST_KLUDGE (void *)
-#else
-# define MSVC_FUNCTYPECAST_KLUDGE
-#endif
-
-#define ACTION_PLAY 0
-#define ACTION_LIST_SAVEGAMES 1
-
-static int sciv_action = ACTION_PLAY;
-
-/*** HW/OS-dependant features ***/
-
-static void
-check_features()
-{
-#ifdef HAVE_ALPHA_EV6_SUPPORT
- int helper;
- printf("Checking for MVI instruction-set extension: ");
-
- helper = 0x100;
-#ifdef __DECC
- axp_have_mvi = asm("amask %0, %v0", helper);
-#else
- __asm__ ("amask %1, %0"
- : "=r"(axp_have_mvi)
- : "r"(helper));
-#endif
-
- axp_have_mvi = !axp_have_mvi;
-
- if (axp_have_mvi)
- printf("found\n");
- else
- printf("not present\n");
-#endif
-}
-
-
-static gfx_state_t static_gfx_state; /* see below */
-static gfx_options_t static_gfx_options; /* see below */
-
-static state_t *gamestate; /* The main game state */
-static gfx_state_t *gfx_state = &static_gfx_state; /* The graphics state */
-static gfx_options_t *gfx_options = &static_gfx_options; /* Graphics options */
-static char *commandline_config_file = NULL;
-
-int
-c_quit(state_t *s)
-{
- script_abort_flag = 1; /* Terminate VM */
- _debugstate_valid = 0;
- _debug_seeking = 0;
- _debug_step_running = 0;
- return 0;
-}
-
-int
-c_die(state_t *s)
-{
- exit(0); /* Die */
- return 0; /* ;-P (fixes warning) */
-}
-
-
-char *old_input = NULL;
-
-#ifdef HAVE_READLINE_READLINE_H
-const char *
-get_readline_input(void)
-{
- char *input;
-
- fflush(NULL);
- input = readline("> ");
-
- if (!input) { /* ^D */
- c_quit(NULL);
- return "";
- }
-
- if (strlen(input) == 0) {
- free (input);
- } else {
-
-#ifdef HAVE_READLINE_HISTORY_H
- add_history(input);
-#endif /* HAVE_READLINE_HISTORY_H */
-
- if (old_input) {
- free(old_input);
- }
- old_input = input;
- }
-
- return old_input? old_input : "";
-}
-#endif /* HAVE_READLINE_READLINE_H */
-
-
-int
-init_directories(char *work_dir, char *game_id)
-{
- char *homedir = sci_get_homedir();
-
- printf("Initializing directories...\n");
- if (!homedir) { /* We're probably not under UNIX if this happens */
-
- if (!getcwd(work_dir, PATH_MAX)) {
- fprintf(stderr,"Cannot get the working directory!\n");
- return 1;
- }
-
- return 0;
- }
-
- /* So we've got a home directory */
-
- if (chdir(homedir)) {
-
-#ifdef _WIN32
- if (!getcwd(work_dir, PATH_MAX)) {
- fprintf(stderr,"Cannot get the working directory: %s\n", work_dir);
- return 1;
- }
-#else /* Assume UNIX-ish environment */
- fprintf(stderr,"Error: Could not enter home directory %s.\n", homedir);
- perror("Reason");
- return 1; /* If we get here, something really bad is happening */
-#endif
- }
-
- if (strlen(homedir) > MAX_HOMEDIR_SIZE) {
- fprintf(stderr, "Your home directory path is too long. Re-compile FreeSCI with "
- "MAX_HOMEDIR_SIZE set to at least %i and try again.\n", (int)(strlen(homedir)));
- return 1;
- }
-
- if (chdir(FREESCI_GAMEDIR)) {
- if (scimkdir(FREESCI_GAMEDIR, 0700)) {
-
- fprintf(stderr, "Warning: Could not enter ~/"FREESCI_GAMEDIR"; save files"
- " will be written to ~/\n");
-
- getcwd(work_dir, PATH_MAX);
- return 0;
-
- }
- else /* mkdir() succeeded */
- chdir(FREESCI_GAMEDIR);
- }
-
- if (chdir(game_id)) {
- if (scimkdir(game_id, 0700)) {
-
- fprintf(stderr,"Warning: Could not enter ~/"FREESCI_GAMEDIR"/%s; "
- "save files will be written to ~/"FREESCI_GAMEDIR"\n", game_id);
-
- getcwd(work_dir, PATH_MAX);
- return 0;
- }
- else /* mkdir() succeeded */
- chdir(game_id);
- }
-
- getcwd(work_dir, PATH_MAX);
-
- return 0;
-}
-
-
-const char *
-get_gets_input(void)
-{
- static char input[1024] = "";
-
- putchar('>');
-
- fflush(NULL);
- while (!strchr(input, '\n'))
- fgets(input, 1024, stdin);
-
- if (!input) {
- c_quit(NULL);
- return "";
- }
-
- if (strlen(input))
- if (input[strlen(input)-1] == '\n');
- input[strlen(input)-1] = 0; /* Remove trailing '\n' */
-
- if (strlen(input) == 0) {
- return old_input? old_input : "";
- }
-
- if (old_input)
- free(old_input);
-
- old_input = (char *) sci_malloc(1024);
- strcpy(old_input, input);
- return input;
-}
-
-
-
-
-static void
-list_graphics_drivers()
-{
- int i = 0;
- while (gfx_get_driver_name(i)) {
- if (i != 0)
- printf(", ");
-
- printf(gfx_get_driver_name(i));
-
- i++;
- }
- printf("\n");
-}
-
-#ifdef __GNUC__
-#warning "Re-enable sound stuff"
-#endif
-#if 0
-static void
-list_pcmout_drivers()
-{
- int i = 0;
- while (pcmout_drivers[i]) {
- if (i != 0)
- printf(", ");
- printf(pcmout_drivers[i]->name);
- i++;
- }
- printf("\n");
-}
-
-static void
-list_midiout_drivers()
-{
- int i = 0;
- while (midiout_drivers[i]) {
- if (i != 0)
- printf(", ");
- printf(midiout_drivers[i]->name);
- i++;
- }
- printf("\n");
-}
-
-
-static void
-list_midi_devices()
-{
- int i = 0;
- while (midi_devices[i]) {
- if (i != 0)
- printf(", ");
- printf(midi_devices[i]->name);
- i++;
- }
- printf("\n");
-}
-
-static void
-list_sound_servers()
-{
- int i = 0;
- while (sound_servers[i]) {
- if (i != 0)
- printf(", ");
- printf(sound_servers[i]->name);
- i++;
- }
- printf("\n");
-}
-#endif
-
-
-/**********************************************************/
-/* Startup and config management */
-/**********************************************************/
-
-typedef struct {
- int script_debug_flag;
- int scale_x, scale_y, color_depth;
- int mouse;
- int master_sound; /* on or off */
- int show_rooms;
- sci_version_t version;
- int res_version;
- char *gfx_driver_name;
- char *gamedir;
- char *gamemenu;
- char *midiout_driver_name;
- char *midi_device_name;
- char *sound_server_name;
- char *pcmout_driver_name;
-} cl_options_t;
-
-#define ON 1
-#define OFF 0
-#define DONTCARE -1
-
-static int game_select(cl_options_t cl_options, config_entry_t *confs, int conf_entries, const char* freesci_dir, const char *games_dir);
-static int game_select_resource_found();
-
-static char *
-parse_arguments(int argc, char **argv, cl_options_t *cl_options, char **savegame_name)
-{
- int c;
-#ifdef HAVE_GETOPT_LONG
- int optindex;
-
- struct option options[] = {
- {"run", no_argument, NULL, 0 },
- {"debug", no_argument, NULL, 1 },
- {"gamedir", required_argument, 0, 'd'},
- {"menudir", required_argument, 0, 'G'},
- {"no-sound", required_argument, 0, 'q'},
- {"sci-version", required_argument, 0, 'V'},
- {"graphics", required_argument, 0, 'g'},
- {"midiout", required_argument, 0, 'O'},
- {"pcmout", required_argument, 0, 'P'},
- {"sound-server", required_argument, 0, 'S'},
- {"mididevice", required_argument, 0, 'M'},
- {"version", no_argument, 0, 'v'},
- {"help", no_argument, 0, 'h'},
- {"scale-x", required_argument, 0, 'x'},
- {"scale-y", required_argument, 0, 'y'},
- {"color-depth", required_argument, 0, 'c'},
- {"disable-mouse", no_argument, 0, 'm'},
- {"list-savegames", no_argument, 0, 'l'},
- {"show-rooms", no_argument, 0, 's'},
- {"config-file", required_argument, 0, 'f'},
- {0,0,0,0}
- };
-
- options[0].flag = &(cl_options->script_debug_flag);
- options[1].flag = &(cl_options->script_debug_flag);
-#endif /* HAVE_GETOPT_H */
-
- cl_options->scale_x = cl_options->scale_y = cl_options->color_depth = 0;
- cl_options->version = 0;
- cl_options->script_debug_flag = 0;
- cl_options->gfx_driver_name = NULL;
- cl_options->gamedir = NULL;
- cl_options->gamemenu = NULL;
- cl_options->midiout_driver_name = NULL;
- cl_options->pcmout_driver_name = NULL;
- cl_options->midi_device_name = NULL;
- cl_options->sound_server_name = NULL;
- cl_options->mouse = ON;
- cl_options->master_sound = ON;
- cl_options->res_version = SCI_VERSION_AUTODETECT;
- cl_options->show_rooms = 0;
-
-#ifdef HAVE_GETOPT_LONG
- while ((c = getopt_long(argc, argv, "qlvhmsDr:d:G:V:g:x:y:c:M:O:S:P:f:", options, &optindex)) > -1) {
-#else /* !HAVE_GETOPT_LONG */
- while ((c = getopt(argc, argv, "qlvhmsDr:d:G:V:g:x:y:c:M:O:S:P:f:")) > -1) {
-#endif /* !HAVE_GETOPT_LONG */
- switch (c) {
-
- case 'r':
- cl_options->res_version = atoi(optarg);
- break;
-
- case 's':
- cl_options->show_rooms = 1;
- break;
-
- case 'D':
- cl_options->script_debug_flag = 1;
- break;
-
- case 'd':
- if (cl_options->gamedir)
- free(cl_options->gamedir);
-
- cl_options->gamedir = sci_strdup(optarg);
- break;
-
- case 'G':
- if (cl_options->gamemenu)
- free(cl_options->gamemenu);
-
- cl_options->gamemenu = sci_strdup(optarg);
- break;
-
- case 'f':
- commandline_config_file = sci_strdup(optarg);
- break;
-
- case 'V': {
- int major = *optarg - '0'; /* One version digit */
- int minor = atoi(optarg + 2);
- int patchlevel = atoi(optarg + 6);
-
- cl_options->version = SCI_VERSION(major, minor, patchlevel);
- }
- break;
-
- case 'g':
- if (cl_options->gfx_driver_name)
- free(cl_options->gfx_driver_name);
- cl_options->gfx_driver_name = sci_strdup(optarg);
- break;
- case 'O':
- if (cl_options->midiout_driver_name)
- free(cl_options->midiout_driver_name);
- cl_options->midiout_driver_name = sci_strdup(optarg);
- break;
- case 'P':
- if (cl_options->pcmout_driver_name)
- free(cl_options->pcmout_driver_name);
- cl_options->pcmout_driver_name = sci_strdup(optarg);
- break;
- case 'M':
- if (cl_options->midi_device_name)
- free(cl_options->midi_device_name);
- cl_options->midi_device_name = sci_strdup(optarg);
- break;
- case 'S':
- if (cl_options->sound_server_name)
- free(cl_options->sound_server_name);
- cl_options->sound_server_name = sci_strdup(optarg);
- break;
- case '?':
- /* getopt_long already printed an error message. */
- exit(1);
-
- case 'x':
- cl_options->scale_x = atoi(optarg);
- break;
-
- case 'y':
- cl_options->scale_y = atoi(optarg);
- break;
-
- case 'c':
- cl_options->color_depth = (atoi(optarg) +7) >> 3;
- break;
-
- case 'm':
- cl_options->mouse = OFF;
- break;
-
- case 'q':
- cl_options->master_sound = OFF;
- break;
-
- case 0: /* getopt_long already did this for us */
- break;
-
- case 'v':
- printf("This is FreeSCI, version %s\n", VERSION);
-
- printf("Supported graphics drivers: ");
- list_graphics_drivers();
-
-#ifdef __GNUC__
-#warning "Re-enable sound stuff"
-#endif
-#if 0
- printf("Supported sound servers: ");
- list_sound_servers();
-
- printf("Supported midiout drivers: ");
- list_midiout_drivers();
-
- printf("Supported midi 'devices': ");
- list_midi_devices();
-
- printf("Supported pcmout drivers: ");
- list_pcmout_drivers();
-#endif
-
- printf("\n");
- exit(0);
-
- case 'h':
- printf("Usage: freesci [options] [game name] [savegame ID]\n"
- "Runs a Sierra SCI game.\n"
- "\n"
- EXPLAIN_OPTION("--gamedir dir\t", "-ddir", "read game resources from dir")
- EXPLAIN_OPTION("--menudir dir\t", "-Gdir", "display menu for all games under dir")
- EXPLAIN_OPTION("--run\t\t", "-r", "do not start the debugger")
- EXPLAIN_OPTION("--sci-version ver", "-Vver", "set the version for freesci to emulate")
- EXPLAIN_OPTION("--version\t", "-v", "display version number and exit")
- EXPLAIN_OPTION("--debug\t", "-D", "start up in debug mode")
- EXPLAIN_OPTION("--help\t", "-h", "display this help text and exit")
- EXPLAIN_OPTION("--graphics gfx", "-ggfx", "use the 'gfx' graphics driver")
- EXPLAIN_OPTION("--scale-x\t", "-x", "Set horizontal scale factor")
- EXPLAIN_OPTION("--scale-y\t", "-y", "Set vertical scale factor")
- EXPLAIN_OPTION("--color-depth\t", "-c", "Specify color depth in bpp")
- EXPLAIN_OPTION("--disable-mouse", "-m", "Disable support for pointing device")
- EXPLAIN_OPTION("--midiout drv\t", "-Odrv", "use the 'drv' midiout driver")
- EXPLAIN_OPTION("--mididevice drv", "-Mdrv", "use the 'drv' midi device (eg mt32 or adlib)")
- EXPLAIN_OPTION("--pcmout drv\t", "-Pdrv", "use the 'drv' pcmout driver")
- EXPLAIN_OPTION("--sound-server srv", "-Ssrv", "Specifies the asynchronous sound server to use")
- EXPLAIN_OPTION("--no-sound\t", "-q", "disable sound output")
- EXPLAIN_OPTION("--list-savegames", "-l", "Lists all savegame IDs")
- EXPLAIN_OPTION("--show-rooms\t", "-s","Displays room numbers on the game console")
- "\n"
- "The game name, if provided, must be equal to a game name as specified in the\n"
- "FreeSCI config file.\n"
- "It is overridden by --gamedir.\n"
- "\n"
- );
- exit(0);
-
- case 'l':
- sciv_action = ACTION_LIST_SAVEGAMES;
- break;
-
- default:
- exit(1);
- }
- }
-#if 0
- } /* Work around EMACS paren matching bug */
-#endif
-
- if (optind+1 >= argc)
- *savegame_name = NULL;
- else
- *savegame_name = argv[optind + 1];
-
- if (optind == argc)
- return NULL;
-
- return
- argv[optind];
-}
-
-static int
-find_config(char *game_name, config_entry_t *conf, int conf_entries,
- sci_version_t *version)
-{
- int i, conf_nr = 0;
-
- for (i = 1; i < conf_entries; i++)
- if (!strcasecmp(conf[i].name, game_name)) {
- conf_nr = i;
- if (version)
- *version = conf[i].version;
- }
-
- return conf_nr;
-}
-
-static void
-init_console()
-{
-#ifdef WANT_CONSOLE
- con_gfx_init();
-#endif
- con_hook_command(&c_quit, "quit", "", "console: Quits gracefully");
- con_hook_command(&c_die, "die", "", "console: Quits ungracefully");
-
- con_hook_int(&(gfx_options->buffer_pics_nr), "buffer_pics_nr",
- "Number of pics to buffer in LRU storage\n");
- con_hook_int(&(gfx_options->pic0_dither_mode), "pic0_dither_mode",
- "Mode to use for pic0 dithering\n");
- con_hook_int(&(gfx_options->pic0_dither_pattern), "pic0_dither_pattern",
- "Pattern to use for pic0 dithering\n");
- con_hook_int(&(gfx_options->pic0_unscaled), "pic0_unscaled",
- "Whether pic0 should be drawn unscaled\n");
- con_hook_int(&(gfx_options->dirty_frames), "dirty_frames",
- "Dirty frames management\n");
- con_hook_int(&gfx_crossblit_alpha_threshold, "alpha_threshold",
- "Alpha threshold for crossblitting\n");
- con_hook_int(&sci0_palette, "sci0_palette",
- "SCI0 palette- 0: EGA, 1:AGI/Amiga, 2:Grayscale\n");
- con_hook_int(&sci01_priority_table_flags, "sci01_priority_table_flags",
- "SCI01 priority table debugging flags: 1:Disable, 2:Print on change\n");
-
- con_passthrough = 1; /* enables all sciprintf data to be sent to stdout */
-
-#ifdef HAVE_READLINE_HISTORY_H
- using_history(); /* Activate history for readline */
-#endif /* HAVE_READLINE_HISTORY_H */
-
-#ifdef HAVE_READLINE_READLINE_H
- _debug_get_input = get_readline_input; /* Use readline for debugging input */
-#else /* !HAVE_READLINE_READLINE_H */
- _debug_get_input = get_gets_input; /* Use gets for debug input */
-#endif /* !HAVE_READLINE_READLINE_H */
-}
-
-
-static int
-init_gamestate(state_t *gamestate, resource_mgr_t *resmgr, sci_version_t version)
-{
- int errc;
- gamestate->resmgr = resmgr;
-
- if ((errc = script_init_engine(gamestate, version))) { /* Initialize game state */
- int recovered = 0;
-
- if (errc == SCI_ERROR_INVALID_SCRIPT_VERSION) {
- int tversion = SCI_VERSION_FTU_NEW_SCRIPT_HEADER - ((version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER)? 0 : 1);
-
- while (!recovered && tversion) {
- printf("Trying version %d.%03x.%03d instead\n", SCI_VERSION_MAJOR(tversion),
- SCI_VERSION_MINOR(tversion), SCI_VERSION_PATCHLEVEL(tversion));
-
- errc = script_init_engine(gamestate, tversion);
-
- if ((recovered = !errc))
- version = tversion;
-
- if (errc != SCI_ERROR_INVALID_SCRIPT_VERSION)
- break;
-
- switch (tversion) {
-
- case SCI_VERSION_FTU_NEW_SCRIPT_HEADER - 1:
- if (version >= SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
- tversion = 0;
- else
- tversion = SCI_VERSION_FTU_NEW_SCRIPT_HEADER;
- break;
-
- case SCI_VERSION_FTU_NEW_SCRIPT_HEADER:
- tversion = 0;
- break;
- }
- }
- if (recovered)
- printf("Success.\n");
- }
-
- if (!recovered) {
- fprintf(stderr,"Script initialization failed. Aborting...\n");
- return 1;
- }
- }
- return 0;
-}
-
-static int
-init_gfx(config_entry_t *conf, cl_options_t *cl_options, gfx_driver_t *driver, resource_mgr_t *resmgr)
-{
- int scale_x = 0, scale_y = 0, color_depth = 0;
-
- if (conf) {
- if (conf->scale)
- scale_x = scale_y = conf->scale;
-
- if (conf->x_scale)
- scale_x = conf->x_scale;
-
- if (conf->y_scale)
- scale_y = conf->y_scale;
-
- if (conf->color_depth)
- color_depth = conf->color_depth >> 3; /* In there it's bpp */
- }
-
- gfx_state->driver = driver;
- gamestate->gfx_state = gfx_state;
- gfx_state->version = resmgr->sci_version;
-
- if (cl_options->scale_x > 0) {
- scale_x = cl_options->scale_x;
-
- if (!scale_y)
- scale_y = cl_options->scale_x;
- }
-
- if (cl_options->scale_y > 0) {
- scale_y = cl_options->scale_y;
-
- if (!scale_x)
- scale_x = cl_options->scale_y;
- }
-
- if (cl_options->color_depth > 0)
- color_depth = cl_options->color_depth;
-
- if (cl_options->color_depth > 0 && scale_x == 0)
- scale_x = scale_y = 2; /* Some default setting */
-
- if (scale_x > 0) {
-
- if (color_depth > 0) {
- if (gfxop_init(gfx_state, scale_x,
- scale_y, (gfx_color_mode_t) color_depth,
- gfx_options, resmgr)) {
- fprintf(stderr,"Graphics initialization failed. Aborting...\n");
- return 1;
- }
- } else {
- color_depth = 4;
- while (gfxop_init(gfx_state, scale_x,
- scale_y, (gfx_color_mode_t) color_depth,
- gfx_options, resmgr) && --color_depth);
-
- if (!color_depth) {
- fprintf(stderr,"Could not find a matching color depth. Aborting...\n");
- return 1;
- }
- }
-
- } else if (gfxop_init_default(gfx_state, gfx_options, resmgr)) {
- fprintf(stderr,"Graphics initialization failed. Aborting...\n");
- return 1;
- }
-
- return 0;
-}
-
-
-typedef void *old_lookup_funct_t(char *name);
-
-typedef void *lookup_funct_t(const char *path, const char *name);
-
-
-static void *
-lookup_driver(lookup_funct_t lookup_func, void explain_func(void),
- const char *driver_class, const char *driver_name, const char *path)
-{
- void *retval = lookup_func(path, driver_name);
-
- if (!retval) {
- if (!driver_name)
- sciprintf("The default %s is not available; please choose"
- " one explicitly.\n", driver_class);
- else
- sciprintf("The %s you requested, '%s', is not available.\n"
-/* "Please choose one among the following: " */
- ,
- driver_class, driver_name);
-/* explain_func(); */
- exit(1);
- }
-
- return retval;
-}
-
-
-/*static void *
-old_lookup_driver(old_lookup_funct_t lookup_func, void explain_func(void),
- char *driver_class, char *driver_name)
-{
- void *retval = lookup_func(driver_name);
-
- if (!retval) {
- sciprintf("The %s you requested, '%s', is not available.\n"
- "Please choose one among the following: ",
- driver_class, driver_name);
- explain_func();
- exit(1);
- }
-
- return retval;
-}*/
-
-#define NAMEBUF_LEN 30
-static void
-list_savegames(state_t *s)
-{
- sci_dir_t dir;
- char *filename = NULL;
-
- sci_init_dir(&dir);
-
- filename = sci_find_first(&dir, "*");
-
- sciprintf("\nSavegame listing:\n"
- "-----------------\n");
- while (filename) {
- char namebuf[NAMEBUF_LEN + 1];
- if (test_savegame(s, filename, namebuf, NAMEBUF_LEN)) {
- if (namebuf[0])
- sciprintf("%s:\t\"%s\"\n", filename, namebuf);
- else
- sciprintf("%s\n", filename);
- }
- filename = sci_find_next(&dir);
- }
- sciprintf("-----------------\n");
-}
-
-void
-get_file_directory(char* directory, const char* file)
-{
- char* end;
-
- strcpy(directory, file);
-
- end = directory + strlen(directory) - 1;
- while ((end >= directory) && (end != 0))
- {
- if (*end == G_DIR_SEPARATOR)
- {
- *end = 0;
- break;
- }
- else
- {
- end--;
- }
- }
-}
-
-static void
-detect_versions(sci_version_t *version, int *res_version, cl_options_t *options, config_entry_t *conf)
-{
- sci_version_t exe_version;
- sci_version_t hash_version;
- int hash_res_version;
- guint32 code;
- int got_exe_version;
- const char *game_name;
-
- sciprintf("Detecting interpreter and resource versions...\n");
-
- got_exe_version = !version_detect_from_executable(&exe_version);
-
- if (got_exe_version) {
- sciprintf("Interpreter version: %d.%03d.%03d (by executable scan)\n",
- SCI_VERSION_MAJOR(exe_version),
- SCI_VERSION_MINOR(exe_version),
- SCI_VERSION_PATCHLEVEL(exe_version));
-
- if (SCI_VERSION_MAJOR(exe_version) >= 1) {
- sciprintf("FIXME: Implement version mapping (results of executable scan ignored)\n");
- got_exe_version = 0;
- }
-
- }
-
- game_name = version_guess_from_hashcode(&hash_version, &hash_res_version, &code);
-
- if (game_name) {
- sciprintf("Interpreter version: %d.%03d.%03d (by hash code %08X)\n",
- SCI_VERSION_MAJOR(hash_version),
- SCI_VERSION_MINOR(hash_version),
- SCI_VERSION_PATCHLEVEL(hash_version), code);
- if (got_exe_version && exe_version != hash_version)
- sciprintf("UNEXPECTED INCONSISTENCY: Hash code %08X indicates interpreter version\n"
- " %d.%03d.%03d, but analysis of the executable yields %d.%03d.%03d (for game\n"
- " '%s'). Please report this!\n",
- code,
- SCI_VERSION_MAJOR(hash_version),
- SCI_VERSION_MINOR(hash_version),
- SCI_VERSION_PATCHLEVEL(hash_version),
- SCI_VERSION_MAJOR(exe_version),
- SCI_VERSION_MINOR(exe_version),
- SCI_VERSION_PATCHLEVEL(exe_version), game_name);
-
- if (hash_res_version != SCI_VERSION_AUTODETECT)
- sciprintf("Resource version: %d (by hash code)\n", hash_res_version);
-
- sciprintf("Game identified as '%s'\n", game_name);
- } else {
- sciprintf("Could not identify game by hash code: %08X\n", code);
-
- if (got_exe_version)
- sciprintf("Please report the preceding two lines and the name of the game you were trying\n"
- "to run to the FreeSCI development team to help other users!\n",
- code);
- }
-
- if (options->version)
- *version = options->version;
- else if (conf && conf->version)
- *version = conf->version;
- else if (game_name)
- *version = hash_version;
- else if (got_exe_version)
- *version = exe_version;
- else
- *version = 0;
-
- if (options->res_version != SCI_VERSION_AUTODETECT)
- *res_version = options->res_version;
- else if (conf && conf->res_version != SCI_VERSION_AUTODETECT)
- *res_version = conf->res_version;
- else if (game_name)
- *res_version = hash_res_version;
- else
- *res_version = SCI_VERSION_AUTODETECT;
-
- if (*version)
- sciprintf("Using interpreter version %d.%03d.%03d\n",
- SCI_VERSION_MAJOR(*version),
- SCI_VERSION_MINOR(*version),
- SCI_VERSION_PATCHLEVEL(*version));
-
- if (*res_version != SCI_VERSION_AUTODETECT)
- sciprintf("Using resource version %d\n", *res_version);
-}
-
-int
-main(int argc, char** argv)
-{
- config_entry_t *active_conf = NULL; /* Active configuration used */
- config_entry_t *confs = {0}; /* Configuration read from config file (if it exists) */
- cl_options_t cl_options; /* Command line options */
- int conf_entries = -1; /* Number of config entries */
- int conf_nr = -1; /* Element of conf to use */
-/* FILE *console_logfile = NULL; */
- char freesci_dir[PATH_MAX+1] = "";
- char startdir[PATH_MAX+1] = "";
- char resource_dir[PATH_MAX+1] = "";
- char work_dir[PATH_MAX+1] = "";
- char *cwd;
- char *gfx_driver_name = NULL;
-/* char *midiout_driver_name = NULL;
- char *midi_device_name = NULL;
- char *pcm_driver_name = NULL; */
- char *game_name = NULL;
- char *savegame_name = NULL;
- sci_version_t version;
- int res_version;
- gfx_driver_t *gfx_driver = NULL;
-#if 0
- sound_server_t *sound_server = NULL;
-#endif
- const char *module_path = SCI_DEFAULT_MODULE_PATH;
- resource_mgr_t *resmgr;
-#ifdef _DREAMCAST
- /* Fake command line arguments. */
- char *args[] = {"/cd/freesci.bin", "-f/ram/config", NULL};
- argv = args;
- argc = 2;
- chdir("/ram");
-#endif
-
- init_console(); /* So we can get any output */
-
- game_name = parse_arguments(argc, argv, &cl_options, &savegame_name);
-
- /* remember where freesci executable is located */
@@ 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