Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: SirCmpwn on March 26, 2011, 02:30:22 pm

Title: World's Smallest Sprite Converter
Post by: SirCmpwn on March 26, 2011, 02:30:22 pm
Hello,
I whipped up this ridiculously small sprite converter program this morning, for those of you feeling the crunch of less memory.  It will convert the 8x8 sprite in the top left corner of the screen to hex for you, weighing only 60 bytes!  I challenge - no, I *dare* you to make a smaller sprite converter.

Note: This was inspired by re-reading this post: http://ourl.ca/8639/161291 (http://ourl.ca/8639/161291)
Title: Re: World's Smallest Sprite Converter
Post by: Munchor on March 26, 2011, 02:40:21 pm
Hello,
I whipped up this ridiculously small sprite converter program this morning, for those of you feeling the crunch of less memory.  It will convert the 8x8 sprite in the top left corner of the screen to hex for you, weighing only 60 bytes!  I challenge - no, I *dare* you to make a smaller sprite converter.

Note: This was inspired by re-reading this post: http://ourl.ca/8639/161291 (http://ourl.ca/8639/161291)

That looks sweet, but you don't even ClrDraw =P I know it's for the speed and size :P
Title: Re: World's Smallest Sprite Converter
Post by: SirCmpwn on March 26, 2011, 02:41:26 pm
That looks sweet, but you don't even ClrDraw =P I know it's for the speed and size :P
I don't do anything that would take up any size.  I don't even turn off the run indicator.  This is in pure assembly, I'm just displaying the raw bytes from the graph screen.
Title: Re: World's Smallest Sprite Converter
Post by: Munchor on March 26, 2011, 02:46:09 pm
That looks sweet, but you don't even ClrDraw =P I know it's for the speed and size :P
I don't do anything that would take up any size.  I don't even turn off the run indicator.  This is in pure assembly, I'm just displaying the raw bytes from the graph screen.

Will you post the code, though?
Title: Re: World's Smallest Sprite Converter
Post by: SirCmpwn on March 26, 2011, 02:47:01 pm
Will you post the code, though?
Title: Re: World's Smallest Sprite Converter
Post by: leafy on March 26, 2011, 02:58:49 pm
Wow's that amazingly small :O I still prefer a more GUI-based editor though, like your other converter.
Is this supposed to be a proof-of concept thing?
Title: Re: World's Smallest Sprite Converter
Post by: SirCmpwn on March 26, 2011, 03:01:25 pm
Wow's that amazingly small :O I still prefer a more GUI-based editor though, like your other converter.
Is this supposed to be a proof-of concept thing?

Note: This was inspired by re-reading this post: http://ourl.ca/8639/161291 (http://ourl.ca/8639/161291)
Title: Re: World's Smallest Sprite Converter
Post by: DJ Omnimaga on March 26, 2011, 04:12:14 pm
Nice, I guess it's good to see these tools as small as possible, especially if you have many small programs.

I'M starting to wonder if we will need a project/releases sub-forum just for sprite editors, converters and map editors now, though. O.O (no offense)
Title: Re: World's Smallest Sprite Converter
Post by: christop on March 26, 2011, 04:20:00 pm
I took SirCmpwn's challenge/dare. Here's my own tiny sprite converter for the TI-86. It's 39 bytes of code/53 bytes on calc. It might be one byte larger if you port it to the 83+ because you can't jump straight to a bcall (or can you?).

EDIT: Derp, I finally saw the mistake in one of the comments. Where it says "height" in "height of graph screen in bytes", it should say "width". Oh well. :D
Title: Re: World's Smallest Sprite Converter
Post by: leafy on March 26, 2011, 04:22:59 pm
Snap CmPwn your bluff just got called :O
Title: Re: World's Smallest Sprite Converter
Post by: DJ Omnimaga on March 26, 2011, 04:23:18 pm
Nice. I wonder if there are any sprite routines for BASIC programmers on the 86 and if the Asm() command is as slow to launch as the one on the 83+ (due to VAT)? I never got to see an hybrid BASIC game for the 86 before and it would be nice to port some 83+ games using them. (although since 86 BASIC is slower than the 82/83/84/85 it might pose a problem).
Title: Re: World's Smallest Sprite Converter
Post by: FloppusMaximus on March 26, 2011, 10:13:37 pm
Well, at first I thought the challenge was to store the sprite in a string in Ans (so you can recall it into an Axe program.)  Then I looked at SirCmpwn's version and realized the challenge was just to display the string on screen. :)

My first version (store the string in Ans) is 39 bytes of code:
Code: [Select]
        ld hl,16
B_CALL CreateTStrng
inc de
ld hl,plotSScreen
loop1: ld b,2
loop: xor a
rld
daa
add a,-16
adc a,40h
inc de
ld (de),a
djnz loop
ld a,l
add a,12
ld l,a
cp 95h
jr c,loop1
B_CALL OP4ToOP1
B_CALL StoAns
ret
(I feel like this could be optimized a little more.)

My second version (display the string on screen) is 26 bytes of code:
Code: [Select]
ld hl,plotSScreen
loop1: ld b,2
loop: xor a
rld
daa
add a,-16
adc a,40h
B_CALL PutC
djnz loop
ld a,l
cp h
ret nc
add a,12
ld l,a
jr loop1
Title: Re: World's Smallest Sprite Converter
Post by: SirCmpwn on March 26, 2011, 10:21:35 pm
Daaaaaaaaamn
Title: Re: World's Smallest Sprite Converter
Post by: ztrumpet on March 26, 2011, 10:23:30 pm
In 83/84 basic, I got it down to 99 bytes with a one letter program name.  Wabbit crashed upon export, so I have no proof of it, but I doubt if it can get any smaller.

Edit: If I just have to display it, I can make it smaller (if anyone cares). :P
Title: Re: World's Smallest Sprite Converter
Post by: jnesselr on March 26, 2011, 10:26:07 pm
okay, that's why Drew doesn't start with a B.  Nicely nicely done FloppusMaximus.
Title: Re: World's Smallest Sprite Converter
Post by: DJ Omnimaga on March 26, 2011, 10:33:49 pm
okay, that's why Drew doesn't start with a B.  Nicely nicely done FloppusMaximus.
Lol >.> Sir will kill you. :P
Title: Re: World's Smallest Sprite Converter
Post by: jnesselr on March 26, 2011, 10:34:33 pm
okay, that's why Drew doesn't start with a B.  Nicely nicely done FloppusMaximus.
Lol >.> Sir will kill you. :P
Oh, most definitely.  It was fun while it lasted though.
Title: Re: World's Smallest Sprite Converter
Post by: SirCmpwn on March 26, 2011, 10:57:12 pm
/me disembowels graphmastur and shoves his head where the bowels resided until very recently
In all seriousness, I spent less than 5 minutes on this program.
Title: Re: World's Smallest Sprite Converter
Post by: DJ Omnimaga on March 26, 2011, 11:00:38 pm
Wow nice, that's quite fast.
Title: Re: World's Smallest Sprite Converter
Post by: jnesselr on March 26, 2011, 11:01:05 pm
/me disembowels graphmastur and shoves his head where the bowels resided until very recently
In all seriousness, I spent less than 5 minutes on this program.
Wow, how painful.
Title: Re: World's Smallest Sprite Converter
Post by: meishe91 on March 26, 2011, 11:23:42 pm
In 83/84 basic, I got it down to 99 bytes with a one letter program name.  Wabbit crashed upon export, so I have no proof of it, but I doubt if it can get any smaller.

Edit: If I just have to display it, I can make it smaller (if anyone cares). :P

Check the new topic I made in the TI-BASIC sub-forum ;)
Title: Re: World's Smallest Sprite Converter
Post by: thepenguin77 on March 30, 2011, 06:17:41 pm
FloppusMaximus, what is this?
Code: [Select]
ld a,l
cp h
ret nc

How did you even come up with that?
Title: Re: World's Smallest Sprite Converter
Post by: Deep Toaster on March 30, 2011, 06:51:53 pm
Genius O.o
Title: Re: World's Smallest Sprite Converter
Post by: FloppusMaximus on March 30, 2011, 10:42:47 pm
Magic! ;)

(Well, actually, serendipity.  I had just done the math to check that 8-bit additions would be sufficient, so I happened to notice that H was just the right value to compare to at that point.  As you can see, plotSScreen + 7 * 12 = 9394h.)