Page 1 of 2

VDP TMS9918A & TMS4116 Config

Posted: Mon May 08, 2023 2:47 pm
by TorontoNabu
Question about the VDP register 1 bit 0 - the 4K/16K selection. It seems that all the ROM/BIOS out there set this bit to 0. Reading the documentation I think this should be set to 1 according to the TMS9118.PDF doc:
Screenshot from 2023-05-08 10-44-52.png
Am I missing something?

----
For some background I am playing around with creating a BIOS to learn the HW and Z80 assembly... the beauty of an 8 bit machine!

Cheers & Thanks.

Re: VDP TMS9918A & TMS4116 Config

Posted: Mon May 08, 2023 4:07 pm
by TorontoNabu
On a similar topic... Has anyone got the VDP interrupt to work? So far I cannot get it to fire on the Z80. I think I have done everything correctly:

1. Setup a new Vector table & update the I register
2. Set bit 3 (for VDP IRQ) in Port A of the sound chip (I/O address 41)
3. Cleared any pending IRQ in VDP by reading read status
4. Enable the IE (bit 2 in register 1) of the VDP

My next step is to probe the /INT line from 9918, then make sure it propagates through U33, U34 & U35. Since the HCCA interrupt seems to be working I'm guessing these are OK. My assumption is that the 9918 is not generating an interrupt... due to my bad programming & poor understanding of the system :(

Re: VDP TMS9918A & TMS4116 Config

Posted: Mon May 08, 2023 8:16 pm
by productiondave
Have a look at the nabu-lib c code which creates and sets up the interrupt handler for the vdp.

You need to register your interrupt handler routine into the im2 vector table. I don't know if this is the same if you're working at the ROM level. Ive only don't this in games I've written for cpm on top of Nabulib and on some experimental assembly I've been playing around with that is based on nabulib but doesn't use nabulib.

It definitely works.

Re: VDP TMS9918A & TMS4116 Config

Posted: Tue May 09, 2023 4:43 pm
by TorontoNabu
Thanks productiondave for the feedback. I have registered the irq handler in the vector table. Actually added unique handlers for all 8 interrupts and I'm getting the HCCA Tx interrupt if I enable it in the control register.

I need to check my code again, I may be reading the VDP status at an inappropriate time, which clears the F flag.

By chance any insight on the 4/16K RAM selection? I've tried and both settings seem to work with a basic screen output. I haven't done any extensive RAM testing yet.

Cheers

Re: VDP TMS9918A & TMS4116 Config

Posted: Tue May 09, 2023 6:21 pm
by DJ Sures
Take a look at the nabulib library in my GitHub. That’ll help you with everything. there’s plenty of example projects as well … including games that use the vdp interrupts.

Re: VDP TMS9918A & TMS4116 Config

Posted: Tue May 09, 2023 6:26 pm
by DJ Sures
Here’s the repo link: https://github.com/DJSures/NABU-LIB

Re: VDP TMS9918A & TMS4116 Config

Posted: Wed May 10, 2023 5:06 am
by TorontoNabu
Thanks for all the help. Got it work tonight. The nabulib did help! My problem was the 9918 documentation labelled in the text description of the register 1 as bit 0 through 7, which i would interpret as bit 0 as the LSB. However the picture of the bits for register 1 shows bit 0 as the MSB!?!... Turns out the picture is correct and matches the source code from Nabulib. All is right with the world again.

Cheers

Re: VDP TMS9918A & TMS4116 Config

Posted: Wed May 10, 2023 5:09 am
by productiondave
This is one of the quirks with all TI documents. Loads of people have fallen for that trap

Re: VDP TMS9918A & TMS4116 Config

Posted: Wed May 10, 2023 5:16 am
by DJ Sures
HAha that reminds me of the AY-3 audio processor documentation. I was fighting for a while with the registers until I found out... they're in octal!!!!

Who the heck uses octal anymore? Well, anymore was 1980 so it makes sense back then

Re: VDP TMS9918A & TMS4116 Config

Posted: Wed May 10, 2023 2:13 pm
by masto
Octal makes it much easier to operate the toggle switches. :-)