Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro and Mappy in VS2022

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Allegro and Mappy in VS2022
agonvs
Member #15,917
March 2015

Hi All,

I'm trying to get Mappy to compile with Allegro 5.2.xx in Visual Studio 2022 using Nuget to install Allegro. Anybody have any luck getting these softs to cooperate?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

agonvs
Member #15,917
March 2015

I tried the single file route. I keep getting a bunch of errors.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

agonvs
Member #15,917
March 2015

Any idea how I can compile it as C in VS?

GullRaDriel
Member #3,861
September 2003
avatar

Well, tell us more about your errors ? Like a compile log as an attachment ?

Maybe you'll have to dig into mappy's source, and check if there are the required 'extern C { }' blocks around the declarations in the headers ?

I really don't see how it would not compile C if it's correctly written.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

agonvs
Member #15,917
March 2015

Build started...
1>------ Build started: Project: Project5, Configuration: Debug x64 ------
1>mappy_A5.c
1>C:\Allegro\mappy_A5.c(120,26): warning C4311: 'type cast': pointer truncation from 'unsigned char *' to 'int'
1>C:\Allegro\mappy_A5.c(126,27): warning C4311: 'type cast': pointer truncation from 'unsigned char *' to 'int'
1>C:\Allegro\mappy_A5.c(809,58): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(811,55): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(815,62): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(832,59): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(834,56): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(895,52): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(897,53): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(899,53): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(901,23): warning C4311: 'type cast': pointer truncation from 'ALLEGRO_BITMAP *' to 'int'
1>C:\Allegro\mappy_A5.c(921,53): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(923,54): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(925,54): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(926,24): warning C4311: 'type cast': pointer truncation from 'ALLEGRO_BITMAP *' to 'int'
1>C:\Allegro\mappy_A5.c(1014,59): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1015,59): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1016,60): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1018,60): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1020,22): warning C4311: 'type cast': pointer truncation from 'ALLEGRO_BITMAP *' to 'int'
1>C:\Allegro\mappy_A5.c(1025,63): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1032,64): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1220,23): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
1>C:\Allegro\mappy_A5.c(1525,35): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\Allegro\mappy_A5.c(1820,59): error C2065: 'BITMAP': undeclared identifier
1>C:\Allegro\mappy_A5.c(1820,60): error C2059: syntax error: ')'
1>C:\Allegro\mappy_A5.c(1847,26): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
1>C:\Allegro\mappy_A5.c(1885,40): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1885,33): error C2106: '=': left operand must be l-value
1>C:\Allegro\mappy_A5.c(1887,41): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1887,34): error C2106: '=': left operand must be l-value
1>C:\Allegro\mappy_A5.c(1889,42): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1889,34): error C2106: '=': left operand must be l-value
1>C:\Allegro\mappy_A5.c(1891,42): warning C4312: 'type cast': conversion from 'long' to 'ALLEGRO_BITMAP *' of greater size
1>C:\Allegro\mappy_A5.c(1891,34): error C2106: '=': left operand must be l-value
1>Done building project "Project5.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Dizzy Egg
Member #10,824
March 2009
avatar

Seems like a problem between x86 and x64 - have you tried building your project for 32-bit instead of 64-bit?

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

agonvs
Member #15,917
March 2015

OK, I tried compiling under 32-bit. Here's what I get:

Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "BITMAP" is undefined Project8 C:\Allegro\mappy_A5.c 1821
Severity Code Description Project File Line Suppression State
Error (active) E0029 expected an expression Project8 C:\Allegro\mappy_A5.c 1821
Severity Code Description Project File Line Suppression State
Error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. Project8 C:\Allegro\mappy_A5.c 1526
Severity Code Description Project File Line Suppression State
Error C2065 'BITMAP': undeclared identifier Project8 C:\Allegro\mappy_A5.c 1821
Severity Code Description Project File Line Suppression State
Error C2059 syntax error: ')' Project8 C:\Allegro\mappy_A5.c 1821

Dizzy Egg
Member #10,824
March 2009
avatar

I managed to get it to compile in Visual Studio using the attached file (had to make some small changes), and had to add ;_CRT_SECURE_NO_WARNINGS to the project preprocessor definitions (Properties->Configuration Properties->C/C++/).

I had to change BITMAP* to ALLEGRO_BITMAP* (only one instance of that) some other bits, but it should now compile and work ok.

Try replacing your mappy_A5.c with the one I have attached, and rebuild your solution (after adding the _CRT_SECURE_NO_WARNINGS) and it should be ok...

[EDIT:]

Also, if you want to build and run the example, you'll have to manually cast (char*) for the SetMap arguments, ie:

SetMap((char*)"test8bpp.fmp", (char*)"mappy demo 1 8bpp map animated", FALSE, FALSE))

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

agonvs
Member #15,917
March 2015

Well, it compiles and runs, but then quits with a divide by zero error...

Dizzy Egg
Member #10,824
March 2009
avatar

If you right-click your project in solution explorer (not the solution, but the project!) and select properties, you should be able to find it here:

{"name":"Wxzupf.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/2\/12c992caef535797c0ceb026bebe63f3.png","w":788,"h":519,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/2\/12c992caef535797c0ceb026bebe63f3"}Wxzupf.png

[EDIT]
Nevermind, you found them!!

[EDIT]
You will need to be more specific; where does it stop with a divide by zero error? I have the demo running without error, so you'll need to explain at what point it stops with the error....

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

agonvs
Member #15,917
March 2015

See the attachment.

Dizzy Egg
Member #10,824
March 2009
avatar

I think I'd need to see your own code where you load/draw the map to figure out why that is happening.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

agonvs
Member #15,917
March 2015

Here it is

Dizzy Egg
Member #10,824
March 2009
avatar

The problem is you're not loading your map before drawing it; MapLoad returns "0" on success, so change your MapLoad to this (lose the !):

if (MapLoad((char*)"myMap.FMP", 1)) //If MapLoad returns a value, exit
    return -5;

If you are running from debugger, make sure you put "myMap.FMP" in the same folder as your project, not in the Project->Debug folder (because VS will run the debugger from the project folder, even though it builds the exe in the Debug folder).

You can make it more readable by changing it to this also:

if (MapLoad((char*)"myMap.FMP", 1) != 0) //If MapLoad returns a value, exit
    return -5;

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It seems mappy for a5 is no longer available. At least I couldn't find it. I downloaded mappy_a5.h from someone's game repo and am using DizzyEgg's modified mappy_a5.c file.

Is there still a website for mappy with A5? The thread that tells about only points to a website with allegro 4 version of mappy.

Dizzy Egg
Member #10,824
March 2009
avatar

I don't think there's a site hosting it; I grabbed it from the Mappy.zip attachment on this post:

Mappy Thread

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

agonvs
Member #15,917
March 2015

YAAAY! It worked! Thank you so much for your help. Mappy can be found here: https://www.tilemap.co.uk/mappy.php

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Thanks DizzyEgg, I didn't see the attachments on that thread. Sadly version A5 is not on that website agonvs, at least I can't find it.

Hey agonvs, can you upload your mappy.fmp map so I can try your code? I want to play around with mappy a little bit.

Dizzy Egg
Member #10,824
March 2009
avatar

agonvs said:

YAAAY! It worked! Thank you so much for your help

You're welcome, we got there in the end 8-)

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Peter Hull
Member #1,136
March 2001

I got it from http://fixbyproximity.com/2011/11/28/2d-game-dev-part-11-2-tile-backgrounds-with-mappy/ but it didn't compile for me without a few tweaks. Maybe we should make a 'definitive version' and put in on Allegro's wiki or somewhere.

agonvs
Member #15,917
March 2015

Here you go. Enjoy!

Dizzy Egg
Member #10,824
March 2009
avatar

Maybe we should make a 'definitive version' and put in on Allegro's wiki or somewhere.

That sounds like a plan, would be useful to have a working version that A5 users can easily find.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

 1   2 


Go to: