Welcome, Guest. Please login or register.


Author Topic: How to do a CPC conversion? (Read 1036 times)

Offline ssr86

  • EP user
  • *
  • Posts: 359
  • Country: pl
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 45.0 Firefox 45.0
    • View Profile
How to do a CPC conversion?
« on: 2016.April.29. 08:11:18 »
This question seems to be addressed to Geco and Istvan as they are the only ones here (?) that have done any such conversions... Could you describe the process of converting a CPC game without having its source code? I guess it depends very much on the ported game itself but maybe some general basics - how to start guide?
« Last Edit: 2016.April.29. 08:55:35 by ssr86 »

Offline IstvanV

  • EP addict
  • *
  • Posts: 4806
  • OS:
  • Linux Linux
  • Browser:
  • Firefox 45.0 Firefox 45.0
    • View Profile
Re: How to do a CPC conversion?
« Reply #1 on: 2016.April.29. 09:34:15 »
There are some old tutorials, but they are in Hungarian:

Geco's tutorial on converting Gunfright
Converting Cybernoid 2 using my tools and CPC "emulation" routines, part 1 (part 2)

The latter also includes two utilities that might be useful for finding and converting pixel data, pixeldisp.lua and cpccolor.exe. In the CPC conversion topics, all of my converted games can be found (I will try to create a list of links to them later, some are already in separate topics where they are easy to find), and I always provided the complete source code and tools that are needed for the conversion. When the same routine, such as the AY emulation, can be found in multiple games, the newer version is generally better, but it is often customized for that particular game, and unneeded parts may have been deleted.

Note that in many of my converted games, there is a frequently used routine that allows for calls into the loader code while preserving the IRQ enabled/disabled state. Unfortunately, on the NMOS Z80 (which is the version of the CPU originally used in the Enterprise), there is a hardware bug that causes this to sometimes fail and the routine returns with interrupts disabled when they were enabled before the call. :oops: Therefore, in the last couple of conversions, I no longer used this solution.

Offline Zozosoft

  • EP addict
  • *
  • Posts: 13521
  • Country: hu
  • OS:
  • Windows XP Windows XP
  • Browser:
  • Firefox 45.0 Firefox 45.0
    • View Profile
    • http://enterprise.iko.hu/
Re: How to do a CPC conversion?
« Reply #2 on: 2016.April.29. 10:02:10 »
Note that in many of my converted games, there is a frequently used routine that allows for calls into the loader code while preserving the IRQ enabled/disabled state. Unfortunately, on the NMOS Z80 (which is the version of the CPU originally used in the Enterprise), there is a hardware bug that causes this to sometimes fail and the routine returns with interrupts disabled when they were enabled before the call.
The EXDOS use this solution for solve the Z80 bug:
Code: ZiLOG Z80 Assembler
  1. TST_IRQ::
  2. ;
  3. ; It returns carry flag set if interrupts were disabled and
  4. ; clear if they were enabled.  Also it disables interrupts.
  5. ;
  6. ;
  7.         XOR     A                       ;Push a zero on stack and pop it
  8.         PUSH    AF                      ; back off so we can tell if it gets
  9.         POP     AF                      ; overwitten with IRQ return address.
  10.         LD      A,R                     ;Get IRQ state
  11.         DI
  12.         RET     PE                      ;Return if interrupts enabled
  13.         DEC     SP                      ;If they appear disabled then check
  14.         DEC     SP                      ; whether the zero is still below stack
  15.         POP     AF
  16.         OR      A                       ;If not then interrupts must have been
  17.         RET     NZ                      ; enabled so return with carry clear.
  18. ;
  19.         SCF                             ;Return with carry set to indicate
  20.         RET                             ; that interrupts were disabled.
  21.  

Offline IstvanV

  • EP addict
  • *
  • Posts: 4806
  • OS:
  • Linux Linux
  • Browser:
  • Firefox 45.0 Firefox 45.0
    • View Profile
Re: How to do a CPC conversion?
« Reply #3 on: 2016.April.29. 14:04:36 »
The EXDOS use this solution for solve the Z80 bug:

In Boulder Dash, I simply created two separate macros (loaderCallDI and loaderCallEI) which need to be used depending on whether interrupts are to be disabled or enabled on return. :oops:

By the way, here is a list of my CPC conversions, from the oldest to the newest post. The links are usually to the hopefully most recent version of the program, but the full source (which includes the original CPC tape or disk image, as well as any Lua scripts or other tools needed for the conversion) is not always available in the linked post, in those cases the missing files can be found earlier in the same topic.

Cybernoid    (converting AY sound is also discussed here in Hungarian)
Hydrofool
Deflektor, Super Hero
Crystal Kingdom Dizzy
ATF
Cybernoid 2
Driller, Total Eclipse, Total Eclipse 2
Castle Master, Castle Master 2, Dark Side
Sorcery
Nebulus
Rick Dangerous    (this is only a fix, the full package is a few posts earlier)
Barbarian and Rick Dangerous 2
Pinball Power    (this is where the NMOS Z80 bug was discovered :oops:)
Boulder Dash    (the final version can be downloaded from here; there is even a simple level editor in Lua for this game :))

In the large "CPC" topic, there are also more discussions in Hungarian related to converting games.

Other than the CPC emulation mode of ep128emu, sjasm 0.39g6, and the already linked utilities like cpccolor.exe, I also used epcompress, dtf, and epimgconv.

Offline ssr86

  • EP user
  • *
  • Posts: 359
  • Country: pl
  • OS:
  • Windows NT 6.2 Windows NT 6.2
  • Browser:
  • Firefox 45.0 Firefox 45.0
    • View Profile
Re: How to do a CPC conversion?
« Reply #4 on: 2016.April.29. 17:14:59 »
Thanks, that's quite a lot of info to dig through. I hope I'll be able to make something of it. But first I need to close a few other "projects" and I'll give it a try then.

Offline geco

  • EP addict
  • *
  • Posts: 5430
  • Country: hu
  • OS:
  • Linux Linux
  • Browser:
  • Firefox 38.0 Firefox 38.0
    • View Profile
Re: How to do a CPC conversion?
« Reply #5 on: 2016.April.29. 19:06:58 »
I am waiting your finished projects :) ( I know at least 2 of them )
If you start converting CPC games, please ask, we will help you :)
Just for 1st try I would recommend a 4 colour game then you just need to build a CPC style LPT, insert AY emulation routine, and change keyboard routines, memory changing routines ( if exist ), modify interrupt (insert ld a,30h out(0b4h),a, create a loader, and you are almost ready (this is the simplest way, if you do not want to change CPC video addressing)