mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2026-01-14 16:40:52 +11:00
Rename other graphic files, remove unused imports
This commit is contained in:
parent
dbc1bebf9f
commit
83552c2ad8
6 changed files with 98 additions and 100 deletions
6
Makefile
6
Makefile
|
|
@ -23,13 +23,13 @@ INTRO_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s
|
|||
INTRO_C_SRCS = intro_main.c utility.c
|
||||
|
||||
DLOG_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s sound.s
|
||||
DLOG_C_SRCS = dlog_main.c input.c utility.c game_hgr_graphics.c line_data.c
|
||||
DLOG_C_SRCS = dlog_main.c input.c utility.c game_hgr_graphics.c hgr_line_data.c
|
||||
|
||||
GAME_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s input_asm.s sound.s
|
||||
GAME_C_SRCS = game_main.c input.c utility.c game_hgr_graphics.c line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
|
||||
GAME_C_SRCS = game_main.c input.c utility.c game_hgr_graphics.c hgr_line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
|
||||
|
||||
DEMO_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s input_asm.s sound.s
|
||||
DEMO_C_SRCS = demo_main.c input.c utility.c game_hgr_graphics_demo.c line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
|
||||
DEMO_C_SRCS = demo_main.c input.c utility.c game_hgr_graphics_demo.c hgr_line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
|
||||
|
||||
# Object files
|
||||
MASTER_OBJS = $(MASTER_ASM_SRCS:%.s=%.o) $(MASTER_C_SRCS:%.c=%.o)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "utility.h"
|
||||
#include "mem_map.h"
|
||||
#include "mem_registers.h"
|
||||
#include "line_data.h"
|
||||
#include "hgr_line_data.h"
|
||||
#include "game_logic.h"
|
||||
#include "tiles.h"
|
||||
#include "charset.h"
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "utility.h"
|
||||
|
||||
const uint16_t line_offset_map[SCREEN_HEIGHT] = {
|
||||
0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x0080, 0x0480, 0x0880, 0x0C80,
|
||||
0x1080, 0x1480, 0x1880, 0x1C80, 0x0100, 0x0500, 0x0900, 0x0D00, 0x1100, 0x1500, 0x1900, 0x1D00,
|
||||
0x0180, 0x0580, 0x0980, 0x0D80, 0x1180, 0x1580, 0x1980, 0x1D80, 0x0200, 0x0600, 0x0A00, 0x0E00,
|
||||
0x1200, 0x1600, 0x1A00, 0x1E00, 0x0280, 0x0680, 0x0A80, 0x0E80, 0x1280, 0x1680, 0x1A80, 0x1E80,
|
||||
0x0300, 0x0700, 0x0B00, 0x0F00, 0x1300, 0x1700, 0x1B00, 0x1F00, 0x0380, 0x0780, 0x0B80, 0x0F80,
|
||||
0x1380, 0x1780, 0x1B80, 0x1F80, 0x0028, 0x0428, 0x0828, 0x0C28, 0x1028, 0x1428, 0x1828, 0x1C28,
|
||||
0x00A8, 0x04A8, 0x08A8, 0x0CA8, 0x10A8, 0x14A8, 0x18A8, 0x1CA8, 0x0128, 0x0528, 0x0928, 0x0D28,
|
||||
0x1128, 0x1528, 0x1928, 0x1D28, 0x01A8, 0x05A8, 0x09A8, 0x0DA8, 0x11A8, 0x15A8, 0x19A8, 0x1DA8,
|
||||
0x0228, 0x0628, 0x0A28, 0x0E28, 0x1228, 0x1628, 0x1A28, 0x1E28, 0x02A8, 0x06A8, 0x0AA8, 0x0EA8,
|
||||
0x12A8, 0x16A8, 0x1AA8, 0x1EA8, 0x0328, 0x0728, 0x0B28, 0x0F28, 0x1328, 0x1728, 0x1B28, 0x1F28,
|
||||
0x03A8, 0x07A8, 0x0BA8, 0x0FA8, 0x13A8, 0x17A8, 0x1BA8, 0x1FA8, 0x0050, 0x0450, 0x0850, 0x0C50,
|
||||
0x1050, 0x1450, 0x1850, 0x1C50, 0x00D0, 0x04D0, 0x08D0, 0x0CD0, 0x10D0, 0x14D0, 0x18D0, 0x1CD0,
|
||||
0x0150, 0x0550, 0x0950, 0x0D50, 0x1150, 0x1550, 0x1950, 0x1D50, 0x01D0, 0x05D0, 0x09D0, 0x0DD0,
|
||||
0x11D0, 0x15D0, 0x19D0, 0x1DD0, 0x0250, 0x0650, 0x0A50, 0x0E50, 0x1250, 0x1650, 0x1A50, 0x1E50,
|
||||
0x02D0, 0x06D0, 0x0AD0, 0x0ED0, 0x12D0, 0x16D0, 0x1AD0, 0x1ED0, 0x0350, 0x0750, 0x0B50, 0x0F50,
|
||||
0x1350, 0x1750, 0x1B50, 0x1F50, 0x03D0, 0x07D0, 0x0BD0, 0x0FD0, 0x13D0, 0x17D0, 0x1BD0, 0x1FD0
|
||||
};
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utility.h"
|
||||
|
||||
const uint16_t line_offset_map[SCREEN_HEIGHT] = {
|
||||
0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x0080, 0x0480, 0x0880, 0x0C80,
|
||||
0x1080, 0x1480, 0x1880, 0x1C80, 0x0100, 0x0500, 0x0900, 0x0D00, 0x1100, 0x1500, 0x1900, 0x1D00,
|
||||
0x0180, 0x0580, 0x0980, 0x0D80, 0x1180, 0x1580, 0x1980, 0x1D80, 0x0200, 0x0600, 0x0A00, 0x0E00,
|
||||
0x1200, 0x1600, 0x1A00, 0x1E00, 0x0280, 0x0680, 0x0A80, 0x0E80, 0x1280, 0x1680, 0x1A80, 0x1E80,
|
||||
0x0300, 0x0700, 0x0B00, 0x0F00, 0x1300, 0x1700, 0x1B00, 0x1F00, 0x0380, 0x0780, 0x0B80, 0x0F80,
|
||||
0x1380, 0x1780, 0x1B80, 0x1F80, 0x0028, 0x0428, 0x0828, 0x0C28, 0x1028, 0x1428, 0x1828, 0x1C28,
|
||||
0x00A8, 0x04A8, 0x08A8, 0x0CA8, 0x10A8, 0x14A8, 0x18A8, 0x1CA8, 0x0128, 0x0528, 0x0928, 0x0D28,
|
||||
0x1128, 0x1528, 0x1928, 0x1D28, 0x01A8, 0x05A8, 0x09A8, 0x0DA8, 0x11A8, 0x15A8, 0x19A8, 0x1DA8,
|
||||
0x0228, 0x0628, 0x0A28, 0x0E28, 0x1228, 0x1628, 0x1A28, 0x1E28, 0x02A8, 0x06A8, 0x0AA8, 0x0EA8,
|
||||
0x12A8, 0x16A8, 0x1AA8, 0x1EA8, 0x0328, 0x0728, 0x0B28, 0x0F28, 0x1328, 0x1728, 0x1B28, 0x1F28,
|
||||
0x03A8, 0x07A8, 0x0BA8, 0x0FA8, 0x13A8, 0x17A8, 0x1BA8, 0x1FA8, 0x0050, 0x0450, 0x0850, 0x0C50,
|
||||
0x1050, 0x1450, 0x1850, 0x1C50, 0x00D0, 0x04D0, 0x08D0, 0x0CD0, 0x10D0, 0x14D0, 0x18D0, 0x1CD0,
|
||||
0x0150, 0x0550, 0x0950, 0x0D50, 0x1150, 0x1550, 0x1950, 0x1D50, 0x01D0, 0x05D0, 0x09D0, 0x0DD0,
|
||||
0x11D0, 0x15D0, 0x19D0, 0x1DD0, 0x0250, 0x0650, 0x0A50, 0x0E50, 0x1250, 0x1650, 0x1A50, 0x1E50,
|
||||
0x02D0, 0x06D0, 0x0AD0, 0x0ED0, 0x12D0, 0x16D0, 0x1AD0, 0x1ED0, 0x0350, 0x0750, 0x0B50, 0x0F50,
|
||||
0x1350, 0x1750, 0x1B50, 0x1F50, 0x03D0, 0x07D0, 0x0BD0, 0x0FD0, 0x13D0, 0x17D0, 0x1BD0, 0x1FD0
|
||||
};
|
||||
9
src/hgr_line_data.h
Normal file
9
src/hgr_line_data.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _HGR_LINE_DATA_HEADER_
|
||||
#define _HGR_LINE_DATA_HEADER_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utility.h"
|
||||
|
||||
extern const uint16_t line_offset_map[SCREEN_HEIGHT];
|
||||
|
||||
#endif /* _HGR_LINE_DATA_HEADER_ */
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef _LINE_DATA_HEADER_
|
||||
#define _LINE_DATA_HEADER_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utility.h"
|
||||
|
||||
extern const uint16_t line_offset_map[SCREEN_HEIGHT];
|
||||
|
||||
#endif /* _LINE_DATA_HEADER */
|
||||
128
src/utility.c
128
src/utility.c
|
|
@ -1,65 +1,63 @@
|
|||
#include "utility.h"
|
||||
|
||||
#include "mem_registers.h"
|
||||
#include "monitor_subroutines.h"
|
||||
#include "line_data.h"
|
||||
|
||||
void num_to_decbuf(uint16_t n, uint8_t len, uint8_t *buf) {
|
||||
|
||||
for(uint8_t idx = 0; idx < len; idx++) {
|
||||
buf[idx] = n % 10;
|
||||
n /= 10;
|
||||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/2602823/in-c-c-whats-the-simplest-way-to-reverse-the-order-of-bits-in-a-byte
|
||||
uint8_t bit_reverse(uint8_t b) {
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/14009765/fastest-way-to-count-bits
|
||||
uint8_t bit_count(uint8_t b) {
|
||||
b = (b & 0x55) + (b >> 1 & 0x55);
|
||||
b = (b & 0x33) + (b >> 2 & 0x33);
|
||||
b = (b & 0x0f) + (b >> 4 & 0x0f);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void lfsr_init(uint16_t reg) {
|
||||
*((uint16_t*)LFSR_REGISTER_ADDRESS) = 0xF00D;
|
||||
}
|
||||
|
||||
uint16_t lfsr_update(void) {
|
||||
uint16_t *lfsr = ((uint16_t*)LFSR_REGISTER_ADDRESS);
|
||||
|
||||
*lfsr ^= (*lfsr) >> 7;
|
||||
*lfsr ^= (*lfsr) << 9;
|
||||
*lfsr ^= (*lfsr) >> 13;
|
||||
|
||||
return *lfsr;
|
||||
}
|
||||
|
||||
#define CRC8RDALLAS_POLY 0x31
|
||||
uint8_t calculate_crc8(uint8_t* data, uint8_t len) {
|
||||
uint8_t crc = 0;
|
||||
|
||||
for(uint8_t data_idx = 0; data_idx < len; data_idx++) {
|
||||
uint8_t carry;
|
||||
uint8_t d = data[data_idx];
|
||||
|
||||
for (uint8_t i = 8; i > 0; i--) {
|
||||
carry = (crc & 0x80);
|
||||
crc <<= 1;
|
||||
if (d & 1) crc |= 1;
|
||||
d >>= 1;
|
||||
if (carry) crc ^= CRC8RDALLAS_POLY;
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
#include "utility.h"
|
||||
|
||||
#include "mem_registers.h"
|
||||
#include "monitor_subroutines.h"
|
||||
|
||||
void num_to_decbuf(uint16_t n, uint8_t len, uint8_t *buf) {
|
||||
for(uint8_t idx = 0; idx < len; idx++) {
|
||||
buf[idx] = n % 10;
|
||||
n /= 10;
|
||||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/2602823/in-c-c-whats-the-simplest-way-to-reverse-the-order-of-bits-in-a-byte
|
||||
uint8_t bit_reverse(uint8_t b) {
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/14009765/fastest-way-to-count-bits
|
||||
uint8_t bit_count(uint8_t b) {
|
||||
b = (b & 0x55) + (b >> 1 & 0x55);
|
||||
b = (b & 0x33) + (b >> 2 & 0x33);
|
||||
b = (b & 0x0f) + (b >> 4 & 0x0f);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void lfsr_init(uint16_t reg) {
|
||||
*((uint16_t*)LFSR_REGISTER_ADDRESS) = 0xF00D;
|
||||
}
|
||||
|
||||
uint16_t lfsr_update(void) {
|
||||
uint16_t *lfsr = ((uint16_t*)LFSR_REGISTER_ADDRESS);
|
||||
|
||||
*lfsr ^= (*lfsr) >> 7;
|
||||
*lfsr ^= (*lfsr) << 9;
|
||||
*lfsr ^= (*lfsr) >> 13;
|
||||
|
||||
return *lfsr;
|
||||
}
|
||||
|
||||
#define CRC8RDALLAS_POLY 0x31
|
||||
uint8_t calculate_crc8(uint8_t* data, uint8_t len) {
|
||||
uint8_t crc = 0;
|
||||
|
||||
for(uint8_t data_idx = 0; data_idx < len; data_idx++) {
|
||||
uint8_t carry;
|
||||
uint8_t d = data[data_idx];
|
||||
|
||||
for (uint8_t i = 8; i > 0; i--) {
|
||||
carry = (crc & 0x80);
|
||||
crc <<= 1;
|
||||
if (d & 1) crc |= 1;
|
||||
d >>= 1;
|
||||
if (carry) crc ^= CRC8RDALLAS_POLY;
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue