Hi!

This message is intended for VDP-aholics and emulator programmers. I am 
examining the V9938 timing details to help Marat improve fMSX. I discovered 
some things about the line interrupt I never heard about before.


I did two measurements that contradicted each other:

First, some definitions:
FH: VDP status register 1, bit 0 (line interrupt flag)
VR: VDP status register 2, bit 6 (vertical retrace flag)
HR: VDP status register 2, bit 5 (horizontal retrace flag)
IE1: VDP register 0, bit 4 (line interrupt enable/disable)

Measurement 1:
1. line interrupts are disabled (IE1)
2. set interrupt line to 20
3. poll the VDP until FH becomes 1
When run, this test doesn't hang the MSX, therefore it must have observed the 
state FH==1.

Measurement 2:
1. line interrupts are disabled (IE1)
2. set interrupt line to 20
3. poll the VDP until VR becomes 1 (wait for vertical retrace)
4. poll the VDP until VR becomes 0 (wait for scanning to start)
5. poll the VDP 30 times for HR==1 followed by HR==0 (wait 30 lines)
6. read FH
When run, this test returns FH==0.
However, if between step 4 and step 5 the step "4a. enable line interrupt 
(IE1)" is added, the test returns FH==1.

Measurement 1 suggests that FH is set when the selected line is reached, even 
if the line interrupt is disabled (IE1==0). However, measurement 2 suggests 
that FH is only set if the line interrupt is enabled (IE1==1).

I can think of only one way to match these results: if the interrupts are 
disabled, FH is set, but is reset shortly after.


A little over a year ago, David Heremans posted this:

> To reset a interrupt from a horizontal line interrupt (reg #19), I used to 
> set the interupt enable bit to zero and then back on again. Turning the bit 
> off also dropped the interrupt.
> This was better because I could now make the interupt line drop in lesser
> time, I just had two write twice to a register. With the official read 
> methode I had to write a register, wait, read a status register and then 
> put #15 back to zero (as assumed by the standard interrupt handler)

At that time, I thought the resetting of the line interrupt status flag was 
caused by the *event* of disabling the line interrupt (IE1 becomes 0). 
However, I now think it is caused by the *state* of the line interrupt being 
disabled (IE1 equals 0). So no matter if line interrupts are disabled before 
or after FH is set, FH will be reset.


Maybe you'll wonder: why is FH set at all if IE1==0?
Well, I did another test that simply selected status register 1 (home of FH) 
and stores its value repeatedly (INIR). IE1 was 0 during the entire test. I 
noticed that FH was set for 2 to 3 INIR cycles on a row. This is not what I 
expected, since the V9938 data book says FH is reset when status register 1 
is read. It seems FH is set during a small interval at the start of the 
selected line. During that interval, nothing can reset it: reading doesn't 
reset it, nor does a disabled interrupt state (IE1==0).


I'd like some comments. Does this theory fit with your experiences with the 
VDP? Are there other explanations for the measurements I described?

I'd appreciate it if someone could write and run some tests, as an 
independant check to make sure these results are not caused by an error in my 
test programs.


The V9938 is such an enigma. I've programmed it for years and I am still 
learning new things about it. :)

Bye,
                Maarten

****
Problems? contact [EMAIL PROTECTED] See also http://www.faq.msxnet.org/
****

Reply via email to