gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > tetris problem

#64778 - vexon - Mon Dec 26, 2005 6:45 pm

hello, I've been working on my first GBA game today which I'm planning to complete :p.
I'm currently having some issues with the movement of the cluster which contains the blocks which are moved individual and are also represented by an array. Could someone please help me out by saying what should be changed in my code to get the blocks moving properly?
the link to the GBA file here
here's the code.. I'm using the HAMlib:

Code:
#include <mygba.h>

//GFX INCLUDES - START//
    #include "GFX\master.pal.c";
    //titlescreen
    #include "GFX\title_screen.raw.c";
    #include "GFX\title_screen.map.c";
    //logo screen (credits)
    //game bg
    #include "GFX\game_bg.raw.c";
    #include "GFX\game_bg.map.c";
    //block
    #include "GFX\block.raw.c";
//GFX INCLUDES - END//

//GLOBAL VARIABLES - START//
    bool bAddcluster = true;
    char* keypressed;
    int speed = 1;
    int speedmultiplier = 0;
    int controlspeed = 0;
    int score = 0;
    int time = 0;
    u8 tickcount=0;
    u8 block[16];
    u8 staticblock[120];
    u8 currentstaticblock=0;
    u8 block_y[16];
    u8 block_x[16];
    char* clustertype;
    u8 clusterpos_x;
    u8 clusterpos_y;
    int completerow;
    char field[13][10]; //rows, colls
//GLOBAL VARIABLES - END//

//FUNCTION PROTOTYPES - START//
    void tick(); //every frame (60 a second)
    void update(); //updates movement
    void proces_input(); //looks for input and what to do then
    void addcluster(); //adds a another block combination to fall from the sky
    void clusterfall(); //let's  a cluster drop
    void rotatecluster(); //rotate that cluster 90 degrees
    void createcluster(char* type); //create a new cluster
    int movecluster(); //move cluster
    int checkrow(); //check if there's a full row
    void makestatic(); //deactivate the cluster if it's grounded
    void checkcollision(); //check for collision to see it can be made static.
//FUNCTION PROTOTYPES - END//

//FUNCTION DECLARATIONS - START//
int main(void)
{
    for(int fillfield = 0; fillfield <= 10; fillfield++){
        field[fillfield][13] = 1;
    }
    map_fragment_info_ptr bg_game;
   
    map_fragment_info_ptr bg_title_screen;
    ham_Init();
    ham_SetBgMode(1);
    ham_LoadBGPal((void*)master_Palette,256);
    ham_LoadObjPal((void*)master_Palette,256);    
    ham_bg[0].ti = ham_InitTileSet((void*)title_screen_Tiles, SIZEOF_16BIT(title_screen_Tiles),1,1);
    ham_bg[0].mi = ham_InitMapEmptySet(3,0);
    bg_title_screen = ham_InitMapFragment((void*)title_screen_Map, 30,20,0,0,30,20,0);
    ham_InsertMapFragment(bg_title_screen,0,0,0);
   
    ham_InitBg(0,1,1,0);

    while(!F_CTRLINPUT_A_PRESSED)
    {
           //show logo :)
    }
    ham_ResetBg();
    //ham_InitText(1);
    ham_SetBgMode(1);
   
    ///ham_SetTextCol(000, 000);
    // Setup the tileset for our image
    ham_bg[1].ti = ham_InitTileSet((void*)game_bg_Tiles, SIZEOF_16BIT(game_bg_Tiles),1,1);
    // Setup the map for our image
    ham_bg[1].mi = ham_InitMapEmptySet(3,0);
    bg_game = ham_InitMapFragment((void*)game_bg_Map, 30,20,0,0,30,20,0);
    ham_InsertMapFragment(bg_game,1,0,0);
    // Display the background

    ham_InitBg(1,1,0,0);
   
    ham_StartIntHandler(INT_TYPE_VBL,(void*)&tick);
    while(1)
    {
           //keep in eternal looopy
    }
    ham_ResetAll();
    return 0;
}

void tick(){
    if(speedmultiplier >= 20){
        //DEBUG START
        ham_VBAText("crap");
        //DEBUG END
        addcluster();
        clusterfall();
        speedmultiplier = 0;
    }
    checkcollision();
    proces_input();
    speedmultiplier += speed;
    update();
    completerow = checkrow();
    ham_CopyObjToOAM();
}

void update(){
    for(int blockN = 0; blockN <= 16; blockN++){
        ham_SetObjX(block[blockN],block_x[blockN]);
        ham_SetObjY(block[blockN],block_y[blockN]);
    }
    ham_DrawText(50,180,"00:01");
}

void proces_input(){
    if(controlspeed > 5){
            if(F_CTRLINPUT_UP_PRESSED)
            {
                //if (block_y[blockN] > 0) block_y[blockN]-=12;
                rotatecluster();
            }

            if(F_CTRLINPUT_DOWN_PRESSED)
            {
                for(int blockN = 0; blockN <= 16; blockN++){
                    if (block_y[blockN] < 140){
                        block_y[blockN]+=12;
                    }
                }
            }

            if(F_CTRLINPUT_LEFT_PRESSED)
            {
                for(int blockN = 0; blockN <= 16; blockN++){
                    if (block_x[blockN] > 60){
                        block_x[blockN]-=12;
                    }
                }
            }

            if(F_CTRLINPUT_RIGHT_PRESSED)
            {
                for(int blockN = 0; blockN <= 16; blockN++){
                    if (block_x[blockN] < 168){
                        block_x[blockN]+=12;
                    }
                }
            }
        controlspeed = 0;
    }
    controlspeed++;
}

void addcluster(){
    if(bAddcluster == true){
        createcluster("L");
        bAddcluster = false;
    }
}

void rotatecluster(){
    //NU DOEN!!
    for(int blockN = 0; blockN <= 16; blockN++){
        block_y[blockN]-=12;
        block_y[blockN]+=12;
        block_x[blockN]-=12;
        block_x[blockN]+=12;
    }
}

void clusterfall(){
    for(int blockN = 0; blockN <= 16; blockN++){
        block_y[blockN]+=12;
    }
    for(int row = 0; row <= 12; row++){
        //check each row
        for(int column = 0; column <= 10; column++){
            //check each column
            if(field[row][column] == 2){
                field[row][column-1] = 2;
                field[row][column] = 0;
                break;
            }
        }
    }
}

void createcluster(char* type){
    clustertype = type;
    if(type == "L"){
        char Lclustershape[4][4] = {{0,2,0,0},{0,2,0,0},{0,2,2,0},{0,0,0,0}};
        int Crow = 0;
        int Ccol = 0;
        for(int row = 13; row >= 8; row--){
            //check each row
                for(int column = 2; column < 7; column++){
                    //check each column
                    field[row][column] = Lclustershape[Crow][Ccol];
                    Ccol++;
                }
            Crow++;
        }
        clusterpos_x = 120;
        clusterpos_y = 0;
        block_x[1] = clusterpos_x;
        block_y[1] = clusterpos_y;
        block_x[2] = clusterpos_x;
        block_y[2] = clusterpos_y+12;
        block_x[3] = clusterpos_x;
        block_y[3] = clusterpos_y+24;
        block_x[4] = clusterpos_x+12;
        block_y[4] = clusterpos_y+24;
        block[1] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[1],block_y[1]);
        block[2] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[2],block_y[2]);
        block[3] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[3],block_y[3]);
        block[4] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[4],block_y[4]);
    }
}

int checkrow(){
    int fullrow;
    for(int row = 0; row <= 12; row++){
        //check each row
        if(fullrow == -1){
            for(int column = 0; column <= 10; column++){
                //check each column
                if(field[row][column] == 0){
                    fullrow = -1;
                    break;
                }else{
                    fullrow = row;
                }
            }
        }else{
            break;
        }
    }
    return fullrow;
}

void makestatic(){
    for(int blockN = 0; blockN <= 16; blockN++){
        staticblock[currentstaticblock] = block[blockN];
        block[blockN] = 0;
        currentstaticblock++;
    }
    for(int row = 0; row <= 12; row++){
        //check each row
        for(int column = 0; column <= 10; column++){
            //check each column
            if(field[row][column] == 2){
                field[row][column] = 1;
            }
        }
    }
    bAddcluster=true;
}

void checkcollision(){
    for(int row = 0; row < 13; row++){
        //check each row
        for(int column = 0; column <= 10; column++){
            //check each column
            if(field[row][column] == 2){
                if(field[row][column+1] == 1){
                makestatic();
                break;
            }
            }else{

            }
        }
    }
}
//FUNCTION DECLARATIONS - END//


Thanks in advance :)[/url]

#64787 - zazery - Mon Dec 26, 2005 7:58 pm

It looks like the first sprite isn't initialized properly. The block_x and block_y arrays are initialized starting at index one, yet whenever you loop through all the blocks you start at index zero. Also many loops go from 0-16, when the array is 0-15 (including 0 makes the entire size 16), for example in the process_input() function. Since you didn't use index zero for the sprite, it is being drawn. I could be wrong, but I think that's your problem.

#64790 - vexon - Mon Dec 26, 2005 8:18 pm

I think I see your point I have changed a lot of code in the meanwhile. Though I might have screwed up the arrays so I'm changing those now.
I'll let you know if it works when done. If anybody has any suggestions to my code design please tell :D

#64802 - tepples - Mon Dec 26, 2005 10:32 pm

How to develop a tetris clone
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#64806 - vexon - Mon Dec 26, 2005 11:13 pm

Thanks Ya'll hehe my game finally works. I need to get the text to work though should be some pallet isue or something.

#64843 - vexon - Tue Dec 27, 2005 12:10 pm

heh well I've just changed an array and now my graphics are screwed up while that array has nothing to do with graphics.
for those who are interested here's my current gba file: here it isss

Here's the bit of code that seems to screw it up:

Code:
char Lclustershape[3][2] = {{2,0},{2,0},{2,2}};
        char Lclustershape[3][2] = {{2,0},{2,0},{2,2}};
        int Crow = 0;
        int Ccol = 0;
        for(int row = 0; row < 3; row++){
            //check each row
                for(int column = 5; column < 7; column++){
                    //check each column
                    field[row][column] = Lclustershape[Crow][Ccol];
                    Ccol++;
                }
            Ccol = 0;
            Crow++;
        }
        Crow=0;
        }



And here's the actual code I have now the collision detection is not fully working yet and neither optimized.
Code:

#include <mygba.h>

//GFX INCLUDES - START//
    #include "GFX\master.pal.c";
    //titlescreen
    #include "GFX\title_screen.raw.c";
    #include "GFX\title_screen.map.c";
    //logo screen (credits)
    //game bg
    #include "GFX\game_bg.raw.c";
    #include "GFX\game_bg.map.c";
    //block
    #include "GFX\block.raw.c";
//GFX INCLUDES - END//

//GLOBAL VARIABLES - START//
    bool bAddcluster = true;
    char* keypressed;
    int speed = 1;
    int speedmultiplier = 0;
    int controlspeed = 0;
    int score = 0;
    int time = 0;
    u8 tickcount=0;
    u8 block[4];
    u8 u8nextcluster[4];
    char* upcomingcluster ="L";
    u8 staticblock[120];
    u8 currentstaticblock=0;
    u8 block_y[4];
    u8 block_x[4];
    char* clustertype;
    u8 clusterpos_x;
    u8 clusterpos_y;
    u8 clusterorientation=0;
    int completerow;
    char field[10][12]; //rows, colls
    bool moveleft;
    bool moveright;
//GLOBAL VARIABLES - END//

//FUNCTION PROTOTYPES - START//
    void tick(); //every frame (60 a second)
    void nextcluster();
    void update(); //updates movement
    void proces_input(); //looks for input and what to do then
    void addcluster(); //adds a another block combination to fall from the sky
    void clusterfall(); //let's  a cluster drop
    void rotatecluster(); //rotate that cluster 90 degrees
    void createcluster(char* type); //create a new cluster
    int movecluster(); //move cluster
    int checkrow(); //check if there's a full row
    void makestatic(); //deactivate the cluster if it's grounded
    void checkcollision(); //check for collision to see it can be made static.
//FUNCTION PROTOTYPES - END//

//FUNCTION DECLARATIONS - START//
int main(void)
{
    ham_InitText(1);
    map_fragment_info_ptr bg_game;
   
    map_fragment_info_ptr bg_title_screen;
    ham_Init();
    ham_SetBgMode(1);
    ham_LoadBGPal((void*)master_Palette,256);
    ham_LoadObjPal((void*)master_Palette,256);    
    ham_bg[0].ti = ham_InitTileSet((void*)title_screen_Tiles, SIZEOF_16BIT(title_screen_Tiles),1,1);
    ham_bg[0].mi = ham_InitMapEmptySet(3,0);
    bg_title_screen = ham_InitMapFragment((void*)title_screen_Map, 30,20,0,0,30,20,0);
    ham_InsertMapFragment(bg_title_screen,0,0,0);
   
    ham_InitBg(0,1,1,0);

    while(!F_CTRLINPUT_A_PRESSED)
    {
           //show logo :)
    }
    ham_ResetBg();
   
    ham_SetBgMode(1);
   
    //ham_SetTextCol(666, 666);
    // Setup the tileset for our image
    ham_bg[1].ti = ham_InitTileSet((void*)game_bg_Tiles, SIZEOF_16BIT(game_bg_Tiles),1,1);
    // Setup the map for our image
    ham_bg[1].mi = ham_InitMapEmptySet(3,0);
    bg_game = ham_InitMapFragment((void*)game_bg_Map, 30,20,0,0,30,20,0);
    ham_InsertMapFragment(bg_game,1,0,0);
    // Display the background

    ham_InitBg(1,1,0,0);
   
    ham_StartIntHandler(INT_TYPE_VBL,(void*)&tick);

    while(1)
    {
           //keep in eternal looopy
    }
    ham_ResetAll();
    return 0;
}

void tick(){
    if(speedmultiplier > 20){
        //DEBUG START
       // ham_VBAText("crap");
        //DEBUG END
        addcluster();
        clusterfall();
        speedmultiplier = 0;
    }
    checkcollision();
    proces_input();
    speedmultiplier += speed;
    completerow = checkrow();
    update();
    ham_CopyObjToOAM();
}

void update(){
    for(int blockN = 0; blockN < 4; blockN++){
        ham_SetObjX(block[blockN],block_x[blockN]);
        ham_SetObjY(block[blockN],block_y[blockN]);
    }
    ham_DrawText(50,180,"00:01");
}

void proces_input(){
    if(controlspeed > 5){
            if(F_CTRLINPUT_UP_PRESSED)
            {
                rotatecluster();
            }

            if(F_CTRLINPUT_DOWN_PRESSED)
            {
                for(int blockN = 0; blockN < 4; blockN++){
                        block_y[blockN]+=12;
                }
            }

            if(F_CTRLINPUT_LEFT_PRESSED)
            {
                for(int row = 0; row < 12; row++){
                        //check each row
                        for(int column = 0; column < 10; column++){
                            //check each column
                            if(field[row][column] == 2){
                                if(field[row][column-1] == 1 || column == 0){
                                    moveleft = false;
                                }else{
                                    moveleft = true;
                                }
                            }
                        }
                }
                if(moveleft == true){
                    for(int blockN = 0; blockN < 4; blockN++){
                        block_x[blockN]-=12;
                    }
                    for(int row = 0; row < 12; row++){
                        //check each row
                        for(int column = 0; column < 10; column++){
                            //check each column
                            if(field[row][column] == 2){
                                field[row][column-1] = 2;
                                field[row][column] = 0;
                                break;
                            }
                        }
                    }
                }
            }

            if(F_CTRLINPUT_RIGHT_PRESSED)
            {
                for(int row = 0; row < 12; row++){
                        //check each row
                        for(int column = 0; column < 10; column++){
                            //check each column
                            if(field[row][column] == 2){
                                if(field[row][column+1] == 1 || column == 9){
                                    moveright = false;
                                }else{
                                    moveright = true;
                                }
                            }
                        }
                }
                if(moveright == true){
                    for(int blockN = 0; blockN < 4; blockN++){
                                block_x[blockN]+=12;
                    }
                    for(int row = 0; row < 12; row++){
                        //check each row
                        for(int column = 0; column < 10; column++){
                            //check each column
                            if(field[row][column] == 2){
                                field[row][column+1] = 2;
                                field[row][column] = 0;
                                break;
                            }
                        }
                    }
                }
            }
        controlspeed = 0;
    }
    controlspeed++;
}

void addcluster(){
    if(bAddcluster == true){
        createcluster(upcomingcluster);
        nextcluster();
        bAddcluster = false;
    }
}

void rotatecluster(){
    //NU DOEN!!
    /*switch(clusterorientation){
        case 0:
        block_y[1]+=24;
        block_x[1]-=12;
        block_x[2]+=12;
        clusterorientation+=90;
        break;
        case 90:
        block_y[1]-=24;
        block_x[1]+=12;
        block_x[3]+=12;
        block_y[3]-=36;
        block_x[2]+=12;
        clusterorientation+=90;
        break;
        case 180:
        block_y[1]+=24;
        clusterorientation+=90;
        break;
        case 270:
        block_y[1]+=24;
        clusterorientation=0;
        break;
    }*/
    //}
}

void clusterfall(){
    for(int blockN = 0; blockN < 4; blockN++){
        block_y[blockN]+=12;
    }
    for(int row = 11; row >= 0; row--){
        //check each row
        for(int column = 0; column < 10; column++){
            //check each column
            if(field[row][column] == 2){
                field[row+1][column] = 2;
                field[row][column] = 0;
                break;
            }
        }
    }
}

void createcluster(char* type){
    clustertype = type;
    if(type == "L"){
        char Lclustershape[3][2] = {{2,0},{2,0},{2,2}};
        int Crow = 0;
        int Ccol = 0;
        for(int row = 0; row < 3; row++){
            //check each row
                for(int column = 5; column < 7; column++){
                    //check each column
                    field[row][column] = Lclustershape[Crow][Ccol];
                    Ccol++;
                }
            Ccol = 0;
            Crow++;
        }
        Crow=0;
        clusterpos_x = 107;
        clusterpos_y = 11;
        block_x[0] = clusterpos_x;
        block_y[0] = clusterpos_y;
        block_x[1] = clusterpos_x;
        block_y[1] = clusterpos_y+12;
        block_x[2] = clusterpos_x;
        block_y[2] = clusterpos_y+24;
        block_x[3] = clusterpos_x+12;
        block_y[3] = clusterpos_y+24;
        block[0] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[0],block_y[0]);
        block[1] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[1],block_y[1]);
        block[2] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[2],block_y[2]);
        block[3] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, block_x[3],block_y[3]);
    }
}

int checkrow(){
    int fullrow;
    for(int row = 0; row < 12; row++){
        //check each row
        if(fullrow == -1){
            for(int column = 0; column < 10; column++){
                //check each column
                if(field[row][column] == 0){
                    fullrow = -1;
                    break;
                }else if(field[row][column] == 1){
                    fullrow = row;
                }
            }
        }else{
            break;
        }
    }
    return fullrow;
}

void makestatic(){
    for(int blockN = 0; blockN < 4; blockN++){
        staticblock[currentstaticblock] = block[blockN];
        block[blockN] = 0;
        currentstaticblock++;
    }
    for(int row = 0; row < 12; row++){
        //check each row
        for(int column = 0; column < 10; column++){
            //check each column
            if(field[row][column] == 2){
                field[row][column] = 1;
            }
        }
    }
    bAddcluster=true;
}

void checkcollision(){
    for(int row = 0; row < 12; row++){
        //check each row
        for(int column = 0; column < 10; column++){
            //check each column
            if(field[row][column] == 2){
                if(field[row+1][column] == 1 || row==11){
                    makestatic();
                }
            }
        }
    }
}

void nextcluster(){
    upcomingcluster = "L";
    if(upcomingcluster == "L"){
        u8nextcluster[0] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, 200,15);
        u8nextcluster[1] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, 200,27);
        u8nextcluster[2] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, 200,39);
        u8nextcluster[3] = ham_CreateObj((void*)block_Bitmap, 0, 1,OBJ_MODE_NORMAL,1,0,0,0,0,0,0, 212,39);
    }
}
//FUNCTION DECLARATIONS - END//

#64860 - zazery - Tue Dec 27, 2005 9:05 pm

It looks like the graphics are messed up already in the title screen. Checking the vram in VBA it looks like you're not adding the tiles correctly, and since ham takes care of that I'm not sure how to suggest to fix that. Did you change any of the ham calls when you redid the array code?

One small thing I noticed is that you call ham_InitText(1), before ham_Init(), but then again I've never used ham so that might not be the problem.

I strongly recommend is commenting out rotation, adding new pieces and everything else except having one piece being displayed and the ability to move it around (up included for debugging). You're trying to design the multiple shapes before actually getting one properly being displayed. It was one of the mistakes I made when designing my version of tetris.

Hope that helps.

#64881 - wintermute - Wed Dec 28, 2005 1:20 am

vexon wrote:
heh well I've just changed an array and now my graphics are screwed up while that array has nothing to do with graphics.
for those who are interested here's my current gba file: here it isss

Here's the bit of code that seems to screw it up:

Code:

#include <mygba.h>

//GFX INCLUDES - START//
    #include "GFX\master.pal.c";
    //titlescreen
    #include "GFX\title_screen.raw.c";
    #include "GFX\title_screen.map.c";
    //logo screen (credits)
    //game bg
    #include "GFX\game_bg.raw.c";
    #include "GFX\game_bg.map.c";
    //block
    #include "GFX\block.raw.c";
//GFX INCLUDES - END//



#including c files is extremely bad practice for many reasons and entirely defeats the point of having separate files. The preprocessor includes these files verbatim in the file you're trying to build which effectively means your project is one very large file. Data arrays in particular use horrendous amounts of memory when compiling, slowing down the build process.

The problems you're seeing sound like your graphics data has not been explicitly aligned and other data is affecting the alignment.

When defining a char array which will be later copied to VRAM you need at least 16 bit alignment but 32 bit is more usual to allow for 32bit DMA copy or CPUFastSet. You may find an aligment macro like the one here somewhere in the HAM headers, it's fairly common and, imo, a necessity for most projects.

Code:


// C file declaring data array

// macro to set alignment in bytes
#define ALIGN(m)   __attribute__((aligned (m)))

// 32bit (4 byte) aligned char array
const char data[] ALIGN(4) = { ... };

// declare the size of the array for other files
const int data_size = sizeof(data);



When using arrays as data it is much better to compile them individually rather than using #include to insert it in your main source file. You should use a header file like this ( using the above code as an example)

Code:

// H file included by files which need to access the data

#ifndef _data_h_
#define _data_h_

extern const char data[];
extern const int data_size;

#endif // _data_h_


Then #include this header in the file and not the C file.

Visual HAM generates a makefile which should allow for compiling object files individually.

#65564 - vexon - Tue Jan 03, 2006 11:26 pm

zazery wrote:
Did you change any of the ham calls when you redid the array code?


Nope, I can just comment out the array code and the game displays fine except that it's not working properly but that's because the shape isn't inserted into the field array.

#65630 - Cearn - Wed Jan 04, 2006 3:05 pm

Yup, that's a data-alignment problem. ham_InitTileSet uses a 32-bit DMA to copy the tiles and I'm thinking you're using either u8 or u16 arrays. Now, if you're compiling data separately that's usually not a problem because individual files are always aligned properly, but as you're #including them and have a whole slew of non-word variables, misalignment is almost guaranteed.

It look like you're using gfx2gba for your graphics conversion. I believe that has a switch to ensure word alignment ... -align, maybe? Or you can use u32 arrays, which are always properly aligned.