VDP TMS9918A & TMS4116 Config

The RetroNET NABU-LIB z88dk C Library for creating games and software.
TorontoNabu
Posts: 19
Joined: Sun Apr 30, 2023 3:39 pm

VDP TMS9918A & TMS4116 Config

Post 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.
TorontoNabu
Posts: 19
Joined: Sun Apr 30, 2023 3:39 pm

Re: VDP TMS9918A & TMS4116 Config

Post 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 :(
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: VDP TMS9918A & TMS4116 Config

Post 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.
TorontoNabu
Posts: 19
Joined: Sun Apr 30, 2023 3:39 pm

Re: VDP TMS9918A & TMS4116 Config

Post 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
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: VDP TMS9918A & TMS4116 Config

Post 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.
TorontoNabu
Posts: 19
Joined: Sun Apr 30, 2023 3:39 pm

Re: VDP TMS9918A & TMS4116 Config

Post 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
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: VDP TMS9918A & TMS4116 Config

Post by productiondave »

This is one of the quirks with all TI documents. Loads of people have fallen for that trap
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: VDP TMS9918A & TMS4116 Config

Post 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
masto
Posts: 39
Joined: Wed Mar 29, 2023 10:15 pm

Re: VDP TMS9918A & TMS4116 Config

Post by masto »

Octal makes it much easier to operate the toggle switches. :-)

ook ook
Post Reply