Open main menu

CDOT Wiki β

Changes

6502 Assembly Language Math Lab

1,358 bytes added, 09:38, 20 January 2020
no edit summary
** [http://www.6502.org/tutorials/6502opcodes.html 6502 Opcodes with Register Definitions]
** [https://www.masswerk.at/6502/6502_instruction_set.html 6502 Opcodes with Detailed Operation Information]
 
== Techniques ==
 
* Bouncing Object
** To bounce an object around the screen:
*** Use two variables for deltaX and deltaY values -- the amount that the object will move in each direction for each update. Add these values to the X,Y position of the object on the screen each time you update the position.
**** These values can simply be -1 or +1 if the object is going to bounce at 45-degree angles.
**** These values will need to include a fractional component for angles other than 45 degrees. This can be handled by using two bytes for each element of the X,Y position and for the deltaX and deltaY values, where one byte represents the integer portion and one byte represents the fractional portion (fixed-point representation).
** Detect when the object has collided with the edge of the screen or other objects, and reverse the sign of the deltaX or deltaY value (or both). For example, when bouncing off the top of the display, set <code>deltaX = -deltaX</code>
 
 
* Keyboard
** The last key pressed is stored in memory location $FF. Clear this location (to 0) after reading it. Printable characters, ENTER, and Backspace are represented by their ASCII codes; the arrow keys are represented by the codes $80-$83 (up/right/down/left).
 
* Random number generator
** A random byte is available at memory location $FE.
 
 
== Lab 2 ==
==== Option 5: Line draw ====
{{Admon/tip|Division|This option may be harder than the others and typically requires division arithmetic!}}
# Create code that has two pixel-sized cursors, moved by two separate sets of keys (e.g., cursor keys for one cursor, and a/w/s/z for the other cursor).
# Draw a line between the cursors which moves whenever one of the cursors is moved.