void _main(void) { LCD_BUFFER backbuffer; unsigned char buffer[100*5*4]; unsigned short i,j; LCD_save(backbuffer); ST_helpMsg("Sprite8Get() Demo - Press Key"); ngetchx(); for (j=0;j<64;j++) { for (i=0;i<20;i++) { Sprite8Get_R(j+(i<<3),0,100,backbuffer,((unsigned char*)buffer)+100*i); } ClrScr(); for (i=0;i<20;i++) { Sprite8_OR_R(i<<3,0,100,((unsigned char*)buffer)+100*i,LCD_MEM); } } ST_helpMsg("Sprite16Get() Demo - Press Key"); ngetchx(); for (j=0;j<64;j++) { for (i=0;i<10;i++) { Sprite16Get_R(j+(i<<4),0,100,backbuffer,((unsigned short*)buffer)+100*i); } ClrScr(); for (i=0;i<10;i++) { Sprite16_OR_R(i<<4,0,100,((unsigned short*)buffer)+100*i,LCD_MEM); } } ST_helpMsg("Sprite32Get() Demo - Press Key"); ngetchx(); for (j=0;j<64;j++) { for (i=0;i<5;i++) { Sprite32Get_R(j+(i<<5),0,100,backbuffer,((unsigned long*)buffer)+100*i); } ClrScr(); for (i=0;i<5;i++) { Sprite32_OR_R(i<<5,0,100,((unsigned long*)buffer)+100*i,LCD_MEM); } } LCD_restore(backbuffer); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
/*===========================================================================*/ void _main(void) { LCD_BUFFER screen; short retval; LCD_save(screen); OSFreeTimer(USER_TIMER); OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE); retval = Test8(); if (retval != KEY_ESC) retval=Test16(); if (retval != KEY_ESC) retval=Test32(); OSFreeTimer(USER_TIMER); LCD_restore(screen); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
void _main(void) { short l,c,k; void *vecran; LCD_BUFFER backbuffer; LCD_save(backbuffer); if(!(vecran=malloc(LCD_SIZE))) return; l=c=0; do { DrawTiles16B(MAP_WIDTH,&map[l][c],vecran,sprts); FastCopyScreen_R(vecran,LCD_MEM); /* memcpy(LCD_MEM,vecran,LCD_SIZE); */ k=ngetchx(); if(k==KEY_RIGHT && c<MAP_WIDTH-15) c++; if(k==KEY_LEFT && c>0) c--; if(k==KEY_DOWN && l<MAP_HEIGHT-8) l++; if(k==KEY_UP && l>0) l--; } while(k!=KEY_ESC); free(vecran); LCD_restore(backbuffer); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
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); }
//============================================================================= // as usual our main function ... //============================================================================= void _main(void) { LCD_BUFFER lcd; LCD_BUFFER doublebuffer; short i; short ball_to_update; INT_HANDLER oldint1 = GetIntVec(AUTO_INT_1); // fetch default interrupt handler INT_HANDLER oldint5 = GetIntVec(AUTO_INT_5); // fetch default interrupt handler // save screen LCD_save(lcd); // install dummy interrupt handlers for AUTO_INT1 and AUTO_INT5 SetIntVec(AUTO_INT_1,DUMMY_HANDLER); SetIntVec(AUTO_INT_5,DUMMY_HANDLER); do { // clear doublebuffer memset(doublebuffer,0,LCD_SIZE); for (i=0;i<NR_BALLS;i++) { // NOTE: DRAWSPRITE is a macro defined at the beginning of this file! DRAWSPRITE(balls[i].x,balls[i].y); } // copy double buffer to visible screen FastCopyScreen_R(doublebuffer,LCD_MEM); for (ball_to_update=0;ball_to_update<NR_BALLS;ball_to_update++) { // calculate new position of ball which should get updated CalcNewPosition(&balls[ball_to_update],max_x,max_y); // loop over all possible combinations and check for collision ... for (i=0;i<NR_BALLS;i++) { if (i==ball_to_update) continue; // don't check against myself // NOTE: TESTCOLLIDE is a macro defined at the beginning of this file! if (TESTCOLLIDE(balls[ball_to_update].newx,balls[ball_to_update].newy,balls[i].newx,balls[i].newy)) { // collision detected -> exchange dirx/diry of involved balls ExchangeDirections(&balls[ball_to_update],&balls[i]); // recalculate new position of ball which should get updated CalcNewPosition(&balls[ball_to_update],max_x,max_y); // if we still stick together than this opponent then this // is not the right target to change my direction ... if (TESTCOLLIDE(balls[ball_to_update].newx,balls[ball_to_update].newy,balls[i].newx,balls[i].newy)) { ExchangeDirections(&balls[ball_to_update],&balls[i]); CalcNewPosition(&balls[ball_to_update],max_x,max_y); } } } // NOTE: this demo is somewhat sloppy. Normally we should not // proceed if a collision is detected AND we shouldn't do the // VERY simple collision detection routine above. // But I don't care about this. It seems to be good enough // to demonstrate the bouncing balls ... balls[ball_to_update].x = balls[ball_to_update].newx; balls[ball_to_update].y = balls[ball_to_update].newy; } } while (!EscapePressed()); // restore old interrupt handlers SetIntVec(AUTO_INT_1,oldint1); SetIntVec(AUTO_INT_5,oldint5); // restore screen LCD_restore(lcd); // empty the keyboard buffer and write "powered by ..." string GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
// Main Function void _main(void) { signed char STATUS, a; int plinkos; unsigned char *Home = malloc(LCD_SIZE); // Allocate the SAVE_SCREEN buffer if (Home == NULL) { Error_Memory(); return; } LCD_save(Home); // Save LCD HomeScreen Contents virtual_dark = malloc ( LCD_SIZE ); // Allocate the dark buffer if (virtual_dark == NULL) {Error_Memory(); return; } virtual_light=malloc ( LCD_SIZE ); // Allocate the light buffer if (virtual_light == NULL) { free(virtual_dark); Error_Memory(); return; } randomize(); if (Gray_prep() == QUIT) { Error_Memory(); goto end; } if (makefile() == QUIT) // Tests whether or not we need a default save file and installs one if the // user doesn't already have one on their calc goto end; for(a = 10; a--;) FADE_LIGHTER(); // Clears both Hidden Gray planes ClearGrayScreen2B(Hiddenl, Hiddend); GraySpriteX8_OR(52, 37, 27, titlel, titled, 7, Hiddenl, Hiddend); FontSetSys (F_4x6); GrayDBufSetHiddenAMSPlane (DARK_PLANE); DrawStr(122, 94, "-- By Fisch", A_NORMAL); GrayDBufSetHiddenAMSPlane (LIGHT_PLANE); DrawStr(123, 95, "-- By Fisch", A_NORMAL); GrayDBufToggleSync(); // switches two sets of planes for(a = 10; a--;) FADE_DARKER(); Waitkey(); NEW_GAME: if ((STATUS = MENU()) == QUIT) goto end; if ((plinkos = PRODUCTS()) == QUIT) goto end; if ((STATUS = INTRO()) == QUIT) goto end; if ((STATUS = main_game(plinkos)) == QUIT) goto end; goto NEW_GAME; end: // Clean up at end of Program Cleanup(); if (Home) { LCD_restore(Home); free(Home); GKeyFlush(); ST_helpMsg("Plinko --By Travis Fischer"); } }
/*===========================================================================*/ 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); }