Jump to content
IGNORED

Odyssey 2 programming - using numbers in a table


Recommended Posts

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.

 

  • 1 month later...
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.

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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...