DeXteRrBDN / dosbox-pinhack

Pinball Fantasies no-scroll patch for DOSBox
15 stars 3 forks source link

Scaling Issue #1

Open sirlee opened 4 years ago

sirlee commented 4 years ago

The patch is great, however whatever I did I could not find a way to get rid of the black borders with this patch.

For this reason I have introduced a new configurable parameter under the pinhack section that allows you to set a custom aspect ratio. With this you will get a perfectly scaled output.

It uses tha aspect_ratio so "aspect=true" in the .conf file needds to be set

.conf file settings:

[sdl]
fullresolution   = desktop
windowresolution = 1080x1920 (or whatever you have)
output           = overlay (or opengl)

[pinhack]
pinhackaspectratio   = 214 (for Pinball Dreams), 187 for Pinball Fantasies

[render]
aspect=true
scaler=none

I modified the following source code files after applying your patch:

vga_draw.cpp:

if (pinhack.enabled) {    // Enabled in config?
    printf("PINHACK: "); // Check for tirggering preconditions...
    if ( ( !pinhack.specifichack.pinballdreams.enabled || pinhack.specifichack.pinballdreams.trigger ) && 
            ( height>=pinhack.triggerheight.min && height<=pinhack.triggerheight.max ) &&
            ( pinhack.triggerwidth.min<=width && width<=pinhack.triggerwidth.max ) ) {
                printf("triggered -> ");
                pinhack.trigger = true;
            printf("original geometry: %dx%d. expanding to geometry: %dx%d.\n",width,height,
            pinhack.expand.width ? pinhack.expand.width : width,
            pinhack.expand.height ? pinhack.expand.height : height);
        // If width or height not set, do not expand!
        if ( pinhack.expand.height ) height = pinhack.expand.height;
        if ( pinhack.expand.width ) width = pinhack.expand.width;
                if ( pinhack.specifichack.pinballdreams.trigger ) pinhack.specifichack.pinballdreams.trigger=false; // On next resolution change, return to normal
       } else {
                pinhack.trigger = false;
                printf("trigger values evalueted but not triggered! Current resolution: %dx%d\n",width,height);
       };
        aspect_ratio = pinhack.aspectratio;
    }

pinhacks.h

/*
 * Copyleft:
 * This file was made to be used with DOSBOX, and so
 * is under GNU general public license
 */

#ifndef __DOSBOX_PINHACK_H
#define __DOSBOX_PINHACK_H
#define PINHACKVERSION 3 

extern struct scrollhack {
    bool enabled,trigger;
    double aspectratio;
    struct { 
        int min, max;
    }triggerwidth,triggerheight;
    struct {int height, width;} expand;
    struct {struct { bool enabled,trigger;}
        psychopinball,
        pinballdreams;
    }specifichack;
    const char * doublewidth;
}pinhack ;

#endif /* __DOSBOX_PINHACK_H */

dosbox.cpp

static void PINHACK_Init(Section * sec) {
    Section_prop * section=static_cast<Section_prop *>(sec);
    /* PINHACK config file parsing */
    pinhack.enabled=(section->Get_bool("pinhack"));
    const char* pinhacktriggerwidthrange=section->Get_string("pinhacktriggerwidth");
    const char* pinhacktriggerheightrange=section->Get_string("pinhacktriggerheight");
        //romans aspect patch
    pinhack.aspectratio=(double)(section->Get_int("pinhackaspectratio")) /100.0;
    pinhack.doublewidth=section->Get_string("pinhackdoublewidth");
    pinhack.expand.height=(section->Get_int("pinhackexpandheight"));
    pinhack.expand.width=(section->Get_int("pinhackexpandwidth"));
    parsetriggerrange ( pinhacktriggerheightrange, pinhack.triggerheight.min, pinhack.triggerheight.max, '-' );
    parsetriggerrange ( pinhacktriggerwidthrange, pinhack.triggerwidth.min, pinhack.triggerwidth.max, '-' );
    if ( ( pinhack.triggerwidth.min == 0 ) && ( pinhack.triggerwidth.max == 0 ) ) pinhack.triggerwidth.max=9999;
    printf("PINHACK: Your DOSBox has been hacked with pinball hacks V %d ",PINHACKVERSION);
    if (pinhack.enabled) { 
        printf("and enabled in your config file!\n");
        printf("PINHACK: width settings: trigger at:");
        printf("%d-%d, expand to %d\n",pinhack.triggerwidth.min, pinhack.triggerwidth.max,pinhack.expand.width);
        printf("PINHACK: height settings: trigger at:");
        printf("%d-%d, expand to %d\n",pinhack.triggerheight.min, pinhack.triggerheight.max,pinhack.expand.height);
        printf("PINHACK: doublewidth: %s\n",pinhack.doublewidth);
        if (pinhack.aspectratio == 0 ){
            pinhack.aspectratio=100;
            printf("PINHACK: aspectratio not found, adusting to 1\n");
            };
        printf("PINHACK: aspectratio: %f\n",pinhack.aspectratio);
    }
    else printf("but disabled in your config file!\n");
    pinhack.specifichack.pinballdreams.enabled=(section->Get_bool("pinhackpd"));
}

void DOSBOX_Init(void) {
    Section_prop * secprop;
    Section_line * secline;
    Prop_int* Pint;
    Prop_hex* Phex;
    Prop_string* Pstring;
    Prop_bool* Pbool;
    Prop_multival* Pmulti;
    Prop_multival_remain* Pmulti_remain;

    SDLNetInited = false;

    // Some frequently used option sets
    const char *rates[] = {  "44100", "48000", "32000","22050", "16000", "11025", "8000", "49716", 0 };
    const char *oplrates[] = {   "44100", "49716", "48000", "32000","22050", "16000", "11025", "8000", 0 };
    const char *ios[] = { "220", "240", "260", "280", "2a0", "2c0", "2e0", "300", 0 };
    const char *irqssb[] = { "7", "5", "3", "9", "10", "11", "12", 0 };
    const char *dmassb[] = { "1", "5", "0", "3", "6", "7", 0 };
    const char *iosgus[] = { "240", "220", "260", "280", "2a0", "2c0", "2e0", "300", 0 };
    const char *irqsgus[] = { "5", "3", "7", "9", "10", "11", "12", 0 };
    const char *dmasgus[] = { "3", "0", "1", "5", "6", "7", 0 };

    /* Setup all the different modules making up DOSBox */
    const char* machines[] = {
        "hercules", "cga", "tandy", "pcjr", "ega",
        "vgaonly", "svga_s3", "svga_et3000", "svga_et4000",
        "svga_paradise", "vesa_nolfb", "vesa_oldvbe", 0 };

    // PINHACK: pinhack config file section

    secprop=control->AddSection_prop("pinhack",&PINHACK_Init, true);

    Pbool = secprop->Add_bool("pinhack",Property::Changeable::Always,false);
    Pbool->Set_help("Boolean: Enable pinball hacks to display whole table at once. Not enabled per default.");

    Pstring = secprop->Add_string("pinhacktriggerwidth",Property::Changeable::Always,"0");
    Pstring->Set_help("The X resolution (width) the pinball hack should trigger at. It is not checked by default or if set to 0. Can be a range.");

    Pstring = secprop->Add_string("pinhacktriggerheight",Property::Changeable::Always,"350");
    Pstring->Set_help("The Y resolution (height) the pinball hack should trigger at. Default is 350 (good for Pinball Fantasies). Can be a range.");

    Pint = secprop->Add_int("pinhackexpandwidth",Property::Changeable::Always,0);
    Pint->SetMinMax(0,4000);
    Pint->Set_help("The X resolution (width) DOSBox will expand to if pinball hack is enabled and triggers.\n"
            "Not very useful probably, but provided here in case someone finds a game where it is useful!");

    Pint = secprop->Add_int("pinhackexpandheight",Property::Changeable::Always,608);
    Pint->SetMinMax(1,4000);
    Pint->Set_help("The Y resolution (height) DOSBox will expand to if pinball hack is enabled and triggers.");

    Pbool = secprop->Add_bool("pinhackpd",Property::Changeable::Always,false);
    Pbool->Set_help("Boolean: Enable pinball dreams to work correctly during intros. Default:false\n");

    Pbool = secprop->Add_bool("pinhackpsycho",Property::Changeable::Always,false);
    Pbool->Set_help("Boolean: Psycho Pinball tilt craphics are messed up if hack enabled. TODO, this is a placeholder and has no function currently.");

    Pstring = secprop->Add_string("pinhackdoublewidth",Property::Changeable::Always,"normal");
    Pstring->Set_help("Used to enable forcing (or disabling) doublewidth with pinhack. The original patch disabled it,\n"
            "but you may find it better enabled, or left to decide by dosbox and use aspect ratio correction insread.\n"
            "normal=do not touch the setting, let DOSBox decide. yes=doublewidth. no=no doublewidth");

//romans patch
    Pint = secprop->Add_int("pinhackaspectratio",Property::Changeable::Always,100);
    Pint->Set_help("Used to force a custom aspect Ratio onto Dosbox, currently only works in Windowd Mode. Usefull to get Pinball Tables Full Size with 16:9 Screens. Pinball Fantasies value is 1.87");

// PINHACK: end config file section

I hope you like these modifications and put them into your "official" patch :) I have added a compiled windows 10 .exe if you want to do a quick test. (I will also put the precompiled exe into the topic at the vogons forum.)

dosboxAllPinballscd.zip dosbox_sourcecode_and_conf.zip

sirlee commented 4 years ago

Update:

small change that will only trigger the aspect patch when the height change is triggered:


    if ( ( !pinhack.specifichack.pinballdreams.enabled || pinhack.specifichack.pinballdreams.trigger ) && 
            ( height>=pinhack.triggerheight.min && height<=pinhack.triggerheight.max ) &&
            ( pinhack.triggerwidth.min<=width && width<=pinhack.triggerwidth.max ) ) {
                printf("triggered -> ");
                pinhack.trigger = true;
            printf("original geometry: %dx%d. expanding to geometry: %dx%d.\n",width,height,
            pinhack.expand.width ? pinhack.expand.width : width,
            pinhack.expand.height ? pinhack.expand.height : height);
        // If width or height not set, do not expand!
        if ( pinhack.expand.height ) height = pinhack.expand.height;
        if ( pinhack.expand.width ) width = pinhack.expand.width;
                if ( pinhack.specifichack.pinballdreams.trigger ) pinhack.specifichack.pinballdreams.trigger=false; // On next resolution change, return to normal
       aspect_ratio = pinhack.aspectratio;
       } else {
                pinhack.trigger = false;
                printf("trigger values evalueted but not triggered! Current resolution: %dx%d\n",width,height);
       };
        //aspect_ratio = ((float)width / (float)height) * ( 25.0 / 7);
        //aspect_ratio = pinhack.aspectratio;
DeXteRrBDN commented 4 years ago

Thanks sirlee!! :D We can try adding those changes in the repository. If you have any repo modifications, please feel free to create a PR or I'll try to create the changes and add them to master branch.

Thanks again 👏

sirlee commented 4 years ago

I have to say I am no full-blown programmer. I know some C++ from Arduino and have some experience with Visual Studio, but I am a bit lost when it comes to GITHub and its terminology. I do not even know what you mean with PR. 

Therefore, may I ask you to try to put it into the master branch?

Thanks you very much for putting time/effort into this solution!

Torinde commented 1 year ago

@Kappa971, you may be interested in this?

Kappa971 commented 1 year ago

@Kappa971, you may be interested in this?

I'm interested in anything that might make those games display properly, but I'm not a developer. You need to ask the DOSBox Staging developers if they are interested in this patch.