Difference between revisions of "Programming"

From Ninerpedia
Jump to navigation Jump to search
Line 46: Line 46:


Automatic RUN DSK1.LOAD
Automatic RUN DSK1.LOAD
* CALL LOAD(-31931,0) and CALL LOAD(-31931,128)
Address >8345; turns off and on Extended Basic list protection. Only the leftmost bit is significant, so all values 0-127 are treated as 0 and 128-255 are treated as 1.


* CALL PEEK(2,a,b):: CALL LOAD(-31804,a,b)
* CALL PEEK(2,a,b):: CALL LOAD(-31804,a,b)

Revision as of 14:34, 5 November 2011

Environments

BASIC and its extensions

The well-known foundation of programming on the TI-99/4A were the built-in TI BASIC and the cartridge-based TI Extended BASIC

The installed TI BASIC Language conformed to the ANSI Standard for Minimal BASIC (X3.60-1978).

Several arcane versions of the BASIC dialect added additional commands to it. Very few programs were ever written to take advantage of the additional commands hidden in some of those cartridges (most notable here is the Personal Record Keeping cartridge), while others had considerable effort devoted to them (TI Extended BASIC being a great favorite).

There were many third-party extensions of TI Extended BASIC.

  • Mechatronics Extended BASIC II+ incorporated the APESOFT Expanded Graphics routines into their version of the cartridge.
  • Triton included many additional commands in their Super Extended BASIC
  • Winfried Winkler included many additional commands in Extended BASIC III (in extremely limited release by Asgard, but generally only available as a set of files for the HSGPL card)
  • Myarc Extended BASIC II included many of the commands originally planned for inclusion in TI Extended BASIC II (as seen on the TI-99/8)

Rich Gilbertson devised the most recent extended version of the TI Extended BASIC dialect, RXB, which is generally available as a set of program images for a GROM emulation device.

The Myarc and the CorComp disk controllers added a number of additional support routines to the language.

Useful CALL LOADs

Other systems are known for their PEEKs and POKEs, but neither TI BASIC nor Extended Basic offer such commands. Instead, we have CALL subprograms that do a similar job, CALL PEEK and CALL LOAD. The LOAD subprogram is actually used to load tagged object code but it can also be used to set values in memory or devices.

  • CALL LOAD(-31962,100,155)

This is address >8326; loading the values 100, 155 at those locations makes the interpreter run the program (RUN).

  • CALL LOAD(-31962,100,126)

100, 126 is the code for NEW.

  • CALL LOAD(-31962,100,136)

100, 136 is RESequence. This will renumber all BASIC lines (here by default start 100, increment 10)

  • CALL LOAD(-31962,160,04)

This will execute RUN without pre-scan

  • CALL LOAD(-31961, 149)

Automatic RUN DSK1.LOAD

  • CALL LOAD(-31931,0) and CALL LOAD(-31931,128)

Address >8345; turns off and on Extended Basic list protection. Only the leftmost bit is significant, so all values 0-127 are treated as 0 and 128-255 are treated as 1.

  • CALL PEEK(2,a,b):: CALL LOAD(-31804,a,b)

At location >0002 we have the program counter component of the RESET vector (usually >0024). -31804 is the address >83C4, which is the pointer to the user-defined interrupt routine. In other words, this will make the system execute a QUIT at the next interrupt.

  • CALL PEEK(-31877,A)

At >837B (this address) we find a copy of the VDP status register which is copied there by the console interrupt service routine (ISR).

  • CALL PEEK(-31879,A)

Address >8379 contains a byte value that is incremented on each VDP interrupt (wraps at 255 back to 0)

  • CALL PEEK(-31878,A) / CALL LOAD(-31878,A)

Address >837A is the highest number of a sprite in auto-motion. You can query the number with CALL PEEK, and you can also modify it with CALL LOAD, which will cause higher sprites to stop auto-motion.

  • CALL LOAD(-31806,A)

>83C2 is a flag byte that is read by the console ISR. It is built up like this:

0 1 2 3 4 5 6 7
Enable* Sprite motion* Sound* Quit key* 0 0 0 0

(* indicated negative logic, means that the feature is on with a 0 bit and off with a 1 bit)

Accordingly we get the following settings:

A=64 (01000000): Disable sprite motion

A=0 (00000000): Enable all

A=16 (00010000): Disable QUIT key

If the Enable* bit is cleared (set to 1) we get no sprite and sound processing and QUIT key, but the VDP status is still being read and copied to >837B, the screen blanks after some time, and the interrupt counter is increased. Also, a user-defined ISR is served if registered at >83C4.

Pre-scan control

Pre-scan is used to allocate memory before the BASIC program starts. It causes a notable pause before the first statement executes, because the pre-scan process scans the whole program for variables and subprograms. Extended Basic allows for a quicker start-up by turning pre-scan off and on; these lines are specific comment lines.

100 GOTO 150
110 A=0 :: B$="" 
120 DATA 1
150 !@P-

turns off pre-scan after line 150

200 !@P+

turns it on after line 200. Pre-scan is enabled by default.

Pre-scan must be active for the following program parts:

  • The first DATA statement
  • The first use of a variable or an array
  • OPTION BASE (if used)
  • Reference to each subprogram called in the program
  • DEFs
  • SUB and SUBEND

Variables introduced in the SUB statement (formal arguments) are locally valid, so they must be included. CALLs in the pre-scan need not list actual arguments. You do not need to build correct assignments to variables either. However, the lines must not be executed, or an error will occur.

100 GOTO 150
110 CALL SCREEN :: CALL MYOWNSUB :: CALL CLEAR :: A,B,C=D :: E :: NAME$ :: !@P-
120 DATA 10
150 CALL CLEAR 
160 REM REST OF PROGRAM

Other Programming Languages

Assembly programing

See also the Programming FAQ