Harry Potter Posted March 29, 2021 Share Posted March 29, 2021 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 Quote Link to comment Share on other sites More sharing options...
snicklin Posted March 29, 2021 Share Posted March 29, 2021 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... Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 29, 2021 Share Posted March 29, 2021 (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 March 29, 2021 by danwinslow Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 29, 2021 Author Share Posted March 29, 2021 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 Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted March 30, 2021 Share Posted March 30, 2021 Where is KEYBDV_handler coming from? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 30, 2021 Author Share Posted March 30, 2021 I guess it would be coming from cc65's Atari800 system library. Quote Link to comment Share on other sites More sharing options...
sanny Posted March 30, 2021 Share Posted March 30, 2021 If you provide a complete example incl. how you compile it, I will take a look. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 30, 2021 Author Share Posted March 30, 2021 I attached a Zip file of the folder containing the source code. source.zip Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 30, 2021 Share Posted March 30, 2021 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. Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 30, 2021 Share Posted March 30, 2021 (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 March 30, 2021 by danwinslow 1 Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 30, 2021 Author Share Posted March 30, 2021 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. Quote Link to comment Share on other sites More sharing options...
mellis Posted March 30, 2021 Share Posted March 30, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 30, 2021 Share Posted March 30, 2021 (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 March 30, 2021 by danwinslow Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted June 1, 2021 Author Share Posted June 1, 2021 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? Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted June 1, 2021 Share Posted June 1, 2021 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 Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted June 1, 2021 Author Share Posted June 1, 2021 That could be causing the error. Thank you! Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted June 1, 2021 Author Share Posted June 1, 2021 I fixed the problem. Same result. I disabled the call to writetitle(). Still, same result. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted June 1, 2021 Author Share Posted June 1, 2021 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.