minor cleanup

This commit is contained in:
2026-07-25 23:50:05 -07:00
parent 1c2579148e
commit 3acd7de9a7
7 changed files with 1 additions and 155 deletions
-11
View File
@@ -7,17 +7,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
// #include "datatypes.cpp"
// #include "helpers.cpp"
// #include "buffer.cpp"
// #include "surface.cpp"
// #include "primatives/line.cpp"
// #include "primatives/point.cpp"
// #include "primatives/rectangle.cpp"
// #include "primatives/trapezoid.cpp"
// #include "primatives/triangle.cpp"
// #include "Texture.cpp"
#include "uwugl.h" #include "uwugl.h"
#include <time.h> #include <time.h>
#include "font.cpp" #include "font.cpp"
-31
View File
@@ -1,31 +0,0 @@
#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "mapperbase.cpp"
namespace UwU {
class TileMapper : public MapperBase<TileMapper> { // not actually tilemapping yet
public:
TileMapper() {
this->tileMap = new uint16_t[16384]; // the map of tile positions 128x128 8x8 tiles from a 512x512 bitmap space
}
uint16_t* tileMap;
Coord2 map(uint16_t x0, uint16_t y0, uint16_t x, uint16_t y) {
uint16_t u0 = x - x0;
uint16_t v0 = y - y0;
// returns uv coordinates that point to a specific pixel of a specific tile on a tilesheet buffer
uint16_t mapX = (u0 & 0x03f8) >> 3;
uint16_t mapY = (v0 & 0x03f8) << 4;
uint16_t tileIndex = tileMap[mapY + mapX];
uint16_t u = (tileIndex & 0x003f) << 3;
u += (u0 & 0x0007);
uint16_t v = (tileIndex & 0x0fc0) >> 3;
v += (v0 & 0x0007);
return Coord2(u, v);
}
};
}
-24
View File
@@ -1,24 +0,0 @@
#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "shaderbase.cpp"
namespace UwU {
class BufferShader : public ShaderBase<BufferShader> {
public:
BufferShader(Buffer buffer) {
this->buffer = buffer;
}
Buffer buffer;
Color shade(uint16_t x, uint16_t y) {
uint32_t index = (y * buffer.stride) + (x * 4);
Color c = Color(buffer.pixels[index + 2], buffer.pixels[index + 1], buffer.pixels[index], buffer.pixels[index + 3]);
return c;
}
};
}
-24
View File
@@ -1,24 +0,0 @@
#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "shaderbase.cpp"
namespace UwU {
class ColorShader : public ShaderBase<ColorShader> {
public:
ColorShader(Color c) {
this->c = c;
}
Color c;
Color shade(uint16_t x, uint16_t y) {
(void)x;
(void)y;
return c;
}
};
}
-30
View File
@@ -1,30 +0,0 @@
#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "shaderbase.cpp"
namespace UwU {
class HGradientShader : public ShaderBase<HGradientShader> {
public:
HGradientShader(uint16_t u0, uint16_t u1, Color c0, Color c1) {
this->u0 = (uint32_t)u0;
this->uScale = 0xffffffff / (1 + (uint32_t)u1 - (uint32_t)u0);
this->c0 = c0;
this->c1 = c1;
}
uint32_t u0;
uint32_t uScale;
Color c0;
Color c1;
Color shade(uint16_t u, uint16_t v) {
(void)v;
uint32_t t = (((uint32_t)u - u0) * uScale) / 0x01000000;
return Helpers::lerpColor(c0, c1, (uint8_t)t);
}
};
}
+1 -5
View File
@@ -1,5 +1 @@
#include "shaderbase.cpp" #include "shaderbase.cpp"
#include "colorshader.cpp"
#include "hgradientshader.cpp"
#include "vgradientshader.cpp"
#include "buffershader.cpp"
-30
View File
@@ -1,30 +0,0 @@
#pragma once
#include <stdint.h>
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "shaderbase.cpp"
namespace UwU {
class VGradientShader : public ShaderBase<VGradientShader> {
public:
VGradientShader(uint16_t v0, uint16_t v1, Color c0, Color c1) {
this->v0 = (uint32_t)v0;
this->vScale = 0xffffffff / (1 + (uint32_t)v1 - (uint32_t)v0);
this->c0 = c0;
this->c1 = c1;
}
uint32_t v0;
uint32_t vScale;
Color c0;
Color c1;
Color shade(uint16_t u, uint16_t v) {
(void)u;
uint32_t t = (((uint32_t)v - v0) * vScale) / 0x01000000;
return Helpers::lerpColor(c0, c1, (uint8_t)t);
}
};
}