8x16 and whatever else unreg wants to know
Moderator: Moderators
-
unregistered
- Posts: 1193
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
-
unregistered
- Posts: 1193
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Sweet! Thank you tokumaru!
I can move our sprite reguarly now!!!
Thank you 3gengames for those two sentences, they helped me alot
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?
Thank you 3gengames for those two sentences, they helped me alot
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?
-
unregistered
- Posts: 1193
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Code: Select all
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 -
unregistered
- Posts: 1193
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
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.unregistered wrote: So far only half of my controller works... the controlpad part works; A B Select Start don't do anything.
Last edited by unregistered on Wed Jun 29, 2011 11:13 am, edited 1 time in total.
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.
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.
-
unregistered
- Posts: 1193
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
No... well, I did a long time ago, I remember.tepples wrote:Have you tried swapping around which button does what?
next to each one of these i commented out the value (in the last code up there)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.
Code: Select all
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 #00000001bNo, that is a good idea, thank you... now, yes they are workingtepples 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?
I've never stepped through anything. Do you have any tips/suggestions? I'm going to use Nintendulator.tepples wrote:Have you tried getting on a PC running Windows and stepping through react_to_input using FCEUX or Nintendulator?
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.
-
unregistered
- Posts: 1193
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
tepples, thanks for these instructions!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.
How can i find out what the line number address is just before jsr react_to_input?
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.
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.