• Register
  • TOS
  • Privacy
  • @NeoGAF
  • Like

Krejlooc
Banned
(10-21-2014, 08:31 PM)
BEGINNING GAME DEVELOPMENT
A Dreamcast dev tutorial

UPDATE NOTE 2016/09/14:
This tutorial is a work in progress. Currently, up to the conclusion of Chapter 3 has been written, although all chapters written are not final and are subject to change. For the sake of prosperity, the original OP is being mirrored untouched: Link!

INTRO
Developing a video game can be a deeply rewarding experience. It is a demonstration of technical proficiency in a number of disciplines that makes it rewarding to engineering types, while simultaneously being an expression of creativity and personality that makes it rewarding for artistic types. If you hang around on gaming forums long enough, you'll undoubtedly see people express the desire to try their hand at making games. There is a creative spark in amateurs that manifests in many art forms, from fan films to cover bands.

I've been doing computer programming focusing on game development for over 20 years now. One of the things I did that immensely helped my understanding of game development was picking a classic console and learning how to program for it. Since about 1998, I've been studying the Sega Genesis, called the Sega Megadrive outside North America, as a hobby. I picked up m68k microprocessor assembly in the process and played along the ROM hacking scene for many years. Learning how the genesis worked gave me a deep understanding of how video games actually interact with hardware, and how those interactions fuel design choices. I've often recommended people pick up a classic system if they are serious about learning game development. Unfortunately, it's pretty hard for a complete beginner to jump into that kind of system due to comparatively weak hardware. We live in an era where programmers have essentially unlimited resources if they are developing a 2D game, which makes jumping back to an era where you are literally counting clock cycles enormously difficult. A better system to recommend people pick up is the Sega Dreamcast.

The Dreamcast is a wonderful system. I consider it the last classic console - in terms of 3D, it offers no shader support (although you can perform bump mapping), nor does it have an incredible CPU that can brute force shader effects. In terms of 3D, it's still of the fixed function pipeline era of OpenGL. It's GPU, the Holly chip, is part of an exotic design - the PowerVR 2 core. It even has a real dedicated sprite mode for 2D graphics. All this means that the Dreamcast has a pretty unique visual style. In terms of design, the Dreamcast is sort of the opposite of the Playstation 2. The PS2 had a powerful CPU - The Emotion Engine - to offset a crummy graphics chip, with only 4MB of fast ram. The Dreamcast, by contrast, had a weak CPU even for the time, but a pretty incredible graphics chip that punched way above its weight to go along with a huge 8MB of slow ram. The PVR Chip is pretty fun to play with - it offers tile based deferred rendering, and has hardware functions that greatly improve it's performance and ways to get even more out of your already-large pool of ram - sometimes even 32 times more.

What all that amounts to is a system that is still unique enough to affect your approach to game design, like you have to do with mega drive programming, but with a lot more power. You need to tap the Dreamcast hardware in a specific way to make it sing, and doing so is pretty fun. I've researched online for a long time and there are many great resources for Dreamcast development out there, but no one singular guide to bring everything together.

The goal of this tutorial is to introduce you to Dreamcast game development. It's meant to be a small slice of what game development can be like, concentrating more on the technical side of the equation than the creative side. With fans who want to dabble in homebrew, there never seems to be a loss for creativity anyways. This guide will walk you through making a breakout clone for the Sega Dreamcast. Breakout was the very first game I ever made using QBasic, several decades ago. Breakout is such a simple game to get your feet wet with - there is really no AI, the rules and mechanics are simple, and we can concentrate most of our energy on actually getting the to know the Dreamcast environment.

This guide will walk you through every step, from you having no tools on your PC (Windows or Linux) at all to running the game on your Dreamcast. Along the way, it will discuss optimization, and teach techniques that can apply to more than just Dreamcast programming. It will also walk you through the creation of tools we will need to make our Dreamcast game, that help us interact with the hardware on deeper levels.

Be mindful, though, that while this is a guide for beginners, a degree of basic programming knowledge will be assumed, but the point of this topic is for beginners to ask questions as we progress through this project to help understand what very basic development is like. I'll also try to explain the logic of what is going on as best as possible. Additionally, I make no claim to being the world's best coder and I'm still pretty new to Dreamcast Development in general, so if my code is embarrassing or I'm doing something all wrong, please feel free to correct me. In the end, this tutorial is for my own benefit as well.

TABLE OF CONTENTS
-LESSON 1: CREATING THE TOOLCHAIN
-LESSON 2: BUILDING OUR FIRST EXAMPLE PROJECT
-LESSON 3: SOFTWARE RENDERING

FILES
ALL FILES (as of 2016/09/14)
--Lesson 1
------IMG Burn 4 DC
------NullDC
------SDL2 Files
------Scramble File
--Lesson 2
------IP.bin
------Bootdreams
------cdi4dc
--Lesson 3
------Lesson3.1.rar
------Lesson3.2.rar
------Lesson3.3.rar
------Lesson3.4.rar
------Lesson3.5.rar
------Lesson3.6.rar
------Lesson3.7.rar

RECOMMENDED RESOURCES
Official KallistiOS reference manual
http://cadcdev.sourceforge.net/docs/kos-2.0.0/
The official online manual for KallistiOS, with reference pages for every function and file in KallistiOS.

DC Emulation
https://dcemulation.org/
DC Emulation is the best resource for Dreamcast programming I found. The board is active, as is the IRC chat (chat.freenode.net, #Dreamcastdev). Many of it's moderators have a deep understanding of KOS, and you get answers to questions pretty quickly.

Dreamcast Programming by Marcus Comstedt
http://mc.pp.se/dc/
Marcus is one of the people who figured out the bin scrambler. His website is old, but is full of great Dreamcast knowledge that is still relevant today

Sega Dreamcast Hardware Specification Outline
http://hwdocs.webs.com/Dreamcast
Sega's official Hardware outline for the Dreamcast, good for a basic understanding of the Dreamcast architecture.

Lazy Foo's SDL Tutorials
http://lazyfoo.net/tutorials/SDL/index.php
Much of our PC software will use SDL 2.0. This guide is not intended to be a tutorial for SDL 2.0, but Lazy Foo's tutorials are where I learned SDL 2.0. You can use his pages if you wish to learn more about SDL 2.0

Gamasutra - Image Compression with Vector Quantization
http://www.gamasutra.com/view/featur...th_vector_.php
While I briefly cover Vector Quantization in this tutorial, this is a better, fuller read on the subject. In fact, I use images from this article to help with the concept.

SPECIAL THANKS TO
I couldn't have possibly learned all I have learned or compiled this guide without the following people or places. It is with a huge debt of gratitude to the following that this guide exists:

Code:

BlackAura
BlueCrab
MetalliC
Tvspelsfreak
Bogglez
tonma
The Taxman
Lazy Foo
Marcus Comstedt
Dan Potter
Light-Dark
Chilly Willy
SWAT
Ivan-Assen Ivanov
Gecko Yamori
Zeboyd Games
PLEASE NOTE: ALL FILES WITHIN THIS TUTORIAL HAVE EITHER BEEN CREATED BY ME, OR USED WITH PERMISSION FROM THE ORIGINAL AUTHORS. ALL CODE IS APPLICABLE UNDER GPL.
Jockel
Member
(10-21-2014, 08:36 PM)
Jockel's Avatar
Subscribed!
Really interested- I intend to follow your tutorial and give feedback.
kd-z
Member
(10-21-2014, 08:40 PM)
kd-z's Avatar
Subbed as well! This is going to be interesting :)
Ramzastrife
Member
(10-21-2014, 08:40 PM)
Subbed. Love the idea, and hopefully will be able to follow along.
MikeHattsu
Member
(10-21-2014, 08:41 PM)
MikeHattsu's Avatar
This is relevant to my interests. Subbed here as well.
Dr Dogg
Member
(10-21-2014, 08:55 PM)
Dr Dogg's Avatar
Yeah, sharing the sentiments in this thread already, sounds like a great idea. Even more so I have most applications installed already. Just got to figure out what I've done with my Dreamcast controllers and where on earth I put an CD/DVD burner as I've not used one in year. Subbed for reading alone!
itxaka
Defeatist
(10-21-2014, 09:01 PM)
itxaka's Avatar
Subcribed! Very interesting
terrisus
Banned
(10-21-2014, 09:05 PM)
OP looks very thorough already.
This will definitely be very interesting to see come together.
MetalSlug
Member
(10-21-2014, 09:06 PM)
MetalSlug's Avatar
Very interesting :)
emb
Member
(10-21-2014, 09:09 PM)
emb's Avatar
Will definitely try to follow along if I get a chance. Cool idea, thanks op.
Krejlooc
Banned
(10-21-2014, 09:11 PM)
K, I had originally intended for the first tutorial to walk you through setting up the toolchain and actually compiling your first source and getting it running on a dreamcast, but because I accidentally hit submit early, I've truncated it, so the first lesson is merely installing the toolchain. I'm about to eat lunch, but when I'm done, I'll type up the next lesson which will walk us through a very simple source code for a dreamcast project to get us displaying a png on screen, building the source code into an executable, and getting it running in both NullDC, our dreamcast emulator we will use for quick testing, as well as an actual dreamcast console itself.

So stay tuned I guess :)
CriterionDog
Member
(10-21-2014, 09:16 PM)
CriterionDog's Avatar
I know NOTHING about any of this, but this seems like such a cool thread. Reading it alone was worth it! I hope something cool comes out of it!
Jockel
Member
(10-21-2014, 09:39 PM)
Jockel's Avatar
Could anyone elaborate on the advantages and disadvantages of SDL and PowerVR?
I'd assume the former is more of a homebrew solution and better for 2D games and the latter is more complicated but capable of rendering polygons (or superior doing it)?
I hope the question's not stupid, I'm completely clueless on programming
PetrCobra
Member
(10-21-2014, 09:54 PM)
PetrCobra's Avatar
Okay, I think I'll try my best to follow this tutorial asap. Don't have a dreamcast but I guess I can just emulate the results...

Subbed!
SirUltimos
Member
(10-21-2014, 09:57 PM)
SirUltimos's Avatar
Just wanted to say that this is an incredible idea and that I'll be following along very closely.
Living Proof
Member
(10-21-2014, 10:00 PM)
Living Proof's Avatar
Very cool idea. I've always entertained the idea of making a game, but I don't kid myself and realize it's all way beyond my capabilities. I'll still enjoy seeing this progress, though, seeing as insight is understanding.
Krejlooc
Banned
(10-21-2014, 10:04 PM)

Originally Posted by Jockel

Could anyone elaborate on the advantages and disadvantages of SDL and PowerVR?
I'd assume the former is more of a homebrew solution and better for 2D games and the latter is more complicated but capable of rendering polygons (or superior doing it)?
I hope the question's not stupid, I'm completely clueless on programming

Sdl is one of the best apis you can use around in general, in fact a huge portion of valve's solution for getting people to adopt opengl stems from letting people know sdl can do much of what direct x does beyond graphics.

Its just that the dc version of sdl is depreciated and slower than powervr, plus I want to learn something new. Sdl, in general, is fine for both 2d and 3d development on the dreamcast.
Spinluck
Member
(10-21-2014, 10:07 PM)
Spinluck's Avatar
I'm more on the art side than the technical side. Although, I assume you cannot be complete ignorant of the technical side of game development even as an artist.

This is very interesting so you have my attention, subbed!
Damaniel
Banned
(10-21-2014, 10:11 PM)
Subscribed! I'm a huge fan of retro development (both on consoles and retro PCs), and while I've dabbled in both NES and GBA development (not to mention my current DOS-era PC development fascination), I've never done Dreamcast development before -- and I wouldn't mind trying.
ZeroXZee
Member
(10-21-2014, 10:19 PM)
ZeroXZee's Avatar
Subscribed! Will follow the lessons if I have a chance :)

Kinda dumb question: at some point, I will need to have a Dreamcast? Or I can use NullDC just fine for devloping?
Spades
Member
(10-21-2014, 10:22 PM)
Spades's Avatar
Subbed for the ride!
Krejlooc
Banned
(10-21-2014, 10:22 PM)

Originally Posted by ZeroXZee

Subscribed! Will follow the lessons if I have a chance :)

Kinda dumb question: at some point, I will need to have a Dreamcast? Or I can use NullDC just fine for devloping?

You can use nulldc - its what we'll be using for quick tests so we dont need to constantly reburn cds, but be aware that emulation isnt perfect, and sometimes what runs on nulldc wont run on a real dreamcast.
Koobion
Member
(10-21-2014, 10:28 PM)
Koobion's Avatar
Very interested in checking this out. Thank you for the effort you put into this.
Wenger'sBakedBaguettes
Member
(10-21-2014, 10:30 PM)
Wenger'sBakedBaguettes's Avatar
Amazing thread, and subscribing to this. I will try it out myself as well once the tutorials are up there. Sounds fun :)
udivision
(10-21-2014, 10:33 PM)
udivision's Avatar
This is crazy... but in a good way.

It only reconfirms that I'll never graduate beyond WYSIWYG editors though.
Exuro
Member
(10-21-2014, 10:35 PM)
Exuro's Avatar
Totally subbing this. Sounds incredibly cool to try out. I've made a basic tictactoe game in SDL and am currently learning to write shaders in opengl so I've been interested in game development lately as I know jack about it, so this should be cool.
b0b
Junior Member
(10-21-2014, 10:39 PM)
great topic!


Originally Posted by Krejlooc

Sdl is one of the best apis you can use around in general, in fact a huge portion of valve's solution for getting people to adopt opengl stems from letting people know sdl can do much of what direct x does beyond graphics.

Its just that the dc version of sdl is depreciated and slower than powervr, plus I want to learn something new. Sdl, in general, is fine for both 2d and 3d development on the dreamcast.


SDL is great, yes - but not on the dreamcast.

i think the latest ported SDL-version on the Dreamcast is 1.2.9 or something. and the port itself isn't great either. Don't blame the porters, SDL just doesn't suit the hardware of the DC...
neither does OpenGL btw. But the newest OpenGL-API does look very promising. It's an wrapper for the PVR-functions with a lot of extra stuff (clipping!)


I looked into both of them - from code of the SDL-port I took information how the input and audio system work and learned one-two things from the older OpenGL-API. but I'm using only kos stuff right now, and the png-stuff from kos-ports. for now, using pngs on the DC isn't that great ;)


The more external libs you use the bigger your executable will be as it's static linked. It's fine for smaller programs... But the memory is very limited (8MB VRAM, 2MB audio and 16mb RAM minus the memory kos reserves for itself)


btw one can also use c++ and, i think, objective-c.
morpix
Member
(10-21-2014, 10:43 PM)
morpix's Avatar
Wow, good job OP. I'm gonna grab an el-cheapo Dreamcast and get this going.
justjustin
Member
(10-21-2014, 10:44 PM)
justjustin's Avatar
Thanks for making this, I had no idea the console was so well understood with a dev culture surrounding it. I would get a real kick out of seeing something I made-- no matter how crude-- boot up on a real Dreamcast, so I'll keep my eye on this thread.
ekgrey
Member
(10-21-2014, 10:45 PM)
ekgrey's Avatar
subbed and bookmarked. i live for Krejlooc threads.
Koozek
Member
(10-21-2014, 10:45 PM)
Koozek's Avatar
Oooh, yeaaah, subbed immediately! Very interesting and insightful Thank you, dude :) Always wanted to see how the development process for consoles looks like. I once read some SNES/GBA game source codes in C (I think it was Super Metroid).
PureXbox
Banned
(10-21-2014, 10:45 PM)
Outstanding work, OP. Excellent stuff!
Krejlooc
Banned
(10-21-2014, 10:48 PM)
I probably won't be able to post part 2 of the tutorial till late tonight, as I'm going to be covering building sources and I want to make sure I have the compiler in front of me to go over its linker options, and, to make sure we're all on the same page, I'll be rebuilding the toolchain from scratch. So expect part 2 on building source late tonight.
Dambrosi
Banned
(10-21-2014, 10:50 PM)
Dambrosi's Avatar
Considering how hard it is to get an old Dreamcast that still works in the Uk, I sure hope that your project runs in emulation. That's probably the only way I could try it out.
Krejlooc
Banned
(10-21-2014, 10:51 PM)

Originally Posted by b0b

great topic!





SDL is great, yes - but not on the dreamcast.

i think the latest ported SDL-version on the Dreamcast is 1.2.9 or something. and the port itself isn't great either. Don't blame the porters, SDL just doesn't suit the hardware of the DC...
neither does OpenGL btw. But the newest OpenGL-API does look very promising. It's an wrapper for the PVR-functions with a lot of extra stuff (clipping!)


I looked into both of them - from code of the SDL-port I took information how the input and audio system work and learned one-two things from the older OpenGL-API. but I'm using only kos stuff right now, and the png-stuff from kos-ports. for now, using pngs on the DC isn't that great ;)


The more external libs you use the bigger your executable will be as it's static linked. It's fine for smaller programs... But the memory is very limited (8MB VRAM, 2MB audio and 16mb RAM minus the memory kos reserves for itself)


btw one can also use c++ and, i think, objective-c.

Thing is, I mainly used SDL as just a cheap, quick way of accessing the framebuffer in the demoes I used, and for doing simple stuff like controller polling. I essentially wrote all my intrinsic functions inline and used as little of SDL as possible, which is where I think it has its place on the Dreamcast. Just a very quick, very lightweight way to push pixels to the screen.

That's part of the reason I want to work with PVR this time around - actually use the library beyond access to the hardware :P

SDL 2.0 is wonderful, btw. That has nothing to do with DC development, but it's comes such a long way since I first began working with SDL back in 1997.
Qwark
Member
(10-21-2014, 10:52 PM)
Qwark's Avatar
Great topic, I'll be checking this out for sure.

Curious, is it legal to sell homebrew games created this way?
zephervack
Member
(10-21-2014, 10:56 PM)
zephervack's Avatar
As someone that works programming accounting software, I cant wait to follow all of this, always dreamed of seeing something I coded running on a console.

Subbed.
MRORANGE
Member
(10-21-2014, 10:58 PM)
MRORANGE's Avatar
Great guide, even the terminal instructions are easy follow.
Krejlooc
Banned
(10-21-2014, 10:58 PM)

Originally Posted by Qwark

Great topic, I'll be checking this out for sure.

Curious, is it legal to sell homebrew games created this way?

Yes, for the most part, because these are not official tools. There might be some niggles with regards to actually obtaining a license from Sega to develop for the dreamcast because they don't issue licenses in the first place anymore, but they definitely won't bring legal action against you or anything. This is how modern, commercial dreamcast games are made, today.
LaneDS
Member
(10-21-2014, 10:59 PM)
LaneDS's Avatar
Man, that's fantastic. Thanks for your effort. Won't be following along or anything, but will peak in from time to time to maybe learn a thing or two and just wanted to give you an e-thumbs up.
Qwark
Member
(10-21-2014, 11:02 PM)
Qwark's Avatar

Originally Posted by Krejlooc

Yes, for the most part, because these are not official tools. There might be some niggles with regards to actually obtaining a license from Sega to develop for the dreamcast because they don't issue licenses in the first place anymore, but they definitely won't bring legal action against you or anything. This is how modern, commercial dreamcast games are made, today.

Awesome, thanks. I was wondering if Pier Solar went this route.
itxaka
Defeatist
(10-21-2014, 11:04 PM)
itxaka's Avatar

Originally Posted by Damaniel

Subscribed! I'm a huge fan of retro development (both on consoles and retro PCs), and while I've dabbled in both NES and GBA development (not to mention my current DOS-era PC development fascination), I've never done Dreamcast development before -- and I wouldn't mind trying.

Interesting. Got any links so a beginner can start looking into this?
Krejlooc
Banned
(10-21-2014, 11:04 PM)

Originally Posted by Qwark

Awesome, thanks. I was wondering if Pier Solar went this route.

I'm not sure if Pier Solar is using KallistiOS, as there are other ways to develop for the dreamcast. But there is a very good chance it is.
The Abominable Snowman
Pure Life tonsil tickle
(10-21-2014, 11:07 PM)
The Abominable Snowman's Avatar
I'm in. Subbed.

Will follow instructions when I get some free time this weekend.
ShutEye
Member
(10-21-2014, 11:16 PM)
ShutEye's Avatar
I read the title as "Lets build a Sega Dreamcast from scratch"

That would be amazing.
Fine Ham Abounds
Member
(10-21-2014, 11:23 PM)
Fine Ham Abounds's Avatar
I cringe when I see another poor soul with an AutoCAD window on their taskbar
Krejlooc
Banned
(10-21-2014, 11:24 PM)

Originally Posted by Fine Ham Abounds

I cringe when I see another poor soul with an AutoCAD window on their taskbar

Autocad is such a useful program, actually.

EDIT: Not for game development, obviously.
b0b
Junior Member
(10-21-2014, 11:26 PM)

Originally Posted by Krejlooc

SDL 2.0 is wonderful, btw. That has nothing to do with DC development, but it's comes such a long way since I first began working with SDL back in 1997.

it is indeed


Originally Posted by itxaka

Interesting. Got any links so a beginner can start looking into this?

http://fabiensanglard.net/

this website is GOLD!

nobody would magically learn programming from it but it's a great resource for ... like ... EVERYTHING!
I found it by searching for quake-sources long time ago. this guy has really great code reviews. stuff like trespasser, quakes, dooms, duke nukem 3d, prince of persia and a bunch of other very interesting stuff.
Timeaisis
(10-21-2014, 11:28 PM)
Timeaisis's Avatar
Holy shit I love this idea.
Krejlooc
Banned
(10-21-2014, 11:30 PM)

Originally Posted by b0b

it is indeed

I saw Ryan Gordon give a lecture over the new features of SDL 2.0 before I began working on it and it was like a dream come true. The sort of modern fresh start SDL has needed for years. I love SDL - it's what I've basically built my career off of - but man the old SDL was so antiquated. Even doing menial things like creating more than 1 window required complex engineering. Now SDL 2.0 makes it easy as pie.

Thread Tools