This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 01 Nov 2008 12:26:46 pm    Post subject:

whit interupts?
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 01 Nov 2008 02:53:24 pm    Post subject:

Well, you could do that. The difficulty is that I'm not sure how accurate the normal timer interrupts will be, especially if you are using the standard TIOS ISR (which has many different possible code paths, meaning the time between interrupts will vary slightly) or if you're using, say, fastcopy (which disables interrupts for quite a long time every frame.)

I would either use a crystal timer, or else the old-fashioned way with a stopwatch. Smile The crystal timers have two advantages over the normal ones: they can be set to fire less often, and they continue counting after an interrupt occurs.

To use a crystal timer (note that of course this requires an 83+ SE or 84+), you would use an ISR that looks something like this:

Code:
Interrupt:
    ex af,af'
    in a,(4)
    and 20h
    jr nz,GotTimerInterrupt
    ex af,af'
    jp 38h
GotTimerInterrupt:
    exx
    call IncTimer
    ld a,3
    out (31h),a
    exx
    ex af,af'
    ei
    ret

IncTimer:
    ld hl,(timeElapsed)
    inc hl
    ld (timeElapsed),hl
    ld a,h
    or l
    ret nz
    ld hl,(timeElapsed+2)
    inc hl
    ld (timeElapsed+2),hl
    ret


This will maintain a 32-bit count of elapsed time in (timeElapsed). You would use something similar to count the number of frames displayed.

To install the interrupt, you'd do something like this at the start of your program:

Code:
    di
   ; standard IM 2 ISR setup
    ld hl,IM2Tab
    ld de,IM2Tab+1
    ld (hl),IM2Addr & 0ffh
    ld bc,256
    ldir
    ld a,0c3h
    ld (IM2Addr),a
    ld hl,Interrupt
    ld (IM2Addr+1),hl
    ld a,IM2Tab / 256
    ld i,a
    im 2

   ; set up timer
    ld a,45h       ; timer frequency = 2048 Hz
    out (30h),a
    ld a,3
    out (31h),a
    ld a,128       ; interrupt will fire every (128 / 2048) = 0.0625 seconds
    out (32h),a
    ei

See WikiTI for other frequency values you could use. Make sure that the interval between interrupts is longer than the longest time you have interrupts disabled.

Finally, when you're finished, turn the timer off as follows (TIOS will crash if you leave the timer running.)

Code:
    im 1
    xor a
    out (30h),a
    out (31h),a
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 01 Nov 2008 04:28:26 pm    Post subject:

sounds complicated...

i guess im going to use the old-fashioned stopwatch + calucator combination Very Happy
Back to top
Spencer


Advanced Newbie


Joined: 06 Nov 2005
Posts: 99

Posted: 01 Nov 2008 05:05:16 pm    Post subject:

If you just wanted to see FPS for debugging purposes, you can use wabbitemu. Keep in mind it calculates based off how often you update the screen (e.g. for a grayscale program it's not useful for calculating your FPS, just the grayscale interrupt's).
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 01 Nov 2008 05:41:54 pm    Post subject:

its not accurate tho... if 11/900 != 66.5

another quistion:

for some reason, this code fails to see multiple keypresses: (ignore dutch comments)

Code:
getkey:
  LD      A, %11111110  ;group van pijltjes
  OUT       (1), A;senden
  NOP \ NOP;wachten
   IN      A, (1);lezen
  CP      $FB;rechts...  
  CALL   z,pressedright

  LD      A, %11111110  ;group van pijltjes
  OUT       (1), A;senden
  NOP \ NOP;wachten
  IN      A, (1);lezen
   CP      $FD;links   
  CALL   z,pressedleft

  LD      A, %11111110  ;group van pijltjes
  OUT       (1), A;senden
  NOP \ NOP;wachten
  IN      A, (1);lezen
  CP      $F7;omhoog   
  CALL   z,pressedup

  LD      A, %11111110  ;group van pijltjes
  OUT       (1), A;senden
  NOP \ NOP;wachten
  IN      A, (1);lezen
  CP      $FE;omlaag   
   CALL   z,presseddown


edit: not wait, i already optimized it to:

Code:
  LD      A, %11111110   ;group van pijltjes
  OUT       (1), A   ;senden
  NOP \ NOP   ;wachten
  IN      A, (1)   ;lezen
  LD   B,A

   BIT   3,B
  CALL   z,pressedup;%11110111
     
  BIT   2,B
  CALL   z,pressedright;%11111011

   BIT   1,B
  CALL   z,pressedleft;%11111101

   BIT   0,B
   CALL   z,presseddown;%11111110

MUCH better


Last edited by Guest on 01 Nov 2008 06:04:00 pm; edited 1 time in total
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 01 Nov 2008 06:10:58 pm    Post subject:

Before reading the key port, you must output $FF to reset it. Then you can output the group number and receive the key presses.
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 01 Nov 2008 06:16:17 pm    Post subject:

really?

because noting happens when i press any key other than the [arrows] or [clear]


Last edited by Guest on 01 Nov 2008 06:18:10 pm; edited 1 time in total
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 01 Nov 2008 07:42:30 pm    Post subject:

Your second example ought to work, so long as you add an FF output to reset the port. Your first example will not detect multiple keys at the same time (hint: the value in A cannot be both FB and FD simultaneously...)
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 02 Nov 2008 09:01:00 am    Post subject:

Just to add another way of testing any speed on the calculator; I toggle the link port status every frame then have a program on my PC that monitors the port, counting the number of times it toggles per second.
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 02 Nov 2008 11:24:58 am    Post subject:

benryves wrote:
Just to add another way of testing any speed on the calculator; I toggle the link port status every frame then have a program on my PC that monitors the port, counting the number of times it toggles per second.
[post="128397"]<{POST_SNAPBACK}>[/post]

cool Razz

another quistion: Neutral

for some reason, lines like this:

Code:
   LD  HL,(IX + Y )


give me label errors -.- (even if i use a real value instand of Y)
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 02 Nov 2008 11:54:14 am    Post subject:

Oh yeah. that instruction actually doesn't exist. The HL left of the comma is a 16-bit location, whereas the (IX) data is only 8. In TASM, it will usually give you the "unused byte in MSB of ___" error. A close alternative is:


Code:
ld h,(ix+Y)
ld l,(ix+(Y+1))


Last edited by Guest on 02 Nov 2008 11:55:28 am; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 02 Nov 2008 12:52:26 pm    Post subject:

i guess the other way around:


Code:
ld (ix+Y),HL


is vailid?

edit: btw, you example is wrong, it stores stuff in big-endian...


Last edited by Guest on 02 Nov 2008 12:56:33 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 02 Nov 2008 01:51:05 pm    Post subject:

You cannot use HL and IX (or HL and IY for that matter) in the same instruction. Try again.
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 02 Nov 2008 05:04:16 pm    Post subject:

DarkerLine wrote:
You cannot use HL and IX (or HL and IY for that matter) in the same instruction. Try again.
[post="128401"]<{POST_SNAPBACK}>[/post]


LD IX,HLRazz

annyway... i stuck upon the folowing trouble:

.db sprite
this puts a string at the memory location.... i want the memory adress of sprite! lol
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 02 Nov 2008 08:16:43 pm    Post subject:

If you're trying to make a table of addresses, keep in mind that an address is a 16-bit value, so you need to use dw rather than db.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 02 Nov 2008 08:52:01 pm    Post subject:

darkstone knight wrote:
DarkerLine wrote:
You cannot use HL and IX (or HL and IY for that matter) in the same instruction. Try again.
[post="128401"]<{POST_SNAPBACK}>[/post]


LD IX,HLRazz

annyway... i stuck upon the folowing trouble:

.db sprite
this puts a string at the memory location.... i want the memory adress of sprite! lol
[post="128403"]<{POST_SNAPBACK}>[/post]

Easy.
Sprite1:
.db %11111111
.db %11111111
.db %11000011
.db %11000011
.db %11000011
.db %11000011
.db %11111111
.db %11111111
gives you a 8*8 box @ memory location Sprite1.


Last edited by Guest on 22 Jul 2010 12:10:51 pm; edited 1 time in total
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 02 Nov 2008 09:44:52 pm    Post subject:

darkstone knight wrote:
i guess the other way around:


Code:
ld (ix+Y),HL


is vailid?

edit: btw, you example is wrong, it stores stuff in big-endian...
[post="128400"]<{POST_SNAPBACK}>[/post]

Remember, since the ld (ix) instructions only load 1 byte, it's up to you -the developer- to decide which data to make little endian and which not to. As long as you're consistent. It's not until you get instructions like LD HL,(NN) or its analog LD (NN),HL, or using .dw where you're 'forced' to work in little endian.


Last edited by Guest on 02 Nov 2008 09:46:15 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 03 Nov 2008 04:11:32 am    Post subject:

FloppusMaximus wrote:
If you're trying to make a table of addresses, keep in mind that an address is a 16-bit value, so you need to use dw rather than db.
[post="128406"]<{POST_SNAPBACK}>[/post]


i tried that, but it still gies junk as my sprite....

@ luby... i want the ADRESS of the sprite, not the actual sprite..


Last edited by Guest on 03 Nov 2008 04:12:48 am; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 03 Nov 2008 07:50:55 am    Post subject:

luby wrote:
darkstone knight wrote:
DarkerLine wrote:
You cannot use HL and IX (or HL and IY for that matter) in the same instruction. Try again.
[post="128401"]<{POST_SNAPBACK}>[/post]


LD IX,HLRazz

annyway... i stuck upon the folowing trouble:

.db sprite
this puts a string at the memory location.... i want the memory adress of sprite! lol
[post="128403"]<{POST_SNAPBACK}>[/post]

Easy.
Sprite1:
.db %11111111
.db %11111111
.db %11000011
.db %11000011
.db %11000011
.db %11000011
.db %11111111
.db %11111111
gives you a 8*8 box @ memory location Sprite1.
[post="128408"]<{POST_SNAPBACK}>[/post]

I am too lazy to actually make my own post so instead I quote people and then don't say anything new Evil or Very Mad


Last edited by Guest on 22 Jul 2010 12:11:10 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 03 Nov 2008 08:39:39 am    Post subject:

calc84maniac wrote:
luby wrote:
darkstone knight wrote:
(...)
[post="128403"]<{POST_SNAPBACK}>[/post]

Easy.
Sprite1:
.db %11111111
.db %11111111
.db %11000011
.db %11000011
.db %11000011
.db %11000011
.db %11111111
.db %11111111
gives you a 8*8 box @ memory location Sprite1.
[post="128408"]<{POST_SNAPBACK}>[/post]

I am too lazy to actually make my own post so instead I quote people and then don't say anything new Evil or Very Mad
[post="128425"]<{POST_SNAPBACK}>[/post]


<rage>BUT I WANT THE MEMORY ADRESS OF THE SPRITE IN DATA
.....
</rage>

and no, .dw sprite does not work


Last edited by Guest on 22 Jul 2010 12:10:33 pm; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement