Re: A89: STron89


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

Re: A89: STron89




WOW..  long letter :)
I'll do some comments here, and some more in your letter...
first...
The thing all of this is doing, is reading the keyboard directly..
this is done by the two memoryadresses $600018 and $60001B

$60018 is used to set witch rows in the keyboard you want to check.. (check the
kbd89.txt on www.ticalc.org to find witch keys are in witch rows) and $60001B is
then used to read from the keyboard witch keys in the rows selected by $600018
is pressed.

more comments within...

S43R80@aol.com wrote:
<cutting some crap...>
> 
> kbd_arrows      EQU             %111111110
> kbd_column5     EQU             %111111101
> kbd_column4     EQU             %111111011
> kbd_column3     EQU             %111110111
> kbd_column2     EQU             %111101111
> kbd_column1     EQU             %111011111
> kbd_exitkey     EQU             %110111111
> 
> dir_left        EQU             0
> dir_up          EQU             1
> dir_right       EQU             2
> dir_down        EQU             3
> 
> _main:
>         bsr             WaitKBD
> 
> Please try to reply in the most simplist terms possible...
> What does EQU do?  and what are those bits used for?  Is it to mask something
> out or something...how come dir_up etc. is given equ and then a number...Is
> that used in some kind of rom call to check if it is pressed?

Theese are different keymasks...   kbd_arrows is the value you should move to
$600018 to read the arrowkeys. (and some more keys)

all the other EQU's (but the dir_xxx) are values you can get when you read from
$60001B..  they are quite selfexplanatoiry when they occur..  

the dir_xxx's are whitch bit in $60001B is cleared when thoose keys are pressed.
(when kbd_arrows have been written to $600018)


> WaitKBD:
>         move.w  #$00,d0                                 ; set keymask to read all keys
>         bsr             ReadKBD
>         cmp.b   #$ff,d0                                 ; check to see if any key is pressed
>         bne             WaitKBD                                 ; if so, start over
>         rts
> 
> Now how does moving 0 into d0 set a  key mask to read all keys?  How is it
> used?
> Now it branches to ReadKBD:

His subroutine uses d0 to hold the mask to be used...

> 
> ReadKBD:
>         move.w  d1,-(a7)
>         move.w  d0,d1
>         move.w  #$700,d0                    ; Disable interrupts, saving old in mask
> in d0
>     trap    #1
> 
>         move.w  d1,($600018)                    ; set keymask
>         nop                                                             ; pause so TI89 has
> time to apply the mask
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         nop
>         clr.w   d1
>         move.b  ($60001b),d1                    ; get keys hit
>         trap    #1
>         move.w  d1,d0
>         move.w  (a7)+,d1
>         rts
> 
> Why is d1 moved onto the stack...It doesn't contain anything yet!  And rightn
> now d0 contains "0" and it is copied to d1...why?  Now the immediate value 700
> in hexadecimal, right?, is moved into d0...what purpose does this serve?  How
> does it "disable the interrupts" and why does this need to be done?  And what
> does trap #1 do?  I have no idea at all!...

d1 is moved to the stack to not be destroyed in the subroutine..  he pop's it of
the stack in the end..
The trap #1 is a "system subroutine" the purpouse of trap #1 is to mess with the
interrupts..  the input he does to trap #1 is doing what he has commented..

> 
> move.w  d1,($600018)
> 
> here d1 is copied to the memory address $600018...Why is it $600018?  what #'s
> can you pick from?  d1 contained 0 right...so your actually moving 0 into that
> mem. address, right?  And how is that setting the key mask?
> 

Explained at top.

> Now nop is used for very small delays...but why did the 89 need extra time?

The ti89 has some hardware to eliminate "key-bouncing" that is, if you press the
key once, you will only detect it once..  unfurtunately this also makes the
keybordmask-setting to be somewhat slow..  so therefore he needs som extra delay
before the keybordmask works...

> 
> So now d1 is cleared right?  When you clear something what does that
> mean...didn't d1 contain 0...isn't it already cleared?
>         move.b  ($60001b),d1
> now why are we moving the contents at mem. address $60001b to d1?  How could
> the contents have changed (it previously contained 0)?  How does that get the
> keys hit...Does it have something to do with the trap #1thing?
> Now why is trap #1 executed again?
> 

explained above..

> then d1 is copied to d0...why dont you just leave the contents of d1 alone?
> 
>         move.w  (a7)+,d1
> 
> I have no idea here!  I'm guessing it is updating the stack so the prog will
> not crash!  But how does this work?

he is restoring d1 from the stack, so it would not be destroyed by the
subroutine..

> 
> now it returns back to WaitKBD:
> WaitKBD:
>         move.w  #$00,d0                                 ; set keymask to read all keys
>         bsr             ReadKBD
>         cmp.b   #$ff,d0                                 ; check to see if any key is pressed
>         bne             WaitKBD                                 ; if so, start over
>         rts
> 
> cmp does $ff minus d0 right?  How does this check if a key is pressed...I
> understand that it branches back to WaitKbd if a the result was 0 but how will
> the result be 0...so if a key is pressed it will go back to ReadKbd??????? if
> not then it will go back to _main?????????

the subroutine returnes the read value from $60001B in d0..   if no keys where
pressed this value should be $ff..

hope this helped.. 


//Olle


References: