Sonic Games prioirty managers, my custom one

Messages
27
if you are looking for a way to import s3k manager but your dis is too bad and doesnt really let you shift the varables around you can just modfy DisplaySprite routine by making a table that takes the priority id and then turns d0 into a word then you just add whatever is in d0 into a1 that being the sprite input table example :

Code:
DisplaySprite:
        lea     (Sprite_Table_Input).w,a1
        moveq   #0,d0
    move.b  priority(a0),d0
        add.w  d0,d0
        move.w  PriorityId(pc,d0.w),d0     ; get values
        adda.w  d0,a1
        cmpi.w  #$7E,(a1)
        bcc.s   return_16510
        addq.w  #2,(a1)
        adda.w  (a1),a1
        move.w  a0,(a1)

return_16510:
        rts
; End of function DisplaySprite
PriorityId:    dc.w  0
               dc.w  $80
               dc.w  $100
               dc.w  $180
               dc.w  $200
               dc.w  $280
               dc.w  $300
               dc.w  $380
that should work for the rest of DisplaySprite routines im not gonna show you cuz this isnt a copy paste guide lmao =P if by chance you want the og s3k Display routine that has a feature to display subsprites without using DisplaySprite3 from s2 there you go
Code:
Draw_Sprite:
        lea    (Sprite_table_input).w,a1
       moveq   #0,d0
        move.b  priority(a1),d0
        add.w  d0,d0
        move.w  PriorityId(pc,d0.w),d0     ; get values
        adda.w    d0,a1

loc_1ABCE:
        cmpi.w    #$7E,(a1)
        bhs.s    loc_1ABDC
        addq.w    #2,(a1)
        adda.w    (a1),a1
        move.w    a0,(a1)

locret_1ABDA:
        rts
; ---------------------------------------------------------------------------

loc_1ABDC:
        cmpa.w    #Sprite_table_input+($80*7),a1
        beq.s    locret_1ABDA
        adda.w    #$80,a1
        bra.s    loc_1ABCE
; End of function Draw_Sprite
 
Last edited:
To optimize this further, for every instance where a value is stored in priority(a0), you could multiply the constant being stored by 2. That way you can remove the line
Code:
add.w  d0,d0
from DisplaySprite.
ACTUALLY you can go even further with optimization and even scrap an entire sst by doing this
Code:
DisplaySpriteCustomized:
        lea    (Sprite_table_input).w,a1
        adda.w    d0,a1

loc_1ABCE:
        cmpi.w    #$7E,(a1)
        bhs.s    loc_1ABDC
        addq.w    #2,(a1)
        adda.w    (a1),a1
        move.w    a0,(a1)

locret_1ABDA:
        rts
; ---------------------------------------------------------------------------

loc_1ABDC:
        cmpa.w    #Sprite_table_input+($80*7),a1
        beq.s    locret_1ABDA
        adda.w    #$80,a1
        bra.s    loc_1ABCE

; End of function DisplaySprite
that will let you scarp the priority sst and would save cycles bc theres no table but to do that you have to update every object to do this
Code:
move.w  #$180,d0 ; priority bit
jsr       DisplaySpriteCustomized
i dont think people would want to update every object to multyply by 2 if i were people who want to do that i would do what i just said
 
i came up with a pretty good idea to optimize sonic 3's prioirty manager by turning the priority sst into an address for the sprite table layer whatever its called this is written in AS it should be alright enough to work with 68k as well
Code:
MacroSetDisplayOb        macro id
    lea    (Sprite_Table_Input).w,a1
    lea    id(a1),a1
    move.w  a1,priority(a0)
    endm
MacroSetDisplayObChild        macro id
    lea    (Sprite_Table_Input).w,a2
    lea    id(a2),a2
    move.w  a2,priority(a1)
    endm
these are the macros the first one is for setting the prioirty in an object load the second one is setting objects prioirty in an Create_NewSprite or in an child object
Code:
DisplaySprite:
Draw_Sprite:

                movea.w   priority(a0),a1

GetAddrToDisplayOb:
        cmpi.b    #$7E,(a1)
        bhs.s    DrawSubsprite
        addq.w    #2,(a1)
        adda.w    (a1),a1
        move.w    a0,(a1)
return_16510:
locret_1ABDA:
        rts
; ---------------------------------------------------------------------------

DrawSubsprite:
        cmpa.w    #Sprite_table_input+($80*7),a1
        beq.s    locret_1ABDA
        lea    $80(a1),a1
        bra.s    GetAddrToDisplayOb
this is the routine from s3k you can see the format is a bit diffrent i also changed some adding to be a lea bc thats faster and does the same thing and that cmpi.w to cmpi.b because you dont need more than a byte to check if sprites has reached the next $80 layer and cmpi with a byte is faster than a word unlike testing witch is the same speed no matter the size heres examples on how to use those macros
Code:
Obj3B:
        move.l     #Dyn_Rock_load,(a0)
    move.l    #Obj3B_MapUnc_15D2E,mappings(a0)
    move.w    #make_art_tile(ArtTile_ArtNem_GHZ_Purple_Rock,3,0),art_tile(a0)
OgRenderingSettings:
    ;bsr.w    Adjust2PArtPointer
        move.b    #4,render_flags(a0)
    move.b    #$13,width_pixels(a0)
    move.b    #$13,height_pixels(a0)
    MacroSetDisplayOb $200
    ;move.w    #$200,priority(a0)


; loc_15D02:
Obj3B_Main:


            move.w    #$1B,d1
        move.w    #$10,d2
        move.w    #$10,d3
        move.w    x_pos(a0),d4
        bsr.w    SolidObject
                jmp    (Sprite_CheckDelete).l
this is incase you are using a creat new sprite routine
Code:
LoadSubSpriteObj:
       jsr Create_New_Sprite3 ; Find a free object slot
       bne.s +
       move.w a1,parent3(a0) ; Set as child object
       MacroSetDisplayObChild $0
       move.l #Draw_Sprite,(a1) ; Load test object
       move.b #%01000100,render_flags(a1) ; Set to render sub sprites
       move.w art_tile(a0),art_tile(a1) ; Base tile ID
       move.l mappings(a0),mappings(a1) ; Mappings
       move.b #$30,width_pixels(a1) ; Set main sprite width
       move.b #$30,height_pixels(a1) ; Set main sprite height
       move.w #3,mainspr_childsprites(a1) ; Set number of child sprites
       move.w x_pos(a0),x_pos(a1) ; Set position
       move.w y_pos(a0),y_pos(a1)
+
       rts
you can also improve those macros to not use much ROM space
Code:
MacroSetDisplayOb        macro id
 
    move.w  #Sprite_Table_Input+id,priority(a0)
    endm
MacroSetDisplayObChild        macro id
 
    move.w  #Sprite_Table_Input+id,priority(a1)
    endm
im gonna call this the EGGMan's Conquest priority manager[/CODE]
 
Back
Top