Open sporniket opened 2 years ago
(nb lignes × nb colonnes) de cellules ( {glyphe, couleur, couleur fond})
using ColorIndex = uint8_t ; using ColorIndexBackground = ColorIndex ; using CellColors = uint8_t ; struct CellColorsExpanded { ColorIndex color; ColorIndexBackground backgroundColor; } ; class CellColorsHelper { static CellColors fromColors(ColorIndex color, ColorIndexBackground backgroundColor) { return (CellColors)((backgroundColor & 0xf) << 4 + color & 0xf) ; } static CellColors fromCellColorsExpanded(CellColorsExpanded colors) { return fromColors(colors.color, colors.backgroundColor) ; } } ; class ColorIndexHelper { static ColorIndex fromCellColors(CellColors colors) { return colors & 0xf ; } } ; class ColorIndexBackgroundHelper { static ColorIndexBackground fromCellColors(CellColors colors) { return (colors >> 4) & 0xf ; } } ; using GlyphIndex = uint16_t ; struct Cell { GlyphIndex glyph ; CellColors colors ; } ;
//Look-Up Table class GlyphLut { public: GlyphIndex fromCharCode8(uint8_t) ; GlyphIndex fromCharCode16(uint16_t) ; } using GlyphMetricPx = uint8_t ; class GlyphSet { GlyphMetricPx glyphWidthPx ; GlyphMetricPx glyphHeightPx ; uint16_t size; //-->glyph index = 0..(size-1) uint8_t* glyphData ; // = (glyphWidthPx+7)>>3 * glyphHeightPx * size } class GlyphSet { GlyphLut lut ; GlyphBitmap bitmap ; }
Désigne directement les cellules à modifier
enum ColorSupport { MONO=2, LIMITED_COLORS=4, FULL_COLORS=16 }; TextModeRam{ private: // instance specs uint8_t gridWidth; uint8_t gridHeight; uint8_t gridSize; //number of cells ColorSupport colorSupport; Cell* screen; // = gridWidth * gridHeight Cell* getCell_unsafe(uint16_t address) {return screen[address];} public: TextModeRam(uint8_t gridWidth, uint8_t gridHeight, ColorSupport colorSupport) ; virtual ~TextModeRam(); //-> libère la zone mémoire Cell* getCell(uint8_t column, uint8_t row) { return (column < gridWidth && row < gridHeight) ? getCell_unsafe(gridWidth*row + column) : nullptr ;) Cell* getCell(uint16_t address) { return (address < gridSize) ? getCell_unsafe(address) : nullptr ;} }
Modèles
Grille
(nb lignes × nb colonnes) de cellules ( {glyphe, couleur, couleur fond})
Rendu graphique : glyphes
Mode Texte direct