Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

Ask all programming questions here!

Apr 20, 2014 at 1:58:41 PM
Dreadmoc (18)
avatar
(Iron Worker) < Eggplant Wizard >
Posts: 314 - Joined: 03/02/2013
Colorado
Profile
Sorry guys,

I'm not as far along as you all seem to be at this point, but I just can't seem to find anything.

My question is, if I plan to eventually move my game to a cart, are there certain tools I should avoid? Playing my game on a cart on my nintendo is the end result I'm looking for and I just want to make sure I use the right tools to achieve this.

Thanks guys.

Edit: After going through a rather painful search mission, I gathered a little more information. I read that it is possible with nesasm using powerpak carts, or using new roms after performing some surgery on existing carts. Though the information is limited and I could use some clarification if anyone has the time. Most video tutorial tend to lead back to Nerdy Nights, and I suspect a lot of this information has simply become buried. I'm having a hard time digging it up, I mean.

As far as assemblers go, would I be able to burn a new rom using ca65? As far as pc to cart transfer, what is the better way to go? I know it seems early, but I want to make sure I'm working with the right tools to begin with rather than fiddle around, get used to one and ave to change later.

Thanks again.

-------------------------

            


Edited: 04/20/2014 at 05:34 PM by Dreadmoc

Apr 20, 2014 at 7:49:57 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
Depends on what kind of game you're making. If you're getting into an NROM game as your first one, you shouldn't have any problems with whatever you use. I'd stick with something simple for the first try.

After that, you should know enough to have an idea about what works and what won't.

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Apr 21, 2014 at 12:35:53 AM
Dreadmoc (18)
avatar
(Iron Worker) < Eggplant Wizard >
Posts: 314 - Joined: 03/02/2013
Colorado
Profile
Thanks, man. I will. I watched your youtube videos on The Grind and some of the gameplay. Sweet shit, dude. I guess what you've done is kind of the model i want to use. Though, I was thinking about a game more like Dr. Mario or Tetris for a first go, but I have a long way to go yet. I just got my feet wet.

I managed to download cc65, fceux and run the simple "Hello, NES!" program. Even that was a nightmare. I finally found a good tutorial on how to separate folders, create the batch for the code and convert the file. Sweet deal. Now I am ready for some nerdy nights!

I have a very long way to go, but I took my first baby steps today.

Thanks for taking the time to answer questions and share knowledge, man. I appreciate it.

Nick

-------------------------

            

Apr 21, 2014 at 1:26:47 PM
Shiru (0)

(Shiru Shiru) < Meka Chicken >
Posts: 677 - Joined: 06/08/2011
Russian Federation
Profile
Assembler does not matter. What you should avoid is old emulators, they aren't very precise and may allow incorrect interaction with the hardware. I.e. your program will work seemingly correctly in such emulator, but not on the real console. Latest versions of Nestopia and Nintendulator are good to go.

Apr 21, 2014 at 2:57:10 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
I pasted a lot of code, so I just did a pastebin.

Here is the issue, when I run this code in the ENGINETITLE section:
  LDA #$01
  STA ChangeColor       ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
  LDA #$29                     
  STA attribute_RAM     ;Color to change to $29

My background goes to all zeros. If I take it out, the background loads just fine, but I my color won't go back to color $29.

Basically, I am changing 1 color of the palette duing game play, specifically address #3F11, and I want to reset it to the default value for the Title Screen. In trying to do so, it breaks my LoadBackround Routine and I get all Zeros. The wierd thing is, the background should be loaded well before this point hits. I cannot for the life of me figure out what I am doing wrong.

I have added a pastebin of the relevant code to the 3 process (Color Change, Switching Gamestates, and Loading Backgrounds). I do run the ColorUpdate Subroutine during gameplay to update some colors when the D-Pad is pressed and everything works fine there. It's only at the Title Screen where it breaks it.

http://pastebin.com/Z785aqBB...

Thanks! Hope this makes sense.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Apr 21, 2014 at 3:26:09 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
Originally posted by: Mega Mario Man

I pasted a lot of code, so I just did a pastebin.

Here is the issue, when I run this code in the ENGINETITLE section:
  LDA #$01
  STA ChangeColor       ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
  LDA #$29                     
  STA attribute_RAM     ;Color to change to $29

My background goes to all zeros. If I take it out, the background loads just fine, but I my color won't go back to color $29.

Basically, I am changing 1 color of the palette duing game play, specifically address #3F11, and I want to reset it to the default value for the Title Screen. In trying to do so, it breaks my LoadBackround Routine and I get all Zeros. The wierd thing is, the background should be loaded well before this point hits. I cannot for the life of me figure out what I am doing wrong.

I have added a pastebin of the relevant code to the 3 process (Color Change, Switching Gamestates, and Loading Backgrounds). I do run the ColorUpdate Subroutine during gameplay to update some colors when the D-Pad is pressed and everything works fine there. It's only at the Title Screen where it breaks it.

http://pastebin.com/Z785aqBB

Thanks! Hope this makes sense.

I guess you took out a lot of code to simplify things for us, but it looks like the palette update is running nonstop at the title screen.  Is there other code that only allows that flag to be set at a certain event?

I would try setting those two variables to their respective values as you're changing the gamestate back to the title, and not when it's actually already in the title gamestate.


-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin



Edited: 04/21/2014 at 03:32 PM by KHAN Games

Apr 21, 2014 at 3:39:39 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
You really shouldn't be running your entire code in NMI like that. If that is your whole program, you've removed the actual "run during NMI" part. Like KHAN said, you just run through the code continuously from top to bottom, over and over, and all NMI does is jump in and insert an additional run through in when NMI hits. Take a look through the NN and my tutorials again, it splits it out nicely.

Also, you should be pushing/popping your registers in NMI or it will cause more problems.

Also, and this really isn't important at this point, but if you just have a 0/1 flag, you can use something like:

UpdateColor:
LDA ChangeColor ;make a variable in zero page and set it to #$01 whenever you want this color to change.
BEQ .End
LDA $2002 ;changing the palette (and background tiles)
LDA #$3F
STA $2006
LDA #$11 ;address of specific color you want to change
STA $2006
LDA attribute_RAM ;value of new color you want to change it to.
STA $2007
DEC ChangeColor
.End:
RTS

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.



Edited: 04/21/2014 at 03:39 PM by Mario's Right Nut

Apr 21, 2014 at 4:33:28 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: KHAN Games

 Is there other code that only allows that flag to be set at a certain event?

I would try setting those two variables to their respective values as you're changing the gamestate back to the title, and not when it's actually already in the title gamestate.
 
The only other place that calls for that code is when the a directional pad is pushed only during game play. I only look at the Start Button on the Game Over and Title Screen. During gameplay, the code is skipped unless one of the directions is pressed.

This was the first way I done it. The title screen works fine at first boot, but breaks when called by the Game Over Screeb.  I actually had it like this first:

;-----------------------------------------------------------  
;-----------------------START TITLE-------------------------
;-----------------------------------------------------------
StartTitle:
   
  LDA #STATETITLE
  STA gamestate
    JSR DisablePPU
    JSR LoadBackground
    JSR EnablePPU
     LDA #$01
     STA ChangeColor       ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
     LDA #$29                     
     STA attribute_RAM     ;Color to change to $29
 
StartTitleDone:
  RTS
--------------


And like this


;-----------------------------------------------------------  
;-----------------------START TITLE-------------------------
;-----------------------------------------------------------
StartTitle:
   
  LDA #STATETITLE
  STA gamestate
    JSR DisablePPU
    JSR LoadBackground
     LDA #$01
     STA ChangeColor       ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
     LDA #$29                     
     STA attribute_RAM     ;Color to change to $29
    JSR EnablePPU
 
StartTitleDone:
  RTS

I thought I was doing everything correct for the NMI process, but maybe not. I have all of the practice code downloaded from NN, in fact this program is directly built off the last NN tutorial. I just ripped out the code and inserted mine as I went along.

I thought I was being clever by leaving out the code that is irrelvant to the situation (I just didn't want to paste my code for all to see) but maybe it is leaving out what you were wanting to see. If you want to request it, I would do a temp pastebin for either of you for the entire code. Just know, there are parts that are intentionally left wrong because I haven't cleaned that part up yet or I am not on that step (such as the attributes for the Title and Game Over Screens.

I will run through the tutorials again. I really don't understand what you mean by some of the suggestions such as "you should be pushing/popping your registers in NMI or it will cause more problems", so apparently I misunderstood something in the tutorials.

MRN, thanks for the slight change to UpdateColor, it's cleaner. Never thought to code it that way.


-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter


Edited: 04/21/2014 at 04:45 PM by Mega Mario Man

Apr 22, 2014 at 12:36:18 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
*EDIT* Apparently My spacing didn't work. Going to try to edit this post.

Rewrote the game states to match MRN's #2 tutorial code and this was the result:
1. Flicker stopped on screen transition (found out I was turning the PPU back on too fast, need to let the NMI handle that).

LDA #STATETITLE
STA gamestate
JSR DisablePPU
JSR LoadBackground
JSR EnablePPU <--------REMOVED, NMI NOW DOES THIS PROCESS

2. I was still getting the all 0's title screen when transitioning from the Game Over screen.
FIX: Fixed this by moving the color change code to the transition of the Game Playing Screen to the Game Over Screen. Don't know why it fixed it, it happens at the same point of the other transition. The only difference, the first is called when you hit the Start Button, the second is called when the condition of the time reaching 00 hits.

DOES NOT WORK HERE:
;-----------------------------------------------------------
;-----------------------START TITLE-------------------------
;-----------------------------------------------------------
StartTitle:

LDA GameState
STA GameState+1

LDA #STATETITLE
STA gamestate

JSR DisablePPU
JSR LoadBackground

LDA #$01
STA ChangeColor                                     ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
LDA #$29
STA attribute_RAM                                   ;Color to change to $29


StartTitleDone:
RTS



CODE WORKS HERE:
;-----------------------------------------------------------
;----------------------GAME OVER----------------------------
;-----------------------------------------------------------
CheckGameOver:
LDA time1
BNE CheckGameOverDone
LDA time10
BNE CheckGameOverDone                   ;Check if Time is 00, if yes, change to Game Over State

LDA GameState
STA GameState+1

LDA #STATEGAMEOVER
STA GameState

JSR DisablePPU
JSR LoadBackground

LDA #$01
STA ChangeColor                                    ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
LDA #$29
STA attribute_RAM                                 ;Color to change to $29


CheckGameOverDone:
RTS


Conclussion: I think I rewrote my entire code for nothing. After moving the game state format to match MRN's instead of what I had, I think I just had to tweak my code just a bit to make it correct. Although, I learned a lot and I'm now confused on some more stuff that I still need to figure out. I know the code works, I'm just not fully grasping how it works. I'm happy it's now to a state where I can move forward with my programming and put this behind me.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter


Edited: 04/22/2014 at 12:40 PM by Mega Mario Man

Apr 22, 2014 at 12:48:03 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Moving forward and not understanding is why you don't get it.

Just gonna point out a logical error too: You don't disable the PPU then not enable it. Unless you do it in the NMI, in which your engine should be constructed so that it handles that situation and doesn't turn on rendering during certain events like screen uploading. Your NMI might cause glitches if you don't remember that point. Disabling, then having an NMI happen when "off" in the middle of doing stuff will lead to nasty bugs, that sometimes may or may not be easy to find.


Edited: 04/22/2014 at 04:24 PM by removed04092017

Apr 22, 2014 at 2:07:31 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
Originally posted by: 3GenGames

Moving forward and not understanding is why you don't get it. Just gonna point out a logical error too: You don't disable the PPU then not enable it. You have to enable it (Or at MINIMUM NMI's) forit to be enabled. Your NMI might cause glitches if you don't remember, it can and does happen. Disabling, then having an NMI happen when "off" in the middle of doing stuff will lead to nasty bugs.

Thanks for clearing that up.   ...?


-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Apr 22, 2014 at 2:29:39 PM
Roth (67)
avatar
(Rob Bryant) < Lolo Lord >
Posts: 1777 - Joined: 09/14/2006
Illinois
Profile
Originally posted by: 3GenGames

Moving forward and not understanding is why you don't get it.


Some people learn in different ways. Sometimes advancing beyond your means is helpful and you start to understand more as you go on. I can't tell you how long it was that I didn't even understand how my controls were working with eor and and'ing and all that jazz. But I moved on to learn more stuff. I ended up catching on to that kind of thing. Like I said, some people learn in different ways. No need to talk to the dude like that.


-------------------------
http://slydogstudios.org...

Apr 22, 2014 at 2:31:06 PM
GradualGames (39)
avatar
(Derek Andrews) < El Ripper >
Posts: 1128 - Joined: 10/09/2009
Pennsylvania
Profile
Originally posted by: Roth

Originally posted by: 3GenGames

Moving forward and not understanding is why you don't get it.


Some people learn in different ways. Sometimes advancing beyond your means is helpful and you start to understand more as you go on. I can't tell you how long it was that I didn't even understand how my controls were working with eor and and'ing and all that jazz. But I moved on to learn more stuff. I ended up catching on to that kind of thing. Like I said, some people learn in different ways. No need to talk to the dude like that.
 

Amen. I've been working as a software engineer for 7 years, have a degree in computer science, have published an NES game and working on a second, and it is *still* a challenge to fully understand my own code, let alone code written by others. Turns out you don't need to be a whiz bang, you just have to work hard and love what you do.


-------------------------
Creators of: Nomolos: Storming the CATsle, and The Legends of Owlia.


Edited: 04/22/2014 at 02:31 PM by GradualGames

Apr 22, 2014 at 2:58:27 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Yeah, I was that way in math, but there's a certain level of understanding you need. If you don't understand WHY a chip does what it does, you're missing something fundamental that you NEED to know.

And MRN, I was just pointing out stuff I saw in his code, why bust my balls? Is it a douchy thing to help? Really?

Apr 22, 2014 at 3:03:23 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
Originally posted by: 3GenGames

Is it a douchy thing to help? Really?

The fact that you're helping and not just making fun of someone is a step in the right direction!


-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Apr 22, 2014 at 3:04:55 PM
GradualGames (39)
avatar
(Derek Andrews) < El Ripper >
Posts: 1128 - Joined: 10/09/2009
Pennsylvania
Profile
Originally posted by: 3GenGames

Yeah, I was that way in math, but there's a certain level of understanding you need. If you don't understand WHY a chip does what it does, you're missing something fundamental that you NEED to know.

And MRN, I was just pointing out stuff I saw in his code, why bust my balls? Is it a douchy thing to help? Really?

You just need to learn to state things in a less flatly dismissive way is all. Nothing wrong with pointing out errors or suggesting an approach to a problem. You have to be careful---what you may perceive as really helpful could end up being the opposite. You might even damn someone to a lifetime devoted to revenge. I know because it happened to me  (I was damned to a lifetime devoted to revenge)


-------------------------
Creators of: Nomolos: Storming the CATsle, and The Legends of Owlia.


Edited: 04/22/2014 at 03:05 PM by GradualGames

Apr 22, 2014 at 3:06:39 PM
Roth (67)
avatar
(Rob Bryant) < Lolo Lord >
Posts: 1777 - Joined: 09/14/2006
Illinois
Profile
Originally posted by: GradualGames

Originally posted by: 3GenGames

Yeah, I was that way in math, but there's a certain level of understanding you need. If you don't understand WHY a chip does what it does, you're missing something fundamental that you NEED to know.

And MRN, I was just pointing out stuff I saw in his code, why bust my balls? Is it a douchy thing to help? Really?

You just need to learn to state things in a less flatly dismissive way is all.

Right on.


-------------------------
http://slydogstudios.org...

Apr 22, 2014 at 3:07:38 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
Originally posted by: 3GenGames

Yeah, I was that way in math, but there's a certain level of understanding you need. If you don't understand WHY a chip does what it does, you're missing something fundamental that you NEED to know.

And MRN, I was just pointing out stuff I saw in his code, why bust my balls? Is it a douchy thing to help? Really?
Okay, we can do this.  I've not got in a good nerd fight for a while.  No, helping is not douchy.  However, a lot of the time the way you say things is really douchy.  On top of that, your comments are difficult to understand and often not really correct, at least the way you phrase them.  When I was first starting out people would tell me to STFU if I couldn't be clear and concise.  So, I'll pass that wisdom along, STFU unless you can relay what you're trying to say without coming off as a dick or including any ambiguity.  



-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Apr 22, 2014 at 3:08:36 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
Those three posted while I was ranting. Good job.

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Apr 22, 2014 at 4:02:33 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
No worries, all. I'm thick skinned. Sometimes a good slap to the back of the head with and calling me an idiot is just what i need.

I understand what they set of code does, but I am getting lost breaking it down line by line. For example, WTF is this guy doing except sitting there spinning in circles:

.loop
  LDA sleeping
  BNE .loop

I just can't grasp the concept why it must be there. And there are other things as well, such as pointers and the random [] around some of them, what's up with the period in from of .loop, and many other things. But then I realize, it works, I can repllcate it in other parts of my code and it works, so why worry. I usually learn what they do when I break the code and I have to relearn it.

Now, since this is a coding question thread, I have one for you all. I'm playing with a new way to write text to the screen. I have 100% written this code by hand trying to understand pointers. It kind of works, however, when it comes time to write the word PAUSE on the screen or erase it, I get 0000000000000000000000000000000000000000000 all the way across the screen in the row where PAUSE should show up. I'm trying to do it this way so I can reuse the loop for future text I want to display.

***NOTE*** Ignore the line comments of the code. I robbed this code from other sections of my code and haven't cleaned it up yet.

;Variables Section
TEXTLENGTH .rs 1
TEXTLOWBYTE .rs 1
TEXTHIGBYTE .rs 1
Text_Pointer .rs 1

;Code I added to my Write Pause Subroutine
  LDA #$05
  STA TEXTLENGTH
 
  LDA #$0E
  STA TEXTLOWBYTE
 
  LDA #$21
  STA TEXTHIGBYTE
 
  LDA #$00
  TAX
 
  LDA Texts,x           ;Load the Main Program Pointer
  STA Text_Pointer
 
  JSR LoadText
 
 

;Load Text Loop

LoadText:
  LDA $2002             ; read PPU status to reset the high/low latch
  LDA #TEXTHIGBYTE                                                                                              ; variable
  STA $2006             ; write the high byte of $2000 address
  LDA #TEXTLOWBYTE                                                                                             ; variable
  STA $2006             ; write the low byte of $2000 address
  LDX #$00              ; start out at 0

LoadTextLoop:
  LDA Text_Pointer, x     ; load data from address (background + the value in x)                          ;variable
  STA $2007             ; write to PPU
  INX                   ; X = X + 1
  CPX #TEXTLENGTH           ; Compare X to hex $80, decimal 128 - copying 128 bytes                         ; variable - Character Length
  BNE LoadTextLoop  ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
  RTS
 

;Databases
 
Texts:
  .word PauseText,UnDrawPauseText
 
PauseText:
 .db  $19,$0A,$1E,$1C,$0E     ;PAUSE
UnDrawPauseText:
 .db  $24,$24,$24,$24,$24     ;Undraw Pause

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter


Edited: 04/22/2014 at 04:08 PM by Mega Mario Man

Apr 22, 2014 at 4:06:35 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: 3GenGames

Moving forward and not understanding is why you don't get it. Just gonna point out a logical error too: You don't disable the PPU then not enable it. You have to enable it (Or at MINIMUM NMI's) forit to be enabled. Your NMI might cause glitches if you don't remember, it can and does happen. Disabling, then having an NMI happen when "off" in the middle of doing stuff will lead to nasty bugs.

I don't think it will be a problem because nothing really happens between that code and the NMI. I was enabling the PPU right after the LoadBackground and it was wigging out my screen. Since going this route, my screen issues have fixed. If it breaks future code, then I guess I will be forced to cross that bridge when it happens. The NMI is still and enigma to me, so any advice helps!


-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Apr 22, 2014 at 4:22:24 PM
Roth (67)
avatar
(Rob Bryant) < Lolo Lord >
Posts: 1777 - Joined: 09/14/2006
Illinois
Profile
Originally posted by: Mega Mario Man

No worries, all. I'm thick skinned. Sometimes a good slap to the back of the head with and calling me an idiot is just what i need.

I understand what they set of code does, but I am getting lost breaking it down line by line. For example, WTF is this guy doing except sitting there spinning in circles:

.loop
  LDA sleeping
  BNE .loop

I just can't grasp the concept why it must be there. And there are other things as well, such as pointers and the random [] around some of them, what's up with the period in from of .loop, and many other things. But then I realize, it works, I can repllcate it in other parts of my code and it works, so why worry. I usually learn what they do when I break the code and I have to relearn it.

Now, since this is a coding question thread, I have one for you all. I'm playing with a new way to write text to the screen. I have 100% written this code by hand trying to understand pointers. It kind of works, however, when it comes time to write the word PAUSE on the screen or erase it, I get 0000000000000000000000000000000000000000000 all the way across the screen in the row where PAUSE should show up. I'm trying to do it this way so I can reuse the loop for future text I want to display.

***NOTE*** Ignore the line comments of the code. I robbed this code from other sections of my code and haven't cleaned it up yet.

;Variables Section
TEXTLENGTH .rs 1
TEXTLOWBYTE .rs 1
TEXTHIGBYTE .rs 1
Text_Pointer .rs 1

;Code I added to my Write Pause Subroutine
  LDA #$05
  STA TEXTLENGTH
 
  LDA #$0E
  STA TEXTLOWBYTE
 
  LDA #$21
  STA TEXTHIGBYTE
 
  LDA #$00
  TAX
 
  LDA Texts,x           ;Load the Main Program Pointer
  STA Text_Pointer
 
  JSR LoadText
 
 

;Load Text Loop

LoadText:
  LDA $2002             ; read PPU status to reset the high/low latch
  LDA #TEXTHIGBYTE                                                                                              ; variable
  STA $2006             ; write the high byte of $2000 address
  LDA #TEXTLOWBYTE                                                                                             ; variable
  STA $2006             ; write the low byte of $2000 address
  LDX #$00              ; start out at 0

LoadTextLoop:
  LDA Text_Pointer, x     ; load data from address (background + the value in x)                          ;variable
  STA $2007             ; write to PPU
  INX                   ; X = X + 1
  CPX #TEXTLENGTH           ; Compare X to hex $80, decimal 128 - copying 128 bytes                         ; variable - Character Length
  BNE LoadTextLoop  ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
  RTS
 

;Databases
 
Texts:
  .word PauseText,UnDrawPauseText
 
PauseText:
 .db  $19,$0A,$1E,$1C,$0E     ;PAUSE
UnDrawPauseText:
 .db  $24,$24,$24,$24,$24     ;Undraw Pause


A pointer is going to be a 16-bit number. So where you have.... lda texts, x  sta Text_Pointer... you are loading an 8-bit value. To be super generic about it, you could just do:

lda <#PauseText
sta Text_Pointer+0
lda >#PauseText
sta Text_Pointer+1

Then you would have to use the Y register and not the X. Since the address is in zero page, using (), y will get you want you want:

lda (Text_Pointer), y
sta $2007
iny
;etc etc

Be sure to change Text_Pointer to .res 2, because you want to reserve 2 bytes for it since it is going to be used as a 16-bit address.

Dunno if there's errors in what I said, but that's what it looks like needs to be done to me. Hope it helps! Oh, and the syntax I use is for ca65, you may need to adjust for whatever assembler you use.

-------------------------
http://slydogstudios.org...

Apr 22, 2014 at 4:26:46 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Originally posted by: Mega Mario Man

Originally posted by: 3GenGames

Moving forward and not understanding is why you don't get it. Just gonna point out a logical error too: You don't disable the PPU then not enable it. You have to enable it (Or at MINIMUM NMI's) forit to be enabled. Your NMI might cause glitches if you don't remember, it can and does happen. Disabling, then having an NMI happen when "off" in the middle of doing stuff will lead to nasty bugs.

I don't think it will be a problem because nothing really happens between that code and the NMI. I was enabling the PPU right after the LoadBackground and it was wigging out my screen. Since going this route, my screen issues have fixed. If it breaks future code, then I guess I will be forced to cross that bridge when it happens. The NMI is still and enigma to me, so any advice helps!

More than likely, you touch $2006 in between screen enabling. Look at The Skinny: http://wiki.nesdev.com/w/index.ph...

Basically, $2000, $2005, and $2006 all share bits of a single 16-bit register, so the last thing you need to do in NMI is update $2005 (x2) and $2000. That will more than likely fix your problem.

And lastly, NMI is easy:
Do graphics updates, including map changes.
Do sprite updates.
(Optional) Do sound stuff.
Write $2005 (x2) and $2000 to the correct values.
Return to the main engine to run engine stuff.



Edited: 04/22/2014 at 04:27 PM by removed04092017

Apr 22, 2014 at 4:47:54 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
Originally posted by: Roth

A pointer is going to be a 16-bit number. So where you have.... lda texts, x  sta Text_Pointer... you are loading an 8-bit value. To be super generic about it, you could just do:

lda <#PauseText
sta Text_Pointer+0
lda >#PauseText
sta Text_Pointer+1

Then you would have to use the Y register and not the X. Since the address is in zero page, using (), y will get you want you want:

lda (Text_Pointer), y
sta $2007
iny
;etc etc

Be sure to change Text_Pointer to .res 2, because you want to reserve 2 bytes for it since it is going to be used as a 16-bit address.

Dunno if there's errors in what I said, but that's what it looks like needs to be done to me. Hope it helps! Oh, and the syntax I use is for ca65, you may need to adjust for whatever assembler you use.

Only difference for the NESASM compiler is he'll have to use [] instead of ().  (Assuming he keeps the beginning of his old routine the same.)


-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin



Edited: 04/22/2014 at 04:51 PM by KHAN Games

Apr 22, 2014 at 4:53:59 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: KHAN Games

Originally posted by: Roth

A pointer is going to be a 16-bit number. So where you have.... lda texts, x  sta Text_Pointer... you are loading an 8-bit value. To be super generic about it, you could just do:

lda <#PauseText
sta Text_Pointer+0
lda >#PauseText
sta Text_Pointer+1

Then you would have to use the Y register and not the X. Since the address is in zero page, using (), y will get you want you want:

lda (Text_Pointer), y
sta $2007
iny
;etc etc

Be sure to change Text_Pointer to .res 2, because you want to reserve 2 bytes for it since it is going to be used as a 16-bit address.

Dunno if there's errors in what I said, but that's what it looks like needs to be done to me. Hope it helps! Oh, and the syntax I use is for ca65, you may need to adjust for whatever assembler you use.

Only difference for the NESASM compiler is he'll have to use [] instead of ().  (Assuming he keeps the beginning of his old routine the same.)
 
Sorry, using NESASM.

It dislikes < and >. I'm messing with the code trying different things.



-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter