It is currently Wed Dec 13, 2017 11:58 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: A small input problem
PostPosted: Sat Jul 09, 2005 9:22 pm 
I am working on a "small" NES emulation project, and I have a bit of a problem with some input. My input function seems to work fine for games like galaga (everything works for it), and Pyramid, but Arkanoid and most other games seem to ignore my input.

Here is what I know....

Arkanoid only reads from 4016 and 4017 in one spot, and my emulator reports sending the keystroke AND it getting loaded into the accumulator correctly.

I disassembled the code around here and got this...
Code:
00/8BE3: A5 00        LDA $00
00/8BE5: 85 01        STA $01
00/8BE7: A5 02        LDA $02
00/8BE9: 85 03        STA $03
00/8BEB: A5 04        LDA $04
00/8BED: 85 05        STA $05
00/8BEF: A5 06        LDA $06
00/8BF1: 85 07        STA $07
00/8BF3: A5 08        LDA $08
00/8BF5: 85 09        STA $09
00/8BF7: A0 08        LDY #$08
00/8BF9: A9 01        LDA #$01
00/8BFB: 8D 16 40     STA $4016
00/8BFE: A9 00        LDA #$00
00/8C00: 8D 16 40     STA $4016
00/8C03: AD 16 40     LDA $4016
00/8C06: 6A           ROR
00/8C07: 26 00        ROL $00
00/8C09: AD 17 40     LDA $4017
00/8C0C: 6A           ROR
00/8C0D: 26 02        ROL $02
00/8C0F: 6A           ROR
00/8C10: 6A           ROR
00/8C11: 6A           ROR
00/8C12: 26 06        ROL $06
00/8C14: 6A           ROR
00/8C15: 26 08        ROL $08
00/8C17: 88           DEY
00/8C18: D0 E9        BNE $8C03


Is it just me, or does the ROR after the read from 4016 do nothing. And then, our result from reading 4016 is destroyed with a read from 4017. What's up here? I know I am in error somewhere becuase this ROM works on other emulators.

note: $00 - $08 seem to be 0x00 during every read as well


Top
  
 
PostPosted: Sat Jul 09, 2005 9:50 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1393
It would probably help for you to know that ROL and ROR perform rotation through the Carry flag...

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 5:36 am 
Thanks for the quick response! .... but, I think I have that covered. Here is my code for for a rol...

Code:
int RW6502::rol_op(int arg)
{
   arg <<= 1;
   P[C] = arg >> 8;
   arg &= 0xFF;
   arg |= P[C];
   P[Z] = (arg == 0x00);
   P[N] = arg >> 7;
   return arg;
};


I think I may have figured out the cause for Arkanoid. Aparently it uses a paddle input that gets its input from 4017. There are other games though that still don't work that I know don't uses paddles: Milliped, DigDug to name a couple.


Top
  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 6:08 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1393
Your ROL code is incorrect, as it merely copies the upper bit of the operand into the bottom bit again.

ROL (and ROR, though backwards) should work as follows:

Code:
---   -----------------
|C|<--|7|6|5|4|3|2|1|0|<-\
---   -----------------  |
 \-----------------------/


That is, the OLD value of C gets shifted into the lower bit of the operand, and the upper bit of the operand becomes the NEW value of C.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 7:02 am 
The doc I used looked like this..... which is why my logic was screwed up.

Code:
---   -----------------
|C|<--|7|6|5|4|3|2|1|0|<-C
---   -----------------  |
 \-----------------------/


Thanks SO much for this! Now I can play about 20 different games on this thing! I wish I could buy you pizza or something!


Top
  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 9:02 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1393
Anonymous wrote:
The doc I used looked like this..... which is why my logic was screwed up.

Code:
---   -----------------
|C|<--|7|6|5|4|3|2|1|0|<-C
---   -----------------  |
 \-----------------------/


Actually, your old code was implemented as this:

Code:
---   -----------------
|C|<--|7|6|5|4|3|2|1|0|<-\
---   -----------------  |
       \-----------------/


...but that's beside the point, since I assume you've got it working properly now.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 10 guests


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