void TextButton::init_vram( const void* source, u16*& vram_dest ) { vram_dest = oamAllocateGfx( this->get_oam(), this->sprite_size, SpriteColorFormat_Bmp ); DC_FlushRange( source, SPRITE_SIZE_PIXELS(this->sprite_size)*2 ); dmaCopy( source, vram_dest, SPRITE_SIZE_PIXELS(this->sprite_size)*2 ); set_16bpp_sprite_opague( vram_dest, SPRITE_SIZE_PIXELS(this->sprite_size)*2 ); }
u16* oamAllocateGfx(OamState *oam, SpriteSize size, SpriteColorFormat colorFormat) { int bytes = SPRITE_SIZE_PIXELS(size); if(colorFormat == SpriteColorFormat_16Color) bytes = bytes >> 1; else if(colorFormat == SpriteColorFormat_Bmp)
void TextButton::init_text_layer( FreetypeRenderer& freetype_renderer ) { if( this->text.length() && this->owns_text_vram ) { // allocate VRAM for 8bpp text layer this->text_vram = oamAllocateGfx( this->get_oam(), this->text_sprite_size, SpriteColorFormat_256Color ); RenderScreenBuffer button_text( this->text_width, this->text_height ); RenderStyle render_style; render_style.center_x = true; freetype_renderer.render( button_text, this->text, this->face, this->font_size, 0, 1, &render_style ); // convert 8bpp sprite data for use in 16bpp mode // FIXME: currently needs ram buffering, as vram supports 16bit operations only u8 conversion_buffer[ SPRITE_SIZE_PIXELS(this->text_sprite_size) ]; tile_8bpp_sprite( (u8*)(button_text.base_address), conversion_buffer, this->text_width, this->text_height ); //DC_FlushRange( conversion_buffer, SPRITE_SIZE_PIXELS(this->sprite_size)*1 ); //dmaCopy( conversion_buffer, this->text_vram, SPRITE_SIZE_PIXELS(this->sprite_size)*1 ); memcpy( this->text_vram, conversion_buffer, SPRITE_SIZE_PIXELS(this->text_sprite_size)*1 ); } }
void TextButton::update_vram(const void* source, u16* vram_dest) { DC_FlushRange( source, SPRITE_SIZE_PIXELS(this->sprite_size)*2 ); dmaCopy( source, vram_dest, SPRITE_SIZE_PIXELS(this->sprite_size)*2 ); set_16bpp_sprite_opague( vram_dest, SPRITE_SIZE_PIXELS(this->sprite_size)*2 ); }