Jump to content

Photo

Weird problems with COLUPF/COLUBK inside Main Loop

colupf colubk weird loop

7 replies to this topic

#1 IuriNery OFFLINE  

IuriNery

    Space Invader

  • 10 posts

Posted Sat Feb 17, 2018 5:04 PM

Hello everyone, I'm trying to create a playfield with different colors, but something weird is happening. Some of the lines of PF/BK are not aligned properly.

 

Here is the Screenshot:

colupf_problem.jpg

 

Here is the assembly code:

Attached File  atari3.asm   31.82KB   41 downloads

 

If I set COLUPF or COLUBK on the main loop, it seems that it messes with some of the lines, but if I set a single color for both COLUPF and COLUBK before the StartOfFrame, everything seems to work fine.

I don't know what I'm doing wrong here, if someone could help me I would be really glad. Thank for your time.

 


#2 easmith OFFLINE  

easmith

    Moonsweeper

  • 270 posts
  • Location:Alexandria, VA

Posted Sat Feb 17, 2018 6:17 PM

I think you are waiting too many cycles to write to the registers after WSYNC. You only have 22ish cycles of Hblank . 

 

try moving the writes to COLUxx right after WSYNC and before writes to PFx .  Still not perfect but it is better.

 

I think you might also be writing to PF after HBLANK and need to preload graphics for next line.


Edited by easmith, Sat Feb 17, 2018 6:49 PM.


#3 SpiceWare ONLINE  

SpiceWare

    Draconian

  • 12,797 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sat Feb 17, 2018 6:49 PM

Work your way through the Collect tutorial.  This particular issue is known as shearing, and is covered in Step 4 - 2 Line Kernel.  

 

It even occurred in released games back in the day, like on the right side of Air-Sea Battle:

 

s_AirSeaBattle_1.png



#4 IuriNery OFFLINE  

IuriNery

    Space Invader

  • Topic Starter
  • 10 posts

Posted Sun Feb 18, 2018 7:46 AM

I think you are waiting too many cycles to write to the registers after WSYNC. You only have 22ish cycles of Hblank . 

 

try moving the writes to COLUxx right after WSYNC and before writes to PFx .  Still not perfect but it is better.

I moved COLUPF & COLUBK as you said, it's better indeed. There are only 2 small issues now:

colupf_problem2.jpg

 

Attached File  atari4.asm   31.83KB   25 downloads

 

 

 

I think you might also be writing to PF after HBLANK and need to preload graphics for next line.

Can you please elaborate on that?

 

 

 

Work your way through the Collect tutorial.  This particular issue is known as shearing, and is covered in Step 4 - 2 Line Kernel.  

I will take a look, thanks!

 

 

 

 

It even occurred in released games back in the day, like on the right side of Air-Sea Battle:

Interesting, so this is a common thing that happens with Atari games that has lots of colors, gradients etc.?

 

 

EDIT: is there a way to set the COLUPF and COLUBK for all the lines once? (outside the game main loop)


Edited by IuriNery, Sun Feb 18, 2018 9:06 AM.


#5 easmith OFFLINE  

easmith

    Moonsweeper

  • 270 posts
  • Location:Alexandria, VA

Posted Sun Feb 18, 2018 10:06 AM

Putting a WSYNC before you blackout the playfield should  fix the bottom line.

 

The other anomaly I think is caused by writing to PF1    1 or 2  cycles late. Not sure how to fix it , I am pretty new.

I think the 2 LK in Collect Tutorial might be the only way to fix it .   I'm not sure I understand it 100% 



#6 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • 762 posts
  • Location:Orlando, FL US

Posted Sun Feb 18, 2018 12:59 PM

If you use a repeating playfield you can set PF0 and PF1 at the end of the previous line during the time PF2 is drawn. That way you can save hblank for other updates such as cokupf and colubk.

#7 tokumaru OFFLINE  

tokumaru

    Moonsweeper

  • 263 posts
  • Location:Rio de Janeiro - Brazil

Posted Sun Feb 18, 2018 8:04 PM

When designing kernels you have to mind WHEN the various registers are being updated. The TIA is continuously drawing images, so if you change something while the TIA is in the middle of a scanline, that change will appear at that point.

A carefully designed kernel will try to keep track of where things are and which part of the screen the TIA is drawing to avoid updating them exactly when they're being rendered.

#8 gauauu OFFLINE  

gauauu

    Moonsweeper

  • 412 posts
  • Location:Illinois

Posted Wed Feb 21, 2018 5:50 PM

This is where the Stella debugger can be really helpful. It will show you exactly where the TIA is on the scanline at any given point as you step though your kernel, making it easy to see where your timing is off.





Also tagged with one or more of these keywords: colupf, colubk, weird, loop

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users