Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Matrefeytontias on January 08, 2014, 05:56:06 pm

Title: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: Matrefeytontias on January 08, 2014, 05:56:06 pm
Hey guys,

As it turns out the bitmapper I wrote for Worms was respectabily fast, I thought that some people would like to use it for their projects. It has ASM in it, so be sure you copy it correctly.

So first, here's the actual code. Sorry to not provide an 8xp file, but I'm posting from my phone as I have no PC for a while :/ instructions on how to use it are below it.

:~1
:For(64)
:+1
:Asm(E5)
:Copy(->r1+CamY* MapW + (CamX/2/2/2)+ MapPtr, r1*12+L6, 12)
:Asm(E1)
:End
:
:If CamX^8
:->r3
:For(r3)r
:Horizontal-
:End
:
:~1
:For(64)
:Select(+1,{->r1+CamY* MapW +(CamX/2/2/2+12)+ MapPtr} and (e^(8-r3->r4)-1 xor EFF)Asm(5D)r4Asm(45CB3B10FC6B) or {r1+1*12-1+L6->r2}->{r2})
:End
:End


At least it's more understandable than Runer's code.

So yeah, don't worry, I had a hard time copying it here too :P

How to use that thing :
Just copy-paste that bunch of code at the place in your program where drawing occurs, and since the whole screen is covered with the map, you don't need ClrDraw anymore, and don't need to maintain the map in an external buffer either. Just keep your plain map for the engine, no need to modify it for scrolling.

If you use that code in your program, it'd be cool to give me credits just for it :)

I can't really know how fast it is, since a whole physics engine runs on top of it in Worms (but it's still fast, so I thought it would be worth posting). So, since I have no PC, could someone post speed tests and/or screenshots, to see how fast it is ? Kinda like Runer did for his own bitmapper one year ago (http://ourl.ca/15124) :P

Share your comments :)
Title: Re: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: TheCoder1998 on January 11, 2014, 10:22:16 am
hey thanks, this could come in handy :)
Title: Re: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: Matrefeytontias on January 11, 2014, 11:22:46 am
Alright, so I took a screenshot and made a program, but really it's waaay faster on-calc ...

(http://img.ourl.ca/smoothEngine.gif)

What you have to do is define °MapW, °MapPtr, °CamX and °CamY to the bitmap's width in bytes, the pointer to it, the X coordinate of the pixel to display to the top-left and its Y coordinate respectively, then put prgmSMOOTH where you want to draw the map. :)
Title: Re: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: Sorunome on January 11, 2014, 12:47:21 pm
You always blow my mind matref :P

Suggestion: Greyscale support!
Title: Re: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: Matrefeytontias on January 11, 2014, 12:59:16 pm
Well, you can scroll greyscale images with :
Code: [Select]
:*ptrToLayer2*->MapPtr
:prgmSMOOTH
:StorePic
:*ptrToLayer1*->MapPtr
:prgmSMOOTH
It's just mapping the grey layer to L6, copying this latter to L3 then mapping the black layer to L6. It's just going to be slow.
Title: Re: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: Runer112 on January 11, 2014, 04:53:51 pm
Hey, that looks familiar (http://ourl.ca/15124/283447)... But I'm assuming yours is some combination of faster, more featured, or easier to use than my 2-year-old bitmapper?
Title: Re: [Axe] Free bitmapper/pixelmapper/smoothscroller for everyone
Post by: Matrefeytontias on January 12, 2014, 05:59:23 am
Faster, not sure. More featured, well yours can't redraw the whole screen each frame nor take variables images or sizes. Easier to use, probably.