diff --git a/Makefile b/Makefile index 1a6e677..edaf3e3 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ include $(DEVKITARM)/3ds_rules # - /default_icon.png #--------------------------------------------------------------------------------- APP_TITLE := SNES9x for 3DS -APP_DESCRIPTION := High compatibility SNES emulator for 3DS. Based on SNES9x 1.43. +APP_DESCRIPTION := SNES emulator for 3DS. APP_AUTHOR := bubble2k16 ASSETS := assets ICON := $(ASSETS)/icon.png diff --git a/source/3dsconfig.cpp b/source/3dsconfig.cpp index 11a9806..09d26eb 100644 --- a/source/3dsconfig.cpp +++ b/source/3dsconfig.cpp @@ -70,7 +70,6 @@ void config3dsReadWriteInt32(const char *format, int *value, int minValue, int m *value = minValue; if (*value > maxValue) *value = maxValue; - //printf ("Scanned %d\n", *value); } else { diff --git a/source/3dsfiles.cpp b/source/3dsfiles.cpp index 3b47a2d..27d240e 100644 --- a/source/3dsfiles.cpp +++ b/source/3dsfiles.cpp @@ -28,12 +28,15 @@ static char currentDir[_MAX_PATH] = ""; void file3dsInitialize(void) { getcwd(currentDir, _MAX_PATH); +#ifdef RELEASE if (currentDir[0] == '/') { char tempDir[_MAX_PATH]; + sprintf(tempDir, "sdmc:%s", currentDir); strcpy(currentDir, tempDir); } +#endif } @@ -95,7 +98,7 @@ void file3dsGoToParentDirectory(void) //---------------------------------------------------------------------- void file3dsGoToChildDirectory(const char* childDir) { - strncat(currentDir, childDir, _MAX_PATH); + strncat(currentDir, &childDir[2], _MAX_PATH); strncat(currentDir, "/", _MAX_PATH); } @@ -158,7 +161,7 @@ void file3dsGetFiles(std::vector& files, const std::vectord_type == DT_DIR) { - files.emplace_back(std::string(dir->d_name), FileEntryType::ChildDirectory); + files.emplace_back(std::string("\x01 ") + std::string(dir->d_name), FileEntryType::ChildDirectory); } if (dir->d_type == DT_REG) { diff --git a/source/3dsgpu.cpp b/source/3dsgpu.cpp index 8570192..3b4f4e3 100644 --- a/source/3dsgpu.cpp +++ b/source/3dsgpu.cpp @@ -170,8 +170,13 @@ void gpu3dsCheckSlider() } else if (sliderVal < 0.3) { - gfxTopRightFramebuffers[0] = gfxOldTopRightFramebuffers[0]; - gfxTopRightFramebuffers[1] = gfxOldTopRightFramebuffers[1]; + u8 isNew3DS = 0; + APT_CheckNew3DS(&isNew3DS); + if (!isNew3DS) + { + gfxTopRightFramebuffers[0] = gfxOldTopRightFramebuffers[0]; + gfxTopRightFramebuffers[1] = gfxOldTopRightFramebuffers[1]; + } gpu3dsSetParallaxBarrier(false); } else if (sliderVal < 0.6) diff --git a/source/3dsimpl.cpp b/source/3dsimpl.cpp index d557bbd..e04a26c 100644 --- a/source/3dsimpl.cpp +++ b/source/3dsimpl.cpp @@ -875,8 +875,8 @@ void S9xSyncSpeed (void) } uint32 prevConsoleJoyPad = 0; -u32 prevConsoleButtonPressed[8]; -u32 buttons3dsPressed[8]; +u32 prevConsoleButtonPressed[10]; +u32 buttons3dsPressed[10]; uint32 S9xReadJoypad (int which1_0_to_4) { @@ -910,6 +910,8 @@ uint32 S9xReadJoypad (int which1_0_to_4) SET_CONSOLE_JOYPAD(BTN3DS_Y, KEY_Y, settings3DS.GlobalButtonMapping) SET_CONSOLE_JOYPAD(BTN3DS_SELECT, KEY_SELECT, settings3DS.GlobalButtonMapping); SET_CONSOLE_JOYPAD(BTN3DS_START, KEY_START, settings3DS.GlobalButtonMapping); + SET_CONSOLE_JOYPAD(BTN3DS_ZL, KEY_ZL, settings3DS.GlobalButtonMapping) + SET_CONSOLE_JOYPAD(BTN3DS_ZR, KEY_ZR, settings3DS.GlobalButtonMapping) } else { @@ -921,8 +923,11 @@ uint32 S9xReadJoypad (int which1_0_to_4) SET_CONSOLE_JOYPAD(BTN3DS_Y, KEY_Y, settings3DS.ButtonMapping) SET_CONSOLE_JOYPAD(BTN3DS_SELECT, KEY_SELECT, settings3DS.ButtonMapping); SET_CONSOLE_JOYPAD(BTN3DS_START, KEY_START, settings3DS.ButtonMapping); + SET_CONSOLE_JOYPAD(BTN3DS_ZL, KEY_ZL, settings3DS.ButtonMapping) + SET_CONSOLE_JOYPAD(BTN3DS_ZR, KEY_ZR, settings3DS.ButtonMapping) } + // Handle turbo / rapid fire buttons. // int *turbo = settings3DS.Turbo; @@ -956,6 +961,8 @@ uint32 S9xReadJoypad (int which1_0_to_4) HANDLE_TURBO(BTN3DS_Y, settings3DS.GlobalButtonMapping); HANDLE_TURBO(BTN3DS_L, settings3DS.GlobalButtonMapping); HANDLE_TURBO(BTN3DS_R, settings3DS.GlobalButtonMapping); + HANDLE_TURBO(BTN3DS_ZL, settings3DS.GlobalButtonMapping); + HANDLE_TURBO(BTN3DS_ZR, settings3DS.GlobalButtonMapping); } else { @@ -965,6 +972,8 @@ uint32 S9xReadJoypad (int which1_0_to_4) HANDLE_TURBO(BTN3DS_Y, settings3DS.ButtonMapping); HANDLE_TURBO(BTN3DS_L, settings3DS.ButtonMapping); HANDLE_TURBO(BTN3DS_R, settings3DS.ButtonMapping); + HANDLE_TURBO(BTN3DS_ZL, settings3DS.ButtonMapping); + HANDLE_TURBO(BTN3DS_ZR, settings3DS.ButtonMapping); } prevConsoleJoyPad = consoleJoyPad; diff --git a/source/3dsimpl.h b/source/3dsimpl.h index f5e54cd..320cf08 100644 --- a/source/3dsimpl.h +++ b/source/3dsimpl.h @@ -10,8 +10,10 @@ #define BTN3DS_Y 3 #define BTN3DS_L 4 #define BTN3DS_R 5 -#define BTN3DS_SELECT 6 -#define BTN3DS_START 7 +#define BTN3DS_ZL 6 +#define BTN3DS_ZR 7 +#define BTN3DS_SELECT 8 +#define BTN3DS_START 9 //--------------------------------------------------------- // 3DS textures diff --git a/source/3dsimpl_gpu.cpp b/source/3dsimpl_gpu.cpp index ae99073..0d404d3 100644 --- a/source/3dsimpl_gpu.cpp +++ b/source/3dsimpl_gpu.cpp @@ -1,6 +1,7 @@ #include "snes9x.h" #include "ppu.h" +#include "3dssettings.h" #include <3ds.h> #include "3dsgpu.h" @@ -8,6 +9,7 @@ #include "3dsimpl_gpu.h" SGPU3DSExtended GPU3DSExt; +extern S9xSettings3DS settings3DS; void gpu3dsSetMode7UpdateFrameCountUniform(); diff --git a/source/3dsinput.cpp b/source/3dsinput.cpp index 9fb44d2..adba446 100644 --- a/source/3dsinput.cpp +++ b/source/3dsinput.cpp @@ -63,7 +63,10 @@ u32 input3dsScanInputForEmulation() // ----------------------------------------------- #endif - if (keysDown & KEY_TOUCH || settings3DS.ButtonHotkeyOpenMenu.IsHeld(keysDown)) + if (keysDown & KEY_TOUCH || + (!settings3DS.UseGlobalEmuControlKeys && settings3DS.ButtonHotkeyOpenMenu.IsHeld(keysDown)) || + (settings3DS.UseGlobalEmuControlKeys && settings3DS.GlobalButtonHotkeyOpenMenu.IsHeld(keysDown)) + ) { impl3dsTouchScreenPressed(); diff --git a/source/3dsmain.cpp b/source/3dsmain.cpp index 0a92a6e..79a91bf 100644 --- a/source/3dsmain.cpp +++ b/source/3dsmain.cpp @@ -355,6 +355,20 @@ std::vector makeOptionsForButtonMapping() { return items; } +std::vector makeOptionsFor3DSButtonMapping() { + std::vector items; + AddMenuDialogOption(items, 0, "-"s); + AddMenuDialogOption(items, static_cast(KEY_A), "3DS A Button"s); + AddMenuDialogOption(items, static_cast(KEY_B), "3DS B Button"s); + AddMenuDialogOption(items, static_cast(KEY_X), "3DS X Button"s); + AddMenuDialogOption(items, static_cast(KEY_Y), "3DS Y Button"s); + AddMenuDialogOption(items, static_cast(KEY_L), "3DS L Button"s); + AddMenuDialogOption(items, static_cast(KEY_R), "3DS R Button"s); + AddMenuDialogOption(items, static_cast(KEY_ZL), "New 3DS ZL Button"s); + AddMenuDialogOption(items, static_cast(KEY_ZR), "New 3DS ZR Button"s); + return items; +} + std::vector makeOptionsForFrameskip() { std::vector items; AddMenuDialogOption(items, 0, "Disabled"s, ""s); @@ -428,7 +442,7 @@ std::vector makeOptionMenu() { []( int val ) { CheckAndUpdate( settings3DS.SRAMSaveInterval, val, settings3DS.Changed ); }); AddMenuCheckbox(items, " Force SRAM Write on Pause"s, settings3DS.ForceSRAMWriteOnPause, []( int val ) { CheckAndUpdate( settings3DS.ForceSRAMWriteOnPause, val, settings3DS.Changed ); }); - AddMenuDisabledOption(items, " (some games like Yoshi's Island require this)"s); + AddMenuDisabledOption(items, " (some games like Yoshi's Island require this)"s); AddMenuHeader2(items, ""s); @@ -457,13 +471,15 @@ std::vector makeOptionMenu() { std::vector makeControlsMenu() { std::vector items; - char *t3dsButtonNames[8]; + char *t3dsButtonNames[10]; t3dsButtonNames[BTN3DS_A] = "3DS A Button"; t3dsButtonNames[BTN3DS_B] = "3DS B Button"; t3dsButtonNames[BTN3DS_X] = "3DS X Button"; t3dsButtonNames[BTN3DS_Y] = "3DS Y Button"; t3dsButtonNames[BTN3DS_L] = "3DS L Button"; t3dsButtonNames[BTN3DS_R] = "3DS R Button"; + t3dsButtonNames[BTN3DS_ZL] = "3DS ZL Button"; + t3dsButtonNames[BTN3DS_ZR] = "3DS ZR Button"; t3dsButtonNames[BTN3DS_SELECT] = "3DS SELECT Button"; t3dsButtonNames[BTN3DS_START] = "3DS START Button"; @@ -472,7 +488,7 @@ std::vector makeControlsMenu() { []( int val ) { CheckAndUpdate( settings3DS.UseGlobalButtonMappings, val, settings3DS.Changed ); - for (int i = 0; i < 8; i++) + for (int i = 0; i < 10; i++) for (int j = 0; j < 4; j++) if (settings3DS.UseGlobalButtonMappings) settings3DS.GlobalButtonMapping[i][j] = settings3DS.ButtonMapping[i][j]; @@ -483,14 +499,14 @@ std::vector makeControlsMenu() { []( int val ) { CheckAndUpdate( settings3DS.UseGlobalTurbo, val, settings3DS.Changed ); - for (int i = 0; i < 6; i++) + for (int i = 0; i < 8; i++) if (settings3DS.UseGlobalTurbo) settings3DS.GlobalTurbo[i] = settings3DS.Turbo[i]; else settings3DS.Turbo[i] = settings3DS.GlobalTurbo[i]; }); - for (size_t i = 0; i < 8; ++i) { + for (size_t i = 0; i < 10; ++i) { std::ostringstream optionButtonName; optionButtonName << t3dsButtonNames[i]; AddMenuHeader2(items, ""); @@ -501,7 +517,7 @@ std::vector makeControlsMenu() { optionName << " Maps to"; AddMenuPicker( items, optionName.str(), ""s, makeOptionsForButtonMapping(), - settings3DS.ButtonMapping[i][j], + settings3DS.UseGlobalButtonMappings ? settings3DS.GlobalButtonMapping[i][j] : settings3DS.ButtonMapping[i][j], DIALOGCOLOR_CYAN, true, [i, j]( int val ) { if (settings3DS.UseGlobalButtonMappings) @@ -512,9 +528,9 @@ std::vector makeControlsMenu() { ); } - if (i < 6) + if (i < 8) AddMenuGauge(items, " Rapid-Fire Speed"s, 0, 10, - settings3DS.Turbo[i], + settings3DS.UseGlobalTurbo ? settings3DS.GlobalTurbo[i] : settings3DS.Turbo[i], [i]( int val ) { if (settings3DS.UseGlobalTurbo) @@ -525,20 +541,45 @@ std::vector makeControlsMenu() { } - AddMenuPicker( items, "Open Emulator Menu", ""s, makeOptionsForButtonMapping(), settings3DS.ButtonHotkeyOpenMenu.MappingBitmasks[0], DIALOGCOLOR_CYAN, true, + AddMenuDisabledOption(items, ""s); + + AddMenuHeader1(items, "EMULATOR FUNCTIONS"s); + + AddMenuCheckbox(items, "Apply keys to all games"s, settings3DS.UseGlobalEmuControlKeys, + []( int val ) + { + CheckAndUpdate( settings3DS.UseGlobalEmuControlKeys, val, settings3DS.Changed ); + if (settings3DS.UseGlobalEmuControlKeys) + settings3DS.GlobalButtonHotkeyOpenMenu.MappingBitmasks[0] = settings3DS.ButtonHotkeyOpenMenu.MappingBitmasks[0]; + else + settings3DS.ButtonHotkeyOpenMenu.MappingBitmasks[0] = settings3DS.GlobalButtonHotkeyOpenMenu.MappingBitmasks[0]; + }); + + AddMenuPicker( items, "Open Emulator Menu", ""s, makeOptionsFor3DSButtonMapping(), + settings3DS.UseGlobalEmuControlKeys ? settings3DS.GlobalButtonHotkeyOpenMenu.MappingBitmasks[0] : settings3DS.ButtonHotkeyOpenMenu.MappingBitmasks[0], DIALOGCOLOR_CYAN, true, []( int val ) { uint32 v = static_cast(val); - CheckAndUpdate( settings3DS.ButtonHotkeyOpenMenu.MappingBitmasks[0], v, settings3DS.Changed ); + + if (settings3DS.UseGlobalEmuControlKeys) + CheckAndUpdate( settings3DS.GlobalButtonHotkeyOpenMenu.MappingBitmasks[0], v, settings3DS.Changed ); + else + CheckAndUpdate( settings3DS.ButtonHotkeyOpenMenu.MappingBitmasks[0], v, settings3DS.Changed ); } ); - AddMenuPicker( items, "Disable Framelimit", ""s, makeOptionsForButtonMapping(), settings3DS.ButtonHotkeyDisableFramelimit.MappingBitmasks[0], DIALOGCOLOR_CYAN, true, + AddMenuPicker( items, "Fast-Forward", ""s, makeOptionsFor3DSButtonMapping(), + settings3DS.UseGlobalEmuControlKeys ? settings3DS.GlobalButtonHotkeyDisableFramelimit.MappingBitmasks[0] : settings3DS.ButtonHotkeyDisableFramelimit.MappingBitmasks[0], DIALOGCOLOR_CYAN, true, []( int val ) { uint32 v = static_cast(val); - CheckAndUpdate( settings3DS.ButtonHotkeyDisableFramelimit.MappingBitmasks[0], v, settings3DS.Changed ); + if (settings3DS.UseGlobalEmuControlKeys) + CheckAndUpdate( settings3DS.GlobalButtonHotkeyDisableFramelimit.MappingBitmasks[0], v, settings3DS.Changed ); + else + CheckAndUpdate( settings3DS.ButtonHotkeyDisableFramelimit.MappingBitmasks[0], v, settings3DS.Changed ); } ); + AddMenuDisabledOption(items, " (Fast-Forward may corrupt/freeze games)"s); + return items; } @@ -723,22 +764,26 @@ bool settingsReadWriteFullListByGame(bool writeMode) int tmp = static_cast(settings3DS.ForceFrameRate); config3dsReadWriteInt32("Framerate=%d\n", &tmp, 0, static_cast(EmulatedFramerate::Count) - 1); settings3DS.ForceFrameRate = static_cast(tmp); - config3dsReadWriteInt32("TurboA=%d\n", &settings3DS.Turbo[0], 0, 1); - config3dsReadWriteInt32("TurboB=%d\n", &settings3DS.Turbo[1], 0, 1); - config3dsReadWriteInt32("TurboX=%d\n", &settings3DS.Turbo[2], 0, 1); - config3dsReadWriteInt32("TurboY=%d\n", &settings3DS.Turbo[3], 0, 1); - config3dsReadWriteInt32("TurboL=%d\n", &settings3DS.Turbo[4], 0, 1); - config3dsReadWriteInt32("TurboR=%d\n", &settings3DS.Turbo[5], 0, 1); + config3dsReadWriteInt32("TurboA=%d\n", &settings3DS.Turbo[0], 0, 10); + config3dsReadWriteInt32("TurboB=%d\n", &settings3DS.Turbo[1], 0, 10); + config3dsReadWriteInt32("TurboX=%d\n", &settings3DS.Turbo[2], 0, 10); + config3dsReadWriteInt32("TurboY=%d\n", &settings3DS.Turbo[3], 0, 10); + config3dsReadWriteInt32("TurboL=%d\n", &settings3DS.Turbo[4], 0, 10); + config3dsReadWriteInt32("TurboR=%d\n", &settings3DS.Turbo[5], 0, 10); config3dsReadWriteInt32("Vol=%d\n", &settings3DS.Volume, 0, 8); config3dsReadWriteInt32("PalFix=%d\n", &settings3DS.PaletteFix, 0, 3); config3dsReadWriteInt32("SRAMInterval=%d\n", &settings3DS.SRAMSaveInterval, 0, 4); + + // v1.20 - we should really load settings by their field name instead! + config3dsReadWriteInt32("TurboZL=%d\n", &settings3DS.Turbo[6], 0, 10); + config3dsReadWriteInt32("TurboZR=%d\n", &settings3DS.Turbo[7], 0, 10); config3dsReadWriteInt32("ForceSRAMWrite=%d\n", &settings3DS.ForceSRAMWriteOnPause, 0, 1); - static char *buttonName[8] = {"A", "B", "X", "Y", "L", "R", "SELECT","START"}; - for (int i = 0; i < 8; ++i) { + static char *buttonName[10] = {"A", "B", "X", "Y", "L", "R", "ZL", "ZR", "SELECT","START"}; + for (int i = 0; i < 10; ++i) { for (int j = 0; j < 3; ++j) { std::ostringstream oss; - oss << "ButtonMap" << i << "_" << j << "=%d\n"; + oss << "ButtonMap" << buttonName[i] << "_" << j << "=%d\n"; config3dsReadWriteInt32(oss.str().c_str(), &settings3DS.ButtonMapping[i][j]); } } @@ -773,6 +818,7 @@ bool settingsReadWriteFullListGlobal(bool writeMode) config3dsReadWriteString("Dir=%s\n", "Dir=%1000[^\n]s\n", file3dsGetCurrentDir()); config3dsReadWriteString("ROM=%s\n", "ROM=%1000[^\n]s\n", romFileNameLastSelected); + // Settings for v1.20 config3dsReadWriteInt32("AutoSavestate=%d\n", &settings3DS.AutoSavestate, 0, 1); config3dsReadWriteInt32("TurboA=%d\n", &settings3DS.GlobalTurbo[0], 0, 10); config3dsReadWriteInt32("TurboB=%d\n", &settings3DS.GlobalTurbo[1], 0, 10); @@ -780,20 +826,25 @@ bool settingsReadWriteFullListGlobal(bool writeMode) config3dsReadWriteInt32("TurboY=%d\n", &settings3DS.GlobalTurbo[3], 0, 10); config3dsReadWriteInt32("TurboL=%d\n", &settings3DS.GlobalTurbo[4], 0, 10); config3dsReadWriteInt32("TurboR=%d\n", &settings3DS.GlobalTurbo[5], 0, 10); + config3dsReadWriteInt32("TurboZL=%d\n", &settings3DS.GlobalTurbo[6], 0, 10); + config3dsReadWriteInt32("TurboZR=%d\n", &settings3DS.GlobalTurbo[7], 0, 10); config3dsReadWriteInt32("Vol=%d\n", &settings3DS.GlobalVolume, 0, 8); - static char *buttonName[8] = {"A", "B", "X", "Y", "L", "R", "SELECT","START"}; - for (int i = 0; i < 8; ++i) { + static char *buttonName[10] = {"A", "B", "X", "Y", "L", "R", "ZL", "ZR", "SELECT","START"}; + for (int i = 0; i < 10; ++i) { for (int j = 0; j < 3; ++j) { std::ostringstream oss; - oss << "ButtonMap" << i << "_" << j << "=%d\n"; + oss << "ButtonMap" << buttonName[i] << "_" << j << "=%d\n"; config3dsReadWriteInt32(oss.str().c_str(), &settings3DS.GlobalButtonMapping[i][j]); } } + config3dsReadWriteInt32("UseGlobalButtonMappings=%d\n", &settings3DS.UseGlobalButtonMappings, 0, 1); + config3dsReadWriteInt32("UseGlobalTurbo=%d\n", &settings3DS.UseGlobalTurbo, 0, 1); + config3dsReadWriteInt32("UseGlobalVolume=%d\n", &settings3DS.UseGlobalVolume, 0, 1); + config3dsReadWriteInt32("UseGlobalEmuControlKeys=%d\n", &settings3DS.UseGlobalEmuControlKeys, 0, 1); - config3dsReadWriteInt32("UseGlobalButtonMappings=%d\n", &settings3DS.UseGlobalButtonMappings, 0, 2); - config3dsReadWriteInt32("UseGlobalTurbo=%d\n", &settings3DS.UseGlobalTurbo, 0, 2); - config3dsReadWriteInt32("UseGlobalVolume=%d\n", &settings3DS.UseGlobalVolume, 0, 2); + config3dsReadWriteBitmask("ButtonMappingDisableFramelimitHold_0=%d\n", &settings3DS.GlobalButtonHotkeyDisableFramelimit.MappingBitmasks[0]); + config3dsReadWriteBitmask("ButtonMappingOpenEmulatorMenu_0=%d\n", &settings3DS.GlobalButtonHotkeyOpenMenu.MappingBitmasks[0]); // All new options should come here! @@ -826,9 +877,13 @@ bool settingsSave(bool includeGameSettings = true) //---------------------------------------------------------------------- void settingsDefaultButtonMapping(int buttonMapping[8][4]) { - bool allZero = true; + uint32 defaultButtons[] = + { SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK, SNES_TL_MASK, SNES_TR_MASK, 0, 0, SNES_SELECT_MASK, SNES_START_MASK }; + + for (int i = 0; i < 10; i++) + { + bool allZero = true; - for (int i = 0; i < 8; i++) for (int j = 0; j < 4; j++) { // Validates all button mapping input, @@ -848,19 +903,10 @@ void settingsDefaultButtonMapping(int buttonMapping[8][4]) if (buttonMapping[i][j]) allZero = false; } - - if (allZero) - { - // Setting default button mapping: - buttonMapping[0][0] = SNES_A_MASK; - buttonMapping[1][0] = SNES_B_MASK; - buttonMapping[2][0] = SNES_X_MASK; - buttonMapping[3][0] = SNES_Y_MASK; - buttonMapping[4][0] = SNES_TL_MASK; - buttonMapping[5][0] = SNES_TR_MASK; - buttonMapping[6][0] = SNES_SELECT_MASK; - buttonMapping[7][0] = SNES_START_MASK; + if (allZero) + buttonMapping[i][0] = defaultButtons[i]; } + } //---------------------------------------------------------------------- @@ -900,7 +946,7 @@ bool settingsLoad(bool includeGameSettings = true) settings3DS.ForceFrameRate = EmulatedFramerate::UseRomRegion; settings3DS.Volume = 4; - for (int i = 0; i < 6; i++) // and clear all turbo buttons. + for (int i = 0; i < 8; i++) // and clear all turbo buttons. settings3DS.Turbo[i] = 0; if (SNESGameFixes.PaletteCommitLine == -2) @@ -1266,7 +1312,7 @@ void emulatorInitialize() if (!gpu3dsInitialize()) { - printf ("Unable to initialized GPU\n"); + printf ("Unable to initialize GPU\n"); exit(0); } @@ -1541,15 +1587,23 @@ void emulatorLoop() snesFrameTotalAccurateTicks = 0; snesFramesSkipped = 0; - if (!settings3DS.ButtonHotkeyDisableFramelimit.IsHeld(input3dsGetCurrentKeysHeld())) { + if ( + (!settings3DS.UseGlobalEmuControlKeys && settings3DS.ButtonHotkeyDisableFramelimit.IsHeld(input3dsGetCurrentKeysHeld())) || + (settings3DS.UseGlobalEmuControlKeys && settings3DS.GlobalButtonHotkeyDisableFramelimit.IsHeld(input3dsGetCurrentKeysHeld())) + ) + { + skipDrawingFrame = (frameCount60 % 2) == 0; + } + else + { if (settings3DS.ForceFrameRate == EmulatedFramerate::Match3DS) { gspWaitForVBlank(); } else { svcSleepThread ((long)(timeDiffInMilliseconds * 1000)); } + skipDrawingFrame = false; } - skipDrawingFrame = false; } } diff --git a/source/3dsmenu.cpp b/source/3dsmenu.cpp index 5b611b5..33866dd 100644 --- a/source/3dsmenu.cpp +++ b/source/3dsmenu.cpp @@ -17,7 +17,7 @@ #define MENU_HEIGHT (14) #define DIALOG_HEIGHT (5) -#define SNES9X_VERSION "v1.20b" +#define SNES9X_VERSION "v1.20" #define ANIMATE_TAB_STEPS 3 @@ -281,11 +281,68 @@ void menu3dsDrawMenu(std::vector& menuTab, int& currentMenuTab, int me //ui3dsDrawRect(0, 24, 320, 25, 0xcccccc); //ui3dsDrawRect(0, 25, 320, 27, 0xeeeeee); - ui3dsDrawStringWithNoWrapping(10, 223, 310, 240, 0xFFFFFF, HALIGN_LEFT, + ui3dsDrawStringWithNoWrapping(10, 223, 285, 240, 0xFFFFFF, HALIGN_LEFT, "A:Select B:Cancel"); - ui3dsDrawStringWithNoWrapping(10, 223, 310, 240, 0xFFFFFF, HALIGN_RIGHT, + ui3dsDrawStringWithNoWrapping(10, 223, 285, 240, 0xFFFFFF, HALIGN_RIGHT, "SNES9x for 3DS " SNES9X_VERSION); + //battery display + const int maxBatteryLevel = 5; + const int battLevelWidth = 3; + const int battFullLevelWidth = (maxBatteryLevel) * battLevelWidth + 1; + const int battBorderWidth = 1; + const int battY1 = 226; + const int battY2 = 233; + const int battX2 = 311; + const int battYHeight = battY2 - battY1; + const int battHeadWidth = 2; + const int battHeadSpacing = 1; + + // battery positive end + ui3dsDrawRect( + battX2 - battFullLevelWidth - battBorderWidth - battHeadWidth, + battY1 + battHeadSpacing, + battX2 - battFullLevelWidth - battBorderWidth, + battY2 - battHeadSpacing, + 0xFFFFFF, 1.0f); + // battery body + ui3dsDrawRect( + battX2 - battFullLevelWidth - battBorderWidth, + battY1 - battBorderWidth, + battX2 + battBorderWidth, + battY2 + battBorderWidth, + 0xFFFFFF, 1.0f); + // battery's empty insides + ui3dsDrawRect( + battX2 - battFullLevelWidth, + battY1, + battX2, + battY2, + 0x1976D2, 1.0f); + + ptmuInit(); + + u8 batteryChargeState = 0; + u8 batteryLevel = 0; + if(R_SUCCEEDED(PTMU_GetBatteryChargeState(&batteryChargeState)) && batteryChargeState) { + ui3dsDrawRect( + battX2-battFullLevelWidth + 1, battY1 + 1, + battX2 - 1, battY2 - 1, 0xFF9900, 1.0f); + } else if(R_SUCCEEDED(PTMU_GetBatteryLevel(&batteryLevel))) { + if (batteryLevel > 5) + batteryLevel = 5; + for (int i = 0; i < batteryLevel; i++) + { + ui3dsDrawRect( + battX2-battLevelWidth*(i+1), battY1 + 1, + battX2-battLevelWidth*(i) - 1, battY2 - 1, 0xFFFFFF, 1.0f); + } + } else { + //ui3dsDrawRect(battX2, battY1, battX2, battY2, 0xFFFFFF, 1.0f); + } + + ptmuExit(); + int line = 0; int maxItems = MENU_HEIGHT; int menuStartY = 29; @@ -516,7 +573,7 @@ int menu3dsMenuSelectItem(SMenuTab& dialogTab, bool& isDialog, int& currentMenuT maxItems--; } - if (thisKeysHeld & KEY_UP || thisKeysHeld & KEY_DOWN) + if ((thisKeysHeld & KEY_UP) || (thisKeysHeld & KEY_DOWN) || (thisKeysHeld & KEY_LEFT) || (thisKeysHeld & KEY_RIGHT)) framesDKeyHeld ++; else framesDKeyHeld = 0; @@ -525,19 +582,21 @@ int menu3dsMenuSelectItem(SMenuTab& dialogTab, bool& isDialog, int& currentMenuT returnResult = -1; break; } - if ((keysDown & KEY_RIGHT) || (keysDown & KEY_R)) + if ((keysDown & KEY_RIGHT) || (keysDown & KEY_R) || ((thisKeysHeld & KEY_RIGHT) && (framesDKeyHeld > 15) && (framesDKeyHeld % 2 == 0))) { if (!isDialog) { - if (keysDown & KEY_RIGHT && - currentTab->MenuItems[currentTab->SelectedItemIndex].Type == MenuItemType::Gauge) + if (currentTab->MenuItems[currentTab->SelectedItemIndex].Type == MenuItemType::Gauge) { - if (currentTab->MenuItems[currentTab->SelectedItemIndex].Value < - currentTab->MenuItems[currentTab->SelectedItemIndex].GaugeMaxValue) + if (keysDown & KEY_RIGHT || ((thisKeysHeld & KEY_RIGHT) && (framesDKeyHeld > 15) && (framesDKeyHeld % 2 == 0))) { - currentTab->MenuItems[currentTab->SelectedItemIndex].SetValue(currentTab->MenuItems[currentTab->SelectedItemIndex].Value + 1); + if (currentTab->MenuItems[currentTab->SelectedItemIndex].Value < + currentTab->MenuItems[currentTab->SelectedItemIndex].GaugeMaxValue) + { + currentTab->MenuItems[currentTab->SelectedItemIndex].SetValue(currentTab->MenuItems[currentTab->SelectedItemIndex].Value + 1); + } + menu3dsDrawEverything(dialogTab, isDialog, currentMenuTab, menuTab); } - menu3dsDrawEverything(dialogTab, isDialog, currentMenuTab, menuTab); } else { @@ -545,20 +604,22 @@ int menu3dsMenuSelectItem(SMenuTab& dialogTab, bool& isDialog, int& currentMenuT } } } - if ((keysDown & KEY_LEFT) || (keysDown & KEY_L)) + if ((keysDown & KEY_LEFT) || (keysDown & KEY_L)|| ((thisKeysHeld & KEY_LEFT) && (framesDKeyHeld > 15) && (framesDKeyHeld % 2 == 0))) { if (!isDialog) { - if (keysDown & KEY_LEFT && - currentTab->MenuItems[currentTab->SelectedItemIndex].Type == MenuItemType::Gauge) + if (currentTab->MenuItems[currentTab->SelectedItemIndex].Type == MenuItemType::Gauge) { - // Gauge adjustment - if (currentTab->MenuItems[currentTab->SelectedItemIndex].Value > - currentTab->MenuItems[currentTab->SelectedItemIndex].GaugeMinValue) + if (keysDown & KEY_LEFT || ((thisKeysHeld & KEY_LEFT) && (framesDKeyHeld > 15) && (framesDKeyHeld % 2 == 0))) { - currentTab->MenuItems[currentTab->SelectedItemIndex].SetValue(currentTab->MenuItems[currentTab->SelectedItemIndex].Value - 1); + // Gauge adjustment + if (currentTab->MenuItems[currentTab->SelectedItemIndex].Value > + currentTab->MenuItems[currentTab->SelectedItemIndex].GaugeMinValue) + { + currentTab->MenuItems[currentTab->SelectedItemIndex].SetValue(currentTab->MenuItems[currentTab->SelectedItemIndex].Value - 1); + } + menu3dsDrawEverything(dialogTab, isDialog, currentMenuTab, menuTab); } - menu3dsDrawEverything(dialogTab, isDialog, currentMenuTab, menuTab); } else { @@ -601,7 +662,7 @@ int menu3dsMenuSelectItem(SMenuTab& dialogTab, bool& isDialog, int& currentMenuT } } - if (keysDown & KEY_UP || ((thisKeysHeld & KEY_UP) && (framesDKeyHeld > 30) && (framesDKeyHeld % 2 == 0))) + if (keysDown & KEY_UP || ((thisKeysHeld & KEY_UP) && (framesDKeyHeld > 15) && (framesDKeyHeld % 2 == 0))) { int moveCursorTimes = 0; @@ -634,7 +695,7 @@ int menu3dsMenuSelectItem(SMenuTab& dialogTab, bool& isDialog, int& currentMenuT menu3dsDrawEverything(dialogTab, isDialog, currentMenuTab, menuTab); } - if (keysDown & KEY_DOWN || ((thisKeysHeld & KEY_DOWN) && (framesDKeyHeld > 30) && (framesDKeyHeld % 2 == 0))) + if (keysDown & KEY_DOWN || ((thisKeysHeld & KEY_DOWN) && (framesDKeyHeld > 15) && (framesDKeyHeld % 2 == 0))) { int moveCursorTimes = 0; do diff --git a/source/3dssettings.h b/source/3dssettings.h index 1a5418f..154f652 100644 --- a/source/3dssettings.h +++ b/source/3dssettings.h @@ -27,13 +27,13 @@ struct ButtonMapping { } void SetDoubleMapping(uint32 mapping0, uint32 mapping1) { - if constexpr (Count > 0) { + if (Count > 0) { MappingBitmasks[0] = mapping0; } - if constexpr (Count > 1) { + if (Count > 1) { MappingBitmasks[1] = mapping1; } - if constexpr (Count > 2) { + if (Count > 2) { for (size_t i = 2; i < MappingBitmasks.size(); ++i) { MappingBitmasks[i] = 0; } @@ -61,7 +61,7 @@ typedef struct int StretchWidth, StretchHeight; int CropPixels; - int Turbo[6] = {0, 0, 0, 0, 0, 0}; // Turbo buttons: 0 - No turbo, 1 - Release/Press every alt frame. + int Turbo[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // Turbo buttons: 0 - No turbo, 1 - Release/Press every alt frame. // Indexes: 0 - A, 1 - B, 2 - X, 3 - Y, 4 - L, 5 - R int Volume = 4; // 0: 100% Default volume, @@ -95,13 +95,17 @@ typedef struct // to the console buttons. This is for consistency with the // other EMUS for 3DS. // - int GlobalButtonMapping[8][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; - int ButtonMapping[8][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; + int GlobalButtonMapping[10][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; + int ButtonMapping[10][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; ::ButtonMapping<1> ButtonHotkeyOpenMenu; // Stores button that can be held to open the menu. ::ButtonMapping<1> ButtonHotkeyDisableFramelimit; // Stores button that can be held to disable the frame limit. + ::ButtonMapping<1> GlobalButtonHotkeyOpenMenu; // Stores button that can be held to open the menu. + + ::ButtonMapping<1> GlobalButtonHotkeyDisableFramelimit; // Stores button that can be held to disable the frame limit. + bool Changed = false; // Stores whether the configuration has been changed and should be written. int UseGlobalButtonMappings = 0; // Use global button mappings for all games @@ -113,9 +117,11 @@ typedef struct int UseGlobalVolume = 0; // Use global button mappings for all games // 0 - no, 1 - yes - int GlobalTurbo[6] = {0, 0, 0, 0, 0, 0}; + int UseGlobalEmuControlKeys = 0; // Use global emulator control keys for all games + + int GlobalTurbo[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // Turbo buttons: 0 - No turbo, 1 - Release/Press every alt frame. - // Indexes for 3DS buttons: 0 - A, 1 - B, 2 - X, 3 - Y, 4 - L, 5 - R + // Indexes for 3DS buttons: 0 - A, 1 - B, 2 - X, 3 - Y, 4 - L, 5 - R, 6 - ZL, 7 - ZR int GlobalVolume = 4; // 0: 100%, 4: 200%, 8: 400% diff --git a/source/3dssnes9x.h b/source/3dssnes9x.h index 8392e67..5916d5c 100644 --- a/source/3dssnes9x.h +++ b/source/3dssnes9x.h @@ -6,7 +6,7 @@ #define RELEASE // Uncomment this to allow user to break into debug mode (for the 65816 CPU) -// +// //#define DEBUG_CPU // Uncomment this to allow user to break into debug mode (for the SPC700 APU) diff --git a/source/tile.cpp b/source/tile.cpp index e59ea51..300e278 100644 --- a/source/tile.cpp +++ b/source/tile.cpp @@ -94,18 +94,15 @@ #include "gfx.h" #include "tile.h" -//#include "3dsgpu.h" - #ifdef USE_GLIDE #include "3d.h" -#endif +#endif extern uint32 HeadMask [4]; extern uint32 TailMask [5]; uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) { - //printf ("Tile Addr: %04x\n", TileAddr); register uint8 *tp = &Memory.VRAM[TileAddr]; uint32 *p = (uint32 *) pCache; uint32 non_zero = 0; @@ -223,31 +220,6 @@ uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) return (non_zero ? TRUE : BLANK_TILE); } - -uint8 ConvertTileTo16Bit (uint16 *palette, uint8 *tile8Bit, uint16 *tile16Bit) -{ - for (int i = 0; i < 8; i++) - { - #define SetPixel16Bit(n) \ - if (tile8Bit[n] != 0) tile16Bit[n] = (palette[tile8Bit[n]] | 1); else tile16Bit[n] = 0; - - SetPixel16Bit(0); - SetPixel16Bit(1); - SetPixel16Bit(2); - SetPixel16Bit(3); - SetPixel16Bit(4); - SetPixel16Bit(5); - SetPixel16Bit(6); - SetPixel16Bit(7); - - #undef SetPixel16Bit - - tile16Bit += 8; - tile8Bit += 8; - } -} - -/* inline void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) { uint8 Pixel; @@ -255,7 +227,7 @@ inline void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if ((Pixel = Pixels[N]) && GFX.Z1 > Depth [N]) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SetPixel(N, Pixel); \ } @@ -273,9 +245,8 @@ inline void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) uint8 *Screen = GFX.S + Offset; uint8 *Depth = GFX.DB + Offset; - #define FN(N) \ - if ((Pixel = Pixels[3 - N]) && GFX.Z1 > Depth [N]) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SetPixel(N, Pixel); \ } @@ -371,861 +342,79 @@ inline void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) #undef FN } - -#define WRITE_8PIXELS(n) \ - void Write8Pixels_##n(uint32 Offset, uint8 *Pixels) \ - { \ - uint32 Pixel; \ - uint16 *Screen = (uint16 *) GFX.S + Offset; \ - if (n & 0x01) { TILE_SetPixel16(0, Pixels[0]); } \ - if (n & 0x02) { TILE_SetPixel16(1, Pixels[1]); } \ - if (n & 0x04) { TILE_SetPixel16(2, Pixels[2]); } \ - if (n & 0x08) { TILE_SetPixel16(3, Pixels[3]); } \ - if (n & 0x10) { TILE_SetPixel16(4, Pixels[4]); } \ - if (n & 0x20) { TILE_SetPixel16(5, Pixels[5]); } \ - if (n & 0x40) { TILE_SetPixel16(6, Pixels[6]); } \ - if (n & 0x80) { TILE_SetPixel16(7, Pixels[7]); } \ - } - -#define WRITE_8PIXELS_FLIPPED(n) \ - void Write8PixelsFlipped_##n(uint32 Offset, uint8 *Pixels) \ - { \ - uint32 Pixel; \ - uint16 *Screen = (uint16 *) GFX.S + Offset; \ - if (n & 0x01) { TILE_SetPixel16(0, Pixels[7]); } \ - if (n & 0x02) { TILE_SetPixel16(1, Pixels[6]); } \ - if (n & 0x04) { TILE_SetPixel16(2, Pixels[5]); } \ - if (n & 0x08) { TILE_SetPixel16(3, Pixels[4]); } \ - if (n & 0x10) { TILE_SetPixel16(4, Pixels[3]); } \ - if (n & 0x20) { TILE_SetPixel16(5, Pixels[2]); } \ - if (n & 0x40) { TILE_SetPixel16(6, Pixels[1]); } \ - if (n & 0x80) { TILE_SetPixel16(7, Pixels[0]); } \ - } - -WRITE_8PIXELS(0) WRITE_8PIXELS_FLIPPED(0) -WRITE_8PIXELS(1) WRITE_8PIXELS_FLIPPED(1) -WRITE_8PIXELS(2) WRITE_8PIXELS_FLIPPED(2) -WRITE_8PIXELS(3) WRITE_8PIXELS_FLIPPED(3) -WRITE_8PIXELS(4) WRITE_8PIXELS_FLIPPED(4) -WRITE_8PIXELS(5) WRITE_8PIXELS_FLIPPED(5) -WRITE_8PIXELS(6) WRITE_8PIXELS_FLIPPED(6) -WRITE_8PIXELS(7) WRITE_8PIXELS_FLIPPED(7) -WRITE_8PIXELS(8) WRITE_8PIXELS_FLIPPED(8) -WRITE_8PIXELS(9) WRITE_8PIXELS_FLIPPED(9) -WRITE_8PIXELS(10) WRITE_8PIXELS_FLIPPED(10) -WRITE_8PIXELS(11) WRITE_8PIXELS_FLIPPED(11) -WRITE_8PIXELS(12) WRITE_8PIXELS_FLIPPED(12) -WRITE_8PIXELS(13) WRITE_8PIXELS_FLIPPED(13) -WRITE_8PIXELS(14) WRITE_8PIXELS_FLIPPED(14) -WRITE_8PIXELS(15) WRITE_8PIXELS_FLIPPED(15) -WRITE_8PIXELS(16) WRITE_8PIXELS_FLIPPED(16) -WRITE_8PIXELS(17) WRITE_8PIXELS_FLIPPED(17) -WRITE_8PIXELS(18) WRITE_8PIXELS_FLIPPED(18) -WRITE_8PIXELS(19) WRITE_8PIXELS_FLIPPED(19) -WRITE_8PIXELS(20) WRITE_8PIXELS_FLIPPED(20) -WRITE_8PIXELS(21) WRITE_8PIXELS_FLIPPED(21) -WRITE_8PIXELS(22) WRITE_8PIXELS_FLIPPED(22) -WRITE_8PIXELS(23) WRITE_8PIXELS_FLIPPED(23) -WRITE_8PIXELS(24) WRITE_8PIXELS_FLIPPED(24) -WRITE_8PIXELS(25) WRITE_8PIXELS_FLIPPED(25) -WRITE_8PIXELS(26) WRITE_8PIXELS_FLIPPED(26) -WRITE_8PIXELS(27) WRITE_8PIXELS_FLIPPED(27) -WRITE_8PIXELS(28) WRITE_8PIXELS_FLIPPED(28) -WRITE_8PIXELS(29) WRITE_8PIXELS_FLIPPED(29) -WRITE_8PIXELS(30) WRITE_8PIXELS_FLIPPED(30) -WRITE_8PIXELS(31) WRITE_8PIXELS_FLIPPED(31) -WRITE_8PIXELS(32) WRITE_8PIXELS_FLIPPED(32) -WRITE_8PIXELS(33) WRITE_8PIXELS_FLIPPED(33) -WRITE_8PIXELS(34) WRITE_8PIXELS_FLIPPED(34) -WRITE_8PIXELS(35) WRITE_8PIXELS_FLIPPED(35) -WRITE_8PIXELS(36) WRITE_8PIXELS_FLIPPED(36) -WRITE_8PIXELS(37) WRITE_8PIXELS_FLIPPED(37) -WRITE_8PIXELS(38) WRITE_8PIXELS_FLIPPED(38) -WRITE_8PIXELS(39) WRITE_8PIXELS_FLIPPED(39) -WRITE_8PIXELS(40) WRITE_8PIXELS_FLIPPED(40) -WRITE_8PIXELS(41) WRITE_8PIXELS_FLIPPED(41) -WRITE_8PIXELS(42) WRITE_8PIXELS_FLIPPED(42) -WRITE_8PIXELS(43) WRITE_8PIXELS_FLIPPED(43) -WRITE_8PIXELS(44) WRITE_8PIXELS_FLIPPED(44) -WRITE_8PIXELS(45) WRITE_8PIXELS_FLIPPED(45) -WRITE_8PIXELS(46) WRITE_8PIXELS_FLIPPED(46) -WRITE_8PIXELS(47) WRITE_8PIXELS_FLIPPED(47) -WRITE_8PIXELS(48) WRITE_8PIXELS_FLIPPED(48) -WRITE_8PIXELS(49) WRITE_8PIXELS_FLIPPED(49) -WRITE_8PIXELS(50) WRITE_8PIXELS_FLIPPED(50) -WRITE_8PIXELS(51) WRITE_8PIXELS_FLIPPED(51) -WRITE_8PIXELS(52) WRITE_8PIXELS_FLIPPED(52) -WRITE_8PIXELS(53) WRITE_8PIXELS_FLIPPED(53) -WRITE_8PIXELS(54) WRITE_8PIXELS_FLIPPED(54) -WRITE_8PIXELS(55) WRITE_8PIXELS_FLIPPED(55) -WRITE_8PIXELS(56) WRITE_8PIXELS_FLIPPED(56) -WRITE_8PIXELS(57) WRITE_8PIXELS_FLIPPED(57) -WRITE_8PIXELS(58) WRITE_8PIXELS_FLIPPED(58) -WRITE_8PIXELS(59) WRITE_8PIXELS_FLIPPED(59) -WRITE_8PIXELS(60) WRITE_8PIXELS_FLIPPED(60) -WRITE_8PIXELS(61) WRITE_8PIXELS_FLIPPED(61) -WRITE_8PIXELS(62) WRITE_8PIXELS_FLIPPED(62) -WRITE_8PIXELS(63) WRITE_8PIXELS_FLIPPED(63) -WRITE_8PIXELS(64) WRITE_8PIXELS_FLIPPED(64) -WRITE_8PIXELS(65) WRITE_8PIXELS_FLIPPED(65) -WRITE_8PIXELS(66) WRITE_8PIXELS_FLIPPED(66) -WRITE_8PIXELS(67) WRITE_8PIXELS_FLIPPED(67) -WRITE_8PIXELS(68) WRITE_8PIXELS_FLIPPED(68) -WRITE_8PIXELS(69) WRITE_8PIXELS_FLIPPED(69) -WRITE_8PIXELS(70) WRITE_8PIXELS_FLIPPED(70) -WRITE_8PIXELS(71) WRITE_8PIXELS_FLIPPED(71) -WRITE_8PIXELS(72) WRITE_8PIXELS_FLIPPED(72) -WRITE_8PIXELS(73) WRITE_8PIXELS_FLIPPED(73) -WRITE_8PIXELS(74) WRITE_8PIXELS_FLIPPED(74) -WRITE_8PIXELS(75) WRITE_8PIXELS_FLIPPED(75) -WRITE_8PIXELS(76) WRITE_8PIXELS_FLIPPED(76) -WRITE_8PIXELS(77) WRITE_8PIXELS_FLIPPED(77) -WRITE_8PIXELS(78) WRITE_8PIXELS_FLIPPED(78) -WRITE_8PIXELS(79) WRITE_8PIXELS_FLIPPED(79) -WRITE_8PIXELS(80) WRITE_8PIXELS_FLIPPED(80) -WRITE_8PIXELS(81) WRITE_8PIXELS_FLIPPED(81) -WRITE_8PIXELS(82) WRITE_8PIXELS_FLIPPED(82) -WRITE_8PIXELS(83) WRITE_8PIXELS_FLIPPED(83) -WRITE_8PIXELS(84) WRITE_8PIXELS_FLIPPED(84) -WRITE_8PIXELS(85) WRITE_8PIXELS_FLIPPED(85) -WRITE_8PIXELS(86) WRITE_8PIXELS_FLIPPED(86) -WRITE_8PIXELS(87) WRITE_8PIXELS_FLIPPED(87) -WRITE_8PIXELS(88) WRITE_8PIXELS_FLIPPED(88) -WRITE_8PIXELS(89) WRITE_8PIXELS_FLIPPED(89) -WRITE_8PIXELS(90) WRITE_8PIXELS_FLIPPED(90) -WRITE_8PIXELS(91) WRITE_8PIXELS_FLIPPED(91) -WRITE_8PIXELS(92) WRITE_8PIXELS_FLIPPED(92) -WRITE_8PIXELS(93) WRITE_8PIXELS_FLIPPED(93) -WRITE_8PIXELS(94) WRITE_8PIXELS_FLIPPED(94) -WRITE_8PIXELS(95) WRITE_8PIXELS_FLIPPED(95) -WRITE_8PIXELS(96) WRITE_8PIXELS_FLIPPED(96) -WRITE_8PIXELS(97) WRITE_8PIXELS_FLIPPED(97) -WRITE_8PIXELS(98) WRITE_8PIXELS_FLIPPED(98) -WRITE_8PIXELS(99) WRITE_8PIXELS_FLIPPED(99) -WRITE_8PIXELS(100) WRITE_8PIXELS_FLIPPED(100) -WRITE_8PIXELS(101) WRITE_8PIXELS_FLIPPED(101) -WRITE_8PIXELS(102) WRITE_8PIXELS_FLIPPED(102) -WRITE_8PIXELS(103) WRITE_8PIXELS_FLIPPED(103) -WRITE_8PIXELS(104) WRITE_8PIXELS_FLIPPED(104) -WRITE_8PIXELS(105) WRITE_8PIXELS_FLIPPED(105) -WRITE_8PIXELS(106) WRITE_8PIXELS_FLIPPED(106) -WRITE_8PIXELS(107) WRITE_8PIXELS_FLIPPED(107) -WRITE_8PIXELS(108) WRITE_8PIXELS_FLIPPED(108) -WRITE_8PIXELS(109) WRITE_8PIXELS_FLIPPED(109) -WRITE_8PIXELS(110) WRITE_8PIXELS_FLIPPED(110) -WRITE_8PIXELS(111) WRITE_8PIXELS_FLIPPED(111) -WRITE_8PIXELS(112) WRITE_8PIXELS_FLIPPED(112) -WRITE_8PIXELS(113) WRITE_8PIXELS_FLIPPED(113) -WRITE_8PIXELS(114) WRITE_8PIXELS_FLIPPED(114) -WRITE_8PIXELS(115) WRITE_8PIXELS_FLIPPED(115) -WRITE_8PIXELS(116) WRITE_8PIXELS_FLIPPED(116) -WRITE_8PIXELS(117) WRITE_8PIXELS_FLIPPED(117) -WRITE_8PIXELS(118) WRITE_8PIXELS_FLIPPED(118) -WRITE_8PIXELS(119) WRITE_8PIXELS_FLIPPED(119) -WRITE_8PIXELS(120) WRITE_8PIXELS_FLIPPED(120) -WRITE_8PIXELS(121) WRITE_8PIXELS_FLIPPED(121) -WRITE_8PIXELS(122) WRITE_8PIXELS_FLIPPED(122) -WRITE_8PIXELS(123) WRITE_8PIXELS_FLIPPED(123) -WRITE_8PIXELS(124) WRITE_8PIXELS_FLIPPED(124) -WRITE_8PIXELS(125) WRITE_8PIXELS_FLIPPED(125) -WRITE_8PIXELS(126) WRITE_8PIXELS_FLIPPED(126) -WRITE_8PIXELS(127) WRITE_8PIXELS_FLIPPED(127) -WRITE_8PIXELS(128) WRITE_8PIXELS_FLIPPED(128) -WRITE_8PIXELS(129) WRITE_8PIXELS_FLIPPED(129) -WRITE_8PIXELS(130) WRITE_8PIXELS_FLIPPED(130) -WRITE_8PIXELS(131) WRITE_8PIXELS_FLIPPED(131) -WRITE_8PIXELS(132) WRITE_8PIXELS_FLIPPED(132) -WRITE_8PIXELS(133) WRITE_8PIXELS_FLIPPED(133) -WRITE_8PIXELS(134) WRITE_8PIXELS_FLIPPED(134) -WRITE_8PIXELS(135) WRITE_8PIXELS_FLIPPED(135) -WRITE_8PIXELS(136) WRITE_8PIXELS_FLIPPED(136) -WRITE_8PIXELS(137) WRITE_8PIXELS_FLIPPED(137) -WRITE_8PIXELS(138) WRITE_8PIXELS_FLIPPED(138) -WRITE_8PIXELS(139) WRITE_8PIXELS_FLIPPED(139) -WRITE_8PIXELS(140) WRITE_8PIXELS_FLIPPED(140) -WRITE_8PIXELS(141) WRITE_8PIXELS_FLIPPED(141) -WRITE_8PIXELS(142) WRITE_8PIXELS_FLIPPED(142) -WRITE_8PIXELS(143) WRITE_8PIXELS_FLIPPED(143) -WRITE_8PIXELS(144) WRITE_8PIXELS_FLIPPED(144) -WRITE_8PIXELS(145) WRITE_8PIXELS_FLIPPED(145) -WRITE_8PIXELS(146) WRITE_8PIXELS_FLIPPED(146) -WRITE_8PIXELS(147) WRITE_8PIXELS_FLIPPED(147) -WRITE_8PIXELS(148) WRITE_8PIXELS_FLIPPED(148) -WRITE_8PIXELS(149) WRITE_8PIXELS_FLIPPED(149) -WRITE_8PIXELS(150) WRITE_8PIXELS_FLIPPED(150) -WRITE_8PIXELS(151) WRITE_8PIXELS_FLIPPED(151) -WRITE_8PIXELS(152) WRITE_8PIXELS_FLIPPED(152) -WRITE_8PIXELS(153) WRITE_8PIXELS_FLIPPED(153) -WRITE_8PIXELS(154) WRITE_8PIXELS_FLIPPED(154) -WRITE_8PIXELS(155) WRITE_8PIXELS_FLIPPED(155) -WRITE_8PIXELS(156) WRITE_8PIXELS_FLIPPED(156) -WRITE_8PIXELS(157) WRITE_8PIXELS_FLIPPED(157) -WRITE_8PIXELS(158) WRITE_8PIXELS_FLIPPED(158) -WRITE_8PIXELS(159) WRITE_8PIXELS_FLIPPED(159) -WRITE_8PIXELS(160) WRITE_8PIXELS_FLIPPED(160) -WRITE_8PIXELS(161) WRITE_8PIXELS_FLIPPED(161) -WRITE_8PIXELS(162) WRITE_8PIXELS_FLIPPED(162) -WRITE_8PIXELS(163) WRITE_8PIXELS_FLIPPED(163) -WRITE_8PIXELS(164) WRITE_8PIXELS_FLIPPED(164) -WRITE_8PIXELS(165) WRITE_8PIXELS_FLIPPED(165) -WRITE_8PIXELS(166) WRITE_8PIXELS_FLIPPED(166) -WRITE_8PIXELS(167) WRITE_8PIXELS_FLIPPED(167) -WRITE_8PIXELS(168) WRITE_8PIXELS_FLIPPED(168) -WRITE_8PIXELS(169) WRITE_8PIXELS_FLIPPED(169) -WRITE_8PIXELS(170) WRITE_8PIXELS_FLIPPED(170) -WRITE_8PIXELS(171) WRITE_8PIXELS_FLIPPED(171) -WRITE_8PIXELS(172) WRITE_8PIXELS_FLIPPED(172) -WRITE_8PIXELS(173) WRITE_8PIXELS_FLIPPED(173) -WRITE_8PIXELS(174) WRITE_8PIXELS_FLIPPED(174) -WRITE_8PIXELS(175) WRITE_8PIXELS_FLIPPED(175) -WRITE_8PIXELS(176) WRITE_8PIXELS_FLIPPED(176) -WRITE_8PIXELS(177) WRITE_8PIXELS_FLIPPED(177) -WRITE_8PIXELS(178) WRITE_8PIXELS_FLIPPED(178) -WRITE_8PIXELS(179) WRITE_8PIXELS_FLIPPED(179) -WRITE_8PIXELS(180) WRITE_8PIXELS_FLIPPED(180) -WRITE_8PIXELS(181) WRITE_8PIXELS_FLIPPED(181) -WRITE_8PIXELS(182) WRITE_8PIXELS_FLIPPED(182) -WRITE_8PIXELS(183) WRITE_8PIXELS_FLIPPED(183) -WRITE_8PIXELS(184) WRITE_8PIXELS_FLIPPED(184) -WRITE_8PIXELS(185) WRITE_8PIXELS_FLIPPED(185) -WRITE_8PIXELS(186) WRITE_8PIXELS_FLIPPED(186) -WRITE_8PIXELS(187) WRITE_8PIXELS_FLIPPED(187) -WRITE_8PIXELS(188) WRITE_8PIXELS_FLIPPED(188) -WRITE_8PIXELS(189) WRITE_8PIXELS_FLIPPED(189) -WRITE_8PIXELS(190) WRITE_8PIXELS_FLIPPED(190) -WRITE_8PIXELS(191) WRITE_8PIXELS_FLIPPED(191) -WRITE_8PIXELS(192) WRITE_8PIXELS_FLIPPED(192) -WRITE_8PIXELS(193) WRITE_8PIXELS_FLIPPED(193) -WRITE_8PIXELS(194) WRITE_8PIXELS_FLIPPED(194) -WRITE_8PIXELS(195) WRITE_8PIXELS_FLIPPED(195) -WRITE_8PIXELS(196) WRITE_8PIXELS_FLIPPED(196) -WRITE_8PIXELS(197) WRITE_8PIXELS_FLIPPED(197) -WRITE_8PIXELS(198) WRITE_8PIXELS_FLIPPED(198) -WRITE_8PIXELS(199) WRITE_8PIXELS_FLIPPED(199) -WRITE_8PIXELS(200) WRITE_8PIXELS_FLIPPED(200) -WRITE_8PIXELS(201) WRITE_8PIXELS_FLIPPED(201) -WRITE_8PIXELS(202) WRITE_8PIXELS_FLIPPED(202) -WRITE_8PIXELS(203) WRITE_8PIXELS_FLIPPED(203) -WRITE_8PIXELS(204) WRITE_8PIXELS_FLIPPED(204) -WRITE_8PIXELS(205) WRITE_8PIXELS_FLIPPED(205) -WRITE_8PIXELS(206) WRITE_8PIXELS_FLIPPED(206) -WRITE_8PIXELS(207) WRITE_8PIXELS_FLIPPED(207) -WRITE_8PIXELS(208) WRITE_8PIXELS_FLIPPED(208) -WRITE_8PIXELS(209) WRITE_8PIXELS_FLIPPED(209) -WRITE_8PIXELS(210) WRITE_8PIXELS_FLIPPED(210) -WRITE_8PIXELS(211) WRITE_8PIXELS_FLIPPED(211) -WRITE_8PIXELS(212) WRITE_8PIXELS_FLIPPED(212) -WRITE_8PIXELS(213) WRITE_8PIXELS_FLIPPED(213) -WRITE_8PIXELS(214) WRITE_8PIXELS_FLIPPED(214) -WRITE_8PIXELS(215) WRITE_8PIXELS_FLIPPED(215) -WRITE_8PIXELS(216) WRITE_8PIXELS_FLIPPED(216) -WRITE_8PIXELS(217) WRITE_8PIXELS_FLIPPED(217) -WRITE_8PIXELS(218) WRITE_8PIXELS_FLIPPED(218) -WRITE_8PIXELS(219) WRITE_8PIXELS_FLIPPED(219) -WRITE_8PIXELS(220) WRITE_8PIXELS_FLIPPED(220) -WRITE_8PIXELS(221) WRITE_8PIXELS_FLIPPED(221) -WRITE_8PIXELS(222) WRITE_8PIXELS_FLIPPED(222) -WRITE_8PIXELS(223) WRITE_8PIXELS_FLIPPED(223) -WRITE_8PIXELS(224) WRITE_8PIXELS_FLIPPED(224) -WRITE_8PIXELS(225) WRITE_8PIXELS_FLIPPED(225) -WRITE_8PIXELS(226) WRITE_8PIXELS_FLIPPED(226) -WRITE_8PIXELS(227) WRITE_8PIXELS_FLIPPED(227) -WRITE_8PIXELS(228) WRITE_8PIXELS_FLIPPED(228) -WRITE_8PIXELS(229) WRITE_8PIXELS_FLIPPED(229) -WRITE_8PIXELS(230) WRITE_8PIXELS_FLIPPED(230) -WRITE_8PIXELS(231) WRITE_8PIXELS_FLIPPED(231) -WRITE_8PIXELS(232) WRITE_8PIXELS_FLIPPED(232) -WRITE_8PIXELS(233) WRITE_8PIXELS_FLIPPED(233) -WRITE_8PIXELS(234) WRITE_8PIXELS_FLIPPED(234) -WRITE_8PIXELS(235) WRITE_8PIXELS_FLIPPED(235) -WRITE_8PIXELS(236) WRITE_8PIXELS_FLIPPED(236) -WRITE_8PIXELS(237) WRITE_8PIXELS_FLIPPED(237) -WRITE_8PIXELS(238) WRITE_8PIXELS_FLIPPED(238) -WRITE_8PIXELS(239) WRITE_8PIXELS_FLIPPED(239) -WRITE_8PIXELS(240) WRITE_8PIXELS_FLIPPED(240) -WRITE_8PIXELS(241) WRITE_8PIXELS_FLIPPED(241) -WRITE_8PIXELS(242) WRITE_8PIXELS_FLIPPED(242) -WRITE_8PIXELS(243) WRITE_8PIXELS_FLIPPED(243) -WRITE_8PIXELS(244) WRITE_8PIXELS_FLIPPED(244) -WRITE_8PIXELS(245) WRITE_8PIXELS_FLIPPED(245) -WRITE_8PIXELS(246) WRITE_8PIXELS_FLIPPED(246) -WRITE_8PIXELS(247) WRITE_8PIXELS_FLIPPED(247) -WRITE_8PIXELS(248) WRITE_8PIXELS_FLIPPED(248) -WRITE_8PIXELS(249) WRITE_8PIXELS_FLIPPED(249) -WRITE_8PIXELS(250) WRITE_8PIXELS_FLIPPED(250) -WRITE_8PIXELS(251) WRITE_8PIXELS_FLIPPED(251) -WRITE_8PIXELS(252) WRITE_8PIXELS_FLIPPED(252) -WRITE_8PIXELS(253) WRITE_8PIXELS_FLIPPED(253) -WRITE_8PIXELS(254) WRITE_8PIXELS_FLIPPED(254) -WRITE_8PIXELS(255) WRITE_8PIXELS_FLIPPED(255) - - -void (*Write8Pixels[256])(uint32, uint8*) = -{ - Write8Pixels_0, - Write8Pixels_1, - Write8Pixels_2, - Write8Pixels_3, - Write8Pixels_4, - Write8Pixels_5, - Write8Pixels_6, - Write8Pixels_7, - Write8Pixels_8, - Write8Pixels_9, - Write8Pixels_10, - Write8Pixels_11, - Write8Pixels_12, - Write8Pixels_13, - Write8Pixels_14, - Write8Pixels_15, - Write8Pixels_16, - Write8Pixels_17, - Write8Pixels_18, - Write8Pixels_19, - Write8Pixels_20, - Write8Pixels_21, - Write8Pixels_22, - Write8Pixels_23, - Write8Pixels_24, - Write8Pixels_25, - Write8Pixels_26, - Write8Pixels_27, - Write8Pixels_28, - Write8Pixels_29, - Write8Pixels_30, - Write8Pixels_31, - Write8Pixels_32, - Write8Pixels_33, - Write8Pixels_34, - Write8Pixels_35, - Write8Pixels_36, - Write8Pixels_37, - Write8Pixels_38, - Write8Pixels_39, - Write8Pixels_40, - Write8Pixels_41, - Write8Pixels_42, - Write8Pixels_43, - Write8Pixels_44, - Write8Pixels_45, - Write8Pixels_46, - Write8Pixels_47, - Write8Pixels_48, - Write8Pixels_49, - Write8Pixels_50, - Write8Pixels_51, - Write8Pixels_52, - Write8Pixels_53, - Write8Pixels_54, - Write8Pixels_55, - Write8Pixels_56, - Write8Pixels_57, - Write8Pixels_58, - Write8Pixels_59, - Write8Pixels_60, - Write8Pixels_61, - Write8Pixels_62, - Write8Pixels_63, - Write8Pixels_64, - Write8Pixels_65, - Write8Pixels_66, - Write8Pixels_67, - Write8Pixels_68, - Write8Pixels_69, - Write8Pixels_70, - Write8Pixels_71, - Write8Pixels_72, - Write8Pixels_73, - Write8Pixels_74, - Write8Pixels_75, - Write8Pixels_76, - Write8Pixels_77, - Write8Pixels_78, - Write8Pixels_79, - Write8Pixels_80, - Write8Pixels_81, - Write8Pixels_82, - Write8Pixels_83, - Write8Pixels_84, - Write8Pixels_85, - Write8Pixels_86, - Write8Pixels_87, - Write8Pixels_88, - Write8Pixels_89, - Write8Pixels_90, - Write8Pixels_91, - Write8Pixels_92, - Write8Pixels_93, - Write8Pixels_94, - Write8Pixels_95, - Write8Pixels_96, - Write8Pixels_97, - Write8Pixels_98, - Write8Pixels_99, - Write8Pixels_100, - Write8Pixels_101, - Write8Pixels_102, - Write8Pixels_103, - Write8Pixels_104, - Write8Pixels_105, - Write8Pixels_106, - Write8Pixels_107, - Write8Pixels_108, - Write8Pixels_109, - Write8Pixels_110, - Write8Pixels_111, - Write8Pixels_112, - Write8Pixels_113, - Write8Pixels_114, - Write8Pixels_115, - Write8Pixels_116, - Write8Pixels_117, - Write8Pixels_118, - Write8Pixels_119, - Write8Pixels_120, - Write8Pixels_121, - Write8Pixels_122, - Write8Pixels_123, - Write8Pixels_124, - Write8Pixels_125, - Write8Pixels_126, - Write8Pixels_127, - Write8Pixels_128, - Write8Pixels_129, - Write8Pixels_130, - Write8Pixels_131, - Write8Pixels_132, - Write8Pixels_133, - Write8Pixels_134, - Write8Pixels_135, - Write8Pixels_136, - Write8Pixels_137, - Write8Pixels_138, - Write8Pixels_139, - Write8Pixels_140, - Write8Pixels_141, - Write8Pixels_142, - Write8Pixels_143, - Write8Pixels_144, - Write8Pixels_145, - Write8Pixels_146, - Write8Pixels_147, - Write8Pixels_148, - Write8Pixels_149, - Write8Pixels_150, - Write8Pixels_151, - Write8Pixels_152, - Write8Pixels_153, - Write8Pixels_154, - Write8Pixels_155, - Write8Pixels_156, - Write8Pixels_157, - Write8Pixels_158, - Write8Pixels_159, - Write8Pixels_160, - Write8Pixels_161, - Write8Pixels_162, - Write8Pixels_163, - Write8Pixels_164, - Write8Pixels_165, - Write8Pixels_166, - Write8Pixels_167, - Write8Pixels_168, - Write8Pixels_169, - Write8Pixels_170, - Write8Pixels_171, - Write8Pixels_172, - Write8Pixels_173, - Write8Pixels_174, - Write8Pixels_175, - Write8Pixels_176, - Write8Pixels_177, - Write8Pixels_178, - Write8Pixels_179, - Write8Pixels_180, - Write8Pixels_181, - Write8Pixels_182, - Write8Pixels_183, - Write8Pixels_184, - Write8Pixels_185, - Write8Pixels_186, - Write8Pixels_187, - Write8Pixels_188, - Write8Pixels_189, - Write8Pixels_190, - Write8Pixels_191, - Write8Pixels_192, - Write8Pixels_193, - Write8Pixels_194, - Write8Pixels_195, - Write8Pixels_196, - Write8Pixels_197, - Write8Pixels_198, - Write8Pixels_199, - Write8Pixels_200, - Write8Pixels_201, - Write8Pixels_202, - Write8Pixels_203, - Write8Pixels_204, - Write8Pixels_205, - Write8Pixels_206, - Write8Pixels_207, - Write8Pixels_208, - Write8Pixels_209, - Write8Pixels_210, - Write8Pixels_211, - Write8Pixels_212, - Write8Pixels_213, - Write8Pixels_214, - Write8Pixels_215, - Write8Pixels_216, - Write8Pixels_217, - Write8Pixels_218, - Write8Pixels_219, - Write8Pixels_220, - Write8Pixels_221, - Write8Pixels_222, - Write8Pixels_223, - Write8Pixels_224, - Write8Pixels_225, - Write8Pixels_226, - Write8Pixels_227, - Write8Pixels_228, - Write8Pixels_229, - Write8Pixels_230, - Write8Pixels_231, - Write8Pixels_232, - Write8Pixels_233, - Write8Pixels_234, - Write8Pixels_235, - Write8Pixels_236, - Write8Pixels_237, - Write8Pixels_238, - Write8Pixels_239, - Write8Pixels_240, - Write8Pixels_241, - Write8Pixels_242, - Write8Pixels_243, - Write8Pixels_244, - Write8Pixels_245, - Write8Pixels_246, - Write8Pixels_247, - Write8Pixels_248, - Write8Pixels_249, - Write8Pixels_250, - Write8Pixels_251, - Write8Pixels_252, - Write8Pixels_253, - Write8Pixels_254, - Write8Pixels_255 }; - -void (*Write8PixelsFlipped[256])(uint32, uint8*) = -{ - Write8PixelsFlipped_0, - Write8PixelsFlipped_1, - Write8PixelsFlipped_2, - Write8PixelsFlipped_3, - Write8PixelsFlipped_4, - Write8PixelsFlipped_5, - Write8PixelsFlipped_6, - Write8PixelsFlipped_7, - Write8PixelsFlipped_8, - Write8PixelsFlipped_9, - Write8PixelsFlipped_10, - Write8PixelsFlipped_11, - Write8PixelsFlipped_12, - Write8PixelsFlipped_13, - Write8PixelsFlipped_14, - Write8PixelsFlipped_15, - Write8PixelsFlipped_16, - Write8PixelsFlipped_17, - Write8PixelsFlipped_18, - Write8PixelsFlipped_19, - Write8PixelsFlipped_20, - Write8PixelsFlipped_21, - Write8PixelsFlipped_22, - Write8PixelsFlipped_23, - Write8PixelsFlipped_24, - Write8PixelsFlipped_25, - Write8PixelsFlipped_26, - Write8PixelsFlipped_27, - Write8PixelsFlipped_28, - Write8PixelsFlipped_29, - Write8PixelsFlipped_30, - Write8PixelsFlipped_31, - Write8PixelsFlipped_32, - Write8PixelsFlipped_33, - Write8PixelsFlipped_34, - Write8PixelsFlipped_35, - Write8PixelsFlipped_36, - Write8PixelsFlipped_37, - Write8PixelsFlipped_38, - Write8PixelsFlipped_39, - Write8PixelsFlipped_40, - Write8PixelsFlipped_41, - Write8PixelsFlipped_42, - Write8PixelsFlipped_43, - Write8PixelsFlipped_44, - Write8PixelsFlipped_45, - Write8PixelsFlipped_46, - Write8PixelsFlipped_47, - Write8PixelsFlipped_48, - Write8PixelsFlipped_49, - Write8PixelsFlipped_50, - Write8PixelsFlipped_51, - Write8PixelsFlipped_52, - Write8PixelsFlipped_53, - Write8PixelsFlipped_54, - Write8PixelsFlipped_55, - Write8PixelsFlipped_56, - Write8PixelsFlipped_57, - Write8PixelsFlipped_58, - Write8PixelsFlipped_59, - Write8PixelsFlipped_60, - Write8PixelsFlipped_61, - Write8PixelsFlipped_62, - Write8PixelsFlipped_63, - Write8PixelsFlipped_64, - Write8PixelsFlipped_65, - Write8PixelsFlipped_66, - Write8PixelsFlipped_67, - Write8PixelsFlipped_68, - Write8PixelsFlipped_69, - Write8PixelsFlipped_70, - Write8PixelsFlipped_71, - Write8PixelsFlipped_72, - Write8PixelsFlipped_73, - Write8PixelsFlipped_74, - Write8PixelsFlipped_75, - Write8PixelsFlipped_76, - Write8PixelsFlipped_77, - Write8PixelsFlipped_78, - Write8PixelsFlipped_79, - Write8PixelsFlipped_80, - Write8PixelsFlipped_81, - Write8PixelsFlipped_82, - Write8PixelsFlipped_83, - Write8PixelsFlipped_84, - Write8PixelsFlipped_85, - Write8PixelsFlipped_86, - Write8PixelsFlipped_87, - Write8PixelsFlipped_88, - Write8PixelsFlipped_89, - Write8PixelsFlipped_90, - Write8PixelsFlipped_91, - Write8PixelsFlipped_92, - Write8PixelsFlipped_93, - Write8PixelsFlipped_94, - Write8PixelsFlipped_95, - Write8PixelsFlipped_96, - Write8PixelsFlipped_97, - Write8PixelsFlipped_98, - Write8PixelsFlipped_99, - Write8PixelsFlipped_100, - Write8PixelsFlipped_101, - Write8PixelsFlipped_102, - Write8PixelsFlipped_103, - Write8PixelsFlipped_104, - Write8PixelsFlipped_105, - Write8PixelsFlipped_106, - Write8PixelsFlipped_107, - Write8PixelsFlipped_108, - Write8PixelsFlipped_109, - Write8PixelsFlipped_110, - Write8PixelsFlipped_111, - Write8PixelsFlipped_112, - Write8PixelsFlipped_113, - Write8PixelsFlipped_114, - Write8PixelsFlipped_115, - Write8PixelsFlipped_116, - Write8PixelsFlipped_117, - Write8PixelsFlipped_118, - Write8PixelsFlipped_119, - Write8PixelsFlipped_120, - Write8PixelsFlipped_121, - Write8PixelsFlipped_122, - Write8PixelsFlipped_123, - Write8PixelsFlipped_124, - Write8PixelsFlipped_125, - Write8PixelsFlipped_126, - Write8PixelsFlipped_127, - Write8PixelsFlipped_128, - Write8PixelsFlipped_129, - Write8PixelsFlipped_130, - Write8PixelsFlipped_131, - Write8PixelsFlipped_132, - Write8PixelsFlipped_133, - Write8PixelsFlipped_134, - Write8PixelsFlipped_135, - Write8PixelsFlipped_136, - Write8PixelsFlipped_137, - Write8PixelsFlipped_138, - Write8PixelsFlipped_139, - Write8PixelsFlipped_140, - Write8PixelsFlipped_141, - Write8PixelsFlipped_142, - Write8PixelsFlipped_143, - Write8PixelsFlipped_144, - Write8PixelsFlipped_145, - Write8PixelsFlipped_146, - Write8PixelsFlipped_147, - Write8PixelsFlipped_148, - Write8PixelsFlipped_149, - Write8PixelsFlipped_150, - Write8PixelsFlipped_151, - Write8PixelsFlipped_152, - Write8PixelsFlipped_153, - Write8PixelsFlipped_154, - Write8PixelsFlipped_155, - Write8PixelsFlipped_156, - Write8PixelsFlipped_157, - Write8PixelsFlipped_158, - Write8PixelsFlipped_159, - Write8PixelsFlipped_160, - Write8PixelsFlipped_161, - Write8PixelsFlipped_162, - Write8PixelsFlipped_163, - Write8PixelsFlipped_164, - Write8PixelsFlipped_165, - Write8PixelsFlipped_166, - Write8PixelsFlipped_167, - Write8PixelsFlipped_168, - Write8PixelsFlipped_169, - Write8PixelsFlipped_170, - Write8PixelsFlipped_171, - Write8PixelsFlipped_172, - Write8PixelsFlipped_173, - Write8PixelsFlipped_174, - Write8PixelsFlipped_175, - Write8PixelsFlipped_176, - Write8PixelsFlipped_177, - Write8PixelsFlipped_178, - Write8PixelsFlipped_179, - Write8PixelsFlipped_180, - Write8PixelsFlipped_181, - Write8PixelsFlipped_182, - Write8PixelsFlipped_183, - Write8PixelsFlipped_184, - Write8PixelsFlipped_185, - Write8PixelsFlipped_186, - Write8PixelsFlipped_187, - Write8PixelsFlipped_188, - Write8PixelsFlipped_189, - Write8PixelsFlipped_190, - Write8PixelsFlipped_191, - Write8PixelsFlipped_192, - Write8PixelsFlipped_193, - Write8PixelsFlipped_194, - Write8PixelsFlipped_195, - Write8PixelsFlipped_196, - Write8PixelsFlipped_197, - Write8PixelsFlipped_198, - Write8PixelsFlipped_199, - Write8PixelsFlipped_200, - Write8PixelsFlipped_201, - Write8PixelsFlipped_202, - Write8PixelsFlipped_203, - Write8PixelsFlipped_204, - Write8PixelsFlipped_205, - Write8PixelsFlipped_206, - Write8PixelsFlipped_207, - Write8PixelsFlipped_208, - Write8PixelsFlipped_209, - Write8PixelsFlipped_210, - Write8PixelsFlipped_211, - Write8PixelsFlipped_212, - Write8PixelsFlipped_213, - Write8PixelsFlipped_214, - Write8PixelsFlipped_215, - Write8PixelsFlipped_216, - Write8PixelsFlipped_217, - Write8PixelsFlipped_218, - Write8PixelsFlipped_219, - Write8PixelsFlipped_220, - Write8PixelsFlipped_221, - Write8PixelsFlipped_222, - Write8PixelsFlipped_223, - Write8PixelsFlipped_224, - Write8PixelsFlipped_225, - Write8PixelsFlipped_226, - Write8PixelsFlipped_227, - Write8PixelsFlipped_228, - Write8PixelsFlipped_229, - Write8PixelsFlipped_230, - Write8PixelsFlipped_231, - Write8PixelsFlipped_232, - Write8PixelsFlipped_233, - Write8PixelsFlipped_234, - Write8PixelsFlipped_235, - Write8PixelsFlipped_236, - Write8PixelsFlipped_237, - Write8PixelsFlipped_238, - Write8PixelsFlipped_239, - Write8PixelsFlipped_240, - Write8PixelsFlipped_241, - Write8PixelsFlipped_242, - Write8PixelsFlipped_243, - Write8PixelsFlipped_244, - Write8PixelsFlipped_245, - Write8PixelsFlipped_246, - Write8PixelsFlipped_247, - Write8PixelsFlipped_248, - Write8PixelsFlipped_249, - Write8PixelsFlipped_250, - Write8PixelsFlipped_251, - Write8PixelsFlipped_252, - Write8PixelsFlipped_253, - Write8PixelsFlipped_254, - Write8PixelsFlipped_255 }; -*/ - - void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { -} + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) +} void DrawClippedTile (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) } void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) } void DrawClippedTilex2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) } void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) } void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) } -/* -inline void __attribute__((always_inline)) WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; - uint16 *Pixels16 = (uint16 *)Pixels; uint16 *Screen = (uint16 *) GFX.S + Offset; uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if ((Pixel = Pixels16[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ - TILE_AssignPixel(N, Pixel); \ + TILE_SetPixel16(N, Pixel); \ } FN(0) @@ -1235,18 +424,16 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16 (uint32 Offset, uint8 #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) { uint32 Pixel; - uint16 *Pixels16 = (uint16 *)Pixels; uint16 *Screen = (uint16 *) GFX.S + Offset; uint8 *Depth = GFX.DB + Offset; - #define FN(N) \ - if ((Pixel = Pixels16[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ - TILE_AssignPixel(N, Pixel); \ + TILE_SetPixel16(N, Pixel); \ } FN(0) @@ -1256,9 +443,6 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED (uint32 Offse #undef FN } - - - inline void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; @@ -1342,45 +526,68 @@ inline void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) FN(3) #undef FN } -*/ void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { -} - + TILE_PREAMBLE + register uint8 *bp; + RENDER_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) +} void DrawClippedTile16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) } void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) } void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) } void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) } void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) } -/* -inline void __attribute__((always_inline)) WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1388,7 +595,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_ADD (uint32 Offset, u uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SelectAddPixel16(N, Pixel); \ } @@ -1401,7 +608,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_ADD (uint32 Offset, u #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1409,7 +616,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_ADD (uint32 O uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SelectAddPixel16(N, Pixel); \ } @@ -1422,7 +629,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_ADD (uint32 O #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1430,7 +637,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_ADD1_2 (uint32 Offset uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SelectAddPixel16Half(N, Pixel); \ } @@ -1443,7 +650,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_ADD1_2 (uint32 Offset #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1451,7 +658,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint3 uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SelectAddPixel16Half(N, Pixel); \ } @@ -1464,7 +671,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint3 #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1472,7 +679,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_SUB (uint32 Offset, u uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SelectSubPixel16(N, Pixel); \ } @@ -1485,7 +692,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_SUB (uint32 Offset, u #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1493,7 +700,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_SUB (uint32 O uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SelectSubPixel16(N, Pixel); \ } @@ -1506,7 +713,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_SUB (uint32 O #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1514,7 +721,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_SUB1_2 (uint32 Offset uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SelectSubPixel16Half(N, Pixel); \ } @@ -1527,7 +734,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_SUB1_2 (uint32 Offset #undef FN } -inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) +inline void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1535,7 +742,7 @@ inline void __attribute__((always_inline)) WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint3 uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SelectSubPixel16Half(N, Pixel); \ } @@ -1637,7 +844,7 @@ inline void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SelectFAddPixel16Half(N, Pixel); \ } @@ -1658,7 +865,7 @@ inline void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SelectFAddPixel16Half(N, Pixel); \ } @@ -1679,7 +886,7 @@ inline void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ TILE_SelectFSubPixel16Half(N, Pixel); \ } @@ -1700,7 +907,7 @@ inline void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if ((Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ TILE_SelectFSubPixel16Half(N, Pixel); \ } @@ -1712,67 +919,151 @@ inline void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -*/ void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_ADDF1_2, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) } void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADDF1_2, + WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) } void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_SUBF1_2, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) } void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUBF1_2, + WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) } void DrawLargePixel (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint8 *sp = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + uint8 pixel; +#define PLOT_PIXEL(screen, pixel) (pixel) + + RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) } void DrawLargePixel16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + uint16 pixel; + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) } void DrawLargePixel16Add (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_ADD_PIXEL(s, p) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_ADD (p, *(s + GFX.Delta)) : \ + COLOR_ADD (p, GFX.FixedColour)) \ + : p) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL) } void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_ADD_PIXEL1_2(s, p) \ +((uint16) (Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_ADD1_2 (p, *(s + GFX.Delta)) : \ + COLOR_ADD (p, GFX.FixedColour)) \ + : p)) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL1_2) } void DrawLargePixel16Sub (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_SUB_PIXEL(s, p) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_SUB (p, *(s + GFX.Delta)) : \ + COLOR_SUB (p, GFX.FixedColour)) \ + : p) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL) } void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { -} + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; -/* +#define LARGE_SUB_PIXEL1_2(s, p) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_SUB1_2 (p, *(s + GFX.Delta)) : \ + COLOR_SUB (p, GFX.FixedColour)) \ + : p) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL1_2) +} #ifdef USE_GLIDE #if 0 @@ -1867,208 +1158,3 @@ void DrawClippedTile3dfx (uint32 Tile, uint32 Offset, #endif #endif - - - - -//------------------------------------------------------------------- -// Optimizations -//------------------------------------------------------------------- - -void GenerateTileMask(SBG* BG, uint8 *pCache, uint32 TileNumber) -{ - bool fullTile = TRUE; - uint8 tileMask = 0; - uint8 tileMaskFlipped = 0; - - for (int y = 0; y < 64; y += 8) - { - tileMask = 0; - //tileMaskFlipped = 0; - for (int x = 0; x < 8; x ++) - { - if (pCache[x + y]) - { - tileMask |= (0x01 << x); - //tileMaskFlipped |= (0x80 >> x); - } - } - // BG->TileMask[TileNumber][y / 8] = tileMask; - //BG->TileMaskFlipped[TileNumber][y / 8] = tileMaskFlipped; - - if (tileMask != 0xFF) - fullTile = FALSE; - } -} - - - -inline void __attribute__((always_inline)) WRITE_8PIXELS16 (uint32 Offset, uint8 *Pixels) -{ - register uint32 Pixel1; - register uint32 Pixel2; - register uint32 Pixel3; - register uint32 Pixel4; - - uint16 *Pixels16 = (uint16 *)Pixels; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N)\ - Pixel1 = Pixels16[N];\ - Pixel2 = Pixels16[N+1];\ - Pixel3 = Pixels16[N+2];\ - Pixel4 = Pixels16[N+3];\ - if (Pixel1) TILE_AssignPixel(N, Pixel1);\ - if (Pixel2) TILE_AssignPixel(N+1, Pixel2); \ - if (Pixel3) TILE_AssignPixel(N+2, Pixel3); \ - if (Pixel4) TILE_AssignPixel(N+3, Pixel4); - - FN(0) - FN(4) - -#undef FN -} - -inline void __attribute__((always_inline)) WRITE_8PIXELS16_FULL (uint32 Offset, uint8 *Pixels) -{ - register uint32 PixelPair1; - register uint32 PixelPair2; - register uint32 PixelPair3; - register uint32 PixelPair4; - - uint32 *Pixels32 = (uint32 *)Pixels; - uint32 *Screen32 = (uint32 *)((uint16 *) GFX.S + Offset); - uint8 *Depth = GFX.DB + Offset; - - PixelPair1 = Pixels32[0]; - PixelPair2 = Pixels32[1]; - PixelPair3 = Pixels32[2]; - PixelPair4 = Pixels32[3]; - - TILE_AssignTwoPixels(0, PixelPair1); - TILE_AssignTwoPixels(1, PixelPair2); - TILE_AssignTwoPixels(2, PixelPair3); - TILE_AssignTwoPixels(3, PixelPair4); -} - -inline void __attribute__((always_inline)) WRITE_8PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) -{ - register uint32 Pixel1; - register uint32 Pixel2; - register uint32 Pixel3; - register uint32 Pixel4; - - uint16 *Pixels16 = (uint16 *)Pixels; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - - -#define FN(N)\ - Pixel1 = Pixels16[7-N];\ - Pixel2 = Pixels16[7-N-1];\ - Pixel3 = Pixels16[7-N-2];\ - Pixel4 = Pixels16[7-N-3];\ - if (Pixel1) TILE_AssignPixel(N, Pixel1);\ - if (Pixel2) TILE_AssignPixel(N+1, Pixel2); \ - if (Pixel3) TILE_AssignPixel(N+2, Pixel3); \ - if (Pixel4) TILE_AssignPixel(N+3, Pixel4); - - FN(0) - FN(4) -#undef FN -} - - -inline void __attribute__((always_inline)) WRITE_8PIXELS16_FULL_FLIPPED (uint32 Offset, uint8 *Pixels) -{ - register uint32 PixelPair1; - register uint32 PixelPair2; - register uint32 PixelPair3; - register uint32 PixelPair4; - - uint32 *Pixels32 = (uint32 *)Pixels; - uint32 *Screen32 = (uint32 *)((uint16 *) GFX.S + Offset); - uint8 *Depth = GFX.DB + Offset; - - PixelPair1 = (Pixels32[0] << 16) | (Pixels32[0] >> 16); - PixelPair2 = (Pixels32[1] << 16) | (Pixels32[1] >> 16); - PixelPair3 = (Pixels32[2] << 16) | (Pixels32[2] >> 16); - PixelPair4 = (Pixels32[3] << 16) | (Pixels32[3] >> 16); - - TILE_AssignTwoPixels(0, PixelPair4); - TILE_AssignTwoPixels(1, PixelPair3); - TILE_AssignTwoPixels(2, PixelPair2); - TILE_AssignTwoPixels(3, PixelPair1); -} - - - -inline void __attribute__((always_inline)) WRITE_8PIXELS16_CLIPPED (uint32 Offset, uint8 *Pixels, uint8 StartPixel, uint8 Width) -{ - register uint32 Pixel1; - uint16 *Pixels16 = &((uint16 *)Pixels)[StartPixel]; - uint16 *Screen = (uint16 *) GFX.S + Offset + StartPixel; - -#define FN(N) Pixel1 = Pixels16[N]; if (Pixel1) TILE_AssignPixel(N, Pixel1); - - switch (Width) - { - case 8: FN(7) - case 7: FN(6) - case 6: FN(5) - case 5: FN(4) - case 4: FN(3) - case 3: FN(2) - case 2: FN(1) - case 1: FN(0) - } -#undef FN -} - - -inline void __attribute__((always_inline)) WRITE_8PIXELS16_CLIPPED_FLIPPED (uint32 Offset, uint8 *Pixels, uint8 StartPixel, uint8 Width) -{ - register uint32 Pixel1; - uint16 *Pixels16 = &((uint16 *)Pixels)[7 - StartPixel]; - uint16 *Screen = (uint16 *) GFX.S + Offset + StartPixel; - -#define FN(N) Pixel1 = Pixels16[- N]; if (Pixel1) TILE_AssignPixel(N, Pixel1); - - switch (Width) - { - case 8: FN(7) - case 7: FN(6) - case 6: FN(5) - case 5: FN(4) - case 4: FN(3) - case 3: FN(2) - case 2: FN(1) - case 1: FN(0) - } -#undef FN -} -*/ - - -void DrawTileBG16 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ -} - -void DrawClippedTileBG16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ -} - -void DrawTileOBJ16 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ -} - -void DrawClippedTileOBJ16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ -} diff --git a/source/tile.h b/source/tile.h index 6a2c5f0..4507e1b 100644 --- a/source/tile.h +++ b/source/tile.h @@ -89,25 +89,21 @@ #ifndef _TILE_H_ #define _TILE_H_ -#define SUBSCREEN_DELTA 524288 -//#define TILE_AssignPixel(N, value) Screen[N]=(value);Depth[N]=GFX.Z2; -#define TILE_AssignPixel(N, value) Screen[N]=(value); -#define TILE_AssignTwoPixels(N, value) Screen32[N]=(value); +#define TILE_AssignPixel(N, value) Screen[N]=(value);Depth[N]=GFX.Z2; #define TILE_SetPixel(N, Pixel) TILE_AssignPixel(N, (uint8) GFX.ScreenColors [Pixel]); #define TILE_SetPixel16(N, Pixel) TILE_AssignPixel(N, GFX.ScreenColors [Pixel]); -#define TILE_AddPixel16(N, Pixel) if (Screen[SUBSCREEN_DELTA+N]) { TILE_AssignPixel(N, COLOR_ADD(GFX.ScreenColors[Pixel], Screen[SUBSCREEN_DELTA+N])); } else { TILE_SetPixel16(N, Pixel) } +#define TILE_AddPixel16(N, Pixel) TILE_AssignPixel(N, COLOR_ADD(GFX.ScreenColors[Pixel], Screen[GFX.Delta+N])); #define TILE_AddFPixel16(N, Pixel) TILE_AssignPixel(N, COLOR_ADD(GFX.ScreenColors[Pixel], GFX.FixedColour)); -#define TILE_AddPixel16Half(N, Pixel) if (Screen[SUBSCREEN_DELTA+N]) { TILE_AssignPixel(N, (uint16)COLOR_ADD1_2(GFX.ScreenColors[Pixel], Screen[SUBSCREEN_DELTA+N])); } else { TILE_SetPixel16(N, Pixel) } +#define TILE_AddPixel16Half(N, Pixel) TILE_AssignPixel(N, (uint16)COLOR_ADD1_2(GFX.ScreenColors[Pixel], Screen[GFX.Delta+N])); #define TILE_AddFPixel16Half(N, Pixel) TILE_AssignPixel(N, (uint16)COLOR_ADD1_2(GFX.ScreenColors[Pixel], GFX.FixedColour)); -#define TILE_SubPixel16(N, Pixel) if (Screen[SUBSCREEN_DELTA+N]) { TILE_AssignPixel(N, COLOR_SUB(GFX.ScreenColors[Pixel], Screen[SUBSCREEN_DELTA+N])); } else { TILE_SetPixel16(N, Pixel) } +#define TILE_SubPixel16(N, Pixel) TILE_AssignPixel(N, COLOR_SUB(GFX.ScreenColors[Pixel], Screen[GFX.Delta+N])); #define TILE_SubFPixel16(N, Pixel) TILE_AssignPixel(N, COLOR_SUB(GFX.ScreenColors[Pixel], GFX.FixedColour)); -#define TILE_SubPixel16Half(N, Pixel) if (Screen[SUBSCREEN_DELTA+N]) { TILE_AssignPixel(N, (uint16)COLOR_SUB1_2(GFX.ScreenColors[Pixel], Screen[SUBSCREEN_DELTA+N])); } else { TILE_SetPixel16(N, Pixel) } +#define TILE_SubPixel16Half(N, Pixel) TILE_AssignPixel(N, (uint16)COLOR_SUB1_2(GFX.ScreenColors[Pixel], Screen[GFX.Delta+N])); #define TILE_SubFPixel16Half(N, Pixel) TILE_AssignPixel(N, (uint16)COLOR_SUB1_2(GFX.ScreenColors[Pixel], GFX.FixedColour)); -/* #define TILE_Select3(N,Pixel,FAddType, AddType) \ switch(SubDepth[N]) \ { \ @@ -115,22 +111,13 @@ case 1: TILE_##FAddType(N, Pixel); break; \ default: TILE_##AddType(N, Pixel); break; \ } - */ -/* + #define TILE_Select2(N,Pixel,FAddType) \ switch(SubDepth[N]) \ { \ case 1: TILE_##FAddType(N, Pixel); break; \ default: TILE_SetPixel16(N, Pixel); break; \ } -*/ - -#define TILE_Select3(N,Pixel,FAddType, AddType) \ - TILE_##AddType(N, Pixel); - -#define TILE_Select2(N,Pixel,FAddType) \ - TILE_##FAddType(N, Pixel); - #define TILE_SelectAddPixel16(N, Pixel) TILE_Select3(N,Pixel, AddFPixel16, AddPixel16) #define TILE_SelectAddPixel16Half(N, Pixel) TILE_Select3(N,Pixel, AddFPixel16, AddPixel16Half) @@ -144,7 +131,6 @@ #define TILE_PREAMBLE \ uint8 *pCache; \ - uint16 *pCache16; \ \ uint32 TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); \ if ((Tile & 0x1ff) >= 256) \ @@ -156,141 +142,68 @@ pCache = &BG.Buffer[(TileNumber = (TileAddr >> BG.TileShift)) << 6]; \ \ if (!BG.Buffered [TileNumber]) \ - { \ - BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \ - if (BG.Buffered [TileNumber] == BLANK_TILE) \ - return; \ - GFX.VRAMPaletteFrame[TileAddr][0] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][1] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][2] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][3] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][4] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][5] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][6] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][7] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][8] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][9] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][10] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][11] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][12] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][13] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][14] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][15] = 0; \ - } \ + BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \ \ if (BG.Buffered [TileNumber] == BLANK_TILE) \ - return; \ - \ + return; \ \ register uint32 l; \ - uint8 pal; \ if (BG.DirectColourMode) \ { \ - if (IPPU.DirectColourMapsNeedRebuild) \ + if (IPPU.DirectColourMapsNeedRebuild) \ S9xBuildDirectColourMaps (); \ - pal = (Tile >> 10) & BG.PaletteMask; \ - pCache16 = 0; \ - GFX.ScreenColors = DirectColourMaps [pal]; \ - if (GFX.VRAMPaletteFrame[TileAddr][pal] != GFX.PaletteFrame[pal + BG.StartPalette / 16]) \ - { \ - GFX.VRAMPaletteFrame[TileAddr][pal] = GFX.PaletteFrame[pal + BG.StartPalette / 16]; \ - ConvertTileTo16Bit(GFX.ScreenColors, pCache, pCache16); \ - } \ + GFX.ScreenColors = DirectColourMaps [(Tile >> 10) & BG.PaletteMask]; \ } \ else \ - { \ - pal = (Tile >> 10) & BG.PaletteMask; \ - pCache16 = 0; \ - GFX.ScreenColors = &IPPU.ScreenColors [(pal << BG.PaletteShift) + BG.StartPalette]; \ - if (GFX.VRAMPaletteFrame[TileAddr][pal] != GFX.PaletteFrame[pal + BG.StartPalette / 16]) \ - { \ - GFX.VRAMPaletteFrame[TileAddr][pal] = GFX.PaletteFrame[pal + BG.StartPalette / 16]; \ - ConvertTileTo16Bit(GFX.ScreenColors, pCache, pCache16); \ - } \ - } - + GFX.ScreenColors = &IPPU.ScreenColors [(((Tile >> 10) & BG.PaletteMask) << BG.PaletteShift) + BG.StartPalette]; - /* #define RENDER_TILE(NORMAL, FLIPPED, N) \ if (!(Tile & (V_FLIP | H_FLIP))) \ { \ - bp = (uint8 *)(pCache + StartLine); \ + bp = pCache + StartLine; \ for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ { \ + if (*(uint32 *) bp) \ NORMAL (Offset, bp); \ + if (*(uint32 *) (bp + 4)) \ NORMAL (Offset + N, bp + 4); \ } \ } \ else \ if (!(Tile & V_FLIP)) \ { \ - bp = (uint8 *)(pCache + StartLine); \ + bp = pCache + StartLine; \ for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ { \ + if (*(uint32 *) (bp + 4)) \ FLIPPED (Offset, bp + 4); \ + if (*(uint32 *) bp) \ FLIPPED (Offset + N, bp); \ } \ } \ else \ if (Tile & H_FLIP) \ { \ - bp = (uint8 *)(pCache + 56 - StartLine); \ + bp = pCache + 56 - StartLine; \ for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ { \ + if (*(uint32 *) (bp + 4)) \ FLIPPED (Offset, bp + 4); \ + if (*(uint32 *) bp) \ FLIPPED (Offset + N, bp); \ } \ } \ else \ { \ - bp = (uint8 *)(pCache + 56 - StartLine); \ + bp = pCache + 56 - StartLine; \ for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ { \ + if (*(uint32 *) bp) \ NORMAL (Offset, bp); \ + if (*(uint32 *) (bp + 4)) \ NORMAL (Offset + N, bp + 4); \ } \ } - */ - -#define RENDER_TILE(NORMAL, FLIPPED, N) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = (uint8 *)(pCache16 + StartLine); \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) \ - { \ - NORMAL (Offset, bp); \ - NORMAL (Offset + N, bp + 8); \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = (uint8 *)(pCache16 + StartLine); \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) \ - { \ - FLIPPED (Offset, bp + 8); \ - FLIPPED (Offset + N, bp); \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = (uint8 *)(pCache16 + 56 - StartLine); \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) \ - { \ - FLIPPED (Offset, bp + 8); \ - FLIPPED (Offset + N, bp); \ - } \ - } \ - else \ - { \ - bp = (uint8 *)(pCache16 + 56 - StartLine); \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) \ - { \ - NORMAL (Offset, bp); \ - NORMAL (Offset + N, bp + 8); \ - } \ - } #define TILE_CLIP_PREAMBLE \ uint32 dd; \ @@ -442,154 +355,3 @@ } #endif - - -// ------------------------------------------------------------ -// Optimizations -// ------------------------------------------------------------ -#define TILE_PREAMBLE2(isBG) \ - uint8 *pCache; \ - uint16 *pCache16; \ -\ - uint32 TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); \ - \ - if (!isBG) \ - { \ - if ((Tile & 0x1ff) >= 256) \ - TileAddr += BG.NameSelect; \ -\ - TileAddr &= 0xffff; \ - }\ -\ - uint32 TileNumber; \ - pCache = &BG.Buffer[(TileNumber = (TileAddr >> BG.TileShift)) << 6]; \ -\ - if (!BG.Buffered [TileNumber]) \ - { \ - BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \ - if (BG.Buffered [TileNumber] == BLANK_TILE) \ - return; \ - GenerateTileMask(&BG, pCache, TileNumber); \ - GFX.VRAMPaletteFrame[TileAddr][0] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][1] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][2] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][3] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][4] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][5] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][6] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][7] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][8] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][9] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][10] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][11] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][12] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][13] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][14] = 0; \ - GFX.VRAMPaletteFrame[TileAddr][15] = 0; \ - } \ -\ - if (BG.Buffered [TileNumber] == BLANK_TILE) \ - return; \ - \ -\ - register uint32 l; \ - uint8 pal; \ - if (BG.DirectColourMode && isBG) \ - { \ - if (IPPU.DirectColourMapsNeedRebuild) \ - S9xBuildDirectColourMaps (); \ - pal = (Tile >> 10) & BG.PaletteMask; \ - pCache16 = 0; \ - GFX.ScreenColors = DirectColourMaps [pal]; \ - if (GFX.VRAMPaletteFrame[TileAddr][pal] != GFX.PaletteFrame[pal + BG.StartPalette / 16]) \ - { \ - GFX.VRAMPaletteFrame[TileAddr][pal] = GFX.PaletteFrame[pal + BG.StartPalette / 16]; \ - ConvertTileTo16Bit(GFX.ScreenColors, pCache, pCache16); \ - } \ - } \ - else \ - { \ - pal = (Tile >> 10) & BG.PaletteMask; \ - pCache16 = 0; \ - GFX.ScreenColors = &IPPU.ScreenColors [(pal << BG.PaletteShift) + BG.StartPalette]; \ - if (GFX.VRAMPaletteFrame[TileAddr][pal] != GFX.PaletteFrame[pal + BG.StartPalette / 16]) \ - { \ - GFX.VRAMPaletteFrame[TileAddr][pal] = GFX.PaletteFrame[pal + BG.StartPalette / 16]; \ - ConvertTileTo16Bit(GFX.ScreenColors, pCache, pCache16); \ - } \ - } - -#define RENDER_TILE_FAST(NORMAL, FLIPPED, FULL_NORMAL, FULL_FLIPPED) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = (uint8 *)(pCache16 + StartLine); \ - if (Offset & 1) \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) NORMAL (Offset, bp); \ - else \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) FULL_NORMAL (Offset, bp); \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = (uint8 *)(pCache16 + StartLine); \ - if (Offset & 1) \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) FLIPPED (Offset, bp); \ - else \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) FULL_FLIPPED (Offset, bp); \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = (uint8 *)(pCache16 + 56 - StartLine); \ - if (Offset & 1) \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) FLIPPED (Offset, bp); \ - else \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) FULL_FLIPPED (Offset, bp); \ - } \ - else \ - { \ - bp = (uint8 *)(pCache16 + 56 - StartLine); \ - if (Offset & 1) \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) NORMAL (Offset, bp); \ - else \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) FULL_NORMAL (Offset, bp); \ - } - -#define RENDER_CLIPPED_TILE_FAST(NORMAL, FLIPPED) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = (uint8 *)(pCache16 + StartLine); \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) \ - { \ - NORMAL (Offset, bp, StartPixel, Width); \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = (uint8 *)(pCache16 + StartLine); \ - for (l = LineCount; l != 0; l--, bp += 16, Offset += GFX.PPL) \ - { \ - FLIPPED (Offset, bp, StartPixel, Width); \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = (uint8 *)(pCache16 + 56 - StartLine); \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) \ - { \ - FLIPPED (Offset, bp, StartPixel, Width); \ - } \ - } \ - else \ - { \ - bp = (uint8 *)(pCache16 + 56 - StartLine); \ - for (l = LineCount; l != 0; l--, bp -= 16, Offset += GFX.PPL) \ - { \ - NORMAL (Offset, bp, StartPixel, Width); \ - } \ - } - -uint8 ConvertTile (uint8 *pCache, uint32 TileAddr); -