Page 1 of 1

Developers Crib Sheet

Posted: 27 Sep 2015 10:58
by thewiz
Hi All,

I have put together a crib sheet for developing on the MTX and Dave has kindly posted it on his site at ... v.htm#crib.

All feedback welcome.

I am now looking for additions to add, such as if the other RST instructions, sys vars etc are worth having or if they are too basic centric. Dave suggested only listing a number of useful ones, e.g. memory pages, addresses used by save/load.

Another idea was useful ROM routines and how to use them.

Over to you :ugeek:

Re: Developers Crib Sheet

Posted: 27 Sep 2015 14:43
by Martin A
RST &28 is a an interesting RST call,

It has all sorts of utility routines as well as the error handling and floating point. Like RST &10 it uses data bytes embedded in the program code to select the appropriate routine.

Values 0-63 generate the appropriate error message. Ie. To halt with an "Out of range" error would be:
RST &28
DB &22 ;error 34

Values 64-127 call a Jump table in Page 1. There's only 3 entries in the table. The interesting one is
RST &28
DB &42

Which calls the VDINIT function to initialise the VDP. The CFX rom makes use of that to enable the display earlier in the start up sequence than normal to print the status screen

Values 129-191 call the floating point package and other useful bits, all 64 possibilities have actions. Values 192-255 call the came routines, but Bit7 is treated as a continuation signal, so the next byte is also interpreted by RST &28, useful for the maths package where there are frequently a number of steps to be taken to perform a given function.

One of the most useful "non math" routines is:
RST &28

That calls the Print the character in A routine at &0CAB. Calling vis RST &28 is recommended as it takes care of any rom paging required. It's easier to use than the RST &10 call that prints the characters in the BC pair, and is the routine that RST &10 calls anyway!

I seem to remember Genpat doing an article or 2 on the floating point, I don't remember if that touched on any of the other utility routines.

Re: Developers Crib Sheet

Posted: 28 Sep 2015 21:10
by Martin A
Re the crib sheet, a couple of things about the VDP section.

The VDP registers for Graphics mode 2 should be

Register 3 - FF
Register 4 - 03

The TI documentation says for graphics mode 2 the LSB's should all be one's instead of 0. The only valid values for graphics 2 are supposed to be 7F or FF for register 3 and 3 or 7 for register 4.

I found out why on a MSX site, the lower bits of both R3 and R4 get ANDed in the hardware, R3 with the upper data bits, R4 with the upper address bits.

R3 I've not played with.

R4 is useful if you're using Graphics 2 in character mode rather than as a bitmap. effectively bit 0 controls the middle 3rd of the display, bit 1 the lower third.

If the bit is set that third of the screen has it's own character definitions, if it's clear the definitions for the top third are used instead. The top third always uses it's own characters.

You can play with this in basic, print something on the top 1/3 of the screen, then set R4 to zero ie:

Code: Select all

10 VS 4: CLS
30 OUT (2),0: OUT (2),128+4
40 GOTO 40
And you'll see 3 Hello's instead of 1

For setting up the VDP
Setting up to read data, send the low byte first, bits 6 and 7 of the 2nd transfer need to be zero, ie (high byte) AND 3F

Setting up to write data, again low byte first, for the high byte bit 7 is clear, bit 6 is set , ie ((high byte) AND 3F) OR 40

For register setups you send the data first, the 2nd transfer needs bit 7 set, ie (register number) OR 80. See the example above.

Trying to mix and match reading and writing to the VDP without the correct setups can do "unexpected" things.

Re: Developers Crib Sheet

Posted: 30 Sep 2015 20:47
by thewiz
Thanks Martin,

That is all good information which I will be adding.

I think I've got a list of the RST FP routine names somewhere if not how to use them all.

Will probably go thro the Genpats looking for anything interesting.