The perfect "Hello World" example for new starters
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
The perfect "Hello World" example for new starters
I keep getting asked to re-upload my Hello World sample from my blog, but it was a learning experience riddled with bad practices so letting it circulate further wouldn't do anyone any good.
5 years on I'm now experienced and would like to rewrite every article into proper tutorials, but as a stop-gap measure I'd like to throw the idea of coming up with the perfect Hello World sample we can point newcomers at to get them started quickly. Existing examples are hard to find, aren't very beginner friendly, are poorly documented, or target specific toolchains.
I ran a workshop on Mega Drive coding at the NVA last year, which ended up with this: https://pastebin.com/kJC99PA7 (and the workshop slides to go with it: https://docs.google.com/presentation/d/ ... sp=sharing).
It might be a good base to start, I'll do some cleanup and add extra comments, but does anyone have any thoughts?
Since it's aimed at beginners, I propose the following:
- Target Motorola syntax
- Compatible with most major assemblers (asm68k, snasm68k, asmx, vasm) with example command lines for each
- Comments for every line (i.e., remind the reader what a particular register is currently being used for every time it's written to)
- Prefer verbose methods that teach, over high performance code that obfuscates (within reason, see next point)
- Shouldn't show or encourage "newbie mistakes" or bad practices
- Should be reusable and extendable
- Define/equate all "magic numbers" or addresses
- Must work on all revisions of real hardware (my original didn't)
Most importantly, it needs to be an example we all agree on as being clean, and won't teach any bad practices.
5 years on I'm now experienced and would like to rewrite every article into proper tutorials, but as a stop-gap measure I'd like to throw the idea of coming up with the perfect Hello World sample we can point newcomers at to get them started quickly. Existing examples are hard to find, aren't very beginner friendly, are poorly documented, or target specific toolchains.
I ran a workshop on Mega Drive coding at the NVA last year, which ended up with this: https://pastebin.com/kJC99PA7 (and the workshop slides to go with it: https://docs.google.com/presentation/d/ ... sp=sharing).
It might be a good base to start, I'll do some cleanup and add extra comments, but does anyone have any thoughts?
Since it's aimed at beginners, I propose the following:
- Target Motorola syntax
- Compatible with most major assemblers (asm68k, snasm68k, asmx, vasm) with example command lines for each
- Comments for every line (i.e., remind the reader what a particular register is currently being used for every time it's written to)
- Prefer verbose methods that teach, over high performance code that obfuscates (within reason, see next point)
- Shouldn't show or encourage "newbie mistakes" or bad practices
- Should be reusable and extendable
- Define/equate all "magic numbers" or addresses
- Must work on all revisions of real hardware (my original didn't)
Most importantly, it needs to be an example we all agree on as being clean, and won't teach any bad practices.
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
Re: The perfect "Hello World" example for new starters
Thank you very much. I've always thought this was much needed ^^
-
- Very interested
- Posts: 115
- Joined: Fri Sep 18, 2015 2:56 pm
Re: The perfect "Hello World" example for new starters
This is much needed. I finally got some time to get back to megadrive and i was learning from your blog and other sources. Thanks for the effort.
Also again, your vdp commands in p57 are wrong,(or i am wrong?) like in your blog:
Commands:
100000 – VRAM Write
110000 – CRAM Write
and should be:
Commands:
000001 – VRAM Write
000011 – CRAM Write
source: sega2.doc
BTW got stuck cant make planes scroll for some reason , would you expand your new guide?
Also again, your vdp commands in p57 are wrong,(or i am wrong?) like in your blog:
Commands:
100000 – VRAM Write
110000 – CRAM Write
and should be:
Commands:
000001 – VRAM Write
000011 – CRAM Write
source: sega2.doc
BTW got stuck cant make planes scroll for some reason , would you expand your new guide?
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
Re: The perfect "Hello World" example for new starters
Oops, looks like I just wrote the bits from the wrong end.Montserrat wrote: Commands:
100000 – VRAM Write
110000 – CRAM Write
and should be:
Commands:
000001 – VRAM Write
000011 – CRAM Write
Yeah I'll add to that snippet and make it scroll. Once the next demo for my game is out of the way I'll get to work on this new Hello World business properly.Montserrat wrote: BTW got stuck cant make planes scroll for some reason , would you expand your new guide?
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
Re: The perfect "Hello World" example for new starters
Ok here's an updated version with better comments, all magic numbers defined using EQU, and a simple V/H scrolling example:
https://pastebin.com/FfaVsrFm
I should add a disclaimer at the top saying it's for learning purposes only and may not be the most performant or organised code. I'll continue to add improvements when I get some spare time back.
https://pastebin.com/FfaVsrFm
I should add a disclaimer at the top saying it's for learning purposes only and may not be the most performant or organised code. I'll continue to add improvements when I get some spare time back.
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
-
- Very interested
- Posts: 115
- Joined: Fri Sep 18, 2015 2:56 pm
Re: The perfect "Hello World" example for new starters
thanks for the new code! ill try to get my scroll working.
Ill wait patiently for more guides ;D
Ill wait patiently for more guides ;D
Re: The perfect "Hello World" example for new starters
Thanks for posting this! I had been trying out some code based on your original blog posts, which was working fine on emulators but wouldn't boot on actual hardware.
Looking forward to any updated tips.
-Matt
Looking forward to any updated tips.
-Matt
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
Re: The perfect "Hello World" example for new starters
Yeah that stuff is so old and I only had a vague idea of what I was doing, I really need to start writing them again as actual tutorials (peer reviewed and fact checked). It was more of a diary.MattM wrote:Thanks for posting this! I had been trying out some code based on your original blog posts, which was working fine on emulators but wouldn't boot on actual hardware.
Looking forward to any updated tips.
-Matt
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
Re: The perfect "Hello World" example for new starters
It was still very useful and I learned a lot from it. Out of curiosity, what was the issue that prevented it from booting on actual hardware? I ended up borrowing some init/header code from another source which worked for me at the time, but I spent a lot of time trying to figure out the difference and wasn't able to track it down.BigEvilCorporation wrote: Yeah that stuff is so old and I only had a vague idea of what I was doing, I really need to start writing them again as actual tutorials (peer reviewed and fact checked). It was more of a diary.
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
Re: The perfect "Hello World" example for new starters
It was all down to the VDP registers if I remember correctly, it was a while ago thoughMattM wrote:It was still very useful and I learned a lot from it. Out of curiosity, what was the issue that prevented it from booting on actual hardware? I ended up borrowing some init/header code from another source which worked for me at the time, but I spent a lot of time trying to figure out the difference and wasn't able to track it down.BigEvilCorporation wrote: Yeah that stuff is so old and I only had a vague idea of what I was doing, I really need to start writing them again as actual tutorials (peer reviewed and fact checked). It was more of a diary.
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
-
- Very interested
- Posts: 209
- Joined: Sat Sep 08, 2012 10:41 am
- Contact:
Re: The perfect "Hello World" example for new starters
I've improved this, and started adding samples to GitHub to replace the old/buggy/poorly-informed/missing ones on my site: https://github.com/BigEvilCorporation/megadrive_samples
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk
Re: The perfect "Hello World" example for new starters
I made a "hello world" assembly demo a year or two ago when working on a few programming tutorials, but never ended up posting it anywhere.
I'm not sure how it stacks up against others. I'm not really a programmer, so I have tons of bad practices. I'm sure it could have been done better, but I maybe it will help someone some day.
It can be compiled by simply running the make.bat
http://mode5.net/download/hello%20world%20example.zip
I'm not sure how it stacks up against others. I'm not really a programmer, so I have tons of bad practices. I'm sure it could have been done better, but I maybe it will help someone some day.
It can be compiled by simply running the make.bat
http://mode5.net/download/hello%20world%20example.zip
Visit my web site at http://www.mode5.net/!