94 lines
2.8 KiB
C
94 lines
2.8 KiB
C
//---------------------------------------------------------------------------------
|
|
// Initial code from devkitARM - http://www.devkit.tk
|
|
//---------------------------------------------------------------------------------
|
|
#include "gba_video.h"
|
|
#include "gba_systemcalls.h"
|
|
#include "gba_input.h"
|
|
#include "gba_interrupt.h"
|
|
#include "gba_sprites.h"
|
|
#include "gba_dma.h"
|
|
#include "pcx.h"
|
|
#include "fade.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
//---------------------------------------------------------------------------------
|
|
// header for binary data generated by bin2o macro in makefile
|
|
//---------------------------------------------------------------------------------
|
|
#include "s_piece_bin.h"
|
|
#include "helds_logo_bin.h"
|
|
#include "helds_pal_bin.h"
|
|
|
|
//---------------------------------------------------------------------------------
|
|
// storage space for palette data
|
|
//---------------------------------------------------------------------------------
|
|
u16 PaletteBuffer[256];
|
|
OBJATTR sprite;
|
|
|
|
unsigned int frame;
|
|
|
|
//---------------------------------------------------------------------------------
|
|
void VblankInterrupt()
|
|
//---------------------------------------------------------------------------------
|
|
{
|
|
frame += 1;
|
|
ScanKeys();
|
|
}
|
|
|
|
void move_show_and_wait(u16 x, u16 y, u16 wait_ticks) {
|
|
// assume we are in vblank
|
|
sprite.attr1 = OBJ_X(x);
|
|
sprite.attr0 = OBJ_256_COLOR | OBJ_Y(y);
|
|
CpuFastSet(&sprite, OAM, COPY32 | sizeof(sprite)/4);
|
|
u16 i;
|
|
for (i=0; i<wait_ticks; i++) VBlankIntrWait();
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------
|
|
// Program entry point
|
|
//---------------------------------------------------------------------------------
|
|
int main(void)
|
|
//---------------------------------------------------------------------------------
|
|
{
|
|
// Set up the interrupt handlers
|
|
InitInterrupt();
|
|
|
|
SetInterrupt( IE_VBL, VblankInterrupt);
|
|
|
|
// Enable Vblank Interrupt to allow VblankIntrWait
|
|
EnableInterrupt(IE_VBL);
|
|
|
|
// Allow Interrupts
|
|
REG_IME = 1;
|
|
|
|
// screen mode, background and objects to display
|
|
SetMode( MODE_4 | BG2_ON | OBJ_ON );
|
|
|
|
CpuFastSet(helds_logo_bin, (u16*)VRAM, COPY32 | helds_logo_bin_size/4);
|
|
CpuFastSet(helds_pal_bin, PaletteBuffer, COPY32 | helds_pal_bin_size / 4);
|
|
FadeToPalette( PaletteBuffer, 60);
|
|
|
|
CpuFastSet(s_piece_bin, BITMAP_OBJ_BASE_ADR, COPY32 | s_piece_bin_size/4);
|
|
CpuFastSet(PaletteBuffer, OBJ_COLORS, COPY32 | sizeof(PaletteBuffer)/4);
|
|
|
|
memset(&sprite, 0, sizeof(sprite));
|
|
sprite.attr2 = OBJ_CHAR(512);
|
|
|
|
while (1)
|
|
{
|
|
VBlankIntrWait();
|
|
move_show_and_wait(147, 74, 60);
|
|
move_show_and_wait(147, 76, 60);
|
|
move_show_and_wait(147, 78, 30);
|
|
move_show_and_wait(145, 78, 30);
|
|
move_show_and_wait(145, 80, 60);
|
|
move_show_and_wait(145, 82, 60);
|
|
move_show_and_wait(145, 84, 60);
|
|
move_show_and_wait(145, 86, 60);
|
|
move_show_and_wait(145, 88, 180);
|
|
}
|
|
}
|
|
|
|
|