Re: [cc65-devel] c64 - getting seemingly random chars on screen
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Michael P. <mp...@bl...> - 2021-03-04 00:13:09
|
On Wed, 3 Mar 2021, gr...@gm... wrote:
> Am Mittwoch, 3. März 2021, 20:15:14 CET schrieb Michael Parson:
>
>> I guess the next question is... why doesn't the X-16 behave the same
>> way?
>
> A bug in it's conio library perhaps? or you are "printing" somewhere else in
> memory that isnt the screen (this could also happen eg if you port this
> program to vic20, which has a much smaller screen)
*shrug* Well, fixed that and it works on the C-64 and the X-16, so,
woo!
Thank you again!
>> As far as compiler/language bugs go, is what I'm seeing with 'cscanf()'
>> expected behavior?
>>
>> #include <conio.h>
>>
>> int main() {
>> unsigned char name[16];
>>
>> clrscr ();
>>
>> cprintf ("what is your name? ");
>> cscanf ("%s", &name);
>> cprintf ("hello, %s\n", name);
>>
>> return 0;
>> }
>>
>> Start typing something at the prompt, hit backspace and it treats it
>> like a return instead?
>
> It's probably expected, scanf doesnt really handle "editing". i'd generally
> avoid using it except for "testcode" - for "production code" you probably want
> a custom textentry function that handles editing properly.
OK. Now that I've got a working C-64 version, after squasing other
bugs that were more obvious due to the slower disk access on the C-64
(the highscore was getting saved in a few places it didn't need to), I
guess I'll look into better ways of reading keyboard input. I have a
vague memory of being told/reading/somehow learning, that scanf() wasn't
considered 'safe' anyways.
This has been a fun learning process, both in learning the C language,
as well as more about the C-64, the machine I loved as a child, played
lots of games on, but other than typing in stuff from RUN and similar
magazines, never programmed using anything other than BASIC.
--
Michael Parson
Pflugerville, TX
|