Mini Memory for the TI-99/4a

Mini-Memory Madness
by Peter Hutchison
TI*MES #27, Winter 1989/90

Screen shots:

Cartridge menu Mini Memory menu Easy debug screen

 I decided to write about the Mini-Memory module which must be one of the most under used modules around (hardly a mention anywhere) as really it is considered as a bit of a damp squid. Well, I’m going to turn that on its head: Mini-Memory is one of the most useful cartridges around, why?

What does it have to offer?

* 4K of directly accessible RAM (not VDP RAM in the console).
* 4K of ROM containing routines for 7 new BASIC CALLs and XML machine code routines e.g., Floating Point arithmetic.
* 6K of Graphics ROM containing GPL machine code routines e.g., Device control and trigonometry arithmetic.
* Easy Bug for debugging m/c programs and examining/changing memory.

What can you do with 4K of RAM?

The TI-99/4A has 16K of built in RAM but, and a big but it is, that NONE of it is directly accessible by the TMS9900 processor, everything has to go through a scratch pad RAM and that what make the Texas SLOW! With 4K of RAM you can write super-fast machine code programs with access to all display modes i.e., standard Graphics mode, 80-column Text mode, Multicolor mode, Bit-map mode and Sprites!!!

You can also save your favourite BASIC programs in RAM using SAVE MINIMEM (if it will fit in 4K) and load it up within seconds by OLD MINIMEM ready to run - no slow disk or tape loading!! You could use it as file space and access it randomly like a disk - useful for storing data temporarily, for example extra screens for games or storing adventure locations descriptions.

What use is the Line-by-Line Assembler?

Well, let’s face it the LBL Assembler is no match for the Editor/Assembler and it takes up most of the 4K RAM itself leaving 768 bytes for your own programs but it does not require disk drives although 32K expansion is necessary (I don’t have any though). The LBL converts the assembly directly into m/c as you type it in and uses directives and labels. It can use the 32K RAM expansion for much larger programs (the new Zenoboard will come in useful here!).

What kind of programs could you write: scrolling routines, routines to access some of the other display modes allowing use of proper graphics, small games and routines for use by BASIC such as real lowercase letters, the list is endless.

How can I use it from BASIC?

There are 7 new CALLs available from TI BASIC when the module is inserted:

CALL INIT                 To initialize the module and 32K if connected.
CALL LOAD             To load programs from disk and poke CPU RAM.
CALL PEEK               To examine the contents of CPU RAM.
CALL POKEV           To poke VDP RAM e.g., the screen.
CALL PEEKV            To examine the contents of VDP RAM.
CALL CHARPAT       Returns the hex pattern of a character.
CALL LINK               Runs machine code programs and pass parameters.

The above subprograms can be used to speed up those slow TI BASIC programs by replacing all those slow CALL V/HCHARs with CALL POKEVs and CALL GCHARs with CALL PEEKVs.

For example, the familiar text print at routine can be replaced with:

1000 FOR C=1 TO LEN(TEXT$)
1010 CALL POKEV (A+C-1, ASC (SEG$(TEXT$, C, 1)) + 96)
1020 NEXT C

where C is the count of characters, TEXT$ contains the text to be printed and A is the address of the screen (0-767). Notice that an offset of 96 must be added to character value in POKEV due to a different nature between BASIC and machine level.

 There are a few programs available in the Tape Library using Mini-Memory: MM Racer, Desert Car (using scrolling routines), Disassembler (recommended for m/c programmers) and Joy Sketch.

If you do buy Mini-Memory (£38 from Database), it is definitely recommended, to get the Editor/Assembler Manual (£15) or Introduction to Assembly Language (£7) which will help to teach beginners. There is also Artist (£7) for artists amongst TI owners. It is a definite must for bored BASIC programmers (like me)!!!

Mini Memory Madness
TI*MES #28, Spring 1990

WRITING MINI MEMORY ASSEMBLER PROGRAMS.

 There are two kinds of machine code programs, those that can be run Easy Bug using the E (execute) command, and those with a BASIC interface e.g., CALL LINK.
 According to the Editor Assembler manual (p.440/441), you must start and end your programs as follows:

SV       DATA 0                                  save return address here.
WS      BSS                 >20                  workspace registers are stored here.
ST       EQU                >837C             address of status register.
SR       MOV               R11,@SV        save return address.
LWPI  WS                    set workspace area.
*
*          Your routine goes here.
*
CLR                R0
MOVB R0, @ST         clear status register.
MOV               @ST, R11        restore return address.
B                     *R11                return to Basic etc.
END

 In most cases your routine would need parameters passing to it via CALL LINK. This is where the ROM routines will come into use. The most useful are as follows (see mini memory manual).

NUMREF ... Get numeric parameter (p.54)
R0 - array element number. Usually, 0 for simple variables.
R1 - parameter number in CALL LINK statement
>834A - Floating point accumulator (FAC) area, 8 bytes long.
This is where your number is stored.

STRREF ... Get string parameter (p.54).
R0 - array element number. Usually, 0 for simple variables.
R1 - parameter number in CALL LINK statement
R2 - Address of memory where string is to be stored.
Must be CPU memory (Mini mem >7000 to 7FFF).

CFI ... Convert floating point number to integer (p.49)
Input ... FAC containing FP number to be converted, 8 bytes long.
Output ... FAC containing a 16-bit integer.

For example, the following code fetches the first parameter of a program called DEMO:
10 CALL LINK(“DEMO”, 105)

 

FC       EQU    >834A             address of FAC.
NM      DATA 0                                   number is stored here.
DM      CLR R0                                   array element number is zero.
LI R1,1                                    first item in argument list.
BLWP @>6044                      get numeric parameter and store in FAC.
BLWP @>601C                      call XMLLNK routine.
DATA >1200                           convert number in FAC to integer.
MOV @FC, R0                       put number into R0.
MOV R0, NM                         store it!

To get your program to run in BASIC you must also store the program name in the ref/def area. If you examine the area starting at >7FE8 you will notice that there are three names there already...

ADDRESS:    NAME:           EXECUTE ADDRESS:
>7FE8             LINES >7D9E Lines demo program
>7FF0             OLD                >71AC LBL assembler
>7FF8             NEW               >71A6 LBL assembler

In most cases if there is only one routine to save put your entry over the LINES entry as follows:

AORG >7FE8
TEXT  ‘DEMO  ‘                    must be six characters long! MUST BE!
DATA >7D50              start address of where DEMO PROGRAM begins,
#                                              Not data area

 If you want to add more entries, then you must use the First Free Address (FFAM) and Last Free Address (LFAM) variables. FFAM is at >701C and LFAM is at >701C.
 Normally FFAM contains >7FB2 and LFAM contains >7FEB. First subtract FFAM from LFAM and if the result is greater than 7 bytes then you can add another entry. Therefore subtract 8 from LFAM and store the result in LFAM. For example, if I wanted to add another routine called DEMO2, I would first examine FFAM and LFAM (using M (memory) command (M701c) from Easy Bug, or in LBLA:

AORG >701C
BSS 4                          this will display contents of >701C to >701F
#
#          LFAM - FFAM: >7FE8 - >7FB2 = >0036 or 54 bytes
#          LFAM - 8 :         >7FE8 - >0008 = >7FE0
#          Now we can store the routine name like this...

AORG >7FE0 the new LFAM address
TEXT ‘DEMO2 ‘        name of routine
DATA >7E80              execution address

 I hope this will be a lot of use to Mini Memory owners confused by the complex description given in the manuals.

Mini Memory Madness
TI*MES #29, Summer 1990

Accessing Graphics from Assembler

 As you may know all screen data, colour data and character data are held in what is known as VDP (Video Display Processor) Memory. To access this memory, as the 9900 cannot directly access it, is via the System Utility Routines (p34 in Mini Memory manual p248 in Ed/Assem Manual).

 The screen contains 24 x 32 characters, a total of 768 character positions, the memory for this starts from address 0 to 767 (see Appendix F). Now, to print a character on the screen, depends from where you are called your program from, that is BASIC or Easy Bug and Mini Memory Run option. If you run from Easy Bug you could enter:

LI R1,>3000               ; ASCII for zero (0)
LI R0, 176                   ; row 5 column 16 (5*32+16)
BLWP @>6024          ; call VSBW routine

which prints a 0 at row 5 and column 16. If in BASIC you’d enter:

LI R1,>9000               ; ASCII for zero + >60 (90)
LI R0, 176                   ; row 5 column 16 (5*32+16)
BLWP @>6024          ; call VSBW routine

as there is a screen bias of >60 (see p61 for example). To write a string of characters you would use VMBW e.g.

LI R0, 40                     ; 2nd line of screen
LI R1, MG                  ; address of text
LI R2, 16                     ; length of text
BLWP @>6028         
....
MG      TEXT ‘TI HOME COMPUTER’

To create graphic characters you can modify the character data stored from address >0400 to >05FF 164 characters from “ ” to “_”) (Appendix F) or >0800 (CHR$ 0) to >0FFF (CHR$ 255) without BASIC (Appendix E). For example, try this:

LI R0, >08F0              ; address in character table
LI R1, CR                   ; address of character data
LI R2, 8                       ; number of bytes
BLWP @>6028          ; define character.
LI R0, 170                   ; screen address (5*32+10)
LI R1, >1E00              ; ASCII code
BLWP @>6024          ; display character
B *R11
CR       DATA >3C7E, >DBFF, >E7B0, >C37E

 The colours of character sets can also be changed, the colours are stored at address >0300 to >031F (or >0380 to >039F without BASIC) for each of the sixteen colour sets. For each byte the most sig. 4 bits contain the foreground colour (0=transparent to 15=white) and the least sig. bits contain the background. The following program sets all colours to black on cyan:-

LI R3, 16                     ; number of sets

(Rest of article missing...)

Links: Info on Mini Memory and Editor Assembler.
Download Win994a emulator .
Read TI*MES magazine.