Subject: VDPID

From: Jeffrey White <[email-masked]>
Date: Sat, 6 Aug 2011 02:08:02 -0700 (PDT)

Preserved in the TI Hardware Compendium, compiled by Dan Eicher:

DTIHM027

CPUID & VDPID 
by Jeff White

40176  2SEP93-2117 Communications
     RE: PC99 and TELCO (Re: Msg 40175)
     From: JHWHITE      To: MARKVC

To clarify that a bit, V14 is used to change the 16K page of VRAM used by the
V9938/V9958.  If data is written to page 0, which is all that exists on the
stock 99/4A, and the page is changed (only possible with V9938/V9958), the
data will not be there.  However, since the page does not change on the
9918A, the data will be found.  The 9918A may mask V14 to V6, and V6 sets
the sprite generator table base address.  Because sprites are inactive in
the text modes which Telco uses, changes to V6 do not affect the video
display.

I have a more innocuous routine, called VDPID, that works on a different
principle.  The only side-effect is that the text mode and background colors
are changed, but the routine does change them to what the programmer gives
the routine.

Jeff

-*-

---------------------------------------------------------------------------

*
*
*
*  CPU identification routine by Jeffrey H. White
*  (c) Copyright 1991
*
*  Usage:  BLWP @CPUID
*
*  Returned values in R1:  if 9900,  = 1
*                          if 9995,  = 2
*                          if 99000, = 3 (Privileged Mode)
*                                    = 4 (User Mode)
*
CPUID  DATA $-16            R8 location
       DATA CPUPC           R9 location
CPUPC  BES  12              skip over R10-R15
       LIMI 0               try to turn off interrupts
       LWPI CPUID-16-6      to preserve R13-R15, new Rx = old R(x-3)
       STST R15             store status
       SLA  R15,12          are interrupts off
       JNE  C99000          no, then definitely in 99000 User Mode
       STWP R13             store current WP
       LI   R14,CONTIN      trick with PC required by LST-less 9900
       LI   R15,>0020       after RTWP, ST10 will be 1 only on 9995/99000
       RTWP                 load ST, keep current WP, and execute next
CONTIN LI   R14,>0001       load value to return if 9900
       STST R15             ST10 was not affected by previous instruction
       SLA  R15,7           check ST7 for Privileged (Supervisor) Mode
       JLT  C99000          ST7=1 always on 99000 in User Mode
       JEQ  C9900           ST10=0 always on 9900
       MOV  @>FFFA,R15      9995 on-chip decrementer location
       AI   R15,>8000       most distant value from decrementer
       MOVB R15,@>FFFB      byte writes to 9995 decrementer mess up both
       AI   R15,>8000       restore register to previous decrementer value
       CB   R15,@>FFFA      decrementing is not fast enough for bytes to equal
       JNE  C9995           on 99000, memory or not, >FFFA will not change
       INC  R14             only executes if 99000 is found
C9995  INC  R14             only incremented once if 9995
       MOV  R15,@>FFFA      restore the value
C9900  LWPI CPUID-16        restore entry WP
       MOV  R11,@>0002(R13) put at caller R1
       RTWP                 finished
C99000 LI   R14,>0004       value returned if 99000 User Mode
       JMP  C9900           go exit

------------------------------------------------------------------------------

*
*  VDP identification routine by Jeffrey H. White
*  (c) Copyright 1991
*
*  Usage:  BLWP @VDPID
*
*  Returned values in R1:  if 9918A, = 1
*                          if V9938, = 2
*                          if V9958, = 3
*
VDPWS  BSS  32
VDPID  DATA VDPWS
       DATA VDPPC
VDPPC  LI   R10,1
       LI   R0,>0F04
       BLWP @VWTR
VDPST  MOVB @VDPSTA,R12
       JGT  VDPST
       JEQ  V9918A
       MOVB @VDPSTA,R12
       JLT  V99X8
       JMP  V9918A
V99X8  LI   R0,>0F01
       BLWP @VWTR
       MOVB @VDPSTA,R12
       SLA  R12,5
       JLT  V9958
       JMP  V9938
V9958  INC  R10
V9938  INC  R10
V9918A LI   R0,>0F00
       BLWP @VWTR
       LI   R0,>07F4
       BLWP @VWTR
       MOV  R10,@>0002(R13)
       RTWP
*
*