Announcement

Collapse
No announcement yet.

Two sstates differences to cheat codes, a source code for Android devices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Two sstates differences to cheat codes, a source code for Android devices

    Hi guys! I want to share a source code (Java) of epsxe2SSTC for ePSXe2.0.8 emulator for Android devices.

    Depending on ePSXe2.0.8 files paths, epsxe2SSTC creates a [VGSerial].epsxe2sstc.txt file containing generated GameShark codes (in the emu's format) based from RAM values in the emu's second sstate file (.002) different from its first sstate file (.001).

    Someone/somebody here may edit/modify the SC and use it for other emulators (for Android devices) which also have RAM data in all of each savestate files.

    Here's the SC:


    <?xml version="1.0"encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.guevarrajdp.epsxe2sstc">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_ST ORAGE"/>
    <application
    android:allowBackup="true"
    android:resizeableActivity="true"
    android:label="epsxe2SSTC">
    <activity android:name="MainActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
    </activity>
    </application>
    </manifest>


    package com.guevarrajdp.epsxe2sstc;//For ePSXe2.0.8(and other versions with similar sstates format and directories) for Android devices
    //This app generates a SLUS...epsxe2sstc.txt (containing GameShark codes) to .../epsxe/cheats/ from bytes difference of .000 & .001 in epsxe/sstates/ limited by user inputs
    import android.app.*;
    import android.os.*;
    import android.widget.*;
    import java.io.*;
    import java.util.zip.*;
    //I just want to make this app less active on resources
    final public class MainActivity extends Activity{
    final protected void onCreate(Bundle B){super.onCreate(B);
    setTitle(null);requestWindowFeature(1);
    EditText e=new EditText(this){//I just want to use only 1 EditText for all inputs
    final public boolean performClick(){
    int l=length();if(l>0&&l==getSelectionStart())try{//Starts the following process if clicked/tapped after the '>'
    String s=getText().toString().substring(0,l-=3);//Inputs: Video Game's Serial code, i=nclusivStart[min=0] & j=xclusivEnd[max=200000] RAM even hex addresses, k=limiting val[empty=all or 0-FFFF]). 4inputs separated by \n=10
    int i=s.indexOf(10)+1,j=s.indexOf(10,i)+1,k=s.indexOf( 10,j);setId(i);//v** setId(i); just for s only
    i=Integer.parseInt(s.substring(i,j-1),16);//All hex inputs to ints(i,j,k)!
    if(i>-1&&i%2<1&&i<(j=Integer.parseInt(s.substring(j,k) ,1 6))&&j<2097153&&j%2<1&&(k=++k<l?Integer.parseInt(s .substring(k),16):-1)<65536){//if empty, k=-1 is for any data diff. per same index/RAM address
    FileInputStream f=null;GZIPInputStream g=null;FileWriter w=null;BufferedWriter x=null;
    try{//Assuming ePSXe2.0.8 main folder is installed as "epsxe" in the default storage
    String p=Environment.getExternalStorageDirectory().getAbs olutePath()+"/epsxe/";s=s.substring(0,getId()-1);setId(i);//^** s shorten to VG's Serial only. User input in i'll be get back after the ff. looped reads
    f=new FileInputStream(p+"sstates/"+s+".000");g=new GZIPInputStream(f);//1st file. ePSXe2.0.8 sstates were gzipped!
    byte[]a=new byte[j-=i];i+=442;do{for(l=i<j?i:j;l>0;l-=g.read(a,0,l));}while((i-=j)>0);//ePSXe2.0.8 sstates' RAM data start at 1ba=442,+inputted start offset. Nested loops in case i+442>(j=arrays'length)
    for(;l<j;l+=g.read(a,l,j-l));g.close();f.close();//Read & copy RAM data to a
    f=new FileInputStream(p+"sstates/"+s+".001");g=new GZIPInputStream(f);//2nd file
    byte[]b=new byte[j];i=getId()+442;do{for(l=i<j?i:j;l>0;l-=g.read(b,0,l));}while((i-=j)>0);
    for(;l<j;l+=g.read(b,l,j-l));g.close();f.close();//Read & copy RAM data to b
    i=getId()+1;j++;l=1;//I want to use i and l also to sign(via +/-) for data diffs. i+1 in case it's 0, j for index &'ll be descending, l for "#(NumOfSet)" label per 16 lines of GameShark codes in the text file
    w=new FileWriter(p+"cheats/"+s+".epsxe2sstc.txt");x=new BufferedWriter(w);//Generated file'll be [VG's Serial].epsxe2sstc.txt
    while((j-=2)>0){i=a[j-1]!=b[j-1]?i:-i;l=a[j]!=b[j]?l:-l;if(i>0||l>0){//Write only the values of b (accord.to limiting val) diff.to a at the same index(+inputted start offset=RAM address)
    if(k>-1&&k<256){i=i>0&&k!=b[j-1]?-i:i;l=l>0&&k!=b[j]?-l:l;}//reused, parallel
    if(k<0||k<256&&(i>0||l>0)||k>255&&i>0&&l>0&&k==((2 55&b[j])<<8|255&b[j-1])){//Write'll be in hi-low/descending order of RAM addresses. Sorry I don't want to reuse & expand s in mem so much.
    x.write((l==1||l==-1?"#"+j+'\n':"")+(i>0&&l>0?'8':'3')+'0'+String.f or mat("%06X",j+(i>0?i:-i)-(i>0?2:1))+' '
    +String.format("%04X",k<256?i>0&&l>0?(255&b[j])<<8|255&b[j-1]:255&b[j-(i>0?1:0)]:k)+'\n');l+=l>0?l<16?1:-15:l>-16?-1:15;}
    }i=i<0?-i:i;l=l<0?-l:l;}t(p+"cheats/"+s+".epsxe2sstc.txt"+" done!");k=-2;//i & l must be back to (+) before start of another loop!
    }catch(Exception e){t("Error:: "+e.getMessage());r(this);}finally{for(i=4;i>0 ;i--)try{if((i>3?x:i>2?w:i>1?g:f)!=null)(i>3?x:i>2?w:i >1?g:f).close();}catch(Exception e){}}
    if(k<-1)finish();//Quits/Exits when done and after the 'Streams & 'Writers are closed!
    }else t("Hex input mismatch");
    }catch(Exception e){t("Error: "+e.getMessage());r(this);}
    return false;}
    };e.setGravity(16);r(e);setContentView(e);getWindo w().setSoftInputMode(5);
    }
    final static private void r(EditText e){e.setText("SLUS_\n0\n200000\n\n\n>");e.setSelec tion(5);}//reset/refresh method
    final private void t(CharSequence c){Toast.makeText(this,c,10000).show();}
    }


    With the SC you can build & create/run the app using AIDE app in this link: https://play.google.com/store/apps/d....aide.ui&hl=en

    I use epsxe2SSTC to find & learn such RAM addresses in Valkyrie Profile (SLUS_011.56, NTSC-U) for PlayStation1, all in this link: https://gamehacking.org/vb/forum/vid...-request/page3
    Last edited by dme3adam; 06-22-2020, 06:45:42 AM.

  • #2
    Implement government directives. Everyone joins hands to fight the epidemic, limit moving out and stay indoors to keep the cleanest living environment. mapquest driving directions

    Comment

    Working...
    X