Saturday, July 30, 2011

Wow, I figured out how to do the compression part of the program!



Hello everyone,
Well I figured out the new programming method to compress the data for the entire world map that saves me a huge amount of bytes.  The screen shot above is from a BRUN of the new program with about 4 new subroutines that work out the compressed data strings.
The Ultima 1 world map is [4] separate maps that are side by side totaling 180 tiles wide by 90 tiles deep!
Previously I would have had to spend 180x90 = 16200 bytes to create the world map!!! "This would not work by the way!"
Now, the total amount to bytes I will use for the entire world map is approximately 90x15 "15 is the average amount of byte groups" = 1350!!! That is almost a 15000 byte savings!
 The new compression program works as follows:
 1. Since each world map line has different types of tiles and different amounts of each tile I used a value at the beginning of each data string that represents the total number of bytes in the data string.
Previously I was going to have to enter 180 total bytes for each of the 90 map line but now I setup each map line as follows:
Exam: MAP1 DFB $0C,$F9,$F9,$F9,$F9,$F9,$F9,$F9,$F9,$F9,$F9,$F9,$F9
 So the $0C represents the twelve total groups of bytes, which will be used in a loop checker. The twelve bytes represent 15 ocean tiles each per byte group!  The 9 is the # that represents an ocean tile/shape.
2. I initialize values for ROW and COLUMN, which for testing start at 0,0.Since I have ROW start at 0 I end up looking through MAP1 data string first.
3.I have a subroutine that first reads the initial byte, which in this case is the $0C and places it in a variable.
4.Then I read the data string again and place each of the seven bytes into an array called PREPMAP,X with the $0C used as a loop checker.
5.I have a subroutine that reads the first byte in the PREPMAP array and stores the value in two variables: HBYTE and LBYTE.
6.I have another subroutine that shifts the HBYTE to get only the F only into the byte.
7.I have the next subroutine shift the LBYTE to get the 9 only into the byte.
8.Now I use HBYTE as a loop checker and place 15 ocean tiles in a TMPSTORE array that is 180 byte long. This subroutine loops again through all 12 bytes, again through the HBYTE and LBYTE and places them in the same TMPSTORE array.
9.Once all 180 bytes are stored in the TMPSTORE array I use another subroutine that gets the value of COLUMN and retrieves that 20 bytes starting at the column value and stores them in an array called MAPSTORE.I run through this process with a loop 10 tiles to get all 200 tiles reference numbers.
10.Now that I have all 200 tiles I was able to use my existing draw subroutines with just a number of tweaks. The tweaks consisted of drawing out the tiles by reading in groups of 20 so I could keep the draw pattern as a top to bottom approach as 10 tiles down and 20 columns to the right.
I know I can clean these processes up and make them faster and cleaner but I just need to spend more time on them and refine each one.
So now I am spending my time recreating the entire [4] maps in excel with all the inidivual tiles images placed in individual cells.  The world map will be 180 tiles wide by 90 tiles deep.
When this is complete I will be able to enter all the data strings for all 90 map lines and move on to the ship movement part of the world map.  I bet you though I forgot about this movement process that happens on the world map.  I have a good idea how to get this to work and not add any really code to the program.  It will add another shape to the program and new parameters for the movement checker.
Talk soon,
Joe
 
 

No comments:

Post a Comment