Simple Operating System
graphics.h
Go to the documentation of this file.
1 
8 #ifndef GRAPHICS_H
9 #define GRAPHICS_H
10 
11 #include "types.h"
12 
16 typedef struct Position {
17  Word x;
18  Word y;
20 
21 const size_t SIZE_X = 640;
22 const size_t SIZE_Y = 350;
23 
30 void writePixel(Position pos, Color color) {
31  asm("int 0x10"
32  ::"a"(0x0c00|color), "b"(0), "c"(pos.x), "d"(pos.y));
33 }
34 
43 void draw(Position begin, Color *data, size_t width, size_t height) {
44  //begin is position of first up right corner pixel
45  Position pos;
46  for(size_t y = 0; y < height; y++) {
47  for(size_t x = 0; x < width; x++) {
48  pos.x = x + begin.x;
49  pos.y = y + begin.y;
50  writePixel(pos, data[y * (width) + x]);
51  }
52  }
53 }
54 
55 #endif
void writePixel(Position pos, Color color)
Draw single pixel.
Definition: graphics.h:30
struct Position Position
Position on screen.
void draw(Position begin, Color *data, size_t width, size_t height)
Draw picture from raw pixel table.
Definition: graphics.h:43
Position on screen.
Definition: graphics.h:16
useful macros, definitions, enums etc.