Robots w/Lasers

March 19, 2006

Ported to C

I ported the code to C. Now it is easier for me to work with.

This makes it easy to scale things, so now I have 10 boucing lights instead of one:

Bouncing lights

bounce3.mpg – 3MB

I’m no ASM master, so I could probably be doing it the hard way, but this code in ASM:

mov tmp1, ballX
lsr tmp1
lsr tmp1
com tmp1
andi tmp1, 0b00000001
mov tmp2, ballY
lsl tmp2 ; multiply by 2
add tmp1, tmp2
ldi tmp2, 0x60
add tmp1, tmp2
ldi yh, 0x00
mov yl, tmp1 ; Y now points at loc in VRAM

mov tmp1, ballX
andi tmp1, 0b00000011
lsl tmp1
ldi tmp2, 1
cpi tmp1, 0
brne shiftit
rjmp shiftdone

shiftit:
lsl tmp2
dec tmp1
brne shiftit

shiftdone:

ld tmp1, y
or tmp2, tmp1
st y, tmp2

Translates to this code in C:

VRAM[ballY] &= ~(1 << (ballX*2));

As you can see, it’s a bit simpler now.

Filed under: AVR — davr @ 2:35 pm

5 Comments »

  1. Hehe, just a bit simpler, yes.
    Speaking of which, I just got my 8×8 displays in the mail today – I’ve got some transistors, a cpld, and a microcontroller just waiting to be hooked up… will post on my blog when I finish it ;)

    Comment by Stephen — March 25, 2006 @ 11:17 pm

  2. Uh oh…I better get back to work, or you’re going to show me up with your 4 bits of brightness plasma routines

    Comment by davr — March 29, 2006 @ 12:54 pm

  3. I’m really impressed!

    Comment by bezdar1 — July 5, 2006 @ 2:53 pm

  4. how about plugging in an Ageia PhysX card? will make life simpler ;-)

    Comment by alon jacoby — March 21, 2008 @ 10:06 am

  5. Hello,

    I find your project very interesting, and I even tried to implement it myself, using the first scheme you posted – with the 3 shifters. However I’m a beginner with programming ATMEGA and uC in general. I wonder if you could post some samples here of your code for making the bouncy or maybe for the design of the smiles. I already put together the electronic part – but for now all the leds are lighted up. :D
    Thanks a lot in advance.

    Comment by dede — May 30, 2009 @ 2:07 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress

Bad Behavior has blocked 4469 access attempts in the last 7 days.




Paid Advertisements
Guitar Lessons - Renegade Motorhome - Costa Rica - British Virgin Islands