It is currently Fri Nov 16, 2018 9:08 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Jan 10, 2018 6:58 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 526
I stumbled upon a couple of FDS games that do something that seems weird while waiting for a disk to be inserted:
Code:
loop:                   
  LDA $4032               
  AND #$01                 
  BEQ loop                 ;if a disk is currently inserted, loop (e.g wait for eject)
  LDA $4032               
  AND #$01                 
  BNE loop                 ;if no disk is currently inserted, loop (e.g wait for insert, but the loop goes back to the first check!)

And then others do this instead (which makes a lot more sense to me):
Code:
wait_eject_loop:         
  LDA $4032               
  AND #$01                 
  BEQ wait_eject_loop     
  LDY #$FF                 
  JSR Delayms             
wait_insert_loop:       
  LDA $4032               
  AND #$01                 
  BNE wait_insert_loop
As far as I can tell, the first version can fail to recognize the newly inserted disk pretty often (which would force the user to eject the disk and then reinsert it). This can happen if you the "drive is empty" bit gets cleared while the code is in the first part of the loop (which loops until the disk is ejected).

My 6502 assembly skills are pretty terrible, so I could be understanding this wrong, but I can actually get this behavior several times in a row in the games (Aspic, Ao no Senritsu) that use the first version (e.g doing eject disk -> wait -> insert disk causes the execution to go back to the first loop and the game doesn't react at all)

The only way the first version would "reliably" be able to exit its loop was if the value of the "drive is empty" bit quickly toggled between 0 and 1 a number of times when physically ejecting or inserting a disk?


Top
 Profile  
 
PostPosted: Fri Jan 12, 2018 5:34 am 
Offline
User avatar

Joined: Fri May 21, 2010 4:10 pm
Posts: 291
Which games are these Sour? Would Aspic-Majaou no Noroi be one of them? This was something that was fixed in nestopia before by martin, under better disc drive emulation. It takes multiple times to get this game to load as a lot of the time ejecting/inserting the disk does nothing.


Top
 Profile  
 
PostPosted: Fri Jan 12, 2018 6:43 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20772
Location: NE Indiana, USA (NTSC)
Sour wrote:
The only way the first version would "reliably" be able to exit its loop was if the value of the "drive is empty" bit quickly toggled between 0 and 1 a number of times when physically ejecting or inserting a disk?

You mean like switch bounce?


Top
 Profile  
 
PostPosted: Fri Jan 12, 2018 2:46 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 526
*Spitfire_NES* wrote:
Would Aspic-Majaou no Noroi be one of them?
Yes, Aspic is one of the 2 games I found that have this problem. Thanks - I'll try to hunt down the change that was done in Nestopia's code for this.
tepples wrote:
You mean like switch bounce?
Exactly what I was hoping to hear! I expected this might be a thing, but my knowledge of electronics is rather limited. If this happens on the FDS, it would make a lot of sense.


Top
 Profile  
 
PostPosted: Fri Jan 12, 2018 2:48 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7714
Location: Seattle
Switch bounce usually only happens in one direction (the "making contact" direction)..


Top
 Profile  
 
PostPosted: Sat Jan 13, 2018 9:44 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 526
lidnariq wrote:
Switch bounce usually only happens in one direction (the "making contact" direction)..
It could probably still explain this, since the buggy loop occurs while waiting for the disk to be inserted, which would presumably push on a switch?

Also, I took a look at Nestopia's code, but it didn't look like anything special was being done for that flag. And Nestopia itself doesn't work properly with Aspic, either (need to switch the disk a bunch of times before it finally works)


Top
 Profile  
 
PostPosted: Sat Jan 13, 2018 10:38 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6953
Location: Canada
Sour wrote:
lidnariq wrote:
Switch bounce usually only happens in one direction (the "making contact" direction)..
It could probably still explain this, since the buggy loop occurs while waiting for the disk to be inserted, which would presumably push on a switch?

I think the switch could be either... push to connect or push to break (my gut says the latter), but there's trivial ways that could either be a high or low signal by the time you read it. The Wiki's pinout says it's low when "media set" at least when coming in to the RAM adapter.


Top
 Profile  
 
PostPosted: Sun Jan 14, 2018 1:36 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7714
Location: Seattle
Briefly looking around for videos of people disassembling the drive itself, I think I see a big normally-closed switch on the side with yellow wires (that is opened by inserting a disk). But the people who uploaded the videos also comment on there being multiple switches inside (there's obviously also the limit switches for seeking to end and beginning), so I'm not certain if I'm both seeing that big one correctly and if it's also the one that detects insertion.


Top
 Profile  
 
PostPosted: Sun Jan 14, 2018 4:58 pm 
Offline
User avatar

Joined: Fri May 21, 2010 4:10 pm
Posts: 291
Hey Sour, sorry i prob should have clarified, this fix was seemingly implemented into nestopia 1.33. I think in subsequent versions martin may have overwrote these fixes in fds since he obviously made many fixes to fds.cpp since then.

Here's a snippet from the changelog for that version:

* More accurate FDS disk drive emulation. Fixes "Aspic-Majaou no Noroi", "Hao Kun no Fushigina Tabi" and possibly others.


Top
 Profile  
 
PostPosted: Fri Jan 19, 2018 7:15 pm 
Offline
User avatar

Joined: Fri May 21, 2010 4:10 pm
Posts: 291
Have you had any luck with this Sour? I tested out nestopia 1.33 and this bug is not in there. I also downloaded the source as well if you are interested in that version. :beer:


Top
 Profile  
 
PostPosted: Sat Jan 20, 2018 1:26 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 526
*Spitfire_NES* wrote:
Have you had any luck with this Sour? I tested out nestopia 1.33 and this bug is not in there. I also downloaded the source as well if you are interested in that version. :beer:
I took a look at the differences between 1.33 and 1.34 before my previous post - but there was a pretty large amount of changes in the FDS code between both versions, which makes it hard to figure out what change might have altered the behavior (esp. since Nestopia's FDS implementation is huge, ~2.5k lines)

Taking a bit of a break from Mesen at the moment, since I've spent far too much time on it in the past weeks between releasing 0.9.4 & porting it to libretro - I'll probably take another look at this at some point, though.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group