From 33c9f0a57eae56e22943f20a8515d40f699e05f0 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 04:14:57 -0400 Subject: [PATCH 01/20] Add known working computer OS instructions to README. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f7119e8..be16234 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ Running this program on the calculator will allow you to transfer variable files Windows 10/Ubuntu 20.04/Android with preinstalled software, or other OSes with various PTP or MTP transfer software. +## Known Working Computer OSes +- Windows 10 using the default file explorer, check under Computer after connecting. +- Ubuntu 20.04 using the default Dolphin File Manager. +- 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/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. From cd6d57b0207e627fb059c5d5c4bab8e49801081d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 04:28:51 -0400 Subject: [PATCH 02/20] Add license. --- LICENSE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6c358c8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019 - 2021 Jacob "jacobly" Young + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 42e90a92f713ff7e5305d5ac16ef7665b0c468d7 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 11:39:02 -0400 Subject: [PATCH 03/20] Add nautilus as a supported ubuntu file browser. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be16234..0861d48 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ PTP or MTP transfer software. ## Known Working Computer OSes - Windows 10 using the default file explorer, check under Computer after connecting. -- Ubuntu 20.04 using the default Dolphin File Manager. +- Ubuntu 20.04 using the default Gnome Files (nautilus) or Dolphin. - Android 11 using the builtin Files application, check notifications after connecting to open. ## Installation From 397ab473a99d040af5bfb9f46c6dfdc8ecff6926 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 15:36:05 -0400 Subject: [PATCH 04/20] Fix sending in data that is a multiple of the max packet size. --- src/main.c | 61 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/main.c b/src/main.c index 3737e58..33a1afe 100644 --- a/src/main.c +++ b/src/main.c @@ -819,6 +819,7 @@ DECLARE_CALLBACK(get_object); DECLARE_CALLBACK(send_object_info); DECLARE_CALLBACK(send_object_container); DECLARE_CALLBACK(send_object); +DECLARE_CALLBACK(zlp_data_in); DECLARE_CALLBACK(final_data_in); DECLARE_CALLBACK(response); DECLARE_CALLBACK(event); @@ -955,33 +956,6 @@ static usb_error_t schedule_ok_response( params, param_count, global); } -static usb_error_t schedule_data_in_response( - usb_endpoint_t endpoint, - const void *data, - size_t data_size, - mtp_global_t *global) { - usb_error_t error; - global->transaction.container.length.size = - sizeof(mtp_container_t) + - data_size; - global->transaction.container.type = - MTP_BT_DATA; - error = usb_ScheduleBulkTransfer( - endpoint = get_endpoint( - endpoint, MTP_EP_DATA_IN), - &global->transaction, - sizeof(mtp_container_t), - NULL, - global); - if (error) return error; - return usb_ScheduleBulkTransfer( - endpoint, - (void *)data, - data_size, - final_data_in_complete, - global); -} - static usb_error_t schedule_data_in( usb_endpoint_t endpoint, size_t data_size, @@ -1001,6 +975,27 @@ static usb_error_t schedule_data_in( global); } +static usb_error_t schedule_data_in_response( + usb_endpoint_t endpoint, + const void *data, + size_t data_size, + mtp_global_t *global) { + usb_error_t error = schedule_data_in( + endpoint, data_size, NULL, global); + if (error == USB_SUCCESS) + error = usb_ScheduleBulkTransfer( + get_endpoint(endpoint, + MTP_EP_DATA_IN), + (void *)data, + data_size, + data_size && + !(data_size % MTP_MAX_BULK_PKT_SZ) + ? zlp_data_in_complete + : final_data_in_complete, + global); + return error; +} + static usb_error_t status_error( usb_transfer_status_t status) { printf("transfer status = %02X\n", status); @@ -2144,6 +2139,18 @@ DEFINE_CALLBACK(send_object) { endpoint, response, NULL, 0, global); } +DEFINE_CALLBACK(zlp_data_in) { + (void)transferred; + if (status != USB_TRANSFER_COMPLETED) + return status_error(status); + if (global->reset) + return schedule_command(endpoint, global); + return usb_ScheduleBulkTransfer( + endpoint, NULL, 0, + final_data_in_complete, + global); +} + DEFINE_CALLBACK(final_data_in) { (void)transferred; if (status != USB_TRANSFER_COMPLETED) From 3210d78938092bbe1602e73fbd9ffc8cf24f2c59 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 20:02:07 -0400 Subject: [PATCH 05/20] Fix receiving archived unnamed variables. --- src/var.asm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/var.asm b/src/var.asm index 1954a5e..eb7300d 100644 --- a/src/var.asm +++ b/src/var.asm @@ -124,11 +124,16 @@ _get_var_data_ptr: ex de,hl bit 15,bc ret nz - ld bc,9 - add hl,bc - ld c,(hl) - add hl,bc - inc hl + ex de,hl + call ti.Sym_Prog_non_t_Lst + jq z,.named + ld c,2 +.named: + ex de,hl + ld de,10 + add hl,de + ld e,c + add hl,de ret section .text From fee2ba9b6f03fcb92fc5e831a44e88958e1521d8 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 21:13:46 -0400 Subject: [PATCH 06/20] Add some missing checks. --- src/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index 33a1afe..84616b7 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,9 @@ typedef struct mtp_global mtp_global_t; X(SET_DEVICE_PROP_VALUE) \ X(MOVE_OBJECT) -#define FOR_EACH_SUPP_EVT(X) +#define FOR_EACH_SUPP_EVT(X) \ + X(OBJECT_ADDED) \ + X(OBJECT_REMOVED) #define FOR_EACH_SUPP_DP(X) \ X(uint8, BATTERY_LEVEL, RANGE) \ @@ -1061,11 +1063,9 @@ static void get_datetime( boot_GetTime(&second, &minute, &hour); sprintf(string, "%04u%02u%02uT%02u%02u%02u", year, month, day, hour, minute, second); - do { - *(char *)result = *pointer; - ++result; - ++pointer; - } while (--i); + do + *(char *)result++ = *pointer++; + while (--i); } static int delete_object( @@ -1749,6 +1749,7 @@ DEFINE_CALLBACK(command) { MTP_RSP_DEVICE_PROP_NOT_SUPPORTED, global); case MTP_OPR_GET_DEVICE_PROP_VALUE: + MAX_PARAMS(1); #define GET_DEVICE_PROP_VALUE_RESPONSE(type, name, form) \ if (global->transaction.payload.params[0] == \ MTP_DP_##name) { \ @@ -1764,6 +1765,7 @@ DEFINE_CALLBACK(command) { MTP_RSP_DEVICE_PROP_NOT_SUPPORTED, global); case MTP_OPR_SET_DEVICE_PROP_VALUE: + MAX_PARAMS(1); usb_ScheduleBulkTransfer( endpoint, &global->transaction.payload, From c02c4733771d9cdb0376768d063a47f971b23044 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 21:19:19 -0400 Subject: [PATCH 07/20] Update readme. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0861d48..9c55200 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ PTP or MTP transfer software. - [ ] Receiving a rom dump. - [ ] Copying variables in either RAM or Archive to another name in either RAM or Archive. - [x] Getting free space in RAM or Archive. -- [x] Geting and seting the current time. -- [x] Geting the current battery level. -- [ ] Geting a device icon for displaying in MTP program UIs. +- [x] Getting the current time. +- [ ] Setting the current time. +- [x] Getting the current battery level. +- [ ] ~~Getting a device icon for displaying in MTP program UIs.~~ - [ ] Optimize for a smaller program size. From d8f0a1f986b497e1b1005edd1de3621047c5c2a2 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 22:21:04 -0400 Subject: [PATCH 08/20] Fix image file names. --- src/var.asm | 21 +++++++++++++++++++-- src/var.h | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/var.asm b/src/var.asm index eb7300d..596fe92 100644 --- a/src/var.asm +++ b/src/var.asm @@ -6,10 +6,9 @@ private ti.DataSize private ti.DelVarArc private ti.EquObj - private ti.flags - private ti.GroupObj private ti.Get_Tok_Strng private ti.GroupObj + private ti.GroupObj private ti.Mov9ToOP1 private ti.OP1 private ti.OP3 @@ -18,13 +17,19 @@ private ti.ProgObj private ti.ProtProgObj private ti.PushErrorHandler + private ti.flags private ti.tAns + private ti.tExtTok private ti.tRecurn private ti.tVarLst private ti.tVarOut include 'ti84pceg.inc' + private ImageObj + private tVarImage1 private varTypeMask +ImageObj := $1A +tVarImage1 := $50 varTypeMask := $3F private DELETE_VAR_NOT_DELETED @@ -260,6 +265,8 @@ _get_var_file_name: sub a,(ti.AppVarObj-ti.ProtProgObj-1) shl 1 sub a,(ti.GroupObj-ti.AppVarObj+1) shl 1 jq c,.named + sub a,(ImageObj-ti.GroupObj-1) shl 1 + jq z,.image ld a,(de) cp a,'.' jq z,.namedEnter @@ -336,6 +343,12 @@ _get_var_file_name: ld a,13 sub a,c ret +.image: + inc de + ld a,(de) + ld de,_image_name+1 + add a,tVarImage1 + ld (de),a .list: dec de .token: @@ -349,6 +362,10 @@ _get_var_file_name: jq .named section .data + public _image_name +_image_name: + db ti.tExtTok,tVarImage1 + public _var_extensions _var_extensions: db "xnxlxmxyxsxpxpci" diff --git a/src/var.h b/src/var.h index 36289b5..072fb33 100644 --- a/src/var.h +++ b/src/var.h @@ -69,7 +69,7 @@ uint8_t create_var(const var_name_t *var_name, const void *data, size_t size); uint8_t arc_unarc_var(const var_name_t *var_name); uint8_t get_var_file_name(const var_name_t *var_name, - wchar_t file_name[13]); + wchar_t file_name[MAX_FILE_NAME_LENGTH]); #ifdef __cplusplus } From 5ed318f89404b250e9fefd08c2d2751ae02ff502 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 13 Apr 2021 21:44:10 -0400 Subject: [PATCH 09/20] Tag v0.0.2b release. --- CHANGELOG.md | 8 ++++++++ README.md | 2 +- src/main.c | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b713927 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# prgmTRANSFER + +## v0.0.1b +- Initial beta release + +## v0.0.2b +- Fix corrupted screen, crash, or garbage data when receiving some variables from Archive. +- Fix incorrect file names for images. diff --git a/README.md b/README.md index 9c55200..62cb334 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# prgmTRANSFER v0.0.1b +# prgmTRANSFER v0.0.2b ### This software is still in beta, no liability for corrupted or lost files, etc! diff --git a/src/main.c b/src/main.c index 84616b7..f9d1200 100644 --- a/src/main.c +++ b/src/main.c @@ -2272,7 +2272,7 @@ int main(void) { static mtp_global_t global; usb_error_t error; ui_Init(); - printf(" TRANSFER v0.0.1b\n" + printf(" TRANSFER v0.0.2b\n" " Connect USB to PC.\n" " Press [clear] to exit.\n" "--------------------------------"); From 0b3b3dbe34edeee2db85d6d0b04e449631076b6c Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Wed, 14 Apr 2021 10:56:29 -0400 Subject: [PATCH 10/20] Mac compatibility I guess. --- font/genfont.c | 6 +++--- makefile | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/font/genfont.c b/font/genfont.c index 786da1f..306ec99 100644 --- a/font/genfont.c +++ b/font/genfont.c @@ -5,14 +5,14 @@ #include #include #include -#include int main(int argc, char **argv) { FT_Library library; FT_Error error; FT_Face face; if ((error = FT_Init_FreeType(&library)) || - (error = FT_New_Face(library, "/usr/share/fonts/fonts-master/apache/robotomono/RobotoMono-Medium.ttf", 0, &face)) || + ((error = FT_New_Face(library, "/usr/share/fonts/fonts-master/apache/robotomono/RobotoMono-Medium.ttf", 0, &face)) && + (error = FT_New_Face(library, "/Library/Fonts/RobotoMono-Medium.ttf", 0, &face))) || (error = FT_Set_Char_Size(face, 0, 550, 0, 141)) || (error = FT_Load_Char(face, U'w', FT_LOAD_DEFAULT))) return error; int width = face->glyph->advance.x >> 6, height = face->size->metrics.height >> 6, height_bytes = (height + 1) >> 1; @@ -45,7 +45,7 @@ int main(int argc, char **argv) { "const uint8_t font[0x100][FONT_WIDTH][FONT_HEIGHT_BYTES] = {\n"); uint8_t *bitmap = calloc(width, height_bytes); if (!bitmap) return 1; - for (char32_t c = U'\0'; c <= U'\xFF'; ++c) { + for (uint32_t c = U'\0'; c <= U'\xFF'; ++c) { memset(bitmap, 0, width * height_bytes); if ((error = FT_Load_Char(face, c, FT_LOAD_DEFAULT)) || (error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL))) return error; diff --git a/makefile b/makefile index dc428c8..c4ad118 100644 --- a/makefile +++ b/makefile @@ -2,6 +2,8 @@ # Makefile Options # ---------------------------- +CC = clang + NAME ?= TRANSFER ICON ?= transfer.png DESCRIPTION ?= "Variable Transfer Program" @@ -27,4 +29,4 @@ src/font.h src/font.c: font/genfont @$< font/genfont: font/genfont.c - @clang -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ + @$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ From 0b40c0d4a94064a7ff1ccef7eacabcc04801aa9a Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 06:36:29 -0400 Subject: [PATCH 11/20] Remove cruft not needed with fixed upstream makefile. --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index c4ad118..623ef81 100644 --- a/makefile +++ b/makefile @@ -13,7 +13,7 @@ ARCHIVED ?= YES CFLAGS ?= -Wall -Wextra -Oz CXXFLAGS ?= -Wall -Wextra -Oz -EXTRA_CSOURCES ?= $(if $(wildcard src/font.c),,src/font.c) +EXTRA_CSOURCES ?= src/font.c EXTRA_USERHEADERS ?= src/ti84pceg.inc src/font.h EXTRA_CLEAN ?= src/font.c src/font.h font/genfont From 6048945f1a64ca39c058972ebfcd52676bedca83 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 06:37:07 -0400 Subject: [PATCH 12/20] Use new upstream usbdrvce features. --- src/main.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index f9d1200..20b9afe 100644 --- a/src/main.c +++ b/src/main.c @@ -842,18 +842,12 @@ static usb_endpoint_t get_endpoint( static usb_error_t stall_data_endpoints( usb_endpoint_t endpoint) { printf("stalling data endpoints\n"); -#if 0 - usb_error_t error; - error = usb_StallEndpoint( + usb_error_t error = usb_SetEndpointHalt( get_endpoint(endpoint, MTP_EP_DATA_IN)); if (error == USB_SUCCESS) - error = usb_StallEndpoint( + error = usb_SetEndpointHalt( get_endpoint(endpoint, MTP_EP_DATA_OUT)); return error; -#else - (void)endpoint; - return USB_ERROR_FAILED; -#endif } static usb_error_t schedule_event( @@ -2199,7 +2193,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 && + setup->bRequest == USB_GET_DESCRIPTOR_REQUEST && setup->wValue == 0x03EE && !setup->wIndex) { DEFINE_STRING_DESCRIPTOR(const, os_specific); error = usb_ScheduleTransfer( From 930d5a634a110c8cf63de94bf89b045ddc6bf21c Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 06:44:51 -0400 Subject: [PATCH 13/20] Improve makefile. --- makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 623ef81..b678d38 100644 --- a/makefile +++ b/makefile @@ -26,7 +26,9 @@ endif include $(CEDEV)/meta/makefile.mk src/font.h src/font.c: font/genfont - @$< + $(Q)echo [running] $< + $(Q)$< font/genfont: font/genfont.c - @$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ + $(Q)echo [compiling] $< + $(Q)$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ From 908e208529a9826fa57e919fc69b7b39555ca59d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 07:25:44 -0400 Subject: [PATCH 14/20] 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 From ecafcfadfe6ae8f3c7e485168ceaaa0f8ab725f0 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 06:37:18 -0400 Subject: [PATCH 15/20] Tag v0.0.3b release. --- CHANGELOG.md | 4 ++++ README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b713927..b15cc11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,7 @@ ## 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. diff --git a/README.md b/README.md index 62cb334..91d7485 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# prgmTRANSFER v0.0.2b +# prgmTRANSFER v0.0.3b ### This software is still in beta, no liability for corrupted or lost files, etc! From a65a8a2e466522889789d702c610d924d8a89a04 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Apr 2021 07:39:14 -0400 Subject: [PATCH 16/20] Bump version. --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index 049db9b..978a554 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,7 @@ CC ?= clang NAME ?= TRANSFER MAJOR_VERSION ?= 0 MINOR_VERSION ?= 0 -PATCH_VERSION ?= 3 +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) From e2d275945f8c8a7bf6126373e5075a217ad05371 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 23 Apr 2021 18:52:20 -0400 Subject: [PATCH 17/20] Set device version to OS version. --- src/main.c | 133 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 50 deletions(-) diff --git a/src/main.c b/src/main.c index 2d5b57b..292596f 100644 --- a/src/main.c +++ b/src/main.c @@ -128,13 +128,13 @@ typedef struct mtp_global mtp_global_t; } #define DATE_TIME_GET_SET 1 #define DATE_TIME_GET(current) \ - get_datetime(current.string) + get_datetime(¤t) #define DATE_TIME_SET(new) #define PERCEIVED_DEVICE_TYPE_DEF 0 #define PERCEIVED_DEVICE_TYPE_GET_SET 0 #define PERCEIVED_DEVICE_TYPE_GET(current) \ - current = 3 + current = 5 #define PERCEIVED_DEVICE_TYPE_SET(new) /* MTP Types */ @@ -167,16 +167,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-83 Premium CE" /* default must be longer than alt */ -#define Lproduct84 L"TI-84 Plus CE" -#define Ldevice_version L"2.20" +#define Lproduct L"TI-84 Plus CE" +#define Lproduct83 L"TI-83 Premium CE" +#define Ldevice_version L"255.255.255.65535" #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 { @@ -717,7 +717,8 @@ 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)]; + wchar_t model[lengthof(Lproduct) > lengthof(Lproduct83) ? + lengthof(Lproduct) : lengthof(Lproduct83)]; mtp_byte_t device_version_length; wchar_t device_version[lengthof(Ldevice_version)]; mtp_byte_t serial_number_length; @@ -1050,19 +1051,19 @@ static uint16_t compute_checksum( } static void get_datetime( - wchar_t result[lengthof(Lfactory_datetime)]) { + datetime_t *result) { uint16_t year; - uint8_t month, day, hour, minute, second, - i = lengthof(Lfactory_datetime); - char string[lengthof(Lfactory_datetime)], - *pointer = string; + uint8_t month, day, hour, minute, second; + char string[lengthof(Lfactory_datetime)]; boot_GetDate(&day, &month, &year); boot_GetTime(&second, &minute, &hour); - sprintf(string, "%04u%02u%02uT%02u%02u%02u", - year, month, day, hour, minute, second); - do - *(char *)result++ = *pointer++; - while (--i); + 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]; } static int delete_object( @@ -2297,7 +2298,11 @@ int main(void) { FOR_EACH_SUPP_OPR(LIST_SUPP_OPR) }, .events_supported_length = lengthof(device_info.events_supported), - .events_supported = {}, + .events_supported = { +#define LIST_SUPP_EVT(name) \ + MTP_EVT_##name, + FOR_EACH_SUPP_EVT(LIST_SUPP_EVT) + }, .device_properties_length = lengthof(device_info.device_properties), .device_properties = { #define LIST_SUPP_DP(type, name, form) \ @@ -2318,14 +2323,8 @@ 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 +2342,7 @@ int main(void) { FOR_EACH_STORAGE(DEFINE_STORAGE_INFO) /* Standard USB Descriptors */ FOR_EACH_STRING_DESCRIPTOR(DEFINE_STRING_DESCRIPTOR) - DEFINE_STRING_DESCRIPTOR(const, product84) + DEFINE_STRING_DESCRIPTOR(const, product83) const static usb_string_descriptor_t *strings[] = { #define ADDRESSOF_STRING_DESCRIPTOR(const, name) &name, FOR_EACH_STRING_DESCRIPTOR(ADDRESSOF_STRING_DESCRIPTOR) @@ -2426,7 +2425,7 @@ int main(void) { .bMaxPacketSize0 = 0x40u, .idVendor = 0x0451u, .idProduct = 0xE010u, - .bcdDevice = 0x260u, /* 2.60 */ + .bcdDevice = 0x240u, /* 2.40 */ .iManufacturer = Imanufacturer, .iProduct = Iproduct, .iSerialNumber = Iserial_number, @@ -2440,34 +2439,68 @@ 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)], - &device_info.serial_number[4 * lengthof(info->calcid)], + (wchar_t *)device_info_strings - 1, #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_info_size = sizeof(mtp_device_info_t); - else { - *(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)) From b5116f962d2686a5d53045ab2d098fe79825221c Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 4 May 2021 20:29:44 -0400 Subject: [PATCH 18/20] Fix #2. --- src/var.asm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/var.asm b/src/var.asm index 596fe92..396f470 100644 --- a/src/var.asm +++ b/src/var.asm @@ -234,6 +234,11 @@ _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 From 7f6c87fcc7815d6ab612d34ba62a48209fda402f Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Mon, 5 Jul 2021 21:53:52 -0400 Subject: [PATCH 19/20] Update artifact url. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91d7485..d70810b 100644 --- a/README.md +++ b/README.md @@ -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/a/toolchain/usbdrvce/clibs.zip) 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/artifact?repo=toolchain&branch=usbdrvce&file=clibs) 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. From 54b210eb14d1fee112cc5d91816635c951a7ab9a Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 12 Feb 2022 17:37:44 -0500 Subject: [PATCH 20/20] Tag v0.0.4b release. --- CHANGELOG.md | 3 +++ README.md | 2 +- makefile | 44 ++++++++++++++++++++------------------------ src/main.c | 1 + 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b15cc11..c49461d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,3 +10,6 @@ ## 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 d70810b..56aa779 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# prgmTRANSFER v0.0.3b +# prgmTRANSFER v0.0.4b ### This software is still in beta, no liability for corrupted or lost files, etc! diff --git a/makefile b/makefile index 978a554..d4a9d91 100644 --- a/makefile +++ b/makefile @@ -2,35 +2,31 @@ # Makefile Options # ---------------------------- -CC ?= clang +NATIVECC = clang -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)" -COMPRESSED ?= YES -ARCHIVED ?= YES +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)" +COMPRESSED = YES +ARCHIVED = YES -FLAGS ?= -Wall -Wextra -Oz -DVERSION='"$(FULL_VERSION)"' -CFLAGS ?= $(FLAGS) -CXXFLAGS ?= $(FLAGS) +FLAGS = -Wall -Wextra -Oz -DVERSION='"$(FULL_VERSION)"' +CFLAGS = $(FLAGS) +CXXFLAGS = $(FLAGS) -EXTRA_CSOURCES ?= src/font.c -EXTRA_USERHEADERS ?= src/ti84pceg.inc src/font.h -EXTRA_CLEAN ?= src/font.c src/font.h font/genfont +EXTRA_CSOURCES = src/font.c +EXTRA_USERHEADERS = src/ti84pceg.inc src/font.h +EXTRA_CLEAN = src/font.c src/font.h font/genfont # ---------------------------- -ifndef CEDEV -$(error CEDEV environment path variable is not set) -endif - -include $(CEDEV)/meta/makefile.mk +include $(shell cedev-config --makefile) all: $(Q)echo [done] prgm$(NAME) $(FULL_VERSION) @@ -49,4 +45,4 @@ src/font.h src/font.c: font/genfont makefile font/genfont: font/genfont.c makefile $(Q)echo [compiling] $< - $(Q)$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ + $(Q)$(NATIVECC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@ diff --git a/src/main.c b/src/main.c index 292596f..3499fb3 100644 --- a/src/main.c +++ b/src/main.c @@ -1181,6 +1181,7 @@ static int send_object( version = entry->version; flag = entry->flag; } + (void)version; flag &= global->transaction.pending .send_object.mask; flag |= global->transaction.pending