void _main(void) { GrayOn(); clrscr(); GraySprite16_XOR_R(8, 8, 16, ball_C0, ball_C1, GetPlane(0), GetPlane(1)); ngetchx(); GrayOff(); }
static inline int Gray_prep(void) { // turn interrupts off and set up a fake interrupt for graymode to use. interrupt1 = GetIntVec(AUTO_INT_1); SetIntVec(AUTO_INT_1, DUMMY_HANDLER); if (!GrayOn()) return QUIT; dbuffer = malloc(GRAYDBUFFER_SIZE); // allocate space for double-buffering if (!dbuffer) return QUIT; GrayDBufInit(dbuffer); // enable double-buffering return 0; }
void _main(void) { INT_HANDLER int1 = GetIntVec(AUTO_INT_1); INT_HANDLER int5 = GetIntVec(AUTO_INT_5); SetIntVec(AUTO_INT_1, DUMMY_HANDLER); SetIntVec(AUTO_INT_5, DUMMY_HANDLER); GrayOn(); //// everything above is just magic, you need it but //don't need to understand it. clrscr(); Sprite8(0,0,8,square,GetPlane(0),SPRT_XOR); Sprite8(8,0,8,square,GetPlane(1),SPRT_XOR); Sprite8(16,0,8,square,GetPlane(0),SPRT_XOR); Sprite8(16,0,8,square,GetPlane(1),SPRT_XOR); while(!_keytest(RR_ENTER)); GrayOff(); SetIntVec(AUTO_INT_1, int1); SetIntVec(AUTO_INT_5, int5); }
// allocate and set up stuff void init() { // start the random number generator randomize(); // allocate our graphic buffers buffermem = malloc(LCD_WIDTH * LCD_HEIGHT * 2); // not enough RAM if (!buffermem) error(LC_MEMORY_ERROR_TEXT); lightbuffer = buffermem; darkbuffer = buffermem + LCD_WIDTH * LCD_HEIGHT; // quit if we can't switch to grayscale if (!GrayOn()) error(LC_GRAYSCALE_ERROR_TEXT); // clear the screen ClrScr(); // get the grayscale plane pointers lightplane = GrayGetPlane(LIGHT_PLANE); darkplane = GrayGetPlane(DARK_PLANE); }
void _main(void) { INT_HANDLER ai1,ai5; void *bloc=malloc(BIG_VSCREEN_SIZE*2+LCD_SIZE*2); // 1 big_vscreen et 1 écran virtuel void *vecran,*big_vscreen; LCD_BUFFER backbuffer; LCD_save(backbuffer); if(!bloc) return; // Initialisations vecran=bloc; big_vscreen=bloc+LCD_SIZE*2; ai1=GetIntVec(AUTO_INT_1); ai5=GetIntVec(AUTO_INT_5); SetIntVec(AUTO_INT_1,DUMMY_HANDLER); SetIntVec(AUTO_INT_5,DUMMY_HANDLER); if(GrayOn()) { RenderMaps(big_vscreen,vecran); GrayOff(); } SetIntVec(AUTO_INT_1,ai1); SetIntVec(AUTO_INT_5,ai5); free(bloc); LCD_restore(backbuffer); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
// Main Function void _main(void) { // This is where the level map is defined // The map is 12 blocks of height 8 tall, and that fills the screen // 0s are blank, 1s are ground blocks, and 2s are the other blocks /*int map1[12][82] = { {0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2,2,2,0,0,0,2,2,2,2,2,2,2,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0}, {0,0,0,2,0,0,0,0,2,2,0,0,0,2,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,2,0,0,0,2,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,2,0,0,2,0,0,2,2,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,2,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0}, {0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,2,0,2,0,2,0,2,2,2,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,0,0,0,0,0,0,0,2,0,2,0,2,0,2,2,2,0,0,0}, {0,0,0,0,0,0,0,0,0,0,2,2,2,0,2,0,0,0,2,0,0,2,2,0,0,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,2,0,0,0,2,0,0,2,2,0,0,0,0,0,2,2,0,2,0,2,0,2,0,0,0,0,0}, {0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,2,0,0,0,2,0,2,2,2,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,2,0,0,0,2,0,2,2,2,0,0,0}, {0,0,0,0,0,0,0,0,0,0,2,2,2,0,2,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,2,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,0,0,0,2,0,2,0,0,0,0,0}, {0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,2,2,0,2,2,0,0,0,0,0,0,0,2,2,0,2,0,2,2,2,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,2,2,0,2,2,0,0,0,0,0,0,0,2,2,0,2,0,2,2,2,0,0,0}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};*/ int map1[12][20] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {8,7,0,0,0,9,7,9,7,0,0,0,0,0,9,8,8,8,8,8}, {0,0,7,0,9,0,0,0,0,7,0,0,0,9,0,0,0,0,0,0}, {0,0,0,8,0,0,0,0,0,0,7,0,9,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,9,7,0,0}, {0,0,0,0,0,0,0,9,7,0,0,0,0,0,0,9,0,0,7,0}, {0,9,8,8,7,0,9,0,0,7,0,0,0,0,9,0,0,0,0,8}, {8,0,0,0,0,8,0,0,0,0,7,0,0,9,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,7,9,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; int key=0; int laser = 0; int justLaser = 0; int missile = 0; int justMissile = 0; int missileSlow = 2; short int keys[8]; POSITION laserPos; POSITION oldLaserPos; POSITION missilePos; POSITION oldMissilePos; POSITION oldRType; POSITION rTypePos = {0,4}; int score = 0; int forward = 0; //int map_x_location=0; //POSITION pos = {80,5}; //int pos = 0; INT_HANDLER interrupt1 = GetIntVec(AUTO_INT_1); // this will save auto int 1 // print a simple title and disclaimer clrscr(); printf("A game by Ben Cherry \nversion 0.2 Beta \nUse at your own risk! \nreport any bugs to me\nArrow keys - move ship\n2nd-fire straight laser\ndiamond-fire down missile\nDestroy the blocks!\nGame may become unstable\npast the ground raise!\nPress Enter to Begin"); while (ngetchx() != KEY_ENTER){} clrscr(); // seed the random numbers randomize(); // get the key masks getKeyMasks(keys); // DESTROY auto-interrupt 1 so as not to mess up _rowread SetIntVec(AUTO_INT_1,DUMMY_HANDLER); if (!GrayOn ()) return; Draw_Map(map1, rTypePos, laserPos, laser, missilePos, missile); // the main game loop while (!quit()) { // if the user has a missile out, deal with it if (missile && missileSlow == 2) { missileSlow = 1; oldMissilePos = missilePos; missilePos.x++; missilePos.y++; if (missilePos.x > 20) missile = 0; if (blowWall(missilePos,map1)) { map1[missilePos.y][missilePos.x]-=2;//= 0; /**/score++; /**/if (map1[missilePos.y][missilePos.x] < 0) map1[missilePos.y][missilePos.x] = 0; missile = 0; justMissile = 0; Draw_Map(map1,rTypePos,laserPos,laser,missilePos,missile); } // if the shot was just fired, then there wont be one to erase if (!justMissile && missile) { moveMissile(oldMissilePos,missilePos); } else if (missile) { drawMissile(missilePos); justMissile = 0; } } else { missileSlow++; } // if the user has a laser shot that is still going, continue it if (laser) { oldLaserPos = laserPos; laserPos.x++; if (laserPos.x > 20) laser=0; if (blowWall(laserPos,map1)) { map1[laserPos.y][laserPos.x]--; //= 0; /**/if (map1[laserPos.y][laserPos.x] == 0) score++; laser = 0; justLaser = 0; Draw_Map(map1,rTypePos,laserPos,laser, missilePos, missile); } // if the shot was just fired, then there wont be one to erase if (!justLaser && laser) { moveLaser(oldLaserPos,laserPos); } else if (laser){ drawLaser(laserPos); justLaser = 0; } } // scroll the screen forward one block every third time through the main loop if (forward == 3) { randMap(&map1); //rTypePos.x++; forward = 0; Draw_Map(map1,rTypePos,laserPos,laser, missilePos, missile); } else { forward++; } // if you ran into a wall, quit if (detectWall(rTypePos,map1)) break; key = _rowread(ARROW_ROW); // if the user pressed right, move the ship right if (key & keys[RIGHT]) { oldRType = rTypePos; rTypePos.x++; if (rTypePos.x > 20) rTypePos.x--; if (!detectWall(rTypePos,map1)){ moveRType(oldRType,rTypePos); } else { //rTypePos.x--; break; } } // If the user pressed left, move the ship left if (key & keys[LEFT]) { oldRType = rTypePos; //rTypePos.x--; if (rTypePos.x - 1 >= 0) rTypePos.x--; if (!detectWall(rTypePos,map1)){ moveRType(oldRType,rTypePos); } else { //rTypePos.x++; break; } } // if the user pressed up, move the ship up if (key & keys[UP]) { oldRType = rTypePos; //rTypePos.y--; if (rTypePos.y - 1 >= 0) rTypePos.y--; if (!detectWall(rTypePos,map1)) { moveRType(oldRType,rTypePos); } else { //rTypePos.y++; break; } } // if the user pressed down, move the ship down if (key & keys[DOWN]) { oldRType = rTypePos; rTypePos.y++; if (rTypePos.y > 12) rTypePos.y = 12; if (!detectWall(rTypePos,map1)) { moveRType(oldRType,rTypePos); } else { //rTypePos.y--; break; } } // if 2nd was pushed, fire the laser if (key & keys[SECOND]) { if (!laser) { justLaser = 1; laser = 1; laserPos.x = rTypePos.x + 1; laserPos.y = rTypePos.y; } } // if diamond was pushed fire the downward missiles if (key & keys[DIAMOND]) { if (!missile) { justMissile = 1; missile = 1; missileSlow = 2; missilePos.x = rTypePos.x; missilePos.y = rTypePos.y; } } // slow down the program because _rowread is too fast delay(); } // somehow the user left the game, either by crashing or quitting, so make sure to disable all changes GrayOff(); SetIntVec(AUTO_INT_1,interrupt1); clrscr(); printf("You destroyed %d blocks!",score); while (ngetchx() != KEY_ENTER){} }
// the main function void _main(void) { unsigned int difficulty = NORMAL; short int key=0; short int keys[8]; unsigned int level_num = 1; unsigned short int score = 0; int done = 0; unsigned int money = 0; int cannon_level = 1; int missile_level = 0; char map[12][MAP_SIZE]; // seed the random numbers randomize(); // get the key masks getKeyMasks(keys); INT_HANDLER interrupt1 = GetIntVec(AUTO_INT_1); // this will save auto int 1 // draw title screen and wait for keypress GrayOn(); drawTitle(2); ngetchx(); //draw background title screen and menu drawTitle(1); drawWords(difficulty); POSITION pointer = {10,0}; drawPointer(pointer); // the menu loop while (1) { key = ngetchx(); if (key == KEY_ENTER && pointer.y != OPTIONS) { if (pointer.y == PLAY) break; if (pointer.y == HIGH_SCORES) printHiScores(); if (pointer.y == HELP) doHelp(); if (pointer.y == ABOUT) { SetIntVec(AUTO_INT_1,interrupt1); GrayOff(); exit(0); } GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); clrscr(); drawTitle(1); drawWords(difficulty); pointer=(POSITION) { 10,0 }; drawPointer(pointer); } if (key == KEY_LEFT && pointer.y == OPTIONS && difficulty < VERY_EASY) { difficulty+=1; GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); clrscr(); drawTitle(1); drawPointer(pointer); drawWords(difficulty); } if (key == KEY_RIGHT && pointer.y == OPTIONS && difficulty > IMPOSSIBLE) { difficulty-=1; GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); clrscr(); drawTitle(1); drawPointer(pointer); drawWords(difficulty); } if (key == KEY_UP || key == KEY_DOWN) drawPointer(pointer); if (key == KEY_UP && pointer.y > 0) pointer.y--; if (key == KEY_DOWN && pointer.y < 4) pointer.y++; if (key == KEY_UP || key == KEY_DOWN) drawPointer(pointer); } key = 0; // turn off gray, so we can destroy auto-int-1 and not mess it up GrayOff(); // DESTROY auto-interrupt 1 so as not to mess up _rowread SetIntVec(AUTO_INT_1,DUMMY_HANDLER); // turn gray back on GrayOn(); // randomize the map randomMap(difficulty, map, level_num); //the main game loop while (!quit() && !done) { done = 0; int fin = 0; int win = 0; int forward = 0; int map_x_location = 0; int laser = 0; int justLaser = 0; int missile = 0; int justMissile = 0; int missileSlow = 2; POSITION laserPos; POSITION oldLaserPos; POSITION missilePos; POSITION oldMissilePos; POSITION oldShip; POSITION ShipPos = {0,5}; // we need to disable gray temporarily to do the shop screen... GrayOff(); SetIntVec(AUTO_INT_1, interrupt1); shop(&money, &cannon_level, &missile_level); SetIntVec(AUTO_INT_1, DUMMY_HANDLER); GrayOn(); // draws the level Draw_Map(map_x_location, map, ShipPos, laserPos, laser, missilePos, missile); // the loop for the action in the level while (!quit()) { // if the user has a missile out, deal with it if (missile && missileSlow == 2) { missileSlow = 1; oldMissilePos = missilePos; missilePos.x++; missilePos.y+=missile; if (missilePos.x > map_x_location + 20) missile = 0; if (missilePos.y < 0 || missilePos.y > 12) { missile = 0; eraseMissile(missilePos, map_x_location); } if (blowWall(missilePos,map)) { if (map[missilePos.y][missilePos.x] < 4) { map[missilePos.y][missilePos.x]-=3; if (map[missilePos.y][missilePos.x] == 0) { score++; money+=BLOCK_VALUE; } } if (map[missilePos.y][missilePos.x] < 0) map[missilePos.y][missilePos.x] = 0; missile = 0; justMissile = 0; Draw_Map(map_x_location,map,ShipPos,laserPos,laser,missilePos,missile); } // if the shot was just fired, then there wont be one to erase if (!justMissile && missile == 1) { moveMissile(oldMissilePos,missilePos,map_x_location); } else if (missile == 1) { drawMissile(missilePos,map_x_location); justMissile = 0; } else if (!justMissile && missile == -1) { moveUpMissile(oldMissilePos, missilePos, map_x_location); } else if (missile == -1) { drawUpMissile(missilePos, map_x_location); justMissile = 0; } } else { missileSlow++; } // if the user has a laser shot that is still going, continue it if (laser) { oldLaserPos = laserPos; laserPos.x++; if (laserPos.x > map_x_location + 20) laser=0; if (blowWall(laserPos,map)) { if (map[laserPos.y][laserPos.x] < 4) { map[laserPos.y][laserPos.x]-=cannon_level; if (map[laserPos.y][laserPos.x] <= 0) { score++; money+=BLOCK_VALUE; map[laserPos.y][laserPos.x] = 0; } } else if (map[laserPos.y][laserPos.x] == 4 && cannon_level == 4) { map[laserPos.y][laserPos.x] = 1; } laser = 0; justLaser = 0; Draw_Map(map_x_location,map,ShipPos,laserPos,laser, missilePos, missile); } // if the shot was just fired, then there wont be one to erase if (!justLaser && laser) { moveLaser(oldLaserPos,laserPos,map_x_location); } else if (laser) { drawLaser(laserPos,map_x_location); justLaser = 0; } } // scroll the screen forward one block every (difficulty) time through the main loop if (forward == difficulty) { map_x_location++; ShipPos.x++; forward = 0; if (map_x_location >= MAP_SIZE - 20) { win = 1; level_num++; break; } // if you ran into a wall, quit if (detectWall(ShipPos,map)) { win = 1; score /= 2 ; break; } Draw_Map(map_x_location,map,ShipPos,laserPos,laser, missilePos, missile); } else { forward++; } // if you ran into a wall, quit if (detectWall(ShipPos,map)) { win = 1; score = 0; break; } if (_rowread(~((short)(1<<1))) & (1<<6) && _rowread(~((short)(1<<2))) & (1<<6)) { win = 1; level_num++; break; } // get keypresses key = _rowread(ARROW_ROW); // if the user pressed right, move the ship right if (key & keys[RIGHT]) { oldShip = ShipPos; ShipPos.x++; if (ShipPos.x > map_x_location + 18) ShipPos.x--; if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // If the user pressed left, move the ship left if (key & keys[LEFT]) { oldShip = ShipPos; ShipPos.x--; if (ShipPos.x < map_x_location) ShipPos.x++; if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // if the user pressed up, move the ship up if (key & keys[UP]) { oldShip = ShipPos; if (ShipPos.y - 1 < 0) { ShipPos.y = 0; } else { ShipPos.y--; } if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // if the user pressed down, move the ship down if (key & keys[DOWN]) { oldShip = ShipPos; ShipPos.y++; if (ShipPos.y > 10) ShipPos.y = 10; if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // if 2nd was pushed, fire the laser if (key & keys[SECOND]) { if (!laser) { justLaser = 1; laser = 1; laserPos.x = ShipPos.x + 1; laserPos.y = ShipPos.y; } } // if diamond was pushed fire the downward missiles if (key & keys[DIAMOND]) { if (missile_level == 3 || missile_level == 1) { if (!missile) { justMissile = 1; missile = 1; missileSlow = 2; missilePos.x = ShipPos.x; missilePos.y = ShipPos.y; } } } // if shift was pushed fire the upward missiles if (key & keys[SHIFT]) { if (missile_level == 2 || missile_level == 3) { if (!missile) { justMissile = 1; missile = -1; missileSlow = 2; missilePos.x = ShipPos.x; missilePos.y = ShipPos.y; } } } /*if (key & keys[ALPHA]) { score += 10; }*/ // slow down the program because _rowread is too fast delay(); } // back to the overall game loop if (win) { if (level_num <= LEVEL_NUM) { won(difficulty, map, level_num); } else { fin = 1; break; } } } // the user left, either by winning or quitting, so make sure everything is reset so the calc will be fine GrayOff(); SetIntVec(AUTO_INT_1,interrupt1); hiScoresGo(score, difficulty, level_num); }
/*===========================================================================*/ void _main(void) { short i,j; unsigned long measure_val; char tmpstr[50] = "Measuring, please wait ..."; static const short modes[4] = {COLOR_LIGHTGRAY,COLOR_DARKGRAY,COLOR_BLACK,COLOR_WHITE}; unsigned short clippedcoord[4]; LCD_BUFFER screen; LCD_save(screen); OSFreeTimer(USER_TIMER); OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE); if (!GrayOn()) goto end; //--------------------------------------------------------------------- // built-in OS line drawing routine ... //--------------------------------------------------------------------- GrayClearScreen_R(); OSTimerRestart(USER_TIMER); for (j=0;j<4;j++) { short used_color = modes[j]; for (i=-40; i<280;i++) GrayDrawClipLine(120,64,i,-40,used_color); for (i=-40; i<168;i++) GrayDrawClipLine(120,64,280,i,used_color); for (i=280;i>=-40; i--) GrayDrawClipLine(120,64,i,168,used_color); for (i=168;i>=-40; i--) GrayDrawClipLine(120,64,-40,i,used_color); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"OS routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); GrayDrawRect(0,0,239,7,COLOR_WHITE,RECT_FILLED); GrayDrawStrExt(0,0,tmpstr,A_NORMAL | A_CENTERED | A_SHADOWED,F_4x6); if (ngetchx() == KEY_ESC) goto end; //--------------------------------------------------------------------- // new line drawing routine ... //--------------------------------------------------------------------- GrayClearScreen_R(); OSTimerRestart(USER_TIMER); for (j=0;j<4;j++) { short used_color = modes[j]; for (i=-40; i<280;i++) GrayClipDrawLine_R(120,64,i,-40,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R); for (i=-40; i<280;i++) GrayClipDrawLine_R(120,64,280,i,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R); for (i=280;i>=-40; i--) GrayClipDrawLine_R(120,64,i,168,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R); for (i=168;i>=-40; i--) GrayClipDrawLine_R(120,64,-40,i,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"Own routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); GrayDrawRect(0,0,239,7,COLOR_WHITE,RECT_FILLED); GrayDrawStrExt(0,0,tmpstr,A_NORMAL | A_CENTERED | A_SHADOWED,F_4x6); if (ngetchx() == KEY_ESC) goto end; GrayOff(); ClrScr(); //--------------------------------------------------------------------- // built-in OS line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<4;j++) { WIN_RECT rect = {120, 64, 0, -40}; for (i=-40; i<280;i++) {rect.x1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); } for (i=-40; i<168;i++) {rect.y1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); } for (i=280;i>=-40; i--) {rect.x1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); } for (i=168;i>=-40; i--) {rect.y1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"OS routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); GrayDrawRect2B(0,0,239,7,COLOR_WHITE,RECT_FILLED,LCD_MEM,LCD_MEM); GrayDrawStrExt2B(0,0,tmpstr,A_NORMAL | A_CENTERED,F_4x6,LCD_MEM,LCD_MEM); if (ngetchx() == KEY_ESC) goto end; //--------------------------------------------------------------------- // new line drawing routine ... //--------------------------------------------------------------------- ClrScr(); OSTimerRestart(USER_TIMER); for (j=0;j<4;j++) { for (i=-40; i<280;i++) ClipDrawLine_R(120,64,i,-40,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R); for (i=-40; i<280;i++) ClipDrawLine_R(120,64,280,i,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R); for (i=280;i>=-40; i--) ClipDrawLine_R(120,64,i,168,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R); for (i=168;i>=-40; i--) ClipDrawLine_R(120,64,-40,i,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"Own routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); GrayDrawRect2B(0,0,239,7,COLOR_WHITE,RECT_FILLED,LCD_MEM,LCD_MEM); GrayDrawStrExt2B(0,0,tmpstr,A_NORMAL | A_CENTERED,F_4x6,LCD_MEM,LCD_MEM); ngetchx(); end: OSFreeTimer(USER_TIMER); GrayOff(); LCD_restore(screen); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
/*===========================================================================*/ void _main(void) { short i,j; unsigned long measure_val; char tmpstr[50] = "Measuring, please wait ..."; short modes[4] = {COLOR_LIGHTGRAY,COLOR_DARKGRAY,COLOR_BLACK,COLOR_WHITE}; LCD_BUFFER screen; LCD_save(screen); if (!GrayOn()) return; OSFreeTimer(USER_TIMER); OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE); GrayClearScreen_R(); GrayDrawStrExt(0,0,tmpstr,A_REPLACE|A_CENTERED|A_SHADOWED,F_4x6); do { //--------------------------------------------------------------------- // built-in OS line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<4 && !kbhit();j++) { short used_color = modes[j]; for (i=0; i<160;i++) GrayDrawLine(80,50,i,8, used_color); for (i=8; i<100;i++) GrayDrawLine(80,50,159,i, used_color); for (i=159;i>=0; i--) GrayDrawLine(80,50,i,99, used_color); for (i=99; i>=8; i--) GrayDrawLine(80,50,0,i, used_color); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"OS routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); GrayDrawRect(0,0,239,7,COLOR_WHITE,RECT_FILLED); GrayDrawStrExt(0,0,tmpstr,A_REPLACE | A_CENTERED | A_SHADOWED,F_4x6); if (kbhit()) break; //--------------------------------------------------------------------- // new line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<4 && !kbhit();j++) { short used_color = modes[j]; for (i=0; i<160;i++) GrayFastDrawLine2B_R(GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),80,50,i,8, used_color); for (i=8; i<100;i++) GrayFastDrawLine2B_R(GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),80,50,159,i, used_color); for (i=159;i>=0; i--) GrayFastDrawLine2B_R(GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),80,50,i,99, used_color); for (i=99; i>=8; i--) GrayFastDrawLine2B_R(GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),80,50,0,i, used_color); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"Own routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); GrayDrawRect(0,0,239,8,COLOR_WHITE,RECT_FILLED); GrayDrawStrExt(0,0,tmpstr,A_REPLACE | A_CENTERED | A_SHADOWED,F_4x6); } while (!kbhit()); ngetchx(); OSFreeTimer(USER_TIMER); GrayOff(); LCD_restore(screen); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }