Sega Genesis Programming Series

Started by dra600n, June 11, 2014, 00:36:43 AM

Previous topic - Next topic

dra600n

Hey all! I've started a Sega Genesis Programming Series to help people new to programming learn how to code. At least that's my intentions! Anyway, I just got done finishing up the first tutorial, so here it is: http://iheartgk.com/gentutorial_1.php

Let me know what you all think, and if anything needs further explaining, let me know and I'll be sure to append it.

The end goal will be a level (possibly more) of a fully functional Mrs. Pac Man, but of course, I'm hoping the material learned is used to make all new homebrews :)

TrekMD

Very nice.  Something to check out.

Going to the final frontier, gaming...


zapiy

Brilliant, will have a play at the weekend when I get some free time.

Own: Jaguar, Lynx, Dreamcast, Saturn, MegaDrive, MegaCD, 32X, GameGear, PS3, PS, PSP, Wii, GameCube, N64, DS, GBA, GBC, GBP, GB,  Xbox, 3DO, CDi,  WonderSwan, WonderSwan Colour NGPC

Carlos

well done, it looks similar to forth with regards to the else if loops. keep it up.

you should try a routine with one moving sprite, I found programming a version of blitz! very educating.

dra600n

Thanks for the responses so far!

Can you explain a little more on what you mean about a single routine to move a sprite? In the Mrs. Pac Man code, that's exactly what's being done (at the moment). As I continue on with the tutorials, I'll be going over more sprite stuff, and the next tutorial will include the background planes and window plane for the HUD.

Following that tutorial, I'll be covering collision detection for eating the pellets, and beginning the AI of the ghosts.

Of course, if there is something specific you'd like to see in the next tutorials, please let me know :)

I do need to link to some graphic editors and music trackers as well, so maybe I'll write up a quick tutorial this evening on creating graphics and music as an "in between" tutorial.

Carlos

Quote from: "dra600n"Thanks for the responses so far!

Can you explain a little more on what you mean about a single routine to move a sprite? In the Mrs. Pac Man code, that's exactly what's being done (at the moment). As I continue on with the tutorials, I'll be going over more sprite stuff, and the next tutorial will include the background planes and window plane for the HUD.

Following that tutorial, I'll be covering collision detection for eating the pellets, and beginning the AI of the ghosts.

Of course, if there is something specific you'd like to see in the next tutorials, please let me know :)

I do need to link to some graphic editors and music trackers as well, so maybe I'll write up a quick tutorial this evening on creating graphics and music as an "in between" tutorial.

Sorry dra600n,

I really meant two moving sprites anyway!

Blitz! is basically 13 UDGs and two moving sprites, a plane and a bomb with two collision detecting routines. As you keep coding you can enhance the graphics and the sounds each time you alter the programme. I would love to see a genesis conversion of this.

You also appreciate how 55 space invaders and a missile ship is still no mean feat even today!

dra600n

Ohhh. Neat. I'll take a look at Blitz! and see what it's about. Maybe I can also use something like that in these tutorials as well. The interesting thing about programming is that there are several methods to do the same thing, and that's one of the things I'm going to stress upon as the tutorials get more in depth and more complex (probably not so much with Mrs. Pac Man, but other things such as raster effects and getting around some of the hardware limitations).

TL

Quote from: "dra600n"Ohhh. Neat. I'll take a look at Blitz! and see what it's about. Maybe I can also use something like that in these tutorials as well. The interesting thing about programming is that there are several methods to do the same thing, and that's one of the things I'm going to stress upon as the tutorials get more in depth and more complex (probably not so much with Mrs. Pac Man, but other things such as raster effects and getting around some of the hardware limitations).

Blitz! Was the game I recommended to you, I remember programming an ST version in HiSoft basic fairly easily called City Bomber. There are loads of variations of this game. Here is one of them that is really nice:

[align=center:1kl2zbi1]Ocean Detox - Atari XL/XE - Longplay[/align:1kl2zbi1]

dra600n

Quote from: "The Laird"
Quote from: "dra600n"Ohhh. Neat. I'll take a look at Blitz! and see what it's about. Maybe I can also use something like that in these tutorials as well. The interesting thing about programming is that there are several methods to do the same thing, and that's one of the things I'm going to stress upon as the tutorials get more in depth and more complex (probably not so much with Mrs. Pac Man, but other things such as raster effects and getting around some of the hardware limitations).

Blitz! Was the game I recommended to you, I remember programming an ST version in HiSoft basic fairly easily called City Bomber. There are loads of variations of this game. Here is one of them that is really nice:

[align=center:32gwv6o4]Ocean Detox - Atari XL/XE - Longplay[/align:32gwv6o4]

Yup! You did. I'll have to copy and paste the link to the video as it's not showing up on my phone. I did find the CBM basic version on YouTube, and it seems like a very simple game to code up. I may see if I can whip up a demo level of it tonight when I get home from work and if it's as easy as I think, I should be able to whip up a tutorial in the next day or 2

Carlos

Here is my code, you can see how simple and short it is, the hex is the udgs, and the procedures look similar to what you are using.

: cdata <builds does > ;
hex
1414 var udgs
081C ,
1C1C ,
0800 ,

2772 ,
F2FA ,
FF7F ,
3F30 ,

F040 ,
91FD ,
FFFD ,
F1C0 ,

557F ,
7F55 ,
557F ,
7F55 ,

4949 ,
497F ,
4949 ,
497F ,

0000 ,
0041 ,
3165 ,
F765 ,

0000 ,
0041 ,
3165 ,
F765 ,

0000 ,
0841 ,
143E ,
3E7F ,

0000 ,
0808 ,
3E2A ,
6B7F ,

FFAA ,
55AA ,
55AA ,
55AA ,

decimal
udgs vram 600 + 13 8 * cmove

( 2nd Block)

: xy@
25 * + vram + ;
5 var seed
: rnd seed @ 1+ 75 * dup seed ! u* swap drop ;
: die cls 1 12 at ." Crash you are Mashed" quit ;
: win cls 1 12 at ." Complete! well done" quit ;

( 3rd Block)

3 const bodies
3 const body1
2 const bombedBodies
6 const body1bombed
2 const roofs
8 const roof1
12 const maxBuildHeight

: building
bodies rnd
body1 +
maxBuildHeight rnd dup
>r 0 do
over 22 i - xy@
over swap ic!
loop drop roofs rnd
roof1 + swap
22 r> - xy@ ic! ;

: city 0 do i
building
loop ;



( 4th Block)

0 var gameover
25 var plane
25 var noplane

: fill 525 0 do 27 emit loop ;

: flash 20 0 do fill cls loop ;

: timeout clock i@ +
begin
dup clock i@ -
0< until drop ;

: moveplane
plane @ 1+
plane ! 10 timeout ;

: coll vram
plane @ 1 + + ic@
 32 < if
flash die
then ;

( 5th Block)

0 var bombdrop
0 var bombpos
0 var initbomb
0 var destroy
0 var score
0 var high

: dokey
inkey 32 = if
1 initbomb !
1 bombdrop !
plane @
25 + bombpos !
then ;

: dispbomb 0 vram bombpos @ + ic! ;

: disspace 32 vram bombpos @ 25 - + ic! ;

: incbomb bombpos @ 25 + bombpos ! ;

: getbomb bombpos @ vram + ic@ ;

( 6th Block)

: dobomb
initbomb @ 1 =
bombdrop @ 1 =
and if
dispbomb incbomb

0 initbomb !
else
initbomb @
0 =
bombdrop @
1 =
and if
getbomb
32 = if
disspace dispbomb
incbomb
else
getbomb

dup 32 = 0=
swap 10 = 0= or
destroy @ 6 < and
if
disspace
dispbomb
incbomb
destroy @ 1 + destroy !
score @ 1+ score !
else
getbomb
10 = if
disspace
0 bombdrop !
0 destroy !
else
destroy @
6 = if
disspace
6 vram bombpos @ + ic!
0 bombdrop !
0 destroy !

then then then then then then ;

( 7th Block)

: high? 
score @
high @
> if
score @ high !
then ;

: win?
plane @ 548 = if win then ;

: top 0 0 at ." Score" score @ .
17 0 at ." High" high @ . ;

: goplane begin
displane
bombdrop @ 0= if
dokey
then
dobomb
bombpos @
550 > if
32 vram bombpos @ + 25 - ic!
0 bombdrop !
0 destroy !
then
moveplane top win? coll
gameover @ 1 = until ;

: run
high?
0  score !
25 plane !
25 noplane !
cls
24 city
25 ground
goplane ;

here is more info about the game, ans some kind comments made by Steve Battle, author of the VIC original saying how nice this version was.

http://retrotext.blogspot.co.uk/2013/09/blitz-is-included-on-infuze-bundle.html

dra600n

Neat! I decided to tackle this game as well :D I only got some graphics done, thanks to Google Images as I suck at making my own graphics (only the cloud and plane are taken from google images, the block is from a royalty free place, the bomb and crate are custom, and the sky line is pretty generic).

Anyway, here's a demo rom of what I got done tonight (graphics took waaaaaay too long, the coding took about 10 minutes): http://www.iheartgk.com/downloads/madbomber.bin

I should be able to have the engine done tomorrow, and then I'll begin the tutorial and explain all the coding.

Carlos

Quote from: "dra600n"Neat! I decided to tackle this game as well :D I only got some graphics done, thanks to Google Images as I suck at making my own graphics (only the cloud and plane are taken from google images, the block is from a royalty free place, the bomb and crate are custom, and the sky line is pretty generic).

Anyway, here's a demo rom of what I got done tonight (graphics took waaaaaay too long, the coding took about 10 minutes): http://www.iheartgk.com/downloads/madbomber.bin

I should be able to have the engine done tomorrow, and then I'll begin the tutorial and explain all the coding.


TL


dra600n

Thanks for posting the screen shot, Carl. I wasn't sure if Facebook would have any issues with embedding pictures on forums, so I didn't even both trying and I was too lazy to FTP into my site lol.

Laird, thank you!

For those that are familiar with Blitz!, I have a question for ya:

When you're flying by, are you limited on how many bombs you can drop? The videos I've seen show people dropping one per fly by, sometimes 2, so I'm not sure if there's a limit, or if you can't drop a bomb until the first one has finished it's path of destruction. Can anyone give me some insight on this please? :) (that means I'll have to include SRAM information in the tutorial as well).

Thanks for the compliments so far! I'm really enjoying writing the tutorials and other misc information :D

TL

It is usually 1 at a time, so once it hits something you can launch another.