/* fresh tty buf to screen */ static void keyboard_write(TTY * tty_p) { int i = 0; u16 print; u32 key = 0; while (!is_tty_buf_empty(tty_p)) { key = keymap[(*(tty_p->tail_p)&0xff)*3]; if (*(tty_p->tail_p) & FLAG_CTRL_L) { if (key == 'p') { scroll(tty_p->console_p, SCROLL_UP, 1); } if (key == 'n') { scroll(tty_p->console_p, SCROLL_DOWN, 1); } if (key == F1) { switch_console(0); current_console_p = &console_table[0]; } if (key == F2) { switch_console(1); current_console_p = &console_table[1]; } if (key == F3) { switch_console(2); current_console_p = &console_table[2]; } goto CLEAR; } int line; if (key & FLAG_EXT) { if (key == ENTER) { line = tty_p->console_p->cursor / (80 * 2); tty_p->console_p->cursor = (line + 1) * (80 * 2); goto ADD_KEY_TO_LINE_CACHE; } if (key == BACKSPACE) { tty_p->console_p->cursor -= 2; xdisp_word_at(0|0x0F00, tty_p->console_p->cursor); del_key_from_line_in_cache(tty_p); goto CLEAR; } } assert(tty_p != NULL); xdisp_word_at(key|0x0f00, tty_p->console_p->cursor); tty_p->console_p->cursor += 2; //write do it ADD_KEY_TO_LINE_CACHE: add_key_to_line_in_cache(*(tty_p->tail_p), tty_p); CLEAR: if (is_current_console(tty_p->console_p)) set_cursor(tty_p->console_p->cursor); tty_p->buf_count--; tty_p->tail_p++; if (tty_p->tail_p == tty_p->read_buf + TTY_BUF_SIZE) tty_p->tail_p = tty_p->read_buf; } }
void init_screen(void) { int i; /* get video I/O port from BIOS */ if (in(VGA_MISC) & IS_COLOUR) { /* colour */ vid_port = CRTC_COLOUR; vid_memory = (unsigned short*) VID_COLOUR; nr_cons = COLOUR_SIZE / SCR_SIZE; } else { /* monochrome */ vid_port = CRTC_MONO; vid_memory = (unsigned short*) VID_MONO; nr_cons = MONO_SIZE / SCR_SIZE; } if (nr_cons > MAX_CONS) nr_cons = MAX_CONS; curcons = &cons_table[0]; /* select default console */ for (i = 0; i < nr_cons; i++) init_console(i); switch_console(0); /* switch to first console */ }
void special_key(unsigned int key) { if(key == KEY_PAGE_DOWN && shift) { scroll_down(current_pty, 10); } else if(key == KEY_PAGE_UP && shift) { scroll_up(current_pty, 10); } else if(key == KEY_ARROW_UP) { sendescstr("[A"); } else if(key == KEY_ARROW_DOWN) { sendescstr("[B"); } else if(key == KEY_ARROW_LEFT) { sendescstr("[D"); } else if(key == KEY_ARROW_RIGHT) { sendescstr("[C"); } else if(key >= KEY_F1 && key <= KEY_F9 && ctrl) { int console = key - KEY_F1; switch_console(console); } else if(key >= KEY_F1 && key < KEY_F10) { char str[5]; str[0] = '['; str[1] = '1' + (key - KEY_F1); str[2] = 'F'; str[3] = 0; sendescstr(str); } else if(key == KEY_DEL) { if(shift) sendescstr("[^4~"); else sendescstr("[4~"); } else if(key == KEY_INSERT) { if(shift) sendescstr("[^1~"); else sendescstr("[1~"); } else if(key == KEY_HOME) { if(shift) sendescstr("[^2~"); else sendescstr("[2~"); } else if(key == KEY_END) { if(shift) sendescstr("[^5~"); else sendescstr("[5~"); } else if(key == KEY_PAGE_DOWN) { sendescstr("[6~"); } else if(key == KEY_PAGE_UP) { sendescstr("[3~"); } else if(key == KEY_BACKTAB) { sendescstr("[Z"); } }
void cleanup() { if (saved_vt!=0) { struct vt_stat state; int fd; fd = open("/dev/console", O_RDWR); ioctl(fd,VT_GETSTATE,&state); close(fd); if (state.v_active == new_vt) { // We're still on the console to which we switched, // so switch back switch_console(saved_vt); } } }
void draw_options(C64 *TheC64) { char *imagefile; char loadprg[255]; int i; static int cursor_pos=3; static Prefs *prefs=NULL; int update_prefs=0; uint16 bg, fg; static int getfilename=0; static int xfiletype; static int set_buttons; static int menu_y=3; static int menu_x=5; static int is_moving=0; static int threshold=10; static int stepping=2; #ifndef SPMP static int gpcpu_speed=133; #endif static int load_snapshot=0; static int save_snapshot=0; enum { D64, LOADSTAR, LOADER, PRG, RESET64, BLANK1, SOUND, BRIGHTNESS, CONTRAST, FRAMESKIP, LIMITSPEED, JOYSTICK, EMU1541CPU, BLANK2, BUTTONS, #ifndef SPMP CHATBOARD, #endif BLANK3, LOAD_SNAP, SAVE_SNAP, BLANK4, #ifndef SPMP DEBUG, RESETGP, #endif NUM_OPTIONS, #ifndef SPMP CPU_SPEED, /* WTF does this come after NUM_OPTIONS?? */ #endif }; const char *option_txt[NUM_OPTIONS+5]; option_txt[SOUND]= "Sound "; option_txt[BRIGHTNESS]= "Brightness "; option_txt[CONTRAST]= "Contrast "; option_txt[FRAMESKIP]= "Frameskip "; option_txt[LIMITSPEED]= "Limit speed "; option_txt[JOYSTICK]= "Joystick in port "; option_txt[EMU1541CPU]= "1541 CPU emulation "; option_txt[D64]= "Attach d64/t64/dir... "; option_txt[LOADSTAR]= "Load first program "; option_txt[LOADER]= "Load d64/dir browser "; option_txt[PRG]= "Load .prg file... "; option_txt[SAVE_SNAP]= "Save snapshot... "; option_txt[LOAD_SNAP]= "Load snapshot... "; #ifndef SPMP option_txt[CPU_SPEED]= "gp32 CPU speed "; option_txt[CHATBOARD]= "Chatboard "; #endif option_txt[BUTTONS]= "Set buttons... "; option_txt[RESET64]= "Reset C=64 "; #ifndef SPMP option_txt[DEBUG]= "Debug console "; option_txt[RESETGP]= "Restart GP32 "; #endif option_txt[BLANK1]= " "; option_txt[BLANK2]= " "; option_txt[BLANK3]= " "; option_txt[BLANK4]= " "; option_txt[NUM_OPTIONS]= " "; option_txt[NUM_OPTIONS+1]= " "; option_txt[NUM_OPTIONS+2]= " "; option_txt[NUM_OPTIONS+3]= " "; option_txt[NUM_OPTIONS+4]= NULL; char brightness_txt[3]=" "; char frameskip_txt[3]=" "; char contrast_txt[4]=" . "; uint8 menu_bg=14; uint8 menu_fg=6; uint8 menu_selbg=7; uint8 menu_selfg=6; if(load_snapshot||save_snapshot) { int sn=draw_snapshotui(TheC64, save_snapshot, prefs->DrivePath[0]); if(sn==-1) { // exit from snapshot ui load_snapshot=0; save_snapshot=0; } else if(!sn) { // snapshot ui stays open return; } else { // exit snapshot and options ui load_snapshot=0; save_snapshot=0; options_enabled=0; return; } } if(getfilename) { imagefile=filerequest(NULL); if(imagefile==NULL) { return; } else if (imagefile==(char *)-1) { getfilename=0; } else { if(xfiletype==0) { //printf("setting DrivePath[0] to -%s-\n", imagefile); strcpy(prefs->DrivePath[0], imagefile); update_prefs=1; cursor_pos=menu_y+LOADSTAR; } else if(xfiletype==1) { for(i=strlen(imagefile); i>0; i--) { if(imagefile[i]=='/') break; } strcpy(loadprg, "\rLOAD\""); strcat(loadprg, imagefile+i+1); strcat(loadprg, "\",8,1\rRUN\r"); imagefile[i]='\0'; strcpy(prefs->DrivePath[0], imagefile); for(i=0; loadprg[i]; i++) loadprg[i]=toupper(loadprg[i]); kbd_buf_feed(loadprg); update_prefs=1; options_enabled=0; } getfilename=0; } } if(set_buttons) { if(draw_buttonsui()) set_buttons=0; button_state&=~X_PRESSED; return; } if(prefs==NULL) prefs=new Prefs(ThePrefs); for(i=0; option_txt[i]; i++) { if(cursor_pos==(menu_y+i)) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, option_txt[i], bg, fg, menu_x, menu_y+i, 0); } // sound state if(prefs->SIDType==SIDTYPE_NONE) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "Off ", bg, fg, menu_x+20, menu_y+SOUND, 0); if(prefs->SIDType==SIDTYPE_DIGITAL) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "On ", bg, fg, menu_x+24, menu_y+SOUND, 0); bg=menu_bg; fg=menu_fg; // brightness brightness_txt[0]=(char)(0x30+((brightness%100)/10)); brightness_txt[1]=(char)(0x30+((brightness%100)%10)); text_out8((uint8 *)gp.pixels, brightness_txt, bg, fg, menu_x+20, menu_y+BRIGHTNESS, 0); // contrast contrast_txt[0]=(char)(0x30+((contrast%100)/10)); contrast_txt[2]=(char)(0x30+((contrast%100)%10)); text_out8((uint8 *)gp.pixels, contrast_txt, bg, fg, menu_x+20, menu_y+CONTRAST, 0); // frameskip frameskip_txt[0]=(char)(0x30+(((prefs->SkipFrames-1)%100)/10)); frameskip_txt[1]=(char)(0x30+(((prefs->SkipFrames-1)%100)%10)); text_out8((uint8 *)gp.pixels, frameskip_txt, bg, fg, menu_x+20, menu_y+FRAMESKIP, 0); // limit speed if(prefs->LimitSpeed==false) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "Off ", bg, fg, menu_x+20, menu_y+LIMITSPEED, 0); if(prefs->LimitSpeed==true) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "On ", bg, fg, menu_x+24, menu_y+LIMITSPEED, 0); bg=menu_bg; fg=menu_fg; // current joyport if(current_joystick==0) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "1 ", bg, fg, menu_x+20, menu_y+JOYSTICK, 0); if(current_joystick==1) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "2 ", bg, fg, menu_x+24, menu_y+JOYSTICK, 0); // 1541 cpu if(prefs->Emul1541Proc==false) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "Off ", bg, fg, menu_x+20, menu_y+EMU1541CPU, 0); if(prefs->Emul1541Proc==true) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "On ", bg, fg, menu_x+24, menu_y+EMU1541CPU, 0); // reset type if(prefs->FastReset==false) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "slow", bg, fg, menu_x+20, menu_y+RESET64, 0); if(prefs->FastReset==true) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "fast", bg, fg, menu_x+24, menu_y+RESET64, 0); #ifndef SPMP // chatboard if(!chatboard_enabled) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "Off ", bg, fg, menu_x+20, menu_y+CHATBOARD, 0); if(chatboard_enabled) { bg=menu_selbg; fg=menu_selfg; } else { bg=menu_bg; fg=menu_fg; } text_out8((uint8 *)gp.pixels, "On ", bg, fg, menu_x+24, menu_y+CHATBOARD, 0); #endif i=menu_y+NUM_OPTIONS+1; // display attached file bg=menu_bg; fg=menu_fg; text_out8((uint8 *)gp.pixels, "drive 8 img: ", bg, fg, menu_x, i++, 0); text_out8((uint8 *)gp.pixels, prefs->DrivePath[0], bg, fg, menu_x, i++, 0); text_out8((uint8 *)gp.pixels, "Press select to load", bg, fg, menu_x, i++, 0); if(button_state&X_PRESSED) { button_state&=~(X_PRESSED); if(cursor_pos==menu_y+LOADSTAR) { kbd_buf_feed("\rLOAD\":*\",8,1:\rRUN\r"); options_enabled=0; } if(cursor_pos==menu_y+LOADER) { load_prg(TheC64, c64loader, sizeof(c64loader)); kbd_buf_feed("\rLOAD\"X\",8,1\rRUN\r"); options_enabled=0; } if(cursor_pos==menu_y+D64) { getfilename=1; xfiletype=0; } else if(cursor_pos==menu_y+PRG) { getfilename=1; xfiletype=1; } else if(cursor_pos==menu_y+RESET64) { TheC64->Reset(); options_enabled=0; } else if(cursor_pos==menu_y+SAVE_SNAP) { //remove("/smfs/gpmm/c64/frodo/snap1"); //TheC64->SaveSnapshot("/smfs/gpmm/c64/frodo/snap1"); //options_enabled=0; save_snapshot=1; } else if(cursor_pos==menu_y+LOAD_SNAP) { //TheC64->LoadSnapshot("/smfs/gpmm/c64/frodo/snap1"); //options_enabled=0; load_snapshot=1; } else if(cursor_pos==menu_y+BUTTONS) { set_buttons=1; #ifndef SPMP } else if(cursor_pos==menu_y+DEBUG) { switch_console(); #endif /*} else if(cursor_pos==10) { app_execute(prefs->DrivePath[0]);*/ #ifndef SPMP } else if(cursor_pos==menu_y+RESETGP) { gp32reboot(); #endif } } if(button_state&UP_PRESSED) { if(is_moving==0||((is_moving>threshold)&&(is_moving%stepping==0))) { if(cursor_pos>menu_y) cursor_pos--; } is_moving++; } else if(button_state&DOWN_PRESSED) { if(is_moving==0||((is_moving>threshold)&&(is_moving%stepping==0))) { if(cursor_pos<menu_y+NUM_OPTIONS-1) cursor_pos++; } is_moving++; } else { is_moving=0; } if(button_state&LEFT_PRESSED) { #ifndef SPMP if(cursor_pos==menu_y+CPU_SPEED) { if(gpcpu_speed==133) { gpcpu_speed=100; printf("setting cpu speed to 100mhz\n"); //cpu_speed(102000000, (43<<12) | (1<<4) | 1, 2); } } #endif if(cursor_pos==menu_y+SOUND) { prefs->SIDType=SIDTYPE_NONE; update_prefs=1; } if(cursor_pos==menu_y+BRIGHTNESS) { if(brightness>0) { brightness--; //ui_set_palette(); } } if(cursor_pos==menu_y+CONTRAST) { if(contrast>0) { contrast--; //ui_set_palette(); } } if(cursor_pos==menu_y+FRAMESKIP) { if(prefs->SkipFrames>1) { prefs->SkipFrames--; update_prefs=1; } } if(cursor_pos==menu_y+LIMITSPEED) { prefs->LimitSpeed=false; update_prefs=1; } if(cursor_pos==menu_y+JOYSTICK) { current_joystick=0; } if(cursor_pos==menu_y+EMU1541CPU) { prefs->Emul1541Proc=false; update_prefs=1; } if(cursor_pos==menu_y+RESET64) { prefs->FastReset=false; update_prefs=1; } #ifndef SPMP if(cursor_pos==menu_y+CHATBOARD) { disable_chatboard(); } #endif } else if(button_state&RIGHT_PRESSED) { #ifndef SPMP if(cursor_pos==menu_y+CPU_SPEED) { if(gpcpu_speed==100) { gpcpu_speed=133; printf("setting cpu speed to 133mhz\n"); //cpu_speed(133500000, (81<<12) | (2<<4) | 1, 2); } } #endif if(cursor_pos==menu_y+SOUND) { prefs->SIDType=SIDTYPE_DIGITAL; update_prefs=1; } if(cursor_pos==menu_y+BRIGHTNESS) { if(brightness<25) { brightness++; //ui_set_palette(); } } if(cursor_pos==menu_y+CONTRAST) { if(contrast<100) { contrast++; //ui_set_palette(); } } if(cursor_pos==menu_y+FRAMESKIP) { if(prefs->SkipFrames<100) { prefs->SkipFrames++; update_prefs=1; } } if(cursor_pos==menu_y+LIMITSPEED) { prefs->LimitSpeed=true; update_prefs=1; } if(cursor_pos==menu_y+JOYSTICK) { current_joystick=1; } if(cursor_pos==menu_y+EMU1541CPU) { prefs->Emul1541Proc=true; update_prefs=1; } if(cursor_pos==menu_y+RESET64) { prefs->FastReset=true; update_prefs=1; } #if 0 if(cursor_pos==menu_y+CHATBOARD) { enable_chatboard(); } #endif } if(update_prefs) { //printf("updating prefs\n"); TheC64->NewPrefs(prefs); ThePrefs=*prefs; delete prefs; prefs=NULL; update_prefs=0; } }
int main (int argc, char** argv) { int err; void *handle; #ifdef DEBUG logfile = fopen ("/dev/.initramfs/usplash_log","w+"); #endif if (argc>1) { if (strcmp(argv[1],"-c")==0) switch_console(8); } chdir("/dev/.initramfs"); if (mkfifo(USPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) { if (errno!=EEXIST) { perror("mkfifo"); cleanup(); exit(1); } } pipe_fd = open(USPLASH_FIFO,O_RDONLY|O_NONBLOCK); if (pipe_fd==-1) { perror("pipe open"); cleanup(); exit(2); } err=bogl_init(); if (!err) { fprintf(stderr,"%d",err); cleanup(); exit (2); } handle = dlopen("/usr/lib/usplash/usplash-artwork.so", RTLD_LAZY); if (!handle) { exit(1); } pixmap_usplash_artwork = (struct bogl_pixmap *)dlsym(handle, "pixmap_usplash_artwork"); bogl_set_palette (0, 16, pixmap_usplash_artwork->palette); left_edge = (bogl_xres - 640) / 2; top_edge = (bogl_yres - 400) / 2; draw_image(pixmap_usplash_artwork); init_progressbar(); text_clear(); event_loop(); bogl_done(); cleanup(); return 0; }