News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

[cpctelera] question for limits - maps

Started by Fmtrx, 20:17, 03 April 20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fmtrx

hello all,

Lately i am experimenting myself on the cpctelera - i have done a quick view of the manual and watched
the 1 hour youtube presentation. What an interesting platform ! -
So i created a map which is 191 X 46 (tile: 4x4). Before creating my code i wanted to make sure that the map will fit and scroll with the tested code from the creator, by modifying the existing example tilemap_hwscroll. So to scroll till the end i have to set  MAXSCROLL=151

Well, it did not work for this value. I noticed that the scrolling worked
till tile no 172 (tile size 4x4) when setting MAXSCROLL=132


#define MAXSCROLL      132//134 and bigger , gets stuck    80   mapwidth - displayed (40)
#define SCR_TILE_WIDTH 40// this is the width of the screen! 40 X 4 = 160 pixels
#define MAP_WIDTH     191//120
#define MAP_HEIGHT     46//46

BUT when setting any value > 132 had as an effect to have the map stuck and not responding with right and left.
My question is, what are the limits of the map size in general regarding width and height ?

The second question has to do with memory management. I noticed a couple of memory management
functions inside the manual. Supposing that a developer does not manage to fit the program in 64k,
so with these functions he has the ability to load both binary code and graphics at the upper 64k
of the 6128 and have all code and graphics in all 128k working as they should be without any restrictions ?

ervin

#1
At first I thought it may have been a datatype issue, but then I found that the variable that is compared with MAXSCROLL is u8 (i.e. unsigned char).
So that's not the problem.

However, I wonder if correct operation until tile 172 is a clue.
Your tiles are 4x4 in size.
Is that 4x4 characters, or 4x4 bytes?

Your tilemap is 191 wide, and your program works until tile 172.
Tile 172 to tile 191 is 20 tiles inclusive.
20 tiles of 4x4 bytes is 80 bytes wide, which is the screen width.

I wonder if you are simply reading past the end of your tilemap data?
I could be COMPLETELY wrong of course... just wondering if this could be a clue.

Fmtrx

#2

I am not sure if my assumptions are correct, so i will describe what i understood:Each tile is 4 X 4 pixels, which is equal to 4 X 2 in bytes if i am correct.
So the width of the  visible area is drawn by 40 tiles.
Thus when launching the map we see from tile 1 to tile 40.
MAXSCROLL is set to 151 so that at the rightmost scroll we will be able to see
(1+MAXSCROLL , 40+MAXSCROLL) which is : from tile 152 to tile 191.

I had the program stuck at these settings so by trial and error i found the maximum
value of the MAXSCROLL that does not crashes the scrolling.
This was the value of 132, which means that i am able to
see from tile  133 to tile 172, and not being able to display the last 19 tiles of the map.

I believe that i am not attempting to read past the map, for the main reason that when i set
the value of 134, the scrolling gets stuck, which is supposed to show tile 174 out of the 191
at the rightmost area of the screen.

I think i will take a look at the generated arrays and verify the lengths. Other than that i am stuck :/

EDIT : the lengths are ok, ( i had the suspicion that make clean, did not delete previous arrays for some random reason and had the old sizes of the example.)


Maybe i overcome the limits of the max map size that cpctelera can display ? Anyone knows ?





ervin

Can you please attach your (zipped) project src folder?
I'd be happy to take a look.
:)

Fmtrx

Sure, i have attached a clean example, as clean as possible, which means that it is the original working example of the author of cpctelera, and the only modifications are:
the map is enlarged to 200 tiles,
sizes in #defines are modified accordingly.


(The max size of the map that its scrolling works is  7912 bytes, and  my example that gets stuck
generates 9200 bytes. Maybe we cannot create maps > 7912 bytes ? )

ervin

It looks like there is nothing wrong with your code.
But I found this in the documentation for cpct_etm_drawTileBox2x4.

map_width is expected to be the width of the tilemap in tiles.
Do not confuse this value with w, that represents the width of the tilebox (please note the difference).
Maximum width of the tilemap is 255 tiles, as it is a u8 value.
However, take into account that maps wider than 127 tiles can represent a problem, as the initial x parameter of this function cannot be greater than 127.


The only thing I can think of is the possibility that your MAP_WIDTH is causing unpredictable behaviour in the tile box routine.
Sorry I can't be of more help.

Fmtrx

#6
which leads to the fact that one has to divide this map to two sub-tilemaps.
This complicates things, as the original map does not have a door so that i could load the new map as the hero opens the door.
It is a big 200 tile level without doors. So the program has to load the new map 'on the fly' as the hero moves e.g. with hero.x > 120th tile
and i am not sure how well this can be executed without producing any delays during the gameplay.
Perhaps i could make a question at the github in cpctelera, just in case there can be a fix to display maps with 255 tiles in width.
I made a check in the maps of the game and i noticed that they have a standard width of 200 tiles with 46 height.
There was also a case of a 120X92 map though.
Amyway, thanks for your time in taking a look of this :)

Arnaud

#7
Hi,
your code crash because you are drawing tiles on code itself  :D
Not exactly but in Firmware Area 0x00 to 0x3F.

The video memory area is 0xC000 -> 0xFFCF for visible part and 0xC000 -> 0xFFFF for full memory.
When applying a video offset of 2 with cpct_setVideoMemoryOffset the vmem area becomes 0xC002 -> 0xFFD1, etc.

And with a MAX_SCROLL = 48 (0x30) then an offset of 96 (0x60) then last pixel of the screen is written at 0xFFD0 + 0x60 = 0x0000.


Fmtrx

#8

well it seems that the tilemap must be 127 tiles max as you say.
On one hand  seems that until 172 it works,  on the other hand  i will not know what other side effects this causes that are not visible in a simple tilemap scroll so one has to stick to 127.

This ruins the 1:1: arcade conversion i was working and i will not be able to use the 200 tile maps i have created and  match exactly the object arrangement of the arcade.
I doubt that the 'on the fly' load of a new map will be a smooth approach.

ervin

This problem affects something I'm working on as well.

I've been researching a solution to it, and I found this discussion from August 2019, started by Arnaud.
http://www.cpcwiki.eu/forum/programming/cpctelera-scrolling-hardware/

There might be some helpful tips in there, particularly near the bottom of the thread.

Fmtrx

i am going to check this out.thanks
In the mean time i have broken the map to two submaps, and then load the next map after scrolling passes a certain threshold.
There is no delay, but the code becomes more complicated, and there is also a bug i have to solve.
(the second submap overwrites the last column of the first submap, and this has an effect of moving the whole first submap two tiles lower than they should be)
I have created a question for a possible enhancement request at the github. I hope that ronaldo will check this out.

Powered by SMFPacks Menu Editor Mod