It is currently Wed Apr 25, 2018 12:10 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 1443 posts ]  Go to page Previous  1 ... 9, 10, 11, 12, 13, 14, 15 ... 97  Next
Author Message
 Post subject:
PostPosted: Fri Jul 01, 2011 10:13 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2259
unregistered wrote:
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]...

It reads $0100 and then writes twice to the status register, right? That's pretty safe, to me. :)


I dunno, but you're stack is there, but you probably shouldn't ever use all of it to even $100, haha. :P Did you get the debugging to work?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2011 10:33 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10430
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2011 11:35 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
Location: cypress, texas
3gengames wrote:
Did you get the debugging to work?


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. :?

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:
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

(They're in the wrong order but that doesn't matter :).) The ROL started to work right... kindof, Select, Start, B, and A worked now. And now the other half doesn't work... It's the same problem on BOTH ROL AND ROR! :D Select doesn't play the famitone song, but it does fix whatever is wrong with my controller reading code. After pressing select all the buttons do something. :?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2011 8:59 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
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. : )


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

Isn't the stack inverted? Is that why you say, "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.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2011 9:02 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2259
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. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 02, 2011 1:16 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10430
Location: Rio de Janeiro - Brazil
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"?

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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 02, 2011 11:21 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3510
Location: Indianapolis
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).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2011 8:45 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
Location: cypress, texas
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).
:? :( I thought # ment immediate mode. :?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2011 9:02 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19949
Location: NE Indiana, USA (NTSC)
It does, but the immediate mode goes in an instruction, not in the equate statement. The instruction is "LDA #" or "AND #"; its operand is 0.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2011 11:44 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
Location: cypress, texas
tepples wrote:
It does, but the immediate mode goes in an instruction, not in the equate statement. The instruction is "LDA #" or "AND #"; its operand is 0.

Ah! :) Thank you tepples! Thank you Memblers! :D


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2011 8:49 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
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. :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2011 9:23 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10430
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2011 10:05 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
Location: cypress, texas
Ah, thank you so much tokumaru! This seems possible now! :D
Thank you God for this understanding! He always helps. :D


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2011 5:07 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 859
Location: cypress, texas
this is crazy. Here is my code
Code:
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.


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. : )


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2011 5:26 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10430
Location: Rio de Janeiro - Brazil
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:
Code:
-Loop:
   lda $4016
   and #$03
   cmp #$01
   rol currControllerButtons
   dex
   bne - Loop

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.).


Last edited by tokumaru on Fri Jul 29, 2011 7:10 am, edited 1 time in total.

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

All times are UTC - 7 hours


Who is online

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