tag:blogger.com,1999:blog-224350115443428324.post2193930115560975825..comments2023-12-28T07:58:52.842-08:00Comments on Santiago Ontañón: Smooth Scroll in XRacingsantihttp://www.blogger.com/profile/09783682812964404314noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-224350115443428324.post-60563797052816835322019-05-01T20:14:05.967-07:002019-05-01T20:14:05.967-07:00Thanks thegeps!!! Yes, you should definitively wri...Thanks thegeps!!! Yes, you should definitively write about it!! Your scroll is super smooth, and I think lots of people would like to learn how to do something like that! :)santihttps://www.blogger.com/profile/09783682812964404314noreply@blogger.comtag:blogger.com,1999:blog-224350115443428324.post-1274766234987923122019-04-30T07:26:12.118-07:002019-04-30T07:26:12.118-07:00Hi Santi, very interesting! I'm thegeps (Giuse...Hi Santi, very interesting! I'm thegeps (Giuseppe) from msx.org<br />I like reading of your techniques. In my scrolling routine I have in RAM (in ROM, actually) 31 couples of tiles and in every couple there are a tile and the tile that in the map can be immediately up. So i read with an offset between the two tiles definition and copy 8 bytes in tiles pattern in VRAM. Same thing I do for color patterns. So I calculate tiles I need and can have double buffer 'cause I have enough room. I hope, in future, I'll write an article to describe my routine as good as your article isGiuseppe Ettore Pintus (thegeps)https://www.blogger.com/profile/03066180636972395242noreply@blogger.comtag:blogger.com,1999:blog-224350115443428324.post-60320332673090038952019-04-22T23:03:24.407-07:002019-04-22T23:03:24.407-07:00Hi Arturo! Thanks! The "6 boxes" were pu...Hi Arturo! Thanks! The "6 boxes" were put there by hand. So, that is the input of the algorithm. <br />- My first version worked exactly as you say, and was working initially, until I started adding more maps, that pushed the approach to the limit.<br />- The problem is that, in addition to having the different tile groups, I need to assign an ID to each tile. Even if there are more than 256 tiles, I only have 256 IDs to assign to tiles, since I want each tile to use just 1 byte in the map. So, I need to figure out which tiles will have the same ID, and thus need to be in different groups. Two tiles with the same ID can never appear at the same time in the screen. This introduced an additional constraint that my initial version of the optimization algorithm could not handle very well.<br />- So, the current version does this: it starts with one group per "rail" with all the tiles needed for that rail, and an empty "common group".<br />- Then, it selects the tile that appears on the largest number of groups, and to resolve ties, it picks that that appears in the largest group (since we want to make the extra groups as small as possible). It moves that tile to the common group, and restarts the process.<br />- The key is that not all tiles are candidates to be moved to the common group. So, before I choose a tile, I run a test to see if I would be able to assign tile IDs to the tiles in all the groups, respecting the constraint that two tiles with the same ID cannot be in the screen at the same time. This is a bit trickier than it seems, since tiles can appear in multiple groups, and they must have the same ID regardless of the group they are on, so, this creates some weird constraints.<br />- If at any time in the process one of the groups becomes a subset of another one, I merge them.<br />- Since my algorithm does greedy optimization, it some times converges to a local optima where the extra groups are too large. So, what I did was to manually force the assignment of some tiles by hand before optimization starts. With that, I Was able to push it to a local optima that had small extra groups (if the were too big, I could not fit them in RAM!)<br /><br />And that's basically it. Now that I read it, it does not look that complicated, but for some reason I struggled when getting it right. Probably I was getting nervous with the deadline looming and me not having a game working yet! hahahasantihttps://www.blogger.com/profile/09783682812964404314noreply@blogger.comtag:blogger.com,1999:blog-224350115443428324.post-79333935523164825772019-04-22T02:44:53.546-07:002019-04-22T02:44:53.546-07:00Great reading!
Can you add details on how you mana...Great reading!<br />Can you add details on how you managed to optimize the common tile set among the 6 tile sets in your picture ?<br />I assume 6 tile sets because you have plotted 6 boxes in the level.<br />I would have computed the intersection among the 6 tile sets as starting point, then I would have added to the common tile set one tile at time from the 6 difference sets, taken from the largest one.<br />The process should end when the sum of the sizes of the common tile set and of the largest difference set is equal to 256.<br /><br />arturohttps://www.blogger.com/profile/14283743978083363775noreply@blogger.com