void region_select_load_gfx() { rbox_init_from_templates(®ion_select_boxes[0]); lz77UnCompVram(pdexSelectBgTiles, (void *)0x0600C000); LZ77UnCompWram(pdexSelectBgMap, bgid_get_tilemap(2)); gpu_pal_apply_compressed(pdexSelectBgPal, 0, 32); gpu_pal_apply(pdex_text_pal, 15 * 16, 32); bgid_mark_for_sync(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); }
void show_bg() { void *data; u32 size; data = malloc_and_LZ77UnComp((void *) backgroundTiles, &size); gpu_copy_to_tileset(1, data, size , 0); gpu_copy_tilemap(1, backgroundMap, 0, 0); gpu_pal_apply(backgroundPal, 0x00, 0x40); bgid_send_tilemap(1); free(data); }
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); }
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; }