diff --git a/CMakeLists.txt b/CMakeLists.txt index 58c7064..cd8936a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) project(Tart VERSION 0.1) # CPP -set( CMAKE_CXX_STANDARD 11) -set( CMAKE_CXX_STANDARD_REQUIRED ON) +#set( CMAKE_CXX_STANDARD 11) +#set( CMAKE_CXX_STANDARD_REQUIRED ON) # C set( CMAKE_C_STANDARD 11) set( CMAKE_C_STANDARD_REQUIRED ON) diff --git a/includes/tart.h b/includes/tart.h index 7b70853..a6dac63 100644 --- a/includes/tart.h +++ b/includes/tart.h @@ -1,3 +1,5 @@ +#ifndef TART_H +#define TART_H // #========================================================================# // | PreacherDHM:TART // | @@ -19,15 +21,20 @@ struct tart_vec2 { short x,y; }; +struct tart_rgb { + tart_byte r,g,b; +}; + /* Tart Cell * * This holds a rgb for the foreground and the background. * Includeing the display character. * */ + struct tart_cell { - tart_byte fr,fg,fb; - tart_byte br,bg,bb; + struct tart_rgb foreground; + struct tart_rgb background; tart_byte style; char display; }; @@ -38,44 +45,41 @@ struct tart_cell { * Allso containes the size of the buffer. * * ........................width............... - * ..........<--------------------------------> - * - * ........^ @################################@ - * - * ........| #................................# - * - * ........| #................................# - * - * height--| #..........buffer................# - * - * ........| #................................# - * - * ........| #................................# - * - * ........V @################################@ + * ..........<-------------------------------->. + * ........^ @################################@. + * ........| #................................#. + * ........| #................................#. + * height--| #.............Buffer.............#. + * ........| #................................#. + * ........| #................................#. + * ........V @################################@. */ struct tart_buffer { - int cell_count; + unsigned int cell_count; tart_byte layer; - tart_vec2 size; - tart_vec2 position; tart_id id; - struct cell* cells; + struct tart_vec2 size; + struct tart_vec2 position; + struct tart_cell* cells; }; -struct tart_render_manager { - struct tart_buffer buffers[sizeof(tart_byte)]; +/* Tart Window + * + * The tart window will have the window size and all of the buffers. + **/ +struct tart_window { + struct tart_buffer buffers[0xFF+1]; tart_byte buffer_count; }; -tart_buffer tart_create_buffer(tart_id, struct tart_vec2, struct tart_vect2); -tart_cell tart_create_cell(char, tart_byte, tart_byte, tart_byte, tart_byte, tart_byte, tart_byte); -tart_byte tart_add_buffer(struct tart_render_manager*, struct tart_buffer); -tart_byte tart_set_buffer(struct tart_render_manager*, struct tart_buffer, tart_byte); +struct tart_buffer tart_create_buffer(tart_id, struct tart_vec2, struct tart_vec2); +struct tart_cell tart_create_cell(char, tart_byte, struct tart_rgb, struct tart_rgb); +tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer); +tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte); -tart_buffer& tart_get_buffer(struct tart_render_manager*, tart_byte); - -tart_cell& tart_get_cell(struct tart_buffer*, int); -tart_cell tart_set_cell(struct tart_buffer*, tart_cell,int); +struct tart_buffer* tart_get_buffer(struct tart_window*, tart_byte); +struct tart_cell* tart_get_cell(struct tart_buffer*, int); +struct tart_cell* tart_set_cell(struct tart_buffer*, struct tart_cell*,int); +#endif diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 40ca748..717090a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,6 @@ project(TartLib VERSION 0.1) set(Lib_SOURCES - tart.cpp + tart.c ) -add_library(${PROJECT_NAME} STATIC ${LIB_SOURCES}) +add_library(${PROJECT_NAME} STATIC tart.c) target_include_directories(${PROJECT_NAME} BEFORE PUBLIC "../includes/") diff --git a/source/tart.c b/source/tart.c index e69de29..8732e07 100644 --- a/source/tart.c +++ b/source/tart.c @@ -0,0 +1,42 @@ +#include "tart.h" +#include + +struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) { + int cell_count = position.x * position.y; + struct tart_cell* cells = malloc(sizeof(struct tart_cell[cell_count])); + struct tart_buffer buf = {cell_count,0,id,size,position,0}; + return buf; +} +struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background) { + return (struct tart_cell){foreground, background, style, display}; +} +tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) { + if(window->buffer_count < 0xFF) { + window->buffers[window->buffer_count] = buffer; + window->buffer_count++; + return window->buffer_count; + } + return 0; +} +tart_byte tart_set_buffer(struct tart_window* window, struct tart_buffer buffer, tart_byte layer) { + if(layer <= 0xFF) { + window->buffers[layer] = buffer; + return layer; + } + return 0; +} + +struct tart_buffer* tart_get_buffer(struct tart_window* window, tart_byte layer) { + return &window->buffers[layer]; +} + +struct tart_cell* tart_get_cell(struct tart_buffer* buffer, int idx) { + return &buffer->cells[idx]; +} +struct tart_cell* tart_set_cell(struct tart_buffer* buffer, struct tart_cell* cell,int idx) { + if(buffer->cell_count >= idx) { + buffer->cells[idx] = *cell; + return cell; + } + return 0; +} diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 13c85dc..bd0a588 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -2,7 +2,7 @@ project(TartTest) set( SOURCES main.cpp ) -add_executable(${PROJECT_NAME} ${SOURCES}) -target_include_directory(${PROJECT_NAME} Pickler) +add_executable(${PROJECT_NAME} ${SOURCES} ) +target_link_libraries(${PROJECT_NAME} PickleLib TartLib) add_test(${PROJECT_NAME} "${CMAKE_SOURCE_DIR}/bin/testing.exe") diff --git a/testing/main.cpp b/testing/main.cpp index 055a024..3d95365 100644 --- a/testing/main.cpp +++ b/testing/main.cpp @@ -1,4 +1,6 @@ +#include "test_tart.h" +#include int main (int argc, char *argv[]) { - + INSTALLSHELF; return 0; } diff --git a/testing/test_tart.h b/testing/test_tart.h new file mode 100644 index 0000000..ca1b68f --- /dev/null +++ b/testing/test_tart.h @@ -0,0 +1,2 @@ +#include +#include