Venus developer information

$LastChangedDate: 2005-02-04 19:39:49 +0100 (Fri, 04 Feb 2005) $

General information

Source code syntax

Making a Venus program basicly requires the following source code syntax.

vRandom     equ   $FE72
vFastCopy   equ   $FE75

      org   $9329

      db    $E7,"9_[V?",0  ; $E7, $39, $5F, $5B, $56, $3F, $00
      [..code comes here..]

When assembled and squished and you take a look at the code using the calculator's program editor, you will see that the "db"-line becomes send(9prgmθV. And that's how Venus works. If you run that program as a TI-Basic program it will execute Venus, which will further handle all the necessary data loading and then jump to the program's assembly part.

However, this is a very general syntax, which doesn't include any program description or icon and doesn't allow the program to be detected by a Venus shell. Therefore this structure will most likely only be used by very general programs not really needing these extras, like for instance assembly math programs

If you are a game developer the following syntax will interest you more as it is used by Venus shells to detect programs.

vRandom     equ   $FE72
vFastCopy   equ   $FE75

      org   $9329

      db    $E7,"9_[V?",0
      jr    nc,start
      db    "description",0
start
      [..code comes here..]

Or this syntax where the extra 32 bytes are an icon.

vRandom     equ   $FE72
vFastCopy   equ   $FE75

      org   $9329

      db    $E7,"9_[V?",0
      jr    nc,start
      db    "description",0
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
      db    00000000b,00000000b
start
      [..code comes here..]

As you can see, the syntax is the same as the one used in Ion programs except for the required Venus startup line of course. This is why you can add an icon to Ion programs too, which will not be displayed by Ion itself, but may be displayed by a Venus shell with Ion compatibility.

Venus built-in routines

There are 2 routines which you can use in your Venus programs: vRandom and vFastCopy.

vRandom

description: iterates the seed and returns the result in HL.

input: nothing

output: hl=seed

registers used: af, de, hl

vFastCopy (by Joe Wingbermuehle)

description: copies the screen buffer to the screen

input: nothing

output: nothing

registers used: af, bc, de, hl

Tips

Quitting a Venus program

Since Venus programs can be started from the home screen they need to take care of any garbage they leave on the screen themselves. So unless you want to display a message to the user when your program quits, use the following two rom calls to quit your program.

      call  _clrScrnFull
      jp    _homeUp

Then, when you press the [On] key during program execution, you will get an err:break when the program exits. This happens because Venus programs are started as TI-Basic programs (remember the send(9-trick). To get rid of this you should reset the flag that indicates the [On] key has been pressed when your program quits.

      res   4,(iy+9)
      call  _clrScrnFull
      jp    _homeUp

Using vRandom

As you might have seen, vRandom doesn't really return anything useful, so you'll have to do that yourself. The advantage is that you aren't bound to any specific format, but are instead free to implement the routine in whatever way you want. The disadvantage is, you'll have to make your own implementation.

A common usage is where you want to have random numbers between 0 and a given upper bound. This can be implemented in a routine as follows.

random
; input: b = upper bound
; output: 0 =< a < b
      call  vRandom
      ld    d,0
      ld    e,h
      ld    h,d
      ld    l,d
randomloop
      add   hl,de
      djnz  randomloop
      ld    a,h
      ret

vRandom stores its seed as a 16-bit value at FE9Eh. When you call vRandom, a formula will be applied to this value and the result will be stored at that address again. It is safe to mess with this value (copy, restore, (re)set it etc.).