![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
vm02 preview #3
I've decided to make another preview available for your geeking pleasure.
A ZIPped DSK file downloadable here: At the prompt for the main class, enter "helloworld" (without quotes). You will be treated to the first ever multi-threaded Java app running on an Apple II. However, I've noted that occasionally you will get a screenfull of bad handle error messages. So much for bug free. Try powering down and booting directly from the disk. I must have an initialization bug somewhere, but whenever I try and track it down, everything works. I'll find it eventually. However, if you do get it to run, just type away. ESC quits (as you will see on the screen). Any 64K Apple II should work - even tested on a Rev 0 (with integer basic ROMS). For the curious, here is the HelloWorld program: <code> import apple2.*; public class HelloWorld extends Thread { private static int hrhandle; private static boolean finished = false; private static Object sync = new Object(); public short SampleShort; public int SampleInst; public String Title; public int TitleRow; HelloWorld(String s, int r) { Title = s; TitleRow = r; } public void run() { int i = 0; int ix = 1; while (!finished) { synchronized (sync) { conio.gotoXY(i, TitleRow); conio.print(Title); } i = i + ix; if (i < 0) { i = 1; ix = 1; } else if (i > (39 - Title.length())) { i = 38 - Title.length(); ix = -1; } } } public static void main(String[] args) { int i, px; char key; HelloWorld h1 = new HelloWorld(" HELLO WORLD ", 0); HelloWorld h2 = new HelloWorld(" PRESS ESC KEY TO QUIT... ", 3); conio.home(); conio.gotoXY(0, 5); conio.print(":_"); h1.start(); // Start HelloWorld thread 1 h2.start(); // Start HelloWorld thread 2 px = 1; while ((key = conio.getKey()) != (char)27) { synchronized (sync) { if (key < ' ') { if (key == (char)8) // LEFT ARROW { if (--px > 0) { conio.gotoXY(px,5); conio.print("_ "); } else px = 1; } } else { conio.gotoXY(px, 5); conio.print(key); conio.print('_'); if (++px > 38) { conio.gotoXY(0,5); conio.print(":_ "); px = 1; } } } } finished = true; // Flag HelloWorld threads to exit for (i = 0; i < 100; i++); conio.home(); conio.println("THAT'S ALL FOLKS..."); } } </code> It is compiled directly to a java class file and run directly. No intermediate steps other than copying it to a DSK image. I also removed the .class extension due to name length, so it shows up simply as HELLOWORLD. I've written my own console I/O class that interfaces to the Apple II's ROM routines. The java system classes are mostly non-existent at this point. Only Object, String, and Thread are currently available and most of their methods are stubbed out. Just enough to try things out. Obviously quite a bit more has been implemented since the last preview. Objects (with inheritance), floating point, single dimension arrays, and multi-threading are implemented. I've written a class file that implements low level 6502 stuff like peeks, pokes, and calls that allow a direct connection to the VM and ROM routines from java. As a result, I've been able to implement more of the code directly in java. Currently vm02 code is only taking about 12K of main memory and 4K of the language card. That is my final goal but there are still some major functionality to be implemented. Exceptions, garbage collection finalization, and multi-dimensional arrays being the biggies. I also wanted to show off some hi-res graphics stuff using the ROM routines, but I found a clash with a few zero page locations that caused all sorts of confusion. Someday I'll get around to writing a real hires and double-hires class. It was pretty cool though. Up next will be getting the memory handle bug tracked down and implementing swapping to disk. This should allow for much bigger programs. Then the rest of the java language stuff noted above. Lastly will be support for 128K. Should make for a pretty nice system. This has been quite an interesting exercise. I think java makes a nice fit to the Apple II. It runs fast enough to be interactive and yet compact enough to not overload the machine. Definitely a good follow-up to Apple Pascal. I really believe it's a better fit to my 1 MHz 6502 than my 2.6 GHz dual core - but that's an argument for another day :-) Dave... |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |