timer a emulation xbtimer and rte

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

timer a emulation xbtimer and rte

Postby charles » Tue Jun 15, 2010 12:15 am

does steem fully support the four timers of a st?

i know the span between two timer calls is "bluffed"
so does this effect the way xbtimer would be emulated
and
furthermore how timer a is induced?

timer_ms is @ adrress $442
and should be 20

but in steem its non affectable

i think i asked similar queston before

but you know how programming is ,,
drift here , drift there ,,only remember half of things a person should

ok thanks
charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
daeghnao
Captain Atari
Captain Atari
Posts: 479
Joined: Wed Oct 27, 2004 12:41 pm
Location: York, UK
Contact:

Re: timer a emulation xbtimer and rte

Postby daeghnao » Tue Jun 15, 2010 10:17 am

charles wrote:does steem fully support the four timers of a st?


Yes. This is how it runs all those fancy games.

i know the span between two timer calls is "bluffed"


I don't think you mean that the time span between timer calls appears to be one thing, but it turns out to be a lie. Maybe you do. Do you know what bluffing is?

so does this effect the way xbtimer would be emulated


The xbtimer call simply programs up various hardware registers of the MFP. It's there for your convenience.

and
furthermore how timer a is induced?


Timer A isn't induced, it's already there. Do you know what it means, to induce something?

timer_ms is @ adrress $442
and should be 20

but in steem its non affectable


As far as I recall (not having my docs with me) the system data _timer_ms records the system's standard time delay between two calls to the GEM event timer. It is a combination of the interrupt frequency on Timer C and the behaviour of the Timer C code (it calls the GEM timer only once every four times it gets called). Changing _timer_ms doesn't affect the interrupt frequency or the behaviour of the Timer C routine.

i think i asked similar queston before

but you know how programming is ,,
drift here , drift there ,,only remember half of things a person should

ok thanks
charles


I don't find that programming is like that for me at all. I tend to, you know, read all the documentation and try as much out for myself as I can.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Tue Jun 15, 2010 10:44 pm

i wasn't really expect your self to help daegnao
i was looking for an answer from the steem authors

no timer a doesn.t run alot of fancy games daegnoe
if you know of some let me know their titles.

it certainily doesn't function under steem but tonight i try it on a real st

and maybe a compilied program uunder steem,

maybe i'll do the question asking . ok?

charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Wed Jun 16, 2010 10:10 am

charles wrote: no timer a doesn.t run alot of fancy games daegnoe
if you know of some let me know their titles.

Poplulous and Sidewinder are using timer a and are running fine under STeem.

charles wrote:it certainily doesn't function under steem but tonight i try it on a real st

Timer A does certainly function under STeem. Why wouldn't it? Timer B, C, and D are working also fine? Timer A is just more of the same.

charles wrote:maybe i'll do the question asking . ok?

Yes, yo do the asking. One fool can ask more questions than seven wise men can answer.

Hans Wessels

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Wed Jun 16, 2010 8:12 pm

Nyh wrote:Poplulous and Sidewinder are using timer a and are running fine under STeem.

I looked into the source of Sidewinder and saw Sidewinder uses timer A to play samples. When you play Sidewinder you can hear the music under Steem so yes, Timer a is working very fine under STeem.

Charles: you are claiming tmier a is not working under STeem as it should. Do you have code to prove it?
Here is the relevant part from the Sidewinder source:

Code: Select all

L02FA:move.b #0,$FFFA19
     move.l  #L02FB,$0134
     move.b  #4,$FFFA1F
     lea     L0301,A0
     movea.l (A0)+,A1
     move.l  (A0)+,D0
     move.l  A0,L0300
     movea.l (A1),A1
     move.l  A1,L027B
     adda.l  D0,A1
     move.l  A1,L02FC
     move.b  #4,$FFFA1F
     move.b  #5,$FFFA19
     rts
L02FB:movem.l D6-D7/A6,-(SP)
     movea.l L027B,A6
     moveq   #0,D7
     move.b  (A6)+,D7
     move.l  A6,L027B
     cmpa.l  #0,A6
L02FC EQU *-4
     bgt.s   L02FD
     lsl.w   #3,D7
     lea     L027A,A6
     move.l  0(A6,D7.w),D6
     move.w  4(A6,D7.w),D7
     lea     $FF8800,A6
     movep.l D6,0(A6)
     movep.w D7,0(A6)
     movem.l (SP)+,D6-D7/A6
     bclr    #5,$FFFA0F
     rte


Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Wed Jun 16, 2010 10:20 pm

ok this is what i been trying , it either crashes or reeturns zero

i have many other of my own attempts
but since this was sent out to be part of a user package
i felt i should learn from this before i go making up my own routines

well guess what , that was three years ago

is this good ?


Code: Select all


move.w #4,d0
brs MFPTIM
rts

*
* START/STOP MFP TIMER
*
MFPTIM pea TIMER(PC) GET INTERRUPT ROUTINE VECTOR
move.w #10,-(a7) COUNT DOWN FROM 10
move.w d0,-(a7) START/STOP TIMER
move.w #0,-(a7) SELECT TIMER A
move.w #31,-(a7) XBTIMER ROUTINE
trap #14
add.l #12,a7
rts
*
* TIMER INTERRUPT ROUTINE
*
TIMER movem.l d0-d7/a0-a6,-(a7) SAVE REGISTERS
lea COUNT(PC),a5
addq.w #1,(a5) INCREMENT PULSE COUNTER
movea.l #$FFFFFA0F,a3
bclr #5,(a3) CLEAR INTERRUPT SERVICE BIT
movem.l (a7)+,d0-d7/a0-a6 RESTORE REGISTERS
rte

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SOUND dc.w $005A,$0100,$073E,$0810,$0B00,$0C09,$0D00,$FF00
STVAL ds.l 1
SEQST ds.l 4
TRAKPTR ds.l 4
BASICHN ds.l 1
ALLOFF ds.b 4
COUNT ds.w 1
end

The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Wed Jun 16, 2010 11:28 pm

nyh nyh nyh ,,daeghnoe dagnoe !!!!

i got it!

sorry but i got atleast the fundemental part to function!

and it always seems this way ,
that until the pressure is on to strive or succeed all i do is throw pencils off my desk
but when demand to complete is p[resent i do get okay results

but now what do i do , i raised data to 255 from 10
and i placed 7 in control in place of 4

but the thing still increments by 65535 every tick

how to make similar to timer c?

here is what i nicely woven together

Code: Select all

gfa part

' sof
'
CLS
' ***************************************
OPEN "I",#1,"b:\musbox.prg"
flen%=LOF(#1)
CLOSE #1
'
DIM mus|(flen%)
mus%=V:mus|(0)
'
BLOAD "b:\musbox.prg",mus%
mus%=mus%+28
' ***************************************
'
DIM reg%(15)
' reg%(0)=0
' reg%(1)=0
' reg%(2)=0
' reg%(3)=0
' reg%(4)=0
' reg%(5)=0
' reg%(6)=0
' reg%(7)=0
' '
' reg%(8)=0
' reg%(9)=0
' reg%(10)=0
' reg%(11)=0
' reg%(12)=0
' reg%(13)=0
' reg%(14)=0
' reg%(15)=0
'
'
' reg%(0)=2
' reg%(7)=1
'
RCALL mus%,reg%()
'
WHILE escape!=FALSE
  '
  WHILE BIOS(1,2)
    '    PRINT reg%(0)
    '    PRINT reg%(1)
    '    PRINT reg%(2)
    '    PRINT reg%(3)
    '    PRINT reg%(4)
    '    PRINT reg%(5)
    '    PRINT reg%(6)
    '    PRINT reg%(7)
    '    PRINT
    '    PRINT reg%(8)
    '    PRINT reg%(9)
    '    PRINT reg%(10)
    '    PRINT reg%(11)
    '    PRINT reg%(12)
    PRINT {reg%(13)}
    '    PRINT reg%(14)
    '    PRINT reg%(15)
    a|=BYTE(BIOS(2,2))
    IF a|=27
      escape!=TRUE
    ELSE IF a|=32
      {reg%(13)}=0
    ENDIF
  WEND
  '
WEND
'
~XBIOS(31,0,0,0,0)
'
'
' eof


Code: Select all

asm part to be compilied then called from above gfa program

   
   move.l #$0007,d0
   bsr MFPTIM
   lea COUNT(PC),a5
        rts
   
   
*
*   START/STOP MFP TIMER
*
MFPTIM    pea TIMER(PC)                 GET INTERRUPT ROUTINE VECTOR
          move.w #255,-(a7)              COUNT DOWN FROM 10
          move.w d0,-(a7)               START/STOP TIMER
          move.w #0,-(a7)               SELECT TIMER A
          move.w #31,-(a7)              XBTIMER ROUTINE
          trap #14
          add.l #12,a7
          rts
*
*   TIMER INTERRUPT ROUTINE
*
TIMER     movem.l d0-d7/a0-a6,-(a7)     SAVE REGISTERS
          lea COUNT(PC),a5
          addq.w #1,(a5)                INCREMENT PULSE COUNTER
          movea.l #$FFFFFA0F,a3
          bclr #5,(a3)                  CLEAR INTERRUPT SERVICE BIT
          movem.l (a7)+,d0-d7/a0-a6     RESTORE REGISTERS
          rte

**********************************************************
SOUND     dc.w $005A,$0100,$073E,$0810,$0B00,$0C09,$0D00,$FF00
STVAL     ds.l 1
SEQST     ds.l 4
TRAKPTR   ds.l 4
BASICHN   ds.l 1
ALLOFF    ds.b 4
COUNT     ds.w 1
          end
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Thu Jun 17, 2010 8:34 am

charles wrote:but the thing still increments by 65535 every tick

how to make similar to timer c?

Your counter is a 16 bit counter, the 200 Hz counter is a 32 bit counter.

Hans Wessels
BTW, you can write your interrupt routine like this:

Code: Select all

*
*   TIMER INTERRUPT ROUTINE
*
TIMER:
     move.l  a0,-(sp)
     lea     COUNT(PC),a0          ; As this is for GFA code we need PC relative code
     addq.w  #1,(a0)               ; INCREMENT PULSE COUNTER
     move.b  #223,$FFFA0F          ; CLEAR INTERRUPT SERVICE BIT
     move.l  (sp)+,a0
     rte

There is no need to save more registers than you are actually using.
There is no need to load $FFFA0F in an address register when you are accessing the address just once.
The fastest way to clear an interrupt service bit is to write all 1's to the register except for the bit you want to clear: %11011111=223, NOTE: this is only valid for the MFP interrupt clear registers

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Thu Jun 17, 2010 10:47 pm

i'm just guessing but the code should save the registers cause the xbios call trashes registers , no??


so besides addq.l to make 32 bit timer , how can we make act like timer c?
shr ???

every forth interupt increace timer a?

charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12774
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: timer a emulation xbtimer and rte

Postby wongck » Fri Jun 18, 2010 2:14 am

charles wrote:i'm just guessing but the code should save the registers cause the xbios call trashes registers , no??

A matter of being Better safe than sorry :mrgreen:
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

AtariMega125
Atari freak
Atari freak
Posts: 74
Joined: Sat Sep 26, 2009 4:53 am
Location: Southern Rocky Mountains, US

Re: timer a emulation xbtimer and rte

Postby AtariMega125 » Fri Jun 18, 2010 3:03 am

charles wrote:i'm just guessing but the code should save the registers cause the xbios call trashes registers , no??

charles


The Xbios functions, if used correctly should take care of the registers they use internally. If you disassemble them--I've only done this for the midi interupt handler--you will see that they push the registers they use onto the stack and and restore them. If a function is not void and returns something in D0, then you must take that into account in your code if you had something in DO before you called the Xbios routine. The Xbios timer routine is a void function--in other words, it returns nothing so, if you don't use DO in your handler, no need to save it.

http://dev-docs.atariforge.org/ Contains the complete TOS developers kit which has a document called "The hitchhikers guide to the bios" which will tell you everything you need to know about all the bios and xbios functions and whether they are void or not.

@Hans
The timer interupt code you cited is almost identical to one I coded for the basic record click of my sequencer using timer A. The only real difference is that I used a bclr instead of writing 1s and 0s directly to the interupt in service register. And the Madmac assembler comes with a good set of basic macros and equates so it reads something like:

bclr #*, isra

This is just generic, I'm too tired right now to look up the actual register and bit number.
A Mega 4 and a Mega 4 STE. Used primarily to run Clab Notator and a few other MIDI utilities.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Fri Jun 18, 2010 11:36 am

charles wrote:i'm just guessing but the code should save the registers cause the xbios call trashes registers , no??

No! No!! No!!!

Not at all!

1.
Guessing is very wrong. You should know. And if you don't know please refer to something like The Atari ompendium. There you can read at page 4.18 what Xbios does with registers.

2.
You are saving all the registers in you interrupt routine. There is no Xbios call in the interrupt routine. So even if Xbios trashes registers it is not an issue there.

3.
Where you are calling the Xbios you are not saving registers. That is not a problem here because there is no important data in those registers.

charles wrote:so besides addq.l to make 32 bit timer , how can we make act like timer c?
shr ???


Well, it would be a great idea to reserve 32 bits of memory for a 32 bit variable.

When you reserve 32 bits of memory and use addq.l to increase the variable it will be a 32 bit counter just like the _hz_200 counter is.

As yet I don't have a clue why you would want to use a shift right.

The Timer C interrupt does a lot of housekeeping for GEM. Your timer A interrupt doesn't do so.

charles wrote:every forth interupt increace timer a?

I assume you mean that every fourth timer C interrupt the GEM housekeeping routines are called. Clearly that is not an issue here.

Hans Wessels
Last edited by Nyh on Fri Jun 18, 2010 11:53 am, edited 1 time in total.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Fri Jun 18, 2010 11:52 am

AtariMega125 wrote:@Hans
The timer interupt code you cited is almost identical to one I coded for the basic record click of my sequencer using timer A. The only real difference is that I used a bclr instead of writing 1s and 0s directly to the interupt in service register. And the Madmac assembler comes with a good set of basic macros and equates so it reads something like:

bclr #*, isra

This is just generic, I'm too tired right now to look up the actual register and bit number.

The move.b instruction with all bits set except the one you want to clear is 4 cycles faster. That is all.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Fri Jun 18, 2010 8:06 pm

nyh please help ,
you do some work now ,i am trying to duplicate timer c in a certain way ,, a 200hz timer
find your self a copy of the st internals and research how timer c is programmed
thats why i use the save registers(
they have save reg so if another bios or interupt is called then branch to and rgisters will be saved ).


nyh:As yet I don't have a clue why you would want to use a shift right.

charlie: this is why i would use a shr to shift the divisor number , which i don't know that we have invoked yet.

nyh :
When you reserve 32 bits of memory and use addq.l to increase the variable it will be a 32 bit counter just like the _hz_200 counter is.

charlie:not as of yet ,, thats why i keep asking for help,, it is increasing at a fast speed

charlie
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Mug UK
Administrator
Administrator
Posts: 11409
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Re: timer a emulation xbtimer and rte

Postby Mug UK » Fri Jun 18, 2010 8:27 pm

Moved to 68000 as that's the direction this thread is heading in.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Fri Jun 18, 2010 9:37 pm

charles wrote:nyh please help ,
you do some work now ,i am trying to duplicate timer c in a certain way ,, a 200hz timer
find your self a copy of the st internals and research how timer c is programmed

I know how to program timers and I have a fairly good idea on how timer C is working. So no research needed for me.

charles wrote: thats why i use the save registers .


charles wrote:nyh:As yet I don't have a clue why you would want to use a shift right.

charlie: this is why i would use a shr to shift the divisor number , which i don't know that we have invoked yet.

And why is it necessary to do that?

charles wrote:nyh :
When you reserve 32 bits of memory and use addq.l to increase the variable it will be a 32 bit counter just like the _hz_200 counter is.

charlie:not as of yet ,, thats why i keep asking for help,, it is increasing at a fast speed

Well, given the parameter which you use to configure your time, what spped should it run. No points for just the answer, give me the complete calculation. Everything on how to calculate timer frequencies can be found in the Atari Compendium.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Fri Jun 18, 2010 11:20 pm

it doesn't work the way u listed nyh
it needs movea.l stack

this is as close to timer c as i can get
pulse length , which you did not mention even tho you knoe alot about timers

and it does primarilly what i need it to do

the divisor must be so it doesn't call the inputs for polling it usese the 20 millisecond
at $442 i think , again i ask ..

oh well still alot more to do

charles

Code: Select all

SAVE "b:\tryplay1"
' sof
~XBIOS(31,0,0,0,0)
'
CLS
' ***************************************
OPEN "I",#1,"b:\musbox.prg"
flen%=LOF(#1)
CLOSE #1
'
DIM mus|(flen%)
mus%=V:mus|(0)
'
BLOAD "b:\musbox.prg",mus%
mus%=mus%+28
'
DIM reg%(15)
reg%(0)=14        !control     -timer mode
reg%(1)=129       !data        -timer count down from in register
reg%(13)=0
'
RCALL mus%,reg%()
'
WHILE escape!=FALSE
  PRINT {reg%(13)}
  '
  WHILE BIOS(1,2)
    a|=BYTE(BIOS(2,2))
    IF a|=27
      escape!=TRUE
    ELSE IF a|=32
      SLPOKE &H4BA,0
      {reg%(13)}=0
    ELSE IF a|=13
      PRINT TIMER
      PRINT
    ENDIF
  WEND
  '
WEND
'
~XBIOS(31,0,0,0,0)
'
' eof






Code: Select all


timera_irc equ $FFFFFA0F
         
   SECTION TEXT   
   
   bsr MFPTIM
   lea COUNT(PC),a5
        rts
      
* * * * * * * * * * * * * * * * *
*   START/STOP MFP TIMER
* * * * * * * * * * * * * * * * *
MFPTIM    pea TIMER(PC)                 INTERRUPT ROUTINE VECTOR
          move.w d1,-(a7)               COUNT DOWN FROM XX-?10 (DATA)
          move.w d0,-(a7)               START/STOP TIMER XX=14?(CONTROL)
          move.w #0,-(a7)               SELECT TIMER A = #0
          move.w #31,-(a7)              XBTIMER ROUTINE
          trap #14
          add.l #12,a7
          rts
* * * * * * * * * * * * * * * * *
*   TIMER INTERRUPT ROUTINE
* * * * * * * * * * * * * * * * *
TIMER     movem.l d0-d7/a0-a6,-(a7)     SAVE REGISTERS
          lea.L COUNT(PC),a5
          addq.l #1,(a5)                INCREMENT PULSE COUNTER
          bclr #5,timera_irc            CLEAR INTERRUPT SERVICE BIT
          movem.l (a7)+,d0-d7/a0-a6     RESTORE REGISTERS
          rte

   section data
**********************************************************
COUNT     ds.l 1
          end

The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Fri Jun 18, 2010 11:31 pm

this is good for those who want to write their own sound routine for do sound


or ultimitally

replace the tracker xbios sound routine with one for midi
using timer a

midi plays in background ta da !!!

still more to do !

faster

charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Sat Jun 19, 2010 9:58 am

charles wrote:it doesn't work the way u listed nyh
it needs movea.l stack

Do you really use an assembler that is picky on the difference between move.l and movea.l?!?

charles wrote:this is as close to timer c as i can get

Please Charles, do the math and calculate the frequency of your timer. Then you will know how to calculate the right parameters for a 200 Hz timer. This one is off by about 5%.

charles wrote:pulse length , which you did not mention even tho you knoe alot about timers

I strongly suggest you to use delay mode because pulse width mode will not work real hardware with no printer connected.

charles wrote:the divisor must be so it doesn't call the inputs for polling it usese the 20 millisecond
at $442 i think , again i ask ..


If you want a 50 Hz interrupt just call this interrupt from every 4rth 200 Hz interrupt call.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Sat Jun 19, 2010 7:23 pm

ok nyh you mentioned this ,

Please Charles, do the math and calculate the frequency of your timer. Then you will know how to calculate the right parameters for a 200 Hz timer. This one is off by about 5%


where do i find the answer, how to calculate?


for all to use , timer a in gfa basic !!!

the best point is , do not need to put into supervisor mode to poke new value its fleaxable read and write to location just like a variable.


why this got moved i don't know , its a fusion of code
let it rest where it lays


Code: Select all

'
SAVE "b:\tryplay3.gfa"
LIST "e:\tryplay3.lst"
'
~XBIOS(31,0,0,0,0)
'
CLS
'
timer_a%=0
'
mus$=""
mus$=MKL$(&H48E7FFFE)+MKI$(&H2A7C)+MKL$(*timer_a%)+MKI$(&H5295)
mus$=mus$+MKI$(&H8B9)+MKI$(&H5)+MKL$(&HFFFFFA0F)+MKL$(&H4CDF7FFF)
mus$=mus$+MKI$(&H4E73)
mus%=V:mus$
'
~XBIOS(31,W:0,W:4,W:96,L:mus%)
'
WHILE escape!=FALSE
  '
  PRINT AT(3,5),timer_a%
  PRINT AT(3,6),TIMER
  '
  WHILE BIOS(1,2)
    a|=BYTE(BIOS(2,2))
    IF a|=27
      escape!=TRUE
    ELSE IF a|=32
      PRINT AT(3,5),SPACE$(13)
      PRINT AT(3,6),SPACE$(13)
      timer_a%=0
      SLPOKE &H4BA,0
    ELSE IF a|=13
    ENDIF
  WEND
  '
WEND
'
~XBIOS(31,0,0,0,0)
'
' eof

charles]
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Sun Jun 20, 2010 3:01 pm

charles wrote:ok nyh you mentioned this ,

Please Charles, do the math and calculate the frequency of your timer. Then you will know how to calculate the right parameters for a 200 Hz timer. This one is off by about 5%


where do i find the answer, how to calculate?

In the Atari ST hardware registers list or the Ataris Compendium with the extra information that the master clock is 2457600 Hz.

charles wrote:for all to use , timer a in gfa basic !!!

I don't think it is a good idea to store a interrupt routine in a string. A string might get relocated with a garbage collect. Causing all kinds of surprising bombs and errors.

Why are you still saving all registers? You are wasting 224 clockcycles with this stupid action.

Can you tell us a which frequency the timer runs? ;-)

charles wrote:the best point is , do not need to put into supervisor mode to poke new value its fleaxable read and write to location just like a variable.

I think the Gfa TIMER command works fine. The Gfa TIMER command doesn't crash, even after a garbage collect.

I still wonder why you want to poke new values into a timer. I guess it is me being stupid on this point.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Sun Jun 20, 2010 3:30 pm

i know a strings address will not change if variables and memory are managed correctly, don't be silly ,

and

the reason why i want to poke new values is so to use like a stop watch



reset timer to 0000000
examine result

less complex then te%=timer-ts%

plus this
way you won't start your program with the timer at 2147483646
it counts up ,rolls over,
and you end up calculating
3 wrongily

its supposed to be
2147483646+3=2147483649
not timer =3

just giving another picture
charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Sun Jun 20, 2010 6:25 pm

charles wrote:the reason why i want to poke new values is so to use like a stop watch

reset timer to 0000000
examine result

less complex then te%=timer-ts%

plus this
way you won't start your program with the timer at 2147483646
it counts up ,rolls over,
and you end up calculating
3 wrongily

its supposed to be
2147483646+3=2147483649
not timer =3

No you are wrong here. Even when the timer rolls over te%=timer-ts% still gives the correct answer. That is one of the nice things about two complement maths.
Try for yourself in compiled Gfa (the interpreter traps on overflows).

And by the way, timer a will roll over from positive to negative 124 days, 6 hours, 36 minutes, 58.24 seconds after the ST has been switched on.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: timer a emulation xbtimer and rte

Postby charles » Sun Jun 20, 2010 7:09 pm

i'm kinda chuckling now!
~ 124 days !!

snicker snicker ha ....ha,,,

its just easier to say 0-34 timer ticks

then


ts%=timer

te%=timer-ts%


i have to try that 2 compliant math timer roll over into negative , i knew it went negative but forgot about 2 compliant ...thats like -4 add 4 =0 ?????

charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: timer a emulation xbtimer and rte

Postby Nyh » Sun Jun 20, 2010 7:22 pm

charles wrote:i have to try that 2 compliant math timer roll over into negative , i knew it went negative but forgot about 2 compliant ...thats like -4 add 4 =0 ?????

No, it is like:
32766 + 4 = -32766
using 16 bit integers.
Or
-32766 - 32766 = 4
Which is the same of course.

And it is called two's complement. Not 2 compliant.

Hans Wessels


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 3 guests