{"action":"created","issue":{"url":"https://api.github.com/repos/catseye/Befunge-93/issues/14","repository_url":"https://api.github.com/repos/catseye/Befunge-93","labels_url":"https://api.github.com/repos/catseye/Befunge-93/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/catseye/Befunge-93/issues/14/comments","events_url":"https://api.github.com/repos/catseye/Befunge-93/issues/14/events","html_url":"https://github.com/catseye/Befunge-93/issues/14","id":337233084,"node_id":"MDU6SXNzdWUzMzcyMzMwODQ=","number":14,"title":"I/O fails in debug mode when CONSOLE not defined","user":{"login":"j4james","id":4181424,"node_id":"MDQ6VXNlcjQxODE0MjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4181424?v=4","gravatar_id":"","url":"https://api.github.com/users/j4james","html_url":"https://github.com/j4james","followers_url":"https://api.github.com/users/j4james/followers","following_url":"https://api.github.com/users/j4james/following{/other_user}","gists_url":"https://api.github.com/users/j4james/gists{/gist_id}","starred_url":"https://api.github.com/users/j4james/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j4james/subscriptions","organizations_url":"https://api.github.com/users/j4james/orgs","repos_url":"https://api.github.com/users/j4james/repos","events_url":"https://api.github.com/users/j4james/events{/privacy}","received_events_url":"https://api.github.com/users/j4james/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-30T18:12:57Z","updated_at":"2018-08-20T12:09:19Z","closed_at":null,"author_association":"NONE","body":"If _bef_ is compiled without the CONSOLE define, and you try to debug a program which uses any of the input/output commands, the code won't be interpreted correctly. It's not just that the I/O commands aren't supported - the problem is that they leave the stack in the wrong state. The output commands don't pop anything, and the input commands don't push anything.\r\n\r\nAs a minimal \"fix\", you could just include a pop for the output commands, and maybe push -1 for the input commands. In case it's not obvious what I mean, here's a possible patch:\r\n\r\n[nocon-patch-1.txt](https://github.com/catseye/Befunge-93/files/2152084/nocon-patch-1.txt)\r\n\r\nIf you want to make a bit more effort though, it is possible to get quite close to the conio implementation using just ANSI escape sequences. I've put together a basic patch showing how that could work:\r\n\r\n[nocon-patch-2.txt](https://github.com/catseye/Befunge-93/files/2152085/nocon-patch-2.txt)\r\n\r\nBut that's just a proof-of-concept - you can see that there's a lot of code duplication going on which is in desperate need of refactoring. That level of change I think is best left to you, though, assuming you even what to do anything with this issue."},"comment":{"url":"https://api.github.com/repos/catseye/Befunge-93/issues/comments/414294396","html_url":"https://github.com/catseye/Befunge-93/issues/14#issuecomment-414294396","issue_url":"https://api.github.com/repos/catseye/Befunge-93/issues/14","id":414294396,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDI5NDM5Ng==","user":{"login":"cpressey","id":6860877,"node_id":"MDQ6VXNlcjY4NjA4Nzc=","avatar_url":"https://avatars1.githubusercontent.com/u/6860877?v=4","gravatar_id":"","url":"https://api.github.com/users/cpressey","html_url":"https://github.com/cpressey","followers_url":"https://api.github.com/users/cpressey/followers","following_url":"https://api.github.com/users/cpressey/following{/other_user}","gists_url":"https://api.github.com/users/cpressey/gists{/gist_id}","starred_url":"https://api.github.com/users/cpressey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpressey/subscriptions","organizations_url":"https://api.github.com/users/cpressey/orgs","repos_url":"https://api.github.com/users/cpressey/repos","events_url":"https://api.github.com/users/cpressey/events{/privacy}","received_events_url":"https://api.github.com/users/cpressey/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T12:09:19Z","updated_at":"2018-08-20T12:09:19Z","author_association":"MEMBER","body":"Ugh, OK.  Here is a historical perspective; you might enjoy it.\r\n\r\nI don't know how much of this survives, but the original idea for \"debugging\" a Befunge program (i.e. viewing the playfield, the stack, and the input/output all at the same time) relied a feature of the Amiga shell: redirection to a newly-opened console window.  You could give a string like `newcon:Title,x,y,w,h` in place of a filename when opening a file; opening that \"file\" would cause a new console window to be opened, writing to it would cause text to appear in it, reading from it would accept input (buffered keystrokes) from it.\r\n\r\nLooking at the code now, I see \"stackfile\", whose purpose was definitely being able to view the stack in another console window, while the program executed.  \"inputfile\" and \"outputfile\" would have been similar (though I'm not sure why they couldn't have just been done with file redirection.)  I don't see a \"playfieldfile\", -- so I think the idea was that `-d` would display the playfield in the main console (\"ANSI debugging\") while you would be expected to pass `newcon:whatever`s on the command-line to open additional console windows for stack, input, and output.\r\n\r\nAnd note that, under the assumption that you have given an `infile` and `outfile`, the behaviour in debug mode isn't actually wrong, because the commands test for those first, and if they're present, the input/output goes there.\r\n\r\nI am fairly certain the `CONSOLE` define was only introduced later, when it was ported to MS-DOS.\r\n\r\nI agree something should be done to at least stop it from exhibiting different behaviour in debug mode, I'm just not sure what, yet.\r\n\r\nI'll start a branch for this but, at the rate I'm going, it might not make it in for v2.24."}}
{"actor":{"display_login":"cpressey"}}