Fix logic

This commit is contained in:
hkz 2025-07-18 09:12:17 +02:00
commit 38a40eb2e4
4 changed files with 37 additions and 13 deletions

View file

@ -8,6 +8,7 @@
#include "line_data.h"
#include "game_logic.h"
#include "tiles.h"
#include "monitor_subroutines.h"
#define SCREEN_WIDTH_B 40
#define GRID_CELL_SIDE 35
@ -45,13 +46,31 @@ void draw_game_background(void) {
}
// This will draw directly to the front buffer
void ddraw_single_tile(uint8_t offset) {
uint8_t* grid = get_front_grid();
if(!grid[offset]) return; // The tile is not there, nothing to do
const uint8_t *tile_data = tiles + (TILE_WIDTH_BYTES * TILE_HEIGHT * (grid[offset] - 1));
uint8_t col = offset % GRID_SIDE;
uint8_t row = offset / GRID_SIDE;
uint8_t delay = 0xFF;
for(uint8_t h = 0; h < TILE_HEIGHT; h++) {
memcpy(front_buf + line_offset_map[TOP_OFFSET + 7 + (row * GRID_CELL_SIDE) + h] + LEFT_OFFSET_B + 1 + (col * GRID_CELL_SIDE/7),
tile_data + (TILE_WIDTH_BYTES * h), TILE_WIDTH_BYTES);
WAIT(48);
}
}
void draw_tiles(void) {
uint8_t* grid = get_front_grid();
// Clear the grid so we'll be able to draw the boxes on
clear_box(GRID_SIDE * (GRID_CELL_SIDE/7) + 1, (GRID_SIDE * GRID_CELL_SIDE) + 6, LEFT_OFFSET_B, TOP_OFFSET + 1, back_buf);
for (uint8_t tile = 0; tile < GRID_SIDE * GRID_SIDE; tile++) {
if(grid[tile]) {
const uint8_t *tile_data = tiles + (TILE_WIDTH_BYTES * TILE_HEIGHT * (grid[tile] - 1));