示例#1
0
// copy BG into area
void set_bg(u8 bg_id, u8 *gfx, u8 *tile_map, u8 *pal, u8 pal_slot, u8 pal_size) {
	void *char_base = (void *)0x6000000 + (0x4000 * bg_id);
	void *map_base = (void *)0x6000000 + (0xF800 - (0x800 * bg_id));
	lz77UnCompVram(gfx, char_base);
	lz77UnCompVram(tile_map, map_base);
	gpu_pal_apply(pal, pal_slot * 16, pal_size);
	gpu_sync_bg_show(bg_id);
}
示例#2
0
void loadBigSprite2(u32 img, u32 pal, u32 dest, u8 bgid, u8 x) {
	u8 *ptr;
	void *data;
	u8 i;

	gpu_pal_apply(pal, 0x60, 0x40);
	LZ77UnCompVram(img, dest);
	data = malloc_and_clear(0x60);
	/* Generate tilemap on the fly */
	ptr = (u8*) data;
	for (i = 0; i < 0x60; ++i) {
		ptr[i] = i;
	}
	int (*func)(u8,u8*,u8,u8,u8,u8,u8,u8,u8,u8,u8,u8) = (int (*)(void)) 0x0800226C + 1;
	/* BGID, tilemap, ?, ?, width, height ,x, y, width, height, ?, offset */
	func(bgid, ptr, 0, 0, 8, 0xC, x, 2, 8, 0xC, 0x10, 0x18);
	gpu_sync_bg_show(bgid);
	bgid_send_tilemap(bgid);
}
示例#3
0
文件: intro.c 项目: Joexv/OakTutorial
void fadeInProfBg(u8 index) {
	if (check_a_pressed(0)) return;
	
	audio_play(0x124);

	/*
	 * Tilemap dimensions
	 */
	u8 *tilemap;
	u16 i, j, k;
	u32 size;
	void *data;
	BUP config = { 0 };

	/*
	 * Allocated enough space for a full screen tilemap
	 */
	tilemap = (u8*) malloc_and_clear(SCREEN_SIZE);
	gmemset(tilemap, 0xFF, SCREEN_SIZE);

	/*
	 * Generate the tilemap on the fly
	 */
	for (k = PROF_MAP_BASE, i = PROF_Y; i < PROF_Y + PROF_HEIGHT; ++i) {
		for (j = PROF_X; j < PROF_X + PROF_WIDTH; ++j)
			tilemap[i * SCREEN_WIDTH + j] = k++;
	}

	/*
	 * Unpack the professor graphics
	 */
	data = malloc_and_LZ77UnComp((void *) profTiles, &size);
	config.SrcNum = size;

	/*
	 * Upscale 4bpp to 8bpp
	 */
	config.SrcBitNum = 4;
	config.DestBitNum = 8;

	/*
	 * Select palette 4
	 */
	config.DestOffset = 64;

	/*
	 * Copy professor graphics to the map base of BG2
	 */
	bitUnPack(data, (void *) 0x06000600, &config);
	gpu_pal_apply((void *) profPal, 0x40, 0x40);
	free(data);

	bgid_set_tilemap(2, tilemap);
	bgid_send_tilemap(2);

	/*
	 * Slow unfade
	 */
	fadescreen(0xFFFFFFFF, 0x10, 0x10, 0x0, 0x0000);
	gpu_sync_bg_show(1);
	gpu_sync_bg_show(2);
	textbox_close();

	tasks[index].args[6] = 0xA0;
	tasks[index].function = (u32) profIntroduce;
}
void region_loop(u8 tid) {
    (void)tid;
    switch (pokedex_context->state) {
    case 0:
        bgid_send_tilemap(2);

        for (u8 i = 0; i < 7; ++i) {
            rboxid_clear_pixels(i, 0);
            rboxid_print(i, FONT_DEX_STD, region_text_x_offset[i], region_text_y_offset[i], &pdex_text_color, 0,
                         pdex_str_regions[i + 1]);
            rboxid_update_tilemap_and_tileset(i);
        }

        region_load_border();
        region_load_icon_palettes();
        for (u8 i = 0; i < 21; ++i)
            region_load_icon(i);

        palette_bg_faded_fill_black();
        pokedex_context->state++;
        break;
    case 1:
        gpu_sync_bg_show(0);
        gpu_sync_bg_hide(1);
        gpu_sync_bg_hide(3);

        gpu_sync_bg_show(2);
        fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 16, 0, 0x0000);
        pokedex_context->state++;
        break;
    case 2:
        if (!pal_fade_control.active)
            pokedex_context->state++;
        break;
    case 3:
        switch (super.buttons_new) {
        case KEY_RIGHT:
            if (pokedex_context->region_selected < 6) {
                pokedex_context->region_selected++;
                m4aSongNumStart(101);
            }
            break;
        case KEY_DOWN:
            if (pokedex_context->region_selected < 3) {
                pokedex_context->region_selected += 3;
                m4aSongNumStart(101);
            }
            break;
        case KEY_LEFT:
            if (pokedex_context->region_selected > 0) {
                pokedex_context->region_selected--;
                m4aSongNumStart(101);
            }
            break;
        case KEY_UP:
            if ((pokedex_context->region_selected > 2) && (pokedex_context->region_selected < 6)) {
                pokedex_context->region_selected -= 3;
                m4aSongNumStart(101);
            }
            break;
        case KEY_A:
            fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
            pokedex_context->state = 10;
            m4aSongNumStart(5);
            break;
        case KEY_B:
            fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
            pokedex_context->state = 11;
            m4aSongNumStart(601);
        default:
            break;
        }
        break;
    case 10:
        if (!pal_fade_control.active) {
            task_del(tid);
            pdex_vram_free_bgmaps();
            pokedex_context->cursor_position_top = region_to_dex[pokedex_context->region_selected];
            set_callback2(pdex_load);
        }
        break;
    case 11:
        if (!pal_fade_control.active) {
            task_del(tid);
            pdex_free_memory();
            set_callback2(c2_overworld_switch_start_menu);
            set_callback1(c1_overworld);
        }
        break;
    default:

        break;
    }
}
示例#5
0
void display_textbox() {
	gpu_sync_bg_show(0);
}