I have this code, it should wait for 10 sec, but it does not.
SECTION main,CODE
incdir include:
include exec/exec_lib.i
include exec/ports.i
include exec/types.i
include exec/execbase.i
include exec/memory.i
include exec/lists.i
include devices/timer.i
include graphics/gfxbase.i
include graphics/graphics_lib.i
include graphics/rastport.i
include graphics/scale.i
; include graphics/rpattr.i
include intuition/intuition_lib.i
include intuition/intuition.i
include dos/dos_lib.i
include dos/dosextens.i
OldOpenLibrary EQU -$0198
CloseLibrary EQU -$019E
lea dos_library_name(pc),a1
move.l 4.w,a6
jsr OldOpenLibrary(a6)
move.l d0,DOSBase
beq .Out
move.l sp,D0
move.l #text_debug,_out_text
jsr .print_text
bsr .open_timer_device
;-------------------------------------------------------------------
bsr .set_timer_to_10sec
move.w #1,timer_device_set
; ----------------------------------------------------------------
move.l timer_request,a1 ; DoIO(A1)
move.l #text_SendIO,_out_text
jsr .print_text
move.l 4.w,a6
jsr _LVOSendIO(a6)
; -----------------------------------------------------------------
; WaitPort
move.l timer_msgport,A0
move.l #text_WaitPort,_out_text
jsr .print_text
move.l 4.w,a6
jsr _LVOWaitPort(a6)
;-------------------------------------------------------------------
bsr .set_timer_to_10sec
move.w #1,timer_device_set
; ----------------------------------------------------------------
move.l timer_request,a1 ; DoIO(A1)
move.l #text_SendIO,_out_text
jsr .print_text
move.l 4.w,a6
jsr _LVOSendIO(a6)
; -----------------------------------------------------------------
; WaitPort
move.l timer_msgport,A0
move.l #text_WaitPort,_out_text
jsr .print_text
move.l 4.w,a6
jsr _LVOWaitPort(a6)
;-----------------------------------------------------------------
bsr .close_timer_device
move.l #IO_SIZE,D0
move.l #IOTV_TIME,D1
move.l #TV_SIZE,D2
move.l #IOTV_SIZE,D3
move.l #text_debug,_out_text
jsr .print_text
; Close Dos.library
move.l DOSBase,a1
move.l 4.w,a6
jsr CloseLibrary(A6)
.Out
rts
.set_timer_to_10sec
move.l timer_request,A0
move.l #TR_ADDREQUEST,IO_COMMAND(A0)
move.l #0,IO_FLAGS(A0)
move.l #0,IO_ERROR(A0) ; reset error
move.l #10,IOTV_TIME+TV_SECS(A0)
move.l #0,IOTV_TIME+TV_MICRO(A0)
rts
.open_timer_device
; movem D0-D7/A0-A6,-(SP)
move.l #text_create_port,_out_text
move.l #0,D0
jsr .print_text
move.l 4.w,a6
jsr _LVOCreateMsgPort(a6)
move.l d0,timer_msgport
move.l #text_return_value,_out_text
jsr .print_text
; Is ok?
cmpi.w #0,D0
BEQ .open_timer_device_failed
; ***** Create Timer Request *****
move.l timer_msgport,A0 ; MsgPort
move.l #IOTV_SIZE,D0 ; Timer Request Size
move.l #text_create_timer_request,_out_text
jsr .print_text
move.l 4.w,a6 ; ExecBase
jsr _LVOCreateIORequest(a6)
move.l D0,timer_request ; D0 is stored in timer_request
move.l #text_return_value,_out_text
jsr .print_text
; Is ok?
cmpi.l #0,D0
BEQ .open_timer_device_failed
; ***** Open Device *****
move.l #timer_device_name,A0
; move.l #UNIT_MICROHZ,D0
move.l #UNIT_VBLANK,D0 ; unit
move.l timer_request,A1
move.l #0,D1 ; flags
move.l #text_open_device,_out_text
jsr .print_text
move.l 4.w,a6
jsr _LVOOpenDevice(a6)
move.l #text_return_value,_out_text
jsr .print_text
.open_timer_device_failed
; movem (SP)+,D0-D7/A0-A6 ; exit early
rts
.close_timer_device
; movem D0-D7/A0-A6,-(SP)
move.w timer_device_set,D0
cmpi.w #0,d0
BEQ .safe_to_close_device
move.l timer_request,A0
move.l (A0),D0
cmpi.w #0,d0
BEQ .no_timer_request
move.l #text_abort_io,_out_text
jsr .print_text
; AbortIO
move.l d0,a1
move.l 4.w,a6
jsr _LVOWaitIO(a6)
move.l #text_WaitIO,_out_text
jsr .print_text
; WaitIO
move.l timer_request,A1
move.l 4.w,a6
jsr _LVOWaitIO(a6)
.safe_to_close_device
; CloseDevice
move.l timer_request,A0
move.l A0,D0
cmpi.w #0,d0
BEQ .no_timer_request
move.l D0,A0
move.l #text_close_device,_out_text
jsr .print_text
move.l 4.w,a6 ; ExceBase
jsr _LVOCloseDevice(a6)
move.l #text_delete_io_request,_out_text
jsr .print_text
; DeleteIORequest
move.l timer_request,A0
move.l 4.w,a6 ; ExceBase
jsr _LVODeleteIORequest(a6)
.no_timer_request
; DeleteIMsgPort
move.l timer_request,A0
move.l A0,d0
move.l timer_msgport,D0
cmpi.w #0,d0
BEQ .no_timer_msgport
move.l D0,A0
move.l #text_delete_msgport,_out_text
jsr .print_text
jsr _LVODeleteMsgPort(a6)
.no_timer_msgport
move.l #text_end_of_function,_out_text
jsr .print_text
; movem (SP)+,D0-D7/A0-A6
rts
.print_text
move.l D0,_lost_D0
move.l D1,_lost_D1
move.l D2,_lost_D2
move.l A0,_lost_A0
move.l A1,_lost_A1
move.l A6,_lost_A6
move.l #printf_args,A1
move.l _out_text,(A1)+
move.l D0,(A1)+
move.l D1,(A1)+
move.l D2,(A1)+
move.l D3,(A1)+
move.l D4,(A1)+
move.l D5,(A1)+
move.l D6,(A1)+
move.l D7,(A1)+
move.l A0,(A1)+
move.l _lost_A1,(A1)+
move.l A2,(A1)+
move.l A3,(A1)+
move.l A4,(A1)+
move.l A5,(A1)+
move.l A6,(A1)+
move.l A7,(A1)+
move.l #PRINT_FMT,D1 ; FMT
move.l #printf_args,D2 ; ARGS
move.l DOSBase,a6 ; DosBase
jsr _LVOVPrintf(a6) ; Printf
move.l _lost_D0,D0
move.l _lost_D1,D1
move.l _lost_D2,D2
move.l _lost_A0,A0
move.l _lost_A1,A1
move.l _lost_A6,A6
rts
even
timer_msgport dc.l 0
timer_request dc.l 0
timer_device_set dc.w 0
DOSBase dc.l 0
_out_text dc.l 0
printf_args ds.l 17
_lost_D0 dc.l 0
_lost_D1 dc.l 0
_lost_D2 dc.l 0
_lost_D3 dc.l 0
_lost_D4 dc.l 0
_lost_D5 dc.l 0
_lost_D6 dc.l 0
_lost_D7 dc.l 0
_lost_A0 dc.l 0
_lost_A1 dc.l 0
_lost_A2 dc.l 0
_lost_A3 dc.l 0
_lost_A4 dc.l 0
_lost_A5 dc.l 0
_lost_A6 dc.l 0
_lost_A7 dc.l 0
text_debug dc.b "debug",0
text_end_of_function dc.b "end of function",0
text_time_to_close_timer_device dc.b "time to close timer.device",0
text_create_timer_request dc.b "create timer request (A0, D0)",0
text_create_msgport dc.b "CreateMsgPort ()",0
text_delete_msgport dc.b "DeleteMsgPort",0
text_close_library dc.b "CloseLibrary",0
text_open_library dc.b "OpenLibrary",0
text_close_device dc.b "CloseDevice(A1)",0
text_open_device dc.b "open device(A0,D0,A1,D1)",0
text_create_port dc.b "CreatePort",0
text_return_value dc.b "return value",0
text_abort_io dc.b "AbortIO(A1)",0
text_WaitPort dc.b "WaitPort(A0)",0
text_WaitIO dc.b "WaitIO(A1)",0
text_DoIO dc.b "DoIO(A1)",0
text_SendIO dc.b "SendIO(A1)",0
text_delete_io_request dc.b "delete io request",0
timer_device_name dc.b "timer.device",0;
dos_library_name dc.b "dos.library",0
PRINT_FMT dc.b "%s:",10
dc.b "D0 %08lx D1 %08lx D2 %08lx D3 %08lx D4 %08lx D5 %08lx D6 %08lx D7 %08lx",10
dc.b "A0 %08lx A1 %08lx A2 %08lx A3 %08lx A4 %08lx A5 %08lx A6 %08lx A7 %08lx",10
dc.b 10,0
program outputs this:
debug:
D0 5C6EE000 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5D42EC40 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFFC
CreatePort:
D0 00000000 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5D42EC40 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
return value:
D0 5F28C540 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5D42EC40 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
create timer request (A0, D0):
D0 00000028 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
return value:
D0 6071E390 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
open device(A0,D0,A1,D1):
D0 00000001 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 60134008 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
return value:
D0 00000000 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 60134008 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
SendIO(A1):
D0 00000000 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFFC
WaitPort(A0):
D0 00000000 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFFC
SendIO(A1):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFFC
WaitPort(A0):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFFC
AbortIO(A1):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
WaitIO(A1):
D0 FFFFFFFD D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
CloseDevice(A1):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
delete io request:
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
DeleteMsgPort:
D0 5F28C540 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
end of function:
D0 5F28C540 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFF8
debug:
D0 00000020 D1 00000020 D2 00000008 D3 00000028 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 02817F0C A6 02A7B402 A7 5C6EDFFC