Sign in to follow this  
Guest

Adventures into MASM

Recommended Posts

Greatings,Finaly I got some corage (although not a lot of time) to experiment MASM to compile scenery.I constructed a model in GMAX which successfully appears in the FS2002 world. But what I realy miss is the possibility of editing the object

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

When I edit my asm files made by GMax, I just compile them with BGLC (the version that came with the effects SDK). That works and you don't need to work with all those include files etc etc.ArnoMember NL2000 Teamhttp://home.wanadoo.nl/arno.gerretsen

Share this post


Link to post
Share on other sites

Hi all.In fact, BGLC is 'drag'n'drop' in nature. From the desktop or explorer, just drag the ASM file over the BGLC icon, drop it, and get a BGL file. Very easy.Also, new ASM macros may be referenced by the 'include filename.inc' command at the top of the ASM text, making BGLC as extensible as MASM itself.Christian Stock has been experimenting with MASM and BGLC, and has developed new macros to create some types of TMF-style flatten and hydro polygons for FS2002.

Share this post


Link to post
Share on other sites

Hi Arno,Thanks for your quick reply!I was using the FS2000 bglc! I didn't remember that a new BGLC was included in the effects SDK!Now it all works!ThanksjmfPS - Now is back to understand what is all this code about!!!

Share this post


Link to post
Share on other sites

Hi there!Any clues on to how to code new macros? I guess that this is to be coded using Microsoft assembler but what confuses me is what has this to do with MSFS scenery engine? What is the approach here? My guess is that BGL macros correspond to certain commands that are coded into the MSFS engine. So what is the nature of these new macros? Is it just a combination of existing macros? Is there any more detailed information about this new (at least for me) language or any tutorial?If it is possible at all what is the approach to understanding all this!CheersjmfThanksjmf

Share this post


Link to post
Share on other sites

I just finished getting comfortable at a beginner level with scasm...then here comes this new language! LOLI'd enjoy finding a good resourse for teaching this bglc language also, so if you run into any good teachings or writings, please let me know.Bob Bernstein

Share this post


Link to post
Share on other sites

Basically the commands are similiar to SCASM, only the names are different. Most parameters given to the commands are the same, etc.But I am also still figuring out how to use them all in BGLC :).ArnoMember NL2000 Teamhttp://home.wanadoo.nl/arno.gerretsen

Share this post


Link to post
Share on other sites

I haven't recognized the lables and how to construct the logic of order of the commands yet. stuff like variable initializing, syntax in commands....I can see some basic familier notions, but its not enough for me to feel comfortable.B

Share this post


Link to post
Share on other sites

Bob,The way I am doing is to model something very simple in gMAX and compile it to BGL but keeping the intermediate asm files. Do the same in FSDS and generate scasm. Then compare both. Most of the SCASM commands may be translated into MASM but as you say the mechanics of it is a bit different. Also the fact of not having the coordinates in LAT LON or meters in meters (not sure about the last one! ) makes life a bit more dificult (well very difficult).Finaly, there is a plugin that allows exporting a FSDS object to dxf. Then you can import it in GMAX. Generate the respective codes (ASM & SCASM) and compare!Hope this helpsjmfPS: It seems that it is not only MASM we need to learn! It is gmax as well! It seams pretty powerfull.

Share this post


Link to post
Share on other sites

If you download my Ryans Creek aerodrome you'll find a small utility called txt2asm. With that you can use real coordinates like this LAT32_E172:22:14.5, run it through txt2asm and then through BGLC. Very handy...Cheers, Christian

Share this post


Link to post
Share on other sites

MASM is the tool from M$ to write programs in assembly code (not what we want though). It has a 'data' and 'code' section. Since we don't want to write any 'code', we only use the 'data' section.The data section works like this:You can basically write out variables in this section (eg into your bgl file). You do this like this:dd 50 , writes a INT32 (4byte int) into the bgl.there are different variables: db (1byte), dw (2bytes), dd (4bytes), df (float). They are shorts, eg dd = DWORD, etc. There is a manual that comes with MASM. Read my MASM howto to find the link to download MASM. one of the packages (the visual studio processor pack) includes a reference manual for masm.You probably have seen how these variables get used in the header section.Now on to macros: in the include files you'll find some macros like:macro whatever arg1, arg2dd arg1dd arg2end macroso if you want to put this into your code:dd 20dd 50you might as well write:whatever 20, 50you can build much more complex macros using other macros and labels, even 'if' commands etc, but these basics should get you going. Have a look in the include files how microsoft did it, you can learn a lot there.Now the neat thing is, because all MASM does is write dd, db, etc variables, we can write our own macros and add macros for all the missing stuff, like I started for the terrain bgls. Even if microsoft would abandon the bgl code and do something completely different, we can again write our own macros and produce the corresponding scenery files...btw, no tutorial, I figured all this out by myself!Cheers, Christian

Share this post


Link to post
Share on other sites

Thanks very much christian,I will follow your sugestions! It seems a bit confusing but at least I know it can be done!I guess that I might be thinking about this in a diferent perspective. This is low level programming! I am not that used to that! My dificulties are in understanding how these bunch of dd, dw or db result in scenery being dsplayed. I will get there .... ;)Thanks for your explanation!jmf

Share this post


Link to post
Share on other sites

Greatings again,I think I will be around for a while now! :)Here is the question! I noticed that the code generated by GMAX (or better, by the plugin) is not very compact. If you are not carefull during the design you end up with a lot more polygons than it's realy necessary. Also I am not sure how to remove non visible poligons. But that is another matter.It would be very usefull if MS issued guidelines and tips in how to use gmax to produce efficient designs in the so expected fs2002 scenery SDK. I am sure that you can't port all the features of gmax into MSFS engine.The other dificulty is my aparent inability of controlling the scale of my design. If for example I want to use 125mm scalling (ie, 8 units for each metre) how do I set it up in gmax? I would like to speed up things by using the equivalent of ScaleX in MASM and I am not convinced that the plugin is optimizing the object for speed!The other thing I would like to know is how to separate the various components of an object? Perhaps a part of an object is repeated over and over and in SCASM I had the chance to define that once and use transformcalls to reproduce as many as I wanted without filling up a BGL with unecessary points. The code produced by gmax is just a compact list of vertexes and draw_tri. I don't even know what belongs to what! The only imediate solution is to select each part individually and export each one separately and then assemble everything manualy in MASM.Some suggestions please!!

Share this post


Link to post
Share on other sites

>Here is the question! I noticed that the code generated by >GMAX (or better, by the plugin) is not very compact. If you >are not carefull during the design you end up with a lot >more polygons than it's realy necessary. Also I am not sure >how to remove non visible poligons. But that is another >matter.I always remove the polygons that are not visible in GMax, just select the polygon you don't want and delete it. Then there are only polygons in the code that you want.And about the code, I think it is very compact. All vertices are collected in one list and then all the polygons are drawn (all the triangles actually, as all polygons are split up in triangles, this make it faster to process by the scenery engine).>It would be very usefull if MS issued guidelines and tips in >how to use gmax to produce efficient designs in the so >expected fs2002 scenery SDK. I am sure that you can't port >all the features of gmax into MSFS engine.It's true that not all features of GMax are supported by the exporter, but I don't hope that the scenery SDK will only be a collection of GMax tips. Just like the MakeMDL SDK, it wouldn't be worth the name SDK in that case. But that is my opinion :). Most of these things can already be found on forums like this one.>The other dificulty is my aparent inability of controlling >the scale of my design. If for example I want to use 125mm >scalling (ie, 8 units for each metre) how do I set it up in >gmax? I would like to speed up things by using the >equivalent of ScaleX in MASM and I am not convinced that the >plugin is optimizing the object for speed! As far as I have seen from the asm files, the scale is always set to 0.5. But the new commands for the vertices allow non integer values, so this doesn't mean your model can't be more detailed then the 0.5 scale. I think you should bother about the scale to much :), I have made a nice little control tower with some stairs to enter it and these had a width of 0.1 meters and they showed up just correct.>The other thing I would like to know is how to separate the >various components of an object?If you leave the optimize tick in the exporter you will see that each part of your object gets his own code (but this make a code even longer and probably less efficient).> Perhaps a part of an object >is repeated over and over and in SCASM I had the chance to >define that once and use transformcalls to reproduce as many >as I wanted without filling up a BGL with unecessary points.I don't now if it is always faster to use the TransformCalls, these commands do require some calculations from the scenery engine and it might be much more efficient to just list a little more points and draw all the objects that way.ArnoMember NL2000 Teamhttp://home.wanadoo.nl/arno.gerretsen

Share this post


Link to post
Share on other sites

I believe the makemdl tools translates your model 1:1 into bgl. This means you are responsible for deleting any non-visible triangles yourself! If you want a framerate friendly model, it's really up to you do make it framerate friendly (ie use as few polygons as possible to get as much detail as possible). It's also up to you to make an efficient texture, ie fit all textures into one texture as small as possible.The reason you have vertices and trilists is very simple. trilists are not just simple triangles, but so called 'tristrips'. They are more efficient as they use less points. For comparison, say you have 3 triangles:triagles: 3 x 3 points = 9 vertices.trilist( joint triangles ): 3 points + 1 point + 1 point = 5 vertices(you have to imagine a simple sketch here, where are the sketching tools in this forum :-lol )It's all about minimizing code and being framerate friendly :)Hope that helps.Christian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this