It is currently Tue Nov 21, 2017 12:42 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: I'm stumped >_>
PostPosted: Tue Mar 03, 2009 2:19 pm 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 214
Location: Fort Wayne, Indiana
I'm kinda new to NES programming, and my first project is a simple platformer...
On the real NES, and in Nestopia, my character flickers badly, but it works just fine in FCEUX for some reason...
If anyone can help me find what the problem is, I'd really appreciate it...
NovaNES.zip


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 2:48 pm 
Online
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2136
Location: Minneapolis, Minnesota, United States
First off, welcome!

I only briefly looked over your code, but I don't think that you're doing sprite DMA in Vblank. Put the lda #2 sta $4014 in the NMI routine, and see what happens.

EDIT: Also, your ASM file is quite messy. Perhaps you should use borders like ";***********" and keep all code indented by the same amount. And I would also suggest making comments indented to the same spot. That's just a suggestion; I find it easier to debug when the code is organized. Though if you can work with it, then do whatever you want :) .

And I also should mention that there's no need to add $800,x to the RAM clearing loop. $800 is a mirror of Zero Page, so you're essentially clearing the same spot twice (though you're using absolute addressing and taking more time/space).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 7:16 pm 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 214
Location: Fort Wayne, Indiana
Celius wrote:
First off, welcome!

I only briefly looked over your code, but I don't think that you're doing sprite DMA in Vblank. Put the lda #2 sta $4014 in the NMI routine, and see what happens.

EDIT: Also, your ASM file is quite messy. Perhaps you should use borders like ";***********" and keep all code indented by the same amount. And I would also suggest making comments indented to the same spot. That's just a suggestion; I find it easier to debug when the code is organized. Though if you can work with it, then do whatever you want :) .

And I also should mention that there's no need to add $800,x to the RAM clearing loop. $800 is a mirror of Zero Page, so you're essentially clearing the same spot twice (though you're using absolute addressing and taking more time/space).

That fixed the flicker, but Nova still disappears when he faces left... I think I should compare my source to an earlier copy that didn't have that problem...

Yeah, I really should use borders... I started adding them in the areas I needed to refer to often, the main loop and the column updating routine...
The indenting... a lot of the code came from a lot of places, some of it's just left over from Tepples's little tutorial thingy, and some I copied from a Super Mario Bros disassembly, (The raster timing thing...) so I haven't indented it all my way just yet... at least it's a bit cleaner than that Turd Racing demo I made for the Pokemon Mini... that thing's source was very ugly...
[edit] I fixed my source. Apparently I was doing DMA crap in my column updating routine I shouldn't have


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 9:34 pm 
Online
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2136
Location: Minneapolis, Minnesota, United States
I'm glad you fixed your problem.

Just as a warning, you should never copy/paste together code. That more than anything will cause bugs. Because all of those different segments of code weren't designed to work together. I've done that and it resulted in a project scrap.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 1:28 pm 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 214
Location: Fort Wayne, Indiana
Celius wrote:
Just as a warning, you should never copy/paste together code. That more than anything will cause bugs. Because all of those different segments of code weren't designed to work together. I've done that and it resulted in a project scrap.

I don't really feel that way... Simple, generic routines written to do common tasks should be easy to reuse, and they have been, for me, at least... I can take a value, pass it through the hexadecimal routine taken from Super Mario world, then pass it to Tepples's hex number printing routine from his Sprite demo, and everything works out okay, though I admit it would be different for complicated, special purpose routines that I don't even understand fully...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 2:01 pm 
Online
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2136
Location: Minneapolis, Minnesota, United States
I think at the very least you could retype it and change variable names and whatnot. That way it would be clean and not headache inducing. You should study the concepts and ideas behind code, and use them to make code that you know fits your needs and only your needs. It not only gives you practice coding and makes you a better programmer (trust me, it makes you a -much- better programmer), but you save yourself from creating the Frankenstein monster out of code. And on the NES, a lot of the time the space and time are so limited that people don't make general purpose routines. They try and get away with doing as much as they can at one time. Though there are some cases where I guess things are more separate.

If you can make sense of those routines and you are fully aware of what you're doing, then I guess whatever. I do think however using someone else's timed code is extremely risky though.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 4:44 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10117
Location: Rio de Janeiro - Brazil
I agree with Celius. There are 2 big issues with copying other people's code: 1. It may do things you are not aware of that screw up tour logic; 2. If the code is correctly prepared to be reused (very common from homebrew coders, but not from commercial games, I guess), it will not be as efficient as it could, because it has to be generic enough to cover most cases.

The second problem is not a big deal, because if you eventually bump into performance issues you'll probably find a way to optimize things. However, the first problem can be pretty disastrous. I absolutely never use code I haven't written. If I find a piece of code that does what I want, I'll study it like hell and make my own based on it's principles, if I decide that's the best rout.

I can understand though that people sometimes want have a fast development cycle and reuse code, but they should at least retype to fit their formatting and learn what the code does to make sure nothing weird is hapenning. I really think you have to know your own programs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 5:14 pm 
Offline
User avatar

Joined: Tue Jul 03, 2007 1:49 pm
Posts: 969
Ya for example. The init code on the wiki. I ASSUMED that cleared the ppu. It didnt.....causing weird problems on (ironicly) a famiclone. Btw thanks to the guy that fixed it for me. (cant remember his name wil have to look at irc logs)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 6:01 pm 
Online
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2136
Location: Minneapolis, Minnesota, United States
Well the only real init code that applies to pretty much any game is:

Code:
   cld
   sei
   ldx #$FF
   txs
   lda #$40   ;I think this is right
   sta $4017
-
   lda $2002
   bpl -
-
   lda $2002
   bpl -


Pretty much any game will have that. Immediately after that though, if you're not updating your palette in the NMI you'll want to do it next. Because the palette can't be written to outside of natural Vblank or Hblank. Once it exits that second wait-for-vblank loop, it will be in natural Vblank, thus allowing you to write to the palette.

tokumaru wrote:
I really think you have to know your own programs.


My thoughts exactly. Though I do like the idea of writing your own library of routines that you just kind of latch into new projects. But like you once said, you should not make programs sacrificing things just so they're easy for the programmer to manage. The 3 most important things to be concerned about are: time, space, and flexibility. Many argue over which of the 3 is more important (I'm pro-flexibility), but those things are way more important than manageable code. Though with a modern day PC, it's pretty safe to put manageability first for small programs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 6:15 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 1518
Location: Fukuoka, Japan
I don't totally agree with everyone here but hey, you always need someone that says the opposite ;)

tokumaru wrote:
I can understand though that people sometimes want have a fast development cycle and reuse code, but they should at least retype to fit their formatting and learn what the code does to make sure nothing weird is hapenning. I really think you have to know your own programs.


It really depends what you're trying to re-use. For example, if I'm trying to re-use someone sound engine (which is a complicated part of a game engine) and it's working well for me, why should I rewrite it? It someone make some common routine that have been tested and working well, why should I re-write it my own way? You just include it and that's it, as long that it's in a separate module.

Not everything needs to be re-written if it does the job. It just that we don't really have a "library" of common use methods for nes so re-usability as been quite scarce for me on that platform.

So my opinion is that it's on a case by case basic. There is no black or white for this: you have to evaluate the re-usability of the code. Tightly optimized code for a specific situation in a specific game may not be re-usable but a module with specific functionality could be.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 8:43 pm 
Online
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2136
Location: Minneapolis, Minnesota, United States
Banshaku wrote:
For example, if I'm trying to re-use someone sound engine (which is a complicated part of a game engine) and it's working well for me, why should I rewrite it? It someone make some common routine that have been tested and working well, why should I re-write it my own way?


Maybe it's just me, but don't you feel kind of bad copying and pasting someone else's code? I feel cheap doing it, like I didn't work for it. And also, aren't there like legal issues regarding that? I don't know much about that.

Also you should rewrite it because it gives you practice programming and you may catch a bug that would be caused if you just copied/pasted it. And I used to think in those books like "C for dummies" that you don't need to do the practice exercises if you understand what they're saying. But then there came a point where I actually decided to do one of the practice exercises later in the book and I had trouble doing it because I kept forgetting things that I'd previously learned but never exercised. Just little things like rewriting code give you practice and in the long run make you way better at programming.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 9:07 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 1518
Location: Fukuoka, Japan
Celius wrote:
Maybe it's just me, but don't you feel kind of bad copying and pasting someone else's code? I feel cheap doing it, like I didn't work for it. And also, aren't there like legal issues regarding that? I don't know much about that.


No if the code was meant for that in the first place. For example, when I'm using the Famitracker sound driver, I'm not copy pasting the code: I'm just including the module to my project with the linker provided by cc65. In that case this is not copy & paste practice at all, I'm just re-using a module that was made available for this purpose.

Regarding legal issues, it depends what the author decided to put the code under which licence.

Celius wrote:
Also you should rewrite it because it gives you practice programming and you may catch a bug that would be caused if you just copied/pasted it.


If it's only a few lines of code that you saw in a sample that uses specific variables (i.e. is not a function that you can call easily) then yes, you have to re-write it since the code could be very specific to this sample and it could have some impact when using. When it's a fully independent module then no, you don't have to. So basically, you have to use your own judgment to see what you have to re-write or not.

On the nes it may not be easy to reuse code since it may be too specific for the game but on other platform this is more common.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 05, 2009 5:27 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3484
Location: Indianapolis
I ripped code all the time when I was learning how to program, for one thing I know I have old controller reading routines that strobe before reading controller #2 (unnecessary) because I originally ripped that out of something by Snowbro. I rewrote it once I knew how the controller ports actually worked.

Other code I've used (that I can think of):
A psuedo-random number generator by kevtris, which he translated from the TTL Cookbook into 6502 asm. Munchie Attack relies on it. I also had translated it to PIC asm for testing an audio filter.

Of course I've used Nerdtracker 2 extensively. I'm starting to use Famitracker. I've also used MCK, experimentally.

Filepack by Mickael Pointer, LZ77 codec for 6502 (Oric computer, but it's good on NES).

Packbits by tepples, RLE codec. I also have my own RLE, but it's more for RLE encoding on NES itself.

I can top all this off with Garage Cart #2 that I'm organizing, it has contributions from least 2 dozen people from all over the world. I have to rip, hack, pack, and bugfix all this (all w/ permission of course).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 05, 2009 7:31 pm 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 214
Location: Fort Wayne, Indiana
Yes, I 'borrow' until I get around to writing my own version, but a big part of this project is modularity, so being generic is pretty important in this case, too... My vision is a platformer where you can hook in your own characters, weapons, and levels, and play as you wish... I need both flexibility and modularity to accomplish this...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 12, 2009 7:53 am 
Offline

Joined: Thu Sep 15, 2005 9:23 am
Posts: 1194
Location: Behind you with a knife!
WedNESday actually crashed when I tried to run it.

:lol:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 7 hours


Who is online

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