FredTheFred Posted August 16, 2015 Share Posted August 16, 2015 Hello, I'v got a question about ending program in CV code. I've made a little simply program. A little text is displayed (Text 1) on screen and another one after pressing fire (Text 2). Very simply and it's working fine on a emulator. but it's an infinite loop after displayed text 2, it's start again on text 1 and waiting to press fire and so on.... How made an ending point ? like exit command or abort ? Quote Link to comment Share on other sites More sharing options...
PkK Posted August 16, 2015 Share Posted August 16, 2015 (edited) It's not clear what you mean by "ending point". What is the desired behaviour? Philipp Edit: Typo. Edited August 16, 2015 by PkK Quote Link to comment Share on other sites More sharing options...
FredTheFred Posted August 16, 2015 Author Share Posted August 16, 2015 I world like to stop the program after an event like pressing Fire button. Actually the program is looping with out ending. Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 16, 2015 Share Posted August 16, 2015 For a program to "exit", there needs to be something to exit to. For example, if you're running a program in a DOS window, when the program exits, it exits to the DOS command prompt. There is no such thing on the ColecoVision, or any other game console: The program "exits" when you turn off the hardware. 1 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted August 16, 2015 Share Posted August 16, 2015 Something like,main{ print_at(0,0,"Text here.");pause(); print_at(1,0,"2nd text here."); loop: goto loop;}Will put the program in infinite loop, thus ending the program. Otherwise, it'll go all the way to the end of the address $FFFF, and then make it way back to $8000, restarting the program. Quote Link to comment Share on other sites More sharing options...
PkK Posted August 16, 2015 Share Posted August 16, 2015 Though using goto without a need to do so is usually considered bad style. Alternatives for infinite loops: for(;; while(true); Quote Link to comment Share on other sites More sharing options...
FredTheFred Posted August 17, 2015 Author Share Posted August 17, 2015 thanks all, in fact my program doesn'y bug, it's a logical state. In the end of program, he starts again and so on... 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.