Basic Questions and Answers Thread

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

  1. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    It's a longword being written to an odd address. The 68k can't do that.
     
  2. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks for all the help Clownacy. Everything is working fine now. 
     
  3. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    So I tried making a different zone use MCZ's level events (and by extension, it's boss). It works fine, except for the fact that the MCZ boss refuses to load it's art, displaying as a garbled mixture of letters, flickies, and other leftover art, implying that it hasn't even attempted to overwrite it's art space. After looking over levevents_MCZ, I discovered these lines:


    moveq #$2C,d0
    bsr.w JmpTo2_LoadPLC
    moveq #$19,d0
    bsr.w JmpTo2_PalLoad2

    After looking up the "$2C" used before the LoadPLC jump in the plr list, I discovered that this is where the art is actually supposed to be loaded. But I have no idea why it isn't working; I tried putting this above the line that defines the boss ID, which is what makes the boss spawn, but that results in the boss not even appearing; which is utterly confounding. Does anyone have any idea why this issue occurs? (Keep in mind, this actually works just fine in MCZ, but not the new level I put it in)

    EDIT: I'm still waiting for an answer... Even a short sentence about what might potentially be causing this would help...
     
    Last edited by a moderator: Mar 1, 2015
  4. jubbalub

    jubbalub Mania fanboy Member

    Joined:
    Dec 25, 2014
    Messages:
    286
    So, edited the title cards for Sonic 1, works fine for GHZ, tried to edit the others, fails to build.

    Warning, wall of text.

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

    ; Sprite mappings - zone title cards

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

    Map_Card: dc.w M_Card_GHZ-Map_Card

    dc.w M_Card_LZ-Map_Card

    dc.w M_Card_MZ-Map_Card

    dc.w M_Card_SLZ-Map_Card

    dc.w M_Card_SYZ-Map_Card

    dc.w M_Card_SBZ-Map_Card

    dc.w M_Card_Zone-Map_Card

    dc.w M_Card_Act1-Map_Card

    dc.w M_Card_Act2-Map_Card

    dc.w M_Card_Act3-Map_Card

    dc.w M_Card_Oval-Map_Card

    dc.w M_Card_FZ-Map_Card

    M_Card_GHZ: dc.b $A ; GREEN HILL | LUSH LANDS

    dc.b $F8, 5, 0, $26, $AC ; L

    dc.b $F8, 5, 0, $46, $BC ; U

    dc.b $F8, 5, 0, $3E, $CC ; S

    dc.b $F8, 5, 0, $1C, $DC ; H

    dc.b $F8, 0, 0, $56, $EC ; Space

    dc.b $F8, 5, 0, $26, $FC ; L

    dc.b $F8, 5, 0, 0, $C ; A

    dc.b $F8, 5, 0, $2E, $1C ; N

    dc.b $F8, 5, 0, $0C, $2C ; D

    dc.b $F8, 5, 0, $3E, $3C ; S

    even

    M_Card_LZ: dc.b $F ; LABYRINTH | TREMENDOUS TIDE

    dc.b $F8, 5, 0, $42, $AC ; T

    dc.b $F8, 5, 0, $3A, $BC ; R

    dc.b $F8, 5, 0, $10, $CC ; E

    dc.b $F8, 5, 0, $2A, $DC ; M

    dc.b $F8, 5, 0, $10, $EC ; E

    dc.b $F8, 5, 0, $2E, $FC ; N

    dc.b $F8, 5, 0, $0C, $C ; D

    dc.b $F8, 5, 0, $32, $1C ; O

    dc.b $F8, 5, 0, $46, $2C ; U

    dc.b $F8, 5, 0, $3E, $3C ; S

    dc.b $F8, 0, 0, $56, $4C ; Space

    dc.b $F8, 5, 0, $42, $5C ; T

    dc.b $F8, 1, 0, $20, $6C ; I

    dc.b $F8, 5, 0, $0C, $74 ; D

    dc.b $F8, 5, 0, $10, $84 ; E

    even

    M_Card_MZ: dc.b $B ; MARBLE | MAGMA MANIA

    dc.b $F8, 5, 0, $2A, $AC ; M

    dc.b $F8, 5, 0, 0, $BC ; A

    dc.b $F8, 5, 0, $18, $CC ; G

    dc.b $F8, 5, 0, $2A, $DC ; M

    dc.b $F8, 5, 0, 0, $EC ; A

    dc.b $F8, 0, 0, $56, $FC ; Space

    dc.b $F8, 5, 0, $2A, $C ; M

    dc.b $F8, 5, 0, 0, $1C ; A

    dc.b $F8, 5, 0, $2E, $2C ; N

    dc.b $F8, 1, 0, $20, $3C ; I

    dc.b $F8, 5, 0, 0, $44 ; A

    even

    M_Card_SLZ: dc.b $F ; STAR LIGHT | STERLING STREET

    dc.b $F8, 5, 0, $3E, $AC ; S

    dc.b $F8, 5, 0, $42, $BC ; T

    dc.b $F8, 5, 0, $10, $CC ; E

    dc.b $F8, 5, 0, $3A, $DC ; R

    dc.b $F8, 5, 0, $26, $EC ; L

    dc.b $F8, 1, 0, $20, $FC ; I

    dc.b $F8, 5, 0, $2E, $4 ; N

    dc.b $F8, 5, 0, $18, $14 ; G

    dc.b $F8, 0, 0, $56, $24 ; Space

    dc.b $F8, 5, 0, $3E, $34 ; S

    dc.b $F8, 5, 0, $42, $44 ; T

    dc.b $F8, 5, 0, $3A, $54 ; R

    dc.b $F8, 5, 0, $10, $64 ; E

    dc.b $F8, 5, 0, $10, $74 ; E

    dc.b $F8, 5, 0, $42, $84 ; T

    even

    M_Card_SYZ: dc.b $D ; SPRING YARD | PLAYFUL PARTY

    dc.b $F8, 5, 0, $36, $AC ; P

    dc.b $F8, 5, 0, $26, $BC ; L

    dc.b $F8, 5, 0, 0, $CC ; A

    dc.b $F8, 5, 0, $4A, $DC ; Y

    dc.b $F8, 5, 0, $14, $EC ; F

    dc.b $F8, 5, 0, $46, $FC ; U

    dc.b $F8, 5, 0, $26, $C ; L

    dc.b $F8, 0, 0, $56, $1C ; Space

    dc.b $F8, 5, 0, $36, $2C ; P

    dc.b $F8, 5, 0, 0, $3C ; A

    dc.b $F8, 5, 0, $3A, $4C ; R

    dc.b $F8, 5, 0, $42, $5C ; T

    dc.b $F8, 5, 0, $4A, $6C ; Y

    even

    M_Card_SBZ: dc.b $C ; SCRAP BRAIN | ROBO REACTOR

    dc.b $F8, 5, 0, $3A, $AC ; R

    dc.b $F8, 5, 0, $32, $BC ; O

    dc.b $F8, 5, 0, 4, $CC ; B

    dc.b $F8, 5, 0, $32, $DC ; O

    dc.b $F8, 0, 0, $56, $EC ; Space

    dc.b $F8, 5, 0, $3A, $FC ; R

    dc.b $F8, 5, 0, $10, $C ; E

    dc.b $F8, 5, 0, 0, $1C ; A

    dc.b $F8, 5, 0, 8, $2C ; C

    dc.b $F8, 5, 0, $42, $3C ; T

    dc.b $F8, 5, 0, $32, $4C ; O

    dc.b $F8, 5, 0, $3A, $5C ; R

    even

    M_Card_Zone: dc.b 4 ; ZONE

    dc.b $F8, 5, 0, $4E, $E0

    dc.b $F8, 5, 0, $32, $F0

    dc.b $F8, 5, 0, $2E, 0

    dc.b $F8, 5, 0, $10, $10

    even

    M_Card_Act1: dc.b 2 ; ACT 1

    dc.b 4, $C, 0, $53, $EC

    dc.b $F4, 2, 0, $57, $C

    M_Card_Act2: dc.b 2 ; ACT 2

    dc.b 4, $C, 0, $53, $EC

    dc.b $F4, 6, 0, $5A, 8

    M_Card_Act3: dc.b 2 ; ACT 3

    dc.b 4, $C, 0, $53, $EC

    dc.b $F4, 6, 0, $60, 8

    M_Card_Oval: dc.b $D ; Oval

    dc.b $E4, $C, 0, $70, $F4

    dc.b $E4, 2, 0, $74, $14

    dc.b $EC, 4, 0, $77, $EC

    dc.b $F4, 5, 0, $79, $E4

    dc.b $14, $C, $18, $70, $EC

    dc.b 4, 2, $18, $74, $E4

    dc.b $C, 4, $18, $77, 4

    dc.b $FC, 5, $18, $79, $C

    dc.b $EC, 8, 0, $7D, $FC

    dc.b $F4, $C, 0, $7C, $F4

    dc.b $FC, 8, 0, $7C, $F4

    dc.b 4, $C, 0, $7C, $EC

    dc.b $C, 8, 0, $7C, $EC

    even

    M_Card_FZ: dc.b $E ; FINAL | FINAL FUCKFEST

    dc.b $F8, 5, 0, $14, $80 ; F

    dc.b $F8, 1, 0, $20, $90 ; I

    dc.b $F8, 5, 0, $2E, $98 ; N

    dc.b $F8, 5, 0, 0, $A8 ; A

    dc.b $F8, 5, 0, $26, $B8 ; L

    dc.b $F8, 0, 0, $56, $C8 ; Space

    dc.b $F8, 5, 0, $14, $D8 ; F

    dc.b $F8, 5, 0, $46, $E8 ; U

    dc.b $F8, 5, 0, 8, $F8 ; C

    dc.b $F8, 5, 0, $22, $8 ; K

    dc.b $F8, 5, 0, $14, $18 ; F

    dc.b $F8, 5, 0, $10, $28 ; E

    dc.b $F8, 5, 0, $3E, $38 ; S

    dc.b $F8, 5, 0, $42, $48 ; T

    even

    include "_mapsGame Over.asm"

    This is the error file:

    SN 68k version 2.53

    C:USERS*no name for you*DESKTOPS1DISASM-MASTERSONIC.ASM(9114) : Warning : Forward reference to redefinable symbol

    C:USERS*DESKTOPS1DISASM-MASTERSONIC.ASM(2296) : Warning : Forward reference to redefinable symbol

    C:USERS*DESKTOPS1DISASM-MASTERSONIC.ASM(2381) : Warning : Forward reference to redefinable symbol

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ89 ENDING SEQUENCE STH.ASM(37) : Error : Branch (32834 bytes) is out of range

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ89 ENDING SEQUENCE STH.ASM(58) : Error : Branch (32808 bytes) is out of range

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ59 SLZ ELEVATORS.ASM(10) : Warning : Forward reference to redefinable symbol

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ5A SLZ CIRCLING PLATFORM.ASM(10) : Warning : Forward reference to redefinable symbol

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ5B STAIRCASE.ASM(10) : Warning : Forward reference to redefinable symbol

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ5E SEESAW.ASM(10) : Warning : Forward reference to redefinable symbol

    Assembly completed.

    2 error(s) from 53309 lines in 0.19 seconds

    I know pretty much nothing about ASM - the most complex thing I've done is add the eggman monitor. Help?
     
    Last edited by a moderator: Mar 6, 2015
  5. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    The warnings aren't nice, though they shouldn't hinder the compiling for now.

    What breaks everything are these two bad boys:

    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ89 ENDING SEQUENCE STH.ASM(37) : Error : Branch (32834 bytes) is out of range
    C:USERS*DESKTOPS1DISASM-MASTER_INCOBJ89 ENDING SEQUENCE STH.ASM(58) : Error : Branch (32808 bytes) is out of rangeOut-of-range errors, probably the most common type of error and also one of the most annoying ones.Basically, your title cards aren't the direct cause for your compilation failing; it's just that somewhere else the game tried to reach something, but can't do so now because of the newly inserted code being larger than what was there before.

    Simple rules apply to fixing these errors.

    Open the mentioned files ("_INCOBJ89 ENDING SEQUENCE STH.ASM" in the first case), find the mentioned line (37 in said case), and check what size your branch has. In 9 out of 10 cases you'll find that the line is something like:

    bra.s SomeLabelSimply replace the .s (which stands for "short") with a .w (which stands for "word"). Shorts, as the name implies, only have a small branching range, whereas words are much, much larger (in numbers, shorts have a total range of a byte; words have a range of, well, a word).
    However, should you find that the errors in question already have a ".w", a different way is required to fix them, which is replacing them with so-called "jumps".

    Jumps are essentially the same thing as branches, only that they don't relatively go to another place based on where the branch is executed, but rather work on an absolute basis, meaning they can go from one end of the game to the other with ease. The disadvantage is that there are no conditional jumps (so nothing like "beq" or "bne" applies to jumps), and jumps are also considerably slower.

    In case you have a "bra.w" and that line only, you can simply replace it with "jmp". In case you have a "bsr.w" and that line only, you can simply replace it with "jsr".

    If it's any other command than bra or bsr, it's a conditional operation. Fixing those errors are a little harder to explain. You need to create a new label somewhere else which jumps to the actual result, and instead go to that via the branch.

    I think an example is easier to understand:

    This:

    cmpi.b #$18,($FFFFFFFF).w ; is that RAM address set to $18?
    bne.w SomeOutOfRangeLabel ; if not, branchBecomes this:
    Code:
    		cmpi.b	#$18,($FFFFFFFF).w		; is that RAM address set to $18?
    		bne.s	JumpTo_SomeOutOfRangeLabel	; if not, branch
    
    	; some other code in between here
    
    JumpTo_SomeOutOfRangeLabel:
    		jmp	SomeOutOfRangeLabel
    An alternative (which I've also touched in my old as hell Basic Error Fixing Guide) is negating the instruction and instead making a skip. Negating "bne" results into "beq", negating "bgt" results into "ble" and so on.
    As an example (based on the above code):

    cmpi.b #$18,($FFFFFFFF).w ; is that RAM address set to $18?
    beq.s SkipJump ; if YES, branch
    jmp SomeOutOfRangeLabel

    SkipJump:
    ...I personally prefer this second method, as I don't need to find a place to put the JumpTo branch and instead can keep everything in one place. However, it requires knowledge of the various conditional branch instructions, so you should memorize the table at the bottom of this page.
    Finally, I hope this made any sense to you. It's really easy to fix these errors and becomes second nature at some point (because you need to be prepared to get confronted with them a lot), but they can be confusing for beginners.
     
    Last edited by a moderator: Mar 9, 2015
  6. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    For the record, I guess the branches involved in this particular case were .w to begin with, since the out of range values are just a little bigger than 32768 and I don't think he added that much stuff in his code :v
     
  7. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Last edited by a moderator: Mar 7, 2015
  8. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    I bet you any money, these are two "bra.w" instructions to the subroutine "DisplaySprite"...

    ...ANY money!
     
  9. tilk

    tilk Active Member Member

    Joined:
    Feb 2, 2012
    Messages:
    30
    Hi! I'm working with a Sonic 3 & Knuckles disassembly, and honestly I was wondering how i can free (And use) this section of the RAM (So i can add some things, like the Clone driver):


    Sprite_table_buffer_2 = ramaddr( $FF7880 ) ; $280 bytes ; alternate sprite table for player 1 in competition mode
    Sprite_table_buffer_P2 = ramaddr( $FF7B00 ) ; $280 bytes ; sprite table for player 2 in competition mode
    Sprite_table_buffer_P2_2 = ramaddr( $FF7D80 ) ; $280 bytes ; alternate sprite table for player 2 in competition mode

    (Yes, i also want to do the hard task of removing the 2p mode; for me, it just takes space...)
     
    Last edited by a moderator: Mar 7, 2015
  10. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    If 2 player competition mode is not actively playing or selected (i.e. the player selected 1 player mode), then there's a good chance those memory spaces are not accessed at all. So I would naturally assume and suggest that you could just use them right off the bat, so long as you prohibit the playing from gaining access to 2 player mode.

    It is however possible, that the memory space is used in player 1 mode as part of a temporary cut-scene or special effect, I'd doubt it, though you could search for other equates that use the same RAM address. It is also possible that majority of subroutines (including that of 1 player mode) will actively clear those memory spaces when starting up a level, maybe you'll benefit from it, maybe you won't. I'm just making it abundantly clear. If you wish to be certain, you could always search those equate names in the source code and find out; where, when, and how, they are accessed, just to be sure, and make your compromises there.

    I am of course, talking out of my arsehole since I do not specialise in Sonic 3 & Knuckles, but I know enough to justify my knowledge.
     
  11. tilk

    tilk Active Member Member

    Joined:
    Feb 2, 2012
    Messages:
    30
    I tried that before (2nd paragraph). However, (If I remember well) there's a problematic point: V-hint. I tried to comment out the references to that addresses by comparing it to it's Sonic 2 equivalent, but it ends messing up something... I guess that the best thing i can do about that is to port the S2 hg V-hint.

    EDIT:

    Nevermind, the problem appears when I move the Plane_buffer or Vram_buffer ram adresses, causing graphical problems... something that i don't know how to fix.

    Also, how I can convert a Sonic 1 object to S3k? I ask because I'm aware that it uses different object & priority managers.
     
    Last edited by a moderator: Mar 8, 2015
  12. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I'm relatively curious about porting in general, although my current interest is porting from S3K or S1 to S2; I've tried looking on Google, but I haven't been able to find even a very general tidbit of help, and as far as I can see, S2 and S1 use the same SSTs (even directly ripping code from S1 results in the object functioning properly for a short period before the game crashes). I definitely would love to work it out myself, but I don't have anything to work off; I've made custom objects before, but porting is a whole different level for me.
     
    Last edited by a moderator: Mar 8, 2015
  13. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    Yes you do: look in here, there's a ported object. Compare it to the original object, Obj_Attracted_Ring. That's how I learnt to do it.
     
    Last edited by a moderator: Mar 8, 2015
  14. jubbalub

    jubbalub Mania fanboy Member

    Joined:
    Dec 25, 2014
    Messages:
    286
    This saved me hours of head banging. Big thanks!
     
  15. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I'm trying to make an object load the special stage results screen, then return to normal play, in Sonic 2. So, I jump to loc_52C4, the results screen loads exactly as I'd want it too, and right after flashing out, it crashes. I've been messing with it for about two hours straight now, and I can't seem to find a solution I can wrap my head around. Here's the error message Flamewing's debugger gives out, if it helps:

    [​IMG]

    And the code I have pointing to it:


    move.b #1,(Got_emerald).w
    move.w #$1D+$80,d0
    jsr (PlayMusic).l ; Play emerald music
    move.w #$10,(Game_mode).w
    jmp loc_52C4

    I really can't figure out why it's crashing like this, my examination implies that it's crashing right at the start of "Level:" (which I highly doubt). When I load the games default special stage, it functions exactly as it should; only this particular entry method causes it to crash after the results screen has finished.
     
    Last edited by a moderator: Mar 9, 2015
  16. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    @Bagumba: No problems. I've also added a little something I felt like it was rather helpful to mention.
     
  17. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    102
    I've been trying to program an action in a player attack routine that works with a specific animation frame in the attack, but it doesn't seem to recognise it. Is this branch correct?:



    move.b #$20,$1C(a0)
    cmpi.b #3,$1A(a0) ;is player on frame 3 of the attack?

     bcs.s HS_End ;if not branch
     
    Last edited by a moderator: Mar 9, 2015
  18. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    $1A is the overall mapping frame, not the relative frame to an animation set. What you want is $1B.

    Furthermore, I'm not quite sure why you're triggering it via the carry flag instead of a simple equal check. Not that it's necessarily wrong, but in case you have more frames to come, the action will trigger at every frame after 2.
     
    Last edited by a moderator: Mar 10, 2015
  19. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    102
    I tried $1B and didn't get the wanted results either. To be specific, I want numerous actions with different frames. It does the first but doesn't time to the later ones.

    What is an equal check again? (probably something obvious but I don't know the definitions).
     
    Last edited by a moderator: Mar 10, 2015
  20. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    beq and bne.