mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2025-12-25 18:32:16 +11:00
Add code to show partial background
This commit is contained in:
parent
4a178dacbe
commit
ccf46b9afb
2 changed files with 45 additions and 2 deletions
3
Makefile
3
Makefile
|
|
@ -10,7 +10,8 @@ LIBS=clib-6502.a
|
|||
# Common source files
|
||||
ASM_SRCS = tk2k_startup.s
|
||||
C_SRCS = main.c monitor_subroutines.c utility.c \
|
||||
game_graphics.c game_logic.c input.c
|
||||
game_graphics.c game_logic.c input.c \
|
||||
line_data.c
|
||||
|
||||
# Object files
|
||||
OBJS = $(ASM_SRCS:%.s=%.o) $(C_SRCS:%.c=%.o)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,60 @@
|
|||
#include "game_graphics.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mem_map.h"
|
||||
#include "mem_registers.h"
|
||||
#include "line_data.h"
|
||||
#include "game_logic.h"
|
||||
|
||||
#define SCREEN_WIDTH_B 40
|
||||
#define TILE_SIDE 28
|
||||
|
||||
#define TOP_OFFSET 14 // Top is offset by 14 lines
|
||||
#define LEFT_OFFSET_B 1 // Left is offset by 1 bytes (7 pixels)
|
||||
|
||||
static uint8_t *front_buf = (uint8_t*)DISPLAY_PAGE_1;
|
||||
static uint8_t *back_buf = (uint8_t*)DISPLAY_PAGE_1;
|
||||
|
||||
// The grid is 5x5 squares,
|
||||
// It is offset on the left side by 7 pixels and on the top by 14
|
||||
// Every square is 28x28 pixels
|
||||
|
||||
void draw_game_background(void) {
|
||||
void swap_display_buffers(void);
|
||||
|
||||
void draw_game_background(void) {
|
||||
// Draw the background on display page 1
|
||||
uint8_t* buf = (uint8_t*)DISPLAY_PAGE_1;
|
||||
|
||||
// Horizontal borders
|
||||
for(uint8_t col = 0; col < GRID_SIDE * 4; col++) {
|
||||
buf[line_offset_map[TOP_OFFSET] + col + LEFT_OFFSET_B] = 0x7F;
|
||||
buf[line_offset_map[TOP_OFFSET + (TILE_SIDE * GRID_SIDE)] + col + LEFT_OFFSET_B] = 0x7F;
|
||||
}
|
||||
|
||||
// vertical borders
|
||||
for(uint8_t col = 0; col < GRID_SIDE * 4; col++) {
|
||||
buf[line_offset_map[TOP_OFFSET] + col + LEFT_OFFSET_B] = 0x7F;
|
||||
buf[line_offset_map[TOP_OFFSET + (TILE_SIDE * GRID_SIDE)] + col + LEFT_OFFSET_B] = 0x7F;
|
||||
}
|
||||
|
||||
// Copy the data from display page 1 to 2
|
||||
memcpy((void*)DISPLAY_PAGE_1, (void*)DISPLAY_PAGE_2, DISPLAY_PAGE_SIZE);
|
||||
|
||||
}
|
||||
|
||||
void draw_tiles(void) {
|
||||
|
||||
swap_display_buffers();
|
||||
}
|
||||
|
||||
void swap_display_buffers(void) {
|
||||
static uint8_t dp_counter = 0;
|
||||
|
||||
uint8_t *temp = front_buf;
|
||||
front_buf = back_buf;
|
||||
back_buf = temp;
|
||||
|
||||
// Show the current buffer
|
||||
PEEK((dp_counter++ & 0x01) ? IO_DISPLAY_PAGE1 : IO_DISPLAY_PAGE2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue