I dunno, but you're stack is there, but you probably shouldn't ever use all of it to even $100, haha. Did you get the debugging to work?unregistered wrote:It reads $0100 and then writes twice to the status register, right? That's pretty safe, to me.3gengames wrote:Go to the debugger, and set a break point for every time it reads/write from/to that location in memory, it won't do anything with your game [besides possibly mess it up]...
8x16 and whatever else unreg wants to know
Moderator: Moderators
Heh, I actually use $FF as my breakpoint location. But that's because I use a good part of page 1 for variables, starting at $0100, since I won't ever need all 256 for the stack. If I'm not mistaken, I use only 32 bytes or so for the stack, the rest is all variables. ZP is also filled with variables, but until I reach the very last byte of it, $FF is a safe place for breakpoints.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Yes, I feel I'm making progress. But, it was too weird and so I changed back to the ROL and so now after pressing select it does something... my meta-sprite returns to the left-hand side of the screen... and then, after that, the controls start working normaly. Each button only completes its ppurpose one time per press. So, it kindof works more now... but if i dont press select, the directional pad does nothing.3gengames wrote:Did you get the debugging to work?
edit: I changed it back to ROL because I wanted to see if select worked. With the ROR I could only press directions on the directional pad. After changing it to ROL I updated my BUTTON definitions:
Code: Select all
BUTTON_RIGHT .equ #00000001b
BUTTON_LEFT .equ #00000010b
BUTTON_DOWN .equ #00000100b
BUTTON_UP .equ #00001000b
BUTTON_START .equ #00010000b
BUTTON_SELECT equ #00100000b
BUTTON_B .equ #01000000b
BUTTON_A .equ #10000000b
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Thank you qbradq for all your code you posted... I can't bring myself to copy it... yet because I learn by trying to fix by myself. : )
Isn't the stack inverted? Is that why you say, "I use a good part of page 1 for variables, starting at $0100"?tokumaru wrote:Heh, I actually use $FF as my breakpoint location. But that's because I use a good part of page 1 for variables, starting at $0100
Last edited by unregistered on Fri Jul 01, 2011 9:03 pm, edited 1 time in total.
He's making the RAM in "pages" of 256.
Page 0=$0000-$00FF
Page 1=$0100-$01FF
And so on. Page 1 is the stck area, it's hard wired. Phen you put something on it, it DE-INCREMENTS the stack. So when you load the stack with FF (LDX #$FF, TXS) it's at the highest point. Most people don't use all of the stack, so sometimes random variables go into the unused space, despite the stack being there. I don't put any there myself, but if I need to, they're going there. I doubt I'll need it though.
Page 0=$0000-$00FF
Page 1=$0100-$01FF
And so on. Page 1 is the stck area, it's hard wired. Phen you put something on it, it DE-INCREMENTS the stack. So when you load the stack with FF (LDX #$FF, TXS) it's at the highest point. Most people don't use all of the stack, so sometimes random variables go into the unused space, despite the stack being there. I don't put any there myself, but if I need to, they're going there. I doubt I'll need it though.
I just meant that since I don't use the whole stack, I put variables in the unused space. So while the stack grows from $1FF down, I have variables from $100 up. As long as the variables don't touch the deepest level my stack goes, that's fine.unregistered wrote:Isn't the stack inverted? Is that why you say, "I use a good part of page 1 for variables, starting at $0100"?
Just a minor point, but I would suggest to avoid doing .equ #00000000 and would do .equ 00000000 instead, then put the # in your code. I know it should work either way, but it's helpful to have your code be as clear as possible that immediate mode is being used (in addition to using all caps for defined constants, like you're doing already).
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
I thought # ment immediate mode.Memblers wrote:Just a minor point, but I would suggest to avoid doing .equ #00000000 and would do .equ 00000000 instead, then put the # in your code. I know it should work either way, but it's helpful to have your code be as clear as possible that immediate mode is being used (in addition to using all caps for defined constants, like you're doing already).
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
My computer got changed or fixed... sorry for missing 3 weeks.
How do I enable the character to move like it used to when pressing a direction? It used to move until you released the dpad direction. Now it only moves 1 pixel per press because of the changes I've been instructed to make. It doesn't check the controller 60 times each second anymore. I don't get it.
How do I enable the character to move like it used to when pressing a direction? It used to move until you released the dpad direction. Now it only moves 1 pixel per press because of the changes I've been instructed to make. It doesn't check the controller 60 times each second anymore. I don't get it.
You should use different kinds of button detection for different game events. For things like menu navigation and shooting for example, you'll want to detect when buttons are pressed, but for walking you'll actually want to react 60 times per second.
Most people just keep 2 button state bytes, one with the buttons that are currently pressed (regardless of their state in the previous frame), and one with the buttons that are pressed now but weren't last frame (i.e. new buttons). Both of them are useful in games.
Most people just keep 2 button state bytes, one with the buttons that are currently pressed (regardless of their state in the previous frame), and one with the buttons that are pressed now but weren't last frame (i.e. new buttons). Both of them are useful in games.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
this is crazy. Here is my code
The wiki code is there in the -Loop part; I commented out the 4 lines and pasted the wiki code... just to see what would happen. It totally suprized me! My figure chose to start moving left and then went on a diagonally north-east path until I stopped nintendulator. Pressing buttons didn't help. I'm so tired... been up all night trying to complete the movement part. There must be some horrible mistake in that code... posting it here to see if yall could figure it out. I'm going to be away from my computer until next Tuesday. We're leaving this morning.. have to get ready. Thank you for reading all of this. Love yall. God, please help me some more. Amen. : )
Code: Select all
lookatController:
lda currControllerButtons
sta lastControllerButtons
LDX #$01
STX $4016
DEX
STX $4016
bit $0100
LDX #$08
-Loop:
;LDA $4016
;LSR A
;ROl currControllerButtons
;DEX
pha
; Read next button state and mask off low 2 bits.
; Compare with $01, which will set carry flag if
; either or both bits are set.
lda $4016
and #$03
cmp #$01
; Now, rotate the carry flag into the top of A,
; land shift all the other buttons to the right
pla
rol a
dex
BNE -Loop
lda lastControllerButtons
eor #$ff ;invert
and currControllerButtons ;AND result with the new state
sta newControllerButtons
RTS ;Controller value in the variable currControllerButtons.
You are not saving the current button status anywhere after reading. Just put "sta currControllerButtons" right below "BNE -Loop". OR replace the whole loop with the following:
I see absolutely no reason for you to be monkeying around with the stack.
I must remind you that copying and pasting code around just to "see if it works" is a terrible way to program. Things end up working by pure luck, meaning you don't learn anything (because you don't know why they worked) and your programs aren't reliable at all, since different circumstances could easily break them.
EDIT: I just want to add that what I meant in my previous messages is that for some game events you should use currControllerButtons (walking, jumping - if you have variable jump heights -, etc.), but for others you should use newControllerButtons (menu navigation, shooting, etc.).
Code: Select all
-Loop:
lda $4016
and #$03
cmp #$01
rol currControllerButtons
dex
bne - Loop
I must remind you that copying and pasting code around just to "see if it works" is a terrible way to program. Things end up working by pure luck, meaning you don't learn anything (because you don't know why they worked) and your programs aren't reliable at all, since different circumstances could easily break them.
EDIT: I just want to add that what I meant in my previous messages is that for some game events you should use currControllerButtons (walking, jumping - if you have variable jump heights -, etc.), but for others you should use newControllerButtons (menu navigation, shooting, etc.).
Last edited by tokumaru on Fri Jul 29, 2011 7:10 am, edited 1 time in total.