Jump to content
Harry Potter

AtaSimpleIO/cc65 doesn't work.

Recommended Posts

Hi!  I am working on a cc65 library called AtaSimpleIO.  It supplies a simplified way of handling keyboard input and text output that decreases overhead by using the ROM routines.  The test program beeps many times, then the emulator (Altirra 2.50) crashes with a program error.  I attached three files that could be causing the error.  Any help would be appreciated.

crt0.s getkey.s test.c

Share this post


Link to post
Share on other sites

I think that the first thing anyone will say is to use a more up to date version of Altirra. Maybe your hardware setup doesn't allow it...

Share this post


Link to post
Share on other sites
Posted (edited)

Much more likely that he's crashed Altirra the old fashioned way. But yeah, grab the latest altirra.

 

HP, that's the standard crt0.s from CC65.  Did you change it?

 

What's in your simple_io.c file?

Edited by danwinslow

Share this post


Link to post
Share on other sites

If you provide a complete example incl. how you compile it, I will take a look.

Share this post


Link to post
Share on other sites
13 hours ago, Harry Potter said:

I changed the crt0.s file but disabled the change.  Sorry about the repeat!  And if you mean the header file, I attached it here.

simpleio.h 2.25 kB · 4 downloads

Yeah, don't mess with the crt0.s file unless you really know what you're doing. Not implying you don't, just saying it's dangerous.

Share this post


Link to post
Share on other sites
Posted (edited)

You commented out your store of the printc jmp address in crt0.s, so now you have a JMP $0000 in there which is definitely going to be an issue. Looks like you were trying to jmp to the address in $E406 with a 1 added to it (?), which I guess is some kind of E: handler entry point, and the same thing for $E414. You don't have to do it like that, you could set printc up in C as a function pointer and set the address at that time, or just drop into ASM and jmp yourself, look at the options for the asm() function to see how to get symbol addresses/values into your asm statement. Your C program will start directly after crts0.s jsr to your main, so you can put any initialization you like there rather than messing with crt0.s itself.

 

Let me just say I think (if I understand) what your seem to be trying to do is probably not a great idea...if you are trying to jump around the CIO handlers by directly calling OS routines to save time, then (a) it's likely to cause problems, and (b) not sure you'll save all that much time. If you want REALLY fast screen writes then write your own code to do direct screen memory writes, or better yet wrap the conio.h calls in your functions, those are already pretty fast. Looks like you are moving a library from a commodore version, but Atari, generally speaking, you don't want to skip handlers and directly call OS functions, they were mostly all designed to be called by handlers or by the OS itself. 

Edited by danwinslow
  • Like 1

Share this post


Link to post
Share on other sites

I thank you for your input.  My SimpleIO libraries are meant to save code by calling the OS directly with minimal extra work.  It's not necessary for most purposes.  I will stop working on it.

Share this post


Link to post
Share on other sites
1 hour ago, danwinslow said:

You commented out your store of the printc jmp address in crt0.s, so now you have a JMP $0000 in there which is definitely going to be an issue. Looks like you were trying to jmp to the address in $E406 with a 1 added to it (?), which I guess is some kind of E: handler entry point, and the same thing for $E414. You don't have to do it like that, you could set printc up in C as a function pointer and set the address at that time, or just drop into ASM and jmp yourself, look at the options for the asm() function to see how to get symbol addresses/values into your asm statement. Your C program will start directly after crts0.s jsr to your main, so you can put any initialization you like there rather than messing with crt0.s itself.

 

Let me just say I think (if I understand) what your seem to be trying to do is probably not a great idea...if you are trying to jump around the CIO handlers by directly calling OS routines to save time, then (a) it's likely to cause problems, and (b) not sure you'll save all that much time. If you want REALLY fast screen writes then write your own code to do direct screen memory writes, or better yet wrap the conio.h calls in your functions, those are already pretty fast. Looks like you are moving a library from a commodore version, but Atari, generally speaking, you don't want to skip handlers and directly call OS functions, they were mostly all designed to be called by handlers or by the OS itself. 

 

+1

 

I agree that bypassing the CIO handlers is bad idea: it will likely break on machines running upgrades that include alternate OSes.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Harry Potter said:

I thank you for your input.  My SimpleIO libraries are meant to save code by calling the OS directly with minimal extra work.  It's not necessary for most purposes.  I will stop working on it.

Please don't quit on my opinion - I am often wrong :) If you are trying to save code space rather than execution time, then yeah maybe it's not needed. But if you want to use your simple_io as a basis to work in a familiar environment or convert something that is written to use those calls, then setting them up to call the CIO handlers won't really add much code, and you can probably reduce the code space used by conio.h functions somewhat by setting up your own, specifically optimized, CIO calls.

Edited by danwinslow

Share this post


Link to post
Share on other sites

I am trying to convert my MadLib programs to the 8-bit Atari, and it uses CBMSimpleIO.  I could replace all the references to ANSI C instructions, but I don't want to.  I'd rather just port CBMSimpleIO to the Atari.  Based on the source code I provided, what's wrong with my code?

Share this post


Link to post
Share on other sites

Look in simpleio.h, you have this defined :-

#ifdef __C128__
void wrietitle (unsigned char columns, char* title);
#else
void wrietitle (char* title);    <<<-------------------
#endif

 

in your code, you have this :-

unsigned char c;
    char s[81];
    writetitle ("Happy-Face!");   <<<------------------
    prints ("Testing, 1, 2, 3, testing!\n");

 

Notice the spelling difference, I'm surprised it compiled

Share this post


Link to post
Share on other sites

I found the bug!  :)   I forgot to write the MSB of the printc() function.  That's the function that prints a character to the screen.  It works now.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...