As per ztrumpet's question on IRC (since he doesn't want to create an account Sad ):

#cemetech on Efnet wrote:
[14:24:07] <ztrumpet> Oh, another thing
[14:24:28] <ztrumpet> How do I make it delay, but each time make the delay get shorter?
[14:25:14] <ztrumpet> Ex in basic: :50->B:Repeat 0:For(A,0,B):End:B-1->B:End


It would be something like this:


Code:
Delay:
    ld hl,5000   ;maximum delay value
DelayOuterLoop:
    push hl
        pop bc    ;this is like hl->bc
DelayInnerLoop:
    dec bc
    ld a,b
    or c
    jr nz,DelayInnerLoop
;---here is where you would do something---
;---the delay between the thing that happens here gets shorter---
    dec hl
    ld a,h
    or l
    jr nz,DelayOuterLoop
    ret

To make the delays decrease faster, you would replace:

Code:
    dec hl
    ld a,h
    or l
with
Code:
    ld de,-2
    add hl,de
    ld a,h
    or l
To make it twice as fast (and of course hl would have to start at a multiple of 2!) or ld de,-3 to make it three times as fast (and hl would have to start at a multiple of three), etc. Makes sense?
Interesting code. Wink
Galandros wrote:
Interesting code. Wink
Thanks. Any comments on it, criticisms, or optimizations that you can see?
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement