Thursday, May 26, 2011

A follow up to the previous questions...

Hi Beth,

Wow, you presented that information like Bam, Bam, and BAM!!   I love it!!!  

To the point, very detailed, awesome!! You’re incredible with this stuff.

You know the weird thing about it; I think I'm actually getting it! The more I read on this stuff, "and boy am I cramming this stuff in" the more it starts to make sense!   Slowly... Yes, but it's starting to make sense.

I lucked out because one of the Assembler books I have is an exercise book that uses examples from the DOS TOOL KIT exclusively, which I was able to get a working copy of.  This is perfect and I have been able to do a couple of the exercises and they have successfully run through the assembler!  Yippee!!!

Boy, you really have me thinking about what you just sent me and since it is very detailed I will be chewing on this for a while. Also, the testing and examples I get to do are perfect! This is what is going to make it all come together for me. I need to program it, process it, and see it function! Pretty soon a light bulb is going to go off and then explode with all the realization that is going to rush in.

I just have one question so far:
I know that you talk about a normal tile with a pixel range of 7x8, which is basically the area that all the books talk about, but how do I do this for groups of tiles that form one large tile? Since the tiles in Ultima 1 are 14x16, should I just rethink all the info you gave me and do everything in a 2x2 format? What I mean is, since a tile in Ultima is made up of 4 - 7x8 tiles, at least I think this is how they did it, should I just rethink the process you gave below and work it so I'm using two tiles next to each other and scroll by [2] UP/DOWN/LEFT/RIGHT?  

I hope I'm saying this correctly but I think you know what I mean.

I will first practice through the info you gave me and get it to a working model with just 1- 7x8 tile, then see if I can move groups of 4 [2x2] tiles.

Thanks so much for all of your help! You are a godsend!

Your gracious grass-hopper,

Joe
Joe,

I’m glad to hear you’re making progress! Keep it up, that’s very cool.

You’re exactly on the right path with the 1x1 vs. 2x2 tiles. It’s easy to subdivide the screen into 1x1, 2x2,  or even 4x4 groupings. Ultima used 2x2 groupings.

Doing a 2x2 is just an extension of 1x1. Instead of 7x8 (8 bytes) your tiles are 14x16 (32 bytes) in size. You end up copying two bytes into each row, then incrementing down, copying the next two, etc. And you do that for 16 rows instead of 8 rows. Otherwise, it’s exactly the same idea.

From the perspective of your program, you might as well treat a graphical 2x2 region as a single “game tile”. Don’t get hung up on trying to make the game understand that each tile is actually a 2x2 set of smaller regions – leave that part for the graphic engine drawing to handle. You just tell it “put a mountain at 1,3 and another at 2,7” and let it handle positioning to the rows you want and drawing the larger tiles as though they were single things. (e.g. the graphic engine would know to multiply all passed x,y tile coordinates by 2, so internally it’ll translate 1,3 to the smaller 2,6 boundaries, then do a 14x16 pixel copy at that location. The game engine never needs to know those internal details.)

Good luck!

-          Beth

More great info from Beth!!

Hello everyone, 
I was able to get a hold of Beth again and ask her some more questions and she graciously responded with the following:
___________________________________________
Hi Beth, 

I was able to get my hands on a copy of DOS Tool Kit for the Apple II, which is the Apple 6502 Assembler/Editor.  Now that I have an assembler I will able to start figuring out how to write some assembly code.  I know this will take a while but I have start somewhere right? 
Question:  The memory address region for the Apple IIe with regard to Hi-Res page 1 is $2000 to $3FFF.   

Is this to say that the range from $2000 to $3FFF is each individual pixel on the screen?   
This seems too big because I have another chart that shows the entire screen layout and it starts at $2000 at the upper left corner then goes to $23D0 at the bottom left, but across the top it shows $00 to $27, which I assume are each byte width from 0 to 39!   

If this is the case, then would the actual memory graphics range be $2000 to $23F7 that reprents a pixel on the screen? 

I’ve done a lot of playing around with the poking dots on the screen using the 8192 value. I have even used the DRAW command and placed shapes on the screen using the same 8192 values.  But from what I’m learning about Assembly I don’t think I get how you would place a character or a shape directly into a memory location. 

I know that you can poke to a specific address in TEXT mode like “POKE 1024,01 and you would end up poking the ascII value of the letter A on the screen at the 0,0 address location.  With this process I think I can figure out that if I created a new set of characters using a character generator I could replace all of the ascII characters that I wouldn’t use in the game, such as all the lower case characters or Inverse character!  With all these new ASCII characters, which would be representing all the tiles on the map, I could do everything in TEXT mode instead of Hi-Res graphics mode.  Maybe….   Since each ASCII character is made up of a byte of information I understand that this byte could be loaded using the ADL command and moved into a memory location by moving from the accumulator to a memory region in the TEXT mode, which is $400 to $7F7 if I use the same memory value logic.   

Is this correct?? 

Now if I still want to use the Hi-Res page 1 graphics mode, which is range $2000 to $23F7, “I think”, then I would need to figure out how to use assembly code to place the same ASCII character into a memory region OR place a shape into a memory location.  Placing a shape into memory is beyond me because a shape is created using more than one byte of information.  I know that when a shape is created it is placed in a shape table which has a starting location for shape 0 then it has another starting location for shape 1, and so on…   There seems to be multiple bytes of information that make up the entire shape table.   

Another question:  You know how when you create a shape table they give you an address where the table is loaded such as; PRINT CHR$(4) “BLOAD SHAPES, A16384” 

The A16384 is the starting location of the entire shape table but what is this value A16384?  Is this a DEC memory location and does this equates to $4000 in Hex?  How do you equate this value A16384 into the memory locations they are in?  I realize that if you have let’s say 50 shapes, all these shapes would start somewhere and take up a range of memory locations right? 

The reason I gave you the value A16384 is because the program “The Complete Graphics System”, which I use to create the shapes, always uses the starting location address of A16384 and says the table will end no further than location 28499.   

Would you use assembly code to grab each byte range that make up the shapes and place them in a memory location on the Hi-Res screen? 
I don’t mean to blast you with a bunch of questions but I feel as though my brain is very close to having a “light bulb moment” and some factors are keeping it from happening.  I feel like I’m close to really understanding this but there are some issues that seem to elude me… if you know what I mean? 
Thanks for any help you can give. 
Sincerely, 
Joe
______________________________
Joseph, 

Okay, first things first. Forget about the using Text mode. And forget about shape tables. Those are both dead-ends. Yes, you can accomplish things with them, yes you could get tiles to draw with either one. I wrote applications in basic using both and completed full little games – but the speed wasn’t there. If you want to really do this, you simply need to copy from your in-memory tiles to the on-screen part of memory.

For a discussion on the insanity that was the Apple 2 hi-res graphics memory layout, here’s a link:


Specifically, start in from “Hands-On Practice with Standard Hi-Res”
That gives you the addresses of the tile “boxes” you want on the screen. There are 40 across at 7 pixels wide and 24 high at 8 pixels each. 
Specifically, start in from “Hands-On Practice with Standard Hi-Res”

You should play around with pushing bits as it calls out, e.g. 2028:1, until you understand how to put pixels into each tile. You can make yourself a chart with all the tile addresses, even.  

One of the crazy things to remember is that the memory is interleaved. So your vertical lines are organized like so: 

$2000,  (Line 0)
$2400,
$2800, (Line 2)
$2C00,
$3000, (Line 4)
$3400,
$3800, (Line 6)
$3C00,
$2080, (Line 8)
$2480,
$2880, (Line 10)
$2C80,
$3080 (Line 12)
Etc.

Don’t feel bad about this – the memory isn’t laid out simply. It’s got a pattern that makes sense, but it was designed the way it was because of the crazy hardware in that box. 

Okay…if you played around with pushing enough bits you should get the idea. Now I’m going to assume you have a good idea of: 
1.       Where each of the tiles start 
2.       What bits make which colors for each address. 

Now you want to copy using Assembly. What you do is to put shapes into memory in the exact same way you want them to appear on the screen. Those will be your tiles. And by having the tiles existing at one place in memory, you can copy that memory multiple times onto the screen to have it draw multiple tiles. So you store your mountains once, off the screen, and then fill in each graphic mountain tile as many times as necessary. 

For the sake of example, I’m going to say you have a tile in memory at $1000. This “tile” is the same size as a tile on the screen, so it’s 7 pixels wide by 8 rows tall. A description of this tile might be as such: 

$1000: 0x7F 
$1001: 0x03   
$1002: 0x44  
$1003: 0x72  
$1004: 0x01  
$1005: 0x1B  
$1006: 0x68  
$1007: 0x10 
Now you need to copy those bits to where you want on the screen. Let’s say you want to put it at the tile at memory address $2000 and the tile at $2100. Conceptually, you want to copy like so: 

$1000 -> copy to -> $2000             $1000 -> copy to -> $2100 
$1001 -> copy to -> $2400             $1001 -> copy to -> $2500 
$1002 -> copy to -> $2800             $1002 -> copy to -> $2900 
Etc. 

Another link, of 6502, is here: 
You should scroll about halfway down to the section on “Instruction Set By Purpose”. For copying, you want to pay close attention to the Accumulator and Index instructions. There’s a lot of other great how-to info on this page as well, you should really check out everything in the “By Purpose” section.

On the Apple II you have 3 “registers” which you can use. This keeps things nice and simple. They are A, X, and Y. (Accumulator, X & Y indexes). You can load them from memory, do comparisons and math based on them, and store them back to memory. 

So…conceptually, you want to do something like: 

1.       Read from $1000 into the Accumulator. This stores 0x7F in the Accumulator. 
2.       Store the value in the Accumulator into memory at $2000. This stores 0x7F into $2000. 

The instructions for doing this would be like so: 

1.       LDA $1000                           (LDA as in “Load A” or “Load Accumulator”) 
2.       STA $2000                            (STA as in “Store A” or “Store Accumulator”) 

From there, the next step is to create a loop that runs through your bytes and copies them. I’m not going to try to write out that loop for you in detail (I sent you the “copy memory” link separately, as I recall) but conceptually, you could do something like this: 
1.       Loop through your read memory 8 times, grabbing each byte sequentially. 
2.       Loop through the write address 8 times, storing the value and incrementing the address by $400 for each byte (thus copying down the vertical row). 
  
You could implement this like so (this is assembly-esque pseudo-code ymmv):

  
1.       Put the source address ($1000) in X         (done as two operations so it can be stored in zero-page)
2.       Put the dest address ($2000) in Y              (as above) 
3.       STX, $A5 
4.       STX, $A6                                                              (This puts 0x1000 into zero-page address $A5 & $A6) 
5.       STY, $A7                                                               (This puts 0x2000 into zero-page address $A7 & $A8) 
6.       STY, $A8 
7.       LDX #$00                                                              (set X to 0) 
8.       LDY #$20                                                              (set Y to 0x20 – the value in $A7) 
9.       LDA  ($A5, X)                                                      (this is “indirect addressing” and is now the same as LDA $1000) 
10.   STA  $A7                                                               (same as STA $2000) 
11.   INX                                                                         (“increment x” -  x is now equal to 1) 
12.   INY                                                                         (do this 4 times – you could also do this by adding 0x04 to Y) 
13.   STY $A7                                                                (this stores 0x24 into $A7) 
14.   LDA ($A5, X)                                                       (this is now the same as LDA $1001) 
15.   STA $A7                                                                (this is now the same as STA $2400) 
16.   Etc… 
  
You can be clever with loops and such, different addressing modes, etc. It just depends on how you want to layout your memory and what makes the most sense to you.   
  
I hope that helps! 
  
-          Beth

Ok, Let me rephrase....

Ok everyone,
I might have been a little hasty when I told you Assembly Language is your friend!  Assembler/Editor is not really your friend!  It’s more like an old high school friend that actually wasn't your friend and ended up stealing your girlfriend and taking her to prom!!  Ok, I think you get idea...  Assembly Language is incredibly unforgiving and hard to figure out, it’s like trying to learn hieroglyphics... no, it’s like trying to learn Egyptian Hieroglyphics!  It is so different than anything I have ever tried to learn in such a short time that I can feel my head start to swell.  Don’t get me wrong, I still love it but it’s going to be a challenge.  I think I saw a quote somewhere that said, “I would rather go through med school than learn to program in Assembly language!”  Boy, that’s encouraging!  At least one nice thing about learning a new language is that there are a lot of resources out there.  Like Beth, if I was to name a main one!  You can find a bunch of books on programming Assembly Language through eBay, Amazon, and Google but you have to really look hard.  Plus, you have to know what you are looking for, there are a lot of books out there but they’re not all great!  Believe me, I have a few bombs in my collection and that also goes for Applesoft Basic and Apple Graphics books.
A couple of great resources I found on Amazon.com were two Assembler Language books.  I have other really good books but these two are going to be essential when it comes time to getting Ultima 1 Revisited up and running.
The books are:
1.    Hi-Res Graphics and Animation using Assembly Language – Leonard Malkin PhD
2.    Apple II Assembly Language Exercises – Leo J. Scanlon
I think these two books are going to be excellent sources of information concerning leaning to code in assembly language and putting graphics on the screen.  Already, I can tell that Leonard Malkin’s book is going to be perfect!  I will be reviewing these two books later and posting the reviews.
One of the great things about Leo Scanlon’s book is it’s written entirely around the Apple DOS TOOL KIT Assembler Editor!  His exercises were written and tested using this exact software application so you have a direct resource into programming with the DOS TOOL KIT.  Believe me; this is critical because the documentation that comes with the Assembler/Editor has no example code what so ever!  The manual only covers definitions and verbiage.   I could not find anything on programming with the DOS TOOL KIT until I found this book.   I literally spent the better part of two days just getting error statements when I tried to enter a simple sample code!  You cannot believe who frustrating it is to enter a command and immediately get an error, over and over and OVER again!  This was mind numbing!  Finally I had a light bulb moment “after rereading the manual eight times!” and something clicked, after that it all started to become clear.  Then, once I received the Exercise book it REALLY became clear and I was able to enter some sample codes that would run through the assembler successfully.  Hoo-rah!
This brings me to my next point…  Everyone who is following this blog should be able to find a good Apple II emulator on the internet and also the .dsk image of the Apple DOS TOOL KIT.  I’ve tested both of these applications and they work fine, they are little hard to get use to but they will work.  With these two applications you should be able to follow along with me when I start posting code and examples.  I highly recommend you get these two applications and get them ready to start programming.  I will try to give as much insight into the process as I can just to make it easier.  My goal is not to make everyone an Assembly Language programmer; no… my goal is to make available all the Applesoft Basic and Assembly code so everyone can program their own copy of Ultima 1 Revisited!!!
So stay tuned and get ready!
Joe

Sunday, May 22, 2011

Apple 6502 Assembler Editor is your friend!!!


Ok everyone, I just couldn't wait... I had to give a little update on what I just received in the mail on Saturday! My package came and boy was I jazzed! I had just received my Apple 6502 Assembler/Editor disk and manuals. You may be saying to yourself, "God, What a geek!" but if you understood the gravity of this package you would realize that this is one of the main components in reaching my goal of recreating the original Ultima 1 program!  

After gaining some true insight into the glory days of programming the apple IIe computer, I found that no game worth its weight was ever programmed without some form of assembly coding. That is to say, any game that relied on speed as a factor in its operations was definitely programmed using some form of Machine Language.

As of today, the only Assembly editors I've heard of so far are: Merlin, Big Mac, LISA "pronounced "Lee-Za", and the Apple Dos Tool Kit, which is what I just received. There are probably many more out there but these seem to be the ones that were used when they programed games on the apple II.

Now the reason I'm so excited is because the Apple II series of computers only came with Integer Basic or Applesoft basic.  The Assembler Editor was a separate package that had to be purchased and back then this package was expensive!!!  The key word here is “purchased”, since we are talking about a software application that is over 25 years old, there aren’t too many packages available for sale in 2011! Actually, I haven’t been able to find ANY Apple II assembler editor for sale until now.  Well, at least I didn’t have to pay the hundreds or thousands of dollars that it would have cost if I bought it in 1980!  I know I could have figured out some way to convert the .dsk files that are available for the Apple II emulator but I’m not going to do this for three reasons: 

1. I don’t know how to do this! 

2. I’m going to recreate the original Ultima 1 program on an original Apple IIe computer just like Richard Garriott did way back in 1980, so I need an actual, physical program to do this!

3.  I want the process to be completely legal and as if I was in 1980 so all the books I’m reading are the real thing, all the programs I’m using are ones I’ve already had or have purchased on eBay, and the Assembly Editor I’m going to use was also purchased and is a legitimate working program for my Apple IIe computer!

With this purchase of the Apple 6502 Assembly Editor I now have the ability to start programming in Machine Language!  This is instrumental because without this program my dream is dead!  It would stop right here and we would probably never know how the original Ultima 1 was ever programmed.  This is going to happen!  I am going to figure out how to program Ultima 1 and then make it available to everyone!  It’s kind of corny to say but this is a bucket list item for me and I plan on making it happen.

So, to recap, I will be programming on an original Apple IIe computer, I know own a legal copy of Apple 6502 Assembler/Editor, and I own a number of really good Assembly language programming books to get me started in the right direction.  With a little time and a lot of effort I will be giving you all some examples of code and some screen shots of Ultima 1 revisited!

Stay tuned, it can only get better!  Hehehe

P.S.  Don’t worry, I will still be posting book and software reviews while learning the magical language of Assembly!

Friday, May 20, 2011

Book Review - How to write an Apple program - Vol.1

It's book review time again and I wanted to talk about one of the BASIC programming books I recently finished reading.  The book is called “How to write an apple program” by Ed Faulk. This is an old school programming book, which gives more theory than examples.  This is the type of book you read when you want to learn the formal structure of how to write a basic program.  It does a lot of explaining through text and uses lots of verbiage to gets its point across.  Some newer programmers are not going to like the slow, methodical pace of this book because it takes it's time in presenting the subject matter and gives you an in-depth approach to each topic, yet lacks extensive code examples.

The book contains 13 chapters and you literally don't program a single piece of code till the middle of the 5th chapter!  That is how deep the text is in this book. 

The topics covered in the book are as follows:
            Ideas - Idea categories
            Where to get ideas
            Combining ideas
            Planning the Program
            Program Function
            Program Overview
            Designing the Program
            Flowcharts
            Pseudo-code
            Coding the Program
            Modular Coding Techniques
            Structured Approaches
            Testing/Debugging
            Approaches to testing
            Fixing Bugs the easy way
            The end of the journey
            Readable documentation
            Eqilogue

The book's pages are not numbered like a normal book, they are sectioned out like a manual with 1-1 and 2-3 as examples.

I do have to say, I did like reading this book only because it was like reading a story, you feel as if you are part of a programming adventure and the book is taking you on that adventure.  It can get a little frustrating to have such small amounts of programming code to work with but the theory is excellent.  Also, the chapters on Flowcharting are really good because they explain the true process of how a program should function and flow.  You get a better understanding of what you are trying to do when you create a working flowchart.  This too is old school programming at its best.

The function of this book is to get you to understand the program writing process and what is needed to create a working program straight off the bat.  When you learn to first plan out your steps and then design your flowchart, followed with a structured program code base, you know your program is going to work the first time!

The code examples given are not exceptionally hard to understand and they are fun to test.  The book also has a lot of illustrations but they too are of an older style and tend to give it that corny 60's feel. 
At the end of the book there is a Checkbook program written in modular form and structured form!
As I said before, there are not a lot of examples and you will be reading each chapter as opposed to writing programs and testing them.
This book is not for everyone and if you have any knowledge with basic programming I would stay clear of this book.  This book is for the true beginner and programmers who want to enjoy a readable book with more theory and story then code.   You will get a better feel for how to program the correct way and it does do a good job of teaching you all the basic fundamentals of programming an apple computer in basic!

If you find it for less than $10 it's an ok read.

Price  - N/A

Date: 1982

Rating is on a 1 to 10 scale with 10 being the highest.
Depth  - 9
Programming – 3
Sample codes - 2
Quality – 7
Bulk - 7
Information – 8
Humor – 6

Overall rating –6 

Monday, May 16, 2011

A REVELATION and her name is Beth!

Hello everyone,
Ok, time for some schooling and I mean at the graduate level!  I was lucky enough to come across someone who is and has had computer experience with the apple and programming in Assembly!  That's right boys and girls, Assembly language is Machine Language and this is how the tile graphics were programmed in Ultima 1.  It would seem that Richard programmed all of the none-essential code in Applesoft basic, such as the menu system, combat, etc; plus the town and castle activities.  The bulk of the map graphics were done in Assembly!  I'm becoming more informed of just how important it is to understand Assembly language to program anything fast on the Apple IIe!
First let me explain how this all came about...  I was starting to go in a wrong direction with regard to the tile graphics, unbeknownst to me!  Due to this path I was producing more and more questions for myself that didn't seem to have any answers.  So, off to the web I went looking for someone who knew the answers and boy was that the best thing I could have ever done.
I came across an interesting website based on one of my questions, the website is:
When you hit the main website, go to the web link under Elizabeth Daggert's name!
Check it out!!
This woman actually received a letter from the man himself, "Richard Garriott"!  Incredible!!  Take a look at it on her website!  This is a part of history!!!
But I digress, she was gracious enough to respond to my initial questions and give me a little background.  When I bombarded her with more questions, she was very patient and understanding, giving me as much detail as she could remember; this is 20 year old info after all! 
She is very knowledgeable in programming and computers with emphasis on programming. 
What follows is a back and forth, question and answers session between Beth and myself.  Please read it all because IT IS GOLD!

Hello,

I'm currently working on a project to revisit the Ultima 1 game and try to program the entire game again from scratch using my apple IIe computer.
I noticed you have had experience with Richard and a game programmed similar to the Ultima game.
How did you do this? How did you program the way the tiles move so smooth and fast?
Do you have any code for the apple I could take a look at? 
I am stuck and I can't seem to find any information on how this was done. 
Looking for help on how to program the way the map tiles moved vertical and horizontal fast and smooth.
Thanks
Joe


Joe, 
  
Hi there! Thanks for your interest. That’s a good challenge you’ve set yourself. 
  
Well, I’d have to dig around for the code myself at this point – I’m sure I’ve got a bunch but it would take some effort on my part to extract it and get it to you. 
  
I don’t know how deep you’re into this problem, so forgive me if I spell out anything you already know. 
  
·         You need to write it in assembly. There’s no other way for it to be fast enough. 
·         You will be writing directly to the video memory. 
·         You need to be very aware of what bytes cause which colors to appear on screen. As I recall every byte made 7 possible pixels in a row, though in reality that was less based on whether you were on green/purple or blue/orange columns.  
·         Tiles are one byte wide and 8 bytes high. This gives about 7x8 pixel tiles, 8 bytes, written vertically into video memory at the correct tile location. I’m trying to remember if I made bigger tiles (e.g. 14x14 or somesuch) but as I recall I settled on the 7x8 thing. 
·         You will store each tile in non-video memory as a “shape”. So, let’s say “0” is water, “1” is land, “2” is trees, “3” is mountains, etc. You then build a [ X ][ Y ] world map of your tiles, like so: 
  
0              1              0              3              0              0 
1              1              0              2              1              0
1              0              0              3              3              0
0              0              0              1              1              1
0              0              1              0              0              0              …etc

·         You then know the address of each [ x ][ y ] tile in absolute video memory. On the video update, you copy from the in-system-memory 8 bytes to the relevant tile-display address in video memory.
·         You should wait for the VBI (Vertical Blank Interval) to update video memory. I forget how to do that on the Apple II, but basically you want to only update video memory when the video raster scanner is moving instead of drawing. There’s a memory address you can watch for that. This will insure that your video updates are “smooth” instead of “tearing”.
·         When the player moves, you update the master grid by introducing a new row or column on one side of the grid while removing the old one from the other. Then redraw.

At one point I built tools for dumping the byte-codes of the shapes as well as building out the maps. A “tile editor” and a “map editor”. You may want to do the same – and it may well be easier to code those in a friendly language other than 6502 assembly and then simply copy your binary data to the Apple for actual testing.

Best of luck, I hope that’s some helpful starting info!
Beth

Hello Beth,
 That is probably the most in-depth amount of information regarding the Ultima Tile Graphics subject I've been able to find anywhere on the internet!!  I'm totally amazed that no one has writing a tutorial on how Ultima 1 tile graphics were programmed and executed.  It is as if it's a mystery or secret that no one ever found out how to do or no one knows how to program.  I just can't believe that for a game that is almost 30 years old, the process of showing how to write this type of game is still a mystery!  Truly amazing! 
 I hope to change all that!!
 Thanks!!!
 First, let me give you some info to see if we are still on the same page.
1.  I read that Richard Garriott programmed the entire Ultima 1 thru 3 games in Applesoft basic and machine language.  I need to be able to follow this format.  He didn't use Assembly so I need to figure out how to do it in these two formats.
 [Beth] – okay. Assembly is “machine language”. It was 6502 machine code. Assembly was the only way to make anything fast enough graphically to have a game on the Apple II. Basic is really, really, really slow and its uses are very limited.
Here’s what you’re going to need:
1.     Get yourself a 6502 chart. You can learn every instruction, I still have a poster on the wall that has them all. There aren’t that many. Beagle Brothers had an excellent chart at one point…
2.        here it is: http://beagle.applearchives.com/the_posters/ 
Also, check out the links on that page, there might be some other good guides.
2.       You need to familiarize yourself with a “Memory Map” of the Apple II. That will answer many of your questions.
                The reason this is important is so that you understand where to put your program in memory, where the graphics memory is, etc.
3.       Here’s the Apple II RedBook, which is a good resource on a variety of topics:

4.       Get yourself an Assembler. I preferred a program called “Merlin”.  I didn’t dig too deeply but here’s a site where somebody is talking about using it in 2008, so it’s got to be out there, looks like there’s a bunch more resources at this site as well:

The only reason you use Basic is for things that don’t need to be fast. I got to where I did everything in 6502. At the very least, your graphics MUST be done in Assembly.
 3. I've done some test example with 2-dimension arrays to layout the 200 "shapes" /graphic tiles but as you said, this is incredibly slow using basic.  You actually see each tiles get laid down on the screen one by one using a loop!  Bad!
 [Beth] – I remember starting that way as well. Yes, you can’t do anything fast in basic. It’s good for learning, but don’t bother for real.
5. So now I'm at a cross road, I have all these methods of creating tiles/shapes and character fonts that can replace ASCII text characters but I don't know how to make them move across the screen all as one!

 [Beth] –  Okay, well, that was what I was trying to get at before. So, here’s your display on-screen array:
1              0              1
1              2              3
1              0              4
 Now the character steps left. You want to slide the array one column left and add a new column to the right, while leaving the character in the center of the screen. Your display array now looks like this:
 0              1              1
2              3              1
0              4              0
That’s all there is to it. You just change every single tile on the screen as the character moves and it gives the illusion of the world moving under the center player.

Your explanation makes sense but I'm still learning how to program in both Applesoft basic and machine language.
How do you assign each tile in absolute video memory?  Can you do this using Poke commands?
 [Beth] – The links I gave you above should get you started and I bet there’s lots of on-line forums to go to from there as well. Let me try to lay down some concepts for you:
1.       Poke and Peek commands literally put values into a particular address in memory (poke) and read from a particular address in memory (peek). On the 64k Apple ][ you have all the memory just sitting in front of you, like a big array. It doesn’t go anywhere. Every bit in memory has a fixed address. You can poke and peek any address you want. So, looking at the memory map you can see where the graphics are drawn from. Literally, at those addresses, the bits in memory is what is displayed on screen. So, to get the idea you could Poke the addresses in the video address space with values and see pixels change on the screen. Make sense?
2.       Now, in machine code (6502 Assembly) you are doing the same thing…but it’s easier to understand because your code exists at a literal address in memory. Every 6502 instruction (like a Poke or a Peek in basic) is a 8-bit “op code”. It has an address. It’s cool, because you can literally see every instruction you make take a slot in memory! As your machine code executes, it simply advances from one memory position to the next one, executing each instruction you’ve put in each byte. Can’t get simpler! And using those instructions, all you really do is move memory, add values and the like. So if you write a few instructions in 6502 to change a value in the video memory address range…bingo! You’ve just put graphics on the screen.
I was thinking that you can put all the tiles number representations such as the 0 for water and 1 for trees into a data base listing.  Then you use a DIM array and read all the values into memory but where would they go?
I’ve heard about VBI (Vertical Blank Interval) to update video memory but I don’t know anything about how this works.  I can’t remember where I read this info but it sound familiar.
If you can find any games you created that are like the Ultima games or any code or programs like the ones you mentioned, it would be greatly appreciated!!!
I don’t want to take time away from anything you are working on but any help you can give would make things a lot easier.  I really want to post everything I find out and come up with on a website so everyone can use it.  I want to make this all available to others so they can make their own games on the apple II computer using this info.
 [Beth] – I think that’s great of you! I really suggest you check out some of the links and online communities/resources out there, though, I bet there’s lots of help to be had. I hope I was able to give you some concepts and applications you can use to start from.
[Joe] -  How is this process done where you copy the 8 bytes form in-system memory to the relevant tile-display address in video memory?  I know that you can use monitor to input the byte information into a specific memory address, it this what you are taking about?

[Beth] - As I mentioned in the last e-mail, you use 6502 assembly and know where the code is via a memory map. While you can do things using the monitor, that’s seriously a pain. Use a nice assembler, like Merlin. Then you can write in Op Codes. Ideally, find yourself a little program in 6502 assembly so you can see how it’s done!

Basically, you’re going to want to store each of your tile shapes at a fixed address in a section of memory that you know is fixed. That will be your data memory. You know that tile #1 (trees) is at address $1000 (just making this up right now). You know that the video map of the players current position is like this:

1              0              1              2
0              1              1              2
1              0              0              1

So you translate that to video addresses (remember I’m making this up, substitute correct video memory addresses appropriately)

$8000    $8008    $8010    $8018
$8100    $8108    $8110    $8118
$8200    $8208    $8210    $8218

And then you’ll copy the 8 bytes from $1000 to $8000, $8010, $8108, $8110, etc. It’s a bit trickier than that, since you’re going to be copying vertically down the tile, but you can setup a nice loop to do it for you. I suggest you figure out where each horizontal row is in video memory and get each of those addresses. Then you can see how to copy memory from one place to where you want it in video memory, for each horizontal row. It should quickly become clear how to map those rows into addresses for tiles. That’s probably an ideal first-6502 program for you to try to write!

From Beth:  You should wait for the VBI (Vertical Blank Interval) to update video memory. I forget how to do that on the Apple II, but basically you want to only update video memory when the video raster scanner is moving instead of drawing. There’s a memory address you can watch for that. This will insure that your video updates are “smooth” instead of “tearing”.

From Joe:  first, what is tearing?  Is this the aftereffect of what the screen refresh does to the shapes on the screen?  How does VBI have any affect when the player can move back and forth really fast by hitting the lift/right arrow keys?  I've done this and the tiles still move really smooth!  Amazing!

[Beth]-  Okay, here’s where I get all the old graphics hardware mixed up. I don’t think the Apple II had page-flipping, so you’re limited to just using the VBI refresh for smooth updates. To understand how this all works, you have to think in terms of CRT monitors. Remember those? Not flat-screens, big old glass tube monitors. They had a “gun” in them that painted the video screen with the colors. This was done mechanically and it took time to refresh the entire screen, writing each row from top to bottom. When the hardware was done filling the video screen, it had to move the “gun” back to the beginning of the page. That also took time. During that time, it wouldn’t be drawing. That “non-drawing” interval is known as the “vertical blank”.

The values being written to the screen are LITERALLY the values in the video memory section of the Apple II. So “tearing” is what happens if you’re writing memory to the video memory at the exact moment the video “gun” is reading to display those bytes on the screen. You end up with half the screen from one frame and half from the other, and it looks like the screen is tearing into two or more sections. Not a good effect for gameplay. So you really want to wait for the video to stop drawing, update all the memory, then let it draw the memory before you write a new frame to it.

From Beth:  When the player moves, you update the master grid by introducing a new row or column on one side of the grid while removing the old one from the other. Then redraw.

From Joe:  How is this done?  Are you saying that you use the memory address to input the new row but how do you move all the other tiles across the screen as one?  How does this shift happen?  It's as if all the shapes on the screen are attached as one entire images and it moves as one! 

[Beth]-  Yes – you refill all of the video memory addresses at the same time, for each new frame.
[Beth]-  Joseph,
Glad I could help. Sure, feel free to mention and/or link me, that’d be great. I need to bring my website into the modern era, I haven’t touched anything there in years. Maybe getting linked will motivate me to switch it up. J
And I’d say, yeah – without an assembler, you’re not going to get very far. It’s really the only way to craft assembly code.
 Are you actually working on an Apple ][ or on an emulator? The emulators I’ve used just let you load “disc images” as though they were actual floppies. If you’re trying to get something onto a really floppy to a real Apple – hah, wow – that’s a bigger pain. You can do it via an Apple 2gs, because those would read/write Apple ][ discs and can connect via an Appletalk network. So, the process I’ve used is to copy onto a floppy and then from a 2gs copy it to a Mac on the network, then from that Mac copy it to a USB stick or to a network-based PC. Presumably that process works in reverse as well.
I bet the files you link to are most easily used on emulators, simply because they’re already on the web. But the bytecode is all the same, so if you can transfer them to physical floppies anything you find online should work just fine on a physical Apple ][. The link you sent has “disk images”, so I’m guessing you should be able to extract those into a file which is just loaded by an emulator as though it were a physical disk.
I think I found you a copy of Merlin here (in case yours doesn’t work):
And here’s a motherlode of stuff:
And here’s another handly reference set of links:
Anything by “Beagle Bros” or just keyword “Beagle” is worth your time to check out 110%. Those guys were the original hackers and nearly everybody who learned to code the Apple ][ owes them big time. Their utilities and charts are golden.
Good luck, I’ll check out your blog and such!
Beth
-------------------
So there you have it, a wealth of information to help all of us to get back on track and in the right direction.  I will be researching Assembler programs to try and get my hands on one.  Once I get one I will be posting new information about examples of code and progress on Ultima 1.  All this new information is going to take a while to digest and it may be a little while till I post some significant code or progress with my Ultima 1 program.  Stay tuned though, I will always have new stuff to post with regards to book reviews and program reviews, etc…
Let’s all thank Beth for her incredible help and soon we can get a major portion of the Ultima 1 program going!!!!
Remember, take a look at her website!
Talk to you soon,
Joe