Reintroduce const correctness

This commit is contained in:
2025-06-09 11:32:59 +02:00
parent 6a05210aa1
commit 1b6007c323
3 changed files with 6 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ namespace Hall
/// <param name="width">The width of the excerpt</param>
/// <param name="height">The height of the excerpt</param>
/// <param name="dataWidth">The width of the image (NOT EXCERPT)</param>
void Draw(unsigned short* data, unsigned short xOffset, unsigned short yOffset, unsigned short screenX, unsigned short screenY, unsigned short width, unsigned short height, unsigned short dataWidth);
void Draw(const unsigned short* data, unsigned short xOffset, unsigned short yOffset, unsigned short screenX, unsigned short screenY, unsigned short width, unsigned short height, unsigned short dataWidth);
/// <summary>
/// Clears the whole screen with the given color
@@ -24,7 +24,7 @@ namespace Hall
/// <param name="color">The format is R5G5B5A1, with the alpha bit being lsb</param>
void Clear(unsigned short color);
void SetData(unsigned short* data);
void SetData(const unsigned short* data);
void SetXOffset(unsigned short xOffset);
void SetYOffset(unsigned short yOffset);
void SetImageWidth(unsigned short imageWidth);

View File

@@ -1,7 +1,7 @@
#include <Hall/Video.h>
volatile char* GPU_START = (char*)0x02000000;
volatile unsigned short** GPU_IMAGE_START = (volatile unsigned short**)(GPU_START + 0);
volatile unsigned short const** GPU_IMAGE_START = (volatile unsigned short const**)(GPU_START + 0);
volatile unsigned short* GPU_IMAGE_X_OFFSET = (volatile unsigned short*)(GPU_START + 4);
volatile unsigned short* GPU_IMAGE_Y_OFFSET = (volatile unsigned short*)(GPU_START + 8);
volatile unsigned short* GPU_IMAGE_WIDTH = (volatile unsigned short*)(GPU_START + 12);
@@ -19,7 +19,7 @@ volatile bool* GPU_COMMAND_SWAP_BUFFERS = (volatile bool*)(GPU_START + 56);
volatile bool* VSYNC_BUFFER_SWAP = (volatile bool*)(GPU_START + 60);
void Hall::Draw(unsigned short* data, unsigned short xOffset, unsigned short yOffset, unsigned short screenX, unsigned short screenY, unsigned short width, unsigned short height, unsigned short dataWidth)
void Hall::Draw(const unsigned short* data, unsigned short xOffset, unsigned short yOffset, unsigned short screenX, unsigned short screenY, unsigned short width, unsigned short height, unsigned short dataWidth)
{
*GPU_IMAGE_START = data;
*GPU_IMAGE_X_OFFSET = xOffset;
@@ -39,7 +39,7 @@ void Hall::Clear(unsigned short color)
*GPU_COMMAND_CLEAR = true;
}
void Hall::SetData(unsigned short* data)
void Hall::SetData(const unsigned short* data)
{
*GPU_IMAGE_START = data;
}

View File

@@ -28,8 +28,7 @@ void RenderModule::RenderSprites(entt::registry& registry)
uint8_t column = sprite.texture_atlas_index % layout.columns;
// Problemchen: Wir können die Sprites nicht strecken... hat keiner Interpolation
// implementiert?
Hall::Draw(reinterpret_cast<unsigned short*>(
const_cast<uint8_t*>(sprite.texture->data)), // Das ist 100% UB
Hall::Draw(reinterpret_cast<unsigned short const*>(sprite.texture->data), // Das ist 100% UB
column * layout.width,
row * layout.height,
pos.x,