Package: berusky Version: 1.1-1 Followup-For: Bug #431906 Hello,
the data files are binary and are litte endian. I understand that a level file is represented by : typedef struct __attribute__ ((__packed__)) { char signum[30]; // -> retezec "Berusky (C) Anakreon 1998" char back; // -> cislo pozadi char music; // -> cislo hudby k tomuto levelu char rot[5]; // -> natoceni hracu char rezerved[100]; // -> pro pozdejsi pouziti word floor[LEVEL_CELLS_Y][LEVEL_CELLS_X][10];// -> podlaha word level[LEVEL_CELLS_Y][LEVEL_CELLS_X][10]; //-> herni plocha (dnesni level) word players[LEVEL_CELLS_Y][LEVEL_CELLS_X]; //-> mapa hracu (dneska sou hraci n levelu) } LEVEL_DISK; I can't read cz comments. Let's hope for the packed attribute to work (some other arch may have stronger alignment requirements, sparc anyone ?) I'm attaching a patch to flip floor/level/players. Maybe the rot member would need to be handled too, i don't know what it is. I don't know if the array layout is endian-dependent, i only flip the word. On the first level, easy, the exit is on the bottom left corner. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: powerpc (ppc) Kernel: Linux 2.6.22-rc7 Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to fr_FR.UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages berusky depends on: ii berusky-data 1.0-1 Data files for Berusky ii libc6 2.5-11 GNU C Library: Shared libraries ii libgcc1 1:4.2-20070609-1 GCC support library ii libsdl1.2debian 1.2.11-9 Simple DirectMedia Layer ii libstdc++6 4.2-20070609-1 The GNU Standard C++ Library v3 berusky recommends no packages. -- no debconf information
--- src/level_game.cpp 2007-03-26 22:17:02.000000000 +0200 +++ src/level_game.cpp.new 2007-07-07 16:14:49.000000000 +0200 @@ -25,6 +25,8 @@ * */ +#include <endian.h> + #include "berusky.h" /**************************************************************** @@ -173,6 +175,17 @@ return(file_exists(NULL, p_file)); } + +static inline word word_from_le(word w) +{ +#if BYTE_ORDER == BIG_ENDIAN + return static_cast<word>(w >> 8) | static_cast<word>(w << 8); +#else + return w; +#endif +} + + void level_generic::level_import(LEVEL_DISK *p_lev) { item_handle item; @@ -185,27 +198,27 @@ for(y = 0; y < LEVEL_CELLS_Y; y++) { // Import correction for floor - item = p_lev->floor[y][x][0]; + item = word_from_le(p_lev->floor[y][x][0]); if(item) item = NO_ITEM; if(p_repo->item_valid(item)) - cell_set(x, y, LAYER_FLOOR, item, p_lev->floor[y][x][1], p_lev->floor[y][x][2], true); + cell_set(x, y, LAYER_FLOOR, item, word_from_le(p_lev->floor[y][x][1]), word_from_le(p_lev->floor[y][x][2]), true); else cell_clear(x, y, LAYER_FLOOR, true); // Import correction for items - item = p_lev->level[y][x][0]; + item = word_from_le(p_lev->level[y][x][0]); if(!item) item = NO_ITEM; if(p_repo->item_valid(item)) - cell_set(x, y, LAYER_ITEMS, item, p_lev->level[y][x][1], p_lev->level[y][x][2], true); + cell_set(x, y, LAYER_ITEMS, item, word_from_le(p_lev->level[y][x][1]), word_from_le(p_lev->level[y][x][2]), true); else cell_clear(x, y, LAYER_ITEMS, true); // Import correction for players - player = p_lev->players[y][x]; + player = word_from_le(p_lev->players[y][x]); if(player == NO_PLAYER) item = NO_ITEM; else {