A82: Help


[Next][Index][Thread]

A82: Help




Okay, since the list has been so quiet recently and I have nothing better to do...

In TxtView, some people (actually, no one, but whatever) may have noticed that it doesn't handle tabs right. It displays only one space instead of the usual eight. Well I'm trying to fix this, but I need some help. I need a fast way to round the x-coord (held in the b register) up to the nearest multiple of 32, with a max of 64. Anything greater than 64, I don't care what b is. In C it would look like this:

if (b<32) b=32;
else if (b<64) b=64;
else return;
goto Done;

This is what I have so far in asm:

 ld a,b
 ld b,32
 cp b \ jr c,Done
 ld b,64
 cp b \ jr c,Done
 ret

That's 12 bytes. I hope someone can beat that. I thought I did for a while with this code, but if you look carefully you'll see it doesn't exactly do the same thing. If you want to challenge yourself, take a look and see if you can figure out why they are different:

 ld a,32
 cp b \ jr nc,ldba
 add a,a
 cp b \ ret c
ldba:
 ld b,a
 jr Done

Um, I can't really offer any prizes for this, other than your name in the credits. I hope that will be enough incentive to maybe wake this list up for one second. Bye


HotBot - Search smarter.
http://www.hotbot.com


Follow-Ups: