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


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

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




Oops. You might have to keep the _getk in the timing loop. It probably
didn't quite hang it -- if you held down CLEAR it should've snapped out of
it. The other potential problem might be if _getk doesn't preserve BC.

-----Original Message-----
From: assembly-83-bounce@lists.ticalc.org
[mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of Ronald Teune
Sent: Tuesday, July 03, 2001 11:06 AM
To: assembly-83@lists.ticalc.org
Subject: [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.

Well, I compiled it, and it hung the calculator.

.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83plus.inc"
;#include "tokens.inc"
.LIST
#define bcall(xxxx) rst 28h \ .dw xxxx
#define bcallz(xxxx) jr nz,$+5 \ rst 28h \ .dw xxxx
#define bcallnz(xxxx) jr z,$+5 \ rst 28h \ .dw xxxx
#define bcallc(xxxx) jr nc,$+5 \ rst 28h \ .dw xxxx
#define bcallnc(xxxx) jr c,$+5 \ rst 28h \ .dw xxxx
#define bjump(xxxx) call 50h \ .dw xxxx
 .addinstr BCALL *       EF   3 NOP 1
saferam1 =9872h ;Ion-
progstart =9327h ;headers
_getk  =4A18h
 .org    progstart-2
        .db     $BB,$6D
#define WAIT ei\ halt\ djnz $-2
begin:
    ld bc,$8000
loop:
    bcall(_getk)
    cp kDown
    jr nz,notdown
    inc bc
notdown:
    cp kUp
    jr nz,notup
    dec bc
notup:
    cp kClear
    ret z
    ld a,$C3    ;off
    out (00h),a
    call wait
    ld a,$C0    ;on
    out (00h),a
    ld hl,loop  ;jump to loop when
    push hl     ;subroutine is done
wait:
    ld h,b
    ld l,c
waitloop:
    dec hl
    ld a,h
    or l
    jr nz,waitloop
    ret
.end
END

>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: