diff options
author | Filippos Karapetis | 2009-02-23 09:03:12 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-02-23 09:03:12 +0000 |
commit | 5e1ab5be9b3d7ff22d92c3e32f2138d53786aad0 (patch) | |
tree | 5820b65664425782b61969b5ec7be600647755b9 /engines/sci/gfx | |
parent | 376e4f86d64a8008ea135eb49d5639556506ed17 (diff) | |
download | scummvm-rg350-5e1ab5be9b3d7ff22d92c3e32f2138d53786aad0.tar.gz scummvm-rg350-5e1ab5be9b3d7ff22d92c3e32f2138d53786aad0.tar.bz2 scummvm-rg350-5e1ab5be9b3d7ff22d92c3e32f2138d53786aad0.zip |
Replaced get_uint_16() with READ_LE_UINT16()
svn-id: r38812
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/gfx_resource.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_view_0.cpp | 10 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_view_1.cpp | 34 |
3 files changed, 24 insertions, 25 deletions
diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h index b306d0d68b..1db6dbc948 100644 --- a/engines/sci/gfx/gfx_resource.h +++ b/engines/sci/gfx/gfx_resource.h @@ -401,11 +401,6 @@ gfx_pixmap_t *gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode); ** the mode has a byte depth of more than 1. */ - -static inline int get_uint_16(const byte *offset) { - return ((unsigned int) offset[0] | (((unsigned int) offset[1]) << 8)); -} - static inline int get_int_16(const byte *offset) { return ((int) offset[0] | (((int) offset[1]) << 8)); } diff --git a/engines/sci/gfx/resource/sci_view_0.cpp b/engines/sci/gfx/resource/sci_view_0.cpp index a43a8acac5..a22f0659b0 100644 --- a/engines/sci/gfx/resource/sci_view_0.cpp +++ b/engines/sci/gfx/resource/sci_view_0.cpp @@ -23,6 +23,8 @@ * */ +#include "common/endian.h" + #include "sci/include/sci_memory.h" #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_resource.h" @@ -123,8 +125,8 @@ static int gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int i; int cels_nr = get_int_16(resource + offset); - if (get_uint_16(resource + offset + 2)) { - GFXWARN("View %02x:(%d): Gray magic %04x in loop, expected white\n", id, loop, get_uint_16(resource + offset + 2)); + if (READ_LE_UINT16(resource + offset + 2)) { + GFXWARN("View %02x:(%d): Gray magic %04x in loop, expected white\n", id, loop, READ_LE_UINT16(resource + offset + 2)); } if (cels_nr * 2 + 4 + offset > size) { @@ -137,7 +139,7 @@ static int gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, dest->cels = (gfx_pixmap_t**)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); for (i = 0; i < cels_nr; i++) { - int cel_offset = get_uint_16(resource + offset + 4 + (i << 1)); + int cel_offset = READ_LE_UINT16(resource + offset + 4 + (i << 1)); gfx_pixmap_t *cel = NULL; if (cel_offset >= size) { @@ -205,7 +207,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) { for (i = 0; i < view->loops_nr; i++) { int error_token = 0; - int loop_offset = get_uint_16(resource + V0_FIRST_LOOP_OFFSET + (i << 1)); + int loop_offset = READ_LE_UINT16(resource + V0_FIRST_LOOP_OFFSET + (i << 1)); int mirrored = resource[mirror_bytepos] & mirror_bitpos; if ((mirror_bitpos <<= 1) == 0x100) { diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index 48c204cf43..82ba6160a2 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -25,6 +25,8 @@ // SCI 1 view resource defrobnicator +#include "common/endian.h" + #include "sci/include/sci_memory.h" #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_resource.h" @@ -274,8 +276,8 @@ static int gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, by int i; int cels_nr = get_int_16(resource + offset); - if (get_uint_16(resource + offset + 2)) { - GFXWARN("View %02x:(%d): Gray magic %04x in loop, expected white\n", id, loop, get_uint_16(resource + offset + 2)); + if (READ_LE_UINT16(resource + offset + 2)) { + GFXWARN("View %02x:(%d): Gray magic %04x in loop, expected white\n", id, loop, READ_LE_UINT16(resource + offset + 2)); } if (cels_nr * 2 + 4 + offset > size) { @@ -288,7 +290,7 @@ static int gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, by dest->cels = (gfx_pixmap_t**)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); for (i = 0; i < cels_nr; i++) { - int cel_offset = get_uint_16(resource + offset + 4 + (i << 1)); + int cel_offset = READ_LE_UINT16(resource + offset + 4 + (i << 1)); gfx_pixmap_t *cel; if (cel_offset >= size) { @@ -332,8 +334,8 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_ view->flags = 0; view->loops_nr = resource[V1_LOOPS_NR_OFFSET]; - palette_offset = get_uint_16(resource + V1_PALETTE_OFFSET); - mirror_mask = get_uint_16(resource + V1_MIRROR_MASK); + palette_offset = READ_LE_UINT16(resource + V1_PALETTE_OFFSET); + mirror_mask = READ_LE_UINT16(resource + V1_MIRROR_MASK); if (view->loops_nr * 2 + V1_FIRST_LOOP_OFFSET > size) { GFXERROR("View %04x: Not enough space in resource to accomodate for the claimed %d loops\n", id, view->loops_nr); @@ -378,7 +380,7 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_ for (i = 0; i < view->loops_nr; i++) { int error_token = 0; - int loop_offset = get_uint_16(resource + V1_FIRST_LOOP_OFFSET + (i << 1)); + int loop_offset = READ_LE_UINT16(resource + V1_FIRST_LOOP_OFFSET + (i << 1)); if (loop_offset >= size) { GFXERROR("View %04x:(%d) supposed to be at illegal offset 0x%04x\n", id, i, loop_offset); @@ -416,12 +418,12 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_ #define V2_LITERAL_OFFSET 28 gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view) { - int xl = get_uint_16(cel_base + V2_CEL_WIDTH); - int yl = get_uint_16(cel_base + V2_CEL_HEIGHT); - int xdisplace = get_uint_16(cel_base + V2_X_DISPLACEMENT); - int ydisplace = get_uint_16(cel_base + V2_Y_DISPLACEMENT); - int runlength_offset = get_uint_16(cel_base + V2_RUNLENGTH_OFFSET); - int literal_offset = get_uint_16(cel_base + V2_LITERAL_OFFSET); + int xl = READ_LE_UINT16(cel_base + V2_CEL_WIDTH); + int yl = READ_LE_UINT16(cel_base + V2_CEL_HEIGHT); + int xdisplace = READ_LE_UINT16(cel_base + V2_X_DISPLACEMENT); + int ydisplace = READ_LE_UINT16(cel_base + V2_Y_DISPLACEMENT); + int runlength_offset = READ_LE_UINT16(cel_base + V2_RUNLENGTH_OFFSET); + int literal_offset = READ_LE_UINT16(cel_base + V2_LITERAL_OFFSET); int pixmap_size = xl * yl; gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel)); @@ -474,8 +476,8 @@ gfxr_loop_t *gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_bas gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size) { gfxr_view_t *view; - int header_size = get_uint_16(resource + V2_HEADER_SIZE); - int palette_offset = get_uint_16(resource + V2_PALETTE_OFFSET); + int header_size = READ_LE_UINT16(resource + V2_HEADER_SIZE); + int palette_offset = READ_LE_UINT16(resource + V2_PALETTE_OFFSET); int bytes_per_loop = resource[V2_BYTES_PER_LOOP]; int loops_num = resource[V2_LOOPS_NUM]; int bytes_per_cel = resource[V2_BYTES_PER_CEL]; @@ -496,7 +498,7 @@ gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size) { seeker = resource + header_size; for (i = 0; i < view->loops_nr; i++) { - int loop_offset = get_uint_16(seeker + V2_LOOP_OFFSET); + int loop_offset = READ_LE_UINT16(seeker + V2_LOOP_OFFSET); int cels = seeker[V2_CELS_NUM]; int mirrored = seeker[V2_IS_MIRROR]; int copy_entry = seeker[V2_COPY_OF_LOOP]; @@ -507,7 +509,7 @@ gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size) { view, bytes_per_cel); else { byte *temp = resource + header_size + copy_entry * bytes_per_loop; - loop_offset = get_uint_16(temp + V2_LOOP_OFFSET); + loop_offset = READ_LE_UINT16(temp + V2_LOOP_OFFSET); cels = temp[V2_CELS_NUM]; gfxr_draw_loop11(id, i, 1, resource, resource + loop_offset, size, cels, view->loops + i, view, bytes_per_cel); |