Quote:
One thing I like from Shiru's examples, is he wrote a whole library of asm functions to handle all common game routines. They aren't explained very well, so I don't use them, but once you write a good 'update PPU with new tiles' asm function, you really don't have to do it again. Every game after that can reuse the same code.
This is how you write fast code in C. Have a huge library of ASM code to handle all basic NES functions.
And if you
need/require something different? What are you going to do then? If you don't have an effective grasp on assembly, then you're at the mercy of someone else's library. This is actually another negative strike against this C environment (it discourages coders for learning assembly until they absolutely have to, or just give up). If you were comfortable with assembly structure, writing any knew library function/routine would be
trivial.
rainwarrior wrote:
Personally I find the most difficult limitation of making games is just the overall scope of content/features and sticking with it for long enough to actually finish the game.
I agree, but what does C or Assembly have to do with any of this? I can think in terms of assembly structure very easily, and write code very effectively and
fast. And while I'm there, in the midst of it, I'm already at an advantage point where I can write something that's effective
and usable, instead of worrying about whether I need to optimize this with assembly support - because the compiler it spitting out some pitifully slow code, or just something that OK or reasonable initially, but ends up compounding into a larger performance issue. Even if you write unoptimized assembly code, you're much less likely to run in this issue.
Quote:
C coding actually helps a lot with being able to finish something; not having to spend as much time coding is a big boon.
I highly,
highly doubt that literally writing code, the physical aspect of typing it out, has any sort of tangible or measurable impact in the grand scheme of writing a game for this platform. And being efficient and comfortable with assembly, negates any issue of trying translating logic into assembly structure.
The act of actually writing code is near meaningless in the grand scheme of things. What takes up time is game design; coming up with tools for making tilemaps, collision maps, AI, specific tweaking to gameplay mechanics and overall design. If know I need to access memory and it needs to be in the structure of a pointer, then it's simple as pie to write the pointer interfacing code. And while I'm there, I can very easily and simply optimize for sequential access (something C compilers for these old system are terrible at, or just straight out don't do it). I'm not talking about voodoo assembly, but your basic everyday building blocks of code.
DRW wrote:
Meh. Proponents of Assembly make it sound like all you need is a bit experience and you can write code as fluently as C. I don't think that's gonna happen very soon.
I can write assembly as fluently, if not better, than C. All things have a learning curve. Are you in it to put something out quick and be done with it? Or actually interested in developing your skills and increasing the performance and scope of projects as you proceed to produce stuffs for this console?
Soon, is relative. It will happen. It all depends if you're willing to invest the time to appropriate the necessary skills, or spend your time fighting with C.
Quote:
C is a huge improvement when it comes to writing code.
In general,
absolutely. But in this context, not even close when it comes with a burden of performance deficits - not to mention other aspects (dealing with predefined design/structure of the compiler setup).
Quote:
To take Shiru's example:
That's Assembly:
Code:
lda my ;multiply my by 32
sta ptr_h ;through shifting
ldy #0 ;a 16-bit var (ptr_h,ptr_l)
sty ptr_l ;to the right for three times
dup 3
lsr ptr_h ;shift
ror ptr_l
edup
lda ptr_l ;add mx as 16-bit value
clc
adc mx
bcc @1
inc ptr_h
@1:
clc
adc #<map ;add map offset
sta ptr_l
lda ptr_h
adc #>map
sta ptr_h
lda [ptr_l],y ;read the value
And that's the same code in C:
Code:
n=map[(my<<5)+mx];
And you're point being? I look at the map fetch code and the first thing I think: I need a pointer and an I need to build an index (y shifted by 5, added to x). I could write that in a matter of a minute (clear as day in my head). I've taken more time enjoying a cup of coffee than something like that. That's trivial. And while I'm there, do I need sequential access to fetch rows or columns? If this is for collision purposes, how many tiles do I need to access (tile grid alignment in relation to the object offset)? I can easily optimize accordingly and/or adapt it for future needs.
Quote:
How many times did I run into this error: LDA SomeConstantValue and the program didn't work? Yeah, it should have been LDA #SomeConstantValue, but it took a lot of time to find this out. This cannot happen in C.
That's the noobish/rookie-ish level mistake, though. When you post something like this, that tells me you have no experience with assembly. Does it happen? Sure. Is it easily tracked down?
Very easily. Matter of fact, when you write your own code in assembly - you can automatically and easily identify it in the debugger. It makes the debugger so much more effective and useful. Have you ever tried wading through C generated assembly code in a debugger (even if it has symbol support)? It's a mess and it slows things down.
Quote:
For example, in my game, in the moment there is only one thing that takes an overly long time that I might have to optimize: The collision checks when the player character attacks. As long as you don't press the attack button, there is a huge part of unneeded time per frame. So, what would I have gained from using Assembly right from the beginning?
Quote:
On the other hand, if I try to imagine what it would have been writing the MovePlayerCharacter function in pure assembly: I might have quit out of frustration long ago.
Quote:
But imagine you finish the game in C (and some low level and time critical Assembly stuff). Then you will have finished it long before you would have finished the game in Assembly.
How long have you been coding for the NES? What have you put out so far? How long have you been working on your current project? If took 3 to 6 months learning and writing assembly structured code (practice; writing experimental routines and getting feedback), you'd already be in the proper mindset to avoid a lot of problems you're exaggerating about. Quitting out of frustration??? You're
coding for the NES! If you've lasted this long, then assembly is nothing. It's just a processor; there are more advance things to consider and work with than simply writing assembly code for a processor (like the video and audio eccentrics and limitations)
I understand people
want that C environment and will put up with whatever in order to make it work. I'm just stating that it's not the shortcut people think it is. At some point, you're going to have to bare the burden of learning assembly - or allow that untapped potential to go to waste. If you want to make that choice, that's fine. But I one should know exactly what they're getting into, and if the investment into this console is more than a passing phase - there are more optimal ways to spend that time. Anything worth doing, requires work. If you're afraid of work - then the NES isn't the right system/environment for you. You're dealing with some severe limitations here. If you're afraid of assembly because it looks daunting or alien, that's only because you have familiarized yourself with it. Assembly is easy. Do you have to re-invent the wheel sometimes? Definitely, but you've now developed in deeper understand of that wheel in relation to where is belongs. That's what the NES represents in terms of coding, structure, and approach.
What I find though, is people making comments about C and assembly, with authority, when they clearly have little understanding of coding in Assembly - and all that it entails. If you can't write effective and efficiently in assembly, easily think about logic in terms of assembly structure - then you really don't have anything valid to contribute on the matter. Insecure defensive excuses and falsehoods, don't help people that might be on that fence - who have a longer investment or view point in developing for this console, who might want to reach the level of commercial software. If your set on using C, then that's perfectly fine. I'm not here saying don't use C. Use whatever you want. But making false statements or over exaggerations about the negatives perceptions of assembly language, helps no one. It comes off as people reassuring their own defense mechanisms and avoiding their insecurities.
I'm not interested in debating what is appropriate for you, personally. I'm just stating the facts and dispelling the exaggerations about assembly. I think someone should know the specifics and truth, before deciding which path to take - or continue on.