-
Content Count
1,533 -
Joined
-
Last visited
Posts posted by Robert M
-
-
Lesson 4 - Binary Counting
In previous lessons, I have hinted that there is a standard method for counting using bits. In this lesson, I will introduce that standard method. First, I want to reiterate that this is NOT the only way to count using bits. It is simply the most common method, and therefore has considerable support for it built into most microprocessors including the 650X processor Family used in most classic gaming consoles and computers from the late 70's and 80's. Numbering Systems: ------------------ I must assume that if you can read the lessons in this class and understand them, then you must be familiar with decimal numbers and basic arithemetic like adding and subtracting. All decimal numbers are made using the ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. When you write a decimal number larger than 9 you must use two or more digits like this: 123 which is one hundred and twenty three. The 1 in 123 does not represent 1 it represents 100. The 2 in 123 is not 2 it is 20. The 3 in 123 does represent 3. Thus we call the 1 the hundreds digit, the 2 the tens digit, and 3 the one's digit. Each digit in a large decimal number represents that digit multiplied by a power of 10 based on its position and summed together. Thus (1 * 10^2) + (2 * 10^1) + (3 * 10^0) = 100 + 20 + 3 = 123 Ta!Da! We count numbers inside computers exactly the same way except that the numbering system in computers does not have 10 digits, it only has 2 digits: 0 and 1 (bits!). The numbering system that uses only 0 and 1 is called the binary numbering system or simply binary. Since it only has 2 digits the value of each binary digit in a large binary number is muliplied by a power of 2 instead of a power of 10 as we do for decimal numbers. The following table shows the positional value of the first 16 bits in the binary number system, as a power of 2. Note that the first position is numbered zero and not one. Bit position. | | Bit value | | 2^0 = 1 => bit 2^1 = 2 2^2 = 4 => octet 2^3 = 8 => nybble 2^4 = 16 2^5 = 32 2^6 = 64 2^7 = 128 => byte 2^8 = 256 2^9 = 512 2^10 = 1024 2^11 = 2048 2^12 = 4096 2^13 = 8192 2^14 = 16384 2^15 = 32768 => word Every computer in the world has a limited number of bits. When you use binary numbers in a computer program you must decide how many bits you will use to store each number that your program must keep track of. For 650X processors the most common numbers of bits to use will be 8 (byte) and 16 (word) because the processor works with data an entire byte at a time for each instruction (see opcodes in lesson 3). You can use any number of bits, but since 8 and 16 are so common we will focus on them for the remainder of this lesson. The same rules will apply to binary numbers made of any number of bits. This should not seem strange, as you can use any number of digits to represent a decimal number. If you don't need all the digits, then your number will have 1 or more leading zeros. 0000123 is the 7-digit decimal number 123, by convention leading zeros are not shown for decimal numbers, but they are always present nonetheless. The same is true for binary numbers. In the real world you can write as big of decimal number as your writing surface will allow. In a computer your writing surface is bits. If you do not have enough bits allocated/available to store a binary number then your program can not store that number and the information will be lost. Such an event is called overflow if the number is too big, or underflow if the number is too small. We will examine overflow and underflow in detail in the next lesson. You may be curious to know what is the biggest binary number you can store in a byte or a word. You already learned the formula in lesson 2 - enumeration. Given N bits, you can store 2^N different values. Counting positive integers starts at zero not one, so N bits can store binary numbers from 0 to (2^N)-1 Example: A byte has 8 bits so N=8: Therefore, a byte can hold unsigned positive integers from 0 to (2^8)-1=256-1=255. From 0 to 255. ALGORITHM to convert decimal to binary: --------------------------------------- To convert a decimal number to binary, you must repeatedly divide that number by 2. The remainder of each division is next binary digit in the binary representation of that decimal number. when there is nothing left to divide, the conversion is done. Example: Convert 123 decimal to its binary equivalent. 123 / 2 = 61 with a remainder of 1 -------+ 61 / 2 = 30 with a remainder of 1 ------+| 30 / 2 = 15 with a remainder of 0 -----+|| 15 / 2 = 7 with a remainder of 1 ----+||| 7 / 2 = 3 with a remainder of 1 ---+|||| 3 / 2 = 1 with a remainder of 1 --+||||| 1 / 2 = 0 with a remainder of 1 -+|||||| ||||||| 123 Decimal = 1111011 binary ALGORITHM to convert binary to decimal: --------------------------------------- Any binary number can be converted to its decimal equivalent, which is often easier for humans to read and understand. To convert a binary number to decimal you must multiply each digit of the binary number by its positional value (see the first table above) and add the digit values together to form the decimal value. Example: Convert 1111011 binary to decimal 1111011 binary ||||||| ||||||+- 1 * 2^0 = 1 * 1 = 1 |||||+-- 1 * 2^1 = 1 * 2 = 2 ||||+--- 0 * 2^2 = 0 * 4 = 0 |||+---- 1 * 2^3 = 1 * 8 = 8 ||+----- 1 * 2^4 = 1 * 16 = 16 |+------ 1 * 2^5 = 1 * 32 = 32 +------- 1 * 2^6 = 1 * 64 = 64 --- 123 decimal Binary Number Notation: ----------------------- Up until now I have been explicitly stating whether a written number is binary or decimal. As you can see it can become tedious to write "binary" or "decimal" after every number to clearly indicate the numbering system being used. Luckily, a handy shorthand notation exists for us to use to save time. For the remainder of this class I will always make use of this notation to indicate whether a number is binary or decimal. Decimal Notation: A decimal number is written with no special notation at all. It is written the same way you have always written decimal numbers. Binary Notation: All binary numbers shall be preceded by the % symbol. Examples: 123 is decimal and %1111011 is its binary equivalent. 101 is decimal = One hundred and one. %101 is binary = 4 + 1 = Five MSB and LSB: Another aspect of binary notation is Most-Significant and Least-Significant Bits (MSB and LSB). By convention a binary number is written from left to right the same as a decimal number. The left-most digit of a number represents the greatest portion of the overall value of the whole number. It is the Most-Significant digit in the number. The right-most digit of any number represents the least portion of the whole value. It is the Least-Significant digit. Each digit in a binary number is a bit. Therefore, the Most-Significant Bit (MSB) of a binary number is the leftmost bit, and the Least-Significant Bit (LSB) is the right most bit. Examples %100010010 ^ ^ | | MSB LSB %10111010010010 ^ ^ | | MSB LSB %100110 ^ ^ | | MSB LSB Please get comfortable with this notation for binary numbers because you will be using it extensively when writing assembly language programs! WHAT about negative numbers! ---------------------------- You may have noticed that so far our discussion of binary has been restricted to positive integers. Computers can count negative numbers, so now we will begin to explore methods for representing negative numbers in binary. We will complete this discussion in Lesson 5. Sign Magnitude Format: The first format for negative numbers we will explore is the sign-magnitude format. The format is easy to understand. For any given binary number add an additional bit to represent the sign of the number. If the sign bit is set, then the number is negative. If the sign bit is clear then the number is positive. The sign bit is the MSB of a sign-magnitude binary number. Examples: %0101 = %0 sign and %101 magnitude = 5 %1101 = %1 sign and %101 magnitude = -5 | +-> The MSB is the Sign bit There is a problem with this method of representing negative numbers. Can you see what that problem is? The problem is with the number zero. Using this system there are 2 instances of zero, a negative zero and a positive zero. There is no such thing as negative zero, so this may not be the best method for representing negative numbers. Two's Complement Format: (Introduction) An alternative to the sign-magnitude format is the two's complement format. Two's complement is superior to sign-magnitude (usually, but not always) because there is only one way to represent zero. Another advantage of two's complement is that when you add or subtract positve and negative numbers, the result is the correct number in two's complement format. To really understand two's complement, you must know how to add and subtract binary numbers. We won't learn how to add and subtract binary numbers until lesson 5, so we will suspend further discussion of negative binary numbers until lesson 5. What about REAL numbers? Yes, you can represent REAL numbers in binary. REAL numbers can also be thought of as fractions (1.23 for example). This is an advanced topic and I don't want to go into it now because I beleive it will confuse more people than it will help them to understand. You can write many, many programs without every needing to use REAL numbers. So just put them out of your mind for now. ------------------------------------------------------------------------- Exercises: 1. Convert 213 to binary 2. Convert %00101100 to decimal 3. Convert 1087 to binary 4. COnvert %1000010100011110 to decimal 5. Using the list of binary numbers below: %00110101 %01000101 %11100001 %10100110 %01001011 %01001110 %11001001 Take the LSB from each of the above numbers, in order from top to bottom, to create a new binary number. The LSB from the first number in the list should be the LSB of the new number. The LSB of the last number in the list is the MSB of the new binary number. What is the new binary number? Now convert that number to decimal. 6. For each of the numbers below, convert them to decimal twice. The first time assume that the numbers are in unsigned positive integer format. The second time assume that the numbers are in sign-magnitude format. a. %1000101 b. %0101010 c. %1100110 d. %0000010 7. What is the range of positive unsigned integers that can be stored in a word. BONUS QUESTION 1: For each number a-d in problem 6, is each number signed or unsigned? (Hint: refer to lesson 1). BONUS Question 2: Is the sign-magnitude format an Enumeration (Lesson 2) or a code (Lesson3), and why? ------------------------------------------------------------------------- NOTE TO READERS: We are rapidly descending from broad concepts to specific details in ASsembly programming. Most often, subsequent lessons will require an understanding of previous lessons. If you have questions after studying this material, do not hesitate to ask.
-
As of 5 minutes ago, I weight 229 pounds
Damn Holiday feasts! :wink: Your body weight can change as much a 5 pounds a day, it just depends on how much liquids and food you eat in a given day. The best way to get a good reading on your weight at home is to weigh your self in the morning with no clothing on and no food or water to drink yet and if you can use the bathroom before you do this, all the better, then you will have a good idea of how much you weigh. If you weigh your self in the afternoon, the you already have food and drinks in you and that changes your weight all day long.I just read your post and if I knew how tall you are I could guess what your target weight should be.

I know, it can vary. I'll just weigh myself sometime on the 13th and that will be the weight. A chance to vary by 5 pounds will make the final result more exciting.
BTW: I am 6 feet tall.
-
I smell a challenge. If he wants to be like that then that is fine. I understand that those who have been in the field may be less hesitant to allow others in, but I will prove him wrong. Mark my words.Are you following my Assembly Language course in the Programming for Newbies forum? It would be good to get some feedback/questions in the lesson threads from a newbie to know what I am successfully communicating, and what I am not.
Cheers!
-
Make sure the catridge case matches the one shown on this website. If its not that form factor, then it is most likely a reproduction. If it seems legit, I would think its worth more than $75.
-
It looks like the shadow cast by the player changes as the Sun moves across the sky. That's very impressive.

-
Um...512 * 8 = 4096
Ah! I was just seeing if anyone was paying attention! Yes, that's it! That's the ticket!
Thanks Nukey, I'll edit the previous post!
-
One word of caution: although 16 bits is often called a word; a word is not always 16 bits.Trying to confuse some newbies?
A word on the 650x is always 16 bit!I agree that on 650x (or any other 8 bit CPU) words are 16 bits. But, the same cannot be said if you are talking about the x86, or 68xxx, or some obscure processor like the PDP-1 or the GI CP1600 used in the Intellivision.
Anyway. For the purposes of this tutorial, word = 16 bits and 16 bits = word.
Eric Ball and the two Toms are correct in that the definitions for byte and word are not written in stone. Their definitions can vary from computer system to computer system. For the purpose of this course, however, a byte is 8 bits and a word is 16-bits.
Cheers!
-
Sorry for the delay!
Excercise ANSWERS:
Excerises:
1. Covert the following decimal numbers to BCD format:
a. 10
b. 253
c. 7689
d. 4
a. 10 = 0001 0000
b. 253 = 0010 0101 0011
c. 7689 = 0111 0110 1000 1001
d. 4 = 0100
2. Give an example of a 3 bit Gray code. NOTE: There is more than 1 correct answer.
Here's a way to make a gray code of any length of bits. Start with a gray code for 1 bit =
0
1
To get a gray code of n+1 bits from a gray code of n bits simply repeat the n code followed (or preceeded) by a single zero, then repeat the n code again in reverse followed by a single 1.
So from the above one bit code we get a two bit code as
0+0 = 00
1+0 = 10
Repeat 1 bit code in reverse.
1+1 = 11
0+1 = 01
Simply repeat this process to get a 3 bit gray code:
00+0 = 000
10+0 = 100
11+0 = 110
01+0 = 010
Repeat 2 bit code in reverse...
01+1 = 011
11+1 = 111
10+1 = 101
00+1 = 001
3. How many nybbles are there in a word?
We know how many bits are in nybble and a word so we can convert from one to the other by converting words to bits and then bits to nybbles.
1 word = 16 bits
1 nybble = 4 bits
nybbles per word = 16/4 = 4 nybbles.
4. How many bits are in 512 bytes?
By our definitions there are 8 bits in a byte. So there will be:
512 * 8 = 4096 bits in 512 bytes. {edited: after error was pointed out by Nukey}
5. How many octets are in 72 nybbles?
Again we will convert from one unit to bits, and then from bits to the other unit.
72 nybbles * 4 (bits per nybble) = 288 bits
288 bits / 3 bits per octet = 96 octets.
6. You wish to store strings in your program. The strings will contain only capital letters A-Z, spaces, periods, question marks, and a special character that marks the end of the string. How many bits are needed to store each character in a string? By packing the character codes together how many characters could fit into 8 bytes?
First we count the total number of symbols possible for each character. A-Z is 26 symbols. Space, period, question mark, and termination are 4 more symbols. 26 + 4 = 30 total possible symbols.
We can enumerate the symbols as we learned in lesson 2. The number of bits needed is
log(base2) 30 rounded up = 5 bits are needed per symbol in the string!
Now the second part of the question asked how many symbols will fit into 8 bytes worth of bits.
total bits = 8 bits per byte * 8 bytes = 64 bits.
Number of symbols in 8 bytes = 64 bits / 5 bits per symbol = 12.8 symbols
Not quite 13 symbols will fit into 8 bytes of space.
-
Hi,
There is no reason you should not be able to get a crisp picture.
Things to try:
1. Check both positions of the channel select switch and see if one is better.
2. Check the connector to the TV for corrosion/dirt. If needed clean it with very very fine steel wool.
3. Get a TV noise reduction filter from Radio shack.
4. Sometimes the RF tuner in the system over time will drift off of the ideal frequency for broadcast to the TV. There is a trim potentiometer inside the VCS that you can turn with a small screwdriver to adjust the output frequency. There is another thread in this forum that details this process. I will add the link if I find it.
Good-luck , and happy gaming.
-
Hi,
I recently shelled out the big bucks and picked up a copy of Battlezone 2000 for Lynx. I enjoy the game well enough, although I find the missions for points from 2000 to 10000 to be a bit tedious
The real reason for this thread is the hidden "3D-game" within the original game. The way to get to this game is detailed on many sites on the web so I won't cover it here.
When I came across the code I assumed it would simply be the same game but with filled polygon graphics instead of vectors. I was surprised to see it is a completely different game! Yes, you are still driving a tank, but the game is completely different. You have much more custimization capability. Pluras you have to pick up parts on the battlefield and install them while still under attack. The goal of the game is not clear. It seems like you are trying to clear all the sectors on a very large map using limited resources. I have found a key, and a spinning pyramid that I think the key will open, but how I haven't determined yet.
I am just amazed, that there is this completely undocumented game within the game. Its not a mini-game or a variation of the main game. Its a completely new game. The frustrating part is there is no documentation provided for this alternate game. I haven't found any on the web either.
So I propose that this thread become a adhoc manual for this new lynx game hidden on the Battlezone cartridge. When you play this game, if you discover something, please add it to the thread.
Regards,
-
I wish you well. All emulators are welcome.
I can't resist, however, pointing out the irony that a .Net application can only run in Windows32.
Keep it coming!
-
Sorry the holiday is taking much of my time, I will post the answers on Friday evening. Unless someone else wants to take a shot at posting the answers
Cheers!
-
Assembly Language Programming - Lesson 3 - Codes
In lesson one we learned what a bit is. In lesson 2 we learned how to use bits to enumerate lists of items. In this lesson we are going to learn how to use bits to encode information.
DEFINITIONS:
Before we study codes, however, we need to take a detour and learn some new terminology. When we enumerated, we saw that with 1 bit we can enumerate 2 items 0 and 1. With 2 bits we can enumerate up to 4 items 00, 01, 10 and 11. So on and so on, such that given N bits we can enumerate up to 2^N items. As you can guess, it is a very common practice to combine bits together for the purpose of enumeration. Some combinations are used so frequently in programming that they have been given special names:
1 bit = a bit
3 bits = an Octet -> Since it can enumerate 8 items.
4 bits = a nybble
8 bits = a byte
16 bits = a word
I will be using these terms in all future lessons so get comfortable with them now. For example the Atari 2600 has 128 bytes of RAM. How many bits is that? ANSWER: 128 bytes * 8 bits/byte = 1024 bits. What is RAM? Don't worry I will explain that in a later lesson.
If you are sharp eyed you may have noticed something about the naming of the bit strings above. Except for the octet each one is a power of 2! 2^0=1 (bit), 2^1=2(no name), 2^2=4(nybble), 2^3=8(byte), 2^4=16(word). This is no accident. Computers are based on bits and manipulate bits hence powers of two are a natural occurance in digital computers. So these numbers appear very often in programming. As a programmer you will find there are advantages to using powers of 2 in your programming. The odd Octet will become clear in Lesson 4.
INTRODUCTION TO CODES:
All enumerations are codes, but not all codes are enumerations. What does that mean? It means that enumerations are one type of binary code.
In lesson 2, we enCODEd the type of fruit (Apple, orange, bananna, cherry) using bits. What makes enumerations special codes is that they exactly match the binary numbering system used in computers for arithmetic so: Apple = 00 = zero, orange = 01 = one, bananna = 10 = two, cherry = 11 = three. We don't have to encode our types of fruit that way we could encode them as Apple = 10110, Orange = 10000, bannana = 10111, cherry = 11000, but this is now a code and not an enumeration.
Operation Codes:
One of the most important codes you will become familiar with is Operation Codes. Every microprocessor (CPU) has what is called an instruction set or a set of operation codes. Operation codes is often abbreviated as opcodes.
Operation codes are the executable (as opposed to pure information) part of your program. The hardware of the microprocessor reads each opcode in the sequence of the program and performs the action demanded. Later in this course we will explore all of the opcodes in the 6507 microprocessor (the processor in the Atari 2600) in detail. In the 6507 instruction set each opcode is 8-bits long, or 1 byte. The opcodes are not an enumeration, they take all sorts of values using 8 bits within a byte often skipping many bit combinations that would make the code an enumeration. The bits set in each opcode were chosen because they simplified the work of the engineers to build the logic circuits in the microprocessor.
Gray Codes:
A gray code is a special kind of binary code of N bits. Gray codes are used for counting 0, 1, 2, 3, etc. Gray codes are special in that each time you add or subtract 1 from the code, only 1 bit will change. Here is an example of a 2-bit gray code:
00 = zero
01 = one
11 = two
10 = three
00 = zero (pattern is repeating...)
You can see that only one bit changes as you count up or down through the 4 combinations. Gray codes are handy in situations where you want to minimize the amount of harware needed to implement a counting circuit in a computer. In the Atari 2600, the driving controllers (Indy 500) use a 2 bit gray code to encode the direction the paddle is being turned, the speed at which the code changes indicates the speed the paddle is turning at.
Binary Coded Decimal (BCD):
Binary Coded Decimal or BCD is a method for storing decimal numbers in an easy (sometimes) to use format within a computer. You are already aware of decimal numbers you use them to count all the time: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, etc. In BCD each decimal digit is encoded into a separate nybble = 4 bits.
decimal = binary
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
Each byte contains 2 nybbles, so each byte can hold 2 BCD digits (00 to 99 decimal). This is an important code for you as a programmer because the 6507 processor has built in support for adding and subtracting BCD numbers. The big advantage for BCD numbers is that each digit is confined to its own nybble. It is therefore easier to isolate the individual digits for drawing them onto the screen. So scores are good candidates for being stored in BCD since you want to draw them on the screen as decimal digits. The big disadvantage for BCD is that you are wasting bits each BCD digit takes 4 bits which if used completely could store 16 values, 6 more than the 10 that it is being used for.
ALPHANUMERIC Codes:
Programmers use alphanumeric codes to store text information used by their programs. Each letter, digit, and punctuation symbol is assigned a binary code. The minimum number of bits in the code is dependent on the desired number of characters used in your text strings. If you only want capital letters, numbers and the punctuation marks . Then you need 26+10+4 = 40 symbols, which requires 6 bits (from Lesson 2) per character in the string. Text manipulation is not a frequent activity for Atari 2600 games since the resources are so limited. Some games do display text. If your game will, then you need to decide between storing the strings as characters and then expanding them into the graphics to display on the screen, or store them in the cartridge already expanded and ready to display. Its a trade off between speed and storage space. We will explore such trade-offs much much later in the class.
There are 2 commonly used Alphanumeric codes for all computers. The first one is called ASCII. ASCII codes are 7 bits long. Therefore there are 128 symbols in the ASCII codes. Many documents on the internet contain ASCII codes. You can recognize these files in Windows as the files with a .txt file type extension. When you write your assembly code programs the program you used to store your code files will most likely store them as ASCII codes. The other common alphanumeric code is the Unicode. Unicode is a 16-bit code. It contains all the letters and symbols needed to display any known language in the world. ASCII has only the letters needed for english.
Summary:
The examples above are just a few codes. An infinite number of codes is possible because as we learned in Lesson 1, the meaning of the bits is entirely up to the programmer writing the program. Please try the exercises below to cement these new ideas home
-----------------------------------------
Excerises:
1. Covert the following decimal numbers to BCD format:
a. 10
b. 253
c. 7689
d. 4
2. Give an example of a 3 bit Gray code. NOTE: There is more than 1 correct answer.
3. How many nybbles are there in a word?
4. How many bits are in 512 bytes?
5. How many octets are in 72 nybbles?
6. You wish to store strings in your program. The strings will contain only capital letters A-Z, spaces, periods, question marks, and a special character that marks the end of the string. How many bits are needed to store each character in a string? By packing the character codes together how many characters could fit into 8 bytes?
Answers will be posted within 24 hours.
-
[quote="davidcalgary29
I always thought "Toki" was vastly underrated. It's an excellent game on the Lynx.
I agree 100%! I think Toki is an excellent platform game. The difficulty ramps very smoothly, and each level provides a unique environment. It was all I was playing for a month. I could never get past the 5 level boss, so I decided to take a break

-
Switchblade II is an okay game. I thought it was too easy. I was able to beat it the third time I played.
Things I didn't like:
- They offer information in the stores for 10 credits. If you buy it you get great tidbits like:
"Jump to avoid enemy shots" = duh!
"Napalm is reccommended" = Napalm sucks! Never buy napalm!
- It was too short/easy.
- I took more damage from falling into the scattered stationary fires than I did from most enemies.
- The only weapon upgrade worth taking is the Guided Missle. It rarely misses. It passes through walls! It does excellent damage.
Compared to other platform games for the Lynx, I thought it was rather weak. I am still trying to beat Toki, now that is a challenge I am enjoying. Viking Child is fun and pleasantly long. I still haven't beaten that one either.
Cheers!
-
I will say 187. I hope you get to that point. (Not only do I want to win, but that will be an awesome acomplishment.)retone,
187 lbs has already been taken. Please pick a different weight.
Cheers!
-
My weight as of 5 minutes ago: 229 lbs
The dreaded holiday season is approaching

-
Just to elaborate on the reasons why more bits than necessary may be used:(snip)
Well said, thanks!
-
1. The cartridge combat has 27 game variations, what is the minimum number of bits the combat program can use to keep track of the current variation?
ANSWER: 2^5 = 32 >= 27, so 5 bits are necessary.
2. The 112 game variations for Space Invaders.
ANSWER: 2^7 = 128 >= 112, so 7 bits are necessary.
3. The Atari 2600 Display is 160 pixels horizontally by 192 pixels vertically (NTSC) To position a player on the screen you must enumerate its horizontal and vertical position. How many bits are needed to store the horizontal and vertical positions of the player?
ANSWER: 2^8 = 256 >= 192 >= 160, so 8 bits are needed for each horizontal or vertical position. 16 bits total.
4. In Surround the "arena" is 40 blocks wide by 20 blocks high. Each block in the playfield is either filled or empty. How many bits are needed to remember the status of the playfield? How many bits are needed to remember the horizontal and vertical position of each player?
ANSWER: Since each block of the area has one of 2 states (filled or empty), we need a bit for each block.
Number of Blocks = 40 * 20 = 800 bits needed for the arena.
2^6 = 64 >= 40 so 6 bits are needed to store each player's horizontal position.
2^5 = 32 > = 20 so 5 bits are needed to store each player's vertical position.
Note: 3 & 4 have two answers depending on whether you are describing width & height independently or not. Bonus marks if you give both answers.This is true.
For problem 3 we could enumerate all the pixels on the screen (160 x 192 = 30720 possible positions)
2^15 = 32767 >= 30720, so you could store the player's position using 15 bits instead of 16 as required for storage of separate X and Y coordinates.
For problem 4 we could do the same trick for storing the player positions
2^10 = 1024 >= 800, so you could store each player's position using 10 bits instead of the 11 needed to store X and Y positions separately.
You may be wondering why then would you not always use the method of storage that uses the fewest bits? The answer is that the code of the program must process the data in the format that you choose, and it is easier to write code for separate X and Y coordinates than it is to write code for single enumerated position. In assembly language programming you will find there are many tricks that can be performed by using exotic data formats. I will provide examples much later in the course.
Now it is time to move on to Lesson 3 - Codes
-
Lesson 2: Enumeration
In lesson 1 we introduced the idea of a bit. We learned that a bit is the smallest piece of information in a computer. We learned that a bit can have either the value 1 or 0. We also learned that we as programmers can assign any meaning we wish to individual bits used by our program.
In this lesson we will look at the important programming practice of enumeration.
e·nu·mer·ate1. To count off or name one by one; list: A spokesperson enumerated the strikers' demands.
2. To determine the number of; count.
Let's say you want the to write a computer game where the player is picking fruit. There are 4 kinds of fruit in the game: Apples, Oranges, Bananas, and Cherries. All 4 kinds of fruit can be on the screen at the same time. Therefore, your program must keep track of each piece of fruit on the screen, and remember what kind of fruit it is so that it can draw the fruit correctly, and award the correct points to the player when they pick the fruit.
The easiest way to track the different kinds of fruit is to enumerate them
Apple = 0
Orange = 1
Banana = 2
Cherries = 3
All information in a computer is stored in bits so let's convert that to a bit:
Apple = 0
Orange = 1
Banana = ??
Uh oh! We have run out values to enumerate our fruit because a bit can only be 0 or 1. To enumerate the fruit we will have to combine 2 bits together like this:
Apple = 00
Orange = 01
Banana = 10
Cherries = 11
The 2 bits together have 4 possible combinations so we can enumerate the fruits in our program using 2 bits for each piece of fruit.
What if our program needs to have 8 different kinds of fruit, how many bits do we need then?
The answer is 3 bits. 3 bits together have 8 value combinations
000
001
010
011
100
101
110
111 = 8 combinations.
The fomula for the number of combinations possible given N bits is:
combinations = 2 ^ N = (2 to the power of N)
So an enumeration of W items will require a minimum of:
N = log2 (W)
Exercises:
------------
Here are some real world examples of enumeration from Atari 2600 games. For each item calculate the minimum bits the program must use to keep track of the particular piece of information.
1. The catridge combat has 27 game variations, what is the minimum number of bits the combat program can use to keep track of the current variation?
2. The 112 game variations for Space Invaders.
3. The Atari 2600 Display is 160 pixels horizontally by 192 pixels vertically (NTSC) To position a player on the screen you must enumerate its horizontal and vertical position. How many bits are needed to store the horizontal and vertical positions of the player?
4. In Surround the "arena" is 40 blocks wide by 20 blocks high. Each block in the playfield is either filled or empty. How many bits are needed to remember the status of the playfield? How many bits are needed to remember the horizontal and vertical position of each player?
I will post the answers in 24 hours.
-
Alright! These are good responses. The key points that you need to take away from this exercise are:
1. The light is either on or off, there are only 2 possible conditions for the light. The light represents a single digital bit.
2. The two states of the bit can represent ANY TWO OPPOSING conditions:
1 or 0
YES or NO
"The Player is alive" or "The player is Dead"
"The Fire button is pressed" or "The fire button is not pressed"
3. All information in a digital computer at its lowest level is composed of bits. There is no piece of information smaller than a single bit.
So how does this relate back to the questions I asked above?
1. What does it mean when the light is on?
It means what ever you the programmer want it to mean is true.
2. What does it mean when the light is off?
The opposing condition for the meaning you give to the bit is true.
By common convention the values 1 and 0 are used to represent the states of bits. One usually means on, yes, or true. Zero usually means off, no, or false. Notice that I said "by convention" and "usually". You could just as well use "A" and "B" or "Zip" and "Zap", but this makes it hard to talk with others about bits, so we will use 1 and 0 in this class.
This is the great secret of all computers and computer programming in general. When you program in assembly language you have complete control/responsibility
to provide the meaning of the values of the bits that make up your program. If you want a a bit to mean "The Dragon is awake" when it is 1 and "The dragon is asleep" when it is zero, that is fine. Just understand that the meaning you give to the bit is completely your own invention and when the user pulls out cartridge with your program and puts another one in, that program will apply a completely different meaning to the EXACT SAME BIT.Alright let's move onto Lesson 2: Enumeration
-
The footpedals are basically 3 buttons that you can map to any of the joystick directions or the firebutton. The footpedals have a pass through plug so you can plug a joystick into the pedal. Any direction/button programmed to a footpedal is no longer connected for the joystick. Example: If you map one of the footpedals to the fire button, then the firebutton on the joystick will no longer do anything, you have to push the corresponding foot pedal to "fire"
So you can really use a set of footpedal with any game. I could see it being very useful for games that use 2 controllers like Raiders of the Lost Ark or Solaris.
Is it better? That's debatable and it comes down to personal preference. For Thrust+ you can combine the footpedals with a driving controller. I haven't tried that yet, but I think it would work quite nicely.
Cheers!
-
Thanks everyone for your guesses so far and encouraging words.
186.9 lbsvb_master, I will be delivering my final weight in the nearest pound, so a decimal guess is bound to lose if others pick 186 and 187. I should have made this clear in the rules. I will assume your guess is 187, but feel free to change your entry one time to some other weight.
Thanks,
-
Assembly Language Programming - Lesson 1
This course assumes no prior knowledge of computer programming. While the examples given in the course are targeted at the 650X family of procesors, the ideas presented will apply to assembly language programming and often programming in general.
Please feel free to posts comments or questions into the Lesson threads. If you wish to ask a private question don't hesitate to send me a PM.
Materials needed:
- The assembler we will be using for this course is DASM. We won't need the assembler for the first several sessions, I will provide links for downloading and installing DASM. DASM is available for DOS, Windows (in a DOS window), Amiga, and Macintosh (OS-9 or OS-X). So the development tools will be available on many platforms.
Lesson 1: The Most Important Thing You Need to Know about Computers.
Imagine you have a black box with a single light bulb sticking out of it. Sometimes the light is on, sometimes it is off. Please answer these questions:
1. What does it mean when the light is on?
2. What does it mean when the light is off?
Until you can answer these questions, programming computers will never quite make sense. Everything else we do in this course will be built on this radical idea. Please take a moment to consider these questions, and try to answer them by responding within this thread. Please be sure to explain the reason for your answers? I will review your responses and provide a definitive answer on Tuesday evening (Central Time, U.S.A.). Hint: There are no wrong answers, its just a mental exercise to broaden your mind.
Regards,

Have some simple questions for you 6502 gurus!
in 2600 Programming For Newbies
Posted
The Dig is down temporarily while it is being moved to another server and getting revamped.
Cheers!