Arrgh, another large post typed, and lost. Let's try that again.
I'll start by repeating that I actually like the 65816, and I've probably done as much code on it as I have the 68K.
Exophase wrote:I'm not really sure if you're saying you posted execution or overall size when you say that.
Well, my reply was in response to you saying that "4 times as many instructions executed" needed backup. I could have used a loop in my example, but I didn't, because although it would have looked shorter on paper, it would have been more instructions executed. I also pointed out that the 65816 version might be smaller cycle-count wise. Sorry, I thought that was pretty clear.
Exophase wrote:Even if a typical level in a game is more than 4096 pixels in both directions (I'm skeptical)
In a 16 bit game? Most games I've seen scroll 2 pixels per frame or faster. 1 pixel looks very slow. It takes no time at all to scroll 4096 pixels...
Exophase wrote:I would be pretty surprised if any significant percentage of SNES games did use 32bit coordinates, do you have a reference on this?
No, of course I don't, do you have a reference that says they don't?
But I know that some do, and I'm sure a LOT do, because contrary to what you might think, it makes perfect sense to do so. However, that doesn't really matter. If you were to look, you'll find a significant number of SNES games use 32 bit addition *somewhere*, even if not for coordinates. I can say that with a lot of confidence. The SNES hardware multiply is insanely quick, and returns a 24 bit result. Games are definitely going to use it, and are definitely going to want to add results - and as I already mentioned, 24 bit adds are more work than 32 bit ones.
Again, the code was only an example. Maybe tomaitheous can provide an example showing the 65816 using
less instructions than the 68000. I'm sure other people can provide many more examples like mine.
Exophase wrote:Doing a 32bit coordinates is a bad approach for a 16bit platform, especially 65c816, and your example worked by taking code written with 68k in mind then adapting it.
It isn't, and as I said before, and will again - I didn't. This is production SNES code. The 68K I just made up on the spot.
Exophase wrote:You keep referring to this as a "simple add" but a 32bit example is quite loaded IMO
What, just because it happens to be something the SNES doesn't do in a single instruction? You seem to be wanting me to produce code thats deliberately limited on the 68K side just to make the 65816 look better. I don't see why I should do that given that we ARE trying to show that the 68000 can do more per instruction than the 65816 can. I haven't deliberately sabotaged the 65816 code, and I could have made it much worse had I wanted to do that. As I mentioned, that is actually real SNES code*, not something I invented to prove a point.
(* ok so its from memory, but given that the code cannot do exactly what it does in any more optimal way, I am confident to say its identical as far as instruction count goes.)
It *IS* a simple add. It's not like it's hideously slow or anything, far from it, and definitely isn't something any SNES programmer would consider a 'bad approach'. It's neccessary, and it's good code. If 16 bit is good enough, you'd do 16 bit on the 68000 too, and it would be faster, and still be less instructions than the 65816 version.
I really wasn't trying to force the issue, but since you don't seem to be convinced, and this isn't a good enough example, I'll give you this one:
There, that's deliberately limited to only 16 bit, and something that will almost certainly appear in a lot of games. How many 65816 instructions is that going to take? If someone can do it in 4 or less, and without cheating by using a huge table, I'll be impressed.
tomaitheous wrote:Expanding your syntax to $xxxx, X would be less confusing/ambiguous or my interpretation of it
Fair enough, the trick I used there isn't immediately obvious to people coming from 6502-land, where they're not used to having 16 bit indexing
tomaitheous wrote:Well, it changes your example
...and my example is part of a larger project where you can't just go around changing the order of things in memory to save two instructions, because you'd have to rewrite most of the game
tomaitheous wrote:You did just that for the 68k - wrote an optimal method
Nah, I didn't

Seriously, to save anything there you'd need to either use 4 INX instructions, and store the data in a slightly strange way, or use 2 and store it in a REALLY odd way. Either way, you'll save, what, 2 instructions max? It isn't worth the saving, and I guarantee you'd just complicate code elsewhere anyway. Plus the 68K code would STILL be way shorter, so you've achieved nothing.
tomaitheous wrote:I hope I don't sound like I'm full of shit
No no, not at all, but I definitely don't agree that your method is 'cleaner'
tomaitheous wrote:None of the projects I've worked on require to have global positions that large updated in realtime
...and I'm not saying that any do, although it definitely makes sense in some games to have things being updated at least some distance from the viewable area. However, it is very nice to be able to use world coordinates. A lot of games have the player coordinate in world space. So you may be in the centre of the screen, but at X=5000 in the world. The scroll coordinates are calculated from there. Other objects on the screen are also in world space. So you see, it often doesn't have anything to do with the size of the screen. It's just a nice way to keep track of things.
tomaitheous wrote:But still, 65536 is 256 screens on the SNES. That's a bit overkill, no?
Yes. But once you've given up trying to cram everything into 16 bits, 32 bit is the next step up, because its less hassle than 24 bit.
tomaitheous wrote:I guess if you needed more than 32768x32768 map, then the 'clc' stays
No, you're missing the point. Think about it. Every time you add a negative value, you're going to get a carry. The clc needs to be there.
tomaitheous wrote:Hmm. I'd have to disagree with that
Well, then I'll tell you why you're wrong
What if you wanted to fire a missile from any point on the screen to any other point on the screen? To get a missile to move from just off the left of the screen, to just off the right of the screen one scanline lower, you'd need at least 9 bit fractions. You'd definitely want more accuracy than that if you wanted these things moving at different speeds, or changing speeds.
Now you may think that that extreme example of moving just one scanline isn't going to happen often. But you still need way more than 4 bits to get any sort of accuracy here, and do you really want to limit what your game engine can do just to save a few cycles? Please say no.
Can you see now why 32 bit is a good idea even if your game DOESN'T scroll?
tomaitheous wrote:16.8+8.8->16.8
That code does not work. Try it. It's also wasteful, and doesn't do 24+24=24

You think its worth a 2 cycle saving?
[edit]oh dear, this thread is now waaay off topic. Sorry,
sheath 