Basic Questions and Answers Thread

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

  1. Renegade

    Renegade RuthlessTheHooman Member

    Joined:
    Nov 20, 2016
    Messages:
    60
    Location:
    New York Desert
    There was a guide for the Flamewing Driver in S1, but it's text was just placeholder.
     
  2. Tanner

    Tanner I play video games and do computer stuff! Member

    Joined:
    Dec 23, 2016
    Messages:
    46
    So, after trying to build with the Sonic 2 Clone Driver v2, I almost made it build!
    But after try and try again, this happens.
    And here's the error log, which makes it even more confusing.
    I'm not sure what to do to fix it, as Size_of_Mega_PCM isn't anywhere in Sonic 2 Clone Driver v2 Comp's ASM, nor is a reference to it made anywhere in the code.
    My Clone_Driver_RAM is set to $0ADD if it helps.
    EDIT: Also, no idea why it re-executes the ASMs as if the sound driver was loaded twice, as I only declared it once where the tutorial told me to call it.
     
  3. Clownacy

    Clownacy UP - ON - CPU Staff

    Joined:
    Aug 15, 2014
    Messages:
    842
    Whoops. It's in MegaPCM - 68k.asm, not Compatibility.asm.
     
  4. Tanner

    Tanner I play video games and do computer stuff! Member

    Joined:
    Dec 23, 2016
    Messages:
    46
    Thanks! Honestly I was scratching my head for a while figuring out what I did wrong.
    EDIT: Found it, and a new problem arises: The error log asks for $84A of room. How would I do this exactly if the !org is adding both together? Could I just hard hardcode it?
    I'm use to how Sonic 2 SMS hardcodes the sizes, hence why I'm asking.
     
    Last edited: Nov 19, 2018
  5. Clownacy

    Clownacy UP - ON - CPU Staff

    Joined:
    Aug 15, 2014
    Messages:
    842
    The org is adding the size to the address where MegaPCM starts.
     
  6. Tanner

    Tanner I play video games and do computer stuff! Member

    Joined:
    Dec 23, 2016
    Messages:
    46
    I finally found the variable that changes the address to what it wants and it compiles.
    But it compiles to a black screen and doesn't do anything else.
    I think the log is hinting at me what's wrong, would you know why it's doing this Clownacy?
    Code:
    > > >sound/Sonic 2 Clone Driver v2 - Functions.asm(70) SMPS_STOPZ80_SAFE(1): warning: address is not properly aligned
    > > >         move.w  sr,(Clone_Driver_RAM+SMPS_RAM.Saved_SR).w
    > > >sound/Sonic 2 Clone Driver v2 - Functions.asm(73) SMPS_STARTZ80_SAFE(2): warning: address is not properly aligned
    > > >         move.w  (Clone_Driver_RAM+SMPS_RAM.Saved_SR).w,sr
    > > >sound/Sonic 2 Clone Driver v2 - Functions.asm(70) SMPS_STOPZ80_SAFE(1): warning: address is not properly aligned
    > > >         move.w  sr,(Clone_Driver_RAM+SMPS_RAM.Saved_SR).w
    > > >sound/Sonic 2 Clone Driver v2 - Functions.asm(73) SMPS_STARTZ80_SAFE(2): warning: address is not properly aligned
    > > >         move.w  (Clone_Driver_RAM+SMPS_RAM.Saved_SR).w,sr
    
     
  7. Novedicus

    Novedicus Well-Known Member Member

    Joined:
    Aug 26, 2013
    Messages:
    857
    Either the instruction is being written to an odd address or "CloneDriver_RAM+SMPS_RAM.Saved_SR" is at an odd address.
     
    MarkeyJester likes this.
  8. Renegade

    Renegade RuthlessTheHooman Member

    Joined:
    Nov 20, 2016
    Messages:
    60
    Location:
    New York Desert
    Alrighty, question time I guess.

    Basically, I want to make the hud in S1 flicker like in S3K rather than going red.
    The problem is, I don't know where I should be looking.

    I'm assuming it involves editing the mappings, but since I use Hivebrain, I have no idea where the mappings are.
    To add onto this, I don't know how I'd delete individual sprite pieces.

    Anyway, thanks in advance for any help.
     
  9. StephenUK

    StephenUK Working on a Quackshot disassembly Administrator

    Joined:
    Aug 5, 2007
    Messages:
    959
    The quickest way is to open the HUD mappings and cycle through the frames deleting the pieces that are highlighted red. That will mean that every time the red is supposed to be displayed, it'll now be blank and so will simulate the flashing effect. I'm not familiar with Sonic 1 so I'm not sure on exact locations, but for editing them you can use SonMapEd or Flex 2, both of which are documented both here and on Sonic Retro to help you learn how to use them.
     
  10. Renegade

    Renegade RuthlessTheHooman Member

    Joined:
    Nov 20, 2016
    Messages:
    60
    Location:
    New York Desert
    I don't know how to delete pieces of a sprite on SonMapED.

    I'll try again later, but I don't know if it'll work.
     
  11. MarkeyJester

    MarkeyJester !%#@ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,660
    Looks like Stephen ninja'd me, so I guess instead I'll elaborate on the mappings themselves.

    The HUD in Sonic 1 is an object (object 21). The mappings for the object are in "_maps\obj21.asm".

    Once opened with a text editor, you will see:
    Code:
    ; ---------------------------------------------------------------------------
    ; Sprite mappings - SCORE, TIME, RINGS
    ; ---------------------------------------------------------------------------
    		dc.w byte_1C5BC-Map_obj21, byte_1C5F0-Map_obj21
    		dc.w byte_1C624-Map_obj21, byte_1C658-Map_obj21
    byte_1C5BC:	dc.b $A
    		dc.b $80, $D, $80, 0, 0
    		dc.b $80, $D, $80, $18,	$20
    		dc.b $80, $D, $80, $20,	$40
    		dc.b $90, $D, $80, $10,	0
    		dc.b $90, $D, $80, $28,	$28
    		dc.b $A0, $D, $80, 8, 0
    		dc.b $A0, 1, $80, 0, $20
    		dc.b $A0, 9, $80, $30, $30
    		dc.b $40, 5, $81, $A, 0
    		dc.b $40, $D, $81, $E, $10
    		dc.b 0
    byte_1C5F0:	dc.b $A
    		dc.b $80, $D, $80, 0, 0
    		dc.b $80, $D, $80, $18,	$20
    		dc.b $80, $D, $80, $20,	$40
    		dc.b $90, $D, $80, $10,	0
    		dc.b $90, $D, $80, $28,	$28
    		dc.b $A0, $D, $A0, 8, 0
    		dc.b $A0, 1, $A0, 0, $20
    		dc.b $A0, 9, $80, $30, $30
    		dc.b $40, 5, $81, $A, 0
    		dc.b $40, $D, $81, $E, $10
    		dc.b 0
    byte_1C624:	dc.b $A
    		dc.b $80, $D, $80, 0, 0
    		dc.b $80, $D, $80, $18,	$20
    		dc.b $80, $D, $80, $20,	$40
    		dc.b $90, $D, $A0, $10,	0
    		dc.b $90, $D, $80, $28,	$28
    		dc.b $A0, $D, $80, 8, 0
    		dc.b $A0, 1, $80, 0, $20
    		dc.b $A0, 9, $80, $30, $30
    		dc.b $40, 5, $81, $A, 0
    		dc.b $40, $D, $81, $E, $10
    		dc.b 0
    byte_1C658:	dc.b $A
    		dc.b $80, $D, $80, 0, 0
    		dc.b $80, $D, $80, $18,	$20
    		dc.b $80, $D, $80, $20,	$40
    		dc.b $90, $D, $A0, $10,	0
    		dc.b $90, $D, $80, $28,	$28
    		dc.b $A0, $D, $A0, 8, 0
    		dc.b $A0, 1, $A0, 0, $20
    		dc.b $A0, 9, $80, $30, $30
    		dc.b $40, 5, $81, $A, 0
    		dc.b $40, $D, $81, $E, $10
    		even
    There are four frames, each frame represents a circumstance for the HUD:

    The first frame "byte_1C5BC" being all yellow.
    The second frame "byte_1C5F0" being identical except for "RINGS" being red.
    The third frame "byte_1C624" being identical except for "TIME" being red.
    The fourth frame "byte_1C658" being identical except both "RINGS" and "TIME" being red.

    Each one starts with a "dc.b $A", this represents the number of sprites in the list (you will notice there are 10 lines below each one (ignoring the "dc.b 0" on the bottom which is a useless even padding), 10 is $A in hex), each line represents "dc.b Y, S, V1, V2, X":

    Y = Y relative position of sprite (00 = centre | FF, FE, FD... ...80 = upwards with 80 being highest | 01, 02, 03... 7F = downards with 7F being the lowest).
    X = X relative position of sprite (00 = centre | FF, FE, FD... ...80 = left with 80 being furthest to the left | 01, 02, 03... 7F = right with 7F being furthest to the right).
    S = Shape of sprite (0 - F), you can break this into binary XXYY where XX is the number of tiles horizontally and YY is the number of tiles vertically (00 = 1 tile | 01 = 2 tiles | 10 = 3 tiles | 11 = 4 tiles).
    V1 + V2 = pattern index (tile, palette, flip, mirror, etc).

    Taking the first sprite of the first frame, you have "dc.b $80, $D, $80, 0, 0", so the values are:

    Y = $80 (So it's quite high)
    X = 0 (middle of the object horizontally)
    S = D (in binary 1101) this is four tiles horizontally and 2 tiles vertically.
    V1 + V2 = 80 + 0 (together as 8000), this is a common standard pattern index for the Mega Drive, the binary format for this is PCCF MVVV VVVV VVVV (P = priority, 0 = low, 1 = high | CC = palette line to use, 00 = line 1, 01 = line 2, 10 = line 3, 11 = line 4 | F = flip, 0 = no, 1 = yes | M = mirror, 0 = no, 1 = yes | V's together represent the tile number, from 000 to 7FF, this is relative to the object's pattern index (i.e. added to)), so this is using tile 0 (relative to the object), is not flipped or mirrored, is using palette line 1, and is high plane (to remain in-front of everything on-screen).

    This single sprite will display the tiles for "SCOR" (without the "E"), the next sprite in the list will display the "E" and three numbers after it (these numbers are usually invisible until the score is high enough), the next sprite in the list after this will be the final four numbers of the score (of which the very last number can be seen on start as you start with "0" score).

    The first three sprites all have Y positions at $80, because they are all on the same line "SCORE-------0". The next two after this will be for "TIME" and "0:00". The next three after this will be for "RING" "S" and "--0". Finally, the last two in the list will be for the Sonic icon and his lives counter.

    Now, all four frames appear to be the same, and appear to almost have identical frames, except, some of the frames have some sprites where the "V1" value is $A0 instead of $80, this is because the pattern index's palette line number is 01 for line 2, instead of 00 for line 1. This is the same text, except using a different palette line, when this text is using the second palette line, it appears "red" because of the colours in that line.

    Looking at the second frame (I have commented the lines for clarity):
    Code:
    byte_1C5F0:	dc.b $A
    		dc.b $80, $D, $80, 0, 0			; "SCOR"
    		dc.b $80, $D, $80, $18,	$20		; "E---"
    		dc.b $80, $D, $80, $20,	$40		; "---0"
    		dc.b $90, $D, $80, $10,	0		; "TIME"
    		dc.b $90, $D, $80, $28,	$28		; "0:00"
    		dc.b $A0, $D, $A0, 8, 0			; "RING"
    		dc.b $A0, 1, $A0, 0, $20		; "S"
    		dc.b $A0, 9, $80, $30, $30		; "--0"
    		dc.b $40, 5, $81, $A, 0			; Sonic's life icon (from monitors)
    		dc.b $40, $D, $81, $E, $10		; The "SONIC", "x" and life numbers
    If you want to remove the "RINGS" (and the numbers) which are displaying in red, then simply delete those three lines for rings (the "RING", "S" and "--0" lines), these three sprites once erased from the list, you will need to decrease the sprite counter on that first line (the $A) by 3. $A - 3 = 7, so you should have as a result:
    Code:
    byte_1C5F0:	dc.b 7
    		dc.b $80, $D, $80, 0, 0			; "SCOR"
    		dc.b $80, $D, $80, $18,	$20		; "E---"
    		dc.b $80, $D, $80, $20,	$40		; "---0"
    		dc.b $90, $D, $80, $10,	0		; "TIME"
    		dc.b $90, $D, $80, $28,	$28		; "0:00"
    		dc.b $40, 5, $81, $A, 0			; Sonic's life icon (from monitors)
    		dc.b $40, $D, $81, $E, $10		; The "SONIC", "x" and life numbers
    You can do the same for when the timer is flashing (the third frame), and for when both the rings and time are flashing (the fourth frame), in the same manner.
     
  12. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    281
    Location:
    Buffalo, NY, USA
    Oddly enough, I also have a HUD related issue. In the Special Stage, I've been attempting to load the ring counter portion of the HUD, and I've gotten the 'RINGS' text itself to load fine. I'm just having problems loading the uncompressed numbers themselves. I eventually tried creating a new subroutine (which somewhat emulates how Hud_Update does it) that at least loads the numbers (and calling for it right before the Special Stage Loop, but they aren't quite appearing at all:

    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine to    load ringcount in Special Stages
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    SSRing_HudNumbers:
    
            clr.b    (f_ringcount).w
            locVRAM    $F2E0        ; set VRAM address
            moveq    #0,d1
            move.w    (v_rings).w,d1    ; load number of rings
            lea    (Hud_100).l,a2
            moveq    #2,d6
            moveq    #0,d4
            lea    Art_Hud(pc),a1
            
            rts
    
    Not very experienced with loading art, so can anyone shed some light on how I should be doing this? Thanks in advance.
     
  13. StephenUK

    StephenUK Working on a Quackshot disassembly Administrator

    Joined:
    Aug 5, 2007
    Messages:
    959
    I haven't tested this, it's purely based on theory, but can you not just load the HUD during special stage initialization as you would when loading a normal zone, and have a check in the HUD object to utilise a different mappings file based on the game mode so it only displays what you want it to? It sounds like a much more simple approach than trying to write specific routine to handle what is effectively the same function.
     
    EMK-20218 likes this.
  14. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    281
    Location:
    Buffalo, NY, USA
    That is how I loaded the 'RINGS' art, but the numbers themselves are handled differently, since they're uncompressed, right? I wanted to load the numbers after the HUD object, but the lea command couldn't reach. So I in turn jumped to that new subroutine to do it.
     
  15. Novedicus

    Novedicus Well-Known Member Member

    Joined:
    Aug 26, 2013
    Messages:
    857
    Just an FYI, that (pc) in that LEA instruction makes it relative. To make it absolute, remove the (pc), and it should reach.
     
    TheInvisibleSun and maple_t like this.
  16. FireRat

    FireRat "The grand imitator..." Member

    Joined:
    Oct 31, 2009
    Messages:
    529
    have the special stage's init do a call to Hud_Base, and add the VInt function a call to Hud_Update. Not sure about this, but alternatively you might just set the ring update flag when you have zero as well (not needing Hud_Base).
     
  17. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    281
    Location:
    Buffalo, NY, USA
    Thanks for the responses so far! Unfortunately, it's still not responding. I forgot to mention that this is for Sonic 1 Git, so this is my init code:


    Code:
    ; ---------------------------------------------------------------------------
    ; Special Stage
    ; ---------------------------------------------------------------------------
    
    GM_Special:                ; XREF: GameModeArray
            move.w    #sfx_EnterSS,d0
            bsr.w    PlaySound_Special ; play special stage entry sound
            bsr.w    PaletteWhiteOut
            disable_ints
            lea    (vdp_control_port).l,a6
            move.w    #$8B03,(a6)    ; line scroll mode
            move.w    #$8004,(a6)    ; 8-colour mode
            move.w    #$8A00+175,(v_hbla_hreg).w
            move.w    #$9011,(a6)    ; 128-cell hscroll size
            move.w    (v_vdp_buffer1).w,d0
            andi.b    #$BF,d0
            move.w    d0,(vdp_control_port).l
            bsr.w    ClearScreen
            jsr    Hud_Base       ; Added Code
    
            enable_ints
            fillVRAM    0,$6FFF,$5000
    
        SS_WaitForDMA:
            move.w    (a5),d1        ; read control port ($C00004)
            btst    #1,d1        ; is DMA running?
            bne.s    SS_WaitForDMA    ; if yes, branch
            move.w    #$8F02,(a5)    ; set VDP increment to 2 bytes
            bsr.w    SS_BGLoad
            moveq    #plcid_SpecialStage,d0
            bsr.w    QuickPLC    ; load special stage patterns
    
            lea    (v_objspace).w,a1
            moveq    #0,d0
            move.w    #$7FF,d1
        SS_ClrObjRam:
            move.l    d0,(a1)+
            dbf    d1,SS_ClrObjRam    ; clear    the object RAM
    
            lea    (v_screenposx).w,a1
            moveq    #0,d0
            move.w    #$3F,d1
        SS_ClrRam1:
            move.l    d0,(a1)+
            dbf    d1,SS_ClrRam1    ; clear    variables
    
            lea    (v_oscillate+2).w,a1
            moveq    #0,d0
            move.w    #$27,d1
        SS_ClrRam2:
            move.l    d0,(a1)+
            dbf    d1,SS_ClrRam2    ; clear    variables
    
            lea    (v_ngfx_buffer).w,a1
            moveq    #0,d0
            move.w    #$7F,d1
        SS_ClrNemRam:
            move.l    d0,(a1)+
            dbf    d1,SS_ClrNemRam    ; clear    Nemesis    buffer
    
            clr.b    (f_wtr_state).w
            clr.w    (f_restart).w
    
    
            jsr    Hud_Update     ;Added Code
            move.b    #id_HUD,(v_objspace+$40).w ; load HUD object. Added Code
           
           
    
            moveq    #palid_Special,d0
            bsr.w    PalLoad1    ; load special stage palette
            jsr    SS_Load        ; load SS layout data
            move.l    #0,(v_screenposx).w
            move.l    #0,(v_screenposy).w
            move.b    #9,(v_objspace).w ; load special stage Sonic object
            bsr.w    PalCycle_SS
            clr.w    (v_ssangle).w    ; set stage angle to "upright"
            move.w    #$0,(v_ssrotate).w ; set stage rotation speed
            move.w    #bgm_SS,d0
            bsr.w    PlaySound    ; play special stage BG    music
            move.w    #0,(v_btnpushtime1).w
            lea    (DemoDataPtr).l,a1
            moveq    #6,d0
            lsl.w    #2,d0
            movea.l    (a1,d0.w),a1
            move.b    1(a1),(v_btnpushtime2).w
            subq.b    #1,(v_btnpushtime2).w
            clr.w    (v_rings).w
            clr.b    (v_lifecount).w
            move.w    #0,(v_debuguse).w
            move.w    #1800,(v_demolength).w
            tst.b    (f_debugcheat).w ; has debug cheat been entered?
            beq.s    SS_NoDebug    ; if not, branch
            btst    #bitA,(v_jpadhold1).w ; is A button pressed?
            beq.s    SS_NoDebug    ; if not, branch
            move.b    #1,(f_debugmode).w ; enable debug mode
    
        SS_NoDebug:
            move.w    (v_vdp_buffer1).w,d0
            ori.b    #$40,d0
            move.w    d0,(vdp_control_port).l
    
            bsr.w    PaletteWhiteIn
    

    Calling for Hud_Base right before the hud object instead causes a little graphical garbling in the bubble art (likely a vram issue). I don't quite understand how it works; I tried playing around with the VRAM addresses in Hud_Base, but it just collides with other art.
     
  18. Samey

    Samey Newcomer Member

    Joined:
    May 3, 2017
    Messages:
    22
    This has had me scratching my head for an eternity, but how would I fix the fm6 restoration bug with Mega Pcm..?
    I'm using the Hivebrain 2005 disassembly.

    I've been trying to get this guide to work with it:
    http://info.sonicretro.org/SCHG_How-to:Fix_Song_Restoration_Bugs_in_Sonic_1's_Sound_Driver

    the part of it thats simply not working is FM6 doesn't fade back in like its supposed to.
    I've also went to the MegaPCM guide to see if I could find any clues for my problem but nothing.
    :confused: Frankly, I have absolutely no idea why the fm6 isn't coming back in the special stages, even though I put in the fix.

    ...maybe there is another routine that does the job of loc_72B78? Honestly, if its not that I don't know.


    Edit: Also, secondary question, what program would I use to edit the mapping files in mapeni folder? (for instance, the SEGA logo's mappings?
    They dont seem to open in SonMapEd. :(
     
    Last edited: Nov 24, 2018
  19. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    299
    Location:
    Australia
    I dunno how the batman game does it, but the closest thing to a flanger effect i can think of to do in SMPS is to play the same thing in 2 channels, but have one of the channels slowly adjust the pitch up and down with the fine pitch adjust coordination flag (flag $E1, or just use the pitch cc in your midi editor if you're gonna export it for mid2smps)
     
    Dj. Joker 27 and MarkeyJester like this.
  20. MarkeyJester

    MarkeyJester !%#@ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,660
    I think the problem is a lack of understanding of both the 68k and the Mega Drive's VDP's various RAM access, this type of thing is less to do with the Sonic game's "engine" and more to do with common software > hardware practices, and this might be why you're struggling...

    There are loads of people on this board who know the answer already, but they probably haven't posted because it's lengthy to explain without leaving out information which you may or may not already know. Information such as; how the palette and tile data is stored digitally, or what many 68k instructions do. If you don't know this information, this is yet more information to have to explain in the post (before we've even gotten to the actual problem at hand), the post becomes really lengthy and bloated, and there's less of a guarantee you will get it. So as far as everyone's concerned, the answer is not worth it to explaining, and I concur with that.

    Now, keep in mind, this is not a hit against you, certainly not, it is just an explanation as to why no-one's been able to give a clear and concise explanation. I will be happy to give you a proper explanation if you'd like, but I have to make immediate assumptions that you know some of the more basic stuff such that I don't have to explain it.

    If you are still interested, then do reply and I will write something up, but do please give me a brief list of what you do know regarding art tiles, VRAM, palettes, sprites, mappings, the 68k, etc. This will help me cut the post (and my time) down.
     
    Dj. Joker 27 likes this.