A89: More stron89 help (new questions)


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

A89: More stron89 help (new questions)




Thanks for your help again...I know it wasn't much fun re-answering basically
the same questions...
Here is the beginning code...My questions lie near the end...

  include "tios.h"
        include "gray4lib.h"
        include "util.h"
        include "hufflib.h"
		include "linelib.h"

        xdef _main
        xdef _comment
        xdef _ti89
		
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

	move.l	#LCD_MEM,a0
	bsr		ClearScreen
		
	bsr		DoProgramInit			; do program initialization stuff
	
	tst.w	teacherkeyload			; test if you should play the saved game
	bne		Game_Play				; if so, skip the menu


SOME OTHER STUFF HERE...NOT NEEDED FOR MY QUESTIONS THOUGH!


; ************ General Keyboard Routines

; ** Read keyboard directly
;    INPUT:  	d0.w=keyboard mask
;    OUTPUT:	d0.b=keys hit
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

; ** 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


ClearLines:
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	add.l	#10,a0
	sub.w	#1,d0
	tst.w	d0
	bne		ClearLines
	rts

	
; ** Clear out screen buffer at a0.l
;	 INPUT:		a0.l=screen offset
ClearScreen:
    move.l  d0,-(a7)                    ; save d0
    move.w  #100,d0
    bsr     ClearLines
    move.l  (a7)+,d0                    ; restore d0
    rts

; ** Program Initialization
DoProgramInit:
	move.w  #$700,d0                    ; Disable interrupts, saving old in mask
in d0
    trap    #1
	bclr.b	#2,($600001)				; disable memory protection
	move.l 	($64),Old_Int1				; save old int1 address
	move.l	#New_Int1,($64)				; set int1 to New_Int1
	bset.b	#2,($600001)				; reenable memory protection
	trap	#1							; restore old interrupt
mask (from d0)
	
	rts
----------------------------------------END OF
CODE-------------------------------------------------
First of all if anyone is wondering how the clearscreen routine works I will
try to explain:
ClearLines:
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	move.l	#00,(a0)+
	add.l	#10,a0
	sub.w	#1,d0
	tst.w	d0
	bne		ClearLines
	rts

; ** Clear out screen buffer at a0.l
;	 INPUT:		a0.l=screen offset
ClearScreen:
    move.l  d0,-(a7)                    ; save d0
    move.w  #100,d0
    bsr     ClearLines
    move.l  (a7)+,d0                    ; restore d0
    rts

Prior to this #LCD_MEM (the screen offset) was moved into a0...Now 100 is
moved into d0 because that is how many pixels there are on the screen (in the
y direction)...Now you jump to the label ClearLines...Now you push the
longword 0(that would be 32 0's(4 bytes)) onto the screen...You do this 5
times because 5*32=160(the x direction pixels).  The next line then updates
a0(so it doesn't crash when you leave the routine i think)...d0 contained
100(y direction) so you need to do the same thing 100 times (1 time for every
line going down)...after you did the first line you subtracted 1 from this so
you can keep track of how manytimes you need to do it...now after the 100th
time d0 will be 0...it is tested to see what flags are set...now if the zflag
is set it means d0 is 0 and the routine has been done 100 times, hence the
screen is cleared!  then you return back...

I doubt that paragraph helped anyone, but it helped me a little just by
writing it down...If i said something wrong...please tell me...

1 question though:  Shouldn't there be a rom call that does this for you???


Ok...my real problem lies with this routine:
; ** Program Initialization
DoProgramInit:
	move.w  #$700,d0                    ; Disable interrupts, saving old in mask
in d0
    trap    #1
	bclr.b	#2,($600001)				; disable memory protection
	move.l 	($64),Old_Int1				; save old int1 address
	move.l	#New_Int1,($64)				; set int1 to New_Int1
	bset.b	#2,($600001)				; reenable memory protection
	trap	#1							; restore old interrupt
mask (from d0)
***FOUND LATER ON:***
New_Int1:							; empty INT 1
	rte
Old_Int1		dc.l 0

???'s
1.  So clearing the 2nd bit in ($600001) will disable memory protection?
2.  What is memory protection?
3.  ($64) is the location of int1?
3.b What is int1 for?  What does it do?
4.  Does dc.l 0 just reserve space?
5.  Now the author makes the new int1 be this instead...why?
                      New_Int1:							; 
	                  rte
    This seems to be doing nothing???
6.  I imagine rte to be a return command...but i couldn't find it
anywhere...what is the difference between rte and rts?
7.  Now if he restores the old interrupt...what was the use of him changing
it???


Thanks for your help on my last questions, Mr. Hedman.  I hope you can be as
enligtening as you were in your last post; I think I am at least progressing
somewhat...

-Steve-


Follow-Ups: