Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Hot_Dog on April 25, 2012, 02:22:19 pm

Title: Near flickerless grayscale without crystal timers
Post by: Hot_Dog 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?
Title: Re: Near flickerless grayscale without crystal timers
Post by: DJ Omnimaga 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.
Title: Re: Near flickerless grayscale without crystal timers
Post by: TIfanx1999 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.
Title: Re: Near flickerless grayscale without crystal timers
Post by: Geekboy1011 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
Title: Re: Near flickerless grayscale without crystal timers
Post by: thepenguin77 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.