LG KS 360

Version Française

My brand new toy is... programmable!

A real little computer!

Programmable en PASCAL?

Go to Nabster's WEB page, another MidletPascal programmer. You'll find several softs to download on your mobile phone! (in french, with project sources).

With the kit MidletPASCAL 2.02, you can create JAVA applications without writting in JAVA. Just write your code in PASCAL and it outputs your JAR and JAD files to be loaded into the phone for using your application.
To RUN your code you'll need the Phone emulator integrated into the WTK from SUN and downloadable here!

The MidletPascal environment

The title's screen of my Master Mind
Example with the Master Mind

I wrote a little application, and here is the whole project to be downloaded: A complete project as I used graphic instructions, the keyboard and command access, load and display images.

Read the source code.

The game board.
Programmable in BASIC?

After some research on the Net, I came accross this site about the CellularBASIC. It is a complete BASIC interpreter written in JAVA. Knowing nothing in JAVA, I had a hard time making some changes in it because some problems were to be solved:
At last, here is the starting screen of the CellularBASIC with my modifications!
A complete menu that allows you to edit, save, load and, of course, run programs!
A view of the editor. On this cellular, the keyboard is really a great thing when programming!

One could regret that some symbols are hard to find (=, ", parenthesis).

Else, you can prepare the source on the PC and copy it to the MicroSD card in the ZAM folder with *.ZAM extension as a text file. It will be loaded with no problem.

The source editor included into the CellularBASIC has problems with the LG KS as it seems that the size of the edition can't exceed 512 bytes! I solved the problem writting my own editor with the MidletPascal (see below).

An example of program:
sub main
FOR I = 1 TO 50
X = INT(RND * width)
Y = INT(RND * height)
R = INT(RND * 50)
if R < 17 then
end if
end sub

The well known 8 queens problem
Clic to get the source code.
sub main
q=0 : i=0 : sol=0
cls : print "Recherche..."

while i<>-2
   if q=9 then
      call dessin
   end if
while i=-1
   if q<9 then
      s(q)=q+r(q) : d(q)=q-r(q)
      i=1 : p=q
      while i<p
         if r(i)=r(p) or s(i)=s(p) or d(i)=d(p) then
            i=-1 : p=-1

92 solutions founds and displayed in 264 secondes
(screen says 311 sec with a previous version).
         end if
   end if
   if i=-1 then
      while p=1
         if r(q)<8 then p=0
         else q=q-1
            if q=0 then p=0 end if
         end if
      if q=0 then
      end if
   end if
end sub
sub dessin
   cls : sol=sol+1
   x=(width-160)/2 : y=(height-160)/2
   color(255,0,0) : filloff : box(x-1,y-1,162,162)
   color(200,200,200) : fillon : box(x,y,160,160)
   color(120,0,0) : c=0
   for k=x to x+140 step 20
      for j=y to y+140 step 20
      	 if c=0 then
         end if
      next j
   next k
   color(0,0,255) : x=x-10 : y=y-10
   for k=1 to 8
   next k
   clt : print sol
   print int((timemilli-t)/100)/10
end sub

What I added:

This BASIC don't have the INKEY$ instruction! I've been unable to add one in spite of my researches on the Canvas in Java. If someone could do it...

The adaptations to be done

If all of this looks a bit hard to you, feel free to contact me for a ready-to-use package.

Of course, you need a JAVA development kit... I took the SUN JAVA Wireless Toolkit for CLDC 2.5, freely available on the site of SUN Microsystems.

On the downlaod page of the CellularBASIC, download the examples cellularbasic.10.ex.zip, unzip them and copy them to your MicroSD card in the ZAM folder. (If you don't have one, copy them to the internal memory in a ZAM folder).

On the downlaod page of the CellularBASIC, download the sources cellularbasic.10.wtk.zip and make those changes in the file CellularBASIC.java: Then the calls to LOAD and SAVE will be redirected to your MicroSD card (or internal memory).

In the WTK 2.5, use "Project"/"Package"/"Create package" to recreate the new JAD and JAR files.

Finally, edit CellularBASIC.JAD and add this line: Then copy the JAR/JAD files to your phone and install them!

My editor MPedit

To bypass the limitations of the CellularBASIC editor, I wrote mine with MidletPASCAL. It is similar to TextEditor, a russian program that was really slow with all the confirmations needed to access the files:
The source code appears, you can navigate through it and, when you press EDIT, you enter into an edit box with the 6 current lines. This bloc can be deleted, modified, appended and when you press ACCEPT, it is inserted in the source.

Navigation in the source code

Edition of a bloc
You can doanwload MPedit. The zip contains:
  • MidletPASCAL source code (folder SRC)
  • Executable code JAR/JAD for the LG KS360 (folder BIN)
  • Source code for the JAVA library to access files (because MPascal doesn't do it alone)
  • The library "class" file to be put in the LIB folder of the MidletPASCAL
By default, access is in the MicroSD, ZAM folder. You can modify the source to match your settings or wait for my future "Default path" extension in the editor itself.

15 décembre 2007