Page 1 of 2

Digital C

Posted: Fri Mar 06, 2020 6:35 pm
by bwinkel67
So I've been re-compiling old software that was written under Digital C in the 90's with some success. I've been using the version that I grabbed off of Dilwyn's site since it was easier than trying to reclaim it from microdrives of my bought version way back when (I do have the original cartridges and backup ones). I'm noticing something odd in that the executable creates a base window with red border even if you create your own and/or change the stdout window. In some cases it persists and then goes away upon a mode change in QDOS and in others it just appears a split second before the final window appears. Back in the 90's I don't ever recall this phenomenon occurring so I must have either a) had an older version that didn't do that or b) there was some sort of flag you set when either compiling (cc) or linking (cg) that I have forgotten. I do use the -nc option during linking but can't find anything else so far.

Anyone use Digital C and have an idea? I'm just trying to reclaim a few pieces of software and am not interested in porting it to C68 -- Digital C was based on Small C and there are differences that would require some reformatting/rewriting (I had to do that back in the 90's when porting to Think C on the Mac). I really just want to re-compile and be done with it since the code was compiled initially with Digital C some 30 years ago and worked as advertised.

Re: Digital C

Posted: Sat Mar 07, 2020 4:16 am
by swensont
Back in the 90's I used Small C a lot. As you said, DPC is just a revised version of Small C. Have you used the _console() function?

It is used like this;

int fd;

fd = _console();

_console() {

int fd1;

fd1 = fopen("con_512x256a0x0","w");
paper(fd1,0);
ink(fd1,4);
border(fd1,1,2);
cls(fd1);
return(fd1);
}

I've used this in my own DP C code. All I see is the window that I defined. Granted I am testing it with SMSQmulator, so it is fast and I might not see what you are seeing.

Tim Swenson

Re: Digital C

Posted: Sat Mar 07, 2020 5:02 am
by bwinkel67
I use a mix of stdout and scr:

In my TERM program

Code: Select all

initialize ()
{
   window(stdout, 448, 162, 32, 24);
   put_win(stdout, icol, pcol, bcol);
   mode(4);

   header = fopen("scr_448x12a32x12", "w");
   put_win(header, icol, pcol, bcol);
   put_hdr(icol, pcol);
   
   baud(bps);
}

put_win (fp, icol, pcol, bcol)
   int fp, icol, pcol, bcol;
{
   paper(fp, pcol);
   ink(fp, icol);
   border(fp, 1, bcol);
   cls(fp);
}
If I did the mode(4) command first then I'd get the outline of the Digital C window below my two windows. If I do a mode 4 on the command line it goes away. With the code above -- mode(4) after the window() -- what I see is the Digital C window begin created (I'm assuming it's for the command line option that I don't use via -nc) and quickly flashing and disappearing and then just my window.

From my CL program:

Code: Select all

initQLscr ()
{
   window(stdin,440,124,35,35);
   paper(stdin,7);
   ink(stdin,0);
   border(stdin,2,3);
   mode(4);
}
Again, I see the Digital C window flashing and then my window.

Are you saying if 1) I don't use the window() function and 2) I also avoid using "scr_" and instead use "con_" I will not only get the window of choice but I won't see the flashes? I think I'll give it a try with CL since it only uses a single window.

Re: Digital C

Posted: Sat Mar 07, 2020 6:02 am
by bwinkel67
I tried this:

Code: Select all

initQLscr ()
{
   
   display = fopen("con_440x124a35x35", "w");
   paper(display,7);
   ink(display,0);
   border(display,2,3);
   mode(4);
} 
It did not fix the problem. I just realized that your con_sole actually uses the entire screen so maybe that's why you don't see the artifacts that Digital C leaves. With the above I basically get the Digital C window and my window on top of it. With con_, doing mode 4 in QDOS now won't even make Digital C's window go away. I'm going to guess its the stdin/stdout channel that was there for the command arguments.

Re: Digital C

Posted: Sat Mar 07, 2020 8:48 am
by NormanDunbar
This might not help with the screen artifacts, but, you should only change mode when you need to. Apparently you should read the current mode and check it before changing. This stops unwanted flashings etc.

I'm wondering if Digital C opens a console in case you don't? Maybe the Pointer Environment is interfering? Do you have that loaded? Maybe its stdin, stdout or stderr?

Just a couple of thoughts.


Cheers,
Norm.

Re: Digital C

Posted: Sat Mar 07, 2020 3:57 pm
by Artificer
Hi,

Quote from Digital C manual section 4.12.2:
"If your program contains a function called _console(), this will be
executed before any console window is opened by the entry code. This
is useful for opening your own console window and overriding the
default windows. Your _console() function must return the file
descriptor of your console window."

So for example should open a window as defined :

#include stdio_h

/* #define NOCCARGC */

int scr_xmax,scr_ymax

char *wndoread="w";
char *wndo="con_";

main {


scr_xmax=1024;
scr_ymax=512;


/* move console to under image */
window(startcon,scr_xmax,scr_ymax,0,0);
paper(startcon,0);
cls(startcon);


}

_console() {
startcon=fopen(wndo,wndoread);
return startcon;
}

Cheers

Re: Digital C

Posted: Sat Mar 07, 2020 5:54 pm
by bwinkel67
Oh, thanks to both of you. I didn't realize that _conosle was a special function you had to override. I will give that a try.

Re: Digital C

Posted: Sat Mar 07, 2020 8:13 pm
by bwinkel67
So still have the same problem. It flashes quickly giving me the original window of Digital C and then disappearing for my window. Here is the code I have:

Code: Select all

main ()
{
   int ln;

   initPARSE();

   /* ... removed since it comes after to show rest of code more easily */
} 

/* initializes the parser */
initPARSE ()
{
   initQLscr();

  /* ... removed since it comes after to show rest of code more easily */
}

_console()
{
  display = fopen("con_", "w");
  return display;
}

initQLscr ()
{
   window(display,440,124,35,35);
   paper(display,7);
   ink(display,0);
   border(display,2,3);
   mode(4);
}
So in main I right away call initPARSE() which right away calls initQLscr() which then uses the "display" pointer to resize my window. Note that I have the _conosle() function opening "display as a con_ and returning it (as per instruction). This works no differently than before. I do still have the mode(4) call but that's because I want my shell to run in that.

Any ideas? Or is it basically that Digital C sets up the console first and then when you change it, the artifact of the quick flash showing the old red-bordered 448x200a32x16 still appears.

Re: Digital C

Posted: Sat Mar 07, 2020 8:47 pm
by bwinkel67
Also changed the _console function to this and still the same behavior.

Code: Select all

_console()
{
  display = fopen("con_440x124a35x35", "w");
  return display;
}
It's not a big deal since it goes away, just a lot of flashing and I was hoping to remove it. I must have never noticed it in the day since I usually ran my QL off of a B&W tv since it gave the best clarity over the RF signal.

Re: Digital C

Posted: Sat Mar 07, 2020 8:55 pm
by Artificer
Hi,

The problem may be that your are calling _console from a procedure within main {}

My marginal notes indicate that _console needs to be called directly within main {} and cannot have any other sub calls within it, the joys of DP.

What about this?

int ln;
int scr_xmax,scr_ymax,xpos,ypos;

char *wndoread="w";
char *wndo="con_";

main ()
{
scr_xmax=440;
scrymax=124;
xpos=35;
ypos=35;
window(display,scr_xmax,scr_ymax,xpos,ypos);
paper(display,7);
ink(display,0);
border(display,2,3);
mode(4);
cls(display);


initPARSE();

/* ... removed since it comes after to show rest of code more easily */
}

/* initializes the parser */
initPARSE ()
{

/* ... removed since it comes after to show rest of code more easily */
}





_console()
{
display = fopen(wndo, wndoread);
return display;
}