From 262f0f42f03c23fb925f215489a776de5d7ba950 Mon Sep 17 00:00:00 2001 From: Jon Sturm Date: Wed, 8 May 2013 23:54:14 -0500 Subject: [PATCH] Add tidump command for TI-83+ Series rom dumping Squashed commit of the following: commit 70602262795b5e5eea49802c84391db79ce1bd9f Author: Jon Sturm Date: Wed May 8 23:45:28 2013 -0500 tidump: remove calc_73.c as it is no longer needed Missed in the last cleanup commit. Signed-off-by: Jon Sturm commit 806c3d8395e8e6b41516ae0a59c7b467a29ecf0c Author: Jon Sturm Date: Thu Apr 4 02:15:29 2013 -0500 tidump: Clean up formatting and move to using the newly exported cmd73.h Also adds TI-84 Plus CSE support and makes things a bit more robust by actually checking return codes of functions for failure. Doesn't yet attempt to retry failed pages, it seems the silverlink gets confused when you do so. Will need further cleanup before merging with master. TODO: Either remove or allow toggling of ram dumps and perhaps add a parameter to only dump single pages for debugging or testing. commit f7b12b6fee3cff3e23d87e29148cbcdfb65ad67a Author: Jon Sturm Date: Tue Apr 10 21:04:45 2012 -0500 Hack in direct memory dumping. Will need to clean up and patch libticalcs so that I don't need to duplicate its internal functions here just for it to work. As well as remove the files taken from libticalcs once those functions are exported. commit de4d3bf4bf2c671c8c334a5804c8fae6f979f114 Author: Jon Sturm Date: Tue Apr 10 20:14:59 2012 -0500 Add missing part of the 89 case in ascii_to_key in tikey This fixes sending keypresses to the TI89T via cables other than the USB DirectLink. Reported on IRC by chronomex. Signed-off-by: Jon Sturm Signed-off-by: Jon Sturm --- src/Makefile.in | 8 +++- src/tidump.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 src/tidump.c diff --git a/src/Makefile.in b/src/Makefile.in index 98d707e..b14e75f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -29,7 +29,8 @@ programs = tiget@EXEEXT@ \ tils@EXEEXT@ \ tiput@EXEEXT@ \ tirm@EXEEXT@ \ - tiscr@EXEEXT@ + tiscr@EXEEXT@ \ + tidump@EXEEXT@ all: $(programs) @@ -75,6 +76,11 @@ tiput@EXEEXT@: tiput.@OBJEXT@ common.@OBJEXT@ tiput.@OBJEXT@: tiput.c titools.h $(compile) -c $(srcdir)/tiput.c +tidump@EXEEXT@: tidump.@OBJEXT@ common.@OBJEXT@ + $(link) -o tidump@EXEEXT@ tidump.@OBJEXT@ common.@OBJEXT@ $(libs) +tidump.@OBJEXT@: tidump.c titools.h + $(compile) -c $(srcdir)/tidump.c + tirm@EXEEXT@: tirm.@OBJEXT@ common.@OBJEXT@ glob.@OBJEXT@ $(link) -o tirm@EXEEXT@ tirm.@OBJEXT@ common.@OBJEXT@ glob.@OBJEXT@ $(libs) tirm.@OBJEXT@: tirm.c titools.h diff --git a/src/tidump.c b/src/tidump.c new file mode 100644 index 0000000..9011ed7 --- /dev/null +++ b/src/tidump.c @@ -0,0 +1,114 @@ +/* + * TITools + * + * Copyright (c) 2010 Benjamin Moody + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include "titools.h" +#include + +#define PKTSIZE 0x400 + +int main(int argc, char **argv) +{ + int rampage,numpages; + + tt_init(argc, argv, NULL, 0, 0, 1); + + uint16_t page = 0; + uint8_t *buffer; + uint16_t length; + FILE *f; + char *filename; + + if (calc_handle->model == CALC_TI84P || calc_handle->model == CALC_TI83P) + { + CalcInfos info; + ticalcs_calc_get_version(calc_handle, &info); + switch(info.hw_version) { + case 1: + case 3: + numpages = 0x74; + rampage = 0x80; + break; + case 0: + numpages = 0x1F; + rampage = 0x40; + break; + case 2: + numpages = 0x3F; + rampage = 0x80; + break; + case 4: + case 5: + numpages = 0xFF; + rampage = 0x80; + break; + default: + goto exit2; // if this happens the world might be ending + } + + buffer = (uint8_t *)malloc(0x5000); + + filename = g_strconcat(tifiles_model_to_string(calc_handle->model), ".", "rom", NULL); + f = fopen(filename, "wb"); + + if (f == NULL) + goto exit; + for(page = 0; page <= numpages; page++ ) { + + printf("Receiving page %X out of %X\n", page, numpages); + + int failed = ti73_send_DUMP(calc_handle, page) + ti73_recv_ACK(calc_handle, NULL) + + ti73_recv_XDP(calc_handle, &length, buffer) + ti73_send_ACK(calc_handle); + if (failed) { + printf("Rom Dump Failed\n"); + goto exit; + } + + if (fwrite(buffer, length, 1, f) < 1) + goto exit; + } + //fclose(f); + //filename = g_strconcat(tifiles_model_to_string(calc_handle->model), ".", "ram", NULL); + //f = fopen(filename, "wb"); + //if (f == NULL) + //goto exit; + //for(data[0]=rampage; data[0]<=rampage+1; data[0]++){ + //printf("Receiving page %X out of %X\n", data[0], rampage+1); + //printf(" PC->TI: MEM REQ\n"); + //dbus_send(calc_handle, PC_TI83p, 0x6F, 8, (uint8_t *)&data); + //ti73_recv_ACK_h(calc_handle, NULL); + //ti73_recv_XDP_h(calc_handle, &length, buffer); + //ti73_send_ACK_h(calc_handle); + //if (fwrite(buffer, length, 1, f) < 1) + //goto exit; + //} + +exit: + fclose(f); + } +exit2: + tt_exit(); + return 0; +}