home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
games
/
gamesuite
/
!Amnesia
/
AmsHelp
/
Technical
/
ObjFound
< prev
next >
Wrap
Text File
|
1994-08-19
|
5KB
|
227 lines
; Amnesia module object handling code
; This code was part of the module code which was assembled using !ExtAsm.
; Copyright A.Southgate 1994 but may be freely distributed and used in the
; creation of other code.
; This is the code used my Amnesia when is finds an object during table
; processing.
; On entry, R10 points to the found object.
; R11 is the R0 value passed to ProcessTable.
.objfound
SUB R10,R10,R9; R10 now points to the found object
STMFD R13!,{R7-R9}
; we need for later
; R7 as pointer to t struct
; R8 as end address
; R9 as object length
LDMIA R10,{R1-R8}
BIC R2,R2,#%1111<<20
STR R2,[R10,#o.flags]
AND R9,R11,#&FF<<24; R9 = the trigger mask
ORR R9,R9,#Amf_colch+Amf_attn+Amf_anim
TST R11,#PF_plot
ORRNE R9,R9,#Amf_plot+Amf_user_plot; request user plot if plots requested
TST R2,#Amf_use_plot_ofs
ORRNE R9,R9,#Amf_use_plot_ofs
TST R2,#Amf_velocity + Amf_attn_timer + Amf_dest_timer + Amf_anim
TSTEQ R2,#Amf_zero_vec + Amf_timer2
BEQ skipvelocity
TST R2,#Amf_velocity
ADDNE R3,R3,R5
ADDNE R4,R4,R6
TST R2,#Amf_zero_vec
MOVNE R5,#0
MOVNE R6,#0
TST R2,#Amf_gravity
BLNE addgravity
TST R2,#Amf_attn_timer + Amf_dest_timer + Amf_anim
SUBNE R7,R7,R7,LSL #16
CMP R7,#0; test for timer expiry
ORRLT R9,R9,#Amf_attn_timer + Amf_dest_timer
STMIA R10,{R1-R7}
TST R2,#Amf_timer2
BLNE runtimer2
.skipvelocity
TST R2,#Amf_game_horiz + Amf_game_vert + Amf_plot_window + Amf_kill_window
BEQ nowindows
STMFD R13!,{R2,R7}
MOV R14,R2 ;NOTE
MOV R5,R8,LSR #16
MOV R6,R8,LSL #16; R1 is <<16 its real value
; and don't forget the <<12 from pixels to coords
MOV R5,R5,LSL #16
SUB R1,R3,R5,LSR #17-coordshift
ADD R3,R3,R5,LSR #17-coordshift
SUB R2,R4,R6,LSR #17-coordshift
ADD R4,R4,R6,LSR #17-coordshift
TST R14,#Amf_game_horiz + Amf_game_vert
BEQ nogamewindow
ADD R0,R12,#v.gamewindow ;the game window triggers when any part of the
; object is outside of it
LDMIA R0,{R5-R8}
CMP R1,R5
CMPGE R7,R3
ORRLT R9,R9,#Amf_game_horiz
CMP R2,R6
CMPGE R8,R4
ORRLT R9,R9,#Amf_game_vert
.nogamewindow
TST R14,#Amf_kill_window
BEQ nokillwindow
ADD R0,R12,#v.killwindow
LDMIA R0,{R5-R8} ;the kill window triggers if an object is entirely
; outside of it.
CMP R1,R7
CMPLE R5,R3
CMPLE R2,R8
CMPLE R6,R4
ORRGT R9,R9,#Amf_kill_window
.nokillwindow
TST R14,#Amf_plot_window
BEQ noplotwindow
TST R9,#Amf_use_plot_ofs
LDRNE R5,[R12,#v.plotxofs]
LDRNE R6,[R12,#v.plotyofs]
ADDNE R1,R1,R5
ADDNE R3,R3,R5
ADDNE R2,R2,R6
ADDNE R4,R4,R6
ADD R0,R12,#v.plotwindow
LDMIA R0,{R5-R8} ;the plot window triggers if an object is entirely
; outside of it.
CMP R1,R7
CMPLT R5,R3
CMPLT R2,R8
CMPLT R6,R4
ORRGE R9,R9,#Amf_plot_window
TST R9,#Amf_plot_window
TSTNE R2,#Amf_colch_window
ORRNE R9,R9,#Amf_colch_window
.noplotwindow
LDMFD R13!,{R2,R7}
.nowindows
; reset regs to return
BIC R0,R11,#PF_advance; signal that we haven't finished
MOV R1,R10
AND R2,R9,R2
TST R2,#Amf_plot_window
BICNE R2,R2,#Amf_plot + Amf_user_plot
BICS R9,R2,#Amf_imask
LDMFD R13!,{R7-R9}
LDMNEFD R13!,{R3-R9,PC}^ ; return if attention required
.noadvance
MOV R0,#0
TST R2,#Amf_kill_window
STRNE R0,[R10,#o.type]
TST R2,#Amf_dest_timer
BEQ nodesttimer
LDR R1,[R10,#o.timer]
CMP R1,#0
STRLT R0,[R10,#o.type]
.nodesttimer
LDR R0,[R10,#o.type]
CMP R0,#0
BEQ objectdead
TST R2,#Amf_plot
BLNE plotobj ;uses previous R0
TST R2,#Amf_colch
BEQ objectskip
TST R2,#Amf_colch_window
BNE objectskip
BL colchadd
LDMVSFD R13!,{R3-R9,PC}
.objectskip
.objectdead
;SWI OS_ReadEscapeState
;BCC lookforobj
B lookforobj
LDMFD R13!,{R3-R9,PC}
.runtimer2
STMFD R13!,{R0}
LDR R0,[R10,#o.timer2]
SUBS R0,R0,R0,LSL #16
STR R0,[R10,#o.timer2]
BICGT R9,R9,#Amf_timer2
LDMFD R13!,{R0}
MOV PC,R14
.addgravity
LDR R0,[R12,#v.gravx]
ADD R5,R5,R0
LDR R0,[R12,#v.gravy]
ADD R6,R6,R0
MOV PC,R14
.plotobj
STMFD R13!,{R0-R3,R14}
TST R2,#Amf_anim
BLNE fastspranim
TST R2,#Amf_use_plot_ofs
LDRNE R3,[R12,#v.plotxofs]
LDR R1,[R10,#o.x]
ADDNE R1,R1,R3
LDRNE R3,[R12,#v.plotyofs]
LDR R2,[R10,#o.y]
ADDNE R2,R2,R3
MOV R1,R1,ASR #coordshift
MOV R2,R2,ASR #coordshift
SWI FastSpr_Plot
LDMFD R13!,{R0-R3,PC}
.fastspranim
TST R2,#Amf_timer2
LDREQ R1,[R10,#o.timer]
LDRNE R1,[R10,#o.timer2]
AND R1,R1,#&FF<<24
ORR R0,R0,R1,LSR #8
MOV PC,R14
.colchadd
STMFD R13!,{R1-R9,R14}
LDR R0,[R12,#v.temp0]
LDR R9,[R0,#4]; get colchtab addr
CMP R9,#0
BEQ colchnotable
SUB R9,R9,#b.sizeof
LDR R1,[R9,#c.writeofs]
LDR R2,[R9,#c.size]
CMP R1,R2
BGE colchnoroom
SUB R0,R10,R7;offset within table
ADD R7,R9,R1; position to write to
LDR R3,[R10,#o.x]
LDR R4,[R10,#o.y]
LDR R8,[R10,#o.size]
MOV R5,R8,LSR #16
MOV R6,R8,LSL #16; R6 is <<16 its real value
MOV R5,R5,LSL #16; now so is R5
SUB R1,R3,R5,LSR #17-coordshift
ADD R3,R3,R5,LSR #17-coordshift
SUB R2,R4,R6,LSR #17-coordshift
ADD R4,R4,R6,LSR #17-coordshift
STMIA R7!,{R0-R4}
SUB R1,R7,R9; restore writeofs
STR R1,[R9,#c.writeofs]
LDMFD R13!,{R1-R9,PC}^
.colchnotable
LDMFD R13!,{R1-R9,R14}
B colchnotableerr
.colchnoroom
LDMFD R13!,{R1-R9,R14}
B colchnoroomerr
; Don't worry - I can't understand it either!
; Andy. 8-)