The program we chose to complete for this lab was pong. For something that seemed relatively simple, there were some complications with it. One thing that seems obvious now but wasn't at the time was that we needed something to delay the drawing of the "ball" on the screen so that it didn't just instantly fly all over the place and the game would be unplayable.
We used the following code for our "sleep function"
delay: iny
cpy #$FF
bne delay
ldy #$00
inx
cpx #$06
bne delay
The above function just gives the processor busy work for a while until it should draw again. In other languages you can call built in methods like sleep for this kind of thing. It was interesting to get a look behind the scenes at what the processor could potentially be doing to make these "sleep" functions happen, though in a real system it would probably be working on other tasks rather than just counting.
No comments:
Post a Comment