View Single Post
Old 28 December 2018, 01:07   #10
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,545
Quote:
Originally Posted by E-Penguin View Post
Both approaches are equivalent - blitting from an unmodified source, be it a bitmap or tile. As long as you have a quick way to determine which tile is used per coordinate.

I was thinking further about the mod. It's one of my favourite instructions but boy is it slow. It occurred to me that you could fit a look up table in 300 or so bytes (320 mod anything > 1 would fit in a .byte), using the y position as the array index. Perhaps not worth it for one mod per frame but if you're doing it a lot, maybe something to think about.
A look up table! Of course :O

I'm using mod a fair bit for different things, and I didn't realise how slow it was, so I'll definitely look at something like that on the next pass. Cheers.

I guess something like this could work

output = lookuptable(input & $1ff)

Which would work for any sized input, so long as the table held the results for 512 values.


The approaches are a bit different in that you're saving memory (two image buffers instead of three) and blitting (when you're scrolling, you only need to blit the new tile to two buffers instead of three). But there's advantages to the three buffer approach too.
earok is offline  
 
Page generated in 0.04275 seconds with 11 queries