#include "os.h" #include "charmap.h" #include "screen.h" #include "imgdump.h" #include "browse.h" typedef struct { unsigned short int y; // horizontal screen offset unsigned short int x; // vertical screen offset unsigned short int w; // width unsigned short int h; // height unsigned long int o; // data offset } manuf_image; #define TIME_DELAY 200 #define N_MANUF_IMAGES 12 #define MANUF_IMAGE_OFFSET 0x894 #define MANUF_IMAGE_SIZE 12 #define MANUF_SIZE_OFFSET 0x924 #define MANUF_RAWSIZE_OFFSET 0x928 #define MANUF_DATA_OFFSET 0x930 #define MANUF_SIZE 0x20000 int help=1; long int rawdata_size; int imgmanuf_copied=0; manuf_image imgmanuf_copy; manuf_image manuf_images[N_MANUF_IMAGES]; unsigned int orderid[N_MANUF_IMAGES]; unsigned int order[N_MANUF_IMAGES]={9,7,7,8,8,5,6,0,1,2,3,4}; unsigned char* infos[N_MANUF_IMAGES]={ "Low Battery", //10th "Boot1 Recoverable Error", //8th "Send Diagnostics Software", //8th "Boot2 Recoverable Error", //9th "Unrecoverable Error", //9th "Progress Bar Background", //6th "Progress Bar", //7th "Background #1", //1st "Background #2", //2nd "Background #3", //3rd "Background #4", //4th "Background #5"}; //5th unsigned char buf[MANUF_SIZE]; unsigned char* rawbuf; unsigned short int* offscreen1; unsigned short int* offscreen2; unsigned short int* offscreen3; int getOrderID(int* k, int* n) { int id=-1,i,j=0; if(*k>=N_MANUF_IMAGES) return id; for(i=0;i=N_MANUF_IMAGES) i=0; return orderid[i]; } void dispLowerImages(int id,unsigned short int* screen) { int i,o; for(o=0;o<=order[id];o++) for(i=0;i=manuf_images[id].w*2) manuf_images[id].o-=manuf_images[id].w*2; if(isKeyDown()) manuf_images[id].o+=manuf_images[id].w*2; if(isKeyLeft() && manuf_images[id].o>=2) manuf_images[id].o-=2; if(isKeyRight()) manuf_images[id].o+=2; } else if(isKeyPressed(KEY_NSPIRE_CTRL)) { if(!isKeyUp() && !isKeyDown() && !isKeyRight() && !isKeyLeft()) k=1; if(isKeyUp() && manuf_images[id].h>1) manuf_images[id].h--; if(isKeyDown()) manuf_images[id].h++; if(isKeyLeft() && manuf_images[id].w>1) manuf_images[id].w--; if(isKeyRight()) manuf_images[id].w++; } else { if(isKeyUp() && manuf_images[id].y>0) manuf_images[id].y--; if(isKeyDown() && manuf_images[id].y+manuf_images[id].h+(manuf_images[id].x+manuf_images[id].w<=SCREEN_WIDTH?0:1)0 || manuf_images[id].y>0)) { if(manuf_images[id].x==0) { if(manuf_images[id].y>0) { manuf_images[id].x=SCREEN_WIDTH-1; manuf_images[id].y--; } } else manuf_images[id].x--; } if(isKeyRight()) { manuf_images[id].x++; if(manuf_images[id].x>=SCREEN_WIDTH) { if(manuf_images[id].yrawdata_size) memcpy(&manuf_images[id],&backm,sizeof(manuf_image)); else if((manuf_images[id].y+manuf_images[id].h-1)*SCREEN_WIDTH+manuf_images[id].x+manuf_images[id].w>SCREEN_HEIGHT*SCREEN_WIDTH) memcpy(&manuf_images[id],&backm,sizeof(manuf_image)); } if(isKeyPressed(KEY_NSPIRE_TAB)) { while(isKeyPressed(KEY_NSPIRE_TAB)); moveImage(getNext(id)); } } int image_x=0, image_y=0; int chooseImage(int id) { int w=1; int i, j, k=0, z, c, sc, d=0, update=1; int height = SCREEN_HEIGHT-3*CHAR_HEIGHT; int zmax=height/6; drawBufFullBoxRGB(offscreen1,0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1,0,0,0); c=0xFF; for(i=0;i3) image_x=0; } if(isKeyUp()) { image_y--; if(image_y<0) image_y=2; } if(isKeyDown()) { image_y++; if(image_y>2) image_y=0; } if(isKeyPressed(KEY_NSPIRE_X)) { memcpy(&imgmanuf_copy,&manuf_images[orderid[k]],sizeof(manuf_image)); memset(&manuf_images[orderid[k]],0,sizeof(manuf_image)); imgmanuf_copied=1; update=1; w=1; } if(isKeyPressed(KEY_NSPIRE_C)) { memcpy(&imgmanuf_copy,&manuf_images[orderid[k]],sizeof(manuf_image)); imgmanuf_copied=1; update=1; } if(isKeyPressed(KEY_NSPIRE_V) && imgmanuf_copied) { memcpy(&manuf_images[orderid[k]],&imgmanuf_copy,sizeof(manuf_image)); update=1; } if(isKeyPressed(KEY_NSPIRE_DEL)) { memset(&manuf_images[orderid[k]],0,sizeof(manuf_image)); update=1; } } if(isKeyPressed(KEY_NSPIRE_ESC)) return -1; return orderid[image_y*4+image_x]; } void main() { int i, manuf_size, z; int image_x=0, image_y=0; unsigned char* pin; unsigned char* pout; char path[1024]; long int data_size; int id; offscreen1 = malloc(SCREEN_WIDTH*SCREEN_HEIGHT*2); offscreen2 = malloc(SCREEN_WIDTH*SCREEN_HEIGHT*2); offscreen3 = malloc(SCREEN_WIDTH*SCREEN_HEIGHT*2); memset(buf,0,MANUF_SIZE); int selected; initScreen(); int k=0,n=0; for(i=0;i=0) { while(any_key_pressed()); moveImage(img_i); while(any_key_pressed()); } free(rawbuf); resetConsole(); displn("Do you want to save your modifications? (y/n)",1,1); waitKey(0); if(waitConfirm()) { h = fopen(path,"wb"); memcpy(buf+MANUF_IMAGE_OFFSET,manuf_images,MANUF_IMAGE_SIZE*N_MANUF_IMAGES); fwrite(buf,1,MANUF_SIZE,h); fclose(h); } } else { displn("ERROR: CX/CM Manuf image doesn't include boot graphics",1,1); waitKey(1); } } else { displn("ERROR: Invalid CX/CM Manuf image",1,1); waitKey(1); } } } free(offscreen1); free(offscreen2); free(offscreen3); }