Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
12622 lines (12084 sloc) 185 KB
;OK, add a cheat mode!
;
;adding chat-line...
;
;OK, modem stuff...
;
;Once 2 machines are linked, player 1 gets to choose options!
;player 2 is ignored...
;
;player 1 if linked=1, 2 if linked=-1
;*********
;* GLOOM *
;*********
;
;error codes
;
;red - allocmem failed
;yel - freemem failed
;orange - unknown script command
;purp - unknown event command
;cyn - can't open file in loadfile
;blu - ran out of remap colours!
ok equ 750+125 ;overkill level!
;
cy equ 166
pl_eyey equ 110
pl_firey equ 60
pl_gutsy equ 64
debugser equ 0
debugmem equ 0
onedemo equ 0
;
ireload equ 5 ;initial reload val.
maxobjects equ 256 ;max objects in game
maxdoors equ 16 ;max doors opening at once
maxblood equ 128 ;max droplets of bluuurd
maxgore equ 128 ;body parts on ground!
maxrotpolys equ 32 ;max rotating thingys.
;
focshft equ 6
grdshft equ 8
darkshft equ 7 ;smaller=smaller range=faster!
maxz equ 16<<darkshft ;16*128=2048*8=16384
;
exshft equ 3
exone equ 1<<exshft
exhalf equ exone>>1
;
linemod equ 40*7
jmp entrypoint
rsreset
;
;rotpoly details...
;
rp_next rs.l 1
rp_prev rs.l 1
;
rp_speed rs.w 1
rp_rot rs.w 1
rp_flags rs.w 1 ;what to do?
;
rp_cx rs.w 1 ;only for rot
rp_cz rs.w 1
rp_first rs.l 1 ;pointer to first!
rp_num rs.w 1
;
rp_vx rs.w 0
rp_lx rs.w 1
rp_vz rs.w 0
rp_lz rs.w 1
rp_ox rs.w 0
rp_na rs.w 1
rp_oz rs.w 0
rp_nb rs.w 1
;
rp_more rs.b 8*31 ;=32 max verts!
;
rp_size rs.b 0
rsreset
;
;sfx channel info
;
fx_status rs.w 1
fx_priority rs.w 1
fx_sfx rs.l 1
fx_vol rs.w 1
fx_offset rs.w 1
fx_dma rs.w 1
fx_int rs.w 1
;
fx_size rs.b 0
rsreset
;
;blood!
;
bl_next rs.l 1
bl_prev rs.l 1
bl_x rs.l 1
bl_y rs.l 1
bl_z rs.l 1
bl_xvec rs.l 1
bl_dest rs.l 0
bl_yvec rs.l 1
bl_zvec rs.l 1
bl_color rs.l 1 ;colour and!
;
bl_size rs.b 0
rsreset
;
;a texture
;
te_pal rs.l 1
;
te_size rs.b 0
rsreset
;
;an opening/closing door!
;
do_next rs.l 1
do_prev rs.l 1
do_poly rs.l 1 ;door polygon
do_lx rs.w 1
do_lz rs.w 1
do_rx rs.w 1
do_rz rs.w 1
do_frac rs.w 1
do_fracadd rs.w 1
;
do_size rs.b 0
rsreset
;
;wall list...
;
wl_next rs.l 1
wl_lsx rs.w 1 ;leftmost screen X
wl_rsx rs.w 1 ;rightmost screen X
wl_nz rs.w 1 ;near Z!
wl_fz rs.w 1 ;far Z!
wl_lx rs.w 1
wl_lz rs.w 1
wl_rx rs.w 1
wl_rz rs.w 1
wl_a rs.w 1
wl_b rs.w 1
wl_c rs.l 1
wl_sc rs.w 1
wl_open rs.w 1 ;0=door shut, $4000=open!
wl_t rs.b 8 ;textures
;
wl_size rs.b 0
rsreset
;
;a zone...
;
zo_done rs.w 1
zo_lx rs.w 1
zo_lz rs.w 1
zo_rx rs.w 1
zo_rz rs.w 1
;
zo_a rs.w 1
zo_b rs.w 1
zo_na rs.w 1
zo_nb rs.w 1
zo_ln rs.w 1
;
zo_t rs.b 8 ;8 textures
;
zo_sc rs.w 1 ;scale (how many txts on wall)
zo_open rs.w 0 ;for wall polys...
zo_ev rs.w 1 ;for events...
;
zo_size rs.b 0 ;32!
rsreset
;
;a shape to draw!
;
sh_next rs.l 1
sh_prev rs.l 1
sh_x rs.w 1
sh_y rs.w 1
sh_z rs.w 1
sh_shape rs.l 1
sh_scale rs.w 0
sh_strip rs.l 1
sh_render rs.l 1 ;drawobjnorm or drawobjinvs
;
sh_size rs.b 0
rsreset
;
;gore...body parts lying around!
;
go_next rs.l 1
go_prev rs.l 1
go_x rs.w 1
go_z rs.w 1
go_shape rs.l 1
;
go_size rs.b 0
rsreset
;
;an object in the game (player/alien etc...)
;
ob_next rs.l 1
ob_prev rs.l 1
ob_x rs.l 1
ob_y rs.l 1
ob_z rs.l 1
ob_rot rs.l 1
;
;start of info load by prog.
ob_info rs.b 0
;
ob_rotspeed rs.l 1
ob_movspeed rs.l 1
ob_shape rs.l 1
ob_logic rs.l 1
ob_render rs.l 1
ob_hit rs.l 1 ;routine to do when damaged
ob_die rs.l 1 ;routine to do when killed
ob_eyey rs.w 1 ;eye height
ob_firey rs.w 1 ;where bullets come from
ob_gutsy rs.w 1
ob_mega rs.w 0
ob_othery rs.w 1
ob_colltype rs.w 1
ob_collwith rs.w 1
ob_cntrl rs.w 1
ob_damage rs.w 1
ob_hitpoints rs.w 1
ob_think rs.w 1
ob_frame rs.l 1 ;anim frame
ob_framespeed rs.l 1 ;anim frame
ob_base rs.w 1
ob_range rs.w 1
ob_weapon rs.w 1 ;weapon meter (0...4)
ob_reload rs.b 1 ;weapon reload timer
ob_reloadcnt rs.b 1 ;counter
ob_hurtpause rs.w 1
ob_firerate rs.w 0
ob_punchrate rs.w 1
ob_bouncecnt rs.w 1 ;how many times my bullets bounce!
ob_firecnt rs.w 0
ob_something rs.w 1
ob_scale rs.w 1 ;scale factor for drawing
ob_lastbut rs.w 1
ob_blood rs.w 1 ;color AND for blood
ob_ypad rs.w 1
;
ob_oldlogic rs.l 1
ob_oldlogic2 rs.l 1
ob_oldhit rs.l 1
ob_olddie rs.l 1
ob_oldrot rs.w 1
ob_newrot rs.w 1
ob_yvec rs.l 1
ob_xvec rs.l 1
ob_zvec rs.l 1
ob_radsq rs.l 1 ;radius squared
ob_rad rs.w 1
ob_delay rs.w 1
ob_delay2 rs.w 0
ob_bounce rs.w 1
ob_hurtwait rs.w 1
;
ob_washit rs.l 1 ;flag for un-hit coll detect!
ob_window rs.l 1 ;pointer back to window!
ob_nxvec rs.w 0 ;normalized X vec
ob_lives rs.w 1
ob_nzvec rs.w 0 ;nomralized z vec
ob_infra rs.w 1
ob_thermo rs.w 1
ob_invisible rs.w 1
ob_hyper rs.w 1
ob_update rs.w 1 ;update stats!
ob_mess rs.l 1 ;message
ob_messlen rs.w 1
ob_messtimer rs.w 1 ;timer for messages
ob_palette rs.l 1 ;palette for window
ob_paltimer rs.w 1 ;timer before back to normal
ob_pixsize rs.w 1
ob_pixsizeadd rs.w 1
ob_telex rs.w 1
ob_telez rs.w 1
ob_telerot rs.w 1
ob_chunks rs.l 1
;
ob_size rs.b 0
rsreset
;
;solid wall draw data
;
vd_z rs.w 1 ;current Z
vd_pal rs.w 1 ;palette# (0...15)
vd_y rs.w 1
vd_h rs.w 1
vd_data rs.l 1
vd_ystep rs.l 1
;
vd_size rs.b 0
rsreset
;
;palette file...
;
pa_numcols rs.w 1 ;how many colours
pa_cols rs.w 256 ;the colours!
rsreset
;
;anim file...
;
an_rotshft rs.w 1
an_frames rs.w 1
an_maxw rs.w 1
an_maxh rs.w 1
an_pal rs.l 1
;
an_size rs.b 0
rsreset
;
;window
;
wi_slice rs.l 1 ;slice window appears in!
wi_nslice rs.l 1 ;next slice to disp.
wi_x rs 1
wi_y rs 1
wi_w rs 1 ;how many chixels across
wi_h rs 1 ;how many down
wi_pw rs 1 ;width of 1 chixel
wi_ph rs 1 ;hite of 1 chixel
;
wi_bw rs 1 ;bitmap width
wi_bh rs 1 ;bitmap height
;
wi_bmapmem rs.l 1
wi_copmem rs.l 1
wi_bmap rs.l 1
wi_cop rs.l 1
wi_cop1 rs.l 1
wi_cop2 rs.l 1
wi_copmod rs.w 1
;
wi_strip rs.l 1
wi_iff rs.l 1 ;show iff instead!
wi_pal rs.l 1 ;palette for IFF!
;
wi_size rs.b 0
key macro
btst #\1&7,\1>>3(a0)
endm
keya1 macro
btst #\1&7,\1>>3(a1)
endm
qkey macro
move.l rawtable(pc),a0
key \1
endm
freemem macro
;
ifne debugmem
lea .fmem\@,a0
jsr freemem_
bra .fmemskip\@
.fmem\@ dc.b '\1',0
even
.fmemskip\@ ;
elseif
jsr freemem_
endc
;
endm
allocmem macro
;
ifne debugmem
;
lea .amem\@,a0
jsr allocmem_
bra .amemskip\@
.amem\@ dc.b '\1',10,0
even
.amemskip\@ ;
elseif
;
jsr allocmem_
;
endc
;
endm
allocmem2 macro
;
ifne debugmem
;
lea .amem\@,a0
jsr allocmem2_
bra .amemskip\@
.amem\@ dc.b '\1',10,0
even
.amemskip\@ ;
elseif
;
jsr allocmem2_
;
endc
;
endm
alloclist macro ;alloclist listname,maxitems,itemsize
;
move.l \2,d0
move.l \3,d1
lea \1(pc),a2
jsr k_alloclist
bra.s alskip\@
;
\1 dc.l 0 ;0
\1_last dc.l 0 ;4
dc.l 0 ;8
\1_free dc.l 0 ;12
alskip\@ ;
endm
k_alloclist ;a2=address of 'first' pointer
;d0=max items, d1=item size
;
move.l a2,8(a2) ;clear out used list
lea 4(a2),a0
clr.l (a0)
move.l a0,(a2)
movem.l d0-d1,-(a7)
mulu d1,d0
move.l #$10001,d1
allocmem alloclist
move.l d0,a0
lea 12(a2),a2
movem.l (a7)+,d0-d1
subq #1,d0
.loop move.l a0,(a2)
move.l a0,a2
add d1,a0
dbf d0,.loop
rts
addnext macro
;
;addnext 'listname'
;add after a5
;return eq if none available else a0
;
move.l \1_free,d0
beq.s .anskip\@
move.l d0,a0
move.l (a0),\1_free
move.l (a5),a1
move.l a1,(a0)
move.l a0,4(a1)
move.l a0,(a5)
move.l a5,4(a0)
.anskip\@ ;
endm
addfirst macro
;
;addfirst 'listname'
;return eq if none available else a0
;
move.l \1_free,d0
beq.s .afskip\@
move.l d0,a0
move.l (a0),\1_free
move.l \1,a1 ;current first
move.l a1,(a0)
move.l a0,4(a1)
move.l a0,\1
move.l #\1,4(a0)
.afskip\@ ;
endm
addlast macro
;
;addlast 'listname'
;return eq in none available else a0
;
move.l \1_free,d0
beq.s .alskip\@
move.l d0,a0
move.l (a0),\1_free
;
move.l \1_last+4,a1 ;current last
move.l a0,(a1)
move.l a1,4(a0)
move.l a0,\1_last+4
move.l #\1_last,(a0)
.alskip\@ ;
endm
killitem macro
;
;killitem listname
;a0=item to kill, return a0=previous item.
;
move.l (a0),a1 ;next of me!
move.l 4(a0),4(a1)
move.l 4(a0),a1 ;prev of me
move.l (a0),(a1)
move.l \1_free,(a0)
move.l a0,\1_free
move.l a1,a0
endm
clearlist macro
;
;clearlist listname
;
.clloop\@ move.l \1,a0
tst.l (a0)
beq .cldone\@
killitem \1
bra .clloop\@
.cldone\@ ;
endm
zerolist macro listname,size of item
;
;fill all list items with 0!
;
clearlist \1
.zlloop\@ addlast \1
beq .zlskip\@
lea 8(a0),a1
moveq #0,d0
move #(\2-8)/2-1,d1
.zlloop2\@ move d0,(a1)+
dbf d1,.zlloop2\@
bra .zlloop\@
.zlskip\@ clearlist \1
;
endm
bwait macro
;
.bwait\@ btst #6,$dff002
beq.s .bwait2\@
bra.s .bwait\@
.bwait2\@ ;
endm
printlong macro
move.l \1,-(a7)
jsr printlong_
endm
check macro
list
check set *-\1
nolist
endm
push macro
movem.l d2-d7/a2-a6,-(a7)
endm
pull macro
movem.l (a7)+,d2-d7/a2-a6
endm
col macro
move #0,$dff106
move \1,$dff180
endm
warn macro
move d0,-(a7)
move #-1,d0
.wloop\@ col \1
dbf d0,.wloop\@
move (a7)+,d0
endm
tempfile ds.b 64
wbmess dc.l 0 ;workbench message!
entrypoint ;
clr.l map_test
move.l 4.w,a6
move.l 276(a6),a5 ;task
tst.l $ac(a5) ;cli?
bne.s cli
;
lea $5c(a5),a0
jsr -384(a6) ;waitport
lea $5c(a5),a0
jsr -372(a6) ;get message
move.l d0,wbmess
bra wb
cli ;
cmp.b #'@',(a0)+
bne.s wb
lea tempfile,a1
move.l a1,map_test
.loop move.b (a0)+,(a1)
beq.s wb
cmp.b #10,(a1)+
bne.s .loop
clr.b -(a1)
wb ;
lea dosname,a1
move.l 4.w,a6
jsr -408(a6)
move.l d0,dosbase
;
move.l d0,a6
jsr -60(a6)
move.l d0,outhand
;
move.l wbmess(pc),d0
beq.s .nocd
move.l d0,a0
move.l $24(a0),a0
move.l (a0),d1
move.l dosbase,a6
jsr -126(a6)
.nocd ;
jsr initmain
bsr bigfont
;
.intro move.l medat(pc),a1
move.l titlemed(pc),a0
jsr 8(a1) ;start title music!
;
.intro2 jsr dointro ;returns gametype
;
cmp #3,gametype
bcs.s .play
move.l medat(pc),a1
jsr 12(a1)
bra.s exittoos
.play ;
bsr initnewgame
tst gametype
bmi .intro2
;
bsr smallfont
tst twowins
beq.s .n2
bsr swaphflags
.n2 bsr execscript_med
.wmf tst fadevol
bne.s .wmf
tst twowins
beq.s .n22
bsr swaphflags
.n22 bsr bigfont
bra .intro
;
exittoos bsr freeobjlist2
move #$4000,$dff09a
move.l ciaa,a0
movem.l rawstuff,d0-d1
movem.l d0-d1,$64(a0)
move #$c000,$dff09a
jsr permit
jsr finitdisplay
jsr finitvbint
jsr finitsfx
jsr finitser
jsr freememlist
jsr undir
;
move.l wbmess(pc),d0
beq.s .bye
;
move.l 4.w,a6
move.l d0,a1
jsr -378(a6)
clr.l wbmess
;
.bye rts
; ************* FAST SUBS ********************
fastsubs
swaphflags movem.l floorflag(pc),d0-d1
move.l d1,floorflag
move.l d0,floorflag2
rts
smallfont move #6,fontw
move #8,fonth
move.l smallfont_,font
rts
bigfont move #8,fontw
move #10,fonth
move.l bigfont_,font
rts
encodejoy ;a0=cntrl block to encode...
;return d0 encoded
;
;bit:
;0 = joyx -1
;1 = joyx 1
;2 = joyy -1
;3 = joyy 1
;4 = joyb true
;5 = joys true
;
moveq #0,d0
;
tst (a0)
beq.s .skipx
bpl.s .x1
bset #0,d0
bra.s .skipx
.x1 bset #1,d0
.skipx tst 2(a0)
beq.s .skipy
bpl.s .y1
bset #2,d0
bra.s .skipy
.y1 bset #3,d0
.skipy tst 4(a0)
beq.s .skipb
bset #4,d0
.skipb tst 6(a0)
beq.s .skipf
bset #5,d0
.skipf ;
rts
decodejoy ;
;d0.b = encoded byte...
;a0 = block to fill
;
;0 = joyx -1
;1 = joyx 1
;2 = joyy -1
;3 = joyy 1
;4 = joyb true
;5 = joys true
;
clr (a0)
move d0,d1
and #3,d1
beq.s .skipx
cmp #1,d1
bne.s .x1
move #-1,(a0)
bra.s .skipx
.x1 move #1,(a0)
.skipx clr 2(a0)
move d0,d1
and #12,d1
beq.s .skipy
cmp #4,d1
bne.s .y1
move #-1,2(a0)
bra.s .skipy
.y1 move #1,2(a0)
.skipy btst #4,d0
sne d1
ext d1
move d1,4(a0)
btst #5,d0
sne d1
ext d1
move d1,6(a0)
rts
sfxs ;
sfx0 ds.b fx_size
sfx1 ds.b fx_size
sfx2 ds.b fx_size
sfx3 ds.b fx_size
sfxintserver0 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx0
dc.l sfxint
sfxintserver1 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx1
dc.l sfxint
sfxintserver2 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx2
dc.l sfxint
sfxintserver3 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx3
dc.l sfxint
initsfx push
move.l 4.w,a6
;
moveq #7,d0
lea sfxintserver0,a1
jsr -162(a6) ;setintvector
;
moveq #8,d0
lea sfxintserver1,a1
jsr -162(a6)
;
moveq #9,d0
lea sfxintserver2,a1
jsr -162(a6)
;
moveq #10,d0
lea sfxintserver3,a1
jsr -162(a6)
;
lea sfxs(pc),a1
move #$80,d0
moveq #1,d1
moveq #0,d2
moveq #3,d3
.loop bsr .init
lea fx_size(a1),a1
dbf d3,.loop
;
pull
rts
;
.init clr fx_status(a1)
move d0,fx_int(a1)
move d1,fx_dma(a1)
move d2,fx_offset(a1)
add d0,d0
add d1,d1
add #16,d2
rts
finitsfx push
move.l 4.w,a6
;
moveq #7,d0
sub.l a1,a1
jsr -162(a6)
;
move.l 4.w,a6
moveq #8,d0
sub.l a1,a1
jsr -162(a6)
;
move.l 4.w,a6
moveq #9,d0
sub.l a1,a1
jsr -162(a6)
;
move.l 4.w,a6
moveq #10,d0
sub.l a1,a1
jsr -162(a6)
;
pull
rts
waitquiet bsr vwait
lea sfxs(pc),a0
moveq #3,d0
.loop tst fx_status(a0)
bne.s waitquiet
lea fx_size(a0),a0
dbf d0,.loop
rts
playsfx ;sfx file in a0, vol in d0, priority in d1
;
move #$4000,$dff09a ;snd/vb ints off
;
lea sfxs(pc),a1
moveq #3,d2
.loop tst fx_status(a1)
beq.s makesfx
lea fx_size(a1),a1
dbf d2,.loop
;
;OK, none free...check priorities
;
lea sfxs(pc),a1
moveq #3,d2
.loop2 cmp fx_priority(a1),d1
bgt.s queuesfx
lea fx_size(a1),a1
dbf d2,.loop2
;
;no-can-do!
;
move #$c000,$dff09a
rts
;
queuesfx ;OK, turn off other and play US!
;
move #1,fx_status(a1)
move d0,fx_vol(a1)
move d1,fx_priority(a1)
move.l a0,fx_sfx(a1) ;play me next!
;
bsr sfxoff
;
move #$c000,$dff09a
rts
sfxoff lea $dff0a0,a2
add fx_offset(a1),a2
move.l chipzero(pc),(a2)
move #1,4(a2) ;len
move #0,8(a2) ;vol
move fx_int(a1),$dff09a
move fx_dma(a1),$dff096
rts
makesfx ;OK, play this SFX NOW!
;
move d1,fx_priority(a1)
move d0,fx_vol(a1)
bsr playsfxnow
move #$c000,$dff09a
rts
playsfxnow move #-2,fx_status(a1)
;
lea $dff0a0,a2
add fx_offset(a1),a2
move (a0)+,6(a2) ;period
move (a0)+,4(a2) ;len
move fx_vol(a1),8(a2) ;vol
move.l a0,(a2) ;data
;
move fx_dma(a1),d0 ;dma bits
or #$8000,d0
move fx_int(a1),d1 ;int bits
move d1,d2
or #$8000,d1
;
move d0,$dff096 ;dma on!
move d1,$dff09a ;int en
move d2,$dff09c ;intreq clr
;
rts
sfxint ;interupt for sfx!
;
tst fx_status(a1)
bge.s .skip
addq #1,fx_status(a1)
blt.s .skip
;
move.l a2,-(a7)
bsr sfxoff
move.l (a7)+,a2
;
.skip move fx_int(a1),$dff09c
moveq #0,d0
rts
dogamemenu ;
move #$20,$dff09a
;
st paused
move framecnt,-(a7)
move linked,-(a7)
clr linked
;
move #$8020,$dff09a
;
move.l player1,a5
move.l ob_palette(a5),-(a7)
move.l #palettesw,ob_palette(a5)
move.l ob_window(a5),a2
jsr plotwbmap
;
tst twowins
beq .p1
;
move.l player2,a5
move.l ob_palette(a5),-(a7)
move.l #palettesw,ob_palette(a5)
move.l ob_window(a5),a2
jsr plotwbmap
.p1 ;
bsr drawall2
;
move.l player1,a5
lea gamemenu,a4
move.l ob_window(a5),a6
jsr initmenu
;
.loop bsr selmenu
beq .done
;
subq #1,d0
bne .notpsize
bsr newpsize
bra .loop
;
.notpsize subq #1,d0
bne .notwsize
bsr newwsize
bra .loop
;
.notwsize subq #1,d0
bne .notlwin
bsr largewin
bra .loop
;
.notlwin subq #1,d0
bne .notfloor
;
addq #1,floorflag
cmp #2,floorflag
bne.s .fskip
move #-1,floorflag
.fskip bsr refresh
bra .loop
;
.notfloor subq #1,d0
bne .notroof
;
addq #1,roofflag
cmp #2,roofflag
bne.s .rskip
move #-1,roofflag
.rskip bsr refresh
bra .loop
.notroof ;
move #1,finished
;
.done bsr finitmenu
;
tst twowins
beq.s .p12
;
move.l player2,a5
move.l (a7)+,ob_palette(a5)
move.l ob_window(a5),a2
jsr plotwbmap
bsr initstats
bsr showstats
.p12 ;
move.l player1,a5
move.l (a7)+,ob_palette(a5)
move.l ob_window(a5),a2
jsr plotwbmap
bsr initstats
bsr showstats
;
move #$20,$dff09a
;
move (a7)+,linked
move (a7)+,framecnt
clr paused
;
move #$8020,$dff09a
;
rts
freewindows lea window1,a0
jsr freewindow
tst twowins
beq.s .p1
lea window2,a0
jsr freewindow
.p1 rts
largewin move.l player1,a5
bsr large
tst twowins
beq refresh
move.l player2,a5
bsr large
bra refresh
large move.l ob_window(a5),a6
move wi_pw(a6),d2
;
cmp #2,d2
beq .lhr
;
;large lo-res window!
;
.lores move #324,d0
move #240,d1
bra thinkwin
;
.lhr bsr swappsize
bra.s .lores
;
move #180,d0
move #240,d1
bra thinkwin
newwsize ;window size stuff!
;
move.l player1,a5
bsr swapwsize
tst twowins
beq refresh
move.l player2,a5
bsr swapwsize
bra refresh
swapwsize ;increment window size!
;
move.l ob_window(a5),a6
movem wi_w(a6),d0-d1 ;w,h
move wi_pw(a6),d2
mulu d2,d0
mulu d2,d1
cmp #2,d2
beq .hr
;
;lo-res!
;
cmp #318,d0
bcs.s .inc
move #132,d0
move d0,d1
bra thinkwin
.inc add #24,d0
move d0,d1
cmp #240,d1
bls thinkwin
move #240,d1
bra thinkwin
;
.hr cmp #180,d0
bcs.s .inc2
tst twowins
bne .min
add #18,d1
cmp #240,d1
bls thinkwin
.min move #132,d0
move d0,d1
bra thinkwin
.inc2 add #24,d0
move d0,d1
;
thinkwin move #180,d3 ;max width!
cmp #2,d2
beq .gmax
move #318,d3
.gmax cmp d3,d0
bls .nm
move d3,d0
.nm ;
cmp #240,d1
bls .n240
move #240,d1
.n240 tst twowins
beq.s .ggt
move #120,d1
.ggt ;
move #160,d3
move d0,d4
lsr #1,d4
sub d4,d3 ;wi_x
move d3,wi_x(a6)
;
ext.l d0
divu d2,d0
move d0,wi_w(a6)
;
tst twowins
bne.s .skip3
;
move #cy,d3
move d1,d4
lsr #1,d4
sub d4,d3
move d3,wi_y(a6)
;
.skip3 ext.l d1
divu d2,d1
move d1,wi_h(a6)
;
rts
newpsize ;toggle pixel size between 2 and 3
;
;copy windows to temp so we can free 'em up later
;
move.l player1,a5
bsr swappsize
tst twowins
beq refresh
move.l player2,a5
bsr swappsize
;
refresh jsr dispoff
bsr finitmenu
;
bsr freewindows
bsr putwindow
;
lea window1,a0
jsr makewindow
lea window1,a0
jsr showwindow
;
tst twowins
beq.s .p1
;
lea window2,a0
jsr makewindow
lea window2,a0
jsr showwindow
;
.p1 jsr calcbpos
;
lea gamemenu,a4
lea window1,a6
jsr initmenu2
;
bsr drawall2
jsr dispon
rts
swappsize move.l ob_window(a5),a6
movem wi_w(a6),d0-d1 ;w,h
move wi_pw(a6),d2
mulu d2,d0
mulu d2,d1
eor #1,d2 ;2,3...
move d2,wi_pw(a6)
move d2,wi_ph(a6)
;
bra thinkwin
showflag dc 0
showit ;don't show if beam in the way!
;
move showflag(pc),d0
beq.s .rts
;
move.l $dff004,d0
lsr.l #8,d0 ;beampos
and #$1ff,d0
;
cmp minbpos(pc),d0
bcs.s .show
cmp maxbpos(pc),d0
bcs.s .rts
;
;cmp minbpos(pc),d0
;bcc.s .rts
;
.show clr showflag
lea window1,a0
jsr showwindowq
lea window2,a0
jmp showwindowq
;
.rts rts
drawall2 bsr drawall
bsr drawall
bra vwait
drawall ;
.wait move doneflag(pc),d0
beq.s .wait ;wait for update
clr doneflag
.wait2 move showflag(pc),d0
bne.s .wait2
;
move.l memory(pc),memat
move.l player1(pc),a5
bsr calcscene
move.l player1(pc),a5
bsr blitscene
move.l player1(pc),a5
bsr drawscene
;
move twowins(pc),d0
beq.s .show
;
move.l memory(pc),memat
move.l player2(pc),a5
bsr calcscene
move.l player2(pc),a5
bsr blitscene
move.l player2(pc),a5
bsr drawscene
;
.show st showflag
rts
resetplayer st ob_update(a5)
clr ob_mega(a5)
clr ob_thermo(a5)
clr ob_infra(a5)
clr ob_invisible(a5)
clr ob_messtimer(a5)
clr ob_pixsize(a5)
clr ob_pixsizeadd(a5)
clr ob_bouncecnt(a5)
move.l #palettes,ob_palette(a5)
rts
message ;print up a message...player in a5
;
move.l (a7),a0 ;return address=message!
move.l a0,ob_mess(a5)
;
moveq #-1,d0
.loop addq #1,d0
tst.b (a0)+
bne.s .loop
;
move d0,ob_messlen(a5)
move #-127,ob_messtimer(a5)
;
move.l a0,d0
addq.l #1,d0
and #$fffe,d0
move.l d0,(a7)
rts
pdelay dc 0 ;non zero=wait between prints
printmess ;a5=object
;
move.l ob_window(a5),a6
move.l ob_mess(a5),a4
move ob_messlen(a5),d0
move wi_bh(a6),d6
lsr #2,d6 ;Y
;
printmess2 ;a6=window, a4=message, d0=length of message, d6=Y
;
move fontw(pc),d2
lsr #1,d2
mulu d2,d0
move #160,d7
sub d0,d7 ;X
;
.loop2 move.b (a4)+,d2
beq .done
cmp.b #' ',d2
beq.s .spc
cmp.b #'0',d2
bcs.s .nnum
cmp.b #'9',d2
bhi.s .nnum
sub.b #'0',d2
ext d2
bra.s .here
.nnum cmp.b #'!',d2
bne.s .notex
moveq #36,d2
bra.s .here
.notex cmp.b #'.',d2
bne.s .notfs
moveq #37,d2
bra.s .here
.notfs cmp.b #':',d2
bne.s .notcol
moveq #38,d2
bra.s .here
.notcol cmp.b #127,d2
bne.s .notcurs
moveq #39,d2
bra.s .here
.notcurs and #31,d2
add #9,d2
.here move.l font(pc),a0
move.l wi_bmap(a6),a1
move d7,d0
move d6,d1
bsr blit
;
move pdelay(pc),d2
subq #1,d2
bmi.s .spc
;
.pdloop bsr vwait
bsr checkany
beq.s .none
move #-1,pdelay
moveq #0,d2
.none dbf d2,.pdloop
;
.spc add fontw(pc),d7
bra .loop2
.done ;
rts
initstats ;
;health...
move.l ob_window(a5),a0
moveq #2,d0
add wi_x(a0),d0
move.l wi_bmap(a0),a1
move.l font(pc),a0
moveq #2,d1
moveq #39,d2
bsr blit
;
;weapon...
move.l ob_window(a5),a0
moveq #2,d0
add wi_x(a0),d0
move.l wi_bmap(a0),a1
move.l font(pc),a0
moveq #12,d1
moveq #44,d2
bra blit
putstrip ;a0=window
;
move.l wi_bmap(a0),a1
move wi_bh(a0),d0
lsr #2,d0
mulu #7*40,d0
add.l d0,a1 ;dest
move.l wi_strip(a0),a0 ;src
;
btst #6,$dff002
.bwait btst #6,$dff002
bne.s .bwait
;
move.l #$9f00000,$dff040
move.l #-1,$dff044
move #0,$dff064
move #0,$dff066
move.l a0,$dff050
move.l a1,$dff054
move #(7*7)<<6+20,$dff058
rts
loff dc 0
showstats ;a5=player
;
;ok, hitpoints...
;
;lagtime...
move.l ob_window(a5),a0
moveq #2,d0
add wi_x(a0),d0
move.l wi_bmap(a0),a1
move.l font(pc),a0
moveq #22,d1
move lagtime(pc),d2
bsr blit
;
move.l ob_window(a5),a0
moveq #44,d5
add wi_x(a0),d5
moveq #40,d4
moveq #0,d6
move ob_hitpoints(a5),d7
;
.hploop cmp d7,d6
bcs.s .hpskip
cmp #25,d7
bcc.s .hpdone
moveq #41,d4
moveq #25,d7
bra.s .hploop
;
.hpskip move.l font(pc),a0
move.l ob_window(a5),a1
move.l wi_bmap(a1),a1
move d5,d0
moveq #2,d1
move d4,d2
bsr blit
addq #2,d5
addq #1,d6
bra.s .hploop
.hpdone ;
;show lives remaining...
;
move.l ob_window(a5),a0
move wi_bw(a0),d5
add wi_x(a0),d5
move ob_lives(a5),d7
beq.s .lvdone
subq #1,d7
.lvloop ;
move.l font(pc),a0
move.l ob_window(a5),a1
move.l wi_bmap(a1),a1
subq #8,d5
move d5,d0
moveq #2,d1
moveq #43,d2
bsr blit
dbf d7,.lvloop
.lvdone ;
;show weapons!
;
move.l ob_window(a5),a0
moveq #44,d5
add wi_x(a0),d5
moveq #49,d4
sub ob_weapon(a5),d4 ;0...4
moveq #1,d7
.wploop ;
move.l font(pc),a0
move.l ob_window(a5),a1
move.l wi_bmap(a1),a1
move d5,d0
moveq #12,d1
moveq #50,d2
cmp.b ob_reload(a5),d7
blt.s .nowp
move d4,d2
.nowp bsr blit
;
add #10,d5
addq #1,d7
cmp #6,d7
bcs.s .wploop
;
rts
blit ;a0=shapetable to blit, a1=bitmap, d0=X, d1=Y, d2=char
;
add.l 4(a0,d2*4),a0
;
mulu #280,d1
add.l d1,a1
move d0,d2
asr #3,d2
add d2,a1 ;dest!
move.l a0,a2
add.l (a0),a2
lea 8(a0),a3
addq #4,a0
and #15,d0
ror #4,d0
;
btst #6,$dff002
.bwait btst #6,$dff002
bne.s .bwait
;
move.l a2,$dff050
move.l a3,$dff04c
move.l a1,$dff048
move.l a1,$dff054
;
move d0,$dff042
or blitmode(pc),d0
move d0,$dff040
move.l #$ffff0000,$dff044
moveq #-2,d0
move d0,$dff064
move d0,$dff062
moveq #38,d0
sub (a0)+,d0
move d0,$dff060
move d0,$dff066
move (a0)+,$dff058
;
rts
blitmode dc $fca
pixsize dc 0 ;pixel size...at least 2!
pixelate ;pixel out the coplist...d0=pixelsize
;
move d0,pixsize
move d0,d1
;
;pixel out vertically, then horizontally
;
move.l cop(pc),a0
lea coloffs(pc),a1
moveq #0,d2 ;x
move d1,d6
lsr #1,d6
.forx ;
move.l a0,a3
lea 0(a1,d2*4),a2
add.l (a2),a3
;
move d2,d5
add d6,d5
cmp width(pc),d5
ble.s .xok
move width(pc),d5
.xok sub d2,d5
ble .done
subq #1,d5
;
.loop2 moveq #0,d3
move.l a3,a4
move.l a0,a5
add.l (a2)+,a5
move d1,d7
lsr #1,d7 ;first Y add
.fory ;
move (a4),d0 ;start column!
move d3,d4
add d7,d4
cmp hite(pc),d4
ble.s .yok
move hite(pc),d4
.yok sub d3,d4
ble .nextx
subq #1,d4
;
.loop move d0,(a5)
add copmod(pc),a4
add copmod(pc),a5
;
dbf d4,.loop
;
.nexty add d7,d3
move d1,d7
bra.s .fory
;
.nextx dbf d5,.loop2
;
add d6,d2
move d1,d6
bra.s .forx
;
.done rts
makeqstrip ;
;do a simple roof/floor strip for blitter to wack in...
;
cmp #$100,con0poke
bne.s .doit
rts
;
.doit move.l qstrip(pc),a0
move.l darktable(pc),a1
move.l palette(pc),a2
move.l qstripbot(pc),a4
moveq #0,d2
;
move floorflag(pc),d0
bne.s .fdone
;
move camy(pc),d0
neg d0
ext.l d0
lsl.l #focshft,d0
;
move.b qcols+1(pc),d2
move.l qstripbot(pc),a4
move maxy(pc),d1
;
.floop subq #1,d1
beq.s .fdone
;
move.l d0,d3
divs d1,d3
cmp #maxz,d3
bcc .fdone
;
move 0(a1,d3*2),d3 ;darkness (0...15)
move.l 0(a2,d3*4),a3 ;pal to use
move 0(a3,d2*2),-(a4) ;colour!
;
bra.s .floop
;
.fdone move roofflag(pc),d0
bne.s .rdone
;
move #-256,d0
sub camy(pc),d0
ext.l d0
lsl.l #focshft,d0 ;cam Y
;
move.b qcols(pc),d2
;
move miny(pc),d1 ;SY
;
.rloop beq.s .rdone
;
move.l d0,d3
divs d1,d3
cmp #maxz,d3
bcc .rdone
;
move 0(a1,d3*2),d3 ;darkness (0...15)
move.l 0(a2,d3*4),a3 ;pal to use
move 0(a3,d2*2),(a0)+ ;colour!
;
addq #1,d1
bra.s .rloop
.rdone ;
moveq #0,d0
.loop cmp.l a4,a0
bcc.s .done
move.l d0,(a0)+
bra.s .loop
;
.done rts
flatcam dc.l 0
flatyadd dc 0
flatyadd2 dc 0
flat ;
;do flat above/below panel!
;
;d0=Y pos of flat
;d1=Screen Y add
;d7=first screen Y (miny or maxy-1)
;
;a0=panel to draw on!
;
ext.l d0
lsl.l #focshft,d0
move.l d0,flatcam
;
move d1,flatyadd
muls copmod(pc),d1
move d1,flatyadd2
;
move d7,d0
add midy(pc),d0
mulu copmod(pc),d0
add.l cop(pc),d0
add.l coloffs(pc),d0
move.l d0,a2
.vloop ;
;find Z on this scanline...
;
tst d7
beq .rts
move.l flatcam(pc),d6
divs d7,d6 ;d6.w = Z
cmp #maxz,d6
bcc .rts
;
move.l darktable(pc),a5
move 0(a5,d6*2),d5
move.l palette(pc),a5
move.l 0(a5,d5*4),a5
;
;Find leftmost X...
;
move minx(pc),d5
muls d6,d5
asr.l #focshft,d5
;
move maxx(pc),d4
muls d6,d4
asr.l #focshft,d4
;
;rotate X1,Z around camera...
;
move d5,d0
move d6,d1
;
move d0,d2
move d1,d3
;
muls icm1(pc),d0
add.l d0,d0
muls icm2(pc),d3
add.l d3,d3
add.l d3,d0
;
muls icm3(pc),d2
add.l d2,d2
muls icm4(pc),d1
add.l d1,d1
add.l d2,d1
;
;d0,d1.q = rotated x1,z
;
;rotate X2,Z around camera...
;
move d4,d2
move d6,d3
;
muls icm1(pc),d4
add.l d4,d4
muls icm2(pc),d3
add.l d3,d3
add.l d3,d4
;
muls icm3(pc),d2
add.l d2,d2
muls icm4(pc),d6
add.l d6,d6
add.l d2,d6
;
;d4,d6.q = rotated x2,z
;
move width(pc),d5
ext.l d5
sub.l d0,d4 ;Xadd
divs.l d5,d4
sub.l d1,d6 ;Zadd
divs.l d5,d6
;
;d0,d1.q=x,z
;d4,d6.q=xadd,zadd
;
;move.l d4,d2
;asr.l #1,d2
;add.l d2,d0
;
;move.l d6,d2
;asr.l #1,d2
;add.l d2,d1
;
swap d0
add camx(pc),d0
swap d1
add camz(pc),d1
swap d4
swap d6
;
move d7,-(a7)
moveq #127,d7
moveq #0,d2
moveq #0,d3
;
move.l a2,a3
;
move wdiv32(pc),-(a7)
;
.hloop2 moveq #31,d5
;
.hloop tst (a3) ;check destination!
bne.s .skip
;
and d7,d0
and d7,d1
move d0,d2
lsl #7,d2
add d2,d1
add.l d4,d0
move.b 0(a0,d1),d3
addx d2,d0
add.l d6,d1
move 0(a5,d3*2),(a3)
addx d2,d1
addq #4,a3
dbf d5,.hloop
bra.s .hhh
;
.skip add.l d4,d0
addx d2,d0
add.l d6,d1
addx d2,d1
addq #4,a3
dbf d5,.hloop
;
.hhh addq #4,a3
subq #1,(a7)
bgt.s .hloop2
bne.s .kl
;
move wrem32(pc),d5
bpl.s .hloop
;
.kl move.l (a7)+,d7
add flatyadd(pc),d7
add flatyadd2(pc),a2
bra .vloop
;
.rts rts
doanims move.l map_anim(pc),a0
lea textures,a1
;
.loop move (a0)+,d0 ;how many frames
beq.s .done
movem (a0)+,d1-d2 ;first, delay
subq #1,(a0)+
bgt.s .loop
move d2,-2(a0)
lea 0(a1,d1*4),a2
;
;do the anim!
;
subq #2,d0
move.l (a2),d2
.loop2 move.l 4(a2),(a2)+
dbf d0,.loop2
move.l d2,(a2)
bra.s .loop
;
.done rts
dorots ;
move.l camrots2(pc),a6
lea rotpolys(pc),a5 ;header!
;
rotloop move.l (a5),a5
tst.l (a5)
beq .done
move rp_speed(a5),d0
beq.s rotloop
;
add d0,rp_rot(a5)
move rp_rot(a5),d0
;
move.l rp_first(a5),a2 ;first
move rp_num(a5),d5
subq #1,d5
move d5,d4
lsl #5,d4
lea 0(a2,d4),a1 ;previous
lea rp_lx(a5),a3
;
btst #0,rp_flags+1(a5)
bne.s morph
;
.rot movem rp_cx(a5),d6-d7 ;centre x,z
and #1023,d0
lea 0(a6,d0*8),a4 ;rotation matrix.
;
.loop bsr rotter
add d6,d0
add d7,d1
movem d0-d1,zo_lx(a2)
movem d0-d1,zo_rx(a1)
bsr rotter
movem d0-d1,zo_na(a2)
exg d0,d1
neg d0
movem d0-d1,zo_a(a2)
move.l a2,a1
lea 32(a2),a2
dbf d5,.loop
;
bra rotloop
;
.done rts
;
morph tst d0
bgt.s .dp
moveq #0,d0
.neg neg rp_speed(a5)
bra.s .skip2
.dp cmp #$4000,d0
blt.s .skip
move #$4000,d0
btst #1,rp_flags+1(a5)
bne.s .neg
clr rp_speed(a5)
.skip2 move d0,rp_rot(a5)
.skip ;
move d0,d4
movem.l a2/d5,-(a7) ;for calculating norms!
;
.loop movem (a3)+,d0-d3
muls d4,d0
lsl.l #2,d0
swap d0
add d2,d0
muls d4,d1
lsl.l #2,d1
swap d1
add d3,d1
movem d0-d1,zo_lx(a2)
movem d0-d1,zo_rx(a1)
move.l a2,a1
lea 32(a2),a2
dbf d5,.loop
;
movem.l (a7)+,a2/d5
;
.loop2 move zo_rx(a2),d0
sub zo_lx(a2),d0
move zo_rz(a2),d1
sub zo_lz(a2),d1
bsr calcnormvec
movem d0-d1,zo_na(a2)
exg d0,d1
neg d0
movem d0-d1,zo_a(a2)
lea 32(a2),a2
dbf d5,.loop2
;
bra rotloop
calcnormvec ;d0,d1 = vector...normalize!
;
;OK, find vector length!
;
move d0,d2
muls d2,d2
move d1,d3
muls d3,d3
add.l d3,d2
;
;OK, sqr of d2.l!
;
move.l #$10000,d3
;
.fitit cmp.l #16384,d2 ;fits?
bcs.s .ok
asr.l #1,d2
mulu.l #92681,d4:d3 ;mult by sqr(2)
move d4,d3
swap d3
bra.s .fitit
;
.ok ;OK to look up, but multiply the result.w by d3.q
;
move.l sqr(pc),a0
and #$fffe,d2
movem 0(a0,d2),d2 ;sqr.l!
mulu.l d3,d2
swap d2 ;length.w
;
;length should be >= both abs(xvec) AND abs(zvec)
;
move d0,d3
bpl.s .xp
neg d3
.xp move d1,d4
bpl.s .zp
neg d4
.zp ;
cmp d4,d3
bcc.s .bg
exg d3,d4
.bg ;
cmp d3,d2
bcc.s .lo
move d3,d2
.lo ;
ext.l d2
;
swap d0
clr d0
divs.l d2,d0
muls.l #32766,d0
swap d0
;
swap d1
clr d1
divs.l d2,d1
muls.l #32766,d1
swap d1
rts
rotter movem (a3)+,d0-d1 ;this x,z
move d0,d2
move d1,d3
;
muls (a4),d0
muls 2(a4),d3
add.l d3,d0
add.l d0,d0
swap d0 ;new x!
;
muls 4(a4),d2
muls 6(a4),d1
add.l d2,d1
add.l d1,d1
swap d1
;
rts
dodoors lea doors(pc),a5
;
.loop move.l (a5),a5
tst.l (a5)
beq .done
;
move.l do_poly(a5),a0
move do_fracadd(a5),d0
add d0,do_frac(a5)
move do_frac(a5),d0
move d0,d1
add d1,d1
move d1,zo_open(a0) ;copy frac
;
move do_rx(a5),d1
sub do_lx(a5),d1 ;width
move d1,d2
muls d0,d2
lsl.l #2,d2
swap d2
move do_lx(a5),d3
sub d2,d3
move d3,zo_lx(a0)
add d1,d3
move d3,zo_rx(a0)
;
move do_rz(a5),d1
sub do_lz(a5),d1
move d1,d2
muls d0,d2
lsl.l #2,d2
swap d2
move do_lz(a5),d3
sub d2,d3
move d3,zo_lz(a0)
add d1,d3
move d3,zo_rz(a0)
;
tst d0
beq.s .kill
cmp #$4000,d0
bne.s .loop
;
.kill move.l a5,a0
killitem doors
move.l a0,a5
bra .loop
;
.done rts
doorsfxflag dc 0
execevent ;d0=event number to execute...1,2...
;
sf doorsfxflag
move.l map_map(pc),a6
move.l map_events(pc),a0
add.l 0(a0,d0*4),a6
;
exec_loop move (a6)+,d0
beq.s .rts
subq #1,d0
beq exec_addobj ;1 - add an object (alien etc)
subq #1,d0
beq exec_opendoor ;2 - open a door
subq #1,d0
beq exec_teleport ;3 - teleport
subq #1,d0
beq exec_loadobjs ;4 - load objects
subq #1,d0
beq exec_changetxt ;5 - change texture
subq #1,d0
beq exec_rotpolys ;6 - start polygons rotating!
;
warn #$f0f
;
.rts tst doorsfxflag
beq.s .nodoor
clr doorsfxflag
move.l doorsfx(pc),a0
moveq #64,d0
moveq #2,d1
bsr playsfx
.nodoor rts
exec_changetxt ;
move (a6)+,d0 ;zone#
move.l map_poly(pc),a1
lsl #5,d0
lea 0(a1,d0),a1 ;polygon to change
;
move (a6)+,d0 ;new texture
move.b d0,zo_t(a1)
bra exec_loop
exec_opendoor st doorsfxflag
addlast doors ;a0=new door
;
move (a6)+,d0 ;door #
move.l map_poly(pc),a1
lsl #5,d0
lea 0(a1,d0),a1 ;polygon to open!
;
;calc lx add, lz add, rx add, rz add
;
move.l a1,do_poly(a0)
move.l zo_lx(a1),do_lx(a0)
move.l zo_rx(a1),do_rx(a0)
clr do_frac(a0)
move #$100,do_fracadd(a0)
bra exec_loop
exec_teleport move.l eventobj(pc),a0
;
move (a6)+,ob_telex(a0)
addq #2,a6
move (a6)+,ob_telez(a0)
move (a6)+,ob_telerot(a0)
;
tst finished2
bne exec_loop
;
move #2,ob_pixsizeadd(a0)
bsr dotelesfx
bra exec_loop
dotelesfx move.l telesfx(pc),a0
moveq #64,d0
moveq #10,d1
bra playsfx
exec_loadobjs ;
.loop move (a6)+,d0
bmi .done
bsr loadanobj
bra.s .loop
.done ;
bra exec_loop
loadanobj ;d0=object#...sys must be permitted
;
lea objinfo,a2
mulu #objinfof-objinfo,d0
move.l _ob_shape-objinfo(a2,d0),a2
lea 8(a2),a3 ;filename
;
tst.l (a2)
bne.s .skip
move.l a3,a0
moveq #1,d1
bsr loadfile
move.l d0,(a2)
beq.s .skip
move.l d0,a0
jsr remapanim
.skip ;
tst.l 4(a2)
bne.s .rts
move.l a3,a0
.loop tst.b (a3)+
bne.s .loop
move.b #'2',-(a3)
moveq #1,d1
bsr loadfile
clr.b (a3)
move.l d0,4(a2)
beq.s .rts
move.l d0,a0
jsr remapanim
;
.rts rts
exec_rotpolys ;
;could also be morphpolys depending on bit 0 of flags!
;
addlast rotpolys
bne.s .ok
addq #8,a6
bra exec_loop
;
.ok st doorsfxflag
movem (a6)+,d0-d3 ;polynum,count,speed,flags
;
clr rp_rot(a0)
move d1,rp_num(a0)
move d2,rp_speed(a0)
move d3,rp_flags(a0)
move d1,d5
subq #1,d5
move.l map_poly(pc),a2 ;polygons!
lsl #5,d0
add d0,a2
move.l a2,rp_first(a0)
;
btst #0,d3
beq .rot
;
;OK, prepare for morph
;
lsl #5,d1
lea 0(a2,d1),a3
lea rp_vx(a0),a1
;
.loop movem zo_lx(a3),d0-d1
movem zo_lx(a2),d2-d3
sub d2,d0
sub d3,d1
movem d0-d3,(a1)
addq #8,a1
;
lea 32(a2),a2
lea 32(a3),a3
dbf d5,.loop
;
bra exec_loop
;
.rot ;First, calc centre X,Z into d6,d7
;
moveq #0,d6
moveq #0,d7
move.l a2,a1
;
.loop0 movem zo_lx(a1),d0/d2
add.l d0,d6
add.l d2,d7
lea 32(a1),a1
dbf d5,.loop0
;
divu d1,d6
divu d1,d7
movem d6-d7,rp_cx(a0)
;
lea rp_lx(a0),a1
subq #1,d1
;
.loop2 movem zo_lx(a2),d0/d2
sub d6,d0
move d0,(a1)+
sub d7,d2
move d2,(a1)+
move.l zo_na(a2),(a1)+
;
lea 32(a2),a2
dbf d1,.loop2
;
bra exec_loop
exec_addobj clr.l dummy
move (a6)+,d0 ;monster type
lea objinfo,a2
mulu #objinfof-objinfo,d0
add.l d0,a2
move.l (a2)+,a3
tst.l (a3)
beq.s .ok
.no addq #8,a6
bra exec_loop
.ok cmp #2,-2(a6) ;player?
bcc.s .notp
addfirst objects
bra.s .bum
.notp addlast objects
.bum beq.s .no
move.l a0,a5
;
move.l a5,(a3)
;
move (a6)+,ob_x(a5)
move (a6)+,ob_y(a5)
move (a6)+,ob_z(a5)
move (a6)+,ob_rot(a5)
;
lea ob_info(a5),a3
move #(objinfof-objinfo-4)>>1-1,d0
.loop move (a2)+,(a3)+
dbf d0,.loop
;
tst ob_blood(a5) ;hi bit of blood=1=invisible!
smi d0
ext d0
move d0,ob_invisible(a5)
;
bsr calcvecs
movem.l d4-d5,ob_xvec(a5)
;
move.l ob_shape(a5),a0
move.l 4(a0),ob_chunks(a5)
move.l (a0),a0
move.l a0,ob_shape(a5)
;
move an_maxw(a0),d0
move d0,ob_rad(a5)
mulu d0,d0
move.l d0,ob_radsq(a5)
;
clr.l ob_washit(a5)
;
bsr rnddelay
;
bra exec_loop
rnddelay move ob_range(a5),d0
bsr rndn
add ob_base(a5),d0
move d0,ob_delay(a5)
;
rts
seedrnd ;seed number in d0.w
;
moveq #54,d1
lea rndtable(pc),a0
;
.loop move d0,(a0)+
mulu #$1efd,d0
add #$dff,d0
dbf d1,.loop
;
move.l a0,k_index
move.l #rndtable+48,j_index
rts
rndw ;return rnd number 0...65535 if d0.w
;
movem.l a0/a1,-(a7)
lea rndtable(pc),a1
move.l j_index(pc),a0
move -(a0),d0
cmp.l a0,a1
bne.s .skip
lea rndtable+110(pc),a0
.skip move.l a0,j_index
move.l k_index(pc),a0
add -(a0),d0
move d0,(a0)
cmp.l a0,a1
bne.s .skip2
lea rndtable+110(pc),a0
.skip2 move.l a0,k_index
movem.l (a7)+,a0/a1
rts
savernd lea rndtable(pc),a0
lea rndback(pc),a1
moveq #(rndtablef-rndtable)/2-1,d0
.loop move (a0)+,(a1)+
dbf d0,.loop
rts
loadrnd lea rndback(pc),a0
lea rndtable(pc),a1
moveq #(rndtablef-rndtable)/2-1,d0
.loop move (a0)+,(a1)+
dbf d0,.loop
rts
rndtable ds.w 55
k_index dc.l 0
j_index dc.l 0
rndtablef
rndback ds.b rndtablef-rndtable
rndl bsr rndw
move d0,d1
bsr rndw
swap d0
move d1,d0
rts
rndn move d0,d1
bsr rndw
mulu d1,d0
swap d0
rts
calcangle2 ;angle of camera to object in a5
;
move camx(pc),d0
sub ob_x(a5),d0
move camz(pc),d1
sub ob_z(a5),d1
bra.s calcangle_
calcangle ;angle of object a5 to object a0...
;
move ob_x(a0),d0
sub ob_x(a5),d0
move ob_z(a0),d1
sub ob_z(a5),d1
;
calcangle_ ;d0.w=x d1.w=y (dest-src)!
;
moveq #0,d2
tst d1
bpl.s .hpos
moveq #16,d2
neg d1
.hpos tst d0
bpl.s .wpos
eor #8,d2
neg d0
.wpos cmp d1,d0
bmi.s .notsteep
bne.s .neq
move #$2000,d1
bra.s .flow
.neq eor #4,d2
exg d1,d0
.notsteep tst d1
bne.s .noflow
moveq #0,d1
bra.s .flow
.noflow ext.l d0
swap d0
divu d1,d0
lsr #6,d0
and #1022,d0
move .arc(pc,d0),d1
.flow move.l .oct(pc,d2),d0
eor d0,d1
swap d0
add d1,d0
lsr #8,d0
rts
;
.oct dc 0,0,$4000,-1,0,-1,$c000,0
dc $8000,-1,$4000,0,$8000,0,$c000,-1
.arc incbin arc.bin
currplayer dc.l 0
calcscene ;a5=player object
;
move #$20,$dff09a
;
move.l a5,currplayer
move.l ob_palette(a5),palette
move ob_thermo(a5),thermo
move ob_infra(a5),infra
move ob_pixsize(a5),pixsize
;
clr.l shapelist
move.l a5,a0
bsr calccamera
bsr makewalls
;
lea objects(pc),a5
;
.loop move.l (a5),a5
tst.l (a5)
beq.s .done
cmp.l currplayer(pc),a5
beq.s .loop
move.l ob_render(a5),a0
tst ob_invisible(a5)
beq.s .notinvs
bpl.s .hb
move.l #drawobjtrans,shaperender
bra.s .rit
.hb move.l #drawobjinvs,shaperender
.rit jsr (a0)
move.l #drawobjnorm,shaperender
bra.s .loop
.notinvs jsr (a0)
bra.s .loop
.done ;
lea gore(pc),a5
;
.loop2 move.l (a5),a5
tst.l (a5)
beq.s .done2
;
movem go_x(a5),d0/d2
moveq #0,d1
move.l go_shape(a5),a0
move #$200,d7
bsr drawshape_q
;
bra.s .loop2
;
.done2 move #$8020,$dff09a
;
rts
blitscene bclr #7,ob_update(a5)
beq.s .noupdate
;
bclr #7,ob_update+1(a5)
beq.s .stats
;
move.l ob_window(a5),a2
moveq #9,d0
bsr wcopy
bsr initstats
;
.stats bsr showstats
;
.noupdate move ob_messtimer(a5),d0
bpl.s .mskip
addq #1,d0
beq.s .mdone
neg ob_messtimer(a5)
move.l ob_window(a5),a0
bsr putstrip
bsr printmess
bra.s .mskip
;
.mdone clr ob_messtimer(a5)
move.l ob_window(a5),a0
bsr putstrip
.mskip ;
rts
drawscene ;a5=player
;
move.l ob_window(a5),a0
bsr dbwindow
;
bsr castwalls
bsr makeqstrip
bsr renderwalls
;
move floorflag(pc),d0
ble.s .nofloor
;
move camy(pc),d0
neg d0
moveq #-1,d1
move maxy(pc),d7
subq #1,d7
move.l floor(pc),a0
bsr flat
;
.nofloor move roofflag(pc),d0
ble.s .noflat
;
move #-255,d0
sub camy(pc),d0
moveq #1,d1
move miny(pc),d7
move.l roof(pc),a0
bsr flat
;
.noflat bsr drawshapes
bsr drawblood
;
move.l currplayer(pc),a0
move ob_pixsize(a0),d0
bne pixelate
rts
chatstuff move chatok(pc),d0
beq.s .rts
;
move chatoutget(pc),d0
cmp chatoutput(pc),d0
beq.s .noout
and #31,d0
lea chatout(pc),a0
move.b 0(a0,d0),d0 ;chat out character!
addq #1,chatoutget
moveq #1,d1
move d0,-(a7)
bsr chatprintout
move (a7)+,d0
sub.b #32,d0 ;encode for chat
bset #6,d0
bsr serput
;
.noout move chatinget(pc),d0
cmp chatinput(pc),d0
beq.s .rts
and #31,d0
lea chatin(pc),a0
move.b 0(a0,d0),d0
addq #1,chatinget
moveq #2,d1
bsr chatprintin
;
.rts rts
sfxvbint lea sfxs(pc),a1
moveq #3,d3
;
.loop tst fx_status(a1)
ble.s .skip
;
;this one queued! gotta play it...
;
subq #1,fx_status(a1)
bgt.s .skip
move.l fx_sfx(a1),a0
bsr playsfxnow
;
.skip lea fx_size(a1),a1
dbf d3,.loop
;
;fade out song if nec.
;
move fadevol(pc),d0
beq.s .nofade
move.l medat(pc),a1
sub #$80,fadevol
bgt.s .setvol
clr fadevol
jmp 12(a1) ;stop song
bra.s .nofade
;
.setvol move fadevol(pc),d0
lsr #8,d0
jmp 16(a1) ;set volume
;
.nofade rts
dc.l readmodem
joytable dc.l readjoy1,readjoy0,readkeys,readcd321,readcd320
readjoy ;a0=player
move ob_cntrl(a0),d0
bmi.s readmodem
;
lea joyx0(pc),a0
lea 0(a0,d0*8),a0
move.l joytable(pc,d0*4),a1
jsr (a1)
move linked(pc),d0
bne.s .send
rts
.send ;
;a0=cntrl block
;
bsr encodejoy
movem.l d0/a0,-(a7)
bsr serput
movem.l (a7)+,d0/a0
;
.noput lea pbuff(pc),a1
;
move pput(pc),d1
and #127,d1
move.b d0,0(a1,d1)
addq #1,pput
;
move pget(pc),d1
and #127,d1
move.b 0(a1,d1),d0
addq #1,pget
;
bra decodejoy
;
readmodem ;
.waitser bsr serget
bpl.s .sergot
;
;OK, do a vwait to allow other machine to catch up!
;
move #$20,$dff09c
.vw ;
ifne debugser
col #$f0f
endc
;
btst #5,$dff01f
beq.s .vw
;
move #$20,$dff09c
bsr chatstuff
bra.s .waitser
;
.sergot lea joyxs(pc),a0
tst.b d0
bpl .djoy
and #$ff,d0
move d0,finished
moveq #0,d0
;
.djoy bsr decodejoy
move.l (a0)+,joyx
move.l (a0),joyb
rts
escape dc 0
readjoys ;fill in appropriate 'joyxn' block...check escape
;
qkey $45
beq.s .noesc
st escape
.noesc move finished(pc),d0
or finished2(pc),d0
bne.s .rts
;
move.l player1(pc),a0
bsr readjoy
move gametype(pc),d0
beq.s .rts
move.l player2(pc),a0
bra readjoy
.rts rts
vbhandler movem.l d2-d7/a2-a6,-(a7)
;
subq #1,(a1)+ ;inc/dec frame counters
addq #1,(a1)
;
;this done every frame!
bsr showit
bsr chatstuff
bsr sfxvbint
;
btst #0,framecnt+1
beq exit_vb
tst paused
bne exit_vb
;
;OK, movement/animation stuff!
;
bsr readjoys
bsr doanims
bsr dorots
bsr dodoors
bsr moveblood
;
ifne debugser
;
;OK, kludge in a random number!
move framecnt(pc),d0
and #126,d0
bne.s .nornd
;
bsr rndw
lea .rndasc(pc),a0
moveq #3,d1
.loop rol #4,d0
move d0,d2
and #15,d2
add #48,d2
cmp #58,d2
bcs.s .rok
addq #7,d2
.rok move.b d2,(a0)+
dbf d1,.loop
;
move.l player1(pc),a5
bsr message
.rndasc dc.b 'aaaa',0
even
;
endc
.nornd ;
move.l a7,obj_stack
lea objects(pc),a5
;
obj_loop move.l (a5),a5
tst.l (a5)
beq exit_vb
;
move.l ob_logic(a5),a0
jsr (a0)
;
;check collision!
;
move ob_collwith(a5),d0
beq.s obj_loop
;
move ob_rad(a5),d1
move ob_x(a5),d6
move ob_z(a5),d7
;
lea objects(pc),a0
;
.loop2 move.l (a0),a0
cmp.l a5,a0
bne.s .this
;
clr.l ob_washit(a5) ;not hit! can get hit next time...
bra obj_loop
.this ;
move ob_colltype(a0),d2
and d0,d2
beq.s .loop2
;
move ob_rad(a0),d2
add d1,d2 ;r sum
;
move ob_x(a0),d3
sub d6,d3
bpl.s .xpl
neg d3
.xpl cmp d2,d3
bcc.s .loop2
;
move ob_z(a0),d4
sub d7,d4
bpl.s .ypl
neg d4
.ypl cmp d2,d4
bcc.s .loop2
;
mulu d2,d2
mulu d3,d3
mulu d4,d4
add.l d4,d3
cmp.l d2,d3
bcc.s .loop2
;
cmp.l ob_washit(a5),a0
beq obj_loop
move.l a0,ob_washit(a5)
;
move finished2(pc),d0
bne obj_loop
;
move.l #killobject3,killjsr
movem.l a0/a5,obj_a0
exg.l a0,a5
;
move ob_damage(a0),d0
move.l ob_hit(a5),a1
sub d0,ob_hitpoints(a5)
bgt.s hit_skip
move.l ob_die(a5),a1
;
hit_skip jsr (a1)
;
hit_ret move.l #killobject2,killjsr
movem.l obj_a0(pc),a0/a5
;
move ob_damage(a0),d0
move.l ob_hit(a5),a1
sub d0,ob_hitpoints(a5)
bgt.s hit_skip2
move.l ob_die(a5),a1
;
hit_skip2 jsr (a1)
bra obj_loop
;
exit_vb st doneflag
bsr showit
;
movem.l (a7)+,d2-d7/a2-a6
moveq #0,d0
;
rts rts
obj_a0 dc.l 0
obj_a5 dc.l 0
obj_stack dc.l 0
killjsr dc.l killobject2
killobject ;
move.l killjsr(pc),a0
jmp (a0)
killobject2 move.l a5,a0
killitem objects
move.l a0,a5
move.l obj_stack(pc),a7
bra obj_loop
killobject3 move.l a5,a0
killitem objects
move.l obj_stack(pc),a7
bra hit_ret
bloodspeed bsr rndw
ext.l d0
lsl.l #2,d0
rts
bloodspeed2 bsr rndw
ext.l d0
lsl.l #5,d0
rts
bloodspeed3 bsr rndw
ext.l d0
lsl.l #4,d0
rts
makesparksq move.l ob_chunks(a5),a2
;
makesparks ;a2=sparks
;
movem.l ob_x(a5),d2-d4
move 2(a2),d5
subq #1,d5
;
.loop addlast objects
beq .rts
movem.l d2-d4,ob_x(a0)
bsr bloodspeed2
move.l d0,ob_xvec(a0)
bsr bloodspeed2
move.l d0,ob_yvec(a0)
bsr bloodspeed2
move.l d0,ob_zvec(a0)
move.l a2,ob_shape(a0)
move d5,ob_frame(a0)
move.l #sparkslogic,ob_logic(a0)
move.l #drawshape_1,ob_render(a0)
clr ob_invisible(a0)
clr ob_colltype(a0)
clr ob_collwith(a0)
bsr rndw
and #15,d0
add #15,d0
move d0,ob_delay(a0)
dbf d5,.loop
.rts rts
sparkslogic subq #1,ob_delay(a5)
ble killobject
movem.l ob_x(a5),d0-d2
add.l ob_xvec(a5),d0
add.l ob_yvec(a5),d1
add.l ob_zvec(a5),d2
movem.l d0-d2,ob_x(a5)
rts
bloodymess ;throw random blood splots everywhere!
;
bsr bloodspeed2
add.l ob_x(a5),d0
move.l d0,d2
bsr bloodspeed2
add.l ob_gutsy(a5),d0
move.l d0,d3
bsr bloodspeed2
add.l ob_z(a5),d0
move.l d0,d4
;
.loop addlast blood
beq.s .done
;
movem.l d2-d4,bl_x(a0)
bsr bloodspeed
move.l d0,bl_xvec(a0)
bsr bloodspeed
move.l d0,bl_yvec(a0)
bsr bloodspeed
move.l d0,bl_zvec(a0)
move ob_blood(a5),bl_color(a0)
;
dbf d7,.loop
;
.done rts
bloodymess2 ;throw random blood splots everywhere!
;
bsr bloodspeed2
add.l ob_x(a5),d0
move.l d0,d2
bsr bloodspeed2
add.l ob_gutsy(a5),d0
move.l d0,d3
bsr bloodspeed2
add.l ob_z(a5),d0
move.l d0,d4
;
.loop addlast blood
beq.s .done
;
movem.l d2-d4,bl_x(a0)
bsr bloodspeed3
move.l d0,bl_xvec(a0)
bsr bloodspeed3
move.l d0,bl_yvec(a0)
bsr bloodspeed3
move.l d0,bl_zvec(a0)
move ob_blood(a5),bl_color(a0)
;
dbf d7,.loop
;
.done rts
chunklogic move mode(pc),d0
beq chunklogic2
;
add.l #$8000,ob_yvec(a5)
move.l ob_yvec(a5),d0
add.l ob_y(a5),d0
blt .skip
;
;OK...hit ground!
;
bsr splat
addlast gore
bne.s .gok
;
move.l gore(pc),a0
killitem gore
addlast gore
beq killobject
;
.gok move ob_x(a5),go_x(a0)
move ob_z(a5),go_z(a0)
move.l ob_shape(a5),a1
move ob_frame(a5),d0
add.l 12(a1,d0*4),a1
move.l a1,go_shape(a0)
;
bra killobject
;
.skip move.l d0,ob_y(a5)
bsr checkvecs
beq.s .rts
clr.l ob_xvec(a5)
clr.l ob_zvec(a5)
.rts rts
chunklogic2 add.l #$8000,ob_yvec(a5)
move.l ob_yvec(a5),d0
add.l d0,ob_y(a5)
blt.s .ok
;bsr splat
bra killobject
.ok movem.l ob_xvec(a5),d0-d1
add.l d0,ob_x(a5)
add.l d1,ob_z(a5)
rts
splat move.l splatsfx(pc),a0
moveq #32,d0
moveq #-1,d1
bra playsfx
blowterra move.l robodiesfx(pc),a0
moveq #64,d0
moveq #20,d1
bsr playsfx
bra blowquick
blowdragon ;same, but messier...
;
;loud!
;
move.l diesfx(pc),a0
moveq #64,d0
moveq #50,d1
bsr playsfx
move.l diesfx(pc),a0
moveq #64,d0
moveq #50,d1
bsr playsfx
move.l robodiesfx(pc),a0
moveq #64,d0
moveq #50,d1
bsr playsfx
move.l robodiesfx(pc),a0
moveq #64,d0
moveq #50,d1
bsr playsfx
;
moveq #63,d7
bsr bloodymess2
;
move.l ob_chunks(a5),a4
bsr blowchunx
bsr blowchunx
bsr blowchunx
bsr blowchunx
;
move.l #dragondead,ob_logic(a5)
move.l #rts,ob_render(a5)
clr ob_colltype(a5)
clr ob_collwith(a5)
move #127,ob_delay(a5)
rts
dragondead subq #1,ob_delay(a5)
bgt.s .rts
;
move #3,finished
;
.rts rts
blowdeath cmp.l sucker(pc),a5
bne.s blowobject
clr.l sucker
clr.l sucking
;
blowobject move.l diesfx(pc),a0
moveq #64,d0
moveq #2,d1
bsr playsfx
blowquick ;
moveq #31,d7
bsr bloodymess2
;
move.l ob_chunks(a5),d0
bne.s .chok
;
moveq #15,d7
bsr bloodymess2
bra killobject
;
.chok move.l d0,a4
bsr blowchunx
bra killobject
blowchunx move 2(a4),d7
subq #1,d7
;
.loop addlast objects
beq killobject
movem.l ob_x(a5),d0-d2
move.l #-64<<16,d1
movem.l d0-d2,ob_x(a0)
;
bsr bloodspeed3
move.l d0,ob_xvec(a0)
bsr bloodspeed3
sub.l #$40000,d0
move.l d0,ob_yvec(a0)
bsr bloodspeed3
move.l d0,ob_zvec(a0)
;
clr ob_invisible(a0)
clr ob_colltype(a0)
clr ob_collwith(a0)
move.l #chunklogic,ob_logic(a0)
move.l a4,ob_shape(a0)
move.l #drawshape_1sc,ob_render(a0)
move d7,ob_frame(a0)
move ob_scale(a5),ob_scale(a0)
;
move an_maxw(a4),d0
move d0,ob_rad(a0)
mulu d0,d0
move.l d0,ob_radsq(a0)
;
dbf d7,.loop
rts
hurtdeath ;OK! death head hit!
;
;point at player, and start to suck his soul!
;
move.l sucking(pc),d0
bne.s .rts
;
bsr pickplayer
cmp.l #playerlogic,ob_logic(a0)
bne.s .rts
;
move.l a0,sucking
move.l a5,sucker
;
move ob_rot(a5),ob_oldrot(a5)
move.l ob_logic(a5),ob_oldlogic(a5)
move.l #deathsuck,ob_logic(a5)
move.l #rts,ob_hit(a5)
move #64,ob_delay(a5)
bra.s deathsuck
;
.rts rts
deathsuck ;death head sucking out a players soul!
;
bsr deathbounce
bsr deathanim
subq #1,ob_delay(a5)
bgt.s .more
move ob_oldrot(a5),ob_rot(a5)
move.l ob_oldlogic(a5),ob_logic(a5)
move.l #hurtdeath,ob_hit(a5)
clr.l sucker
clr.l sucking
bra rnddelay
;
.more move.l sucking(pc),a0
move.l a0,a2
bsr calcangle ;point at player!
move d0,ob_rot(a5)
;
add #128,d0
and #255,d0
move.l camrots(pc),a3
lea 0(a3,d0*8),a3
;
move.l a3,suckangle
;
;calc x/z vecs
;
moveq #3,d7
bsr addsoul
;
.rts rts
sucker dc.l 0
sucking dc.l 0
suckangle dc.l 0
addsoul ;d7 times!
;
addlast blood
beq .rts
;
move 2(a3),d2
ext.l d2
lsl.l #5,d2
neg.l d2
move 6(a3),d3
ext.l d3
lsl.l #5,d3
;
move.l d2,bl_xvec(a0)
move.l a5,bl_yvec(a0)
move.l d3,bl_zvec(a0)
;
swap d2
swap d3
add d2,d2
add d3,d3
add ob_x(a2),d2
add ob_z(a2),d3
;
bsr rndw
and #63,d0
sub #32,d0
add d2,d0
move d0,bl_x(a0)
;
bsr rndw
and #63,d0
sub #32,d0
add #110,d0
move d0,bl_y(a0) ;>0= funny blood!
;
bsr rndw
and #63,d0
sub #32,d0
add d3,d0
move d0,bl_z(a0)
;
bsr rndw
and #1,d0
move soulcols(pc,d0*2),bl_color(a0)
;
dbf d7,addsoul
;
.rts rts
soulcols dc $0ff,$0f0
hurtghoul moveq #31,d7
bsr bloodymess
rts
hurtterra move.l a0,-(a7)
move.l shootsfx2(pc),a0
moveq #64,d0
moveq #2,d1
bsr playsfx
move.l (a7)+,a0
bra.s hurtobject
hurtngrunt move.l a0,-(a7)
bsr rndw
and #3,d0
cmp lastgrunt(pc),d0
bne.s .new
addq #1,d0
and #3,d0
.new move d0,lastgrunt
lea grunttable(pc),a0
move.l 0(a0,d0*4),a0
move.l (a0),a0
moveq #64,d0
moveq #1,d1
bsr playsfx
move.l (a7)+,a0
;
hurtobject move ob_colltype(a0),d0
and #24,d0
bne.s .rts
;
moveq #23,d7
bsr bloodymess
move ob_hurtpause(a5),ob_hurtwait(a5)
beq .rts
;
move #4,ob_frame(a5)
move.l ob_logic(a5),ob_oldlogic2(a5)
move.l ob_hit(a5),ob_oldhit(a5)
move.l #pauselogic2,ob_logic(a5)
move.l #rts,ob_hit(a5)
;
.rts rts
lizhurt move.l a0,-(a7)
move.l lizhitsfx(pc),a0
moveq #64,d0
moveq #1,d1
bsr playsfx
move.l (a7)+,a0
bra hurtobject
pauselogic2 subq #1,ob_hurtwait(a5)
bgt.s .rts
clr ob_frame(a5)
move.l ob_oldlogic2(a5),ob_logic(a5)
move.l ob_oldhit(a5),ob_hit(a5)
.rts rts
pauselogic subq #1,ob_delay(a5)
bgt.s .skip
;
bsr rnddelay
move.l ob_oldlogic(a5),ob_logic(a5)
;
;if in front of player, continue on old course...
;
bsr pickcalc
;
;bsr pickplayer
;tst ob_invisible(a0)
;bne.s .useold ;can't see player! no intelligence...
;bsr calcangle
;
move ob_rot(a0),d1
and #255,d1
sub d0,d1
bpl.s .pl
neg d1
.pl cmp #64,d1
bcs.s .skip
cmp #192,d1
bcc.s .skip
;
.useold move ob_oldrot(a5),ob_rot(a5)
bsr calcvecs
;
.skip rts
shoot ;
;fire off a bullet...
;
;d2 : colltype
;d3 : collwith
;d4 : hitpoints
;d5 : damage
;d6 : speed
;a2=bullet shape
;a3=sparks shape
;
addfirst objects
beq .rts
;
move ob_bouncecnt(a5),ob_bouncecnt(a0)
move ob_x(a5),ob_x(a0)
move ob_y(a5),d0
add ob_firey(a5),d0
move d0,ob_y(a0)
move ob_z(a5),ob_z(a0)
move.l #firelogic,ob_logic(a0)
move.l #drawshape_1,ob_render(a0)
move.l #rts,ob_hit(a0)
move.l #killobject,ob_die(a0)
move d2,ob_colltype(a0)
move d3,ob_collwith(a0)
move d4,ob_hitpoints(a0)
move d5,ob_damage(a0)
move d6,ob_movspeed(a0)
move.l a2,ob_shape(a0)
clr ob_invisible(a0)
clr ob_frame(a0)
move.l a3,ob_chunks(a0)
;
move ob_rot(a5),d0
and #255,d0
move.l camrots(pc),a1
lea 0(a1,d0*8),a1
;
move 2(a1),d0
move d0,ob_nxvec(a0)
neg d0
muls d6,d0
add.l d0,d0
move 6(a1),d1
move d1,ob_nzvec(a0)
muls d6,d1
add.l d1,d1
;
movem.l d0-d1,ob_xvec(a0)
;add.l d0,ob_x(a0)
;add.l d1,ob_z(a0)
;
move #32,ob_rad(a0)
move.l #32*32,ob_radsq(a0)
;
.rts rts
pickcalc ;pick a player and calculate angle to player!
;
bsr pickplayer
bsr calcangle
tst ob_invisible(a0)
beq.s .rts
move d0,-(a7)
bsr rndw
and #63,d0
sub #32,d0
add (a7)+,d0
and #255,d0
.rts rts
fire1 bsr pickcalc
;
;random noise for inaccuracy!
;
move d0,-(a7)
bsr rndw
and #31,d0
sub #16,d0
add (a7)+,d0
and #255,d0
;
move d0,ob_rot(a5)
bsr calcvecs
move #7,ob_delay(a5)
move.l ob_logic(a5),ob_oldlogic(a5)
move.l #pauselogic,ob_logic(a5)
clr.l ob_frame(a5)
;
moveq #4,d2 ;colltype
moveq #0,d3 ;collwith
moveq #1,d4 ;hitpoints
moveq #1,d5 ;damage
moveq #20,d6 ;speed
moveq #0,d7 ;acceleration!
lea bullet1,a2
lea sparks1,a3
;
bsr shoot
;
rts
pickplayer ;pick nearest player
;
move.l player1(pc),a0
move gametype(pc),d0
beq.s .rts
move.l player2(pc),a1
move linked(pc),d0
bpl.s .nosw
;
exg a0,a1
.nosw ;
tst ob_hitpoints(a0)
beq .sw
tst ob_hitpoints(a1)
beq.s .rts
;
move ob_x(a5),d0
sub ob_x(a0),d0
muls d0,d0
move ob_z(a5),d1
sub ob_z(a0),d1
muls d1,d1
add.l d1,d0 ;dist to player a0
;
move ob_x(a5),d1
sub ob_x(a1),d1
muls d1,d1
move ob_z(a5),d2
sub ob_z(a1),d2
muls d2,d2
add.l d2,d1 ;dist to player a1
;
cmp.l d1,d0
bcs.s .rts
;
.sw move.l a1,a0
;
.rts rts
checkcoll ;check for collision between a5, and a0
;
move ob_rad(a5),d1
move ob_rad(a0),d2
add d1,d2 ;r sum
;
move ob_x(a0),d3
sub ob_x(a5),d3
bpl.s .xpl
neg d3
.xpl cmp d2,d3
bcc.s .no
;
move ob_z(a0),d4
sub ob_z(a5),d4
bpl.s .ypl
neg d4
.ypl cmp d2,d4
bcc.s .no
;
mulu d2,d2
mulu d3,d3
mulu d4,d4
add.l d4,d3
cmp.l d2,d3
bcc.s .no
;
moveq #-1,d0
rts
;
.no moveq #0,d0
rts
baldycharge ;
;baldy charging at player!
;
bsr checkvecs
beq baldy_skip
;
baldy_tonorm move.l ob_movspeed(a5),d0
lsr.l #2,d0
move.l d0,ob_movspeed(a5)
;
move.l ob_framespeed(a5),d0
lsr.l #2,d0
move.l d0,ob_framespeed(a5)
;
move.l ob_oldlogic(a5),ob_logic(a5)
bsr rnddelay
;
bra monsterfix
;
baldy_skip ;close to player? start throwing punches around!
;
bsr pickcalc
;
sub ob_rot(a5),d0
cmp #32,d0
bgt baldy_tonorm
cmp #-32,d0
blt baldy_tonorm
;
move.l a0,ob_washit(a5)
bsr checkcoll
beq monsternew ;no collisions!
;
;go into punch mode!
;
move.l #baldypunch,ob_logic(a5)
move ob_punchrate(a5),ob_delay(a5)
clr.l ob_frame(a5)
rts
baldypunch ;
bsr pickplayer
bsr checkcoll
bne.s .doit
;
clr.l ob_frame(a5)
bra baldy_tonorm
;
.doit subq #1,ob_delay(a5)
ble.s .punch
rts
.punch move ob_punchrate(a5),ob_delay(a5)
moveq #0,d0 ;stand frame
cmp ob_frame(a5),d0
bne .skip
;
clr.l ob_washit(a5) ;punch!
bsr calcangle
move d0,ob_rot(a5)
moveq #5,d0
.skip move d0,ob_frame(a5)
rts
calcbangle bsr calcangle
tst ob_invisible(a0)
beq.s .notinv
;
;invisible, add some randomeness!
;
move d0,-(a7)
bsr rndw
and #127,d0
sub #64,d0
add (a7)+,d0
and #255,d0
;
.notinv move d0,ob_rot(a5)
rts
lizardlogic ;
subq #1,ob_delay(a5)
bgt monstermove ;charge?
;
bsr pickcalc ;pic player in a0!
move ob_x(a5),d0
sub ob_x(a0),d0
muls d0,d0
move ob_z(a5),d1
sub ob_z(a0),d1
muls d1,d1
add.l d1,d0
cmp.l #256*256,d0
bcc.s bl2
;
move.l lizsfx(pc),a0
moveq #32,d0
moveq #5,d1
bsr playsfx
;
bra bl2
baldylogic ;
;OK, what can baldy do...
;
;how about, walk around similar to the marine, but randomly
;charge at you?
;
;then, if he's close enough, he throws a punch!
;
subq #1,ob_delay(a5)
bgt monstermove ;charge?
;
bl2 bsr pickcalc
move d0,ob_rot(a5)
;
move.l ob_movspeed(a5),d0
lsl.l #2,d0
move.l d0,ob_movspeed(a5)
move.l ob_framespeed(a5),d0
lsl.l #2,d0
move.l d0,ob_framespeed(a5)
;
bsr calcvecs
move.l ob_logic(a5),ob_oldlogic(a5)
move.l #baldycharge,ob_logic(a5)
;
rts
terralogic ;
move ob_rot(a5),ob_oldrot(a5)
subq #1,ob_delay(a5)
ble .fire
;
move ob_delay(a5),d0
and #31,d0
bne monstermove
;
move.l robotsfx(pc),a0
moveq #64,d0
moveq #10,d1
bsr playsfx
bra monstermove
;
.fire ;OK, terra goes apeshit! stand there firing off at player!
;use punchrate as firedelay!
;
clr ob_frame(a5)
move #1,ob_delay(a5)
move ob_firecnt(a5),ob_delay2(a5)
move.l #terralogic2,ob_logic(a5)
rts
terralogic2 ;
subq #1,ob_delay(a5)
bgt.s .rts
;
move ob_firerate(a5),ob_delay(a5)
;
;OK, to to face player and fire away!
;
bsr pickcalc
move d0,ob_rot(a5)
bsr calcvecs
;
moveq #4,d2 ;colltype
moveq #0,d3 ;collwith
moveq #1,d4 ;hitpoints
moveq #3,d5 ;damage
moveq #16,d6 ;speed
moveq #0,d7 ;acceleration!
lea bullet4,a2
lea sparks4,a3
;
bsr shoot
;
move.l shootsfx3(pc),a0
moveq #32,d0
moveq #5,d1
bsr playsfx
;
subq #1,ob_delay2(a5)
bgt.s .rts
;
bsr rnddelay
move.l #terralogic,ob_logic(a5)
;
.rts rts
ghoullogic ;
addq #8,ob_bounce(a5)
move ob_bounce(a5),d0
move.l camrots(pc),a0
and #255,d0
move 0(a0,d0*8),d0
ext.l d0
lsl.l #5,d0 ;+/- 32
swap d0
add #-32,d0
move d0,ob_y(a5)
;
bsr pickcalc
move d0,ob_rot(a5)
;
subq #1,ob_delay(a5)
bgt.s .skip
;
move #1,ob_frame(a5)
move.l #$2000,ob_framespeed(a5)
moveq #4,d2 ;colltype
moveq #0,d3 ;collwith
moveq #1,d4 ;hitpoints
moveq #3,d5 ;damage
moveq #20,d6 ;speed
moveq #0,d7 ;acceleration!
lea bullet2,a2
lea sparks2,a3
;
bsr shoot
bsr rnddelay
;
.skip ;OK, ghoul moves around ignoring walls!
;
;he's pointed at player...how about randomly selected to make
;this his new movement vector?
;
bsr rndw
move ob_movspeed(a5),d1
lsl #8,d1
cmp d1,d0
bcc.s .no
;
bsr calcvecs
;
move.l ghoulsfx(pc),a0
moveq #32,d0
moveq #-5,d1
bsr playsfx
;
.no movem.l ob_xvec(a5),d0-d1
add.l d0,ob_x(a5)
add.l d1,ob_z(a5)
;
move.l ob_framespeed(a5),d0
beq.s .rts
add.l d0,ob_frame(a5)
cmp #3,ob_frame(a5)
bcs.s .rts
;
clr ob_frame(a5)
clr.l ob_framespeed(a5)
;
.rts rts
demonpause move ob_delay(a5),d0
move d0,d1
and #4,d0
sne d0
ext d0
and #5,d0 ;0 or 5
move d0,ob_frame(a5)
;
and #7,d1 ;do a fire?
cmp #7,d1
bne.s .nofire
;
move ob_delay(a5),d0
lsr #3,d0
mulu #18,d0
lea wtable(pc),a0
moveq #4,d2 ;colltype
moveq #0,d3 ;collwith
movem 0(a0,d0),d4-d6 ;hits,dam,speed
mulu #$c000,d5
swap d5 ;3/4 damage!
moveq #0,d7 ;acc
movem.l 6(a0,d0),a2-a3 ;bullets/sparks
move.l 14(a0,d0),-(a7) ;sfx!
;
bsr shoot
;
move.l (a7)+,a0
move.l (a0),a0
moveq #32,d0
moveq #0,d1
bsr playsfx
;
.nofire subq #1,ob_delay(a5)
bgt.s .rts
;
bsr rnddelay
move.l ob_oldlogic(a5),ob_logic(a5)
;
.rts rts
demonlogic ;
move ob_rot(a5),ob_oldrot(a5)
subq #1,ob_delay(a5)
bgt monstermove
;
bsr pickcalc
;
move d0,ob_rot(a5)
bsr calcvecs
move #5<<3-1,ob_delay(a5)
move.l ob_logic(a5),ob_oldlogic(a5)
move.l #demonpause,ob_logic(a5)
;
rts
phantomlogic ;
move ob_rot(a5),ob_oldrot(a5)
subq #1,ob_delay(a5)
bgt monstermove
;
bsr pickcalc
;
move d0,ob_rot(a5)
bsr calcvecs
move #7,ob_delay(a5)
move.l ob_logic(a5),ob_oldlogic(a5)
move.l #pauselogic,ob_logic(a5)
move #5,ob_frame(a5)
;
moveq #4,d2 ;colltype
moveq #0,d3 ;collwith
moveq #1,d4 ;hitpoints
moveq #3,d5 ;damage
moveq #20,d6 ;speed
moveq #0,d7 ;acceleration!
lea bullet3,a2
lea sparks3,a3
;
bra shoot
deathbounce addq #4,ob_bounce(a5)
move ob_bounce(a5),d0
move.l camrots(pc),a0
and #255,d0
move 0(a0,d0*8),d0
ext.l d0
lsl.l #5,d0 ;+/- 64
swap d0
add #-48,d0
move d0,ob_y(a5)
rts
deathheadlogic ;
;cruises around rotating at speed ob_delay
;
bsr deathbounce
;
bsr checkvecs
bne.s .hit
;
;charge player?
;
bsr pickcalc ;find angle to player
move ob_rot(a5),d1
and #255,d1
sub d0,d1 ;am I near?
bpl.s .ansk
neg d1
.ansk cmp #16,d1
bcc.s .notnear
;
;OK! chargaroony!
;
move d0,ob_rot(a5)
move.l #deathcharge,ob_logic(a5)
bra calcvecs
.hit add #128,ob_rot(a5)
bsr rnddelay
.notnear move ob_delay(a5),d0
add d0,ob_rot(a5)
bsr calcvecs
rts
deathanim move.l ob_framespeed(a5),d0
add.l d0,ob_frame(a5)
cmp.l #$8000,ob_frame(a5)
blt.s .fix
cmp.l #$28000,ob_frame(a5)
blt.s .fok
.fix neg.l d0
add.l d0,ob_frame(a5)
move.l d0,ob_framespeed(a5)
;
.fok rts
deathcharge bsr deathbounce
bsr deathanim
;
bsr pickcalc
move ob_rot(a5),d1
and #255,d1
sub d1,d0 ;am I near?
bpl.s .ansk
neg d0
.ansk cmp #128,d0
bcc.s .hit
bsr checkvecs
bne.s .hit2
rts
.hit2 add #128,ob_rot(a5)
.hit move.l #deathheadlogic,ob_logic(a5)
move.l #$8000,ob_frame(a5)
bra rnddelay
monsterlogic ;
move ob_rot(a5),ob_oldrot(a5)
;monster cruising around minding his own business...
;
subq #1,ob_delay(a5)
ble fire1
;
monstermove bsr checkvecs
beq.s monsternew
;
;OK, try 90/-90 degrees...
;
monsterfix bsr rndw
moveq #64,d1
tst d0
bpl.s .umk
moveq #-64,d1
.umk add d1,ob_rot(a5)
bsr calcvecs
bsr checkvecs
beq.s monsternew
;
add #128,ob_rot(a5)
bsr calcvecs
bsr checkvecs
beq.s monsternew
;
move ob_oldrot(a5),d0
add #128,d0
move d0,ob_rot(a5)
;
bsr calcvecs
bsr checkvecs
monsternew ;
move.l ob_framespeed(a5),d0
add.l d0,ob_frame(a5)
and #3,ob_frame(a5)
rts
dragonfire ;dragon fires at you!
;
;d2 : colltype
;d3 : collwith
;d4 : hitpoints
;d5 : damage
;d6 : speed
;a2=bullet shape
;a3=sparks shape
;
subq #1,ob_delay(a5)
bpl .rts
move ob_delay(a5),d0
cmp #-16*8,d0
bgt.s .try
move #47,ob_delay(a5)
rts
.try and #7,d0
bne .rts
;
.fire moveq #0,d2 ;colltype
moveq #24+3,d3 ;collwith - p1/p2/bullets
moveq #1,d4 ;hitpoints
moveq #3,d5 ;damage
moveq #16,d6 ;speed
lea bullet5,a2
lea sparks5,a3
;
addlast objects
beq .rts
;
move ob_bouncecnt(a5),ob_bouncecnt(a0)
move ob_x(a5),ob_x(a0)
move ob_y(a5),d0
add ob_firey(a5),d0
move d0,ob_y(a0)
move ob_z(a5),ob_z(a0)
move.l #homeinlogic,ob_logic(a0)
move.l #drawshape_1,ob_render(a0)
move.l #makesparksq,ob_hit(a0)
move.l #blowdb,ob_die(a0)
move d2,ob_colltype(a0)
move d3,ob_collwith(a0)
move d4,ob_hitpoints(a0)
move d5,ob_damage(a0)
move d6,ob_movspeed(a0)
move.l a2,ob_shape(a0)
clr ob_invisible(a0)
clr ob_frame(a0)
move.l a3,ob_chunks(a0)
;
move ob_rot(a5),d0
and #255,d0
move.l camrots(pc),a1
lea 0(a1,d0*8),a1
;
move 2(a1),d0
move d0,ob_nxvec(a0)
neg d0
muls d6,d0
add.l d0,d0
move 6(a1),d1
move d1,ob_nzvec(a0)
muls d6,d1
add.l d1,d1
;
movem.l d0-d1,ob_xvec(a0)
;
move #32,ob_rad(a0)
move.l #32*32,ob_radsq(a0)
;
.rts rts
blowdb bsr makesparksq
bra killobject
homeinlogic bsr checkvecs
bne.s blowdb
bsr pickcalc ;find angle to player!
move.l camrots(pc),a0
lea 0(a0,d0*8),a0
move 2(a0),d4 ;x acc.
neg d4
ext.l d4
lsl.l #2,d4
move 6(a0),d5 ;z acc.
ext.l d5
lsl.l #2,d5
;
add.l ob_xvec(a5),d4
move.l d4,d0
bpl.s .pl1
neg.l d0
.pl1 cmp.l #$200000,d0 ;max speed
bcc.s .sk1
move.l d4,ob_xvec(a5)
;
.sk1 add.l ob_zvec(a5),d5
move.l d5,d0
bpl.s .pl2
neg.l d0
.pl2 cmp.l #$200000,d0
bcc.s .sk2
move.l d5,ob_zvec(a5)
.sk2 ;
bra putfire
dragonanim move.l ob_framespeed(a5),d0
add.l d0,ob_frame(a5)
and #3,ob_frame(a5)
rts
getobrot move ob_rotspeed(a5),d0
bne.s .addr
;
;OK, randomly left/rite!
;
bsr rndw
and #1,d0
bne.s .addr2
moveq #-1,d0
;
.addr2 lsl #2,d0
move d0,ob_rotspeed(a5)
;
.addr rts
dragonlogic ;OK! end of game baddy!
;
;how about cruising around in a circle a-la
;deathhead!
;
bsr dragonanim
bsr dragonfire
bsr checkvecs
beq.s .nohit
;
;OK, dragon has hit a wall...rot him around till he's clear!
;
bsr getobrot
lsl #2,d0
add d0,ob_rot(a5)
bra calcvecs
.nohit ;
bsr pickcalc
move ob_rot(a5),d1
and #255,d1
sub d0,d1 ;am I near?
bpl.s .ansk
neg d1
.ansk moveq #6,d0
tst ob_rotspeed(a5)
bne.s .sh
moveq #24,d0
.sh cmp d0,d1
bcs.s .near
;
;not pointed at player!
bsr getobrot
add d0,ob_rot(a5)
bra calcvecs
;
.near clr ob_rotspeed(a5) ;towards player!
rts
weaponlogic ;
move.l camrots(pc),a0
;
addq #8,ob_movspeed(a5)
move ob_movspeed(a5),d0
and #127,d0
move 2(a0,d0*8),d0
asr #8,d0
move d0,ob_y(a5)
;
move.l ob_framespeed(a5),d0
add.l d0,ob_frame(a5)
move ob_frame(a5),d0
move.l ob_shape(a5),a0
cmp 2(a0),d0
bcs.s .skip
clr ob_frame(a5)
.skip ;
subq #1,ob_delay(a5)
bgt .rts
bsr rnddelay
;
addlast objects
beq.s .rts
;
movem.l ob_x(a5),d2-d4
movem.l d2-d4,ob_x(a0)
bsr bloodspeed2
move.l d0,ob_xvec(a0)
bsr bloodspeed2
move.l d0,ob_yvec(a0)
bsr bloodspeed2
move.l d0,ob_zvec(a0)
move.l ob_chunks(a5),a2
move.l a2,ob_shape(a0)
move 2(a2),d0
bsr rndn
move d0,ob_frame(a0)
move.l #sparkslogic,ob_logic(a0)
move.l #drawshape_1,ob_render(a0)
clr ob_invisible(a0)
clr ob_colltype(a0)
clr ob_collwith(a0)
bsr rndw
and #15,d0
add #15,d0
move d0,ob_delay(a0)
.rts rts
calcvecs move ob_rot(a5),d0
;
and #255,d0
move.l camrots(pc),a0
lea 0(a0,d0*8),a0
;
move ob_movspeed(a5),d4
move d4,d5
muls 2(a0),d4
add.l d4,d4
neg.l d4
move.l d4,ob_xvec(a5)
muls 6(a0),d5
add.l d5,d5
move.l d5,ob_zvec(a5)
rts
checkvecs movem.l ob_xvec(a5),d6-d7
add.l ob_x(a5),d6
add.l ob_z(a5),d7
bsr checknewslow ;ok to stand here?
beq.s .ok
;
move.l ob_x(a5),d6
move.l ob_z(a5),d7
bsr checknewslow
bne.s .fix
moveq #-1,d1 ;use old pos, and report hit!
rts
;
.fix bsr adjustposq ;fixup!
moveq #-1,d1
;
.ok move.l d6,ob_x(a5)
move.l d7,ob_z(a5)
tst d1
rts
playerdead bsr getcntrl
;
subq #1,ob_delay(a5)
bgt.s .rts
;
cmp #2,gametype
bne.s .notcom
;
;combat game!
;
move #4,finished2
move #1,ob_pixsizeadd(a5)
move.l #rts,ob_logic(a5)
;
bsr getother
move #1,ob_pixsizeadd(a0)
.rts rts
.notcom ;
tst ob_lives(a5)
beq.s .dead
move.l #waitrestart,ob_logic(a5)
rts
;
.dead move.l #rts,ob_logic(a5)
;
tst gametype
bne.s .not1p
;
;OK, one player game done!
;
.allover move #2,finished
rts
;
.not1p move.l player1,a0
cmp.l a5,a0
bne.s .goth
move.l player2,a0
.goth tst ob_hitpoints(a0)
ble.s .allover
rts
waitrestart bsr getcntrl
;
bsr checkfireb
beq.s .rts
;
move ob_weapon(a5),d0
move d0,-(a7)
;
lea p1x(pc),a0
lea player1_+4,a1
cmp.l player1,a5
beq.s .got
lea p2x(pc),a0
lea player2_+4,a1
.got lea ob_info(a5),a2
move #(objinfof-objinfo-4)>>1-1,d0
.loop move (a1)+,(a2)+
dbf d0,.loop
move (a0)+,ob_x(a5)
move (a0)+,ob_z(a5)
move (a0)+,ob_rot(a5)
;
move (a7)+,d0
move d0,ob_weapon(a5)
;
move.l ob_shape(a5),a0
move.l 4(a0),ob_chunks(a5)
move.l (a0),a0
move.l a0,ob_shape(a5)
;
bsr resetplayer
move #-1,ob_update(a5)
st ob_lastbut(a5)
;
.rts rts
playerdeath bsr getcntrl
;
addq #4,ob_rot(a5)
addq #4,ob_eyey(a5)
cmp #-32,ob_eyey(a5)
blt .rts
;
move #-32,ob_eyey(a5)
move.l #playerdead,ob_logic(a5)
move #63,ob_delay(a5)
;
cmp #2,gametype
bne.s .notcom
;
;death in combat game!
;
move.l player1,a0
cmp.l a5,a0
bne.s .got
move.l player2,a0
.got tst ob_hitpoints(a0)
ble.s .draw ;it's a draw!
;
.win move.l a5,-(a7)
;
move.l a0,a5
clr ob_collwith(a5)
clr ob_colltype(a5)
bsr message
dc.b 'winner!',0
even
;
move.l (a7)+,a5
subq #1,ob_lives(a5)
move #-1,ob_update(a5) ;refresh 'lives'
bsr message
dc.b 'loser!',0
even
;
rts
.draw ;
rts
.notcom ;
;2 player? do damage to both players!
;
tst gametype
beq.s .nlink
bsr getother
move #-1,ob_update(a0)
subq #1,ob_lives(a0)
bpl.s .nlink
clr ob_lives(a0)
;
.nlink move #-1,ob_update(a5)
subq #1,ob_lives(a5)
bgt.s .rts
clr ob_lives(a5)
bsr message
dc.b 'game over',0
even
;
.rts rts
getother ;get other player from a5!
;
move.l player1(pc),a0
cmp.l a0,a5
bne.s .rts
move.l player2(pc),a0
.rts rts
redpal move.l #palettesr,ob_palette(a5)
move #2,ob_paltimer(a5)
rts
playerhit tst ob_damage(a0)
beq.s .rts
st ob_update(a5)
bsr redpal
.rts rts
playerdie bsr redpal
clr ob_hitpoints(a5)
st ob_update(a5)
move.l #playerdeath,ob_logic(a5)
clr ob_colltype(a5)
clr ob_collwith(a5)
rts
inchealth ;inc health of a5
;
addq #5,ob_hitpoints(a5)
cmp #25,ob_hitpoints(a5)
ble.s .skip
move #25,ob_hitpoints(a5)
.skip st ob_update(a5)
bsr message
dc.b 'health bonus!',0
even
rts
healthgot bsr playtsfx
move.l a5,-(a7)
move.l a0,a5
bsr inchealth
move.l (a7)+,a5
bra killobject
playtsfx move.l a0,-(a7)
move.l tokensfx(pc),a0
moveq #64,d0
moveq #0,d1
bsr playsfx
move.l (a7)+,a0
rts
weapongot bsr playtsfx
;
move.l a5,-(a7)
move ob_weapon(a5),d0 ;weapon #!
move.l a0,a5
bsr weapond0
move.l (a7)+,a5
bra killobject
weapond0 cmp ob_weapon(a5),d0
bne .new
;
subq.b #1,ob_reload(a5)
beq.s .skip
cmp.b #1,ob_reload(a5)
bne.s .notfull
bsr message
dc.b 'weapon boosted to full!',0
even
bra.s .kill
;
.notfull bsr message
dc.b 'weapon boost!',0
even
;
.kill st ob_update(a5)
rts
;
.skip addq.b #1,ob_reload(a5)
add #250,ob_mega(a5)
cmp #ok,ob_mega(a5)
bcs.s .mwb
;
bsr message
dc.b 'ultra mega overkill!!!',0
even
rts
;
.mwb bsr message
dc.b 'mega weapon boost!',0
even
rts
;
.new move d0,ob_weapon(a5)
move.b #ireload,ob_reload(a5)
st ob_update(a5)
bsr message
dc.b 'new weapon!',0
even
bra.s .kill
invisigot move.l a5,-(a7)
move.l a0,a5
;
add #1500,ob_invisible(a5)
bsr message
dc.b 'invisibility!',0
even
;
move.l (a7)+,a5
bra killobject
invincgot tst ob_hyper(a0)
bne.s .rts
move.l a5,-(a7)
move.l a0,a5
;
move #-$200,ob_hyper(a5)
bsr message
dc.b 'hyper!',0
even
;
move.l (a7)+,a5
bra killobject
;
.rts rts
bouncygot cmp #3,ob_bouncecnt(a0)
bcc.s .rts
addq #1,ob_bouncecnt(a0)
move.l a5,-(a7)
move.l a0,a5
bsr message
dc.b 'bouncy bullets!',0
even
move.l (a7)+,a5
bra killobject
.rts rts
thermogot add #1500,ob_thermo(a0)
move.l a5,-(a7)
move.l a0,a5
bsr message
dc.b 'got the thermo glasses!',0
even
move.l (a7)+,a5
bra killobject
maxsize equ $280
playertimers tst ob_mega(a5)
beq.s .nomega
subq #1,ob_mega(a5)
bne.s .nomega
bsr message
dc.b 'mega wepaon out...',0
even
;
.nomega tst ob_thermo(a5)
beq.s .noth
subq #1,ob_thermo(a5)
bne.s .noth
bsr message
dc.b 'thermo glasses out...',0
even
;
.noth tst ob_messtimer(a5)
ble.s .notm
subq #2,ob_messtimer(a5)
.notm ;
tst ob_invisible(a5)
beq.s .noti
subq #1,ob_invisible(a5)
bne.s .noti
bsr message
dc.b 'invisibility out...',0
even
.noti ;
tst ob_paltimer(a5)
beq.s .notp
subq #1,ob_paltimer(a5)
bne.s .notp
move.l #palettes,ob_palette(a5)
.notp ;
move ob_pixsizeadd(a5),d0
beq.s .notpix
add d0,ob_pixsize(a5)
bne.s .pixnz
;
clr ob_pixsizeadd(a5)
bra.s .notpix
;
.pixnz cmp #24,ob_pixsize(a5)
bne.s .notpix
;
move finished2(pc),finished
bne.s .notpix
;
move ob_telex(a5),ob_x(a5)
move ob_telez(a5),ob_z(a5)
move ob_telerot(a5),ob_rot(a5)
neg ob_pixsizeadd(a5)
.notpix ;
move ob_hyper(a5),d0
beq.s .nothyper
bpl.s .hplus
;
;hyper is minus! growing...
;
subq #4,d0
move d0,d1
neg d1
cmp #maxsize,d1
bne.s .hdone
move #750<<2+maxsize,d0
bra.s .hdone
;
.hplus subq #4,d0
cmp #maxsize,d0
bhi.s .hdone2
bne.s .noteq
bsr message
dc.b 'hyper out...',0
even
move #maxsize,d0
.noteq move d0,d1
cmp #$200,d0
bne.s .hdone
moveq #0,d0
;
.hdone move d1,ob_scale(a5)
;
move d1,d2
mulu #((pl_eyey<<16)/$200),d2
swap d2
neg d2
move d2,ob_eyey(a5)
;
move d1,d2
mulu #((pl_firey<<16)/$200),d2
swap d2
neg d2
move d2,ob_firey(a5)
;
move d1,d2
mulu #((pl_gutsy<<16)/$200),d2
swap d2
neg d2
move d2,ob_gutsy(a5)
;
.hdone2 move d0,ob_hyper(a5)
.nothyper ;
rts
footstep move.l d0,-(a7)
move.l footstepsfx(pc),a0
moveq #16,d0
moveq #0,d1
bsr playsfx
move.l (a7)+,d0
rts
pbuff ds.b 128 ;player controls to use!
pput dc 0 ;put new cntrl here
pget dc 0 ;read this for actual
getcntrl move ob_cntrl(a5),d0
lea joyx0(pc),a0
move.l 0(a0,d0*8),joyx
move.l 4(a0,d0*8),joyb
rts
maxrotsp equ $40000
rotacc equ $20000
rotrevacc equ $40000
rotsetacc equ $20000
rotplayer ;return rot in d0, leave a0
;
move joys(pc),d0 ;strafing?
bne.s .norot
move joyx(pc),d0
beq.s .norot
;
move.l #rotacc,d1 ;rotacc
move ob_rotspeed(a5),d2
beq.s .useacc
eor d2,d0
bpl.s .useacc
move.l #rotrevacc,d1 ;fast rev!
.useacc move joyx(pc),d0
bpl.s .plus
neg.l d1
.plus add.l d1,ob_rotspeed(a5)
cmp.l #maxrotsp,ob_rotspeed(a5)
bgt.s .fixaccpl
cmp.l #-maxrotsp,ob_rotspeed(a5)
bge.s .addrot
move.l #-maxrotsp,ob_rotspeed(a5)
bra.s .addrot
.fixaccpl move.l #maxrotsp,ob_rotspeed(a5)
bra.s .addrot
;
.norot tst.l ob_rotspeed(a5)
beq.s .skip
bpl.s .orpl
add.l #rotsetacc,ob_rotspeed(a5)
ble.s .addrot
.clrrot clr.l ob_rotspeed(a5)
bra.s .skip
.orpl sub.l #rotsetacc,ob_rotspeed(a5)
bmi.s .clrrot
;
.addrot move.l ob_rotspeed(a5),d0
add.l d0,ob_rot(a5)
;
.skip rts
moveplayer ;work out movement vector into d0/d1...check still/moving!
;
move joyy(pc),d0
bne .move
move joys(pc),d0
beq.s .still
move joyx(pc),d0
bne.s .strafe
;
.still move ob_bounce(a5),d1
bne.s .nob
rts
.nob add #30,ob_bounce(a5)
move ob_bounce(a5),d1
and #127,d1
cmp #30,d1
bcc .fskip
clr ob_bounce(a5)
clr ob_frame(a5)<