English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 05 January 2014, 23:22   #1
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,163
why is that code not working?

Hi,

I'm trying to get current time in assembler on kick 1.3 (for a whdload slave), quick n dirty.
I open the timer device, sounds OK, then I call GetSysTime and it does nothing (not even crashes )

what's wrong?? (sorry for the indents, is there some CODE html mark to use?)


open_timer_device
move.l $4,A6
lea timername(pc),a0
moveq.l #0,d0
moveq.l #0,d1
lea iorequest(pc),a1
jsr _LVOOpenDevice(a6)
tst.l D0
beq.b .ok
illegal
.ok
lea iorequest(pc),a1
lea timerbase(pc),a3
move.l $14(a1),(a3) ; save timerbase

; small test
lea timeval(pc),a0
MOVEA.L timerbase(pc),A6
JSR -66(A6)

; => a0 still contains $DEADBEEF patterns!!
rts


timerbase:
dc.l 0
timeval
dc.l $DEADBEEF,$DEADBEEF
dc.l $DEADBEEF,$DEADBEEF
iorequest:
blk.b $40,0 ; should be enough

timername:
dc.b "timer.device",0
jotd is offline  
Old 05 January 2014, 23:27   #2
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
I'm too tired to check your code right now but you can use this code which I wrote years ago, it should work fine:

Code:
	incdir	sources:include/
	include	sources:include/lvos.i
	include	exec/exec.i
	include	devices/timer.i


; Create message Port
	move.l	$4.w,a6
	lea	VARS(pc),a5
	jsr	_LVOCreateMsgPort(a6)
	move.l	d0,MsgPort-VARS(a5)

; Create IORequest
	move.l	d0,a0
	moveq	#IOTV_SIZE,d0
	jsr	_LVOCreateIORequest(a6)
	move.l	d0,IOReq-VARS(a5)
	move.l	d0,a4

; Open timer.device
	move.l	d0,a1
	lea	tdname(pc),a0
	moveq	#UNIT_MICROHZ,d0
	moveq	#0,d1
	jsr	_LVOOpenDevice(a6)	; -444


	move.l	IO_DEVICE(a4),a6
	lea	time(pc),a0
	jsr	_LVOGetSysTime(a6)	; -66

	move.l	time+TV_SECS(pc),d0
	divu.l	#60,d0			; mins

	move.l	d0,d1
	divu.l	#60,d1			; hours

	move.l	d1,d2
	divu.l	#24,d2			; days
	

	rts
	


	move.l	#TR_GETSYSTIME,IO_COMMAND(a4)
	move.l	a4,a1
	jsr	_LVODoIO(a6)

	move.b	IO_ERROR(a4),d0
	lea	IOTV_TIME(a4),a0	
	move.l	TV_SECS(a0),d0
	move.l	TV_MICRO(a0),d1

	rts


VARS
MsgPort		dc.l	0
IOReq		dc.l	0
tdname		dc.b	"timer.device",0
time		ds.b	TV_SIZE
;IOReq		ds.b	IO_SIZE
;TDMsgPort	ds.b	MP_SIZE
StingRay is offline  
Old 05 January 2014, 23:56   #3
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@jotd

As I see on RKM then GetSysTime function is available for V36+.
Asman is offline  
Old 06 January 2014, 00:04   #4
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Just noticed it is for a WHDLoad slave, in that case you can use WHLoad's "WHDLTAG_TIME_GET" tag, see docs for resload_Control.
StingRay is offline  
Old 06 January 2014, 06:48   #5
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by jotd View Post
is there some CODE html mark to use?
Yes. {code} {/code}. Just replace {} with []. You can also check StingRay's first post by quoting it.
Thorham is offline  
Old 06 January 2014, 06:59   #6
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,163
thanks, that s a kick 1.3 issue only
but Stingray also included the legacy doIo call that does it

btw whdload flag does not work in my case I need an updated value for timing regulation of a Dos game ! (no cia banging)

Edit: I have tried to DoIO but still no luck I get an error return code, see code below.

HHEEEEEELP!!

Code:
open_timer_device
	move.l	$4,A6
	lea	timername(pc),a0
	moveq.l	#UNIT_MICROHZ,d0
	moveq.l	#0,d1
	lea	iorequest(pc),a1
	jsr	_LVOOpenDevice(a6)
	tst.l	D0
	beq.b	.ok
	illegal	; cannot happen
.ok
	rts

; > D0: current seconds
; > D1: current micros

get_current_time:
	movem.l	A0/A1/A6,-(A7)
	move.l	$4.W,A6
	lea	iorequest(pc),a1
	move.l	#TR_GETSYSTIME,IO_COMMAND(a1)
	jsr	_LVODoIO(a6)

	lea	iorequest(pc),a1
	move.b	IO_ERROR(a1),d0   ; always bad
	lea	IOTV_TIME(a1),a0	
	move.l	TV_SECS(a0),d0
	move.l	TV_MICRO(a0),d1
	movem.l	(A7)+,A0/A1/A6

	rts


timerbase:
	dc.l	0
iorequest:
	blk.b	$40,0	; should be enough

timername:
	dc.b	"timer.device",0

Last edited by jotd; 06 January 2014 at 23:49.
jotd is offline  
Old 10 January 2014, 19:40   #7
Wepl
Moderator
 
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 866
what about your msgport?
the iorequest has to be init I think.
Wepl is offline  
Old 11 January 2014, 18:05   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,163
exactly what I just figured out! thanks
jotd is offline  
Old 11 January 2014, 18:55   #9
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
I think that following routines should works on kick 1.3. Warning I didn't tested them
Code:
;-----------------------------------------------------------------------------
;in -
;out D0 - MsgPort or 0 if fails
CreateMsgPort:
	;allocate signal
		move.l	4.w,A6
		moveq	#-1,D0		;any signal
		jsr	-330(A6)	;exec AllocSignal
		move.b	D0,D2		;D2 = signal
		bmi	.failSignal

	;allocate memory for MsgPort structure
		moveq	#$22,D0		;size of MsgPort
		move.l	#$10001,D1	;MEMF_CLEAR|MEMF_PUBLIC
		jsr	-198(A6)	;exec AllocMem
		tst.l	D0
		beq	.failMemory

	;initialize MsgPort structure
		move.l	D0,A0
		move.b	#4,8(A0)	;NT_MSGPORT in mp_Node.ln_Type
		move.b	#0,12(A0)	;mp_flags = PA_SIGNAL
		move.b	D2,15(A0)	;mp_sig = signal

		move.l	$114(A6),16(A0)	;m_sigtask = ThisTask
		lea	$14(A0),A0	;mp_msglist
		move.l	A0,8(A0)	;LH_TAILPRED = LH_HEAD
		addq.l	#4,A0		;goto LH_TAIL
		clr.l	(A0)		;clear it
		move.l	A0,-(A0)	;LH_HEAD = LH_TAIL
		rts

.failMemory	move.b	D2,D0
		jsr	-336(A6)	;exec FreeSignal
.failSignal	moveq	#0,D0
		rts

;-----------------------------------------------------------------------------
; in A0 - msgport
; out -
DeleteMsgPort:
		move.l	A0,D2
		beq	.exit
	;free signal
		moveq	#0,D0
		move.b	15(A0),D0	;mp_sig
		move.l	4.w,A6
		jsr	-336(A6)	;FreeSignal
		move.l	D2,A1
		moveq	#-1,D0
		move.l	D0,$14(A1)	;MP_MSGLIST = -1
		move.l	D0,(A1)		;LH_HEAD = -1
	;free msgport structure
		moveq	#$22,D0
		jsr	-210(A6)	;exec FreeMem
.exit		rts

;-----------------------------------------------------------------------------

;in
;	a0 - MsgPort
;	d0 - size or IORequest
;out
;	d0 - IORequest or 0 if fails
CreateIORequest:
		move.l	D0,D2
		move.l	A0,D3
		beq	.exit
		move.l	#$10001,D1
		move.l	4.w,A6
		jsr	-198(A6)
		tst.l	D0
		beq	exit
		move.l	D0,A0
		move.b	#7,8(A0)	;LN_TYPE = NT_REPLYMSG
		move.l	D3,$e(A0)	;MN_REPLYPORT = D3
		move.l	D2,$12(A0)	;MN_LENGTH = D2
.exit		rts
Asman is offline  
Old 11 January 2014, 23:16   #10
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by jotd View Post
Edit: I have tried to DoIO but still no luck I get an error return code, see code below.

HHEEEEEELP!!

Code:
    move.l    #TR_GETSYSTIME,IO_COMMAND(a1)
Replace the move.l with move.w and the code will work, sorry for the typo in my code posted above.


Edit: here's the fully working DoIO() version:

Code:
	incdir	sources:include/
	include	sources:include/lvos.i
	include	exec/exec.i
	include	devices/timer.i


; Create message Port
	move.l	$4.w,a6
	lea	VARS(pc),a5
	jsr	_LVOCreateMsgPort(a6)
	move.l	d0,MsgPort-VARS(a5)

; Create IORequest
	move.l	d0,a0
	moveq	#IOTV_SIZE,d0
	jsr	_LVOCreateIORequest(a6)
	move.l	d0,IOReq-VARS(a5)
	move.l	d0,a4

; Open timer.device
	move.l	d0,a1
	lea	tdname(pc),a0
	moveq	#UNIT_MICROHZ,d0
	moveq	#0,d1
	jsr	_LVOOpenDevice(a6)	; -444


	move.l	$4.w,a6
	move.w	#TR_GETSYSTIME,IO_COMMAND(a4)
	move.l	a4,a1
	jsr	_LVODoIO(a6)

	move.b	IO_ERROR(a4),d7

	lea	IOTV_TIME(a4),a0	
	move.l	TV_SECS(a0),d0
	move.l	TV_MICRO(a0),d1

	rts


VARS
MsgPort		dc.l	0
IOReq		dc.l	0
tdname		dc.b	"timer.device",0
time		ds.b	TV_SIZE

Last edited by StingRay; 11 January 2014 at 23:22. Reason: added source
StingRay is offline  
Old 12 January 2014, 00:02   #11
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,163
move.l #TR_GETSYSTIME,IO_COMMAND(a1) !!!

yes that's it. I knew it was a size problem.

aaargh asm + kick13 = hell

thanks, it seems to work (thanx everyone). At least returns D0 and D1 different each time. Now I have to calibrate my loops and I can fix most kickemu games going too fast.
jotd is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
start up code help simon_m74 New to Emulation or Amiga scene 2 08 April 2013 22:24
What's this code doing? Jherek Carnelia Coders. General 13 15 August 2011 17:55
External Disk Drive working and not working fc.studio support.Hardware 12 10 August 2009 03:04
floppy df0 working / not working Dave_wb support.Hardware 3 07 January 2009 09:11
3D code and/or internet code for Blitz Basic 2.1 EdzUp Retrogaming General Discussion 0 10 February 2002 11:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:09.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13237 seconds with 15 queries