Basic Questions and Answers Thread

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

  1. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Yes. I'm using it for AngleMap and both CollArrays.
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    You're on the right tracks, but there's a misunderstanding on how the instructions work, first of all, when loading the Zone ID from FFFFFE10 into d3, it can be 00, 01, 02, 03, 04, 05, etc. Your table is full of long-words (4 bytes each). This means in simple terms:

    Zone 00 needs to load the long-word at CollArrayTable + 00

    Zone 01 needs to load the long-word at CollArrayTable + 04

    Zone 02 needs to load the long-word at CollArrayTable + 08

    Zone 03 needs to load the long-word at CollArrayTable + 0C

    Zone 04 needs to load the long-word at CollArrayTable + 10

    Zone 05 needs to load the long-word at CollArrayTable + 14

    etc...

    Now, the "CollArrayTable + 00", "CollArrayTable + 04", etc, is pretty much this "CollArrayTable(pc,d3.w)". In essence what you're doing is "CollArrayTable + d3". But this means d3 needs to be; 00, 04, 08, 0C, 10, etc. It needs to be a multiple of 4 bytes (because each long-word is 4 bytes).

    After loading the Zone ID into d3, simply multiply d3 by 4. You can do this with the "mulu" instruction, or you can use the "lsl" and shift it left twice, or if you want the quickest method, add d3 to itself twice:

    add.w d3,d3 ; multiply d3 by x2
    add.w d3,d3 ; multiply d3 by x2 again (x4)If d3 was 00, afterwards it will be 00.If d3 was 01, afterwards it will be 04.

    If d3 was 02, afterwards it will be 08.

    ...and so on.

    The second problem is the "lea CollArrayTable(pc,d3.w),a2" instruction itself. LEA will load the address of the table at CollArrayTable + d3. You should be using MOVEA.L to load the address from the table at CollArrayTable + d3:

    Code:
    		movea.l	CollArrayTable(pc,d3.w),a2		; load address from CollArrayTable + d3
     
  3. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Thanks Markey! I used this for every instance CollArray1 and 2 and AngleMap were used and it works pretty well. Unfortunately, sometimes Sonic falls through the floor and when he is pushing against a wall, he moves into the wall and bounces back. These may be mistakes I made when adding the code.

    Edit: I haven't seen any mistakes so I don't know what's causing the collision to be slightly messed up.
     
    Last edited by a moderator: Apr 21, 2015
  4. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I've tried inserting Death Egg Zone act 1s' music (from S&K) to the Clone Driver V2 both through using Flamewings' convertor and through Flamewings' SMPs pack, but both cause really odd, scratchy sounds to obnoxiously play part way through the song. I originally thought it was the DAC, but removing the DAC track didn't do anything to the odd sounds, and Death Egg Zone 1 has no PSG tracks, which means (in my limited viewpoint) that the static is either an issue with A. the instruments (which makes no sense), or B. The way the FM track is structured (which makes even less sense). What's going on? Is this an issue with my installation of the driver, or the song? Every other song I've added (including Death Egg Zone act 2) has no issue regarding this.
     
  5. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    I believe I brought this up with ValleyBell once. He said it was to do with how the FM instrument used makes use of a feature exclusive to SMPS Z80 - S3K's driver.


    The best you could do to fix it would be to modify a value in the instrument, which would make it sound almost identical to how it does normally. The details of this are unknown to me.


    You can always just use S&K/flamewing's driver. SMPS 68k only seems good for advanced DAC features, which no one ever takes advantage of.
     
    Last edited by a moderator: Apr 23, 2015
  6. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    417
    Location:
    Town Creek, AL
    I'm still trying to port over S2's HPZ to S1 and am getting closer to loading correct art, but it locks up at title cards & the HPZ art seems to load over the oval. All I did was port over the macro for loading it's chunks & HPZ's main level load blocks.


    Also, would using S2's main level block load code be best, or load chunks from ROM?
     
  7. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    What disassembly are you using? It would be hard to port any Sonic 2 level (even the beta levels) to Sonic 1 without using a 128 variation. When using that, in order to have the it show up correctly you have to convert all the files. I do this by loading the level in SonED2, changing the project files to use Sonic 1's compression, and saving it. If you added a new zone, try seeing if you made any mistakes when following the tutorial.
     
  8. tilk

    tilk Active Member Member

    Joined:
    Feb 2, 2012
    Messages:
    30
    Hm... I guess that I asked this before, but I'll do so again as I got no answer. Sonic 2 Nick arcade prototipe (Or as I like to call it, Sonic 2 Alpha) What object manager it uses? It uses Sonic 1 format, or the Sonic 2 Final format? I ask because I want to port objects from Sonic 1 to sonic 2 (And if the Nick arcade uses the Sonic 2 Final format, I can just port them from there/easily)
     
  9. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    The nick arcade prototype uses sonic 1s' object manager. This is the big reason why many of it's features are easier to port back to S1 then it is to bring them into S2.
     
  10. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    What is the "nMaxPSG2" SMPS command in SMPS2ASM? It keeps popping up in S3K/S3D songs, and building with these commands results in build errors along the lines of "symbol not defined". The songs play fine when I comment the lines out, but the beginning of the song sounds a little off because of this. Clearly, it's an S3K/S3D only thing, but I'm curious as to what it is (and more importantly, how to make those songs work without it).
     
    Last edited by a moderator: Apr 26, 2015
  11. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    They should be defined in _smps2asm_inc.asm. If they aren't, you need a newer include file.
     
  12. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    On further inspection, it seems like it might just be that. I was just using the _smps2asm_inc.asm in the clone driver v2. That should probably be fixed...

    EDIT: Actually, on further, further inspection, I found this little comment:

    ; SMPS2ASM uses nMaxPSG for songs from S1/S2 drivers.
    ; nMaxPSG1 and nMaxPSG2 are used only for songs from S3/S&K/S3D drivers.
     

    It appears to be an S3K exclusive, after all.

    EDIT2: It seems your answer was correct. I added in the definition from a new copy of the asm file.
     
    Last edited by a moderator: Apr 27, 2015
  13. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    SMPS2ASM v0.2 was added to my driver in v2.2.5.1, which was over two months ago, thank you...
     
    Last edited by a moderator: Apr 27, 2015
  14. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    417
    Location:
    Town Creek, AL
      
    Using hivebrain address music by markey jester, been converting levels using level converter.
     
  15. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Porting over S2 and/or S3K levels to S1 is physically impossible without making drastic changes to S1's code and layouts. Sonic 2 has a smaller chunk system, so making HPZs layout be both intact and good looking would be problematic; Markeys' 128 disassembly fixes this. Besides the chunks, the rest should be just fine; your issue is clearly with the guide for adding new level slots, because adding data to an existing slot, used or not, is usually quite easy (I only really do this in Sonic 2, though, so I might be wrong)...
     
  16. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    417
    Location:
    Town Creek, AL
    I can probably deal with lesser chunks & just edit from there. Or see about starting over using 128 instead (or try converting from hivebrain address to 128 address so I won't start over.)
     
  17. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Edit: I am using Sonic 1 Hivebrain. The code is ported from Sonic 2 Aurochs with help from Sonic 2 Xenowhirl.

    After successfully porting the spring object from Sonic 2 to Sonic 1, I wanted to port Sonic 2's invincibility object because I thought it looked neat. I'm using it to replace the invincibility object created using SuperEgg's shield optimizing guide. Here's what I have:


    ; ---------------------------------------------------------------------------
    ; Object 4A - New Invincibility Object
    ; ---------------------------------------------------------------------------

    Obj4A: ; XREF: Obj_Index
    move.l #UnC_Stars,d1
    move.w #$A820,d2
    move.w #$200,d3
    jsr (QueueDMATransfer).l
    moveq #0,d0
    move.b $A(a0),d0
    move.w off_1D98C(pc,d0.w),d1
    jmp off_1D98C(pc,d1.w)
    ; ===========================================================================
    off_1D98C: dc.w loc_1D9A4-off_1D98C; 0 ; DATA XREF: h+6A18o h+6A1Ao ...
    dc.w loc_1DA0C-off_1D98C; 1
    dc.w loc_1DA80-off_1D98C; 2
    dc.l byte_1DB8F ; 0
    dc.w $B
    dc.l byte_1DBA4
    dc.w $160D
    dc.l byte_1DBBD
    dc.w $2C0D
    ; ===========================================================================

    loc_1D9A4: ; DATA XREF: h+6A18o
    moveq #0,d2
    lea (off_1D98C,pc),a2
    lea (a0),a1
    moveq #3,d1

    loc_1D9AE: ; CODE XREF: h+6A88j
    move.b 0(a0),0(a1)
    move.b #4,$A(a1)
    move.l #off_1DCBC,4(a1)
    move.w #$541,2(a1)
    move.b #4,1(a1)
    bset #6,1(a1)
    move.b #$10,$E(a1)
    move.b #2,$F(a1)
    move.w $3E(a0),$3E(a1)
    move.b d2,$36(a1)
    addq.w #1,d2
    move.l (a2)+,$30(a1)
    move.w (a2)+,$34(a1)
    lea $40(a1),a1
    dbf d1,loc_1D9AE
    move.b #2,$A(a0)
    move.b #4,$34(a0)

    loc_1DA0C: ; DATA XREF: h+6A18o
    movea.w $3E(a0),a1
    btst #1,$2B(a1)
    beq.w Delete_Obj4A
    move.w 8(a1),d0
    move.w d0,8(a0)
    move.w $C(a1),d1
    move.w d1,$C(a0)
    lea $10(a0),a2
    lea (byte_1DB82,pc),a3
    moveq #0,d5

    loc_1DA34: ; CODE XREF: h+6ACEj
    move.w $38(a0),d2
    move.b (a3,d2.w),d5
    bpl.s loc_1DA44
    clr.w $38(a0)
    bra.s loc_1DA34
    ; ===========================================================================

    loc_1DA44: ; CODE XREF: h+6AC8j
    addq.w #1,$38(a0)
    lea (byte_1DB42,pc),a6
    move.b $34(a0),d6
    jsr (loc_1DB2C,pc)
    move.w d2,(a2)+
    move.w d3,(a2)+
    move.w d5,(a2)+
    addi.w #$20,d6 ; ' '
    jsr (loc_1DB2C,pc)
    move.w d2,(a2)+
    move.w d3,(a2)+
    move.w d5,(a2)+
    moveq #$12,d0
    btst #0,$22(a1)
    beq.s loc_1DA74
    neg.w d0

    loc_1DA74: ; CODE XREF: h+6AFCj
    add.b d0,$34(a0)
    move.w #$80,d0 ; '€'
    jmp DisplaySprite3
    ; ===========================================================================

    loc_1DA80: ; DATA XREF: h+6A18o
    movea.w $3E(a0),a1
    btst #1,$2B(a1)
    beq.w Delete_Obj4A
    lea ($FFFFEED2).w,a5
    lea ($FFFFE500).w,a6
    tst.b $3F(a0)

    loc_1DAAC: ; CODE XREF: h+6B2Ej
    move.b $36(a0),d1
    lsl.b #2,d1
    move.w d1,d2
    add.w d1,d1
    add.w d2,d1
    move.w (a5),d0
    sub.b d1,d0
    lea (a6,d0.w),a2
    move.w (a2)+,d0
    move.w (a2)+,d1
    move.w d0,8(a0)
    move.w d1,$C(a0)
    lea $10(a0),a2
    movea.l $30(a0),a3

    loc_1DAD4: ; CODE XREF: h+6B6Ej
    move.w $38(a0),d2
    move.b (a3,d2.w),d5
    bpl.s loc_1DAE4
    clr.w $38(a0)
    bra.s loc_1DAD4
    ; ===========================================================================

    loc_1DAE4: ; CODE XREF: h+6B68j
    swap d5
    add.b $35(a0),d2
    move.b (a3,d2.w),d5
    addq.w #1,$38(a0)
    lea (byte_1DB42,pc),a6
    move.b $34(a0),d6
    jsr (loc_1DB2C,pc)
    move.w d2,(a2)+
    move.w d3,(a2)+
    move.w d5,(a2)+
    addi.w #$20,d6 ; ' '
    swap d5
    jsr (loc_1DB2C,pc)
    move.w d2,(a2)+
    move.w d3,(a2)+
    move.w d5,(a2)+
    moveq #2,d0
    btst #0,$22(a1)
    beq.s loc_1DB20
    neg.w d0

    loc_1DB20: ; CODE XREF: h+6BA8j
    add.b d0,$34(a0)
    move.w #$80,d0 ; '€'
    jmp DisplaySprite3
    ; ===========================================================================

    loc_1DB2C: ; DATA XREF: h+6ADCt h+6AEAt ...
    andi.w #$3E,d6 ; '>'
    move.b (a6,d6.w),d2
    move.b 1(a6,d6.w),d3
    ext.w d2
    ext.w d3
    add.w d0,d2
    add.w d1,d3
    rts

    Delete_Obj4A:
    jmp DeleteObject
    ; ===========================================================================
    byte_1DB42: dc.b $F, 0, $F, 3, $E, 6, $D, 8, $B, $B, 8, $D, 6, $E, 3, $F; 0
    ; DATA XREF: h+6AD4t h+6B7Et
    dc.b 0,$10,$FC, $F,$F9, $E,$F7, $D,$F4, $B,$F2, 8,$F1, 6,$F0, 3; 16
    dc.b $F0, 0,$F0,$FC,$F1,$F9,$F2,$F7,$F4,$F4,$F7,$F2,$F9,$F1,$FC,$F0; 32
    dc.b $FF,$F0, 3,$F0, 6,$F1, 8,$F2, $B,$F4, $D,$F7, $E,$F9, $F,$FC; 48
    byte_1DB82: dc.b 8, 5, 7, 6, 6, 7, 5, 8, 6, 7, 7, 6,$FF; 0
    ; DATA XREF: h+6ABAt
    byte_1DB8F: dc.b 8, 7, 6, 5, 4, 3, 4, 5, 6, 7,$FF, 3, 4, 5, 6, 7; 0
    ; DATA XREF: h+6A1Eo
    dc.b 8, 7, 6, 5, 4; 16
    byte_1DBA4: dc.b 8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7,$FF, 2, 3, 4; 0
    ; DATA XREF: h+6A24o
    dc.b 5, 6, 7, 8, 7, 6, 5, 4, 3; 16
    byte_1DBBD: dc.b 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6,$FF, 1, 2, 3; 0
    ; DATA XREF: h+6A2Ao
    dc.b 4, 5, 6, 7, 6, 5, 4, 3, 2; 16
    byte_1DBD6: dc.b 0, 2, 0, 5, 0, 5, 1, 5, 2, 5, 3, 5, 4,$FF; 0
    ; DATA XREF: h+69F0o
    ; -------------------------------------------------------------------------------
    ; Unknown Sprite Mappings
    ; -------------------------------------------------------------------------------
    off_1DCBC:
    include "_mapsobj4A.asm"

    I converted the mappings to Sonic 1 and ported DisplaySprite3. I assume I made a mistake while trying to use uncompressed art.

    Also, how do I make some of the code generated by Selbi's Parallax Editor scroll automatically?
     
    Last edited by a moderator: May 7, 2015
  18. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    As earlier posts would tell you, that object uses the 'multi-sprite' display mode. I think that 'bset #6,1(a1)' is what enables it. Unfortunately, multi-sprite mode isn't in S1, so that will need porting from S2's BuildSprites. You gotta mind the difference in mapping format, which requires the ported code be modified.
     
  19. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Thanks but I found it too complicated just for adding something so small. I decided to keep the code I had before but use the art from Sonic 2 and custom mappings. I got a pretty good but not nearly impressive result.

    I want to make the clouds move by themselves in my background to make the level look more alive.
     
  20. Narcologer

    Narcologer Hell angel Member

    Joined:
    May 2, 2015
    Messages:
    91
    Location:
    Robotropolis
    Last edited by a moderator: May 9, 2015