#8959 - VgSlag - Thu Jul 24, 2003 11:37 pm
Hi, I'm new to GBA programming but wanted t get a grip of the basics... I was testing this:
It works on the emu but not on the actual hardware... the bg doesn't display. Could anyone explain why please?
Thanks,
G
Code: |
#include <mygba.h> // Graphics Includes // Bg #include "gameBg.raw.c" #include "gameBg.pal.c" // Player #include "player.raw.c" #include "player.pal.c" // Global Variables u8 player; // Sprite index for the player u8 player_x = 10; u8 player_y = 10; u16 player_rot = 0; // Function definitions void vblFunc(); void drawScreen(); void queryKeys(); int main(void) { ham_Init(); // Setup the background mode ham_SetBgMode(4); // DMA the background picture TOOL_DMA1_SET(&gameBg_Bitmap, MEM_BG_PTR, SIZEOF_32BIT(gameBg_Bitmap), DMA_TRANSFER_32BIT, DMA_STARTAT_NOW) // Initialize the background palette ham_LoadBGPal(&gameBg_Palette,SIZEOF_16BIT(gameBg_Palette)); // Initialize the sprite palette ham_LoadObjPal(&player_Palette, 256); // Setup the sprite player = ham_CreateObj(&player_Bitmap,0,2, OBJ_MODE_NORMAL,1,0,1,0,0,0,0,player_x,player_y); // Set up the sprite for rotation ham_SetObjRotEnable(player, 1); // Set the rotation set number ham_SetObjRotSetSelect(player, 0); // Start the VBL interrupt handler ham_StartIntHandler(INT_TYPE_VBL,&vblFunc); while(TRUE) { } return 0; } void vblFunc() { // Copy block sprite to hardware ham_CopyObjToOAM(); // Check which keys are down queryKeys(); // Re-draw the screen drawScreen(); return; } // Function to check the player keys void queryKeys () { // Is Left pressed? if (F_CTRLINPUT_LEFT_PRESSED) { --player_x; } // Is Right pressed? if (F_CTRLINPUT_RIGHT_PRESSED) { ++player_x; } // Is Up pressed? if (F_CTRLINPUT_UP_PRESSED) { --player_y; } // Is Down pressed? if (F_CTRLINPUT_DOWN_PRESSED) { ++player_y; } // Is Start pressed? if (F_CTRLINPUT_START_PRESSED) { ++player_rot; } } // Function to draw the player movement void drawScreen () { ham_SetObjXY(player, player_x, player_y); ham_RotObjDefineSet(0, player_rot % 360, 0x100, 0x100); } /* END OF FILE */ |
It works on the emu but not on the actual hardware... the bg doesn't display. Could anyone explain why please?
Thanks,
G