Re: [cc65] Optimizing C code

Date view Thread view Subject view

From: Shawn Jefferson (sjefferson_at_sd62.bc.ca)
Date: 2003-09-04 17:37:31


>  4. mask is not really needed:
>
>          if (creg != BAKCOL(bmp->mode)) {
>              data |= (creg+1) << plot4cshift[bit];
>          }

This doesn't work (as far as I can tell), since my bit pattern in creg may be 01, 10, or 11.  That's why I turn off the pixel to be painted and then repaint it after.  Or am I missing something here?

>  5. In fact, it is also possible to remove the data variable.

See above.

>  6. The multiplication will kill your performance, so I would try to work
>     around it.
>
>  7. Calling a subroutine for each pixel passing 4 parameters over the stack
>     is a performance problem for itself. I would suggest to use nested loops
>     instead that plot whole rows or the complete picture. Doing this, it
>     would also be possible to eliminate the multiplication (except for the
>     start).

Good points, but I don't see much way around it for a generic plot function that will accept arbitrary bitmap sizes.  This is for a general purpose graphics library for the Atari, not fully optimized for a particular purpose.  I don't see any way around these two issues with this particular function.

>1. and 2. are mentioned explicitly in the docs (coding.xxxx), you may want to
>(re-)read this document.

The x and y values are signed ints because I copied this function from the one that does clipping, and then removed all the clipping code.  I will make them unsigned, since out of bounds values with this function don't make sense.  As for the pre-increment, I have never really understood how or why you would use it, and in all examples of C code I have seen, the post-increment operator is used.  Old habits are hard to break.  I'll try that in the code as well.

Thanks for you help, David and Ullrich!

¯
Shawn Jefferson



----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-09-04 17:40:13 CEST