Making map viever in C#.NET

smoochy boys on tour

wbrian

Dedicated Member
Dedicated Member
Aug 31, 2007
193
2
64
Hi all.

First - I sorry for my english:P

I will make a simple mir3 map viever in C#.NET. But i'm beginner and i don't know much about map file build. I have little experience with making app with C#.NET (i've made wav file reader with oscillogram,dft etc.).

Any help would be appreciated;)

p.s:
Here is a part of h102_2.map hex:

Code:
0000 0000 0000 0000 0000 0000 0000 0000 
0000 0000 0000 1200 1600 0000 0214 0002 
1400 0214 0002 1400 0214 0002 1400 0214 
0002 1400 0214 0002 1400 0214 0002 1400 
0214 0002 1400 0214 0002 1400 0214 0002 
1400 0214 0002 1400 0214 0002 1400 0214 
0002 1400 0214 0002 1400 0214 0002 1400 
0214 0002 1400 0214 0002 1400 0214 0002 
1400 0214 0002 1400 0214 0002 1400 0214 
0002 1400 0214 0002 1400 0214 0002 1400 
0214 0002 1400 0214 0002 1400 0214 0002 
1400 0214 0002 1400 0214 0002 1400 0214 
0002 1400 0214 0002 1400 0214 0002 1400 
0214 0002 1400 0214 0002 1400 0214 0002 
1400 0214 0002 1400 0214 0002 1400 0214 
0002 1400 0214 0002 1400 0214 0002 1400 
0214 0002 1400 0214 0002 1400 0214 0002 
1400 0214 0002 1400 0214 0002 1400 0214 
0002 1400 0214 0002 1400 0214 0002 1400 
0214 0002 1400 0214 0002 1400 0214 0002 
1400 0214 00FC FFFF 0F0F FFFF FFFF 0000 
0000 00FC FFFF 0F0F FFFF FFFF 0000 0000 
00FC FFFF 0F0F FFFF FFFF 0000 0000 00FC 
FFFF 0F0F FFFF FFFF 0000 0000 00FC FFFF 
0F0F FFFF FFFF 0000 0000 00FC FFFF 0F0F 
FFFF FFFF 0000 0000 00FC FFFF 0F0F FFFF 
FFFF 0000 0000 00FC FFFF 0F0F FFFF FFFF 
0000 0000 00FC FFFF 0F0F FFFF FFFF 0000 
0000 00FC FFFF 0F0F FFFF FFFF 0000 0000 
00FC FFFF 0F0F FFFF FFFF 0000 0000 00FC 
FFFF 0F0F FFFF FFFF 0000 0000 00FC FFFF 
0F0F FFFF FFFF 0000 0000 00FC FFFF 0F0C

p.s.2:I know that some info is here : http://www.lomcn.co.uk/forum/showthread.php?t=59553
but i need to understand it (on example etc).
 

DjDarkBoyZ

Dev
Golden Oldie
Aug 11, 2006
1,065
228
260
127.Ø.Ø.1
Make a structure like tells in the thread you have looked and fill them with the map data you like (mir3 map).

This is my structures in my mir3 viewer beta.

Public Structure tagMAPFILEHEADER
Dim MapLoaded As Boolean

Dim szDesc() As Byte '20 CHAR array
Dim wAttr As UInteger
Dim shWidth As Short
Dim shHeight As Short
Dim cEventFileIdx As Byte
Dim cFogColor As Byte
End Structure

Public Structure tagTILEINFO
Dim bFileIdx As Byte
Dim wTileIdx As UInteger
End Structure

Public Structure tagCELLINFO
Dim bFlag As Byte
Dim bAnimation As Byte
Dim bAniLastFrame As Byte

Dim bTopFile As Byte
Dim bBotFile As Byte

Dim wBotImg As UShort
Dim wTopImg As UShort
Dim bAniFrame As Byte
Dim bAniTick As Byte
Dim wAniCurrTick As UShort
Dim bLight As Byte
End Structure
For your understand:

Im talking in file position, pointer or offset ok? if some of this is wrong tell me.

Positions for MapHeader:
szDesc - 0 to 19 "Map Description"
MapAtr - 20 & 21 "Atributes"
MapWidth - 22 & 23 "With of Map"
MapHeight - 24 & 25 "Height of Map"
EventFileIdx - 26
FogColor - 27
Tile Array are (MAPFILEHEADER.shWidth / 2, MAPFILEHEADER.shHeight / 2) ok?

and the obj array are
CellTiles(MAPFILEHEADER.shWidth, MAPFILEHEADER.shHeight)

Start of map data at position 28.

MapFileIdx = 0
MapTileIdx= 1 & 2
In C# you can read this in one line without loops or another methods copying data directly to tile array understanding the tile array is 3 bytes every position in X,Y Map and using this order
(X,Y) = (0,0) , (0,1) , (0,2),etc.

The obj is the same, immediately after tile data but using the obj structure obviously Like this order (positions):

'Can Walk?
MapFlag = 0

'Image library
TopFileIdx = 3
BottomFileIdx = 4

'Image Index inside lib
BottomImageIndex = 5 & 6
TopImageIndex = 7 & 8

'Light
Light = 13
The obj cell structure have 13 bytes per position.
The animations and other things you need to be done but with this you can start reading and rendering is very easy, take a look for example how mir2 sources render maps and objects and you can see mir3 maps easy.

The full info of structures is in the thread you have linked.
I hope this serves you :)
Cya ;)
 

mapadale

Guest
I'm not putting down what you are doing, but why bother at all.

Corys map viewer and editor are more than enough to surfice.
 

wbrian

Dedicated Member
Dedicated Member
Aug 31, 2007
193
2
64
@DjDarkBoyZ
Thank you so much;) Your information is so useful for me - and i hope for others;)

@mapadale
I don't agree with you. Colys viever and editor is good, but making new with explanation is good point to understanding how it works (e.g. coding). Also building a viever is good point to learn C#.NET:P

P.S. Thanks one more time DjDarkBoyZ;) Ill pm to you when i have a stupid question:P
P.S.2. When i got completly working app i'll put my source here.