bluetriforce Posted August 6, 2004 Share Posted August 6, 2004 I need to know how to make a Atari 2600 game. All I know about binary numbers is converting decimal to binary numbers and converting binary to decimal numbers. I am not good at math? Which websites do I go to learn more about binary numbers, hexadecimal and the accumulator the easy way with step by step tutorials I don't understand almost anything below this line. I need someone to explain this to me what is below this line. bits 7 <----------------------------------->0 +---+---+---+---+---+---+---+---+ | N | V | | B | D | I | Z | C | <-- flag, 0/1 = reset/set +---+---+---+---+---+---+---+---+ N = NEGATIVE. Set if bit 7 of the accumulator is set. V = OVERFLOW. Set if the addition of two like-signed numbers or the subtraction of two unlike-signed numbers produces a result greater than +127 or less than -128. B = BRK COMMAND. Set if an interrupt caused by a BRK, reset if caused by an external interrupt. D = DECIMAL MODE. Set if decimal mode active. I = IRQ DISABLE. Set if maskable interrupts are disabled. Z = ZERO. Set if the result of the last operation (load/inc/dec/ add/sub) was zero. C = CARRY. Set if the add produced a carry, or if the subtraction produced a borrow. Also holds bits after a logical shift. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Big Player Posted August 6, 2004 Share Posted August 6, 2004 I need to know how to make a Atari 2600 game. All I know about binary numbers is converting decimal to binary numbers and converting binary to decimal numbers. I am not good at math? Which websites do I go to learn more about binary numbers, hexadecimal and the accumulator the easy way with step by step tutorials http://www.atariarchives.org/mlb/chapter2.php While you're at it, read the rest of the book. http://www.atariarchives.org/mlb/ I don't understand almost anything below this line. I need someone to explain this to me what is below this line. bits 7 <----------------------------------->0 +---+---+---+---+---+---+---+---+ | N | V | | B | D | I | Z | C | <-- flag, 0/1 = reset/set +---+---+---+---+---+---+---+---+ http://www.atariarchives.org/roots/chapter_3.php Read the rest of this book too. http://www.atariarchives.org/roots/ Happy reading. Quote Link to comment Share on other sites More sharing options...
Susuwatari Posted August 6, 2004 Share Posted August 6, 2004 It also helps if you're good at math as well. It may not seems like much but good math would really help on decent code programming. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted August 6, 2004 Share Posted August 6, 2004 These are all "flags" of the status register. Whenever a computer performs an operation, these flags go up or down (i.e. the bits change between 0 and 1) depending on the result of that instruction. You shouldn't be concerned with all of them right off the bat...so I'll list the common ones you'll normally be using... Zero flag: This can be set if the last arithmatic operation resulted in a zero, as in... LDX #$01 ;when the above line executes, the X register holds a value of 1 DEX ;when that DEX has executed, the X register will be zero and the flag goes up in the status register. The flag can also be set if a comparison between 2 numbers is EQUAL. When a comparison is done, it is basically subtracting the argument. Like this: LDX #$01 ;X now holds a value of 1 CPX #$01 ;Comparing X (=1) to the value of 1 (=1). 1 - 1 = 0, and the flag goes up Why is any of that useful? Well, for a start it helps make conditional branches work. Conditional branches are like JMP instructions...but they work by looking at the flags of the status register. If either of those above examples were followed with... BEQ nextpart ...the program would take the branch and go to the routine "nextpart" (Branch if EQual). Alternately, you could do this... BNE not_equal ...and the branch would NOT be taken if the zero flag is set (Branch if Not Equal). Note: branches can only jump a distance of 128 bytes in either direction. Negative flag: 65xx memory locations can only hold a maximum value of 255 (or hex $FF). In conditional operations, values equal to 0 to 127 ($00-$7F) are considered to be positive. Values equal to 128 to 255 ($80-$FF) are considered to be negative. This is really useful when it comes to checking if a value has tried to drop below $00...when this happens, the value "wraps around" to $FF (and then the program considers it to be negative). As in this... LDX #$00 ;X now holds a value of 0 DEX ;when that DEX has executed, the X register will have dropped below zero and wrapped around to $FF ($00 - $01 = $FF). The negative flag goes up, and a conditional branch can be used to go to the routine that deals with the eventuality of X going below zero... BMI x_has_rolled (Branch on MInus) ...or a branch can be used to deal with the eventuality that X didn't roll... BPL X_didnt_roll (Branch on PLus) Carry flag: This bit will go up if the last addition has rolled above $FF (carry). Alternately, a carry flag that has already been set when a subtraction rolls under $00 (borrow). Then the program can use that carry flag when dealing with a subsequent branch or arithmatic operation. For example, here's how you could update a "score"... CLC ;clear the carry flag for addition... LDA POINTS ;fetch the number of points we are adding ADC SCORE_LO ;add in the low byte of the score ;note: if the above rolled above $FF, the carry flag will now be set) STA SCORE_LO ;save the updated low byte LDA SCORE_MID ;now load in the 2nd score variable ADC #$00 ;...and add the carry that was saved (if any) ;note: if THAT operation rolled over, the carry flag will be set again STA SCORE_MID ;save the 2nd score variable LDA SCORE_HI ;now load in the 3rd score variable ADC #$00 ;...and add the carry that was saved (if any) ;note: if THAT operation rolled over, the carry flag will be set again STA SCORE_HI ;save the 3rd score variable Also, the carry flag can also be used to check if a number is less or greater than the argument. LDY LIVES ;load the number of player's lives CPY #$03 ;check to see if it's equal to 3 BCC addlife ;if it's LESS than or equal to 3, go to the routine addlife ;if Y had been 4, the carry flag would have changed... 3-4 -> borrow Decimal flag: This can only be set or cleared by the instructions SED or CLD respectively. What this does is make the computer "assume" that the values being worked with ONLY have a range from 0 to 99. This is really handy to have the computer treat the hex numbers that it is used to working with to the more familiar DECIMAL numbers that we are. Hex value $10 is equal to decimal value 16. With the decimal mode set, it still really is equal to decimal 16...but it will treat it LIKE a decimal number. No A's, B's, C's, D's, E's, or F's will show up...and when $09 gets one added to it it will become $10 instead of $0A. Look at this addition routine... CLC ;clear the carry flag for addition... SED ;set to work in decimal mode LDA POINTS ;fetch the number of points we are adding ADC SCORE_LO ;add in the low byte of the score ;note: if the above rolled above $99, the carry flag will now be set) LDA SCORE_HI ;now load in the 2nd score variable ADC #$00 ;...and add the carry that was saved (if any) ;note: if THAT operation rolled over, the carry flag will be set again STA SCORE_HI ;save the 2nd score variable CLD ;clear decimal mode That short routine will keep our score variables in handy digits 0 to 9 Caution: Be sure to clear decimal mode once you are done with it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.