int main (int argc, char **argv) { char *term; char *buf; term = argv[1]; printf ("TERM: %s\n", term); buf = (char *) tgetent (0, term); if ((int) buf <= 0) { printf ("No entry.\n"); return 0; } printf ("Entry: %s\n", buf); tprint ("cm"); tprint ("AL"); printf ("co: %d\n", tgetnum ("co")); printf ("am: %d\n", tgetflag ("am")); return 0; }
void showwatch() { if (show_scrshot) { for (unsigned y = 0; y < wat_sz; y++) for (unsigned x = 0; x < 37; x++) txtscr[80*30 + (wat_y+y)*80 + (wat_x+x)] = 0xFF; } else { Z80 &cpu = CpuMgr.Cpu(); wtline("PC", cpu.pc, 0); wtline("SP", cpu.sp, 1); wtline("BC", cpu.bc, 2); wtline("DE", cpu.de, 3); wtline("HL", cpu.hl, 4); wtline("IX", cpu.ix, 5); wtline("IY", cpu.iy, 6); wtline("BC'", cpu.alt.bc, 7); wtline("DE'", cpu.alt.de, 8); wtline("HL'", cpu.alt.hl, 9); wtline(0, user_watches[0], 10); wtline(0, user_watches[1], 11); wtline(0, user_watches[2], 12); } const char *text = "watches"; if (show_scrshot == 1) text = "screen memory"; if (show_scrshot == 2) text = "ray-painted"; tprint(wat_x, wat_y-1, text, W_TITLE); if(comp.flags & CF_DOSPORTS) tprint(wat_x+34, wat_y-1, "DOS", W_DOS); frame(wat_x,wat_y,37,wat_sz,FRAME); }
void show_time() { Z80 &cpu = CpuMgr.Cpu(); tprint(time_x, time_y, "time delta:", W_OTHEROFF); char text[32]; sprintf(text, "%14I64d", cpu.Delta()); tprint(time_x+11, time_y, text, W_OTHER); tprint(time_x+25, time_y, "t", W_OTHEROFF); frame(time_x, time_y, 26, 1, FRAME); }
void group_trace(boolean e) { begin_diagnostic(); print_char('{'); if(e) tprint("leaving "); else tprint("entering "); print_group(e); print_char('}'); end_diagnostic(false); }
void showbanks() { Z80 &cpu = CpuMgr.Cpu(); for (int i = 0; i < 4; i++) { char ln[64]; sprintf(ln, "%d:", i); tprint(banks_x, banks_y+i+1, ln, W_OTHEROFF); strcpy(ln, "?????"); cpu.BankNames(i, ln); tprint(banks_x+2, banks_y+i+1, ln, bankr[i]!=bankw[i] ? W_BANKRO : W_BANK); } frame(banks_x, banks_y+1, 7, 4, FRAME); tprint(banks_x, banks_y, "pages", W_TITLE); }
void lookf(struct tobj *t){ if(t == self.next){ printf(self.next->type & IN ? "You are in " : "You are at "); } else{ printf("You are looking at "); } if(t == &self){ tprint(t, 1, "You have "); } else{ tprint(t, 1, "There is "); } }
void print_glue(scaled d,int order,const char*s) { print_scaled(d); if((order<normal)||(order> filll)){ tprint("foul"); }else if(order> normal){ tprint("fi"); while(order> sfi){ print_char('l'); decr(order); } }else if(s!=NULL){ tprint(s); } }
void tprint_esc(const char*s) { int c= escape_char_par; if(c>=0&&c<STRING_OFFSET) print(c); tprint(s); }
void show_ay() { if (!conf.sound.ay_scheme) return; const char *ayn = comp.active_ay ? "AY1" : "AY0"; if (conf.sound.ay_scheme < AY_SCHEME_QUADRO) ayn = "AY:", comp.active_ay = 0; tprint(ay_x-3, ay_y, ayn, W_TITLE); SNDCHIP *chip = &ay[comp.active_ay]; char line[32]; for (int i = 0; i < 16; i++) { line[0] = "0123456789ABCDEF"[i]; line[1] = 0; tprint(ay_x + i*3, ay_y, line, W_AYNUM); sprintf(line, "%02X", chip->get_reg(i)); tprint(ay_x + i*3 + 1, ay_y, line, i == (chip->get_activereg()) ? W_AYON : W_AYOFF); } frame(ay_x, ay_y, 48, 1, FRAME); }
void tprint(AvlTree T, int D) { if (T != NULL) { tprint(T->Left, D + 1); char s[D]; strcpy(s, ""); for (int i = 0; i < D; i++) { strcat(s, "\t"); } // puts(s); fprintf(stdout, "%s%d|%d\n", s, T->Element, T->Height); tprint(T->Right, D + 1); } }
void if_warning(void) { boolean w= false; int i= in_open; base_ptr= input_ptr; input_stack[base_ptr]= cur_input; while(if_stack[i]==cond_ptr){ if(tracing_nesting_par> 0){ while((input_stack[base_ptr].state_field==token_list)|| (input_stack[base_ptr].index_field> i)) decr(base_ptr); if(input_stack[base_ptr].name_field> 17) w= true; } if_stack[i]= vlink(cond_ptr); decr(i); } if(w){ tprint_nl("Warning: end of "); print_cmd_chr(if_test_cmd,cur_if); print_if_line(if_line); tprint(" of a different file"); print_ln(); if(tracing_nesting_par> 1) show_context(); if(history==spotless) history= warning_issued; } }
int main(void) { SearchTree T = NULL; MakeEmpty(T); // Insert(50, T); // for (int i = 50; i > 0; i--) // { // T = Insert(i, T); // } // for (int i = 51; i < 100; i++) // { // T = Insert(i, T); // } srand(time(NULL)); for (int i = 0; i < 100; i++) { T = Insert( rand() % 100, T); } tprint(T, 0); // for (int i = 0; i < 100; i++) // { // T = Delete(rand() % 100, T); // } // tprint(T, 0); return 0; }
void group_warning(void) { boolean w= false; int i= in_open; base_ptr= input_ptr; input_stack[base_ptr]= cur_input; while((grp_stack[i]==cur_boundary)&&(i> 0)){ if(tracing_nesting_par> 0){ while((input_stack[base_ptr].state_field==token_list)|| (input_stack[base_ptr].index_field> i)) decr(base_ptr); if(input_stack[base_ptr].name_field> 17) w= true; } grp_stack[i]= save_value(save_ptr); decr(i); } if(w){ tprint_nl("Warning: end of "); print_group(true); tprint(" of a different file"); print_ln(); if(tracing_nesting_par> 1) show_context(); if(history==spotless) history= warning_issued; } }
void showstack() { Z80 &cpu = CpuMgr.Cpu(); for (unsigned i = 0; i < stack_size; i++) { char xx[10]; //-2:1234 //SP:1234 //+2: if (!i) *(unsigned*)xx = WORD2('-','2'); else if (i==1) *(unsigned*)xx = WORD2('S','P'); else sprintf(xx, (i > 8) ? "%X" : "+%X", (i-1)*2); sprintf(xx+2, ":%02X%02X", cpu.DirectRm(cpu.sp+(i-1)*2+1), cpu.DirectRm(cpu.sp+(i-1)*2)); tprint(stack_x, stack_y+i, xx, W_OTHER); } tprint(stack_x, stack_y-1, "stack", W_TITLE); frame(stack_x, stack_y, 7, stack_size, FRAME); }
void showports() { char ln[64]; sprintf(ln, " FE:%02X", comp.pFE); tprint(ports_x, ports_y, ln, W_OTHER); sprintf(ln, "7FFD:%02X", comp.p7FFD); tprint(ports_x, ports_y+1, ln, (comp.p7FFD & 0x20) && !((conf.mem_model == MM_PENTAGON && conf.ramsize == 1024) || (conf.mem_model == MM_PROFI && (comp.pDFFD & 0x10))) ? W_48K : W_OTHER); switch (conf.mem_model) { case MM_KAY: case MM_SCORP: case MM_PROFSCORP: case MM_PLUS3: dbg_extport = 0x1FFD; dgb_extval = comp.p1FFD; break; case MM_PROFI: dbg_extport = 0xDFFD; dgb_extval = comp.pDFFD; break; case MM_ATM450: dbg_extport = 0xFDFD; dgb_extval = comp.pFDFD; break; case MM_ATM710: case MM_ATM3: dbg_extport = (comp.aFF77 & 0xFFFF); dgb_extval = comp.pFF77; break; case MM_QUORUM: dbg_extport = 0x0000; dgb_extval = comp.p00; break; default: dbg_extport = -1; } if (dbg_extport != -1) sprintf(ln, "%04X:%02X", dbg_extport, dgb_extval); else sprintf(ln, "cmos:%02X", comp.cmos_addr); tprint(ports_x, ports_y+2, ln, W_OTHER); sprintf(ln, "EFF7:%02X", comp.pEFF7); tprint(ports_x, ports_y+3, ln, W_OTHER); frame(ports_x, ports_y, 7, 4, FRAME); tprint(ports_x, ports_y-1, "ports", W_TITLE); }
void print_file_line(void) { int level= in_open; while((level> 0)&&(full_source_filename_stack[level]==0)) decr(level); if(level==0){ tprint_nl("! "); }else{ tprint_nl(""); tprint(full_source_filename_stack[level]); print_char(':'); if(level==in_open) print_int(line); else print_int(line_stack[level+1]); tprint(": "); } }
void print_spec(int p,const char*s) { if(p<0){ print_char('*'); }else{ print_scaled(width(p)); if(s!=NULL) tprint(s); if(stretch(p)!=0){ tprint(" plus "); print_glue(stretch(p),stretch_order(p),s); } if(shrink(p)!=0){ tprint(" minus "); print_glue(shrink(p),shrink_order(p),s); } } }
void file_warning(void) { halfword p= save_ptr; int l= cur_level; int c= cur_group; int i; save_ptr= cur_boundary; while(grp_stack[in_open]!=save_ptr){ decr(cur_level); tprint_nl("Warning: end of file when "); print_group(true); tprint(" is incomplete"); cur_group= save_level(save_ptr); save_ptr= save_value(save_ptr); } save_ptr= p; cur_level= (quarterword)l; cur_group= (group_code)c; p= cond_ptr; l= if_limit; c= cur_if; i= if_line; while(if_stack[in_open]!=cond_ptr){ tprint_nl("Warning: end of file when "); print_cmd_chr(if_test_cmd,cur_if); if(if_limit==fi_code) tprint_esc("else"); print_if_line(if_line); tprint(" is incomplete"); if_line= if_line_field(cond_ptr); cur_if= if_limit_subtype(cond_ptr); if_limit= if_limit_type(cond_ptr); cond_ptr= vlink(cond_ptr); } cond_ptr= p; if_limit= l; cur_if= c; if_line= i; print_ln(); if(tracing_nesting_par> 1) show_context(); if(history==spotless) history= warning_issued; }
main() { struct node *root; char word[20]; root = 0; next = 0; while (getword(word)) lookup(word, &root)->count++; tprint(root); return 0; }
unsigned find1dlg(unsigned start) { static char ftext[12] = ""; strcpy(str, ftext); filledframe(10,10,16,4); tprint(10,10," find string ", FRM_HEADER); tprint(11,12,"text:", FFRAME_INSIDE); if (!inputhex(17,12,8,false)) return -1; strcpy(ftext, str); unsigned len = strlen(ftext); unsigned i; //Alone Coder 0.36.7 for (unsigned ptr = memadr(start+1); ptr != start; ptr = memadr(ptr+1)) { for (/*unsigned*/ i = 0; i < len; i++) if (editrm(memadr(ptr+i)) != ftext[i]) break; if (i == len) return ptr; } tprint(11,12," not found ", FFRAME_ERROR); debugflip(); while (!process_msgs()); return -1; }
void print_font_identifier(internal_font_number f) { str_number fonttext; fonttext= font_id_text(f); if(fonttext> 0){ print_esc(fonttext); }else{ tprint_esc("FONT"); print_int(f); } if(tracing_fonts_par> 0){ tprint(" ("); print_font_name(f); if(font_size(f)!=font_dsize(f)){ tprint("@"); print_scaled(font_size(f)); tprint("pt"); } print_char(')'); } }
unsigned find2dlg(unsigned start) { static unsigned code = 0xF3, mask = 0xFF; char ln[64]; filledframe(10,10,16,5); tprint(10,10," find data ", FRM_HEADER); sprintf(ln, "code: %08X", _byteswap_ulong(code)); tprint(11,12,ln, FFRAME_INSIDE); sprintf(ln, "mask: %08X", _byteswap_ulong(mask)); tprint(11,13,ln, FFRAME_INSIDE); sprintf(str, "%08X", _byteswap_ulong(code)); if (!inputhex(17,12,8,true)) return -1; sscanf(str, "%x", &code); code = _byteswap_ulong(code); tprint(17,12,str, FFRAME_INSIDE); sprintf(str, "%08X", _byteswap_ulong(mask)); if (!inputhex(17,13,8,true)) return -1; sscanf(str, "%x", &mask); mask = _byteswap_ulong(mask); unsigned i; //Alone Coder 0.36.7 for (unsigned ptr = memadr(start+1); ptr != start; ptr = memadr(ptr+1)) { unsigned char *cd = (unsigned char*)&code, *ms = (unsigned char*)&mask; for (/*unsigned*/ i = 0; i < 4; i++) if ((editrm(memadr(ptr+i)) & ms[i]) != (cd[i] & ms[i])) break; if (i == 4) return ptr; } tprint(11,12," not found ", FFRAME_ERROR); tprint(11,13," ", FFRAME_ERROR); debugflip(); while (!process_msgs()); return -1; }
void showdos() { // CD:802E // STAT:24 // SECT:00 // T:00/01 // S:00/00 //[vv] if (conf.trdos_present) comp.wd.process(); char ln[64]; unsigned char atr = conf.trdos_present ? W_OTHER : W_OTHEROFF; sprintf(ln, "CD:%02X%02X", comp.wd.cmd, comp.wd.data); tprint(dos_x, dos_y, ln, atr); sprintf(ln, "STAT:%02X", comp.wd.status); tprint(dos_x, dos_y+1, ln, atr); sprintf(ln, "SECT:%02X", comp.wd.sector); tprint(dos_x, dos_y+2, ln, atr); sprintf(ln, "T:%02X/%02X", comp.wd.seldrive->track, comp.wd.track); tprint(dos_x, dos_y+3, ln, atr); sprintf(ln, "S:%02X/%02X", comp.wd.system, comp.wd.rqs); tprint(dos_x, dos_y+4, ln, atr); frame(dos_x, dos_y, 7, 5, FRAME); #if 1 tprint(dos_x, dos_y-1, "beta128", W_TITLE); #else sprintf(ln, "%X-%X %d", comp.wd.state, comp.wd.state2, comp.wd.seldrive->track); tprint(dos_x,dos_y-1, ln, atr); #endif /* // STAT:00101010 // CMD:80,STA:2A // DAT:22,SYS:EE // TRK:31,SEC:01 // DISK:A,SIDE:0 char ln[64]; unsigned char atr = conf.trdos_present ? 0x20 : 0x27; sprintf(ln, "STAT:00000000"); unsigned char stat = in_trdos(0x1F); for (int i = 0; i < 7; i++) ln[i+5] = (stat & (0x80 >> i)) ? '1':'0'; tprint(dos_x, dos_y+1, ln, atr); sprintf(ln, "CMD:%02X,STA:%02X", comp.trdos.cmd, stat); tprint(dos_x, dos_y+2, ln, atr); sprintf(ln, "DAT:%02X,SYS:%02X", comp.trdos.data, in_trdos(0xFF)); tprint(dos_x, dos_y+3, ln, atr); sprintf(ln, "TRK:%02X,SEC:%02X", comp.trdos.track, comp.trdos.sector); tprint(dos_x, dos_y+4, ln, atr); sprintf(ln, "DISK:%c,SIDE:%c", 'A'+(comp.trdos.system & 3), (comp.trdos.system & 0x10) ? '0':'1'); tprint(dos_x, dos_y+5, ln, atr); frame(dos_x, dos_y+1, 13, 5, FRAME); tprint(dos_x, dos_y, "beta128", 0x83); */ }
static void wtline(const char *name, unsigned ptr, unsigned y) { char line[40]; if(name) sprintf(line, "%3s: ", name); else sprintf(line, "%04X ", ptr); Z80 &cpu = CpuMgr.Cpu(); for (unsigned dx = 0; dx < 8; dx++) { unsigned char c = cpu.DirectRm(ptr++); sprintf(line+5+3*dx, "%02X", c); line[7+3*dx] = ' '; line[29+dx] = c ? c : '.'; } line[37] = 0; tprint(wat_x, wat_y+y, line, W_OTHER); }
int main(void) { AvlTree T = NULL; MakeEmpty(T); T = Insert(1, T); // T = Insert(2, T); // T = Insert(3, T); for (int i = 0; i < 100; i++) { T = Insert(i, T); } tprint(T, 0); return 0; }
void write_out(halfword p) { int old_setting; int j; char*s,*ss; int callback_id; int lua_retval; expand_macros_in_tokenlist(p); old_setting= selector; j= write_stream(p); if(file_can_be_written(j)){ selector= j; }else if((j==term_only)&&(selector==term_and_log)){ selector= log_only; tprint_nl(""); }else{ tprint_nl(""); } s= tokenlist_to_cstring(def_ref,false,NULL); if(selector<no_print){ callback_id= callback_defined(process_output_buffer_callback); if(callback_id> 0){ lua_retval= run_callback(callback_id,"S->S",s,&ss); if((lua_retval==true)&&(ss!=NULL)){ xfree(s); s= ss; } } } tprint(s); xfree(s); print_ln(); flush_list(def_ref); selector= old_setting; }
void mon_tool() { Z80 &cpu = CpuMgr.Cpu(); static unsigned char unref = 0xCF; if (ripper) { OPENFILENAME ofn = { 0 }; char savename[0x200]; *savename = 0; ofn.lStructSize = (WinVerMajor < 5) ? OPENFILENAME_SIZE_VERSION_400 : sizeof(OPENFILENAME); ofn.lpstrFilter = "Memory dump\0*.bin\0"; ofn.lpstrFile = savename; ofn.nMaxFile = sizeof savename; ofn.lpstrTitle = "Save ripped data"; ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; ofn.hwndOwner = wnd; ofn.lpstrDefExt = "bin"; ofn.nFilterIndex = 1; if (GetSaveFileName(&ofn)) { for (unsigned i = 0; i < 0x10000; i++) snbuf[i] = (cpu.membits[i] & ripper) ? cpu.DirectRm(i) : unref; FILE *ff = fopen(savename, "wb"); if (ff) fwrite(snbuf, 1, 0x10000, ff), fclose(ff); } ripper = 0; } else { filledframe(tool_x, tool_y, 17, 6); tprint(tool_x, tool_y, " ripper's tool ", FRM_HEADER); tprint(tool_x+1,tool_y+2, "trace reads:", FFRAME_INSIDE); *(unsigned*)str = 'Y'; if (!inputhex(tool_x+15,tool_y+2,1,false)) return; tprint(tool_x+15,tool_y+2,str,FFRAME_INSIDE); if (*str == 'Y' || *str == 'y' || *str == '1') ripper |= MEMBITS_R; *(unsigned*)str = 'N'; tprint(tool_x+1,tool_y+3, "trace writes:", FFRAME_INSIDE); if (!inputhex(tool_x+15,tool_y+3,1,false)) { ripper = 0; return; } tprint(tool_x+15,tool_y+3,str,FFRAME_INSIDE); if (*str == 'Y' || *str == 'y' || *str == '1') ripper |= MEMBITS_W; tprint(tool_x+1,tool_y+4, "unref. byte:", FFRAME_INSIDE); unsigned ub; if ((ub = input2(tool_x+14,tool_y+4,unref)) == -1) { ripper = 0; return; } unref = (unsigned char)ub; if (ripper) for (unsigned i = 0; i < 0x10000; i++) cpu.membits[i] &= ~(MEMBITS_R | MEMBITS_W); } }
void mon_fill() { filledframe(6,10,26,5); char ln[64]; sprintf(ln, "start: %04X end: %04X", addr, end); tprint(6,10, " fill memory block ", FRM_HEADER); tprint(7,12, "pattern (hex):", FFRAME_INSIDE); tprint(7,13, ln, FFRAME_INSIDE); static char fillpattern[10] = "00"; unsigned char pattern[4]; unsigned fillsize = 0; strcpy(str, fillpattern); if (!inputhex(22,12,8,true)) return; strcpy(fillpattern, str); if (!fillpattern[0]) strcpy(fillpattern, "00"); for (fillsize = 0; fillpattern[2*fillsize]; fillsize++) { if (!fillpattern[2*fillsize+1]) fillpattern[2*fillsize+1] = '0', fillpattern[2*fillsize+2] = 0; pattern[fillsize] = hex(fillpattern + 2*fillsize); } tprint(22,12," ", FFRAME_INSIDE); tprint(22,12,fillpattern, FFRAME_INSIDE); unsigned a1 = input4(14,13,addr); if (a1 == -1) return; addr = a1; tprint(14,13,str,FFRAME_INSIDE); a1 = input4(24,13,end); if (a1 == -1) return; end = a1; unsigned pos = 0; for (a1 = addr; a1 <= end; a1++) { cpu.DirectWm(a1, pattern[pos]); if (++pos == fillsize) pos = 0; } }
void prompt_input(const char*s) { wake_up_terminal(); tprint(s); term_input(); }
void print_group(boolean e) { switch(cur_group){ case bottom_level: tprint("bottom level"); return; break; case simple_group: case semi_simple_group: if(cur_group==semi_simple_group) tprint("semi "); tprint("simple"); break;; case hbox_group: case adjusted_hbox_group: if(cur_group==adjusted_hbox_group) tprint("adjusted "); tprint("hbox"); break; case vbox_group: tprint("vbox"); break; case vtop_group: tprint("vtop"); break; case align_group: case no_align_group: if(cur_group==no_align_group) tprint("no "); tprint("align"); break; case output_group: tprint("output"); break; case disc_group: tprint("disc"); break; case insert_group: tprint("insert"); break; case vcenter_group: tprint("vcenter"); break; case math_group: case math_choice_group: case math_shift_group: case math_left_group: tprint("math"); if(cur_group==math_choice_group) tprint(" choice"); else if(cur_group==math_shift_group) tprint(" shift"); else if(cur_group==math_left_group) tprint(" left"); break; } tprint(" group (level "); print_int(cur_level); print_char(')'); if(saved_value(-1)!=0){ if(e) tprint(" entered at line "); else tprint(" at line "); print_int(saved_value(-1)); } }