English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 31 March 2022, 21:13   #1
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
PTPlayer / Vertical Blank Interrupt / 060

Hi!

I've just tried my RoboCop build out on some real hardware to see how it's looking and I've come across the following issue: when I the ptplayer audio initialised using '_mt_install_cia' and I start playing a mod file, the scrolling completely breaks, and the blitted objects all seem to go haywire.

Example here, the first part of the video shows how the game runs without the audio initialised and playing a mod, the second part with:

[ Show youtube player ]

This was recorded on FS-UAE, but the result is exactly the same on a 060 A4000 machine. I can only guess it's some sort of PTPlayer interrupt (level 6 I think) clashing with the vertical blank interrupt I have refreshing the display (level 3 I think).

No issues with a plain A1200 setup on FS-UAE, and I'm trying to get my A1200 hardware up and running to check that but in the mean time, does anyone have any pointers as to why this might happen?

Cheers,
Daniel
DanielAllsopp is offline  
Old 31 March 2022, 22:20   #2
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,406
I'm not entirely sure what causes this. I was thinking it might be a race condition between the interrupts, but given it's a protracker interrupt that causes the issue it seems to me that the race condition should not occur every frame (because the interrupt will not occur on the same scanline between frames). So that doesn't really make much sense.

It almost looks like some register isn't being properly saved/restored between the interrupts. Which would also be weird as the ptplayer you're referring to stacks all registers.

One thing that might certainly cause issues though, is that the interrupts on A4000's with fast accelerators can sometimes trigger multiple times in a row before the motherboard's slow interrupt acknowledgment gets processed. This would be the case if the interrupt ends too quickly (for instance, it's in fast memory or the cache).

Generally this can be fixed by acknowledging interrupts twice in the code instead of once (both in the PT Player and in the other interrupt code). This works because CPU access to chip memory/custom chips is slow enough to let the acknowledgment propagate before the CPU returns from the exception.

Last edited by roondar; 31 March 2022 at 22:30.
roondar is offline  
Old 31 March 2022, 22:49   #3
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
Try to disable int2 and 6 (so PT interrupts won't fire), if that fixes it interrupts are the cause. @roondar has good suggestions, especially "It almost looks like some register isn't being properly saved/restored between the interrupts" -> Look at your own interrupt routines, maybe they assume some registers have specific values (usual culprits being a4 or a6).
paraj is offline  
Old 31 March 2022, 23:46   #4
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
VBR ?

Do you have the value of the VBR? This needs to be passed to the player init
DanScott is offline  
Old 01 April 2022, 12:44   #5
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
Thanks all, I'll go across my code with a fine tooth comb and see if anything pops out at me.

Quote:
Originally Posted by DanScott View Post
VBR ?

Do you have the value of the VBR? This needs to be passed to the player init
Yeah, I think I'm passing on the correct VBR to the player init. That stuff is all handled by Photon's startup code but I will double check everything.

Thanks for the pointers everyone!
DanielAllsopp is offline  
Old 01 April 2022, 17:24   #6
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
So a bit more information:

- The VBR is getting set correctly via Supervisor() if the CPU is != 68000
- As far as I can see, all of the registers are being saved/restored (but I will be going over this again)
- If I install the vertical blank interrupt before I install the PTPlayer interrupt then the player doesn't initialise correctly and no sound is output at all.

I'll check on Gorman and continue my analysis...
DanielAllsopp is offline  
Old 01 April 2022, 19:08   #7
mc6809e
Registered User
 
Join Date: Jan 2012
Location: USA
Posts: 372
How much time does your vblank int handler take? Is it being delayed excessively by frequent lvl 6 ints generated by the player?

Have your vblank handler change the background color at the very end if your routine to see just when it competes relative to the rest of the screen.

Instead of vblank ints, maybe you can use the copper to trigger an int at the end of the last displayed line. This will give your handler more time.
mc6809e is offline  
Old 01 April 2022, 23:26   #8
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
More thinking out loud and trying anything... am I setting up my vertical blank interrupt correctly?

Code:
 
;-----
; install interrupt
move.l VBRPtr,a0
move.l #VerticalBlankInterrupt,INTVECTORL3(a0)
move.w #$c020,INTENA(a6)
Code:
VerticalBlankInterrupt:
  movem.l d0/a6,-(sp)
  lea CUSTOM,a6

  btst #5,$1f(a6) ;check if it's our vertb int.
  beq.s .notvb
  *--- do stuff here ---*

  bsr UpdateFrame

  *--- do stuff here ---*
  moveq #$20,d0 ;poll irq bit
  move.w d0,INTREQ(a6)
  move.w d0,INTREQ(a6)
.notvb:
  movem.l (sp)+,d0/a6
rte
DanielAllsopp is offline  
Old 01 April 2022, 23:40   #9
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Interrupt setup is OK. Does the "UpdateFrame" routine save/restore all used registers?
StingRay is offline  
Old 02 April 2022, 01:09   #10
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
Quote:
Originally Posted by StingRay View Post
Interrupt setup is OK. Does the "UpdateFrame" routine save/restore all used registers?
Yeah, I've checked and checked again. It's something to do with the blitter... everything seems to be fine with the sprites, but the blitter is doing weird things

This is what the output looks like on the A4000 (060):



This is the same executable on the A1200 with standard config:

DanielAllsopp is offline  
Old 02 April 2022, 01:21   #11
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Does your blitter code expect $dff000 in A6 just like your level 3 interrupt?

And is your blitter waits before or after your BLTSIZE activation?
Galahad/FLT is offline  
Old 02 April 2022, 01:39   #12
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
Set-up is ok if you preface it with e.g. $7fff to INTENA (disable everything, and btw calling exec's Disable() won't do the job properly). If you only do $c020 to INTENA, you are enabling VBL int3 but also leaving the rest as is (e.g. inherited from system, which has several other interrupts enabled).
I'd also do $0020 to INTREQ (in your case it doesn't matter I guess, but in general you might not want your interrupt to trigger right away because request bit was pre-set).
a/b is offline  
Old 02 April 2022, 02:07   #13
mc6809e
Registered User
 
Join Date: Jan 2012
Location: USA
Posts: 372
Your interrupt handler looks like it checks for the possibility of another interrupting event. Are there other events that cause an int3 like the blitter? If other int3s are possible, what happens to old vector to handle those ints? You don't save the old vector when installing your own.
mc6809e is offline  
Old 02 April 2022, 02:09   #14
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by a/b View Post
Set-up is ok if you preface it with e.g. $7fff to INTENA (disable everything, and btw calling exec's Disable() won't do the job properly). If you only do $c020 to INTENA, you are enabling VBL int3 but also leaving the rest as is (e.g. inherited from system, which has several other interrupts enabled).
I'd also do $0020 to INTREQ (in your case it doesn't matter I guess, but in general you might not want your interrupt to trigger right away because request bit was pre-set).
He already does $0020 to Intreq with the moveq #$20,d0
Galahad/FLT is offline  
Old 02 April 2022, 02:09   #15
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by a/b View Post
Set-up is ok if you preface it with e.g. $7fff to INTENA (disable everything, and btw calling exec's Disable() won't do the job properly). If you only do $c020 to INTENA, you are enabling VBL int3 but also leaving the rest as is (e.g. inherited from system, which has several other interrupts enabled).
I'd also do $0020 to INTREQ (in your case it doesn't matter I guess, but in general you might not want your interrupt to trigger right away because request bit was pre-set).
He already does the $0020 to INTREQ with that moveq #$20 at the end.
Galahad/FLT is offline  
Old 02 April 2022, 07:17   #16
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
Yep, but not while installing the interrupt handler (that's what I had in mind). If request bit is not cleared, interrupt might trigger right after you hit INTENA (for VBL doesn't matter much, but in general...).
a/b is offline  
Old 02 April 2022, 11:21   #17
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by DanielAllsopp View Post
Yeah, I've checked and checked again. It's something to do with the blitter... everything seems to be fine with the sprites, but the blitter is doing weird things
Is the blitter setup done correctly, most importantly modulo and mask registers?
StingRay is offline  
Old 03 April 2022, 23:10   #18
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by DanielAllsopp View Post
when I the ptplayer audio initialised using '_mt_install_cia' and I start playing a mod file, the scrolling completely breaks, and the blitted objects all seem to go haywire.
But the music is playing flawlessly? Did you check the correct player routine is called on a level 6 interrupt?

Sounds like there is something timing-critical in your VERTB-handler which cannot tolerate losing the CPU for the few raster lines the player needs. Also note that the ptplayer interrupts will always be at different frame positions. It is not synchronised with the video in any way.

Quote:
Originally Posted by DanielAllsopp View Post
- If I install the vertical blank interrupt before I install the PTPlayer interrupt then the player doesn't initialise correctly and no sound is output at all.
This is also very strange. Do level-6 timer interrupts happen at all in this case? Is the player routine called? Who calls _mt_install_cia? Is is called from the level-3 interrupt or from the "main" program? And this also happens only with 060 systems?

Generally the player should work fine with level-3 interrupts and I'm testing with my A3000/060 all the time. All my games are coded in a way that most of the engine is running in a VERTB-interrupt.
phx is offline  
Old 04 April 2022, 13:31   #19
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
Sorry guys, I've had the weekend off coding (things like this demotivate me immensely) but will pick up and try and get answers to your questions over the next couple of days. Thanks for all of your suggestions and input, I appreciate the help.

I won't let it defeat me
DanielAllsopp is offline  
Old 05 April 2022, 01:26   #20
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
Hi! Hopefully I've got some answers to your questions below, if not I'll try again in the morning. Here's a couple of files anyway:

Intro Executable
Level Executable
Startup Code

Thanks again for any help!

Quote:
Originally Posted by Galahad/FLT View Post
Does your blitter code expect $dff000 in A6 just like your level 3 interrupt?

And is your blitter waits before or after your BLTSIZE activation?
Yeah, A6 should always contain $dff000. I purposely don't use that register for anything else, but forcing it just to check results in the same issues.

Regarding the blitter waits, I tend to wait before I setup the blitter registers, so well before the BLTSIZH(a6) activation.

My blitter wait code is a macro and looks like this:

Code:
WAITBLITTER:macro
	tst.w (a6)			;for compatibility with A1000
.wb\@:	btst #6,2(a6)
	bne.s .wb\@
	endm
Quote:
Originally Posted by a/b View Post
Set-up is ok if you preface it with e.g. $7fff to INTENA (disable everything, and btw calling exec's Disable() won't do the job properly). If you only do $c020 to INTENA, you are enabling VBL int3 but also leaving the rest as is (e.g. inherited from system, which has several other interrupts enabled).
I'd also do $0020 to INTREQ (in your case it doesn't matter I guess, but in general you might not want your interrupt to trigger right away because request bit was pre-set).
I already have the $7fff to INTENA set in my startup code, so it's done before I do anything else like creating the other interrupts. See my startup.s file above.

Quote:
Originally Posted by mc6809e View Post
Your interrupt handler looks like it checks for the possibility of another interrupting event. Are there other events that cause an int3 like the blitter? If other int3s are possible, what happens to old vector to handle those ints? You don't save the old vector when installing your own.
I don't think other level 3 interrupts are possible, as I've disabled them in my startup code with $7fff.

Quote:
Originally Posted by StingRay View Post
Is the blitter setup done correctly, most importantly modulo and mask registers?
That was my first thought, but if that was the case wouldn't the blitter setup be incorrect for standard 020 systems where the issue doesn't occur?

Quote:
Originally Posted by phx View Post
But the music is playing flawlessly? Did you check the correct player routine is called on a level 6 interrupt?
Yeah, the music plays flawlessly, but I'm not sure how to check the player routine is being called correctly on a level 6 interrupt

Quote:
Originally Posted by phx View Post
This is also very strange. Do level-6 timer interrupts happen at all in this case? Is the player routine called? Who calls _mt_install_cia? Is is called from the level-3 interrupt or from the "main" program? And this also happens only with 060 systems?

Generally the player should work fine with level-3 interrupts and I'm testing with my A3000/060 all the time. All my games are coded in a way that most of the engine is running in a VERTB-interrupt.
_my_install_cia is installed from the main loop, and not the level 3 interrupt for the VBL. It seems to be only 060 systems, but I can't be sure. I guess I could check with 030 / 040 systems in FS-UAE but I don't have real hardware with those CPUs.

I've tried the very latest version of player too, and called _mt_music from the VBL interrupt with the VBLANK_MUSIC set to 1. Same issue too

Last edited by DanielAllsopp; 08 April 2022 at 19:46. Reason: Removed obsolete links to executable files... it's fixed!
DanielAllsopp is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiblitz 3 and PtPlayer Nightshft Coders. Blitz Basic 4 14 November 2021 00:28
CIA or vertical blank/copper interrupt for playing music in an intro? pushead Coders. Asm / Hardware 25 24 April 2021 11:40
Extended Vertical Blank sandruzzo Coders. Asm / Hardware 9 23 October 2019 15:17
Vertical blank and Bobs geldo79 Coders. Asm / Hardware 4 21 October 2019 10:04
ASM: Wait for Vertical Blank Asman Coders. Tutorials 75 01 October 2019 12:11

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:57.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10501 seconds with 16 queries