English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. AMOS

 
 
Thread Tools
Old 26 September 2017, 18:36   #1
Brick Nash
Registered User

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 192
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.
Brick Nash is offline  
AdSense AdSense  
Old 26 September 2017, 18:45   #2
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 920
Send a message via Yahoo to Samurai_Crow
Quote:
Originally Posted by Brick Nash View Post
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.
Store the HRev image to a separate Bob in the bank. HRev is a processor intensive operation and is global to every use of the Bob.

Sent from my Prism II using Tapatalk
Samurai_Crow is offline  
Old 26 September 2017, 19:49   #3
Brick Nash
Registered User

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 192
Do you mean have a left and right version of every image?
Brick Nash is offline  
Old 26 September 2017, 22:43   #4
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 920
Send a message via Yahoo to Samurai_Crow
Yeah.

Sent from my Prism II using Tapatalk
Samurai_Crow is offline  
Old 26 September 2017, 23:54   #5
Brick Nash
Registered User

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 192
Quote:
Originally Posted by Samurai_Crow View Post
Yeah.

Sent from my Prism II using Tapatalk
Ok cool.

Just out of curiosity, what's the point in having the HRev/VRev then?
Brick Nash is offline  
Old 26 September 2017, 23:59   #6
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 920
Send a message via Yahoo to Samurai_Crow
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
Samurai_Crow is offline  
Old 27 September 2017, 10:59   #7
Brick Nash
Registered User

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 192
Ok cool, thanks for the info.
Brick Nash is offline  
Old 27 September 2017, 16:26   #8
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,076
That's an interesting finding, thank you for reporting that.

Quote:
Originally Posted by Brick Nash View Post
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.
Wouldn't it suffice to store the bank separate from the program and start the program with Load "bank.abk"?
idrougge is offline  
Old 27 September 2017, 16:40   #9
Brick Nash
Registered User

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 192
Quote:
Originally Posted by idrougge View Post
That's an interesting finding, thank you for reporting that.



Wouldn't it suffice to store the bank separate from the program and start the program with Load "bank.abk"?

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
Brick Nash is offline  
Old 27 September 2017, 17:37   #10
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,076
You could try freeing the bank before loading or on exit, and possibly inside the "on error" handler.
idrougge is offline  
Old 27 September 2017, 23:21   #11
Brick Nash
Registered User

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 192
Ok cool. I'm not quite sure how to do that but I'll look at the manual and see what it says. Thanks!
Brick Nash is offline  
Old 12 October 2017, 23:59   #12
volvo_0ne
Registered User

 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 248
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!)
volvo_0ne is offline  
Old 13 October 2017, 20:01   #13
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,076
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.
idrougge is offline  
AdSense AdSense  
 


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 17:34
flipping through screens using middle mouse button Yulquen74 request.Apps 5 27 June 2014 22:31
Workaround found for running WinUAE under Wine/Linux mark_k support.WinUAE 14 24 November 2008 04:56
Flipping floppies Dave_wb support.Hardware 8 03 December 2006 13:36
Possible slowdown workaround Toni Wilen support.WinUAE 3 03 September 2005 01:21

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 22:20.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.29717 seconds with 12 queries