Author Topic: Really fast 9-level grayscale  (Read 5889 times)

0 Members and 1 Guest are viewing this topic.

Offline Hooloovoo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 225
  • Rating: +22/-0
    • View Profile
Really fast 9-level grayscale
« 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.
« Last Edit: August 03, 2015, 12:03:18 am by Runer112 »
"My world is Black & White. But if I blink fast enough, I see it in Grayscale." -tr1p1ea
Spoiler For some of the calcs I own:



(actually I have quite a few more than this, but I don't feel like making bars for them all.)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Really fast 9-level grayscale
« Reply #1 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

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Really fast 9-level grayscale
« Reply #2 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.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Really fast 9-level grayscale
« Reply #3 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!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Really fast 9-level grayscale
« Reply #4 on: August 03, 2015, 09:10:49 pm »
Yes, that is true. Unfortunately, I'm without a link cable at the moment. :(

Offline Hooloovoo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 225
  • Rating: +22/-0
    • View Profile
Re: Really fast 9-level grayscale
« Reply #5 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.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale." -tr1p1ea
Spoiler For some of the calcs I own:



(actually I have quite a few more than this, but I don't feel like making bars for them all.)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Really fast 9-level grayscale
« Reply #6 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

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Hooloovoo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 225
  • Rating: +22/-0
    • View Profile
Re: Really fast 9-level grayscale
« Reply #7 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
« Last Edit: August 04, 2015, 11:52:06 pm by Hooloovoo »
"My world is Black & White. But if I blink fast enough, I see it in Grayscale." -tr1p1ea
Spoiler For some of the calcs I own:



(actually I have quite a few more than this, but I don't feel like making bars for them all.)

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: Really fast 9-level grayscale
« Reply #8 on: August 04, 2015, 11:50:02 pm »
I'll have to test this out when I get home, looks promising :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Really fast 9-level grayscale
« Reply #9 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 ?
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Really fast 9-level grayscale
« Reply #10 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 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.
« Last Edit: August 06, 2015, 09:41:49 am by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Really fast 9-level grayscale
« Reply #11 on: August 06, 2015, 11:04:33 am »

That only applies to DRAM. The calculator uses SRAM 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).
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Hooloovoo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 225
  • Rating: +22/-0
    • View Profile
Re: Really fast 9-level grayscale
« Reply #12 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.
« Last Edit: August 06, 2015, 03:35:01 pm by Hooloovoo »
"My world is Black & White. But if I blink fast enough, I see it in Grayscale." -tr1p1ea
Spoiler For some of the calcs I own:



(actually I have quite a few more than this, but I don't feel like making bars for them all.)