aalea wrote:
Code: Select all
#include <qdos.h>
void main(void){
short dm = 8;
short dt = -1;
mt_dmode (&dm,&dt);
}
not sure if it's ok, but works.
Looks OK to me.
aalea wrote:
But when I try to read the keyboard, I was totally lost, and I can't found information on internet about how to do it?
Using QDOS, you can actually read the keyboard in several ways:
- Read a row of the keyboard directly(raw), like KEYROW in S*BASIC
- Read a byte from the keyboard queue (like INKEY$)
- Even more sophisticated methods using the C stdio library
I guess you know how to do (3) when you know C.
(2) works like so:
Code: Select all
int channelID;
char key;
int error;
channelID = fgetchid (stdout); // get the QDOS channel ID for stdout
error = io_fbyte (channelID, -1, &key); // Fetches last keypress into key
If you don't want to wait for a key, change the "-1" in the io_fbyte call (the "timeout") to 0 or the number of ticks you want to wait for a key press. When error==ERR_NC, no key was available.
And (1) is even a bit more tricky, because you need to talk to the co-processor like so:
Code: Select all
long IPCcmd [2] = { 0x09010000L, 0x00000102L }; // The "1" in the second long is the keyrow #
int keyRow = mt_ipcom ((char *)IPCcmd); // returns the same as S*BASIC KEYROW
The above example is set to read KEYROW (1) (replace the "1" in the second long with the row # you want to read, it's set to - Cursor keys, ENTER, ESC - in the example) and returns a bit mask of pressed keys in the respective row. Consult the SuperBASIC manual to see how the keys are encoded. If you want to understand the "magic" behind IPCcmd, consult the QDOS Technical Guide on MT.IPCOM.
aalea wrote:
There area any simple source code? or any tutorial that can I use to learn?
Not that I would know of a suitable one that handles QDOS from C. Best is to read the QDOS Technical guide (which will explain everything in a very concise manner, and in Assembly). Second best is to ask here, when you get stuck
(All documentation can be found on dilwyn.me.uk)