i was writing some code for a small project i'm working on and form somke reason, it never displays the main function. it just makes the user input 7 times before crashing. any ideas? i can't seem to locate my error.
package rtnasm;
/*
* RTNASM - n64 assembler
*
* problems - for some reason it's asking for input on start instead of using the main method.
* idk how to fix it.
*/
import java.util.Scanner;
import java.util.Stack;
import java.io.DataInputStream;
public class rtnasm {
public static constants c = new constants();
public static void main(String [] args)
{
System.out.println("Real Time Nintendo 64 Assmebler by Alexander Frankland");
System.out.println("Version 0.44 Rev B");
System.out.println("\nChangelog");
System.out.println("------------");
System.out.println("Added new function to allow users to overwrite single existing lines");
System.out.println("to view a full list of functions type help");
Menu();
}
public static void Menu()
{
System.out.println("\nRTNASM::");
System.out.print(c.options.toLowerCase());
if(c.options.indexOf("help") > 0)
HelpMsg();
else if(c.options.indexOf("newfile") > 0)
SetFileName();
else if(c.options.indexOf("viewcode") > 0)
ReturnStack();
else if(c.options.indexOf("exit") > 0)
EndProgram();
else if(c.options.indexOf("editline") > 0)
EditLine();
else
System.out.println("Not a valid function!");
}
public static void SetFileName()
{
System.out.println("Enter the file name below (you'll hvae to program this name into the header of the rom!)");
System.out.println("File name: ");
System.out.print(c.FileName);
SetMemoryBuffer();
}
public static void SetMemoryBuffer()
{
System.out.println("Enter the value for the size of the rom(0 for 4mb. Hint: Size < 81920000!)");
System.out.println("Rom Size: ");
System.out.print(c.MaxOpcodesGet);
if(c.MaxOpcodesGet == 0 || c.MaxOpcodesGet > 81920000)
c.MaxOpcodesGet = 40960000;
OpcodeEntry();
}
public static void OpcodeEntry()
{
System.out.println("File: " + c.FileName);
System.out.println("Approx. Size: " + c.ApproxSize + "MB(" + c.MaxOpcodes + ")");
System.out.println("You may now begin to enter you code below! type endl to exit!");
System.out.println("\n");
for (c.i = 0; c.i < c.MaxOpcodes;)
{
System.out.println(Integer.toHexString(c.i).toUpperCase() + ": ");
System.out.print(c.OpcodeGet.toUpperCase());
if(c.OpcodeGet.indexOf("ENDL") > 0)
Menu();
else
{
c.Opcode[c.i] = c.OpcodeGet;
c.OpcodeStack.add(c.i, c.Opcode[c.i]);
c.i+=1;
continue;
}
}
}
public static void ReturnStack()
{
System.out.println("Printing all of your inputed code to the screen!");
for(c.x = 0; c.x < c.OpcodeStack.size();)
{
c.Output = c.OpcodeStack.get(c.x);
System.out.println(Integer.toHexString(c.x).toUpperCase() + ": " + c.Output);
c.x+=1;
}
}
public static void HelpMsg()
{
System.out.println("\nList of functions");
System.out.println("-------------------");
System.out.println("newfile - creates a new romfile");
System.out.println("viewcode - displays all entered code");
System.out.println("editline - edits a specific line you entered");
System.out.println("writeall - writes code to .z64 file of specified name (COMMING SOON!)");
System.out.println("options - sets options (COMMING SOON)");
System.out.println("exit - ends the program");
System.out.println("help - displays this help screen");
}
public static void EditLine()
{
System.out.println("Enter the line you want to edit: ");
System.out.print(c.LineNumGet);
System.out.println("Enter the new code for the specified line: ");
System.out.print(c.OpcodeGet);
c.Opcode[c.LineNum] = c.OpcodeGet;
c.OpcodeStack.remove(c.LineNum);
c.OpcodeStack.add(c.LineNum, c.Opcode[c.LineNum]);
}
public static void EndProgram()
{
System.exit(0);
}
}
class constants
{
public DataInputStream di;
public Stack<String> OpcodeStack = new Stack<String>();
public int x,i,t;
public int MaxOpcodesGet = new Scanner(System.in).nextInt();
public int MaxOpcodes = MaxOpcodesGet;
public String[] Opcode = new String[MaxOpcodes];
public String FileNameGet = new Scanner(System.in).nextLine();
public String FileName = FileNameGet + ".z64";
public float ApproxSize = MaxOpcodes / 10240000;
public String OpcodeGet = new Scanner(System.in).nextLine();
public String Output;
public String options = new Scanner(System.in).nextLine();
public int LineNumGet = new Scanner(System.in).nextInt();
public int LineNum = LineNumGet;
}