A89: Newbie Question


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

A89: Newbie Question



ok, first of all, i'm not going release this code as a new program or
anything like that, but i'm justing messing with it to test my asm skills.
i'm tring to get the timer by Arie to count down instead of up, but it
doesn't like the way i am tring to do it.
it starts at 65k seconds and starts counting down. any1 can help me, i
would be greatful.
thanks.
Rob Smith
;-------------------------------------------------------------------------------------------------
		;1999/03/06
		;Arie_Benichou@Hotmail.com
;-------------------------------------------------------------------------------------------------
		include		doorsos.h
		include		graphlib.h
;-------------------------------------------------------------------------------------------------
		xdef		 _ti89   
		xdef		 _main   
		xdef 		 _comment  
;-------------------------------------------------------------------------------------------------
Laps     		equ  		100
MaskRow1 	equ 		%11111101
MaskRow5 	equ  		%11011111
MaskRow6 	equ  		%10111111
;-------------------------------------------------------------------------------------------------
DispValue: 	MACRO
 		clr.l   		d2 
 		move.w  		\1,d2
 		bsr     		String
 		PxlText 		a0,\2,\3,\4,\5
		ENDM
;-------------------------------------------------------------------------------------------------
Int1_OFF: 	MACRO
 		clr.l   		d0
 		move.w  		#$0700,d0
 		trap    		#1
 		bclr.b			#2,($600001)  
 		move.l  		\1,($64)  
 		bset.b  		#2,($600001)
 		trap    		#1
		ENDM
;-------------------------------------------------------------------------------------------------
Int1_ON:		MACRO  
 		clr.l   		d0   
 		move.w  		#$0700,d0  
 		trap    		#1   
 		bclr.b  		#2,($600001)  
 		move.l  		($64),\1
 		move.l  		\2,($64)  
 		bset.b  		#2,($600001)
 		trap    		#1
		ENDM
;-------------------------------------------------------------------------------------------------
PxlText:		MACRO  
 		SetFont  		\5
 		move.w  		\4,-(a7)
 		move.l  		\1,-(a7)
 		move.w  		\2,-(a7)
 		move.w  		\3,-(a7)
 		jsr 		doorsos::DrawStrXY
 		lea     		10(a7),a7
		ENDM
;-------------------------------------------------------------------------------------------------
_main:		Int1_ON  		oldint1,#NewInt1
		jsr		graphlib::clr_scr
;-------------------------------------------------------------------------------------------------
CLEAR:		PxlText		#time,#44,#48,#4,#2
 		clr.w    		timer
 		clr.w    		seconds
 		clr.w    		minutes
 		clr.w    		hours
 		add.w   		#1,hours
;------------------------------------------------------------------------------------------------
KeyBoard:	cmp.w    		#360,timer
 		ble      		\MaskRow
 		bsr      		CheckTime

\MaskRow	move.w   		#MaskRow1,d0
 		bsr      		GetKey
 		btst.b   		#6,d0
 		beq      		CLEAR
 		move.w  		#MaskRow5,d0
 		bsr      		GetKey
 		btst.b   		#0,d0
 		beq      		APPS
 		move.w   		#MaskRow6,d0
 		bsr      		GetKey
 		btst.b   		#0,d0
 		beq      		ESC

 		bra      		KeyBoard
;-------------------------------------------------------------------------------------------------
APPS:		trap		#4
 		bra      		KeyBoard
;-------------------------------------------------------------------------------------------------
ESC:		Int1_OFF		oldint1
Return		rts
;-------------------------------------------------------------------------------------------------
CheckTime: 	clr.w    		timer
 		sub.w   		#1,seconds
	 	cmp.w    		#0,seconds
		bne		\DispTime
		clr.w			seconds
		add.w    		#59,seconds
 		sub.w    		#1,minutes
 		cmp.w    		#0,minutes
		bne		\DispTime
		clr.w			minutes
 		add.w    		#59,minutes
 		sub.w    		#1,hours
 		cmp.w    		#0,hours
		bne		\DispTime
		rts

\DispTime	DispValue 	seconds,#44,#96,#4,#2
 		DispValue 	minutes,#44,#72,#4,#2
 		DispValue 	hours,#44,#48,#4,#2
		rts
;-------------------------------------------------------------------------------------------------
GetKey:  	move.w  		d0,$600018
 		move.w  		#Laps,d0  
\delay  	 	dbra  		d0,\delay
 		move.b  		$60001b,d0 
 		rts    
;-------------------------------------------------------------------------------------------------
NewInt1:		add.w		#1,timer
		rte
;-------------------------------------------------------------------------------------------------
String: 		move.l 		#str+8,a0
 		clr.b  		(a0)
 		clr.l  		d3

\str_loop 		add.l  		#1,d3
 		divu   		#10,d2
 		swap   		d2
 		add.b  		#48,d2
 		move.b 		d2,-(a0)
 		clr.w  		d2
 		swap   		d2
 		tst.w  		d2
 		bne    		\str_loop
 		cmp.l  		#1,d3
 		bne    		Return
 		clr.l  		d2
 		add.b  		#48,d2
 		move.b 		d2,-(a0)
 		rts
;-------------------------------------------------------------------------------------------------
_comment: 	dc.b  		"Time by Arie",0
;-------------------------------------------------------------------------------------------------
time:		dc.b		"00:00:00"

  		BSS
str:     		ds.b  		8
timer:  		ds.w  		1
seconds: 	ds.w  		1
minutes: 		ds.w  		1
hours:   		ds.w  		1
oldint1: 		ds.l  		1 
;-------------------------------------------------------------------------------------------------
		end