Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- /* This program is free software. It comes without any warranty, to
- * the extent permitted by applicable law. You can redistribute it
- * and/or modify it under the terms of the Do What The Fuck You Want
- * To Public License, Version 2, as published by Sam Hocevar. See
- * http://sam.zoy.org/wtfpl/COPYING for more details. */
- public class SlotChanger {
- /**
- * @param args
- */
- public static void main(String[] args) {
- System.out.println("### PROJECT DIVA CUSTOM DLC SLOT CHANGER v0.15");
- System.out.println("Written by Suyo (ProjectDIVA.net)");
- System.out.println("----------------------------------------");
- FileInputStream fis;
- String ifilen = "in.EDAT";
- if (args[0] != null) ifilen = args[0];
- String ofilen = "out.EDAT";
- File ifile = new File(ifilen);
- File ofile = new File(ofilen);
- if (!ifile.exists() || !ifile.isFile()) {
- System.out.println(ifilen+": does not exist!");
- return;
- }
- if (ofile.exists()) {
- System.out.println(ofilen+": exists already! Please rename it before running this!");
- return;
- }
- int[] fileArray;
- try {
- System.out.println("Opening "+ifilen+"...");
- fis = new FileInputStream(ifile);
- fileArray = new int[(int) ifile.length()];
- int i=0;
- int offs=0;
- System.out.println("Reading file... this could take a while.");
- while(i != -1) { /* -1 is a constant for 'EOF' : end of file. */
- i=fis.read();
- if (i!=-1) fileArray[offs] = i;
- offs++;
- }
- fis.close();
- } catch (Exception e) {
- System.out.println(ifilen+": Unknown error while opening!");
- return;
- }
- System.out.println("\nDLC Type: "+((char) fileArray[0x1800]));
- System.out.println("Current Slot: "+((char) fileArray[0x1803])+((char) fileArray[0x1804])+((char) fileArray[0x1805]));
- System.out.print("Enter new Slot (0-999): ");
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String newslot = null;
- try {
- newslot = br.readLine();
- } catch (IOException ioe) {
- System.out.println("IO error trying to read new slot!");
- return;
- }
- try {
- int i = Integer.parseInt(newslot);
- if (i>999) {
- System.out.println("The number is too big!");
- return;
- } else if (i<0) {
- System.out.println("The number is too small!");
- return;
- }
- } catch(NumberFormatException nfe) {
- System.out.println("This isn't a number!");
- return;
- }
- while (newslot.length()<3) newslot = "0" + newslot;
- fileArray[0x1803] = newslot.charAt(0);
- fileArray[0x1804] = newslot.charAt(1);
- fileArray[0x1805] = newslot.charAt(2);
- try {
- System.out.println("\nOpening "+ofilen+"...");
- FileOutputStream fos = new FileOutputStream(ofile);
- DataOutputStream dos = new DataOutputStream(fos);
- System.out.println("Writing file... this could take a while.");
- for (int i: fileArray) {
- dos.writeByte(i);
- }
- dos.close();
- } catch (Exception e) {
- System.out.println(ofilen+": Unknown Error while writing!");
- }
- System.out.println("\nSuccess! We're done here.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement