#include #define DIAGS_SIZE 0xA0000 void errormsg(char *mesg){ char title[20]; char msg[150]; ascii2utf16(title, "Ndless", sizeof(title)); ascii2utf16(msg, mesg, sizeof(msg)); show_dialog_box2(0, title, msg); } int main(void) { char title[20]; char msg[150]; FILE *ifile; ifile = fopen("/documents/ndless/diags.img.tns", "rb"); if (!ifile) { errormsg("Can't open input file\n/documents/ndless/diags.img.tns"); return 1; } // ------- load at 11800000 to parse & trim the diags header ----- while (fread((void *)0x11800000 , 1, 4, ifile) == 4) { if (*(unsigned int *)0x11800000 == 0xe59ff018){ // find first ARM instruction break; } } fread((void *)0x11800004 , 1, DIAGS_SIZE, ifile); // read the remainder of diags fclose(ifile); asm( ".arm \n" "ldr pc, =0x11800000 @ jump to diags\n" ); // ----- should not get here ---- ascii2utf16(title, "Ndless", sizeof(title)); ascii2utf16(msg, "Problem executing diags", sizeof(msg)); show_dialog_box2(0, title, msg); return 0; }