Advertisement
Green_Snake

S3K objects manager fully commented

Dec 2nd, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LoadObjects:
  2.         moveq   #0,d0
  3.         move.b  ObjManager_Routine.w,d0     ; get manager routine
  4.         jmp .indx(pc,d0.w)          ; jump to appropriate code
  5.  
  6. ; ---------------------------------------------------------------------------
  7. .indx       bra.w   .init               ; initialization code
  8.         bra.w   LoadObjects_Main
  9.         bra.w   LoadObjects_Main
  10.         rts
  11. ; ---------------------------------------------------------------------------
  12.  
  13. .init       move.l  #Sprite_ListingK,d0     ; get S&K sprite listings
  14.         move.b  Current_Zone.w,d1       ; get zone ID
  15.         cmpi.b  #$16,d1
  16.         bhs.s   .sk             ; branch if last 2 zones
  17.         cmpi.b  #$E,d1
  18.         bhs.s   .s3             ; branch if Azure Lake or higher
  19.         cmpi.b  #7,d1
  20.         bhs.s   .sk             ; branch if MHZ or higher
  21.  
  22. .s3     move.l  #Sprite_Listing3,d0     ; get S3 sprite listings
  23. .sk     move.l  d0,Object_index_addr.w      ; store the address
  24.         addq.b  #4,ObjManager_Routine.w     ; use next routine
  25.  
  26.         tst.b   Transport_Flag.w
  27.         bne.s   .noclear
  28.     clearRAM Object_respawn_table, Camera_X_Pos_Diff-Object_respawn_table
  29.  
  30. .noclear    move.w  Current_Zone.w,d0       ; get zone ID
  31.         ror.b   #1,d0               ; make act ID bit be 7th bit
  32.         lsr.w   #5,d0               ; shift right 5 times (each act is in increments of 4)
  33.         lea ObjectLayoutPtrs,a0     ; get object layout position array
  34.         movea.l (a0,d0.w),a0            ; get the appropriate one to a0
  35.  
  36.         cmpi.w  #$1701,Current_Zone.w
  37.         beq.s   .0              ; branch if master emerald shrine
  38.         cmpi.b  #$16,Current_Zone.w
  39.         bhs.s   .normal             ; branch if zone $16xx or $1700
  40.         cmpi.b  #$14,Current_Zone.w
  41.         beq.s   .normal             ; branch if Glowing Spheres
  42.         cmpi.b  #$13,Current_Zone.w
  43.         bhs.s   .0              ; branch if GumBall or higher
  44.         tst.w   Multiplayer_Flag.w
  45.         beq.s   .normal
  46.  
  47. .0      addq.b  #8,ObjManager_Routine.w     ; this makes the object manager just rts.
  48.         jsr CreateObject(pc)        ; attempt to create a new object
  49.         bne.s   .camerashit         ; if failed, branch
  50.  
  51.         lea Current_Respawn_Index.w,a3  ; get respawn index
  52.         movea.l Object_index_addr.w,a4      ; get object table
  53.         move.w  #$800,d6            ; get max x
  54.         cmpi.w  #$1701,Current_Zone.w
  55.         bne.s   .notshrine          ; branch if not master emerald shrine
  56.         move.w  #$1780,d6           ; get max x
  57.  
  58. .notshrine  cmp.w   (a0),d6             ; compare object position against d6
  59.         bls.s   .camerashit         ; if higher than d6, dont load
  60.         jsr CreateObj_Anyway(pc)        ; load the next object
  61.         beq.s   .notshrine          ; if more can be loaded, keep loading
  62.  
  63. .camerashit clr.w   Camera_X_Rough.w        ; clear camera rough X
  64.         cmpi.w  #$1701,Current_Zone.w
  65.         bne.s   .rts                ; branch if not master emerald shrine
  66.  
  67.         move.w  Camera_X.w,d1           ; get camera x-pos
  68.         subi.w  #128,d1             ; sub 128 from it
  69.         andi.w  #$FF80,d1           ; keep in proper range
  70.         move.w  d1,Camera_X_Rough.w     ; and store value
  71. .rts        rts
  72. ; ---------------------------------------------------------------------------
  73.  
  74. .normal     move.l  a0,ObjMng_AdrRight.w
  75.         move.l  a0,ObjMng_AdrLeft.w     ; store address of the object layout
  76.  
  77.         lea Object_respawn_table.w,a3   ; get object respawn table
  78.         cmpi.b  #$14,Current_Zone.w
  79.         bne.s   .notglow            ; branch if not Glowing spheres
  80.  
  81.         lea Level_layout_main+$3F8.w,a3 ; I just assume this is used as the respawn table in glowing spheres
  82.         moveq   #($200/4)-1,d6
  83. .clr        clr.l   (a3)+               ; clear next long
  84.         dbf d6,.clr             ; loop until done
  85.         lea Level_layout_main+$3F8.w,a3
  86.  
  87. ; the following code resets the variables and offsets of the manager so that,
  88. ; the objects manager will load the objects directly onscreen (and a little offscreen)
  89. ; and corrects all the variables with relevant values. Also makes sure correct amount of
  90. ;  respawn indexes are skipped to keep enough space for all objects left from the player
  91. .notglow    move.w  Camera_X.w,d6           ; get camera X-pos
  92.         subi.w  #128,d6             ; sub 128 from it
  93.         bhs.s   .noreset            ; if higher than 0, branch
  94.         moveq   #0,d6               ; reset to 0
  95.  
  96. .noreset    andi.w  #$FF80,d6           ; keep in chunks of 128 pixels
  97.         movea.l ObjMng_AdrRight.w,a0        ; get the address of the objloader
  98.  
  99. ; this seems to load the objects from start of the level until the position behind you
  100. ; these objects will no be loaded to RAM, but rather, just skipped over, counting the address of the last loaded object and its respawn index
  101. .chkobjsleft    cmp.w   (a0),d6             ; compare object position against d6
  102.         bls.s   .chkdone            ; if higher than d6, branch
  103.         addq.w  #6,a0               ; next object in list
  104.         addq.w  #1,a3               ; next respawn table index
  105.         bra.s   .chkobjsleft            ; check next
  106.  
  107. .chkdone    move.l  a0,ObjMng_AdrRight.w        ; store address to load from
  108.         move.w  a3,ObjMng_RespawnRight.w    ; and store respawn table
  109.  
  110.         lea Object_respawn_table.w,a3   ; get respawn index to a3
  111.         cmpi.b  #$14,Current_Zone.w
  112.         bne.s   .notglow2           ; branch not if Glowing Spheres
  113.         lea Level_layout_main+$3F8.w,a3 ; get the table used by glowing spheres
  114.  
  115. .notglow2   movea.l ObjMng_AdrLeft.w,a0
  116.         subi.w  #128,d6             ; sub 128 from Camera X again. This is grossly offscreen,
  117.                             ; but is done to account for the objects loader later on
  118.         blo.s   .chkdone2           ; if this position would be offscreen, it is assumed there are no objects to load
  119.  
  120. .chkobjsright   cmp.w   (a0),d6             ; compare object position against d6
  121.         bls.s   .chkdone2           ; if higher than d6, branch
  122.         addq.w  #6,a0               ; next object in list
  123.         addq.w  #1,a3               ; next respawn table index
  124.         bra.s   .chkobjsright           ; check next
  125.  
  126. .chkdone2   move.l  a0,ObjMng_AdrLeft.w     ; store address to load from
  127.         move.w  a3,ObjMng_RespawnLeft.w     ; and store respawn table
  128.  
  129.         move.w  #-1,ObjMgr_Camera_X.w       ; reset camera X
  130.         move.w  Camera_Y.w,d0           ; get camera y-position
  131.         andi.w  #$FF80,d0           ; keep in range
  132.         move.w  d0,ObjMgr_Camera_Y.w        ; store it so no unnecesary Y-checks shouldnt be done
  133. ; ---------------------------------------------------------------------------
  134.  
  135. LoadObjects_Main:
  136.         move.w  Camera_Y.w,d1           ; get camera Y-pos
  137.         subi.w  #128,d1             ; sub 128 pixels from it
  138.         andi.w  #$FF80,d1           ; keep in range
  139.         move.w  d1,Camera_Y_Rough.w     ; save this
  140.  
  141.         move.w  Camera_X.w,d1           ; get camera X-pos
  142.         subi.w  #128,d1             ; sub 128 pixels from it
  143.         andi.w  #$FF80,d1           ; keep in range
  144.         move.w  d1,Camera_X_Rough.w     ; save this
  145.  
  146.         movea.l Object_index_addr.w,a4
  147.         tst.w   Camera_min_Y.w
  148.         bpl.s   .noywrap            ; branch if Y-wrapping isnt active
  149.         lea CreateObj_ChkYWrap(pc),a6   ; use check code, that account for Y-wrapping
  150.  
  151.         move.w  Camera_Y.w,d3           ; get camera Y-positon
  152.         andi.w  #$FF80,d3           ; keep in range
  153.         move.w  d3,d4               ; copy result
  154.         addi.w  #512,d4             ; set lower y-boundary
  155.         subi.w  #128,d3             ; set upper y-boundary
  156.         bpl.s   .setnowrap          ; if d3 is positive, branch
  157.         and.w   Screen_Y_wrap_value.w,d3    ; wrap d3
  158.         bra.s   .common
  159.  
  160. .nowrap     move.w  Screen_Y_wrap_value.w,d0    ; get vertical wrap value
  161.         addq.w  #1,d0               ; add 1 to it
  162.         cmp.w   d0,d4               ; compare with lower y-boundary
  163.         bls.s   .setnowrap          ; if no below the level either, branch
  164.         and.w   Screen_Y_wrap_value.w,d4    ; wrap this value
  165.         bra.s   .common
  166. ; ---------------------------------------------------------------------------
  167.  
  168. .noywrap    move.w  Camera_Y.w,d3           ; get camera Y-positon
  169.         andi.w  #$FF80,d3           ; keep in range
  170.         move.w  d3,d4               ; copy result
  171.         addi.w  #512,d4             ; set lower y-boundary
  172.         subi.w  #128,d3             ; set upper y-boundary
  173.         bpl.s   .noywrap            ; if still positive, branch
  174.         moveq   #0,d3               ; force upper level boundary
  175. .setnowrap  lea CreateObj_ChkNoWrap(pc),a6  ; use check code, that doesnt account for Y-wrapping
  176.  
  177. .common     move.w  #$FFF,d5
  178.         move.w  Camera_X.w,d6           ; get camera x-pos
  179.         andi.w  #$FF80,d6           ; keep in ramge
  180.         cmp.w   ObjMgr_Camera_X.w,d6        ; check against last range
  181.         beq.w   LoadObjects_Common      ; branch if same
  182.         bge.s   LoadObjects_Forward     ; if new range is greater than last, branch
  183. ; ---------------------------------------------------------------------------
  184.  
  185.         ; else the range is less than.
  186.         move.w  d6,ObjMgr_Camera_X.w        ; store the new range
  187.         movea.l ObjMng_AdrLeft.w,a0     ; get the current objects left
  188.         movea.w ObjMng_RespawnLeft.w,a3     ; and appropriate respawn list
  189.         subi.w  #128,d6             ; sub 128 from the x-pos
  190.         blo.s   .endload            ; if outside level boundary, branch
  191.         jsr CreateObject(pc)        ; attempt to load new object
  192.         bne.s   .endload            ; branch if failed
  193.  
  194. .loadloop   cmp.w   -6(a0),d6           ; check if the last object is in range
  195.         bge.s   .endload            ; if not, branch
  196.         subq.w  #6,a0               ; get the actual object address
  197.         subq.w  #1,a3               ; get the actual respawn table address
  198.  
  199.         jsr (a6)                ; attempt to spawn the object
  200.         bne.s   .loadfail           ; branch if we could not load object afterall
  201.         subq.w  #6,a0
  202.         bra.s   .loadloop           ; attempt to load new object
  203.  
  204. .loadfail   addq.w  #6,a0               ;
  205.         addq.w  #1,a3               ; undo loading an object
  206.  
  207. .endload    move.l  a0,ObjMng_AdrLeft.w     ; store the current object
  208.         move.w  a3,ObjMng_RespawnLeft.w     ; and respawn index
  209.  
  210.         movea.l ObjMng_AdrRight.w,a0        ; get the current objects right
  211.         movea.w ObjMng_RespawnRight.w,a3    ; and appropriate respawn list
  212.         addi.w  #768,d6             ; look two chunks forwards
  213.  
  214. ; this counts all the objects that have now moved offscreen
  215. .chkloop    cmp.w   -6(a0),d6           ; check if the last object is out of range
  216.         bgt.s   .chkdone            ; if is, branch
  217.         subq.w  #6,a0               ; get object before this
  218.         subq.w  #1,a3               ; and its respawn index
  219.         bra.s   .chkloop            ; check next object
  220.  
  221. .chkdone    move.l  a0,ObjMng_AdrRight.w        ; store the current object
  222.         move.w  a3,ObjMng_RespawnRight.w    ; and respawn index
  223.         bra.s   LoadObjects_Common      ; and branch away!
  224. ; ---------------------------------------------------------------------------
  225.  
  226. LoadObjects_Forward:
  227.         move.w  d6,ObjMgr_Camera_X.w        ; store the new range
  228.         movea.l ObjMng_AdrRight.w,a0        ; get the current objects right
  229.         movea.w ObjMng_RespawnRight.w,a3    ; and appropriate respawn list
  230.         addi.w  #640,d6             ; look two chunks forwards
  231.         jsr CreateObject(pc)        ; attempt to load new object
  232.         bne.s   .endload            ; branch if failed
  233.  
  234. .loadloop   cmp.w   (a0),d6             ; check if the last object is in range
  235.         bls.s   .endload            ; if not, branch
  236.         jsr (a6)                ; attempt to spawn the object
  237.         addq.w  #1,a3               ; get new respawn index (remember this does not modify CCR)
  238.         beq.s   .loadloop           ; branch if we could load objects
  239.  
  240. .endload    move.l  a0,ObjMng_AdrRight.w        ; store the current object
  241.         move.w  a3,ObjMng_RespawnRight.w    ; and respawn index
  242.  
  243.         movea.l ObjMng_AdrLeft.w,a0     ; get the current objects left
  244.         movea.w ObjMng_RespawnLeft.w,a3     ; and appropriate respawn list
  245.         subi.w  #768,d6             ; check 1 chunk backwards
  246.         blo.s   .chkdone            ; if outside of level, branch
  247.  
  248. ; this counts all the objects that have now moved offscreen
  249. .chkloop    cmp.w   (a0),d6             ; check if the last object is out of range
  250.         bls.s   .chkdone            ; if is, branch
  251.         addq.w  #6,a0               ; get object after this
  252.         addq.w  #1,a3               ; and its respawn index
  253.         bra.s   .chkloop            ; check next object
  254.  
  255. .chkdone    move.l  a0,ObjMng_AdrLeft.w     ; store the current object
  256.         move.w  a3,ObjMng_RespawnLeft.w     ; and respawn index
  257. ; ---------------------------------------------------------------------------
  258.  
  259. LoadObjects_Common:
  260.         move.w  Camera_Y.w,d6           ; get camera x-pos
  261.         andi.w  #$FF80,d6           ; keep in ramge
  262.         move.w  d6,d3               ; copy the value
  263.         cmp.w   ObjMgr_Camera_Y.w,d6        ; check against last range
  264.         beq.w   .loadend            ; branch if same
  265.         bge.s   .movingdown         ; if new range is greater than last, branch
  266. ; ---------------------------------------------------------------------------
  267.  
  268.         ; else the range is less than.
  269.         tst.w   Camera_min_Y.w
  270.         bpl.s   .nowrap             ; branch if level does not Y-wrap
  271.         tst.w   d6
  272.         bne.s   .mvupwrap
  273.         cmpi.w  #128,ObjMgr_Camera_Y.w
  274.         bne.s   .mvdownwrap
  275.  
  276. .mvupwrap   subi.w  #128,d3             ; look one chunk up
  277.         bpl.s   .ycheck             ; branch if still positive
  278.         and.w   Screen_Y_wrap_value.w,d3    ; wrap y-pos
  279.         bra.s   .ycheck
  280.  
  281. .nowrap     subi.w  #128,d3             ; look one chunk up
  282.         bmi.w   .loadend
  283.         bra.s   .ycheck
  284. ; ---------------------------------------------------------------------------
  285.  
  286. .movingdown tst.w   Camera_min_Y.w
  287.         bpl.s   .nowrap2            ; branch if level does not Y-wrap
  288.         tst.w   ObjMgr_Camera_Y.w
  289.         bne.s   .mvdownwrap
  290.         cmpi.w  #128,d6
  291.         bne.s   .mvupwrap
  292.  
  293. .mvdownwrap addi.w  #384,d3             ; look one chunk down
  294.         cmp.w   Screen_Y_wrap_value.w,d3
  295.         blo.s   .ycheck             ; if we should now wrap yet
  296.         and.w   Screen_Y_wrap_value.w,d3    ; wrap the y-position
  297.         bra.s   .ycheck
  298.  
  299. .nowrap2    addi.w  #384,d3             ; look one chunk down
  300.         cmp.w   Screen_Y_wrap_value.w,d3
  301.         bhi.s   .loadend
  302. ; ---------------------------------------------------------------------------
  303.  
  304. .ycheck     jsr CreateObject(pc)        ; attempt to create an object
  305.         bne.s   .loadend            ; if failed, branch
  306.         move.w  d3,d4               ; copy y-pos
  307.         addi.w  #128,d4             ; look one chunk down
  308.         move.w  #$FFF,d5
  309.  
  310.         movea.l ObjMng_AdrLeft.w,a0     ; get the current objects left
  311.         movea.w ObjMng_RespawnLeft.w,a3     ; get respawn list left
  312.         move.l  ObjMng_AdrRight.w,d7        ; get the current objects right
  313.         sub.l   a0,d7               ; sub the left position from right
  314.         beq.s   .loadend            ; branch if no objects
  315.         addq.w  #2,a0               ; align to obj y
  316.  
  317. .loadnext   tst.b   (a3)                ; has object been loaded?
  318.         bmi.s   .loadfail           ; if so, branch
  319.  
  320.         move.w  (a0),d1             ; get objects y-pos
  321.         and.w   d5,d1               ; keep it in range of 0-$FFF
  322.         cmp.w   d3,d1
  323.         blo.s   .loadfail           ; branch if out of range in top
  324.         cmp.w   d4,d1
  325.         bhi.s   .loadfail           ; branch if out of range in bottom
  326.  
  327.         bset    #7,(a3)             ; mark as loaded
  328.         move.w  -2(a0),xpos(a1)         ; get x-position
  329.         move.w  (a0),d1             ; get y-position
  330.         move.w  d1,d2               ; copy it
  331.         and.w   d5,d1               ; keep in range
  332.         move.w  d1,ypos(a1)         ; store it as the new y-pos
  333.  
  334.         rol.w   #3,d2               ; get X & Y flip bits to start of d2
  335.         andi.w  #3,d2               ; keep only X & Y flip bits
  336.         move.b  d2,render(a1)           ; store render flags
  337.         move.b  d2,status(a1)           ; store status
  338.  
  339.         move.b  2(a0),d2            ; get ID
  340.         add.w   d2,d2
  341.         add.w   d2,d2               ; quadruple it
  342.         move.l  (a4,d2.w),(a1)          ; get the object ID from listings table
  343.  
  344.         move.b  3(a0),subtype(a1)       ; get object subtype
  345.         move.w  a3,respawn(a1)          ; get the respawn index
  346.         jsr CreateObjFromLoader(pc)     ; attempt to load more objects
  347.         bne.s   .loadend            ; if none could be loaded, branch
  348.  
  349. .loadfail   addq.w  #6,a0               ; next objects address
  350.         addq.w  #1,a3               ; next respawn index
  351.         subq.w  #6,d7               ; sub the size of the object
  352.         bne.s   .loadnext           ; if there is object remaining, branch
  353. .loadend    move.w  d6,ObjMgr_Camera_Y.w        ; store camera Y-pos
  354.         rts
  355. ; ---------------------------------------------------------------------------
  356. ; unused/dead code
  357.         bset    #7,(a3)             ; mark as loaded
  358.         beq.s   CreateObj_Anyway        ; if wasn't loaded, load
  359.         addq.w  #2,a0               ; increment to address of the next object
  360.         moveq   #0,d1               ; ensure that upstream code knows to continue loading
  361.         rts
  362. ; ---------------------------------------------------------------------------
  363.  
  364. CreateObj_Anyway:
  365.         move.w  (a0)+,xpos(a1)          ; copy x-position
  366.         move.w  (a0)+,d1            ; get y-position
  367.         move.w  d1,d2               ; copy it
  368.         andi.w  #$FFF,d1            ; filter out unnecessary bits
  369.         move.w  d1,ypos(a1)         ; store the new y-pos
  370.  
  371.         rol.w   #3,d2               ; get X & Y flip bits to start of d2
  372.         andi.w  #3,d2               ; keep only X & Y flip bits
  373.         move.b  d2,render(a1)           ; store render flags
  374.         move.b  d2,status(a1)           ; store status
  375.  
  376.         move.b  (a0)+,d2            ; get object ID
  377.         add.w   d2,d2
  378.         add.w   d2,d2               ; quadruple it
  379.         move.l  (a4,d2.w),(a1)          ; get the object ID from listings table
  380.  
  381.         move.b  (a0)+,subtype(a1)       ; get object subtype
  382.         move.w  a3,respawn(a1)          ; get the respawn index
  383.         bra.w   CreateObjFromLoader     ; attempt to create a new object
  384. ; ---------------------------------------------------------------------------
  385. ; subroutine to try and load new objects from object layout files.
  386. ; has different code for Y-wrapped and non-Y-Wrapped levels.
  387. ;
  388. ; input:
  389. ; d3 = upper boundary
  390. ; d4 = lower boundary
  391. ; d5 = Y-position filter bits
  392. ; a0 = index of object layout file
  393. ; a1 = target object
  394. ; a3 = respawn table address
  395. ; ---------------------------------------------------------------------------
  396.  
  397. CreateObj_ChkYWrap:
  398.         tst.b   (a3)                ; check if the object is already loaded
  399.         bpl.s   .notloaded          ; if not, branch
  400.         addq.w  #6,a0               ; increment to address of the next object
  401.         moveq   #0,d1               ; ensure that upstream code knows to continue loading
  402.         rts
  403.  
  404. .notloaded  move.w  (a0)+,d7            ; get x-position
  405.         move.w  (a0)+,d1            ; get y-position
  406.         move.w  d1,d2               ; copy y-position
  407.         bmi.s   .loadnoy            ; branch if this object ignore y-checks
  408.         and.w   d5,d1               ; keep y-position in range
  409.  
  410.         cmp.w   d3,d1
  411.         bhs.s   .spawn              ; branch if on range from top(?)
  412.         cmp.w   d4,d1
  413.         bls.s   .spawn              ; branch if on range from bottom
  414.  
  415.         addq.w  #2,a0               ; increment to address of the next object
  416.         moveq   #0,d1               ; ensure that upstream code knows to continue loading
  417.         rts
  418. ; ---------------------------------------------------------------------------
  419.  
  420. .loadnoy    and.w   d5,d1               ; keep y-position in range
  421. .spawn      bset    #7,(a3)             ; mark as loaded
  422.         move.w  d7,xpos(a1)         ; store the new x-pos
  423.         move.w  d1,ypos(a1)         ; store the new y-pos
  424.  
  425.         rol.w   #3,d2               ; get X & Y flip bits to start of d2
  426.         andi.w  #3,d2               ; keep only X & Y flip bits
  427.         move.b  d2,render(a1)           ; store render flags
  428.         move.b  d2,status(a1)           ; store status
  429.  
  430.         move.b  (a0)+,d2            ; get object ID
  431.         add.w   d2,d2
  432.         add.w   d2,d2               ; quadruple it
  433.         move.l  (a4,d2.w),(a1)          ; get the object ID from listings table
  434.  
  435.         move.b  (a0)+,subtype(a1)       ; get object subtype
  436.         move.w  a3,respawn(a1)          ; get the respawn index
  437.         bra.w   CreateObjFromLoader     ; attempt to create a new object
  438. ; ---------------------------------------------------------------------------
  439.  
  440. CreateObj_ChkNoWrap:
  441.         tst.b   (a3)                ; check if the object is already loaded
  442.         bpl.s   .notloaded          ; if not, branch
  443.         addq.w  #6,a0               ; increment to address of the next object
  444.         moveq   #0,d1               ; ensure that upstream code knows to continue loading
  445.         rts
  446.  
  447. .notloaded  move.w  (a0)+,d7            ; get x-position
  448.         move.w  (a0)+,d1            ; get y-position
  449.         move.w  d1,d2               ; copy y-position
  450.         bmi.s   .loadnoy            ; branch if this object ignore y-checks
  451.         and.w   d5,d1               ; keep y-position in range
  452.  
  453.         cmp.w   d3,d1
  454.         blo.s   .outofrange         ; branch if out of range from top
  455.         cmp.w   d4,d1
  456.         bls.s   .spawn              ; branch if on range from bottom
  457.  
  458. .outofrange addq.w  #2,a0               ; increment to address of the next object
  459.         moveq   #0,d1               ; ensure that upstream code knows to continue loading
  460.         rts
  461. ; ---------------------------------------------------------------------------
  462.  
  463. .loadnoy    bset    #7,(a3)             ; mark as loaded
  464. .spawn      move.w  d7,xpos(a1)         ; store the new x-pos
  465.         move.w  d1,ypos(a1)         ; store the new y-pos
  466.  
  467.         rol.w   #3,d2               ; get X & Y flip bits to start of d2
  468.         andi.w  #3,d2               ; keep only X & Y flip bits
  469.         move.b  d2,render(a1)           ; store render flags
  470.         move.b  d2,status(a1)           ; store status
  471.  
  472.         move.b  (a0)+,d2            ; get object ID
  473.         add.w   d2,d2
  474.         add.w   d2,d2               ; quadruple it
  475.         move.l  (a4,d2.w),(a1)          ; get the object ID from listings table
  476.  
  477.         move.b  (a0)+,subtype(a1)       ; get object subtype
  478.         move.w  a3,respawn(a1)          ; get the respawn index
  479. ; ---------------------------------------------------------------------------
  480.  
  481. CreateObjFromLoader:
  482.         subq.w  #1,d0       ; not sure what d0 is here, but I can just guess
  483.                     ; it keeps track of how many objects we have checked
  484.         bmi.s   .rts        ; if negative, branch
  485.  
  486. .chk        lea objsize(a1),a1  ; get next object
  487.         tst.l   (a1)        ; test if there is object here
  488.         dbeq    d0,.chk     ; if isn't, and more objects are to be done, keep looping.
  489. .rts        rts
  490. ; ---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement