Page 1 of 1

C68 Window

Posted: Mon Jul 23, 2018 6:49 pm
by Whopper
Hi All,

Please could one (or more) or you C68 gurus out their show me some example code to define and use a window? I do not want the default sized window, but to use my own values.

I've looked at the documentation and, apart from a headache (and drinking problem) I've only achieved a remarkable amount of errors.


Thank you,

Whopper

Re: C68 Window

Posted: Mon Jul 23, 2018 7:10 pm
by XorA
This?

viewtopic.php?f=3&t=1788&start=80#p16234

I asked a similar question ages ago!

Re: C68 Window

Posted: Mon Jul 23, 2018 7:51 pm
by Whopper
XorA wrote:This?

viewtopic.php?f=3&t=1788&start=80#p16234

I asked a similar question ages ago!
XorA,

No, unfortunately not that. I've got that. I found the definition of the WINDOWDEF-t type and can create an instance of the type. But how to create the thing? That's my problem.

Thanks for answering,

Whopper

Re: C68 Window

Posted: Mon Jul 23, 2018 8:31 pm
by tofro
The initial Window in a C68 program is called the console - It is normally opened by the startup code and defined by setting the _condetails structure.

If you want to open additional windows beyond the console, there are various ways to do that:

(

Code: Select all

chanid_t ut_con (WINDOWDEF_t *wdef)
is a low-level call to open a new window - It's not associated with C I/O in any way, and only prepared for unbuffered I/O, so your only way to use it is low-level calls like io_sstrg() and sd_... calls.

Code: Select all

chanid_t ut_window (char *name, char *details)
Is similar, with a device name like "con_512x256a0x0" and the same restrictions.

For C I/O, you need to open or fopen a device with a device name:

Code: Select all

FILE *handle;
handle = fopen (con_512x256a0x0","rw");
if (handle != NULL) {
	fprintf (handle, "%s\n", "Hello World");
}
will open a new window for C character I/O. You can use standard C I/O functions to communicate with that window. Note you will not get the nice C68 window title and border that you get on the console.

You close such a window in exactly the same way as you would close any other file.

Tobias

Re: C68 Window

Posted: Mon Jul 23, 2018 9:07 pm
by Whopper
tofro,

Thanks for your reply.

The last code example seems to be what I want. I tried this on Qemulator and Q68 and neither worked. They both compiled fine, but on executing the default console was was displayed with the usual end message "Press ENTER to continue."

Whopper

Re: C68 Window

Posted: Mon Jul 23, 2018 9:20 pm
by tofro
Note if you actually want to see the window, you need to give the system some time to draw it - Your program seems to end prematurely and the window is closed again so fast (because the job is done), that you have no chance to see something. Send the program into a long loop after opening the window.

Tobias