Ticket #8398: cga.v1.patch

File cga.v1.patch, 13.7 KB (added by sev-, 20 years ago)

CGA v1 patch

  • base/gameDetector.cpp

     Index: base/gameDetector.cpp
    RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
    retrieving revision 1.99
    diff -u -r1.99 gameDetector.cpp
     
    9696        "  --native-mt32            True Roland MT-32 (disable GM emulation)\n"
    9797        "  --output-rate=RATE       Select output sample rate in Hz (e.g. 22050)\n"
    9898        "  --aspect-ratio           Enable aspect ratio correction\n"
     99        "  --render-mode=MODE       Enable additional render modes (cga, ega, herc)\n"
    99100        "\n"
    100101#if !defined(DISABLE_SKY) || !defined(DISABLE_QUEEN)
    101102        "  --alt-intro              Use alternative intro for CD versions of Beneath a\n"
     
    122123        ConfMan.registerDefault("fullscreen", false);
    123124        ConfMan.registerDefault("aspect_ratio", false);
    124125        ConfMan.registerDefault("gfx_mode", "normal");
     126        ConfMan.registerDefault("render_mode", "default");
    125127
    126128        // Sound & Music
    127129        ConfMan.registerDefault("music_volume", 192);
     
    478480                                ConfMan.set("aspect_ratio", cmdValue, kTransientDomain);
    479481                        END_OPTION
    480482
     483                        DO_LONG_OPTION("render-mode")
     484                                int renderMode = Common::parseRenderMode(option);
     485                                if (renderMode == Common::kRenderDefault)
     486                                        goto ShowHelpAndExit;
     487
     488                                ConfMan.set("render_mode", option, kTransientDomain);
     489                        END_OPTION
     490
    481491                        DO_LONG_OPTION("savepath")
    482492                                // TODO: Verify whether the path is valid
    483493                                ConfMan.set("savepath", option, kTransientDomain);
  • common/util.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/util.cpp,v
    retrieving revision 1.47
    diff -u -r1.47 util.cpp
     
    219219}
    220220
    221221
     222#pragma mark -
     223
     224
     225const RenderModeDescription g_renderModes[] = {
     226        {"herc", "Hercules", kRenderHerc},
     227        {"cga", "CGA", kRenderCGA},
     228        {"ega", "EGA", kRenderEGA},
     229        {0, 0, kRenderDefault}
     230};
     231
     232RenderMode parseRenderMode(const String &str) {
     233        if (str.isEmpty())
     234                return kRenderDefault;
     235
     236        const char *s = str.c_str();
     237        const RenderModeDescription *l = g_renderModes;
     238        for (; l->code; ++l) {
     239                if (!scumm_stricmp(l->code, s))
     240                        return l->id;
     241        }
     242
     243        return kRenderDefault;
     244}
     245
     246const char *getRenderModeCode(RenderMode id) {
     247        const RenderModeDescription *l = g_renderModes;
     248        for (; l->code; ++l) {
     249                if (l->id == id)
     250                        return l->code;
     251        }
     252        return 0;
     253}
     254
     255const char *getRenderModeDescription(RenderMode id) {
     256        const RenderModeDescription *l = g_renderModes;
     257        for (; l->code; ++l) {
     258                if (l->id == id)
     259                        return l->description;
     260        }
     261        return 0;
     262}
     263
    222264
    223265}       // End of namespace Common
  • common/util.h

    RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
    retrieving revision 1.46
    diff -u -r1.46 util.h
     
    147147
    148148extern const PlatformDescription g_platforms[];
    149149
    150 
    151150/** Convert a string containing a platform name into a Platform enum value. */
    152151extern Platform parsePlatform(const String &str);
    153152extern const char *getPlatformCode(Platform id);
    154153extern const char *getPlatformDescription(Platform id);
    155154
     155/**
     156 * List of render modes. It specifies which original graphics mode
     157 * to use. Some targets used postprocessing dithering routines for
     158 * reducing color depth of final image which let it to be rendered on
     159 * such low-level adapters as CGA or Hercules.
     160 */
     161enum RenderMode {
     162        kRenderDefault = -1,
     163        kRenderEGA = 0,
     164        kRenderCGA = 1,
     165        kRenderHerc = 2
     166};
     167
     168struct RenderModeDescription {
     169        const char *code;
     170        const char *description;
     171        Common::RenderMode id;
     172};
     173
     174extern const RenderModeDescription g_renderModes[];
     175
     176/** Convert a string containing a render mode name into a RenderingMode enum value. */
     177extern RenderMode parseRenderMode(const String &str);
     178extern const char *getRenderModeCode(RenderMode id);
     179extern const char *getRenderModeDescription(RenderMode id);
     180
    156181}       // End of namespace Common
    157182
    158183
  • gui/options.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
    retrieving revision 1.68
    diff -u -r1.68 options.cpp
     
    7575        : Dialog(x, y, w, h),
    7676        _domain(domain),
    7777        _enableGraphicSettings(false),
    78         _gfxPopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),
     78        _gfxPopUp(0), _renderModePopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),
    7979        _enableAudioSettings(false),
    8080        _multiMidiCheckbox(0), _mt32Checkbox(0), _subCheckbox(0),
    8181        _enableVolumeSettings(false),
     
    108108                        }
    109109                }
    110110
     111                _renderModePopUp->setSelected(0);
     112
     113                if (ConfMan.hasKey("render_mode", _domain)) {
     114                        const Common::RenderModeDescription *p = Common::g_renderModes;
     115                        const Common::RenderMode renderMode = Common::parseRenderMode(ConfMan.get("render_mode", _domain));
     116                        int sel = 0;
     117                        for (int i = 0; p->code; ++p, ++i) {
     118                                if (renderMode == p->id)
     119                                        sel = i + 2;
     120                        }
     121                        _renderModePopUp->setSelected(sel);
     122                }
     123
    111124#ifndef _WIN32_WCE
    112125                // Fullscreen setting
    113126                _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
     
    167180
    168181                                if ((int32)_gfxPopUp->getSelectedTag() >= 0)
    169182                                        ConfMan.set("gfx_mode", _gfxPopUp->getSelectedString(), _domain);
     183
     184                                if ((int32)_renderModePopUp->getSelectedTag() >= 0)
     185                                        ConfMan.set("render_mode", _renderModePopUp->getSelectedString(), _domain);
    170186                        } else {
    171187                                ConfMan.removeKey("fullscreen", _domain);
    172188                                ConfMan.removeKey("aspect_ratio", _domain);
    173189                                ConfMan.removeKey("gfx_mode", _domain);
     190                                ConfMan.removeKey("render_mode", _domain);
    174191                        }
    175192                }
    176193
     
    240257        _enableGraphicSettings = enabled;
    241258
    242259        _gfxPopUp->setEnabled(enabled);
     260        _renderModePopUp->setEnabled(enabled);
    243261#ifndef _WIN32_WCE
    244262        _fullscreenCheckbox->setEnabled(enabled);
    245263        _aspectCheckbox->setEnabled(enabled);
     
    282300                gm++;
    283301        }
    284302
     303        // RenderMode popup
     304        _renderModePopUp = new PopUpWidget(boss, x-5, yoffset, w+5, kLineHeight, "Render mode: ", 100);
     305        yoffset += 16;
     306        _renderModePopUp->appendEntry("<default>");
     307        _renderModePopUp->appendEntry("");
     308        const Common::RenderModeDescription *rm = Common::g_renderModes;
     309        for (; rm->code; ++rm) {
     310                _renderModePopUp->appendEntry(rm->description, rm->id);
     311        }
     312
    285313        // Fullscreen checkbox
    286314        _fullscreenCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Fullscreen mode");
    287315        yoffset += 16;
  • gui/options.h

    RCS file: /cvsroot/scummvm/scummvm/gui/options.h,v
    retrieving revision 1.24
    diff -u -r1.24 options.h
     
    7171        PopUpWidget *_gfxPopUp;
    7272        CheckboxWidget *_fullscreenCheckbox;
    7373        CheckboxWidget *_aspectCheckbox;
     74        PopUpWidget *_renderModePopUp;
    7475
    7576        //
    7677        // Audio controls
  • scumm/actor.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
    retrieving revision 1.319
    diff -u -r1.319 actor.cpp
     
    14001400        } else if (_vm->_features & GF_OLD_BUNDLE) {
    14011401                for (i = 0; i < 16; i++)
    14021402                        palette[i] = i;
     1403
     1404                // Make stuff more visible on CGA. Based on disassembly
     1405                if (_vm->_features & GF_16COLOR && _vm->_renderMode == Common::kRenderCGA) {
     1406                        palette[6] = 5;
     1407                        palette[7] = 15;
     1408                }
    14031409        } else {
    14041410                for (i = 0; i < 32; i++)
    14051411                        palette[i] = 0xFF;
  • scumm/charset.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
    retrieving revision 2.124
    diff -u -r2.124 charset.cpp
     
    12691269        if (chr == '@')
    12701270                return;
    12711271
     1272        // Based on disassembly
    12721273        _vm->_charsetColorMap[1] = _color;
     1274        if (_vm->_features & GF_16COLOR && _vm->_renderMode == Common::kRenderCGA) {
     1275                static byte CGAtextColorMap[16] = {0,  3, 3, 3, 5, 5, 5,  15,
     1276                                                                                   15, 3, 3, 3, 5, 5, 15, 15};
     1277                _color = CGAtextColorMap[_color & 0x0f];
     1278                is2byte = 0;
     1279        }
     1280
     1281        if (_vm->_features & GF_16COLOR && _vm->_renderMode == Common::kRenderHerc) {
     1282                static byte HercTextColorMap[16] = {0, 15,  2, 15, 15,  5, 15,  15,
     1283                                                                                   8, 15, 15, 15, 15, 15, 15, 15};
     1284                _color = HercTextColorMap[_color & 0x0f];
     1285                is2byte = 0;
     1286        }
     1287
    12731288
    12741289        int type = *_fontPtr;
    12751290        if (is2byte) {
  • scumm/gfx.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
    retrieving revision 2.387
    diff -u -r2.387 gfx.cpp
     
    508508                dst += _vm->_screenWidth;
    509509                text += _textSurface.pitch;
    510510        }
    511        
     511
     512        if (_vm->_features & GF_16COLOR && _vm->_renderMode == Common::kRenderCGA)
     513                ditherCGA(_compositeBuf + x + y * _vm->_screenWidth, _vm->_screenWidth, x, y, width, height);
     514
    512515        // Finally blit the whole thing to the screen
    513516        _vm->_system->copyRectToScreen(_compositeBuf + x + y * _vm->_screenWidth, _vm->_screenWidth, x, y, width, height);
    514517}
    515518
     519// CGA
     520// indy3 loom maniac monkey1 zak
     521//
     522// Herc
     523// maniac monkey1 zak
     524//
     525// EGA
     526// monkey2 loom maniac monkey1 atlantis indy3 zak loomcd
     527
     528// CGA dithers 4x4 square with direct substitutes
     529// Odd lines have colors swapped, so there will be checkered patterns.
     530// But apparently there is a mistake for 10th color.
     531void Gdi::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const {
     532        byte *ptr;
     533        int idx1, idx2;
     534        static byte cgaDither[2][2][16] = {
     535                {{0, 1, 0, 1, 2, 2, 0, 0, 3, 1, 3, 1, 3, 2, 1, 3},
     536                 {0, 0, 1, 1, 0, 2, 2, 3, 0, 3, 1, 1, 3, 3, 1, 3}},
     537                {{0, 0, 1, 1, 0, 2, 2, 3, 0, 3, 1, 1, 3, 3, 1, 3},
     538                 {0, 1, 0, 1, 2, 2, 0, 0, 3, 1, 1, 1, 3, 2, 1, 3}}};
     539
     540        for (int y1 = 0; y1 <  height; y1++) {
     541                ptr = dst + y1 * dstPitch;
     542
     543                idx1 = (y + y1) % 2;
     544                for (int x1 = 0; x1 < width; x1++) {
     545                        idx2 = (x + x1) % 2;
     546                        *ptr++ = cgaDither[idx1][idx2][*ptr & 0xF];
     547                }
     548        }
     549}
     550
     551
    516552#pragma mark -
    517553#pragma mark --- Background buffers & charset mask ---
    518554#pragma mark -
  • scumm/gfx.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
    retrieving revision 1.99
    diff -u -r1.99 gfx.h
     
    256256        /* Misc */
    257257        void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
    258258        void updateDirtyScreen(VirtScreen *vs);
    259        
     259        void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const;
     260
    260261        byte *getMaskBuffer(int x, int y, int z);
    261262       
    262263        int getZPlanes(const byte *smap_ptr, const byte *zplane_list[9], bool bmapImage) const;
  • scumm/palette.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/palette.cpp,v
    retrieving revision 2.22
    diff -u -r2.22 palette.cpp
     
    4848        setPalColor(15, 255, 255, 255);
    4949}
    5050
     51void ScummEngine::setupCGAPalette() {
     52        setPalColor( 0,   0,   0,   0);
     53        setPalColor( 1,   0, 168, 168);
     54        setPalColor( 2, 168,   0, 168);
     55        setPalColor( 3, 168, 168, 168);
     56
     57        // Setup cursor palette
     58        setPalColor( 7, 170, 170, 170);
     59        setPalColor( 8,  85,  85,  85);
     60        setPalColor(15, 255, 255, 255);
     61}
     62
    5163void ScummEngine::setupEGAPalette() {
    5264        setPalColor( 0,   0,   0,   0);
    5365        setPalColor( 1,   0,   0, 170);
  • scumm/scumm.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
    retrieving revision 1.322
    diff -u -r1.322 scumm.cpp
     
    981981        }
    982982        _confirmExit = ConfMan.getBool("confirm_exit");
    983983
     984        if (ConfMan.hasKey("render_mode")) {
     985                _renderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str());
     986        }
     987
    984988        _hexdumpScripts = false;
    985989        _showStack = false;
    986990
     
    12521256                        _shadowPalette[i] = i;
    12531257                if ((_features & GF_AMIGA) || (_features & GF_ATARI_ST))
    12541258                        setupAmigaPalette();
     1259                else if (_renderMode == Common::kRenderCGA)
     1260                        setupCGAPalette();
    12551261                else
    12561262                        setupEGAPalette();
    12571263        }
  • scumm/scumm.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
    retrieving revision 1.531
    diff -u -r1.531 scumm.h
     
    870870        int _screenStartStrip, _screenEndStrip;
    871871        int _screenTop;
    872872
     873        Common::RenderMode _renderMode;
     874
    873875protected:
    874876        ColorCycle _colorCycle[16];     // Palette cycles
    875877
     
    932934
    933935        const byte *getPalettePtr(int palindex, int room);
    934936        void setupAmigaPalette();
     937        void setupCGAPalette();
    935938        void setupEGAPalette();
    936939        void setupV1ManiacPalette();
    937940        void setupV1ZakPalette();
  • scumm/vars.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/vars.cpp,v
    retrieving revision 1.113
    diff -u -r1.113 vars.cpp
     
    553553                        VAR(VAR_VIDEOMODE) = 50;
    554554                else if (_gameId == GID_MONKEY2 && (_features & GF_AMIGA))
    555555                        VAR(VAR_VIDEOMODE) = 82;
     556                else if (_features & GF_16COLOR && _renderMode == Common::kRenderCGA)
     557                        VAR(VAR_VIDEOMODE) = 4;
    556558                else
    557559                        VAR(VAR_VIDEOMODE) = 19;
    558560                if (_gameId == GID_LOOM && _features & GF_OLD_BUNDLE) {