English Amiga Board


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

 
 
Thread Tools
Old 10 March 2020, 12:04   #1
DanielAllsopp
Registered User

DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 48
Remaining CPU Time

Hey!

Am I correct in thinking that the easiest way to see how much CPU time is remaining is to simply change COLOR00 to a different colour at the end of your main loop?

I have a double buffered setup on a 64 colour screen, based on Photon's double buffering example and I get the following:



When I don't swap the buffers over and I'm only setting a few sprite pointers and changing the palette in the copper, then I get a full screen of red which I assume is a lot of time left.

If however, I enable the buffer swap it drops dramatically! I imagine if I start doing anything else then the display will drop to 25fps and the red will start filling the screen up again?

Here's the code which is swapping the buffers:

Code:
SwapBuffers:
  move.w #$12c,d0			;No buffering, so wait until raster
  bsr.w WaitRaster		;is below the Display Window.

  *--- swap buffers ---*
  movem.l DrawBuffer(PC),a2-a3
  exg a2,a3
  movem.l a2-a3,DrawBuffer	;draw into a2, show a3

  *--- show one... ---*
  move.l a3,a0
  moveq #BytesSingleBitplaneLine,d0
  lea BplPtrs+2,a1
  moveq #DisplayDepth-1,d1
  bsr.w PokePtrs
  rts
Code:
PokePtrs:				                ;generic, poke ptrs into copper list
.bpll:	move.l a0,d2
	swap d2
	move.w d2,(a1)			          ;high word of address
	move.w a0,4(a1)			          ;low word of address
	addq.w #8,a1			            ;skip two copper instructions
	add.l d0,a0			              ;next ptr
	dbf d1,.bpll
	rts
The buffers are setup as such:

Code:
DrawBuffer:	dc.l Screen2		;pointers to buffers to be swapped
ViewBuffer:	dc.l Screen

*******************************************************************************
	SECTION ChipBuffers,BSS_C	;BSS doesn't count toward exe size
*******************************************************************************

  CNOP 0,8
Screen:
  ds.b DisplayHeight*BytesAllBitplaneLines

  CNOP 0,8
Screen2:
  ds.b DisplayHeight*BytesAllBitplaneLines
Everything look ok to everyone? Or do I have some major ASM noob mistakes in there?

I'm currently using FS-UAE; is there any reliable way to tell if the screen is updating at 50fps?

Thanks!
DanielAllsopp is offline  
Old 10 March 2020, 13:52   #2
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,710
Do you call the SwapBuffers before or after setting the colour?

I ask because SwapBuffers waits until rasterline $12c, which is fairly far down the screen. So if you only set the colour after that call, I'd expect exactly what we see here: you wait until end of frame and only then change colour.
roondar is offline  
Old 10 March 2020, 14:22   #3
DanielAllsopp
Registered User

DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 48
Quote:
Originally Posted by roondar View Post
Do you call the SwapBuffers before or after setting the colour?

I ask because SwapBuffers waits until rasterline $12c, which is fairly far down the screen. So if you only set the colour after that call, I'd expect exactly what we see here: you wait until end of frame and only then change colour.
I do indeed call SwapBuffers before setting the colour; and what you've said has made perfect sense now!

Let me do some fiddling around. Once again, thanks Roondar!
DanielAllsopp is offline  
Old 10 March 2020, 15:12   #4
DanielAllsopp
Registered User

DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 48
So although what you say makes complete sense roondar, it still makes no difference to what order I do this in:

Code:
MainLoop:

  move.w #$0000,BPLCON3(a6)
  move.w #$0b00,COLOR00(a6)
  move.w #$0200,BPLCON3(a6)
  move.w #$0400,COLOR00(a6)

  bsr SwapBuffers


	btst #6,CIAAPORTA		         ;Left mouse button not pressed?
	bne.w MainLoop			         ;then loop

    *--- exit ---*
	rts
Changing the scanline value from $12c in the WaitRaster code does affect the place where the colour is changed, so it still must be having an affect on it.

The WaitRaster code looks like this:

Code:
WaitRaster:				             ;Wait for scanline d0. Trashes d1.
.l:	move.l 4(a6),d1
	lsr.l #1,d1
	lsr.w #7,d1
	cmp.w d0,d1
	bne.s .l			               ;wait until it matches (eq)
	rts
Something doesn't quite make sense to me here.

Edit:
Hmm, unless I wait until the top of the screen before swapping buffers, so:

Code:
move.w #$2c,d0
bsr.w WaitRaster
and then continue with the main loop.

Last edited by DanielAllsopp; 10 March 2020 at 15:30. Reason: Brainwave!
DanielAllsopp is offline  
Old 10 March 2020, 15:49   #5
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,710
I generally wait for top of frame at the beginning of each frame. But you can also wait for bottom of frame at the end. It doesn't really change much, but it would change where you see the colour change

The way I use colour bars for showing "CPU use" is to start the colour change just prior to the stuff I want to time and change it back just prior to any "wait until next frame" routine. So in my code, I'd do something like:
Code:
Mainloop:
move.w #$000,color(a6) ; end raster bar
move.w #$2c,d0
bsr.w WaitRaster

move.w #$900,color(a6) ; start raster bar
<do stuff>
bra Mainloop
Edit:
Just for fun, a form of the above with "end of frame" waiting should then look like this (same idea, no extra time spend waiting, but bar is now in a different place as the code starts to run at a different scanline):
Code:
Mainloop:
move.w #$900,color(a6) ; start raster bar
<do stuff>

move.w #$000,color(a6) ; end raster bar
move.w #$12c,d0
bsr.w WaitRaster

bra Mainloop
Edit 2: note you can wait on any raster position in these examples, this really doesn't change anything other than the "when in frame" the code runs. You can also do the top example using $12c instead if you like that better, or the bottom with $2c...

Last edited by roondar; 10 March 2020 at 15:55. Reason: Added some stuff for fun (and profit?!)
roondar is offline  
Old 10 March 2020, 15:53   #6
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,694
Daniel, Also don't forget you can use the visual debugger which is extremely useful for measuring time.

Go into the debugger with shift+F12 and type v -2

You'll then see all cycle slots consumed by time on the Amiga.

PS. If someone know an online resource for the different colour meanings then please post it.

...

Just a little note on the woes of double buffering.... I've seen loads of people struggle (including me) with implementing double buffering. What normally happens is you'll get artifacts remaining from the previous frame that hasn't been restored properly. So remember, when restoring a frame you need to restore the data for the previous frame that was shown and not the current one being built. I've found the easiest way to achieve it (for me) is to use a third pristine screen and simply hold an offset from screen origin, modulo and blit size for the rectangle to be restored, when restoring you simply feed back those values back to the blitter from the source pristine screen to the screen being rebuilt.

Last edited by mcgeezer; 10 March 2020 at 16:02. Reason: Double Buffering woes.
mcgeezer is offline  
Old 10 March 2020, 15:57   #7
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,710
Quote:
Originally Posted by mcgeezer View Post
PS. If someone know an online resource for the different colour meanings then please post it.
Don't have that, but I can tell you that in my version
  • red = audio
  • yellow = copper
  • grey = cpu
  • blue = bitplanes
  • blue/green = blitter
  • white = disk
  • black = idle
  • dot at start of scanline (various colours): interrupt (f.e.x. a red dot for CIA timer interrupt, dark blue for audio, IIRC yellow for copper/blitter)

Last edited by roondar; 10 March 2020 at 16:00. Reason: Added the colour for disk DMA, reordered
roondar is offline  
Old 10 March 2020, 16:43   #8
DanielAllsopp
Registered User

DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 48
Brilliant advice and guidance as usual guys. Thanks a lot for your insights!

I didn't know about the DMA Debugger in FS-UAE, so that's another good thing to know!
DanielAllsopp is offline  
Old 10 March 2020, 16:51   #9
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,694
Quote:
Originally Posted by DanielAllsopp View Post
Brilliant advice and guidance as usual guys. Thanks a lot for your insights!

I didn't know about the DMA Debugger in FS-UAE, so that's another good thing to know!
Ohhh... not sure it's implemented in FS-UAE... it is in WinUAE.
mcgeezer is offline  
Old 10 March 2020, 16:54   #10
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,442
Roondar's list is right. Just for completeness, full DMA slots colors:

Code:
Refresh 	0x444444
CPU code	0xa25342
|__data 	0xad98d6
Copper		0xeeee00
|__wait		0xaaaa22
|__special/$E0	0x666644
Audio		0xff0000
Blitter		0x008888
|__fill		0x0088ff
|__line		0x00ff00
Bitplane	0x0000ff
Sprite		0xff00ff
Disk		0xffffff
and IRQ colors:
Code:
noIRQ		0x000000
i1		0x444444
i2		0x008800
i3		0xffff00
i4		0x000088
i5		0x880000
i6		0xff0000
i7		0xffffff
now if someone wants to convert from RGB to verbose color names, how did roondar, does us a favor

Last edited by ross; 10 March 2020 at 17:19. Reason: added IRQs
ross is offline  
Old 10 March 2020, 17:50   #11
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,710
Quote:
Originally Posted by ross View Post
and IRQ colors:
now if someone wants to convert from RGB to verbose color names, how did roondar, does us a favor
Your wish is my command
Code:
noIRQ                                   0x000000
Software/Disk block/Serial empty        0x444444
Ports/Timers		                0x008800
Copper/VBlank/Blitter		        0xffff00
Audio (0-3)		                0x000088
Serial receive/Disk sync		0x880000
External interrupt		        0xff0000
NMI		                        0xffffff
(assuming the list used by WinUAE is identical to the INTENA bit assignments)
roondar 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
Help us sorting out mantis database / remaining bugs/todo in slaves jotd project.WHDLoad 14 06 July 2019 00:04
Selling A3660 CPU card, including Rev 5 CPU - NEW - professionally built tbtorro MarketPlace 1 17 June 2018 20:14
Amiga joystick on pc for xyz time, but this time with adapter? :) Srksi support.WinUAE 3 24 May 2018 04:57
App to update Amiga System time from web time?? DDNI request.Apps 2 31 December 2007 08:21
Biggest remaining WHDload improvement needed: Stop the flashing! mr_a500 project.WHDLoad 22 13 February 2006 09:20

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 11:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.07172 seconds with 14 queries