[SOLVED][VDP] What are the two bytes that have to be written into the VDP status address?

Talk about programming CreatiVision (except games programming). Projects of homebrew hardware are also welcome.
Post Reply
Fabrizio Caruso
Posts: 41
Joined: Mon Feb 05, 2018 9:23 am
Contact:

[SOLVED][VDP] What are the two bytes that have to be written into the VDP status address?

Post by Fabrizio Caruso » Sun Feb 11, 2018 5:46 pm

Hi

I need to access the VDP. I have understood the basics of the read/write procedure but not the details.

What do I need to write into the status read/write registers?
The first byte is the LSB.
The second byte seems to be the MSB + something else.
What is the something else?

Fabrizio
Last edited by Fabrizio Caruso on Sat Oct 19, 2019 10:18 am, edited 1 time in total.
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: [VDP] What are the two bytes that have to be written into the VDP status address?

Post by carlsson » Tue Feb 27, 2018 10:52 am

You add $40 to indicate the address is set up for writing, or $00 to indicate it is set up for reading.

This doc is for the Spectravideo but is has the same type of VDP, see Address Register: http://samdal.com/svvideo.htm
Fabrizio Caruso
Posts: 41
Joined: Mon Feb 05, 2018 9:23 am
Contact:

Re: [VDP] What are the two bytes that have to be written into the VDP status address?

Post by Fabrizio Caruso » Thu Mar 15, 2018 2:44 pm

Sorry I still do not understand why on other examples I see $80 added instead of $40.

I need some simple to write into VDP memory from C without using interrupts.
I am supposed to do this in C with very little Assembly.

Let us assume the VDP registers are already set.
I need:
1. a function VPOKE(loc,value) to write value onto loc (VDP memory) and
2. a function VPEEK(loc) to read the value contained in loc (VDP memory).

If I understand well, this can be done by writing/reading into two registers (for value and status).
I do not understand what to write into the status registers.
ThomHa
Posts: 4
Joined: Thu Mar 08, 2018 5:22 pm

Re: [VDP] What are the two bytes that have to be written into the VDP status address?

Post by ThomHa » Fri Mar 16, 2018 12:20 am

If you add 0x80 then you'll write to a register instead of to VRAM.

Logic is:

To write to a register, write the value you want to set, then write (the register address) + 0x80.

To write to VRAM, write the low byte of the address, then write the high byte + 0x40, then write the value to write to the data register.

When the TMS next has an access slot, it'll write the value you submitted. A design flaw is that there's no way to know when the value has been written and if you supply the next byte to write too soon, you'll overwrite the previous value. So don't attempt to do block transfers in a tight loop. Wait for interrupt to get better access shoot availability.

Pseudocode is:

Disable interrupts.
Read the status register.
Write low byte of address.
Write high byte + 0x40.
Write data.
Wait.
Write data for address + 1.
Etc.

Reading the status register has the effect of making it explicit that the next thing you're going to write us the low byte, not the high. You don't know what state the VFP has been left in by the previous user.

Apologies for the vagueness on 'wait' — I know the TMS fairly well but not the CreatiVision, or any other 6502 TMS machine; when paired with the Z80 it's usually connected as an IO device, which makes accessing it quite slow and usually means you don't need to take that much care.
Post Reply