diff --git a/.gitignore b/.gitignore index 4a0dbe1..6eccb79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ +icon/ti83pce.ico +icon/ti84pce.ico font/genfont src/font.* +src/*_icon.* obj/* bin/* diff --git a/CHANGELOG.md b/CHANGELOG.md index c49461d..b713927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,3 @@ ## v0.0.2b - Fix corrupted screen, crash, or garbage data when receiving some variables from Archive. - Fix incorrect file names for images. - -## v0.0.3b -- Use new usbdrvce error handling features. -- Improve build system. - -## v0.0.4b -- Recompile for new usbdrvce. diff --git a/README.md b/README.md index 56aa779..62cb334 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# prgmTRANSFER v0.0.4b +# prgmTRANSFER v0.0.2b ### This software is still in beta, no liability for corrupted or lost files, etc! @@ -13,7 +13,7 @@ PTP or MTP transfer software. - Android 11 using the builtin Files application, check notifications after connecting to open. ## Installation -1. Send [TRANSFER.8xp release](https://github.com/jacobly0/transfer/releases/latest) and [nightly clibs.8xg from usbdrvce branch](https://jacobly.com/artifact?repo=toolchain&branch=usbdrvce&file=clibs) to your calculator using other transfer software. +1. Send [TRANSFER.8xp release](https://github.com/jacobly0/transfer/releases/latest) and [nightly clibs.8xg from usbdrvce branch](https://jacobly.com/a/toolchain/usbdrvce/clibs.zip) to your calculator using other transfer software. 1. Run `Asm(prgmTRANSFER)` and then plug-and-play with a usb cable to supported OSes, or using supported software. 1. The screen should display a debug log that can be ignored unless things go wrong, in which case the last few lines should be reported if there is an issue. 1. Press `clear` to exit. diff --git a/icon/ti83pce-128.ico b/icon/ti83pce-128.ico new file mode 100644 index 0000000..e5ea56f Binary files /dev/null and b/icon/ti83pce-128.ico differ diff --git a/icon/ti83pce-256.ico b/icon/ti83pce-256.ico new file mode 100644 index 0000000..8ff1f4d Binary files /dev/null and b/icon/ti83pce-256.ico differ diff --git a/icon/ti83pce-32.ico b/icon/ti83pce-32.ico new file mode 100644 index 0000000..f64ae7b Binary files /dev/null and b/icon/ti83pce-32.ico differ diff --git a/icon/ti83pce-64.ico b/icon/ti83pce-64.ico new file mode 100644 index 0000000..29d7e0f Binary files /dev/null and b/icon/ti83pce-64.ico differ diff --git a/icon/ti84pce-128.ico b/icon/ti84pce-128.ico new file mode 100644 index 0000000..aa5dd8b Binary files /dev/null and b/icon/ti84pce-128.ico differ diff --git a/icon/ti84pce-256.ico b/icon/ti84pce-256.ico new file mode 100644 index 0000000..8382875 Binary files /dev/null and b/icon/ti84pce-256.ico differ diff --git a/icon/ti84pce-32.ico b/icon/ti84pce-32.ico new file mode 100644 index 0000000..ed894b7 Binary files /dev/null and b/icon/ti84pce-32.ico differ diff --git a/icon/ti84pce-64.ico b/icon/ti84pce-64.ico new file mode 100644 index 0000000..edbf9f5 Binary files /dev/null and b/icon/ti84pce-64.ico differ diff --git a/transfer.png b/icon/transfer.png similarity index 100% rename from transfer.png rename to icon/transfer.png diff --git a/transfer.xcf b/icon/transfer.xcf similarity index 100% rename from transfer.xcf rename to icon/transfer.xcf diff --git a/makefile b/makefile index d4a9d91..2654765 100644 --- a/makefile +++ b/makefile @@ -2,47 +2,48 @@ # Makefile Options # ---------------------------- -NATIVECC = clang +CC = clang +CONVERT = convert +PRINTF = printf NAME = TRANSFER -MAJOR_VERSION = 0 -MINOR_VERSION = 0 -PATCH_VERSION = 4 -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 $(FULL_VERSION)" +ICON = icon/transfer.png +DESCRIPTION = "Variable Transfer Program" COMPRESSED = YES ARCHIVED = YES -FLAGS = -Wall -Wextra -Oz -DVERSION='"$(FULL_VERSION)"' -CFLAGS = $(FLAGS) -CXXFLAGS = $(FLAGS) +CFLAGS = -Wall -Wextra -Oz +CXXFLAGS = -Wall -Wextra -Oz -EXTRA_CSOURCES = src/font.c -EXTRA_USERHEADERS = src/ti84pceg.inc src/font.h -EXTRA_CLEAN = src/font.c src/font.h font/genfont +ICON_COLORS = 16 +ICON_SIZES = 32 64 + +GEN_CSOURCES = src/ti83pce_icon.c src/ti84pce_icon.c src/font.c +EXTRA_CSOURCES = $(filter-out $(wildcard $(GEN_CSOURCES)),$(GEN_CSOURCES)) +EXTRA_USERHEADERS = src/ti83pce_icon.h src/ti84pce_icon.h src/ti84pceg.inc src/font.h +EXTRA_CLEAN = $(GEN_CSOURCES) $(patsubst %.c,%.h,$(GEN_CSOURCES)) icon/ti83pce.ico icon/ti84pce.ico font/genfont # ---------------------------- -include $(shell cedev-config --makefile) +ifndef CEDEV +$(error CEDEV environment path variable is not set) +endif -all: - $(Q)echo [done] prgm$(NAME) $(FULL_VERSION) +include $(CEDEV)/meta/makefile.mk -beta: KIND_VERSION = b -beta: BUILD_VERSION = -beta: all +icon/%.ico: $(patsubst %,icon/\%-%.ico,$(ICON_SIZES)) + @$(CONVERT) $^ -colors $(ICON_COLORS) $@ -release: BUILD_VERSION = -release: REV_VERSION = -release: all +src/%_icon.h: icon/%.ico + @$(PRINTF) "#ifndef $*_icon_h\n#define $*_icon_h\n\n#define $*_icon_uncompressed_size `wc -c < $<`\nextern const unsigned char $*_icon[];\n\n#endif\n" > $@ -src/font.h src/font.c: font/genfont makefile - $(Q)echo [running] $< - $(Q)$< +src/%_icon.c: icon/%.ico + @$(CONVBIN) --iformat bin --input $< --compress zx7 --name $*_icon --oformat c --output $@ -font/genfont: font/genfont.c makefile - $(Q)echo [compiling] $< - $(Q)$(NATIVECC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ +src/font.h src/font.c: font/genfont + @$< + +font/genfont: font/genfont.c + @$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ + +.SECONDARY: $(EXTRA_CLEAN) diff --git a/src/main.c b/src/main.c index 3499fb3..7c63060 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,8 @@ typedef struct mtp_global mtp_global_t; #define usb_transfer_data_t mtp_global_t /* Includes */ -#include "font.h" +#include "ti83pce_icon.h" +#include "ti84pce_icon.h" #include "ui.h" #include "var.h" @@ -22,7 +23,7 @@ typedef struct mtp_global mtp_global_t; #include #include -#include +#include #include #include @@ -37,11 +38,9 @@ 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 \ +#define LARGE_BUFFER \ ((void *)((mtp_byte_t *)lcd_Ram + LCD_WIDTH * LCD_HEIGHT)) #define FOR_EACH_SUPP_OPR(X) \ @@ -66,10 +65,11 @@ typedef struct mtp_global mtp_global_t; X(OBJECT_ADDED) \ X(OBJECT_REMOVED) -#define FOR_EACH_SUPP_DP(X) \ - X(uint8, BATTERY_LEVEL, RANGE) \ - X(datetime, DATE_TIME, NONE) \ - X(uint32, PERCEIVED_DEVICE_TYPE, NONE) +#define FOR_EACH_SUPP_DP(X) \ + X(uint8, BATTERY_LEVEL, RANGE) \ + X(datetime, DATE_TIME, NONE) \ + X(uint32, PERCEIVED_DEVICE_TYPE, NONE) \ + X(auint8, DEVICE_ICON, NONE) #define FOR_EACH_SUPP_CF(X) \ X(UNDEFINED) @@ -113,32 +113,60 @@ typedef struct mtp_global mtp_global_t; #define get_arc_free_space_in_bytes \ (os_ArcChk(), os_TempFreeArc) -#define BATTERY_LEVEL_MIN 0 -#define BATTERY_LEVEL_MAX 4 -#define BATTERY_LEVEL_STEP 1 -#define BATTERY_LEVEL_DEF 0 -#define BATTERY_LEVEL_GET_SET 0 -#define BATTERY_LEVEL_GET(current) \ - current = boot_GetBatteryStatus() -#define BATTERY_LEVEL_SET(new) +#define BATTERY_LEVEL_MIN(value) value = 0 +#define BATTERY_LEVEL_MAX(value) value = 4 +#define BATTERY_LEVEL_STEP(value) value = 1 +#define BATTERY_LEVEL_SIZE sizeof +#define BATTERY_LEVEL_DEF(value) value = 0 +#define BATTERY_LEVEL_GET_SET 0 +#define BATTERY_LEVEL_GET(value) \ + value = boot_GetBatteryStatus() +#define BATTERY_LEVEL_SET(value) (void)0 -#define DATE_TIME_DEF { \ - .length = lengthof(Lfactory_datetime), \ - .string = Lfactory_datetime, \ - } -#define DATE_TIME_GET_SET 1 -#define DATE_TIME_GET(current) \ - get_datetime(¤t) -#define DATE_TIME_SET(new) +#define DATE_TIME_SIZE sizeof +#define DATE_TIME_DEF(value) do { \ + value.length = \ + lengthof(Lfactory_datetime); \ + memcpy(value.string, \ + Lfactory_datetime, \ + sizeof(value.string)); \ + } while (0) +#define DATE_TIME_GET_SET 1 +#define DATE_TIME_GET(value) \ + get_datetime(value.string) +#define DATE_TIME_SET(value) (void)0 -#define PERCEIVED_DEVICE_TYPE_DEF 0 -#define PERCEIVED_DEVICE_TYPE_GET_SET 0 -#define PERCEIVED_DEVICE_TYPE_GET(current) \ - current = 5 -#define PERCEIVED_DEVICE_TYPE_SET(new) +#define PERCEIVED_DEVICE_TYPE_SIZE sizeof +#define PERCEIVED_DEVICE_TYPE_DEF(value) value = 0 +#define PERCEIVED_DEVICE_TYPE_GET_SET 0 +#define PERCEIVED_DEVICE_TYPE_GET(value) value = 3 +#define PERCEIVED_DEVICE_TYPE_SET(value) (void)0 + +#define DEVICE_ICON_SIZE(type) \ + (sizeof(mtp_size_t) + global->device_icon_size) +#define DEVICE_ICON_DEF DEVICE_ICON_GET +#define DEVICE_ICON_GET_SET 0 +#define DEVICE_ICON_GET(value) do { \ + value.num_elements = \ + global->device_icon_size; \ + zx7_Decompress( \ + value.elements, \ + global->device_icon); \ + } while (0) +#define DEVICE_ICON_SET(value) /* MTP Types */ +typedef struct int128 { + int64_t high; + uint64_t low; +} int128_t; + +typedef struct uint128 { + uint64_t high; + uint64_t low; +} uint128_t; + typedef uint8_t mtp_byte_t; typedef uint16_t mtp_version_t; typedef uint16_t mtp_enum_t; @@ -146,6 +174,23 @@ typedef uint32_t mtp_size_t; typedef uint32_t mtp_id_t; typedef uint32_t mtp_param_t; typedef uint64_t mtp_uint64_t; + +#define DECLARE_ARRAY_TYPE(name) \ + typedef struct a##name { \ + mtp_size_t num_elements; \ + name##_t elements[]; \ + } a##name##_t; +DECLARE_ARRAY_TYPE(uint8) +DECLARE_ARRAY_TYPE(int8) +DECLARE_ARRAY_TYPE(uint16) +DECLARE_ARRAY_TYPE(int16) +DECLARE_ARRAY_TYPE(uint32) +DECLARE_ARRAY_TYPE(int32) +DECLARE_ARRAY_TYPE(uint64) +DECLARE_ARRAY_TYPE(int64) +DECLARE_ARRAY_TYPE(uint128) +DECLARE_ARRAY_TYPE(int128) + #define DECLARE_TRUNC_TYPE(name) \ typedef union mtp_trunc_##name { \ mtp_##name##_t name; \ @@ -167,16 +212,16 @@ typedef usb_error_t(*mtp_transaction_callback_t)( #define Los_specific L"MSFT100\1" #define Lmtp_extensions L"microsoft.com: 1.0;" #define Lmanufacturer L"Texas Instruments Incorporated" -#define Lproduct L"TI-84 Plus CE" -#define Lproduct83 L"TI-83 Premium CE" -#define Ldevice_version L"255.255.255.65535" +#define Lproduct L"TI-83 Premium CE" /* default must be longer than alt */ +#define Lproduct84 L"TI-84 Plus CE" +#define Ldevice_version L"2.20" #define Lserial_number L"0000000000000000" #define Lcharging_cfg L"Charging" #define Lmtp_interface L"MTP" /* magic string to aid detection */ #define Lram_storage_desc L"RAM" -#define Lram_volume_id Lserial_number "R" +#define Lram_volume_id Lserial_number"R" #define Larc_storage_desc L"Archive" -#define Larc_volume_id Lserial_number "A" +#define Larc_volume_id Lserial_number"A" #define Lfactory_datetime L"20150101T000000" typedef enum string_id { @@ -647,6 +692,13 @@ typedef enum mtp_object_property_code { /* MTP Structures */ +typedef struct mtp_device_property_description { + mtp_enum_t device_property_code; + mtp_enum_t datatype; + mtp_byte_t get_set; + mtp_byte_t values[]; +} mtp_device_property_description_t; + typedef struct mtp_object_info_header { mtp_trunc_id_t storage_id; mtp_enum_t object_format; @@ -717,8 +769,7 @@ typedef struct mtp_device_info { mtp_byte_t manufacturer_length; wchar_t manufacturer[lengthof(Lmanufacturer)]; mtp_byte_t model_length; - wchar_t model[lengthof(Lproduct) > lengthof(Lproduct83) ? - lengthof(Lproduct) : lengthof(Lproduct83)]; + wchar_t model[lengthof(Lproduct)]; mtp_byte_t device_version_length; wchar_t device_version[lengthof(Ldevice_version)]; mtp_byte_t serial_number_length; @@ -797,6 +848,8 @@ struct mtp_global { mtp_transaction_t transaction; mtp_event_t events[MTP_MAX_PENDING_EVENTS]; /* MTP Info */ + size_t device_icon_size; + const void *device_icon; size_t device_info_size; const mtp_device_info_t *device_info; #define DECLARE_STORAGE_INFO(name) \ @@ -831,6 +884,7 @@ DECLARE_CALLBACK(response); DECLARE_CALLBACK(event); /* Other Forward Function Declarations */ + usb_error_t wait_for_usb(mtp_global_t *global); /* MTP Function Definitions */ @@ -846,12 +900,18 @@ static usb_endpoint_t get_endpoint( static usb_error_t stall_data_endpoints( usb_endpoint_t endpoint) { printf("stalling data endpoints\n"); - usb_error_t error = usb_SetEndpointHalt( +#if 0 + usb_error_t error; + error = usb_StallEndpoint( get_endpoint(endpoint, MTP_EP_DATA_IN)); if (error == USB_SUCCESS) - error = usb_SetEndpointHalt( + error = usb_StallEndpoint( get_endpoint(endpoint, MTP_EP_DATA_OUT)); return error; +#else + (void)endpoint; + return USB_ERROR_FAILED; +#endif } static usb_error_t schedule_event( @@ -1051,19 +1111,19 @@ static uint16_t compute_checksum( } static void get_datetime( - datetime_t *result) { + wchar_t result[lengthof(Lfactory_datetime)]) { uint16_t year; - uint8_t month, day, hour, minute, second; - char string[lengthof(Lfactory_datetime)]; + uint8_t month, day, hour, minute, second, + i = lengthof(Lfactory_datetime); + char string[lengthof(Lfactory_datetime)], + *pointer = string; boot_GetDate(&day, &month, &year); boot_GetTime(&second, &minute, &hour); - int count = - snprintf(string, lengthof(string), - "%04u%02u%02uT%02u%02u%02u", - year, month, day, hour, minute, second); - result->length = count <= 0 ? 0 : count + 1; - for (mtp_byte_t i = 0; i != result->length; ++i) - result->string[i] = string[i]; + sprintf(string, "%04u%02u%02uT%02u%02u%02u", + year, month, day, hour, minute, second); + do + *(char *)result++ = *pointer++; + while (--i); } static int delete_object( @@ -1106,7 +1166,7 @@ static int send_object( mtp_global_t *global) { size += global->transaction.state .send_object.extra; - const var_file_header_t *header = OBJECT_BUFFER; + const var_file_header_t *header = LARGE_BUFFER; if (size <= offsetof(var_file_header_t, entry.data) + sizeof(uint16_t) || @@ -1181,7 +1241,6 @@ static int send_object( version = entry->version; flag = entry->flag; } - (void)version; flag &= global->transaction.pending .send_object.mask; flag |= global->transaction.pending @@ -1707,40 +1766,35 @@ DEFINE_CALLBACK(command) { break; case MTP_OPR_GET_DEVICE_PROP_DESC: MAX_PARAMS(1); -#define DECLARE_FORM_NONE(type) -#define DECLARE_FORM_RANGE(type) \ - type##_t minimum_value; \ - type##_t maximum_value; \ - type##_t step_size; -#define DEFINE_FORM_NONE(name) -#define DEFINE_FORM_RANGE(name) \ - .minimum_value = name##_MIN, \ - .maximum_value = name##_MAX, \ - .step_size = name##_STEP, +#define INIT_FORM_NONE(type, name, value) (void)0 +#define INIT_FORM_RANGE(type, name, value) do { \ + name##_MIN((*(type##_t *)value)); \ + value += name##_SIZE(type##_t); \ + name##_MAX((*(type##_t *)value)); \ + value += name##_SIZE(type##_t); \ + name##_STEP((*(type##_t *)value)); \ + value += name##_SIZE(type##_t); \ + } while (0) #define GET_DEVICE_PROP_DESC_RESPONSE(type, name, form) \ if (global->transaction.payload.params[0] == \ MTP_DP_##name) { \ - static struct name##_DESC { \ - mtp_enum_t device_property_code; \ - mtp_enum_t datatype; \ - mtp_byte_t get_set; \ - type##_t factory_default_value; \ - type##_t current_value; \ - mtp_byte_t form_flag; \ - DECLARE_FORM_##form(type) \ - } name = { \ - .device_property_code = MTP_DP_##name, \ - .datatype = MTP_TC_##type, \ - .get_set = name##_GET_SET, \ - .factory_default_value = name##_DEF, \ - .current_value = name##_DEF, \ - .form_flag = MTP_FORM_##form, \ - DEFINE_FORM_##form(name) \ - }; \ - name##_GET(name.current_value); \ + mtp_device_property_description_t *desc = \ + LARGE_BUFFER; \ + desc->device_property_code = MTP_DP_##name; \ + desc->datatype = MTP_TC_##type; \ + desc->get_set = name##_GET_SET; \ + mtp_byte_t *value = desc->values; \ + name##_DEF((*(type##_t *)value)); \ + value += name##_SIZE(type##_t); \ + name##_GET((*(type##_t *)value)); \ + value += name##_SIZE(type##_t); \ + *value++ = MTP_FORM_##form; \ + INIT_FORM_##form(type, name, value); \ return schedule_data_in_response( \ - endpoint, &name, \ - sizeof(name), global); \ + endpoint, \ + LARGE_BUFFER, \ + value - (mtp_byte_t *)LARGE_BUFFER, \ + global); \ } FOR_EACH_SUPP_DP(GET_DEVICE_PROP_DESC_RESPONSE) return schedule_error_response( @@ -1752,11 +1806,12 @@ DEFINE_CALLBACK(command) { #define GET_DEVICE_PROP_VALUE_RESPONSE(type, name, form) \ if (global->transaction.payload.params[0] == \ MTP_DP_##name) { \ - type##_t current; \ - name##_GET(current); \ + name##_GET((*(type##_t *)LARGE_BUFFER)); \ return schedule_data_in_response( \ - endpoint, ¤t, \ - sizeof(current), global); \ + endpoint, \ + LARGE_BUFFER, \ + name##_SIZE(type##_t), \ + global); \ } FOR_EACH_SUPP_DP(GET_DEVICE_PROP_VALUE_RESPONSE) return schedule_error_response( @@ -2102,7 +2157,7 @@ DEFINE_CALLBACK(send_object_container) { .send_object.extra = transferred - sizeof(mtp_container_t); - memcpy(OBJECT_BUFFER, + memcpy(LARGE_BUFFER, global->transaction.payload.buffer, extra); if (extra && transferred != MTP_MAX_BULK_PKT_SZ) @@ -2110,7 +2165,7 @@ DEFINE_CALLBACK(send_object_container) { endpoint, status, extra, global); return usb_ScheduleBulkTransfer( endpoint, - OBJECT_BUFFER + extra, + LARGE_BUFFER + extra, global->transaction.container.length.word - sizeof(mtp_container_t) - extra, send_object_complete, @@ -2198,7 +2253,7 @@ static usb_error_t usb_event(usb_event_t event, (USB_DEVICE_TO_HOST | USB_STANDARD_REQUEST | USB_RECIPIENT_DEVICE) && - setup->bRequest == USB_GET_DESCRIPTOR_REQUEST && + setup->bRequest == USB_GET_DESCRIPTOR && setup->wValue == 0x03EE && !setup->wIndex) { DEFINE_STRING_DESCRIPTOR(const, os_specific); error = usb_ScheduleTransfer( @@ -2271,19 +2326,10 @@ int main(void) { static mtp_global_t global; usb_error_t error; ui_Init(); -#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(); + printf(" TRANSFER v0.0.2b\n" + " Connect USB to PC.\n" + " Press [clear] to exit.\n" + "--------------------------------"); static mtp_device_info_t device_info = { .standard_version = 100, /* 1.00 */ .mtp_vendor_extension_id = 6, @@ -2299,11 +2345,7 @@ int main(void) { FOR_EACH_SUPP_OPR(LIST_SUPP_OPR) }, .events_supported_length = lengthof(device_info.events_supported), - .events_supported = { -#define LIST_SUPP_EVT(name) \ - MTP_EVT_##name, - FOR_EACH_SUPP_EVT(LIST_SUPP_EVT) - }, + .events_supported = {}, .device_properties_length = lengthof(device_info.device_properties), .device_properties = { #define LIST_SUPP_DP(type, name, form) \ @@ -2324,8 +2366,14 @@ int main(void) { }, .manufacturer_length = lengthof(device_info.manufacturer), .manufacturer = Lmanufacturer, + .model_length = lengthof(Lproduct), + .model = Lproduct, + .device_version_length = lengthof(device_info.device_version), + .device_version = Ldevice_version, + .serial_number_length = lengthof(device_info.serial_number), + .serial_number = Lserial_number Lserial_number, }; -#define DEFINE_STORAGE_INFO(name) \ +#define DEFINE_STORAGE_INFO(name) \ static name##_mtp_storage_info_t name##_storage_info = { \ .storage_type = MTP_ST_FIXED_RAM, \ .filesystem_type = MTP_FT_GENERIC_FLAT, \ @@ -2343,7 +2391,7 @@ int main(void) { FOR_EACH_STORAGE(DEFINE_STORAGE_INFO) /* Standard USB Descriptors */ FOR_EACH_STRING_DESCRIPTOR(DEFINE_STRING_DESCRIPTOR) - DEFINE_STRING_DESCRIPTOR(const, product83) + DEFINE_STRING_DESCRIPTOR(const, product84) const static usb_string_descriptor_t *strings[] = { #define ADDRESSOF_STRING_DESCRIPTOR(const, name) &name, FOR_EACH_STRING_DESCRIPTOR(ADDRESSOF_STRING_DESCRIPTOR) @@ -2426,7 +2474,7 @@ int main(void) { .bMaxPacketSize0 = 0x40u, .idVendor = 0x0451u, .idProduct = 0xE010u, - .bcdDevice = 0x240u, /* 2.40 */ + .bcdDevice = 0x260u, /* 2.60 */ .iManufacturer = Imanufacturer, .iProduct = Iproduct, .iSerialNumber = Iserial_number, @@ -2440,68 +2488,38 @@ int main(void) { .strings = strings, }; const system_info_t *info = os_GetSystemInfo(); - for (mtp_byte_t i = 0; i != MTP_MAX_PENDING_EVENTS; ++i) - global.events[i].container.type = MTP_BT_EVENT; - mtp_byte_t *device_info_strings = &device_info.model_length; - if (info->hardwareType & 1) { - *device_info_strings++ = - lengthof(Lproduct83); - memcpy(device_info_strings, - Lproduct83, - sizeof(Lproduct83)); - device_info_strings += - sizeof(Lproduct83); - *(mtp_byte_t *)&device.bcdDevice = - 0x60; /* 2.60 */ - strings[Iproduct - 1] = &product83; - var_extensions[0x23][0] = 'p'; - } else { - *device_info_strings++ = - lengthof(Lproduct); - memcpy(device_info_strings, - Lproduct, - sizeof(Lproduct)); - device_info_strings += - sizeof(Lproduct); - } - { - char version[lengthof(Ldevice_version)]; - int count = - snprintf(version, lengthof(version), - "%u.%u.%u.%04u", - info->osMajorVersion, - info->osMinorVersion, - info->osRevisionVersion, - info->osBuildVersion); - mtp_byte_t size = count <= 0 ? 0 : count + 1; - *device_info_strings++ = size; - for (mtp_byte_t i = 0; i != size; ++i) { - *device_info_strings++ = version[i]; - device_info_strings++; - } - } - *device_info_strings++ = - lengthof(Lserial_number Lserial_number); - memcpy(device_info_strings, - Lserial_number, - sizeof(Lserial_number) - - sizeof(L'\0')); - device_info_strings += - sizeof(Lserial_number Lserial_number); - global.device_info = &device_info; - global.device_info_size = - device_info_strings - - (mtp_byte_t *)&device_info; -#define SET_STORAGE_INFO_PTR(name) \ - global.name##_storage_info = &name##_storage_info; - FOR_EACH_STORAGE(SET_STORAGE_INFO_PTR) wchar_t *serial_numbers[] = { &serial_number.bString[2 * lengthof(info->calcid)], - (wchar_t *)device_info_strings - 1, + &device_info.serial_number[4 * lengthof(info->calcid)], #define LIST_STORAGE_INFO_SERIAL(name) \ &name##_storage_info.volume_identifier[2 * lengthof(info->calcid)], FOR_EACH_STORAGE(LIST_STORAGE_INFO_SERIAL) }; + for (mtp_byte_t i = 0; i != MTP_MAX_PENDING_EVENTS; ++i) + global.events[i].container.type = MTP_BT_EVENT; + if (info->hardwareType & 1) { + global.device_icon_size = ti83pce_icon_uncompressed_size; + global.device_icon = ti83pce_icon; + global.device_info_size = sizeof(mtp_device_info_t); + } else { + global.device_icon_size = ti84pce_icon_uncompressed_size; + global.device_icon = ti84pce_icon; + *(mtp_byte_t *)&device.bcdDevice = 0x40; /* 2.40 */ + device_info.model_length = lengthof(Lproduct84); + memcpy(device_info.model, Lproduct84, sizeof(Lproduct84)); + memmove(&device_info.model[lengthof(Lproduct84)], + &device_info.device_version_length, + sizeof(mtp_device_info_t) - + offsetof(mtp_device_info_t, device_version_length)); + global.device_info_size = sizeof(mtp_device_info_t) - + sizeof(Lproduct) + sizeof(Lproduct84); + strings[Iproduct - 1] = &product84; + var_extensions[0x23][0] = 'e'; + } + global.device_info = &device_info; +#define SET_STORAGE_INFO_PTR(name) \ + global.name##_storage_info = &name##_storage_info; + FOR_EACH_STORAGE(SET_STORAGE_INFO_PTR) for (mtp_byte_t i = 2 * lengthof(info->calcid); i; ) { mtp_byte_t nibble = info->calcid[--i >> 1]; if (!(i & 1)) diff --git a/src/ui.c b/src/ui.c index 5e6394f..85a44cd 100644 --- a/src/ui.c +++ b/src/ui.c @@ -8,7 +8,9 @@ #include #include -static uint8_t static_rows, row, col, swap; +#define STATIC_ROWS 4 + +static uint8_t row, col, swap; #define buffer(n) (*(uint8_t (*)[4][LCD_WIDTH][LCD_HEIGHT >> 1])lcd_Ram)[(n) ^ swap] void ui_Init(void) { @@ -29,10 +31,6 @@ 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(); @@ -58,7 +56,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 d998800..e7f3eaf 100644 --- a/src/ui.h +++ b/src/ui.h @@ -2,7 +2,6 @@ #define UI_H void ui_Init(void); -void ui_Lock(void); void ui_Cleanup(void); #endif diff --git a/src/var.asm b/src/var.asm index 396f470..596fe92 100644 --- a/src/var.asm +++ b/src/var.asm @@ -234,11 +234,6 @@ _arc_unarc_var: ex (sp),iy push de .enter: - ld a,(de) - cp a,'A' - ret c - cp a,ti.tAns - ret z ld hl,.return call ti.PushErrorHandler lea hl,iy