Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    I'm trying to fix Sonic's balancing problem with the conveyor belts in Scrap Brain 2. It seems like my fix is working, but there one detail that could cause a problem, therefore this question:


    Is there any object that could modify Sonic's speed while Sonic is standing? (I do mean the speed, the one stored in $FFD010)


    I know most objects modify the coordinates directly, and so far I couldn't find any that would modify the speed, but I don't want to overlook something.
     
    Last edited by a moderator: Aug 10, 2012
  2. Kensou

    Kensou Well-Known Member Member

    Joined:
    Aug 19, 2010
    Messages:
    59
    I remember that bug. In what situations that bug exactly happens?
     
  3. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    This one:


    /monthly_08_2012/post-1059-0-76005200-1344615951_thumb.png


    The fix I have requires to avoid the balancing animations if Sonic's speed isn't null, otherwise, before Sonic falls, every balancing animation is used for a few frames each and that's ugly.
     

    Attached Files:

  4. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    No objects alter Sonic's X speed if he is on the ground, the problem here is that Sonic's X and Y speeds are technically uneffective when he is not in the air (or well, that's a bit of an understatement), the angle in which Sonic is on the floor, is taken and used to collect the sine wave X and Y positions, these positions are multiplied by the ground speed (the one held at 14-5 of Sonic's SST space), the X and Y positions that were multiplied, are then saved into the X and Y speeds (the ones held at 10-1 and 12-3), this however, is done in the Sonic object's routines itself, and these speeds are converted and added to his X and Y positions almost directly after, before any other objects, or any other routines during the main loop are able to manipulate those speeds, so altering them anywhere else will have no effect, hence useless trying.


    Additionally, you cannot alter Sonic's ground speed without his animation of walking/running coming into action, it wouldn't look like he's "standing" on the conveyor belt and being moved by it. The advice I can only give that works the way you would like it, is to preserve a memory space for an X speed, and then add that X speed to Sonic's X speed before it is "converted and added" to Sonic's X position, it will require clearing that space when not in use, and obviously making sure nothing else alters it.


    A tough fix, really tough, sorry if this is not the information you were looking for.
     
    Last edited by a moderator: Aug 11, 2012
  5. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    It's a perfect answer, now I know what to fix (although it's probably specific to my hack), thanks. :)


    The bug itself was fixed when I asked the question, I was worrying about possible problems the fix would cause if the speed was modified anywhere else. Actually I'm precisely using that property of the speed value as a kind of flag.


    I'll write the fix here, if anyone wants to try and find possible problems:


    In obj68_main, add 12 to both widths (in decimal).


    Then in Obj68_MoveSonic, replace addi.w #$30,d1 with addi.w #$23,d1, and after add.w d0,8(a1), add




    asl.w #4,d0 ; < you can use less than 4 here, as it will influence sonic's speed if he jumps. For full inertia, use 8


    add.w d0,$10(a1)



    and after Sonic_Balance: , add





    tst.w $10(a0)


    bne.w Sonic_LookUp



    I absolutely don't know how the fix will behave in the original game, or in other hacks.


    In my hack I've had to fix a problem with the camera while charging the peelout or spindash on a conveyor belt, but for now that's it.
     
  6. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    My next plan is to add foreground objects into GHZ; much like those girders in SLZ... I'm designing large totem polls. I already have the art and mapings finished, and a cheap copy of object5C's code (It's just there because I get a few errors without the routines being called.) But now it is time for the coding, yet I already know that this code line for obj10 will be entirly different than the code provided on the girder object (5C). What would be my best option? Heres some concept of how the level would look with it: [​IMG]
     
  7. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I would like to help, but I'm afraid I can't find a question.
     
  8. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    If that wan't enough then could you please help me with my issue, sir Selbi?
     
    Last edited by a moderator: Aug 20, 2012
  9. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Oh I've seen that, and that's not the issue. I was asking what it is you are actually asking for? What sort of option? Sorry if I'm misreading something here, but I can't seem to find your question.
     
  10. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Oh that. I need to construct the code and have it loaded once GHZ is loaded. Could you help out in any way?
     
  11. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Ah, now I get it.


    Well, you really shouldn't use a completely new object and rather go with a level specific version of Obj5C. Generally, all you need to do is to change the tile offset to the new location. As a basic example of how that works:



    move.w #$83CC,2(a0) ; set offest for SLZ
    tst.b ($FFFFFE10).w ; is level GHZ?


    bne.s Obj5C_NotGHZ ; if not, branch


    move.w #$8555,2(a0) ; set offset for GHZ


    Obj5C_NotGHZ:



    You obviously need to change the tile offset to whatever VRAM address you've assigned your new art to.
     
    Last edited by a moderator: Aug 21, 2012
  12. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Alright, I have the new VRAM adress set, now I need to implement the art into GHZ it'sself... bombard me with negative reputation, I can take it. Could you possibly guide me through this bit as well?
     
  13. theocas

    theocas #! Member

    Joined:
    Apr 10, 2010
    Messages:
    375
    It's actually quite special. Sonic 1 loads art when the level loads through the use of the Pattern Load Cue system. Open the file in "_inc/Pattern load cues.asm" Since you want to add something to Green Hill, find the label called "PLC_GHZ" You should see something as below (I might've edited this):





    ; ---------------------------------------------------------------------------


    ; Pattern load cues - Green Hill


    ; ---------------------------------------------------------------------------


    PLC_GHZ: dc.w $A


    dc.l Nem_GHZ_1st ; GHZ main patterns


    dc.w 0


    dc.l Nem_Stalk ; flower stalk


    dc.w $6B00


    dc.l Nem_PplRock ; purple rock


    dc.w $7A00


    dc.l Nem_Crabmeat ; crabmeat enemy


    dc.w $8000


    dc.l Nem_Buzz ; buzz bomber enemy


    dc.w $8880


    dc.l Nem_Chopper ; chopper enemy


    dc.w $8F60


    dc.l Nem_Newtron ; newtron enemy


    dc.w $9360


    dc.l Nem_Motobug ; motobug enemy


    dc.w $9E00


    dc.l Nem_Spikes ; spikes


    dc.w $A360


    dc.l Nem_HSpring ; horizontal spring


    dc.w $A460


    dc.l Nem_VSpring ; vertical spring


    dc.w $A660


    PLC_GHZ2: dc.w 5


    dc.l Nem_Swing ; swinging platform


    dc.w $7000


    dc.l Nem_Bridge ; bridge


    dc.w $71C0


    dc.l Nem_SpikePole ; spiked pole


    dc.w $7300


    dc.l Nem_Ball ; giant ball


    dc.w $7540


    dc.l Nem_GhzWall1 ; breakable wall


    dc.w $A1E0


    dc.l Nem_GhzWall2 ; normal wall


    dc.w $6980



    You'll notice there's two PLC's — one loads before the title card fades out, another while the level is faded in already.


    Anyways, as you may notice, the first word of the PLC is the number of entries in the PLC, minus one. Followed by that is 6 bytes per pattern entry. The first is a longword pointing to the art, and the second is the word offset into VRAM where it will be loaded. Art must be Nemesis compressed. The rest should be obvious =P
     
  14. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    I have that already entered and such into the PLC. The art dosent load. I suppose the VRAM adress is not valid. I'll conitnue working on it. Thanks for the information anyway.
     
  15. rika_chou

    rika_chou Adopt Member

    Joined:
    Aug 11, 2007
    Messages:
    689
    Remember, to get the right VRAM address you have to multiply your tile number by 20.


    So if your object code is using $3CC, like the above code, multiply it by $20 to get $7980 (using a hex calculator).


    An easy way to see the VRAM is to make a savestate when your level is loaded, open the savestate in SonED1, read the 8x8 tiles from the savestate, go to the tile editor, then you can see where everything is loaded. This helps when trying to find some free VRAM space.
     
    Last edited by a moderator: Aug 22, 2012
  16. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    I have object 5C loaded in GHZ but it is not loading the art set specifically for it and the PLC has the code of the object I want loaded. But it loads nothing more than a hunk of garbage. So I know that it isn't loading anything but the object its'self. The code has been changed a bit and the new VRAM pointers are set, but it still dosen't load. It'd be the best option to post the actual object code to be sure if I made a mistake:



    Code:
    
    ; ---------------------------------------------------------------------------
    
    ; Object 5C - metal girders in foreground (SLZ)
    
    ; ---------------------------------------------------------------------------
    
    Obj5C:	 ; XREF: Obj_Index
    
    moveq #0,d0
    
    move.b $24(a0),d0
    
    move.w Obj5C_Index(pc,d0.w),d1
    
    jmp Obj5C_Index(pc,d1.w)
    
    ; ===========================================================================
    
    Obj5C_Index: dc.w Obj5C_Main-Obj5C_Index
    
    dc.w Obj5C_Display-Obj5C_Index
    
    ; ===========================================================================
    
    Obj5C_Main: ; XREF: Obj5C_Index
    
    move.w #$7980,2(a0) ; set offest for SLZ
    
    tst.b ($FFFFFE10).w ; is level GHZ?
    
    bne.s Obj5C_NotGHZ ; if not, branch
    
    move.w #$8555,2(a0) ; set offset for GHZ
    
    Obj5C_NotGHZ:
    
    addq.b #2,$24(a0)
    
    move.l #Map_obj5C,4(a0)
    
    move.w #$83CC,2(a0)
    
    move.b #$10,$19(a0)
    
    Obj5C_Display: ; XREF: Obj5C_Index
    
    move.l ($FFFFF700).w,d1
    
    add.l d1,d1
    
    swap d1
    
    neg.w d1
    
    move.w d1,8(a0)
    
    move.l ($FFFFF704).w,d1
    
    add.l d1,d1
    
    swap d1
    
    andi.w #$3F,d1
    
    neg.w d1
    
    addi.w #$100,d1
    
    move.w d1,$A(a0)
    
    bra.w DisplaySprite
    
    ; ===========================================================================
    
    ; ---------------------------------------------------------------------------
    
    ; Sprite mappings - metal girders in foreground (SLZ)
    
    ; ---------------------------------------------------------------------------
    
    Map_obj5C: include "_mapsobj5C.asm"
    
    Map_obj5Cghz: include "_mapsghztotem.asm"
    
    even
    
    Nem_OBJ5c: incbin "artnemghztotem.bin" ; large totem pole in GHZ
    
    even
    
    ...
    
    
    Is the code just incomplete or is it that nothing is leading to the projection of the art its'self?

    [/CODE]
     
    Last edited by a moderator: Aug 23, 2012
  17. Malevolence

    Malevolence Well-Known Member Member

    Joined:
    Jul 29, 2008
    Messages:
    97
    You know that code is continuous right?


    Obj5C_Main: ; XREF: Obj5C_Index


    move.w #$7980,2(a0) ; set offest for SLZ


    tst.b ($FFFFFE10).w ; is level GHZ?


    bne.s Obj5C_NotGHZ ; if not, branch


    move.w #$8555,2(a0) ; set offset for GHZ


    Obj5C_NotGHZ:


    addq.b #2,$24(a0)


    move.l #Map_obj5C,4(a0)


    move.w #$83CC,2(a0)


    move.b #$10,$19(a0)


    If it's ghz it's going through the not ghz code too, you want


    Obj5C_Main: ; XREF: Obj5C_Index


    move.w #$7980,2(a0) ; set offest for SLZ


    tst.b ($FFFFFE10).w ; is level GHZ?


    bne.s Obj5C_NotGHZ ; if not, branch


    move.w #$8555,2(a0) ; set offset for GHZ


    addq.b #2,$24(a0)


    move.w #$83CC,2(a0)


    move.b #$10,$19(a0)


    bra.s Obj5C_Display


    Obj5C_NotGHZ:


    addq.b #2,$24(a0)


    move.l #Map_obj5C,4(a0)


    or something
     
    Last edited by a moderator: Aug 23, 2012
  18. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    I did notice this, and changed the lines. It still loads incorrectly:


    [​IMG]
     
    Last edited by a moderator: Aug 23, 2012
  19. rika_chou

    rika_chou Adopt Member

    Joined:
    Aug 11, 2007
    Messages:
    689
    You have to free up some VRAM or find and unused space, you can see that the tiles you are trying to use are already being used by the rock.
     
  20. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Well this will be a new hight. Since I never changed or have attmpted to free VRAM space. Thanks for the assistance.