diff options
author | Max Horn | 2002-12-25 20:07:09 +0000 |
---|---|---|
committer | Max Horn | 2002-12-25 20:07:09 +0000 |
commit | 5c39a82633fd158fe40ae107160b07da699ef169 (patch) | |
tree | 007e43c86b2232447d132c4a1b994d8cee2da6ed | |
parent | 5f5e96e24f9864c185846a9257b61ea26dc51a34 (diff) | |
download | scummvm-rg350-5c39a82633fd158fe40ae107160b07da699ef169.tar.gz scummvm-rg350-5c39a82633fd158fe40ae107160b07da699ef169.tar.bz2 scummvm-rg350-5c39a82633fd158fe40ae107160b07da699ef169.zip |
two good rules of thumb: don't use typecasts if you don't have to - type cast have a nasty habit of hiding and causing problems. When a method takes a pointer argument, if possible make it const. :-). Cleanup. Fixed font rendering in CMI: you need to call updateDirtyRect() if you modify the screen...
svn-id: r6143
-rw-r--r-- | scumm/gfx.cpp | 6 | ||||
-rw-r--r-- | scumm/nut_renderer.cpp | 29 | ||||
-rw-r--r-- | scumm/nut_renderer.h | 10 | ||||
-rw-r--r-- | scumm/script.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 8 |
5 files changed, 31 insertions, 24 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index efedd8d1dd..075aee2760 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -331,7 +331,7 @@ void Scumm::drawDirtyScreenParts() _system->copy_rect(src, _realWidth, 0, vs->topline, _realWidth, vs->height - _screenTop); for (i = 0; i < gdi._numStrips; i++) { - vs->tdirty[i] = (byte)vs->height; + vs->tdirty[i] = vs->height; vs->bdirty[i] = 0; } } @@ -372,9 +372,9 @@ void Gdi::updateDirtyScreen(VirtScreen *vs) if (bottom) { top = vs->tdirty[i]; - vs->tdirty[i] = (byte)vs->height; + vs->tdirty[i] = vs->height; vs->bdirty[i] = 0; - if (i != (_numStrips - 1) && vs->bdirty[i + 1] == (byte)bottom && vs->tdirty[i + 1] == (byte)top) { + if (i != (_numStrips - 1) && vs->bdirty[i + 1] == bottom && vs->tdirty[i + 1] == top) { // Simple optimizations: if two or more neighbouring strips form one bigger rectangle, // blit them all at once. w += 8; diff --git a/scumm/nut_renderer.cpp b/scumm/nut_renderer.cpp index b1e0187ed6..0cb1c1f41f 100644 --- a/scumm/nut_renderer.cpp +++ b/scumm/nut_renderer.cpp @@ -1,5 +1,4 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or @@ -20,10 +19,11 @@ */ #include "stdafx.h" -#include "engine.h" +#include "scumm.h" #include "nut_renderer.h" -NutRenderer::NutRenderer() { +NutRenderer::NutRenderer(Scumm *vm) { + _vm = vm; _initialized = false; _loaded = false; _dataSrc = NULL; @@ -81,7 +81,7 @@ void NutRenderer::bindDisplay(byte *dst, int32 width, int32 height, int32 pitch) _initialized = true; } -bool NutRenderer::loadFont(char *filename, char *dir) { +bool NutRenderer::loadFont(const char *filename, const char *dir) { debug(2, "NutRenderer::loadFont() called"); if (_loaded == true) { debug(2, "NutRenderer::loadFont() Font already loaded, ok, loading..."); @@ -177,31 +177,37 @@ int32 NutRenderer::getStringWidth(char *string) { return length; } -void NutRenderer::drawString(char *string, int32 x, int32 y, byte color, int32 mode) { - debug(2, "NutRenderer::getDrawString() called"); +void NutRenderer::drawString(const char *string, int32 x, int32 y, byte color, int32 mode) { + debug(2, "NutRenderer::drawString() called"); if (_loaded == false) { - debug(2, "NutRenderer::getDrawString() Font is not loaded"); + debug(2, "NutRenderer::drawString() Font is not loaded"); return; } - int32 l = 0; + int l = 0; + int left = x; + int height = 0, tmp; do { if ((x < 0) || (y < 0) || (x > _dstWidth) || (y > _dstHeight)) { - debug(2, "NutRenderer::getDrawString() position x, y out of range"); + debug(2, "NutRenderer::drawString() position x, y out of range"); return; } drawChar(string[l], x, y, color); x += getCharWidth(string[l]); + tmp = getCharHeight(string[l]); + if (height < tmp) + height = tmp; l++; } while (string[l] != 0); + _vm->updateDirtyRect(0, left, x, y, y + height, 0); } void NutRenderer::drawChar(char c, int32 x, int32 y, byte color) { - debug(2, "NutRenderer::getDrawChar() called"); + debug(2, "NutRenderer::drawChar('%c', %d, %d, %d) called", c, x, y, (int)color); if (_loaded == false) { - debug(2, "NutRenderer::getDrawChar() Font is not loaded"); + debug(2, "NutRenderer::drawChar() Font is not loaded"); return; } @@ -231,6 +237,5 @@ void NutRenderer::drawChar(char c, int32 x, int32 y, byte color) { } } } - } diff --git a/scumm/nut_renderer.h b/scumm/nut_renderer.h index 57fd7e5b4c..3c349a6f8c 100644 --- a/scumm/nut_renderer.h +++ b/scumm/nut_renderer.h @@ -1,5 +1,4 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or @@ -24,8 +23,11 @@ #include "common/file.h" +class Scumm; + class NutRenderer { private: + Scumm *_vm; int32 _offsets[256]; byte _tmpCodecBuffer[2000]; byte *_dataSrc; @@ -37,13 +39,13 @@ private: void decodeCodec44(byte *dst, byte *src, uint32 length); public: - NutRenderer(); + NutRenderer(Scumm *vm); ~NutRenderer(); void bindDisplay(byte *dst, int32 width, int32 height, int32 pitch); - bool loadFont(char *filename, char *dir); + bool loadFont(const char *filename, const char *dir); void drawChar(char c, int32 x, int32 y, byte color); - void drawString(char *string, int32 x, int32 y, byte color, int32 mode); + void drawString(const char *string, int32 x, int32 y, byte color, int32 mode); int32 getCharWidth(char c); int32 getCharHeight(char c); int32 getStringWidth(char *string); diff --git a/scumm/script.cpp b/scumm/script.cpp index 5b4b4213eb..2613acc3b1 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -285,7 +285,7 @@ void Scumm::executeScript() _opcode = fetchScriptByte(); _scriptPointerStart = _scriptPointer; vm.slot[_currentScript].didexec = 1; - debug(1, "Script %d, offset 0x%x: [%X] %s()", + debug(3, "Script %d, offset 0x%x: [%X] %s()", vm.slot[_currentScript].number, _scriptPointer - _scriptOrgPointer, _opcode, diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 26c26e25a2..1bfc76e029 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -38,17 +38,17 @@ // FIXME: Move this somewhere better :) void Scumm_v8::loadCharset(int charset) { - char fontname[255]; + char fontname[256]; sprintf(fontname, "resource/font%d.nut", charset); warning("Loading charset %s\n", fontname); - _fr[charset] = new NutRenderer; - if (!(_fr[charset]->loadFont(fontname, (char*)getGameDataPath()))) { + _fr[charset] = new NutRenderer(this); + if (!(_fr[charset]->loadFont(fontname, getGameDataPath()))) { delete _fr[charset]; _fr[charset] = NULL; return; } - _fr[charset]->bindDisplay((byte*)virtscr[0].screenPtr, (int32)_realWidth, (int32)_realHeight, (int32)_realWidth); + _fr[charset]->bindDisplay(virtscr[0].screenPtr, _realWidth, _realHeight, _realWidth); } void Scumm_v8::setupOpcodes() |