I’m fairly new to Retro programming. But I have a Computer Science degree and when I went to college I learned Assembly, Pascal, and C. I currently mostly program in Python or Groovy for my job. I’m 54 so it’s been quite some time since I did assembly but I understand the basics and have been watching a lot of the community’s tutorials on assembly for the 650c2 and even bought a book. So I’m relearning.
Here’s my question, I have a C64 BASIC program I want to port to the Commander X16 but it definitely has Peeks and Pokes in it. What’s the best way to translate those to the Cammander X16. Do you need to use a disassembler? Are there certain Peeks and Pokes that you just can’t translate to the Commander X16 due to the architecture? Are there common peeks and pokes that were used on the c64 that the community have all ready figured out and translated?
Translate Peeks and Pokes from c64 BASIC Program?
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
Re: Translate Peeks and Pokes from c64 BASIC Program?
AFAIK, if you want to translate a program from C64 to X16, you need to know exactly what the different peeks and pokes does.
It may not be necessary to disassemble the entire program, but you do need to know what the different peeks and pokes do in order to convert it to something that works on the X16
It may not be necessary to disassemble the entire program, but you do need to know what the different peeks and pokes do in order to convert it to something that works on the X16
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Re: Translate Peeks and Pokes from c64 BASIC Program?
I'm not very familiar with Commodore-type computers, having grown up with Apple II machines, but just like with Apples, I'm sure there are lists of common PEEKs and POKEs for the Commodore 64 you can find online. Some will be very straightforward to replace, such as the POKE commands to change text screen background and border color, as those can be replaced with commands on the X16. PEEKs and POKEs for graphics and sound will be completely different (fortunately those have been replaced with actual BASIC commands), as will ones intended for POKE-ing text directly to the screen (instead of using PRINT statements).
Look for SYS statements as well. Some might be KERNEL calls, which can be translated to the X16 relatively easily, but if the program has any machine language subroutines those will need to be rewritten for the X16. You can identify those usually by seeing a list of DATA statements followed by a bunch of numbers and then there will be a section in the program where there's a FOR...NEXT loop where the DATA statements are read and POKEd into memory.
Look for SYS statements as well. Some might be KERNEL calls, which can be translated to the X16 relatively easily, but if the program has any machine language subroutines those will need to be rewritten for the X16. You can identify those usually by seeing a list of DATA statements followed by a bunch of numbers and then there will be a section in the program where there's a FOR...NEXT loop where the DATA statements are read and POKEd into memory.
Re: Translate Peeks and Pokes from c64 BASIC Program?
In addition to what has been discussed, check, if possible, to see which version of the 64 the program is intended for as the memory maps can vary between models. If it doesn't say it's probably for the original "breadbin" version.
Here's a breakdown of the original memory map from the C64 Wiki:
https://www.c64-wiki.com/wiki/Memory_Map
Here's a breakdown of the original memory map from the C64 Wiki:
https://www.c64-wiki.com/wiki/Memory_Map
Re: Translate Peeks and Pokes from c64 BASIC Program?
As JimmyDansbo pointed out, you will have to know what the various addresses do in order to port the program to the X16.
A C64 BASIC program may perform PEEKs and POKEs into memory for at least four different reasons:
- Graphics and/or sprites: As BASIC V2 contains no commands for either, direct memory and VIC-II register access via POKE and PEEK is the only way to use these features.
- Sound: As above, BASIC V2 has no commands to access the SID PSG.
- System variables: POKEs may be used to alter various KERNAL/BASIC settings, such as lowering the top of BASIC memory.
- Assembly routines: Some BASIC programs make use of (typically quite short) assembly language programs that are POKEd into memory and called with the SYS command.
To figure out what a specific address does, consult a memory map for the Commodore 64, like this one.
Huh? Why would one need a disassembler in order to figure out what a POKE command in BASIC does?
There certainly are POKE commands that cannot be directly translated, such as values written to the various SID registers. Since neither of the sound chips in the X16 resemble the SID, one would have to use entirely different commands and/or values to reproduce a similar sound.
Re: Translate Peeks and Pokes from c64 BASIC Program?
Wow thank you everyone for all this information! This definitely helps a lot. Now I know what I’ll be researching, messing with this weekend.
I actually want to port this game “Galaxy” that my friend and I actually played on the Atari 800 from tape cassette, but they have a port on the c64. Believe it was originally on Apple II. I plan on porting it first in BASIC and then writing my own version with updated graphics and other features.
https://en.wikipedia.org/wiki/Galaxy_(video_game)
https://www.mobygames.com/game/14769/galaxy/
I actually want to port this game “Galaxy” that my friend and I actually played on the Atari 800 from tape cassette, but they have a port on the c64. Believe it was originally on Apple II. I plan on porting it first in BASIC and then writing my own version with updated graphics and other features.
https://en.wikipedia.org/wiki/Galaxy_(video_game)
https://www.mobygames.com/game/14769/galaxy/
Re: Translate Peeks and Pokes from c64 BASIC Program?
OK so I have a version that some what works. There were only a couple of pokes and there is a sys section but I took those out as it looked like the program would run with out them.
90 PRINT"{clear}{light gray}":POKE53280,6:POKE53281,0
POKE 53280,C change border color (C=0-15)
POKE 53281,C change screen color (C=0-15)
3390 POKE198,0:PRINT"{clear}"LEFT$(VTB$,8):INPUT"how many players (1-20)";PN
POKE 198,0 Clears Keyboard Buffer (Default Value 198,0)
AND there is this part:
2090 SYS64738
Which a quick google search comes up with this:
SYS 64738 is a Commodore 64 C-64 ROM routine that would reset the computer (as if it were turned off and then on again).
The rest of the code is just BASIC.
Now I'll start making changes. And refactor the code the way I wan it. First I'll add the proper screen background, then sound, and it's running too fast. And get rid of all the tape code as it is not needed.
I do need to figure out the back arrow key as it's mapped as the excape key for c64 and you need to hit that to open the map or save, change the turns etc.
90 PRINT"{clear}{light gray}":POKE53280,6:POKE53281,0
POKE 53280,C change border color (C=0-15)
POKE 53281,C change screen color (C=0-15)
3390 POKE198,0:PRINT"{clear}"LEFT$(VTB$,8):INPUT"how many players (1-20)";PN
POKE 198,0 Clears Keyboard Buffer (Default Value 198,0)
AND there is this part:
2090 SYS64738
Which a quick google search comes up with this:
SYS 64738 is a Commodore 64 C-64 ROM routine that would reset the computer (as if it were turned off and then on again).
The rest of the code is just BASIC.
Now I'll start making changes. And refactor the code the way I wan it. First I'll add the proper screen background, then sound, and it's running too fast. And get rid of all the tape code as it is not needed.
I do need to figure out the back arrow key as it's mapped as the excape key for c64 and you need to hit that to open the map or save, change the turns etc.
- Attachments
-
- TI Avalon Hill Galaxy Instructions.pdf
- Original Instructions for the game
- (4.73 MiB) Downloaded 376 times
Re: Translate Peeks and Pokes from c64 BASIC Program?
The good news is Commander has a COLOR command, so the POKE to change color can be done with COLOR.
The SYS for RESET is also not needed. We have a RESET command that actually does a hardware reset of the system.
The SYS for RESET is also not needed. We have a RESET command that actually does a hardware reset of the system.
Re: Translate Peeks and Pokes from c64 BASIC Program?
Ok so right now I think the port looks best in the lower rez screen, just hit the 40/80 display button before you run it.
Also I figured out that on the Commander X-16 the F1 key brings up the in game menu.
Also I figured out that on the Commander X-16 the F1 key brings up the in game menu.
- Attachments
-
- 58C7C10E-40FC-4310-8572-64F1838DD8C1.jpeg (3.17 MiB) Viewed 2105 times
-
- B7A1562D-DC09-4651-80EC-575B6AC62AE8.jpeg (3.43 MiB) Viewed 2105 times
-
- 59C9627A-6635-4F03-8E43-5904386A031B.jpeg (3.43 MiB) Viewed 2105 times
-
- C825F4FB-2C94-4105-B334-AA48B35F507D.jpeg (3.26 MiB) Viewed 2105 times