// C Header File // Created 12/28/2002; 6:35:00 PM extern volatile short int5_count; extern volatile short animframe; extern volatile short gw,gx,gy; extern _DEREF_INT_HANDLER menu_handler[]; static inline void PrepMenu(void); short domenu (BYTE x, BYTE y, char *setmenu[],char comps,short choice, short array); #ifndef __MENUS_H__ #define __MENUS_H__ volatile short int5_count; volatile short animframe; volatile short gw,gx,gy; DEFINE_INT_HANDLER(menu_handler) { int5_count++; if(!(int5_count%3)) { animframe++; if(animframe==5) animframe = 0; GraySprite16_MASK(gx-20,10*gw+gy-4,16,planets+animframe*32, planets+animframe*32+16,menumask,menumask,gg->plane1,gg->plane2); } } static inline void PrepMenu(void) { register GameGlobals *ggg asm("a4") = gg; memset(ggg->textplane,0xFF,LCD_SIZE); DrawGrayStrExt2B(0,3+display_offsety,(char*)titleVersionString, A_REVERSE|A_CENTERED,F_8x10,ggg->textplane,ggg->textplane); DrawGrayStrExt2B(0,84+display_offsety,(char*)authorString, A_REVERSE|A_CENTERED,F_6x8,ggg->textplane,ggg->textplane); DrawGrayStrExt2B(0,93+display_offsety,(char*)webSiteString, A_REVERSE|A_CENTERED,F_4x6,ggg->textplane,ggg->textplane); } /* inverse rectangle */ void InvertRect(short x0,short y0,short x1, short y1,void* plane) { SCR_RECT sr = {{x0, y0, x1, y1}}; PortSet(plane,239,127); ScrRectFill(&sr,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); } //void inverserectangle(w,xa,xb) InvertGrayRect2B(xa, w, xb, w + 9,textggg->plane,textggg->plane); #define MAXWAIT 20 /* Function for displaying and returning selected menu option */ short domenu (BYTE x, BYTE y, char *setmenu[],char comps,short choice, short array) { register GameGlobals *ggg asm("a4") = gg; short w = 0, changed = 1, i, j, exit = 0; short total = comps; short totalplace = 0; short this_y = 10 * w + y - 1; unsigned char max = x + 116; void redraw(void) { DrawStars(); FastCopyScreen(gg->BGlight,gg->plane1); FastCopyScreen(gg->BGdark,gg->plane2); GraySprite16_MASK(x-20,this_y-3,16,planets+animframe*32, planets+animframe*32+16,menumask,menumask,gg->plane1,gg->plane2); } w = choice; if(x<20) x=20; gw = w; gx = x; gy = y; animframe = 0; int5_count = 0; SetIntVec(AUTO_INT_5,menu_handler); FontSetSys(F_6x8); if(max>LCD_WIDTH-1) max = LCD_WIDTH - 1; if (comps > 7) comps = 7; PortSet(ggg->textplane,239,127); for (i = totalplace, j = 0; i < comps + totalplace; i++, j++) { char *str; if(array==-1) str = setmenu[i]; else str = stringIdx(array,i); DrawStr(x, 10 * j + y,str,A_REVERSE); } //InvertRect (x - 1,this_y,max,this_y+9,textggg->plane); while (exit == 0) { if (changed == 1) { if (totalplace < 0) totalplace = 0; comps = total - totalplace; if (comps > 7) comps = 7; InvertRect (x - 1,this_y,max,this_y+9,ggg->textplane); changed = 0; } redraw(); if (_keytest(RR_UP)) { while(_keytest(RR_UP)) { redraw(); } InvertRect (x - 1,this_y,max,this_y+9,ggg->textplane); if (w == 0) { if (totalplace > 7) { totalplace -= 7; w = 7; } else { w = comps; } } if (w > 0) w--; changed = 1; this_y = 10 * w + y - 1; gw = w; } else if (_keytest(RR_DOWN)) { while(_keytest(RR_DOWN)) { redraw(); } InvertRect (x - 1,this_y,max,this_y+9,ggg->textplane); if (w == comps - 1) { if (total > totalplace + 7) { totalplace += 7; } else totalplace = 0; w = -1; } if (w < comps - 1) w++; if (w == -1) w = 0; changed = 1; this_y = 10 * w + y - 1; gw = w; } else if (_keytest(RR_ENTER) || _keytest(RR_2ND)) { while(_keytest(RR_ENTER) || _keytest(RR_2ND)) { redraw(); } SetIntVec(AUTO_INT_5,int5_handler); return w + totalplace; } else if (_keytest(RR_ESC)) { while(_keytest(RR_ESC)) { redraw(); } exit++; } } SetIntVec(AUTO_INT_5,int5_handler); return comps-1; } #endif