My first post so hello to all
It's not that I can't do it but I know I won't do it efficiently and it really matters this time. I tend to complicate too much in programming areas I'm not very experienced with so I come to ask your help guys.
But before I start to present you my question let me explain please a very important thing. I'm creating a program in an ancient BASIC like language called AMOS for AMIGA computers. It's important because I aim to 2 MB of RAM configuration. Yes, two MEGABYTES, not gigabytes . This changes a lot as you surly agree.
I have a world map 2400 x 2400 pixels. It's simply too large to load it complete to the memory (apart from this map I have other graphics, a lot of code and also need a room for music and sound samples.) I decided to divide and split it into smaller sections:
I created files called by the following order:
world_ne_1a.iff
world_ne_1b.iff
world_ne_1c.iff
...
world_ne_5a.iff
world_ne_5b.iff
world_ne_5c.iff
world_se_1a.iff
...
world_se_5c.iff
world_nw_1a.iff
...
world_nw_5c.iff
world_sw_1a.iff
...
world_sw_5c.iff
Those files are about 40kB each and have resolution 400 x 240 pixels.
This is how I'd do it (it might not be the best way but this what came to my mind):
Input: A spot on the map using real N/W/E/S coordinates.
1. Convert to pixel coordinates (geo to pixel - already fully functional in my program).
2. Check to which of the four sections of the world it corresponds. For instance, if it's NE section of the globe/map then the program determines on which box 400 x 240 pixels it appears on.
3. Load that file (e.g. world_ne_2b.iff)
4. Copy whole image and store it as blocks 50 x 30 pixels (400/50=8, 240/30=8 - I need those to be divisible by 8 pixes and these values fit perfectly my need)
5. Having X,Y converted data pixel from point 1. center corresponding block (50 x 30 pixel) on the screen (200 x 176 (on my sketch it's 200 x 180 but it should be 200 x 176)) and fill the rest of the visible screen around it with other appropiate blocks of the map.
6. New data input: GoSub 1., GoSub 2., GoTo 7.
7. If new coordinates do not correspond to the actual section displayed on the screen and other map blocks stored in RAM erase those blocks from memory and GoTo point 2.
That's the main idea. But there can be a more RAM memory hungry scenario where a spot appears on the map close to the "corner" of a 400 x 240 box. Then the program needs to load two or even four pictures depending on the X,Y axis. But even four images (~160kB) loaded into RAM is not a problem.
Now goes my question: How to program it using BASIC like code? How would you do it guys? In a pseudo code or whatever language you prefer (except references to API or DLLs)
Thank you in advance and if you need me to clarify some of my description please let me know.