Tutorial 7
Displaying Text

Overview
   
This tutorial will show you how to make a program that will display normal and inverse (white on black) text.

Programming
   
The program below will display normal text on the home screen. The program uses the calls we have already learned, and adds some new ones. In a future tutorial, we will make a program that displays small text.

 

#define B_CALL(xxxx)   rst 28h \ .dw xxxx
#define B_JUMP(xxxx)  call 50h \ .dw xxxx

_clrlcdfull                      =4540h                         ;The calls we will be using are defined here or use an include file
_homeup                      =4558h
 
_puts                            =450Ah
CURCOL                      =800Dh
CURROW                     =800Ch
           
            .org 9D95h 1">       
           
            B_CALL(_clrlcdfull)                               ;Clear the screen
            B_CALL(_homeup)                                ;Bring on the home screen
            ld         a,04">                                           ;Load "a" register as zero
            ld         (CURCOL),a                             ;Load zero into the y coordinate
            ld         (CURROW),a                            ;Load zero into the x coordinate
            ld         hl,txtLabel                                ;Load text from label below
            B_CALL(_puts) 4">                                     ;Put text on screen
            B_CALL(_clrlcdfull)                               ;Clear screen
            ret5">                                                       ;Return to OS
txtLabel:5">                                                          ;the "Label" can be replaced with any name you want as long as you change the one on the top
            .db       "This Program    "
 
.db       "displays text      "
            .db       "on the home     "
            .db       "screen. It can   "
            .db       "be up to 16 char"
            .db       "long, it     can  "
            .db       "only be 8 lines  "
            .db       "long.              ",0         
.end
END
 

New Commands Used
   
(CURCOL) - the y coordinate of the cursor
    (CURROW) - the x coordinate of the cursor
    _puts - Puts the text on the screen. This command will bring the specified text to the screen.
    _getkey - Detects a key press on the key pad
    ld - z80 instruction fo loading something. In this program, it loads 0 (zero) to the "a" register. The syntax is - ld (register), (value#)

Registers
   
The calculator's memory is where nearly all data is stored.  Unfortunately, memory access is relatively slow for the processor.  So, when we want the processor to manipulate data, like add two numbers together, we don't want to do it in the memory.  Instead, we load the data into special fast memory locations inside the processor itself called registers. In the normal text displaying program (above), the value "0" was saved into the "a" register. The value in the register was then in turn, loaded in to CURCOL and CURROW (the X and Y coordinates of the text). Registers are extremely important! If you don't understand them, I recommend that you read tutorial 4 in Andy S.' tutorials.

Inverse Text
   
Jeez, things just keep getting better. Inverse text is normal font text (white) on a black background. This program will display the text "TI-83 Plus Asm" in inverse text. All you need to know to display inverse text is loading text coordinates and setting textinverse mode.

 
#define bcall(xxxx)        rst 28h \ .dw xxxx
#define bjump(xxxx)      call 50h \ .dw xxxx
 

_clrlcdf             =4540h
_homeup          =4558h
_puts                =450Ah
CURCOL          =800Dh
CURROW         =800Ch
textinverse        =3                                            ;See the new commands section for more information
textflags           =5
 
.org 9D95h
 
            bcall(_clrlcdf)    
            bcall(_homeup)
            set       textInverse,(iy+textflags)            ;Sets the textinverse mode
            ld         a,0                                           ;Load 0 to the "a" register
            ld         (CURCOL),a                 1">            ;Setting Y coordinates
            ld         a,0                                           ;Loading 0 to the "a" register
            ld         (CURROW),a                            ;Setting X coordinates
            ld         hl,txtTIAsm                   1">            ;Display text from the TIAsm label 2
            bcall(_puts) 3">                                          ;Put text on screen
            res       textInverse,(iy+textflags)            ;Resets the text inverse                        

            ret4                                                      ;Return to OS
txtTIAsm:
            .db       " TI-83 Plus Asm ",0                  ;Text to be displayed on screen
.end
END
 

New Commands Used
   
set - z80 instruction that sets the characteristics of the TI
    res - z80 instruction which will reset the characteristic
    textinverse - Inverse text mode of the TI
    textflags - You don't need to know this yet

 

 

Tutorial 8

    Click to return to the site's menu... or here to get back to the tutorial's menu.