3 Replies - 516 Views - Last Post: 23 February 2018 - 11:06 PM Rate Topic: -----

#1 Programmer2004   User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 47
  • Joined: 25-October 17

My most messy code, I guess

Posted 22 February 2018 - 02:35 PM

Hello. I would like to share with you my most messy code, I guess. It's from my unfinished and unreleased project which emulated the BBC BASIC language, which could run very simple programs written in BASIC for BBC Micro computers (it was also capable of booting the instruction screen of 3D Bomb Alley game). I wrote it in Java over half year ago. You had to extract files from BBC Micro disk image and load a file called $BOOT to the emulator. However, the BASIC interpreter was very unoptimized and messy. When I was developing it I used to think it was done very well and simply, but when I look at it now, it just makes me laugh so much.

Here's the code of interpreter:
package hardware;
import java.io.RandomAccessFile;
import java.io.FileNotFoundException;
import java.io.IOException;
import static hardware.Video.outputText;
import static hardware.Video.setMode;
import java.io.File;
import static java.lang.Math.pow;
import static hardware.Audio.setS;
import static hardware.Audio.setPi1;
import static hardware.Audio.setPi2;
import static hardware.Audio.setPi3;
import static hardware.Audio.setPn1;
import static hardware.Audio.setPn2;
import static hardware.Audio.setPn3;
import static hardware.Audio.setAA;
import static hardware.Audio.setAD;
import static hardware.Audio.setAS;
import static hardware.Audio.setAR;
import static hardware.Audio.setALA;
import static hardware.Audio.setALD;
import static hardware.Video.setCharacterLines;
import java.util.ArrayList;
import static hardware.Video.enableScale;
import static hardware.Video.setColor;
import static hardware.Keyboard.keyPressed;
import static hardware.Keyboard.clear;
import static hardware.Video.getMode;
import static hardware.Video.setDisplayedColor;
import static hardware.Video.setTextAreaLeft;
import static hardware.Video.setTextAreaBottom;
import static hardware.Video.setTextAreaRight;
import static hardware.Video.setTextAreaTop;
import static hardware.Video.getCursorY;
import static hardware.Video.setCursorX;
import static hardware.Video.setCursorY;
import static hardware.Video.setBackgroundColor;
import static hardware.Video.getResolutionX;
import static hardware.Video.getResolutionY;
import static hardware.Video.getBackgroundColor;
import static hardware.Video.setPixel;
import static hardware.Video.getTextAreaLeft;
import static hardware.Video.getTextAreaRight;
import static hardware.Video.getTextAreaTop;
import static hardware.Video.getTextAreaBottom;
import static hardware.MOSTechnology6502.interpret;
public class BASIC{
	private static String programFileParentPath="";
	private static byte program[]=new byte[0];
	private static int pp=0;
	private static boolean separator=false;
	private static ArrayList<String>variableNames=new ArrayList<String>();
	private static ArrayList<Integer>variableValues=new ArrayList<Integer>();
	private static ArrayList<Integer>loopAddresses=new ArrayList<Integer>();
	private static ArrayList<String>loopVariables=new ArrayList<String>();
	private static ArrayList<Integer>loopToVariables=new ArrayList<Integer>();
	private static ArrayList<Integer>loopSteps=new ArrayList<Integer>();
	private static String temporaryProgramFileParentPath="";
	private static byte temporaryProgram[]=new byte[0];
	private static boolean assembly=false;
	public static void reset(){
		programFileParentPath="";
		program=new byte[0];
		pp=0;
		separator=false;
		variableNames=new ArrayList<String>();
		variableValues=new ArrayList<Integer>();
		loopAddresses=new ArrayList<Integer>();
		loopVariables=new ArrayList<String>();
		loopToVariables=new ArrayList<Integer>();
		loopSteps=new ArrayList<Integer>();
		assembly=false;
		return;
	}
	public static void start(String path){
		programFileParentPath=new File(path).getParent();
		RandomAccessFile file=null;
		try{
			file=new RandomAccessFile(path,"r");
		}
		catch(FileNotFoundException exception){
		}
		try{
			program=new byte[(int)file.length()];
		}
		catch(IOException exception){
		}
		try{
			file.read(program);
		}
		catch(IOException exception){
		}
		try{
			file.close();
		}
		catch(IOException exception){
		}
		return;
	}
	public static void load(String path){
		temporaryProgramFileParentPath=new File(path).getParent();
		RandomAccessFile file=null;
		try{
			file=new RandomAccessFile(path,"r");
		}
		catch(FileNotFoundException exception){
		}
		try{
			temporaryProgram=new byte[(int)file.length()];
		}
		catch(IOException exception){
		}
		try{
			file.read(temporaryProgram);
		}
		catch(IOException exception){
		}
		try{
			file.close();
		}
		catch(IOException exception){
		}
		return;
	}
	public static void tick(){
		if(!assembly){
			while(pp<program.length&&program[pp]==' '){
				pp++;
				continue;
			}
			if(pp<program.length&&program[pp]=='*'){
				pp++;
				while(pp<program.length&&program[pp]==' '){
					pp++;
					continue;
				}
				if(pp+1<program.length&&program[pp]=='B'&&program[pp+1]=='.'){
					pp+=2;
					while(pp<program.length&&program[pp]==' '){
						pp++;
						continue;
					}
					if(pp<program.length&&program[pp]==0xd){
						pp++;
						outputText("BASIC\n\n");
					}
				}
			}
			else{
				if(pp+2<program.length&&program[pp]=='C'&&program[pp+1]=='H'&&program[pp+2]=='.'){
					pp+=3;
					while(pp<program.length&&program[pp]==' '){
						pp++;
						continue;
					}
					if(pp<program.length&&program[pp]=='"'){
						pp++;
						if(programFileParentPath.charAt(programFileParentPath.length()-1)!='\\')
							programFileParentPath+="\\";
						String text=programFileParentPath+"$.";
						while(pp<program.length&&program[pp]!='"'){
							text+=(char)program[pp];
							pp++;
							continue;
						}
						if(pp<program.length&&program[pp]=='"')
							pp++;
						while(pp<program.length&&program[pp]==' '){
							pp++;
							continue;
						}
						if(pp<program.length&&program[pp]==0xd){
							pp++;
							File file=new File(text);
							if(!file.exists())
								outputText("\nNot found\n");
							else{
								reset();
								start(text);
							}
						}
					}
				}
				else{
					boolean line=pp+2<program.length&&program[pp]==0xd;
					if(line||separator){
						if(line){
							separator=false;
							pp+=3;
						}
						boolean mode0=pp+3<program.length&&program[pp]==8&&program[pp+1]==0x20&&(program[pp+2]&0xff)==0xeb&&program[pp+3]==0x20;
						boolean mode1=pp+1<program.length&&(program[pp]==0x3a||program[pp]==0x1d)&&(program[pp+1]&0xff)==0xeb;
						if(mode0||mode1){
							if(mode0)
								pp+=4;
							if(mode1)
								pp+=2;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int mode=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									mode+=numbers[number-1];
								else{
									mode+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								mode=-mode;
							mode%=8;
							setMode((byte)mode);
						}
						if(pp+3<program.length&&program[pp]==0xd&&program[pp+1]==0x20&&(program[pp+2]&0xff)==0xd7&&program[pp+3]==0x20){
							pp+=4;
							if(pp<program.length&&program[pp]=='"'){
								pp++;
								if(programFileParentPath.charAt(programFileParentPath.length()-1)!='\\')
									programFileParentPath+="\\";
								String text=programFileParentPath+"$.";
								while(pp<program.length&&program[pp]!='"'){
									text+=(char)program[pp];
									pp++;
									continue;
								}
								if(pp<program.length&&program[pp]=='"')
									pp++;
								pp++;
								File file=new File(text);
								if(!file.exists())
									outputText("\nNot found\n");
								else{
									reset();
									start(text);
								}
							}
						}
						if(pp+1<program.length&&(program[pp]==0x29||program[pp]==0x2d||program[pp]==0x27)&&(program[pp+1]&0xff)==0xe2){
							pp+=2;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int n=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount-=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									n+=numbers[number-1];
								else{
									n+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								n=-n;
							n%=16;
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int s=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									s+=numbers[number-1];
								else{
									s+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								s=-s;
							setS((byte)n,s);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int pi1=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									pi1+=numbers[number-1];
								else{
									pi1+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								pi1=-pi1;
							if(pi1<0)
								pi1%=129;
							else
								pi1%=128;
							setPi1((byte)n,(byte)pi1);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int pi2=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									pi2+=numbers[number-1];
								else{
									pi2+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								pi2=-pi2;
							if(pi2<0)
								pi2%=129;
							else
								pi2%=128;
							setPi2((byte)n,(byte)pi2);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int pi3=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									pi3+=numbers[number-1];
								else{
									pi3+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								pi3=-pi3;
							if(pi3<0)
								pi3%=129;
							else
								pi3%=128;
							setPi3((byte)n,(byte)pi3);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int pn1=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									pn1+=numbers[number-1];
								else{
									pn1+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								pn1=-pn1;
							pn1%=256;
							setPn1((byte)n,(byte)pn1);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int pn2=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									pn2+=numbers[number-1];
								else{
									pn2+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								pn2=-pn2;
							pn2%=256;
							setPn2((byte)n,(byte)pn2);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int pn3=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									pn3+=numbers[number-1];
								else{
									pn3+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								pn3=-pn3;
							pn3%=256;
							setPn3((byte)n,(byte)pn3);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int aa=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									aa+=numbers[number-1];
								else{
									aa+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								aa=-aa;
							setAA((byte)n,aa);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int ad=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									ad+=numbers[number-1];
								else{
									ad+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								ad=-ad;
							setAD((byte)n,ad);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int as=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									as+=numbers[number-1];
								else{
									as+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								as=-as;
							setAS((byte)n,as);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int ar=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									ar+=numbers[number-1];
								else{
									ar+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								ar=-ar;
							setAR((byte)n,ar);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int ala=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									ala+=numbers[number-1];
								else{
									ala+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								ala=-ala;
							setALA((byte)n,ala);
							if(pp<program.length&&program[pp]==',')
								pp++;
							numberCount=0;
							numbers=new byte[10];
							minus=false;
							int ald=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									ald+=numbers[number-1];
								else{
									ald+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								ald=-ald;
							setALD((byte)n,ald);
						}
						boolean vdu0=pp<program.length&&(program[pp]&0xff)==0xef;
						boolean vdu1=pp+1<program.length&&program[pp]==0x1d&&(program[pp+1]&0xff)==0xef;
						if(vdu0||vdu1){
							if(vdu0)
								pp++;
							if(vdu1)
								pp+=2;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int code=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									code+=numbers[number-1];
								else{
									code+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								code=-code;
							if(pp<program.length&&program[pp]==',')
								pp++;
							if(code==23){
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int character=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										character+=numbers[number-1];
									else{
										character+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									character=-character;
								if(pp<program.length&&program[pp]==',')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int line0=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										line0+=numbers[number-1];
									else{
										line0+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									line0=-line0;
								if(pp<program.length&&program[pp]==';')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int line2=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										line2+=numbers[number-1];
									else{
										line2+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									line2=-line2;
								if(pp<program.length&&program[pp]==';')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int line4=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										line4+=numbers[number-1];
									else{
										line4+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									line4=-line4;
								if(pp<program.length&&program[pp]==';')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int line6=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										line6+=numbers[number-1];
									else{
										line6+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									line6=-line6;
								setCharacterLines((byte)character,new byte[]{(byte)line0,0,(byte)line2,0,(byte)line4,0,(byte)line6,0});
								if(pp<program.length&&program[pp]==';')
									pp++;
							}
							if(code==19&&getMode()==2){
								String name="";
								int character=0;
								while(pp<program.length&&(program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'||(character>0&&((program[pp]>='0'&&program[pp]<='9')||program[pp]=='%'))){
									name+=(char)program[pp];
									pp++;
									character++;
									continue;
								}
								boolean variableFound=false;
								int variableID=0;
								for(int id=0;id<variableNames.size();id++){
									if(variableNames.get(id).equals(name)){
										variableFound=true;
										variableID=id;
										break;
									}
									continue;
								}
								if(pp<program.length&&program[pp]==',')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int color=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										color+=numbers[number-1];
									else{
										color+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									color=-color;
								color%=16;
								if(pp<program.length&&program[pp]==';')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int value=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										value+=numbers[number-1];
									else{
										value+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									value=-value;
								if(pp<program.length&&program[pp]==';')
									pp++;
								if(!variableFound)
									outputText("\nNo such variable\n");
								else
									setDisplayedColor((byte)(variableValues.get(variableID)%16),(byte)color);
							}
							if(code==28){
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int xLeft=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										xLeft+=numbers[number-1];
									else{
										xLeft+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									xLeft=-xLeft;
								setTextAreaLeft((byte)xLeft);
								setCursorX((byte)xLeft);
								if(pp<program.length&&program[pp]==',')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int yBottom=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										yBottom+=numbers[number-1];
									else{
										yBottom+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									yBottom=-yBottom;
								setTextAreaBottom((byte)yBottom);
								if(pp<program.length&&program[pp]==',')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int xRight=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										xRight+=numbers[number-1];
									else{
										xRight+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									xRight=-xRight;
								setTextAreaRight((byte)xRight);
								if(pp<program.length&&program[pp]==',')
									pp++;
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int yTop=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										yTop+=numbers[number-1];
									else{
										yTop+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									yTop=-yTop;
								setTextAreaTop((byte)yTop);
								setCursorY((byte)yTop);
							}
							if(code==26){
								setTextAreaLeft((byte)0);
								setTextAreaRight((byte)(getResolutionX()/8-1));
								setTextAreaTop((byte)0);
								setTextAreaBottom((byte)(getResolutionY()/8-1));
								setCursorX((byte)0);
								setCursorY((byte)0);
							}
						}
						boolean for0=pp<program.length&&(program[pp]&0xff)==0xe3;
						boolean for1=pp+1<program.length&&program[pp]==0x1a&&(program[pp+1]&0xff)==0xe3;
						if(for0||for1){
							if(for0)
								pp++;
							if(for1)
								pp+=2;
							String name="";
							int character=0;
							while(pp<program.length&&(program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'||(character>0&&((program[pp]>='0'&&program[pp]<='9')||program[pp]=='%'))){
								name+=(char)program[pp];
								pp++;
								character++;
								continue;
							}
							if(pp<program.length&&program[pp]=='=')
								pp++;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int value0=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									value0+=numbers[number-1];
								else{
									value0+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								value0=-value0;
							boolean variableFound=false;
							int variableID=0;
							for(int id=0;id<variableNames.size();id++){
								if(variableNames.get(id).equals(name)){
									variableFound=true;
									variableID=id;
									break;
								}
								continue;
							}
							if(!variableFound){
								variableNames.add(name);
								variableValues.add(value0);
							}
							else
								variableValues.set(variableID,value0);
							loopVariables.add(name);
							while(pp<program.length&&program[pp]==' '){
								pp++;
								continue;
							}
							if(pp<program.length&&(program[pp]&0xff)==0xb8){
								pp++;
								while(pp<program.length&&program[pp]==' '){
									pp++;
									continue;
								}
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int value1=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										value1+=numbers[number-1];
									else{
										value1+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									value1=-value1;
								loopToVariables.add(value1);
								loopAddresses.add(pp);
							}
							while(pp<program.length&&program[pp]==' '){
								pp++;
								continue;
							}
							if(pp<program.length&&(program[pp]&0xff)==0x88){
								pp++;
								while(pp<program.length&&program[pp]==' '){
									pp++;
									continue;
								}
								numberCount=0;
								numbers=new byte[10];
								minus=false;
								int step=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										step+=numbers[number-1];
									else{
										step+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									step=-step;
								loopSteps.add(step);
							}
						}
						boolean print0=pp<program.length&&(program[pp]&0xff)==0xf1;
						boolean print1=pp+1<program.length&&(program[pp]==0x34||program[pp]==0x32||program[pp]==0x30||program[pp]==0x1b||program[pp]==0x25||program[pp]==0x27||program[pp]==0x28||program[pp]==0x21||program[pp]==0x26||program[pp]==0x41||program[pp]==0x2e)&&(program[pp+1]&0xff)==0xf1;
						if(print0||print1){
							if(print0)
								pp++;
							if(print1)
								pp+=2;
							while(pp<program.length&&program[pp]!=0xd&&program[pp]!=':'){
								if(program[pp]==0x27){
									pp++;
									outputText("\n");
								}
								else{
									if((program[pp]&0xff)==0x8a){
										pp++;
										boolean firstValue=true;
										boolean add=false;
										int tabs=0;
										while(pp<program.length&&program[pp]!=')'){
											if(pp<program.length&&(program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'){
												String name=""+(char)program[pp];
												pp++;
												while(pp<program.length&&((program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'||(program[pp]>='0'&&program[pp]<='9')||program[pp]=='%')){
													name+=(char)program[pp];
													pp++;
													continue;
												}
												boolean variableFound=false;
												int variableID=0;
												for(int id=0;id<variableNames.size();id++){
													if(variableNames.get(id).equals(name)){
														variableFound=true;
														variableID=id;
														break;
													}
													continue;
												}
												if(!variableFound)
													outputText("\nNo such variable\n");
												else{
													if(firstValue){
														tabs=variableValues.get(variableID);
														firstValue=false;
													}
													if(add){
														tabs+=variableValues.get(variableID);
														add=false;
													}
												}
											}
											if(pp<program.length&&program[pp]=='+'){
												pp++;
												add=true;
											}
											if(pp<program.length&&(program[pp]=='-'||(program[pp]>='0'&&program[pp]<='9'))){
												byte numberCount=0;
												byte numbers[]=new byte[10];
												boolean minus=false;
												int value=0;
												for(numberCount=1;numberCount<=10;numberCount++){
													if(numberCount==1&&pp<program.length&&program[pp]=='-'){
														minus=true;
														pp++;
													}
													else{
														if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
															numbers[numberCount-1]=(byte)(program[pp]-0x30);
															pp++;
														}
														else{
															numberCount--;
															break;
														}
													}
													continue;
												}
												if(numberCount>10)
													numberCount=10;
												byte power=1;
												for(byte number=numberCount;number>0;number--){
													if(number==numberCount)
														value+=numbers[number-1];
													else{
														value+=numbers[number-1]*pow(10,power);
														power++;
													}
													continue;
												}
												if(minus)
													value=-value;
												if(firstValue){
													tabs=value;
													firstValue=false;
												}
												if(add){
													tabs+=value;
													add=false;
												}
											}
											for(int tab=0;tab<tabs;tab++){
												outputText(" ");
												continue;
											}
										}
										if(pp<program.length&&program[pp]==')')
											pp++;
									}
									else{
										if(pp<program.length&&(program[pp]&0xff)==0xbd){
											pp++;
											if(pp<program.length&&program[pp]=='(')
												pp++;
											byte numberCount=0;
											byte numbers[]=new byte[10];
											boolean minus=false;
											int character=0;
											for(numberCount=1;numberCount<=10;numberCount++){
												if(numberCount==1&&pp<program.length&&program[pp]=='-'){
													minus=true;
													pp++;
												}
												else{
													if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
														numbers[numberCount-1]=(byte)(program[pp]-0x30);
														pp++;
													}
													else{
														numberCount--;
														break;
													}
												}
												continue;
											}
											if(numberCount>10)
												numberCount=10;
											byte power=1;
											for(byte number=numberCount;number>0;number--){
												if(number==numberCount)
													character+=numbers[number-1];
												else{
													character+=numbers[number-1]*pow(10,power);
													power++;
												}
												continue;
											}
											if(minus)
												character=-character;
											boolean character141=character==141;
											boolean character133=character==133;
											boolean character135=character==135;
											byte y=getCursorY();
											if(character141){
												enableScale(y);
												enableScale((byte)(y+1));
											}
											if(character133)
												setColor(y,(byte)5);
											if(character135)
												setColor(y,(byte)7);
											if(character133||character135)
												outputText(" ");
											if(pp<program.length&&program[pp]==')')
												pp++;
										}
										else{
											if(pp<program.length&&program[pp]=='"'){
												pp++;
												String text="";
												while(pp<program.length&&program[pp]!='"'){
													text+=(char)program[pp];
													pp++;
													continue;
												}
												outputText(text);
												if(pp<program.length&&program[pp]=='"')
													pp++;
												continue;
											}
											else
												pp++;
										}
									}
									continue;
								}
							}
							if(pp-1<program.length&&program[pp-1]!=';')
								outputText("\n");
						}
						if(pp<program.length&&(program[pp]&0xff)==0xed){
							pp++;
							if(loopAddresses.size()==0)
								outputText("\nNo FOR\n");
							else{
								String variable=loopVariables.get(loopVariables.size()-1);
								int variableID=0;
								for(int id=0;id<variableNames.size();id++){
									if(variableNames.get(id).equals(variable)){
										variableID=id;
										break;
									}
									continue;
								}
								if(variableValues.get(variableID)<loopToVariables.get(loopToVariables.size()-1)){
									pp=loopAddresses.get(loopAddresses.size()-1);
									variableValues.set(variableID,variableValues.get(variableID)+(loopSteps.isEmpty()?1:loopSteps.get(loopSteps.size()-1)));
								}
								else{
									loopAddresses.remove(loopAddresses.size()-1);
									loopVariables.remove(loopVariables.size()-1);
									loopToVariables.remove(loopToVariables.size()-1);
									if(loopSteps.size()!=0)
										loopSteps.remove(loopSteps.size()-1);
								}
							}
						}
						if(pp<program.length&&program[pp]==0x1a){
							pp++;
							if(pp<program.length&&(program[pp]&0xff)==0xe3){
								pp++;
								String name="";
								int character=0;
								while(pp<program.length&&(program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'||(character>0&&((program[pp]>='0'&&program[pp]<='9')||program[pp]=='%'))){
									name+=(char)program[pp];
									pp++;
									character++;
									continue;
								}
								if(pp<program.length&&program[pp]=='=')
									pp++;
								byte numberCount=0;
								byte numbers[]=new byte[10];
								boolean minus=false;
								int value0=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								byte power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										value0+=numbers[number-1];
									else{
										value0+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									value0=-value0;
								boolean variableFound=false;
								int variableID=0;
								for(int id=0;id<variableNames.size();id++){
									if(variableNames.get(id).equals(name)){
										variableFound=true;
										variableID=id;
										break;
									}
									continue;
								}
								if(!variableFound){
									variableNames.add(name);
									variableValues.add(value0);
								}
								else
									variableValues.set(variableID,value0);
								loopVariables.add(name);
								if(pp<program.length&&(program[pp]&0xff)==0xb8){
									pp++;
									numberCount=0;
									numbers=new byte[10];
									minus=false;
									int value1=0;
									for(numberCount=1;numberCount<=10;numberCount++){
										if(numberCount==1&&pp<program.length&&program[pp]=='-'){
											minus=true;
											pp++;
										}
										else{
											if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
												numbers[numberCount-1]=(byte)(program[pp]-0x30);
												pp++;
											}
											else{
												numberCount--;
												break;
											}
										}
										continue;
									}
									if(numberCount>10)
										numberCount=10;
									power=1;
									for(byte number=numberCount;number>0;number--){
										if(number==numberCount)
											value1+=numbers[number-1];
										else{
											value1+=numbers[number-1]*pow(10,power);
											power++;
										}
										continue;
									}
									if(minus)
										value1=-value1;
									loopToVariables.add(value1);
									loopAddresses.add(pp);
								}
							}
							else{
								String name="";
								int character=0;
								while(pp<program.length&&(program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'||(character>0&&((program[pp]>='0'&&program[pp]<='9')||program[pp]=='%'))){
									name+=(char)program[pp];
									pp++;
									character++;
									continue;
								}
								if(pp<program.length&&program[pp]=='=')
									pp++;
								byte numberCount=0;
								byte numbers[]=new byte[10];
								boolean minus=false;
								int value0=0;
								for(numberCount=1;numberCount<=10;numberCount++){
									if(numberCount==1&&pp<program.length&&program[pp]=='-'){
										minus=true;
										pp++;
									}
									else{
										if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
											numbers[numberCount-1]=(byte)(program[pp]-0x30);
											pp++;
										}
										else{
											numberCount--;
											break;
										}
									}
									continue;
								}
								if(numberCount>10)
									numberCount=10;
								byte power=1;
								for(byte number=numberCount;number>0;number--){
									if(number==numberCount)
										value0+=numbers[number-1];
									else{
										value0+=numbers[number-1]*pow(10,power);
										power++;
									}
									continue;
								}
								if(minus)
									value0=-value0;
								boolean variableFound=false;
								int variableID=0;
								for(int id=0;id<variableNames.size();id++){
									if(variableNames.get(id).equals(name)){
										variableFound=true;
										variableID=id;
										break;
									}
									continue;
								}
								if(!variableFound){
									variableNames.add(name);
									variableValues.add(value0);
								}
								else
									variableValues.set(variableID,value0);
							}
						}
						if(pp+3<program.length&&program[pp]==0xc&&(program[pp+1]&0xff)==0xf5&&(program[pp+2]&0xff)==0xfd&&(program[pp+3]&0xff)==0xa6){
							int temporaryPP=pp+4;
							if(temporaryPP<program.length&&program[temporaryPP]=='(')
								temporaryPP++;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int key=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&temporaryPP<program.length&&program[temporaryPP]=='-'){
									minus=true;
									temporaryPP++;
								}
								else{
									if(temporaryPP<program.length&&program[temporaryPP]>='0'&&program[temporaryPP]<='9'){
										numbers[numberCount-1]=(byte)(program[temporaryPP]-0x30);
										temporaryPP++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									key+=numbers[number-1];
								else{
									key+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								key=-key;
							if(temporaryPP<program.length&&program[temporaryPP]==')')
								temporaryPP++;
							if(!keyPressed((byte)key))
								pp-=3;
							else
								pp=temporaryPP;
						}
						if(pp+3<program.length&&program[pp]==0xb&&program[pp+1]=='*'&&program[pp+2]=='F'&&program[pp+3]=='X'){
							pp+=4;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int code=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									code+=numbers[number-1];
								else{
									code+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								code=-code;
							if(code==15){
								if(pp<program.length&&program[pp]==0x2c){
									pp++;
									numberCount=0;
									numbers=new byte[10];
									minus=false;
									int buffer=0;
									for(numberCount=1;numberCount<=10;numberCount++){
										if(numberCount==1&&pp<program.length&&program[pp]=='-'){
											minus=true;
											pp++;
										}
										else{
											if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
												numbers[numberCount-1]=(byte)(program[pp]-0x30);
												pp++;
											}
											else{
												numberCount--;
												break;
											}
										}
										continue;
									}
									if(numberCount>10)
										numberCount=10;
									power=1;
									for(byte number=numberCount;number>0;number--){
										if(number==numberCount)
											buffer+=numbers[number-1];
										else{
											buffer+=numbers[number-1]*pow(10,power);
											power++;
										}
										continue;
									}
									if(minus)
										buffer=-buffer;
									if(buffer==0||buffer==1)
										clear();
								}
							}
						}
						if(pp+1<program.length&&(program[pp]&0xff)==0xd3&&program[pp+1]=='='){
							pp+=2;
							byte numberCount=1;
							while(pp<program.length&&((numberCount==1&&(program[pp]=='&'||program[pp]=='-'))||(program[pp]>='0'&&program[pp]<='9'))){
								numberCount=1;
								pp++;
								continue;
							}
						}
						if(pp+5<program.length&&(program[pp]==0x11||program[pp]==0x15)&&program[pp+1]=='*'&&program[pp+2]=='L'&&program[pp+3]=='O'&&program[pp+4]=='A'&&program[pp+5]=='D'){
							pp+=6;
							if(pp<program.length&&program[pp]=='"'){
								pp++;
								if(programFileParentPath.charAt(programFileParentPath.length()-1)!='\\')
									programFileParentPath+="\\";
								String text=programFileParentPath+"$.";
								while(pp<program.length&&program[pp]!='"'){
									text+=(char)program[pp];
									pp++;
									continue;
								}
								File file=new File(text);
								if(!file.exists())
									outputText("\nNot found\n");
								else
									load(text);
								if(pp<program.length&&program[pp]=='"')
									pp++;
								for(byte number=0;number<4;number++){
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9')
										pp++;
									continue;
								}
							}
						}
						if(pp<program.length&&(program[pp]&0xff)==0xfb){
							pp++;
							byte numberCount=0;
							byte numbers[]=new byte[10];
							boolean minus=false;
							int color=0;
							for(numberCount=1;numberCount<=10;numberCount++){
								if(numberCount==1&&pp<program.length&&program[pp]=='-'){
									minus=true;
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
										numbers[numberCount-1]=(byte)(program[pp]-0x30);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>10)
								numberCount=10;
							byte power=1;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									color+=numbers[number-1];
								else{
									color+=numbers[number-1]*pow(10,power);
									power++;
								}
								continue;
							}
							if(minus)
								color=-color;
							color%=256;
							if(color>=128&&color<=255){
								color-=128;
								if(getMode()==2)
									color%=16;
								if(getMode()==7)
									color%=8;
								setBackgroundColor((byte)color);
							}
						}
						if(pp<program.length&&(program[pp]&0xff)==0xdb){
							pp++;
							for(short x=(short)(getTextAreaLeft()*8);x<=getTextAreaRight()*8+7;x++){
								for(short y=(short)(getTextAreaTop()*8);y<=getTextAreaBottom()*8+7;y++){
									setPixel(x,y,getBackgroundColor());
									continue;
								}
								continue;
							}
						}
						if(pp+6<program.length&&program[pp]==0xa&&program[pp+1]=='['&&program[pp+2]=='O'&&program[pp+3]=='P'&&program[pp+4]=='T'&&program[pp+5]=='I'&&program[pp+6]=='%'){
							pp+=7;
							assembly=true;
						}
						if(pp<program.length&&program[pp]==':'){
							separator=true;
							pp++;
						}
					}
					else
						pp++;
				}
			}
		}
		else{
			boolean line=pp+2<program.length&&program[pp]==0xd;
			if(line||separator){
				if(line){
					pp+=3;
					separator=false;
				}
				if(pp<program.length&&program[pp]==0x1d){
					pp++;
					if(pp+2<program.length&&program[pp]=='L'&&program[pp+1]=='D'&&program[pp+2]=='Y'){
						pp+=3;
						while(pp<program.length&&program[pp]==' '){
							pp++;
							continue;
						}
						if(pp<program.length&&program[pp]=='#'){
							pp++;
							byte value=0;
							if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
								value=program[pp];
								pp++;
							}
							interpret((byte)0xa0,value);
						}
					}
				}
				if(pp+2<program.length&&program[pp]=='L'&&program[pp+1]=='D'&&program[pp+2]=='X'){
					pp+=3;
					while(pp<program.length&&program[pp]==' '){
						pp++;
						continue;
					}
					if(pp<program.length&&program[pp]=='&'){
						pp++;
						byte numberCount=0;
						byte numbers[]=new byte[2];
						byte value=0;
						for(numberCount=1;numberCount<=2;numberCount++){
							if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
								numbers[numberCount-1]=(byte)(program[pp]-0x30);
								pp++;
							}
							else{
								if(pp<program.length&&program[pp]>='A'&&program[pp]<='F'){
									numbers[numberCount-1]=(byte)(program[pp]-0x37);
									pp++;
								}
								else{
									numberCount--;
									break;
								}
							}
							continue;
						}
						if(numberCount>2)
							numberCount=2;
						for(byte number=numberCount;number>0;number--){
							if(number==numberCount)
								value+=numbers[number-1];
							else
								value+=numbers[number-1]*0x10;
							continue;
						}
						interpret((byte)0xa6,value);
					}
				}
				if(pp+2<program.length&&program[pp]=='B'&&program[pp+1]=='E'&&program[pp+2]=='Q'){
					pp+=3;
					while(pp<program.length&&program[pp]==' '){
						pp++;
						continue;
					}
					String name="";
					int character=1;
					while(pp<program.length&&program[pp]!=0xd&&program[pp]!=':'&&((program[pp]>='A'&&program[pp]<='Z')||(program[pp]>='a'&&program[pp]<='z')||program[pp]=='_'||(character>1&&(program[pp]>='0'&&program[pp]<='9')))){
						name+=(char)program[pp];
						character++;
						pp++;
						continue;
					}
					boolean codeFound=false;
					while(!codeFound){
						if(pp+2<program.length&&program[pp]==0xd){
							pp+=3;
							if(pp+1<program.length&&(program[pp]==0x1e||program[pp]==0x2b)&&program[pp+1]=='.'){
								pp+=2;
								boolean characterFound=true;
								for(character=0;character<name.length();character++){
									if(pp<program.length&&program[pp]!=name.charAt(character))
										characterFound=false;
									pp++;
									continue;
								}
								if(characterFound)
									codeFound=true;
							}
							else
								pp++;
						}
						else
							pp++;
						continue;
					}
				}
				if(pp+2<program.length&&program[pp]=='L'&&program[pp+1]=='D'&&program[pp+2]=='A'){
					pp+=3;
					while(pp<program.length&&program[pp]==' '){
						pp++;
						continue;
					}
					if(pp<program.length&&program[pp]=='#'){
						pp++;
						byte value=0;
						if(pp<program.length&&program[pp]=='&'){
							pp++;
							byte numberCount=0;
							byte numbers[]=new byte[2];
							for(numberCount=1;numberCount<=2;numberCount++){
								if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
									numbers[numberCount-1]=(byte)(program[pp]-0x30);
									pp++;
								}
								else{
									if(pp<program.length&&program[pp]>='A'&&program[pp]<='F'){
										numbers[numberCount-1]=(byte)(program[pp]-0x37);
										pp++;
									}
									else{
										numberCount--;
										break;
									}
								}
								continue;
							}
							if(numberCount>2)
								numberCount=2;
							for(byte number=numberCount;number>0;number--){
								if(number==numberCount)
									value+=numbers[number-1];
								else
									value+=numbers[number-1]*0x10;
								continue;
							}
						}
						else{
							if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
								value=(byte)(program[pp]-0x30);
								pp++;
							}
						}
						interpret((byte)0xa9,value);
					}
				}
				if(pp+2<program.length&&program[pp]=='S'&&program[pp+1]=='T'&&program[pp+2]=='A'){
					pp+=3;
					while(pp<program.length&&program[pp]==' '){
						pp++;
						continue;
					}
					if(pp<program.length&&program[pp]=='&'){
						byte value=0;
						if(pp<program.length&&program[pp]>='0'&&program[pp]<='9'){
							value=(byte)(program[pp]-0x30);
							pp++;
						}
						else{
							if(pp<program.length&&program[pp]>='A'&&program[pp]<='F'){
								value=(byte)(program[pp]-0x37);
								pp++;
							}
						}
						interpret((byte)0x85,value);
					}
				}
				if(pp<program.length&&program[pp]==':'){
					pp++;
					separator=true;
				}
			}
		}
		return;
	}
}



Tell me what you think about this. :lol:/>/>/>

Is This A Good Question/Topic? 0
  • +

Replies To: My most messy code, I guess

#2 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11071
  • View blog
  • Posts: 18,909
  • Joined: 19-March 11

Re: My most messy code, I guess

Posted 22 February 2018 - 02:46 PM

Quote

catch(IOException exception){
}
try{
file.read(program);
}
catch(IOException exception){
}
try{
file.close();
}
catch(IOException exception){
}
return;



I guess it's good to be sure that exception gets totally caught.
Was This Post Helpful? 2
  • +
  • -

#3 Programmer2004   User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 47
  • Joined: 25-October 17

Re: My most messy code, I guess

Posted 22 February 2018 - 02:48 PM

Yeah, I don't know why I made it this way. :lol:/>

This post has been edited by andrewsw: 23 February 2018 - 02:10 AM
Reason for edit:: removed previous quote, just use the Reply button

Was This Post Helpful? 0
  • +
  • -

#4 ndc85430   User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 825
  • Posts: 3,337
  • Joined: 13-June 14

Re: My most messy code, I guess

Posted 23 February 2018 - 11:06 PM

The major problem here is lack of abstraction - that tick method is far too long and tells you all the very tiny details about what it's doing, which makes it difficult to understand because you don't get a good idea of the high level function it's trying to perform. So, the different parts of what this is supposed to do should be abstracted away into methods and classes that are composed in a way to describe what it means to tick.

The other problem is lack of whitespace, both on lines (e.g. either side of =) and between lines to show statements that go together. More whitespace would make the code easier to read. The analogy I can come up with here is to think about when you're writing some long piece of text (essay, article, thesis, ...). You separate each group of thoughts into their own paragraphs, for example. Vertical whitespace is how you separate different thoughts in say, a method.

Uncle Bob's "Clean Code" talks a lot about these and related issues.

This post has been edited by ndc85430: 23 February 2018 - 11:51 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1