From 06c46fe423616f516648c67279f5c204398a2bd2 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 30 Oct 2004 22:13:48 +0000 Subject: Let Saga::SURFACE inherit from SURFACE svn-id: r15702 --- saga/console.cpp | 2 +- saga/font.cpp | 10 +++++----- saga/gfx.cpp | 60 ++++++++++++++++++++++++++++---------------------------- saga/gfx.h | 8 +++----- saga/isomap.cpp | 4 ++-- saga/render.cpp | 8 ++++---- saga/sprite.cpp | 16 +++++++-------- saga/text.cpp | 8 ++++---- 8 files changed, 57 insertions(+), 59 deletions(-) diff --git a/saga/console.cpp b/saga/console.cpp index 98ddf9061d..f626443395 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -206,7 +206,7 @@ int Console::draw(SURFACE *ds) { fill_rect.top = 0; fill_rect.left = 0; fill_rect.bottom = _yPos + 1; - fill_rect.right = ds->buf_w; + fill_rect.right = ds->w; _vm->_gfx->drawRect(ds, &fill_rect, _vm->_gfx->matchColor(CONSOLE_BGCOLOR)); txt_fgcolor = _vm->_gfx->matchColor(CONSOLE_TXTCOLOR); diff --git a/saga/font.cpp b/saga/font.cpp index f581a293fe..736237c6d4 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -422,7 +422,7 @@ int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, si int c_bit; int ct; - if ((text_x > ds->buf_w) || (text_y > ds->buf_h)) { + if ((text_x > ds->w) || (text_y > ds->h)) { // Output string can't be visible return SUCCESS; } @@ -458,7 +458,7 @@ int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, si // Get length of character in bytes c_byte_len = ((draw_font->fce[c_code].width - 1) / 8) + 1; - row_limit = (ds->buf_h < (text_y + draw_font->hdr.c_height)) ? ds->buf_h : text_y + draw_font->hdr.c_height; + row_limit = (ds->h < (text_y + draw_font->hdr.c_height)) ? ds->h : text_y + draw_font->hdr.c_height; char_row = 0; for (row = text_y; row < row_limit; row++, char_row++) { @@ -467,9 +467,9 @@ int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, si continue; } - output_ptr = ds->buf + (ds->buf_pitch * row) + text_x; - output_ptr_min = ds->buf + (ds->buf_pitch * row) + (text_x > 0 ? text_x : 0); - output_ptr_max = output_ptr + (ds->buf_pitch - text_x); + output_ptr = (byte *)ds->pixels + (ds->pitch * row) + text_x; + output_ptr_min = (byte *)ds->pixels + (ds->pitch * row) + (text_x > 0 ? text_x : 0); + output_ptr_max = output_ptr + (ds->pitch - text_x); // If character starts off the screen, jump to next character if (output_ptr < output_ptr_min) { diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 433de8c44f..4cb679625c 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -43,10 +43,10 @@ Gfx::Gfx(OSystem *system, int width, int height) { debug(0, "Init screen %dx%d", width, height); // Convert surface data to R surface data - back_buf.buf = (byte *)calloc(1, width * height); - back_buf.buf_w = width; - back_buf.buf_h = height; - back_buf.buf_pitch = width; + back_buf.pixels = calloc(1, width * height); + back_buf.w = width; + back_buf.h = height; + back_buf.pitch = width; back_buf.clip_rect.left = 0; back_buf.clip_rect.top = 0; @@ -66,7 +66,7 @@ Gfx::Gfx(OSystem *system, int width, int height) { /* ~Gfx() { - free(GfxModule.r_back_buf->buf); + free(GfxModule.r_back_buf->pixels); } */ @@ -99,16 +99,16 @@ int Gfx::simpleBlit(SURFACE *dst_s, SURFACE *src_s) { int y, w, p; assert((dst_s != NULL) && (src_s != NULL)); - assert(dst_s->buf_w == src_s->buf_w); - assert(dst_s->buf_h == src_s->buf_h); + assert(dst_s->w == src_s->w); + assert(dst_s->h == src_s->h); - src_p = src_s->buf; - dst_p = dst_s->buf; + src_p = (byte *)src_s->pixels; + dst_p = (byte *)dst_s->pixels; - w = src_s->buf_w; - p = src_s->buf_pitch; + w = src_s->w; + p = src_s->pitch; - for (y = 0; y < src_s->buf_h; y++) { + for (y = 0; y < src_s->h; y++) { memcpy(dst_p, src_p, w); dst_p += p; @@ -176,12 +176,12 @@ int Gfx::bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, if (clip.left == clip.right) { clip.left = 0; - clip.right = ds->buf_w; + clip.right = ds->w; } if (clip.top == clip.bottom) { clip.top = 0; - clip.bottom = ds->buf_h; + clip.bottom = ds->h; } // Clip source rectangle to destination surface @@ -244,12 +244,12 @@ int Gfx::bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, // Transfer buffer data to surface read_p = (src + src_off_x) + (src_w * src_off_y); - write_p = (ds->buf + dst_off_x) + (ds->buf_pitch * dst_off_y); + write_p = ((byte *)ds->pixels + dst_off_x) + (ds->pitch * dst_off_y); for (row = 0; row < src_draw_h; row++) { memcpy(write_p, read_p, src_draw_w); - write_p += ds->buf_pitch; + write_p += ds->pitch; read_p += src_w; } @@ -387,7 +387,7 @@ int Gfx::drawRect(SURFACE *ds, Rect *dst_rect, int color) { int left, top, right, bottom; if (dst_rect != NULL) { - dst_rect->clip(ds->buf_w, ds->buf_h); + dst_rect->clip(ds->w, ds->h); left = dst_rect->left; top = dst_rect->top; @@ -401,18 +401,18 @@ int Gfx::drawRect(SURFACE *ds, Rect *dst_rect, int color) { } else { left = 0; top = 0; - right = ds->buf_w; - bottom = ds->buf_h; + right = ds->w; + bottom = ds->h; } w = right - left; h = bottom - top; - write_p = ds->buf + (ds->buf_pitch * top) + left; + write_p = (byte *)ds->pixels + (ds->pitch * top) + left; for (row = 0; row < h; row++) { memset(write_p, color, w); - write_p += ds->buf_pitch; + write_p += ds->pitch; } return SUCCESS; @@ -681,7 +681,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { right = temp; } - write_p = ds->buf + (top * ds->buf_pitch) + left; + write_p = (byte *)ds->pixels + (top * ds->pitch) + left; dx = right - left; if (dx < 0) { @@ -696,7 +696,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { if (dx == 0) { for (i = 0; i <= dy; i++) { *write_p = (byte) color; - write_p += ds->buf_pitch; + write_p += ds->pitch; } return; } @@ -710,7 +710,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { if (dx == dy) { for (i = 0; i <= dx; i++) { *write_p = (byte) color; - write_p += x_vector + ds->buf_pitch; + write_p += x_vector + ds->pitch; } return; } @@ -735,7 +735,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { *write_p = (byte) color; write_p += x_vector; } - write_p += ds->buf_pitch; + write_p += ds->pitch; for (i = 0; i < (dy - 1); i++) { run = min_run; @@ -750,7 +750,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { *write_p = (byte) color; write_p += x_vector; } - write_p += ds->buf_pitch; + write_p += ds->pitch; } // Horiz. seg @@ -758,7 +758,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { *write_p = (byte) color; write_p += x_vector; } - write_p += ds->buf_pitch; + write_p += ds->pitch; return; } else { @@ -781,7 +781,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { // Vertical seg for (k = 0; k < init_run; k++) { *write_p = (byte) color; - write_p += ds->buf_pitch; + write_p += ds->pitch; } write_p += x_vector; @@ -795,7 +795,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { // Vertical seg for (k = 0; k < run; k++) { *write_p = (byte) color; - write_p += ds->buf_pitch; + write_p += ds->pitch; } write_p += x_vector; } @@ -803,7 +803,7 @@ void Gfx::drawLine(SURFACE *ds, const Point *p1, const Point *p2, int color) { // Vertical seg for (k = 0; k < end_run; k++) { *write_p = (byte) color; - write_p += ds->buf_pitch; + write_p += ds->pitch; } write_p += x_vector; return; diff --git a/saga/gfx.h b/saga/gfx.h index b281f21f0a..b99881d0c9 100644 --- a/saga/gfx.h +++ b/saga/gfx.h @@ -26,6 +26,8 @@ #ifndef SAGA_GFX_H_ #define SAGA_GFX_H_ +#include + namespace Saga { using Common::Point; @@ -60,11 +62,7 @@ struct COLOR { int alpha; }; -struct SURFACE { - byte *buf; - int buf_w; - int buf_h; - int buf_pitch; +struct SURFACE : Graphics::Surface { Rect clip_rect; }; diff --git a/saga/isomap.cpp b/saga/isomap.cpp index d23e876400..8fbf46ea56 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -236,7 +236,7 @@ int IsoMap::drawTile(SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { tile_h = _tile_tbl[tile_i].tile_h; read_p = tile_p; - draw_p = dst_s->buf + tile_x + (tile_y * dst_s->buf_pitch); + draw_p = (byte *)dst_s->pixels + tile_x + (tile_y * dst_s->pitch); draw_x = tile_x; draw_y = tile_y; @@ -251,7 +251,7 @@ int IsoMap::drawTile(SURFACE *dst_s, uint16 tile_i, int tile_x, int tile_y) { } for (row = 0; row < tile_h; row++) { - draw_p = dst_s->buf + draw_x + ((draw_y + row) * dst_s->buf_pitch); + draw_p = (byte *)dst_s->pixels + draw_x + ((draw_y + row) * dst_s->pitch); w_count = 0; // temporary y clip diff --git a/saga/render.cpp b/saga/render.cpp index 4aaccd3b09..819fdecfb7 100644 --- a/saga/render.cpp +++ b/saga/render.cpp @@ -155,7 +155,7 @@ int Render::drawScene() { if (_flags & RF_SHOW_FPS) { sprintf(txt_buf, "%d", _fps); fps_width = _vm->_font->getStringWidth(SMALL_FONT_ID, txt_buf, 0, FONT_NORMAL); - _vm->_font->draw(SMALL_FONT_ID, backbuf_surface, txt_buf, 0, backbuf_surface->buf_w - fps_width, 2, + _vm->_font->draw(SMALL_FONT_ID, backbuf_surface, txt_buf, 0, backbuf_surface->w - fps_width, 2, _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE); } @@ -164,7 +164,7 @@ int Render::drawScene() { int msg_len = strlen(PAUSEGAME_MSG); int msg_w = _vm->_font->getStringWidth(BIG_FONT_ID, PAUSEGAME_MSG, msg_len, FONT_OUTLINE); _vm->_font->draw(BIG_FONT_ID, backbuf_surface, PAUSEGAME_MSG, msg_len, - (backbuf_surface->buf_w - msg_w) / 2, 90, _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE); + (backbuf_surface->w - msg_w) / 2, 90, _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE); } // Update user interface @@ -185,8 +185,8 @@ int Render::drawScene() { // Draw console _vm->_console->draw(backbuf_surface); - _system->copyRectToScreen(backbuf_surface->buf, backbuf_surface->buf_w, 0, 0, - backbuf_surface->buf_w, backbuf_surface->buf_h); + _system->copyRectToScreen((byte *)backbuf_surface->pixels, backbuf_surface->w, 0, 0, + backbuf_surface->w, backbuf_surface->h); _system->updateScreen(); return SUCCESS; diff --git a/saga/sprite.cpp b/saga/sprite.cpp index d0fa8cb076..44df015a91 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -219,19 +219,19 @@ int Sprite::draw(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, int spr_x decodeRLESprite(sprite_data_p, 64000, _decodeBuf, s_width * s_height); - buf_row_p = ds->buf + ds->buf_pitch * spr_y; + buf_row_p = (byte *)ds->pixels + ds->pitch * spr_y; src_row_p = _decodeBuf; // Clip to right side of surface clip_width = s_width; - if (s_width > (ds->buf_w - spr_x)) { - clip_width = (ds->buf_w - spr_x); + if (s_width > (ds->w - spr_x)) { + clip_width = (ds->w - spr_x); } // Clip to bottom side of surface clip_height = s_height; - if (s_height > (ds->buf_h - spr_y)) { - clip_height = (ds->buf_h - spr_y); + if (s_height > (ds->h - spr_y)) { + clip_height = (ds->h - spr_y); } for (i = 0; i < clip_height; i++) { @@ -240,7 +240,7 @@ int Sprite::draw(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, int spr_x *(buf_row_p + j + spr_x) = *(src_row_p + j); } } - buf_row_p += ds->buf_pitch; + buf_row_p += ds->pitch; src_row_p += s_width; } @@ -360,7 +360,7 @@ int Sprite::drawOccluded(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, i // Finally, draw the occluded sprite src_row_p = _decodeBuf + ci.src_draw_x + (ci.src_draw_y * s_width); - dst_row_p = ds->buf + ci.dst_draw_x + (ci.dst_draw_y * ds->buf_pitch); + dst_row_p = (byte *)ds->pixels + ci.dst_draw_x + (ci.dst_draw_y * ds->pitch); mask_row_p = mask_buf + ci.dst_draw_x + (ci.dst_draw_y * mask_w); for (y = 0; y < ci.draw_h; y++) { @@ -378,7 +378,7 @@ int Sprite::drawOccluded(SURFACE *ds, SPRITELIST *sprite_list, int sprite_num, i dst_p++; mask_p++; } - dst_row_p += ds->buf_pitch; + dst_row_p += ds->pitch; mask_row_p += mask_w; src_row_p += s_width; } diff --git a/saga/text.cpp b/saga/text.cpp index f48ab11806..be14528995 100644 --- a/saga/text.cpp +++ b/saga/text.cpp @@ -59,8 +59,8 @@ int SagaEngine::textDraw(int font_id, SURFACE *ds, const char *string, int text_ text_x = TEXT_CENTERLIMIT; } - if (text_x > ds->buf_w - TEXT_CENTERLIMIT) { - text_x = ds->buf_w - TEXT_CENTERLIMIT; + if (text_x > ds->w - TEXT_CENTERLIMIT) { + text_x = ds->w - TEXT_CENTERLIMIT; } if (text_x < (TEXT_MARGIN * 2)) { @@ -70,12 +70,12 @@ int SagaEngine::textDraw(int font_id, SURFACE *ds, const char *string, int text_ string_w = _font->getStringWidth(font_id, string, string_len, flags); - if (text_x < (ds->buf_w / 2)) { + if (text_x < (ds->w / 2)) { // Fit to right side fit_w = (text_x - TEXT_MARGIN) * 2; } else { // Fit to left side - fit_w = ((ds->buf_w - TEXT_MARGIN) - text_x) * 2; + fit_w = ((ds->w - TEXT_MARGIN) - text_x) * 2; } if (fit_w >= string_w) { -- cgit v1.2.3