void mount_root(void) { register struct file_system_type **fs_type; register struct super_block *sb; struct inode *inode, d_inode; struct file filp; int retval; retry_floppy: memset(&filp, 0, sizeof(filp)); filp.f_inode = &d_inode; filp.f_mode = ((root_mountflags & MS_RDONLY) ? 1 : 3); memset(&d_inode, 0, sizeof(d_inode)); d_inode.i_rdev = ROOT_DEV; retval = blkdev_open(&d_inode, &filp); if (retval == -EROFS) { root_mountflags |= MS_RDONLY; filp.f_mode = 1; retval = blkdev_open(&d_inode, &filp); } for (fs_type = &file_systems[0]; *fs_type; fs_type++) { struct file_system_type *fp = *fs_type; if (retval) break; #ifdef BLOAT_FS if (!fp->requires_dev) continue; #endif sb = read_super(ROOT_DEV, fp->name, root_mountflags, NULL, 1); if (sb) { inode = sb->s_mounted; /* NOTE! it is logically used 4 times, not 1 */ inode->i_count += 3; sb->s_covered = inode; sb->s_flags = (unsigned short int) root_mountflags; current->fs.pwd = current->fs.root = inode; printk("VFS: Mounted root (%s filesystem)%s.\n", fp->name, (sb->s_flags & MS_RDONLY) ? " readonly" : ""); return; } } #ifdef CONFIG_BLK_DEV_BIOS if (ROOT_DEV == 0x0380) { if (filp.f_op->release) filp.f_op->release(&d_inode, &filp); else printk("Release not defined\n"); printk("VFS: Insert root floppy and press ENTER\n"); wait_for_keypress(); goto retry_floppy; } #endif panic("VFS: Unable to mount root fs on %s\n", kdevname(ROOT_DEV)); }
static inline void info(void) { int loop; const char * const str[12] = {"Plinko V 1.0", "By Travis Fischer", "", "Win as many plinko chips as you can", "by guessing the correct digit in the", "price of the given product.", "Then, drop your chips down the plinko board", "and win BIG!!!", "--July 6, 2003--", "", "Thanks to the TIGCC team and everyone at tict", "*****@*****.**"}; char buffer[45]; ClearGrayScreen2B(Hiddenl, Hiddend); FontSetSys (F_4x6); for(loop = 0; loop < 12; loop ++) { sprintf (buffer, "%s", str[loop]); GrayDBufSetHiddenAMSPlane (LIGHT_PLANE); DrawStr((LCD_WIDTH - DrawStrWidth(buffer, F_4x6))/2 + 1, 1 + 8 * loop, buffer, A_NORMAL); GrayDBufSetHiddenAMSPlane (DARK_PLANE); DrawStr((LCD_WIDTH - DrawStrWidth(buffer, F_4x6))/2, 8 * loop, buffer, A_NORMAL); //DrawGrayStrExt2B(0, 8 * loop, (char*)str[loop], A_NORMAL|A_SHADOWED|A_CENTERED, F_4x6, //Hiddenl, Hiddend); } GrayDBufToggleSync(); // switches two sets of planes wait_for_keypress(); }
/* * Stub to avoid needing to drag in Linux device drivers just for FS. * Used by FS code to support booting from floppy. * * Split off from wait_for_keypress since that glue routine is always needed * while this one is only needed if the linux device drivers are NOT used. */ void floppy_eject(void) { extern void wait_for_keypress(void); printk("Remove floppy from drive and then press return\n"); wait_for_keypress(); printk("Thanks!\n"); }
static int kbd_read(struct inode *inode, struct file *file, char *buffer, int count) { int cnt = count; if (is_empty()) { wait_for_keypress(); } while(cnt && !is_empty()) { *buffer++ = buf[out]; out = (out+1) % BUFLEN; cnt--; } return count - cnt; }
/* * print the show_hotkeys message */ void show_hotkeys(void) { printf("A2Conway - by [email protected]\n\n"); printf("built at %s %s\n", __DATE__, __TIME__); printf("\nHotkeys:\n"); printf("\tr:randomize\n"); printf("\tg:spawn gosper glider gun\n"); printf("\ts:spawn simkins glider gun\n"); printf("\tp:pause\n"); printf("\t1:switch to wraparound naive engine\n"); printf("\t2:switch to nowrap naive engine\n"); printf("\t3:switch to wraparound optimized engine\n"); printf("\t\t\t(3 is the default mode)\n"); printf("\t4:switch to nowrap optimized engine\n"); printf("\t?:show this text\n"); printf("\tq:quit\n\n"); printf("press enter to continue\n"); wait_for_keypress(CH_ENTER); }
int selection_box(void **list, char *needs_mark, int nlines, selbox_type_t type, int what_help, char *heading) { NEWWIN *mywin; int wlines = min(nlines, (max_y - 1) - 4); int total_win_size = wlines + 4; int win_width = max(32, max_x / 3); int wcols = win_width - 4; int pos = 0, ppos = -1, offs = 0, poffs = -1; int loop = 0, sel = -1; char first = 1; char *dummy = (char *)mymalloc(wcols + 1); int path_max = find_path_max(); char *selstr = (char *)mymalloc(path_max + 1), selfound = 0; selstr[0] = 0x00; mywin = create_popup(total_win_size, win_width); for(;;) { int c; /* draw list */ if (pos != ppos) { int entries_left = (nlines - pos); werase(mywin -> win); if (heading) win_header(mywin, heading); else if (type == SEL_WIN) win_header(mywin, "Select window"); else if (type == SEL_SUBWIN) win_header(mywin, "Select subwindow"); else if (type == SEL_FILES) win_header(mywin, "Select file"); else if (type == SEL_CSCHEME) win_header(mywin, "Select color scheme"); else if (type == SEL_HISTORY) win_header(mywin, "Select string from history"); for(loop=0; loop<min(entries_left, wlines); loop++) { char invert = generate_string(dummy, list, type, wcols, loop + pos); if (loop == offs) ui_inverse_on(mywin); if (invert) color_on(mywin, find_colorpair(COLOR_YELLOW, -1, 0)); if (needs_mark && needs_mark[loop + pos]) mvwprintw(mywin -> win, loop + 2, 1, "*"); mvwprintw(mywin -> win, loop + 2, 2, "%s", dummy); if (invert) color_off(mywin, find_colorpair(COLOR_YELLOW, -1, 0)); if (loop == offs) ui_inverse_off(mywin); } draw_border(mywin); ppos = pos; poffs = offs; } else if (poffs != offs) { int yellow_cp = find_colorpair(COLOR_YELLOW, -1, 0); char invert = generate_string(dummy, list, type, wcols, poffs + pos); if (invert) color_on(mywin, yellow_cp); mvwprintw(mywin -> win, poffs + 2, 2, "%s", dummy); if (invert) color_off(mywin, yellow_cp); invert = generate_string(dummy, list, type, wcols, offs + pos); ui_inverse_on(mywin); if (invert) color_on(mywin, yellow_cp); if (needs_mark && needs_mark[offs + pos]) mvwprintw(mywin -> win, loop + 2, 1, "*"); mvwprintw(mywin -> win, offs + 2, 2, "%s", dummy); if (invert) color_off(mywin, yellow_cp); ui_inverse_off(mywin); poffs = offs; } if (first) { first = 0; color_on(mywin, find_colorpair(COLOR_GREEN, -1, 0)); mvwprintw(mywin -> win, total_win_size - 2, 2, "Press ^G to abort"); color_off(mywin, find_colorpair(COLOR_GREEN, -1, 0)); } else { int loop, len = strlen(selstr); for(loop=0; loop<wcols; loop++) mvwprintw(mywin -> win, total_win_size - 2, 1 + loop, " "); if (!selfound) color_on(mywin, find_colorpair(COLOR_RED, -1, 0)); mvwprintw(mywin -> win, total_win_size - 2, 1, "%s", &selstr[max(0, len - wcols)]); if (!selfound) color_off(mywin, find_colorpair(COLOR_RED, -1, 0)); } mydoupdate(); c = wait_for_keypress(what_help, 0, mywin, 1); if (c == KEY_UP) { if ((offs + pos) > 0) { if (offs) offs--; else pos--; } else { wrong_key(); } } else if (c == KEY_DOWN) { if ((pos + offs) < (nlines-1)) { if (offs < (wlines-1)) offs++; else pos++; } else { wrong_key(); } } else if (c == KEY_NPAGE) { if ((pos + offs) < (nlines - 1)) { pos += min(wlines, (nlines - 1) - (pos + offs)); } else { wrong_key(); } } else if (c == KEY_PPAGE) { if ((pos + offs - wlines) >= 0) { if (pos > wlines) { pos -= wlines; } else { pos -= (wlines - offs); offs = 0; } } else if (offs > 0) { offs = 0; } else if (pos > 0) { pos = 0; } else { wrong_key(); } } else if (c == KEY_ENTER || c == 13 || c == 10) { sel = pos + offs; break; } else if (c == abort_key || c == -1) { break; } else if ((c > 31 && c != 127) || (c == KEY_BACKSPACE)) { int index, curlen; curlen = strlen(selstr); if (c == KEY_BACKSPACE) { if (curlen > 0) selstr[curlen - 1] = 0x00; else wrong_key(); } else if (curlen < path_max) { selstr[curlen] = c; selstr[curlen + 1] = 0x00; } else wrong_key(); curlen = strlen(selstr); if (curlen > 0) { index = find_sb_string(list, type, nlines, selstr); if (index != -1) { ppos = -1; sel = pos = index; selfound = 1; } else { selfound = 0; } } } else { wrong_key(); } } delete_popup(mywin); myfree(dummy); myfree(selstr); return sel; }
static void do_mount_root(void) { struct file_system_type * fs_type; struct super_block * sb; struct vfsmount *vfsmnt; struct inode * inode, d_inode; struct file filp; int retval; #ifdef CONFIG_ROOT_NFS if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) if (nfs_root_init(nfs_root_name, nfs_root_addrs) < 0) { printk(KERN_ERR "Root-NFS: Unable to contact NFS " "server for root fs, using /dev/fd0 instead\n"); ROOT_DEV = MKDEV(FLOPPY_MAJOR, 0); } if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) { ROOT_DEV = 0; if ((fs_type = get_fs_type("nfs"))) { sb = &super_blocks[0]; while (sb->s_dev) sb++; sb->s_dev = get_unnamed_dev(); sb->s_flags = root_mountflags & ~MS_RDONLY; if (nfs_root_mount(sb) >= 0) { inode = sb->s_mounted; inode->i_count += 3 ; sb->s_covered = inode; sb->s_rd_only = 0; sb->s_dirt = 0; sb->s_type = fs_type; current->fs->pwd = inode; current->fs->root = inode; ROOT_DEV = sb->s_dev; printk (KERN_NOTICE "VFS: Mounted root (nfs filesystem).\n"); vfsmnt = add_vfsmnt(ROOT_DEV, "rootfs", "/"); if (!vfsmnt) panic("VFS: add_vfsmnt failed for NFS root.\n"); vfsmnt->mnt_sb = sb; vfsmnt->mnt_flags = sb->s_flags; return; } sb->s_dev = 0; } if (!ROOT_DEV) { printk(KERN_ERR "VFS: Unable to mount root fs via NFS, trying floppy.\n"); ROOT_DEV = MKDEV(FLOPPY_MAJOR, 0); } } #endif #ifdef CONFIG_BLK_DEV_FD if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) { floppy_eject(); printk(KERN_NOTICE "VFS: Insert root floppy and press ENTER\n"); wait_for_keypress(); } #endif memset(&filp, 0, sizeof(filp)); memset(&d_inode, 0, sizeof(d_inode)); d_inode.i_rdev = ROOT_DEV; filp.f_inode = &d_inode; if ( root_mountflags & MS_RDONLY) filp.f_mode = 1; /* read only */ else filp.f_mode = 3; /* read write */ retval = blkdev_open(&d_inode, &filp); if (retval == -EROFS) { root_mountflags |= MS_RDONLY; filp.f_mode = 1; retval = blkdev_open(&d_inode, &filp); } if (retval) /* * Allow the user to distinguish between failed open * and bad superblock on root device. */ printk("VFS: Cannot open root device %s\n", kdevname(ROOT_DEV)); else for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { if (!fs_type->requires_dev) continue; sb = read_super(ROOT_DEV,fs_type->name,root_mountflags,NULL,1); if (sb) { inode = sb->s_mounted; inode->i_count += 3 ; /* NOTE! it is logically used 4 times, not 1 */ sb->s_covered = inode; sb->s_flags = root_mountflags; current->fs->pwd = inode; current->fs->root = inode; printk ("VFS: Mounted root (%s filesystem)%s.\n", fs_type->name, (sb->s_flags & MS_RDONLY) ? " readonly" : ""); vfsmnt = add_vfsmnt(ROOT_DEV, "rootfs", "/"); if (!vfsmnt) panic("VFS: add_vfsmnt failed for root fs"); vfsmnt->mnt_sb = sb; vfsmnt->mnt_flags = root_mountflags; return; } } panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); }
void statistics_menu(void) { NEWWIN *mywin = create_popup(23, 65); int offset = 0, cur_line = 0; for(;;) { int c; int vmsize = get_vmsize(getpid()); time_t now = time(NULL); struct tm *tmnow = localtime(&now); proginfo **plist = NULL; char *issub = NULL; int *winnr = NULL; int loop, nwin = 0; /* create list of (sub-)windows */ for(loop=0; loop<nfd; loop++) { proginfo *cur = &pi[loop]; while(cur) { plist = (proginfo **)myrealloc(plist, (nwin + 1) * sizeof(proginfo *)); issub = (char *) myrealloc(issub, (nwin + 1) * sizeof(char) ); winnr = (int *) myrealloc(winnr, (nwin + 1) * sizeof(int) ); plist[nwin] = cur; issub[nwin] = (cur != &pi[loop]); winnr[nwin] = loop; nwin++; cur = cur -> next; } } werase(mywin -> win); win_header(mywin, "Statistics"); for(loop=0; loop<18; loop++) { int cur_index = loop + offset; int is_sub_indent; if (cur_index >= nwin) break; is_sub_indent = issub[cur_index]; if (loop == cur_line) ui_inverse_on(mywin); if (is_sub_indent) mvwprintw(mywin -> win, 2 + loop, 7, "%s", shorten_filename(plist[cur_index] -> filename, 54)); else mvwprintw(mywin -> win, 2 + loop, 2, "[%02d] %s", winnr[cur_index], shorten_filename(plist[cur_index] -> filename, 56)); if (loop == cur_line) ui_inverse_off(mywin); } mvwprintw(mywin -> win, 20, 2, "Run-time: %.2f hours %02d:%02d", (get_ts() - mt_started) / 3600.0, tmnow -> tm_hour, tmnow -> tm_min); if (vmsize != -1) { char *vmsize_str = amount_to_str(vmsize); mvwprintw(mywin -> win, 20, 35, "Memory usage: %s", vmsize_str); myfree(vmsize_str); } escape_print(mywin, 21, 2, "Press ^r^ to reset counters, ^q^ to exit"); draw_border(mywin); mydoupdate(); c = toupper(wait_for_keypress(HELP_STATISTICS, popup_refresh_interval, mywin, 1)); if (c == 'R') { for(loop=0; loop<nfd; loop++) { proginfo *cur = &pi[loop]; while(cur) { reset_counters(&cur -> statistics); cur = cur -> next; } } } else if (c == KEY_UP) { if (cur_line) cur_line--; else if (offset) offset--; else wrong_key(); } else if (c == KEY_DOWN) { if ((cur_line + offset) < (nwin - 1)) { if (cur_line < (18 - 1)) cur_line++; else offset++; } else wrong_key(); } else if (c == 13 || c == ' ') { statistics_popup(winnr[cur_line + offset], plist[cur_line + offset]); } else if (c == 'Q' || c == abort_key) { myfree(plist); myfree(issub); myfree(winnr); break; } else if (c != -1) { wrong_key(); } myfree(plist); myfree(issub); myfree(winnr); } delete_popup(mywin); }
void info(void) { NEWWIN *mywin = create_popup(19, 60); int line = 7; struct utsname uinfo; int proc_u_line; char *term = getenv("TERM"); mvwprintw(mywin -> win, 1, 2, "-=* MultiTail " VERSION " *=-"); mvwprintw(mywin -> win, 3, 2, "Written by [email protected]"); mvwprintw(mywin -> win, 4, 2, "Website: http://www.vanheusden.com/multitail/"); if (!use_colors) mvwprintw(mywin -> win, line++, 2, "Your terminal doesn't support colors"); if (uname(&uinfo) == -1) error_popup("Retrieving system information", -1, "uname() failed\n"); else { line++; mvwprintw(mywin -> win, line++, 2, "Running on:"); #ifdef _GNU_SOURCE mvwprintw(mywin -> win, line++, 2, "%s/%s %s %s", uinfo.nodename, uinfo.sysname, uinfo.machine, uinfo.domainname); #else mvwprintw(mywin -> win, line++, 2, "%s/%s %s", uinfo.nodename, uinfo.sysname, uinfo.machine); #endif mvwprintw(mywin -> win, line++, 2, "%s %s", uinfo.release, uinfo.version); line++; } if (has_colors()) mvwprintw(mywin -> win, line++, 2, "colors: %d, colorpairs: %d (%d), change colors: %s", COLORS, COLOR_PAIRS, cp.n_def, can_change_color()?"yes":"no"); else mvwprintw(mywin -> win, line++, 2, "Terminal does not support colors."); if (term) mvwprintw(mywin -> win, line++, 2, "Terminal size: %dx%d, terminal: %s", max_x, max_y, term); else mvwprintw(mywin -> win, line++, 2, "Terminal size: %dx%d", max_x, max_y); if (beep_interval > 0) mvwprintw(mywin -> win, line++, 2, "Did %d beeps.", did_n_beeps); proc_u_line = line++; escape_print(mywin, 16, 2, "_Press any key to exit this screen_"); #if defined(__FreeBSD__) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(sun) || defined(__sun) || defined(__GNU__) || defined(__CYGWIN__) for(;;) { dtime_t run_time = get_ts() - mt_started; #ifndef __CYGWIN__ double v1, v2, v3; get_load_values(&v1, &v2, &v3); mvwprintw(mywin -> win, 6, 2, "Current load of system: %f %f %f", v1, v2, v3); #endif if (run_time) { struct rusage usage; if (getrusage(RUSAGE_SELF, &usage) == -1) error_exit(TRUE, FALSE, "getrusage() failed\n"); mvwprintw(mywin -> win, proc_u_line, 2, "Runtime: %02d:%02d:%02d, avg.proc.usage: %.2f%% ints/s: %.1f", (int)(run_time / 3600), ((int)run_time / 60) % 60, (int)run_time % 60, ((double)usage.ru_utime.tv_sec + (double)usage.ru_utime.tv_usec / 1000000.0 + (double)usage.ru_stime.tv_sec + (double)usage.ru_stime.tv_usec / 1000000.0) * 100.0 / run_time, (double)total_wakeups / run_time); } mydoupdate(); if (wait_for_keypress(-1, popup_refresh_interval, mywin, 0) != -1) break; } #else mydoupdate(); wait_for_keypress(-1, 0, mywin, 0); #endif delete_popup(mywin); }
void statistics_popup(int f_index, proginfo *cur) { NEWWIN *popup = create_popup(16, 68); const char *title = "Statistics for "; char *abbr_fname = shorten_filename(cur -> filename, 54 - strlen(title)); char buffer[54 + 1]; snprintf(buffer, sizeof(buffer), "%s%s", title, abbr_fname); for(;;) { dtime_t time_running = get_ts() - cur -> statistics.start_ts; time_t start_ts = (time_t)cur -> statistics.start_ts; char *start_ts_str = mystrdup(ctime(&start_ts)); time_t lastevent = (time_t)cur -> statistics.lastevent; char *last_ts_str = mystrdup(ctime(&lastevent)); char *dummy; char *vmsize_str = NULL; char *fsize_str = NULL; char *total_data_processed_str = amount_to_str(cur -> statistics.bytes_processed); char *buffer_kb; off64_t fsize = -1; int c; int total_re = 0; int loop; if (cur -> wt == WT_COMMAND) { vmsize_str = amount_to_str(get_vmsize(cur -> pid)); } else if (cur -> wt == WT_FILE) { (void)file_info(cur -> filename, &fsize, 0, NULL, NULL); fsize_str = amount_to_str(fsize); } dummy = strchr(start_ts_str, '\n'); if (dummy) *dummy = 0x00; dummy = strchr(last_ts_str, '\n'); if (dummy) *dummy = 0x00; werase(popup -> win); win_header(popup, buffer); ui_inverse_on(popup); mvwprintw(popup -> win, 3, 2, "# lines :"); mvwprintw(popup -> win, 3, 27, "#l/s :"); mvwprintw(popup -> win, 3, 44, "Avg len:"); mvwprintw(popup -> win, 4, 2, "Data interval :"); if (cur -> wt == WT_COMMAND) mvwprintw(popup -> win, 5, 2, "VM size :"); else if (cur -> wt == WT_FILE) mvwprintw(popup -> win, 5, 2, "File size :"); mvwprintw(popup -> win, 9, 2, "Data processed:"); mvwprintw(popup -> win, 9, 27, "Bps :"); mvwprintw(popup -> win, 6, 2, "Started at :"); mvwprintw(popup -> win, 7, 2, "Last event :"); mvwprintw(popup -> win, 8, 2, "Next expected@:"); mvwprintw(popup -> win, 10, 2, "# matched r.e.:"); mvwprintw(popup -> win, 11, 2, "Buffered lines:"); mvwprintw(popup -> win, 11, 27, "Bytes:"); mvwprintw(popup -> win, 11, 44, "Limit :"); mvwprintw(popup -> win, 12, 2, "# of beeps: "); if (cur -> wt == WT_COMMAND) { mvwprintw(popup -> win, 13, 2, "Number of runs:"); mvwprintw(popup -> win, 13, 27, "Last rc:"); } ui_inverse_off(popup); mvwprintw(popup -> win, 3, 18, "%d", cur -> statistics.n_events); mvwprintw(popup -> win, 6, 18, "%s", start_ts_str); if (cur -> statistics.lastevent != (dtime_t)0.0) mvwprintw(popup -> win, 7, 18, "%s", last_ts_str); else mvwprintw(popup -> win, 7, 18, "---"); if (cur -> statistics.n_events == 0) { mvwprintw(popup -> win, 4, 18, "Not yet available"); } else { double avg = cur -> statistics.med / (double)cur -> statistics.n_events; double dev = sqrt((cur -> statistics.dev / (double)cur -> statistics.n_events) - pow(avg, 2.0)); /* serial correlation coefficient */ double scct1 = cur -> statistics.scct1 + cur -> statistics.scclast * cur -> statistics.sccu0; double med = cur -> statistics.med * cur -> statistics.med; double scc = (double)cur -> statistics.n_events * cur -> statistics.dev - med; if (scc != 0.0) { scc = ((double)cur -> statistics.n_events * scct1 - med) / scc; mvwprintw(popup -> win, 4, 18, "average: %.2f, std.dev.: %.2f, SCC: %1.6f", avg, dev, scc); } else mvwprintw(popup -> win, 4, 18, "average: %.2f, std.dev.: %.2f, not correlated", avg, dev); if (avg) { double dummy_d = (double)(time(NULL) - cur -> statistics.lastevent) / avg; time_t next_event = cur -> statistics.lastevent + (ceil(dummy_d) * avg); char *ne_str = mystrdup(ctime(&next_event)); char *dummy_str = strchr(ne_str, '\n'); if (dummy_str) *dummy_str = 0x00; mvwprintw(popup -> win, 8, 18, "%s", ne_str); myfree(ne_str); } mvwprintw(popup -> win, 3, 53, "%.1f", (double)cur -> statistics.bytes_processed / (double)cur -> statistics.n_events); } if (cur -> wt == WT_COMMAND) mvwprintw(popup -> win, 5, 18, "%s", vmsize_str); else if (cur -> wt == WT_STDIN || cur -> wt == WT_SOCKET) mvwprintw(popup -> win, 5, 18, "n.a."); else if (cur -> wt == WT_FILE) mvwprintw(popup -> win, 5, 18, "%s", fsize_str); myfree(vmsize_str); myfree(fsize_str); mvwprintw(popup -> win, 9, 18, "%s", total_data_processed_str); myfree(total_data_processed_str); if (time_running > 0) { char *bps_str = amount_to_str((double)cur -> statistics.bytes_processed / (double)time_running); mvwprintw(popup -> win, 9, 34, "%s", bps_str); myfree(bps_str); mvwprintw(popup -> win, 3, 34, "%.4f", (double)cur -> statistics.n_events / (double)time_running); } buffer_kb = amount_to_str(lb[f_index].curbytes); mvwprintw(popup -> win, 11, 18, "%d", lb[f_index].curpos); mvwprintw(popup -> win, 11, 34, "%s", buffer_kb); myfree(buffer_kb); mvwprintw(popup -> win, 12, 18, "%d", cur -> beep.did_n_beeps); escape_print(popup, 14, 2, "Press ^r^ to reset counters, ^q^ to exit"); myfree(start_ts_str); myfree(last_ts_str); for(loop=0; loop<cur -> n_re; loop++) total_re += (cur -> pre)[loop].match_count; if (cur -> statistics.n_events) mvwprintw(popup -> win, 10, 18, "%d (%.2f%%)", total_re, (total_re * 100.0) / (double)cur -> statistics.n_events); else mvwprintw(popup -> win, 10, 18, "%d", total_re); if (cur -> wt == WT_COMMAND) { mvwprintw(popup -> win, 13, 18, "%d", cur -> n_runs); mvwprintw(popup -> win, 13, 36, "%d", cur -> last_exit_rc); } if (lb[f_index].maxnlines > 0) { mvwprintw(popup -> win, 11, 53, "%d lines", lb[f_index].maxnlines); } else if (lb[f_index].maxbytes > 0) { char *str = amount_to_str(lb[f_index].maxbytes); mvwprintw(popup -> win, 11, 53, "%s", str); myfree(str); } draw_border(popup); mydoupdate(); c = toupper(wait_for_keypress(HELP_STATISTICS_POPUP, popup_refresh_interval, popup, 0)); if (c == 'Q' || c == abort_key) { break; } else if (c == 'R') { reset_counters(&cur -> statistics); } else if (c != -1) { wrong_key(); } } delete_popup(popup); }
int scrollback_do(int window_nr, buffer *pbuf, int *winnrs, char *header) { int rc = 0; char *find = NULL; char fullscreen = scrollback_fullscreen_default; NEWWIN *mywin1 = NULL, *mywin2 = NULL; int nlines, ncols; compute_text_dimensions(&nlines, &ncols, fullscreen); int offset = max(0, pbuf -> curpos - nlines); /* FIXME: aantal regels laten afhangen van lengte */ char redraw = 2; int line_offset = 0; char show_winnr = default_sb_showwinnr; mybool_t case_insensitive = re_case_insensitive; buffer cur_lb; int loop = 0; memset(&cur_lb, 0x00, sizeof(cur_lb)); for(loop=0; loop<pbuf -> curpos; loop++) { if ((pbuf -> be)[loop].Bline == NULL) continue; cur_lb.be = myrealloc(cur_lb.be, (cur_lb.curpos + 1) * sizeof(buffered_entry)); cur_lb.be[cur_lb.curpos].pi = (pbuf -> be)[loop].pi; if ((pbuf -> be)[loop].pi != NULL && (!IS_MARKERLINE((pbuf -> be)[loop].pi)) && (pbuf -> be)[loop].pi -> cdef.term_emul != TERM_IGNORE) { color_offset_in_line *cmatches; int n_cmatches; cur_lb.be[cur_lb.curpos].Bline = emulate_terminal((pbuf -> be)[loop].Bline, &cmatches, &n_cmatches); myfree(cmatches); } else cur_lb.be[cur_lb.curpos].Bline = strdup((pbuf -> be)[loop].Bline); cur_lb.be[cur_lb.curpos].ts = (pbuf -> be)[loop].ts; cur_lb.curpos++; } LOG("---\n"); if (global_highlight_str) { find = mystrdup(global_highlight_str); } create_scrollback_windows(&mywin1, &mywin2, nlines, ncols, fullscreen); for(;;) { int c, uc; if (redraw == 2) { int index = 0; int lines_used = 0; if (mywin1) { ui_inverse_on(mywin1); mvwprintw(mywin1 -> win, nlines + 1, 1, "%s - %d buffered lines", shorten_filename(header, max(24, ncols - 24)), cur_lb.curpos); ui_inverse_off(mywin1); if (!no_linewrap) ui_inverse_on(mywin1); mvwprintw(mywin1 -> win, nlines + 1, ncols - 8, "LINEWRAP"); if (!no_linewrap) ui_inverse_off(mywin1); } werase(mywin2 -> win); if (!no_linewrap && line_offset > 0) { int temp_line_offset = line_offset; int n_chars_to_display_left = strlen((cur_lb.be)[offset].Bline) - temp_line_offset; while(lines_used < nlines && n_chars_to_display_left > 0) { scrollback_displayline(winnrs?winnrs[offset]:window_nr, mywin2, &cur_lb, offset, lines_used, temp_line_offset, 1, show_winnr); temp_line_offset += ncols; n_chars_to_display_left -= ncols; lines_used++; } index++; } for(;(offset + index) < cur_lb.curpos && lines_used < nlines;) { int lines_needed = get_lines_needed((cur_lb.be)[offset + index].Bline, ncols); if (no_linewrap || lines_needed == 1) { scrollback_displayline(winnrs?winnrs[offset + index]:window_nr, mywin2, &cur_lb, offset + index, lines_used, no_linewrap?line_offset:0, no_linewrap, show_winnr); lines_used++; } else { int cur_line_offset = 0; while(lines_used < nlines && lines_needed > 0) { scrollback_displayline(winnrs?winnrs[offset + index]:window_nr, mywin2, &cur_lb, offset + index, lines_used, cur_line_offset, 1, show_winnr); cur_line_offset += ncols; lines_used++; lines_needed--; } } index++; } redraw = 1; } if (redraw == 1) { mydoupdate(); redraw = 0; } c = wait_for_keypress(HELP_SCROLLBACK_HELP, 0, NULL, 1); uc = toupper(c); if (c == 'q' || c == abort_key || c == KEY_CLOSE || c == KEY_EXIT) { break; } else if (c == 'Q' || c == -1) /* Q: close whole stack of scrollbackwindows, -1: something got closed */ { rc = -1; break; } else if (c == 20 && winnrs != NULL) /* ^t */ { show_winnr = 1 - show_winnr; redraw = 2; } else if (c == 'x') { send_to_clipboard(pbuf); } else if (c == 'Y') { no_linewrap = !no_linewrap; redraw = 2; line_offset = 0; } else if (c == KEY_F(9) || c == 23) /* ^w */ { fullscreen = ! fullscreen; compute_text_dimensions(&nlines, &ncols, fullscreen); create_scrollback_windows(&mywin1, &mywin2, nlines, ncols, fullscreen); redraw = 2; } else if (c == 't') { statistics_menu(); } else if ((c == KEY_LEFT || c == KEY_BACKSPACE) && no_linewrap) { if (line_offset > 0) line_offset--; redraw = 2; } else if (c == KEY_SLEFT && no_linewrap) { if (line_offset >= (ncols / 2)) line_offset -= (ncols / 2); else line_offset = 0; redraw = 2; } else if (c == KEY_SRIGHT && no_linewrap) { line_offset += (ncols / 2); redraw = 2; } else if (c == KEY_BEG && no_linewrap) { if (line_offset) { line_offset = 0; redraw = 2; } } else if (c == KEY_BTAB) { if (line_offset >= 4) line_offset -= 4; else line_offset = 0; redraw = 2; } else if (c == KEY_RIGHT && no_linewrap) { line_offset++; redraw = 2; } else if ((c == KEY_UP || c == 'y' || c == 25 || /* ^y */ c == 'k' || /* c == 11 || */ /* ^k */ c == 16) /* ^p */ && (offset > 0 || (!no_linewrap && line_offset > 0))) { if (no_linewrap) { offset--; } else if (line_offset > 0) { line_offset = max(0, line_offset - ncols); } else { offset--; line_offset = (get_lines_needed((cur_lb.be)[offset].Bline, ncols) - 1) * ncols; } wmove(mywin2 -> win, 0, 0); winsdelln(mywin2 -> win, 1); scrollback_displayline(winnrs?winnrs[offset]:window_nr, mywin2, &cur_lb, offset, 0, line_offset, no_linewrap, show_winnr); redraw = 1; } else if ((c == KEY_DOWN || c == 'e' || c == 5 || /* ^e */ c == 'j' || c == 14 || /* ^n */ c == 13 || c == KEY_ENTER) && offset < (cur_lb.curpos - 1)) { if (no_linewrap) { offset++; } else if (strlen((cur_lb.be)[offset].Bline) > (line_offset + ncols)) { line_offset += ncols; } else if (offset < (cur_lb.curpos - 1)) { if (strlen((cur_lb.be)[offset].Bline) > (line_offset + ncols)) line_offset += ncols; else { line_offset = 0; offset++; } } redraw = 2; } else if ((c == KEY_NPAGE || c == 'f' || c == 6 || /* ^f */ c == ('V' - 65 + 1) || /* ^v */ c == ' ' || c == 'z' || c == 'u' || c == ('U' - 65 + 1)) /* ^u */ && offset < (cur_lb.curpos - 1)) { if (no_linewrap) { offset += nlines; if (offset >= cur_lb.curpos) offset = cur_lb.curpos - 1; } else { int n_lines_to_move = nlines; while(n_lines_to_move > 0 && offset < (cur_lb.curpos)) { if (line_offset > 0) { if (line_offset + ncols >= strlen((cur_lb.be)[offset].Bline)) { line_offset = 0; offset++; n_lines_to_move--; } else { line_offset += ncols; n_lines_to_move--; } } else { n_lines_to_move -= get_lines_needed((cur_lb.be)[offset].Bline, ncols); offset++; } } if (n_lines_to_move < 0) line_offset = (-n_lines_to_move) * ncols; } redraw = 2; } else if ((c == KEY_PPAGE || c == 'b' || c == 2 || /* ^b */ c == 'w' || c == 'd' || c == 4) /* ^d */ && offset > 0) { if (no_linewrap) { offset -= nlines; if (offset < 0) offset = 0; } else { int n_lines_to_move = nlines; if (line_offset) n_lines_to_move -= line_offset / ncols; while(n_lines_to_move > 0 && offset > 0) { offset--; n_lines_to_move -= get_lines_needed((cur_lb.be)[offset].Bline, ncols); if (n_lines_to_move < 0) { line_offset = (get_lines_needed((cur_lb.be)[offset].Bline, ncols) + n_lines_to_move) * ncols; } } } redraw = 2; } else if ((c == KEY_HOME || c == 'g' || c == '<' || c == KEY_SBEG) && offset > 0) { line_offset = offset = 0; redraw = 2; } else if ((c == KEY_END || c == 'G' || c == '>' || c == KEY_SEND) && offset < (cur_lb. curpos - 1)) { offset = cur_lb. curpos - 1; redraw = 2; } else if (uc == 'R' || c == ('R' - 65 + 1) || c == ('L' - 65 + 1) || c == KEY_REFRESH) { redraw = 2; } else if (c == ('K' - 65 + 1) || c == KEY_MARK) { scrollback_find_popup(&find, &case_insensitive); if (find) { int rc; regfree(&global_highlight_re); myfree(global_highlight_str); global_highlight_str = NULL; if ((rc = regcomp(&global_highlight_re, find, (case_insensitive == MY_TRUE?REG_ICASE:0) | REG_EXTENDED))) { regexp_error_popup(rc, &global_highlight_re); myfree(find); } else { global_highlight_str = find; } redraw = 2; /* force redraw */ } } else if (c == 'f' || c == '/' || c == '?' || c == KEY_FIND || c == KEY_SFIND) { char direction = (c == '?' || c == KEY_SFIND) ? -1 : 1; scrollback_find_popup(&find, &case_insensitive); if (find) { if (scrollback_search_new_window) { if (scrollback_search_to_new_window(&cur_lb, header, find, case_insensitive) == -1) { /* cascaded close */ rc = -1; break; } } else { int new_f_index; redraw = 2; /* force redraw */ regfree(&global_highlight_re); myfree(global_highlight_str); global_highlight_str = NULL; new_f_index = find_string(&cur_lb, find, 0, direction, case_insensitive); if (new_f_index == -1) { wrong_key(); } else { offset = new_f_index; line_offset = 0; } } } } else if (uc == 'N' || c == KEY_NEXT || c == KEY_PREVIOUS || c == KEY_SNEXT) { if (find != NULL) { char direction = (c == 'n' || c == KEY_NEXT) ? 1 : -1; int start_offset = offset + direction; int new_f_index = find_string(&cur_lb, find, start_offset, direction, case_insensitive); if (new_f_index == -1) { wrong_key(); } else { redraw = 2; /* force redraw */ offset = new_f_index; line_offset = 0; } } else { wrong_key(); } } else if (c == 's' || c == KEY_SAVE) { scrollback_savefile(&cur_lb); redraw = 2; /* force redraw */ } else if (c == 'h') { show_help(HELP_SCROLLBACK_HELP); } else if (c == 'c') { toggle_colors(); redraw = 2; /* force redraw */ } else if (c == 'i') { info(); } else if (c == 'T') { statistics_menu(); } else if (c == 20) { toggle_subwindow_nr(); redraw = 2; /* force redraw */ } else { wrong_key(); } } delete_popup(mywin2); if (mywin1) delete_popup(mywin1); myfree(find); delete_be_in_buffer(&cur_lb); return rc; }
int menu_get_input (void) { int cx, cy; int option = 0; int prev_option = 1; int x, y; int KeyPressed; struct termios stored_terminal; struct get_arrow_keys num_keypad = { '8', '2', '4', '6' }; struct get_arrow_keys alpha_keypad = { 'j', 'm', ',', '.' }; get_term_settings (stored_terminal); set_term_raw (); /* Paint the screen with the bitmap */ put_screen (menu_picture); /* Put the buttons on the screen */ for (cx = 0; cx <= MAX_MENU_COLS-1; cx++) for (cy = 0; cy <= MAX_MENU_ROWS-1; cy++) { x = MENU_COL+MENU_COL_GAP*cx; y = MENU_ROW+MENU_ROW_GAP*cy; ansi_PutString (x+1, y+1, menu_options [cy*MAX_MENU_COLS+cx]); draw_box_XY (x, y, x+MENU_ITEM_WIDTH, y+MENU_ITEM_HEIGHT, CHAR_hyphen, CHAR_pipe, CHAR_plus); } /* Keep looping until 'select' or 'Q' has been pressed and then return the option selected to the parent function */ while (1) { if (prev_option != option) { cx = prev_option % 2; cy = prev_option / 2; ansi_DefaultAttr (); x = MENU_COL+MENU_COL_GAP*cx; y = MENU_ROW+MENU_ROW_GAP*cy; ansi_PutString (x+1, y+1, menu_options [cy*MAX_MENU_COLS+cx]); draw_box_XY (x, y, x+MENU_ITEM_WIDTH, y+MENU_ITEM_HEIGHT, CHAR_hyphen, CHAR_pipe, CHAR_plus); cx = option % 2; cy = option / 2; ansi_SetAttr (ATTR_reverse); x = MENU_COL+MENU_COL_GAP*cx; y = MENU_ROW+MENU_ROW_GAP*cy; ansi_PutString (x+1, y+1, menu_options [cy*MAX_MENU_COLS+cx]); draw_box_XY (x, y, x+MENU_ITEM_WIDTH, y+MENU_ITEM_HEIGHT, CHAR_hyphen, CHAR_pipe, CHAR_plus); ansi_SetAttr (ATTR_normal); } prev_option = option; wait_for_keypress (); switch (get_arrow (TRUE, &alpha_keypad, &num_keypad)) { case DIR_up: if ((option != 0) && (option != 1)) option-=2; break; case DIR_down: if ((option != 4) && (option != 5)) option+=2; break; case DIR_left: if (option % 2 == 1) option--; break; case DIR_right: if (option % 2 == 0) option++; break; case DIR_unknown: KeyPressed = terminal_getchar (); if ((KeyPressed == MENU_SELECT_1) || (KeyPressed == MENU_SELECT_2) || (KeyPressed == MENU_SELECT_3)) { set_term_settings (stored_terminal); return (option); } if (toupper (KeyPressed) == 'Q') { set_term_settings (stored_terminal); return (5); } break; } } }
static inline char main_game(unsigned char plinkos) { unsigned char STATUS = RUNNING, x, y = 0, oldx = 59; unsigned int Amount, Total = 0; char buffer[15]; FontSetSys(F_4x6); while( plinkos-- ) { ClearGrayScreen2B(virtual_dark, virtual_light); GraySpriteX8_OR(0, 0, 100, plinkol, plinkod, 20, virtual_light, virtual_dark); PRINT_TOTAL(Total); SHOW_PLINKOS(5, plinkos - 1, virtual_light, virtual_dark); new_chip(oldx, plinkos); x = oldx; y = 2; DRAWALL(x, y); while (STATUS == RUNNING) { if (_keytest (RR_LEFT) && x > 3) MOVE_LEFT( &x ); if (_keytest (RR_RIGHT) && x < 115) MOVE_RIGHT( &x ); if (_keytest (RR_ESC)) STATUS = EXIT; if (_keytest (RR_2ND) || _keytest (RR_DOWN)) STATUS = DROP; } if (STATUS == EXIT) return -1; oldx = x; Amount = DROPPING( &x ); // After this, x will be from 0 to 8 if (Amount == EXIT) return -1; Total += Amount; //GRAPHIC(30, 20, /* HEIGHT */14, /* WIDTH */32, (char*) Zerol, (char*) Zerod, SMALL); /*for(y = 1; y < 6; y++) { period = 15000*(1+random( y )); memset (Actived, 255, LCD_SIZE); // clear virtual gray planes memset (Activel, 255, LCD_SIZE); for(wait = 1; wait < period; wait++); period = 15000*(1+random( y )); DRAWALL(14 * x + 3, 93); for(wait = 1; wait < period; wait++); }*/ SHUFFLE( x ); DRAWALL(14 * x + 3, 93); DRAWALL(14 * x + 3, 93); GRAPHIC(45, 36, x, FALSE);//, gfx_light[x], gfx_dark[x], x); GrayDBufToggleSync(); // switches two sets of planes Waitkey() STATUS = RUNNING; } sprintf(buffer, "Score %d", Total); x = (LCD_WIDTH - DrawStrWidth(buffer, F_6x8)) / 2 - 16; DrawGrayStrExt2B(x, 2, (char*)buffer, A_NORMAL|A_SHADOWED, F_6x8, Activel, Actived); wait_for_keypress(); if (CHECK_FOR_HIGH(Total) == QUIT) // Checks whether or not the user got a high score, writes a new // high score if they did get one, and calls a function to display the new high scores return QUIT; return STATUS; }
void main(){ int i, j, xinc, yinc, Margin; char ch; WORD curr_x=0, curr_y=0; pal = (char far *) farmalloc(256*3); pal2 = (char far *) farmalloc(256*3); userfnt1 = (char far *) farmalloc(256*16+4); /* INITIALIZE XLIB */ /* we set up Mode X 360x200x256 with a logical width of ~ 500 */ /* pixels; we actually get 496 due to the fact that the width */ /* must be divisible by 8 */ x_text_mode(); /* make sure VGA is in color mode, if possible */ x_set_mode(X_MODE_360x200,500); /* actually is set to 496 */ x_install_vsync_handler(2); x_set_splitscreen(ScrnPhysicalHeight-60); /* split screen 60 pixels high */ x_set_doublebuffer(220); x_text_init(); x_hide_splitscreen(); x_mouse_init(); MouseColor=2; atexit(exitfunc); /* DRAW BACKGROUND LINES */ for(j=0;j<ScrnPhysicalHeight;j++){ x_line(0,j,ScrnLogicalPixelWidth,j,16+(j%239),VisiblePageOffs); } ctrlbrk(terminate); x_get_pal_struc(pal, 240,16); load_user_fonts(); intro_1(); x_set_font(2); x_hide_mouse(); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Hi, folks. This is yet another FREEWARE Mode X"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " graphics library. It is by no means complete,"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " but I believe it contains a rich enough set of"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " functions to achieve its design goal - to be"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " a game development oriented library for"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Borland TC/BC/BC++ and TASM programmers."); x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " This library comes with TASM and C sources."); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " It was inspired by the DDJ Graphics column and"); x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " many INTERNET and USENET authors who, unlike the"); x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " majority of programmers (you know who you are!),"); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " willingly share their code and ideas with others."); x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " I can't afford, nor do I want, to copyright"); x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " this code - but if you use it, some credit would "); x_printf(textwindow_x+5,50+104,VisiblePageOffs,9," be appreciated. "); wait_for_keypress(); subsequent_page(); x_set_font(0); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"Supported 256 colour resolutions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"Supported 256 colour resolutions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " 320x200 Standard for games ~ 4 pages"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " 320x240 DDJ Mode X square pixels ~ 3.5 pages"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " 360x200 My favourite for games ~ 3 pages "); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " 360x240 ~ 2.8 pages"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " 320x400 ~ 2 pages "); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " 320x480 All subsequent modes support"); x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " 360x400 less than two pages."); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " 360x480"); x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " 376x282,360x360,376x308,376x564,256x200,256x240"); x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " Phew! and they'll run on all VGA cards and "); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " monitors (some of the weird ones are best suited"); x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " to monitors with both vert & horiz adjustments)"); x_printf(textwindow_x+5,50+98,VisiblePageOffs,2, " "); x_printf(textwindow_x+5,50+106,VisiblePageOffs,2," Overkill? Maybe!! "); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Text display functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Text display functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Several text printing functions are provided."); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " They support the VGA ROM 8x14 and 8x8 fonts as"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " well as user-defined fonts (like this 6x8 font)."); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " Furthermore, a function similar to printf is"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " included which provides formatted text output."); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " User defined fonts may be proportionally spaced"); x_printf(textwindow_x+5,50+58,VisiblePageOffs,9, " but have a maximum width of 8 pixels."); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Advanced screen functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Advanced screen functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " The library supports virtual screens larger"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " than the physical screen, panning of such"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " screens, and a split screen option."); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " These functions can be used together or"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " in isolation, and in the lower resolutions"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " double buffering can also be accomplished."); x_rect_fill(0, 0, ScrnPhysicalPixelWidth,60,SplitScrnOffs,5); x_line(0,0,ScrnPhysicalPixelWidth,0,2,SplitScrnOffs); x_set_font(1); x_printf(10,10,SplitScrnOffs,2, " This is a split screen, tops for scores."); x_set_font(0); for (i=ScrnPhysicalHeight;i>ScrnPhysicalHeight-60;i--){ x_adjust_splitscreen(i); } x_printf(10,25,SplitScrnOffs,2, " Even better for scrolling games etc."); x_cp_vid_rect(0,0,ScrnLogicalPixelWidth,ScrnLogicalHeight,0,0, VisiblePageOffs,HiddenPageOffs, ScrnLogicalPixelWidth,ScrnLogicalPixelWidth); x_show_mouse(); wait_for_keypress(); curr_x=curr_y=0; init_object(60,90,4, 12, -1, 1, MK_FP(FP_SEG(bm2),FP_OFF(bm2))); init_object(30,30,4, 12, 1, 1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(80,120,4, 12, 2, 1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(300,200,4, 12, 1, -2, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(360,30,4, 12, -1, -1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(360,10,4, 12, -2, 2, MK_FP(FP_SEG(bm),FP_OFF(bm))); x_hide_mouse(); while (!kbhit()&& !(MouseButtonStatus==LEFT_PRESSED)){ animate(); if (objects[0].X>=curr_x+ScrnPhysicalPixelWidth-32 && curr_x < MaxScrollX) curr_x++; else if (objects[0].X < curr_x+16 && curr_x > 0) curr_x--; if (objects[0].Y>=curr_y+ScrnPhysicalHeight-92 && curr_y < MaxScrollY) curr_y++; else if (objects[0].Y < curr_y+16 && curr_y > 0) curr_y--; x_page_flip(curr_x,curr_y); while(StartAddressFlag); } while(MouseButtonStatus==LEFT_PRESSED); while(kbhit()) getch(); clear_objects(); x_page_flip(curr_x,curr_y); while(StartAddressFlag); x_set_start_addr(0,0); for (j=0;j<4;j++){ x_hide_splitscreen(); delay(100); x_show_splitscreen(); delay(100); } for (i=ScrnPhysicalHeight-60;i<=ScrnPhysicalHeight;i++){ x_adjust_splitscreen(i); } x_hide_mouse(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Palette functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Palette functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " A number of palette manipulation functions"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " are provided. You have already seen some of"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " them in action. Another common operation is"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " palette fading. "); i=0; ch=255; while (x_cpcontrast_pal_struc(pal, pal2,ch-=2)){ x_put_pal_struc(pal2); x_rot_pal_struc(pal,palscrolldir); i++; }; for (j=0;j<i;j++){ x_cpcontrast_pal_struc(pal, pal2,ch+=2); x_put_pal_struc(pal2); x_rot_pal_struc(pal,palscrolldir); }; wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 3.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 3.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " NEW functions not demonstrated here include:"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - RLE data compression"); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - FAST compiled masked bitmaps"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Hardware detection"); x_show_mouse(); wait_for_keypress(); x_hide_mouse(); for (i = 0; i < 150; i++) { x_circle(0, 0, i, 181 - i, VisiblePageOffs); x_circle(360 - i, 0, i, i + 30, VisiblePageOffs); x_circle(0, 200 - i, i, i + 30, VisiblePageOffs); x_circle(360 - i, 200 - i, i, 181 - i, VisiblePageOffs); } for (i = 0; i < 100; i++) x_filled_circle(80 + i, i, 201 - (i << 1), 30+i, VisiblePageOffs); x_show_mouse(); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 4.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 4.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " NEW functions not demonstrated here include:"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - FAST VRAM-based masked bitmaps, including"); x_printf(textwindow_x+5,50+18,VisiblePageOffs,9, " support for clipping regions"); x_printf(textwindow_x+5,50+28,VisiblePageOffs,9, " - Faster, smaller compiled bitmaps"); x_printf(textwindow_x+5,50+38,VisiblePageOffs,9, " - Improved planar bitmap performance and"); x_printf(textwindow_x+5,50+46,VisiblePageOffs,9, " additional support for clipping"); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " - mouse module"); x_printf(textwindow_x+5,50+66,VisiblePageOffs,9, " - Detection of math co-processor and mouse"); x_printf(textwindow_x+5,50+76,VisiblePageOffs,9, " - Bezier curve module"); x_printf(textwindow_x+5,50+86,VisiblePageOffs,9, " - Four new resolutions, including one with"); x_printf(textwindow_x+5,50+94,VisiblePageOffs,9, " square pixels (376x282)"); x_printf(textwindow_x+5,50+104,VisiblePageOffs,9, " - More bug fixes"); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 5.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 5.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " - *FAST* filled and clipped triangles ideal for"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " 3D work. Thanks to S. Dollins for the code."); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Filled and clipped polygons, C++ Compatible"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - header files, and of course bug fixes!"); x_show_mouse(); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 6.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 6.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " - Fast flood filling functions "); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - New pbm flipping put functions."); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Timer synchronized vertical retrace"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Tripple buffering extensions"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Checkout demo 9 and 10 for previews"); x_show_mouse(); wait_for_keypress(); randomize(); x_hide_mouse(); while(kbhit()) getch(); palscrolldir^=1; do { int x0,x1,x2,y0,y1,y2,i; i=random(256); x0=random(ScrnLogicalPixelWidth); x1=random(ScrnLogicalPixelWidth); x2=random(ScrnLogicalPixelWidth); y0=random(ScrnPhysicalHeight); y1=random(ScrnPhysicalHeight); y2=random(ScrnPhysicalHeight); x_triangle(x0,y0,x1,y1,x2,y2,i,VisiblePageOffs); } while (!kbhit() && !(MouseButtonStatus==LEFT_PRESSED)); while(MouseButtonStatus==LEFT_PRESSED); while(kbhit()) getch(); x_show_mouse(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," PLEASE..."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," PLEASE..."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Please mention my name in programs that use XLIB"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " just to make me feel it was worth the effort."); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " If you have any bug to report please feel free to"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " mail me a message. Any hints, suggestions and"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " contributions are welcome and encouraged."); x_printf(textwindow_x+5,50+52,VisiblePageOffs,9, " I have contributed this code to the public domain."); x_printf(textwindow_x+5,50+60,VisiblePageOffs,9, " Please respect my wishes and leave it there."); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " Finally, I hope you all find this stuff useful,"); x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " Themie Gouthas - [email protected]"); wait_for_keypress(); x_hide_mouse(); x_shift_rect (27, 27, 360-27, 177, 27, 23, VisiblePageOffs); x_rect_fill(25, 173, 335, 176, VisiblePageOffs, 1); for (i = 0; i < 50; i++) { x_shift_rect (27, 26, 360-27, 177 - (i * 3), 27, 23, VisiblePageOffs); } }
void __init mount_root(void) { struct file_system_type * fs_type; struct super_block * sb; struct vfsmount *vfsmnt; struct inode * d_inode = NULL; struct file filp; int retval; #ifdef CONFIG_ROOT_NFS if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) { ROOT_DEV = 0; if ((fs_type = get_fs_type("nfs"))) { sb = get_empty_super(); /* "can't fail" */ sb->s_dev = get_unnamed_dev(); sb->s_flags = root_mountflags; sema_init(&sb->s_vfs_rename_sem,1); vfsmnt = add_vfsmnt(sb, "/dev/root", "/"); if (vfsmnt) { if (nfs_root_mount(sb) >= 0) { sb->s_dirt = 0; sb->s_type = fs_type; current->fs->root = dget(sb->s_root); current->fs->pwd = dget(sb->s_root); ROOT_DEV = sb->s_dev; printk (KERN_NOTICE "VFS: Mounted root (NFS filesystem)%s.\n", (sb->s_flags & MS_RDONLY) ? " readonly" : ""); return; } remove_vfsmnt(sb->s_dev); } put_unnamed_dev(sb->s_dev); sb->s_dev = 0; } if (!ROOT_DEV) { printk(KERN_ERR "VFS: Unable to mount root fs via NFS, trying floppy.\n"); ROOT_DEV = MKDEV(FLOPPY_MAJOR, 0); } } #endif #ifdef CONFIG_BLK_DEV_FD if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) { #ifdef CONFIG_BLK_DEV_RAM extern int rd_doload; #endif floppy_eject(); #ifndef CONFIG_BLK_DEV_RAM printk(KERN_NOTICE "(Warning, this kernel has no ramdisk support)\n"); #else /* rd_doload is 2 for a dual initrd/ramload setup */ if(rd_doload==2) rd_load_secondary(); else #endif { printk(KERN_NOTICE "VFS: Insert root floppy and press ENTER\n"); wait_for_keypress(); } } #endif memset(&filp, 0, sizeof(filp)); d_inode = get_empty_inode(); d_inode->i_rdev = ROOT_DEV; filp.f_dentry = NULL; if ( root_mountflags & MS_RDONLY) filp.f_mode = 1; /* read only */ else filp.f_mode = 3; /* read write */ retval = blkdev_open(d_inode, &filp); if (retval == -EROFS) { root_mountflags |= MS_RDONLY; filp.f_mode = 1; retval = blkdev_open(d_inode, &filp); } iput(d_inode); if (retval) /* * Allow the user to distinguish between failed open * and bad superblock on root device. */ printk("VFS: Cannot open root device %s\n", kdevname(ROOT_DEV)); else for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { if (!(fs_type->fs_flags & FS_REQUIRES_DEV)) continue; sb = read_super(ROOT_DEV,fs_type->name,root_mountflags,root_mount_data,1); if (sb) { sb->s_flags = root_mountflags; current->fs->root = dget(sb->s_root); current->fs->pwd = dget(sb->s_root); printk ("VFS: Mounted root (%s filesystem)%s.\n", fs_type->name, (sb->s_flags & MS_RDONLY) ? " readonly" : ""); vfsmnt = add_vfsmnt(sb, "/dev/root", "/"); if (vfsmnt) return; panic("VFS: add_vfsmnt failed for root fs"); } } #ifdef CONFIG_EMPEG_DISPLAY display_bootfail(); #endif panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); }
/* * returning 1 will cause the currently running engine to exit */ uint8_t process_keys(void) { uint8_t c; if (kbhit() > 0) { c=cgetc(); CLEARKEYBUF; if (c == 'p') { #ifdef MIXED_MODE printf("PAUSED. Press p to Continue.\n"); #endif wait_for_keypress('p'); } else if (c == '1') { engine_sel = ENGINE_SEL_WRAP_NAIVE; engine_state = ENGINE_RUN; #ifdef MIXED_MODE printf("Naive wrap mode enabled.\n"); #endif return 1; } else if (c == '2') { engine_sel = ENGINE_SEL_NOWRAP_NAIVE; engine_state = ENGINE_RUN; #ifdef MIXED_MODE printf("Naive nowrap mode enabled.\n"); #endif return 1; } else if (c == '3') { engine_sel = ENGINE_SEL_WRAP_OPT; engine_state = ENGINE_RUN; #ifdef MIXED_MODE printf("Optimized wrap mode enabled.\n"); #endif return 1; } else if (c == '4') { engine_sel = ENGINE_SEL_NOWRAP_OPT; engine_state = ENGINE_RUN; #ifdef MIXED_MODE printf("Optimized nowrap mode enabled.\n"); #endif return 1; } else if (tolower(c) == 'q') { engine_state = ENGINE_STOP; return 1; } else if (c == '?') { memcpy((uint8_t *)0x5000,0x400,0x800); text_mode(); printf("\n\n\n\n\n\n\n"); show_hotkeys(); #ifdef MIXED_MODE gotoxy(0,MAXROWPAIRCNT); POKE(TEXTWINDOW_TOP_EDGE,MAXROWPAIRCNT); gr_mode(SS_PAGE2OFF, SS_MIXEDON); #else gr_mode(SS_PAGE2OFF, SS_MIXEDOFF); #endif memcpy((uint8_t *)0x400,0x5000,0x800); } else if (tolower(c) == 'r') randomize(gr_page[find_page()], 400); else if (tolower(c) == 'g') gospergun(gr_page[find_page()]); else if (tolower(c) == 's') simkins(gr_page[find_page()]); } return 0; }