Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Free CPU ressources  (Read 3143 times)

0 Members and 1 Guest are viewing this topic.

gibs

  • A600
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 35
Free CPU ressources
« on: September 01, 2012, 12:29:57 AM »

Hi,
I am the guy behind TinyLauncher/AmigaParachute/AmigaBootSelector.
I have a question, back in time I had a Peek address to display on screen the vertical position of the VBL, usefull for optimising the code to run in 1VBL/50FPS.

Does anyone have this information ?

Thanks.
« Last Edit: September 01, 2012, 12:33:59 AM by gibs »
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Free CPU ressources
« Reply #1 on: September 02, 2012, 03:27:19 AM »

Hi,

You need to interrogate the Amiga's chips.  These start at address $DFF000.  Be very careful playing around in this area of the Amiga's memory map unless you've got the ROM Kernel Manual handy and you really know what you're doing!  (And a supply of 'brave' pills!)

The offset you want is called VHPOSR (= $4) which gives a bit more than you need.  So, to cut a long story short:

Code: [Select]
Y_POS=Leek($DFF004) and $1FF00
Ror.l 8,Y_POS

This will give you the vertical position of the beam in Y_POS.  What you do with it after that is up to you...  ;)

If you've got the CRAFT library installed, it has a function called Y Beam which does the same thing.  Good luck.
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

gibs

  • A600
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 35
Re: Free CPU ressources
« Reply #2 on: September 03, 2012, 09:45:06 AM »

Thank you very much uncle Bruce :)
Do you know the way I can display it visually onscreen (without loosing any resources) ?
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Free CPU ressources
« Reply #3 on: September 03, 2012, 11:44:04 AM »

It all depends on what you've got going on elsewhere on the screen(s).  As long as you've got a small stable area on a screen, a simple:

Locate X,Y : Print Y_POS;

Will show you where the beam's got to.  It will jitter about a lot (it's being refreshed 50 times a second!) but should be readable unless Y_POS is hovering around the 1-to-2 and 2-to-3 digit changeover values.  E.g. 8,12,10,9,10,etc. or 97,101,100,98,etc.  If that's a problem just change it to:

Locate X,Y : Print Using "###";Y_POS;

Don't worry too much about chewing resources to display the result - you've got 144,000 CPU clock cycles each 1/50th second on a standard A600.  You can't do anything without chewing some resources.  The instructions to get Y_POS only take a handful of cycles.  And, to some extent, it's then irrelevant how long it takes to display it.   :)

If you've got no stable screen space to display the values, a more complex solution is to log them into a memory bank.  Create a Data Bank so you can save it if need be.  Size it to whatever number of samples you think is reasonable.  It will get written to at the rate of 50 bytes per second, so, for example, a 60 second sample would need 60 * 50 = 3,000 bytes.

Here's a quick sample prog to get a rough idea how long that Locate and Print Using is taking.  When it finishes, it goes to direct mode.  From there, just ListBank to get its adddress and use Peek to get at your samples.  If you've got a lot of samples, save the bank to disc and put a simple program together to list it to screen.  Note that this sample makes no attempt to Erase the bank as you will want to look at it - multiple runs will produce multiple banks!

Code: [Select]
'
'  I always prefix my globals with "G_"
'
'     G_Y_POS          Beam's Y position
'
'     G_B_NUM          Bank number
'     G_B_START        Bank start address 
'     G_B_END          Bank end address 
'     G_B_LEN          Bank length
'     G_B_POS          Bank pointer 


Global G_Y_POS

Global G_B_NUM
Global G_B_START
Global G_B_END
Global G_B_LEN
Global G_B_POS

G_B_LEN=100

'===============================================
'
'   Somewhere in your intialisation code:
'
Proc _INIT_BANK
'
'===============================================

Screen Open 0,640,256,16,Hires

_COUNT=1

Do
   Wait Vbl
   Locate 0,10
   Print Using "####";_COUNT
   
   '===============================================
   '   Wherever in your code that you're putting 
   '   your check on the Y beam position:
   '
   
   G_Y_POS=Leek($DFF004) and $1FF00
   Ror.l 8,G_Y_POS
   If G_B_POS<G_B_END
      Poke G_B_POS,G_Y_POS
      Inc G_B_POS
   End If
   
   '
   '===============================================
   
   Inc _COUNT
   If _COUNT>G_B_LEN Then Exit
Loop

Direct

Procedure _INIT_BANK
   '   
   '   Create the bank, grab its details and 
   '   initialise its pointer
   '
   Proc _GET_FREE_BANK_NUMBER
   G_B_NUM=Param
   Reserve As Data G_B_NUM,G_B_LEN
   G_B_START=Start(G_B_NUM)
   G_B_END=G_B_START+G_B_LEN
   G_B_POS=G_B_START
End Proc

Procedure _GET_FREE_BANK_NUMBER
   '
   '   Search for a free memory bank and return its number
   '
   For B=255 To 16 Step -1
      If Length(B)=0 Then Exit
   Next B
End Proc[B]
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

gibs

  • A600
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 35
Re: Free CPU ressources
« Reply #4 on: September 07, 2012, 06:58:34 AM »

Thank you very much
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022