m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--harddoomdev.c38
-rw-r--r--private_data.h13
2 files changed, 44 insertions, 7 deletions
diff --git a/harddoomdev.c b/harddoomdev.c
index 31e0def..1a818ea 100644
--- a/harddoomdev.c
+++ b/harddoomdev.c
@@ -85,17 +85,27 @@ void ping_sync(struct doom_data *doom_data)
void set_surf_src_pt(struct doom_data *doom_data, dma_addr_t page_table)
{
- send_command(doom_data, HARDDOOM_CMD_SURF_SRC_PT(page_table));
+ if (doom_data->surf_src_pt != page_table) {
+ doom_data->surf_src_pt = page_table;
+ send_command(doom_data, HARDDOOM_CMD_SURF_SRC_PT(page_table));
+ }
}
void set_surf_dst_pt(struct doom_data *doom_data, dma_addr_t page_table)
{
- send_command(doom_data, HARDDOOM_CMD_SURF_DST_PT(page_table));
+ if (doom_data->surf_dst_pt != page_table) {
+ doom_data->surf_dst_pt = page_table;
+ send_command(doom_data, HARDDOOM_CMD_SURF_DST_PT(page_table));
+ }
}
void set_surf_dims(struct doom_data *doom_data, uint32_t width, uint32_t height)
{
- send_command(doom_data, HARDDOOM_CMD_SURF_DIMS(width, height));
+ if (doom_data->surf_dims_w != width || doom_data->surf_dims_h != height) {
+ doom_data->surf_dims_w = width;
+ doom_data->surf_dims_h = height;
+ send_command(doom_data, HARDDOOM_CMD_SURF_DIMS(width, height));
+ }
}
void set_xy_a(struct doom_data *doom_data, uint16_t x, uint16_t y)
@@ -115,17 +125,28 @@ void set_fill_color(struct doom_data *doom_data, uint8_t color)
void set_texture_pt(struct doom_data *doom_data, dma_addr_t page_table_dev)
{
- send_command(doom_data, HARDDOOM_CMD_TEXTURE_PT(page_table_dev));
+ if (doom_data->texture_pt != page_table_dev) {
+ doom_data->texture_pt = page_table_dev;
+ send_command(doom_data, HARDDOOM_CMD_TEXTURE_PT(page_table_dev));
+ }
}
void set_texture_dims(struct doom_data *doom_data, uint32_t size, uint16_t height)
{
- send_command(doom_data, HARDDOOM_CMD_TEXTURE_DIMS(size,height));
+ if (doom_data->texture_dims_s != size ||
+ doom_data->texture_dims_h != height) {
+ doom_data->texture_dims_s = size;
+ doom_data->texture_dims_h = height;
+ send_command(doom_data, HARDDOOM_CMD_TEXTURE_DIMS(size,height));
+ }
}
void set_flat(struct doom_data *doom_data, dma_addr_t flat_dev)
{
- send_command(doom_data, HARDDOOM_CMD_FLAT_ADDR(flat_dev));
+ if (doom_data->flat_addr != flat_dev) {
+ doom_data->flat_addr = flat_dev;
+ send_command(doom_data, HARDDOOM_CMD_FLAT_ADDR(flat_dev));
+ }
}
void set_ustart(struct doom_data *doom_data, uint32_t ustart)
@@ -150,7 +171,10 @@ void set_vstep(struct doom_data *doom_data, uint32_t vstep)
void set_draw_params(struct doom_data *doom_data, uint8_t flags)
{
- send_command(doom_data, HARDDOOM_CMD_DRAW_PARAMS(flags));
+ if (doom_data->draw_params != flags) {
+ doom_data->draw_params = flags;
+ send_command(doom_data, HARDDOOM_CMD_DRAW_PARAMS(flags));
+ }
}
void fill_rect(struct surface_data *surface_data, struct doomdev_fill_rect rect)
diff --git a/private_data.h b/private_data.h
index fed5b60..f8f3057 100644
--- a/private_data.h
+++ b/private_data.h
@@ -15,6 +15,19 @@ struct doom_data {
struct semaphore pong_async_sem;
uint16_t cmd_counter;
+
+ // cache of registers we don't want to modify when not neccessary
+ uint32_t surf_dst_pt;
+ uint32_t surf_src_pt;
+ uint32_t texture_pt;
+ uint32_t flat_addr;
+ uint32_t colormap_addr;
+ uint32_t translation_addr;
+ uint32_t surf_dims_w;
+ uint32_t surf_dims_h;
+ uint32_t texture_dims_s;
+ uint32_t texture_dims_h;
+ uint32_t draw_params;
};
struct surface_data {