The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.3.33 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Users browsing this thread: 1 Guest(s)
Faster compression & Imperial Camp boxes

#1
Posts: 18
Threads: 3
Thanks Received: 0
Thanks Given: 0
Joined: Nov 2019
Reputation: 0
Status
None
The Imperial Camp has a box which can be walked on but not walked off causing a softlock. This seems due to the player changing layers to walk under a nearby wall but one of the boxes being at the transition point makes returning impossible. The way I fixed this bug required working with compressed data.

A perl script is available on the compression page; however, while experimenting I found that it did not meet my needs. I want to keep WC executing in under 1 second under any configuration but discovered that larger chunks of data could take significantly longer to compress. The Imperial Camp bug does not require compressing much data but I want something flexible for future changes.

Attached are compression and decompression functions in Python which seem to significantly improve upon current methods.
Also attached are benchmarks of various sizes between the perl script, functions in BC, and my method. Benchmarks use Perl 5.30.0 and Python 3.8.5 on my development machine.

The benchmarks decompress then recompress data at:
0x2fe49b (1048 bytes), wob_minimap
0x2f114f (8449 bytes), wob_graphics
0x02686c (8692 bytes), title_intro_fc_world
0x2ed434 (15643 bytes), wob_map
0x18f000 (24178 bytes), title_intro

Additionally, 3 tests were run by compressing and then decompressing the beginning of a ROM.
0x0, (20000 bytes), rom_start_20k
0x0, (50000 bytes), rom_start_50k
0x0, (65535 bytes), rom_start

As a sidenote, none of the BC tests decompressed to the exact original data. I am not certain whether this was an error in the compression, decompression or my testing. I used the decompress/recompress functions and default simple/complicated arguments.

My new methods were able to compress each test in under 1.5 seconds.
The biggest improvement came from the wob_map test at 0x2ed434. The perl script took 5 minutes and 58 seconds, BC produced an error, and this approach was able to successfully compress it in 1.404 seconds.
Another notable example was title_intro at 0x18f000 taking 43.692 seconds in the perl script, 6.564 seconds in BC, and 1.210 seconds with this approach.
The improvement also seems consistent with smaller data. wob_minimap is only 1048 bytes and completed in 0.567 seconds with the perl script, 0.249 seconds in BC, but only 0.048 seconds with this approach.

The perl decompression time can sometimes run slightly faster but is overall negligable.
There was no significant difference in compressed sizes between the perl script and this approach. BC compression typically produced larger sizes except in the case of wob_minimap.

Overall, this new approach seems to be much faster without any loss in compression.
There are still possible optimizations; however, I am satsified with the improvement in time complexity for now. Hopefully it can be used to significantly speed up other projects as well and may also be helpful in other games such as Chrono Trigger.

As for the Imperial Camp box bug, my solution was to change those boxes to use impassable box tiles from the same map.
The boxes are on layer 1, the data for which is at index 0x1c. The pointer leads to address 0xda6970, which is 1582 bytes
The coordinates for the boxes to change are (19, 13), (15, 14), (18, 14)

Code:
address = 0xda6970
size = 1582

tilemap = load(address, size)
decompressed = decompress(tilemap)

map_width = 64
impassable_box_tile = 62 # box tile that cannot be entered
coordinates = [(19, 13), (15, 14), (18, 14)] # coordinates of boxes to change
for coordinate in coordinates:
    decompressed[coordinate[0] + coordinate[1] * map_width] = impassable_box_tile

compressed = compress(decompressed)
write(address, compressed)

This will not allow character sprites to get close enough to appear "behind" those boxes anymore but will fix appearing inside them, only displaying half the sprite, and the softlock.


Attached Files Thumbnail(s)
   
.txt  compression.txt (3.92 KB, 13 downloads)
  Find
Quote  
[-] The following 5 users say Thank You to AtmaTek for this post:
  • Everything (03-07-2021), Gi Nattak (03-08-2021), madsiur (03-07-2021), snaphat (05-14-2021), SSJ Rick (03-13-2021)



Messages In This Thread
Faster compression & Imperial Camp boxes - by AtmaTek - 03-07-2021, 02:56 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite