void TextFunctions::TextFunctions::SetTextColour(u32 colour, u32 shadowColour, u32 paperColour) { TTC* context = tte_get_context(); context->cattr[TTE_INK] = colour & 0xF; context->cattr[TTE_SHADOW] = shadowColour & 0xF; context->cattr[TTE_PAPER] = paperColour & 0xF; }
//! Character-plot for affine BGs using an 8x8 font. void ase_drawg_w8h8(uint gid) { TTC *tc= tte_get_context(); u8 se= tc->cattr[TTE_SPECIAL] + gid; _sbmp8_plot(&tc->dst, tc->cursorX/8, tc->cursorY/8, se); }
//! Erase part of the affine tilemap canvas. void ase_erase(int left, int top, int right, int bottom) { TTC *tc= tte_get_context(); //# Check for single sequence sbmp8_rect(&tc->dst, left>>3, top>>3, right>>3, bottom>>3, tc->cattr[TTE_PAPER]); }
//! Load important color attribute data. void tte_set_color_attrs(const u16 cattrs[]) { int ii; TTC *tc= tte_get_context(); for(ii=0; ii<4; ii++) tc->cattr[ii]= cattrs[ii]; }
//! Character-plot for affine BGs using an 8x16 font. void ase_drawg_w8h16(uint gid) { TTC *tc= tte_get_context(); uint x0= tc->cursorX/8, y0= tc->cursorY/8; u8 se= tc->cattr[TTE_SPECIAL] + gid*2; _sbmp8_plot(&tc->dst, x0, y0 , se); _sbmp8_plot(&tc->dst, x0, y0+1, se+1); }
//! Set color attribute of \a type to \a cattr. void tte_set_color(eint type, u16 color) { TTC *tc= tte_get_context(); if(tc->dst.palData != NULL) tc->dst.palData[tc->cattr[type]]= color; else tc->cattr[type]= color; }
//! Unwind the object text-buffer void obj_erase(int left, int top, int right, int bottom) { TTC *tc= tte_get_context(); int ii=0, nn= tc->dst.pitch; OBJ_ATTR *obj= (OBJ_ATTR*)tc->dst.data; for(ii=0; ii<nn; ii++) obj_hide(obj--); tc->dst.pitch= 0; }
//! Load important color data. void tte_set_colors(const u16 colors[]) { int ii; TTC *tc= tte_get_context(); if(tc->dst.palData != NULL) for(ii=0; ii<4; ii++) tc->dst.palData[tc->cattr[ii]]= colors[ii]; else for(ii=0; ii<4; ii++) tc->cattr[ii]= colors[ii]; }
//! Base initializer of a TTC. void tte_init_base(const TFont *font, fnDrawg drawProc, fnErase eraseProc) { if(tte_get_context() == NULL) tte_set_context(&__tte_main_context); TTC *tc= tte_get_context(); memset(tc, 0, sizeof(TTC)); tc->font= (TFont*)(font ? font : &fwf_default); tc->drawgProc= drawProc ? drawProc : dummy_drawg; tc->eraseProc= eraseProc ? eraseProc : dummy_erase; // Default is SBB 0 const TSurface srf= { (u8*)se_mem, 32*2, 32, 32, 8, SRF_BMP16, 256, pal_bg_mem }; tc->dst = srf; tc->cattr[TTE_INK] = 0xF1; tc->cattr[TTE_SHADOW] = 0xF2; tc->cattr[TTE_PAPER] = 0; tc->cattr[TTE_SPECIAL]= 0; tc->marginRight= SCREEN_WIDTH; tc->marginBottom= SCREEN_HEIGHT; }
//! Character-plot for objects. void obj_drawg(uint gid) { // PONDER: no obj for ' ' ? TTC *tc= tte_get_context(); TFont *font= tc->font; uint x0= tc->cursorX, y0= tc->cursorY; uint id= tc->dst.pitch; OBJ_ATTR *obj= &((OBJ_ATTR*)tc->dst.data)[-id]; tc->dst.pitch= (id+1 < tc->dst.width ? id+1 : 0); obj->attr0= tc->cattr[0] | BFN_PREP(y0, ATTR0_Y); obj->attr1= tc->cattr[1] | BFN_PREP(x0, ATTR1_X); obj->attr2= tc->cattr[2] + gid*font->cellW*font->cellH/64; }
void TextFunctions::SetFont(const TFont* font) { TTC* context = tte_get_context(); context->font = (TFont*)font; }
const TFont* TextFunctions::GetFont() { TTC* context = tte_get_context(); return context->font; }
void TextFunctions::SetTextPaletteSlot(u32 paletteID) { TTC* context = tte_get_context(); TSurface* surface = &context->dst; surface->palData = pal_bg_bank[paletteID]; }
//! Set color attribute of \a type to \a cattr. void tte_set_color_attr(eint type, u16 cattr) { TTC *tc= tte_get_context(); tc->cattr[type]= cattr; }