Jump to content
IGNORED

A temporary black UI glitch when turning player on in P/M graphics


mirao

Recommended Posts

Hi, I playing with P/M graphics in assembly code (here is my demo) and very often when I run the program I'm getting a disturbing black stripe (for about 0.1 sec) just before player (green square) is turned on.

 

image.png.96001c90527062e19da9619060edf031.png

I tested it in emulators Altirra and also in atari800. The issue happens in both.

Is it a known behavior or could I prevent it somehow? I know it's a triviality, just wondering if anything is wrong in my code.

I think that when I had a real Atari HW (Atari 800XE) a saw the glitch several times too, but not quite sure as it's a long time ago.

Edited by mirao
Link to comment
Share on other sites

Hi!

14 minutes ago, mirao said:

Hi, I playing with P/M graphics in assembly code (here is my demo) and very often when I run the program I'm getting a disturbing black stripe (for about 0.1 sec) just before player (green square) is turned on.

 

image.png.96001c90527062e19da9619060edf031.png

I tested it in emulators Altirra and also in atari800. The issue happens in both.

Is it a known behavior or could I prevent it somehow? I know it's a triviality, just wondering if anything is wrong in my code.

I think that when I had a real Atari HW (Atari 800XE) a saw the glitch several times too, but not quite sure as it's a long time ago.

 

You are first enabling the P/M graphics, and then enabling P/M DMA, so you have one frame with bus-data in your P/M.

 

Correct way is to do all the settings in one frame, to avoid any flicker. In Turbo BASIC XL and FastBasic, you can use a "PAUSE 0" just before starting to write to registers.

 

Have Fun!

 

  • Like 1
Link to comment
Share on other sites

50 minutes ago, dmsc said:

Hi!

 

You are first enabling the P/M graphics, and then enabling P/M DMA, so you have one frame with bus-data in your P/M.

 

Correct way is to do all the settings in one frame, to avoid any flicker. In Turbo BASIC XL and FastBasic, you can use a "PAUSE 0" just before starting to write to registers.

 

Have Fun!

 

 

Hi, thank you very much. When i submitted my question I got similar idea too 🙂

Solved by inserting of lda:cmp:req RTCLOK + 2 between setting of SDMCTL (DMA) and GRACTL (turn player on): https://github.com/mirao/atari800-asm/blob/master/joystick/joystick.asm#L55-L60

Edited by mirao
Link to comment
Share on other sites

It's not uninitialized data, it's bus data as dmsc noted. The issue is that SDMCTL is an OS shadow variable while GRACTL isn't, so DMACTL isn't updated from SDMCTL until vertical blank, while GRACTL goes live immediately. This causes GTIA to try to pull data that ANTIC hasn't put there. The suggested change above fixes this by waiting for RTCLOK to tick over, thus confirming that the VBI handler has run to copy SDMCTL to DMACTL, and then changing GRACTL in the same vertical blank.

 

Another way to fix this is to wait for vertical blank first, then write both SDMCTL and DMACTL. This avoids the possibility of a glitch if the VBI runs between the write to SDMCTL and the wait for VBI loop.

 

Technically, waiting for RTCLOK isn't quite correct here as that is incremented in VBI stage 1, while the majority of shadow variables including SDMCTL are processed in VBI stage 2. The latter can be skipped if an IRQ happens to run at just the wrong time to preempt VBI stage 2, such as the keyboard IRQ. In practice, this seems to be rare as I've never actually seen it happen. There are ways to poll for VBI stage 2, though, such as writing $FF to PTRIG7 and polling it until bit 7 clears.

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

23 hours ago, phaeron said:

....

There are ways to poll for VBI stage 2, though, such as writing $FF to PTRIG7 and polling it until bit 7 clears.

 

Thanks for explanation, it makes me things more clear.
Waiting for VBI stage 2 (that prevents black artifact) works for me this way:

; Enable player with double line resolution
mva #42 SDMCTL

; Wait for VBI stage 2, otherwise you might get a black stripe glitch when player is turned on
; Waiting uses the fact that PTRIG7 is reset in VBI stage 2 after SDMCTL -> DMACTL
mva #$ff PTRIG7
bit:rmi PTRIG7

; Turn on player
mva #2 GRACTL

 

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