Changes

Jump to: navigation, search

6502 Assembly Language Math Lab

1,738 bytes added, 15:27, 3 February 2020
Write-Up
** [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. * Drawing a Line** To draw a line between two arbitrary points (X<sub>1</sub>,Y<sub>1</sub>)(X<sub>2</sub>,Y<sub>2</sub) where X<sub>2</sub>-X<sub>1</sub> > Y<sub>2</sub>-Y</sub>1</sub> and all coordinates are positive, calculate the rise/run, then set Y=Y<sub>1</sub> and iterate for X=X<sub>1</sub>:X<sub>2</sub> incrementing Y by the rise/run each step.** Use fixed-point math for the rise/run (aka deltaY) value. == Lab 2 3 ==
=== Setup ===
==== 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.
Post an entry on your blog describing your experiments in this lab. Include:
# An introduction, so that someone who happens across your blog will understand the context of what you're writing about.
# The results from the two ''Writing Code'' portions of the lab, including the code, a description of how the code works, and the results produced. Credit other sources appropriately (i.e., font/graphics data, code snippets) and ensure that you are in compliance with the licenses of any code snippets used.
# Your experiences with this lab -- your impressions of the Assembly Language, what you learned, and your reflections of the process.
Remember to follow the [[Blog Guidelines]] as you write.

Navigation menu