English Amiga Board


Go Back   English Amiga Board > Support > support.FS-UAE

 
 
Thread Tools
Old 13 January 2021, 11:30   #1
Waxhead
Registered User
 
Join Date: Nov 2020
Location: Etne / Norway
Posts: 12
Bug: Reading from address $BFE400 and $BFE500 always returns 255

Howdy,

Ages ago it seems I made a little program that needed some random numbers. Being a young and stupid programmer I pulled the randomness by reading a char/byte from address $BFE400 and $BFE500 and multiplied those together.

My program used to work on WinUAE but suddenly my program failed. Apparently WinUAE changed something, I can't remember when (but can probably try to find out if needed).

Real Amigas return "noise" by reading these addresses e.g. a random number. fs-uae (and the last time I checked WinUAE) does not. Since UAE strives to be accurate (CPU cycle accurate for example) then in the name of accuracy for the emulation UAE should at least return some pseudo random number to mimmic real Amigas if a read is done on those addresses.

Decided to report this for fs-uae since I don't use WinUAE anymore (I am exclusively on Debian GNU/Linux).
Waxhead is offline  
Old 13 January 2021, 11:44   #2
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
The "noise" is undefined behaviour and emulated if "more compatible" checkbox is set (in 68000 mode only I think). At least in WinUAE.
StingRay is offline  
Old 13 January 2021, 12:09   #3
FrodeSolheim
FS-UAE Developer
 
FrodeSolheim's Avatar
 
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
What configuration are you using?
FrodeSolheim is offline  
Old 13 January 2021, 12:54   #4
Waxhead
Registered User
 
Join Date: Nov 2020
Location: Etne / Norway
Posts: 12
Quote:
Originally Posted by FrodeSolheim View Post
What configuration are you using?
For this particular test I use a config that looks like so:

Amiga model: A4000 , 3.1 ROM 68040 CPU (ROM rev. 40.70)
Accuracy: High
512K slow ram, 8MB Fast ram
Everything else is the default e.g. no JIT or any other settings.

Anything else? I think this is the most relevant ones.

Regarding the comment about undefined behavior. Well if undefined behavior returning something rather than 0 / 0xFF then I would argue that it is not undefined from a emulation point of view. It is as simpe as the real thing returning something while the emulation does not.

Incidentally I talked with a friend that used to run my program , I remembers that my program worked until (and including) WinUAE 3.20 , after that the "noise" disappeared.
Waxhead is offline  
Old 13 January 2021, 13:21   #5
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Waxhead View Post
Regarding the comment about undefined behavior. Well if undefined behavior returning something rather than 0 / 0xFF then I would argue that it is not undefined from a emulation point of view. It is as simpe as the real thing returning something while the emulation does not.

It is undefined. What do you think your program does? Reading CIA registers or bus noise?


And btw, it is a very bad approach to get "random" values.
StingRay is offline  
Old 13 January 2021, 14:00   #6
Waxhead
Registered User
 
Join Date: Nov 2020
Location: Etne / Norway
Posts: 12
Quote:
Originally Posted by StingRay View Post
It is undefined. What do you think your program does? Reading CIA registers or bus noise?

And btw, it is a very bad approach to get "random" values.
How can it be undefined when real hardware output something that varies and the emulation does not? There is a difference and the difference is something rater than nothing.

I believe my program is reading bus noise, but then again I have not written code for my Amiga in 24 years or so.

But does it matter?! On real hardware it reads something that varies , but on emulation it read static values. I would again argue that something rater than nothing is something that is NOT undefined. Is not bus noise a definition after all?
Waxhead is offline  
Old 13 January 2021, 15:17   #7
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,303
I've never seen such things done in games.
jotd is offline  
Old 13 January 2021, 15:37   #8
Exodous
Registered User
 
Join Date: Sep 2019
Location: Leicester / England
Posts: 203
If it is not defined as being an official source of random number generation then it must be considered "undefined".

Technically, this means your operation could have failed on any legitimate hardware if a minor tweak or revision was made that meant your view of "randomness" was no longer present.
Exodous is offline  
Old 13 January 2021, 16:22   #9
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
It is fully emulated if 68000 and more compatible (prefetch) enabled. Returned data is not random.

68040+ has always returned either all zeros or all ones when reading unknown memory address.

Some 68020 configs may have returned something else but it has never been accurate. (Most likely this isn't random either but returns something from some buffer)
Toni Wilen is online now  
Old 14 January 2021, 14:04   #10
Waxhead
Registered User
 
Join Date: Nov 2020
Location: Etne / Norway
Posts: 12
Exodous : Yes , you are correct - but no minor tweak was apparently done which means that the behavior as far as real Amiga's goes should be "defined". E.g. we can at least say that most Amiga's did behave either so or so.

Toni: Well on my real hardware (which is packed away somewhere) I had a A500 with a GVP HD8+ and a Microbotics VXL030 accelerator (+ ramboard). The CPU was a 68EC030 at 40Mhz and my program worked perfectly (despite being coded badly) on both that CPU and the regular 68000. If I recall correctly it was only tested on kickstart 2.04 and 3.1.

I can't find any option in fs-uae-launcer that allows me to set anyting more accurate than what I have (some help about what options would be appreciated).
I tested with various CPU's and I was NOT able to replicate the behavior you describe. I got all 0xFF back all the time.

And I talked with my friend again - he says that no matter what CPU was used on WinUAE 3.20 or before it always worked e.g. always returned some random(ish) value. After 3.20 and with the latest version it return 0. He also tested with and without JIT and various other options. No effect.

We did a comparision back in 2017 ( picture: http://www.se2a1.net/tmp/UAE_vs_REAL.png )
This are screenshots of a program that shows byte reads from memory run under real amiga + uae 3.20 and uae 3.50+. The output is colored (how it is colored, we don't remember)

ROW 1 = $BFE000 to $BFEF00
ROW 2 = $BFE001 to $BFEF01
ROW 3 = $BFD000 to $BFDF00
ROW 4 = $BFD001 to $BFDF01

There is a difference....
Waxhead is offline  
Old 14 January 2021, 16:35   #11
FrodeSolheim
FS-UAE Developer
 
FrodeSolheim's Avatar
 
Join Date: Dec 2011
Location: Førde, Norway
Age: 43
Posts: 4,043
@Waxhead The easiest is to use one of the Amiga 1000, Amiga 500 or Amiga 600 models with default settings. Then you'll get a cycle-exact 68000. When you use the Amiga 4000 model, you get a CPU without cycle-exact (and without compatible/prefetch) by default, even if you change the CPU model.
FrodeSolheim is offline  
Old 14 January 2021, 17:01   #12
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
I think you only got "lucky" with your board. I just tried A500 + Hurricane 530 and only get $FF. It probably depends on board's data buffers and how they work.
Toni Wilen is online now  
Old 14 January 2021, 17:23   #13
Waxhead
Registered User
 
Join Date: Nov 2020
Location: Etne / Norway
Posts: 12
@FrodeSolheim: Ok thanks, this is about what I have done so I should be good.

@Toni Wilen: Ok understand, but I got a friend that has many Amiga's. I'll ask him if we can try this out on MANY machines. A500, A1200 etc... it will probably take some time but if we get this done it will be interesting to see the results!
Waxhead is offline  
Old 14 January 2021, 17:25   #14
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
Quote:
Originally Posted by Waxhead View Post
@Toni Wilen: Ok understand, but I got a friend that has many Amiga's. I'll ask him if we can try this out on MANY machines. A500, A1200 etc... it will probably take some time but if we get this done it will be interesting to see the results!
Probably every accelerator board can have slightly different behavior

I have lots of A1200 boards (and other models and everything) but testing is so boring..

Actually _every_ undefined address space should be checked. Which makes it even more boring..

EDIT: This needs two tests: one that reads register multiple times in a loop and another that reads it one by one not in loop. Because what usually happens is that data buffer(s)/latches keep the old value and when reading memory address that does not drive the bus, it reads the buffered value. Or all zero or all one if there are pullup or pulldown resistors. Two tests are needed because we want to see if data is always the same when CPU does not do any other accesses (=whole loop in caches) and if CPU prefetches affect the result.

Last edited by Toni Wilen; 15 January 2021 at 08:42.
Toni Wilen is online now  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple copper waits beyond 255 Auscoder Coders. Asm / Hardware 8 29 July 2019 12:56
$BFE400 / $BFE500 from Winuae 3.3.0 and forwards responds with 0 StoneOakvalley support.WinUAE 6 06 August 2017 23:18
BUG: World Class Leader Board (Returns to title screen) killergorilla project.Killergorilla's WHD packs 18 18 December 2007 17:14
An old friend returns... SabreGolly Retrogaming General Discussion 2 22 August 2003 04:01
Batman Returns Rockercute28 support.Games 1 29 October 2002 10:06

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 18:43.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12490 seconds with 15 queries