コード例 #1
0
ファイル: copter.c プロジェクト: jwallher/heli
/* function to setup background 0 for this program */
void setup_background() {

    /* load the palette from the image into palette memory*/
    for (int i = 0; i < PALETTE_SIZE; i++) {
        bg_palette[i] = background_palette[i];
    }

    /* load the image into char block 0 (16 bits at a time) */
    volatile unsigned short* dest = char_block(0);
    unsigned short* image = (unsigned short*) background_data;
    for (int i = 0; i < ((background_width * background_height) / 2); i++) {
        dest[i] = image[i];
    }

    /* set all control the bits in this register */
    *bg0_control = 0 |    /* priority, 0 is highest, 3 is lowest */
        (0 << 2)  |       /* the char block the image data is stored in */
        (0 << 6)  |       /* the mosaic flag */
        (1 << 7)  |       /* color mode, 0 is 16 colors, 1 is 256 colors */
        (16 << 8) |       /* the screen block the tile data is stored in */
        (1 << 13) |       /* wrapping flag */
        (0 << 14);        /* bg size, 0 is 256x256 */

    /* load the tile data into screen block 16 */
    dest = screen_block(16);
    for (int i = 0; i < (map_width * map_height); i++) {
        dest[i] = map[i];
    }
}
コード例 #2
0
ファイル: collide.c プロジェクト: jbramnick/305game
/* function to setup background 0 for this program */
void setup_background() {

	/* load the palette from the image into palette memory*/
	memcpy16_dma((unsigned short*) bg_palette, (unsigned short*) background_palette, PALETTE_SIZE);

	/* load the image into char block 0 */
	memcpy16_dma((unsigned short*) char_block(0), (unsigned short*) background_data,
			(background_width * background_height) / 2);

	/* set all control the bits in this register */
	*bg0_control = 0 |    /* priority, 0 is highest, 3 is lowest */
		(0 << 2)  |       /* the char block the image data is stored in */
		(0 << 6)  |       /* the mosaic flag */
		(1 << 7)  |       /* color mode, 0 is 16 colors, 1 is 256 colors */
		(16 << 8) |       /* the screen block the tile data is stored in */
		(1 << 13) |       /* wrapping flag */
		(0 << 14);        /* bg size, 0 is 256x256 */

	/* load the tile data into screen block 16 */
	memcpy16_dma((unsigned short*) screen_block(16), (unsigned short*) map, map_width * map_height);
}