// Main Function void _main(void) { ST_helpMsg("F800+rom idx FLINE executed"); //ST_helpMsg is automatically a fline instuction due to USE_FLINE_ROM_CALLS ngetchx(); //asm(".word 0xF800+0x29b"); //idle asm(" TestBsr: .word 0xFFF0 .long (TestBsrFunc-TestBsr)-2 bra BsrTestFinished TestBsrFunc: rts BsrTestFinished: "); ST_helpMsg("$FFF0 FLINE executed");ngetchx(); asm("bra TestBra"); asm("retBra:"); ST_helpMsg("$FFF1 FLINE executed");ngetchx(); asm(".word 0xFFF2 .word 0x19E*4 /* ClrScr */"); ST_helpMsg("FFF2 index*4 FLINE executed");ngetchx(); }
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) { short i,j; unsigned long measure_val; char tmpstr[50] = "Measuring, please wait ..."; short modes[6] = { A_REPLACE,A_XOR,A_REVERSE,A_XOR,A_REPLACE,A_REVERSE}; LCD_BUFFER screen; LCD_save(screen); FontSetSys(F_4x6); OSFreeTimer(USER_TIMER); OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE); ClearScreen(); DrawStr(0,0,tmpstr,A_REPLACE); do { //--------------------------------------------------------------------- // built-in OS line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<6 && !kbhit();j++) { short used_mode = modes[j]; for (i=0; i<160;i++) DrawLine(80,50,i,8, used_mode); for (i=8; i<100;i++) DrawLine(80,50,159,i, used_mode); for (i=159;i>=0; i--) DrawLine(80,50,i,99, used_mode); for (i=99; i>=8; i--) DrawLine(80,50,0,i, used_mode); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"OS Routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); memset(LCD_MEM,0,30*8); DrawStr(0,0,tmpstr,A_REPLACE); if (kbhit()) break; //--------------------------------------------------------------------- // new line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<6 && !kbhit();j++) { short used_mode = modes[j]; for (i=0; i<160;i++) FastDrawLine_R(LCD_MEM,80,50,i,8, used_mode); for (i=8; i<100;i++) FastDrawLine_R(LCD_MEM,80,50,159,i, used_mode); for (i=159;i>=0; i--) FastDrawLine_R(LCD_MEM,80,50,i,99, used_mode); for (i=99; i>=8; i--) FastDrawLine_R(LCD_MEM,80,50,0,i, used_mode); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"Own Routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); memset(LCD_MEM,0,30*8); DrawStr(0,0,tmpstr,A_REPLACE); } while (!kbhit()); ngetchx(); OSFreeTimer(USER_TIMER); LCD_restore(screen); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
/*===========================================================================*/ void _main(void) { #define bsize (100*20+4) // Size of a bitmap for a 160x100 screen. int i; LCD_BUFFER lcd; static const SCR_RECT theScreen = {{0,0,159,99}}; unsigned char sscreen[bsize]; unsigned char sscreen2[bsize]; LCD_save(lcd); BitmapGet(&theScreen,sscreen); memset(sscreen2,0,bsize); ((BITMAP*)sscreen2)->NumRows=((BITMAP*)sscreen)->NumRows; ((BITMAP*)sscreen2)->NumCols=((BITMAP*)sscreen)->NumCols; GKeyFlush(); for (i = 0; (i <= 360) && (!kbhit()); i++) { RotateSpriteX8_R(((BITMAP*)sscreen)->Data,((BITMAP*)sscreen2)->Data,160,100,80,50,i); ClrScr(); FastCopyScreen160to240_R(100,((BITMAP*)sscreen2)->Data,LCD_MEM); } LCD_restore(lcd); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); #undef bsize }
void __attribute__ ((noreturn)) Error(FILE *fp) { if (fp != NULL) fclose(fp); ST_helpMsg("Error creating 'sumogfx' File"); exit(1); }
/*===========================================================================*/ 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); }
// \/ //there is an address error somewhere in this routine. static void ScrollFromTop(WINDOW *w, HEX_DAT *d) { WIN_RECT wr={ 0, 0, 0, 0 }; BACKGROUND_DAT *bg=&gBGDAT; USHORT result_top; USHORT result_bottom; USHORT *ptr; char buff[150]; DASM_DAT dasm; wr.x1=WinWidth(w); wr.y1=ScrollFromBottom_helper+C(6-1,8-1); if((ULONG)bg->baseaddr && (ULONG)d->top>(ULONG)bg->baseaddr && bg->hOffsetTable) { ptr=HeapDeref(bg->hOffsetTable); result_top=bsearch(ptr, (ULONG)d->top - (ULONG)bg->baseaddr, bg->entries-1); result_bottom=bsearch(ptr, (ULONG)bottom_addr - (ULONG)bg->baseaddr, bg->entries-1); if(result_top==USHRT_MAX || result_bottom==USHRT_MAX) { d->top-=2; WinPaint(w, d); #ifdef DEBUG ST_helpMsg("Address Not In Buffer."); #endif return; } if(result_top) { result_top--; //the previous instruction result_bottom--; } d->top=(char*)&bg->baseaddr[ptr[result_top]>>1]; bottom_addr=(char*)&bg->baseaddr[ptr[result_bottom]>>1]; WinScrollV(w, &wr, C(-6,-8)); disassemble_one((unsigned short*)d->top, &dasm); sprintf(buff, "%lx%s", d->top, dasm.text); WinStrXY(w, 1, 1, buff); }
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); }
/*===========================================================================*/ static inline short Test32(void) { unsigned long measure_val; char tmpstr[100]; short x,y; long count; //------------------------------------------------------------------------- // original sprite functions //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32(x,y,8,spritedata32,LCD_MEM,SPRT_AND); Sprite32(x,y,8,spritedata32,LCD_MEM,SPRT_OR); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"TIGCCLIB AND+OR: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; #if __TIGCCLIB_VERSION__ >= 272 //------------------------------------------------------------------------- // original sprite functions with RPLC (GCC4TI 0.96 Beta 10+) //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32(x,y,8,spritedata32,LCD_MEM,SPRT_RPLC); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"TIGCCLIB RPLC: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; #endif //------------------------------------------------------------------------- // modified sprite functions using separate and/or //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32_AND_R(x,y,8,spritedata32,LCD_MEM); Sprite32_OR_R(x,y,8,spritedata32,LCD_MEM); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"ExtGraph AND+OR: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; //------------------------------------------------------------------------- // modified sprite functions using just one call //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32_MASK_R(x,y,8,spritedata32,spritedata32,LCD_MEM); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"ExtGraph MASK: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32_BLIT_R(x,y,8,spritedata32,0x00000000,LCD_MEM); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"ExtGraph BLIT: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32_RPLC_R(x,y,8,spritedata32,LCD_MEM); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"ExtGraph RPLC: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; //------------------------------------------------------------------------- // original sprite functions //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32(x,y,8,spritedata32,LCD_MEM,SPRT_XOR); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"TIGCCLIB AND+OR: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); if (ngetchx() == KEY_ESC) return KEY_ESC; //------------------------------------------------------------------------- // modified sprite functions using just one call //------------------------------------------------------------------------- count = 0; ClrScr(); OSTimerRestart(USER_TIMER); for (y=0;y<100-16;y++) { for (x=0;x<160-32;x++) { count++; Sprite32_XOR_R(x,y,8,spritedata32,LCD_MEM); } } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"ExtGraph XOR: %lu ticks for %ld sprites",INITIAL_TIMER_VALUE-measure_val,count); ST_helpMsg(tmpstr); return ngetchx(); }
// 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 Error_Memory(void) { ST_helpMsg("Error, Not Enough Memory. Free up RAM"); }
/*===========================================================================*/ 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); }
// Main Function void _main(void) { ST_helpMsg("Saving external data, please wait..."); UnArchive("sumogfx"); FILE *fp = fopen("sumogfx", "wb"); if (!fp) Error(NULL); /* Write all Graphics Data into the 'sumodat' File */ //#define Write(x) printf("%lu\n", sizeof(x)); ngetchx(); #define Write(x) ({ Putshort(sizeof((x)), fp); if (fwrite((x), sizeof((x)), 1, fp) != 1) {Error(fp);} }) Write(stomp1); Write(stomp2); Write(stomp3); Write(salt1); Write(salt3); Write(kneel1); Write(kneel3); Write(kneel5); Write(tackle1); Write(tackle3); Write(walk1); Write(walk3); Write(charge1); Write(charge3); Write(tumble1); Write(tumble2); Write(tumble3); Write(tumble4); Write(spinn1); Write(spinn3); Write(tossbackleft); Write(pummel1); Write(pummelpush1); Write(pummellift1); Write(pummellift3); Write(pummellift5); Write(earthquake_throwleft); Write(shoveleft); Write(shovedright); Write(shovedleftedge1); Write(shovedleftedge2); Write(pummelthrowleft); Write(throwleft); Write(thrownright); Write(pummelthrowcounter1); Write(punchleft1); Write(punchleft2); Write(punchedleft1); Write(punchedleft2); Write(tauntleft1); Write(tauntleft2); Write(laughing1); Write(laughing2); Write(sumoeating1); Write(sumoeating2); Write(sweepingleft); Write(smushedleft); Write(bellyflopleft1); Write(bellyflopleft2); Write(backwardsslamleft1); Write(backwardsslamleft2); Write(slammed); Write(Ring_Matrix); Write(ring_sprites); // Put the extension "gfx" onto the Graphics File and close it fputc(0, fp); fputs("gfx", fp); fputc(0, fp); fputc(OTH_TAG, fp); fclose(fp); Archive("sumogfx"); // Archive the Configuration File ST_helpMsg("External Data File 'sumogfx' created"); }
//============================================================================= // 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 ){ //Create or load savefile SAVE gameState; if(readSave(&gameState)) makeSave(&gameState); writeSave(&gameState); /*just to test whether writing is possible here so the player doesn't spend a long time and lose their progress*/ //Buffer for the text at the bottom of the scoreString = (char*)malloc(60*sizeof(char)); if(scoreString == NULL) exit(ER_MEMORY); //Pause menu pauseMenu = PopupNew(strConv[11], 50); if(pauseMenu == H_NULL) memkill(4, ER_MEMORY); PopupAddText(pauseMenu, -1, "New Game", 1); PopupAddText(pauseMenu, 0, "Options", 2); PopupAddText(pauseMenu,2,"Toggle Animations",5); PopupAddText(pauseMenu,2,"Reset Save Data",6); PopupAddText(pauseMenu, -1, "Exit", 3); PopupAddText(pauseMenu, -1, "About", 4); //Hiscore Name Entry nameBox = DialogNewSimple(140,35); if(nameBox == H_NULL) memkill(3, ER_MEMORY); DialogAddTitle(nameBox,"NEW HISCORE!",BT_OK,BT_NONE); DialogAddRequest(nameBox,3,14,"Name:", 0, 10, 14); //Game Over Entry gameOver = PopupNew("GAME OVER!", 40); if(gameOver == H_NULL) memkill(2, ER_MEMORY); PopupAddText(gameOver,-1,"Try Again",1); PopupAddText(gameOver,-1,"Exit",2); //About Dialouge aboutBox = DialogNewSimple(140,80); if(aboutBox == H_NULL) memkill(1, ER_MEMORY); DialogAddTitle(aboutBox,"ABOUT",BT_OK,BT_NONE); DialogAddText(aboutBox, 3, 13, "2048: A sliding tile puzzle"); DialogAddText(aboutBox, 3, 21, "Ti68k port by Harrison Cook"); DialogAddText(aboutBox, 3, 29, "Original game by Gabriele Cirulli"); DialogAddText(aboutBox, 3, 37, "\"Based on\" 1024 by Veewo Studio"); DialogAddText(aboutBox, 3, 45, "\"Conceptually Similar to\":"); DialogAddText(aboutBox, 3, 52, "Threes by Asher Vollmer"); DialogAddText(aboutBox, 3, 59, "Built using TIGCC"); ClrScr(); FontSetSys(F_8x10); randomize(); short int key; for(;;){ ClrScr(); drawGrid(gameState.grid); sprintf(scoreString, "Score: %lu Hiscore: %lu by %s", gameState.score, gameState.bscore, gameState.name); if(!isGridAvailable(gameState.grid)){ if(gameState.score > gameState.bscore){ DialogDo(nameBox,CENTER,CENTER, gameState.name,NULL); gameState.bscore = gameState.score; FontSetSys(F_8x10); } gameState.score = 0; initGrid(gameState.grid); switch(PopupDo(gameOver,CENTER,CENTER,0)){ case 1: continue; break; default: goto endGame; } } ST_helpMsg(scoreString); nodraw: ST_busy(ST_IDLE); key = ngetchx(); ST_busy(ST_BUSY); ST_helpMsg(scoreString); char move = 4; if(key == KEY_UP) move = UP; else if(key == KEY_RIGHT) move = RIGHT; else if(key == KEY_DOWN) move = DOWN; else if(key == KEY_LEFT) move = LEFT; else if(key == KEY_OFF || key==KEY_ON) //Turn the calculator off during a game. Resume it later off(); else if(key == KEY_ESC){ //Brings up the pause menu switch (PopupDo(pauseMenu,CENTER,CENTER,0)){ case 1: //1. New Game gameState.score = 0; initGrid(gameState.grid); break; //case 2: //2. Options //this is a submenu case 3: //3: Exit endGame: writeSave(&gameState); memkill(0,0); break; case 4: //4: About DialogDo(aboutBox,CENTER,CENTER,NULL,NULL); //Dialog sets the font weirdly, set it back FontSetSys(F_8x10); break; case 5: //1. Toggle Animations gameState.animations = !gameState.animations; break; case 6: //2. Reset Saved Data makeSave(&gameState); break; } } else goto nodraw; if(move < 4){ if(isDirectionAvailable(gameState.grid, move)){ shiftGrid(gameState.grid,move,&gameState.score, gameState.animations); pushNewTile(gameState.grid); } else goto nodraw; } } }