void bios_boot_demo(void) { VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); VDP_setHInterrupt(0); term_print(" ___ ___ ___ ___ ___ ___ ___ ___ ___", 1); term_print(" |___ |__ | _ |___| | _ |__ |\\ | |__ |___ | |___ ", 1); term_print(" ___| |___ |___| | | |___| |___ | \\| |___ ___| | ___|", 1); term_print("", 20); term_print(" Entry Vector 0x202", 2); term_print(" CSHBIOS(C)2016 Computer Science House", 2); term_print(" MD-VA6 BOOT ROM Revision 3", 30); term_print("", 0); term_print(" CPU1 : Motorola 68000 7.6MHz", 2); term_print(" Speed : 7.61 MHz", 2); term_print("", 0); term_print(" CPU2 : Zilog Z80 3.8MHz", 2); term_print(" Speed : 3.80 MHz", 60); term_print("", 0); term_print(" Press DEL to run Setup", 0); term_print(" Press <F8> for BBS POPUP", 170); term_print("", 0); term_print(" SRAM Asynchronous 2 x 65256 (64k x 8), single channel, parallel", 16); term_print(" Checking SRAM...", 60); term_print(" 8K OK", 7); term_print(" 16K OK", 7); term_print(" 24K OK", 7); term_print(" 32K OK", 7); term_print(" 40K OK", 7); term_print(" 48K OK", 7); term_print(" 56K OK", 7); term_print(" 64K OK", 60); term_print("", 0); term_print(" VDP : Sega 315-5313 (Yamaha YM7101)", 2); term_print(" Speed: 56MHz", 2); term_print(" VRAM: 64K Serial Out Parallel Load DRAM", 2); term_print(" CRAM: 64 x 9", 2); term_print(" TMSS Enabled", 1); term_print("", 60); term_print(" 0xC00000 : Data Port", 20); term_print(" 0xC00004 : Control Port", 20); term_print(" 0xC00008 : H/V counter", 20); term_print(" 0xC00011 : SN76489", 20); term_print(" 0xC0001C : Debug Register", 70); term_print("", 0); term_print(" Starting demo...", 120); }
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 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"); }
//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 }
int main(void) { music_init(); music_play(3); u16 delay_mod = 4; u16 col_inc_cnt = 0; setup(); reset_demo: hint_val = 3; col = 0; col_off = 0; phrase_num = 0; scroll_off = 0; dscroll = 0; term_pos = 0; term_scrolling = 0; sprites_dma_simple(); term_pos = 0; VDP_setHInterrupt(0); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); // Greyscale palette for text VDP_setPaletteColor(0,0x000); VDP_setPaletteColor(1,0x444); VDP_setPaletteColor(2,0x888); VDP_setPaletteColor(3,0xEEE); VDP_setScreenWidth256(); bios_boot_demo(); VDP_setScreenWidth320(); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); awful_put_logo(8, 2); startup_stretch(); VDP_setVerticalScroll(PLAN_A, 252); VDP_setVerticalScroll(PLAN_B, 252); VDP_setHIntCounter(hint_val); SYS_setHIntCallback((_voidCallback *)h_int); volatile u8 p1 = pad_read(0); sprites_init(); col_puts40(8,0,"Computer Science House"); // Initialize background stars star stars[NUM_STARS]; u16 i = 0; for (i = 0; i < NUM_STARS; i++) { stars[i].x = i * 5; stars[i].y = 128 + i * 8; stars[i].speed = (i % 7) + 1; stars[i].offset = (3 * i) % 4; stars[i].size = (i % 4 == 0) ? ('.' + COL_FONT_VRAM_OFFSET) : (128 + '.' + COL_FONT_VRAM_OFFSET); } print_phrase(8); u16 delay = 0; u8 dir = 0; VDP_setHInterrupt(1); for (;;) { delay++; if (col_inc_cnt == 0) { col_inc_cnt = hint_val; col_off += 0x002; } else { col_inc_cnt--; } if (delay == 512) { if (phrase_num == 8) { phrase_num = 0; VDP_setHInterrupt(0); sprite_set(0, 0, 0, 0, 0, 0); sprites_dma_simple(); while (vbl_wait) { __asm__("nop"); } vbl_wait = 1; goto reset_demo; } hint_val++; if (hint_val == 10) { hint_val = 3; } delay_mod = delay_mod >> 1; if (delay_mod == 0) { delay_mod = delay_mod = 4; } VDP_setHIntCounter(hint_val); VDP_setHInterrupt(0); print_phrase(phrase_num); VDP_setHInterrupt(1); phrase_num++; delay = 0; } process_stars(&stars); while (vbl_wait) { __asm__("nop"); } VDP_setHInterrupt(0); VDP_setPaletteColor(14,palette[col]); col = col_off; vbl_wait = 1; sprites_dma_simple(); VDP_setHInterrupt(1); } return 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); } } }
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; } }
void titleScreen() { snowflake snowflakes[TITLE_SCREEN_SNOWFLAKES]; SpriteDef sfdefs[TITLE_SCREEN_SNOWFLAKES]; VDP_resetScreen(); VDP_resetSprites(); // Load Swirls VDP_loadTileData(swirls, TILE_USERINDEX, 20, TRUE); VDP_loadTileData(title_screen, TILE_USERINDEX + 20, 15, TRUE); VDP_loadTileData(swirl_spr, TILE_USERINDEX + 35, 20, TRUE); VDP_setPalette(PAL1, swirl_pal); VDP_setPalette(PAL2, sel_pal); VDP_setPalette(PAL3, ts_pal); JOY_init(); JOY_setEventHandler(titleHandler); ImageAsset* title = getImage(titlbg); VDP_setPalette(PAL0, title->palette); VDP_loadTileData(title->tiles, TILE_USERINDEX + 55, (title->xTiles * title->yTiles), TRUE); VDP_fillTileMapRectInc(VDP_PLAN_B, TILE_ATTR_FULL(PAL0, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 55), 0, 0, title->xTiles, title->yTiles); MEM_free( title ); VDP_fillTileMapRectInc(VDP_PLAN_A, TILE_ATTR_FULL(PAL3, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 20), 18, 3, 5, 3); VDP_drawText("Mega Swirl", 1, 7); VDP_drawText("Testing Demo", 1, 8); VDP_drawText(VERSION_STRING, 1, 9); VDP_drawText("Music from Deflemask by", 1, 11); VDP_drawText("Delek", 1, 12); VDP_drawText("Featuring artwork by", 1, 14); VDP_drawText("Radioactivemantaray", 1, 15); VDP_drawText("- Press Start to Play -", 1, 21); VDP_drawText(BUILD_DATE, 1, 24); u8 selected_swirl; for(int i = 0; i != TITLE_SCREEN_SNOWFLAKES; i++) { snowflakes[i].startedAt = snowflakes[i].startDelay = snowflakes[i].fallRate = snowflakes[i].swirltype = 0; sfdefs[i].posx = sfdefs[i].posy = sfdefs[i].tile_attr = sfdefs[i].size = sfdefs[i].link = 0; selected_swirl = (custrand() % 4); snowflakes[i].swirltype = selected_swirl; // Select one of four swirl types snowflakes[i].startDelay = ((custrand() % 3000) + 1) / 300; // Select between a 1-10 second delay (300 ticks per second) snowflakes[i].startedAt = getTick(); // Time when this snowflake was created snowflakes[i].fallRate = (custrand() % 2) + 1; // Select how fast this snowflake should fall to the bottom of the screen sfdefs[i].posx = (custrand() % 320); // Select X position for this swirl sfdefs[i].posy = -16; // Start it off screen sfdefs[i].size = SPRITE_SIZE(2, 2); sfdefs[i].tile_attr = TILE_ATTR_FULL(PAL1, PRIORITY_HIGH, FALSE, FALSE, TILE_USERINDEX + 35 + (4 * selected_swirl)); // This will need to be changed as we need tiles arranged for sprites if(i != 0) { sfdefs[i - 1].link = i; } } VDP_setSpritesDirect(0, sfdefs, TITLE_SCREEN_SNOWFLAKES); Z80_loadDriver(Z80_DRIVER_VGM, 1); Z80_requestBus(1); YM2612_enableDAC(); Z80_releaseBus(); SND_startPlay_VGM(muz_title); while (waitflag == FALSE) { for(int i = 0; i != TITLE_SCREEN_SNOWFLAKES; i++) { if(getTick() - snowflakes[i].startedAt >= snowflakes[i].startDelay) { if(sfdefs[i].posy != 240) { sfdefs[i].posy = sfdefs[i].posy + snowflakes[i].fallRate; } else { selected_swirl = (custrand() % 4); snowflakes[i].startDelay = ((custrand() % 3000) + 1) / 300; snowflakes[i].startedAt = getTick(); snowflakes[i].fallRate = (custrand() % 2) + 1; sfdefs[i].posx = (custrand() % 320); sfdefs[i].posy = -16; } } VDP_setSpritesDirect(0, sfdefs, TITLE_SCREEN_SNOWFLAKES); } } waitflag = FALSE; srand(GET_HVCOUNTER); VDP_clearPlan(APLAN, FALSE); JOY_setEventHandler(joyHandler); ImageAsset* test = getImage(swlspace); VDP_setPalette(PAL0, test->palette); VDP_loadTileData(test->tiles, TILE_USERINDEX + 55, (test->xTiles * test->yTiles), TRUE); VDP_fillTileMapRectInc(VDP_PLAN_B, TILE_ATTR_FULL(PAL0, PRIORITY_LOW, FALSE, FALSE, TILE_USERINDEX + 55), 0, 0, test->xTiles, test->yTiles); MEM_free( test ); SND_stopPlay_VGM(); }
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); } }