Re: Translate Peeks and Pokes from c64 BASIC Program?
Posted: Sun Feb 04, 2024 8:56 am
Commander X16 Community Forums
https://cx16forum.com/forum/
My go-to screen. Would've been nice of they included a true C=64 sized (40x25) screen and an 80x25 screen, which was most common with terminals and PCs. They could make room by dumping screens 5 and 6 which probably won't get much use, being only 20 characters wide.
Thank you for the info on the screen, I'll use that for this direct port. I'm hoping to redisgn the program with a better layout and functionality, so still need to decide what resolution I'll use. Might like to have the map up and the menu options available at all times.
Thanks for the info. Yes COLOR should work nice. From what I have been able to figure out this program manipulates the position of the cursor a lot in the print commands. Specially for the map. It seems to have a short hand for the CHR$() codes. These don't seem to work in c64 or Commander X16 BASIC is you just put in the rawl code. If I create a prg file using CBM PRG Studio understands short hand in the print commands. It's able to create a working PRG file from the code.
Those are called Tok64 codes. They were a convention started in type-in magazines in the 80s. It just means you need to press that key when typing in the code, or you can use the PETCAT program that comes with the VICE emulation suite to turn it back into a PRG file. (I'm also working on a tokenizer that will do this, but I've got a few things ahead of that on my to-do list.)
PRINT HEX$(ASC("{Control+9}")) 12 █The {SPACE*7} literally just means "press the space bar 7 times."
This helps a lot! Thanks! I get what you are saying for the spaces but there is code that moves up, down and to the left. I can’t simulate that by hitting the space bar. I’l have to figure out the hex code for them. But now I have an understanding what this is and how to deal with it.TomXP411 wrote: ↑Sun Feb 04, 2024 10:03 pm
Those are called Tok64 codes. They were a convention started in type-in magazines in the 80s. It just means you need to press that key when typing in the code, or you can use the PETCAT program that comes with the VICE emulation suite to turn it back into a PRG file. (I'm also working on a tokenizer that will do this, but I've got a few things ahead of that on my to-do list.)
So the key is quote mode. In Commodore BASIC, typing a quote puts you in quote mode, where the editor inserts the raw values for command keys (arrow keys, control+letter, colors, F-keys). These are displayed in reverse print. A-Z represent PETSCII 1-26, and [ £ ] ↑ ← represent 27-31.
At the keyboard, if you type PRINT " and then press Control+9 (the Rvs On key), you'll see an inverted R after the quote. Any text printed after that will be in inverse print, until the next CR, Shift+CR, or Rvs Off (Control+0).
Pressing the INS (Insert) key also triggers quote mode for 1 character. So you can use that to quickly insert a single command character.
Resolving the issue
While the X16 emulator does not support tok64 codes, it does support a different shorthand: \X hex codes. In this case, Rvs On is \X12.
You can get the hex for any control code this way:
PRINT HEX$(ASC("{Control+9}")) 12 █The {SPACE*7} literally just means "press the space bar 7 times."
So for line 240, what you need to do is manually convert those tok64 codes to either hex codes or simply edit them in the emulator.
Approach 1: In a text editor, edit the line to look like this:
240 PRINT "\X12TRY AGAIN\X92 "
Approach 2:
leave the tok64 codes in the string. Paste the program into the emulator, then LIST 240
Move the cursor to +REVERSE ON|. Delete that and press INS one time. Press Control+9.
You should now have an inverse R in front of TRY AGAIN.
Now go to the +SPACE * 7| and type over that with 7 spaces, removing the extra 4 characters with the Delete key.
I hope that helps a little.
Cursor movement is one of the things you can do in quote mode. If you see {up} or {up 3}, then replace that by just pressing cursor up while in quote mode (once for just {up} and 3 times for {up 3}).FuzzySilk wrote: ↑Mon Feb 05, 2024 2:58 amThis helps a lot! Thanks! I get what you are saying for the spaces but there is code that moves up, down and to the left. I can’t simulate that by hitting the space bar. I’ll have to figure out the hex code for them. But now I have an understanding what this is and how to deal with it.
It would seem pretty odd to me to use an EMPTY GOSUB as a Time Delay. Thinking of my Own BASIC coding style I might have an empty GOSUB either as a place Holder for code I intend to write but haven't written yet. (In which case I would expect a REM there) Or possibly to preserve Program flow if I deprecate code that I no longer want to use.
Commodore BASIC V2 didn't have any commands for cursor control, so short of manipulating the cursor position by POKEing values into locations 211 and 214, using control characters was basically (ahem) the only way to do it.