diff --git a/MkGCC,fd7 b/MkGCC,fd7 new file mode 100644 index 0000000..324d3e6 --- /dev/null +++ b/MkGCC,fd7 @@ -0,0 +1,38 @@ +| Generic Library builder for GCC on RISC OS +| by Paolo Fabio Zaino + +echo ++++++++++++++++++++++++ +echo ++ Building using GCC ++ +echo ++++++++++++++++++++++++ + +Set Build$Root + +WimpSlot -min 28672K + +echo --------------------- +echo Building the Library: +echo --------------------- + +Dir .src +IfThere @.UltimaVM.o.* Then wipe @.UltimaVM.o.* ~C ~V +make all THROWBACK=-throwback OS=RISC_OS -f MakeFileGCC + +|IFthere @.o.ezinilib Then copy @.o.libezini @.^.!LibEzINI.a.libezini ~C N +|IFthere @.h.ezini Then copy @.h.ezini @.^.!LibEzINI.h.ezini ~C N + +echo +echo --------------------- +echo + +echo --------------------- +echo Building Tests: +echo --------------------- + +Dir .tests +make all THROWBACK=-throwback -f MakeFileGCC + +echo +echo --------------------- +echo + +Dir diff --git a/MkGCCClean,fd7 b/MkGCCClean,fd7 new file mode 100644 index 0000000..8e3a731 --- /dev/null +++ b/MkGCCClean,fd7 @@ -0,0 +1,6 @@ +Dir .src +WimpSlot -min 16384K +make clean -f MakeFileGCC + + + diff --git a/src/MakefileGCC b/src/MakefileGCC new file mode 100644 index 0000000..35400c8 --- /dev/null +++ b/src/MakefileGCC @@ -0,0 +1,64 @@ +# MicroFB - A simple Framebuffer library for RISC OS +# (c) 2024 by Paolo Fabio Zaino, all rights reserved +# Licensed under the CDDL v1.1 License + +CC = g++ +PTHREAD = -pthread +EXT_SYM = . +CFLAGS_BASE = -Wall -Wextra -pedantic -std=gnu++11 -O2 +LDFLAGS_EXTRA = +extras = +server = +client = + +LIB_NAME = MicroFB +LIB_SOURCES = fb.cpp layer.cpp render_strategy.cpp +LIB_OBJECTS = $(LIB_SOURCES:.cpp=.o) +LIB_OUT = lib$(LIB_NAME)$(EXT_SYM)a +LIB_LINK = -L./ -l$(LIB_NAME) + +ifeq ($(OS), RISC_OS) + CC = g++ +# PTHREAD = -lpthread + PTHREAD = + EXT_SYM =. + CFLAGS_BASE = -Wall -Wextra -pedantic -std=gnu++11 + LDFLAGS_EXTRA = -lgcc -lstdlib_extras + #extras = stdlib_extras + LIB_LINK = -l$(LIB_NAME) +endif +ifeq ($(OS), Darwin) + CC = /opt/homebrew/bin/g++-13 + PTHREAD = -pthread + LIB_LINK = $(LIB_OUT) +endif + +CFLAGS = $(CFLAGS_BASE) $(PTHREAD) + + +all: $(LIB_OUT) $(server) $(client) + +# Pre-GCC 4.8.1 compatibility +stdlib_extras: stdlib_extras.cpp + $(CC) $(CFLAGS) -o stdlib_extras.o -c stdlib_extras.cpp + ar rcs libstdlib_extras.a stdlib_extras.o + +# Library compilation +$(LIB_OUT): $(LIB_OBJECTS) + ar rcs $(LIB_OUT) $(LIB_OBJECTS) + +$(LIB_OBJECTS): $(LIB_SOURCES) + $(CC) $(CFLAGS) -c $(LIB_SOURCES) + +# Server executable +#$(server): Server.cpp $(LIB_OUT) $(extras) +# $(CC) $(CFLAGS) -o $(server) Server.cpp $(LIB_LINK) $(LDFLAGS_EXTRA) + +# Client executable +#$(client): Client.cpp $(LIB_OUT) $(extras) +# $(CC) $(CFLAGS) -o $(client) Client.cpp $(LIB_LINK) $(LDFLAGS_EXTRA) + +.PHONY: clean + +clean: + rm -f $(LIB_OBJECTS) $(LIB_OUT) $(server) $(client) diff --git a/src/MkGCC.sh b/src/MkGCC.sh old mode 100644 new mode 100755 index 2d0c924..060b272 --- a/src/MkGCC.sh +++ b/src/MkGCC.sh @@ -3,13 +3,13 @@ # This is a special file that will be used to control automated code # analysis tools such as SonarQube, Coverity, etc. on GitHub. # This file is not meant to be executed by humans, but by automated -# tools. +# tools. # If you want to build the project, please use the MkGCC (note no .sh) # script instead or MkDDE on RISC OS. -# MAKE SURE this file is calling your MakefileGCC with the correct +# MAKE SURE this file is calling your MakefileGCC with the correct # target and make sure your MakefileGCC uses the variable OS to -# determine the target OS. +# determine the target OS. current_dir="$1" if [ "$current_dir" == "" ]; then @@ -21,4 +21,4 @@ cd ${current_dir} cat ${current_dir}/MakeFileGCC # Make the artifacts -make static OS=`uname -s` -f ${current_dir}/MakefileGCC +make all OS=`uname -s` -f ${current_dir}/MakefileGCC diff --git a/src/cpp/fb b/src/cpp/fb index c5d9c89..8207609 100644 --- a/src/cpp/fb +++ b/src/cpp/fb @@ -1,35 +1,54 @@ /* - * This file is part of: + * This file is part of: * MicroFB, a minimal framebuffer library for RISC OS * - * Description: + * Description: * This project aims to provide a simple and efficient way to manage - * the framebuffer on RISC OS using C++11. It abstracts the direct - * interaction with the GraphicsV API, offering a higher-level + * the framebuffer on RISC OS using C++11. It abstracts the direct + * interaction with the GraphicsV API, offering a higher-level * interface for drawing operations and framebuffer manipulation. * * Author: * Paolo Fabio Zaino, all rights reserved. - * Distributed under License: - * CDDL v1.1 (Common Development and Distribution License Version - * 1.1) The use of this project is subject to the terms of the - * CDDL v1.1. This project can be used and distributed according - * to the terms of this license. For details on the CDDL v1.1, + * Distributed under License: + * CDDL v1.1 (Common Development and Distribution License Version + * 1.1) The use of this project is subject to the terms of the + * CDDL v1.1. This project can be used and distributed according + * to the terms of this license. For details on the CDDL v1.1, * please refer to the official license documentation. */ -#include "fb.hpp" -#include "layer.hpp" +#include +#include // For std::shared_ptr + +// Include MicroFB libraries +#include "common.h" +#if GCC_VERSION < 50000 +// Include my own C++ STDLib extras for compatibility with older GCC versions +//#include "stdlib_extras.h" +#endif +#include "fb.h" +#include "layer.h" // Constructor -FrameBuffer::FrameBuffer(unsigned int width, unsigned int height, std::shared_ptr strategy) - : width(width), height(height), renderStrategy(strategy) {} +FrameBuffer::FrameBuffer(unsigned int h_dim, unsigned int v_dim, std::shared_ptr strategy) + : renderStrategy(strategy), width(h_dim), height(v_dim) {} // Add a layer to the framebuffer -void FrameBuffer::addLayer(const Layer& layer) { +void FrameBuffer::addLayer(const std::shared_ptr& layer) { layers.push_back(layer); } +// Add a layer to the framebuffer +void FrameBuffer::addLayer(std::shared_ptr&& layer) { + layers.push_back(std::move(layer)); +} + +// Add a layer to the framebuffer +void FrameBuffer::addLayer() { + layers.push_back(std::make_shared(width, height, renderStrategy, currentMemoryManager)); +} + // Remove a layer from the framebuffer by index void FrameBuffer::removeLayer(size_t index) { if (index < layers.size()) { @@ -38,7 +57,7 @@ void FrameBuffer::removeLayer(size_t index) { } // Accessor for layer by index -Layer& FrameBuffer::getLayer(size_t index) { +std::shared_ptr FrameBuffer::getLayer(size_t index) const { // Simple bounds checking, throw std::out_of_range if index is invalid if (index >= layers.size()) { throw std::out_of_range("Layer index is out of range."); @@ -51,7 +70,16 @@ void FrameBuffer::setRenderStrategy(std::shared_ptr strategy) { renderStrategy = strategy; // Update the render strategy for all existing layers for (auto& layer : layers) { - layer.setRenderStrategy(renderStrategy); + layer->setRenderStrategy(renderStrategy); + } +} + +// Set the memory manager for the framebuffer and all its layers +void FrameBuffer::setMemoryManager(std::shared_ptr manager) { + currentMemoryManager = manager; + // Update the memory manager for all existing layers + for (auto& layer : layers) { + layer->setMemoryManager(currentMemoryManager); } } diff --git a/src/cpp/layer b/src/cpp/layer index 01f3c03..7a2a4a1 100644 --- a/src/cpp/layer +++ b/src/cpp/layer @@ -1,35 +1,45 @@ /* - * This file is part of: + * This file is part of: * MicroFB, a minimal framebuffer library for RISC OS * - * Description: + * Description: * This project aims to provide a simple and efficient way to manage - * the framebuffer on RISC OS using C++11. It abstracts the direct - * interaction with the GraphicsV API, offering a higher-level + * the framebuffer on RISC OS using C++11. It abstracts the direct + * interaction with the GraphicsV API, offering a higher-level * interface for drawing operations and framebuffer manipulation. * * Author: * Paolo Fabio Zaino, all rights reserved. - * Distributed under License: - * CDDL v1.1 (Common Development and Distribution License Version - * 1.1) The use of this project is subject to the terms of the - * CDDL v1.1. This project can be used and distributed according - * to the terms of this license. For details on the CDDL v1.1, + * Distributed under License: + * CDDL v1.1 (Common Development and Distribution License Version + * 1.1) The use of this project is subject to the terms of the + * CDDL v1.1. This project can be used and distributed according + * to the terms of this license. For details on the CDDL v1.1, * please refer to the official license documentation. */ #include // For std::shared_ptr -#include "mem_manager.hpp" -#include "layer.hpp" +// Include MicroFB libraries +#include "common.h" +#if GCC_VERSION < 50000 +// Include my own C++ STDLib extras for compatibility with older GCC versions +//#include "stdlib_extras.h" +#endif +#include "mem_manager.h" +#include "layer.h" // Constructor implementation -Layer::Layer(pixel_t width, pixel_t height, std::shared_ptr strategy) - : width(width), height(height), opacity(1.0f), visible(true), currentRenderStrategy(strategy) { - +Layer::Layer(pixel_t width, pixel_t height, std::shared_ptr strategy, std::shared_ptr currMemoryManager) + : currentRenderStrategy(strategy), opacity(1.0f), visible(true), width(width), height(height) { + + if (currentMemoryManager == nullptr) { + currentMemoryManager = currMemoryManager; + } + // Initialize pixel buffer with default color (0) - pixels = static_cast(memoryManager->allocate(width * height * sizeof(color_t))); - + pixels = static_cast(currentMemoryManager->allocate(width * height * sizeof(color_t))); + } // Destructor implementation @@ -37,67 +47,77 @@ Layer::~Layer() { // Not much for now } +// Set the render strategy +void Layer::setRenderStrategy(std::shared_ptr strategy) { + currentRenderStrategy = strategy; // Set the render strategy +} + +// Set the memory manager +void Layer::setMemoryManager(std::shared_ptr manager) { + currentMemoryManager = manager; // Set the memory manager +} + // Clear the layer with a specific color void Layer::clear(color_t color) { - currentRenderStrategy->clear(pixels, color); // Use the render strategy to clear the layer + currentRenderStrategy->clear(*this, color); // Use the render strategy to clear the layer } // Direct pixel manipulation void Layer::setPixel(pixel_t x, pixel_t y, color_t color) { - currentRenderStrategy->setPixel(pixels, x, y, color); // Use the render strategy to set the pixel + currentRenderStrategy->setPixel(*this, x, y, color); // Use the render strategy to set the pixel } // Draw a line void Layer::drawLine(pixel_t x1, pixel_t y1, pixel_t x2, pixel_t y2, color_t color) { - currentRenderStrategy->drawLine(pixels, x1, y1, x2, y2, color); // Use the render strategy to draw the line + currentRenderStrategy->drawLine(*this, x1, y1, x2, y2, color); // Use the render strategy to draw the line } // Draw a rectangle void Layer::drawRect(pixel_t x, pixel_t y, pixel_t w, pixel_t h, color_t color) { - currentRenderStrategy->drawRect(pixels, x, y, w, h, color); // Use the render strategy to draw the rectangle + currentRenderStrategy->drawRect(*this, x, y, w, h, color); // Use the render strategy to draw the rectangle } // Fill a rectangle void Layer::fillRect(pixel_t x, pixel_t y, pixel_t w, pixel_t h, color_t color) { - currentRenderStrategy->fillRect(pixels, x, y, w, h, color); // Use the render strategy to fill the rectangle + currentRenderStrategy->fillRect(*this, x, y, w, h, color); // Use the render strategy to fill the rectangle } -// Draw a circle +// Draw a circle void Layer::drawCircle(pixel_t x, pixel_t y, pixel_t r, color_t color) { - currentRenderStrategy->drawCircle(pixels, x, y, r, color); // Use the render strategy to draw the circle + currentRenderStrategy->drawCircle(*this, x, y, r, color); // Use the render strategy to draw the circle } -// Fill a circle +// Fill a circle void Layer::fillCircle(pixel_t x, pixel_t y, pixel_t r, color_t color) { - currentRenderStrategy->fillCircle(pixels, x, y, r, color); // Use the render strategy to fill the circle + currentRenderStrategy->fillCircle(*this, x, y, r, color); // Use the render strategy to fill the circle } -// Draw an ellipse +// Draw an ellipse void Layer::drawEllipse(pixel_t x, pixel_t y, pixel_t rx, pixel_t ry, color_t color) { - currentRenderStrategy->drawEllipse(pixels, x, y, rx, ry, color); // Use the render strategy to draw the ellipse + currentRenderStrategy->drawEllipse(*this, x, y, rx, ry, color); // Use the render strategy to draw the ellipse } -// Fill an ellipse +// Fill an ellipse void Layer::fillEllipse(pixel_t x, pixel_t y, pixel_t rx, pixel_t ry, color_t color) { - currentRenderStrategy->fillEllipse(pixels, x, y, rx, ry, color); // Use the render strategy to fill the ellipse + currentRenderStrategy->fillEllipse(*this, x, y, rx, ry, color); // Use the render strategy to fill the ellipse } -// Draw a polygon +// Draw a polygon void Layer::drawPolygon(const std::vector& points, color_t color) { - currentRenderStrategy->drawPolygon(pixels, points, color); // Use the render strategy to draw the polygon + currentRenderStrategy->drawPolygon(*this, points, color); // Use the render strategy to draw the polygon } -// Fill a polygon +// Fill a polygon void Layer::fillPolygon(const std::vector& points, color_t color) { - currentRenderStrategy->fillPolygon(pixels, points, color); // Use the render strategy to fill the polygon + currentRenderStrategy->fillPolygon(*this, points, color); // Use the render strategy to fill the polygon } -// Draw text +// Draw text void Layer::drawText(pixel_t x, pixel_t y, const char* text, color_t color) { - currentRenderStrategy->drawText(pixels, x, y, text, color); // Use the render strategy to draw the text + currentRenderStrategy->drawText(*this, x, y, text, color); // Use the render strategy to draw the text } -// Draw an image +// Draw an image void Layer::drawImage(pixel_t x, pixel_t y, const Layer& image) { - currentRenderStrategy->drawImage(pixels, x, y, image); // Use the render strategy to draw the image + currentRenderStrategy->drawImage(*this, x, y, image); // Use the render strategy to draw the image } diff --git a/src/h/common b/src/h/common new file mode 100644 index 0000000..6d208ec --- /dev/null +++ b/src/h/common @@ -0,0 +1,280 @@ +/* + * This file is part of the QuantumPi(e) project. + * + * QuantumPi(e): Quantum Register Library for Raspberry Pi + * Clusters + * + * Description: + * QuantumPi(e) is a C++ library designed to integrate + * quantum operations into traditional software by + * simulating quantum computing on Raspberry Pi clusters, + * particularly in configurations like Turing Pi 2 clusters. + * It provides quantum register manipulation functionalities + * along with server and client libraries for distributed + * quantum computing tasks. The library is optimized for + * RISC OS, Linux, and BSD environments. + * + * Author: Paolo Fabio Zaino + * Copyright (c) 2021 Paolo Fabio Zaino, all rights reserved + * Distribution License: CDDL v1.1 + * + * Repository: github.com/pzaino/QuantumPi-e- + * + * QuantumPi(e) is built for ease of integration into + * existing software systems, enabling developers to + * harness the power of quantum computing on Raspberry Pi + * clusters. It offers a flexible and efficient solution for + * quantum register manipulation and distributed quantum + * computing tasks. This library is intended for educational + * purposes, research,and potential commercial applications. + * Contributions and feedback are welcome to enhance its + * functionality and performance. + */ + +#ifndef COMMON_H +#define COMMON_H + +// Check the OS: +#define OS_RISCOS 0 +#define OS_WINDOWS 1 +#define OS_OS2 2 +#define OS_LINUX 3 +#define OS_BSD 4 +#define OS_MACOS 5 +#define OS_SOLARIS 6 +#define OS_HPUX 7 +#define OS_HAIKU 8 +#define OS_BEOS 9 +#define OS_QNX 10 +#define OS_TRU64 11 +#define OS_UNIX 12 +#define OS_AIX 13 +#define OS_AMIGAOS 14 +#define OS_MORPHOS 15 +#define OS_SYLLABLE 16 +#define OS_VMS 17 + +#if defined(__riscos) || defined(__riscos__) || defined(RISC_OS) + // RISC OS is OS 0 + #define OS OS_RISCOS + #define OS_TYPE 0 +#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) + // Windows is OS 1 + #define OS OS_WINDOWS + #define OS_TYPE 2 +#elif defined(__os2__) || defined(__OS2__) || defined(OS2) || defined(_OS2) + // OS/2 is OS 2 + #define OS OS_OS2 + #define OS_TYPE 1 +#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) + // Linux is OS 3 + #define OS OS_LINUX + #define OS_TYPE 1 +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) + // BSD is OS 4 + #define OS OS_BSD + #define OS_TYE 1 +#elif defined(__APPLE__) || defined(__MACH__) + // Mac OS is OS 5 + #define OS OS_MACOS + #define OS_TYPE 1 +#elif defined(__sun) || defined(sun) || defined(__sun__) + // Solaris is OS 6 + #define OS OS_SOLARIS + #define OS_TYPE 1 +#elif defined(__hpux) || defined(__hpux__) + // HP-UX is OS 7 + #define OS OS_HPUX + #define OS_TYPE 1 +#elif defined(__HAIKU__) || defined(__HAIKU) + // Haiku is OS 8 + #define OS OS_HAIKU + #define OS_TYPE 1 +#elif defined(__BEOS__) || defined(__beos__) + // BeOS is OS 9 + #define OS OS_BEOS + #define OS_TYPE 1 +#elif defined(__QNX__) || defined(__QNXNTO__) + // QNX is OS 10 + #define OS OS_QNX + #define OS_TYPE 1 +#elif defined(__tru64__) || defined(_SYSTYPE_OSF1) + // Tru64 UNIX is OS 11 + #define OS OS_TRU64 + #define OS_TYPE 1 +#elif defined(__unix__) || defined(__unix) || defined(unix) || defined(__UNIX__) + // UNIX is OS 12 + #define OS OS_UNIX + #define OS_TYPE 1 +#elif defined(_AIX) || defined(__TOS_AIX__) || defined(__aix__) || defined(__aix) + // AIX is OS 13 + #define OS OS_AIX + #define OS_TYPE 1 +#elif defined(__amigaos__) || defined(__amigaos) + // AmigaOS is OS 14 + #define OS OS_AMIGAOS + #define OS_TYPE 1 +#elif defined(__MORPHOS__) || defined(__morphos__) + // MorphOS is OS 15 + #define OS OS_MORPHOS + #define OS_TYPE 1 +#elif defined(__SYLLABLE__) || defined(__SYLLABLE) + // Syllable is OS 16 + #define OS OS_SYLLABLE + #define OS_TYPE 1 +#elif defined(__VMS) || defined(VMS) || defined(__VMS_VER) + // OpenVMS is OS 17 + #define OS OS_VMS + #define OS_TYPE 1 +#else + // Unknown OS + #define OS -1 + #define OS_TYPE -1 +#endif + +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(__arm) + // ARM architecture + #define ARCH 0 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__aarch64__) || defined(__arm64__) || defined(__ARM64__) || defined(__ARM_ARCH_8A__) + // ARM 64 bit architecture + #define ARCH 1 + #define ARCH_BITS 64 + #define ARCH_TYPE 0 +#elif defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__386) + // x86 architecture + #define ARCH 2 + #define ARCH_BITS 32 + #define ARCH_TYPE 1 +#elif defined(__x86_64__) || defined(_M_X64) + // x86 64 bit architecture + #define ARCH 3 + #define ARCH_BITS 64 + #define ARCH_TYPE 1 +#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) + // MIPS architecture + #define ARCH 4 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__PPC__) || defined(__power__) + // PowerPC 32 architecture + #define ARCH 5 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) + // PowerPC 64 architecture + #define ARCH 5 + #define ARCH_BITS 64 + #define ARCH_TYPE 0 +#elif defined(__sparc__) || defined(__sparc) + // SPARC architecture + #define ARCH 6 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__hppa__) || defined(__HPPA__) + // HP PA-RISC architecture + #define ARCH 7 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__s390__) || defined(__s390x__) + // IBM S/390 architecture + #define ARCH 8 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__alpha__) || defined(__alpha) + // DEC Alpha architecture + #define ARCH 9 + #define ARCH_BITS 64 + #define ARCH_TYPE 0 +#elif defined(__ia64__) || defined(_IA64) || defined(__IA64__) || defined(__ia64) || defined(_M_IA64) || defined(__itanium__) + // Intel Itanium architecture + #define ARCH 10 + #define ARCH_BITS 64 + #define ARCH_TYPE 0 +#elif defined(__m68k__) || defined(M68000) + // Motorola 68000 architecture + #define ARCH 11 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__sh__) || defined(__sh) || defined(SHx) + // SuperH 32 architecture + #define ARCH 12 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__sh64__) || defined(__sh64) || defined(SHx64) + // SuperH 64 architecture + #define ARCH 12 + #define ARCH_BITS 64 + #define ARCH_TYPE 0 +#elif defined(__m32r__) || defined(__m32rx__) + // Renesas M32R architecture + #define ARCH 13 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__arc__) || defined(__arc) + // ARC architecture + #define ARCH 14 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__nds32__) || defined(__NDS32__) + // Andes NDS32 architecture + #define ARCH 15 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#elif defined(__riscv64) || defined(__riscv64__) + // RISC-V 64 bit architecture + #define ARCH 17 + #define ARCH_BITS 64 + #define ARCH_TYPE 0 +#elif defined(__riscv) || defined(__riscv__) + // RISC-V architecture + #define ARCH 16 + #define ARCH_BITS 32 + #define ARCH_TYPE 0 +#else + // Unknown architecture + #define ARCH -1 + #define ARCH_BITS 32 + #define ARCH_TYPE 1 +#endif + +#define CLANG 0 +#define GCC 1 +#define NORCROFT 2 +#define MSVC 3 + +#if defined(__clang__) || defined(__clang) + // Clang compiler + #define COMPILER CLANG + #define COMPILER_TYPE 0 + #define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) +#define GCC_VERSION (CLANG_VERSION) +#elif defined(__GNUC__) || defined(__GNUC) + // GCC compiler + #define COMPILER GCC + #define COMPILER_TYPE 0 + #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#elif defined(__CC_NORCROFT) || defined(__CC_NORCROFT__) + // Norcroft compiler + #define COMPILER NORCROFT + #define COMPILER_TYPE 0 +#elif defined(_MSC_VER) || defined(_MSC_VER_) + // MSVC compiler + #define COMPILER MSVC + #define COMPILER_TYPE 1 +#else + // Unknown compiler + #define COMPILER -1 + #define COMPILER_TYPE -1 +#endif +#ifndef GCC_VERSION +#define GCC_VERSION 1000000000 +#endif + + + + + +#endif // COMMON_H +// src/h/common diff --git a/src/h/fb b/src/h/fb new file mode 100644 index 0000000..a7fa2fd --- /dev/null +++ b/src/h/fb @@ -0,0 +1,64 @@ +/* + * This file is part of: + * MicroFB, a minimal framebuffer library for RISC OS + * + * Description: + * This project aims to provide a simple and efficient way to manage + * the framebuffer on RISC OS using C++11. It abstracts the direct + * interaction with the GraphicsV API, offering a higher-level + * interface for drawing operations and framebuffer manipulation. + * + * Author: + * Paolo Fabio Zaino, all rights reserved. + * Distributed under License: + * CDDL v1.1 (Common Development and Distribution License Version + * 1.1) The use of this project is subject to the terms of the + * CDDL v1.1. This project can be used and distributed according + * to the terms of this license. For details on the CDDL v1.1, + * please refer to the official license documentation. + */ + +#ifndef FB_HPP +#define FB_HPP + +#include +#include // For std::shared_ptr + +// Include MicroFB libraries +#include "common.h" +#if GCC_VERSION < 50000 +// Include my own C++ STDLib extras for compatibility with older GCC versions +//#include "stdlib_extras.h" +#endif +#include "layer.h" +#include "render_strategy.h" +#include "mem_manager.h" + +class FrameBuffer { + private: + std::shared_ptr currentMemoryManager; + std::vector> layers; // Use shared pointers for layers + std::shared_ptr renderStrategy; // Shared rendering strategy + unsigned int width; // Horizontal dimension of the framebuffer + unsigned int height; // Vertical dimension of the framebuffer + + public: + // Constructor + FrameBuffer(unsigned int h_dim, unsigned int v_dim, std::shared_ptr strategy); + + // Methods for managing layers using shared_ptr + void addLayer(const std::shared_ptr& layer); + void addLayer(std::shared_ptr&& layer); + void addLayer(); + + void removeLayer(size_t index); + + std::shared_ptr getLayer(size_t index) const; // Return type changed to shared_ptr + + void setRenderStrategy(std::shared_ptr strategy); + void setMemoryManager(std::shared_ptr manager); + + void mergeLayers(); // Placeholder for actual implementation +}; + +#endif // FB_HPP diff --git a/src/hpp/layer b/src/h/layer similarity index 78% rename from src/hpp/layer rename to src/h/layer index f5c3e43..8971b4d 100644 --- a/src/hpp/layer +++ b/src/h/layer @@ -1,20 +1,20 @@ /* - * This file is part of: + * This file is part of: * MicroFB, a minimal framebuffer library for RISC OS * - * Description: + * Description: * This project aims to provide a simple and efficient way to manage - * the framebuffer on RISC OS using C++11. It abstracts the direct - * interaction with the GraphicsV API, offering a higher-level + * the framebuffer on RISC OS using C++11. It abstracts the direct + * interaction with the GraphicsV API, offering a higher-level * interface for drawing operations and framebuffer manipulation. * * Author: * Paolo Fabio Zaino, all rights reserved. - * Distributed under License: - * CDDL v1.1 (Common Development and Distribution License Version - * 1.1) The use of this project is subject to the terms of the - * CDDL v1.1. This project can be used and distributed according - * to the terms of this license. For details on the CDDL v1.1, + * Distributed under License: + * CDDL v1.1 (Common Development and Distribution License Version + * 1.1) The use of this project is subject to the terms of the + * CDDL v1.1. This project can be used and distributed according + * to the terms of this license. For details on the CDDL v1.1, * please refer to the official license documentation. */ @@ -25,14 +25,21 @@ #include #include // For std::shared_ptr -#include "mem_manager.hpp" -#include "render_strategy.hpp" +// Include MicroFB libraries +#include "common.h" +#if GCC_VERSION < 50000 +// Include my own C++ STDLib extras for compatibility with older GCC versions +//#include "stdlib_extras.h" +#endif +#include "mem_manager.h" +#include "render_strategy.h" typedef uint32_t color_t; // 32-bit color typedef uint32_t pixel_t; // 32-bit pixel, assuming it represents dimensions class Layer { private: + std::shared_ptr currentMemoryManager; std::shared_ptr currentRenderStrategy; public: @@ -43,9 +50,14 @@ class Layer { pixel_t height; // vertical dimension of the layer // Constructor and destructor - Layer(pixel_t width, pixel_t height, std::shared_ptr strategy); + Layer(pixel_t width, pixel_t height, + std::shared_ptr strategy, + std::shared_ptr currMemoryManager); ~Layer(); + void setRenderStrategy(std::shared_ptr strategy); + void setMemoryManager(std::shared_ptr manager); + // Drawing operations void clear(color_t color); // Clear the layer with a specific color void setPixel(pixel_t x, pixel_t y, color_t color); // Direct pixel manipulation diff --git a/src/hpp/mem_manager b/src/h/mem_manager similarity index 100% rename from src/hpp/mem_manager rename to src/h/mem_manager diff --git a/src/hpp/render_strategy b/src/h/render_strategy similarity index 100% rename from src/hpp/render_strategy rename to src/h/render_strategy diff --git a/src/hpp/fb b/src/hpp/fb deleted file mode 100644 index ab7979c..0000000 --- a/src/hpp/fb +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of: - * MicroFB, a minimal framebuffer library for RISC OS - * - * Description: - * This project aims to provide a simple and efficient way to manage - * the framebuffer on RISC OS using C++11. It abstracts the direct - * interaction with the GraphicsV API, offering a higher-level - * interface for drawing operations and framebuffer manipulation. - * - * Author: - * Paolo Fabio Zaino, all rights reserved. - * Distributed under License: - * CDDL v1.1 (Common Development and Distribution License Version - * 1.1) The use of this project is subject to the terms of the - * CDDL v1.1. This project can be used and distributed according - * to the terms of this license. For details on the CDDL v1.1, - * please refer to the official license documentation. - */ - -#ifndef FB_HPP -#define FB_HPP - -#include -#include // For std::shared_ptr - -#include "layer.hpp" -#include "render_strategy.hpp" - -class FrameBuffer { - private: - std::vector layers; // Collection of layers - std::shared_ptr renderStrategy; // Shared rendering strategy - unsigned int width, height; // Dimensions of the framebuffer - - public: - // Constructor that initializes the framebuffer with dimensions and a rendering strategy - FrameBuffer(unsigned int width, unsigned int height, std::shared_ptr strategy) - - // Add a layer to the framebuffer - void addLayer(const Layer& layer); - - // Remove a layer from the framebuffer by index - void removeLayer(size_t index); - - // Accessor for layer by index - Layer& getLayer(size_t index); - - // Set the render strategy for the framebuffer and all its layers - void setRenderStrategy(std::shared_ptr strategy); - - // Method to merge all layers - Placeholder for actual implementation - void mergeLayers(); - -}; - -#endif // FB_HPP