27 November 2017, 15:18 | #1 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Blitter interrupt during VERTB interrupt
In an unnamed project I have a queue with several 16x16 tiles to blit (each node has bitmap and tile image address). I thought about processing the queue with Blitter interrupts, so I am free to run any code I like while the Blitter is busy.
The problem: My main program is running in a VERTB interrupt, and I am probably confused. Both are level 3 interrupts, so the Blitter can never interrupt my program, right? Does it make sense to change the interrupt mask with "MOVE #$2200,SR" during my VERTB interrupt to allow new level 3 interrupts again? I really would like to have both: run my program in VERTB and use Blitter interrupts... |
27 November 2017, 15:24 | #2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Read INTREQR to check what kind of level 3 interrupt was triggered (copper, blitter, vertical blank) and acknowledge them accordingly.
|
27 November 2017, 15:52 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Hmm? Are you saying that Copper, Blitter and Vertb interrupts can interrupt each other?
That would be easy... To clarify: I want several Blitter interrupts to be processed WHILE the VERTB interrupt handling is still running. Last edited by phx; 27 November 2017 at 16:04. Reason: Clarification |
27 November 2017, 16:14 | #4 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
The only way to get a same level IRQ is as you say, but you have to clean INTREQ VERTB first to avoid immediate re-trigger. Or poll BLIT bit at some time in your VBL routine.. (not so good). EDIT: and warning, the following VERTB can trigger (so better some semaphore in code) Last edited by ross; 27 November 2017 at 16:24. Reason: [] |
|
27 November 2017, 16:52 | #5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Ahh, ok! Thanks. Makes sense.
The following VERTB should not interrupt me, otherwise my game engine is too slow and I have to optimize it. |
27 November 2017, 16:55 | #6 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I think the best way to achieve this is to trigger a SoftInt (which is level 1) at the start of the vertical blank interrupt, then do the job in that new int.
Then this work can be interrupted by a level 3 interrupt and you have no risk of reentrancy. How exactly this is done, depends if your code is OS friendly or not. |
27 November 2017, 17:00 | #7 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
VBL won't interrupt Blitter handler and vice versa. You'll need one handler and then check INTREQR bits and clear them appropriately, as pointed out above.
Something like: Code:
btst #6,$dff01e beq.b NotBlitter move.w #$0040,$dff09c ; start another blit here NotBlitter: btst #5,$dff01e beq.b NotVBL move.w #$0020,$dff09c ; your main VBL code here NotVBL: rte |
27 November 2017, 17:12 | #8 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
If your "new VBL Level 1" is interrupted immediately by a blitter storm, and you needed to make some init before some raster position, you can have bad video glitch. EDIT: indeed these are only theoretical speculations, if the BLIT or VBL IRQ drivers are slow then there is something wrong in code Last edited by ross; 27 November 2017 at 17:24. |
|
27 November 2017, 17:22 | #9 | |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
Quote:
|
|
27 November 2017, 17:55 | #10 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Of course only the low priority stuff has to be put out of the vbl handler. This is, as Kalms said, moving heavy processing out of the vbl.
|
27 November 2017, 18:16 | #11 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Indeed, I quite like the soft-int solution. Will think about it.
Thanks for your comments! |
27 November 2017, 20:43 | #12 | |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 259
|
Quote:
Does your main routine needs to run in supervisor mode? If not, you could also wait for the VBI by hand checking the INTREQR register and execute your main routine in user mode. So it would be no problem to interrupt it by a level3 blitter-finish-interrupt. |
|
27 November 2017, 21:55 | #13 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Hi dissident! Good ideas in your post but .. how to make them coexist real-time copper video effects with blitter register write that copper should do in "random" moments?
Create a (slow) copper list that already contains all possible blitter register writes in every lines? [EDIT: yes, you can insert a simple COPxLC/COPJMPx pair, but then you need to limit your CMOVEs to defined quantity to not disrupt CWAIT code when you are back in the original list] And there also the question of double writes to "slow bus".. first write to chip ram to fill copper list, then from copper to registers. phx is not talking about a demo in which you manage the limitations you are subjected to, but a game where you have to make switches of various colors each line, modify BPLxPT, multiplexing sprite or who know I'm not against this method, but I think that is useful for CWAIT (with BFD=0) in vertical video blank period only. And then in that case COP2LC/COPJMP2 idea is applicable. I vaguely remember that i've debugged something similar. Last edited by ross; 27 November 2017 at 22:08. Reason: [] |
27 November 2017, 23:28 | #14 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
How many cycles will pass, when blitting a 16x16 tile with 5 planes and mask? All DMA channels used. Quote:
Quote:
Indeed, there will be multiplexed sprites, color changes and scrolling. |
|||
28 November 2017, 00:39 | #15 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
Well, there are actually several reasons for this choice. But too OT, maybe for another thread |
|
28 November 2017, 15:57 | #16 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,510
|
There is not much gained by running CPU and blitter simultaneously if blitter cycle sequence does not have any idle cycles (which are always available for the CPU. Don't waste them!). In no-idle-cycle case CPU is immediately (technically after 2 or 3 cycles) blocked until blitter finishes.
IMHO it is practically only useful when clearing (every other blitter cycle is idle cycle) or D=A filling (every 3rd cycle is idle cycle). All other common channel combinations don't have idle cycles. Only exception is if code is running in real fast ram. (or blitter nasty not set but why would you do that in a demo or game?) |
29 November 2017, 17:17 | #17 | |||
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 259
|
Quote:
For OCS, assuming the steady registers are already initialized and the A&B-pointers point to the repeated bar/mask pattern (8 colours) in memory which are increased after every blit automatically, this could look like this: The CPU only changes the $xxxx positions, the display starts at $2C and is visible within the positions $81-$1C1, the blit and the BPLxPT updates are done in the horizontal blank area. Code:
DC.W $0040,$xxxx ;BLTCON0 DC.W $0042,$xxxx ;BLTCON1 DC.W $0048,$xxxx ;BLTCPTH DC.W $004a,$xxxx ;BLTCPTL DC.W $0054,$xxxx ;BLTDPTH DC.W $0056,$xxxx ;BLTDPTL DC.W $2bd3,$fffe ;WAIT $D2,$2B DC.W $0058,(3*1*64)+(32/16);BLTSIZE DC.W $2be1,$fffe ;WAIT $E0,$2B DC.W $00e2,$0040 ;BPL1PTH DC.W $00ea,$nnnn ;BPL1PTL DC.W $00f2,$0040 ;BPL2PTH DC.W $00e6,$nnnn ;BPL2PTL DC.W $00ee,$0040 ;BPL3PTH DC.W $00f6,$nnnn ;BPL3PTL DC.W $0102,$xxxx ;BPLCON1 DC.W $0180,$xxxx ;COLOR00 DC.W $0001;$0000 ;Pseudo blitter finished (OCS A1000/2000A bug) DC.W $0001;$0000 ;The real blitter wait DC.W $0040,$xxxx ;BLTCON0 DC.W $0042,$xxxx ;BLTCON1 DC.W $0042,$xxxx ;BLTCON1 DC.W $0048,$xxxx ;BLTCPTH DC.W $004a,$xxxx ;BLTCPTL DC.W $0054,$xxxx ;BLTDPTH DC.W $0056,$xxxx ;BLTDPTL DC.W $2bd3,$fffe ;WAIT $D2,$2C ... Quote:
Quote:
Yes, this is a good idea as in the vertical blank area no bitplane DMA interrupts the blitter DMA. |
|||
29 November 2017, 17:57 | #18 | |||||
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 259
|
Quote:
Quote:
Code:
8*16*5*2 t= ---------- =180,55 microseconds 7.09 BTW: Why do you use all channels? I suppose these are your blits to copy objects in to a background picture. Quote:
COP2LC-jump-pos already initialized by the CPU. The CPU only changes $xxxx. Code:
cop1 ... DC.W $008A,$0000 ;Jump to copperlist2 cop2 ... DC.W $0001,$0000 <- Entry for second blit DC.W $0001,$0000 DC.W $0040,$xxxx .... DC.W $0058,$xxxx DC.W $0001,$0000 <- Entry for first blit DC.W $0001,$0000 DC.W $0040,$xxxx .... DC.W $0058,$xxxx DC.W $FFFF,$FFFE <- Entry for no blit Quote:
Quote:
Code:
DC.W $2C01,$7FFE ;Wait y-pos & pseudo waitblit DC.W $0180,$xxxx DC.W $0001,$0000 DC.W $0040,$xxxx .... DC.W $01FE,$0000 ;Changed to $0058,$xxxx if blit is used / needed DC.W $2D01,$FFFE DC.W $0180,$xxxx DC.W $2E01,$7FFE DC.W $0180,$xxxx DC.W $0001,$0000 DC.W $0040,$xxxx .... DC.W $01FE,$0000 ;Changed to $0058,$xxxx if blit is used / needed |
|||||
29 November 2017, 18:03 | #19 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Toni is certainly right. This discouraged me so much that I reverted all my Blitter interrupt code last night. So I will just set Blitter to Nasty and copy all masked tiles.
|
29 November 2017, 18:30 | #20 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Thanks for the examples with the Copper blits. I have to think about it. Maybe there will even be enough room after the last sprite-multiplexing in the middle of the screen (for a parallax effect). There shouldn't be much copper activity until end of frame. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Q: Copper Interrupt | Herpes | Coders. Asm / Hardware | 3 | 25 April 2016 13:31 |
Trigger level 7 interrupt | geir | support.FS-UAE | 2 | 15 August 2015 22:45 |
Interrupt 7 | BigT | support.WinUAE | 2 | 07 September 2013 22:25 |
level 7 interrupt on A600 | xc8 | Hardware mods | 1 | 26 October 2008 14:53 |
Level 7 interrupt | Kintaro | support.WinUAE | 1 | 21 January 2004 17:31 |
|
|