I've written a test program to open a console in C68, write some test and draw a block. The console is 512x256, but I've noticed that the text and graphics are shifted to the left. I left in the end message "press any key" that keeps the window open and it's text is where I would expect it. Am I not initialzing the console right?
Attached in a screenshot and the code.
Tim Swenson
{can't seem to attach the code so I'll place it there]
/* gtest2_c
Graphics Test with C68 and QDOS calls
*/
#include <stdio.h>
#include <qdos_h>
char _prog_name[]="gtest";
/* char *_endmsg=NULL; */
int (*_cmdparams)()=NULL;
long (*_cmdchannels)()=NULL;
int (*_cmdwildcard)()=NULL;
long (*_stackchannels)()=NULL;
/* set up definition of CONsole window */
struct WINDOWDEF _condetails = {
2, /* border color */
1, /* border width */
0, /* Paper */
7, /* Ink */
512, /* Width */
256, /* Heigth */
0, /* X origin */
0 /* Y origin */
};
/* set up definition of BLOCK */
struct QLRECT block = {
20, /* Width */
20, /* Height */
0, /* X origin */
0 /* Y origin */
};
void main () {
int i,x;
FILE *fd;
chanid_t channel_id;
fd = fopen("CON_","wr");
channel_id = fgetchid(fd);
_initcon();
sd_clear(channel_id,-1);
fprintf(fd,"Test \n");
sd_fill(channel_id,(timeout_t) -1,(colour_t) 2,&block);
fprintf(fd,"test test \n");
for ( i = 1; i > 1000000000; i++) {
x = i * i;
}
fclose(fd);
}
C68 Console
Re: C68 Console
The global variable _condetails is only applied to the initial console that is opened by the startup code by default - additional console windows that are opened in your code don't get _condetails applied.
If you want to resize such a console, use the sd_wdef or ut_win library calls, for example.
Tobias
If you want to resize such a console, use the sd_wdef or ut_win library calls, for example.
Tobias
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: C68 Console
Tofro,
Thanks. I was thinking that opening "CON_" was referring to the first console. If I use the default console, how do I convert that into a QDOS file handle? Or should I just open my own window (not open a default console) and go that route. I'll probably try that this evening and see how it goes.
Tim Swenson
Thanks. I was thinking that opening "CON_" was referring to the first console. If I use the default console, how do I convert that into a QDOS file handle? Or should I just open my own window (not open a default console) and go that route. I'll probably try that this evening and see how it goes.
Tim Swenson
Re: C68 Console
That's simple. The default console has a C file handle that is assigned to the global variable stdout.swensont wrote:Tofro,
Thanks. I was thinking that opening "CON_" was referring to the first console. If I use the default console, how do I convert that into a QDOS file handle? Or should I just open my own window (not open a default console) and go that route. I'll probably try that this evening and see how it goes.
Tim Swenson
To get the QDOS channel ID associated with that C file handle, use the function fgetchid.
Code: Select all
QLRECT_t wrect = { 512,256,0,0 };
int channelId, result;
/* obtain channel ID of default window */
channelId = fgetChid (stdout);
/* resize default window */
result = sd_wdef (channelId, -1, 0, 1, &wrect);
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: C68 Console
Tim,
some of what you see might actually not be a problem caused by C68, but rather a standard "problem" (not actually) one of PE:
For your convenience, C68 opens the default console as a managed window (i.e. sets the PE outline). If you don't tell it otherwise, the outline of the default console (which is the primary window) will have a size that fits onto the BBQL's "TV" screen, and PE (not C68) will force all secondaries (i.e. all channels you'll open yourself) to fit within this secondary window.
This can be addressed in two ways:
I'll check.
Hope this helps,
Tobias
some of what you see might actually not be a problem caused by C68, but rather a standard "problem" (not actually) one of PE:
For your convenience, C68 opens the default console as a managed window (i.e. sets the PE outline). If you don't tell it otherwise, the outline of the default console (which is the primary window) will have a size that fits onto the BBQL's "TV" screen, and PE (not C68) will force all secondaries (i.e. all channels you'll open yourself) to fit within this secondary window.
This can be addressed in two ways:
- Tell C68 to not set the outline of the initial console. This is done by telling the C68 runtimes not to do anything about the initial console, by setting the consetup function to a "do nothing" dummy:
This will automatically make the initial console an unmanaged window i.e. a naked QDOS con_ (implies its contents will also not be restored by PE after it has been buried) and tell PE to leave that window alone completely. This will allow your program to open windows of arbitrary size and position outside this initial window.
Code: Select all
// Note this needs to be outside any function on global level void (*consetup)() = NULL;
- While the previous approach is the "PE, leave that window alone" approach, the other way to address that is a more PE-cooperative approach: Before you open a secondary, set the outline of the primary to some size that has enough room to fit your desired secondary's size. You use the iop_outl call to do that. So if you want your secondary to be able to cover the whole screen, set the outline of fgetchid(stdout) (the primary) to the whole screen first (you might want to detect the actual screen size first before that). This makes sure your secondary can fit into the primary and is not forced to some smaller size and position by PE.
You can do that also by supplying a _condetails structure of your desired primary window's size on global level and override the default initial console size in C68 (note your program might not run then properly on machines with a screen size that cannot fit that new default).This will make the initial C68 console fill the BBQL's whole MONITOR screen size.Code: Select all
// Note this needs to be outside any function on global level WINDOWDEF_t _condetails = { 2, /* border colour (red) */ 0, /* border width */ 0, /* paper (black) */ 7, /* ink (white) */ 512. /* width (pixel) */ 256, /* height (pixels) */ 0, /* x origin */ 0 /* y origin */};
I'll check.
Hope this helps,
Tobias
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO