I present to you the open source IDE MIDlet Pascal 3.0 beta 2, which allows you to write applications Midp1.0-2.0 on Pascal in a similar language.
On Habré already there are two articles, but one about the still paid version, and the second is unsuccessful. Articles I found after writing this.
So MIDlet Pascal 3.0 is a direct descendant of
MIDlet Pascal 2 by Nikša Orlić. After version 2.02, the author of the program stopped working on improving Midlet Pascal. However, he said that he agreed to transfer the source code to any person to continue development, who is familiar with Java and C ++ (on which Midlet Pascal is written), with the proviso that the project will become open source and will develop. In September 2009, the source code of MIDletPascal was transferred to the Russian-language team
boolean.nameSo, we need the latest current version with
SourceForge .
If you need to take the necessary
libraries here , you need to put them in% MIDlet Pascal dir% / Libs. As a rule, with each library there is a% LibName% .txt file with a list of functions and brief help on them.
You will also need any of the java emulators. I use
sjboy and
kemulator (unfortunately I didn’t find the official page of this emulator, so the link leads to the first file dump found).
')
Attention when installing antiviruses can swear on some components (for example, my Dr.Web swore).
Some versions of anti-virus programs (Norton, McAfee, ...) report any program written in MidletPascal, like the “Trojan.Redbrowser.A” virus.
This is because the RedBrowser Trojan was written using MidletPascal, which secretly sends out SMS messages.
In version 3.0, it is planned to change the code of one of the classes to make it different from previous programs and eliminate the false positives of the McAfee antivirus. Users of the current version are encouraged to encrypt the finished program with some obfuscator, for example, JSink.
therefore, before installing, add the installation path to your anti-virus exceptions.
So we have:
MIDlet Pascal;
A great desire to write something;
Some free time.
Since I am a happy owner of an old Nokia N70, I naturally write to it and the toy is designed for a resolution of 176x208.
Launch MIDlet Pascal and welcomes us to the main window.

Create a new project File> New> Project call and specify the folder where it will be stored, the name should consist of Latin characters, otherwise the phone will swear at the wrong file format, but emulators digest perfectly.
In the Project Managere section in the configuration section we set our type of midlet, in our case Midp2.0 fullscreen.
attention, do not try to edit project properties in Project Manager

pressing delete (this is not the case with the backspace;)) deletes the characters not from these fields but from the place where the cursor is in the editor window, besides data from these fields is still not saved, to change them open the project file% project dir % /% project name% .mpproj with any text editor and edit at your pleasure.
We draw all the resources we need, to create resources, I used a free
artweaver interface similar to the good old Photoshop .
I got the following.

All links to the project are added via Project Manager> resource> add and saved in the% project dir% / res folder. If you use several configurations (for example, for different screen resolutions), then you can match all the resources of the desired configuration.
Well, it remains to write the program code itself.
Let's see what the MIDlet Pascal actually offers us in terms of language:
10 simple types
boolean
char
integer
real
string
http
resource
image
recordStore
command
2 integrated
record
array
conditions
if ... then ...
logical operations
and
or
xor
not
cycles
for … to … do (downto)
while … do
repeat … until
yes, case unfortunately not, I hope that for now
Well, actually, everything you need is available.
Create a loop in the main module that will track keystrokes
program tag;
function ProcessUserInput(AKeyCode : integer): boolean;
begin
//
ProcessUserInput := AKeyCode <> KE_KEY0;// 0
end;
begin
repeat
//
until not ProcessUserInput(GetKeyPressed);
end.
Now we create everything through the same Project Manager separate unit and describe our buttons.
In the listing, of course, not all functions are given.
unit Button;
interface
type
TButton = record
img : image;
pos,num : integer;
end;
...
procedure Paint(AButton : TButton; pos : integer);
procedure Init(AButton : TButton; ImgNumber : integer);
...
implementation
var
bImg: image;
procedure Init(AButton : TButton; ImgNumber : integer);
begin
AButton.img := LoadImage('/' + IntegerToString(ImgNumber) + '.png');
AButton.num := ImgNumber;
end;
procedure Paint(AButton : TButton; pos: integer);
begin
AButton.pos := pos;
DrawImage(bImg,PosToX(pos),PosToY(pos));
DrawImage(AButton.img,PosToX(pos),PosToY(pos));
end;
initialization
bImg := LoadImage('/back.png');//
end.
by the same principle, we implement everything else, if possible, grouping similar code into one module.
Now, about drawing the image, after placing any element on the screen, you need to call it updated by the repaint procedure.
here is the implementation of Hello World, the procedure drawText (text, x, y) will put the text on the screen at the given coordinates.
Program HelloWorld;
Begin
drawText('Hello, world!', 5 ,5);
repaint;
delay(5000);
end.
If you want to display two labels, then repaint should be used at the very end to draw everything.
Program HelloWorld;
Begin
drawText('Hello, world!', 5 ,5);
drawText('And again!', 5 ,15);
repaint;
delay(5000);
end.
So, as a repaint is quite a resource-intensive procedure, it is recommended to call it when you really need to redraw the screen.
About optimization.
If your code operates on any variables, it is recommended to use global ones, since local variables in procedures and functions consume significantly more resources.
but back to our game, I got the following.
The game can:
generate a random playing field
save and load the playing field
voice acting
ability to save settings
everything else can be implemented by yourself, space for optimization in the code of the sea;)
linksGame sourcesSelection of libraries (including those necessary for compiling the game)
The Pascal MIDlet page on SourceForgeRussian community MIDlet PascalMIDlet Pascal Help