JVERGE: what is it?

JVerge is an attempt to bring all the Verge engine into Java. All the C-dependent code was removed and changed by a Java counterpart. 
That means all video/sound/music/keyboard/mouse code. The VC library code was adapted as needed (rect/circle/triangle/blit/etc), and some functions wasn't implemented, specially the File, Socket, Movie playback and Window functions.
JVerge has some new features: wrapable maps, as described in another topic, and the ability to play VGM/VGZ files (from Sega Master System, Genesis and other consoles).
JVerge does NOT parse VC or LUA scripts. It's more like a Java API, so you write code in Java and use JVerge functionality.  
Java is multiplataform, so I hope JVerge runs ok in any Windows, Mac, Linux and other systems with a Java Virtual Machine (JVM). In the future, maybe it could be possible to adapt it to Android and other similar platforms.

I have implemented three demos to show JVerge working:
- Phantasy Star remake: I've converted just a small portion of my original Verge PS remake, because I plan to come back later and actually finish this project. It's a common FF/PS-like game, with a top view and 2D chars walking in the map. It's using a 480x320 resolution, same as Ipad, I think.  
- Alex Kidd: It's here to show that Verge is not just about RPGs. Alex Kidd was a popular 2D platform game in Sega Master System. I've added my own levels and plan to extend it later. 
- Sully Chronicles: Well, converting Sully was very useful to fix a lot of errors, misconceptions and buggy code in my JVerge engine conversion. Now the engine is way more stable. But I've performed a direct conversion - that was faster than rewriting the Sully code to the Java paradigm.

I've packed them in .JAR executable jars (just run java -jar X.jar). It's also possible and recommended to developers to use an IDE like Eclipse or Netbeans, place the project there and see the source code running smoothly, understand it better, etc.
They are also separate projects/GIT repositories. For developers: Ak, Ps and Sully are dependent of JVerge. If you just want to experiment the demos, there are a 'redist' folder in each project with an executable JAR. 

https://github.com/rafael-esper/JVerge	
https://github.com/rafael-esper/Ak	
https://github.com/rafael-esper/Sully	
https://github.com/rafael-esper/PS	


JVERGE: The Future

In a next release, I plan to change the JVerge code into something more OO, like placing the methods inside the domain classes, e.g., printstring inside VFont, rect/circle/blit/etc inside VImage, playmusic inside VMusic, and so on.  
There are some unimplemented functions, possible bugs, and interesting things to do. 
If someone is interested in the project, I'd be happy to help extending JVerge to whatever we can think of.
If nobody cares about it, I'm going to concentrate my efforts in my Phantasy Star remake, and I'd be happy doing so.

NOTES ON SULLY CONVERSION
My initial goal was to show that the main tech demo would work properly with the Java engine, but now it is an example of a mindless bad programming practice: lots of static and public methods and properties, lots of static imports, and a general disoriented object programming.

- Some variables were converted to boolean. In Java you can't do: "while(count)", if count is an int. Need to change to "while(count !=0)"
- Add "break" clause after each "case" in the "switch" clause (unlike VC).
- A lot of methods and properties were changed to static. This is so anti-OO. :-(
- There is no script code being interpreted, it's just Java code. So the map() function can't just stop the remaining code to run. 
- In order to implement the Sully introduction (that can be escaped anytime with Esc), I've opted to create a Java thread and use the ugly and deprecated method stop. I could have done this in a more elegant way, but the code would be changed a lot more.  
- Java imports are different from C includes. So in order to call a function of an outer file, that would be normally included in C, I had to add the full path (like "a.b.function) to the callfunction method.
- Unlike VC, Java is case-sensitive. A lot of calls were changed because of this.
- As SetClip is not yet implemented, I've changed a little the textbox behavior to produce the same effects.
- The "|" text delimiter was changed to "&", because "|" has another meaning to regex String function. Needed to change this in all Menus and Shops. 
- I've performed some changes in the simpletype_rpg package, creating the structs (in Java, classes) in the corresponding classes. Not enough to be really OO, though.
- Reimplemented the data_load with Java File API. Not very hard to convert (just text files). But the token separator was changed to a tab ("\t"), and just ONE tab in the .dat files. 
- Data_load strcmp was different from expected, so changed !strcmp to strcmp and vice-versa
- The item "Cap" is just three letters long, so was interpreted as junk, because of MIN_LINE_LENGTH. Changed to LongCap.
- I've changed some MenuOff() and MenuOn() calls to EntStart() and EntFinish(), because somehow, the player wasn't stopped in the dramatic scenes, shops, etc.
- There were some bugs in the original code, like accessing a -1 index in an array in the AddPlayerI() function. Those bugs become evident in the Java code, as it's not allowed.
- There were some strange TextBox without the comma (like TextBox(PORTRAIT, "a" "b", "c"); How these were working?!
- Load/Saving works fine outside the executable Jars (like in Eclipse or just running java directly). But when packing the code in a .JAR, I wasn't able to deal with saving files externally to the JAR, but loading files works fine. I'm thinking about a solution to this problem.  
- I had a lot of problems with case-sensitive stuff (because JAR files are case-sensitive). 
- There were some unused variables.
- I see that there is another version of Sully somewhere, judging by screenshots. Is the code available?


IMMEDIATE TODO (SECOND RELEASE)
(X) Add windows menus (like Fusion)
(X) Try to optimize video drawing
( ) Check VGM loops (right now they aren't looping)
( ) VGMs don't play, just VGZ.
- Implement key mapping (b1,b2,b3,b4)
- Make it more OO (less static methods, no public properties, no static imports)
- Music/Map/CHR/Vsp caching
- Implement music volume
- Investigate why sometimes the transparency stops working (when swapping window/full screen)
(SOLVED!) Investigate following entity spawning far from the player (related to wrappable maps)
(SOLVED!) Investigate why wander entities change facing while walking (OK, it occurs also in V3/Sully)

TODO
- Fix: Thread.stop does not work on n-Core CPU -> Refactor!
- Sully Load-Save in suplementary folder (see http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file)
- Sully: Try to save a file in the classpath './', in order to solve .sav problem (externally to the Jar)
- Sully: FIX CustomColorFilter when running Sarah Flashback in Oldville
- Sully: FIX Sparkles
- FIX: Entities' movement get screwed after talking to them
- Add logging capabilities (instead of system.out/err)
- Implement WrapBlit, TWrapBlit
- Verify ColorFilter, Implement Rotate, Flip, etc (See Graphics2d Rotate, Scale, etc)
- Implement AlphaBlit (http://verge-rpg.com/docs/the-verge-3-manual/graphics-functions/alphablit/)
- Implement TODO functions in Script
- Check if Script unused functions work properly
- Document code with Javadoc (get from V3 Manual) 
- See Generic way to implement graphics API (in order to extend it to Android, IPad, etc)

WON'T DO TODOs
- Socket implementation
- Movie playback implementation
- File functions implementation
- Window functions implementation
- Joysticks
- Create VC parser (parser or JIT Compiler?)
- Create LUA parser (parser or JIT Compiler?)
- See 3D API with fixed-z (~2D) to enable Video optimization
