Jump to content

Photo

bB Tutorial, Session 2


14 replies to this topic

#1 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • 5,558 posts
  • Location:Georgia, USA

Posted Mon Feb 20, 2006 2:22 AM

(I don't know if I should be posting these sessions under the same thread, for now I'll post them as separate threads.)

batari BASIC for Beginners -- Session 2: What You'll Need
---------------------------------------------------------

To program for the Atari 2600 using batari BASIC, you'll need to have the following:

A Computer
----------

Since the batari BASIC compiler actually runs on a computer, you'll obviously need a computer. And since you're reading this tutorial in an online forum, I presume that you already have a computer! However, your computer must use an operating system for which all of the necessary tools are available.

I'm using a computer running Windows XP, and batari BASIC is probably most readily accessible for a Windows computer-- because the Windows executables for batari BASIC are already built when each new version is released-- so for the most part this tutorial assumes that you're using a Windows computer. (By the way, I was still using Windows 95 up until a few months ago, and I was starting to run into compatibility issues with some of the tools, so if you're still using Windows 95, you might want to consider upgrading to at least Windows 98, if not a more recent version like Windows XP.)

If you're using some other operating system-- Mac OS X, Linux, Unix, Amiga, etc.-- you'll probably need to build batari BASIC executables, and possibly executables for some of the other tools, which will run on your system. I encourage anyone using a non-Windows operating system to contribute comments or instructions, and to post any executables that you've had to build, for the benefit of any other readers who are using the same operating system as you.

A Text Editor or IDE
--------------------

You'll need a text editor to write your programs with. Any text editor will do, even a word processor, as long as you save your program source code as a plain ASCII text file so batari BASIC and DASM can read it. Note that all text editors are definitely not equal, so you may already have one that you prefer to use.

If you're using a Windows computer, you can use EDIT.COM, Notepad, or WordPad, all of which are included with Windows. EDIT.COM is the old MS-DOS editor, so it runs from the command prompt (just open a command prompt and type "edit"), and it doesn't look as "pretty" as Notepad or WordPad. However, EDIT.COM lets you edit multiple files at the same time, whereas Notepad and WordPad can work with only one open file at a time. On the other hand, you can always open multiple copies of Notepad or WordPad if you want to edit more than one file at a time. In any case, I suggest that you use EDIT.COM, Notepad, or WordPad only if you have no other options available.

Instead, you are strongly urged to use an IDE ("integrated development environment"), which is simply a special text editor that can be set up to compile and run programs in different programming languages. Again, all IDEs are not equal, and if you're a programmer, you may already have an IDE that you prefer. There are some advanced IDEs that are sold commercially, but unfortunately they tend to be a bit pricey, since they're marketed to professional programmers. There are also some good shareware and freeware IDEs available, although they tend not to be as feature-laden as the upscale commercial IDEs.

In this tutorial, I'll be using Crimson Editor, which is a free IDE for Windows that's available over the internet. In Session 3, I'll show you how to set up Crimson Editor to compile and run batari BASIC and 6502 assembly language programs.

Another option is to use the free 2600IDE program which Jacco Mintjes ("Attendo") created specifically for batari BASIC. Although 2600IDE doesn't have all of the editing capabilities (e.g., search, or search and replace) that are standard with most text editors, it does have a built-in sprite editor and playfield editor, and it's easy to use with the batari BASIC compiler and an Atari 2600 emulator. 2600IDE can also be used to write, compile, and run pure 6502 assembly programs.

Finally, there was an MS-DOS based IDE called ADEV that came in the 2600SDK package, which was a package put together by Matthew Ozor, that used to be available on the DASM web site. The IDE was essentially like the EDIT.COM editor, but it included the ability to compile and run programs. Unfortunately, the link to download the 2600SDK package no longer works. Fortunately, Crimson Editor lets you do everything (and more) that the ADEV IDE let you do. Nevertheless, if you'd like to try the ADEV IDE, I've uploaded a copy of it to the AtariAge website.

Non-Windows users are encouraged to post suggestions for text editors and IDEs that run under their chosen operating systems.

The batari BASIC Package
------------------------

Several versions of batari BASIC have been released-- 0.1, 0.2, 0.3, 0.35, and 0.99. Version 0.35 is the most recent "official" release, and it can be downloaded either from the "semi-official" batari BASIC home page (where the earlier versions of batari BASIC are also available), or from the AtariAge web site. Version 0.99 has been posted on the AtariAge web site as a pre-release "work in progress." Since version 0.99 is currently the "latest and greatest" (pre-)release, that's the version we'll be using in this tutorial. As any newer versions are released, we'll migrate to them.

The batari BASIC package includes a build of the Windows executables, but if you're using a non-Windows and non-DOS system, you'll need to build executables for your system. Brief instructions on how to do that are included in the documentation for batari BASIC.

The DASM Assembler
------------------

Compiling a batari BASIC program is actually a two-step process. First, the batari BASIC program listing must be compiled with the batari BASIC compiler, which converts it into a 6502 assembly language source file. Then this assembly file must be compiled into a binary ROM image file using a 6502 assembler. The batari BASIC compiler creates assembly code which is formatted for the DASM assembler, so it's expected that you'll use that assembler. If you insist on using some other 6502 assembler, you'll need to be sure that it can handle the format used by DASM, or else you'll have to convert the DASM-compatible code to a format that's acceptable to your chosen assembler. Obviously, the preferred course is to just use DASM.

Although the batari BASIC package already includes the Windows build of the DASM assembler, you're encouraged to download and install the DASM package separately, if only for the documentation that comes with it. And if you're using a non-Windows system, then you must download the DASM package separately, because it comes with builds for a variety of operating systems. Consequently, once you've downloaded and installed the DASM package, you might want to delete the versions for operating systems that you aren't using.

An Atari 2600 Emulator
----------------------

Although you can run your Atari 2600 programs on an actual Atari 2600 or 7800 if you have the necessary equipment (e.g., a Supercharger, Cuttle Cart, Cuttle Cart 2, or Krokodile Cartridge, along with any other devices that they require for loading ROM images into them), it will be most convenient to run your programs on an Atari 2600 emulator. There are many such emulators available, for a variety of operating systems, so your choice of emulator will be partly dictated by your operating system, and partly based on your personal preferences (since all emulators are not equal).

For this tutorial, I'll primarily be using the Stella emulator, but I'll occasionally also use the z26 and PCAE emulators, and possibly other emulators as well.

In addition to the preceding required tools, there are some optional items that you're strongly encouraged to obtain:

Programming Documentation for the Atari 2600
--------------------------------------------

There are several documents on the internet that explain the memory map of the Atari 2600, what the different memory locations do and how to use them, etc. If you get only one document, I suggest that it be the "Stella Programmer's Guide," which is available in PDF form. But you may want to search the internet for other documents as well. I'll post a list of documents I'm aware of in Session 3.

A Command Reference for batari BASIC
------------------------------------

Although I'll be giving you information about the batari BASIC language in this tutorial, you'll also want to have one or more references that provide a handy summary of batari BASIC's commands. There are a couple of help files that came with some of the earlier versions of batari BASIC, but the help file hasn't been updated for version 0.99 yet. And there's also a batari BASIC help page that Duane Alan Hahn ("Random Terrain") put together. Having handy summaries such as these will be extremely useful as you learn how to program in batari BASIC.

A Reference for the 6502 Assembly Language
------------------------------------------

You'll want to have one or more references that provide handy summaries of the op codes and addressing modes in the 6502 assembly language, especially tables that list the number of bytes and the number of machine cycles used by each op code in its various addressing modes. Programming for the Atari 2600 is very different from programming for a computer like the Atari 800, because on the Atari 2600 you must control the way each scan line is drawn on the TV screen. Furthermore, the Atari 2600's processor is slow (e.g., it's only two-thirds as fast as the Atari 800's processor, and the Atari 800 isn't very fast, either), which means you often end up "chasing the raster beam," or trying to perform certain tasks-- like changing colors or modifying the data for the players and playfield registers-- before it's time for them to be drawn on the scan line. Also, the Atari 2600 is limited to only 4K of cartridge ROM (although bankswitching allows this to be stretched to 8K, 12K, 16K, etc.), so Atari 2600 programmers generally try to find ways to squeeze their code into the smallest possible space. Thus, the number of machine cycles and the number of bytes used by the various 6502 assembly instructions will often be critical to know.

A Loose-Leaf Binder
-------------------

Even though you can download a lot of tutorials and documentation to your computer, and view it onscreen, it's very helpful to be able to leaf through this information in printed form. Thus, it's a good idea to print out these documents and put them in a loose-leaf binder for easy access, with tabbed separator pages to help you quickly flip to the specific document that you're interested in.

You can also put blank sheets of lined notebook paper in the binder, so you can keep notes about game ideas; insights you've gained into an Atari 2600 memory location, 6502 assembly instruction, or batari BASIC command; scratch calculations for memory usage or cycle counts related to a game you're working on; etc.

Graphing Paper and Colored Pens or Pencils
------------------------------------------

You may also want to put blank sheets of graphing paper in the binder, to help you can draw ideas for game screens, playfield designs, player shapes, etc.

And for this, you might want to buy a selection of colored pencils or felt-tip pens, so you can sketch your ideas in color.

A Paint Program
---------------

In addition to (or perhaps instead of) drawing things on paper, you might want to use a paint program to help you design game screens on your computer. Windows comes with a Paint program, but you might have another graphics software program that you prefer. Sometimes you may want to do emulator screen captures of a game you're working on, and load it into a graphics program for inspection or editing, so it's a good idea to use a graphics program that can handle different types of graphics file formats.

An Advanced Calculator
----------------------

You will frequently find it helpful or necessary to convert between decimal, hexadecimal, and binary number bases, or perform calculations in these number bases. Windows comes with a Calculator program that can be switched to "Scientific" view for such things, but you might also want to get a pocket calculator that can do operations in hexadecimal, and that can convert numbers from decimal to hexadecimal or binary and vice versa.

A File Comparison Utility
-------------------------

When you're working on a game, you might have several different copies of the game where you've tried out different things. In that case, you may find it helpful to be able to quickly compare two files and see where they're different. Windows has a file comparison command, but there are some free file comparison utilities available on the internet that you might want to look into. Also, many of the more up-scale IDEs have built-in file comparison functions, so if you're using a fancy commercial IDE, you might not need to find a separate file comparison utility. In Session 3, I'll show you how to integrate a free file comparison utility with the free Crimson Editor IDE.

A 6502 Disassembler
-------------------

You may occasionally find it very helpful to disassemble a game that someone else wrote, to see how they did something. There are some commented disassemblies of several Atari 2600 games on the internet, but you might have to disassemble a game yourself. There are two 6502 disassemblers which were specifically designed for disassembling Atari games-- Distella for the 2600 and 7800, and DIS6502 for the 8-bit Atari computers (although with the proper equates file, DIS6502 can also be used to disassemble games for the Atari 2600).

A File Splitter
---------------

The Distella disassembler can't disassemble ROMs that are larger than 4K, so if you want to disassemble a game that uses bankswitching, you'll first need to split the ROM into two or more 4K segments. I've written a Windows utility program that can do this.

A Hacking Utility
-----------------

Finally, you might find it helpful to look at a game ROM with some sort of hacking utility, because such utilities generally display the ROM data in a format that makes it easy to find the player shapes. On the other hand, game graphics are usually considered to be protected by copyright, so you need to be careful and considerate when looking at the player graphics used in someone else's game.

In Session 3, I'll discuss ways to organize everything on your system, and help you get all of the required or optional tools downloaded and installed on your computer.

Michael Rideout

#2 gambler172 OFFLINE  

gambler172

    River Patroller

  • 2,999 posts
  • none
  • Location:germany

Posted Fri Feb 24, 2006 3:19 PM

Hi Michael
great work,that is what i need.
greetings Gambler172

#3 atwwong OFFLINE  

atwwong

    Stargunner

  • 1,165 posts
  • Haunted Adventurer
  • Location:Vancouver

Posted Sat Feb 25, 2006 1:05 PM

(I don't know if I should be posting these sessions under the same thread, for now I'll post them as separate threads.)

Thanks, Michael; I like them as separate threads. It will make things easier to find later, rather than scrolling through one huge thread, as long as your keep up your great tutorials! :thumbsup: Maybe I'll be able to make an honest-to-goodness bB Homebrew. :)
Cheers,
Tony

#4 RedBeard OFFLINE  

RedBeard

    Chopper Commander

  • 179 posts
  • Location:Oregon, USA

Posted Fri Mar 24, 2006 11:12 PM

SeaGtGruff:
1) Please tell me how do you pronounce SeaGtGruff? Is it "see - gt - gruf" or "see - seargeant - gruf' or "seaagut - grif" or what? (Is it a play on seargent? You're military? (y: I salute you, n: maybe we should join...)) or maybe "goat" implications? a'la' Jeff "Yak" Minter? Just wondering...

B) Please, please, please, keep up the tutorials! Seriously, even if they're half-a-tutorial at a time, just
do it, please. If there is anything I can do to help, just let me know. I type, maybe, ten words a minute. I know a (tiny) bit of JAVA programming. Just let me know...

><> RedBeard

P.S. I really do want to (finally) program a VCS game... :roll:

#5 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • Topic Starter
  • 5,558 posts
  • Location:Georgia, USA

Posted Sat Mar 25, 2006 4:15 AM

SeaGtGruff:
1) Please tell me how do you pronounce SeaGtGruff? Is it "see - gt - gruf" or "see - seargeant - gruf' or "seaagut - grif" or what? (Is it a play on seargent? You're military? (y: I salute you, n: maybe we should join...)) or maybe "goat" implications? a'la' Jeff "Yak" Minter? Just wondering...


It's a pun, a combination of "Sea Goat" (because I'm a Capricorn) and "Billy Goats Gruff" (because one day when I was being grouchy, my mother said, "I declare, you can be so *gruff* at times," and I immediately thought of the name "Sea Goat Gruff"). When I joined AOL back in 1995, there was a 10-character restriction on the AOL screen names at that time, so I abbreviated "Goat" to "Gt" and left out the spaces, hence I capitalized the S, G, and G to help indicate that they're the beginnings of separate words.

B) Please, please, please, keep up the tutorials! Seriously, even if they're half-a-tutorial at a time, just
do it, please. If there is anything I can do to help, just let me know. I type, maybe, ten words a minute. I know a (tiny) bit of JAVA programming. Just let me know...

><> RedBeard

P.S. I really do want to (finally) program a VCS game... :roll:


I have the next several installments planned out, but I got hung up on the third installment, which is a pretty good indication that I need to simplify things more, plus I need to stop playing games (I'm addicted to "Millipede" and "Well of Souls" right now). My current session plan is as follows:

Session 3 - Getting Set Up (installing batari BASIC, DASM, Crimson Editor, Stella, etc.)
Session 4 - The TV Picture (a brief description of how the TV fields and frames are drawn)
Session 5 - The Atari's Features (an overview of the 2600's graphics features, what it can do)
Session 6 - The Atari's Memory Map (an outline of the 2600's memory organization and mirroring)
Session 7 - Designing a Game (some comments about planning a game)
Session 8 - The Programming Statements (an overview of batari BASIC and 6502 assembly)
Session 9 - Writing a Program (an overview of coding rules and programming structures)
Session 10 - Video Blanking, the Background, Colors, and Kernels (first actual programming lesson, how to do a simple kernel loop in assembly, how to choose and set the colors)
Session 11 - The Playfield, the Ball, and Collisions (drawing and controlling the playfield and ball, detecting and processing collisions)
Session 12 - The Console Switches and Game Controllers (reading/processing the console switches, the joysticks, the paddles, etc.)
Session 13 - The Players and Missiles (drawing and controlling the players and missiles)
Session 14 - The Timer (setting/reading/processing the timer)
Session 15 - Sounds (creating sounds)

I know the title is "batari BASIC for Beginners," but I want to include assembly programming at the same time, because it's very easy to include in-line assembly within a batari BASIC program, and there's a lot of things you really can't do in batari BASIC unless you use assembly to do it. So I want to give an overview of the kinds of things you really need to know for 2600 assembly programming-- how a TV picture is drawn, how a game's display kernel controls that, etc. And I want to post the next several sessions in groups. Ideally, I should have posted 1, 2, and 3 at once, and then I could do the other sessions in threes as well-- 4, 5, and 6, then 7, 8, and 9, etc. And my current outline is subject to change based on feedback and what people want or need. I'm trying to get 3, 4, 5, and 6 posted this weekend to get me back on track.

Michael Rideout

#6 atwwong OFFLINE  

atwwong

    Stargunner

  • 1,165 posts
  • Haunted Adventurer
  • Location:Vancouver

Posted Sat Mar 25, 2006 5:39 PM

Multiple sessions posted in one weekend?! Anything you post will be greatly appreciated by us "newbies" :D

#7 gambler172 OFFLINE  

gambler172

    River Patroller

  • 2,999 posts
  • none
  • Location:germany

Posted Sun Mar 26, 2006 10:31 AM

Hi Michael
i am waitnig for session 3.Hope it will be posted soon.
greetings Gambler172

#8 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • Topic Starter
  • 5,558 posts
  • Location:Georgia, USA

Posted Wed Mar 29, 2006 1:33 AM

Hi Michael
i am waitnig for session 3.Hope it will be posted soon.
greetings Gambler172


I apologize, I thought I was going to get it posted this past weekend, but then I spent Saturday, Sunday, and Monday in bed with a fever and a headache. I finished Session 3 tonight, and I hope the installation instructions in it are okay. :)

Michael Rideout

#9 Brad2600 OFFLINE  

Brad2600

    Quadrunner

  • 24,871 posts
  • Formerly known as Kepone, 2002-2012
  • Location:South Burlington, VT

Posted Fri Apr 14, 2006 12:43 PM

I tried to get into Bb last year but I dropped out because it became too difficult to understand.

Would love to give it another shot though. A good tutorial can go a long way for some.

#10 kamakazi OFFLINE  

kamakazi

    Dragonstomper

  • 530 posts
  • Location:Moberly, Missouri

Posted Sun Feb 28, 2010 5:12 AM

I'm liking this so far...

#11 freshbrood OFFLINE  

freshbrood

    Space Invader

  • 43 posts

Posted Sat Oct 31, 2015 5:00 PM

Where did these tutorials ever go?



#12 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 10,948 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sat Oct 31, 2015 5:11 PM

Where did these tutorials ever go?

 
With your "early VCS" goal, consider going the assembly language route.  See my blog series Collect for a tutorial on writing a 2K game. as well as Easy 6502, a nice online tutorial for learning 6502 code.



#13 freshbrood OFFLINE  

freshbrood

    Space Invader

  • 43 posts

Posted Sat Oct 31, 2015 5:55 PM

I will look into it, thanks Spice! 



#14 freshbrood OFFLINE  

freshbrood

    Space Invader

  • 43 posts

Posted Sat Oct 31, 2015 5:59 PM

Whoa Spice, it's very well written, thank you! I might just start from scratch there!



#15 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 10,948 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sat Oct 31, 2015 7:37 PM

Thanks!  If you have any questions just post a comment in the appropriate blog entry.  I'll answer soon as I can, though I've a lot going on the next few weeks so it might not be right away.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users