void GM_Level() { _restart: v_gamemode |= GameMode_PreLevel; // flag that we're in pre-level sequence if(f_demo != DemoMode_Credits) PlaySound_Special(BGM_Fade); ClearPLC(); PaletteFadeOut(); // If we're not doing an ending sequence demo... if(f_demo != DemoMode_Credits) { DISABLE_INTERRUPTS(); NemDec(Nem_TitleCard, 0xB000); ENABLE_INTERRUPTS(); auto plc1 = LevelHeaders[v_zone].gfx >> 24; if(plc1 != 0) AddPLC(plc1); // load level patterns AddPLC(PLC_Main2); // load standard patterns }
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); } }
void __fastcall run_game_loop(int uMsg) { //int v3; // eax bool v5; // zf //int v6; // eax signed int v7; // [esp+8h] [ebp-24h] LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // [esp+Ch] [ebp-20h] struct tagMSG msg; // [esp+10h] [ebp-1Ch] nthread_ignore_mutex(1); start_game(uMsg); saveProc = SetWindowProc(GM_Game); control_update_life_mana(); msg_process_net_packets(); gbRunGame = 1; gbProcessPlayers = 1; gbRunGameResult = 1; drawpanflag = 255; DrawAndBlit(); PaletteFadeIn(8); drawpanflag = 255; gbGameLoopStartup = 1; nthread_ignore_mutex(0); while ( gbRunGame ) { diablo_color_cyc_logic(); if ( PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE) ) { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); while ( PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE) ) { if ( msg.message == WM_QUIT ) { gbRunGameResult = 0; gbRunGame = 0; break; } TranslateMessage(&msg); DispatchMessageA(&msg); } if ( !gbRunGame || (v7 = 1, !nthread_has_500ms_passed()) ) v7 = 0; SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); v5 = v7 == 0; } else { //_LOBYTE(v6) = nthread_has_500ms_passed(); v5 = nthread_has_500ms_passed() == 0; } if ( !v5 ) { multi_process_network_packets(); game_loop(gbGameLoopStartup); msgcmd_send_chat(); gbGameLoopStartup = 0; DrawAndBlit(); } #ifdef SLEEP Sleep(1); #endif } if ( (unsigned char)gbMaxPlayers > 1u ) pfile_write_hero(); pfile_flush_W(); PaletteFadeOut(8); SetCursor(0); ClearScreenBuffer(); drawpanflag = 255; scrollrt_draw_game_screen(1); SetWindowProc(saveProc); free_game(); if ( cineflag ) { cineflag = 0; DoEnding(); } }