Author Topic: GX Grayscale Library  (Read 7163 times)

0 Members and 2 Guests are viewing this topic.

Ashbad

  • Guest
Re: GX Grayscale Library
« Reply #15 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 :)

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: GX Grayscale Library
« Reply #16 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: GX Grayscale Library
« Reply #17 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.

Ashbad

  • Guest
Re: GX Grayscale Library
« Reply #18 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: GX Grayscale Library
« Reply #19 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.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: GX Grayscale Library
« Reply #20 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 -, 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)
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Ashbad

  • Guest
Re: GX Grayscale Library
« Reply #21 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 :(
« Last Edit: April 18, 2011, 08:10:27 am by Ashbad »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: GX Grayscale Library
« Reply #22 on: May 06, 2011, 10:19:17 am »
How is this coming along? I would be sad if this dies...
I'm not a nerd but I pretend:

Ashbad

  • Guest
Re: GX Grayscale Library
« Reply #23 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.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: GX Grayscale Library
« Reply #24 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 :)
I'm not a nerd but I pretend:

Ashbad

  • Guest
Re: GX Grayscale Library
« Reply #25 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 :))

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: GX Grayscale Library
« Reply #26 on: May 06, 2011, 01:35:52 pm »
Oh, aha.thanks for explaining!
I'm not a nerd but I pretend:

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: GX Grayscale Library
« Reply #27 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.
« Last Edit: May 06, 2011, 01:40:52 pm by Runer112 »

Ashbad

  • Guest
Re: GX Grayscale Library
« Reply #28 on: May 06, 2011, 04:53:47 pm »
shut up, that's why.



jk ;D but seriously, just because of many reasons.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: GX Grayscale Library
« Reply #29 on: May 08, 2011, 08:34:23 am »
I agree with Runer, making an axiom out of this would be cool too.