My laptop crashed at home, while I'm at my parent's place, so I don't really have access to any resources or a compiler. But I wrote a few routines on paper, that I'm posting here so I don't lose them
If anyone wants to test and debug them, go ahead
[Routines deleted]
I've also been working on a binary search for sorted arrays, but that's getting pretty long, so I'm starting to wonder if it'll be of any use
Because the gain in speed of the search algorithm is being taken up by the search process, unless you have really long arrays. Which brings me to another concern, why on earth would you want to sort a list of values? If you could link those values to some other data it would make sense (sorting highscores, keys, sprites, whatever you can sort by some index or value), but the numbers themselves have no real meaning, so sorting them is pretty useless...
In other words, we should come up with something like objects or classes in assembly, that link bits of data together. I have absolutely no idea how to do that yet
Input anyone?
The only thing I could come up with is an array like this:
Code: Select all
Highscores:
.db 7 \ .dw name1
.db 21 \ .dw name2
.db 16 \ .dw name3
.db term
name1:
.db "Vincent",0
name2:
.db "Ben",0
name3:
.db "Tim",0
You could sort that and get the last pointer to find out who has the best score, or whatever. Or you could use this data structure with binary search to get a better average search time for sprites in a game (you know, a map in assembly is a collection of sprite indexes, rendering it requires you to look all the sprites up in memory and putting them on the screen).
Anyway, I'm just thinking out loud here. If anyone has some good ideas, please post them
[More routines deleted]