[A83] Re: Official H**s Replacement Commands & Questions & PulseWidthMod


[Prev][Next][Index][Thread]

[A83] Re: Official H**s Replacement Commands & Questions & PulseWidthModulation




Actually the one I sent later was a bit better -- because it didn't use
HALT, and I fixed the errors in the first part. You'll get only low
frequencies with this one (and not very good variation either -- something
like 160Hz, 80Hz, 53Hz, 40Hz, etc -- not much in between.

-----Original Message-----
From: assembly-83-bounce@lists.ticalc.org
[mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of Ronald Teune
Sent: Monday, July 02, 2001 8:01 AM
To: assembly-83@lists.ticalc.org
Subject: [A83] Re: Official H**s Replacement Commands & Questions &
PulseWidthModulation



Thanks for the explanation.
This should work

#define WAIT ei\ halt\ djnz $-2    ; hey, that's cool!
begin:
    ld b,0
loop:
    bcall(_getky)
    cp kDown
    inc b \ ret            ;This isn't
    jr nz,notdown    ;all correct
notdown:                ;I'm afraid
    cp kUp                ;
    jr nz,notup           ;
    dec b \ ret            ;
notup:
    cp kClear
    ret z
    ld a,$C3    ;off    You're right, I forgot the $
    out($00),a
    push bc    ;added
    WAIT
    pop bc    ;added
    ld a,$C0    ;on
    out($00),a    ;added
    push bc    ;added
    WAIT
    pop bc    ;added
    jr loop

>It doesn't exactly seem that your code would work, because B is always
reset
>to the value 0 after one go through the loop, which would make changing the
>width not be noticed. But optimization ideas anyway:
>
>#define WAIT ei\ halt\ djnz $-2
>begin:
>    ld b,0
>loop:
>    bcall(_getky)
>    cp kDown
>    inc b \ ret
>    jr nz,notdown
>notdown:
>    cp kUp
>    jr nz,notup
>    dec b \ ret
>notup:
>    cp kClear
>    ret z
>    ld a,$C3    ;off
>    out($00),a
>    WAIT
>    ld a,$C0    ;on
>    WAIT
>    jr loop
>
>-----Original Message-----
>From: assembly-83-bounce@lists.ticalc.org
>[mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of Ronald Teune
>Sent: Monday, July 02, 2001 6:39 AM
>To: Assembly 83
>Subject: [A83] Official H**s Replacement Commands & Questions &
>PulseWidthModulation
>
>
>
>HRC1: ex de,hl = push de \ push hl \ pop de \ pop hl ;this should work, I
>guess
>HRC2: ld a,xx = push bc \ ld b,xx \ ld a,b \ pop bc
>More crap coming soon, maybe...
>Feel free to add other commands...
>
>Question:
>1 What does ldir do? Does it copy the graph buffer to the screen? In
>   ionm.z80 it's used to run a module stored in saferam1 (graph buffer?)
>2 Is there a command that extracts bits from a variable? I think 'bit' does
>   the trick, so bit 1 is the first bit of a and bit 2 is the 2nd bit of a
>   and bit 3 the 3rd, ... and I think it sets the zero flag for 1 and the
>   nonzero flag for 0. Is this correct?
>
>PWM:
>
>Didn't test it, but this should work. The 'on' pulse is a bit longer than
>the 'off' pulse.
>
>begin:
>    ld b,0
>loop:
>    bcall(_getky)
>    cp kDown
>    call z, incb    ;speed down
>    cp kUp
>    call z, decb    ;speed up
>    cp kClear
>    ret z
>    ld a,C3    ;off
>    out(00),a
>    call wait
>    ld a,C0    ;on
>    call wait
>    jp loop
>incb:
>    inc b \ ret
>decb:
>    dec b \ ret
>wait:
>    ei \ halt \ djnz wait \ ret
>
>
>
>
>
>
>
>





References: