diff options
author | James Brown | 2002-03-14 13:57:28 +0000 |
---|---|---|
committer | James Brown | 2002-03-14 13:57:28 +0000 |
commit | fa9cc1d34118490dacc60e45e91ae614459f5136 (patch) | |
tree | 54ab1ce2bbfd02566f40d19ca881e0978d37dc06 | |
parent | a5d424aa18f933a003ecbae5bddf9428a559de15 (diff) | |
download | scummvm-rg350-fa9cc1d34118490dacc60e45e91ae614459f5136.tar.gz scummvm-rg350-fa9cc1d34118490dacc60e45e91ae614459f5136.tar.bz2 scummvm-rg350-fa9cc1d34118490dacc60e45e91ae614459f5136.zip |
Make some code-execution changes to allow early initilisation of GUI.
svn-id: r3748
-rw-r--r-- | gfx.cpp | 2 | ||||
-rw-r--r-- | gui.cpp | 57 | ||||
-rw-r--r-- | gui.h | 29 | ||||
-rw-r--r-- | resource.cpp | 8 | ||||
-rw-r--r-- | scummvm.cpp | 15 | ||||
-rw-r--r-- | sdl.cpp | 30 |
6 files changed, 120 insertions, 21 deletions
@@ -80,9 +80,9 @@ void Scumm::initVirtScreen(int slot, int top, int height, bool twobufs, bool fou vs->xstart = 0; size = vs->width * vs->height; vs->size = size; + if (vs->scrollable) size += 320*4; - createResource(rtBuffer, slot+1, size); if (twobufs) { @@ -27,6 +27,7 @@ enum { PAUSE_DIALOG }; + void Gui::draw(int start,int end) { int i; @@ -73,6 +74,24 @@ const GuiWidget *Gui::widgetFromPos(int x, int y) { return NULL; } +void Gui::drawChar(const char str, int xx, int yy) { + unsigned int buffer, mask = 0, x, y; + byte *tmp; + + tmp = &guifont[0]; + tmp += 224 + (str + 1)*8; + + for(y=0;y<8;y++){ + for(x=0;x<8;x++){ + unsigned char color; + if ((mask >>= 1) == 0) {buffer = *tmp++; mask = 0x80;} + color = ((buffer & mask) != 0); + if (color) + hline(xx + x, yy + y, yy + y + 1); + } + } + +} void Gui::drawString(const char *str, int x, int y, int w, byte color, bool center) { StringTab *st = &_s->string[5]; st->charset = 1; @@ -81,8 +100,14 @@ void Gui::drawString(const char *str, int x, int y, int w, byte color, bool cent st->xpos = x; st->ypos = y; st->right = x + w; - _s->_messagePtr = (byte*)str; - _s->drawString(5); + + if (_s->_gameId) { /* If a game is active.. */ + _s->_messagePtr = (byte*)str; + _s->drawString(5); + } else { + for (uint letter = 0; letter < strlen(str); letter++) + drawChar(str[letter], st->xpos + (letter * 8), st->ypos); + } } void Gui::drawWidget(const GuiWidget *w) { @@ -181,8 +206,10 @@ byte *Gui::getBasePtr(int x, int y) { x += _parentX; y += _parentY; _vs = _s->findVirtScreen(y); + if (_vs==NULL) return NULL; + return _s->getResourceAddress(rtBuffer, _vs->number+1) + x + (y-_vs->topline)*320 + _s->_screenStartStrip*8; } @@ -201,6 +228,7 @@ void Gui::lineto(int x, int y) { y2^=y^=y2^=y; ptr = getBasePtr(x, y); + if (ptr==NULL) return; @@ -355,7 +383,7 @@ const byte string_map_table_v6[] = { 117, /* How may I serve you? */ 109, /* Select a game to LOAD */ 108, /* Name your SAVE game */ - 96, /* Save */ + 96, /* Save */ 97, /* Load */ 98, /* Play */ 99, /* Cancel */ @@ -368,7 +396,7 @@ const byte string_map_table_v5[] = { 0, /* How may I serve you? */ 20, /* Select a game to LOAD */ 19, /* Name your SAVE game */ - 7, /* Save */ + 7, /* Save */ 8, /* Load */ 9, /* Play */ 10, /* Cancel */ @@ -379,6 +407,9 @@ const byte string_map_table_v5[] = { const char *Gui::queryString(int string, int id) { static char namebuf[64]; + if (!_s->_gameId) + return "blah!"; + if (id>=20 && id<=28) { sprintf(namebuf, "%2d. %s", id-20+_slotIndex, game_names[id-20]); return namebuf; @@ -470,11 +501,19 @@ byte Gui::getDefaultColor(int color) { void Gui::init(Scumm *s) { _s = s; - _bgcolor = getDefaultColor(0); - _color = getDefaultColor(1); - _textcolor = getDefaultColor(2); - _textcolorhi = getDefaultColor(6); - _shadowcolor = getDefaultColor(8); + if (_s->_gameId) { + _bgcolor = getDefaultColor(0); + _color = getDefaultColor(1); + _textcolor = getDefaultColor(2); + _textcolorhi = getDefaultColor(6); + _shadowcolor = getDefaultColor(8); + } else { + _bgcolor = 0; + _color = 2; + _textcolor = 6; + _textcolorhi = 3; + _shadowcolor = 2; + } } void Gui::loop() { @@ -62,6 +62,7 @@ struct Gui { void lineto(int x, int y); void hline(int x, int y, int x2); void vline(int x, int y, int y2); + void drawChar(const char str, int xx, int yy); void drawString(const char *str, int x, int y, int w, byte color, bool center); void widgetClear(const GuiWidget *w); void widgetBorder(const GuiWidget *w); @@ -81,4 +82,32 @@ struct Gui { void pause(); }; +// Built-in font +static byte guifont[] = {0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7, +7,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,8,5,8,8,7,7,7,6,7,7,7,7,7,5,6,7,5,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,3,5,0,8,7,7,7,7,7,7,0,6,7,7,7,5,5,5,7,0,6,8,8,7,7,7,7,7,0,7,7,0,0, +0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,1,3,6,12, +24,62,3,0,128,192,96,48,24,124,192,0,0,3,62,24,12,6,3,1,0,192,124,24,48,96,192,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,74,72,0,0,0,0,0,128,128,128,0,0,0,0,0,0,0,0,0,0,0,0,0,60,66,153,161,161,153,66,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,96,96,96,96,0,0,96,0,102,102,102,0,0,0,0,0,102,102,255,102,255,102,102,0,24,62,96,60,6,124,24,0,98,102,12,24,48,102,70,0,60,102,60,56,103,102,63,0,96,48,16,0,0,0,0,0,24,48,96,96,96,48,24,0,96,48,24,24,24,48,96,0, +0,102,60,255,60,102,0,0,0,24,24,126,24,24,0,0,0,0,0,0,0,48,48,96,0,0,0,126,0,0,0,0,0,0,0,0,0,96,96,0,0,3,6,12,24,48,96,0,60,102,102,102,102,102,60,0,24,24,56,24,24,24,126,0,60,102,6,12,48,96,126,0,60,102,6,28,6,102,60,0,6, +14,30,102,127,6,6,0,126,96,124,6,6,102,60,0,60,102,96,124,102,102,60,0,126,102,12,24,24,24,24,0,60,102,102,60,102,102,60,0,60,102,102,62,6,102,60,0,0,0,96,0,0,96,0,0,0,0,48,0,0,48,48,96,14,24,48,96,48,24,14,0,0,0,120,0,120,0,0,0,112,24, +12,6,12,24,112,0,60,102,6,12,24,0,24,0,0,0,0,255,255,0,0,0,24,60,102,126,102,102,102,0,124,102,102,124,102,102,124,0,60,102,96,96,96,102,60,0,120,108,102,102,102,108,120,0,126,96,96,120,96,96,126,0,126,96,96,120,96,96,96,0,60,102,96,110,102,102,60,0,102,102,102, +126,102,102,102,0,120,48,48,48,48,48,120,0,30,12,12,12,12,108,56,0,102,108,120,112,120,108,102,0,96,96,96,96,96,96,126,0,99,119,127,107,99,99,99,0,102,118,126,126,110,102,102,0,60,102,102,102,102,102,60,0,124,102,102,124,96,96,96,0,60,102,102,102,102,60,14,0,124,102,102,124, +120,108,102,0,60,102,96,60,6,102,60,0,126,24,24,24,24,24,24,0,102,102,102,102,102,102,60,0,102,102,102,102,102,60,24,0,99,99,99,107,127,119,99,0,102,102,60,24,60,102,102,0,102,102,102,60,24,24,24,0,126,6,12,24,48,96,126,0,120,96,96,96,96,96,120,0,3,6,12,24,48, +96,192,0,120,24,24,24,24,24,120,0,0,0,0,0,0,219,219,0,0,0,0,0,0,0,0,255,102,102,102,0,0,0,0,0,0,0,60,6,62,102,62,0,0,96,96,124,102,102,124,0,0,0,60,96,96,96,60,0,0,6,6,62,102,102,62,0,0,0,60,102,126,96,60,0,0,14,24,62,24,24, +24,0,0,0,62,102,102,62,6,124,0,96,96,124,102,102,102,0,0,48,0,112,48,48,120,0,0,12,0,12,12,12,12,120,0,96,96,108,120,108,102,0,0,112,48,48,48,48,120,0,0,0,102,127,127,107,99,0,0,0,124,102,102,102,102,0,0,0,60,102,102,102,60,0,0,0,124,102,102,124,96, +96,0,0,62,102,102,62,6,6,0,0,124,102,96,96,96,0,0,0,62,96,60,6,124,0,0,24,126,24,24,24,14,0,0,0,102,102,102,102,62,0,0,0,102,102,102,60,24,0,0,0,99,107,127,62,54,0,0,0,102,60,24,60,102,0,0,0,102,102,102,62,12,120,0,0,126,12,24,48,126,0, +24,48,48,96,48,48,24,0,96,96,96,0,96,96,96,0,96,48,48,24,48,48,96,0,0,0,0,0,0,0,0,0,8,12,14,255,255,14,12,8,60,102,96,96,102,60,24,56,102,0,102,102,102,102,62,0,12,24,60,102,126,96,60,0,24,36,60,6,62,102,62,0,102,0,60,6,62,102,62,0,48, +24,60,6,62,102,62,0,0,0,0,0,0,0,0,0,0,60,96,96,96,60,24,56,24,36,60,102,126,96,60,0,102,0,60,102,126,96,60,0,48,24,60,102,126,96,60,0,0,216,0,112,48,48,120,0,48,72,0,112,48,48,120,0,96,48,0,112,48,48,120,0,102,24,60,102,126,102,102,0,0,0, +0,0,0,0,0,0,24,48,124,96,120,96,124,0,0,0,108,26,126,216,110,0,30,40,40,126,72,136,142,0,24,36,60,102,102,102,60,0,102,0,60,102,102,102,60,0,48,24,60,102,102,102,60,0,24,36,0,102,102,102,62,0,48,24,102,102,102,102,62,0,0,0,0,0,0,0,0,0,102,60,102, +102,102,102,60,0,102,0,102,102,102,102,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,24,60,6,62,102,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,28,54,54,124,102,102,124,64,0,0,0}; + #endif diff --git a/resource.cpp b/resource.cpp index 82e8ec9e44..a362dbbc03 100644 --- a/resource.cpp +++ b/resource.cpp @@ -790,7 +790,9 @@ void Scumm::nukeResource(int type, int idx) { debug(9, "nukeResource(%d,%d)", type, idx); CHECK_HEAP - assert( res.address[type] ); + if (!res.address[type]) + return; + assert( idx>=0 && idx < res.num[type]); if ((ptr = res.address[type][idx]) != NULL) { @@ -1185,6 +1187,9 @@ void Scumm::readMAXS() { } void Scumm::allocateArrays() { + // Note: Buffers are now allocated in scummMain to allow for + // early GUI init. + _objectOwnerTable = (byte*)alloc(_numGlobalObjects); _objectStateTable = (byte*)alloc(_numGlobalObjects); _classData = (uint32*)alloc(_numGlobalObjects * sizeof(uint32)); @@ -1210,7 +1215,6 @@ void Scumm::allocateArrays() { allocResTypeData(rtTemp,MKID('NONE'),10, "temp", 0); allocResTypeData(rtScaleTable,MKID('NONE'),5, "scale table", 0); allocResTypeData(rtActorName, MKID('NONE'),NUM_ACTORS,"actor name", 0); - allocResTypeData(rtBuffer, MKID('NONE'),10,"buffer", 0); allocResTypeData(rtVerb, MKID('NONE'),_numVerbs,"verb", 0); allocResTypeData(rtString, MKID('NONE'),_numArray,"array", 0); allocResTypeData(rtFlObject, MKID('NONE'),_numFlObject,"flobject", 0); diff --git a/scummvm.cpp b/scummvm.cpp index f530ef2e0c..a42e203c20 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -25,6 +25,7 @@ #include "string.h" #include "sound.h" +extern void launcherLoop(); void Scumm::initRandSeeds() { _randSeed1 = 0xA943DE35; _randSeed2 = 0x37A9ED27; @@ -209,9 +210,15 @@ void Scumm::scummMain(int argc, char **argv) { _midi_driver = MIDI_NULL; #endif parseCommandLine(argc, argv); + + /* Init graphics and create a primary virtual screen */ + initGraphics(this, _fullScreen, _scale); + allocResTypeData(rtBuffer, MKID('NONE'),10,"buffer", 0); + initVirtScreen(0, 0, 200, false, false); if (_exe_name==NULL) - error("Specify the name of the game to start on the command line"); + //error("Specify the name of the game to start on the command line"); + launcherLoop(); if (!detectGame()) { warning("Game detection failed. Using default settings"); @@ -247,9 +254,7 @@ void Scumm::scummMain(int argc, char **argv) { // if (_gameId==GID_MONKEY2 && _bootParam==0) { // _bootParam = 10001; -// } - - initGraphics(this, _fullScreen, _scale); +// } if (_features & GF_SMALL_HEADER) readIndexFileSmall(); @@ -439,7 +444,7 @@ void Scumm::parseCommandLine(int argc, char **argv) { if (argc < 2) { printf( USAGE_STRING ); - exit(1); + //exit(1); } /* Parse the arguments */ @@ -62,7 +62,7 @@ void updatePalette(Scumm *s) { int num = s->_palDirtyMax - first + 1; int i; byte *data = s->_currentPalette; - + data += first*3; for (i=0; i<num; i++,data+=3) { colors[i].r = data[0]; @@ -771,6 +771,29 @@ void initGraphics(Scumm *s, bool fullScreen, unsigned int scaleFactor) { #undef main #endif + +void launcherLoop() { + int last_time, new_time; + int delta = 0; + last_time = SDL_GetTicks(); + + gui.saveLoadDialog(); + do { + updateScreen(&scumm); + + new_time = SDL_GetTicks(); + waitForTimer(&scumm, delta * 15 + last_time - new_time); + last_time = SDL_GetTicks(); + + if (gui._active) { + gui.loop(); + delta = 5; + } else + error("gui closed!"); + } while(1); + +}; + int main(int argc, char* argv[]) { int delta; int last_time, new_time; @@ -810,11 +833,10 @@ int main(int argc, char* argv[]) { #endif scumm._gui = &gui; + gui.init(&scumm); sound.initialize(&scumm, &snd_driv); scumm.scummMain(argc, argv); - - if (!(scumm._features & GF_SMALL_HEADER)) - gui.init(&scumm); + gui.init(&scumm); /* Reinit GUI after loading a game */ last_time = SDL_GetTicks(); delta = 0; |