Jump to content
IGNORED

Drawing a playfield... what am I doing wrong here?


PicardHS

Recommended Posts

This is probably a stupid mistake, but I can't figure out what I'm doing wrong. I'm just trying to draw the Atari logo on the playfield. The bitmap is 31 lines long, but I'm using LSR twice before loading it so it is the same for four scanlines.

 

Here is my code for looping through the scanlines:

        ldy #191
        
        tya
        lsr
        lsr
        tax
ScanLoop
        lda PFData2,X
        sta PF2
        lda PFData1,X
        sta PF1
        
        sta WSYNC
        
        tya
        lsr
        lsr
        tax
        
        dey
        bne ScanLoop

And I get something that looks like this:

post-49237-0-84865100-1495647142.png

 

Thanks in advance, I don't know where I messed up here.

 

Edit: Woops, that whole four lines of "tya lsr lsr tax" was meant to go after the DEY. I don't think that was causing it lol.

Edited by PicardHS
Link to comment
Share on other sites

Shouldn't the Y register be loaded with 31*4 and not 191?

Sorry for confusion, but that is actually the amount of scanlines in the TV frame, I have it decrementing down as I loop through the scanlines.

 

Also, I am very very sorry for this late response. :\

Link to comment
Share on other sites

Yeah, 191 divided by 4 is 47, but you only have 31 lines of actual picture data, so indices 47 down to 31 will fetch garbage (whatever lies past the bitmap in the ROM), and then indices 30 through 0 will read the actual picture. So you either have to extend the picture to fill the entire screen, or add some padding before and/or after the picture and have the loop go from 124 down.

 

Also, why write the tya, lsr, lsr, tax block twice? You could move the ScanLoop label up and completely remove the second instance of these instructions.

Edited by tokumaru
Link to comment
Share on other sites

add some padding before and/or after the picture and have the loop go from 124 down.

That seems like a good solution. I'll try it out.

 

 

Also, why write the tya, lsr, lsr, tax block twice?

One of them is before the frame starts, one is during the actual picture drawing before the next scanline, to prepare for drawing the next scanline. Having it during the hblank on that scanline itself I think takes up too many cycles.

Edited by PicardHS
Link to comment
Share on other sites

I tried your solution, and it worked! Thank you, tokumaru! I'll see if there is a better solution than having the same four lines twice. I could make it only update the TIA every four scanlines, but I don't really feel like doing that. I want to make a static effect for this, that was the original idea, but I got hung up on the playfield 'cause I'm a noob and haven't done this in a while.

Link to comment
Share on other sites

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...