Author Topic: Dr. Mario  (Read 7169 times)

0 Members and 2 Guests are viewing this topic.

Brian Alvarez

  • Guest
Dr. Mario
« on: August 03, 2019, 01:56:17 AM »
 This is not a commercial game. It is not intended for sale.
This is only a programming excersize.

 Since DIR$ is still not working for 64 bit compilations, this code
works only for 32 bit for now.

 Due to the size of the resources... i cannot post them. The forum
says max 20000kb, and individual file size 15000kb... but it rejected
my 3.8mb RES file. If this is fixed i can post it, along with a copy of
the compiled program for oxygen and for PowerBASIC (same code
compiles fine for both).


Brian Alvarez

  • Guest
Re: Dr. Mario
« Reply #1 on: August 03, 2019, 02:03:46 AM »

 Notes about this code... it is definately not for the faint of heart. It contains cryptic code
due to it being a conversion. 

 The PluriBASIC code is very transparent, and easy to understand. So far Oxygen can handle most
of what i throw at it. :)

Arnold

  • Guest
Re: Dr. Mario
« Reply #2 on: August 03, 2019, 07:17:10 AM »
Hi Brian,

the sceenshots look very nice, and the code is very interesting in several aspects. Did you try to upload the .res file as a zip file? If I recall this correctly it worked for me in the past. But I was a beginner at that time and I suppose I exaggerated a little bit unknowingly.

I wonder why you prototyped ¤GetModuleHandle but use GetModuleHandle in several places of the code? This will allow compiling to an exe file, but running the code within the editor applying Oxygen.dll will result in an error message.

Regarding 32/64 bit: I assume there are several places where sys must be used instead of dword/int (or vice versa?), as pointers are treated differently in these machines. But I have noticed that you already discovered a reason in FindFirstFile.

Roland

Brian Alvarez

  • Guest
Re: Dr. Mario
« Reply #3 on: August 03, 2019, 11:00:39 AM »
Hello Arnold, it is normally a 5.1 MB executable, the resources are 5.0MB, but
can be compressed down to 3.8 MB it cannot go smaller than that because of
already having compressed resources (mp3's).

 I will see if i can post them in parts, so that others can compile the res file. :)

 Regarding the getmodulehandle thing, some parts are generated by PluriBASIC,
and some others are manually entered by me. I normally use GetModuleHandle(0),
but pluribasic most of the times generates the other one.

 What editor are you refering to?

Arnold

  • Guest
Re: Dr. Mario
« Reply #4 on: August 03, 2019, 12:40:51 PM »
I use PSPad where I can add an option to run drmario.o2bas directly with co2.exe. (I have first to comment out the lines $ filename ...; and: uses rtl32). But I can do this also with Oxide.exe in the folder of Oxygenbasic. The option: Compile / Run program directly (F5) runs the program using Oxygen.dll. Compile / Compile and Run Binary32/64 creates and starts the program. This is a cool option, because I can apply: uses name.res in the beginning of the code. Unfortunately my MS Defender puts the exe file in quarantine at the moment and I must get it back.

Brian Alvarez

  • Guest
Re: Dr. Mario (Playable and compilable)
« Reply #5 on: August 03, 2019, 10:00:56 PM »

 I uploaded the code and resources to GitHub:

https://github.com/MrBrianAlvarez/DrMario-Exercise

 There is a playable copy compiled in Oxygen 32bits, I will upload
a PowerBASIC version and a 64bit version compiled with Oxygen.

Arnold

  • Guest
Re: Dr. Mario (Playable and compilable)
« Reply #6 on: August 04, 2019, 02:44:06 AM »
Hi Brian,

this is certainly the most challenging contribution to Oxygenbasic, which is not from Charles. Comparable with it is only Oxyscheme, that should however be adapted to the newest version of O2.

As I never played the game, there is a need to read the rules of DrMario, but by experimenting a little bit I can see that this is a very nice app.

Something is strange though. It is possible to compile the code to a 32-bit exe, link the resource file and start the app. But I noticed that you created a 64-bit exe. When I try to do this on my system, compiling and linking will work but the the dialog will not open and the app blocks the memory. I compared my exe file with yours, it indicates the same size (5386752 / 5390336 Bytes), but something must be different. Did you use the same code for creating the 64-bit exe?

Roland

Brian Alvarez

  • Guest
Re: Dr. Mario (Playable and compilable)
« Reply #7 on: August 04, 2019, 09:19:04 AM »
Hello, Yes it is fairly complex, but not that much. It only took me like a few hours during 2 days (not consecutive) but it was a very good excersize. It also served the purpose of finding bugs in complex code. Surprisingly, i found less bugs than i expected (in my own code) and only 2 in oxygen, which is pretty nice.

 I really onjoyed Dr. mario when i was a kid back in the 90's. Me and my sister used to play for hours (she usually kicked my butt in it). Now that i think of it, it would be a good excersize to convert it into a 2 player game over a TCP connection. But that will have to wait until i complete the TCP functionality.

 The answer to "Did you use the same code for creating the 64-bit exe?" is a YES. and also a NO.

 I used the exact same PluriBASIC code for compiling it to Oxygen32/64 and also to PowerBASIC. No changes required in absolute. But for oxygen the generated 64bit version has some small differences with the 32 bit one. For example, PluriBASIC generates different headers for window class definition, so, no... unfortunately it is not just a matter of changing the rtl32 to rtl64 in the oxygen code. Of course i can post if if you want.

Mike Lobanovsky

  • Guest
Re: Dr. Mario
« Reply #8 on: August 04, 2019, 10:42:54 AM »
Hi Brian,

I'm sorry but your app doesn't work for me under my Windows 7 Ultimate. The app tries to launch for 3 or 4 seconds while the cursor turns to a spinner. But then nothing happens and the app aborts silently without a notice or crash. :-\

Another problem is that if you inspect your o2bas source file in the repo, you'll probably notice that most of your func names start with weird Japanese (?) glyphs instead of symbol/char pair as seen e.g. on this site or in my editors and Notepad... :o

Can the latter be somehow related to the former, do you think?

Brian Alvarez

  • Guest
Re: Dr. Mario
« Reply #9 on: August 04, 2019, 11:36:37 AM »
 Hello Mike,

 That is strange, it was developed under Windows 7 Ultimate. So, the reason must be something else.

 It plays small SFX from resource (they are WAV files), and if the executable doesnt find one
of the mp3 sound effects, it tries to create the files from resource. I think that is what is taking a little
while at the beggining.

 In a moment, I will upload a PowerBASIC version of the executable, please check if that makes a
difference. If it does make a difference, then probably i (or charles) have some debugging to do.

 :)

Brian Alvarez

  • Guest
Re: Dr. Mario
« Reply #10 on: August 04, 2019, 11:50:28 AM »
 Oh, about the Japanese characters, this is an encoding issue.

 Oxygen allows non-alphanumeric characters in the variable names, as well as in function, subs and other
components of the code. I prepended a special character ¤ to avoid collisions with user code. Nothing to worry
about, but it wont show correctly on a site or notepad.

 If you ran the executable, then I dont think the issues are related. But if you compiled the code manually, then
it all depends on the tools you used. Im not sure. I dont think it should be an issue, but then again, I'm not sure.

 Just to make sure, try the pre-compiled excutables to see if it makes a difference? If it doesnt make a difference
then at least i will have some clues on what to look for...

 A version for PowerBASIC has been uploaded.

 By the way... if the problem persists, please make sure your antivirus is not killing it before it finishes extracting
the files from resources, or if it already did! because if your antivirus didnt allow the executable to finish extracting
the files, they may exist and no more attempts to extract them will be made... but they may be corrupt now.


Arnold

  • Guest
Re: Dr. Mario
« Reply #11 on: August 04, 2019, 12:36:00 PM »
This is indeed curious. After unzipping DrMario-Exercise-master.zip there are no problems with the characters of drmario.o2bas. But if I open the website with the code of drmario.o2bas I get the same result as Mike. Until now I did not see this different character representation of source code file and html.

But the app runs very nice on my system, as well compiled to 32-bit and also the provided 64-bit version.


Brian Alvarez

  • Guest
Re: Dr. Mario
« Reply #12 on: August 04, 2019, 02:05:31 PM »
What OS are you running Arnold?

Arnold

  • Guest
Re: Dr. Mario
« Reply #13 on: August 04, 2019, 02:29:09 PM »
I assume it is Windows 10 Home. If I run cmd, the console indicates: Microsoft Windows [Version 10.0.17134.885]

Charles Pegge

  • Guest
Re: Dr. Mario
« Reply #14 on: August 04, 2019, 02:50:34 PM »
o2 reserves ascii codes 127 and 248-255 for internal use. Ascii codes 128-247 have the same status as alpha characters.

Customised use of ! # $ % & ? in a word (except for the first character) is also possible:

Code: [Select]
string c$&$="abc"
print c$&$