----------------------------------------------------------------------------- ----------------------------------------------------------------------------- 82-PORTS.TXT A Programmer's Guide to TI-82 Ports Version 0.5 Copyright (c) 1997 Mattias Lindqvist & Dines Justesen ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- This file tries to explain what the TI82's ports are used for, and how to use them. Suggestions, additions and corrections are very welcome, mail Dines Justesen at c958362@student.dtu.dk or Mattias Lindqvist ml@df.lth.se Most of the ports on the TI82 is used in the same way as on the TI85. Because the TI82 has another kind of display some of the ports has been moved to another location, but most of them are used in exactly the sameway. Therefore most code written for the TI85 can easily be translated to the TI82. ----------------------------------------------------------------------------- Port 0 : Link port R/W ----------------------------------------------------------------------------- This port is used to communicate with other calcs, computers and CBL equipment. The port is used in the same as on the TI85. Write: ------ Bit State Function -------------------------------------------------------------------- 6+7 Have some effect, but it does not seem important. Use 11. 5 1 White wire is negative or off 0 White wire is negative or positive 4 1 Red wire is negative or off 0 Red wire is negative or positive 3 1 White wire is negative 0 White wire is positive or off 2 1 Red wire is negative 0 Red wire is positive or off 0+1 Have some effect, but it does not seem important. Use 00. The following values is used by the rom. Value Function ---------------------------------------------------- C0 White wire is positive. Red wire is positive. D4 White wire is positive. Red wire is negative. E8 White wire is negative. Red wire is positive. The value FC could be used to make both red and white wire negative, but this is not used by the system. Read: ----- Bit State Function ------------------------------------------------------------------------ 4-7 Not used. (Always 0 ?) 2+3 Last value written 1 1 White wire is positive, but curcuit is open 0 White wire is positive and electrons are flowing, or negative 0 1 Red wire is positive, but curcuit is open 0 Red wire is positive and electrons are flowing, or negative ----------------------------------------------------------------------------- Port 1 : Keyboard R/W ----------------------------------------------------------------------------- This port is used to read the keypad. When a byte is written to port 1, any bit set will mask out the keys listed below. Bit Keys ------------------------------ 7 6 Y= WINDOW ZOOM TRACE GRAPH 2ND MODE DEL 5 STO> LN LOG X^2 X^-1 MATH ALPHA 4 0 1 4 7 , SIN MATRX x,T,o 3 . 2 5 8 ( COS PRGM STAT 2 (-) 3 6 9 ) TAN VARS 1 ENTER + - * / ^ CLEAR 0 UP DOWN LEFT RIGHT When the keypad is read,a low bit means that one of the keys listed has been pressed. Bit Key ------------------------------------------------ 7 ALPHA x,T,o DEL STAT 6 MATH MATRX PRGM VARS CLEAR MODE 5 X^-1 SIN COS TAN ^ 4 X^2 , ( ) / Y= 3 LOG 7 8 9 * WINDOW UP 2 LN 4 5 6 - F3 ZOOM RIGTH 1 STO> 1 2 3 + TRACE LEFT 0 0 . (-) ENTER GRAPH DOWN ----------------------------------------------------------------------------- Port 2 : Set rom page R/W ----------------------------------------------------------------------------- This port changes/returns the current rom page used. The rom page chosen here is mapped into memory from $4000. Bit Function -------------------------------------------------------- 0-3 Number of rom page (0 to 7) 4-7 Unknown, but use 10001 otherwise the calc might halt ----------------------------------------------------------------------------- Port 3 : Status R/W ----------------------------------------------------------------------------- Port 3 is used check/set the status of misc hardware on the ti82. Write: Bit Function ------------------------------ 4-7 Not used ? 3 LCD Status + (1 = Off) ??? 2 Mask timer interrupts if clear ? 1 VBI 0 Mask ON key interrupts ? Read: Bit Function ------------------------------ 4-7 Always 0 (not used) 3 On key status (1 = not pressed) 2-0 Not know ----------------------------------------------------------------------------- Port 4 : Interrupt control W? ----------------------------------------------------------------------------- This register is controlles the speed of the hardware interrupts. Bit Function ------------------------------ 3-7 Not used 1-2 Interrupt speed (11 = normal, 00 = fastest) 0 Calc frezes if set ----------------------------------------------------------------------------- Port 10 : Control port for the display controller W? ----------------------------------------------------------------------------- Send a command to this port to tell the controller what to do on the display, then write the needed data to the Data port. For instructions on how to use this port see below. ----------------------------------------------------------------------------- Port 11 : Data port for the display controller R/W ----------------------------------------------------------------------------- After having written the needed control words to the control port, the data values are read from/written to this port. For instructions on how to use this port see below. The display controller ---------------------- The TI82 does not have a memory mapped display like the TI85, but instead it uses a display controller to read/write from it. Below is an explanation on how to use varius functions of the controller. The display controller probably forgets all data when it is turned off, therefore the ti82 has a speciel buffer for backup up when APD is used. The following information explains how to use the display controller for varius purposes. Before all write operations to the controller you have to call the build in delay function. If you do not call the delay function the display controller migth not execute the command written to it (it might even do something else!). Set contrast ------------ Any command writen to port 10 which has the 2 MSB set will alter the contrast. The valid values for the contast is 18h to 3Fh, with 3Fh being the darkest and 18h the lightest. So to set the contrast to the value in a use the following code (a has to hold a valid contrast value). or 0C0h ; Set the two MSB's call 7F3h ; Delay use for display commands out (10h),a ; Write command to port ret Note that this function will set the contrast, but it will be returned to the previus value if the build in functions are used. The system functions uses contrast values 0 to 20, and the current value is stored in the system part of the ram. To avoid that the contrast is set to what it was before remember to change the value in the system ram too. Read/set pixel -------------- The display controller writes/reads from the position indicated by the display cursor. The cursor can be moved by writing a command to port 10h, followed by a number which indicates where to go. One command will change the line another one the coloum. 20h . . . . . . . . 2Bh (0,0) The drawing on the left shows the coordinates 80h +----------------------+ used by the system and the display control- | | ler. The values in () is the system coordi- . | y | nates, the other ones are the coordinates . | | | used by the display controller. The system . | v | uses another coordinate set too, when this is . | | used the top line (line 0 before) is called 63 | x--> | and the bottom line line 1. The values in the BFh +----------------------+ x direction are the same as before except that (63,95) the last line is not used. So the pixel in the upper rigth corner is called (63,94). The command to change the coloum is 20h + the number of the coloum. The valid coloum numbers are 0h to Bh, with 0 being the coloum most to the left. So to go to coloum 0 use the following code. ld a,20h ; Write coloum number call 7F3h ; Display delay out (10h),a The command to change the line is 80h + the number of the line. Valid line numbers are from 0 to 3Fh, with 0 being the topmost line. So to goto the line at the bottom of the display use the following code. ld a,0BFh ; Write line number call 7F3h ; Display delay out (10h),a After the cursor position has been changed the first value read from port 11h is not the byte at that position. So after each change of cursor position you have to make one read operation before you start reading data. Block Write ----------- After each read/write operation the cursor position is automaticly increased. This function can be used to read/write larger amount of data at a time. You can use the commands 5 and 7 to choose the direction in which the cursor moves after a write/read operation. 5 makes the cursor go to the rigth, 7 makes it go down. The rom contains two functions which changes the direction, the advantages of using them is that they do not alter the A register (see 82-ROM for information on these rutines). Hardware scroll --------------- The display controller can scroll the picture it is currently showing, but only up/down. This will not move the picture in the controllers internal memory, but it will show the picture starting from a different addres. The command to scroll the picture is 40 + the number of lines you want the display scrolled. So for example to scroll the display 3 lines (up) you could use the following code. ld a,$43 out ($10),a call $7F3 On/Off ------ The display controller can be told to start/stop sending data to the display by sending the commands 2 (stop) and 3 (start). This does not turn off the display even though it look clear, you have to use port 3 to turn off the power to the display. Stopping the display controller will not erase the memory in it, but turning off the power will. Other functions --------------- Besides the functions mentioned above the following functions is known to be used in the rom. 1,8,12 These functions have not been tested, but from the rom it looks like they are used to turn on/off the display. This leaves the following functions which might be unused or just not yet know. 0,4,6,9..11,13..1F,2C..3F,C0..D7