Skip to main content
Became Hot Network Question
update question to make it easier to find for others, answer by Curt was awesome!
Link
Peter B.
  • 4.5k
  • 16
  • 38

cprintf printing visibleinvisible characters in C program on VIC 20

added second case to include new knowledge about the problem
Source Link
Peter B.
  • 4.5k
  • 16
  • 38

cprintf not printing visible characters in C program on VIC 20

However when I run the program on the VIC20 emulator of VICE, the program terminates without printing any visible output (except for the "READY." from the OS). It turned out that the text is actually there, but it was printed with white characters on white background, although the foreground color was the default blue.

Compiling the same program forAfter adding a clrscr() command, cprintf is working:

  #include <VIC20>   /* this line seems to have no effect */
  #include <stdlib.h>
  #include <conio.h>
  
  int main (void)
  {
      clrscr();
      cprintf ("Hello world!\r\n");
      return EXIT_SUCCESS;
  }

On the C64 the printing works as intendedindependently if there is a clrscr() or not.

Am I missing somethingWhat is the reason that cprintf plays up in the version without the clrscr()?

cprintf not printing in C program on VIC 20

However when I run the program on the VIC20 emulator of VICE, the program terminates without printing any output (except for the "READY." from the OS).

Compiling the same program for the C64 works as intended.

Am I missing something?

cprintf printing visible characters in C program on VIC 20

However when I run the program on the VIC20 emulator of VICE, the program terminates without printing any visible output (except for the "READY." from the OS). It turned out that the text is actually there, but it was printed with white characters on white background, although the foreground color was the default blue.

After adding a clrscr() command, cprintf is working:

  #include <VIC20>   /* this line seems to have no effect */
  #include <stdlib.h>
  #include <conio.h>
  
  int main (void)
  {
      clrscr();
      cprintf ("Hello world!\r\n");
      return EXIT_SUCCESS;
  }

On the C64 the printing works independently if there is a clrscr() or not.

What is the reason that cprintf plays up in the version without the clrscr()?

Source Link
Peter B.
  • 4.5k
  • 16
  • 38

cprintf not printing in C program on VIC 20

I want to compile and run a Hello World program in C with the cc65 compiler for an unexpanded VIC-20 model. For printing I'm using the conio.h function cprintf, since the conio implementation requires less memory than stdio.

The program looks like this (originally suggested by Ulrich von Bassewitz here):

  #include <stdlib.h>
  #include <conio.h>
  
  int main (void)
  {
      cprintf ("Hello world!\r\n");
      return EXIT_SUCCESS;
  }

I compiled with cl65 -t vic20 helloworld.c -o helloworld.prg --mapfile map.txt

The mapfile shows that the compiled code fits, stack starts at 0x1A00, so there is 151 bytes left between 0x18AF and the stack:

  Name                   Start     End    Size  Align
  ----------------------------------------------------
  ZEROPAGE              000002  00001B  00001A  00001
  LOADADDR              000FFF  001000  000002  00001
  EXEHDR                001001  00100C  00000C  00001
  STARTUP               00100D  001046  00003A  00001
  ONCE                  001047  001052  00000C  00001
  CODE                  001053  001709  0006B7  00001
  RODATA                00170A  001834  00012B  00001
  DATA                  001835  001868  000034  00001
  INIT                  001869  001882  00001A  00001
  BSS                   001883  0018AF  00002D  00001

However when I run the program on the VIC20 emulator of VICE, the program terminates without printing any output (except for the "READY." from the OS).

Compiling the same program for the C64 works as intended.

According to the cc65 documentation, conio.h should work for the VIC20 platform.

Am I missing something?