Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Ashbad on April 16, 2011, 04:38:27 pm

Title: GX Grayscale Library
Post by: Ashbad on April 16, 2011, 04:38:27 pm
Dalanian software presents... a new library for assembly development supporting:

- 3, 4, 8, and 16 level grayscale rendering
- toggle between user activation and interrupt triggering
- sprite routines for all levels
- user defined buffers
- useful buffer editing commands
- almost perfect alignment to the LCD in interrupt mode (for up to 8 level grayscale)
- toggle between different ANDing techniques to achieve more balanced colors!
- support for all models and LCD drivers
- and much more!

This will be released very soon in a BETA form, released to the general z80 assembly coding public to test and report bugs, inconveniences, and opinions/advice!
I shall upload a screenshot of a WIP tomorrow afternoon, showing the sheer power of this wonderful library and what it can do for YOU!

Thanks in advance for all support!

~ Ashbad, CEO and Founder of Dalanian Software
Title: Re: GX Grayscale Library
Post by: willrandship on April 16, 2011, 04:52:44 pm
Nspire 84+ Emu support? Its grayscale is far more finicky, unfortunately, so it doesn't work quite right with reg. grayscale. Sounds cool though!
Title: Re: GX Grayscale Library
Post by: Ashbad on April 16, 2011, 04:58:50 pm
Thanks :) it should work fine with an emu, if it's put at the right settings, I'm sure ;)
Title: Re: GX Grayscale Library
Post by: willrandship on April 16, 2011, 05:35:16 pm
Well, the official nspire emu for the 84+ sucks at greyscale, unless you tune it just right. It's practically a whole new LCD.
Title: Re: GX Grayscale Library
Post by: Ashbad on April 16, 2011, 05:40:31 pm
Really?  O.o I've actually heard it was quite good at grayscale, maybe I've been misinformed :/
Title: Re: GX Grayscale Library
Post by: willrandship on April 16, 2011, 06:09:37 pm
Maybe that's only on my OS (1.4) but yeah, it sucks for mine. At least it's fairly stable. Something that bricks a real 84+ will give me a RAM clear :P if I handle it correctly, that is.
Title: Re: GX Grayscale Library
Post by: Ashbad on April 16, 2011, 06:42:07 pm
interesting -- I'll see if someone knows how much different the Emu works with grayscale with full specs, and I can see if I can eventually help you out ;)

first things first though, I have to get it working for something first ;D
Title: Re: GX Grayscale Library
Post by: willrandship on April 16, 2011, 07:06:32 pm
ok. Sounds cool, and you don't have to mess around just for me. Hopefully a third party emu will come out that has its own grey support, which will be better than on a real calc, due to hardware support :)
Title: Re: GX Grayscale Library
Post by: Ashbad on April 16, 2011, 07:27:54 pm
well, I'm sure there are also others who would like to have it, plus I said I would support all LCDs regardless of model so I will keep that promise ;)

Also, if anyone has any ideas, please post them ;D
Title: Re: GX Grayscale Library
Post by: Munchor on April 17, 2011, 05:45:37 am
well, I'm sure there are also others who would like to have it, plus I said I would support all LCDs regardless of model so I will keep that promise ;)

Also, if anyone has any ideas, please post them ;D

Great, don't use non-Nspire functions please :D I'd like to be able to try this.l
Title: Re: GX Grayscale Library
Post by: Ashbad on April 17, 2011, 11:34:12 am
I think I have all but 16 level basic rendering pretty much functioning, so maybe a screenie later at some point ;)

ALSO, I really would appreciate some ideas :P
Title: Re: GX Grayscale Library
Post by: Munchor on April 17, 2011, 01:27:12 pm
I think I have all but 16 level basic rendering pretty much functioning, so maybe a screenie later at some point ;)

ALSO, I really would appreciate some ideas :P

16 GREYSCALE? Sweeeeeeeet.
Title: Re: GX Grayscale Library
Post by: Ashbad on April 17, 2011, 01:28:13 pm
indeed ;) I'm sure though it won't be used for SHMUPS though :P

however, picture viewing is a big possibility ;)
Title: Re: GX Grayscale Library
Post by: Munchor on April 17, 2011, 01:29:48 pm
indeed ;) I'm sure though it won't be used for SHMUPS though :P

however, picture viewing is a big possibility ;)

Has anyone else even done that before??
Title: Re: GX Grayscale Library
Post by: Ashbad on April 17, 2011, 01:32:52 pm
I think thepenguin made a few grayscale libraries before ;)

however, I don't think there are very many 8 level game besides chips challenge (by calc84) -- and definately NO 16 level ones.
Title: Re: GX Grayscale Library
Post by: Ashbad on April 17, 2011, 09:50:01 pm
I cannot test my all new 3 level rendering routine tonight, but I have resolved to post it here instead ;)

I used brass' label system to full extent, so it's a little hard to read in that sense.  Sorry :(

Code: [Select]
Level3copyInt
LD HL, Buf1 + 767
LD DE, Buf2 + 767
PUSH HL
PUSH DE
LD C, $10
LD A, $04 ;this uses Y auto-decrement mode ;)
OUT (C), A
LD B,64
LD A,12
PUSH AF

@ ;set to last row
.db $ED,$70
JP M,{-1@}
OUT (C), $BF
@ ;set to last column
.db $ED,$70 ;IN F, (C)
JP M,{-1@}
OUT (C), $2E
LD A,12
PUSH AF
@
LD A, (HL)
AND %10101010
DEC HL
PUSH HL
PUSH AF
LD A, (DE)
AND %01010101
DEC DE
POP HL
OR H
POP HL
@
.db $ED,$70 ;IN F, (C)
JP M,{-1@}
OUT ($11),A
POP AF
PUSH AF
EX DE, HL
DEC A
CP $00
JR Z,{-2@}
DJNZ {-3@}
@
RET

This is crazy optimized from my last version, since I learned a few things (like the opcode for IN F,(C) and a few techniques) -- Enjoy :)
Title: Re: GX Grayscale Library
Post by: Runer112 on April 17, 2011, 09:56:06 pm
A note: the in f,(c) opcode is undocumented. If you use it, you don't have to worry about the grayscale looking bad on the Nspire's screen, because this opcode will straight-up fail on it.
Title: Re: GX Grayscale Library
Post by: DJ Omnimaga on April 17, 2011, 09:56:20 pm
Interesting, would this only be for ASM or could it be used through an axiom? A lot of people lately use their own GS routines and won't release them. Back then there were some being released, but they are now obsoleted by today's grayscale standards. It would be nice to finally see near perfect grayscale on calc, like ThePenguin77 chess game, for example.
Title: Re: GX Grayscale Library
Post by: Ashbad on April 17, 2011, 09:58:41 pm
A note: the in f,(c) opcode is undocumented. If you use it, you don't have to worry about the grayscale looking bad on the Nspire's screen, because this opcode will straight-up fail on it.

I know -- I already discussed that with kerm, and I think the way Imma gonna go right now is make it work great for the Ti-8x NORMAL brand, and make an optional other build that takes care of the Nspire issue -- it's not that complex, but it really adds ~5000 cycles per rendering :(

And DJ: it would work through an axiom, but until I have it working the way I want I won't make an axiom version.
Title: Re: GX Grayscale Library
Post by: DJ Omnimaga on April 17, 2011, 10:03:22 pm
Ah ok, I guess it's best to get it working for ASM first. Personally it should be Nspire compatible, though, so people don't need to compile multiple versions of their games all the time and worry about speed differences too much.
Title: Re: GX Grayscale Library
Post by: thepenguin77 on April 17, 2011, 11:46:37 pm
I think thepenguin made a few grayscale libraries before ;)

however, I don't think there are very many 8 level game besides chips challenge (by calc84) -- and definately NO 16 level ones.

I have made 16 level grayscale before, it's actually how I was first mentioned on this forum - link (http://ourl.ca/4866/90559) -, and I must say, it's definitely not flickerless. While from an early standpoint, you might say, "I don't see why this won't work," you are forgetting about one major problem: the LCD refresh rate.

When you are doing 16 level grayscale, you obviously break the screen time up into 15 segments of equal time. Each bit of the shade gets its own share of the time to be on. With bits 3210
3: 8/15
2: 4/15
1: 2/15
0: 1/15
Now the huge problem here is that bit 0 is only on for 1/15 frames. And since the calculator can only go 60 fps, (the driver can go 120-240, but the screen just won't show it), that lowest frequency will turn on 4 times per second. So any pixel with bit 0 set is going to have that 4 Hz flicker go through it. And when 50% of the pixels on the screen have bit 0 set, you get horrible patterns going across the screen. I mean, try tapping your finger 4 times per second, that's what the pixel is going to do. I remember shades 7 and 8 almost looked like they were just turning off and on.

So the bottom line. 8 level works great and you can get near flickerless, 16 level not so much.


But in other news, it's great to see a grayscale library :D  And another reason this probably won't work on the Nspire is because it doesn't have crystal timers. (That was annoying to figure out)
Title: Re: GX Grayscale Library
Post by: Ashbad on April 18, 2011, 08:09:26 am
Very interesting, and very helpful :)  I think I may leave 16 level out of the equation in that case, then ;)  I thought it was going to be hard -- instead of messing with only 1 byte at a time, it would be 2 O.o

Hmm, seems as though it would be a pain to get anything working for the Nspire x.x Should I try to find a run-around, or just leave them in the dust?  Because the first issue Runer pointed out could be fixed like this:

Code: [Select]
PUSH BC
PUSH AF
IN B, (C)
POP AF
POP HL
JP M, {-1@}
LD BC, HL

however, as you are sure to imagine, this adds ~10000 cycles per rendering :(
Title: Re: GX Grayscale Library
Post by: aeTIos on May 06, 2011, 10:19:17 am
How is this coming along? I would be sad if this dies...
Title: Re: GX Grayscale Library
Post by: Ashbad on May 06, 2011, 01:21:19 pm
When I do finish it, I don't think I'll allow it to be in axiom form.
Title: Re: GX Grayscale Library
Post by: aeTIos on May 06, 2011, 01:23:05 pm
Why did you say /allow/ ? Its your project, so IMO you are the one who was going to create an axiom... explain :)
Title: Re: GX Grayscale Library
Post by: Ashbad on May 06, 2011, 01:31:53 pm
I only want it available to pure assembly developers, and if I do make it in axiom form, it won't be allowed for this year's axe contest (unless if you bribe me :))
Title: Re: GX Grayscale Library
Post by: aeTIos on May 06, 2011, 01:35:52 pm
Oh, aha.thanks for explaining!
Title: Re: GX Grayscale Library
Post by: Runer112 on May 06, 2011, 01:40:15 pm
Why not make it an Axiom? The pure assembly developers have access to some great grayscale routines posted by people like thepenguin77. It seems to me that Axe programmers would be the ones most aided by packaged grayscale routines.
Title: Re: GX Grayscale Library
Post by: Ashbad on May 06, 2011, 04:53:47 pm
shut up, that's why.

(http://27.media.tumblr.com/tumblr_lenlejp0wt1qdoghio1_500.png)

jk ;D but seriously, just because of many reasons.
Title: Re: GX Grayscale Library
Post by: Munchor on May 08, 2011, 08:34:23 am
I agree with Runer, making an axiom out of this would be cool too.
Title: Re: GX Grayscale Library
Post by: Binder News on May 08, 2011, 09:08:08 pm
I third that!
Title: Re: GX Grayscale Library
Post by: Ashbad on May 08, 2011, 09:15:21 pm
I third that!

I call for fourth person Veto
Title: Re: GX Grayscale Library
Post by: DJ Omnimaga on May 08, 2011, 09:23:01 pm
I sex that!

EDIT: Woops I skipped 5 x.x

Title: Re: GX Grayscale Library
Post by: Ashbad on May 08, 2011, 09:35:44 pm
:P

I sext that.  screw 5.  I never use it in life, unless I'm counting how many sides a star has, and even then I just know its a decrement of sex.
Title: Re: GX Grayscale Library
Post by: DJ Omnimaga on May 08, 2011, 09:38:13 pm
oh woops I meant sixth x.x O.O

Anyway Axiom would be nice, but only once you finished the ASM version. Later maybe an Axiom version can be done so Axe coders aren't singled out, although personally, Axe grayscale is already very easy to use compared to any other language (even xLIB)
Title: Re: GX Grayscale Library
Post by: Munchor on May 09, 2011, 07:28:33 am
Well, I guess Ashbad doesn't want to make an axiom out of it and we shouldn't beg him even more. However, I'd like to say yet again I'd really like it.

EDIT: How's the coding going on?