Since it is like 35 years ago I seriously coded 6502 I'm currently a bit rusty, but I'm trying to figure out a decently fast sorting algorithm for small arrays like for a list of Y-values of objects that are to be displayed on the screen as the scanlines passes by. This must be something that is quite common and already solved many times over for 2600 games. I did my own version of a bubble sort that is kept sorted byte-by-byte as I move the Y-values from the objects into the array of sorted data that is used in the kernel display loop. It is significantly larger in code size than the standard bubble sorts I found for 6502, but it performs rather well both for data that is already pre-sorted and data that is in reverse order.
In the table below the first three entries are for my code the last two is something I found on the net. (This is for sorting 8 bytes)
; First value is the number of scanlines required for pre-sorted data,
; second is for data that is fully reverse order.
; Yellow 3.0 - 7.5 (369 bytes) Continous Unrolled
; Orange 7.4 - 12.0 (262 bytes) Continous Subroutined
; Red 4.0 - 9.0 (138 bytes) Continous Fallthrough
; Blue 2.4 - 29.9 ( 51 bytes) Bubblesort
; Green 12.1 - 14.0 ( 53 bytes) Optisort
But spending 4 to 9 scanlines of time for sorting just eight bytes seems like a very long time. I guess you guys have something much better for this, or is it what's actually expected time wise ? Here's a visual comparison of the data from the above table:
[Edit: Seems like attachments are auto-displayed so I removed it from the post itself]