home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 44
/
Amiga_Dream_44.iso
/
RiscPc
/
jeux
/
biohazard.arc
/
s
/
VSyncEvent
< prev
next >
Wrap
Text File
|
1994-06-05
|
5KB
|
215 lines
; Use the GET directive to include register definitions as if typed here
KEEP
GET h.WolfReg
; Use the GET directive to include a list of SWI names as if typed here
GET h.SWInames
; Area name C$$code advisable as wanted to link with C output
AREA |C$$code|, CODE, READONLY
; Export global symbols
IMPORT |x$stack_overflow|
EXPORT |InitiateScreenEvent|
EXPORT |RelinquishScreenEvent|
EXPORT |VerifyBufferClear|
EXPORT |SetFlagBufferUsed|
EXPORT |ScreenEvent|
InitScEvX DCB "InitiateScreenEvent", 0
ALIGN
InitScEvY DCD &ff000000 + InitScEvY - InitScEvX
; *************************************************************************
; Initialise the vsyncing screen re-drawing routine.
; Claims event, and issues a FX 14,4 to begin vsyncing
; On entry:
; null
;
; Returns:
; null
; *************************************************************************
|InitiateScreenEvent|
STMFD r13!,{r0-r12,link}
;Claim screen event for ScreenEvent
MOV r0,#16
ADR r1,|ScreenEvent|
MOV r2,#1
SWI OS_Claim
;FX 14,4 - initialise vsyncing event
MOV r0,#14
MOV r1,#4
SWI OS_Byte
EndInitSEnt
LDMFD r13!,{r0-r12,pc}
Activate_SEvent
DCD 0
; *************************************************************************
; Relinquish the vsyncing screen re-drawing routine.
; Issues a FX 13,4 to end vsyncing and then relinquishes event
; On entry:
; null
;
; Returns:
; null
; *************************************************************************
ReliSEntX DCB "RelinquishScreenEvent", 0
ALIGN
ReliSEntY DCD &ff000000 + ReliSEntY - ReliSEntX
|RelinquishScreenEvent|
STMFD r13!,{r0-r12,link}
;FX 13,4 - stop vsyncing
MOV r0,#13
MOV r1,#4
SWI OS_Byte
;Relinquish event
MOV r0,#16
ADR r1,|ScreenEvent|
MOV r2,#1
SWI OS_Release
EndReliSEnt
LDMFD r13!,{r0-r12,pc}
CurrentBuffer
DCD 3
; Flag codes are...
;
; 0 = buffer clear and ready to use
; 1 = buffer full and ready to be displayed
; 2 = buffer being used to display picture on screen
Flags
DCD 0
DCD 0
DCD 2
DCD 0
DCD 0
DCD 0
|ScreenEvent|
CMP r0,#4 ;check for vsync
MOVNES pc,r14
STMFD r13!,{r0-r12,r14}
;load up flags
ADR r3,CurrentBuffer
ADR r4,Flags
MOV r7,r4
LDR r2,[r3]
;modify base of flags to point to the next buffer to be shown
MOV r5,#1
CMP r2,#1
ADDEQ r4,r4,#4 ;point to buffer 2
MOVEQ r5,#2
CMP r2,#2
ADDEQ r4,r4,#8 ;point to buffer 3
MOVEQ r5,#3 ;if buffer is 3, next buffer is 1.
CMP r2,#2
ADDEQ r7,r7,#4
CMP r2,#3
ADDEQ r7,r7,#8
LDR r6,[r4]
CMP r6,#1
BNE EndScreenEvent ;next buffer is empty & not ready for use
;flip screen banks to show next screen
MOV r0,#113
MOV r1,r5
SWI OS_Byte
;update current buffer
STR r5,[r3]
;clear the flags.
MOV r6,#0
STR r6,[r7]
MOV r6,#2
STR r6,[r4]
EndScreenEvent
LDMFD r13!,{r0-r12,pc}
; *************************************************************************
; Busy waits until a particular buffer is clear.
; On entry:
; r0 = buffer to check
;
; Returns:
; null
; *************************************************************************
|VerifyBufferClear|
STMFD r13!,{r0-r12,r14}
;get address of flags base & current buffer
ADR r1,Flags
;modify to point to correct flag
CMP r0,#2
ADDEQ r1,r1,#4
CMP r0,#3
ADDEQ r1,r1,#8
WaitLoop
;check if buffer is clear
LDR r2,[r1]
CMP r2,#0
BNE WaitLoop
EndVBufClear
LDMFD r13!,{r0-r12,pc}
; *************************************************************************
; Sets the flag for a particular buffer as used
; On entry:
; r0 = buffer to set
;
; Returns:
; null
; *************************************************************************
|SetFlagBufferUsed|
STMFD r13!,{r0-r12,r14}
;get address of flags base & current buffer
ADR r1,Flags
;modify to point to correct flag
CMP r0,#2
ADDEQ r1,r1,#4
CMP r0,#3
ADDEQ r1,r1,#8
;set the flag
MOV r2,#1
STR r2,[r1]
EndSetFBufUsed
LDMFD r13!,{r0-r12,pc}
END