Compare commits

..

12 commits

Author SHA1 Message Date
Jacob Young
90bd5c0416 Add device icon. 2021-04-14 10:59:45 -04:00
Jacob Young
b0046f3f0e Mac compatibility I guess. 2021-04-14 10:59:16 -04:00
Jacob Young
45980d5c1c Tag 0.0.2b release. 2021-04-13 22:32:05 -04:00
Jacob Young
81e5234be1 Fix image file names. 2021-04-13 22:31:46 -04:00
Jacob Young
47e228f052 Update readme. 2021-04-13 21:39:14 -04:00
Jacob Young
0928c2855c Add some missing checks. 2021-04-13 21:39:14 -04:00
Jacob Young
8cd1815417 Fix receiving archived unnamed variables. 2021-04-13 21:39:14 -04:00
Jacob Young
96833322de Fix sending in data that is a multiple of the max packet size. 2021-04-13 21:14:18 -04:00
Jacob Young
18adbb523c Add nautilus as a supported ubuntu file browser. 2021-04-13 11:39:02 -04:00
Jacob Young
c0b584ac77 Add license. 2021-04-13 04:28:51 -04:00
Jacob Young
6b39fe15f8 Add known working computer OS instructions to README. 2021-04-13 04:14:57 -04:00
Jacob Young
ce2d78cc25 Tag 0.0.1b release. 2021-04-13 03:54:38 -04:00
18 changed files with 222 additions and 215 deletions

3
.gitignore vendored
View file

@ -1,4 +1,7 @@
icon/ti83pce.ico
icon/ti84pce.ico
font/genfont font/genfont
src/font.* src/font.*
src/*_icon.*
obj/* obj/*
bin/* bin/*

View file

@ -6,10 +6,3 @@
## v0.0.2b ## v0.0.2b
- Fix corrupted screen, crash, or garbage data when receiving some variables from Archive. - Fix corrupted screen, crash, or garbage data when receiving some variables from Archive.
- Fix incorrect file names for images. - 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.

View file

@ -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! ### 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. - Android 11 using the builtin Files application, check notifications after connecting to open.
## Installation ## 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. 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. 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. 1. Press `clear` to exit.

BIN
icon/ti83pce-128.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
icon/ti83pce-256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
icon/ti83pce-32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
icon/ti83pce-64.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
icon/ti84pce-128.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
icon/ti84pce-256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
icon/ti84pce-32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
icon/ti84pce-64.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

View file

@ -2,47 +2,48 @@
# Makefile Options # Makefile Options
# ---------------------------- # ----------------------------
NATIVECC = clang CC = clang
CONVERT = convert
PRINTF = printf
NAME = TRANSFER NAME = TRANSFER
MAJOR_VERSION = 0 ICON = icon/transfer.png
MINOR_VERSION = 0 DESCRIPTION = "Variable Transfer Program"
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 COMPRESSED = YES
ARCHIVED = YES ARCHIVED = YES
FLAGS = -Wall -Wextra -Oz -DVERSION='"$(FULL_VERSION)"' CFLAGS = -Wall -Wextra -Oz
CFLAGS = $(FLAGS) CXXFLAGS = -Wall -Wextra -Oz
CXXFLAGS = $(FLAGS)
EXTRA_CSOURCES = src/font.c ICON_COLORS = 16
EXTRA_USERHEADERS = src/ti84pceg.inc src/font.h ICON_SIZES = 32 64
EXTRA_CLEAN = src/font.c src/font.h font/genfont
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: include $(CEDEV)/meta/makefile.mk
$(Q)echo [done] prgm$(NAME) $(FULL_VERSION)
beta: KIND_VERSION = b icon/%.ico: $(patsubst %,icon/\%-%.ico,$(ICON_SIZES))
beta: BUILD_VERSION = @$(CONVERT) $^ -colors $(ICON_COLORS) $@
beta: all
release: BUILD_VERSION = src/%_icon.h: icon/%.ico
release: REV_VERSION = @$(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" > $@
release: all
src/font.h src/font.c: font/genfont makefile src/%_icon.c: icon/%.ico
$(Q)echo [running] $< @$(CONVBIN) --iformat bin --input $< --compress zx7 --name $*_icon --oformat c --output $@
$(Q)$<
font/genfont: font/genfont.c makefile src/font.h src/font.c: font/genfont
$(Q)echo [compiling] $< @$<
$(Q)$(NATIVECC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@
font/genfont: font/genfont.c
@$(CC) -O3 -flto $< `pkg-config --cflags --libs freetype2` -o $@
.SECONDARY: $(EXTRA_CLEAN)

View file

@ -14,7 +14,8 @@ typedef struct mtp_global mtp_global_t;
#define usb_transfer_data_t mtp_global_t #define usb_transfer_data_t mtp_global_t
/* Includes */ /* Includes */
#include "font.h" #include "ti83pce_icon.h"
#include "ti84pce_icon.h"
#include "ui.h" #include "ui.h"
#include "var.h" #include "var.h"
@ -22,7 +23,7 @@ typedef struct mtp_global mtp_global_t;
#include <fileioc.h> #include <fileioc.h>
#include <usbdrvce.h> #include <usbdrvce.h>
#include <debug.h> #include <compression.h>
#include <tice.h> #include <tice.h>
#include <inttypes.h> #include <inttypes.h>
@ -37,11 +38,9 @@ typedef struct mtp_global mtp_global_t;
#define lengthof(array) (sizeof(array) / sizeof(*(array))) #define lengthof(array) (sizeof(array) / sizeof(*(array)))
#define charsof(literal) (lengthof(literal) - 1)
#define COUNT_EACH(...) +1 #define COUNT_EACH(...) +1
#define OBJECT_BUFFER \ #define LARGE_BUFFER \
((void *)((mtp_byte_t *)lcd_Ram + LCD_WIDTH * LCD_HEIGHT)) ((void *)((mtp_byte_t *)lcd_Ram + LCD_WIDTH * LCD_HEIGHT))
#define FOR_EACH_SUPP_OPR(X) \ #define FOR_EACH_SUPP_OPR(X) \
@ -66,10 +65,11 @@ typedef struct mtp_global mtp_global_t;
X(OBJECT_ADDED) \ X(OBJECT_ADDED) \
X(OBJECT_REMOVED) X(OBJECT_REMOVED)
#define FOR_EACH_SUPP_DP(X) \ #define FOR_EACH_SUPP_DP(X) \
X(uint8, BATTERY_LEVEL, RANGE) \ X(uint8, BATTERY_LEVEL, RANGE) \
X(datetime, DATE_TIME, NONE) \ X(datetime, DATE_TIME, NONE) \
X(uint32, PERCEIVED_DEVICE_TYPE, NONE) X(uint32, PERCEIVED_DEVICE_TYPE, NONE) \
X(auint8, DEVICE_ICON, NONE)
#define FOR_EACH_SUPP_CF(X) \ #define FOR_EACH_SUPP_CF(X) \
X(UNDEFINED) X(UNDEFINED)
@ -113,32 +113,60 @@ typedef struct mtp_global mtp_global_t;
#define get_arc_free_space_in_bytes \ #define get_arc_free_space_in_bytes \
(os_ArcChk(), os_TempFreeArc) (os_ArcChk(), os_TempFreeArc)
#define BATTERY_LEVEL_MIN 0 #define BATTERY_LEVEL_MIN(value) value = 0
#define BATTERY_LEVEL_MAX 4 #define BATTERY_LEVEL_MAX(value) value = 4
#define BATTERY_LEVEL_STEP 1 #define BATTERY_LEVEL_STEP(value) value = 1
#define BATTERY_LEVEL_DEF 0 #define BATTERY_LEVEL_SIZE sizeof
#define BATTERY_LEVEL_GET_SET 0 #define BATTERY_LEVEL_DEF(value) value = 0
#define BATTERY_LEVEL_GET(current) \ #define BATTERY_LEVEL_GET_SET 0
current = boot_GetBatteryStatus() #define BATTERY_LEVEL_GET(value) \
#define BATTERY_LEVEL_SET(new) value = boot_GetBatteryStatus()
#define BATTERY_LEVEL_SET(value) (void)0
#define DATE_TIME_DEF { \ #define DATE_TIME_SIZE sizeof
.length = lengthof(Lfactory_datetime), \ #define DATE_TIME_DEF(value) do { \
.string = Lfactory_datetime, \ value.length = \
} lengthof(Lfactory_datetime); \
#define DATE_TIME_GET_SET 1 memcpy(value.string, \
#define DATE_TIME_GET(current) \ Lfactory_datetime, \
get_datetime(&current) sizeof(value.string)); \
#define DATE_TIME_SET(new) } 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_SIZE sizeof
#define PERCEIVED_DEVICE_TYPE_GET_SET 0 #define PERCEIVED_DEVICE_TYPE_DEF(value) value = 0
#define PERCEIVED_DEVICE_TYPE_GET(current) \ #define PERCEIVED_DEVICE_TYPE_GET_SET 0
current = 5 #define PERCEIVED_DEVICE_TYPE_GET(value) value = 3
#define PERCEIVED_DEVICE_TYPE_SET(new) #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 */ /* 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 uint8_t mtp_byte_t;
typedef uint16_t mtp_version_t; typedef uint16_t mtp_version_t;
typedef uint16_t mtp_enum_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_id_t;
typedef uint32_t mtp_param_t; typedef uint32_t mtp_param_t;
typedef uint64_t mtp_uint64_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) \ #define DECLARE_TRUNC_TYPE(name) \
typedef union mtp_trunc_##name { \ typedef union mtp_trunc_##name { \
mtp_##name##_t name; \ mtp_##name##_t name; \
@ -167,16 +212,16 @@ typedef usb_error_t(*mtp_transaction_callback_t)(
#define Los_specific L"MSFT100\1" #define Los_specific L"MSFT100\1"
#define Lmtp_extensions L"microsoft.com: 1.0;" #define Lmtp_extensions L"microsoft.com: 1.0;"
#define Lmanufacturer L"Texas Instruments Incorporated" #define Lmanufacturer L"Texas Instruments Incorporated"
#define Lproduct L"TI-84 Plus CE" #define Lproduct L"TI-83 Premium CE" /* default must be longer than alt */
#define Lproduct83 L"TI-83 Premium CE" #define Lproduct84 L"TI-84 Plus CE"
#define Ldevice_version L"255.255.255.65535" #define Ldevice_version L"2.20"
#define Lserial_number L"0000000000000000" #define Lserial_number L"0000000000000000"
#define Lcharging_cfg L"Charging" #define Lcharging_cfg L"Charging"
#define Lmtp_interface L"MTP" /* magic string to aid detection */ #define Lmtp_interface L"MTP" /* magic string to aid detection */
#define Lram_storage_desc L"RAM" #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_storage_desc L"Archive"
#define Larc_volume_id Lserial_number "A" #define Larc_volume_id Lserial_number"A"
#define Lfactory_datetime L"20150101T000000" #define Lfactory_datetime L"20150101T000000"
typedef enum string_id { typedef enum string_id {
@ -647,6 +692,13 @@ typedef enum mtp_object_property_code {
/* MTP Structures */ /* 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 { typedef struct mtp_object_info_header {
mtp_trunc_id_t storage_id; mtp_trunc_id_t storage_id;
mtp_enum_t object_format; mtp_enum_t object_format;
@ -717,8 +769,7 @@ typedef struct mtp_device_info {
mtp_byte_t manufacturer_length; mtp_byte_t manufacturer_length;
wchar_t manufacturer[lengthof(Lmanufacturer)]; wchar_t manufacturer[lengthof(Lmanufacturer)];
mtp_byte_t model_length; mtp_byte_t model_length;
wchar_t model[lengthof(Lproduct) > lengthof(Lproduct83) ? wchar_t model[lengthof(Lproduct)];
lengthof(Lproduct) : lengthof(Lproduct83)];
mtp_byte_t device_version_length; mtp_byte_t device_version_length;
wchar_t device_version[lengthof(Ldevice_version)]; wchar_t device_version[lengthof(Ldevice_version)];
mtp_byte_t serial_number_length; mtp_byte_t serial_number_length;
@ -797,6 +848,8 @@ struct mtp_global {
mtp_transaction_t transaction; mtp_transaction_t transaction;
mtp_event_t events[MTP_MAX_PENDING_EVENTS]; mtp_event_t events[MTP_MAX_PENDING_EVENTS];
/* MTP Info */ /* MTP Info */
size_t device_icon_size;
const void *device_icon;
size_t device_info_size; size_t device_info_size;
const mtp_device_info_t *device_info; const mtp_device_info_t *device_info;
#define DECLARE_STORAGE_INFO(name) \ #define DECLARE_STORAGE_INFO(name) \
@ -831,6 +884,7 @@ DECLARE_CALLBACK(response);
DECLARE_CALLBACK(event); DECLARE_CALLBACK(event);
/* Other Forward Function Declarations */ /* Other Forward Function Declarations */
usb_error_t wait_for_usb(mtp_global_t *global); usb_error_t wait_for_usb(mtp_global_t *global);
/* MTP Function Definitions */ /* MTP Function Definitions */
@ -846,12 +900,18 @@ static usb_endpoint_t get_endpoint(
static usb_error_t stall_data_endpoints( static usb_error_t stall_data_endpoints(
usb_endpoint_t endpoint) { usb_endpoint_t endpoint) {
printf("stalling data endpoints\n"); 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)); get_endpoint(endpoint, MTP_EP_DATA_IN));
if (error == USB_SUCCESS) if (error == USB_SUCCESS)
error = usb_SetEndpointHalt( error = usb_StallEndpoint(
get_endpoint(endpoint, MTP_EP_DATA_OUT)); get_endpoint(endpoint, MTP_EP_DATA_OUT));
return error; return error;
#else
(void)endpoint;
return USB_ERROR_FAILED;
#endif
} }
static usb_error_t schedule_event( static usb_error_t schedule_event(
@ -1051,19 +1111,19 @@ static uint16_t compute_checksum(
} }
static void get_datetime( static void get_datetime(
datetime_t *result) { wchar_t result[lengthof(Lfactory_datetime)]) {
uint16_t year; uint16_t year;
uint8_t month, day, hour, minute, second; uint8_t month, day, hour, minute, second,
char string[lengthof(Lfactory_datetime)]; i = lengthof(Lfactory_datetime);
char string[lengthof(Lfactory_datetime)],
*pointer = string;
boot_GetDate(&day, &month, &year); boot_GetDate(&day, &month, &year);
boot_GetTime(&second, &minute, &hour); boot_GetTime(&second, &minute, &hour);
int count = sprintf(string, "%04u%02u%02uT%02u%02u%02u",
snprintf(string, lengthof(string), year, month, day, hour, minute, second);
"%04u%02u%02uT%02u%02u%02u", do
year, month, day, hour, minute, second); *(char *)result++ = *pointer++;
result->length = count <= 0 ? 0 : count + 1; while (--i);
for (mtp_byte_t i = 0; i != result->length; ++i)
result->string[i] = string[i];
} }
static int delete_object( static int delete_object(
@ -1106,7 +1166,7 @@ static int send_object(
mtp_global_t *global) { mtp_global_t *global) {
size += global->transaction.state size += global->transaction.state
.send_object.extra; .send_object.extra;
const var_file_header_t *header = OBJECT_BUFFER; const var_file_header_t *header = LARGE_BUFFER;
if (size <= if (size <=
offsetof(var_file_header_t, entry.data) + offsetof(var_file_header_t, entry.data) +
sizeof(uint16_t) || sizeof(uint16_t) ||
@ -1181,7 +1241,6 @@ static int send_object(
version = entry->version; version = entry->version;
flag = entry->flag; flag = entry->flag;
} }
(void)version;
flag &= global->transaction.pending flag &= global->transaction.pending
.send_object.mask; .send_object.mask;
flag |= global->transaction.pending flag |= global->transaction.pending
@ -1707,40 +1766,35 @@ DEFINE_CALLBACK(command) {
break; break;
case MTP_OPR_GET_DEVICE_PROP_DESC: case MTP_OPR_GET_DEVICE_PROP_DESC:
MAX_PARAMS(1); MAX_PARAMS(1);
#define DECLARE_FORM_NONE(type) #define INIT_FORM_NONE(type, name, value) (void)0
#define DECLARE_FORM_RANGE(type) \ #define INIT_FORM_RANGE(type, name, value) do { \
type##_t minimum_value; \ name##_MIN((*(type##_t *)value)); \
type##_t maximum_value; \ value += name##_SIZE(type##_t); \
type##_t step_size; name##_MAX((*(type##_t *)value)); \
#define DEFINE_FORM_NONE(name) value += name##_SIZE(type##_t); \
#define DEFINE_FORM_RANGE(name) \ name##_STEP((*(type##_t *)value)); \
.minimum_value = name##_MIN, \ value += name##_SIZE(type##_t); \
.maximum_value = name##_MAX, \ } while (0)
.step_size = name##_STEP,
#define GET_DEVICE_PROP_DESC_RESPONSE(type, name, form) \ #define GET_DEVICE_PROP_DESC_RESPONSE(type, name, form) \
if (global->transaction.payload.params[0] == \ if (global->transaction.payload.params[0] == \
MTP_DP_##name) { \ MTP_DP_##name) { \
static struct name##_DESC { \ mtp_device_property_description_t *desc = \
mtp_enum_t device_property_code; \ LARGE_BUFFER; \
mtp_enum_t datatype; \ desc->device_property_code = MTP_DP_##name; \
mtp_byte_t get_set; \ desc->datatype = MTP_TC_##type; \
type##_t factory_default_value; \ desc->get_set = name##_GET_SET; \
type##_t current_value; \ mtp_byte_t *value = desc->values; \
mtp_byte_t form_flag; \ name##_DEF((*(type##_t *)value)); \
DECLARE_FORM_##form(type) \ value += name##_SIZE(type##_t); \
} name = { \ name##_GET((*(type##_t *)value)); \
.device_property_code = MTP_DP_##name, \ value += name##_SIZE(type##_t); \
.datatype = MTP_TC_##type, \ *value++ = MTP_FORM_##form; \
.get_set = name##_GET_SET, \ INIT_FORM_##form(type, name, value); \
.factory_default_value = name##_DEF, \
.current_value = name##_DEF, \
.form_flag = MTP_FORM_##form, \
DEFINE_FORM_##form(name) \
}; \
name##_GET(name.current_value); \
return schedule_data_in_response( \ return schedule_data_in_response( \
endpoint, &name, \ endpoint, \
sizeof(name), global); \ LARGE_BUFFER, \
value - (mtp_byte_t *)LARGE_BUFFER, \
global); \
} }
FOR_EACH_SUPP_DP(GET_DEVICE_PROP_DESC_RESPONSE) FOR_EACH_SUPP_DP(GET_DEVICE_PROP_DESC_RESPONSE)
return schedule_error_response( return schedule_error_response(
@ -1752,11 +1806,12 @@ DEFINE_CALLBACK(command) {
#define GET_DEVICE_PROP_VALUE_RESPONSE(type, name, form) \ #define GET_DEVICE_PROP_VALUE_RESPONSE(type, name, form) \
if (global->transaction.payload.params[0] == \ if (global->transaction.payload.params[0] == \
MTP_DP_##name) { \ MTP_DP_##name) { \
type##_t current; \ name##_GET((*(type##_t *)LARGE_BUFFER)); \
name##_GET(current); \
return schedule_data_in_response( \ return schedule_data_in_response( \
endpoint, &current, \ endpoint, \
sizeof(current), global); \ LARGE_BUFFER, \
name##_SIZE(type##_t), \
global); \
} }
FOR_EACH_SUPP_DP(GET_DEVICE_PROP_VALUE_RESPONSE) FOR_EACH_SUPP_DP(GET_DEVICE_PROP_VALUE_RESPONSE)
return schedule_error_response( return schedule_error_response(
@ -2102,7 +2157,7 @@ DEFINE_CALLBACK(send_object_container) {
.send_object.extra = .send_object.extra =
transferred - transferred -
sizeof(mtp_container_t); sizeof(mtp_container_t);
memcpy(OBJECT_BUFFER, memcpy(LARGE_BUFFER,
global->transaction.payload.buffer, global->transaction.payload.buffer,
extra); extra);
if (extra && transferred != MTP_MAX_BULK_PKT_SZ) if (extra && transferred != MTP_MAX_BULK_PKT_SZ)
@ -2110,7 +2165,7 @@ DEFINE_CALLBACK(send_object_container) {
endpoint, status, extra, global); endpoint, status, extra, global);
return usb_ScheduleBulkTransfer( return usb_ScheduleBulkTransfer(
endpoint, endpoint,
OBJECT_BUFFER + extra, LARGE_BUFFER + extra,
global->transaction.container.length.word - global->transaction.container.length.word -
sizeof(mtp_container_t) - extra, sizeof(mtp_container_t) - extra,
send_object_complete, send_object_complete,
@ -2198,7 +2253,7 @@ static usb_error_t usb_event(usb_event_t event,
(USB_DEVICE_TO_HOST | (USB_DEVICE_TO_HOST |
USB_STANDARD_REQUEST | USB_STANDARD_REQUEST |
USB_RECIPIENT_DEVICE) && USB_RECIPIENT_DEVICE) &&
setup->bRequest == USB_GET_DESCRIPTOR_REQUEST && setup->bRequest == USB_GET_DESCRIPTOR &&
setup->wValue == 0x03EE && !setup->wIndex) { setup->wValue == 0x03EE && !setup->wIndex) {
DEFINE_STRING_DESCRIPTOR(const, os_specific); DEFINE_STRING_DESCRIPTOR(const, os_specific);
error = usb_ScheduleTransfer( error = usb_ScheduleTransfer(
@ -2271,19 +2326,10 @@ int main(void) {
static mtp_global_t global; static mtp_global_t global;
usb_error_t error; usb_error_t error;
ui_Init(); ui_Init();
#define CENTER(string) \ printf(" TRANSFER v0.0.2b\n"
printf("%*s%.*s", \ " Connect USB to PC.\n"
(LCD_WIDTH / FONT_WIDTH + \ " Press [clear] to exit.\n"
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 = { static mtp_device_info_t device_info = {
.standard_version = 100, /* 1.00 */ .standard_version = 100, /* 1.00 */
.mtp_vendor_extension_id = 6, .mtp_vendor_extension_id = 6,
@ -2299,11 +2345,7 @@ int main(void) {
FOR_EACH_SUPP_OPR(LIST_SUPP_OPR) FOR_EACH_SUPP_OPR(LIST_SUPP_OPR)
}, },
.events_supported_length = lengthof(device_info.events_supported), .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_length = lengthof(device_info.device_properties),
.device_properties = { .device_properties = {
#define LIST_SUPP_DP(type, name, form) \ #define LIST_SUPP_DP(type, name, form) \
@ -2324,8 +2366,14 @@ int main(void) {
}, },
.manufacturer_length = lengthof(device_info.manufacturer), .manufacturer_length = lengthof(device_info.manufacturer),
.manufacturer = Lmanufacturer, .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 = { \ static name##_mtp_storage_info_t name##_storage_info = { \
.storage_type = MTP_ST_FIXED_RAM, \ .storage_type = MTP_ST_FIXED_RAM, \
.filesystem_type = MTP_FT_GENERIC_FLAT, \ .filesystem_type = MTP_FT_GENERIC_FLAT, \
@ -2343,7 +2391,7 @@ int main(void) {
FOR_EACH_STORAGE(DEFINE_STORAGE_INFO) FOR_EACH_STORAGE(DEFINE_STORAGE_INFO)
/* Standard USB Descriptors */ /* Standard USB Descriptors */
FOR_EACH_STRING_DESCRIPTOR(DEFINE_STRING_DESCRIPTOR) FOR_EACH_STRING_DESCRIPTOR(DEFINE_STRING_DESCRIPTOR)
DEFINE_STRING_DESCRIPTOR(const, product83) DEFINE_STRING_DESCRIPTOR(const, product84)
const static usb_string_descriptor_t *strings[] = { const static usb_string_descriptor_t *strings[] = {
#define ADDRESSOF_STRING_DESCRIPTOR(const, name) &name, #define ADDRESSOF_STRING_DESCRIPTOR(const, name) &name,
FOR_EACH_STRING_DESCRIPTOR(ADDRESSOF_STRING_DESCRIPTOR) FOR_EACH_STRING_DESCRIPTOR(ADDRESSOF_STRING_DESCRIPTOR)
@ -2426,7 +2474,7 @@ int main(void) {
.bMaxPacketSize0 = 0x40u, .bMaxPacketSize0 = 0x40u,
.idVendor = 0x0451u, .idVendor = 0x0451u,
.idProduct = 0xE010u, .idProduct = 0xE010u,
.bcdDevice = 0x240u, /* 2.40 */ .bcdDevice = 0x260u, /* 2.60 */
.iManufacturer = Imanufacturer, .iManufacturer = Imanufacturer,
.iProduct = Iproduct, .iProduct = Iproduct,
.iSerialNumber = Iserial_number, .iSerialNumber = Iserial_number,
@ -2440,68 +2488,38 @@ int main(void) {
.strings = strings, .strings = strings,
}; };
const system_info_t *info = os_GetSystemInfo(); 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[] = { wchar_t *serial_numbers[] = {
&serial_number.bString[2 * lengthof(info->calcid)], &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) \ #define LIST_STORAGE_INFO_SERIAL(name) \
&name##_storage_info.volume_identifier[2 * lengthof(info->calcid)], &name##_storage_info.volume_identifier[2 * lengthof(info->calcid)],
FOR_EACH_STORAGE(LIST_STORAGE_INFO_SERIAL) 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; ) { for (mtp_byte_t i = 2 * lengthof(info->calcid); i; ) {
mtp_byte_t nibble = info->calcid[--i >> 1]; mtp_byte_t nibble = info->calcid[--i >> 1];
if (!(i & 1)) if (!(i & 1))

View file

@ -8,7 +8,9 @@
#include <string.h> #include <string.h>
#include <tice.h> #include <tice.h>
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] #define buffer(n) (*(uint8_t (*)[4][LCD_WIDTH][LCD_HEIGHT >> 1])lcd_Ram)[(n) ^ swap]
void ui_Init(void) { void ui_Init(void) {
@ -29,10 +31,6 @@ void ui_Init(void) {
*(volatile uint8_t *volatile *)&lcd_UpBase = &buffer(0)[0][0]; *(volatile uint8_t *volatile *)&lcd_UpBase = &buffer(0)[0][0];
} }
void ui_Lock(void) {
static_rows = row;
}
void ui_Cleanup(void) { void ui_Cleanup(void) {
boot_ClearVRAM(); boot_ClearVRAM();
boot_TurnOn(); boot_TurnOn();
@ -58,7 +56,7 @@ void outchar(char c) {
sizeof(buffer(1)) - FONT_HEIGHT_BYTES); sizeof(buffer(1)) - FONT_HEIGHT_BYTES);
for (unsigned x = 0; x != LCD_WIDTH; ++x) { for (unsigned x = 0; x != LCD_WIDTH; ++x) {
memcpy(&buffer(0)[x][0], &buffer(1)[x][0], 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) * memset(&buffer(0)[x][((LCD_HEIGHT / FONT_HEIGHT - 1) *
FONT_HEIGHT) >> 1], 0xFF, FONT_HEIGHT_BYTES); FONT_HEIGHT) >> 1], 0xFF, FONT_HEIGHT_BYTES);
} }

View file

@ -2,7 +2,6 @@
#define UI_H #define UI_H
void ui_Init(void); void ui_Init(void);
void ui_Lock(void);
void ui_Cleanup(void); void ui_Cleanup(void);
#endif #endif

View file

@ -234,11 +234,6 @@ _arc_unarc_var:
ex (sp),iy ex (sp),iy
push de push de
.enter: .enter:
ld a,(de)
cp a,'A'
ret c
cp a,ti.tAns
ret z
ld hl,.return ld hl,.return
call ti.PushErrorHandler call ti.PushErrorHandler
lea hl,iy lea hl,iy