It is currently Wed Sep 26, 2018 12:03 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 1451 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 97  Next
Author Message
 Post subject:
PostPosted: Wed Jun 22, 2011 10:17 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
Is it good to set up the controller reading part with a system that checks each button-part to see if it has already been pressed and so then it should be ignored until it's released?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2011 11:54 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10819
Location: Rio de Janeiro - Brazil
You don't need any complex logic for that. With just a few bitwise operations you can detect all kinds of keypresses. Read this post and the ones after it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2011 2:25 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2263
I have the controller reading code a subroutine, then I put my movement and actions based off the computer in my main engine, I think that'd the standard way of doing things.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 9:51 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
Sweet! Thank you tokumaru! :D I can move our sprite reguarly now!!!

Thank you 3gengames for those two sentences, they helped me alot :D once I finally spent time to understand it.

So far only half of my controller works... the controlpad part works; A B Select Start don't do anything. Do you have an idea of what coould be wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 10:00 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2263
Well, can't tell without the code... :P


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 10:38 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
Code:
lookatController:
  lda ControllerButtons
  sta lastControllerButtons

   LDX #$01
STX $4016
DEX
STX $4016
LDX #$08
-Loop:
LDA $4016
LSR A
ROr ControllerButtons
DEX
BNE -Loop

  lda lastControllerButtons
  eor #$ff ;invert
  and ControllerButtons ;AND result with the new state
  sta pressedControllerButtons

RTS ;Controller value in the variable ControllerButtons.

...

react_to_input:
   
   jsr lookatController

   lda pressedControllerButtons    ; Is the A button down?
        and BUTTON_A ;#00000001b
      beq @b
      inc aFrame        ;run only once per press.
              
@b:      lda pressedControllerButtons      ;Is the B button down?
      and BUTTON_B ;#00000010b
      beq @select
      lda #0
      sta aFrame
      jsr low_c    ;low_c is just small code that plays a note
      
@select lda pressedControllerButtons  ; Select does something(music no working)
      and BUTTON_SELECT ;#00000100b
      beq @start
      ldx <musicA_module ;also songA
      ldy >musicA_module      
      jsr FamiToneMusicStart
      
@start   lda pressedControllerButtons  ; Start does nothing
      and BUTTON_START ;#00001000b
      beq @up
      jsr FamiToneMusicStop
      
@up      lda pressedControllerButtons   ;Is Up  down?
      and BUTTON_UP ;#00010000b
      beq @down
      dec oY
@down   lda pressedControllerButtons ;is Down down?
      and BUTTON_DOWN ;#00100000b
      beq @left
      inc oY
@left   lda pressedControllerButtons  ;is Left down?
      and BUTTON_LEFT ;#01000000b
      beq @right
      dec oX
@right  lda pressedControllerButtons  ;Is Right down?
        and BUTTON_RIGHT ;#10000000b
      beq not_dn
      inc oX
not_dn:   rts 


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 10:59 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2263
Hmm, not sure what it's doing here and I don't know if I can find out. Is it doing anything at all? What isn't happening?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 11:05 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
unregistered wrote:
So far only half of my controller works... the controlpad part works; A B Select Start don't do anything.


A & B aren't working at all, they are susposed to advance and reset the sprite frame. Select and start arent working at alll, they are susposed to start and stop a famitone song.


Last edited by unregistered on Wed Jun 29, 2011 11:13 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 11:12 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2263
Are you ROLing them the right way in your routine? You ROR, I dunno if you ment to do a ROL instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 11:12 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20574
Location: NE Indiana, USA (NTSC)
Have you tried swapping around which button does what?

What are the definitions of BUTTON_A, BUTTON_B, BUTTON_SELECT, and BUTTON_START? They appear not to be present in this page of the discussion or on the previous page.

Have you made sure that A, B, Select, and Start are correctly mapped in the emulator on which you're testing, such as by playing someone else's homebrew game?

Have you tried getting on a PC running Windows and stepping through react_to_input using FCEUX or Nintendulator?


EDIT:
@3gengames: ROR is fine if you prefer little-endian bit order of the buttons in the byte, not unlike how the Game Boy Advance buttons are ordered.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 11:33 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
tepples wrote:
Have you tried swapping around which button does what?


No... well, I did a long time ago, I remember. :)

tepples wrote:
What are the definitions of BUTTON_A, BUTTON_B, BUTTON_SELECT, and BUTTON_START? They appear not to be present in this page of the discussion or on the previous page.


next to each one of these i commented out the value (in the last code up there)
Code:
BUTTON_RIGHT .equ #10000000b
BUTTON_LEFT  .equ #01000000b
BUTTON_DOWN  .equ #00100000b
BUTTON_UP    .equ #00010000b
BUTTON_START .equ #00001000b
BUTTON_SELECT .equ #00000100b
BUTTON_B     .equ #00000010b
BUTTON_A     .equ #00000001b


tepples wrote:
Have you made sure that A, B, Select, and Start are correctly mapped in the emulator on which you're testing, such as by playing someone else's homebrew game?


No, that is a good idea, thank you... now, yes they are working

tepples wrote:
Have you tried getting on a PC running Windows and stepping through react_to_input using FCEUX or Nintendulator?


I've never stepped through anything. Do you have any tips/suggestions? I'm going to use Nintendulator.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 11:49 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20574
Location: NE Indiana, USA (NTSC)
In Nintendulator 0.970, open your ROM and under Debug, choose Disassembly. In the Controls pane of the debugger window, click "Step" to stop your program. Click "Step" a few more times to execute an instruction at a time. In the Trace pane, scroll up and down to see instructions around the program counter. You can double-click an instruction to set a breakpoint. Once you've set a breakpoint on an instruction; the "Run" button in the will run the program until a breakpoint is executed. So if you put a breakpoint just before jsr react_to_input, you can run the program and then step through the subroutine.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 1:51 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
tepples wrote:
In Nintendulator 0.970, open your ROM and under Debug, choose Disassembly. In the Controls pane of the debugger window, click "Step" to stop your program. Click "Step" a few more times to execute an instruction at a time. In the Trace pane, scroll up and down to see instructions around the program counter. You can double-click an instruction to set a breakpoint. Once you've set a breakpoint on an instruction; the "Run" button in the will run the program until a breakpoint is executed. So if you put a breakpoint just before jsr react_to_input, you can run the program and then step through the subroutine.


tepples, thanks for these instructions! :)

How can i find out what the line number address is just before jsr react_to_input?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 2:25 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20574
Location: NE Indiana, USA (NTSC)
That depends on how your assembler outputs listing or map files.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2011 4:02 pm 
Offline
User avatar

Joined: Wed Oct 15, 2008 11:50 am
Posts: 939
What I usually do is put in a dummy instruction and set a breakpoint on that. In Nintendulator you can tell it to break when a certain address is read or written to.

I usually do a bit $0100 to read from the last byte of the stack, something that does not normally happen in my programs. I stick that instruction in wherever I want a break, then set the break point to Read $0100.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1451 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 97  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 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