Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Hooloovoo on August 02, 2015, 11:13:42 pm

Title: Really fast 9-level grayscale
Post by: Hooloovoo on August 02, 2015, 11:13:42 pm
In IRC, Sorunome mentioned how he wanted to maybe do an 8-level grayscale routine for Reuben. This somehow got me thinking about one of my older projects, a 9-level grayscale routine, except this time, I wanted to optimize it far too much. So I did. Here are the results, with a demo pattern. It would look better if I put it into an interrupt routine, but I actually think it looks okay at least without.  Bonus points to anyone who can figure out how it works without looking at the spoiler. Clear exits the demo program.
Spoiler For Spoiler:
The program uses the z80's R register as a counter for the loop, which leaves more free registers. It also uses the pop instruction to take data from the screen buffer, so I cannot use the stack.
Title: Re: Really fast 9-level grayscale
Post by: Sorunome on August 03, 2015, 02:46:18 pm
I tried this on my 83+SE and it is pretty insane! I wonder how good you can make it look if you use crystal timers
Title: Re: Really fast 9-level grayscale
Post by: TIfanx1999 on August 03, 2015, 05:22:57 pm
A screenshot would be nice. In all cases I've seen, the higher number of shades you go the less difference there are between them. Ie, the darkes shades tend to look too similar to one another as do the light ones. I think about 6 shades seem to be the most discernible.
Title: Re: Really fast 9-level grayscale
Post by: Runer112 on August 03, 2015, 05:33:30 pm
A screenshot would be nice. In all cases I've seen, the higher number of shades you go the less difference there are between them. Ie, the darkes shades tend to look too similar to one another as do the light ones. I think about 6 shades seem to be the most discernible.

I don't trust emulators to accurately reproduce 3- or 4-level grayscale, let alone 9-level grayscale. A picture/video of a physical device would probably be more accurate. But I'm not sure even that would be totally accurate, because cameras often have their own time-blending that's different than the human eye.

I guess that just means we need to try it for ourselves!
Title: Re: Really fast 9-level grayscale
Post by: TIfanx1999 on August 03, 2015, 09:10:49 pm
Yes, that is true. Unfortunately, I'm without a link cable at the moment. :(
Title: Re: Really fast 9-level grayscale
Post by: Hooloovoo on August 04, 2015, 12:29:27 am
Here is an update which fixes a bug Runer reported and adds timer support, both for standard timers and crystal timers. Crystal timer support is there, you just need to change the define and reassemble with spasm. You will probably need to change the delay time, it should all be self-explanatory.

I tried to take a picture, but I couldn't get one to look like what I'm seeing with my eyes. I guess the answer is to run it for yourself, even though that answer sucks.
Title: Re: Really fast 9-level grayscale
Post by: Sorunome on August 04, 2015, 04:43:28 am
Uuuuh, here it is that sometimes when i run it the gray is only on the left 64x64pxl box and the rightmost 16pxl column is just static o.O
Title: Re: Really fast 9-level grayscale
Post by: Hooloovoo on August 04, 2015, 10:21:00 am
Uuuuh, here it is that sometimes when i run it the gray is only on the left 64x64pxl box and the rightmost 16pxl column is just static o.O
I thought I had fixed this bug, which I had thought was due to LCD delay issues. The LCD is going into 6-bit mode somehow, but I'm not sure exactly how it happens. It only happens on some of my calculators, particularly the older ones, such as one of my 83+s but not the other, and my oldest 84+.

EDIT: I think I have fixed it for good, and also sped it up even more by removing some of the outi's. Things are attached

EDIT2: another version, fixes the same possible but unlikely LCD problem hopefully for good
Title: Re: Really fast 9-level grayscale
Post by: tr1p1ea on August 04, 2015, 11:50:02 pm
I'll have to test this out when I get home, looks promising :).
Title: Re: Really fast 9-level grayscale
Post by: TheMachine02 on August 06, 2015, 08:30:34 am
This definitly sound interesting. I wonder however how the r register is used. It look like you manually set it up with your value (46h). However, won't that cause some part of RAM to stop refreshing and goes random ?
Title: Re: Really fast 9-level grayscale
Post by: Iambian on August 06, 2015, 09:31:32 am
This definitly sound interesting. I wonder however how the r register is used. It look like you manually set it up with your value (46h). However, won't that cause some part of RAM to stop refreshing and goes random ?
That only applies to DRAM. The calculator uses SRAM (https://en.wikipedia.org/wiki/Static_random-access_memory) which maintains state without the need to refresh.

----
I just d/l'd the file and sent it to the emulator. Looks pretty nice with steady freq settings, though you can see the patterns. I know this isn't representative and I should endeavor to get it onto actual hardware ... as soon as I can pry the cable from my brother, who is using it on his PS3 controller to keep it charged.
Title: Re: Really fast 9-level grayscale
Post by: TheMachine02 on August 06, 2015, 11:04:33 am

That only applies to DRAM. The calculator uses SRAM (https://en.wikipedia.org/wiki/Static_random-access_memory) which maintains state without the need to refresh.

Nice. So the r register is free for any usage ? That could be usefull. (Of course there is the per M1 States increase, but I guess it is ok).
Title: Re: Really fast 9-level grayscale
Post by: Hooloovoo on August 06, 2015, 11:17:50 am
Yep, the R register is free, and you can use it for any loop which always has the same number of instructions (branching is only allowed if you're very very careful), of up to 128 loops. if you're using it for >64 loops, you need to have an odd number of instructions in your loop because of divisibility.

The I register, designed for interrupt routines is also free if IM 2 is not used, or it is saved, but is not as useful because arithmetic is not really possible, and it doesn't change by itself like R.