IFACEMETHODIMP CanvasSwapChain::WaitForVerticalBlank() { return ExceptionBoundary( [&] { auto& device = m_device.EnsureNotClosed(); auto deviceInternal = As<ICanvasDeviceInternal>(device); auto output = deviceInternal->GetPrimaryDisplayOutput(); // // Only hardware devices and WARP devices under MSBDA have // access to display output. We do a yield on // render-only (explicitly requested) SW devices, where // the output will be null. // if (output) { ThrowIfFailed(output->WaitForVBlank()); } else { m_adapter->Sleep(0); } }); }
//--------------------------------------------------------------------------------- int main(void) { short scrX=0, scrY=0; unsigned short pad0, move; // Initialize SNES consoleInit(); // Copy tiles to VRAM bgInitTileSet(0, &LandTiles, &LandPalette, 1, (&LandTiles_end - &LandTiles), (&LandPalette_end - &LandPalette), BG_16COLORS, 0x0000); bgInitTileSet(2, &CloudTiles, &CloudPalette, 0, (&CloudTiles_end - &CloudTiles), (&CloudPalette_end - &CloudPalette), BG_4COLORS, 0x1000); // Copy Map to VRAM bgInitMapSet(0, &Maps, (&Maps_end - &Maps),SC_32x32, 0x2000); bgInitMapSet(2, &Mapsc, (&Mapsc_end - &Mapsc),SC_32x32, 0x2400); // Now Put in 16 color mode and put cloud on top of screen setMode(BG_MODE1,BG3_MODE1_PRORITY_HIGH); bgSetDisable(1); // Set BG3 SubScreen and bgSetEnableSub(2); // enable Subscreen Color ADD/SUB and Color addition on BG1 and Backdrop color setColorEffect(CM_SUBBGOBJ_ENABLE, CM_MSCR_BACK | CM_MSCR_BG1); // Wait for nothing :P while(1) { // change scrolling scrX++; bgSetScroll(2, scrX,0); WaitForVBlank(); } return 0; }
//--------------------------------------------------------------------------------- int main(void) { u16 scrX=0, scrY=0; u16 pad0, move; // Initialize SNES consoleInit(); // Initialize text console with our font consoleInitText(0, 1, &snesfont); // Copy tiles to VRAM bgInitTileSet(1, &patterns, &palette, 0, (&patterns_end - &patterns), 16*2, BG_16COLORS, 0x4000); // Copy Map to VRAM bgInitMapSet(1, &map, (&map_end - &map),SC_64x64, 0x1000); // Now Put in 16 color mode and disable last BG setMode(BG_MODE1,0); bgSetDisable(2); // Wait for nothing :P while(1) { // no move currently move = 0; // Refresh pad values scanPads(); // Get current #0 pad pad0 = padsCurrent(0); // Update scrolling with current pad switch (pad0) { case KEY_RIGHT : scrX+=2; move = 1; break; case KEY_LEFT : scrX-=2; move = 1; break; case KEY_DOWN : scrY+=2; move = 1; break; case KEY_UP : scrY-=2; move = 1; break; } if (move) bgSetScroll(1, scrX,scrY); // Just inform user consoleDrawText(0,0,"SCR X=%d Y=%d",scrX,scrY); WaitForVBlank(); } return 0; }
//--------------------------------------------------------------------------------- int main(void) { // Initialize SNES consoleInit(); // Put current handler to our function spr_queue = 0xff; spr_mutex = 0; __nmi_handler=myconsoleVblank; // Init Sprites gfx and palette with default size of 16x16 (and don't load sprite tiles) oamInitGfxSet(&gfxpsrite, 2, &palsprite, 16*2, 0, ADRGFXSPR, OBJ_SIZE16); // Define sprites parmaters oamSet(0, 100, 100, 3, 0, 0, 0, 0); // Put sprite in 100,100, with maximum priority 3 from tile entry 0, palette 0 oamSetEx(0, OBJ_SMALL, OBJ_SHOW); // Now Put in 16 color mode and disable all backgrounds setMode(BG_MODE1,0); bgSetDisable(0); bgSetDisable(1); bgSetDisable(2); // add new sprite to queue addSprite(&gfxpsrite, ADRGFXSPR); // Wait for nothing :P while(1) { // Refresh pad values in VBL and Get current #0 pad pad0 = padsCurrent(0); if (pad0) { // Key A pressed if(pad0 & KEY_A) { // if not yet pressed if (padkeya == 0) { padkeya=1; // avoid adding new sprite continuisly // add new sprite to queue addSprite((&gfxpsrite)+8*4*2, ADRGFXSPR); } } else padkeya=0; } // Wait VBL 'and update sprites too ;-) ) WaitForVBlank(); } return 0; }
//--------------------------------------------------------------------------------- int main(void) { // Initialize SNES consoleInit(); // Copy tiles to VRAM bgInitTileSet(0, &patterns, &palette, 0, (&patterns_end - &patterns), (&palette_end - &palette), BG_16COLORS, 0x4000); // Copy Map to VRAM bgInitMapSet(0, &map, (&map_end - &map),SC_32x32, 0x0000); // Now Put in 16 color mode and disable other BGs except 1st one setMode(BG_MODE1,0); bgSetDisable(1); bgSetDisable(2); // Wait for nothing :P while(1) { WaitForVBlank(); } return 0; }
//--------------------------------------------------------------------------------- void splash(void) { int counter = 0; consoleInitText(0, 0, &snesfont); consoleSetShadowCol(0,RGB15(16,16,16)); setMode(BG_MODE1,0); bgSetDisable(1); bgSetDisable(2); consoleDrawText(12,10,"WARNING !"); consoleDrawText(1,14,"This is game is played in Tate"); consoleDrawText(2,16,"(Screen should be vertical)"); while(counter<400) { counter++; WaitForVBlank(); } consoleDrawText(12,10," "); consoleDrawText(1,14," "); consoleDrawText(2,16," "); return; }
void GM_Title() { PlaySound_Special(BGM_Stop); ClearPLC(); PaletteFadeOut(); DISABLE_INTERRUPTS(); SoundDriverLoad(); VDP_RegWrite(0x00, 4); // 8-colour mode VDP_RegWrite(0x02, vram_fg >> 10); // set foreground nametable address VDP_RegWrite(0x04, vram_bg >> 13); // set background nametable address VDP_RegWrite(0x10, 1); // 64-cell hscroll size VDP_RegWrite(0x12, 0); // window vertical position VDP_RegWrite(0x0B, 3); VDP_RegWrite(0x07, 0x20); // set background colour (palette line 2, entry 0) f_wtr_state = 0; ClearScreen(); Clear_Objects(); NemDec(Nem_JapNames, 0); NemDec(Nem_CreditText, 0x14C0); EniDec(Eni_JapNames, 0xFF0000, 0); CopyTilemap(0xFF0000, 0xC000, 0x27, 0x1B); Clear_Palette(v_pal_dry_dup); PalLoad1(Palette_Sonic); v_objspace[2].id = ID_CreditsText; ExecuteObjects(); BuildSprites(); PaletteFadeIn(); DISABLE_INTERRUPTS(); NemDec(Nem_TitleFg, 0x4000); NemDec(Nem_TitleSonic, 0x6000); NemDec(Nem_TitleTM, 0xA200); CopyToVRAM(Art_Text, 0xD000, 0x290 * sizeof(ushort)); v_lastlamp = 0; v_debuguse = 0; f_demo = 0; v_w_FFEA = 0; v_zone = 0; v_pcyc_time = 0; LevelSizeLoad(); DeformLayers(); EniDec(Blk16_GHZ, v_16x16, 0); KosDec(Blk256_GHZ, v_256x256); LevelLayoutLoad(); PaletteFadeOut(); DISABLE_INTERRUPTS(); ClearScreen(); DrawChunks(0x6000, &v_bg1posx, v_lvllayout + 0x40); EniDec(Eni_Title, 0xFF0000, 0); CopyTilemap(0xFF0000, 0xC206, 0x21, 0x15); NemDec(Nem_GHZ_1st, 0); PalLoad1(Palette_Title); PlaySound_Special(BGM_Title); f_debugmode = 0; v_demolength = 0x178; memset(&v_objspace[2], 0, 32); v_objspace[1].id = ID_TitleSonic; v_objspace[2].id = ID_PSBTM; // "PRESS START BUTTON" if(v_megadrive & 0x80) { // Outside Japan, load the TM object v_objspace[3].id = ID_PSBTM; v_objspace[3].frame = 3; } v_objspace[4].id = ID_PSBTM; v_objspace[4].frame = 2; // sprite line limiter..? ExecuteObjects(); DeformLayers(); BuildSprites(); NewPLC(PLC_Main); v_title_dcount = 0; v_title_ccount = 0; VDP_Control(v_vdp_buffer1 | 0x40); PaletteFadeIn(); do { WaitForVBlank(VBlank_Title); ExecuteObjects() DeformLayers(); BuildSprites(); PCycle_Title(); RunPLC(); v_objspace[0].x += 2; if(v_objspace[0].x >= 7168) { v_gamemode = GameMode_Sega; return; } auto levSelCode = (v_megadrive & 0x80) ? LevSelCode_US : LevSelCode_J; auto buttons = v_jpadpress1 & Buttons_Dir; if(buttons == levSelCode[v_title_dcount]) { v_title_dcount++; if(buttons == 0) { auto count = (v_title_ccount >> 1) & 3; if(count == 0) f_levselcheat = true; else if(v_megadrive & 0x80) { // International version f_debugcheat = true; f_slomocheat = true; } else { /// Japanese version if(count == 1) f_slomocheat = true; else if(count == 2) f_debugcheat = true; else f_creditscheat = true; } PlaySound_Special(SFX_Ring); } }
int main(void) { // Initialize SNES consoleInit(); // Initialize text console with our font consoleInitText(0, 1, &snesfont); // Copy tiles to VRAM bgInitTileSet(1, &patterns, &palette, 0, (&patterns_end - &patterns), (&palette_end - &palette), BG_16COLORS, 0x4000); // Copy Map to VRAM bgInitMapSet(1, &map, (&map_end - &map),SC_32x32, 0x0000); // Now Put in 16 color mode and disable other BGs except 1st one //setMode(BG_MODE1,0); bgSetDisable(1); bgSetDisable(2); setMode(BG_MODE1,0); bgSetDisable(2); // Just inform user // consoleDrawText(1,1,"test text"); // Wait for nothing :P //while(1) { // WaitForVBlank(); //} sendByte(0x02); //send magic byte int pad0; int set=0; while(1) { set=0; // Refresh pad values scanPads(); // Get current #0 pad pad0 = padsCurrent(0); clean(); // Update scrolling with current pad switch (pad0) { case KEY_UP : set=1; consoleDrawText(22,14,"g"); //7 r consoleDrawText(22,19,"a"); //1 x consoleDrawText(25,21,"b"); //2 a consoleDrawText(22,23,"c"); //3 b consoleDrawText(20,21,"d"); //4 y consoleDrawText(12,20,"e"); //5 se consoleDrawText(15,20,"f"); //6 st break; case KEY_RIGHT : set=2; consoleDrawText(22,14,"n"); consoleDrawText(22,19,"h"); consoleDrawText(25,21,"i"); consoleDrawText(22,23,"j"); consoleDrawText(20,21,"k"); consoleDrawText(12,20,"l"); consoleDrawText(15,20,"m"); break; case KEY_DOWN : set=3; consoleDrawText(22,14,"u"); consoleDrawText(22,19,"o"); consoleDrawText(25,21,"p"); consoleDrawText(22,23,"q"); consoleDrawText(20,21,"r"); consoleDrawText(12,20,"s"); consoleDrawText(15,20,"t"); break; case KEY_LEFT : set=4; consoleDrawText(20,14,"blank"); consoleDrawText(22,19,"v"); consoleDrawText(25,21,"w"); consoleDrawText(22,23,"x"); consoleDrawText(20,21,"y"); consoleDrawText(12,20,"z"); consoleDrawText(15,20," "); break; case KEY_L : if(pos!=0){ pos--; str[pos]=0x00; consoleDrawText(3+pos,9," "); } while(pad0 & KEY_L){ scanPads(); pad0 = padsCurrent(0); } break; case KEY_R : sendString(); while(pad0 & KEY_R){ scanPads(); pad0 = padsCurrent(0); } break; } /* KEY_A = BIT(7), //!< pad A button. KEY_B = BIT(15), //!< pad B button. KEY_SELECT = BIT(13), //!< pad SELECT button. KEY_START = BIT(12), //!< pad START button. KEY_RIGHT = BIT(8), //!< pad RIGHT button. KEY_LEFT = BIT(9), //!< pad LEFT button. KEY_DOWN = BIT(10), //!< pad DOWN button. KEY_UP = BIT(11), //!< pad UP button. KEY_R = BIT(4), //!< Right shoulder button. KEY_L = BIT(5), //!< Left shoulder button. KEY_X = BIT(6), //!< pad X button. KEY_Y = BIT(14), //!< pad Y button. * */ if( (pad0&KEY_UP)&&(pad0&KEY_A) ){ addChar(11,7,'b'); } if( (pad0&KEY_UP)&&(pad0&KEY_B) ){ addChar(11,15,'c'); } if( (pad0&KEY_UP)&&(pad0&KEY_X) ){ addChar(11,6,'a'); } if( (pad0&KEY_UP)&&(pad0&KEY_Y) ){ addChar(11,14,'d'); } if( (pad0&KEY_UP)&&(pad0&KEY_START) ){ addChar(11,12,'f'); } if( (pad0&KEY_UP)&&(pad0&KEY_SELECT) ){ addChar(11,13,'e'); } if( (pad0&KEY_UP)&&(pad0&KEY_R) ){ addChar(11,4,'g'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_A) ){ addChar(10,7,'p'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_B) ){ addChar(10,15,'q'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_X) ){ addChar(10,6,'o'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_Y) ){ addChar(10,14,'r'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_START) ){ addChar(10,12,'t'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_SELECT) ){ addChar(10,13,'s'); } if( (pad0&KEY_DOWN)&&(pad0&KEY_R) ){ addChar(10,4,'u'); } if( (pad0&KEY_LEFT)&&(pad0&KEY_A) ){ addChar(9,7,'w'); } if( (pad0&KEY_LEFT)&&(pad0&KEY_B) ){ addChar(9,15,'x'); } if( (pad0&KEY_LEFT)&&(pad0&KEY_X) ){ addChar(9,6,'v'); } if( (pad0&KEY_LEFT)&&(pad0&KEY_Y) ){ addChar(9,14,'y'); } //if( (pad0&KEY_LEFT)&&(pad0&KEY_START) ){ addChar(9,12,'f'); } if( (pad0&KEY_LEFT)&&(pad0&KEY_SELECT) ){ addChar(9,13,'z'); } if( (pad0&KEY_LEFT)&&(pad0&KEY_R) ){ addChar(9,4,' '); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_A) ){ addChar(8,7,'i'); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_B) ){ addChar(8,15,'j'); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_X) ){ addChar(8,6,'h'); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_Y) ){ addChar(8,14,'k'); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_START) ){ addChar(8,12,'m'); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_SELECT) ){ addChar(8,13,'l'); } if( (pad0&KEY_RIGHT)&&(pad0&KEY_R) ){ addChar(8,4,'n'); } consoleDrawText(7,3,"snesnet text demo"); consoleDrawText(7,14,"back"); if(set==0) consoleDrawText(20,14,"send"); consoleDrawText(6,17,"set"); WaitForVBlank(); } return 0; }
void WaitForVBlank(int routine) { v_vbla_routine = routine; WaitForVBlank(); }