void handleInput(crap::keyboard& keyboard, crap::mouse& mouse, camera& cam) { glm::vec3 offset( 0.0f, 0.0f, 0.0f); if( keyboard.is_pressed(crap::keyboard::key_W) || keyboard.is_pressed(crap::keyboard::key_w)) cam.offsetPosition( cam.forward() * 0.1f); if( keyboard.is_pressed(crap::keyboard::key_S) || keyboard.is_pressed(crap::keyboard::key_s)) cam.offsetPosition( -cam.forward() * 0.1f); if( keyboard.is_pressed(crap::keyboard::key_A) || keyboard.is_pressed(crap::keyboard::key_a)) cam.offsetPosition( -cam.right() * 0.1f); if( keyboard.is_pressed(crap::keyboard::key_D) || keyboard.is_pressed(crap::keyboard::key_d)) cam.offsetPosition( cam.right() * 0.1f); if( keyboard.is_pressed(crap::keyboard::key_up) || keyboard.is_pressed(crap::keyboard::key_page_up)) cam.offsetPosition( cam.up() * 0.1f); if( keyboard.is_pressed(crap::keyboard::key_down) || keyboard.is_pressed(crap::keyboard::key_page_down)) cam.offsetPosition( -cam.up() * 0.1f); crap::vector2i mouse_position = mouse.position(); crap::vector2i screensize( 1024, 768 ); crap::vector2i screencenter = screensize / 2; crap::vector2i move = mouse.movement(); if( mouse.is_pressed( crap::mouse::button_1 ) ) cam.offsetOrientation( move.y / 10.0f, move.x / 10.0f ); //mouse.set_position( screencenter ); //mouse.movement(); }
int main(int argc, char *argv[]) { char *file_name; uint8_t i; screensize(&screen_width, &screen_height); /* printf("width=%d height=%d\n", screen_width, screen_height); */ if (argc <= 1) { /* ProDOS doesn't support piping input/output so, if there are no arguments, ask for a file name. */ file_name = input_file_name(); if (file_name != NULL && strcmp(file_name,"")!=0) { more(file_name); } } else { /* If there are arguments, process them. */ for (i = 1; i < argc; ++i) { more(argv[i]); } } return EXIT_SUCCESS; }
/* * Scroll to the next/previous screen */ int scroll(char arg[]) { int s, size; int cur[1]; cur[0] = 0; size = screensize(); s = screen; switch (*arg) { case 0: case '+': s++; if (s * size >= msgCount) { printf("On last screenful of messages\n"); return (0); } screen = s; break; case '-': if (--s < 0) { printf("On first screenful of messages\n"); return (0); } screen = s; break; default: printf("Unrecognized scrolling command \"%s\"\n", arg); return (1); } return (headers(cur)); }
int headers(int *msgvec) { int n, mesg, flag, size; struct message *mp; size = screensize(); n = msgvec[0]; if (n != 0) screen = (n-1)/size; if (screen < 0) screen = 0; mp = &message[screen * size]; if (mp >= &message[msgCount]) mp = &message[msgCount - size]; if (mp < &message[0]) mp = &message[0]; flag = 0; mesg = mp - &message[0]; if (dot != &message[n-1]) dot = mp; for (; mp < &message[msgCount]; mp++) { mesg++; if (mp->m_flag & MDELETED) continue; if (flag++ >= size) break; printhead(mesg); } if (flag == 0) { printf("No more mail.\n"); return (1); } return (0); }
void HUD::update(float p_fDeltaTime, sf::Time p_xTimer) { if (m_xPlayerObject->getCurWep() == 1) { m_xRightLargeCircleItem = m_xRightLargeCircleBaton; } else if (m_xPlayerObject->getCurWep() == 2) { m_xRightLargeCircleItem = m_xRightLargeCircleGun; } else if (m_xPlayerObject->getCurWep() == 0) { m_xRightLargeCircleItem = m_xRightLargeCircleGarotte; } sf::Vector2f screensize(1920, 1080); m_xLeftSmallCircle->setPosition(m_xView->getCenter() + sf::Vector2f(3, 675) - screensize / 2.f); m_xLeftSmallCircleItem->setPosition(m_xView->getCenter() + sf::Vector2f(50, 732) - screensize / 2.f); m_xRightLargeCircle->setPosition(m_xView->getCenter() + sf::Vector2f(1690, 847) - screensize / 2.f); m_xRightLargeCircleItem->setPosition(m_xView->getCenter() + sf::Vector2f(1690, 847) - screensize / 2.f); m_xLeftLargeCircle->setPosition(m_xView->getCenter() + sf::Vector2f(3, 847) - screensize / 2.f); m_xLeftLargeCircleItem->setPosition(m_xView->getCenter() + sf::Vector2f(3, 847) - screensize / 2.f); std::stringstream sstream; sstream << (int)p_xTimer.asSeconds(); m_xText->setString(sstream.str()); m_xText->setPosition(m_xView->getCenter() + sf::Vector2f(1920/2 - 20, 50) - screensize / 2.f); }
/*-----------------------------------------------------------------------------------*/ void ctk_draw_init(void) { (void)bgcolor(SCREENCOLOR); (void)bordercolor(BORDERCOLOR); screensize(&sizex, &sizey); ctk_draw_clear(0, sizey); }
int main (void) { unsigned char XSize, YSize; /* Set screen colors */ (void) textcolor (COLOR_WHITE); (void) bordercolor (COLOR_BLACK); (void) bgcolor (COLOR_BLACK); /* Clear the screen, put cursor in upper left corner */ clrscr (); /* Ask for the screen size */ screensize (&XSize, &YSize); /* Draw a border around the screen */ /* Top line */ cputc (CH_ULCORNER); chline (XSize - 2); cputc (CH_URCORNER); /* Vertical line, left side */ cvlinexy (0, 1, YSize - 2); /* Bottom line */ cputc (CH_LLCORNER); chline (XSize - 2); cputc (CH_LRCORNER); /* Vertical line, right side */ cvlinexy (XSize - 1, 1, YSize - 2); /* Write the greeting in the mid of the screen */ gotoxy ((XSize - strlen (Text)) / 2, YSize / 2); cprintf ("%s", Text); #if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__) /* Wait for the user to press a button */ joy_install (joy_static_stddrv); while (!joy_read (JOY_1)) ; joy_uninstall (); #else /* Wait for the user to press a key */ cgetc (); #endif /* Clear the screen again */ clrscr (); /* Done */ return EXIT_SUCCESS; }
/*-----------------------------------------------------------------------------------*/ void ctk_draw_init(void) { (void)bgcolor(SCREENCOLOR); (void)bordercolor(BORDERCOLOR); (void)textcolor(WINDOWCOLOR_FOCUS); screensize(&sizex, &sizey); ctk_draw_clear(0, sizey); gotoxy(0, 0); }
/*-----------------------------------------------------------------------------------*/ void console_init(void) { /* mouse support is ncurses-specific */ #ifdef NCURSES_MOUSE_VERSION mmask_t oldmask; #endif static unsigned char done; int bg, fg; if(done) { return; } done = 1; initscr(); start_color(); cbreak(); /* don't echo typed characters */ noecho(); /* disable return -> newline translation */ nonl(); /* hide text cursor, CTK draws its own */ curs_set(0); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); #ifdef NCURSES_MOUSE_VERSION /* done here because ctk_mouse_init() is called before anyway */ mousemask(ALL_MOUSE_EVENTS, &oldmask); #endif screensize(&width, &height); /* we must declare all possible color pairs */ for(fg = 0; fg < 8; fg++) { for(bg = 0; bg < 8; bg++) { init_pair(MKPAIR(bg, fg), fg, bg); } } /* set window title */ putp("\033]0;Contiki\a"); /* don't block on read, just timeout 1ms */ timeout(1); /* make sure we return the terminal in a clean state */ signal(SIGINT, ctrlhandler); atexit(console_exit); }
static int scroll1(char *arg, int onlynew) { int size; int cur[1]; cur[0] = onlynew ? -1 : 0; size = screensize(); switch (*arg) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': screen = atoi(arg); goto scroll_forward; case '\0': screen++; goto scroll_forward; case '$': screen = msgCount / size; goto scroll_forward; case '+': if (arg[1] == '\0') screen++; else screen += atoi(arg + 1); scroll_forward: if (screen * size > msgCount) { screen = msgCount / size; printf(catgets(catd, CATSET, 7, "On last screenful of messages\n")); } break; case '-': if (arg[1] == '\0') screen--; else screen -= atoi(arg + 1); if (screen < 0) { screen = 0; printf(catgets(catd, CATSET, 8, "On first screenful of messages\n")); } if (cur[0] == -1) cur[0] = -2; break; default: printf(catgets(catd, CATSET, 9, "Unrecognized scrolling command \"%s\"\n"), arg); return(1); } return(headers(cur)); }
/*-----------------------------------------------------------------------------------*/ unsigned char console_resize(void) { unsigned char new_width; unsigned char new_height; screensize(&new_width, &new_height); if(new_width != width || new_height != height) { width = new_width; height = new_height; return 1; } return 0; }
int main(void) { screensize(&cols, &rows); clrscr(); updatefps(10); while (1) { if (kbhit()) { unsigned char c = cgetc(); if (c == '0') updatefps(10); else if (c >= '1' && c <= '9') updatefps((c - '0') * 4); else return 0; } updateanim(); } }
void screeninit(void) { uchar *fb; int set; ulong chan; set = screensize() == 0; fb = fbinit(set, &xgscreen.r.max.x, &xgscreen.r.max.y, &xgscreen.depth); if(fb == nil){ print("can't initialise %dx%dx%d framebuffer \n", xgscreen.r.max.x, xgscreen.r.max.y, xgscreen.depth); return; } xgscreen.clipr = xgscreen.r; switch(xgscreen.depth){ default: print("unsupported screen depth %d\n", xgscreen.depth); xgscreen.depth = 16; /* fall through */ case 16: chan = RGB16; break; case 24: chan = BGR24; break; case 32: chan = ARGB32; break; } memsetchan(&xgscreen, chan); conf.monitor = 1; xgdata.bdata = fb; xgdata.ref = 1; gscreen = &xgscreen; gscreen->width = wordsperline(gscreen->r, gscreen->depth); memimageinit(); memdefont = getmemdefont(); screenwin(); screenputs = myscreenputs; swcursorinit(); }
/* * Print the current active headings. * Don't change dot if invoker didn't give an argument. */ PUBLIC int headers(void *v) { int *msgvec; int n; int flag; struct message *mp; int size; msgvec = v; size = screensize(); n = msgvec[0]; if (n != 0) screen = (n - 1)/size; if (screen < 0) screen = 0; if ((mp = get_message(screen * size + 1)) == NULL) { int msgCount; msgCount = get_msgCount(); if (screen * size + 1 > msgCount) mp = get_message(msgCount - size + 1); if (mp == NULL) mp = get_message(1); } flag = 0; if (dot != get_message(n)) dot = mp; for (/*EMPTY*/; mp; mp = next_message(mp)) { if (mp->m_flag & MDELETED) continue; if (flag++ >= size) break; printhead(get_msgnum(mp)); } if (flag == 0) { (void)printf("No more mail.\n"); return 1; } return 0; }
/* * Scroll to the next/previous screen */ PUBLIC int scroll(void *v) { char *arg; int s; int size; int cur[1]; arg = v; cur[0] = 0; size = screensize(); s = screen; switch (*arg) { case 0: case '+': s++; if (s * size >= get_msgCount()) { (void)printf("On last screenful of messages\n"); return 0; } screen = s; break; case '-': if (--s < 0) { (void)printf("On first screenful of messages\n"); return 0; } screen = s; break; default: (void)printf("Unrecognized scrolling command \"%s\"\n", arg); return 1; } return headers(cur); }
/* * Print out the headlines for each message * in the passed message list. */ int from(void *v) { int *msgvec = v; int *ip, n; FILE *obuf = stdout; char *cp; (void)&obuf; (void)&cp; if (is_a_tty[0] && is_a_tty[1] && (cp = value("crt")) != NULL) { for (n = 0, ip = msgvec; *ip; ip++) n++; if (n > (*cp == '\0' ? screensize() : atoi(cp)) + 3) { cp = get_pager(); if (sigsetjmp(pipejmp, 1)) goto endpipe; if ((obuf = Popen(cp, "w", NULL, 1)) == NULL) { perror(cp); obuf = stdout; } else safe_signal(SIGPIPE, onpipe); } } for (ip = msgvec; *ip != 0; ip++) printhead(*ip, obuf, mb.mb_threaded); if (--ip >= msgvec) setdot(&message[*ip - 1]); endpipe: if (obuf != stdout) { safe_signal(SIGPIPE, SIG_IGN); Pclose(obuf); safe_signal(SIGPIPE, dflpipe); } return(0); }
/* * ~p command. */ static void print_collf(FILE *collf, struct header *hp) { char *lbuf = NULL; FILE *obuf = stdout; struct attachment *ap; char *cp; enum gfield gf; size_t linecnt, maxlines, linesize = 0, linelen, count, count2; (void)&obuf; (void)&cp; fflush(collf); rewind(collf); count = count2 = fsize(collf); if (is_a_tty[0] && is_a_tty[1] && (cp = value("crt")) != NULL) { for (linecnt = 0; fgetline(&lbuf, &linesize, &count2, NULL, collf, 0); linecnt++); rewind(collf); maxlines = (*cp == '\0' ? screensize() : atoi(cp)); maxlines -= 4; if (hp->h_to) maxlines--; if (hp->h_subject) maxlines--; if (hp->h_cc) maxlines--; if (hp->h_bcc) maxlines--; if (hp->h_attach) maxlines--; maxlines -= myaddrs(hp) != NULL || hp->h_from != NULL; maxlines -= value("ORGANIZATION") != NULL || hp->h_organization != NULL; maxlines -= value("replyto") != NULL || hp->h_replyto != NULL; maxlines -= value("sender") != NULL || hp->h_sender != NULL; if (linecnt > maxlines) { cp = get_pager(); if (sigsetjmp(pipejmp, 1)) goto endpipe; obuf = Popen(cp, "w", NULL, 1); if (obuf == NULL) { perror(cp); obuf = stdout; } else safe_signal(SIGPIPE, onpipe); } } fprintf(obuf, catgets(catd, CATSET, 62, "-------\nMessage contains:\n")); gf = GIDENT|GTO|GSUBJECT|GCC|GBCC|GNL|GFILES; if (value("fullnames")) gf |= GCOMMA; puthead(hp, obuf, gf, SEND_TODISP, CONV_NONE, NULL, NULL); while (fgetline(&lbuf, &linesize, &count, &linelen, collf, 1)) prout(lbuf, linelen, obuf); if (hp->h_attach != NULL) { fputs(catgets(catd, CATSET, 63, "Attachments:"), obuf); for (ap = hp->h_attach; ap != NULL; ap = ap->a_flink) { if (ap->a_msgno) fprintf(obuf, " message %u", ap->a_msgno); else fprintf(obuf, " %s", ap->a_name); if (ap->a_flink) putc(',', obuf); } putc('\n', obuf); } endpipe: if (obuf != stdout) { safe_signal(SIGPIPE, SIG_IGN); Pclose(obuf); safe_signal(SIGPIPE, dflpipe); } if (lbuf) free(lbuf); }
void main(void) { int i, j, n; unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0; clrscr(); screensize(&xsize, &ysize); cputs("cc65 conio test\n\rInput: [ ]"); cputsxy(0, 2, "Colors:" ); tcol = textcolor(0); /* remember original textcolor */ bgcol = bgcolor(0); /* remember original background color */ bcol = bordercolor(0); /* remember original border color */ bgcolor(bgcol);bordercolor(bcol); for (i = 0; i < 3; ++i) { gotoxy(i,3 + i); for (j = 0; j < 16; ++j) { textcolor(j); cputc('X'); } } textcolor(tcol); cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize ); chlinexy(0,6,xsize); cvlinexy(0,6,3); chlinexy(0,8,xsize); cvlinexy(xsize-1,6,3); cputcxy(0,6,CH_ULCORNER); cputcxy(xsize-1,6,CH_URCORNER); cputcxy(0,8,CH_LLCORNER); cputcxy(xsize-1,8,CH_LRCORNER); for (i = 0; i < 5; ++i) { gotoxy(xsize - 5,i); for (j = 0; j < 5; ++j) { cputc(grid[i][j]); } } gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } revers(0); for (i = 0; i < 256; ++i) { if ((i != '\n') && (i != '\r')) { cputc(i); } else { cputc(' '); } } while(wherex() > 0) { cputc('#'); } revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } revers(0); cursor(1); for(;;) { gotoxy(8, 2); j = n & 1; revers(j); cputc(j ? 'R' : ' '); revers(j ^ 1); cputs(" revers"); revers(0); gotoxy(8 + inpos,1); i = cgetc(); if ((i >= '0') && (i<='9')) { textcolor(i - '0'); } else if (i == CH_CURS_LEFT) { inpos = (inpos - 1) & 7; } else if (i == CH_CURS_RIGHT) { inpos = (inpos + 1) & 7; } else if (i == CH_F5) { bgcol = (bgcol + 1) & 0x0f; bordercolor(bgcol); } else if (i == CH_F6) { bgcol = (bgcol - 1) & 0x0f; bordercolor(bgcol); } else if (i == CH_F7) { bgcol = (bgcol + 1) & 0x0f; bgcolor(bgcol); } else if (i == CH_F8) { bgcol = (bgcol - 1) & 0x0f; bgcolor(bgcol); } else { cputc(i); inpos = (inpos + 1) & 7; } ++n; } for(;;); }
int main(void) { char C; /* Clock variables */ clock_t Ticks; clock_t Wait; unsigned Days; unsigned Hours; unsigned Minu; unsigned Sec; unsigned Milli; /* Actual test variables */ register unsigned lhs = 0; register unsigned rhs = 0; register unsigned res; /* Clear the screen, and output an informational message. */ clrscr (); screensize (&Width, &Height); cprintf ("This program does an exhaustive test of\r\n" "the multiplication routine. It runs for\r\n" "several days; so, please wait very\r\n" "patiently (or, speed up your emulator).\r\n" "\n" "Progress: "); /* Remember the current position for the progress bar */ X = wherex (); Y = wherey (); /* Mark the maximum limit of the bar. */ revers (1); cputcxy (BAR_ELEMENTS, Y, ' '); cputcxy (BAR_ELEMENTS, Y + 1, ' '); revers (0); /* [Targets that have clock() will define CLOCKS_PER_SEC.] */ #ifdef CLOCKS_PER_SEC /* Start timing the test. */ Ticks = clock(); #endif do { /* Update the progress bar */ ProgressMeter (lhs); /* Enable this to test the progress-meter code. ** (And, run emulators at their maximun speed.) */ #if 0 continue; #endif /* Do one row of tests */ res = 0; do { if (lhs * rhs != res) { #ifdef CLOCKS_PER_SEC Wait = clock (); #endif gotoxy (0, Y+3); cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res); cprintf ("Press a key -- 'Q' to quit. "); cursor (1); C = toupper (cgetc ()); cclearxy (0, Y+3, Width); cclearxy (0, Y+4, Width); #ifdef CLOCKS_PER_SEC /* Don't time the user's interaction. */ Ticks += clock () - Wait; #endif if (C == 'Q') { goto Done; } } if (kbhit () && toupper (cgetc ()) == 'Q') { goto Done; } res += lhs; } while (++rhs != 0); } while (++lhs != 0); Done: #ifdef CLOCKS_PER_SEC /* Calculate the time used */ Ticks = clock() - Ticks; Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC; Sec = (unsigned) (Ticks / CLOCKS_PER_SEC); Minu = Sec / 60; Hours = Minu / 60; Days = Hours / 24; Hours %= 24; Minu %= 60; Sec %= 60; /* Print the time used */ gotoxy (0, Y+3); cprintf ("Time used:\r\n" " %u days,\r\n" " %u hours,\r\n" " %u minutes,\r\n" " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli); #endif #ifdef __ATARI__ if (_dos_type != SPARTADOS && _dos_type != OSADOS) { cprintf ("\rTap a key, to exit. "); cgetc(); } #endif return 0; }
int main (int argc, const char* argv[]) { unsigned char SourceId; unsigned char TargetId; dhandle_t Source = NULL; dhandle_t Target = NULL; unsigned int SectSize; unsigned int SectCount; char* Buffer; unsigned int Sector; unsigned int ChunkCount; unsigned int ChunkOffset = 0; clrscr (); screensize (&ScreenX, &ScreenY); /* Allow user to read exit messages */ if (doesclrscrafterexit ()) { atexit ((void (*)) cgetc); } cputs ("Floppy Disk Copy\r\n"); chline (16); cputs ("\r\n"); /* Get source and target drive id (which may very well be identical) */ switch (argc) { case 1: SourceId = AskForDrive ("Source"); TargetId = AskForDrive ("Target"); cputs ("\r\n"); break; case 2: SourceId = TargetId = atoi (argv[1]); break; case 3: SourceId = atoi (argv[1]); TargetId = atoi (argv[2]); break; default: cprintf ("\r\nToo many arguments\r\n"); return EXIT_FAILURE; } cputs ("\r\n"); do { /* Check for single drive copy or inital iteration */ if (SourceId == TargetId || Source == NULL) { AskForDisk ("Source", SourceId); } /* Check for initial iteration */ if (Source == NULL) { /* Open source drive */ Source = dio_open (SourceId); if (Source == NULL) { cprintf ("\r\n\nError %d on opening Drive %d\r\n", (int) _oserror, SourceId); return EXIT_FAILURE; } SectSize = dio_query_sectsize (Source); SectCount = dio_query_sectcount (Source); /* Allocate buffer */ Buffer = AllocBuffer (SectSize, SectCount, &ChunkCount); if (Buffer == NULL) { cputs ("\r\n\nError on allocating Buffer\r\n"); return EXIT_FAILURE; } } ClearLine (); /* Read one chunk of sectors into buffer */ for (Sector = ChunkOffset; Sector < SectCount && (Sector - ChunkOffset) < ChunkCount; ++Sector) { cprintf ("\rReading Sector %d of %d", Sector + 1, SectCount); /* Read one sector */ if (dio_read (Source, Sector, Buffer + (Sector - ChunkOffset) * SectSize) != 0) { cprintf ("\r\n\nError %d on reading from Drive %d\r\n", (int) _oserror, SourceId); return EXIT_FAILURE; } } /* Check for single drive copy or inital iteration */ if (TargetId == SourceId || Target == NULL) { AskForDisk ("Target", TargetId); } /* Open target drive on initial iteration */ if (Target == NULL) { Target = dio_open (TargetId); if (Target == NULL) { cprintf ("\r\n\nError %d on opening Drive %d\r\n", (int) _oserror, TargetId); return EXIT_FAILURE; } /* Check for compatible drives */ if (dio_query_sectsize (Target) != SectSize || dio_query_sectcount (Target) != SectCount) { cputs ("\r\n\nFormat mismatch between Drives\r\n"); return EXIT_FAILURE; } } ClearLine (); /* Write one chunk of sectors from buffer */ for (Sector = ChunkOffset; Sector < SectCount && (Sector - ChunkOffset) < ChunkCount; ++Sector) { cprintf ("\rWriting Sector %d of %d", Sector + 1, SectCount); /* Write one sector */ if (dio_write (Target, Sector, Buffer + (Sector - ChunkOffset) * SectSize) != 0) { cprintf ("\r\n\nError %d on writing to Drive %d\r\n", (int) _oserror, TargetId); return EXIT_FAILURE; } } /* Advance to next chunk */ ChunkOffset += ChunkCount; } while (Sector < SectCount); ClearLine (); cprintf ("\rSuccessfully copied %d Sectors\r\n", SectCount); free (Buffer); dio_close (Source); dio_close (Target); return EXIT_SUCCESS; }
/* ** There is a delay between when the VIC sends its signal, and when the display ** shows that signal. There is another delay between the display and when ** the lightpen says that it saw that signal. Each display and pen is different. ** Therefore, the driver must be calibrated to them. A white bar is painted on ** the screen; and, a line is drawn down the middle of it. When the user clicks ** on that line, the difference between its position and where the VIC thinks ** that the pen is pointing becomes an offset that is subtracted from what the ** VIC sees. */ void __fastcall__ pen_calibrate (unsigned char *XOffset) { unsigned char oldBg = bgcolor (COLOR_BLUE); unsigned char oldText = textcolor (COLOR_GRAY3); unsigned char oldRev = revers (1); unsigned char sprite0Color = VIC.spr_color[0]; unsigned char width, width2, height, height4, height8; struct mouse_info info; screensize (&width, &height); width2 = width / 2; height4 = height / 4; height8 = height4 * 8; /* Draw a bar and line. */ clrscr (); cclearxy (0, height4, height4 * width); cvlinexy (width2, height4 + 1, height4 - 2); revers (0); /* Print instructions. */ cputsxy (width2 - (sizeof COMMAND1) / 2, height / 2 + 1, COMMAND1); cputsxy (width2 - (sizeof COMMAND2) / 2, height / 2 + 3, COMMAND2); VIC.spr_color[0] = COLOR_GRAY2; mouse_show (); mouse_move (width2 * 8, height8 / 2); for (;;) { /* Wait for the main button to be released. */ do ; while ((mouse_buttons () & MOUSE_BTN_LEFT)); /* Wait for the main button to be pressed. */ do { mouse_info (&info); } while (!(info.buttons & MOUSE_BTN_LEFT)); /* Find out if the pen is on or off the bar. */ if (info.pos.y < height8 || info.pos.y >= height8 * 2) { break; } /* On the bar; adjust the offset. */ /* Characters are eight pixels wide. ** The VIC-II sees every other pixel; ** so, we use half of the difference. */ *XOffset += (info.pos.x - (width2 * 8 + 8/2)) / 2; } /* Off the bar; wait for the main button to be released. */ do ; while ((mouse_buttons () & MOUSE_BTN_LEFT)); mouse_hide (); VIC.spr_color[0] = sprite0Color; revers (oldRev); textcolor (oldText); bgcolor (oldBg); clrscr (); }
int main(void) { char C; /* Clock variable */ clock_t Ticks; unsigned Sec; unsigned Milli; /* Actual test variables */ register unsigned lhs = 0; register unsigned rhs = 0; register unsigned res; /* Clear the screen and output an informational message */ clrscr (); screensize (&Width, &Height); cprintf ("This program does an exhaustive test of\r\n" "the multiplication routine. It runs\r\n" "several days, so please wait very\r\n" "patiently (or speedup your emulator)\r\n" "\r\n" "Progress:\r\n"); /* Remember the current position for the progress bar */ X = wherex (); Y = wherey (); /* Read the clock */ Ticks = clock(); do { /* Update the progress bar */ ProgressMeter (lhs); /* Do one row of tests */ res = 0; do { if (lhs * rhs != res) { gotoxy (X, Y+1); cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res); cprintf ("Press a key ..., 'Q' to quit"); C = toupper (cgetc ()); cclearxy (X, Y+1, Width); cclearxy (X, Y+2, Width); if (C == 'Q') { goto Done; } } res += lhs; } while (++rhs != 0); } while (++lhs != 0); Done: /* Calculate the time used */ Ticks = clock() - Ticks; Sec = (unsigned) (Ticks / CLOCKS_PER_SEC); Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC; /* Print the time used */ gotoxy (X, Y+1); cprintf ("Time used: %u.%03u seconds\n", Sec, Milli); return 0; }
//============================================================================================================= void Game::DrawWithShadersInverted(float syncalpha) { size_t written = 0; size_t count = 0; // texturába rajzoljuk a jelenetet oldsurface = NULL; game->Graphics->GetRenderTarget(0, &oldsurface); game->Graphics->SetRenderTarget(0, rendersurface); game->Graphics->Clear(0, NULL, D3DCLEAR_TARGET, 0xff6694ed, 1.0f, 0); background.Draw(); quads.Lock(); { for( enemyset::iterator it = enemies.begin(); it != enemies.end(); ++it ) { written = (*it)->Write(count, quads); count += written; } written = avatar.Write(count, quads); count += written; for( projectilelist::iterator it = avatarprojectiles.begin(); it != avatarprojectiles.end(); ++it ) { it->Position.smooth(syncalpha); quads.WriteQuad(count, it->Position.value, it->Image->Size, it->Image->Texcoords); ++count; } for( projectilelist::iterator it = enemyprojectiles.begin(); it != enemyprojectiles.end(); ++it ) { it->Position.smooth(syncalpha); DummyFramework::CHelper::MirrorX(texcoords, it->Image->Texcoords); quads.WriteQuad(count, it->Position.value, it->Image->Size, texcoords); ++count; } for( poweruplist::iterator it = powerups.begin(); it != powerups.end(); ++it ) { written = it->Write(count, quads); count += written; } for( explosionlist::iterator it = explosions.begin(); it != explosions.end(); ++it ) { written = it->Write(count, quads); count += written; } } quads.Unlock(); if( count > MAX_SPRITES ) { count = MAX_SPRITES; std::cout << "!!!Attempt to buffer overflow!!!\n"; } game->StateManager->SetTexture(0, atlastex1); quads.Draw(count); // a texturát kirajzoljuk hullámzo effekttel game->Graphics->SetRenderTarget(0, oldsurface); game->StateManager->SetTexture(1, wave); game->StateManager->SetTexture(2, rendertarget); oldsurface->Release(); idtransform._11 = GameVariables::ScreenWidth; idtransform._22 = GameVariables::ScreenHeight; idtransform._41 = -0.5f; idtransform._42 = -0.5f; if( invert == 3 ) DummyFramework::CHelper::MirrorXY(texcoords, basictexcoords); else if( invert == 2 ) DummyFramework::CHelper::MirrorY(texcoords, basictexcoords); else DummyFramework::CHelper::MirrorX(texcoords, basictexcoords); D3DXVECTOR4 screensize(GameVariables::ScreenWidth, GameVariables::ScreenHeight, 0, 1); distort->SetTechnique("distort"); distort->SetFloat("time", (float)GameVariables::Sync.Timer().Time()); distort->SetVector("screensize", &screensize); distort->Begin(NULL, _DUMMY_EFFECT_DONT_SAVE_); distort->BeginPass(0); { game->DrawImage(idtransform, texcoords, 0xffffffff); } distort->EndPass(); distort->End(); game->StateManager->SetVertexShader(NULL); game->StateManager->SetPixelShader(NULL); game->StateManager->SetTexture(2, NULL); // a hudot mindennek a tetejére #ifdef DEBUG_ENTITIES size_t tmp = count; #endif count = 0; quads.Lock(); { written = hud.Write(count, quads); count += written; written = avatarbubble.Write(count, quads); count += written; } quads.Unlock(); if( count > MAX_SPRITES ) { count = MAX_SPRITES; std::cout << "!!!Attempt to buffer overflow!!!\n"; } quads.Draw(count); #ifdef DEBUG_ENTITIES std::cout << "quads: " << (tmp + count) << ", e: " << enemies.size() << ", p: " << powerups.size() << ", x: " << explosions.size() << ", a: " << avatarprojectiles.size() << ", ep: " << enemyprojectiles.size() << " \r"; #endif }
static void vgactl(Cmdbuf *cb) { int align, i, size, x, y, z; char *chanstr, *p; ulong chan; Cmdtab *ct; VGAscr *scr; extern VGAdev *vgadev[]; extern VGAcur *vgacur[]; scr = &vgascreen[0]; ct = lookupcmd(cb, vgactlmsg, nelem(vgactlmsg)); switch(ct->index) { case CMhwgc: if(strcmp(cb->f[1], "off") == 0) { lock(&cursor); if(scr->cur) { if(scr->cur->disable) scr->cur->disable(scr); scr->cur = nil; } unlock(&cursor); return; } if(strcmp(cb->f[1], "soft") == 0) { lock(&cursor); swcursorinit(); if(scr->cur && scr->cur->disable) scr->cur->disable(scr); scr->cur = &swcursor; if(scr->cur->enable) scr->cur->enable(scr); unlock(&cursor); return; } for(i = 0; vgacur[i]; i++) { if(strcmp(cb->f[1], vgacur[i]->name)) continue; lock(&cursor); if(scr->cur && scr->cur->disable) scr->cur->disable(scr); scr->cur = vgacur[i]; if(scr->cur->enable) scr->cur->enable(scr); unlock(&cursor); return; } break; case CMtype: for(i = 0; vgadev[i]; i++) { if(strcmp(cb->f[1], vgadev[i]->name)) continue; if(scr->dev && scr->dev->disable) scr->dev->disable(scr); scr->dev = vgadev[i]; if(scr->dev->enable) scr->dev->enable(scr); return; } break; case CMtextmode: screeninit(); return; case CMsize: x = strtoul(cb->f[1], &p, 0); if(x == 0 || x > 10240) error(Ebadarg); if(*p) p++; y = strtoul(p, &p, 0); if(y == 0 || y > 10240) error(Ebadarg); if(*p) p++; z = strtoul(p, &p, 0); chanstr = cb->f[2]; if((chan = strtochan(chanstr)) == 0) error("bad channel"); if(chantodepth(chan) != z) error("depth, channel do not match"); cursoroff(1); deletescreenimage(); if(screensize(x, y, z, chan)) error(Egreg); vgascreenwin(scr); resetscreenimage(); cursoron(1); return; case CMactualsize: if(scr->gscreen == nil) error("set the screen size first"); x = strtoul(cb->f[1], &p, 0); if(x == 0 || x > 2048) error(Ebadarg); if(*p) p++; y = strtoul(p, nil, 0); if(y == 0 || y > 2048) error(Ebadarg); if(x > scr->gscreen->r.max.x || y > scr->gscreen->r.max.y) error("physical screen bigger than virtual"); physgscreenr = Rect(0,0,x,y); scr->gscreen->clipr = physgscreenr; return; case CMpalettedepth: x = strtoul(cb->f[1], &p, 0); if(x != 8 && x != 6) error(Ebadarg); scr->palettedepth = x; return; case CMdrawinit: memimagedraw(scr->gscreen, scr->gscreen->r, memblack, ZP, nil, ZP, S); if(scr && scr->dev && scr->dev->drawinit) scr->dev->drawinit(scr); return; case CMlinear: if(cb->nf!=2 && cb->nf!=3) error(Ebadarg); size = strtoul(cb->f[1], 0, 0); if(cb->nf == 2) align = 0; else align = strtoul(cb->f[2], 0, 0); if(screenaperture(size, align) < 0) error("not enough free address space"); return; /* case CMmemset: memset((void*)strtoul(cb->f[1], 0, 0), atoi(cb->f[2]), atoi(cb->f[3])); return; */ case CMblank: drawblankscreen(1); return; case CMunblank: drawblankscreen(0); return; case CMblanktime: blanktime = strtoul(cb->f[1], 0, 0); return; case CMpanning: if(strcmp(cb->f[1], "on") == 0) { if(scr == nil || scr->cur == nil) error("set screen first"); if(!scr->cur->doespanning) error("panning not supported"); scr->gscreen->clipr = scr->gscreen->r; panning = 1; } else if(strcmp(cb->f[1], "off") == 0) { scr->gscreen->clipr = physgscreenr; panning = 0; } else break; return; case CMhwaccel: if(strcmp(cb->f[1], "on") == 0) hwaccel = 1; else if(strcmp(cb->f[1], "off") == 0) hwaccel = 0; else break; return; case CMhwblank: if(strcmp(cb->f[1], "on") == 0) hwblank = 1; else if(strcmp(cb->f[1], "off") == 0) hwblank = 0; else break; return; } cmderror(cb, "bad VGA control message"); }
int main (void) #endif { struct mouse_info info; struct mouse_box full_box, small_box; unsigned char width, height; char C; bool Invisible = true, Done = false, Jailed = false; #ifdef __ATARIXL__ cprintf ("adding heap: $%04X bytes at $%04X\r\n", &_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__), &_HIDDEN_RAM_LAST__); _heapadd (&_HIDDEN_RAM_LAST__, (size_t)(&_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__))); cgetc (); #endif #ifndef NO_DEBUG /* Initialize the debugger */ DbgInit (0); #endif /* Set dark-on-light colors. Clear the screen. */ #ifdef __CBM__ (void) bordercolor (COLOR_GRAY2); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_GRAY1); #else (void) bordercolor (COLOR_BLUE); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_BLACK); #endif cursor (0); clrscr (); /* If a lightpen driver is installed, then it can get a calibration value ** from this file (if it exists). Or, the user can adjust the pen; and, ** the value will be put into this file, for the next time. ** (Other drivers will ignore this.) */ #if defined(__C64__) || defined(__C128__) || defined(__CBM510__) pen_adjust ("pen.dat"); #endif #if DYN_DRV /* If a dynamically loadable driver is named on the command line, ** then use that driver instead of the standard one. */ if (argc > 1) { mouse_name = argv[1]; } else { #if defined(__ATARI__) || defined(__C64__) || defined(__C128__) char selection, flag = 0; cprintf ("Select mouse driver:\r\n" " 0 - Joystick\r\n" #ifdef __ATARI__ " 1 - ST Mouse\r\n" " 2 - Amiga Mouse\r\n" " 3 - Atari Trakball\r\n" " 4 - Atari TouchPad\r\n" #else " 1 - 1351 Mouse\r\n" " 2 - Inkwell Mouse\r\n" " 3 - Paddle\r\n" #endif "Enter selection: "); while (1) { switch (selection = cgetc ()) { case '0': mouse_name = MSENAME_0; flag = 1; break; case '1': mouse_name = MSENAME_1; flag = 1; break; case '2': mouse_name = MSENAME_2; flag = 1; break; case '3': mouse_name = MSENAME_3; flag = 1; break; #ifdef __ATARI__ case '4': mouse_name = MSENAME_4; flag = 1; break; #endif } if (flag) break; } cprintf ("%c\r\nOK, loading \"%s\",\r\nplease wait patiently...\r\n", selection, mouse_name); #else /* Output a warning about the standard driver that is needed. */ DoWarning (); mouse_name = mouse_stddrv; #endif } /* Load and install the driver. */ CheckError ("mouse_load_driver", mouse_load_driver (&MOUSE_CALLBACK, mouse_name)); #else /* not DYN_DRV */ #if !defined(MOUSE_DRIVER) && (defined(__ATARI__) || defined(__C64__) || defined(__C128__)) { char selection, flag = 0; cprintf ("Select mouse driver:\r\n" " 0 - Joystick\r\n" #ifdef __ATARI__ " 1 - ST Mouse\r\n" " 2 - Amiga Mouse\r\n" " 3 - Atari Trakball\r\n" " 4 - Atari TouchPad\r\n" #else " 1 - 1351 Mouse\r\n" " 2 - Inkwell Mouse\r\n" " 3 - Paddle\r\n" #endif "Enter selection: "); while (1) { switch (selection = cgetc ()) { case '0': mouse_drv_use = MSESTAT_0; flag = 1; break; case '1': mouse_drv_use = MSESTAT_1; flag = 1; break; case '2': mouse_drv_use = MSESTAT_2; flag = 1; break; case '3': mouse_drv_use = MSESTAT_3; flag = 1; break; #ifdef __ATARI__ case '4': mouse_drv_use = MSESTAT_4; flag = 1; break; #endif } if (flag) break; } } #else mouse_drv_use = mouse_static_stddrv; #endif /* Install the driver. */ CheckError ("mouse_install", mouse_install (&MOUSE_CALLBACK, # ifdef MOUSE_DRIVER MOUSE_DRIVER # else #if defined(__ATARI__) || defined(__C64__) || defined(__C128__) mouse_drv_use #else mouse_static_stddrv #endif # endif )); #endif #ifndef NO_JAIL /* Get the initial bounding box. */ mouse_getbox (&full_box); #endif screensize (&width, &height); top: clrscr (); /* Print a help line */ cputs (" d)ebug h)ide q)uit s)how j)ail"); gotoxy (1, 20); cprintf ("SP: $%04X", getsp()); /* Put a cross at the center of the screen. */ gotoxy (width / 2 - 3, height / 2 - 1); #if defined(__CBM__) cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4, width / 2, ""); #else cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4, width / 2, ""); #endif /* Test loop */ ShowState (Jailed, Invisible); do { /* Get the current co-ordinates and button states; and, print them. */ mouse_info (&info); gotoxy (0, 2); cprintf (" X = %3d\r\n", info.pos.x); cprintf (" Y = %3d\r\n", info.pos.y); cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ? #ifdef __CBM__ 0x5F #else 'v' #endif : '^'); cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ? #ifdef __CBM__ 0x5F #else 'v' #endif : '^'); /* Handle user input */ if (kbhit ()) { cclearxy (1, 9, 23); switch (tolower (C = cgetc ())) { #ifndef NO_DEBUG case 'd': BREAK(); /* The debugger might have changed the colors. ** Restore them. */ #ifdef __CBM__ (void) bordercolor (COLOR_GRAY2); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_GRAY1); #else (void) bordercolor (COLOR_BLUE); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_BLACK); #endif /* The debugger changed the screen; restore it. */ goto top; #endif case 'h': mouse_hide (); ShowState (Jailed, ++Invisible); break; #ifndef NO_JAIL case 'j': if (Jailed) { mouse_setbox (&full_box); Jailed = false; } else { small_box.minx = max (info.pos.x - 10, full_box.minx); small_box.miny = max (info.pos.y - 10, full_box.miny); small_box.maxx = min (info.pos.x + 10, full_box.maxx); small_box.maxy = min (info.pos.y + 10, full_box.maxy); mouse_setbox (&small_box); Jailed = true; } ShowState (Jailed, Invisible); break; #endif case 's': mouse_show (); if (Invisible) { ShowState (Jailed, --Invisible); } break; case 'q': Done = true; break; default: gotoxy (1, 9); cprintf ("Spurious character: $%02X", C); } } } while (!Done); #if DYN_DRV /* Uninstall and unload the driver. */ CheckError ("mouse_unload", mouse_unload ()); #else /* Uninstall the static driver. */ CheckError ("mouse_uninstall", mouse_uninstall ()); #endif /* Say goodbye */ cputsxy (0, height / 2 + 3, "Goodbye!"); return EXIT_SUCCESS; }
int headers(void *v) { int *msgvec = v; int g, k, n, mesg, flag = 0, lastg = 1; struct message *mp, *mq, *lastmq = NULL; int size; enum mflag fl = MNEW|MFLAGGED; size = screensize(); n = msgvec[0]; /* n == {-2, -1, 0}: called from scroll() */ if (screen < 0) screen = 0; k = screen * size; if (k >= msgCount) k = msgCount - size; if (k < 0) k = 0; if (mb.mb_threaded == 0) { g = 0; mq = &message[0]; for (mp = &message[0]; mp < &message[msgCount]; mp++) if (visible(mp)) { if (g % size == 0) mq = mp; if (mp->m_flag&fl) { lastg = g; lastmq = mq; } if (n>0 && mp==&message[n-1] || n==0 && g==k || n==-2 && g==k+size && lastmq || n<0 && g>=k && mp->m_flag&fl) break; g++; } if (lastmq && (n==-2 || n==-1 && mp==&message[msgCount])) { g = lastg; mq = lastmq; } screen = g / size; mp = mq; mesg = mp - &message[0]; if (dot != &message[n-1]) { for (mq = mp; mq < &message[msgCount]; mq++) if (visible(mq)) { setdot(mq); break; } } if (mb.mb_type == MB_IMAP) imap_getheaders(mesg+1, mesg + size); for (; mp < &message[msgCount]; mp++) { mesg++; if (!visible(mp)) continue; if (flag++ >= size) break; printhead(mesg, stdout, 0); } } else { /* threaded */ g = 0; mq = threadroot; for (mp = threadroot; mp; mp = next_in_thread(mp)) if (visible(mp) && (mp->m_collapsed <= 0 || mp == &message[n-1])) { if (g % size == 0) mq = mp; if (mp->m_flag&fl) { lastg = g; lastmq = mq; } if (n>0 && mp==&message[n-1] || n==0 && g==k || n==-2 && g==k+size && lastmq || n<0 && g>=k && mp->m_flag&fl) break; g++; } if (lastmq && (n==-2 || n==-1 && mp==&message[msgCount])) { g = lastg; mq = lastmq; } screen = g / size; mp = mq; if (dot != &message[n-1]) { for (mq = mp; mq; mq = next_in_thread(mq)) if (visible(mq) && mq->m_collapsed <= 0) { setdot(mq); break; } } while (mp) { if (visible(mp) && (mp->m_collapsed <= 0 || mp == &message[n-1])) { if (flag++ >= size) break; printhead(mp - &message[0] + 1, stdout, mb.mb_threaded); } mp = next_in_thread(mp); } } if (flag == 0) { printf(catgets(catd, CATSET, 6, "No more mail.\n")); return(1); } return(0); }
int main (void) #endif { struct mouse_info info; struct mouse_box full_box, small_box; unsigned char width, height; char C; bool Invisible = true, Done = false, Jailed = false; /* Initialize the debugger */ DbgInit (0); /* Set dark-on-light colors. Clear the screen. */ #ifdef __CBM__ (void) bordercolor (COLOR_GRAY2); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_GRAY1); #else (void) bordercolor (COLOR_BLUE); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_BLACK); #endif cursor (0); clrscr (); /* If a lightpen driver is installed, then it can get a calibration value ** from this file (if it exists). Or, the user can adjust the pen; and, ** the value will be put into this file, for the next time. ** (Other drivers will ignore this.) */ #if defined(__C64__) || defined(__C128__) || defined(__CBM510__) pen_adjust ("pen.dat"); #endif #if DYN_DRV /* If a dynamically loadable driver is named on the command line, ** then use that driver instead of the standard one. */ if (argc > 1) { mouse_name = argv[1]; } else { /* Output a warning about the standard driver that is needed. */ DoWarning (); mouse_name = mouse_stddrv; } /* Load and install the driver. */ CheckError ("mouse_load_driver", mouse_load_driver (&mouse_def_callbacks, mouse_name)); #else /* Install the driver. */ CheckError ("mouse_install", mouse_install (&mouse_def_callbacks, # ifdef MOUSE_DRIVER MOUSE_DRIVER # else mouse_static_stddrv # endif )); #endif /* Get the initial bounding box. */ mouse_getbox (&full_box); screensize (&width, &height); top: clrscr (); /* Print a help line */ cputs (" d)ebug h)ide q)uit s)how j)ail"); /* Put a cross at the center of the screen. */ gotoxy (width / 2 - 3, height / 2 - 1); #if defined(__CBM__) cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4, width / 2, ""); #else cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4, width / 2, ""); #endif /* Test loop */ ShowState (Jailed, Invisible); do { /* Get the current co-ordinates and button states; and, print them. */ mouse_info (&info); gotoxy (0, 2); cprintf (" X = %3d\r\n", info.pos.x); cprintf (" Y = %3d\r\n", info.pos.y); cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ? #ifdef __CBM__ 0x5F #else 'v' #endif : '^'); cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ? #ifdef __CBM__ 0x5F #else 'v' #endif : '^'); /* Handle user input */ if (kbhit ()) { cclearxy (1, 9, 23); switch (tolower (C = cgetc ())) { case 'd': BREAK(); /* The debugger might have changed the colors. ** Restore them. */ #ifdef __CBM__ (void) bordercolor (COLOR_GRAY2); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_GRAY1); #else (void) bordercolor (COLOR_BLUE); (void) bgcolor (COLOR_WHITE); (void) textcolor (COLOR_BLACK); #endif /* The debugger changed the screen; restore it. */ goto top; case 'h': mouse_hide (); ShowState (Jailed, ++Invisible); break; case 'j': if (Jailed) { mouse_setbox (&full_box); Jailed = false; } else { small_box.minx = max (info.pos.x - 10, full_box.minx); small_box.miny = max (info.pos.y - 10, full_box.miny); small_box.maxx = min (info.pos.x + 10, full_box.maxx); small_box.maxy = min (info.pos.y + 10, full_box.maxy); mouse_setbox (&small_box); Jailed = true; } ShowState (Jailed, Invisible); break; case 's': mouse_show (); if (Invisible) { ShowState (Jailed, --Invisible); } break; case 'q': Done = true; break; default: gotoxy (1, 9); cprintf ("Spurious character: $%02X", C); } } } while (!Done); #if DYN_DRV /* Uninstall and unload the driver. */ CheckError ("mouse_unload", mouse_unload ()); #else /* Uninstall the static driver. */ CheckError ("mouse_uninstall", mouse_uninstall ()); #endif /* Say goodbye */ cputsxy (0, height / 2 + 3, "Goodbye!"); return EXIT_SUCCESS; }
static void vgactl(char* a) { int align, i, n, size, x, y, z; char *chanstr, *field[6], *p; ulong chan; VGAscr *scr; extern VGAdev *vgadev[]; extern VGAcur *vgacur[]; Rectangle r; n = tokenize(a, field, nelem(field)); if(n < 1) error(Ebadarg); scr = &vgascreen[0]; if(strcmp(field[0], "hwgc") == 0){ if(n < 2) error(Ebadarg); if(strcmp(field[1], "off") == 0){ lock(&cursor); if(scr->cur){ if(scr->cur->disable) scr->cur->disable(scr); scr->cur = nil; } unlock(&cursor); return; } for(i = 0; vgacur[i]; i++){ if(strcmp(field[1], vgacur[i]->name)) continue; lock(&cursor); if(scr->cur && scr->cur->disable) scr->cur->disable(scr); scr->cur = vgacur[i]; if(scr->cur->enable) scr->cur->enable(scr); unlock(&cursor); return; } } else if(strcmp(field[0], "type") == 0){ if(n < 2) error(Ebadarg); for(i = 0; vgadev[i]; i++){ if(strcmp(field[1], vgadev[i]->name)) continue; if(scr->dev && scr->dev->disable) scr->dev->disable(scr); scr->dev = vgadev[i]; if(scr->dev->enable) scr->dev->enable(scr); return; } } else if(strcmp(field[0], "size") == 0){ if(n < 3) error(Ebadarg); if(drawhasclients()) error(Ebusy); x = strtoul(field[1], &p, 0); if(x == 0 || x > 2048) error(Ebadarg); if(*p) p++; y = strtoul(p, &p, 0); if(y == 0 || y > 2048) error(Ebadarg); if(*p) p++; z = strtoul(p, &p, 0); chanstr = field[2]; if((chan = strtochan(chanstr)) == 0) error("bad channel"); if(chantodepth(chan) != z) error("depth, channel do not match"); cursoroff(1); deletescreenimage(); if(screensize(x, y, z, chan)) error(Egreg); vgascreenwin(scr); cursoron(1); return; } else if(strcmp(field[0], "actualsize") == 0){ if(scr->gscreen == nil) error("set the screen size first"); if(n < 2) error(Ebadarg); x = strtoul(field[1], &p, 0); if(x == 0 || x > 2048) error(Ebadarg); if(*p) p++; y = strtoul(p, nil, 0); if(y == 0 || y > 2048) error(Ebadarg); if(x > scr->gscreen->r.max.x || y > scr->gscreen->r.max.y) error("physical screen bigger than virtual"); r = Rect(0,0,x,y); if(!eqrect(r, scr->gscreen->r)){ if(scr->cur == nil || scr->cur->doespanning == 0) error("virtual screen not supported"); } physgscreenr = r; return; } else if(strcmp(field[0], "palettedepth") == 0){ if(n < 2) error(Ebadarg); x = strtoul(field[1], &p, 0); if(x != 8 && x != 6) error(Ebadarg); scr->palettedepth = x; return; } else if(strcmp(field[0], "drawinit") == 0){ if(scr && scr->dev && scr->dev->drawinit) scr->dev->drawinit(scr); return; } else if(strcmp(field[0], "linear") == 0){ if(n < 2) error(Ebadarg); size = strtoul(field[1], 0, 0); if(n < 3) align = 0; else align = strtoul(field[2], 0, 0); if(screenaperture(size, align)) error("not enough free address space"); return; } /* else if(strcmp(field[0], "memset") == 0){ if(n < 4) error(Ebadarg); memset((void*)strtoul(field[1], 0, 0), atoi(field[2]), atoi(field[3])); return; } */ else if(strcmp(field[0], "blank") == 0){ if(n < 1) error(Ebadarg); drawblankscreen(1); return; } else if(strcmp(field[0], "blanktime") == 0){ if(n < 2) error(Ebadarg); blanktime = strtoul(field[1], 0, 0); return; } else if(strcmp(field[0], "hwaccel") == 0){ if(n < 2) error(Ebadarg); if(strcmp(field[1], "on") == 0) hwaccel = 1; else if(strcmp(field[1], "off") == 0) hwaccel = 0; return; } else if(strcmp(field[0], "hwblank") == 0){ if(n < 2) error(Ebadarg); if(strcmp(field[1], "on") == 0) hwblank = 1; else if(strcmp(field[1], "off") == 0) hwblank = 0; return; } error(Ebadarg); }