+atari2600land Posted February 10, 2020 Share Posted February 10, 2020 So I have this: randomtrack1: db 0a0h, 0f0h, 0f0h randomtrack2: db 0f0h, 0a0h, 0f0h randomtrack3: db 0f0h, 0f0h, 0a0h tracknum: db randomtrack1 & 0ffh db randomtrack2 & 0ffh db randomtrack3 & 0ffh Each randomtrack data represents a sprite being on screen. If the value is f0h, then it's not on screen, but if it's a0h then it is. I have this variable called "randomness" that I'd like to put into a code that pulls the number of tracknum that is the value of "randomness" (0, 1, or 2.) So I started to do that. I have this: mov r0,#randomness mov a,@r0 mov r6,a ; randomness now in r6 add a,#tracknum & 0ffh movp a, @a ;get byte mov r1,a mov r0,#000h mov r7,#1 call copyspriteloop3 ... The problem is, I don't know what to do with r6 after I moved randomness into it. All I get if I put this in there is a pattern that keeps repeating over and over again, which isn't what I want to do at all. Help me, please. Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/ Share on other sites More sharing options...
+atari2600land Posted February 12, 2020 Author Share Posted February 12, 2020 Perhaps posting the entire code would help. chris17.a48 Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/#findComment-4455836 Share on other sites More sharing options...
carlsson Posted February 12, 2020 Share Posted February 12, 2020 I had a look, but I don't know the instruction set nor the system well enough to follow your clever coding. Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/#findComment-4456165 Share on other sites More sharing options...
DanBoris Posted April 2, 2020 Share Posted April 2, 2020 On 2/9/2020 at 10:47 PM, atari2600land said: So I have this: randomtrack1: db 0a0h, 0f0h, 0f0h randomtrack2: db 0f0h, 0a0h, 0f0h randomtrack3: db 0f0h, 0f0h, 0a0h tracknum: db randomtrack1 & 0ffh db randomtrack2 & 0ffh db randomtrack3 & 0ffh Each randomtrack data represents a sprite being on screen. If the value is f0h, then it's not on screen, but if it's a0h then it is. I have this variable called "randomness" that I'd like to put into a code that pulls the number of tracknum that is the value of "randomness" (0, 1, or 2.) So I started to do that. I have this: mov r0,#randomness mov a,@r0 mov r6,a ; randomness now in r6 add a,#tracknum & 0ffh movp a, @a ;get byte mov r1,a mov r0,#000h mov r7,#1 call copyspriteloop3 ... The problem is, I don't know what to do with r6 after I moved randomness into it. All I get if I put this in there is a pattern that keeps repeating over and over again, which isn't what I want to do at all. Help me, please. It's been a while since I have worked with the 8048, but I think you have a problem right away with this code: mov r0,#randomness mov a,@r0 mov r6,a ; randomness now in r6 Lets says randomness = 2. The first line moves 2 into R0. The second line gets the value in RAM that is at the address stored in R0, so in this case if will get whatever is stored in memory location 2 which is also R2. Line three moves that value in to R6. So randomness wouldn't end up in R6. Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/#findComment-4498792 Share on other sites More sharing options...
+atari2600land Posted April 3, 2020 Author Share Posted April 3, 2020 So how would I move #randomness into r6 then? Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/#findComment-4499403 Share on other sites More sharing options...
carlsson Posted April 3, 2020 Share Posted April 3, 2020 But would randomness ever be 2, or rather an address $006E or whatever range O2 games operate within? The value at that address may very well be 2, but then you first load the address to the label into R0, then load A with the content at the address pointed by R0 and move it to R6. Or at least that is how I interpret the instructions above. Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/#findComment-4499415 Share on other sites More sharing options...
DanBoris Posted April 3, 2020 Share Posted April 3, 2020 2 hours ago, atari2600land said: So how would I move #randomness into r6 then? MOV A,#randomness MOV R6,A Quote Link to comment https://forums.atariage.com/topic/301739-odyssey-2-programming-using-numbers-in-a-table/#findComment-4499463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.