Changes in SuperWaba 2.0 beta 1 IMPORTANT: this is a BETA version. if you find any bug, please shrink your code so the bug is still there and send it to me. dont send me big codes! also, backup your data. although this version is stable, be aware that if you find a serious bug, you may need to do a hard reset in your handheld! I would like to thank Rick Wild; the more I know his virtual machine, the more impressed I become with his work. I would also like to thank Ralf Kleberhoff, Noli Sicad and Matthias Ringwald for they invaluable help. This beta release of SuperWaba 2.0 is the result of 5 months of dedicated home work. I had a dream. The dream was give SuperWaba a better look and feel for its user interface. My dream started with the code that Ralf sent me about entering in gray scale. I then started learning the 68000 assembler. This was necessary because the most used routines, like setPixel, drawHLine, drawVLine had to be the fast as possible. After this was done, i started to make the other routines. I spent almost 3 weeks searching for graphical algorithms in the net. Hundreds of sites visited. I found almost all, but the draw/fill arc. I had to made it. Then, a guy asked: dont SuperWaba handles double/long? No, i said, not yet. Then i started the research in how to implement those, and here it is. Native support for longs and doubles. I also improved the wextras exegen and warp files, which now is the official ones to build SuperWaba. There are also hundreds of enhancements through all the library, like support for sprite, collision detection, circles, pies... the sky is the limit! My final goal is: make SuperWaba the best java virtual machine for the PalmPilot of the world! Thanks for all the help. Guilherme Campos Hazan. tip: to see how powerful SuperWaba 2.0 is, run the welcome app (by clicking in the SuperWaba icon) . Please be aware that, as ALL programs that supports gray scale in ALL PalmOs devices, SuperWaba 2.0 access some reserved areas in the rom and other structures. So, dont care for PalmEmulator warnings. i'm aware of all of them. . See the file org/directory.txt for details about the new directory structure. see also the readme.txt files under almost all directories. . new creator ID for SuperWaba: SWAB . this will help with the coexistence of multiple waba vm versions . new directory structure to conform with the new Waba Specifications. the org/wabavm/palm/desktop directory has the packages needed to test the program in the desktop computer, and org/wabavm/palm/device directory has the classes, the vm itself, the docs and the bin directory, the waba and the java packages; all related only to when the program runs in the device. . if you need the project files of CodeWarrior 6 to build the VM and/or the Stub, please ask me. . wextras.wababin.* now is copied to the bin directory. warp had been modified to create warp files (i removed it a long time ago) . to see how to build the pdb and prc files, see the make.bat under the \org\wabavm\palm\examples\bench directory. . exegen now has an option /v to write the app version information. eg: "/v 2.01" or "/v 2.0" . warp now has an option /! to not create the warp file (only the pdb file will be created) . desktop.waba.io.Catalog now correctly writes the creation date to the pdb file . desktop.waba.io.Catalog now sets the AttrBackup field if the database is modified . new methods in waba.io.Catalog: get/setAttributes. use the DB_ATTR_* masks to get/set individual bits. . new methods in waba.io.Catalog: get/setRecordAttributes. use the REC_ATTR_* masks to get/set individual bits. . now in desktop.waba.io.Catalog the date and attributes are preserved if the file was readed from disk . now in desktop.waba.io.Catalog the methods toPDB and fromPDB are non-static. Use the default constructor to get access to it if you want. . toPDB and fromPDB now has a new parameter: Vector _attr, which will hold the attributes for each record. they can be null. . the wextras 1.3 package from Rob Nielsen is now under the org.wabavm.palm.addons directory. this directory will hold all classes from third party users that may be putted together. . added TextArea from Michael Brereton to the org.wabavm.palm.addons. . corrected the Convert.toString(char c) method. it was not converting correctly the international chars. . added support for menu bar from wextras. Since SuperWaba uses the Control class instead of MenuBar, it calls menubar.setVisible(true) in order to pop it up. added the method Window.setMenuBar. added the method wextras.ui.MenuBar.setVisible(boolean b) . modified org.wabavm.palm.desktop.waba.sys.Vm.openInputStream to handle jar files. used code from Scott Cytacki @ 20010222 . modified org.wabavm.palm.device.waba.io.DataStream.readString as mike mcroberts pointed to grow the byte array if necessary . implemented Gennadi Pergament modifications to correct the fatal errors when poping up some palm dialogs. this bug is since waba 1.0. ATTENTION: to correct this error, i had to create a default form for Waba. So, be aware of this when creating waba.prc from others compilers . added the Symbol barcode scanner support implemented by Tom Cuthill (vm growed 1.5kb); added the class waba.io.Scanner.java . added support for the list icon (15x2), thanks to ed crandwel for the startup code. . corrected convertion in formatDouble, it was not formatting precision below 0.32767 . added support for double's!!! all bytecodes implemented, tested and working. . added a new constructor to StringBuffer: StringBuffer(startSize) . changed String.hashCode to match the one in jdk 1.2.2. . waba.sys.Convert: new method toDouble(String), toString(double), toLong(String), toString(long), toLong(String, radix), toString(long,radix), forDigit(i,radix), digitOf(char,radix) . new method in class String: reversed (returns the reversed of the current string) . added support for long's!!! all bytecodes implemented and working. . now SuperWaba is a multi-segment application. This means that now the sky is the limit. PS: SuperWaba still works in Palm OS 2.0 . improved class Graphics. Now it supports GRAY SCALE in all palm os versions (starting from PalmOS 2). Support for color in next version. Lots of new methods: . colors from 0 to 3 . draw/fill circles . draw arcs . draw/fill pies . draw elliptical arcs . draw/fill elliptical pies . instant screen erase . set/get pixel . dotted line in all directions . draw/fill round rect . getAnglePoint to get the point of an ellipse given an angle; usefull to see where to draw the pie labels . draw/fill polygons of any shape . collisionDetect: returns true if two bitmaps collides (tested and working) . eraseRect replace all pixels with the foreground color by the background color . new constants in the class Color: GS_WHITE, GS_BRIGHT, GS_DARK, GS_BLACK. those constants are returned from getGray(). New constructor Color(int rgb); new method int getRGB(); new constant array: GS_PAL (GrayScale palette. use the constants GS_xxx as the indexes), used to get the color that represent the desired gray scale; new method equals; new constants BLACK DARK BRIGHT WHITE that represents the colors in gray scale. . added class Math taked from Jump2. To reduce its size, i stripped out all methods that used float; since double is much more accurate, you can compute the values using double and then cast to float. the method random was modified. . waba.sys.Convert: removed the methods add,sub,mul,div. since now there is native support, there are no needs for those methods. Also, max,min,abs,random were moved to class waba.util.Math. Added the methods doubleToLongBits and longBitsToDouble. added constants MIN_LONG_VALUE and MAX_LONG_VALUE. . new methods in waba.io.DataStream: writeDouble, readDouble, writeLong, readLong. . added method parseNative in MethodsHash so a normal method string is converted to java bytecode defs. eg: boolean clip(waba.fx.Rect r) -> waba/fx/Graphics_clip_(Lwaba/fx/Rect;)Z . also modified nativeHash to create the output with the same formatting of the waba native method table and a function prototype (with its header) is also created. everything is outputted to methodshash.txt. . prc commandline: now the maximum class name length for the command line argument in the prc is 200. was 80. . user defined command line arguments: now the prc can receive command line arguments. there is no maximum length (unless specified by palm os). . warp and exegen now has an option /$ to set the copy protection attribute of the prc and the pdb file. . extended the prc name from 30 to 31 bytes. . PrcFile now automatically finds all the offsets of the placeholders. it scans for strings and scans the prc file to find the offset of each bitmap record. . in Window.popupModal if the programmer try to popup in the wrong way, do it in the write way. I thoght that just reading the docs would be enough. ;-) . added a catch to waba/applet/Applet.java class to trap linkage errors. . new method Vm.getMaxColors: returns the number of colors supported by the device. . corrected errors in Vm about arrayCopy that Sean Luke WabaWalker :-) pointed out. . Added 2 methods to Object: equals and toString, this one native. changed all toString methods on the controls. . Vm.debug is modified. now the strings are sent to a memo record created with the title: "SuperWaba Debug Console". the line is writted as " mystring \n". at the program's end a "--- End ---" line is entered. the memo is *not* deleted at each program start. The Vm.trace strings are also sent to there. the memo is created only if you issue a Vm.debug or vm.setTrace command. it also may slowdown a little your program. dont forget to turn off your echoes when you send your program to your customer!!! . htPut in waba.c now sends a debug message to the console when it finds a duplicated hash value. . new Label.set3d method. just for fun... :-) . the controls are being converted to grayScale and color support. the difference is unbelievable!!! . String.valueOf(Object) now returns obj.toString instead of "?" . String.equals(Object), if obj is not a string, now returns super.equals(obj) instead of true . new methods String.indexOf(String) and String.indexOf(String, startIndex) . corrected a wrong comparision of string boundaries in String.indexOf(char,int) . in the vm, new constant STU_USE_STATIC2 so a secundary buffer is used. good for routines that needs 2 temporary buffers. expanded sbytes to 192 (was 64) . changed the behavior of setVisible in the Control class. now it sets a flag that is ignored in Container.paintChildren method . new methods and members for class control: (set/get)backColor, (set/get)foreColor. so each control can have different colors (preparation for COLORS!) . added Color.defaultBackColor, Color.defaultForeColor so users dont have to specify the default colors of the controls. . added Graphics.draw3dRect, used in most controls. use the constants EDIT LOWERED RAISED CKECK. . new methods Color.darker, Color.brighter . removed Tab and TabBar from waba.ui. use TabPanel instead. if you dont want to use it, get the old classes, change the packages and add to your project. . button.drawButton (static method) removed. use Graphics.draw3dRect instead . now the controls have a disabled state look&feel. . removed radio.drawRadio. and check.drawCheck. . removed ISurface from window, putted in Control. . added ComboBox, ListBox and PopList to waba.ui. thanks to Daniel Tauschke. just to understand: ComboBox uses a PopList as the popup window. PopList is a Window that adds a ListBox to itself. . new method Rect.set(x,y,w,h) . class Edit simplified . new method Graphics.drawArrow to draw the arrows for all controls. . new empty constructor for class Rect. . Button now accepts images. . new Image.getGraphics(). same as new Graphics(Image) . new class Coord, to store x,y values. If i used Point, it wont make sense use it in getSize methods. If i used Size, it wont make sense if used in getPoint methods. So, Coord is more general. Coord has two methods width() and height() hat just return x and y. just to make more sense. ;-) . new constructor for class Rect: Rect(Coord topleft, Coord bottomright) . to use less memory, Vector grows 20% at each time (instead of doubling) . new methods Control.getSize and Control.getPos, both returning a Coord . new method Button.createArrowButton to make easier create image buttons with arrow images. used by many ui classes . new method Button.setPressed used to simulate a button press. . new method Control.getParentWindow() . Container.setEnabled now calls setEnabled in all childrens. . removed all toString() implementations. they will be back in the appletviewer port. with the toString's i was getting 4549 more bytes in the superwaba.pdb! . added Control.addedNotify and Control.removedNotify protected methods. called by the container when the control is added/removed to/from it. . PushButtonGroup: new method setSimpleBorder, to remove the 3d borders (and the bigger required size) . removed tones at startup. putted a fade out hourglass. . new method Convert.toString(double d) . new methods StringBuffer.valueOf(long) and valueOf(double) . removed beep in TabPanel tab click. . YES! I DID IT!!! if a system dialog comes on, my trap of sysTrapWinSetActiveWindow turns off gray mode, displayes the dialog and comes back when finished. :-))) . Image class . 1,2,4,8 bit depth support . support for rle4 and rle8 compressed bitmaps . more bitmap draw operations, including transparent bitmap color (sprite) . setPixels and getPixels are DEPRECATED. better saying, they are no more implemented. until the final release, they will be removed. no more time to create another way in this beta version. . added methods rol and ror to class Math. . new method Vm.getScreenSize(), returning a Coord. . new native private method Window.drawOffScreen. only used to update the screen as fast as possible. . new method Button.setGap to set the gap between the text/image and the borders. the default is 1. used when the size is set by getPreferredXXX. . new method Button.setBorder. now there are 3 styles of button border: BORDER_NONE, BORDER_SIMPLE AND BORDER_3D. 3D is the default. . new method Image.set/getTransparentColor . new method Button.getImage(). returns null if the Button is a text one. . new method TabPanel.setCaptionColor - just to set the text color of the captions . corrected FontMetrics documentation. . now the Control.getBackColor() and getForeColor returns the ideal disabled color if the control is not enabled. the disabled color is defined as foreColor.brighter() and backColor.darker(). . corrected getPalmFontID for PalmOS 2.0 when selected the big font. Theres no big font in palm 2. . now when a fatal error occurs, the full message is sent to the debug console. . excluded line number in trace; included method desc; . trapped a unknown error exception that occured when the array was zero-length . new method Container.getChilds() to return an array of controls inside the container . new method Vector.clear() to reset the vector. . new method Convert.tokenizeString that returns an array of parsed strings . new methods Edit.setEditable and isEditable() - allow or disallow the enter of text from the user . new public variable Control.appId : a application defined constant. This constant is not used; its only a placeholder for the application so it can set to any value it wants . growed default memory sizes of exegen. new option /! in exegen to not generate .lnk file . new Method Image.changeColors(from, to): Changes all the pixels of the image from one color to the other. Note that the current value of the transparent color is not changed. When you load a mono bmp (consumes less memory), it is stored internally as grayScale (or color). Using this routine, you can change the colors to any other you want. . putted a message when you try to create a graphics object for the control but theres no parent yet. good for help you debug your code. . changed Control.toString(): if the appId != 0, append it. good for debugging. . added Control.isDisplayed: return true if the parent of this Control is added to somewhere. Some controls, like the TabPanel, has n containers, but only one is displayed at a time. With this method, the Control can inspect if your container is the one available. . new method Graphics.setColors: sets both fore and background colors, taking as parameter a Color. . corrected visual of round border Windows. . class TabPanel now is redesigned. new method SetType to set the tab position: TAB_TOP or TAB_BOTTOM. Now the default gaps are 1,1,1,1 instead of 0,0,0,0. . new methods Rect.modify to resize the rect; x2() returns x+width-1; y2() returns y+height-1 . removed IKeys.CONTRAST. since theres a form, the contrast dialog (and the other system dialogs) dont crash SW. . removed Window(String title, boolean border) that was deprecated since 1.12 . trapped another unknown error. in this error, the obj was greater than 65535. happened when the Keyboard class was set to doubleBuffer and it was poped up. . new type for Edit: PASSWORD. in this type, only the last char is displayed. all the others are displayed as *. Thanks to Pablo Lopez-Jamar for the idea. . now when the Edit mode is CURRENCY and the popup keyboard is invoked, a Calculator is displayed. Taked from VPFinance. . changed getClientRect to return the rect in relative coords, not in absolute coords. corrected if border but no title . corrected PushButtonGroup getPreferredWidth and getPreferredHeight. . currected Hashtable.getKeys. thanks to David gecawich . new method Window.getOffScreen. used to return the image that the double buffer uses. . new method Graphics.getTranslation to return the current translate. Comments and bugs (i have no time to correct those now) . Note that the foreColor and backColor implementation is to prepare for COLOR support. all disabled colors are based on the control's back and fore colors; they are relative, not fixed. . although a java int has 32 bits, please dont use graphical coordinates greater than a signed 16 bits integer (< -32767 or > 32768). if you do so, strange things can happen... . i tested almost 90% of all double and long bytecodes, but some opcodes were not tested (did not found how to test them). . note that all controls changed its sizes, so youll need to fix some thing when porting old apps. . DONT TRY TO RUN SUPERWABA 2.0 BETA 1 IN A COLOR DEVICE: IT WILL CRASH! . Convert.formatDouble still doesnt recognizes exp term. . If you want to use superwaba 2 with your old code, you must recompile your sources and generate the pdb and prc files. the old prc file wont work with sw 2.0 (ps: this is not a bug!) . since the vm is now multi-segmented, its harder to compile (and theres no time to write a how to now) . to make support for double and longs, the vm is now consumming more memory. so, you may have to change the memory params to make your app work. also, since grayscale requires more memory, i'm sure i may have to break the 64k object memory heap sonner than i thinked. . the welcome app is taking about 20k of the pdb files. until the final release, i'll strip out all the extra stuff putted there. its here now only to demonstrate the new features. . i found a very interesting and strange behaviour. in my palm iiie, when i draw vertical or horizontal lines under a BRIGHT background, some ghost lines appear. then, if i draw a WHITE line where the ghost lines appers, they disappear! i hope this will only happen in IIIe devices but, if it happen, you can easily use this trick. In Professional, III and V this dont happens. . need to make the statePosition work. . the Graphics.copyRect is VERY slow. i need to convert it to assembler. note also that since the offscreen windows uses that method, its popup is very sloooooooooow. :-) Future Enhancements . implementation of the changes in the serial class (irda) by Matthias Ringwald. i didnt did this yet bc it needs to convert the whole project to 3.5. but i'll do it in next release. . virtual screen support . appletviewer support and, who knows, wince port (anyone wants to do it?) . use of Image.loadFrom(byte []) and byte []saveTo() to save/load Images (bitmaps). in the loadFrom you pass an array containing a normal bmp file type. saveTo returns a new bmp file format with the image. were there any other use for the old setPixels that i did not know? . implement the grayscale version of the caps lock and command indicators. . Color support . User defined fonts . automatic dithering or color images to grayscale. currently, the thresshold + color luminance method is used . faster drawBitmap . dinamyc load of native methods, thus reducing vm size . Edit class optimization. . Child windows . drawed focus (the dotted rect around the current focused control) . change invPixelNOCT and erasePixelNOCT to invVLineNOCT and eraseVLineNOCT to improve performance . IR send/receive. . command line arguments for methodshash. . moveable popup/child windows. . scrollable container. . use of the default popup keyboard (is this a good idea?) . Oh my God! when will I have time to SuperWabaJump?