News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_kilon

Starting coding for Amstrad

Started by kilon, 08:45, 09 March 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kilon

Hey guys , you miss a sticky for getting started.

I got my Amstrad CPC 6128 as first computer in 1988 and I coded Basic on it. Decades later I have passed through most popular languages to settle in with Python and Pharo as my favorite languages.

However I always found Assembly fun to code in back in my DOS days. Things were so simpler back then. So I am wondering how I can code Assembly using Arnold (I killed my CPC long time ago to motivate my father to get me a new computer :D ) .

I would not mind also coding in C.

So any pointers ?

I only care doing super simple stuff, I was thinking a text game with some graphics. I make 3d graphics with Blender so I can make a few images.

Bryce

Have you browsed the wiki instead of just the Forum: CPCWiki - THE Amstrad CPC encyclopedia!

Bryce.

kilon

Doh

Guilty as charged  ;D . No idea why it did not cross my mind to look at the wiki.Thank you .

AMSDOS

These 2 threads below are C related and maybe of interest to you:


"Programming in C on the CPC" - has load of Links in it


"cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC." - may have something in it of use.


I rely more on the available Language Compilers the CPC had with the exception of CPC BASIC 3 or Winape Assembler that I occasionally use. Using the newer languages which function on PCs would allow you to generate more optimised code over the old CPC compilers which rely on a whole library of routines (ones that you use & may not necessarily use), to allow your program to function.


CPC Basic 3 - as the name suggests can take a Locomotive BASIC program and convert it into Assembly, Z88DK or Binary, though isn't 100% Locomotive BASIC compatible, the big drawback would be lack of Floating Numbers.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

kilon

Quote from: AMSDOS on 09:38, 09 March 15
These 2 threads below are C related and maybe of interest to you:


"Programming in C on the CPC" - has load of Links in it


"cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC." - may have something in it of use.


I rely more on the available Language Compilers the CPC had with the exception of CPC BASIC 3 or Winape Assembler that I occasionally use. Using the newer languages which function on PCs would allow you to generate more optimised code over the old CPC compilers which rely on a whole library of routines (ones that you use & may not necessarily use), to allow your program to function.


CPC Basic 3 - as the name suggests can take a Locomotive BASIC program and convert it into Assembly, Z88DK or Binary, though isn't 100% Locomotive BASIC compatible, the big drawback would be lack of Floating Numbers.

thank you I have started to read the links , a lot of info, very useful :)

TFM

Quote from: kilon on 08:45, 09 March 15
(I killed my CPC long time ago to motivate my father to get me a new computer :D ) .


What?  :o
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

kilon

#6
Quote from: TFM on 20:52, 09 March 15

What?  :o

Call me Kilon The CPC Slayer.

Yeah sadly its a true story that may cause some heart attacks in this forum.

I always had a love and hate relationship with my CPC. The truth was that I never wanted it as a computer , my eye was always set on Amiga . I really hated its Green color monitor. Amiga 500 at time (december 1988) was a ton better in term of graphics.

But I also loved CPC because it was a computer and it was quite fun , I loved the games and had good times coding in Basic. So in no way I did not enjoy using my CPC.

4 years after I got CPC , I went to a private school for coding and I was learning many languages , Basic, dbase and clipper. But my eyes were now set on pcs and their impressive hardware. I could not use any of the software other people were using or code in the languages they did and I was fed up with CPC and its green monitor , so I killed it :D .

I was left without a computer for 1-2 years and then my father got me a new one. A 486Dx2 at 60 mhz, 10 times faster than CPC and at last I had a beautiful color monitor and even got a soundblaster audio card. I was in heaven :D Learned C and even did Assembly with DOS.

Of course I felt bad for killing it by using an incompatible power adaptor, but to this day I have no regrets. My father would most likely have left me with CPC for several years, if not a decade, he was always afraid I would not follow his profession and instead become a coder. So he was trying to frustrate as much as possible to give up coding and computers altogether. Kept nagging him several years after I killed CPC for a new PC and he never even told me to fix CPC instead.

Obviously if I could I would have avoid it, but I have no regrets. CPC had to die for the greater good.  I also made it look like an accident for my plan to work.

By the way I am studying Z80 now following the link in CPCWiki . The good news is that I am already a bit familiar with Assembly because I coded for DOS. I always wanted to learn CPC assembly but I was scared 8 year old at the time when even Basic looked too hard :D . So this is a way to fulfill a childhood dream ;) 

I have not figured out how to compile Z80 for Arnold yet.

trabitboy

#7
Hello,
I went back and learnt "unoptimized" z80 assembly on the cpc one and a half year ago,
I found the information I needed in the wiki, but scattered in a lot of different places,
I still had a lot of searching / structuring to do.


Most importantly, what helped me as a c/java programmer was the tuto from ti calc:
Z80 Documentation - ticalc.org


assembly in 28 days.


I found winape very useful and I encourage you to use it, if you want a proper hello world I can find back simple sources .


I'm a "real noob" but I am at the level where I can write an unoptimized graphic game,
I might be more accessible to ask questions to .


With the permission from the others,
I might be able to do a tutorial from 0 on winpae, as a new wiki section,
to give back something .


Do I need special rights to create a page/ amend the programming section ?
Or is a sticky thread better ?


#edit#
small helloworld for winape with lots of comments,
open winape,
f3 to open assembler
open file
f9 to assemble
back to cpc
type
call &4000
return




Shining

I went back active last year and scince I'm coding c/c++/c# in my professional job, I use a mixture of C and ASM on CPC.


I'm completely using SDCC C-compiler and the included assembler. This ASM code is not 100% compatible to the other cpc-assembler solutions (the syntax is quite different and some illegal opcodes are not supported).


If you are interested in this way, then, besides the wiki, take a look at AMSTRAD CPC PROGRAMMING TUTORIALS
TGS is back

Download my productions at:
cpc.scifinet.org

kilon

Quote from: trabitboy on 09:51, 10 March 15

Most importantly, what helped me as a c/java programmer was the tuto from ti calc:
Z80 Documentation - ticalc.org


yeap thats a very good tutorial.

QuoteI found winape very useful and I encourage you to use it, if you want a proper hello world I can find back simple sources .

I am using Arnold because I am a MacOSX user. But I have a VM with windows installed, I can give winape a try.

QuoteI'm a "real noob" but I am at the level where I can write an unoptimized graphic game,
I might be more accessible to ask questions to .

Noob or no noob, if you can answer my questions then mission accomplished ;)

QuoteWith the permission from the others,
I might be able to do a tutorial from 0 on winpae, as a new wiki section,
to give back something .

I find hard to believe that anyone would object to that, certainly not me :)

thanks you also for the example.

QuoteI'm completely using SDCC C-compiler and the included assembler. This ASM code is not 100% compatible to the other cpc-assembler solutions (the syntax is quite different and some illegal opcodes are not supported).

From what I read the use of C is very limited because of the limitation of the hardware. So I would prefer to write code in Assembly, plus its an excuse for me to learn Aseembly even more. Call me freak but always loved coding in Assembly. Always felt dirty but in a good way  8)

I love your link, great info.

I think I am on the right road, its now more of question of reading the documentation and writting the code. From the link I think z88dk is probably the best choice for me as a Mac developer.   Thanks


trabitboy

Winape is really cool to get started because you start it, hit f3,and start writing ; also it has built in breakpoint capability

TFM

Honestly... while waiting 1-2 years for a PC I would have easily made the money by picking up a spare time job. Actually that was the way I financed my computers back the day.

And explaining the old man that a PC may be needed for work would most likely have stimulated him for financial aid.

Willingly destructing a CPC gives bad karma for a long time. Only way out is to fix lot's of them.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

kilon

#12
Quote from: TFM on 17:06, 10 March 15
Honestly... while waiting 1-2 years for a PC I would have easily made the money by picking up a spare time job. Actually that was the way I financed my computers back the day.

And explaining the old man that a PC may be needed for work would most likely have stimulated him for financial aid.

Willingly destructing a CPC gives bad karma for a long time. Only way out is to fix lot's of them.

I got the CPC at the age of 9 , I killed it at the age of 12 . 14 years old I got the pc.  Underage work (under the age of 15) is illegal in my country and even if did decide to work ilegally I still would have made peanuts compared to the cost of a pc at the time, since the salaries in Greece are very low even for adults without qualifications.

I was also a crazy kid at the time (diagnosed with hyperactive syndrome), nobody would want to hire me , with not the best capacity of self control. My teachers suffered more than enough :D

Also at the time I loved to brake things , test them , take them to their extremes. I am also still , not a collector guy. If something is not used then it has to go. At best I would have sold CPC but for very little since PC were all the rage at the time. I also dont believe in Karma . I rarely do things I regret, this is definetly not one of them. So sorry if this shocks you but for me my Amstrad never truly died. It gave me  my great love for coding which is something I am very grateful for and it taught me how fun computers can be. It would have died for me if I kept it and got bored of everything computer wise and finally gave up or became another regular user using it mostly for facebook. The hardware is gone, but memories will stay with me forever :)

And now I can also contribute back to Amstrad by producing new code for it ;)

Who knows maybe one day you may forgive me :D

TFM

Oh, well... Welcome in the forum. Glad to see you somehow back to the CPC.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

kilon

Quote from: TFM on 20:07, 10 March 15
Oh, well... Welcome in the forum. Glad to see you somehow back to the CPC.  :)

Thank you TFM. I am also impessed with your OS , though I did not have the chance to try it yet. I will try it soon. I was a bit on a dilemma whether I should code in Amstrad emulator or Amiga emulator. But I really like the community here. Besides Amstrad looks 100x cooler in color monitor than in green screen so I now I have the opportunity to experience Amstrad in much more fun way than I did with my own back then.

I would not mind to own also the real hardware but I dont have the space. With your help I am reading the Z80 tutorial and its actually quite easy :) Most certainly I wont be making any very good games any time soon but I can certainly code something interesting.

trabitboy

Graphical game can come pretty fast you need:


- to store your data in structures and be able to curse them


- blit to the odd ram layout


- get keyboard input


if you do something single screen, and step by step in a first iteration,
it can come pretty fast.

arnoldemu

Coding for any computer is a great learning experience.

Do not worry if your first game is not perfect, because each time a game is made and completed you gain a better toolset, you understand the system better so can do it better next time.

kilon

Quote from: trabitboy on 14:08, 11 March 15
Graphical game can come pretty fast you need:


- to store your data in structures and be able to curse them


- blit to the odd ram layout


- get keyboard input


if you do something single screen, and step by step in a first iteration,
it can come pretty fast.

Unfortunatly the one thing that really annoys me so far is that it forces me to use windoom and I seriously dont like windoom. So far following the tutorial on cpcmania for sdcc hello world , it needs hex2bin which is a windoom app and something to generate a dsk file , again a windoom app.

Are there any alternatives for macos ?

Concerning the game, thats is not so much a problem. I am not that serious in coding something big for CPC, my return to CPC has to do more with a itch I had to revive my memory about Assembly. The game as you said will be super small, one screen, probably a board game of some sort/ adventure.

What it means "to be able to curse them" ?

"Coding for any computer is a great learning experience."

I am not new to coding, I regularly code in python and pharo , which are my favorite languages. I am already working on a very big project for creating a visual programming language for Blender the open source 3d application. But I wanted to take a brake and try something very different ;)

arnoldemu

Quote from: kilon on 14:58, 11 March 15
Unfortunatly the one thing that really annoys me so far is that it forces me to use windoom and I seriously dont like windoom. So far following the tutorial on cpcmania for sdcc hello world , it needs hex2bin which is a windoom app and something to generate a dsk file , again a windoom app.
Is there source for it?

Quote
Are there any alternatives for macos ?
try cpcxfs. It's command-line based.
http://www.cpctech.org.uk/download/cpcxfs.zip

I haven't tried compiling it for mac, but it builds for linux.
If I have time I'll build it for mac and update the sources.


make -f makefile.lnx



cpcxfs -nd test.dsk
cpcxfs test.dsk -p file.bin



"Coding for any computer is a great learning experience."

I am not new to coding, I regularly code in python and pharo , which are my favorite languages. I am already working on a very big project for creating a visual programming language for Blender the open source 3d application. But I wanted to take a brake and try something very different
[/quote]
Nice.

You may find that coding for CPC has some challenges because of the limited memory size and display compared to much more powerful systems.


TFM

Quote from: kilon on 12:28, 11 March 15
Thank you TFM. I am also impessed with your OS , though I did not have the chance to try it yet. I will try it soon. I was a bit on a dilemma whether I should code in Amstrad emulator or Amiga emulator. But I really like the community here. Besides Amstrad looks 100x cooler in color monitor than in green screen so I now I have the opportunity to experience Amstrad in much more fun way than I did with my own back then.

I would not mind to own also the real hardware but I dont have the space. With your help I am reading the Z80 tutorial and its actually quite easy :) Most certainly I wont be making any very good games any time soon but I can certainly code something interesting.


Cool! That's the right attitude :-) Being creative is much fun :-)


Well, if you code with Emulators and need somebody to test on real hardware then you find enough help here! And I can help of course too.
Thank's for your compliment, FutureOS of course runs on emulators too. If you need it with special ROM numbers for the emu, just PM me.
You're right about the Color monitor, that's a whole other world. For coding I use the GT still though.


Amiga is fun too I guess, never had one, but saw the machine couple of times at friends place. Since that time we try to be better than amiga  ;)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

kilon

Quote from: arnoldemu on 15:05, 11 March 15
Is there source for it?
try cpcxfs. It's command-line based.
http://www.cpctech.org.uk/download/cpcxfs.zip

I haven't tried compiling it for mac, but it builds for linux.
If I have time I'll build it for mac and update the sources.


make -f makefile.lnx



cpcxfs -nd test.dsk
cpcxfs test.dsk -p file.bin



"Coding for any computer is a great learning experience."

I am not new to coding, I regularly code in python and pharo , which are my favorite languages. I am already working on a very big project for creating a visual programming language for Blender the open source 3d application. But I wanted to take a brake and try something very different

Nice.

You may find that coding for CPC has some challenges because of the limited memory size and display compared to much more powerful systems.



it gives me an error unix.c:15:10: fatal error: 'malloc.h' file not found

hex2bin is open source but looks too tied to windoom , no mention of any unix.

Its not the end of the world I can use windoom. But yeah macos builds are ideal.

QuoteWell, if you code with Emulators and need somebody to test on real hardware then you find enough help here! And I can help of course too.
Thank's for your compliment, FutureOS of course runs on emulators too. If you need it with special ROM numbers for the emu, just PM me.
You're right about the Color monitor, that's a whole other world. For coding I use the GT still though.

I tried FutureOS online version, first Java complained about security issues  , I added your website to the security exceptions then it loaded but everything was crawling, I could not move the cursor around. The disk slots cliking on them did nothing.  Will give it also a try with Arnold.

jrodriguezv

#21
I can use hex2bin in Linux compiling it. Try it.

Perhaps cpc-dev-tool-chain works on Mac:
https://github.com/cpcitor/cpc-dev-tool-chain/blob/master/README.md

Try it

ronaldo

#22
hex2bin and cpcxfs do work flawlessly either on Linux or on Windows/Cygwin. I have never tryied in MacOS, but shouldn't be so hard to adapt, given that they compile and work on Linux.

As @jrodriguezv suggests, you may try cpc-dev-tool-chain on MacOS. I have been using it on various Linux flavours and on Windows/Cygwin and the latest version works like a charm.

If you find problems using it on MacOS, I suggest reporting them to @cpcitor: he's willing to improve any problem like this to make cpc-dev-tool-chain work on every platform. If you finally use windows, here you are a .

cpc-dev-tool-chain includes (automating compilations and install steps):

       
  • Hex2bin
  • cpcxfs
  • iDSK
  • 2cdt
  • playtzx
  • sdcc
  • z88dk
  • cpcrslib
  • cfwi

gerald

Quote from: kilon on 17:32, 11 March 15
hex2bin is open source but looks too tied to windoom , no mention of any unix.
No need of hex2bin on unix, use objcopy (or sdobjcopy with sdcc)

Here are the rules I use in my makefiles (windows/linux):

objcopy = sdobjcopy

%.bin : %.ihx
       ${objcopy} -Iihex -Obinary  $< $@

kilon

Why you people believe something that build for Linux will build for MacOS when the two operating systems are so diffirent ? Massively different I would say. Its not that simple. I have seen loads of people suffer to get linux builds to work on MacOS.

So no hex2bin does not build on macos. I also don't know how to mess with makefiles and customise builds.  Though it seems sooner or later I will have to learn.

cpc-dev-tool-chain fails to build too.

If I use windows then I have no need for cpc-dev-tools since windoom is already covered.

sdobjcopy seems to work.

Thank you all for trying to help me out, really appreciate it.



Powered by SMFPacks Menu Editor Mod