26 September 2017, 17:36 | #1 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 421
|
Workaround to X-Flipping issue found. No actual solution as yet.
Right folks, after three days of tearing my hair out I've discovered why one of my biggest issues keeps happening. The thing is I haven't found a solution as yet, just a very clumsy workaround but I thought I'd share it just in case anyone else was having the same issue.
The problem was that the images in my object bank were seemingly getting flipped horizontally at random. I'd start a game and there'd be maybe a few frames out a walk animation which were the wrong way round or maybe one frame out of a punch animation which had been flipped. It was incredibly frustrating, especially when trying to check animations for things I'm working on. Anyway I discovered that when the program is exited by pushing ctr+c, Amos automatically saves whatever has happened to the images in regard to X-flipping, to the bank (the one held in temporary memory for the program, not the actual saved file). For example if the games starts and the default X-Flip variable is set to false (facing right) and the player taps the joystick left, that would set the flip variable to true (facing left) and activate the $8000+n instruction. Now the bob is facing left on the first frame of a walk animation. If the game is then exited back to the editor, that first frame of the walk animation will get automatically stored in the temp object bank facing that direction whereas the other frames in the animation set would still be the correct way around. Since the game obviously re-uses this temporary bank when the game restarts all the variables for flipping get reset back to the default false (facing right), but the problem is that they will also be the default setting for the frame which is the wrong way round. I'm not sure why Amos does this as it serves no real purpose if the game is being restarted. At first I thought it was my code or even the Hrev()/$8000+n instruction which was glitchy, but it turns out the code itself is absolutely fine. It seems the only solution is to go into the object editor and re-load the fresh bank from the file every single time the game is exited and then exit the object editor to get the "save current bank to program" prompt. It's kind of clumsy and irritating to do and I've hit the save button instead of the load one a few times by mistake now and had to reset the images by hand before saving again. My failed solution was to try and auto re-load the image bank every time the game is exited so there is a correct set of images all facing the right way in the bank (refreshing the set essentially). I did this by putting a command in the main loop whereby if ctrl +c is pressed then it would re-load the images from the saved bank. It didn't work unfortunately. Maybe the program is exiting before it gets a chance to reload all the images but I don't know. Bar actually re-writing Amos itself to include a image bank refresh on exit from the actual saved bank file, I'm unsure as to how I'd get a tidy solution to this issue. I'm open to suggestions and or solutions if there are any. Even if there aren't then I hope this information will be useful to someone who may be experiencing the same problem and at the very least can just do the manual bank reload in the object editor. Thanks. |
26 September 2017, 17:45 | #2 | |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
Quote:
Sent from my Prism II using Tapatalk |
|
26 September 2017, 18:49 | #3 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 421
|
Do you mean have a left and right version of every image?
|
26 September 2017, 21:43 | #4 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
Yeah.
Sent from my Prism II using Tapatalk |
26 September 2017, 22:54 | #5 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 421
|
|
26 September 2017, 22:59 | #6 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
HRev is a slow bitwise operation that would otherwise have needed Assembly code for speed. VRev is less so but they both are common operations.
Sent from my Prism II using Tapatalk |
27 September 2017, 09:59 | #7 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 421
|
Ok cool, thanks for the info.
|
27 September 2017, 15:26 | #8 | |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
That's an interesting finding, thank you for reporting that.
Quote:
|
|
27 September 2017, 15:40 | #9 | |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 421
|
Quote:
Thank you. The bank does load at the start of the program just before the main loop starts, but (and I may be wrong about this) it appears to keep a temporary copy somewhere for re-use. As I say, when the game re-starts, all the images x-flip positions are at what they were in the previous game. However, when the bank is manual re-loaded in the object editor from the .abk file they resume their correct direction both in the editor and if the game is re-run. I too assumed that the program would just constantly load a fresh set of images if the Load "bank.abk" command was at the start of the code, but it appears that a previous run of the code does affect the next one. At least in those circumstances. I'm runiong ot ouside the main loop thoug |
|
27 September 2017, 16:37 | #10 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
You could try freeing the bank before loading or on exit, and possibly inside the "on error" handler.
|
27 September 2017, 22:21 | #11 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 421
|
Ok cool. I'm not quite sure how to do that but I'll look at the manual and see what it says. Thanks!
|
12 October 2017, 22:59 | #12 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
UNLESS Storage or Memory are short, it's MUCH easier (and faster) to define your reversed images in the sprite/icon banks rather than put up with the problems the REV commands bring with them.
(That's just my opinion of course!) |
13 October 2017, 19:01 | #13 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
One thing I do in Blitz is to copy and flip all relevant images after they have been loaded. That way, you waste memory but not disk space, and you don't have to update two images each time you change a bob.
That way, you just have to add an offset or flip a bit when flipping a bob in the game since all mirrored images have the same offset from the non-flipped one. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Any way to workaround WHDRun problem? | jimmy2x2x | support.Other | 2 | 28 October 2014 16:34 |
flipping through screens using middle mouse button | Yulquen74 | request.Apps | 5 | 27 June 2014 21:31 |
Workaround found for running WinUAE under Wine/Linux | mark_k | support.WinUAE | 14 | 24 November 2008 03:56 |
Flipping floppies | Dave_wb | support.Hardware | 8 | 03 December 2006 12:36 |
Possible slowdown workaround | Toni Wilen | support.WinUAE | 3 | 03 September 2005 00:21 |
|
|