// disassemble from address 1 to address 2 unsigned int disassemble(uint16 addr1, uint16 addr2) { uint8 instr; int count, line; char string1[128]; char string2[128]; addr = addr1; count = (addr2 == 0) ? 24 : 0; line = 0; memory = memory5200; clrEmuScreen(0x00); while ((addr < addr2 || count > 0) && (addr < 0xFFFC)) { sprintf(msg, "%x: ", addr); printXY(msg, 0, line * 8, 11); instr = memory[addr]; addr++; sprintf(string2, " "); show_opcode(string1, instr); show_operand(string2, instr); sprintf(msg, "%s %s", string1, string2); printXY(msg, 48, line * 8, 12); line++; if (count > 0) count--; } BlitBuffer(0, 240); return addr; }
void AICarbon::eval(int x, int y) { OXCell *c = &cell[x+4][y+4]; printXY(300, 0, 60, " [%d,%d,%d,%d],[%d,%d,%d,%d] ", c->status1[0][0], c->status1[1][0], c->status1[2][0], c->status1[3][0], c->status1[0][1], c->status1[1][1], c->status1[2][1], c->status1[3][1]); printXY(300, 16, 60, "%d,%d", c->status4[0], c->status4[1]); printXY(300, 32, 60, "%d", c->prior()); }
void browser_primitive( char *title1, char *title2, GSTEXTURE *gsTexture, float x1, float y1, float x2, float y2) { if(!menutex || !bgtex) { menu_bgtexture(gsTexture, x1,y1,x2,y2,1); } else { menu_background(x1,y1,x2,y2,1); } menu_background(x1,y1,x1+(strlen(title1)*9),y1+FONT_HEIGHT*2,2); menu_background(x2-(strlen(title2)*12), y1, x2, y1+FONT_HEIGHT*2,2); printXY(title1, x1+(strlen(title2)+4), y1+FONT_HEIGHT/2, 3, FCEUSkin.textcolor, 2, 0); printXY(title2, x2-(strlen(title2)*10), y1+FONT_HEIGHT/2, 3, FCEUSkin.textcolor, 2, 0); }
void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT double alpha = .5; double x_avg = 0; double y_avg = 0; volatile short x_pos = 0; volatile short y_pos = 0; char buffer[40]; int count = 0; clock_init(); lcd_on(); init_xy_display(); BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO IFG1 &= ~OFIFG; // Clear OSCFault flag BCSCTL2 |= SELM_0 + DIVM_3 + DIVS_3; // MCLK = DCO/8 while(1) { count++; read_xy_calc_avg(&x_avg, &y_avg, alpha); if (!(count % 2)) printXY(buffer, (int)x_avg, (int)y_avg); } }
void hexview(uint16 viewaddr) { int i, count; count = 0; memory = memory5200; clrEmuScreen(0x00); for(i=viewaddr; i < viewaddr + 160; i++) { if((count % 8) == 0) { sprintf(msg, "%4X: ", i); printXY(msg, 0, (count / 8) * 8, 14); } sprintf(msg, "%02X", memory[i]); printXY(msg, 48 + 32 * (count % 8), (count / 8) * 8, 14); count++; } printXY("Press any key to continue...", 0, 230, 15); BlitBuffer(0, 240); }
//List interrupt vectors void listvectors(void) { /* Page Two Vectors $200 Immediate IRQ vector $202 Immediate VBI vector $204 Deferred VBI vector $206 DLI vector $208 Keyboard IRQ vector $20A Keypad routine continuation vector $20C BREAK key IRQ vector $20E BRK instruction IRQ vector $210 Serial Input Data Ready IRQ vector $212 Serial Output Data Needed IRQ vector $214 Serial Output Finished IRQ vector $216 POKEY Timer 1 IRQ vector $218 POKEY Timer 2 IRQ vector $21A POKEY Timer 4 IRQ vector */ memory = memory5200; clrEmuScreen(0x00); printXY("Page Two IRQ Vectors:", 8, 0, 15); sprintf(msg, "$200 Imm IRQ: %02X%02X", memory[0x201], memory[0x200]); printXY(msg, 8, 16, 15); sprintf(msg, "$202 Imm VBI: %02X%02X", memory[0x203], memory[0x202]); printXY(msg, 8, 24, 15); sprintf(msg, "$204 Def VBI: %02X%02X", memory[0x205], memory[0x204]); printXY(msg, 8, 32, 15); sprintf(msg, "$206 DLI Vec: %02X%02X", memory[0x207], memory[0x206]); printXY(msg, 8, 40, 15); sprintf(msg, "$208 Key IRQ: %02X%02X", memory[0x209], memory[0x208]); printXY(msg, 8, 48, 15); sprintf(msg, "$20A Key cont: %02X%02X", memory[0x20B], memory[0x20A]); printXY(msg, 8, 56, 15); sprintf(msg, "$20C BREAK Key IRQ: %02X%02X", memory[0x20D], memory[0x20C]); printXY(msg, 8, 64, 15); sprintf(msg, "$20E BRK instr IRQ: %02X%02X", memory[0x20F], memory[0x20E]); printXY(msg, 8, 72, 15); //textprintf(buffer, font, 8, 80, 15, "$210 Ser Inp Data Rdy: %02X%02X", memory[0x211], memory[0x210]); //textprintf(buffer, font, 8, 88, 15, "$212 Ser Out Data Req: %02X%02X", memory[0x213], memory[0x212]); //textprintf(buffer, font, 8, 96, 15, "$214 Ser Out Complete: %02X%02X", memory[0x215], memory[0x214]); //textprintf(buffer, font, 8, 104, 15, "$216 Pokey T1: %02X%02X", memory[0x217], memory[0x216]); //textprintf(buffer, font, 8, 112, 15, "$218 Pokey T2: %02X%02X", memory[0x219], memory[0x218]); //textprintf(buffer, font, 8, 120, 15, "$21A Pokey T3: %02X%02X", memory[0x21B], memory[0x21A]); printXY("Press any key to continue...", 0, 230, 15); BlitBuffer(0, 240); }
void Ingame_Menu(void) { char *temp; int i,selection = 0; oldselect = -1; char stateoption[16]; strcpy(stateoption,"State number: "); int option_changed = 0; int menu_x1 = gsGlobal->Width*0.25; int menu_y1 = gsGlobal->Height*0.15; int menu_x2 = gsGlobal->Width*0.75; int menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; int text_line = menu_y1 + 4; char options[14][23] = { { "State number: " }, { "Save State" }, { "Load State" }, { "Filtering: "}, { "LowPass: "******"Configure Input" }, { "Rapidfire Switch: "}, { "RapidFire P1: " }, { "RapidFire P2: " }, { "Reset Game" }, { "Exit Game" }, { "Exit Menu" }, { "Palette:" }, { "" } }; for(i=0;i<14;i++) { switch(i) { case 0: sprintf(options[i],"%s%d",options[i],statenum); break; case 3: if(!Settings.filter) sprintf(options[i],"%s%s",options[i],"Off"); else sprintf(options[i],"%s%s",options[i],"On"); break; case 4: if(!Settings.lowpass) sprintf(options[i],"%s%s",options[i],"Off"); else sprintf(options[i],"%s%s",options[i],"On"); break; case 6: if(!Settings.turbo) { sprintf(options[i],"%s%s",options[i],"Off"); } else { sprintf(options[i],"%s%s",options[i],"On"); } break; case 7: switch(aorborab[0]) { case 0: sprintf(options[i],"%s%s",options[i],"Off"); break; case 1: sprintf(options[i],"%s%s",options[i],"A"); break; case 2: sprintf(options[i],"%s%s",options[i],"B"); break; case 3: sprintf(options[i],"%s%s",options[i],"AB"); break; } break; case 8: switch(aorborab[1]) { case 0: sprintf(options[i],"%s%s",options[i],"Off"); break; case 1: sprintf(options[i],"%s%s",options[i],"A"); break; case 2: sprintf(options[i],"%s%s",options[i],"B"); break; case 3: sprintf(options[i],"%s%s",options[i],"AB"); break; } break; case 13: sprintf(options[i],"%s%s",options[i],palette_names[Settings.current_palette - 1].name); break; } } #ifdef SOUND_ON audsrv_stop_audio(); #endif gsKit_mode_switch(gsGlobal, GS_ONESHOT); gsGlobal->DrawOrder = GS_PER_OS; while(1) { selected = 0; //clear selected flag selection += menu_input(0,0); if(selection == 12 && oldselect == 11) { selection++; } //12 is palette if(selection == 12 && oldselect == 13) { selection--; } if(selection > 13) { selection = 0; } if(selection < 0) { selection = 13; } if(oldselect != selection || option_changed) { i = 0x10000; while(i--) asm("nop\nnop\nnop\nnop"); gsKit_queue_reset(gsGlobal->Os_Queue); option_changed = 0; menu_primitive("Options", &MENU_TEX, menu_x1, menu_y1, menu_x2, menu_y2); for(i=0;i<14;i++) { if(selection == i) { //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, DarkYellowFont, options[i]); printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0); } else { //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, WhiteFont, options[i]); printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0); } } DrawScreen(gsGlobal); } oldselect = selection; if(selected) { if(selected == 2) { //menu combo pressed again selection = 11; } i = selection; switch(i) { case 0: //State Number statenum++; if(statenum > 9) {statenum = 0;} sprintf(options[i],"%s%d",stateoption,statenum); FCEUI_SelectState(statenum); option_changed = 1; break; case 1: FCEUI_SaveState(NULL); SetupNESGS(); return; case 2: FCEUI_LoadState(NULL); SetupNESGS(); return; case 3: Settings.filter ^= 1; if(Settings.filter) { temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"On"); } else { temp = strstr(options[i],"On"); *temp = 0; strcat(options[i],"Off"); } option_changed = 1; break; case 4: Settings.lowpass ^= 1; if(Settings.lowpass) { FCEUI_SetLowPass(Settings.lowpass); temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"On"); } else { FCEUI_SetLowPass(Settings.lowpass); temp = strstr(options[i],"On"); *temp = 0; strcat(options[i],"Off"); } option_changed = 1; break; case 6: Settings.turbo ^= 1; if(Settings.turbo) { temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"On"); } else { temp = strstr(options[i],"On"); *temp = 0; strcat(options[i],"Off"); } option_changed = 1; break; case 7: aorborab[0]++; if(aorborab[0] > 3) aorborab[0] = 0; switch(aorborab[0]) { case 0: //Off rapidfire_a[0] = 0; rapidfire_b[0] = 0; temp = strstr(options[i],"AB"); *temp = 0; strcat(options[i],"Off"); break; case 1: //A rapidfire_a[0] = 1; rapidfire_b[0] = 0; temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"A"); break; case 2: //B rapidfire_a[0] = 0; rapidfire_b[0] = 1; temp = strstr(options[i]," A"); *temp = 0; strcat(options[i]," B"); break; case 3: //AB rapidfire_a[0] = 1; rapidfire_b[0] = 1; temp = strstr(options[i]," B"); *temp = 0; strcat(options[i]," AB"); break; } option_changed = 1; break; case 8: aorborab[1]++; if(aorborab[1] > 3) aorborab[1] = 0; switch(aorborab[1]) { case 0: //Off rapidfire_a[1] = 0; rapidfire_b[1] = 0; temp = strstr(options[i],"AB"); *temp = 0; strcat(options[i],"Off"); break; case 1: //A rapidfire_a[1] = 1; rapidfire_b[1] = 0; temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"A"); break; case 2: //B rapidfire_a[1] = 0; rapidfire_b[1] = 1; temp = strstr(options[i]," A"); *temp = 0; strcat(options[i]," B"); break; case 3: //AB rapidfire_a[1] = 1; rapidfire_b[1] = 1; temp = strstr(options[i]," B"); *temp = 0; strcat(options[i]," AB"); break; } option_changed = 1; break; case 9: FCEUI_ResetNES(); SetupNESGS(); return; case 10: fdsswap = 0; statenum = 0; exitgame = 1; selected = 0; return; case 11: SetupNESGS(); return; case 13: Settings.current_palette++; if(Settings.current_palette > MAXPAL) {Settings.current_palette = 1;} sprintf(options[i],"%s",palette_names[Settings.current_palette - 1].name); SetupNESTexture(); option_changed = 1; break; } } } }
/** Browser Menu Display: PAL/NTSC Emulated System: PAL/NTSC Center Screen Configure Save Path: (browse to path) Configure Elf Path: (browse to path) Exit to Elf Path Exit to PS2Browser **/ int Browser_Menu(void) { char *temp; char cnfpath[2048]; int i,selection = 0; oldselect = -1; int option_changed = 0; int menu_x1 = gsGlobal->Width*0.25; int menu_y1 = gsGlobal->Height*0.15; int menu_x2 = gsGlobal->Width*0.75; int menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; int text_line = menu_y1 + 4; char options[12][39] = { { "Display: " }, { "Interlacing: " }, { "Emulated System: " }, { "Center Screen" }, { "Configure Save Path: " }, { "" }, { "Configure ELF Path: " }, { "" }, { "Save FCEUltra.cnf"}, { "Power Off" }, { "Exit to ELF" }, { "Exit Options Menu" } }; //fill lines with values for(i=0;i<12;i++) { switch(i) { case 0: if(!Settings.display) { sprintf(options[i],"%s%s",options[i],"NTSC"); } else { sprintf(options[i],"%s%s",options[i],"PAL"); } break; case 1: if(Settings.interlace) { sprintf(options[i],"%s%s",options[i],"On"); } else { sprintf(options[i],"%s%s",options[i],"Off"); } break; case 2: if(!Settings.emulation) { sprintf(options[i],"%s%s",options[i],"NTSC"); } else { sprintf(options[i],"%s%s",options[i],"PAL"); } break; case 5: strzncpy(options[5],Settings.savepath,38); break; case 7: strzncpy(options[7],Settings.elfpath,38); break; } } while(1) { selected = 0; //clear selected flag selection += menu_input(0,0); if(selection > 11) { selection = 0; } if(selection < 0) { selection = 11; } if(selection == 5 && oldselect == 4) { selection++; } //5 is savepath if(selection == 5 && oldselect == 6) { selection--; } if(selection == 7 && oldselect == 6) { selection++; } //7 is elfpath if(selection == 7 && oldselect == 8) { selection--; } if((oldselect != selection) || option_changed) { gsKit_clear(gsGlobal,GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00)); menu_primitive("Options", &MENU_TEX, menu_x1, menu_y1, menu_x2, menu_y2); for(i=0;i<12;i++) { if(selection == i) { //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, DarkYellowFont, options[i]); printXY(options[i],menu_x1+10,text_line+i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0); } else { //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, WhiteFont, options[i]); printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0); } } DrawScreen(gsGlobal); if(power_off) option_changed = 1; power_off--; if(!power_off) { strcpy(cnfpath,"xyz:/imaginary/hypothetical/doesn't.exist"); FILE *File; File = fopen(cnfpath,"r"); if(File != NULL) fclose(File); } } oldselect = selection; option_changed = 0; if(selected) { if(selected == 2) { selection = 11; } i = selection; switch(i) { case 0: //Display PAL/NTSC Settings.display ^= 1; if(Settings.display) { gsGlobal->Mode = GS_MODE_PAL; gsGlobal->Height = 512; defaulty = 72; temp = strstr(options[i],"NTSC"); *temp = 0; strcat(options[i],"PAL"); } else { gsGlobal->Mode = GS_MODE_NTSC; gsGlobal->Height = 448; defaulty = 50; temp = strstr(options[i],"PAL"); *temp = 0; strcat(options[i],"NTSC"); } gsGlobal->Width = 640; gsGlobal->Field = GS_FIELD; if (gsGlobal->Interlace == GS_NONINTERLACED) { gsGlobal->Height = gsGlobal->Height/2; gsGlobal->StartY = gsGlobal->StartY/2 -1 ; } gsGlobal->StartY = gsGlobal->StartY + Settings.offset_y; //if(Settings.interlace && (gsGlobal->Mode == GS_MODE_NTSC)) //gsGlobal->StartY = gsGlobal->StartY + 22; //else //gsGlobal->StartY = gsGlobal->StartY + 11; //normalize_screen(); gsKit_init_screen(gsGlobal); /* Apply settings. */ gsKit_mode_switch(gsGlobal, GS_ONESHOT); menu_x1 = gsGlobal->Width*0.25; menu_y1 = gsGlobal->Height*0.15; menu_x2 = gsGlobal->Width*0.75; menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; text_line = menu_y1 + 4; option_changed = 1; //SetGsCrt(gsGlobal->Interlace,gsGlobal->Mode,gsGlobal->Field); break; case 1: //Interlacing Off/On Settings.interlace ^= 1; if (gsGlobal->Mode == GS_MODE_PAL) gsGlobal->Height = 512; else gsGlobal->Height = 448; if(Settings.interlace) { gsGlobal->Interlace = GS_INTERLACED; //gsGlobal->StartY = (gsGlobal->StartY-1)*2; temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"On"); } else { gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->StartY = gsGlobal->StartY/2 + 1; gsGlobal->Height = gsGlobal->Height/2; temp = strstr(options[i],"On"); *temp = 0; strcat(options[i],"Off"); } gsGlobal->Width = 640; gsGlobal->Field = GS_FIELD; //normalize_screen(); gsKit_init_screen(gsGlobal); /* Apply settings. */ gsKit_mode_switch(gsGlobal, GS_ONESHOT); menu_x1 = gsGlobal->Width*0.25; menu_y1 = gsGlobal->Height*0.15; menu_x2 = gsGlobal->Width*0.75; menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; text_line = menu_y1 + 4; option_changed = 1; //SetGsCrt(gsGlobal->Interlace,gsGlobal->Mode,gsGlobal->Field); break; case 2: //Emulated System Settings.emulation ^= 1; if(Settings.emulation) { temp = strstr(options[i],"NTSC"); *temp = 0; strcat(options[i],"PAL"); } else { temp = strstr(options[i],"PAL"); *temp = 0; strcat(options[i],"NTSC"); } FCEUI_SetVidSystem(Settings.emulation); option_changed = 1; break; case 3: //Center Screen while(menu_input(0,2) != 2) {} i = 0x10000; while(i--) asm("nop\nnop\nnop\nnop"); option_changed = 1; break; case 4: //Configure Save Path h = 0; //reset browser selection = 0; oldselect = -1; selected = 0; strcpy(path,"path"); //end reset browser strcpy(Settings.savepath,Browser(0,1)); printf("%s",Settings.savepath); strzncpy(options[5],Settings.savepath,38); selected_dir = 0; h = 0; selection = 0; oldselect = -1; strcpy(path,"path"); option_changed = 1; selected = 0; break; case 6: //Configure ELF Path h = 0; selection = 0; oldselect = -1; selected = 0; strcpy(path,"path"); strcpy(Settings.elfpath,Browser(1,2)); strzncpy(options[7],Settings.elfpath,38); h = 0; selection = 0; oldselect = -1; strcpy(path,"path"); option_changed = 1; selected = 0; break; case 8: //Save CNF fioMkdir("mc0:FCEUMM"); Save_Global_CNF("mc0:/FCEUMM/FCEUltra.cnf"); break; case 9: //Power Off poweroffShutdown(); if(Settings.display) power_off = 50/4; else power_off = 60/4; option_changed = 1; break; case 10: //Exit to ELF return 2; case 11: //Exit Options Menu selected = 0; return 1; } } } }
void printhelp(void) { clrEmuScreen(0x00); printXY("AVAILABLE COMMANDS:", 0, 0, 13); printXY("<Enter> Disassemble at current address.", 16, 8, 13); printXY("s Step thru current instruction.", 16, 16, 13); printXY("S Step thru current scanline.", 16, 24, 13); printXY("f run till next frame / VBI", 16, 32, 13); printXY("r Run / Resume", 16, 40, 13); printXY("D <addr> disassemble address <addr>", 16, 48, 13); printXY("v View hexdump at current address", 16, 56, 13); printXY("V <addr> View hexdump at address <addr>", 16, 64, 13); printXY("l View display list data", 16, 72, 13); printXY("c View character set", 16, 80, 13); printXY("p View player/missile data", 16, 88, 13); printXY("1 Show collision registers", 16, 96, 13); printXY("i List interrupt vectors", 16, 104, 13); printXY("T <addr> run to <addr>", 16, 112, 13); printXY("K trigger Keyboard interrupt", 16, 120, 13); printXY("B trigger Break interrupt", 16, 128, 13); printXY("0 Set TRIG0 to 0", 16, 136, 13); printXY("Q or quit Quit / Exit", 16, 144, 13); printXY("Press any key to continue...", 0, 230, 15); BlitBuffer(0, 240); }