Basic Questions and Answers Thread

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

  1. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    889
    BurningFlame: There is no limit on total object count, but there is a limit on how many objects can have the "remember state" flag set in a level. Although it sounds like you're saying the objects were literally deleted from the object file, which sounds more like a bug with the level editor. I hope you were using SonED2, because otherwise I have a serious problem.

    LazloPsylus: Well you could read the manual to see what those things are, but I will spell it out for you. A function is an inline mini-macro that can be used within any instruction, directive, or macro argument. A function is defined like "make_art_tile function addr,pal,pri,((pri&1)<<15)|((pal&3)<<13)|(addr&tile_mask)" and used like "move.w #make_art_tile(ArtTile_ArtUnc_Sonic,0,0),art_tile(a0)". Character sets are a way to redefine the mapping between characters and bytes in strings. For example:
    Code:
        charset    ' ',$FF
        charset    '0',0
        charset    '1',2
        charset    '2',4
        charset    '3',6
        charset    '4',8
        charset    '5',$A
        charset    '6',$C
        charset    '7',$E
        charset    '8',$10
        charset    '9',$12
        charset    ':',$14
        charset    'E',$16
    
    ; byte_410D4:
    Hud_TilesBase:
        dc.b "E      0"
        dc.b "0:00"
    ; byte_410E0:
    ; Hud_TilesZero:
    Hud_TilesRings:
        dc.b "  0"
    Hud_TilesBase_End
    
        charset
    
    I'm sure Natsumi will tell you these are garbage that hides the original meaning of the code or something like that, but personally I find them to be very useful tools. And yes, you can emulate their functionality with ASM68K macros, but with AS you don't have to.
     
    ProjectFM and FireRat like this.
  2. BurningFlame

    BurningFlame Golden Ringsperience Requiem Member

    Joined:
    Jan 1, 2017
    Messages:
    37
    Location:
    Vodkaland
    Thanks, I found out dat game remembers rings, which is useless.
    EDIT: Duh, still have to place objects again by myself
    EDIT: Found backup, yay. (nobody cares)
    EDIT(again):How many objects game can remember?
     
    Last edited: Oct 9, 2017
  3. AURORA☆FIELDS

    AURORA☆FIELDS the cute one here Member

    Joined:
    Oct 7, 2011
    Messages:
    737
    Location:
    Finlandia
    It is true that with ASS you dont "have to" deal with macros to do the same thing. But you do have to deal it refusing to assemble completely valid code for no reason whatsoever, for it to only go away after you add some more code.
     
    AkumaYin likes this.
  4. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    Can anyone help me figure out why my code is destroying my hack on good emulators? I was stuck on a terrible laptop for a week and had to use picodrive to test. When I came back I was in for a rude awakening. The weird thing about the thing the errors it spits out is that I have 3 item boxes programmed to do the same thing and they just modify different memory addresses. The first monitor is the glitchiest and spits out the most errors. The second one works as intended. The third one doesn't spit out as many errors as the first. I tried switching addresses and the same results were received.
    Code:
    ; ===========================================================================
    ; ---------------------------------------------------------------------------
    ; Object 2E - contents of monitors
    ; ---------------------------------------------------------------------------
    
    Obj2E:                    ; XREF: Obj_Index
            moveq    #0,d0
            move.b    $24(a0),d0
            move.w    Obj2E_Index(pc,d0.w),d1
            jsr    Obj2E_Index(pc,d1.w)
            bra.w    DisplaySprite
    ; ===========================================================================
    Obj2E_Index:    dc.w Obj2E_Main-Obj2E_Index
            dc.w Obj2E_Move-Obj2E_Index
            dc.w Obj2E_Delete-Obj2E_Index
    ; ===========================================================================
    
    Obj2E_Main:                ; XREF: Obj2E_Index
            addq.b    #2,$24(a0)
            move.w    #$680,2(a0)
            move.b    #$24,1(a0)
            move.b    #3,$18(a0)
            move.b    #8,$19(a0)
            move.w    #-$300,$12(a0)
            moveq    #0,d0
            move.b    $1C(a0),d0
            addq.b    #2,d0
            move.b    d0,$1A(a0)
            movea.l    #Map_obj26,a1
            add.b    d0,d0
            adda.w    (a1,d0.w),a1
            addq.w    #1,a1
            move.l    a1,4(a0)
    
    Obj2E_Move:                ; XREF: Obj2E_Index
            tst.w    $12(a0)        ; is object moving?
            bpl.w    Obj2E_ChkEggman    ; if not, branch
            bsr.w    SpeedToPos
            addi.w    #$18,$12(a0)    ; reduce object    speed
            rts   
    ; ===========================================================================
    
    Obj2E_ChkEggman:            ; XREF: Obj2E_Move
            addq.b    #2,$24(a0)
            move.w    #29,$1E(a0)
            move.b    $1C(a0),d0
            cmpi.b    #1,d0        ; does monitor contain Eggman?
            bne.s    Obj2E_ChkSonic
            rts            ; Eggman monitor does nothing
    ; ===========================================================================
    
    Obj2E_ChkSonic:
            cmpi.b    #2,d0        ; does monitor contain Sonic?
            bne.s    Obj2E_ChkShoes
    
    ExtraLife:
            addq.b    #1,($FFFFFE12).w ; add 1 to the    number of lives    you have
            addq.b    #1,($FFFFFE1C).w ; add 1 to the    lives counter
            move.w    #$88,d0
            jmp    (PlaySound).l    ; play extra life music
    ; ===========================================================================
    
    Obj2E_ChkShoes:
            cmpi.b    #3,d0        ; does monitor contain speed shoes?
            bne.s    Obj2E_ChkShield
            move.b    #1,($FFFFFE2E).w ; speed up the    BG music
            move.w    #$4B0,($FFFFD034).w ; time limit for the power-up
            move.w    #$C00,($FFFFF760).w ; change Sonic's top speed
            move.w    #$18,($FFFFF762).w
            move.w    #$80,($FFFFF764).w
            move.w    #$E2,d0
            jmp    (PlaySound).l    ; Speed    up the music
    ; ===========================================================================
    
    Obj2E_ChkShield:
            cmpi.b    #4,d0        ; does monitor contain a shield?
            bne.s    Obj2E_ChkInvinc
            move.b    #1,($FFFFFE2C).w ; give    Sonic a    shield
            move.b    #$38,($FFFFD180).w ; load shield object    ($38)
            move.w    #$AF,d0
            jmp    (PlaySound).l    ; play shield sound
    ; ===========================================================================
    
    Obj2E_ChkInvinc:
            cmpi.b    #5,d0        ; does monitor contain invincibility?
            bne.s    Obj2E_ChkRings
            move.b    #1,($FFFFFE2D).w ; make    Sonic invincible
            move.w    #$4B0,($FFFFD032).w ; time limit for the power-up
            move.b    #$38,($FFFFD200).w ; load stars    object ($3801)
            move.b    #1,($FFFFD21C).w
            move.b    #$38,($FFFFD240).w ; load stars    object ($3802)
            move.b    #2,($FFFFD25C).w
            move.b    #$38,($FFFFD280).w ; load stars    object ($3803)
            move.b    #3,($FFFFD29C).w
            move.b    #$38,($FFFFD2C0).w ; load stars    object ($3804)
            move.b    #4,($FFFFD2DC).w
            tst.b    ($FFFFF7AA).w    ; is boss mode on?
            bne.s    Obj2E_NoMusic    ; if yes, branch
            move.w    #$87,d0
            jmp    (PlaySound).l    ; play invincibility music
    ; ===========================================================================
    
    Obj2E_NoMusic:
            rts   
    ; ===========================================================================
    
    Obj2E_ChkRings:
            cmpi.b    #6,d0        ; does monitor contain 10 rings?
            bne.s    Obj2E_ChkS
            addi.w    #$A,($FFFFFE20).w ; add    10 rings to the    number of rings    you have
            ori.b    #1,($FFFFFE1D).w ; update the ring counter
            cmpi.w    #100,($FFFFFE20).w ; check if you have 100 rings
            bcs.s    Obj2E_RingSound
            bset    #1,($FFFFFE1B).w
            beq.w    ExtraLife
            cmpi.w    #200,($FFFFFE20).w ; check if you have 200 rings
            bcs.s    Obj2E_RingSound
            bset    #2,($FFFFFE1B).w
            beq.w    ExtraLife
    
    Obj2E_RingSound:
            move.w    #$B5,d0
            jmp    (PlaySound).l    ; play ring sound
    ; ===========================================================================
    
    Obj2E_ChkS:
            cmpi.b    #7,d0        ; does monitor contain 'Emerald'
            bne.s    Obj2E_ChkEm2
            cmpi.w     #0,($FFFFF75F).w    ; did player collect this 'emerald'
            bne.s    Denied
            move.b  #1,($FFFFF75F).w
    Obj2E_ChkEm2:
            cmpi.b    #8,d0        ; does monitor contain 'Emerald'
            bne.s    Obj2E_ChkEm3
            cmpi.w    #0,($FFFFF5C0).w        ; did player collect this 'emerald'
            bne.s    Denied
            move.b  #1,($FFFFF5C0).w
    Obj2E_ChkEm3:
            cmpi.b    #9,d0        ; does monitor contain 'Emerald'
            bne.s    Obj2E_ChkEnd
            cmpi.w     #0,($FFFFF75D).w        ; did player collect this 'emerald'
            bne.s    Denied
            move.b  #1,($FFFFF75D).w
    
    Obj2E_ChkEnd:
            rts            ; 'S' and goggles monitors do nothing
    Denied:
            addi.w    #$A,($FFFFFE20).w ; add    10 rings to the    number of rings    you have
            ori.b    #1,($FFFFFE1D).w ; update the ring counter
            move.w    #$B5,d0
            jmp    (PlaySound).l    ; play ring sound
            rts
    
    ; ===========================================================================
    
    Obj2E_Delete:                ; XREF: Obj2E_Index
            subq.w    #1,$1E(a0)
            bmi.w    DeleteObject
            rts    
     
  5. LazloPsylus

    LazloPsylus The Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    Hmm, I see what you mean with charsets. Interesting. I'll look up functions as well, as I'm curious.
     
    Niko likes this.
  6. AURORA☆FIELDS

    AURORA☆FIELDS the cute one here Member

    Joined:
    Oct 7, 2011
    Messages:
    737
    Location:
    Finlandia
    Ziro you do know that you can no do word accesses to odd addresses, right? 68000 doesn't support that. For reference, this is one of the lines I am talking about
    Code:
    cmpi.w     #0,($FFFFF75F).w
     
  7. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    889
    I think the game can have $FE objects remembering their state in a level.
     
  8. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    Oops I forgot about that. I'll change it later and see if it fixes the issue. Thanks :)

    Edit: Welp it might of fixed another problem down the road but the same exact thing happened. Here is the code with the updated addresses.

    Code:
    Obj2E_ChkS:
            cmpi.b    #7,d0        ; does monitor contain 'Emerald'
            bne.s    Obj2E_ChkEm2
            cmpi.w     #0,($FFFFF622).w    ; did player collect this 'emerald'
            bne.s    Denied
            move.b  #1,($FFFFF622).w
    Obj2E_ChkEm2:
            cmpi.b    #8,d0        ; does monitor contain 'Emerald'
            bne.s    Obj2E_ChkEm3
            cmpi.w    #0,($FFFFF5C0).w        ; did player collect this 'emerald'
            bne.s    Denied
            move.b  #1,($FFFFF5C0).w
    Obj2E_ChkEm3:
            cmpi.b    #9,d0        ; does monitor contain 'Emerald'
            bne.s    Obj2E_ChkEnd
            cmpi.w     #0,($FFFFF664).w        ; did player collect this 'emerald'
            bne.s    Denied
            move.b  #1,($FFFFF664).w
     
    Last edited: Oct 9, 2017
  9. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    868
    Location:
    Portland, Maine
    You're checking word values and then setting a byte value. That means that you are checking if both $FFFFF622 and $FFFFF623 are zero, then setting $FFFFF622 to 1 if it is. I don't think this is the source of your error, but it will prevent some unwanted behavior. Also, you can use "tst.w ($FFFFF622).w" instead of "cmpi.w #0,($FFFFF622).w" for more efficiency.
     
    Niko and warr1or2 like this.
  10. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    397
    Location:
    Town Creek, AL
    What's the image size of the sonic object on the title screen? I want to replace it, & the image i want to use is WAY too large.
     
  11. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    Thanks for the tip I thought of using it in the beginning but I used the compare instruction instead for some reason (because I am not too smart). It is still the same outcome though but you could have saved me from a future problem.

    Edit: Holy shit MainMemory your suggestion was actually the thing that would solve it but the build.bat thing you gave me the night before tried to build another file that didn't exist (sonic.asm) and logged errors to a separate file instead of straight into the command window so I though there were not any errors so nothing was changing and it was not building. WOW
     
    Last edited: Oct 10, 2017
  12. Niko

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    Ziro_: Not sure if that's user error not seeing the lack of a 1 in "sonic.asm." as some Sonic 1 disassemblies have different file names. If not, then either way, you can put a "pause" at the end of the batch file you're using to run it, which will allow you to manually copy it to the clipboard.
    ___________________________________

    @Lone Devil: I know you're out there somewhere.
    I was hoping to ask about the SA2 mods of Knuckles and Metal over Sonic.
    To be more specific, what the method of transferring objects from one character to the other was.

    And, if anyone knows if SA2's player models for Sonic & Knuckles have the tails separated like SA1/DX, that'd be helpful. More so with the address that the mesh can be found at within the .prs file, if known.

    MainMemory: I understand that .prs compressed files used in SA2B can be decompressed with the common decompress-er, but the resulting files contain Oh, hey. Hex shows GVM headers. GameCube SA2B uses GVMs, still. PuyoTools works, then. Now I wonder why the SA2 Mod Loader looks for .pak files. Convenience? Anywho, leaving this here for any other curious souls.

    As for, now, anyone who'd know:
    Six button support.
    Natsumi's tutorial is great, and I've gotten it to work with Sonic 1, but I'm trying to get it working with GitHub Sonic 2. Also looking at the "outdated" tutorial of the same subject for button values, I've got a good hold of changing the controller reads from bytes to words, but this ends up with strange readings, or none at all when applied. I'd bet that this has to do with either InitPads, or the alternative tutorial's ReadJoypads, as it's what actually detects the six button controller.
    The problem, then, is that the syntax doesn't match for these replacement subroutines. I was wondering if anyone could help translate it. I'm really lost, and not finding these functions after extensive searches. I was also thinking of asking which part of the overall Joypad read function actually reads the extra four (counting Mode) buttons, as a way of getting it in quickly, prior to finalizing it.

    Note to self: Stop working with code at midnight. It was if statements like if, endif, and "ifne." Still not sure about that last one, though.
    Code:
    > > >s2.readInput.asm(5): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(8): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(14): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(22): error: ELSEIF/ENDIF without IF
    > > >     else
    > > >s2.readInput.asm(23): error: symbol double defined
    > > > INITPADS.CTRL
    > > > .ctrl
    > > >s2.readInput.asm(24): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(30): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay            ; delay
    > > >s2.readInput.asm(32): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay            ; delay
    > > >s2.readInput.asm(34): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay            ; delay
    > > >s2.readInput.asm(36): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay            ; delay
    > > >s2.readInput.asm(45): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(51): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay
    > > >s2.readInput.asm(53): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay
    > > >s2.readInput.asm(109): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(122): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(125): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(132): error: unknown opcode
    > > > IFNE
    > > > .ctrl3    ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(135): error: ELSEIF/ENDIF without IF
    > > >     else
    > > >s2.readInput.asm(138): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(161): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(165): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(168): error: unknown opcode
    > > > IFNE
    > > > .ctrl6    ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(171): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(190): error: unknown opcode
    > > > CTRL_DELAY
    > > >     ctrl_delay                ; delay
    > > >s2.readInput.asm(207): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >s2.readInput.asm(211): error: ELSEIF/ENDIF without IF
    > > >     endif
    > > >s2.readInput.asm(214): error: unknown opcode
    > > > IFNE
    > > >     ifne CTRL_ENABLE_MULTI
    > > >: error: open macro definition
    > > >
    
     
    Last edited: Oct 10, 2017
  13. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    @Calvin Oh I was not trying to blame MainMemory. I agree it was a user error, sorry if I did not make that clear.
     
  14. BurningFlame

    BurningFlame Golden Ringsperience Requiem Member

    Joined:
    Jan 1, 2017
    Messages:
    37
    Location:
    Vodkaland
    $FE Objects in a single Act? Or in a zone?
     
  15. LuigiXHero

    LuigiXHero Well-Known Member Member

    Joined:
    Mar 22, 2014
    Messages:
    279
  16. BurningFlame

    BurningFlame Golden Ringsperience Requiem Member

    Joined:
    Jan 1, 2017
    Messages:
    37
    Location:
    Vodkaland
    Thanks, now I can build levels without worries!
     
  17. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    532
    Location:
    France
  18. ralakimus

    ralakimus pretty much a dead account Member

    Joined:
    Aug 26, 2013
    Messages:
    1,069
    Do the actual rotated tiles exist in the ROM? Did you make sure it runs SS_LoadWalls VBla_0A's @nochg (Git)/loc_E64 (Hivebrain) and VBla_16's @nochg/loc_1060?

    EDIT: Actually, the 2nd question I asked is dumb, since art IS being loaded. Maybe the angle ID isn't being properly updated? What about the "previous" angle?
     
  19. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    532
    Location:
    France
    Thanks, but when i tried to change the angle value:
    Code:
    SS_LoadWalls:
            moveq    #0,d0
            move.b    ($FFFFF780).w,d0    ; get the Special Stage angle
            lsr.b    #2,d0            ; modify so it can be used as a frame ID
            andi.w    #$F,d0
            cmp.b    ($FFFFFF7C).w,d0    ; does the modified angle match the recorded value?
            beq.s    @return            ; if so, branch
    ...
    It doesn't change anything in game.
    I look to my code since many hours, without find any solution. But i know it's an angle/frame problem.
     
  20. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    889
    Generally, model swaps can be performed by using the ModelRelabeler tool to transfer the labels from the model you want to replace (eg SONICMDL\0.sa2mdl) into the model you want to use instead (eg KNUCKMDL\142.sa2mdl).

    I don't know if they have separate tails, with our tools as they are now it's impossible to tell.