From 908e208529a9826fa57e919fc69b7b39555ca59d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 07:25:44 -0400 Subject: [PATCH] Improve display of title and version. --- makefile | 30 ++++++++++++++++++++++++------ src/main.c | 20 ++++++++++++++++---- src/ui.c | 10 ++++++---- src/ui.h | 1 + 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/makefile b/makefile index b678d38..049db9b 100644 --- a/makefile +++ b/makefile @@ -2,16 +2,23 @@ # Makefile Options # ---------------------------- -CC = clang +CC ?= clang NAME ?= TRANSFER +MAJOR_VERSION ?= 0 +MINOR_VERSION ?= 0 +PATCH_VERSION ?= 3 +KIND_VERSION ?= n +BUILD_VERSION ?= -$(shell git rev-parse --short HEAD) +FULL_VERSION ?= v$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)$(KIND_VERSION)$(BUILD_VERSION) ICON ?= transfer.png -DESCRIPTION ?= "Variable Transfer Program" +DESCRIPTION ?= "Variable Transfer Program $(FULL_VERSION)" COMPRESSED ?= YES ARCHIVED ?= YES -CFLAGS ?= -Wall -Wextra -Oz -CXXFLAGS ?= -Wall -Wextra -Oz +FLAGS ?= -Wall -Wextra -Oz -DVERSION='"$(FULL_VERSION)"' +CFLAGS ?= $(FLAGS) +CXXFLAGS ?= $(FLAGS) EXTRA_CSOURCES ?= src/font.c EXTRA_USERHEADERS ?= src/ti84pceg.inc src/font.h @@ -25,10 +32,21 @@ endif include $(CEDEV)/meta/makefile.mk -src/font.h src/font.c: font/genfont +all: + $(Q)echo [done] prgm$(NAME) $(FULL_VERSION) + +beta: KIND_VERSION = b +beta: BUILD_VERSION = +beta: all + +release: BUILD_VERSION = +release: REV_VERSION = +release: all + +src/font.h src/font.c: font/genfont makefile $(Q)echo [running] $< $(Q)$< -font/genfont: font/genfont.c +font/genfont: font/genfont.c makefile $(Q)echo [compiling] $< $(Q)$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ diff --git a/src/main.c b/src/main.c index 20b9afe..2d5b57b 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,7 @@ typedef struct mtp_global mtp_global_t; #define usb_transfer_data_t mtp_global_t /* Includes */ +#include "font.h" #include "ui.h" #include "var.h" @@ -36,6 +37,8 @@ typedef struct mtp_global mtp_global_t; #define lengthof(array) (sizeof(array) / sizeof(*(array))) +#define charsof(literal) (lengthof(literal) - 1) + #define COUNT_EACH(...) +1 #define OBJECT_BUFFER \ @@ -2266,10 +2269,19 @@ int main(void) { static mtp_global_t global; usb_error_t error; ui_Init(); - printf(" TRANSFER v0.0.2b\n" - " Connect USB to PC.\n" - " Press [clear] to exit.\n" - "--------------------------------"); +#define CENTER(string) \ + printf("%*s%.*s", \ + (LCD_WIDTH / FONT_WIDTH + \ + charsof(string)) / 2, \ + string, \ + charsof(string) % \ + (LCD_WIDTH / FONT_WIDTH) != 0, \ + "\n"); + CENTER("TRANSFER " VERSION); + CENTER("Connect USB to PC."); + CENTER("Press [clear] to exit."); + CENTER("--------------------------------"); + ui_Lock(); static mtp_device_info_t device_info = { .standard_version = 100, /* 1.00 */ .mtp_vendor_extension_id = 6, diff --git a/src/ui.c b/src/ui.c index 85a44cd..5e6394f 100644 --- a/src/ui.c +++ b/src/ui.c @@ -8,9 +8,7 @@ #include #include -#define STATIC_ROWS 4 - -static uint8_t row, col, swap; +static uint8_t static_rows, row, col, swap; #define buffer(n) (*(uint8_t (*)[4][LCD_WIDTH][LCD_HEIGHT >> 1])lcd_Ram)[(n) ^ swap] void ui_Init(void) { @@ -31,6 +29,10 @@ void ui_Init(void) { *(volatile uint8_t *volatile *)&lcd_UpBase = &buffer(0)[0][0]; } +void ui_Lock(void) { + static_rows = row; +} + void ui_Cleanup(void) { boot_ClearVRAM(); boot_TurnOn(); @@ -56,7 +58,7 @@ void outchar(char c) { sizeof(buffer(1)) - FONT_HEIGHT_BYTES); for (unsigned x = 0; x != LCD_WIDTH; ++x) { memcpy(&buffer(0)[x][0], &buffer(1)[x][0], - FONT_HEIGHT_BYTES * STATIC_ROWS); + FONT_HEIGHT_BYTES * static_rows); memset(&buffer(0)[x][((LCD_HEIGHT / FONT_HEIGHT - 1) * FONT_HEIGHT) >> 1], 0xFF, FONT_HEIGHT_BYTES); } diff --git a/src/ui.h b/src/ui.h index e7f3eaf..d998800 100644 --- a/src/ui.h +++ b/src/ui.h @@ -2,6 +2,7 @@ #define UI_H void ui_Init(void); +void ui_Lock(void); void ui_Cleanup(void); #endif