This commit is contained in:
2025-06-11 21:07:07 -05:00
parent 7d8e1051fe
commit ffaef7aa8d
5 changed files with 37 additions and 24 deletions

View File

@ -0,0 +1,19 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
#define RENDER_TILE_COUNT 384
#define RENDER_TILE_WIDTH 8
#define RENDER_TILE_BYTES_PER_ROW 2
#define RENDER_TILE_HEIGHT 8
#define RENDER_TILE_BYTES_PER_TILE (RENDER_TILE_BYTES_PER_ROW * RENDER_TILE_HEIGHT)
#define RENDER_BACKGROUND_COLUMNS 32
#define RENDER_BACKGROUND_ROWS 32
#define RENDER_BACKGROUND_TILE_COUNT (RENDER_BACKGROUND_COLUMNS * RENDER_BACKGROUND_ROWS)
#define RENDER_PALETTE_COLOR_COUNT 4

View File

@ -1,7 +1,10 @@
#include "display/render.h"
#include "util/memory.h"
uint8_t backgroundtiles[] = {
#define backgroundTilesCount 7
uint8_t backgroundTiles[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE, 0xFE, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
@ -108,8 +111,8 @@ void pdelay(uint8_t numVbls) {
void main(void) {
renderInit();
set_bkg_data(0, 7, backgroundtiles);
set_bkg_tiles(0, 0, backgroundmapWidth, backgroundmapHeight, backgroundmap);
renderTilesBuffer(0, 7, backgroundTiles);
renderBackgroundTilesBufferRectangle(0, 0, backgroundmapWidth, backgroundmapHeight, backgroundmap);
renderDisplayOn();

View File

@ -7,6 +7,9 @@
#pragma once
#include "duskgb.h"
#include "display/renderbase.h"
#define RENDER_BACKGROUND_X SCX_REG
#define RENDER_BACKGROUND_Y SCY_REG
#define RENDER_BACKGROUND_Y SCY_REG
#define renderTilesBuffer set_bkg_data

View File

@ -12,17 +12,15 @@
uint8_t RENDER_BACKGROUND_X = 0;
uint8_t RENDER_BACKGROUND_Y = 0;
uint8_t RENDER_STATUS = 0;
bool_t RENDER_DISPLAY_ON = false;
uint8_t RENDER_TILES[RENDER_TILE_COUNT] = { 0 };
uint8_t RENDER_BACKGROUND_TILEMAP[RENDER_BACKGROUND_TILE_COUNT] = { 0 };
Color RENDER_PALETTE[RENDER_PALETTE_COLOR_COUNT] = {
{ 102, 191, 47, 255 },
{ 78, 146, 35, 255 },
{ 48, 89, 22, 255 },
{ 18, 33, 8, 255 }
};
bool_t RENDER_DISPLAY_ON = false;
RenderTexture2D RENDER_BACKBUFFER;
RenderTexture2D RENDER_TILES_TEXTURE;
@ -159,7 +157,7 @@ void renderDisplayOff(void) {
RENDER_DISPLAY_ON = false;
}
void set_bkg_data(
void renderTilesBuffer(
const uint8_t index,
const uint8_t count,
const uint8_t *tiles
@ -175,7 +173,7 @@ void set_bkg_data(
);
}
void set_bkg_tiles(
void renderBackgroundTilesBufferRectangle(
const uint8_t xPos,
const uint8_t yPos,
const uint8_t width,

View File

@ -7,23 +7,13 @@
#pragma once
#include "duskraylib.h"
#define RENDER_TILE_COUNT 384
#define RENDER_TILE_WIDTH 8
#define RENDER_TILE_BYTES_PER_ROW 2
#define RENDER_TILE_HEIGHT 8
#define RENDER_TILE_BYTES_PER_TILE (RENDER_TILE_BYTES_PER_ROW * RENDER_TILE_HEIGHT)
#define RENDER_BACKGROUND_COLUMNS 32
#define RENDER_BACKGROUND_ROWS 32
#define RENDER_BACKGROUND_TILE_COUNT (RENDER_BACKGROUND_COLUMNS * RENDER_BACKGROUND_ROWS)
#include "display/renderbase.h"
extern uint8_t RENDER_BACKGROUND_X;
extern uint8_t RENDER_BACKGROUND_Y;
extern uint8_t RENDER_TILES[RENDER_TILE_COUNT];
#define RENDER_PALETTE_COLOR_COUNT 4
extern Color RENDER_PALETTE[RENDER_PALETTE_COLOR_COUNT];
extern bool_t RENDER_DISPLAY_ON;
extern uint8_t RENDER_TILES[RENDER_TILE_COUNT];
extern Color RENDER_PALETTE[RENDER_PALETTE_COLOR_COUNT];
/**
* Sets the background tile data.
@ -32,7 +22,7 @@ extern bool_t RENDER_DISPLAY_ON;
* @param count The number of tiles to set.
* @param tiles Pointer to the tile data array.
*/
void set_bkg_data(
void renderTilesBuffer(
const uint8_t index,
const uint8_t count,
const uint8_t *tiles
@ -47,7 +37,7 @@ void set_bkg_data(
* @param height The height of the background in tiles.
* @param tiles Pointer to the tile map data.
*/
void set_bkg_tiles(
void renderBackgroundTilesBufferRectangle(
const uint8_t x,
const uint8_t y,
const uint8_t width,