Monday, May 16, 2011

Some new insight into the Ultima map…

Hello all,
Well, I have been beating my brains out trying to figure out how Richard was able to move all the tiles/shapes across the screen so fast and smooth!  I mean WOW, when I play the original version on my apple IIe, I can move back and forth really fast and there is no lag or stutter in the movement of all the tiles!  This got me to thinking!  I have a couple of ideas how he did it and I found out how he could not have done it!
First, how he didn’t do it:  Ok, I created some shapes using Shapes in Color program, which is an easy program to use by the way.  After I created about 8 to 10 shapes, mostly the map highlights such as trees, plains, mountains, and dungeons, etc…  I used an array and some for-next loops to DRAW all the tiles on the screen.  This process works but is really slow, you can actually see all the tiles being placed on the screen one after the other.  As you can see from the image earlier in the Blog, I was successful in creating an Ultima map screen but this was ultimately a Failure!  Next, I tried to POKE the shapes on the screen but since they are created shapes using vector plotting it just doesn’t work right. 
How I think he did it: I think he created him tiles by using LARGE size character sets and replacing them with original character sets.  Example; he made some trees in double size of a small character set, which is 14x16!  First clue!  All of Richards tiles are 14x16 pixels and a LARGE size character is 14x16! Second clue!  You are able to POKE character directly to the screen and scroll them much quicker than you can shapes!  So I think Richard used a set of created characters and replaced the unused character in the apple memory.  This way he can CALL them from memory and POKE them around the screen much quicker!
So now, how did he do this!  This is what I will try to accomplish next!  I have already started to make some LARGE size character sets.  I will only create the main map tiles and a single main fighter character, and maybe one or two monsters!
Once these are complete I will save this character set into the unused lower character set and then try to manipulate them around the screen and see how fast I can get this to work by using POKE and CALL statements.
I will let you know how it goes later…

Friday, May 6, 2011

Ultima 1, where it all started!





Creating the first map layout of Ultima 1 Revisited!!!

Hello everyone,
Back again with new info and new photos…
I just posted some photos of my initial Ultima 1 map layout plus some Basic programming code to go along with it!  This initial layout is only the display screen filled with shapes.  Right now I don’t have the movement completely figured out but I understand how to create shapes, how the shapes are placed on the screen, and how you erase the shapes to move them.
1.    Creating shapes - I don’t recommend you try to create shapes by inputting the data in binary method!  This is way too slow and cumbersome.  Get yourself a good graphics program.  I recommend, and I will be reviewing some of these programs in the future, “Shapes in Colors”, “The Graphics Magician”, and/or “The Complete Graphics System I or II”.  These initial programs are great for creating and storing shapes, shape tables, and full screen pictures.  You can’t edit a shape once it is created but you can erase and recreate with some of these programs.  NOTE – when you create a new shape table be sure to use a large number for the amount of shapes that will be in the table, this way you won’t run out of spaces for shapes and have to create a new table.
2.    Placing Shapes on the screen – There is a lot to this function!  You need to understand the following commands: DRAW, XDRAW, POKE, BLOAD, HCOLOR, DIM(a,b), ARRAYS, ROT, and SCALE.  These commands are directly related to placing, moving, and manipulating shapes on the screen.  If you have a good understanding of these commands and how they work, you will be able to start creating some cool displays that look just like the maps in the Ultima games!!!  These commands also help streamline your program to keep it simple and small.  You should also learn about HGR and HGR2, these two graphics modes let you place shapes in two different screens, which will allow you to show one screen full on shapes or an image while another set of shapes or images are being created in the background.  This helps create smooth animation or shapes movement.
3.    Erasing shapes – To erase a shape you need t use the XDRAW command.  This command will basically “draw” the shape in its opposite color.  In essence, shift it to the opposite color that isn’t being shown on the screen.  When you create a shape you have color limitations due to the TV screen pixel format.  In the Apple  II you don’t get to use any color you want, you are limited to color combinations such as Blue/Orange or Green/Purple.  These color are plotted on odd and even columns within the shapes you create.  So the trees are created in the alternate White because it is made up of green and purple pixels, which you only use the green columns to create the trees.  I know this is weird but it is how you have to deal with the color issue in the Apple computer.  It sucks but you have to get use to it. So, in the tree shape example, when you draw the tree shape to the screen you use white as the color reference and it shows up as green trees on the screen.  Remember that you only used the green pixels when you created the shape in the first place.  To erase the tree shape you have to XDRAW the shape, which draws the shifted shape using the purple pixels.  Since the purple pixels aren’t meant to be seen, they don’t show on the screen and WHAM, no shape! If you want a better explanation then this you can find it in any of the graphics manuals or books that cover it.
There is a lot that goes into shapes and shape tables, and this is the key concept of Graphic Tiles used all of the first five Ultima games! 
With regard to the attached program, I posted and will continue to post all the code I create for this project.  It may not be correct and there could always be a better way but this is how I have learned to do the things you see so far.   Remember that I am learning too as we go along and as I learn things will change and new ideas may come up so be prepared to be pushed into different directions.  I’m not a structured programmer and I like to try different things out when I am testing, this makes for some strange programming examples.  Also remember that this is a project to recreate the entire Ultima 1 game from scratch and since I have no idea how it was created in the beginning, I have no ideas how it will turn out in the end.  We are all at the mercy of Applesoft Basic and my brain!  Be afraid, be very afraid!
Play with the program and experiment by changing thing around.  As I said before, if you create a shape table with a name different than my name of ULTIMA1 then you need to change line 5 do show your shape table name and not mine.  Also, play with different data lines and create your own map layout!  All of the lines within the 5000 block are for the shape image and they represent the order in which they were created.   So when you see a 2 or a 1 or a 5 you should now which shape that number represents.  In my shape table the numbers equate to the following shapes:
1 = plains
2= trees
3 = mountains
4 = dungeon entrance
5 = castle
6 = your character the fighter
7 = Troll
8 = water
Then reason I created the water shapes last is because the first 7 shapes use the alternate WHITE color i.e Green/Purple and you can use 3 as the HCOLOR assigned number.  With the water shape you can’t use white and have to use the Blue/Orange color coding.  All you do is pick the blue pixels when you create the shape and the orange pixels won’t show up when you draw the shape on the screen.  Also its easier to remember that in the 8 shape table, the last shape is blue!  So in the data base section under the 6000 line block, you need to remember to use a 6 “Blue” color code when placing this shape!  So enter the program and play with the data lines and create your own Ultima 1 map layouts!  I would love to see some photos of Ultima Map layouts created by others; you can post them here for display!  Just have fun with it and you will be learning in the process!
So to reiterate, Graphic Tiles in Ultima games are SHAPES, which are placed in SHAPE TABLES!  Research this if you want to find out more on these two key concepts.
COLOR concept understanding is critical when creating new shapes; you must understand which color combos you can use when you create each new shape.  If you get this wrong then your shape will look strange on the screen or show up in a different color than you expected!  Plus, in Ultima the shapes must be create to a size 14 wide by 16 high!  This is a must!  If you don’t create your shapes to this size they will not fit the screen correctly or be spaced incorrectly.  You also need to be consistent when you pick your starting point.  You must use the same starting point for each new shape and they have to start on an odd number.  I use 1 for X and 16 for Y, this seems to work out fine.  If you count the number of tiles on the Ultima 1 map you will see that there are 20 tiles side to side and 10 tiles top to bottom!
The next concept I will be working on is how to create the master map layout.  This means creating the entire map for the Ultima 1 world and then trying to figure out the programming involved to move around the world.  I know this involves using multi dimensioned arrays, i.e MAP(a,b) and large data base lines!  Wish me luck!
As always, if you have any ideas or info that can help me and others please post it here and we can all work together on it.

Here are some of the shapes I created in the "Shapes in Color" program






The first program to place the shapes on the screen




Here is the Applesoft Basic program code I created to place the shapes on the screen in the correct order and placement.
On line 5 you can see the BLOAD command, which shows the name of the Shape Table.  I used ULTIMA1 for the name of my shape table, if you use something different then you need to change this name.
In this test I used a for-next loop to place all the shapes/Graphic Tiles on the screen but you will notice when you run this program that it is a slow process to place the tiles on the screen.  They get placed one at a time and slowly fill up the screen.  You could do this in the background while you have the HGR2 screen up, which is page two of the Hi-Res graphics mode.  The more I read, the more I am getting a better understanding of how these two graphic modes work together for moving graphics on the screen.  Can you say Animation boys and girls!!!
The way HGR2 works is you can be in page 1 HGR screen with a shape or image and in the background you could be drawing another image or shape in HGR2 page 2.  this way, you can switch between the two pages and get a clean animation from the two images or shapes!  Pretty cool!
In my program I am only using HGR page 1 and placing the shapes on the screen one by one as a test.  I am trying to figure out a way to get the shapes to move UP/DOWN/RIGHT/LEFT.  I know you use a GET command to check for Keystrokes and then move the shapes based on the key pressed but you can’t use a FOr-Next loop to move the shapes because it is too slow.  They would show up clunky and be placed on the screen one-by-one, which is not how you see it in the game.
The DATA in the 5000 lines are the SHAPE numbers for each row. Hence, you have 20 data values per line up to the 10 lines.  The DATA in lines 6000 are for the HCOLOR values of each shape.  You must have a color value assigned to each shape or it will show up wacky.  When you create a shape you assign a color value to it like white or blue or green or even white assorted.  This color value must be issued with the DRAW command or you get strange affect with the shape.  Also, you must start on an odd X value when drawing the shape because the shapes are assigned a 1 for the X value and if you start it on an even value you get the shape to shift and you get the next color shift in the shape.  I will explain this issue later in more detail.
Have fun with the program, if you have any questions please ask.
More to come later.

First Ultima 1 map layout

Here is my first layout of the tile system used in Ultima 1.
Pretty cool huh? I finally figured out how to correctly create the Ultima shapes and place them on the screen in the right configuration.  So far, for this test I only created 8 shapes.
Commands of the the day are… DRAW, XDRAW, HCOLOR, BLOAD, ROT, and SCALE!
You need to have an understanding of these commands to get to this point!

Wednesday, May 4, 2011

Testing the new shapes I created...

Hello everyone,
I know, it’s been awhile since my last post but what can I say... I'm busy! 
Ok, so I created some shapes using "Shapes in Color" by Harry Moneyhun.  Crap, I found out just how important it is to pre-work your shapes!  You should follow these steps when creating your shapes to save yourself from wasting time later doing them all over again!

1.  Make sure you know which color you want your colors to show up as!  In Applesoft Hi-Res you only have 8 colors to work with and only four are real colors; blue, orange, green, purple!  The other four are black and white or the alternate of these two colors.  Now remember that only one color is going to show up based on the column you plot to.  With orange/blue you can use even or odd plotting columns to get the color you want, if you plot a blue and an orange dot right next to each other they both show up white!  Go figure!
So, in Ultima 1, Richard used Alternate White on most of the shapes, that’s why when you see them on the screen you see some greens and some purple dots!  This is because you plot points on the shape and it is a mix of green and purple tied together to give you white.  He could have used just white and plot the points together to only show white with no blend of the other two colors.  I did my shapes in only two colors; white and blue/orange.  I use white for all the character shapes and monsters, plus the mountains and castles.  I used blue/orange for the water.  For the plains and forests I used alternate white because I only plotted on the green columns.  This is important because when you do a draw command of the shapes on the screen on an ODD x,y plot point, plot you reference the color alt-white in hcolor=, you only see the green dots.  I have to reiterate how important this is because when this is done correctly you are able to use an XDRAW command and this draws the shape again in its cross-color, which is black.  The XDRAW command is what basically erases the shape on the screen!  I learned the hard way on how this works because when I tried to create my shapes in green and uses an XDRAW command, I would get purple trees since the cross-color is purple!!!  Crap!  So, the point to take here is that if you want white shapes then creates them in white!  If you want green or purple shapes create them in alt white which lets you do green or purple based on the column you uses!  Whew!  That is a mouthful!
2.  Determine ahead of time how many shapes you are going to create for your shape table!  If you don't know the total then you better use an application that allows you to append to the existing shape table!
3.  Make sure you keep the same starting point when creating each shape!  If you use a different axis point when creating shapes and you start drawing them to the screen, they will be all over the place instead of right next to each other!
4.  In Ultima 1, Richard made his shapes in a grid of 14x16.  That is 14 pixels wide by 16 pixels high!  If you don't use this standard then you won’t be able to have 20 tiles across and 10 tiles down!  In Ultima 1 there are a total of 200 graphic tiles on the screen at one time which make up the land of Britannia.
5.  Try to leave the left most column open if possible!  Sometimes this pixel will bleed to the other side of the screen if you move it too far to the right when drawing in on the screen!
6.  If you want to make moving shapes like the sea serpent or the water tiles in later Ultima's, you must create more than one of those tiles with a slight variation to it.  So, for example, if you want a monster to move his arms you have to create a shape of the monster with arms down and then create another shape with the arms up.  Then when you draw the shapes on the screen you will have to draw then Draw the shape then draw the second shape and draw the second shape again.  This gives the animation of a moving monster.  I will explain this in more detail later in the blog.
These are just some of the things you need to follow when creating new shapes for your Ultima game!
More later...