VDP Registers

From Ninerpedia
Revision as of 11:43, 12 October 2014 by Stephen Shaw (talk | contribs) (adjustments to layout)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

TI VIDEO DISPLAY PROCESSOR REGISTERS - VDP

This rather strange title heads an article on the use of the seven VDP Registers.

The article is aimed squarely at owners with Mini Memory, but is of use to anyone interested in machine code or even TI Forth.

A short machine code utility would enable owners with Extended Basic and 32k ram to also use these registers by means of CALL LINK to load the registers.

Even if you lack any of these extras, the article may be of interest in revealing a little of the consoles internal working.

VDP is a TI first: a separate computer chip which does all the display work. On the 99/4A the chip is also made to pass Basic program data to the main processor. Widely used (for instance in the MSX machines) the VDP Processor is the most costly integrated circuit in your console, currently costing some GBP 15.00.

The VDP Registers hold information which controls the essential workings of the VDP... and I shall start with a look at the first register! Not all the registers will be dealt with in such detail, but there is a summary at the end.

The value of the registers (which can only be written to, not read) can be amended in a TI BASIC program, using Mini Memory, by using CALL PEEKV.

Use PEEKV to WRITE to the register as follows: Each of the VDP registers has a basic memory value allocated to it. The value of the registers is changed by peek'ing a memory address which is offset from this basic value. A dummy variable is used after the offset address which can have any or no value. The listings below demonstrate.

Detailed explanations of useful registers

VDP Register One

A multipurpose register, controlling several different aspects of console operation. By changing the value in this register we can adjust:

4/16k selection ; Screen blank; VDP Interrupt switch; graphics modes; sprite sizes.

The basic address of vdp register one is -32512

To this is added the value of each of 8 control bits. The normal value is 224:

Bit 0, value 128 = 16k selected
Bit 1, value 64 = screen enabled
Bit 2, value 32 = interrupts enabled
Bit 3, value 0 = NOT 40 column text node
Bit 4, value 0 = NOT multicolour mode
Bit 5, value 0 = Has to be a zero here
Bit 6, value 0 = standard sized sprites
Bit 7, value 0 = unmagnified sprites
TOTAL:224
Bit 7 is 0 or 1 having a digital value of O or 1,
Bit 6 is 0 or 1 having a digital value of O or 2,
Bit 5 has a value of 0 or 4,
Bit 4 has a value of 0 or 8 and so on...)
REFERENCE: Editor Assembler Manual Pages 326/327
Adding the digital value of each bit (128 + 64 + 32) we get 224.
To set the register we use CALL PEEKV with mini memory.

EXAMPLE: If we wish to set just bits 0 and 2, 128 + 32 = 160 and (160 - 32512) is -32352.

With this value, bit 1 is zero, or screen not enabled (screen is blank)

In your program insert: CALL PEEKV(-32352,A) where A is just a variable of any or no value.

Note that A is a dummy variable which is required, but it is only the memory address in the peekv that actually does the work.

Now, the screen can be set up with any text or graphics and while we are setting it up, the viewer will see only a blank screen ( unless he presses a key!).

You can instantly switch the screen back on with: CALL PEEKV(-32288, A) where -32288 is made up from 224-32512.

Look at the normal bit settings above: to turn the screen off, we need to turn the value of bit 1 to 0, that is subtract 64 from the normal register value (224-64= 160= address 160-32512) .

Now experiment with other settings of register 1.

NB: If you disable the interrupts, you switch off the key scans etc & end up with a 'hung-up' console

Try to use different sized TI BASIC sprites!


VDP Register Two

REGISTER TWO defines the base address of the Screen Image Table.

If you reserve a chunk of VDP memory (either using CALL FILES if you have a disk drive, or CALL LOAD(-318B8,A1,A2)if you don't) then you can set up a screen display (or displays) and just by one CALL PEEKV, instantly change the entire screen display.

This register is switched in chunks of a full one k, 1024 bytes.

BASIC ADDRESS: -32256
NORMAL START ADDRESS: 0
Reset to normal: -32256 +1024*0 = CALL PEEKV(-32256,A)

Sample use of VDP Register 2

This little program requires the Mini Memory is plugged in to give you access to POKEV. It is pretty impressive and uses VDP register 2 to build up an alternative display which can be instantly recalled.

It is necessary to reserve an area of memory for the second display: see the initial rem statements. For the use of PEEKV see the notes at the end. The symbol @ is a valid variable name.

When RUN, an initial design of horizontal bars will appear, and will shortly be followed by a blank screen. when the second design appears, press SPACE for a quick demonstration!

1 REM USING VDP REGISTER
2 REM TO INSTANTLY CHANGE
3 REM SCREEN DISPLAY
5 REM BEFORE KEYING IN OR
6 REM LOADING THIS PROGRAM
7 REM RESERVE MEMORY:
8 REM IF YOU HAVE A DISK
9 REM SYSTEM, USE
10 REM CALL FILES(8), THEN
11 REM NEW
12 REM ELSE KEY IN
13 REM CALL LOAD(-31888,56,
0) THEN KEY IN NEW THEN LOAD
100 CALL CLEAR
110 PRINT "WAIT A FEW MINUTE
S WHILE THETWO SCREENS ARE S
ET UP':::
120 FOR T=0 TO 5
130 CALL COLOR(T+9,T+2,T+2)
140 CALL HCHAR(1+T*4,1,96+T*
8,128)
150 NEXT T
151 REM NOW TRANSFER TO
2ND SCREEN AREA:
160 FOR Z=1 TO 768 STEP 24
170 CALL PEEKV(Z,A,B,C,D,E,F
,G,H,I,J,K,L,M,N,O,P,Q,R,S,T
,U,V,W,X)
180 CALL POKEV(Z+14336,A,B,C
,D,E,F,G,H,I,J,K,L,M,N,O,P,Q
,R,S,T,U,V,W,X)
190 NEXT Z
191 REM BLANK SCREEN BEFORE
PLACING TEXT
200 CALL PEEKV(-32352,A)
210 PRINT "PRESS SPACE FOR N
EXT SCREEN"
211 REM AND TRANSFER TEXT T
O BOTTOM OF 2ND SCREEN
220 FOR @=705 TO 768 STEP 32
221 REM NOTE USE OF @ AS A
VARIABLE!
230 CALL PEEKV(@,A,B,C,D,E,F
,G,H,I,J,K,L,M,N,O,P,Q,R,S,T
,U,V,,X,Y,Z,AA,BB,CC,DD,EE,
FF)
240 CALL POKEV(@+14336,A,B,C
,D,E,F,G,H,I,J,K,L,M,N,O,P,Q
,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,
DD,EE,FF)
250 NEXT @
260 CALL CLEAR
261 REM CLEAR SCREEN AND
SWITCH DISPLAY BACK 0N...
270 CALL PEEKV( -32288,A)
280 PRINT "SECOND SCREEN BEI
NG BUILT.."
290 FOR T=0 TO 5
300 CALL VCHAR(1,1+T*5,96+T*
8,120)
310 NEXT T
320 PRINT "PRESS SPACE FUR N
EXT SCREEN"
330 CALL KEY(3,A,B)
340 IF A<>32 THEN 330
341 REM A SIMPLE PEEKV WILL
CHANGE TO SCREEN TWO:
INSTANTLY
350 CALL PEEKV( -32242,A)
360 CALL KEY(3,A,B)
370 IF A<>32 THEN 360
380 CALL PEEKV( -32256,A)
390 GOTO 330
400 END

VDP Register Five

Sprite Attirbute List location.

If you glance at your Mini Memory Manual, you will see on page 75, that TI claim the 'standard' Sprite Attribute List is using VDP memory locations 768 to 895. There is therefore enough room for 32 sprites... or is there?

In fact, TI have shown an incorrect start address for the pattern colour table, as the colours for the cursor and the edge of the screen are held in location 895. In order to use 32 sprites without spoiling the screen colour, we need to move the sprite attribute list (SAL for short).

This we are permitted to do. Page 327 of the Editor Assembler Manual refers.

The address at which the Sprite Attribute List (henceforth: SAL) can be found is stored in VDP REGISTER 5.

The value of the registers is changed by peek'ing a memory address which is offset from the appropriate basic value.

Example:
The basic address for VDP register 5 is -31488.
The normal SAL starts at address 768, which is 6 x 128.
Thus we can vary the SAL in units of 128: each offset=128.

To have 32 sprites on screen, we need 32x4=128 bytes of memory which will not be corrupted by the TI BASIC program. An apparently safe area can be found around VDP address 1536-> which is usually used to store the definitions of characters 97 onwards.

To move the SAL to start at 1536, we divide 1536 by 128: 1536/128 = 12.
we then add this offset to the basic address for register five:
-31488 + 12 = -31476
As you can see from the listing, to move the SAL we merely use:
CALL PEEKV(-31476,A) [The variable A is a dummy but necessary]

NB: There is no need to reserve memory for this program. (MINI MEMORY REOUIRED).

100 REM MOVE SPRITE TABLE
110 CALL PEEKV(-31476,A)
120 REM
130 CALL CLEAR
140 PRINT "HOW MANY SPRITES DOES A":"TI99/4A HAVE?"
150 FOR RT=1 TO 120
160 FOR SP=0 TO 31
170 CALL POKEV(1536+SP*4,RT+3*SP,20+SP*5,159+SP,15)
180 NEXT SP
190 NEXT RT
200 GOTO 150
210 REM
220 REM TO RESTORE SYSTEM
230 REM KEY IN:
240 REM CALL PEEKV(-31482,A)
250 END

This short program will produce 32 sprites, slowly moving down the screen.


All of the registers can be changed in the same way, and details can be found in the editor/assembler manual, pages 326/327.

Summary of all of the registers

All of the registers can be changed in the same way, and details can be found in the editor/assembler manual, pages 326/327.

REGISTER ZERO

is a multi purpose register, only one bit of which has any relevance to the TI99/4A. This is used to select bit map mode. It does not seem to be of use from TI Basic.

REGISTER ONE

is dealt with in detail above.

REGISTER TWO

defines the base address of the Screen Image Table. See above for an example.

REGISTER THREE

is the base address of the colour table. You can instantly change the colours of every colour set by switching the base address of the color table. As above, you need to reserve memory, and place your alternative table into the reserved memory area, then switch into it, and out of it.

Basic Address: -32000
Normal Start Address: varies:-
TI BASIC: 768, EX BAS: 2048, Machine code,Ed/As:896

Reset to TI Basic Normal: -32000 + ( 13 * 64) = CALL PEEKV(-31232,A)

(Multiplier is 64. The first address is the values for the colour of colour set number one.)

REGISTER FOUR

Base address of the pattern descriptor table. In TI Basic, the register has a value of 0 and therefore points to the same area of memory as the screen: BUT: the screen occupies only 0 to 768. The pattern descriptor table is in chunks of 2k, and thus with a base of zero, the top is at 2048. In TI Basic, you will find the character patterns described from locations 1008 to 2040.

Thus, although the two tables occupy the same area of memory, they do not conflict. However, this does explain why you cannot define characters with ASCII values under 30 or over 143. There is not enough unused table.

This also explains why, when using Sprites with TI Basic and Mini Memory, you do not use the actual ASCII value, but a larger number, to point to the correct pattern description in the table: normally the console will calculate the offset for you, but using CALL POKEV in this way, we need to add the offset on for it.

Basic address: -31744 Multiplier:2048
eg -31744 +1 = CALL PEEK(-31743,A) will locate table at 2048.

(NB: It will point to 2048 as start of table: it is up to you to actually place meaningful values in there

REGISTER FIVE

base address of sprite attribute list. Dealt with above. Basic address: -31488 Multiplier: 128

NOTE: We are not given the opportunity to relocate the SPRITE VELOCITY TABLE.

The Sprite Velocity Table expects to find the Sprite Attribute List at 768, and automatic motion of sprites is not possible unless the SAL is found in this ‘normal' position.

REGISTER SIX

Base address of the SPRITE DESCRIPTOR TABLE. In Extended Basic (& TI Basic with Mini Mem) the Sprite Descriptor Table uses the SAME memory area as character descriptions. This enables us to give the ASCII value of a charactor to indicate what we want our sprite to look like.

However, when using machine code, this table can be relocated which enables us to use 32 sprites which do not look like any of the definable characters.

The BASIC ADDRESS is -31232 Multiplier: 2048

REGISTER SEVEN

a dual purpose register.

Bits 0 to 3 carry the colour code of the foreground colour when using the 40 column text mode, while bits 4 to 7 carry the colour code for the SCREEN.Of little value from Basic.

Basic address is -30976

The default value of the register is >F5 (245) when using the Editor Assembler, but with TI BASIC or Extended Basic, the register has a normal value of >07 (Decimal 7, Binary 000001111. This value of 7 equates to a COLOR CODE of 8, Cyan.

The editor assembler manual incorrectly gives a Basic default value of >17