Author Topic: Near flickerless grayscale without crystal timers  (Read 2701 times)

0 Members and 1 Guest are viewing this topic.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Near flickerless grayscale without crystal timers
« on: April 25, 2012, 02:22:19 pm »
Thepenguin77's perfect grayscale used crystal timers for flickerless grayscale because data could be copied to the screen at a consistent rate.  Is there a technique to make things nearly flickerless without using the crystal timers?  Like is there a technique using interrupts?

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: Near flickerless grayscale without crystal timers
« Reply #1 on: April 25, 2012, 02:31:25 pm »
I'M sure Jim e managed to do it, same for Duck back in the days. However, the problem is that it looked bad on 15 MHz calculators and one technique required the user to manually calibrate the grayscale by choosing between 4 presets before running his program.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Near flickerless grayscale without crystal timers
« Reply #2 on: April 25, 2012, 02:59:43 pm »
DJ_O is correct. Jim E and Ducks package both did it, and both use interrupts. Jim's is more up to date and is largely based on Duck's work. Tr1plea also has quite a lot of experience with grayscale using interrupts, many consider him a guru as well. As he's still around I think I'd ask him. :) Although the grayscale did look worse on the 15mhz models, it was still acceptable IMHO. You could actually write separate routines for each model. Jim E's and duck's only utilized 6Mhz.

Offline Geekboy1011

  • The Oneironaut
  • Donator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2031
  • Rating: +119/-2
  • Dream that Awakening dream
    • View Profile
Re: Near flickerless grayscale without crystal timers
« Reply #3 on: April 25, 2012, 04:31:21 pm »
Its really just adjusting the interupts so it looks good. The issue with it tho is unlike the timers you only get rough timeslices which make it occasionally not perfect

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: Near flickerless grayscale without crystal timers
« Reply #4 on: April 25, 2012, 06:35:34 pm »
I was so excited when I saw this topic. But it was a question...

Anyways, I've thought about this, but I've never actually done it. Here's how I think you'd go about it.
1. Set interrupts to the fastest speed that is consistent (For this, I'd go with timer two at 1120Hz)
2. Determine how many t-states take place between interrupts.

Then we get into the actual code. The goal of your interrupt system would be to ignore what the calculator interrupt system is doing and to make your own interrupts that run at 60Hz. The way you'd go about it is this:
1. Find the number of t-states it takes to get the interrupt frequency you want (this is a constant actually and doesn't need to be exact, we'll call 83+'s 6MHz, so 6MHz/60 = 100,000.
2. int(100,000 / (t-states per interrupt)) will get you the number of interrupt cycles to wait. So when these interrupts occur, just quickly return.
3. After those interrupts have expired, take the remaining t-states (100,000 - (cycles waited)*(t-states per interrupt)) and wait that long (in the interrupt).
4. After you've waited, start an LCD copy

5. Then you'd just repeat this process, keeping in mind that next time, you aren't starting cleanly on the beginning of an interrupt.

So an example, let's say that you find your calculator to run with 5,360 t-states per interrupt. To achieve the goal of 100,000, you'd need to wait 18 interrupt cycles and then 3,520 t-states in the 18th interrupt. At this point you'd fire the LCD copy.

Now it gets more involved when you calculate the next virtual interrupt, you have to remember that the interrupt system didn't wait for you, this means that the first interrupt is going to happen in 1,840 t-states. So with that information, you are going to need to dispatch 19 interrupts waiting 1,680 t-states in the 19th.

Then you'd just repeat this simple process over and over. To adjust the frequency, just take that goal 100,000 and adjust it to whatever you want. Higher goals will lower the frequency and lower goals will raise the frequency.




« Last Edit: April 25, 2012, 06:37:53 pm by thepenguin77 »
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