Jump to content
IGNORED

Asymmetric playfield problem


jbs30000

Recommended Posts

Hi. Although I'm not new to programming, or even 2600 programming, I am new to 2600 asm programming.

 

I've been following along with the tutorials made by Andrew Davie. They're fantastic and easy to follow. But I've come upon a strange problem.

 

I'm on chapter 20, which is asymmetric playfields. I wrote code, OK, mostly copied code, to display my own 40x192 playfield. When I first ran the program the playfield was upside down, but otherwise displayed right. So I flipped the playfield, re-ran the FSB program to create playfield data and re-assembled the program. Now the image isn't quiet drawn correctly.

 

Here is the upside down version post-12524-0-90382800-1322739878_thumb.png and here is the right-side up version post-12524-0-66938600-1322739915_thumb.png

 

Here is the asm file Test.asm

and if it will help, the image data Test1.asm

 

Thank you.

Edited by jbs30000
Link to comment
Share on other sites

The glitch at the top of the screen is because you're not clearing PF0,PF1, and PF2 at the end of each frame, so it's displaying the last data in those registers at the top.

 

The glitch at the bottom of the screen is because your data crosses a page boundary... when you're loading PF data and the page boundary is crossed an extra cycle is needed, throwing off the timing of your kernel.

 

A quick fix is to add "align 256" strategically above data to ensure it doesn't do this, though a less wasteful solution is to explicitly place the data in specific locations so this doesn't happen.

Link to comment
Share on other sites

Oh, and to make sure that it wasn't the image file that was the problem, I reused the image file that was displaying upside down and changed the code in the test program to display it right side up. It looks better, but it has some garbage on the top of the screen.

post-12524-0-05963400-1322743148_thumb.png

 

I guess I'm having a hard time telling if it's the image or the code to display it.

Link to comment
Share on other sites

The glitch at the top of the screen is because you're not clearing PF0,PF1, and PF2 at the end of each frame, so it's displaying the last data in those registers at the top.

 

The glitch at the bottom of the screen is because your data crosses a page boundary... when you're loading PF data and the page boundary is crossed an extra cycle is needed, throwing off the timing of your kernel.

 

A quick fix is to add "align 256" strategically above data to ensure it doesn't do this, though a less wasteful solution is to explicitly place the data in specific locations so this doesn't happen.

Sorry, for some reason when I posted my second post, I didn't see this one.

 

OK, so do I place the data in a specific location by using the SEG and ORG directives? Or maybe just ORG?

 

Thank you.

Edited by jbs30000
Link to comment
Share on other sites

You do not need the SEG at the beginning, only ORG $F000.

 

In Test1.asm put an "align 256" in front of every strip label:

 

align 256

Test1_STRIP_0

.byte 255

...

align 256

Test1_STRIP_1

.byte 255

...

 

And since you are using an inverted playfield you need to add

 

lda #$FF

sta PF0

sta PF1

sta PF2

 

after sta VBLANK. That should fix it.

post-27536-0-94221000-1322780791_thumb.png

  • Like 1
Link to comment
Share on other sites

To save a bit of rom, you can throw in a check to ensure its only done when the data is crossing a boundary. I also like to include a message to let me know how many bytes the padding wasted...

 

  if >. != >[.+192]
pad1start
  align 256
pad1end
  echo "padding 1 wasted ",(pad1end-pad1start)," bytes"
  endif

Link to comment
Share on other sites

You do not need the SEG at the beginning, only ORG $F000.

 

In Test1.asm put an "align 256" in front of every strip label:

 

align 256

Test1_STRIP_0

.byte 255

...

align 256

Test1_STRIP_1

.byte 255

...

 

And since you are using an inverted playfield you need to add

 

lda #$FF

sta PF0

sta PF1

sta PF2

 

after sta VBLANK. That should fix it.

 

OK, I did what you said, and it looks a lot better, but there is a line that goes across most of the top of the screen.

 

I've been checking my code against what the tutorial and what you and RevEng have been saying, and it appears to match, but apparently I have done something wrong. If you, or somebody, wouldn't mind checking my code one last time I would really appreciate it. I'm sure it must be a tiny error. Thank you.

 

I'll just post the program code, as the image code is what I posted with align 256 added before each data table.

Test.asm

Link to comment
Share on other sites

OK, I found a solution. Before Test1_STRIP_0 I put ORG $F100. Before Test1_STRIP1 I put ORG $F200, and so on.

 

I thought that doing that would do the same thing as putting an align 256 before each data table, but apparently not.

 

Not sure what went wrong, but it should. I use this very same approach (the conditional one) with strips of bitmap data in the bB titlescreen kernel module, since I can't dictate what ORG the data will eventually wind up at. Never had a problem with it.

Link to comment
Share on other sites

You are starting your reads from the tables at index 192. However, only indexes 0 through to 191 have valid data. To correct this problem change all the "lda Test1_STRIP_0,x" instructions to "lda Test1_STRIP_0-1,x" (repeat for all the strips). I know that doesn't look right but you actually terminate the loop after a pass where X is equal to 1. There is no pass through the loop with X equal to 0 meaning you have an out by one error.

Link to comment
Share on other sites

I don't know if you got it running by now, but here is what I used to create the above image. It's a modification of your first Test.asm. Since this uses an incrementing loop, it runs from 0 to 191 and avoids the issue GroovyBee mentioned.

 

I also included the listing created by dasm (add -lTest.lst, I renamed it to Test.list.asm so that I could upload it). It can be seen that the aligns work as expected, strip 0 at $F100, strip 1 at $F200 and so on.

Test.asm

Test1.asm

Test.list.asm

Link to comment
Share on other sites

I don't know if you got it running by now, but here is what I used to create the above image. It's a modification of your first Test.asm. Since this uses an incrementing loop, it runs from 0 to 191 and avoids the issue GroovyBee mentioned.

 

I also included the listing created by dasm (add -lTest.lst, I renamed it to Test.list.asm so that I could upload it). It can be seen that the aligns work as expected, strip 0 at $F100, strip 1 at $F200 and so on.

 

Yes, adding the ORG statements made the program run fine, but I will check out what you did. Thank you.

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