// HEL Library \\ |
HEL's map-system implementation supports large maps. The map-drawer only updates "dirty" rows and columns, instead of always redrawing the whole map!
It's quite faster than the original HAM functions. It uses DMA transfers to update the map and LookUpTables whereever possible to gain maximum speed. I actually spend a lot of time to getting it that fast!
It supports parallax scrolling, using fixed point math.
It supports Virtual Maps. A Virtual Map in HEL's sense is an invisble datalayer only, which can be used as a collision or event map. There is no limit in creating Virtual Map's!
It also has an implementation for callback notify's.
All these useful things making HEL's map-system implementation to a very powerful tool!
|
Scroll multiply layers at the same time.
|
|
Scroll multiply layers at the same time.
|
|
De-Initialize a map.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); // Lots of stuff here ... hel_MapDeInit(&MapInfo);
|
|
Get custom data.
|
|
Get the currect map position in tiles.
TMapScrollInfo MapInfo; TPoint32 Pt={0,0}; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPosition(&MapInfo, 512, 0); Pt = hel_MapGetPosition(&MapInfo); ham_VBAText("Position in tiles X: %d \n", Pt.X); ham_VBAText("Position in tiles Y: %d \n", Pt.Y);
|
|
Get the currect map position in pixel.
TMapScrollInfo MapInfo; TPoint32 Pt={0,0}; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPosition(&MapInfo, 512, 0); Pt = hel_MapGetPositionInPixel(&MapInfo); ham_VBAText("Position in pixels X: %d \n", Pt.X); ham_VBAText("Position in pixels Y: %d \n", Pt.Y);
|
|
Get position of a tile.
TPoint32 Pt = hel_MapGetPositionInPixelFrom(&g_MapInfo, 2, 3);
|
|
Get a maptile.
u16 Index = hel_MapGetTileAt(&g_MapInfo, 98, 56);
|
|
Get a pointer to a maptile.
u16 Index = *(u16*)hel_MapGetTilePtrAt(&g_MapInfo, 98, 56);
|
|
Initialize a map.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, // BgNo 4096, // Map-width in tiles 32, // Map-height in tiles FALSE, // Is it a rotation map? Layer0_Map); // Pointer to map-data
|
|
Initialize a map.
TMapScrollInfo structure, which is used by most of the hel mapfunctions. The hardwaremap is set to 32x32 tiles.
The parameter MapSize can be one of the following defines, depending on, whether it is a rotation map or not... For a normal map use one of these:
For a rotation map use one of these:
TMapScrollInfo MapInfo; MapInfo = hel_MapInitEx(0, // BgNo 4096, // Map-width in tiles 512, // Map-height in tiles TRUE, // Is it a rotation map? MAP_SIZE_ROT_64X64, // hardware mapsize Layer0_Map); // Pointer to map-data
|
|
Initialize a VirtualMap.
TMapScrollInfo MapInfo; MapInfo = hel_MapInitVirtual(128, 32, sizeof(u16), (void*)sample_Collision);
|
|
Check if a map uses boundschecking.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); if (hel_MapIsBoundsCheckEnabled(&MapInfo)) ham_VBAText("Boundscheck enabled\n"); else ham_VBAText("Boundscheck disabled\n");
|
|
Check if parallax is enabled.
|
|
Redraw the map.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapRedraw(&MapInfo);
|
|
Scroll the map. The hel_MapScrollBy function scrolls the map and redraws the "dirty" columns and/or rows only. It does not redraw the whole screen for some performance reasons. You can use negative values to scroll to the map to the left and/or up. If a callback-function was specified with hel_MapSetCallbacks, it triggers the assigned callback-function whenever a new column or row has been drawn.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); while(GameLoopActive) { if(NewFrame) { if(UserPressedRight) { // Scroll one pixel to the right u8 ScrollResult = hel_MapScrollBy(&MapInfo, 1, 0); // check if it was able to scroll on x-axis if(ScrollResult & 1) { Print("Scrolled on X"); } // check if it was able to scroll on y-axis if(ScrollResult & 2) { Print("Scrolled on Y"); } } } } hel_MapDeInit(&MapInfo);
|
|
Scroll map to a specific position automatically.
TMapScrollInfo g_MapInfo; // X/Y Tile-Position (Camera Key-Points) const TPoint16 CamKeyPoints[5]= { // X, Y Tile Positions {10, 5}, {28, 5}, {15, 5}, {15,25}, { 0, 0} }; // Map Cinema Scrolling Information TMapCamScrollInfo g_MapCamInfo = { &CamKeyPoints, // Pointer to keypoints 5, // Count of keypoints 0 // Start keypoint }; // Init map g_MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); u8 CamScrollWorking=1; while(1) { if(NewFrame) { if(CamScrollWorking) { CamScrollWorking = hel_MapScrollTo(&g_MapInfo, &g_MapCamInfo, 1, 1); } NewFrame=FALSE; } } |
|
Setup map bounds checking.
pMapInfo . This means, you cannot scroll out of the map. It stops scrolling when it hits the "edges" of the map. It's turned on by default when you use hel_MapInit.Disabling this feature means you can scroll out of the map and this could end up in tile-curruption when you do not code an own "is currect position still in map" routine.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); // Turn off boundscheck hel_MapIsBoundsCheckEnabled(&MapInfo, FALSE);
|
|
Setup map notify-callbacks.
TMapScrollInfo MapInfo; // Is called whenever a new row has been drawn void MapOnTopRowChanged(TMapScrollInfo *pMapInfo, u32 X, u32 Y) { ham_DrawText(1, 1, "MapOnTopRowChanged "); ham_DrawText(1, 2, "X: %d ", X); ham_DrawText(1, 3, "Y: %d ", Y); } // Init map MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); // Set callback function(s) hel_MapSetCallbacks(&MapInfo, (PMapNotifyFunc)MapOnTopRowChanged, NULL); // Scroll the map by 32 pixels in X and Y hel_MapScrollBy(&MapInfo, 32, 32);
|
|
Set custom data.
|
|
Enable or disable Parallax support.
TMapScrollInfo structure specified by pMapInfo . Specify TRUE to enable, or FALSE to disable.
|
|
Set parallax X/Y ratio.
pMapInfo . This function automatically enables parallax-support for the specified structure.
hel_MapSetParallaxRatio(&MapInfo, PARALLAX_FLOAT_TO_RATIO(0.7), // Ratio on X PARALLAX_FLOAT_TO_RATIO(0.8)); // Ratio on Y
|
|
Set map position in tiles.
X and Y must be specified in tiles.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPosition(&MapInfo, 512, 0);
|
|
Set map position in pixels.
X and Y must be specified in pixels.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPositionInPixel(&MapInfo, 512, 0);
|