Videopac / Odyssey2 forum
February 22, 2019, 12:05:22 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Al lot of attachments from Nov 2011 till april 2012 are damaged. Please ask the original poster to re-upload if you need them.
 
   Home   arcade Help Login Register links videopac.nl  
Pages: [1]   Go Down
  Print  
Author Topic: Sprite colors  (Read 207 times)
Chris!
Give this man a Jopac!
******
Posts: 1119



WWW
« on: November 14, 2018, 02:57:48 PM »

So I want a particular sprite, sprite 1, to get a random color. Right now, I have this code:
Code:
mov r1,#006h
mov a,t
anl a,#0F8h   
movx @r1,a
Which does a good job, but it only selects from half the available colors (0, 2, 4, and 6). I want to know why this is happening and if there's a way to make the program "choose" from all 8 colors instead of just 4.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Sdw
Trying to get the cartridge in...
*
Posts: 30


« Reply #1 on: November 14, 2018, 03:59:13 PM »

It seems like you are getting your value from a timer, right?
I'd say that some kind of pseudo-random function would be better suited for this.
Logged
TedFoolery
Played Munchkin once...
**
Posts: 71


« Reply #2 on: November 14, 2018, 04:40:42 PM »

Yes, a random function generator would be ideal, but for the sake of speed or byte size you could also try using a different group of bits from the timer. This uses the first three bits and moves them to the correct position:
Code:
mov r1,#006h
mov a,t
anl a,#03h
rl a
rl a
rl a
movx @r1,a

or use the last three bits:
Code:
mov r1,#006h
mov a,t
anl a,#0e0h
rr a
movx @r1,a
Logged
Chris!
Give this man a Jopac!
******
Posts: 1119



WWW
« Reply #3 on: November 14, 2018, 05:02:18 PM »

I was fiddling around with the code a little and found this gives great results, and it's random every time you turn the Odyssey2 on:
Code:
mov r0,#lettercolor
movx a,@r0
add a,#8
movx @r0,a

mov R1,#lettercolor
mov R0,#03Eh
mov a,t
anl a,#0F8h   
movx @R1,a
I put this in a call routine when the sprite color needs to be changed.
The "lettercolor" is actually a sprite. The sprites are letters. I got bored of the standard ones so I made a couple of new ones. They're lowercase this time. I thought the Odyssey 2 had an RNG, the t (for timer) function. Or am I wrong?
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!