/* Handlers... WHY?! * GOTTA FIND A MODULAR SOLUTION!! */ void joyAtkHandler ( u16 joy, u16 joyChanged, u16 state ) { int xc = fix32ToInt(p1.x); int yc = fix32ToInt(p1.y); // Player 1 if (joy == JOY_1) { if ( (state & BUTTON_A) || (state & BUTTON_B) || (state & BUTTON_C) ) // if (state & BUTTON_B ) { if (p1_dir.y != 0) { VDP_drawText( "XXX", xc - 1, fix32ToInt(p1.y - p1_dir.y) ); VDP_drawText( "XXX", xc - 1, fix32ToInt(p1.y - 2*p1_dir.y) ); } else if (p1_dir.x != 0) { VDP_drawText( "XX", fix32ToInt(p1.x + 2*p1_dir.x), yc - 1 ); VDP_drawText( "XX", fix32ToInt(p1.x + 2*p1_dir.x), yc ); VDP_drawText( "XX", fix32ToInt(p1.x + 2*p1_dir.x), yc + 1 ); } } VDP_setTileMapXY( VDP_PLAN_A, 0, xc, yc ); VDP_setTileMapXY( VDP_PLAN_A, 0, fix32ToInt(p1.x + p1_dir.x), fix32ToInt(p1.y - p1_dir.y) ); } }
int main() { x=0; y=0; oldx=0; oldy=0; VDP_loadTileData( (const u32 *)tile1, 1, 1, 0); VDP_setTileMapXY(APLAN, 1, x+2, y+2); JOY_init(); JOY_setEventHandler( &myJoyHandler ); //VDP_drawText("Hello World!", x, y); while(1) { VDP_drawText(" ", oldx, oldy); VDP_drawText("Hello World!", x, y); VDP_setTileMapXY(APLAN, 1, x+2, y+2); VDP_waitVSync(); } return (0); }
static void _init( u16 hard ) { if ( hard == 0 ) // 0 is soft reset { VDP_drawText ( "BUG HUNT", 16, 9 ); VDP_drawText ( "FOR SEGA MEGADRIVE", 11, 11 ); VDP_drawText ( "BY THE AFROMONKEYS, 2015", 8, 13 ); waitMs(3000); // That's weird. // Resetting in SGDK v1.11 invokes JOY_init() that // makes Justifier | Menacer not to be detected if // mouse is on PORT_1 if ( JOY_getPortType(PORT_1) != PORT_TYPE_PAD ) { VDP_drawText ( "PLEASE, REBOOT YOUR SYSTEM", 7, 19 ); while ( 1 ); } _start_entry(); // even more reset } sd_reset(); SYS_assertReset(); // makes gensKmod crash, WTF?! VDP_init(); //JOY_init(); // can cause mouse + justifer issues h_scroll = 0; VDP_setScrollingMode ( HSCROLL_PLANE, VSCROLL_PLANE ); /* The scroll mode never change during the game */ VDP_setPlanSize(64,32); save_init( ); SPR_init(0); /* Sprite Engine INIT */ VDP_setPalette(PAL3, sprpal.data); /* Sprite Palette (never change during the game) */ /* PAD & Mouse (PORT_1) & Lightgun (PORT_2) Support */ _JOYint ( TRUE ); LightgunInit ( PORT_2 ); VINT_SCROLL_FLAG = FALSE; VINT_JOY_UPDATE = FALSE; SYS_setVIntCallback((_voidCallback*) VIntCallback); FIRST_TIME_FLAG = TRUE; }
void display_memFree(u16 displayTimeMs){ char free_memStr[6]; int free_mem = MEM_getFree(); intToStr(free_mem, free_memStr, 6); VDP_drawText("FREE MEM :", 10, 9); VDP_drawText(free_memStr, 10, 10); VDP_waitVSync(); waitMs(displayTimeMs); VDP_drawText(" ", 10, 9); VDP_drawText(" ", 10, 10); }
static void createPauseMenu(u8 player){ u8 x = leftEdge(player), y = Y_PAUSE; u8 i; VDP_drawText(" OPTIONS", x, y); //draw underline for (i=x+6; i<x+13; i++){ VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+4), i, y+1); } VDP_drawText("Coming soon...", x, y+2); VDP_drawText("Double-tap START", x, y+5); VDP_drawText("to resume", x, y+6); }
void text_write ( char *str, u8 x, u8 y ) { SYS_disableInts ( ); VDP_clearTileMapRect ( PLAN_B, x, y, strlen(str), 1 ); VDP_drawText ( str, x, y ); SYS_enableInts ( ); }
int main(){ main_tunnel(500); VDP_drawText("END", 10, 10); while (1){ VDP_waitVSync(); } return 0; }
// illegal instruction exception default callback void _illegalinst_callback() { VDP_init(); VDP_drawText("ILLEGAL INSTRUCTION !", 7, 3); showException4WDump(5); while(1); }
// division by zero exception default callback void _zerodivide_callback() { VDP_init(); VDP_drawText("DIVIDE BY ZERO !", 10, 3); showExceptionDump(5); while(1); }
// address error default callback void _addresserror_callback() { VDP_init(); VDP_drawText("ADDRESS ERROR !", 10, 3); showBusAddressErrorDump(5); while(1); }
// CHK instruction default callback void _chkinst_callback() { VDP_init(); VDP_drawText("CHK INSTRUCTION EXCEPTION !", 5, 10); showException4WDump(12); while(1); }
// TRAPV instruction default callback void _trapvinst_callback() { VDP_init(); VDP_drawText("TRAPV INSTRUCTION EXCEPTION !", 5, 3); showException4WDump(5); while(1); }
// privilege violation exception default callback void _privilegeviolation_callback() { VDP_init(); VDP_drawText("PRIVILEGE VIOLATION !", 5, 3); showExceptionDump(5); while(1); }
// error exception default callback void _errorexception_callback() { VDP_init(); VDP_drawText("EXCEPTION ERROR !", 5, 3); showExceptionDump(5); while(1); }
static void writeText ( u8 *str, u16 pal, u8 inc_y ) { u8 x = 20 - strlen ( str ) / 2; SYS_disableInts(); VDP_setTextPalette ( pal ); VDP_drawText ( prepare_string(str), x, y ); SYS_enableInts(); y += inc_y; }
static u16 showValueU32U32(char *str1, u32 value1, char *str2, u32 value2, u16 pos) { char s[64]; strclr(s); addValueU32(s, str1, value1); addValueU32(s, str2, value2); VDP_drawText(s, 0, pos); return pos + 1; }
void TEXT_printf(u16 x, u16 y, const char *fmt, ...) { char buf[41]; va_list args; s16 i; va_start(args, fmt); i=vsprintf(buf,fmt,args); va_end(args); VDP_drawText(buf, x, y); }
int main( void ) { #ifdef UNIT_TEST_MODE VDP_drawText( "Romble is compiled in Unit Test mode", 0, 0 ); VDP_drawText( "Executing test cases...", 0, 1 ); SpecRunner_test(); VDP_drawText( "Done. Press RESET to test again.", 0, 3 ); while(1); #endif Romble_init(); // Setup a Supervisor and change its state to Supervisor_State_BETATEST as an initial state Supervisor* supervisor = NULL; NEW_OBJECT( Supervisor, supervisor ); FUNCTIONS( Supervisor, BaseView, supervisor )->changeState( supervisor, Supervisor_State_BETATEST ); Log_message( Log_Level_INFO, FILE_LINE(), "boot ok" ); while(1) { } }
void doSelect(struct FileSystem *fs, s16 choice) { const struct FileEntry *const file = dirList[choice]; const char *str = file->fileName; u32 cluster = file->firstCluster; u32 length = file->length; const u32 clusterLen = fatGetClusterLength(fs); const u16 clustersPerStar = (u16)(length / (32*clusterLen)); u16 x = 0, i; volatile u8 *const ssf2Reg = (volatile u8 *)0xA130F3; u8 page = 0x40; u8 *const LWM = (u8*)0x480000; u8 *const HWM = LWM + 512*1024; u8 *ptr = LWM; u8 isFirst; // Work out what x offset to use for the ROM name while ( *str ) { str++; x++; } x = (40-x) >> 1; str = dirList[choice]->fileName; // Construct loading screen VDP_waitVSync(); VDP_clearPlan(VDP_PLAN_A, 1); VDP_waitDMACompletion(); VDP_setTextPalette(PAL1); VDP_drawText(str, x, 11); VDP_setTextPalette(PAL2); VDP_drawText("Loading...", 15, 24); VDP_drawText("+--------------------------------+", 3, 25); VDP_drawText("| |", 3, 26); VDP_drawText("+--------------------------------+", 3, 27); VDP_setTextPalette(PAL0); *ssf2Reg = page; isFirst = 1; *((u16*)0x430000) = (clusterLen>>2)-1; for ( x = 4; x < 32+4; x++ ) { for ( i = 0; i < clustersPerStar; i++ ) { if ( isFirst ) { cluster = fatReadCluster(fs, cluster, (u8*)0x430002); isFirst = 0; } else { cluster = fatReadCluster(fs, cluster, ptr); } ptr += clusterLen; if ( ptr == HWM ) { ptr = LWM; page++; *ssf2Reg = page; } } VDP_drawText("*", x, 26); } *ssf2Reg = 0x40; // point back at bottom of RAM __asm__("trap #0"); }
static void refreshDriverParams() { const u16 driver_ind = getCurrentDriverIndex(); const char* str; u16 start; u16 len; u16 posY; u16 i, j; VDP_clearTileMapRect(PLAN_A, 0, 3, 40, 8); str = driver->name; len = strlen(str); start = 20 - (len / 2); setTextPalette(driver != &drivers[0]); VDP_drawText("<", start - 2, 3); VDP_setTextPalette(PAL0); VDP_drawText(str, start, 3); setTextPalette(driver != &drivers[NUM_DRIVER - 1]); VDP_drawText(">", start + len + 1, 3); posY = 5; for(i = 0; i < driver->num_cmd; i++) { const cmd_def *cur_cmd = &driver->cmds[i]; u16 posX = 2; str = cur_cmd->name; VDP_setTextPalette(PAL0); VDP_drawText(str, posX, posY); posX += strlen(str); for(j = 0; j < cur_cmd->num_param; j++) { const param_def *cur_param = &cur_cmd->params[j]; str = cur_param->name; setTextPalette(params_value[driver_ind][i] == cur_param); VDP_drawText(str, posX, posY); posX += strlen(str); } posY++; } VDP_setTextPalette(PAL0); if (cmd == NULL) VDP_drawText("*", 0, 3); else VDP_drawText("*", 0, 5 + getCurrentCmdIndex()); }
int main() { u16 i, j; const driver_def *cur_driver; const cmd_def *cur_cmd; JOY_setEventHandler(joyEvent); VDP_setScreenWidth320(); VDP_setHInterrupt(0); VDP_setHilightShadow(0); SYS_setVIntCallback(vintEvent); // point to first driver driver = &drivers[0]; cmd = NULL; dmaMethod = 0; for(i = 0, cur_driver = drivers; i < NUM_DRIVER; i++, cur_driver++) for(j = 0, cur_cmd = cur_driver->cmds; j < MAX_CMD; j++, cur_cmd++) params_value[i][j] = cur_cmd->params; VDP_setPalette(PAL0, font_pal_lib.data); VDP_setPaletteColor((PAL1 * 16) + 15, 0x0888); VDP_setTextPalette(PAL0); VDP_drawText("Current Z80 driver", 10, 1); VDP_drawText("DMA Method:", 1, 26); refreshDriverInfos(); while(1) { VDP_waitVSync(); } }
void drawBoard() { int x, y; char score_string[11]; for (y = 0; y != BOARD_Y; y++) { for (x = 0; x != BOARD_X; x++) { if (board[y][x].id) { if (board[y][x].selected) VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL2, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT); else VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL1, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + (4 * board[y][x].id)), CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT); } else { VDP_clearTileMapRect(VDP_PLAN_A, CUR(x), CUR(y), SWIRL_WIDTH, SWIRL_HEIGHT); } } } VDP_drawText("Level 1", 31, 3); //VDP_drawText("Goals:", 32, 5); //VDP_drawText("0 / 0", 32, 6); VDP_drawText("Score:", 30, 26); intToStr((s32)score, score_string, 1); VDP_clearTileMapRect(VDP_PLAN_A, 30, 27, 10, 1); VDP_drawText(score_string, 30, 27); VDP_updateSprites(); }
void DrawText() { VDP_drawText("Return", 15, 10); if (playerObject->aiState != AI_STATE_DEBUG) { VDP_drawText("Debug Mode: Off", 15, 11); } else { VDP_drawText("Debug Mode: On ", 15, 11); } if (debugSettings.invincibility) { VDP_drawText("Invincibility: On ", 15, 12); } else { VDP_drawText("Invincibility: Off", 15, 12); } if (debugSettings.waitforvsync) { VDP_drawText("Wait for VSync: On ", 15, 13); } else { VDP_drawText("Wait for VSync: Off", 15, 13); } if (debugSettings.showFPSCounter) { VDP_drawText("Show FPS Counter: On ", 15, 14); } else { VDP_drawText("Show FPS Counter: Off", 15, 14); } }
static void clearPlayerSide(u8 player){ u8 i = 0; u8 x = (WIDTH_TILES/2) * player; char blankString[(WIDTH_TILES/2)+1]; for (i=0; i<WIDTH_TILES/2; i++){ blankString[i] = ' '; } blankString[WIDTH_TILES/2] = '\0'; for (i=0; i<HEIGHT_TILES; i++){ VDP_drawText(blankString, x, i); } }
void typeText ( char *str, u8 x, u8 y, u16 ms ) { u8 i, len = strlen ( str ); for ( i=0; i<len; i++ ) { const char aux[2] = { str[i], '\0' }; SYS_disableInts(); VDP_drawText ( aux, x++, y ); SYS_enableInts(); if ( aux[0] != ' ' ) { waitMs(ms); } } }
int main(){ main_logo(100); //exit after x vbl after fade NEXTSEQPREPA main_underwater_starfield_fx(500); NEXTSEQPREPA main_boing_ball_fx(500); NEXTSEQPREPA main_twisted_metal(500); NEXTSEQPREPA main_tunnel(250); NEXTSEQPREPA main_axelay_fx(400); NEXTSEQPREPA main_vector_balls(300); NEXTSEQPREPA main_logo(100); NEXTSEQPREPA VDP_drawText("END", 10, 10); while(1){ VDP_waitVSync(); } return 0; }
//Processes Credits screen void Credits() { JOY_setEventHandler( &BtnNada ); //Set Event handler to nothing const u8 x=1; //Constant column value for text disp u8 y=1; //Variable row ~ const wait=3000; //Time in MS to wait echo_play_bgm(BGM_14); //Play IceHockey2 DrawBG(0); //cls DrawBG(10); //Draw Hockey rink //Setup text planes and colors VDP_setTextPlan(PLAN_B); VDP_setTextPriority(PTRUE); VDP_setPaletteColor((OBJPAL * 16)+15,0xEE); //Yellow VDP_setTextPalette(OBJPAL); //Draw a line, increment row, draw next line, repeat in screen chunks // 1234567890123456789012345678901234567 VDP_drawText("+-----------------------------------+",x,y);y++; VDP_drawText("| ULTRA AIR HOCKEY (Genesis), V1.0 |",x,y);y++; VDP_drawText("| Credits |",x,y);y++; VDP_drawText("+-----------------------------------+",x,y);y++; VDP_drawText("|Producer Tamkis|",x,y);y++; VDP_drawText("|Art creator Tamkis|",x,y);y++; VDP_drawText("+-----------------------------------+",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| Music |",x,y);y++; VDP_drawText("|All songs were converted to the |",x,y);y++; VDP_drawText("|Echo sound engine |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| Various module music artists |",x,y);y++; VDP_drawText("|Unless otherwise noted, all modules|",x,y);y++; VDP_drawText("|are from modarchive.org/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|http://modarchive.org/index.php?req|",x,y);y++; VDP_drawText("|uest=view_by_moduleid&query=NUMBER |",x,y);y++; VDP_drawText("v v",x,y);y++; //wait MS, clear the text plane, repeat for next screen chunk waitMs(wait); VDP_clearPlan(BPLAN,0); y=1; VDP_drawText("| |",x,y);y++; VDP_drawText("|hockey_fever.xm The Einstein Crew |",x,y);y++; VDP_drawText("|144817 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|nes_mes2.mod Goto80 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|PITTITLE.mod (Unknown) |",x,y);y++; VDP_drawText("|112082 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|ice-hockey_94theme.mod Subtance/ |",x,y);y++; VDP_drawText("|inflow 121145 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|organmaster.mod Gamma7 |",x,y);y++; VDP_drawText("|169287 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|intro101.mod w.o.t.w of |",x,y);y++; VDP_drawText("|supplex |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|hurry_up.mod reflex/rebels |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("v v",x,y);y++; waitMs(wait); VDP_clearPlan(BPLAN,0); y=1; VDP_drawText("|slowmotion.mod tobbx/Tobbe Lars|",x,y);y++; VDP_drawText("|157022 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|Castle_load.mod Exodus |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|complexity.mod (Unknown) |",x,y);y++; VDP_drawText("|92979 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|Reflexity_music.mod (subsong #3) |",x,y);y++; VDP_drawText("|Unknown 109459 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|chipmunks.mod Jester/Sanity |",x,y);y++; VDP_drawText("|36792 |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|icehockey2.mod Subversion |",x,y);y++; VDP_drawText("|123683 |",x,y);y++; VDP_drawText("+-----------------------------------+",x,y);y++; VDP_drawText("v v",x,y);y++; waitMs(wait); VDP_clearPlan(BPLAN,0); y=1; VDP_drawText("| Sound effects |",x,y);y++; VDP_drawText("|Unless otherwise noted, all sfx are|",x,y);y++; VDP_drawText("|from Freesound.org |",x,y);y++; VDP_drawText("|http://www.freesound.org/people/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|ID(+16) Name URL |",x,y);y++; VDP_drawText("|01 Menu highlight |",x,y);y++; VDP_drawText("|broumbroum/sounds/50561/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|02 Menu select |",x,y);y++; VDP_drawText("|Bertrof/sounds/131658/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|03 Puck hit |",x,y);y++; VDP_drawText("|krb21/sounds/118604/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|04/30 Puck deflect |",x,y);y++; VDP_drawText("|BranRainey/sounds/108737/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("v v",x,y);y++; waitMs(wait); VDP_clearPlan(BPLAN,0); y=1; VDP_drawText("|05 Bumper hit |",x,y);y++; VDP_drawText("|timgormly/sounds/170140/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|06 Powerup get |",x,y);y++; VDP_drawText("|RandomationPictures/sounds/138491/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|07 Powerup use |",x,y);y++; VDP_drawText("|jobro/sounds/35464/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|08 Goal siren |",x,y);y++; VDP_drawText("|UncleSigmund/sounds/117122/ |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|09-29 Announcer guy stuff |",x,y);y++; VDP_drawText("|All generated w Acapela Box using |",x,y);y++; VDP_drawText("|the English (UK) Peter voice |",x,y);y++; VDP_drawText("|https://acapela-box.com/AcaBox/ |",x,y);y++; VDP_drawText("|index.php |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("v v",x,y);y++; waitMs(wait); VDP_clearPlan(BPLAN,0); y=1; VDP_drawText("|31 Buzzer |",x,y);y++; VDP_drawText("|cognito%20perceptu/sounds/17468/ |",x,y);y++; VDP_drawText("+-----------------------------------+",x,y);y++; VDP_drawText("| Beta testers |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|DUDE #1 - Stuff |",x,y);y++; VDP_drawText("|DUDE #2 - Stuff |",x,y);y++; VDP_drawText("|DUDE #3 - Stuff |",x,y);y++; VDP_drawText("+-----------------------------------+",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| Special Thanks |",x,y);y++; VDP_drawText("|Oerg866 and SiktheHedgehog |",x,y);y++; VDP_drawText("|Echo Sound Engine and related tools|",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("|Stephane Help, SGDK |",x,y);y++; VDP_drawText("|Nemesis Exodus emulator (debuging)|",x,y);y++; VDP_drawText("v v",x,y);y++; waitMs(wait); VDP_clearPlan(BPLAN,0); y=1; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("+===================================+",x,y);y++; VDP_drawText("| YOU |",x,y);y++; VDP_drawText("| FOR PLAYING! |",x,y);y++; VDP_drawText("| Ultra Air Hockey (Genesis) V1.0 |",x,y);y++; VDP_drawText("| EagleSoft Ltd 2015 |",x,y);y++; VDP_drawText("| www.eaglesoftltd.com |",x,y);y++; VDP_drawText("+===================================+",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; VDP_drawText("| |",x,y);y++; waitMs(wait); echo_wait_sfx(SFX_02); //Play select sfx VDP_fadeOutAll(100,_FALSE); DrawBG(0); //cls }
//Handles the Options menu selections void BtnOptions(u16 joy, u16 changed, u16 state) { u8 Vert=_FALSE; //Flag if vert menu item was changed u8 Horiz=_FALSE; //~ horiz ~ char val[2]; //String holding Sound/Music test ID char name[25]; //String ~ Name of the sfx/music u8 i=0; //Generic counter var u8 pal=2; //Active palette to use (OBJPAL or PWRPAL) if (joy == JOY_1) { //If up pressed if (state & BUTTON_UP) { echo_play_sfx(SFX_01); //HiLite HItem--; //Decrement HItem, wrap if needed if (HItem<=MMin) { HItem=MMax-1; } //Set vert/horiz as changed Vert=PTRUE; Horiz=PTRUE; } //if up released else if (changed & BUTTON_UP) { //Set vert/horiz as unchanged Vert=_FALSE; Horiz=_FALSE; } //If down pressed if (state & BUTTON_DOWN) { echo_play_sfx(SFX_01); //HiLite sfx HItem++; //Increment if (HItem>=MMax) { HItem=MMin+1; } Vert=PTRUE; Horiz=PTRUE; } else if (changed & BUTTON_RIGHT) { Vert=_FALSE; Horiz=_FALSE; } //if left pressed if (state & BUTTON_LEFT) { //Process each for HItem row if (HItem==1) { //Decrement Opts[1], wrap if necessary Opts[1]--; if (Opts[1]==255) { Opts[1]=2; } } //Toggle bool (!bool) if ((HItem>=2) && (HItem<=4)) { if (Opts[HItem]==_FALSE) { Opts[HItem]=PTRUE; } else { Opts[HItem]=_FALSE; } //If toggling music if (HItem==3) { //If false, stop BGM; else play Nes_Mes2 again if (Opts[HItem]==_FALSE) { echo_stop_bgm(); } else { echo_play_bgm(BGM_03); } } } //If Sound test if (HItem==6) { //Decremenet S_ID, wrap if necessary S_ID--; if (S_ID<0) { S_ID=S_Max; } } //If music test, decrement M_ID, wrap if necessary if (HItem==5) { M_ID--; if (M_ID<0) { M_ID=M_Max; } } echo_play_sfx(SFX_02); //Select Horiz=PTRUE; //Flag horiz as changed } //If released else if (changed & BUTTON_LEFT) { Horiz=_FALSE; //Unflag Horiz } //If right pressed if (state & BUTTON_RIGHT) { //Process each HItem row //Difficulty, increment, wrap as necessary if (HItem==1) { Opts[1]++; if (Opts[1]>2) { Opts[1]=_FALSE; } } //Toggle bools (!bool) if ((HItem>=2) && (HItem<=4)) { if (Opts[HItem]==_FALSE) { Opts[HItem]=PTRUE; } else { Opts[HItem]=_FALSE; } //If toggling music, stop bgm if false; else play Nes_Mes2 if (HItem==3) { if (Opts[HItem]==_FALSE) { echo_stop_bgm(); } else { echo_play_bgm(BGM_03); } } } //If Sound test, increment S_ID, wrap if necessary if (HItem==6) { S_ID++; if (S_ID>S_Max) { S_ID=0; } } //If Music test, increment M_ID, wrap if necessary if (HItem==5) { M_ID++; if (M_ID>M_Max) { M_ID=0; } } echo_play_sfx(SFX_02); //Select sfx Horiz=PTRUE; //Flag Horiz as changed } //if released, unflag horiz else if (changed & BUTTON_RIGHT) { Horiz=_FALSE; } //If A button pressed if (state & BUTTON_A) { //If Sound test, play the selected S_ID if (HItem==6) { echo_play_sfx(Sounds[S_ID]); } //if Music test, play the selected M_ID if (HItem==5) { echo_play_bgm(Songs[M_ID]); } } //If Start button pressed if (state & BUTTON_START) { echo_play_sfx(SFX_03); //Play hockey deflect sfx SItem=1; //Select item } //If vert changed if (Vert==PTRUE) { //Clear text rows for (i=10;i<=16;i++) { VDP_clearText(5, i, 1); } //Set to PWRPAL VDP_setTextPalette(PWRPAL); VDP_drawText(">",5,HItem+10); //Disp hilighted row } //If Horiz changed if (Horiz==PTRUE) { //Get/set appropriate palette if (HItem==1){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); //Draw difficulty text and selected difficulty VDP_drawText("Difficulty:",6,11); VDP_drawText(" ",20,11); switch(Opts[1]) { case 0: VDP_drawText("Easy",20,11); break; case 1: VDP_drawText("Medium",20,11); break; case 2: VDP_drawText("Hard",20,11); break; } //Get/set palettes, show lables for powerups, music, and sound toggles if (HItem==2){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); VDP_drawText("Powerups",6,12); if (HItem==3){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); VDP_drawText("Music:",6,13); if (HItem==4){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); VDP_drawText("Sfx:",6,14); //Show selected boolean states for them, with appropriate palette for (i=2;i<=4;i++) { if (HItem==i){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); if (Opts[i]==_FALSE) { VDP_drawText("OFF",20,10+i); } else { VDP_drawText("ON ",20,10+i); } } //Ditto for Music test if (HItem==5){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); VDP_drawText("Music test:",6,15); VDP_drawText(" ",20,15); intToStr(M_ID,val,1); //Convert M_ID to string VDP_drawText(val,20,15); //Display it //Ditto for Sound test if (HItem==6){pal=PWRPAL;}else{pal=OBJPAL;} VDP_setTextPalette(pal); VDP_drawText("Sound test:",6,16); VDP_drawText(" ",20,16); intToStr(S_ID,val,1); VDP_drawText(val,20,16); //If Sound/music test if ((HItem==5)||(HItem==6)) { //Fetch and show the music/sound name VDP_setTextPalette(PWRPAL); if (HItem==5) { VDP_drawText("Song title: ",6,18); VDP_drawText(" ",6,19); VDP_drawText(Song_Names[M_ID],6,19);//@Get song title here } else { VDP_drawText("Sound title:",6,18); VDP_drawText(" ",6,19); VDP_drawText(Sound_Names[S_ID],6,19);//Get sfx title here } } else { //If neither, clear the lines VDP_drawText(" ",6,18); VDP_drawText(" ",6,19); } } } }
static void refreshDriverCmd() { VDP_clearTileMapRect(PLAN_A, 0, 12, 40, 8); setTextPalette(1); switch(driver->id) { case Z80_DRIVER_PCM: VDP_drawText("press A to start/end playback", 1, 12); break; case Z80_DRIVER_2ADPCM: VDP_drawText("press A to start/end channel 1", 1, 12); VDP_drawText("press B to start/end channel 2", 1, 13); break; case Z80_DRIVER_4PCM_ENV: VDP_drawText("press A to start/end channel 1", 1, 12); VDP_drawText("press B to start/end channel 2", 1, 13); VDP_drawText("press C to start/end channel 3", 1, 14); VDP_drawText("press START to start/end channel 4", 1, 15); break; case Z80_DRIVER_MVS: VDP_drawText("press A to start/end play MVS music", 1, 12); VDP_drawText("press B to play PCM SFX", 1, 13); break; case Z80_DRIVER_TFM: VDP_drawText("press A to start play", 1, 12); VDP_drawText("press START to stop play", 1, 13); break; case Z80_DRIVER_VGM: VDP_drawText("press A to play Sonic 1 VGM", 1, 12); VDP_drawText("press B to play RoadRash VGM", 1, 13); VDP_drawText("press C to play Bad Apple VGM", 1, 14); VDP_drawText("press Start to stop/resume VGM", 1, 15); VDP_drawText("press X to play PCM SFX", 1, 17); break; case Z80_DRIVER_XGM: VDP_drawText("press A to play Streets Of Rage 2 XGM", 1, 12); VDP_drawText("press B to play Bad Apple (PCM) XGM", 1, 13); VDP_drawText("press C to play Midnight Resistance XGM", 1, 14); VDP_drawText("press START to pause/resume XGM music", 1, 15); VDP_drawText("press X to play PCM SFX ch 2", 1, 17); VDP_drawText("press Y to play PCM SFX ch 3", 1, 18); VDP_drawText("press Z to play PCM SFX ch 4", 1, 19); VDP_drawText("Z80 CPU load:", 1, 21); break; } }
static void vintEvent() { u16 i; u16 in, out; char strNum[8]; char str[40]; // set BUS protection for XGM driver if (driver->id == Z80_DRIVER_XGM) SND_set68KBUSProtection_XGM(TRUE); in = GET_VCOUNTER; if ((in >= 224) && (in <= 230)) { switch(dmaMethod) { case 1: VDP_doDMAEx(VDP_DMA_VRAM, 0, 0x8000, (6 * 1024) / 2, 2); break; case 2: for(i = 0; i < 4; i++) { VDP_doDMAEx(VDP_DMA_VRAM, 0, 0x8000, 1024 / 2, 2); waitSubTick(0); } break; case 3: for(i = 0; i < 8; i++) { VDP_doDMAEx(VDP_DMA_VRAM, 0, 0x8000, 256 / 2, 2); waitSubTick(0); } break; } } out = GET_VCOUNTER; if (driver->id == Z80_DRIVER_XGM) { u16 load; // remove BUS protection for XGM driver SND_set68KBUSProtection_XGM(FALSE); // get Z80 cpu estimated load load = SND_getCPULoad_XGM(); uintToStr(load, str, 3); strcat(str, " %"); VDP_clearText(16, 21, 10); VDP_drawText(str, 16, 21); // { // u8 debugValues[12]; // // getZ80Debug(debugValues); // // strcpy(str, "4 PCM mixing: "); // // uintToStr(debugValues[0], strNum, 3); // strcat(str, strNum); // strcat(str, " "); // uintToStr(debugValues[4], strNum, 3); // strcat(str, strNum); // // VDP_drawText(str, 1, 22); // // strcpy(str, "XGM prep & parse: "); // // uintToStr(debugValues[5], strNum, 3); // strcat(str, strNum); // strcat(str, " "); // uintToStr(debugValues[6], strNum, 3); // strcat(str, strNum); // strcat(str, " "); // uintToStr(debugValues[7], strNum, 3); // strcat(str, strNum); // // VDP_drawText(str, 1, 23); // // strcpy(str, "Ext com & sync: "); // // strcat(str, strNum); // strcat(str, " "); // uintToStr(debugValues[8], strNum, 3); // strcat(str, strNum); // strcat(str, " "); // uintToStr(debugValues[9], strNum, 3); // strcat(str, strNum); // // VDP_drawText(str, 1, 24); // } } else { VDP_clearTextLine(22); VDP_clearTextLine(23); VDP_clearTextLine(24); } if ((in >= 224) && (in <= 230)) { switch(dmaMethod) { case 0: VDP_drawText("NONE ", 13, 26); break; case 1: VDP_drawText("1 x 6KB ", 13, 26); break; case 2: VDP_drawText("4 x 1KB ", 13, 26); break; case 3: VDP_drawText("8 x 256B", 13, 26); break; } } else VDP_drawText("NOT DONE", 13, 26); if (dmaMethod) { strcpy(str, "DMA start at "); uintToStr(in, strNum, 3); strcat(str, strNum); strcat(str, " - end at "); uintToStr(out, strNum, 3); strcat(str, strNum); VDP_drawText(str, 1, 27); } else VDP_clearTextLine(27); }