fix tab/spaces

This commit is contained in:
Justin C. Miller
2018-04-10 01:03:52 -07:00
parent eaa9d2ba53
commit 067ff3af89
8 changed files with 62 additions and 64 deletions

View File

@@ -19,10 +19,10 @@ enum psf2_flags {
struct psf2_header {
uint8_t magic[4];
uint32_t version;
uint32_t header_size; // offset of bitmaps in file
uint32_t header_size; // offset of bitmaps in file
uint32_t flags;
uint32_t length; // number of glyphs
uint32_t charsize; // number of bytes for each character
uint32_t length; // number of glyphs
uint32_t charsize; // number of bytes for each character
uint32_t height, width; // max dimensions of glyphs
};
@@ -36,35 +36,32 @@ font::load(void const *data)
}
}
uint8_t const *font_data = static_cast<uint8_t const *>(data) + psf2->header_size;
return font{
psf2->height,
psf2->width,
psf2->length,
font_data};
uint8_t const *font_data = static_cast<uint8_t const *>(data) + psf2->header_size;
return font{
psf2->height,
psf2->width,
psf2->length,
font_data};
}
font::font() :
m_height(0),
m_width(0),
m_count(0),
m_data(nullptr)
m_count(0),
m_data(nullptr)
{}
font::font(unsigned height, unsigned width, unsigned count, uint8_t const *data) :
m_height(height),
m_width(width),
m_count(count),
m_data(data)
m_size(width, height),
m_count(count),
m_data(data)
{}
void
font::draw_glyph(
screen &s,
uint32_t glyph,
screen::pixel_t color,
screen::coord_t x,
screen::coord_t y) const
screen &s,
uint32_t glyph,
screen::pixel_t color,
unsigned x,
unsigned y) const
{
unsigned bwidth = (m_width+7)/8;
uint8_t const *data = m_data + (glyph * glyph_bytes());

View File

@@ -6,28 +6,28 @@
class font
{
public:
static font load(void const *data);
static font load(void const *data);
unsigned glyph_bytes() const { return m_height * ((m_width + 7) / 8); }
unsigned count() const { return m_count; }
unsigned width() const { return m_width; }
unsigned height() const { return m_height; }
bool valid() const { return m_count > 0; }
unsigned glyph_bytes() const { return m_height * ((m_width + 7) / 8); }
unsigned count() const { return m_count; }
unsigned width() const { return m_width; }
unsigned height() const { return m_height; }
bool valid() const { return m_count > 0; }
void draw_glyph(
screen &s,
uint32_t glyph,
screen::pixel_t color,
screen::coord_t x,
screen::coord_t y) const;
void draw_glyph(
screen &s,
uint32_t glyph,
screen::pixel_t color,
unsigned x,
unsigned y) const;
private:
font();
font(unsigned height, unsigned width, unsigned count, uint8_t const *data);
font();
font(unsigned height, unsigned width, unsigned count, uint8_t const *data);
unsigned m_height;
unsigned m_width;
unsigned m_count;
uint8_t const *m_data;
unsigned m_height;
unsigned m_width;
unsigned m_count;
uint8_t const *m_data;
};

View File

@@ -6,8 +6,8 @@
#include "screen.h"
extern "C" {
void do_the_set_registers(popcorn_data *header);
void kernel_main(popcorn_data *header);
void do_the_set_registers(popcorn_data *header);
void kernel_main(popcorn_data *header);
}
void

View File

@@ -4,12 +4,12 @@ screen::color_masks::color_masks(pixel_t r, pixel_t g, pixel_t b) : r(r), g(g),
screen::resolution::resolution(coord_t w, coord_t h) : w(w), h(h) {}
screen::screen(
void *framebuffer,
coord_t hres, coord_t vres,
pixel_t rmask, pixel_t gmask, pixel_t bmask) :
m_framebuffer(static_cast<pixel_t *>(framebuffer)),
m_masks(rmask, gmask, bmask),
m_resolution(hres, vres)
void *framebuffer,
coord_t hres, coord_t vres,
pixel_t rmask, pixel_t gmask, pixel_t bmask) :
m_framebuffer(static_cast<pixel_t *>(framebuffer)),
m_masks(rmask, gmask, bmask),
m_resolution(hres, vres)
{
}

View File

@@ -5,24 +5,25 @@
class screen
{
public:
using coord_t = uint32_t;
using pixel_t = uint32_t;
using coord_t = uint32_t;
using pixel_t = uint32_t;
screen(
void *framebuffer,
coord_t hres, coord_t vres,
pixel_t rmask, pixel_t gmask, pixel_t bmask);
screen(
void *framebuffer,
coord_t hres, coord_t vres,
pixel_t rmask, pixel_t gmask, pixel_t bmask);
void fill(pixel_t color);
void draw_pixel(coord_t x, coord_t y, pixel_t color);
screen() = delete;
screen(const screen &) = delete;
void fill(pixel_t color);
void draw_pixel(unsigned x, unsigned y, pixel_t color);
struct color_masks {
pixel_t r, g, b;
color_masks(pixel_t r, pixel_t g, pixel_t b);
};
screen() = delete;
screen(const screen &) = delete;
struct resolution {
coord_t w, h;