Welcome, Guest. Please login or register.


Author Topic: porting amstrad cpctelera software to enterprise (Read 1807 times)

Offline teopl

  • Newbie
  • Posts: 8
  • Country: cs
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
porting amstrad cpctelera software to enterprise
« on: 2020.June.14. 11:46:20 »
Hello.

After spending 2 days investigating about platform differences (amstrad cpc and enterprise) my enthusiasm of porting software from CPC to EP is at very low point :)

reason for this is that I don't have nearly enough of required knowledge of assembler and the platforms and I also used cpctelera library which does produce z80 assembler and doesn't use CPC firmware (which is good) but in any case for me to handle keyboard, different video setup, sound... it would be too big task as it looks right now.

I have watched a little of chibiakumas fantastic enterprise tutorials and read a little here on the forum about various porting (also AGD for example) and I decided to put this idea of porting my cpctelera software to enterprise "on hold" since it's currently outside of my scope.

That being said, my question is: does someone here has knowledge about cpctelera library and what effort would be to make the cpctelera output enterprise executables? (or something close to that). Is this even possible to do? (at least to some degree)

Sorry if the question is "too ambitious" but there is already very large software/games written using this library and I guess EP could benefit from this.


Offline geco

  • EP addict
  • *
  • Posts: 5753
  • Country: hu
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #1 on: 2020.June.14. 21:50:38 »
Hello Teopl

one of our forum members, Árpád wanted to convert CPC-telera to Enterprise, I helped him to create EP specific Z80 code, it worked , adding AY emulation routine was left, unfortunately he could not finish it, asked me to do it, but I did not want to finish, i did not like it's slow compile speed. We put together EP specific Z80 code within one day ( except AY ) Babaspalace ( a cpctelera game ) worked without sound, and colour conversion.
Probably i have EP specific Z80 code, if you are interested in it, i can check my mails.
« Last Edit: 2020.June.14. 22:24:42 by szipucsu »

Offline teopl

  • Newbie
  • Posts: 8
  • Country: cs
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #2 on: 2020.June.14. 22:45:53 »
wow that sounds exactly what I would need! regarding the sound - it's not that important and can be added separately.

so, yes I am very interested in that project, please send me what you find. (and any instructions you may find about the conversion process)

if babas palace without sound can be ported, that should be enough for me...

Offline geco

  • EP addict
  • *
  • Posts: 5753
  • Country: hu
  • OS:
  • Linux Linux
  • Browser:
  • Firefox 68.0 Firefox 68.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #3 on: 2020.June.15. 16:40:35 »
Start1.src is the source of loader, it has to be updated on 4 places: (laoder screen can be inserted also into the loader if you have, i can modifiy the source)
file name, and it's length
file length
file load address
game start address.

CPCteleraEPz80 contains the z80 sources for EP , CPC z80 sources have to be replaced by this
in this version CPC 300Hz interrupt is not emulated, it can be done also, but if you use interrupt only for playing music, and change palette colour then it is usesless, for palette colour LPT has to be modified.
Please remove calling Arkos tracker player from your program at testing, it can cause program hang.

Arkos tracker player can be ported too for EP, just i hate that assembler format what cpctelera use, and basic IF usage, if you wish i can try to make the modified source, but you should test it, i do not like to wait 2 coffee break for a compilation :D :D

Offline teopl

  • Newbie
  • Posts: 8
  • Country: cs
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #4 on: 2020.June.15. 23:21:07 »
Thank you very much, I hope I can test this soon and let you know the results!

My guess is that I may have some questions :)

But first I will try to understand as much as possible by myself, hopefully in next few days. (or during weekend)

First I will try to convert and run simple cpctelera helloworld.

Then I will try to compile the chat program since it's simpler then the game I have.

I use 300 Hz interrupt for arkos sound (that will be disabled) and for async tasks (this is needed!) so I guess the interrupt calls must be supported (doesn't have to be 300 Hz).

About cpctelera asm format, yes, as someone who knows very very little about asm I was confused even more with this various formats so I used sdcc, rasm, pasmo depending on source format. For some conversions between formats I used http://julien-nevo.com/disark/ - works quite well

Regarding compilation time, I am not sure why it took long but I know that there are some optimization flags for the sdcc compiler which can reeeeally make it long like this:

Code: [Select]
Z80CCFLAGS    := --peep-file ${CPCT_PATH}/tools/sdcc-3.6.8-r9946/peep/z88dk_speculative_peepholes.def --max-allocs-per-node 2000000 --opt-code-speed
My code is not (yet) that much optimized and it compiles fast (I read about babas palace - every byte was important since there are 100 levels in 64K game - I guess they needed those optimized flags)


Offline geco

  • EP addict
  • *
  • Posts: 5753
  • Country: hu
  • OS:
  • Linux Linux
  • Browser:
  • Firefox 68.0 Firefox 68.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #5 on: 2020.June.16. 08:50:15 »
My guess is that I may have some questions :)
No problem, i will try to answer, and if you find any bugs, or the program does not start, i will try to help you, just send me the binary :)

But first I will try to understand as much as possible by myself, hopefully in next few days. (or during weekend)
Fortunately CPCtelera does not use too much built in z80 code, so if you need explanation about EP part, i can try to do it.

First I will try to convert and run simple cpctelera helloworld.

Then I will try to compile the chat program since it's simpler then the game I have.
I forgot to mention, START1.SRC is in SJASM 0.39 format, this creates the loader for the binary.

I use 300 Hz interrupt for arkos sound (that will be disabled) and for async tasks (this is needed!) so I guess the interrupt calls must be supported (doesn't have to be 300 Hz).

About cpctelera asm format, yes, as someone who knows very very little about asm I was confused even more with this various formats so I used sdcc, rasm, pasmo depending on source format. For some conversions between formats I used http://julien-nevo.com/disark/ - works quite well
Yes, the sync tasks should be changed to 50Hz, but normally it is few changes, as i remember source of Babas Palace had to be changed in 3-4 places, 300Hz interrups can be implemented also, but it had to be resynchronized after every longer disabled interrupt, or changing to EP EXOS interrupt.

That sounds good, probably i will try iti always done manual changing between formats :)

Regarding compilation time, I am not sure why it took long but I know that there are some optimization flags for the sdcc compiler which can reeeeally make it long like this:

Code: [Select]
Z80CCFLAGS    := --peep-file ${CPCT_PATH}/tools/sdcc-3.6.8-r9946/peep/z88dk_speculative_peepholes.def --max-allocs-per-node 2000000 --opt-code-speed
My code is not (yet) that much optimized and it compiles fast (I read about babas palace - every byte was important since there are 100 levels in 64K game - I guess they needed those optimized flags)
It can happen we did not used the fastest way, i did not know anything about CPCtelera, i just changed the EP specific asm part,  Árpád played with it, but he was not an expert either :)  As i remember without optimalization compile took for some minutes with optimization 30-45 minutes. (or probably some flag was )

Offline teopl

  • Newbie
  • Posts: 8
  • Country: cs
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #6 on: 2020.June.23. 17:42:45 »
Thanks geco for all the help, in the end I had to do only some minor code changes to be able to port the Symbiface3 chat app!

(thanks gflorez for testing on real EP+SF3)

Code changes: (like advised by geco)

- disabling sound
- disabling masked draw so all background is black (not sure if this was really needed)
- changed from 300 to 50 interrupt calls per second
- changed teopl_main.c to main.c (not sure why but this was needed - lost a 1-2 days on this :) )

Porting my game will have to wait a bit, first to finish it and then to find a way to execute other tricks like palette change for the bottom screen where I hide my levels, maybe enable 300 interrupt calls per second instead of 50, ...

But as proof of concept (and eve more!) this looks very good meaning we can program for 2 platforms with almost no issues at all using cpctelera and C!

One day, maybe geco's code can be added to official cpctelera... Thanks again geco!

Offline gflorez

  • EP addict
  • *
  • Posts: 2988
  • Country: es
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #7 on: 2020.June.23. 18:37:30 »
This is a picture of the TMTnet chat program working on my EP:

24930-0


On it, I am talking with myself, user 4 to user 4.
« Last Edit: 2020.June.23. 20:38:27 by gflorez »

Offline Tutus

  • EP lover
  • *
  • Posts: 519
  • Country: hu
  • OS:
  • Mac OS X 10.15 Mac OS X 10.15
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
    • Enterpress News
Re: porting amstrad cpctelera software to enterprise
« Reply #8 on: 2020.June.23. 21:09:44 »
Great!!! :smt038

Offline geco

  • EP addict
  • *
  • Posts: 5753
  • Country: hu
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #9 on: 2020.June.24. 12:20:39 »
@Teopl: I made the modified version of loader, it is the original, so if you would not like to make modifications on this then you can inject the new code into your existing loader:
calling disable_scr_bottom after LPT creation
calling load_map before main code is loaded

copy code from disable_scr_bottom to label filemap (this line should be included too)

I hope i did not make any mistakes, if yes, please ping me.

Offline teopl

  • Newbie
  • Posts: 8
  • Country: cs
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 77.0 Firefox 77.0
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #10 on: 2020.June.25. 23:03:33 »
I finally tested this, works very well!

Also, hiding bottom part of the screen (with the loaded on-screen data) works perfect!

Only thing is that I have some "black hole" in the random data loaded on screen but I guess that is because data is loaded continually and CPC screen is strangely segmented :)



who is interested, I am using 4720 bytes of screen memory by loading compressed levels on screen in these locations: (and then hiding the data)

bank1: [50592, ) = 560 bytes
bank2: [52640, ) = 560 bytes
bank3: [54688, ) = 560 bytes
bank4: [56736, ) = 560 bytes
bank5: [58784, ) = 560 bytes
bank6: [60752, ) = 640 bytes
bank7: [62800, ) = 640 bytes
bank8: [64848, ) = 640 bytes

I think that now I have enough to start porting my game but that will have to wait a while. As soon as I make something worth showing, I will post here!


Offline geco

  • EP addict
  • *
  • Posts: 5753
  • Country: hu
  • OS:
  • Linux Linux
  • Browser:
  • Chrome 83.0.4103.96 Chrome 83.0.4103.96
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #11 on: 2020.June.26. 00:46:26 »
that should not be a problem, strange cpc screen addressing used in ep version of cpctelere too :-D each pixel line is stored next 800h and each character line in next 50h.

Offline geco

  • EP addict
  • *
  • Posts: 5753
  • Country: hu
  • OS:
  • Linux Linux
  • Browser:
  • Chrome 83.0.4103.96 Chrome 83.0.4103.96
    • View Profile
Re: porting amstrad cpctelera software to enterprise
« Reply #12 on: 2020.June.26. 00:48:48 »
if the problem is that the bottom of the screen still contains random data, please send me the binary on slack, i will check it