Version | all |
---|---|
Header | {z88dk}/include/newbrain.h |
Source | {z88dk}/libsrc/newbrain |
Include | #include <newbrain.h> |
Linking | n/a |
Compile | n/a |
Supported | Grundy BewBrain |
Comments | n/a |
The “newbrain” library contains functions specific to the Grundy NewBrain computer.
The following data structure describes the NewBrain streams; the currently available functions don't need it because it is transparently managed by the ROM routines. It is useful only to create custom devices.
struct NB_STREAM { u8_t stream; /* stream number */ u8_t driver; /* driver number */ u8_t port; /* port number */ u8_t unused; /* unused */ u16_t address; /* own memory address */ };
struct NB_DRIVER { u8_t entries; /* Number of entry points less 1 */ u8_t openin; /* open for input */ u8_t openout; /* open for output */ u8_t dinput; /* reads a byte from device */ u8_t doutput; /* outputs a byte */ u8_t dclose; /* close the device */ }
Open a stream; these functions are used by the fcntl driver too.
If an error occurs, the error code is returned, otherwise zero.
Examples:
Allocate more memory on channel '0' (console), then open a graphics window leaving two text rows on the top. The graphics device shares the console memory.
nb_open( OUTP, 0, 0, 0, "150" ); nb_open( OUTP, 5, DEV_GRAPHICS, 5, "#0,229" ); printf("Hello!\n2 lines text + lo rez graphics...");
Open the 80 columns console (available on expanded models only), and replace the default output device. Note that the control characters (i.e. line feed) are different.
nb_close (0); nb_open( OUTP, 0, DEV_SSEIO, 0, "" );
Close a file/stream.
Close all the streams.
Send a byte to the stream.
Send a string to the stream.
Send a byte block to the stream. Returns the number of bytes effectively written.
Send a NewBrain-formatted numeric value to the stream.
Get a byte from the stream.
Get a string of max 255 characters from the stream.
Examples:
Read the directory from floppy disk.
char buf[150]; /* Open the directory device on stream 50 */ nb_open( OUTP, 50, DEV_SDISCIO, 0, "" ); /* send 'DIR' command (3) for 'A:*.*' to directory device */ nb_puts( 50, "3A:*.*\n" ); while (strlen( nb_gets(50, buf) )>0) { printf ("%s\n",buf); nb_puts( 50, "4"); /* ask for next item */ } nb_close( 50 );
Get a byte block from the stream. Returns the number of bytes effectively read.
Put a char un the AD models LCD display (position from 0 to 15)
Probably works in non-expanded mode only
Sends a string to the AD models LCD display.
Probably works in non expanded models only
Returns true on an user BREAK request
warm_reset: jump to BASIC entry
Works in non-expanded models only