Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #6264 > unrolled thread
| Started by | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| First post | 2023-12-10 19:47 -0500 |
| Last post | 2023-12-11 10:11 -0500 |
| Articles | 11 — 5 participants |
Back to article view | Back to comp.sys.apple2.programmer
Ctrl-C Interrupt? Bill Chatfield <bill_chatfield@yahoo.com> - 2023-12-10 19:47 -0500
Re: Ctrl-C Interrupt? fadden <fadden@fadden.com> - 2023-12-10 17:54 -0800
Re: Ctrl-C Interrupt? Bill Chatfield <bill_chatfield@yahoo.com> - 2023-12-11 10:07 -0500
Re: Ctrl-C Interrupt? Hugh Hood <hughhood@earthlink.net> - 2023-12-10 21:10 -0600
Re: Ctrl-C Interrupt? Bill Chatfield <bill_chatfield@yahoo.com> - 2023-12-11 10:09 -0500
Re: Ctrl-C Interrupt? Oliver Schmidt <ol.sc@web.de> - 2023-12-11 19:10 +0000
Re: Ctrl-C Interrupt? Bill Chatfield <bill_chatfield@yahoo.com> - 2023-12-11 15:39 -0500
Re: Ctrl-C Interrupt? Oliver Schmidt <ol.sc@web.de> - 2023-12-12 20:36 +0000
Re: Ctrl-C Interrupt? Bill Chatfield <bill_chatfield@yahoo.com> - 2023-12-12 23:55 -0500
Re: Ctrl-C Interrupt? I am Rob <gids.rs@sasktel.net> - 2023-12-10 20:30 -0800
Re: Ctrl-C Interrupt? Bill Chatfield <bill_chatfield@yahoo.com> - 2023-12-11 10:11 -0500
| From | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| Date | 2023-12-10 19:47 -0500 |
| Subject | Ctrl-C Interrupt? |
| Message-ID | <20231210194712.4301d589@smilodon-gracilis> |
Is there any way to have Ctrl-C interrupt a BIN program like it does a Basic program? I know Ctrl-Reset will do it, but that messes up the screen and probably other things too.
[toc] | [next] | [standalone]
| From | fadden <fadden@fadden.com> |
|---|---|
| Date | 2023-12-10 17:54 -0800 |
| Message-ID | <58223802-5373-43c7-8157-62ba758aadfcn@googlegroups.com> |
| In reply to | #6264 |
On Sunday, December 10, 2023 at 4:47:14 PM UTC-8, Bill Chatfield wrote: > Is there any way to have Ctrl-C interrupt a BIN program like it does a > Basic program? I know Ctrl-Reset will do it, but that messes up the > screen and probably other things too. It's not a system feature; it doesn't send a signal the way a UNIX line discipline does. It's being tested for explicitly by the BASIC interpreter, here: https://6502disassembly.com/a2-rom/Applesoft.html#SymISCNTC
[toc] | [prev] | [next] | [standalone]
| From | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| Date | 2023-12-11 10:07 -0500 |
| Message-ID | <20231211100742.6b7f25a6@smilodon-gracilis> |
| In reply to | #6265 |
On Sun, 10 Dec 2023 17:54:54 -0800 (PST) fadden <fadden@fadden.com> wrote: > It's not a system feature; it doesn't send a signal the way a UNIX > line discipline does. Is it too much to ask for an Apple II to work like UNIX? Haha :-) :-) I've always been frustrated by the inconsistency that you Ctrl-C a BASIC program but you have to Ctrl-Reset a binary program. You have to know what type of program is running to know what interrupt to use. I guess you can always use Ctrl-Reset, but that is more invasive.
[toc] | [prev] | [next] | [standalone]
| From | Hugh Hood <hughhood@earthlink.net> |
|---|---|
| Date | 2023-12-10 21:10 -0600 |
| Message-ID | <8ROdnZS9bYMI4Ov4nZ2dnZfqnPednZ2d@earthlink.com> |
| In reply to | #6264 |
On 12/10/2023 6:47 PM, Bill Chatfield wrote: > Is there any way to have Ctrl-C interrupt a BIN program like it does > a Basic program? I know Ctrl-Reset will do it, but that messes up > the screen and probably other things too. > Bill, Are you able to patch the particular BIN program? If so, I might suggest you inject a JMP somewhere in the program's main 'run' loop to some new code you graft onto the end of the code. The new code would save the registers, poll the keyboard, check for a CTRL-C, and just BRK if a CTRL-C is found. If not, just add whatever code you messed up by inserting the JMP to the new code, restore the registers, and then JMP back to where the program was interrupted. Or, if the program already is polling the keyboard for some input, can you just re-purpose a key you don't normally need to do the same, or maybe JMP to a routine to add the check for CTRL-C? Just some thoughts. Maybe none of them are appealing. I'm assuming you're not using a IIgs where you can interrupt and Visit the Monitor. Hugh Hood
[toc] | [prev] | [next] | [standalone]
| From | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| Date | 2023-12-11 10:09 -0500 |
| Message-ID | <20231211100943.0c7dcc0e@smilodon-gracilis> |
| In reply to | #6266 |
On Sun, 10 Dec 2023 21:10:13 -0600 Hugh Hood <hughhood@earthlink.net> wrote: > Just some thoughts. Maybe none of them are appealing. > > I'm assuming you're not using a IIgs where you can interrupt and > Visit the Monitor. I am working on a Apple II/e/c program with the cc65 C compiler. I can check for Ctrl-C in various places.
[toc] | [prev] | [next] | [standalone]
| From | Oliver Schmidt <ol.sc@web.de> |
|---|---|
| Date | 2023-12-11 19:10 +0000 |
| Message-ID | <ul7mrh$2l8d7$1@solani.org> |
| In reply to | #6269 |
Hi Bill, > I am working on a Apple II/e/c program with the cc65 C compiler. I can > check for Ctrl-C in various places. In this case I suggest to use - kbhit() and cgetc() to detect the Ctrl-C - exit() to quit if Ctrl-C was detected - atexit() to run custom cleanup code Not directly related but there's also doesclrscrafterexit() that allows you determine if the user will be able to read output from your program after exit - i.e. an error message. You can call it i.e. from your atexit() function and call cgetc() if it returns true having the user acknowledge that he has read the message. Regards, Oliver
[toc] | [prev] | [next] | [standalone]
| From | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| Date | 2023-12-11 15:39 -0500 |
| Message-ID | <20231211153907.71933ea0@smilodon-gracilis> |
| In reply to | #6271 |
On Mon, 11 Dec 2023 19:10:41 -0000 (UTC) Oliver Schmidt <ol.sc@web.de> wrote: > In this case I suggest to use > - kbhit() and cgetc() to detect the Ctrl-C > - exit() to quit if Ctrl-C was detected > - atexit() to run custom cleanup code Thanks! I was thinking of using an asm block to check KBD for characters. What you said is much better. I also forgot about atexit(). I need to put that in now to close files. It's like the "finally" block of a try/catch/finally around main(). I'm a Java programmer during the day.
[toc] | [prev] | [next] | [standalone]
| From | Oliver Schmidt <ol.sc@web.de> |
|---|---|
| Date | 2023-12-12 20:36 +0000 |
| Message-ID | <ulag8n$2mkpn$1@solani.org> |
| In reply to | #6272 |
Hi Bill, > Thanks! You're welcome :-) > I was thinking of using an asm block to check KBD for > characters. What you said is much better. I'm quite often surprised by the amount of workarounds people "find" although the functionality is already present in the Apple II C library. > I also forgot about atexit(). > I need to put that in now to close files. It's like the "finally" block > of a try/catch/finally around main(). I'm a Java programmer during the > day. You don't need to do so for closing files. All still open files are closed by the C library exit code. That code is by the way also executed on Ctrl-Reset during the runtime of a cc65 C program. So the behavior on Ctrl-Reset isn't as undefined/fatal as you might think. I even had once the case where I totally ran out of memory so I couldn't add some quit code. Instead I simply documented Ctrl-Reset as the official way to quit the program ;-) Regards, Oliver
[toc] | [prev] | [next] | [standalone]
| From | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| Date | 2023-12-12 23:55 -0500 |
| Message-ID | <20231212235506.6847234a@smilodon-gracilis> |
| In reply to | #6275 |
On Tue, 12 Dec 2023 20:36:39 -0000 (UTC) Oliver Schmidt <ol.sc@web.de> wrote: > You don't need to do so for closing files. All still open files are > closed by the C library exit code. I am always amazed about how well cc65 implements the standard. I was thinking in terms of BASIC which does not do that and gets completely screwed up if you don't close files. > That code is by the way also executed on Ctrl-Reset during the > runtime of a cc65 C program. So the behavior on Ctrl-Reset isn't as > undefined/fatal as you might think. That is very impressive. I never would have guessed that. > I even had once the case where I totally ran out of memory so I > couldn't add some quit code. Instead I simply documented Ctrl-Reset > as the official way to quit the program ;-) :D
[toc] | [prev] | [next] | [standalone]
| From | I am Rob <gids.rs@sasktel.net> |
|---|---|
| Date | 2023-12-10 20:30 -0800 |
| Message-ID | <14c5a885-e220-4c7e-9828-56812d996600n@googlegroups.com> |
| In reply to | #6264 |
> Is there any way to have Ctrl-C interrupt a BIN program like it does a > Basic program? I know Ctrl-Reset will do it, but that messes up the > screen and probably other things too. A simple method would be to just poll $C000, then place JSR's to this routine where you would want the keyboard to be interrupted. Say, after a page of text is displayed or even throughout your code at various places. Another method is to just put a $00, after the code you want to check out. It has the added benefit of displaying the registers. BIT $C000 BPL RETURN LDA $C000 BIT $C010 CMP #$83 BNE RETURN JMP $FF69 ; for monitor of $3D0 for Applesoft RETURN RTS
[toc] | [prev] | [next] | [standalone]
| From | Bill Chatfield <bill_chatfield@yahoo.com> |
|---|---|
| Date | 2023-12-11 10:11 -0500 |
| Message-ID | <20231211101101.46dbb959@smilodon-gracilis> |
| In reply to | #6267 |
On Sun, 10 Dec 2023 20:30:01 -0800 (PST) I am Rob <gids.rs@sasktel.net> wrote: > A simple method would be to just poll $C000, then place JSR's to this > routine where you would want the keyboard to be interrupted. Say, > after a page of text is displayed or even throughout your code at > various places. Yes, I can try that. Thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.apple2.programmer
csiph-web