diff options
author | Oystein Eftevaag | 2006-01-13 03:27:01 +0000 |
---|---|---|
committer | Oystein Eftevaag | 2006-01-13 03:27:01 +0000 |
commit | d47ae2ca9f8326dc05f95c23f6e7ee8ffa132445 (patch) | |
tree | e334b0dec0c9333e7c8e54a1b623f37c6555908e /kyra/screen.cpp | |
parent | 37e82c8c46fa40a85f64549158a5708942bfbeb1 (diff) | |
download | scummvm-rg350-d47ae2ca9f8326dc05f95c23f6e7ee8ffa132445.tar.gz scummvm-rg350-d47ae2ca9f8326dc05f95c23f6e7ee8ffa132445.tar.bz2 scummvm-rg350-d47ae2ca9f8326dc05f95c23f6e7ee8ffa132445.zip |
Implemented a few drawing functions used by the menu, corrected a few incorrect
opcode debug messages, and blocked unnecessary sprite anim script looping.
svn-id: r19992
Diffstat (limited to 'kyra/screen.cpp')
-rw-r--r-- | kyra/screen.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/kyra/screen.cpp b/kyra/screen.cpp index c9d6a08687..aeeb374f19 100644 --- a/kyra/screen.cpp +++ b/kyra/screen.cpp @@ -435,6 +435,79 @@ void Screen::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum) } } +void Screen::drawBox(int x1, int y1, int x2, int y2, int color1, int color2) { + debug(9, "Screen::drawBox(%i, %i, %i, %i, %i, %i)", x1, y1, x2, y2, color1, color2); + + //if (_menuUnk1 == 0) + //return; + + hideMouse(); + + fillRect(x1, y1, x2, y1 + 1, color1); + fillRect(x2 - 1, y1, x2, y2, color1); + + drawClippedLine(x1, y1, x1, y2, color2); + drawClippedLine(x1 + 1, y1 + 1, x1 + 1, y2 - 1, color2); + drawClippedLine(x1, y2, x2, y2, color2); + drawClippedLine(x1, y2 - 1, x2 - 1, y2 - 1, color2); + + showMouse(); +} + +void Screen::drawClippedLine(int x1, int y1, int x2, int y2, int color) { + debug(9, "Screen::drawClippedLine(%i, %i, %i, %i, %i)", x1, y1, x2, y2, color); + + if (x1 < 0) + x1 = 0; + else if (x1 > 319) + x1 = 319; + + if (x2 < 0) + x2 = 0; + else if (x2 > 319) + x2 = 319; + + if (y1 < 0) + y1 = 0; + else if (y1 > 199) + y1 = 199; + + if (y2 < 0) + y2 = 0; + else if (y2 > 199) + y2 = 199; + + if (x1 == x2) + if (y1 > y2) + drawLine(true, x1, y2, y1 - y2 + 1, color); + else + drawLine(true, x1, y1, y2 - y1 + 1, color); + else + if (x1 > x2) + drawLine(false, x2, y1, x1 - x2 + 1, color); + else + drawLine(false, x1, y1, x2 - x1 + 1, color); +} + +void Screen::drawLine(bool horizontal, int x, int y, int length, int color) { + debug(9, "Screen::drawLine(%i, %i, %i, %i, %i)", horizontal, x, y, length, color); + + uint8 *ptr = getPagePtr(_curPage) + y * SCREEN_W + x; + + if (horizontal) { + assert((y + length) <= SCREEN_H); + int currLine = 0; + while (currLine < length) { + *ptr = color; + ptr += SCREEN_W; + currLine++; + } + } else { + assert((x + length) <= SCREEN_W); + memset(ptr, color, length); + } +} + void Screen::setAnimBlockPtr(int size) { debug(9, "Screen::setAnimBlockPtr(%d)", size); free(_animBlockPtr); |