Dual1456.java, a 1456 applet landscape.

William Overington

Copyright 2000 William Overington

This document is intended for people who have a knowledge of Java and would like to learn more about how this 1456 applet landscape is programmed in Java. This section may be safely missed out by people who are reading these documents just to program in 1456 object code itself without learning about the underlying Java software that allows it to run.

Here is the source code of the Dual1456.java program.

import java.awt.*;
import java.awt.event.*;
 
public class Dual1456 extends java.applet.Applet implements
                                               MouseListener

// Software written by William Overington
// WOverington@ngo.globalnet.co.uk
// 26 September 2000
// Copyright 2000 William Overington
//
// This software is a 1456 Applet Landscape for use with
// 1456 object code.
// The 1456 object code system is explained at
// http://www.users.globalnet.co.uk/~ngo

// Experimental derivative of Softboard1456.java using two 1456 engines.
// 5 October 2000
// Updated
// 10 October 2000

  {
    String active1456engine;
    Engine1456 firefly = new Engine1456();
    Engine1456 northstar = new Engine1456();
    String software,software01,software02,software03,software04,
           software05,software06,software07,software08,software09;
    int length,length01,length02,length03,length04,length05,length06,
               length07,length08,length09;
    String commonstring;
    int obeycode;
    char resultchar;
    String string00,string01,string02,string03,string04,
                    string05,string06,string07,string08,string09;
    String string101,string102,string103,string104;
    int pressx,pressy;
    boolean shiftdown,controldown,altdown;
    boolean splittheeventhandler = false;
    boolean colourtoolbarison = false;
    Font font1120, font1122, font1180, font1182,
         font1240, font1242, font1360, font1362,
         font1480, font1482, font1600, font1602,
         font1720, font1722, font3120, font3180;
    int fontcode;

    public void init()
      {
        setLayout(null);
        setBounds(0,0,700,400);
        addMouseListener(this);

        software="";
        software01 = getParameter("SOFTWARE01");
        if (software01 != null)
          {
            length01=software01.length();
            if (length01 > 0)
              {
                software=software+software01;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software02 = getParameter("SOFTWARE02");
        if (software02 != null)
          {
            length02=software02.length();
            if (length02 > 0)
              {
                software=software+software02;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software03 = getParameter("SOFTWARE03");
        if (software03 != null)
          {
            length03=software03.length();
            if (length03 > 0)
              {
                software=software+software03;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }
        
        software="";
        software04 = getParameter("SOFTWARE04");
        if (software04 != null)
          {
            length04=software04.length();
            if (length04 > 0)
              {
                software=software+software04;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software05 = getParameter("SOFTWARE05");
        if (software05 != null)
          {
            length05=software05.length();
            if (length05 > 0)
              {
                software=software+software05;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software06 = getParameter("SOFTWARE06");
        if (software06 != null)
          {
            length06=software06.length();
            if (length06 > 0)
              {
                software=software+software06;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software07 = getParameter("SOFTWARE07");
        if (software07 != null)
          {
            length07=software07.length();
            if (length07 > 0)
              {
                software=software+software07;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software08 = getParameter("SOFTWARE08");
        if (software08 != null)
          {
            length08=software08.length();
            if (length08 > 0)
              {
                software=software+software08;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software09 = getParameter("SOFTWARE09");
        if (software09 != null)
          {
            length09=software09.length();
            if (length09 > 0)
              {
                software=software+software09;
                firefly.loadSoftwareFromAppletParameters(software);
                northstar.loadSoftwareFromAppletParameters(software);
              }
          }
      
        string01 = getParameter("STRING01");
        if (string01 != null)
          {
            firefly.loadStringFromString(1,string01);
          }

        string02 = getParameter("STRING02");
        if (string02 != null)
          {
            firefly.loadStringFromString(2,string02);
          }

        string03 = getParameter("STRING03");
        if (string03 != null)
          {
            firefly.loadStringFromString(3,string03);
          }

        string04 = getParameter("STRING04");
        if (string04 != null)
          {
            firefly.loadStringFromString(4,string04);
          }

        string05 = getParameter("STRING05");
        if (string05 != null)
          {
            firefly.loadStringFromString(5,string05);
          }

        string06 = getParameter("STRING06");
        if (string06 != null)
          {
            firefly.loadStringFromString(6,string06);
          }

        string07 = getParameter("STRING07");
        if (string07 != null)
          {
            firefly.loadStringFromString(7,string07);
          }

        string08 = getParameter("STRING08");
        if (string08 != null)
          {
            firefly.loadStringFromString(8,string08);
          }

        string09 = getParameter("STRING09");
        if (string09 != null)
          {
            firefly.loadStringFromString(9,string09);
          }

        string101 = getParameter("STRING101");
        if (string101 != null)
          {
            northstar.loadStringFromString(1,string101);
          }

        string102 = getParameter("STRING102");
        if (string102 != null)
          {
            northstar.loadStringFromString(2,string102);
          }

        string103 = getParameter("STRING103");
        if (string103 != null)
          {
            northstar.loadStringFromString(3,string103);
          }

        string104 = getParameter("STRING104");
        if (string104 != null)
          {
            northstar.loadStringFromString(4,string104);
          }

        commonstring = getParameter("COMMON");

        setBackground(Color.white);

        firefly.landscapeAuthorIs("William Overington" +
                                  "    " +
                                  "WOverington@ngo.globalnet.co.uk");

        northstar.landscapeAuthorIs("William Overington" +
                                    "    " +
                                    "WOverington@ngo.globalnet.co.uk");

        font1120 = new Font("SansSerif", Font.PLAIN, 12);
        font1122 = new Font("SansSerif", Font.ITALIC, 12);
        font1180 = new Font("SansSerif", Font.PLAIN, 18);
        font1182 = new Font("SansSerif", Font.ITALIC, 18);
        font1240 = new Font("SansSerif", Font.PLAIN, 24);
        font1242 = new Font("SansSerif", Font.ITALIC, 24);
        font1360 = new Font("SansSerif", Font.PLAIN, 36);
        font1362 = new Font("SansSerif", Font.ITALIC, 36);
        font1480 = new Font("SansSerif", Font.PLAIN, 48);
        font1482 = new Font("SansSerif", Font.ITALIC, 48);
        font1600 = new Font("SansSerif", Font.PLAIN, 60);
        font1602 = new Font("SansSerif", Font.ITALIC, 60);
        font1720 = new Font("SansSerif", Font.PLAIN, 72);
        font1722 = new Font("SansSerif", Font.ITALIC, 72);
        font3120 = new Font("Monospaced", Font.PLAIN, 12);
        font3180 = new Font("Monospaced", Font.PLAIN, 18);

        obeycode=1;

        fontcode = 1120;

        active1456engine="firefly";
      }

    public void mousePressed(MouseEvent e)
      {
        pressx=e.getX();
        pressy=e.getY();
        if ((pressx < 20) & (pressy < 20))
          {
            if (active1456engine == "firefly")
              {
                active1456engine="northstar";
                int commonlength=commonstring.length();
                if (commonlength > 0)
                  {
                    int address = 0;
                    for(int commoni=0; commoni < commonlength; commoni++)
                      {
                        char commonchar=commonstring.charAt(commoni);
                        if ((commonchar >= '0') & (commonchar <= '9'))
                          {
                            address=10*address +
                                      (int)commonchar -
                                      (int)'0';
                          }
                        else
                          {
                            if (commonchar == 'd')
                              {
                                double tempd;
                                tempd=firefly.double1456Get(address);
                                northstar.double1456Set(address,tempd);
                              }
                            if (commonchar == 'i')
                              {
                                int tempi;
                                tempi=firefly.integer1456Get(address);
                                northstar.integer1456Set(address,tempi);
                              }
                            if (commonchar == 'c')
                              {
                                char tempc;
                                tempc=firefly.char1456Get(address);
                                northstar.char1456Set(address,tempc);
                              }
                            if (commonchar == 's')
                              {
                                String temps;
                                temps=firefly.string1456Get(address);
                                northstar.string1456Set(address,temps);
                              }
                            address=0;
                          }
                    
                      }
                  }
                }
            else
              {
                active1456engine="firefly";
                int commonlength=commonstring.length();
                if (commonlength > 0)
                  {
                    int address = 0;
                    for(int commoni=0; commoni < commonlength; commoni++)
                      {
                        char commonchar=commonstring.charAt(commoni);
                        if ((commonchar >= '0') & (commonchar <= '9'))
                          {
                            address=10*address +
                                      (int)commonchar -
                                      (int)'0';
                          }
                        else
                          {
                            if (commonchar == 'd')
                              {
                                double tempd;
                                tempd=northstar.double1456Get(address);
                                firefly.double1456Set(address,tempd);
                              }
                            if (commonchar == 'i')
                              {
                                int tempi;
                                tempi=northstar.integer1456Get(address);
                                firefly.integer1456Set(address,tempi);
                              }
                            if (commonchar == 'c')
                              {
                                char tempc;
                                tempc=northstar.char1456Get(address);
                                firefly.char1456Set(address,tempc);
                              }
                            if (commonchar == 's')
                              {
                                String temps;
                                temps=northstar.string1456Get(address);
                                firefly.string1456Set(address,temps);
                              }
                            address=0;
                          }
                      }
                  }
              }
            
            obeycode=2;

          }
        else
          {
            shiftdown=e.isShiftDown();
            controldown=e.isControlDown();
            altdown=e.isAltDown();
            firefly.integer1456Set(5,pressx);
            firefly.integer1456Set(6,pressy);
            northstar.integer1456Set(5,pressx);
            northstar.integer1456Set(6,pressy);
            if (shiftdown)
              {
                firefly.integer1456Set(7,1);
                northstar.integer1456Set(7,1);
              }
            else
              {
                firefly.integer1456Set(7,0);
                northstar.integer1456Set(7,0);
              }
            if (controldown)
              {
                firefly.integer1456Set(8,1);
                northstar.integer1456Set(8,1);
              }
            else
              {
                firefly.integer1456Set(8,0);
                northstar.integer1456Set(8,0);
              }
            if (altdown)
              {
                firefly.integer1456Set(9,1);
                northstar.integer1456Set(9,1);
              }
            else
              {
                firefly.integer1456Set(9,0);
                northstar.integer1456Set(9,0);
              }

            if (splittheeventhandler)
              {
                if (pressy < 300)
                  {
                    obeycode = 70;
                  }
                else
                  {
                    int column = pressx / 25;
                    int row = (pressy - 300) / 25;
                    obeycode = 100 + (28 * row) + column;
                  }
              }
            else
              {
                obeycode=41;
              }
          }
        repaint();
      }

    public void mouseReleased(MouseEvent e)
      {

      }

    public void mouseClicked(MouseEvent e)
      {

      }

    public void mouseEntered(MouseEvent e)
      {
       
      }

    public void mouseExited(MouseEvent e)
      {
       
      }

    public void paint(Graphics screen)
      {

        chooseFont(screen);

        if (obeycode == 1)
          {   
            resultchar =
              firefly.obeySoftwareAtLabel(screen,obeycode);
            resultchar =
              northstar.obeySoftwareAtLabel(screen,obeycode);
            obeycode=2;
          }
        if (active1456engine == "firefly")
          {
            resultchar =
              firefly.obeySoftwareAtLabel(screen,obeycode);
          }
        else
          {
            resultchar =
              northstar.obeySoftwareAtLabel(screen,obeycode);
          }

        if (resultchar == '?')
          {
            do
              {
                int functionchoice;
                if (active1456engine == "firefly")
                  {
                    functionchoice=
                    firefly.softwareinterruptparameterGet();
                  }
                else
                  {
                    functionchoice=
                    northstar.softwareinterruptparameterGet(); 
                  }

                if (functionchoice == 1)
                  {
                    if (active1456engine == "firefly")
                      {
                        firefly.string1456Set
                          (19,"The 1456 engine in action.");
                      }
                    else
                      {
                        northstar.string1456Set
                          (19,"The 1456 engine in action."); 
                      }
                  }

                if (functionchoice == 13)
                  {
                    splittheeventhandler = true;
                  }

                if (functionchoice == 14)
                  {
                    splittheeventhandler = false;
                  }

                if (functionchoice == 23)
                  {
                    colourtoolbarison = true;
                    for(int row=0; row < 4; row++)
                      {
                        for(int column=0; column < 28; column++)
                          {
                            int checkerboardcount = row + column;
                            int checkerboardparity = checkerboardcount % 2;
                            if (checkerboardparity == 0)
                              {
                                screen.setColor(Color.lightGray);
                              }
                            else
                              {
                                screen.setColor(Color.yellow);
                              }
                            screen.fillRect(25*column,300+25*row,25,25);
                          }
                      }

                  }

                if (functionchoice == 24)
                  {
                    colourtoolbarison = false;
                    screen.setColor(Color.white);
                    screen.fillRect(0,300,700,100);
                  }                

                if ((functionchoice > 1000) &
                    (functionchoice < 6999))
                  {
                    fontcode=functionchoice;
                    chooseFont(screen);
                  }

                if ((functionchoice >= 10000) &
                    (functionchoice <= 10999))
                  // override basic key grid with a light grey square
                  {
                    int routinecode=(functionchoice - 10000);
                    int keycode=routinecode - 100;
                    int ytop=300 + 25*(keycode / 28);
                    int xleft=25*(keycode % 28);
                    screen.setColor(Color.lightGray);
                    screen.fillRect(xleft,ytop,25,25); 
                  }

                if ((functionchoice >= 11000) &
                    (functionchoice <= 11999))
                  // override basic key grid with a yellow square
                  {
                    int routinecode=(functionchoice - 11000);
                    int keycode=routinecode - 100;
                    int ytop=300 + 25*(keycode / 28);
                    int xleft=25*(keycode % 28);
                    screen.setColor(Color.yellow);
                    screen.fillRect(xleft,ytop,25,25);
                  }

                if ((functionchoice >= 12000) &
                    (functionchoice <= 12999))
                  // override basic key grid with a white square
                  {
                    int routinecode=(functionchoice - 10000);
                    int keycode=routinecode - 100;
                    int ytop=300 + 25*(keycode / 28);
                    int xleft=25*(keycode % 28);
                    screen.setColor(Color.white);
                    screen.fillRect(xleft,ytop,25,25); 
                  }

                if (active1456engine == "firefly")
                  {
                    resultchar =
                    firefly.obeySoftwareAfterSoftwareInterrupt(screen);
                  }
                else
                  {
                    resultchar =
                    northstar.obeySoftwareAfterSoftwareInterrupt(screen);
                  }
                    
              } while (resultchar == '?');
          }

      }

    public void chooseFont(Graphics screen)
      {
        switch (fontcode)
          {
            case 1120:
              screen.setFont(font1120);
              break;
            case 1122:
              screen.setFont(font1122);
              break;
            case 1180:
              screen.setFont(font1180);
              break;
            case 1182:
              screen.setFont(font1182);
              break;
            case 1240:
              screen.setFont(font1240);
              break;
            case 1242:
              screen.setFont(font1242);
              break;
            case 1360:
              screen.setFont(font1360);
              break;
            case 1362:
              screen.setFont(font1362);
              break;
            case 1480:
              screen.setFont(font1480);
              break;
            case 1482:
              screen.setFont(font1482);
              break;
            case 1600:
              screen.setFont(font1600);
              break;
            case 1602:
              screen.setFont(font1602);
              break;
            case 1720:
              screen.setFont(font1720);
              break;
            case 1722:
              screen.setFont(font1722);
              break;
            case 3120:
              screen.setFont(font3120);
              break;
            case 3180:
              screen.setFont(font3180);
              break;
         } // end of switch block
  
      }

    public void update(Graphics screen)
      {
        paint(screen);
      }

  }
 

The use of the Dual1456 1456 applet landscape is explained in the next section.

1456 object code

Copyright 2000 William Overington