[net.micro.atari] 520ST xbios

sansom@trwrba.UUCP (Richard E. Sansom) (11/07/85)

As promised, here is a list of some of the xbios() calls which
owners of the Hippo-C compiler may wish to use.  Since I don't know
much about the Hippo I can't promise that they will work as listed
here (I've heard that the Hippo int size is 32 bits?).  Oh well,
good luck!

-------------------------------------------------------------------------------

/*
 * If Hippo-C has no xbios() call available, you may be able to
 * get away with the following:
 *
 *		.text
 *	_xbios:	move.l	(sp)+,.temp	; get return address
 *		trap	#14		; trap 14 is xbios
 *		move.l	.temp,-(sp)	; push return address
 *		rts			; return to calling program
 *
 *		.bss
 *	.temp:	ds.l			; temporary storage
 *
 *
 * In this document, the following definitions are assumed:
 *
 *	char = 8-bits
 *	int  = 16-bits
 *      long = 32-bits
 *
 */


/* long Physbase()
 *			Returns the address of the screen's physical
 *			base at the beginning of the next vertical
 *			blank.
 */

#define Physbase()  xbios(2)

/* long Logbase()
 *			Returns the address of the screen's logical
 *			base immediately.
 */

#define Logbase()   xbios(3)

/* int Getrez()
 *			Returns the screen's resolution (0, 1, or 2).
 */

#define Getrez()    xbios(4)

/* VOID Setscreen(log_addr, phys_addr, rez)
 * long log_addr,	Set the screen's logical location (log_addr),
 *	phys_addr;	physical location (phys_addr), and resolution
 * int  rez;		(rez).  Negative parameters are ignored,
 *			making it possible to set one parameter
 *			without affecting the others.
 */

#define Setscreen(logaddr,physaddr,rez) xbios(5,logaddr,physaddr,rez)

/* VOID Setpalette(palette_ptr)
 * long palette_ptr;	Set the palette register (all 16 colors)
 *			from the 16 ints pointed to by palette_ptr.
 */

#define Setpalette(palette_ptr) xbios(6,palette_ptr)

/* int  Setcolor(color_num,color)
 * int  color_num,	Set the palette number "color_num" to
 *      color;		the given "color".  Returns the old color (if
 *			old color is negative, no change occured).
 */

#define Setcolor(color_num,color) xbios(7,color_num,color)

/* long Random()
 *			Returns a 24-bit psuedo-random number.
 */

#define Random() xbios(17)

/* char Giaccess(data,reg_num)
 * char data;		Read or write a register on the sound chip.
 * int  reg_num;	"reg_num" is the affected register, ORed with
 *				$00 to read
 *				$80 to write
 *			"data" is the byte to write to the register.
 */

#define Giaccess(data,reg_num) xbios(28,data,reg_num)

-------------------------------------------------------------------------------

I hope these will help some of you out there.  Remember to make sure
that all of your ints are 16-bits (let me know if I'm wrong about
Hippo's int size).
					R. E. Sansom

jenkin@utai.UUCP (Michael Jenkin) (11/11/85)

In article <1665@trwrba.UUCP> sansom@trwrba.UUCP (Richard E. Sansom) writes:
>As promised, here is a list of some of the xbios() calls which
>owners of the Hippo-C compiler may wish to use.  Since I don't know
>much about the Hippo I can't promise that they will work as listed
>here (I've heard that the Hippo int size is 32 bits?).  Oh well,
>good luck!
>
>-------------------------------------------------------------------------------
>
>/*
> * If Hippo-C has no xbios() call available, you may be able to
> * get away with the following:
> *
> *		.text
> *	_xbios:	move.l	(sp)+,.temp	; get return address
> *		trap	#14		; trap 14 is xbios
> *		move.l	.temp,-(sp)	; push return address
> *		rts			; return to calling program
> *
> *		.bss
> *	.temp:	ds.l			; temporary storage
> *
> *
> * In this document, the following definitions are assumed:
> *
> *	char = 8-bits
> *	int  = 16-bits
> *      long = 32-bits
> *
> */

sorry - it just will not work under HIPPO-C.  Unlike the 'C' that comes
with the development system, HIPPO-C passes everything on the stack as
a 4 byte quantity - thus calls which expect objects of size < 4 will
not execute correctly.  For example, the setscreen call will not
execute correctly as the resolution parameter must be passed as a WORD
value on the stack.

While I'm here.... I'd like to check something out with ST developers
on the net.  A TTP program gets passed argc/argv on the stack, this
stuff is read from the base page before the task is fired up. HIPPO-C
will generate a .PRG file but it does not set up the stack properly for
the call.  Is there a way to get the base page back after a .TTP program
has started up?
-- 
--
Michael Jenkin					University of Toronto
USENET:	{decvax,ihnp4,allegra}!utcsri!utai!jenkin
CSNET:	jenkin@Toronto 
BELL: 	416-978-7321