Mednafen Members Members   Search Search   Help Help   Register Register   Login Login   Home Home
Home » Mednafen » Development » Minor SMS patch enabling vertical crop
Show: Today's Messages  :: Show Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Minor SMS patch enabling vertical crop [message #6186] Sun, 10 May 2020 16:33
jaminc  [PM]
This is a very minor modification to enable me to crop off some pixels using a config file so that all that is rendered is the portion of the screen that is used. Although I've tested this and it appears to work, I am not familiar enough with the codebase to know how technically valid this approach is, so I'm posting it here for review or for anyone who desires this functionality. I based it off of similar functionality in the NES core.

If there is any desire by the Mednafen team to integrate this code into the project, I grant whatever legal status desired (ownership or whatever) to whomever requires it to the extent that I am capable of granting it.

Visible on github here: https://github.com/Canar/mednafen-git/commit/6c8965c3558cb4cf37c5a7f8e0edddb61da6f778

diff --git a/src/sms/system.cpp b/src/sms/system.cpp
index 6a35c0c..d12e04a 100644
--- a/src/sms/system.cpp
+++ b/src/sms/system.cpp
@@ -25,7 +25,7 @@ namespace MDFN_IEN_SMS
 bitmap_t bitmap;
 input_t input;
 static int32 SoftResetCount;
-static unsigned sls, sle;
+static unsigned sls, sle, scs, sce;
 
 /* Run the virtual console emulation for one frame */
 void system_frame(int skip_render)
@@ -162,9 +162,9 @@ static void Emulate(EmulateSpecStruct *espec)
  }
  else
  {
-  espec->DisplayRect.x = 0;
+  espec->DisplayRect.x = scs;
   espec->DisplayRect.y = sls;
-  espec->DisplayRect.w = 256;
+  espec->DisplayRect.w = sce + 1 - scs;
   espec->DisplayRect.h = sle + 1 - sls;
  }
 
@@ -248,12 +248,20 @@ static void LoadCommon(GameFile* gf)
   {
    sls = MDFN_GetSettingUI((sms.display == DISPLAY_PAL) ? "sms.slstartp" : "sms.slstart");
    sle = MDFN_GetSettingUI((sms.display == DISPLAY_PAL) ? "sms.slendp" : "sms.slend");
+   scs = MDFN_GetSettingUI("sms.scstart");
+   sce = MDFN_GetSettingUI("sms.scend");
 
    if(sle < sls)
     std::swap(sls, sle);
 
+   if(sce < scs)
+    std::swap(sls, sle);
+
    MDFNGameInfo->lcm_height = sle + 1 - sls;
    MDFNGameInfo->nominal_height = sle + 1 - sls;
+
+   MDFNGameInfo->lcm_width = sce + 1 - scs;
+   MDFNGameInfo->nominal_width = sce + 1 - scs;
   }
 
   MDFNGameInfo->MasterClock = MDFN_MASTERCLOCK_FIXED(sndclk);
@@ -391,6 +399,9 @@ static const MDFNSetting SMSSettings[] =
  { "sms.slstartp", MDFNSF_NOFLAGS, gettext_noop("First displayed scanline in PAL mode."), NULL, MDFNST_UINT, "0", "0", "239" },
  { "sms.slendp", MDFNSF_NOFLAGS, gettext_noop("Last displayed scanline in PAL mode."), NULL, MDFNST_UINT, "239", "0", "239" },
 
+ { "sms.scstart", MDFNSF_NOFLAGS, gettext_noop("First displayed column."), NULL, MDFNST_UINT, "0", "0", "255" },
+ { "sms.scend", MDFNSF_NOFLAGS, gettext_noop("Last displayed column."), NULL, MDFNST_UINT, "255", "0", "255" },
+
  { NULL }
 };
 


  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:macOS Catalina - can't get 1.24.0 UNSTABLE to compile
Next Topic:Triggering Anti-Modchip
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ ]

Current Time: Sun May 5 03:30:23 CDT 2024
.:: Contact :: Home ::.

Powered by FUDforum.
Copyright © FUDforum Bulletin Board Software