Basic Questions and Answers Thread

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

  1. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    Alright then, Hope it works for you. It was unused so who knows what it was originally or could have been.
     
  2. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Ok so after playing some Sonic 3D Flickies Island, I wanted to try something. Knowing that I would fail I thought that I would ask here first.


    How would I go about making my own PCM to replace the SEGA sound?
     
  3. rika_chou

    rika_chou Adopt Member

    Joined:
    Aug 11, 2007
    Messages:
    689
    IIRC, you can replace it with any wav file that is:


    "16000Hz mono


    8-bit unsigned


    PCM raw audio"


    So take any sound, get a program that can convert and save it, and you can just replace the old one. Though the sound clip you choose will have some quality loss.
     
  4. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    I have a question that seems small enough to ask here, I got my boost on it's own counter and made it so it subtracts 1 every time it runs so that if you don't have any you can't use it, it can be filled up by me either assigning something to $FFFFFFF6 from Regen's RAM Editor, or it going up by 1 when I collect a ring. However, here's the issue: my code is subtracting 1 from $FFFFFFF6 way too fast, and I hardly get anytime at all, I looked at how the underwater count decreases slowly, but I have no idea how it does that.


    Here's my code:



    Code:
    
    InitSonic_Boost:
    
      tst.b  ($FFFFFFF6).w ; does Sonic have any rings?
    
      bne.s  InitSonic_Boost2 ;If so branch
    
      rts
    
    
    
    InitSonic_Boost2:
    
      move.b  ($FFFFF602).w,d0						; load player 1held controls
    
      andi.b  #$10,d0
    
      bne.s   SetBoostByte				  ; If so, branch
    
      cmpi.b  #1,($FFFFFFE8).w			  ; Was Sonic in boost mode?
    
      beq.s   UnsetBoostByte				  ; If he was, branch
    
      rts													; Not in boost mode either, might as well end then
    
    
    
    SetBoostByte:
    
      move.b  #1,($FFFFFFE8).w			  ; Move 1 to counter, setting Sonic in boost mode
    
      move.b  #1,($FFFFFE2E).w			  ; Speed up the BG music
    
      move.w  #$C00,($FFFFF760).w	; Increase Sonic's top speed
    
      move.w  #$18,($FFFFF762).w	  ; Increase Sonic's acceleration
    
      move.b  #1,($FFFFFE2D).w ; make Sonic invincible
    
      subq.b  #1,($FFFFFFF6).w  ;subtract 1 from Boost Count
    
      cmpi.b  #0,($FFFFFFF6).w			  ; Does Sonic Have Boost?
    
      beq.s   UnsetBoostByte				  ; If he doesn't, branch
    
      move.w  #$E2,d0								; Move E2 to d0
    
      jmp	(PlaySound).l			 ; Speed up the music
    
    
    
    UnsetBoostByte:
    
      clr.b   ($FFFFFFE8).w			; Clear Sonic's boost counter
    
      move.w  #$600,($FFFFF760).w	; Restore Sonic's speed
    
      move.w  #$C,($FFFFF762).w		; Restore Sonic's acceleration
    
      clr.b  ($FFFFFE2D).w ; make Sonic vunerable
    
      clr.b   ($FFFFFE2E).w			; Cancel speed shoes
    
      move.w  #$E3,d0								; Move E3 to d0
    
      jmp (PlaySound).l						; Run music at normal speed
    
    

    Any Help will be greatly appreciated. :(


    P.S. (Credit to redhotsonic and MarkeyJester for helping me getting it to work in the first place, check my last thread to see the code they gave me and here to see what I added/edited)

    [/CODE]
     
    Last edited by a moderator: Jan 24, 2012
  5. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
     
    Last edited by a moderator: Jan 24, 2012
  6. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    vladikcomper: Thanks! It works great, I tried the first way and it wasn't working for me so I tried the second one and it worked perfectly, I made a video (Albeit with no sound because CamStudio doesn't like recording sound, but I wanted to show the RAM Counter because I haven't found a way to make the counter show in game as of yet. However since my internet connection is horribly slow, I will be uploading the video after I get home from school today. Although If you want I'll put these files on my desktop and record from there since apparently a microphone on my desktop outputs sound, if anyone wants to hear sound. Personally I don't think it makes a difference, since you know the routines working if you see the RAM Counter, but Music speed up is part of the routine, so tell me what you would like me to do and I'll do it when I get home.
     
  7. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Any ideas for programs that can do this?
     
  8. SSGD

    SSGD "I can't believe what cool boots you have on!" Member

    Joined:
    Nov 14, 2011
    Messages:
    125
    Location:
    Room 101
    You can either use Windows sound recorder (what I used for my replacement of the SEGA sound) or for something of a more worthwhile sound editing program, try Audacity. Just change the sound format options when saving the file to whats needed.
     
  9. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    How do I change what palette line an object uses?
     
  10. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    I'm sure the WAV file must be 24,000 bytes or less (according to one program anyway, can't remember what that program was though)
     
  11. rika_chou

    rika_chou Adopt Member

    Joined:
    Aug 11, 2007
    Messages:
    689
    You can change it in the mappings, or in the object code.



    move.w #$YXXX,2(a0)



    Y = palette line (0 = line 1, 2 = line 2, 4 = line 3, 6 = line 4)


    XXX = VRAM
     
    Last edited by a moderator: Jan 24, 2012
  12. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    Don't forget to get rid of the header (can be done in a hex editor) or else there will be a click sound before the sound starts.

    This is changed in the line where the game loads the art. I'd have to look it up to tell you exactly, but Yxxx,(RAM ADDRESS), iirc it's the Y that changes the line.
     
    Last edited by a moderator: Jan 24, 2012
  13. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    @rika_chou Well I changed this:




    Obj0E_Main: ; XREF: Obj0E_Index


    addq.b #2,$24(a0)


    move.w #$F0,8(a0)


    move.w #$DE,$A(a0)


    move.l #Map_obj0E,4(a0)


    move.w #$1300,2(a0)


    move.b #1,$18(a0)


    move.b #29,$1F(a0) ; set time delay to 0.5 seconds


    lea (Ani_obj0E).l,a1


    bsr.w AnimateSprite



    But then I get this in game:


    [​IMG]


    Do I have to change it in the mappings? And if so can I do this in SonMapEd?
     
  14. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    You maybe able to get away with it in SonMapED. Just load the art, maps,palette and then press P to switch palette lines. Then when happy with the line your on save palette. You may need to save the tile and mappings so that the art picks up the palette line change.
     
  15. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    move.w #$1300,2(a0)


    is the line, What did it say beforehand? It's tricky to get it working at first. 1 is the digit you want to change, following this format:


    0 = line 1


    2 = line 2


    4 = line 3


    6 = line 4


    if you want it the first palette line you'd need it at 2 and not 1
     
  16. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks guys it works now!
     
  17. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    I'm trying to make it so that in the Game if you lose a Special Stage the game won't go ahead and go to the next one. However I get this Error right here when building:



    Code:
    
    SN 68k version 2.53
    
    C:\USERS\...\SONIC1.ASM<35874> : Error
    
    : Illegal Value (-222)
    
    lea ss_startloc(pc,d0.w),a1
    
    C:\USERS\...\SONIC1.ASM<35877> : Error
    
    : Illegal Value (-256)
    
    movea.ll ss_layoutindex(pc,d0.w),a0
    
    Errors during pass 1 - pass 2 aborted
    
    Assembly completed.
    
    2 Error(s) from 49472 lines in 0.83 seconds
    
    Lightnings's ROM Padder
    
    Reported Size: 0					 Reported Checksum: 0
    
    Size applied:  7F					 Checksum Applied: 0
    
    


    Here's my code:



    Code:
    
    SS_Load:    ; XREF: SpecialStage
    
      ;moveq #0,d0
    
      cmpi.b #0,($FFFFFE57).w ;Does Sonic have no Emerarlds?
    
      bne.s SS_SpecialStageNum1 ;If So, branch
    
      cmpi.b #1,($FFFFFE57).w ;Does Sonic have 1 Emerald?
    
      bne.s SS_SpecialStageNum2 ;If So, branch
    
      cmpi.b #2,($FFFFFE57).w ;Does Sonic have 2 Emeralds?
    
      bne.s SS_SpecialStageNum3 ;If So, branch
    
      cmpi.b #3,($FFFFFE57).w ;Does Sonic have 3 Emeralds?
    
      bne.s SS_SpecialStageNum4 ;If So, branch
    
      cmpi.b #4,($FFFFFE57).w ;Does Sonic have 4 Emeralds?
    
      bne.s SS_SpecialStageNum5 ;If So, branch
    
      cmpi.b #5,($FFFFFE57).w ;Does Sonic have 5 Emeralds?
    
      bne.s SS_SpecialStageNum6 ;If So, branch
    
      cmpi.b #6,($FFFFFE57).w ;Does Sonic have 6 Emeralds?
    
      bne.s SS_ChkEmldNum
    
      ;move.b ($FFFFFE16).w,d0 ; load number of last special stage entered
    
      ;cmpi.b #6,($FFFFFE16).w
    
      ;addq.b #1,($FFFFFE16).w
    
      ;cmpi.b #6,($FFFFFE16).w
    
      ;bcs.s SS_ChkEmldNum
    
      move.b #0,($FFFFFE16).w ; reset if higher than 6
    
     
    
    SS_SpecialStageNum1:
    
      move.b #1,($FFFFFE16).w
    
      move.b ($FFFFFE16).w,d0
    
      jmp SS_LoadData
    
    SS_SpecialStageNum2:
    
      move.b #2,($FFFFFE16).w
    
      move.b ($FFFFFE16).w,d0
    
      jmp SS_LoadData
    
     
    
    SS_SpecialStageNum3:
    
      move.b #3,($FFFFFE16).w
    
      move.b ($FFFFFE16).w,d0
    
      jmp SS_LoadData
    
     
    
    SS_SpecialStageNum4:
    
      move.b #4,($FFFFFE16).w
    
      move.b ($FFFFFE16).w,d0
    
      jmp SS_LoadData
    
     
    
    SS_SpecialStageNum5:
    
      move.b #5,($FFFFFE16).w
    
      move.b ($FFFFFE16).w,d0
    
      jmp SS_LoadData
    
    SS_SpecialStageNum6:
    
      move.b #6,($FFFFFE16).w
    
      move.b ($FFFFFE16).w,d0
    
      jmp SS_LoadData
    
     
    
    SS_ChkEmldNum:
    
      cmpi.b #6,($FFFFFE57).w ; do you have all emeralds?
    
      beq.s SS_LoadData ; if yes, branch
    
      moveq #0,d1
    
      move.b ($FFFFFE57).w,d1
    
      subq.b #1,d1
    
      bcs.s SS_LoadData
    
      lea ($FFFFFE58).w,a3 ; check which emeralds you have
    
    SS_ChkEmldLoop:
    
      cmp.b (a3,d1.w),d0
    
      bne.s SS_ChkEmldRepeat
    
      jmp SS_Load
    
    ; ===========================================================================
    
    SS_ChkEmldRepeat:
    
      dbf d1,SS_ChkEmldLoop
    
    SS_LoadData:
    
      lsl.w #2,d0
    
      lea SS_StartLoc(pc,d0.w),a1
    
      move.w (a1)+,($FFFFD008).w
    
      move.w (a1)+,($FFFFD00C).w
    
      movea.l SS_LayoutIndex(pc,d0.w),a0
    
      lea ($FF4000).l,a1
    
      move.w #0,d0
    
      jsr (EniDec).l
    
      lea ($FF0000).l,a1
    
      move.w #$FFF,d0
    
    SS_ClrRAM3:
    
      clr.l (a1)+
    
      dbf d0,SS_ClrRAM3
    
      lea ($FF1020).l,a1
    
      lea ($FF4000).l,a0
    
      moveq #$3F,d1
    
    loc_1B6F6:
    
      moveq #$3F,d2
    
    loc_1B6F8:
    
      move.b (a0)+,(a1)+
    
      dbf d2,loc_1B6F8
    
      lea $40(a1),a1
    
      dbf d1,loc_1B6F6
    
      lea ($FF4008).l,a1
    
      lea (SS_MapIndex).l,a0
    
      moveq #$4D,d1
    
    loc_1B714:
    
      move.l (a0)+,(a1)+
    
      move.w #0,(a1)+
    
      move.b -4(a0),-1(a1)
    
      move.w (a0)+,(a1)+
    
      dbf d1,loc_1B714
    
      lea ($FF4400).l,a1
    
      move.w #$3F,d1
    
    loc_1B730:
    
      clr.l (a1)+
    
      dbf d1,loc_1B730
    
      rts
    
    ; End of function SS_Load
    
    

    I have no clue why this is happening, so any help would be GREATLY Appreciated! :)

    [/CODE]
     
  18. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    Well, what's at those lines that the assembler is saying are borked up?
     
  19. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Basically, this happens if label goes too far from the instruction that refers to it.


    These commands use addressing mode d8(pc,dn). The effective address is calculated adding PC (program counter, an offset of the current instruction), the contents of a data register and 8-bit displacement.


    Displacement is short type, it can take values $-80...$7F (-128...127 is decimal). This means the label used as displacement can only be THIS far from the instruction itself, if it isn't, the Illegal value error occurs.


    As you have added a lot of new code there, these labels became too far from the instructions, so the displacement value isn't reachable.


    There is a generic way to fix this kind of errors.


    Replace



    lea ss_startloc(pc,d0.w),a1



    with



    lea SS_StartLoc(pc),a1
    adda.w d0,a1



    Replace



    movea.l ss_layoutindex(pc,d0.w),a0



    with



    movea.l SS_LayoutIndex(pc),a0
    adda.w d0,a0



    The first instruction in every example uses d16(pc) addressing mode, where d16 is 16-bit displacement, therefore your label can be -$8000...$7FFF bytes far from instruction offset ($8000 bytes is 32 Kilobytes by the way!).


    As I said, the way I just described is generic, but it's always better to do the things properly. This issue is often avoided by optimizing code or moving instructions closer to labels (if possible).


    Branches you used for every number of emeralds can be replaced with simply copying one memory byte to another like this:



    move.b ($FFFFFE57).w,($FFFFFE16).w ; move the value of address $FFFE57 to $FFFE16



    However, I'm not sure what you're trying to do with this code, I don't know SS code well either. I only can point out that branches you've used are incorrect, they won't work as comments say. BNE after a CMP means "branch is not equal", I know it's easy to confuse with its meaning below TST for beginners.


    Also "jmp SS_LoadData" is a bit odd here. SS_LoadData is near from this code as line "beq.s SS_LoadData" shows, so you'd better replace JMP with BRA.S.
     
  20. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    vladikcomper: I was trying to make it so if You lose a Special Stage it doesn't advance you to the next stage as I plan on editing the Special Stage layout later. Your fix worked initially but It had a problem, after the first special stage all the other Special Stages loaded Garbage or froze. I looked at how you said it was a "generic" fix. So I looked at the code and saw that "SS_StartLoc" and "SS_LayoutIndex" were before the SS_Load routine, meaning those lines basically had to loop almost the WHOLE ENTIRE ROM ​before getting to their destination. I fixed this and put the "SS_StartLoc" and "SS_LayoutIndex" routines almost right after these lines and I also put these lines back to their original state:



    Code:
    
    lea SS_StartLoc(pc,d0.w),a1
    
    


    Code:
    
    movea.l SS_LayoutIndex(pc,d0.w),a0
    
    

    , I also had to tweak the code a little to get this to work ( As shown in one of the comments on the code) but In the end I got it to work correctly. However, I did use your line which copies the emerald count into the Special Stage count in RAM, and it works as expected ( I really never though of doing that! :eek: ).

    So Here's my final SS_Load Subroutine:

    Code:
    
    ---------------------------------------------------------------------------
    
    ; Subroutine to load special stage layout
    
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    
    SS_Load:	; XREF: SpecialStage
    
      cmpi.b #0,($FFFFFE57).w ;Does Sonic have no Emerarlds?
    
      beq.s SS_SpecialStageNumLoad ;If So, branch
    
      cmpi.b #1,($FFFFFE57).w ;Does Sonic have 1 Emerald?
    
      beq.s SS_SpecialStageNumLoad ;If So, branch
    
      cmpi.b #2,($FFFFFE57).w ;Does Sonic have 2 Emeralds?
    
      beq.s SS_SpecialStageNumLoad ;If So, branch
    
      cmpi.b #3,($FFFFFE57).w ;Does Sonic have 3 Emeralds?
    
      beq.s SS_SpecialStageNumLoad ;If So, branch
    
      cmpi.b #4,($FFFFFE57).w ;Does Sonic have 4 Emeralds?
    
      beq.s SS_SpecialStageNumLoad ;If So, branch
    
      cmpi.b #5,($FFFFFE57).w ;Does Sonic have 5 Emeralds?
    
      beq.s SS_SpecialStageNumLoad ;If So, branch
    
      cmpi.b #6,($FFFFFE57).w ;Does Sonic have 6 Emeralds?
    
      beq.s SS_ChkEmldNum
    
      move.b #0,($FFFFFE16).w ; reset if higher than 6
    
    
    
    SS_SpecialStageNumLoad:
    
      move.b  ($FFFFFE57).w,($FFFFFE16).w   ; move the value of address $FFFE57 to $FFFE16
    
      move.b ($FFFFFE16).w,d0
    
      bra.s  SS_LoadData
    
    
    
    SS_ChkEmldNum:
    
      cmpi.b #6,($FFFFFE57).w ; do you have all emeralds?
    
      beq.s SS_LoadData ; if yes, branch
    
      moveq #0,d1
    
      move.b ($FFFFFE57).w,d1
    
      subq.b #1,d1
    
      bcs.s SS_LoadData
    
      lea ($FFFFFE58).w,a3 ; check which emeralds you have
    
    SS_ChkEmldLoop:
    
      cmp.b (a3,d1.w),d0
    
      bne.s SS_ChkEmldRepeat
    
      jmp SS_Load
    
    ; ===========================================================================
    
    SS_ChkEmldRepeat:
    
      dbf d1,SS_ChkEmldLoop
    
    SS_LoadData:
    
      lsl.w #2,d0
    
      lea SS_StartLoc(pc,d0.w),a1
    
      move.w (a1)+,($FFFFD008).w
    
      move.w (a1)+,($FFFFD00C).w
    
      movea.l SS_LayoutIndex(pc,d0.w),a0
    
      lea ($FF4000).l,a1
    
      move.w #0,d0
    
      jsr (EniDec).l
    
      lea ($FF0000).l,a1
    
      move.w #$FFF,d0
    
      jmp SS_ClrRAM3 ;Yes This has to be jmp, because when I tried bra.s the game crashed upon loading a special stage
    
    
    
    ;----------------
    
    SS_StartLoc: incbin miscsloc_ss.bin
    
      even
    
    
    
    SS_LayoutIndex:
    
    include "_incSpecial stage layout pointers.asm"
    
    ;--------------------
    
    SS_ClrRAM3:
    
      clr.l (a1)+
    
      dbf d0,SS_ClrRAM3
    
      lea ($FF1020).l,a1
    
      lea ($FF4000).l,a0
    
      moveq #$3F,d1
    
    loc_1B6F6:
    
      moveq #$3F,d2
    
    loc_1B6F8:
    
      move.b (a0)+,(a1)+
    
      dbf d2,loc_1B6F8
    
      lea $40(a1),a1
    
      dbf d1,loc_1B6F6
    
      lea ($FF4008).l,a1
    
      lea (SS_MapIndex).l,a0
    
      moveq #$4D,d1
    
    loc_1B714:
    
      move.l (a0)+,(a1)+
    
      move.w #0,(a1)+
    
      move.b -4(a0),-1(a1)
    
      move.w (a0)+,(a1)+
    
      dbf d1,loc_1B714
    
      lea ($FF4400).l,a1
    
      move.w #$3F,d1
    
    loc_1B730:
    
      clr.l (a1)+
    
      dbf d1,loc_1B730
    
      rts
    
    
    
    ; End of function SS_Load
    
    
    And If it's alright with you vladikcomper can I make a tutorial of how to do this (as you helped me with it) :)


    Thanks for the help, and I swear this was a lot easier than trying to add the boost (Which isn't done) :)

    [/CODE]
     
    Last edited by a moderator: Jan 28, 2012