Basic Questions and Answers Thread

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

  1. Hanoch

    Hanoch Well-Known Member Member

    Joined:
    Aug 3, 2008
    Messages:
    312
    Location:
    Israel

    $1C is not an odd address.


    @Deoxys: You're using bchg, use move instead.
     
  2. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    404
    Location:
    Russia
    $1C byte is animation number, but you need just change the frame depending on boss' health, right? Then it would be better to use $1A for this purpose.


    Another weird thing about your code is using bchg instruction. It changes the bit, 0 to 1 and 1 to 0. Your routine is running every frame, so, this way everything will be quite messy.


    Let's imagine how your code will work:


    Frame #0, Health #8 -> bchg #0 -> $1C(a0) = %00000001 ($01)


    Frame #1, Health #8 -> bchg #0 -> $1C(a0) = %00000000 ($00)


    Frame #2, Health #8 -> bchg #0 -> $1C(a0) = %00000001 ($01)


    (let's say Sonic has hit the boss!)


    Frame #3, Health #7 -> bchg #1 -> $1C(a0) = %00000011 ($03)


    Frame #4, Health #7 -> bchg #1 -> $1C(a0) = %00000001 ($01)


    ect.


    As you can see, you'll get absolutely random values due to bchg instruction.


    And the last problem, what if you want to change boss' health to 16 for example? =P


    So it would be better to write something like this:



    move.b $21(a4),$1A(a0)
    jmp DisplaySprite



    That's it! =) So if the the health is 8, sprite will use frame #8, etc.


    EDIT: Grammar
     
    Last edited by a moderator: Feb 15, 2011
  3. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    "lea ($FFFFD010).w,a4" ? D010 is $10(an) when (an) is Sonic's main address, so you're checking $31(an) which is Sonic's remaining invulnerability time in s1.
     
  4. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    It actually was purposely to load object adresses.


    ALSO: Vladik, that didn't work
     
    Last edited by a moderator: Feb 15, 2011
  5. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,873
    cmpi.w #8,$21(a4)



    Code:
    				cmpi.w  #7,$21(a4)
    

    Two "odd" addresses while you compare a "word", it must be compared using a byte, or using an even address.
     
  6. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    404
    Location:
    Russia
    Hm, what way this didn't work?


    If the object is not even displayed, check out if one can be displayed correctly, i.e. if mappings, art pointers, coordinates are loaded and mapping frames 0 to 8 are correct.


    If you have wrong frame displayed, check out if $21(a4) contains what it supposed to contain. I can't understand how your "lea ($FFFFD010).w,a4" works. It actually loads byte 10 of Sonic's STT, so how can $21(a4) contain boss' health counter?
     
  7. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    After the label of the boss's objects (before any index), add this



    move.b $21(aX),($FFFFFF99).w



    (Obj3D for example uses a0, if you understand it)


    Define a object ID, for this. I defined obj04 to this example:



    ; ---------------------------------------------------------------------------
    ; Object 04 - Boss Hits counter


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


    Obj04: ; XREF: Obj_Index


    moveq #0,d0 ; Borrar d0


    move.b $24(a0),d0 ; Preparar index


    move.w Obj04_Index(pc,d0.w),d1 ; Index


    jmp Obj04_Index(pc,d1.w) ; Index


    ; ===========================================================================


    Obj04_Index: dc.w Obj04_Main-Obj04_Index


    dc.w Obj04_First-Obj04_Index


    ; ===========================================================================


    Obj04_Main: ; XREF: Obj04_Index


    addq.b #2,$24(a0) ; Terminar el resto de los codigos hasta rts y avanzar de rutina


    move.l #Map_obj04,4(a0) ; Cargar mapas


    move.w #$3A0,2(a0) ; Ubicacion en VRAM


    move.b #0,1(a0)


    move.b #1,$18(a0)


    move.w #$90,8(a0)


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


    Obj04_Display:


    jmp DisplaySprite


    rts


    Obj04_First:


    move.b ($FFFFFF99).w,$1A(a0)


    jsr Obj04_Display


    rts


    ; ===========================================================================


    Map_obj04:


    include "_maps\obj04.asm"



    Note: you must define your VRAM address to make it work correctly.


    I used $3A0 for this example.


    (and yes, I'm sharing this code. Anyone can use this, but if credit me)


    Good luck...
     
    Last edited by a moderator: Feb 15, 2011
  8. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    And I'm telling you you aren't loading the object's address.


    D000 to D03F are Sonic's status table in s1. Object addresses in s1 are D000+40*n where n is a natural number, B000+40*n in s2, and B000+4A*n in s3 so you can't have an object starting in D010.
     
  9. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Do'l! I was gonna do that, *steals it, and runs*. Jokes aside, I echoe what was said, although not as knowledgeable, I know that ram adress aint gonna work.
     
  10. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Especially if the boss object is loaded using singleobjload (and it should be).


    For example, in GHz, the boss loads through this:



    loc_6EB0:
    cmpi.w #$2960,($FFFFF700).w


    bcs.s locret_6EE8


    bsr.w SingleObjLoad ; << this finds an empty object slot in the main SST space (which goes from FFFFD800 to FFFFEFFF)


    bne.s loc_6ED0


    move.b #$3D,0(a1) ; << this loads GHZ boss object in the free address found by singleobjload


    move.w #$2A60,8(a1)


    move.w #$280,$C(a1)



    So, an example to load another object AND save the boss' address would be:




    Loc_6EB0:


    cmpi.w #$2960,($FFFFF700).w


    bcs.s locret_6EE8


    bsr.w SingleObjLoad ; << this finds an empty object slot in the main SST space (which goes from FFFFD800 to FFFFEFFF)


    bne.s loc_6ED0


    move.b #$3D,0(a1) ; << this loads GHZ boss object ID in the free address found by singleobjload


    move.w #$2A60,8(a1)


    move.w #$280,$C(a1)


    movea.l a1,a2 ; << this copies address of the boss in a2


    bsr.w SingleObjLoad ; << find another empty object slot in the main SST space


    bne.s loc_6ED0


    move.b #$4F,0(a1) ; << this loads health bar object ID in the free address found by singleobjload


    move.l a2,$30(a1) ; << this loads the address contained in a2 in $30(a1) (note, to do this, don't write (a2), it would move the data contained at the address pointed by a2 rather than copying the address itself)



    and in your object, those first two line should look like:




    obj4f_Flash:


    movea.l $30(a0),a4 ; << this loads the address of the boss in a4
     
    Last edited by a moderator: Feb 16, 2011
  11. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    404
    Location:
    Russia
    SpirituInsanum has an absolutely right idea.


    I just wanted to do a small fix:



    movea.l a1,a2 ; << this copies address of the boss in a2



    instead of


    Code:
    		lea	a1,a2			; << this copies address of the boss in a2
    
     
  12. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Eek, you're right, I should never code when I'm tired xD


    Besides, it should have been (a1),a2 not a1,a2. I'll correct it to avoid confusion.
     
  13. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Just asking... you saw my code? :'x
     
    Last edited by a moderator: Feb 18, 2011
  14. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    302
    Location:
    Australia
    I don't know if this is a bug with the TilemapToVRAM function (ShowVDPGraphics in the old disassembly) or maybe I'm doing something wrong, but occasionally chunks of the tilemap don't draw at all. For example:


    /monthly_02_2011/post-1201-1298178864_thumb.gif/monthly_02_2011/post-1201-1298178880_thumb.gif


    It only happens every now and then, but often enough to be pretty annoying. Has anyone had this problem before, and worked out a solution?
     

    Attached Files:

  15. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,873
    Try this...


    Before you call "TilemapToVRAM" put in "move #$2700,sr" to disable the IRQ's (interrupts), or put your mapping code somewhere during the V-Blank routines.
     
  16. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    302
    Location:
    Australia
    Just noticed that it does get fully drawn for maybe a single frame, something's overwriting it almost instantly though. Messing with the interrupts isn't helping. Frustrating :lol:


    edit: fixed it, didn't realise I was calling TilemapToVRAM a second time :lol: I'm an idiot
     
    Last edited by a moderator: Feb 21, 2011
  17. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    Hi. I know, to show a map in plane A, I must made something with $C0000 (I think, anyway), but I need the map in plane B


    How I do it?
     
  18. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    404
    Location:
    Russia
    Plane B mappings are stored to start from $E000 in Sonic 1.


    Also, Plane A starts from $C000, not $C0000.
     
  19. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    403
    Location:
    Town Creek, AL
    how do i make the rings decrease in sonic 1 as if sonic 2's super sonic? (but needing it for S monitor)


    and with the eggman monitor (placed in GHZ for testing at the time) how do i make it so "Is sonic at 1 life? if yes branch" so that with 1 life you set an eggman monitor it won't take a life?


    the way it's set up you get an eggman monitor, you're still alive but 1 life lost, but 1-0=0, 0-1=UNLIMITED. a glitch to be fixed.
     
  20. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    404
    Location:
    Russia
    Your second question is so simple, that it isn't even worth to be asked here, I think. Try putting some efforts in solving the problems before asking. To begin with, take a look at this: http://info.sonicretro.org/SCHG:Sonic_the_...hog/RAM_Editing