Jump to content
  • 0

Converting C64 prg to Commander X16


JimmyDansbo
 Share

Question

A while back, my brother told me that he would like to create a program for the Commander X16 that would be able to convert a program/game written for the Commodore 64 to make it run on the Commander X16.

Preferably, it would do the conversion on the fly, but a conversion from file to file was not out of the question.

I told him that it would be close to impossible to create such a program as it would mean that he would need 100% understanding of the inner workings of the C64 and be able to figure every demo-scene programmers tricks out in his own program.

Our conversation ended there, but I have been thinking about this ever since and now I have written a short guide (mostly to convince my self that it can not be done) on how one could go ahead and do it.

Have a look at https://techblog.dansbo.dk/?p=366

What do you guys think, would it be possible to create a program that can convert almost any C64 program to Commander X16?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
A while back, my brother told me that he would like to create a program for the Commander X16 that would be able to convert a program/game written for the Commodore 64 to make it run on the Commander X16.
Preferably, it would do the conversion on the fly, but a conversion from file to file was not out of the question.
I told him that it would be close to impossible to create such a program as it would mean that he would need 100% understanding of the inner workings of the C64 and be able to figure every demo-scene programmers tricks out in his own program.
Our conversation ended there, but I have been thinking about this ever since and now I have written a short guide (mostly to convince my self that it can not be done) on how one could go ahead and do it.
Have a look at https://techblog.dansbo.dk/?p=366
What do you guys think, would it be possible to create a program that can convert almost any C64 program to Commander X16?

No. The hardware is too different. The only stuff that will convert over with little or no change is text based stuff. It is possible to pseudo mimic the SID.


Sent from my iPhone using Tapatalk
  • Thanks 1
Link to comment
Share on other sites

  • 0

I think it is possible in the future, just not probable that a code converter could be done. I believe it would take a ton of computing power to do so; I don't see it being on the fly on the X16 as there is only so much one can expect a 65C02 to be able to do.

Looking at your example you've converted about 20 bytes of assembly into over 100 bytes - five times. I think memory space would quickly become an issue. While the example puts two characters on the screen, I don't think many existing C64 programs would take such an approach, rather subroutines would be involved. I guess that might reduce the memory required.

Consider computer translation of human languages. One can convert some text word-for-word, but translating idioms really requires a grasp of the language and the intentions of the speaker/writer. 

With enough human power a program could be converted as you've proven. The question becomes how long it would take before a computer had enough power and insight to do the task? In that future, would "retro computing" be considered using a device manufactured last year?

Edited by Edmond D
Added "In that future" to last line
  • Thanks 1
Link to comment
Share on other sites

  • 0

I think it's definitely possible to do a simple (well, "simple"), line-by-line converter that detects when you're writing to a C64-specific area and converts it to an equivalent X16 area.  The same for converting graphics calls to equivalent VERA calls, etc.  The only thing is, as people pointed out, in a lot of the more complex cases, such as demo scene stuff, that would probably end up being slow, since the various techniques to accomplish things on the C64 would not always be the best way to do things on the X16.  So it's definitely possible, just that it would have a limitation of being slow in a lot of cases.

  • Thanks 1
Link to comment
Share on other sites

  • 0

It is said that any computer can emulate any computer given enough time. So such a program could be as "simple" as implementing the emulator for the desired platform and running the code through. This is the biggest hammer approach to the problem, and probably the slowest, but should be able to perfectly emulate the C64 in all ways other than speed. Difficulties to overcome:

  1. BASIC dialects are different, but really x16 has a superset of C64 BASIC. Still, the addition of new statements and functions means that there can be perfectly valid programs on C64 that do not use PEEK or POKE that are invalid x16 programs. MX, MY, and MB could be variables in C64 BASIC but are integer functions in x16, just as one example.
  2. CPUs are different. Any ML program that uses an undocumented 6502 instruction will have to be adapted in some way to support the 65C02 which doesn't have undocumented instructions.
  3. Memory map is of course different.
  4. There is slightly less available RAM to BASIC programs. More when you consider banking but a BASIC program that just barely fit on a C64 might not fit on X16.
  5. Timing related issues. Not only might some things be too slow to replicate, some things might be way too fast given the faster CPU.
  6. Copy protection would require complex emulation given the differences between typical floppy drives and SDCARDS.
  7. Self modifying code is going to be a huge issue.

In some ways this can be compared to a language compiler that allows you to select whether you want fast code or compact code. Such a converter might allow the user to indicate whether they want fast or accurate conversion.

 

  • Thanks 1
Link to comment
Share on other sites

  • 0

While the other guys are all correct, there are some emulation techniques I can suggest. 
 

for text mode, the space at $400-800 is still available. That’s screen RAM on the 64, but we call “golden RAM” on the CX16. 
 

so one emulation technique would be to allow programs to address “screen memory” here and simply copy that data to VERA regularly. You can do something similar with a bank at $A000 for color or bitmap memory. 

however, those tactics will only work for programs that don’t need rapid updates. It certainly would not be fast enough for arcade games. 
 

Short version: it depends on the program, but I’m with the others in the “port, don’t emulate” camp. 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use