I want to optimize my code, but I don't know which is more faster and uses less memory.
If I use variables (uhh, maybe registers?) like OAM or OAM_SUB, It will be more than one statement and thus uses more ROM memory than using API (like oamSet). However, oamSet is a function and it will use call stack, and I have to use oamUpdate to apply the changes so it might be a little more slow
So which is better, variable or API?
Which one is more better, directly setting variables or API?
Re: Which one is more better, directly setting variables or
a few questions:
why do you want to optimize your code?
Is it running too slowly?
Is so, then where is it running too slowly?
Why do the think it is running slowly in this section?
Are you running out of memory?
If so, then how much free memory do you have, and how much more do you need?
running faster and using less memory are two separate and independent goals. However, doing one frequently sacrifices the other.
I am not really sure what you are asking in regards to variables and APIs. Are you asking if setting registers directly is better than using the libnds API for sprites? I suspect that you will find little difference (if any at all) in the performance either way. Since the libnds APIs are easier to understand - I would say they are better - until/unless you can prove why they are not.
Do not worry about this level of performance unless you need to.
why do you want to optimize your code?
Is it running too slowly?
Is so, then where is it running too slowly?
Why do the think it is running slowly in this section?
Are you running out of memory?
If so, then how much free memory do you have, and how much more do you need?
running faster and using less memory are two separate and independent goals. However, doing one frequently sacrifices the other.
I am not really sure what you are asking in regards to variables and APIs. Are you asking if setting registers directly is better than using the libnds API for sprites? I suspect that you will find little difference (if any at all) in the performance either way. Since the libnds APIs are easier to understand - I would say they are better - until/unless you can prove why they are not.
Do not worry about this level of performance unless you need to.
Re: Which one is more better, directly setting variables or
Ah, yes, I know OAM APIs push all the changes in oamUpdate() which are saved by other oam functions, but registers apply changes immediately. Okay, I'll use the way that best fits in my code. By the way, It is better to replace some of calls of <video.h> functions to directly setting registers because the functions aren't complex and just cost some call stack (It is not true if they're "inline")elhobbs wrote:a few questions:
why do you want to optimize your code?
Is it running too slowly?
Is so, then where is it running too slowly?
Why do the think it is running slowly in this section?
Are you running out of memory?
If so, then how much free memory do you have, and how much more do you need?
running faster and using less memory are two separate and independent goals. However, doing one frequently sacrifices the other.
I am not really sure what you are asking in regards to variables and APIs. Are you asking if setting registers directly is better than using the libnds API for sprites? I suspect that you will find little difference (if any at all) in the performance either way. Since the libnds APIs are easier to understand - I would say they are better - until/unless you can prove why they are not.
Do not worry about this level of performance unless you need to.
Re: Which one is more better, directly setting variables or
If you write to OAM or OAM_SUB, you're updating sprites 'immediately' (meaning in the current frame) while using libnds APIs, you're 'preparing' OAMs for an update that you'll do later, probably right when VBlank starts. This is however not really related to performance, but it is surely related to program logic...
Who is online
Users browsing this forum: No registered users and 0 guests