Basic Questions and Answers Thread

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

  1. Clownacy

    Clownacy Well-Known Member Staff

    Joined:
    Aug 15, 2014
    Messages:
    890
    'add d0,d0' is faster than 'lsl #1,d0'. I'm not sure if the sizes are different. I think two 'add d0,d0's is faster than 'lsl #2,d0', but the size will be larger

    Always use the smallest available branch/jump sizes

    'moveq #0,d0' is faster than 'clr.l d0'. I think their sizes are the same

    A series of clear/writes (same data being written) can be sped up by loading the data into a register and writing the contents of that. This also works with addresses: instead of writing to multiple '(address).l's or '(address).w's, load the address into an available address register and use that. This should also save you space in the long run

    For the most part, you can get away with referencing RAM addresses as '().w', which is faster and smaller than '().l'

    Unroll your loops (dbf or manual) for speed, or keep them rolled for size

    My 68k manual could be horribly wrong, but it seems 'lea $10(a0),a0' is faster than 'adda.w #$10,a0'

    If a certain piece of code is used in multiple areas, make it into a subroutine. Good for space, but costs speed. S3K did this with common object SST setup, and I believe S2 did something similar with sub-object setup

    Some data is stored as bytes, when the code that uses it runs calculations that require that data be word-length. This is usually done with the 'ext.w' instruction, but having it that way is a size-optimisation measure. If you'd prefer a speed-optimised approach, manually extend the data to word length, remove the 'ext.w', and, if there is any, modify the index-generating code to account for the doubled size of the data
     
    Last edited by a moderator: Jan 13, 2015
  2. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    70
    Is there any way to move the touch radius of an object? I know some can expand their collision but I want an object to move it's collision according to certain frames (or at least expand only in one direction). Is this possible?
     
  3. โบวี่

    โบวี่ 빈보위 Member

    Joined:
    Dec 27, 2011
    Messages:
    215
    I'd like to know if there is any way to get Sonic 1's Sound Driver to play songs faster than 150bpm.

    Is it possible? I'm not too good at coding.

    I'm using Markey's 128 Disasm.
     
    Last edited by a moderator: Jan 13, 2015
  4. Roxurface

    Roxurface Well-Known Member Member

    Joined:
    Oct 5, 2014
    Messages:
    69
    I'm not really sure what you're using to make your music, but find some way to edit the Ticks/Quarter and Tempo Div.  The lower these values are the greater your tempo will be.  For example, by default your song is 12 Ticks/Quarter and has a Tempo Div of 2.  By making your TempoDiv 1, you double all of the Tempo Mod values, making your maximum 300 BPM and your minimum 150.  There is an SMPS Tempo Calculator that's packaged with Mid2SMPS to help you understand this concept.
     
  5. N30member

    N30member non-pro user btw Member

    Joined:
    Feb 15, 2014
    Messages:
    216
    Location:
    Kazakhstan
    Going off topic, but sound driver in any Sonic 1 disasm is the same. In Project 1:2-8 MJ edited only chunk format, while the rest of code is taken from Hivebrain.
     
  6. Kaz

    Kaz Well-Known Member Member

    Joined:
    Nov 2, 2013
    Messages:
    66
    It is, if you port S3K's Z80 Tempo System to Sonic 1. Although that requires advanced code conversion tools and knowledge, Clownacy already has it ported to the 68000, in Clownacy's S2 Clone Driver.
     
  7. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    ...Or you could find the correct divider. It's possible...or not have a MIDI over that tempo. Alternatively you could lengthen every note x2 and cut the tempo in half, so 160, note length 1, make it 80 and not length 1/2...it takes a long time but this is why I sequence my own MIDIs to not run into this problem.
     
  8. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,779
    Location:
    italy
    I think he should divide the note durations in half if he wants them to play faster, but alas, my Midi editor can rescale the note lenghts, so it doesn't "take a long time" to do what you're suggesting. Just keep in mind that you might lose precision on short notes if you do so.
     
  9. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    70
    Is it possible to connect an objects position according to which animation frame it's on. Say make an object move one extra tile to the right with each animation frame.
     
  10. Kaz

    Kaz Well-Known Member Member

    Joined:
    Nov 2, 2013
    Messages:
    66
    So I made a lazy macro to display text directly without using DMA for an options screen, based on how Sonic 2 displayed the copyright text on it's title screen. (128x128 git)
     




    displayText: macro pos,text,length
    lea (v_128x128+pos).l,a1
    lea (text).l,a2
    moveq #length,d6
    @loop: move.w (a2)+,(a1)+ ; load mappings
    dbf d6,@loop
    copyTilemap v_128x128,$C000,$27,$1B
    endm



    and used this test example on my options screen:




    move #$2700,sr

    displayText $0054,CopyrightText,$A





    and I end up with this:

    [​IMG]

    I think it has to do with ShowVDPGraphics/TilemapToVRAM.
     
  11. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,820
    A few ideas.

    • Is "v_128x128" a re-writeable memory space (i.e. RAM)?
    • Is "v_128x128" an even address?
    • Is "pos" an even value (and/or in range of the buffer)?
    • Is "text" an even address?
    • Are the contents at the address of "text" in word size (i.e. not byte characters/ASCII)?
    • Is the length valid with a -1 taken into account for the first run?
    • Is the "copyTilemap" a working macro that isn't full of shit?
    • Are the values 27 and 2B meant to be -1 or does the actual macro already handle this for you resulting in confusion?
    I also feel that the "copyTilemap" there should be done after returning from that subroutine, that way you can do say:
    Code:
    DisplayMessage:	displayText	$0120,Hello,$0005
    	displayText	$0410,MyNameIs,$040
    	displayText	$0820,WhatsYours,$0030
    	copyTilemap	v_128x128,$C000,$27,$1B
    Without the screen being updated every single time. I may also recommend having the text fit with a terminating value (like an end marker) rather than specifying a size. And have the routine terminate when it comes across that marker, that may make things easier for you.
     
    Last edited by a moderator: Jan 17, 2015
  12. Kaz

    Kaz Well-Known Member Member

    Joined:
    Nov 2, 2013
    Messages:
    66
    1. v_128x128 = $FFFF0000, or Chunk_Table in Sonic 2.

    2. yes, v_128x128 is an even RAM address.

    3. "pos" has to be an even value, or the game crashes.

    4. "text" is an even address.

    5. The contents of "text" are in words. They are simply pointers to VRAM art.

    6. Not sure, but that might not effect anything but how much text the routine has to draw itself.

    7. CopyTilemap is a ShowVDPGraphics (TilemapToVRAM) macro, featured in SVN+ disasms of Sonic 1.

    With my params, this is how it looks unexpanded:




    lea ($FF0000).l,a1

    move.l #$40000003,d0

    moveq #$27,d1

    moveq #$1B,d2

    bsr.w TilemapToVRAM (ShowVDPGraphics)




    8. ..... you left me confused there.

    I'm stupid, I don't know how to do that.
     
    Last edited by a moderator: Jan 17, 2015
  13. StephenUK

    StephenUK Working on a Quackshot disassembly Administrator

    Joined:
    Aug 5, 2007
    Messages:
    992
    I'm sorry but is that kind of sarcastic response really necessary towards someone clearly trying to help you?
     
  14. Kaz

    Kaz Well-Known Member Member

    Joined:
    Nov 2, 2013
    Messages:
    66
    I'm sorry but is that kind of sarcastic response really necessary towards someone clearly trying to help you?




    Sorry.. for reasons, my OCD had to clearly tell him why he didn't understand what v_128x128 is.

    Edit: I finally got end markers working... but now the text is spaced out!

    [​IMG]


    Code:
    
    displayText: macro pos,text
    
    lea (v_128x128+pos).l,a1
    
    lea (text).l,a2
    
    @loop: cmpi.w  #'_',(a1)+       ; end marker?
    
    beq.s   @finish  ; if so, branch
    
    move.w (a2)+,(a1)+ ; load mappings
    
    bra.s   @loop
    
    @finish:
    
    endm
    
    
    
    
     


    CopyrightText:

    dc.w  $68B ; ©

    dc.w 0 ;

    dc.w  $682 ; 1

    dc.w  $680 ; 9

    dc.w  $681 ; 9

    dc.w  $685 ; 2

    dc.w 0 ;

    dc.w  $6A0 ; S

    dc.w  $692 ; E

    dc.w  $694 ; G

    dc.w  $68E ; A

    dc.w  '_'


     

    Aaaaaaargh....
     
    Last edited by a moderator: Jan 17, 2015
  15. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,820
    I'd say that v_128x128 was not cleared properly (or at all) before using it, hence the graphical defects on your screen. If the original emblem mappings are there, and those are the ones that are meant to display, then I'd say the art in VRAM has been shifted out of proportion.

    As for the macro:

    displayText: macro pos, text
    lea (v_128x128+pos).l,a1
    lea (text).l,a2
    move.w (a2)+,d0
    cmpi.w #'_',d0
    beq.s @Finish

    @Loop:
    move.w d0,(a1)+
    move.w (a2)+,d0
    cmpi.w #'_',d0
    bne.s @Loop

    @Finish:
    endmAnd no, I have never used the "GitHub Community Disasms".
    I try not to make assumptions about an equate, whose value can be changed by anyone at anytime to suit the needs of the hacker/programmer. You may very well decide to change it to another location for a specific reason. There may be a typo somewhere which has caused the equate value to shift out of spectrum (i.e. a 0 was erased from the end by yourself by mistake, resulting in $FFFF000 (68k address FFF000 (RAM F000 instead of 0000)). We can never afford to miss these types of mistakes. The questions were there to stir your curiosity so you'd go and double check, just to be sure, they were nothing more than rhetorical questions.

    I don't expect you to show the addresses you work with, nor do I expect you to listen to any ideas I may present. Likewise, please don't expect me to be using the same resources that you are using. I don't intend on having several disassembly variants on my computer to cover everyone, especially if it's a disassembly that's constantly changing. So when you present a name, always expect someone to query the definition of that name. A number is a number, but a name could be anything.

    I'm not having a pop here, or telling you how to act, that's your own freedom of choice, I'm just making sure here that you understand why I asked these questions. If you feel my posts are rather arrogant or unhelpful, then I'll refrain from posting in future.

    At any rate, sorry for the confusion.
     
  16. Kaz

    Kaz Well-Known Member Member

    Joined:
    Nov 2, 2013
    Messages:
    66
    Man I've been a dick to a lot of people lately, including my family..... Sorry about that, it's just that over break I haven't got a lot of sleep lately, and my OCD is acting up in some places....

    [​IMG]

    This picture is sort of related.
     
    Last edited by a moderator: Jan 18, 2015
  17. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    70
    Okay concerning my previous question, I've made some progress, I've got the object to move accordingly so it hits objects as it extends. However the process is kinda laggy, you can see the object flicker as it moves with each frame. Is there any way of tweaking this so the transition is less visible?:

    EDIT: Never mind. Fixed it by moving the animation script cues.
     
    Last edited by a moderator: Jan 19, 2015
  18. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    813
    Location:
    Portland, Maine
    After using the Sonic Retro "Port Sonic 3's Driver to Sonic 1" tutorial, I get this message and a window that says that asm68k.exe has stopped working:

    The instruction at 00402285 referenced memory at 00000004

    The memory could not be read from
     
    Last edited by a moderator: Jan 25, 2015
  19. Chaotix

    Chaotix Boredom Incarnate Member

    Joined:
    Aug 21, 2014
    Messages:
    190
    Location:
    Teufort
    I know this may be a silly question to ask, but how do I use the mid2smps program? And how can I test it on my hack? (Remember, this is someone who does not know a lot about how sonic hacks are made, I just like to play them :p)
     
  20. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    813
    Location:
    Portland, Maine
    Could someone please help with my problem? I am confused on what I can do to fix this.
     
    Last edited by a moderator: Jan 25, 2015