From bc28f2819bd0d32a739e4b3aab760ac007eba196 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 29 Oct 2019 15:24:57 +0100 Subject: [PATCH] + init implementation + Color and KeyType constructor + Registers struct --- src/Color.cpp | 8 ++++++++ src/Color.h | 6 +++--- src/KeyCode.cpp | 9 +++++++++ src/KeyCode.h | 16 +++++++--------- src/LayoutVersion.h | 2 +- src/internal.cpp | 5 +++++ src/internal.h | 43 +++++++++++++++++++++++++++++++++++++++++++ src/vkvm.cpp | 6 ++++++ src/vkvm.h | 12 ++++++------ 9 files changed, 88 insertions(+), 19 deletions(-) create mode 100644 src/Color.cpp create mode 100644 src/KeyCode.cpp create mode 100644 src/internal.cpp create mode 100644 src/vkvm.cpp diff --git a/src/Color.cpp b/src/Color.cpp new file mode 100644 index 0000000..3daac50 --- /dev/null +++ b/src/Color.cpp @@ -0,0 +1,8 @@ + +#include "Color.h" + +Color::Color(unsigned char red, unsigned char green, unsigned char blue) + : red(red), green(green), blue(blue){ + +} + diff --git a/src/Color.h b/src/Color.h index 93172d7..3d75e99 100644 --- a/src/Color.h +++ b/src/Color.h @@ -1,8 +1,6 @@ #ifndef LIBRARY_COLOR_H #define LIBRARY_COLOR_H -static const Color black = Color(0, 0, 0); -static const Color white = Color(255, 255, 255); /** * color values represented as rgb values. @@ -17,9 +15,11 @@ private: unsigned char blue; public: - Color(red, green, blue); + Color(unsigned char red, unsigned char green, unsigned char blue); }; +const Color black = Color(0, 0, 0); +const Color white = Color(255, 255, 255); #endif diff --git a/src/KeyCode.cpp b/src/KeyCode.cpp new file mode 100644 index 0000000..6e7e2c7 --- /dev/null +++ b/src/KeyCode.cpp @@ -0,0 +1,9 @@ + +#include "KeyCode.h" + +KeyCode::KeyCode(int value) : value(value) {} + +int KeyCode::getValue() { + return value; +} + diff --git a/src/KeyCode.h b/src/KeyCode.h index cb9d2a5..65ab74d 100644 --- a/src/KeyCode.h +++ b/src/KeyCode.h @@ -1,17 +1,15 @@ #ifndef LIBRARY_KEYCODE_H #define LIBRARY_KEYCODE_H +class KeyCode { +private: + int value; +public: + explicit KeyCode(int value); + int getValue(); +}; const KeyCode Backspace = KeyCode(8); const KeyCode tabulator = KeyCode(9); -class KeyCode { - -private: - KeyCode(int value); -public: - int getValue(); -}; - - #endif diff --git a/src/LayoutVersion.h b/src/LayoutVersion.h index 3d0dd54..ce24e93 100644 --- a/src/LayoutVersion.h +++ b/src/LayoutVersion.h @@ -2,7 +2,7 @@ #define LIBRARY_LAYOUTVERSION_H enum LayoutVersion { - V1 = 1; + V1 = 1 }; #endif diff --git a/src/internal.cpp b/src/internal.cpp new file mode 100644 index 0000000..d9575d2 --- /dev/null +++ b/src/internal.cpp @@ -0,0 +1,5 @@ +#include "internal.h" + +Internal internal; + + diff --git a/src/internal.h b/src/internal.h index e67ce89..65baee5 100644 --- a/src/internal.h +++ b/src/internal.h @@ -4,6 +4,48 @@ #include "EventType.h" #include "KeyCode.h" #include "LayoutVersion.h" +#include "GraphicMode.h" +#include "Color.h" + +/** + * the Control Registers + * @author Julian Hinxlage + * @since 0.1.0 + */ +struct Registers{ + int layout_version; + int trigger_reset; + int width_pixels; + int height_pixels; + GraphicMode graphicMode; + int autoRedrawInterval; + int timerInterruptInterval; + Color background_color; + Color foreground_color; + int characters_per_row; + int characters_per_column; + int textMode_font; + int textMode_font_width; + int textMode_font_height; + int mouse_pos_x; + int mouse_pos_y; + char keyboardBuffer[16]; + int keyboardBuffer_index_w; + int keyboardBuffer_index_r; +}; + +struct InterruptEntry{ + int pid; + int signum; +}; + +/** + * internal values for the library. + */ +struct Internal{ + int sharedMemoryPid; +}; +extern Internal internal; /** * set layout version. @@ -51,4 +93,5 @@ void buttonPressed(KeyCode keyCode); // text area [max_textMode_width * max_textMode_height] // pixel area [max_height_pixels * max_height_pixels * sizeof(uint_32)] + #endif \ No newline at end of file diff --git a/src/vkvm.cpp b/src/vkvm.cpp new file mode 100644 index 0000000..45218e4 --- /dev/null +++ b/src/vkvm.cpp @@ -0,0 +1,6 @@ +#include "vkvm.h" +#include "internal.h" + +void initialize(int pid) { + internal.sharedMemoryPid = pid; +} diff --git a/src/vkvm.h b/src/vkvm.h index 1a6e959..a95731f 100644 --- a/src/vkvm.h +++ b/src/vkvm.h @@ -162,18 +162,18 @@ void setForegroundColor(Color newValue); //text mode -/** - * get characters per line in text mode. - * @return characters per line. - */ -int getCharactersPerLine(); - /** * get characters per row in text mode. * @return characters per row. */ int getCharactersPerRow(); +/** + * get characters per column in text mode. + * @return characters per column. + */ +int getCharactersPerColumn(); + /** * get currently used font in text mode. * @return currently used font.