//Processes Main Menu void MainMenu() { u8 Done=_FALSE; DrawBG(7); if (DBUG==_FALSE) { echo_wait_sfx(SFX_09); //"Ultra Air Hockey!" echo_wait_sfx(SFX_08); //Siren } Trig=PTRUE; //Loop until Done is PTRUE while (Done==_FALSE) { echo_play_bgm(BGM_02); //Play HockeyFever (Loop) InitMenu(1,0,0,4,PTRUE); //Init menu to 3 items JOY_setEventHandler(&BtnHMenu); //Set appropriate button handler //While nothing is selected while (SItem==0) { VDP_waitVSync(); //If a dir key was pressed, update the background to reflect highlighted choice if (Trig==PTRUE) { DrawBG(10+HItem); } } //Process the selected item switch (SItem) { //Play case 1: VDP_fadeOutAll(100,_FALSE); ChrselMenu(); //Do Char selection menu Done=PTRUE; break; //Options case 2: echo_wait_sfx(SFX_11); //"Options" VDP_fadeOutAll(100,_FALSE); OptionsMenu(); Trig=PTRUE; break; //Credits case 3: echo_wait_sfx(SFX_12); //"Credits" VDP_fadeOutAll(100,_FALSE); Credits(); Trig=PTRUE; break; } } JOY_setEventHandler( &BtnNada ); //Remove button handler }
void waitHz ( u16 hz ) { while ( hz-- ) { VDP_waitVSync(); } }
static u16 wait ( u16 hz ) { u16 ret = 0; if ( exit ) { ret = 1; } while ( hz-- ) { VDP_waitVSync(); JoyReader_update(); if( joy1_pressed_abc | joy1_pressed_start ) { exit = 1; ret = 1; displayOff(10); break; } } return ret; }
void text_draw_sprite ( u8 *str, u16 x, u16 y, u16 ms ) { #define TILE _base + _positions[chr] * _width * _height #define ATTR TILE_ATTR_FULL ( _palette, 1, 0, 0, TILE ) u8 chr, i = 0; const u16 size = _genres->size >> 8; const u8 width = _genres->width; while ( (chr = *str++) ) { chr -= ' '; chr = ( chr >= 96 ) ? 0 : chr; if ( ! _positions[chr] ) { _positions[chr] = _counter++; VDP_loadTileData ( _genres->sprites[chr], TILE, size, TRUE ); VDP_waitVSync(); } VDP_setSprite ( i, x+i*width, y, size, ATTR, i+1 ); VDP_updateSprites(); waitMs ( ms ); ++i; } }
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); }
//Processes Options Menu void OptionsMenu() { DrawBG(0); //cls echo_play_bgm(BGM_03); //Play Nes_Mes2 DrawBG(9); //Init text plane (Plane, text prio, text colors) VDP_setTextPlan(PLAN_B); VDP_setTextPriority(PTRUE); VDP_setPaletteColor((OBJPAL * 16)+15,0xE); //Non higlited color VDP_setPaletteColor((PWRPAL * 16)+15,0xEE); //Hilited color VDP_setTextPalette(OBJPAL); InitMenu(1,0,0,7,_FALSE); //Init a 6 item menu S_ID=0; M_ID=0; //Set joy handler to Options type JOY_setEventHandler( &BtnOptions ); while (SItem==0) { VDP_waitVSync(); } DrawBG(0); //cls }
void waitMusicStop ( ) { while ( XGM_isPlaying() ) { VDP_waitVSync(); } }
int main(){ main_tunnel(500); VDP_drawText("END", 10, 10); while (1){ VDP_waitVSync(); } return 0; }
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"); }
void waitSc ( u16 sc ) { sc *= getHz(); while ( sc-- ) { VDP_waitVSync(); } }
void stars_draw ( ) { u8 i; vobject_add ( ESTRELLITA1 ); vobject_add ( ESTRELLITA2 ); vobject_add ( ESTRELLITA3 ); vobject_add ( ESTRELLITA4 ); Vect2D_s16 posiciones = { vdpSpriteCache[splist_griel].x - 4-128, vdpSpriteCache[splist_griel].y + 2-128 }; s16 x = posiciones.x; s16 y = posiciones.y; vsprite_set ( sprites[0] = 71, x-12, y-12, ESTRELLITA1 ); vsprite_set ( sprites[1] = 72, x+12, y-12, ESTRELLITA2 ); vsprite_set ( sprites[2] = 73, x-12, y+12, ESTRELLITA3 ); vsprite_set ( sprites[3] = 74, x+12, y+12, ESTRELLITA4 ); u16 duracion = animation_duracion(ESTRELLITA1); while ( duracion-- ) { if ( duracion % 4 == 0 ) { _freeze_objects(); } vobject_update(); vobject_upload ( ); VDP_updateSprites(80,1); VDP_waitVSync(); } vobject_delete ( ESTRELLITA1 ); vobject_delete ( ESTRELLITA2 ); vobject_delete ( ESTRELLITA3 ); vobject_delete ( ESTRELLITA4 ); for ( i=0; i<STARTS_SPRITES; i++ ) { u8 sprite = sprites [ i ] ; splist_hide_sprite ( sprite ); vsprite_animation ( sprite, EMPTY_SPRITE ); sd_delete ( sprite ); } stars_init (); }
int main(void) { titleScreen(); initBoard(); drawBoard(); VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL3, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 20), 32, 0, 5, 3); while(1) { VDP_waitVSync(); } return 0; }
//Character selection menu //@Fix glitchy BG screen and display of Arrow void ChrselMenu() { Sprite sprites[1]; //Sprite struct DrawBG(0); //Cls DrawBG(8); //Draw "How many players" BG InitMenu(1,0,0,3,_FALSE); //Init a 2 item Menu //Setup the arrow sprite SYS_disableInts(); SPR_init(16); //Sprite tile cache of 16 tiles SYS_enableInts(); // !@ Screws up SPR_initSprite(&sprites[0], &SPR_Arrow, 271, 266, TILE_ATTR(MISCPAL,TRUE,FALSE,FALSE)); //Init the Arrow Sprite VDP_setPalette(MISCPAL, SPR_Arrow.palette->data); //Init pal OBJPAL to Arrow pal echo_play_sfx(SFX_13); //"How many players are going to play today?" JOY_setEventHandler( &BtnHMenu ); //Setup joy handler to HMenu type //While no items are selected while (SItem==0) { //If 1 player hilighted if ((HItem==1) && (Trig==_FALSE)) { SPR_setPosition(&sprites[0],271,266); //Set new arrow position SPR_update(sprites, 1); //Update it } else { SPR_setPosition(&sprites[0],311, 266); SPR_update(sprites, 1); } VDP_waitVSync(); } VDP_resetSprites(); //@Toggle amt of players as appropriately if (SItem==1) { Opts[0]=_FALSE; } else { Opts[0]=PTRUE; } SPR_setPosition(&sprites[0],-128, -128); //@Kill sprite SPR_update(sprites, 1); //Update it SPR_end; //Kill sprite engine echo_wait_sfx(SFX_10); //"Let us play some hockey!" VDP_fadeOutAll(100,_FALSE); }
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 beastScrollingFX(){ u32 hscrollInc = 0; u16 vblCount = 0; u16 vramIndex = TILE_USERINDEX; short i; Sprite sprites[BALL_COUNT]; SYS_disableInts(); VDP_clearPlan(APLAN, 0); VDP_clearPlan(BPLAN, 0); /* Set a larger tileplan to be able to scroll */ VDP_setPlanSize(64, 32); /* Draw the foreground */ VDP_setPalette(PAL1, ground.palette->data); VDP_drawImageEx(BPLAN, &ground, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 4, FALSE, FALSE); VDP_drawImageEx(BPLAN, &ground, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 24, 4, FALSE, FALSE); vramIndex += ground.tileset->numTile; VDP_setPalette(PAL0, rse_logo.palette->data); VDP_drawImageEx(APLAN, &rse_logo, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vramIndex), 0, 6, FALSE, FALSE); vramIndex += rse_logo.tileset->numTile; for(i = 0; i < BALL_COUNT; i++) SPR_initSprite(&sprites[i], &ball_metal, 0, 0, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, 0)); VDP_setPalette(PAL2, ball_metal.palette->data); SPR_init(BALL_COUNT); SYS_enableInts(); SND_startPlay_XGM(midnight); while (1){ hscrollInc = 0; VDP_waitVSync(); VDP_setHorizontalScroll(PLAN_B, -vblCount); VDP_setHorizontalScroll(PLAN_A, sinFix16(vblCount << 2)); for(i = 0; i < BALL_COUNT; i++) { // SPR_setPosition(&sprites[i], 160 + sinFix16((vblCount << 2) + (i << 5)), 100 + cosFix16((vblCount << 3) + (i << 3))); sprites[i].x = (160 + 0x80) + sinFix16((vblCount << 2) + (i << 5)); sprites[i].y = (100 + 0x80) + cosFix16((vblCount << 3) + (i << 3)); } SPR_update(sprites, BALL_COUNT); vblCount += 1; } }
void waitJoyHz ( u16 hz ) { while ( hz-- ) { VDP_waitVSync(); JoyReader_update(); if ( joy1_pressed ) { return ; } } }
void waitJoyHzBtn ( u16 hz ) { while ( hz-- ) { VDP_waitVSync(); JoyReader_update(); if ( joy1_pressed_abc|joy1_pressed_start ) { return ; } } }
void waitJoy ( ) { while ( 1 ) { VDP_waitVSync(); JoyReader_update(); if ( joy1_pressed ) { return ; } } }
void transition_fx(u8 frames, u16 vramindex_start) { s16 i, j, k, l; u16 sw, sh; current_plan = VDP_PLAN_A; current_pal = PAL0; SYS_disableInts(); vramIndex = vramindex_start; // u16 VDP_getPlanWidth(); // u16 VDP_getPlanHeight(); VDP_drawImageEx(APLAN, &transition_pattern_0, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 0, FALSE, FALSE); // vramIndex += transition_pattern_0.tileset->numTile; SYS_enableInts(); sw = VDP_getPlanWidth(); sh = VDP_getPlanHeight(); for(i = 0; i < sw + WIPE_TILE_WIDTH; i++) { VDP_waitVSync(); for(j = 0; j < sh; j++) for(k = 0; k < WIPE_TILE_WIDTH; k++) { l = i - k; if (l < 0) l = 0; else if (l > sw) l = sw - 1; l -= j; if (l < 0) break; else if (l > sw) break; VDP_setTileMapXY(current_plan, vramIndex + k, l, j); //TILE_ATTR_FULL(current_pal, FALSE, FALSE, FALSE, j)); } } }
int main() { VDP_setScreenWidth320(); Vector2D speed = { FIX32(0.2), FIX32(0.2) }; Vector2D position = { FIX32( 1), FIX32( 1) }; // Init joy handler JOY_init(); JOY_setEventHandler( &joyAtkHandler ); // Under construction // SPR_init( (4 * 8) + (3 * 3 * 9) ); // Knighty is 2x2 tiles and 8 frames, Wizard is 3x3 and 9 frames SPR_init( (4 * 8) + (3 * 3 * 9) ); draw_arena(); init_player_wizard(140, 128); init_player_knighty(128, 128); spr_players[1] = WIZARD_SPR; spr_players[0] = KNIGHTY_SPR; // game loop while (1) { // directionalInput( &p1, &p2 ); wizard_control(&p1, JOY_1); knighty_control(&p2, JOY_2); bounceCharacter( &speed, &position ); debugPlayers(p1, p2, p1_dir, p2_dir); // control_wizard(&p1); SPR_update(spr_players, 2); // wait for the screen to refresh VDP_waitVSync(); } SPR_end(); return 0; }
static void setDisplay ( u16 on, u16 frames, u16 *colors ) { VDP_waitVSync(); if ( frames ) { if ( on ) { VDP_fadeAllTo ( (u16*) colors, frames, 0 ); } else { VDP_fadeOutAll ( frames, 0 ); } } else { SYS_disableInts ( ); VDP_setPaletteColors ( 0, (u16*) colors, 64 ); SYS_enableInts ( ); } }
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; }
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 joyHandler(u16 joy, u16 changed, u16 state) { switch (joy) { case JOY_1: if (state & BUTTON_A) { if (board[SEL(cursor.posy)][SEL(cursor.posx)].selected == TRUE) { int deleted_amount = recursiveDelete(SEL(cursor.posx),SEL(cursor.posy), board[SEL(cursor.posy)][SEL(cursor.posx)].id); if (deleted_amount == 1) score-=10; else score+=deleted_amount * 10; applyGravity(); applyLeftShift(); drawBoard(); selected = FALSE; } else if (board[SEL(cursor.posy)][SEL(cursor.posx)].id != 0) { if(selected) { unselectEverything(); } selected = TRUE; recursiveFloodSelect(SEL(cursor.posx), SEL(cursor.posy), board[SEL(cursor.posy)][SEL(cursor.posx)].id, TRUE); drawBoard(); } else { if(selected) { unselectEverything(); selected = FALSE; drawBoard(); } } } if (state & BUTTON_UP) { if (SEL(cursor.posy) > 0) { int oldy = cursor.posy; while(cursor.posy != oldy - 16) { VDP_waitVSync(); cursor.posy-=CURSOR_INCREMENT_SPEED; VDP_setSpriteDirectP(0, &cursor); } } } if (state & BUTTON_DOWN) { if (SEL(cursor.posy) < BOARD_Y - 1) { int oldy = cursor.posy; while(cursor.posy != oldy + 16) { VDP_waitVSync(); cursor.posy+=CURSOR_INCREMENT_SPEED; VDP_setSpriteDirectP(0, &cursor); } } } if (state & BUTTON_LEFT) { if (SEL(cursor.posx) > 0) { int oldx = cursor.posx; while(cursor.posx != oldx - 16) { VDP_waitVSync(); cursor.posx-=CURSOR_INCREMENT_SPEED; VDP_setSpriteDirectP(0, &cursor); } } } if (state & BUTTON_RIGHT) { if (SEL(cursor.posx) < BOARD_X - 1) { int oldx = cursor.posx; while(cursor.posx != oldx + 16) { VDP_waitVSync(); cursor.posx+=CURSOR_INCREMENT_SPEED; VDP_setSpriteDirectP(0, &cursor); } } } break; } }
static void fastStarFieldFX() { u16 vramIndex = TILE_USERINDEX; s16 i, ns, s; Sprite sprites[256]; SYS_disableInts(); VDP_clearPlan(APLAN, 0); VDP_clearPlan(BPLAN, 0); VDP_setPlanSize(32, 32); /* Draw the foreground */ VDP_drawImageEx(BPLAN, &starfield, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 0, TRUE, FALSE); vramIndex += starfield.tileset->numTile; /* Set the proper scrolling mode (line by line) */ VDP_setScrollingMode(HSCROLL_LINE, VSCROLL_PLANE); /* Create the scrolling offset table */ s = 1; for(i = 0; i < TABLE_LEN; i++) { scroll_PLAN_B[i] = 0; do { ns = -((random() % 3) + 1); } while (ns == s); scroll_speed[i] = ns; s = ns; } /* Setup the sprites */ SPR_init(256); for(i = 0; i < MAX_DONUT; i++) SPR_initSprite(&sprites[i], &donut, 0, 0, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, 0)); SPR_update(sprites, MAX_DONUT); VDP_setPalette(PAL2, donut.palette->data); SYS_enableInts(); /* Start !!!! */ s = 0; while (TRUE) { VDP_waitVSync(); BMP_showFPS(1); /* Scroll the starfield */ VDP_setHorizontalScrollLine(PLAN_B, 2, scroll_PLAN_B, TABLE_LEN, TRUE); for(i = 0; i < TABLE_LEN; i++) scroll_PLAN_B[i] = (scroll_PLAN_B[i] + scroll_speed[i]) & 0xFF; /* Animate the donuts */ for(i = 0; i < MAX_DONUT; i++) { // SPR_setPosition(&sprites[i], (cosFix16(s + (i << 5)) << 1) + 160 - 16, sinFix16(s + (i << 5)) + 112 - 16); sprites[i].x = (cosFix16(s + (i << 5)) << 1) + 160 - 16 + 0x80; sprites[i].y = sinFix16(s + (i << 5)) + 112 - 16 + 0x80; SPR_setFrame(&sprites[i], ((s >> 4) + i) & 0x7); } s += 4; SPR_update(sprites, MAX_DONUT); } }
void JOY_init() { vu8 *pb; u8 a, id; u16 i; joyEventCB = NULL; gport = 0xFFFF; // disable ints SYS_disableInts(); /* check for EA 4-Way Play */ pb = (vu8 *)0xa10009; *pb = 0x40; pb = (vu8 *)0xa1000b; *pb = 0x43; pb = (vu8 *)0xa10005; *pb = 0x7C; pb = (vu8 *)0xa1000b; *pb = 0x7F; pb = (vu8 *)0xa10005; *pb = 0x7C; pb = (vu8 *)0xa10003; a = *pb & 3; if (a == 0) { /* EA 4-Way Play detected */ portType[PORT_1] = PORT_TYPE_EA4WAYPLAY; portType[PORT_2] = PORT_TYPE_EA4WAYPLAY; portSupport[PORT_1] = JOY_SUPPORT_EA4WAYPLAY; portSupport[PORT_2] = JOY_SUPPORT_OFF; for (i=JOY_1; i<JOY_NUM; i++) { joyType[i] = JOY_TYPE_UNKNOWN; /* default to unknown */ joyState[i] = 0; joyAxisX[i] = 0; joyAxisY[i] = 0; } // restore ints SYS_enableInts(); /* wait a few vblanks for JOY_update() to get valid data */ VDP_waitVSync(); VDP_waitVSync(); VDP_waitVSync(); return; /* EA 4-Way Play is the only thing that can be plugged in as it takes both ports */ } /* * Initialize ports for peripheral interface protocol - default to * TH Control Method for pads */ /* set the port bits direction */ pb = (vu8 *)0xa10009; *pb = 0x40; pb += 2; *pb = 0x40; pb += 2; *pb = 0x40; /* set the port bits value */ pb = (vu8 *)0xa10003; *pb = 0x40; pb += 2; *pb = 0x40; pb += 2; *pb = 0x40; VDP_waitVSync(); VDP_waitVSync(); /* get ID port 1 */ pb = (vu8 *)0xa10003; a = *pb; *pb = 0x00; id = (a & 8) | (a & 4) ? 8 : 0; id |= (a & 2) | (a & 1) ? 4 : 0; a = *pb; *pb = 0x40; id |= (a & 8) | (a & 4) ? 2 : 0; id |= (a & 2) | (a & 1) ? 1 : 0; portType[PORT_1] = id; /* get ID port 2 */ pb = (vu8 *)0xa10005; a = *pb; *pb = 0x00; id = (a & 8) | (a & 4) ? 8 : 0; id |= (a & 2) | (a & 1) ? 4 : 0; a = *pb; *pb = 0x40; id |= (a & 8) | (a & 4) ? 2 : 0; id |= (a & 2) | (a & 1) ? 1 : 0; portType[PORT_2] = id; /* now set the port support */ portSupport[PORT_1] = JOY_SUPPORT_OFF; /* default to off */ portSupport[PORT_2] = JOY_SUPPORT_OFF; /* default to off */ for (i=JOY_1; i<JOY_NUM; i++) { joyType[i] = JOY_TYPE_UNKNOWN; /* default to unknown */ joyState[i] = 0; joyAxisX[i] = 0; joyAxisY[i] = 0; } switch (portType[PORT_1]) { case PORT_TYPE_MENACER: case PORT_TYPE_JUSTIFIER: /* init port for light gun control */ pb = (vu8 *)0xa10009; *pb = 0x30; pb = (vu8 *)0xa10003; *pb = 0x30; break; case PORT_TYPE_MOUSE: case PORT_TYPE_TEAMPLAYER: /* init port for Three Line Handshake Method */ pb = (vu8 *)0xa10009; *pb = 0x60; pb = (vu8 *)0xa10003; *pb = 0x60; break; case PORT_TYPE_PAD: portSupport[PORT_1] = JOY_SUPPORT_6BTN; /* default to on for pads */ break; } switch (portType[PORT_2]) { case PORT_TYPE_MENACER: case PORT_TYPE_JUSTIFIER: /* init port for light gun control */ pb = (vu8 *)0xa1000b; *pb = 0x30; pb = (vu8 *)0xa10005; *pb = 0x30; break; case PORT_TYPE_MOUSE: case PORT_TYPE_TEAMPLAYER: /* init port for Three Line Handshake Method */ pb = (vu8 *)0xa1000b; *pb = 0x60; pb = (vu8 *)0xa10005; *pb = 0x60; break; case PORT_TYPE_PAD: portSupport[PORT_2] = JOY_SUPPORT_6BTN; /* default to on for pads */ break; } /* check if need to turn on an input device */ if ((portType[PORT_1] != PORT_TYPE_PAD) && (portType[PORT_2] != PORT_TYPE_PAD)) { /* no pads - look for teamplayer or mouse */ if (portType[PORT_1] == PORT_TYPE_TEAMPLAYER) JOY_setSupport(PORT_1, JOY_SUPPORT_TEAMPLAYER); else if (portType[PORT_2] == PORT_TYPE_TEAMPLAYER) JOY_setSupport(PORT_2, JOY_SUPPORT_TEAMPLAYER); else if (portType[PORT_1] == PORT_TYPE_MOUSE) JOY_setSupport(PORT_1, JOY_SUPPORT_MOUSE); else if (portType[PORT_2] == PORT_TYPE_MOUSE) JOY_setSupport(PORT_2, JOY_SUPPORT_MOUSE); } // restore ints SYS_enableInts(); /* wait a few vblanks for JOY_update() to get valid data */ VDP_waitVSync(); VDP_waitVSync(); VDP_waitVSync(); /* now update pads to reflect true type (3 or 6 button) */ if (portType[PORT_1] == PORT_TYPE_PAD) if (joyType[JOY_1] == JOY_TYPE_PAD3) portSupport[PORT_1] = JOY_SUPPORT_3BTN; if (portType[PORT_2] == PORT_TYPE_PAD) if (joyType[JOY_2] == JOY_TYPE_PAD3) portSupport[PORT_2] = JOY_SUPPORT_3BTN; }
int main() { u16 i, newJoy = 0, oldJoy = 0, autoRepeatDelay = 0, redraw = 1; s16 choice = 0; const char *str; struct FileSystem fs; u16 numFiles; // Init the screen, display message VDP_setScreenWidth320(); VDP_setHInterrupt(0); VDP_setHilightShadow(0); VDP_setTextPalette(PAL0); VDP_drawText("MakeStuff USB MegaDrive Dev Kit v2", 3, 10); VDP_drawText("Reading SD-card...", 11, 12); // Initialise the SD card sdInit(); // Get the geometry of the first SD-card partition fatOpenFileSystem(&fs); // Initialise workspace for the directory list initFiles((u16*)0x440000); // Get the list of game ROMs fatListDirectory(&fs, fs.rootDirCluster, storeFile); // Sort the list alphabetically numFiles = dirPtr - dirList; quickSort((CVPtr *)dirList, 0, numFiles, (CompareFunc)myFileComp); // Display the list for ( ; ; ) { newJoy = JOY_readJoypad(0); if ( newJoy & BUTTON_UP && choice > 0 ) { if ( !(oldJoy & BUTTON_UP) ) { choice--; redraw = 1; autoRepeatDelay = 0; } else { if ( autoRepeatDelay == 10 ) { choice--; redraw = 1; } else { autoRepeatDelay++; } } } if ( newJoy & BUTTON_DOWN && choice < numFiles-1 ) { if ( !(oldJoy & BUTTON_DOWN) ) { choice++; redraw = 1; autoRepeatDelay = 0; } else { if ( autoRepeatDelay == 10 ) { choice++; redraw = 1; } else { autoRepeatDelay++; } } } if ( newJoy & BUTTON_START ) { doSelect(&fs, choice); } oldJoy = newJoy; VDP_waitVSync(); if ( redraw ) { VDP_clearPlan(VDP_PLAN_A, 1); VDP_waitDMACompletion(); for ( i = 2; i < 26; i++ ) { if ( i >= 11-choice && i < numFiles-choice+11 ) { str = dirList[choice+i-11]->fileName; if ( i == 11 ) { VDP_setTextPalette(PAL1); VDP_drawText(str, 2, i); VDP_setTextPalette(PAL0); } else { VDP_drawText(str, 2, i); } } } } redraw = 0; } }
static void displayFullScreenPicture(){ s16 i,j,k; u16 tmp_tile_index; SYS_disableInts(); VDP_clearPlan(APLAN, 0); VDP_clearPlan(BPLAN, 0); /* Set a larger tileplan to be able to scroll */ VDP_setPlanSize(64, 32); /* Draw the background */ // VDP_drawImageEx(BPLAN, &pic00, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 0, TRUE, TRUE); // vramIndex += pic00.tileset->numTile; VDP_setScrollingMode(HSCROLL_PLANE, VSCROLL_PLANE); VDP_setVerticalScroll(PLAN_B, 0); VDP_setVerticalScroll(PLAN_A, 0); VDP_setHorizontalScroll(PLAN_B, 0); VDP_setHorizontalScroll(PLAN_A, 0); SYS_enableInts(); // vramIndex = 0; VDP_waitDMACompletion(); while (1){ /* Pic 0 */ // tmp_tile_index = curTileInd; SYS_disableInts(); VDP_drawImageEx(APLAN, &pic00, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 0, TRUE, TRUE); SYS_enableInts(); RSE_pause(RSE_FRAMES(1*60)); RSE_pause(RSE_FRAMES(2*60)); VDP_fadeOut(1, 63, 16, FALSE); RSE_turn_screen_to_black(); VDP_waitDMACompletion(); for(i = 0; i < 224 >> 3; i++) { VDP_waitVSync(); RSE_clearTileRowB(i); RSE_clearTileRowA(i); } /* Pic 1 */ // curTileInd = tmp_tile_index; SYS_disableInts(); VDP_drawImageEx(APLAN, &pic01a, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 12 >> 3, TRUE, TRUE); VDP_waitDMACompletion(); VDP_drawImageEx(BPLAN, &pic01b, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, vramIndex + pic01a.tileset->numTile), 0, 12 >> 3, TRUE, TRUE); SYS_enableInts(); RSE_pause(RSE_FRAMES(3*60)); VDP_fadeOut(1, 63, 16, FALSE); RSE_turn_screen_to_black(); VDP_waitDMACompletion(); for(i = 0; i < 224 >> 3; i++) { VDP_waitVSync(); RSE_clearTileRowB(i); RSE_clearTileRowA(i); } /* Pic 2 */ // curTileInd = tmp_tile_index; SYS_disableInts(); VDP_drawImageEx(APLAN, &pic02a, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), (320 - 256) >> 4, 0, TRUE, TRUE); VDP_waitDMACompletion(); VDP_drawImageEx(BPLAN, &pic02b, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, vramIndex + pic02a.tileset->numTile), (320 - 256) >> 4, 0, TRUE, TRUE); SYS_enableInts(); RSE_pause(RSE_FRAMES(3*60)); VDP_fadeOut(1, 63, 16, FALSE); RSE_turn_screen_to_black(); VDP_waitDMACompletion(); for(i = 0; i < 224 >> 3; i++) { VDP_waitVSync(); RSE_clearTileRowB(i); RSE_clearTileRowA(i); } /* Pic 9 */ // curTileInd = tmp_tile_index; SYS_disableInts(); VDP_drawImageEx(APLAN, &pic09, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, vramIndex), 0, 0, TRUE, TRUE); SYS_enableInts(); RSE_pause(RSE_FRAMES(3*60)); VDP_fadeOut(1, 63, 16, FALSE); RSE_turn_screen_to_black(); VDP_waitDMACompletion(); for(i = 0; i < 224 >> 3; i++) { VDP_waitVSync(); RSE_clearTileRowB(i); RSE_clearTileRowA(i); } } }