A89: STron89


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

A89: STron89




Hi I'm trying to figure some things out from the stron89 source code but I am
having trouble with even the first couple lines/subroutines of code...I would
REALLY appreciate it if someone would help me...It looks kind of long but
there are really only a few questions: :)...thanks

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?

_main:
	bsr		WaitKBD

now I understand that this branches to the subroutine WaitIBD...

; ** Wait for all buttons to be released
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:

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!...

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?

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

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?

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?

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


Follow-Ups: