Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. Ralakimus

    Ralakimus

    This was a triumph Tech Member
    The other problem with trying to do any kind of software screen drawing on the Genesis is timing. You'd need to make sure that you are drawing pixels at the right time, pretty much dedicating all of the time during screen drawing to just that, no real time for game logic except for blanking periods. Also, not all systems are built equal, so while it may run perfectly on one system, on another, it'd look distorted. (See this)

    So yeah, you're just better off making a tile buffer that gets sent to VRAM. You'd just need to make sure that your buffer drawing code is efficient enough, use lookup tables whenever it's best to use them, avoid slower instructions like MULU/MULS and DIVU/DIVS, etc., avoid unnecessary/redundant code, etc. etc. Also, set up a double buffer in VRAM so it doesn't appear glitchy when it starts transferring tiles.

    With figuring out how to draw the circles from the thing you linked to, one method that comes to mind that for each scanline, you set up a number of smaller lines to draw and their widths with how you set up the circles. These lines would be drawn one after another. There may be a better method out there without resorting to completely prerendering it all, but this is what I'm thinking (and I wouldn't be surprised if there was, I'm not exactly the greatest when it comes to coming up with the most optimal code and methods, but meh). At least with this, you don't need to waste time drawing the entirety of every circle, and just draw only what's gonna show up.

    I also advise against setting up a standard bitmap buffer that gets converted into tiles when it comes to actually setting up pixels. I'm pretty sure it'd be faster to just determine the correct address and nibble to write to, which shouldn't be too slow or hard to do if you write just write pixel by pixel, line by line in order, which can be done with the method I described above. Don't even bother clearing the buffer either, since the entire thing would get overwritten anyways.
     
    Last edited: Nov 26, 2019
    • Agree Agree x 1
    • Informative Informative x 1
    • List
  2. MarkeyJester

    MarkeyJester

    ♡ ! Resident Jester
    It's funny you bring that up, just yesterday I noticed that thread and was contemplating on how I would handle such a thing on the Mega Drive.

    The thing with programming something that has apparent complex visual changes for a primitive machine, is that you often need to think simpler, it isn't always necessary to draw pixels in real time to achieve something which would appear that way. Let's be honest here, the graphics there are very simple, they're not exactly complex.

    I would've opted for a raw/flat image of the tube (and possible bending permutations) and using palette cycling to animate the tube, using both planes to switch between palette lines (I would imagine the linked example would need more than one palette line), and perhaps use H-blank/H-scroll to switch the vertical/horizontal lines between the various permutations to achieve the bending/curving at various positions. You'd have enough VRAM for the circles, but at the same time, the circles are small enough to render with real-time scaling without causing lag, so direct pixel/tile rendering could be an option for those, but if you had the VRAM I would suggest the former.
     
    • Agree Agree x 1
    • Informative Informative x 1
    • List
  3. Aerosol

    Aerosol

    FML and FU2 Moderator
    10,537
    53
    28
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
    The linked example would definitely need more than one palette line, but for use in a game you could get away with just one. You don't want a rainbow for every level after all, freeing up the second plane for something else, like a different effect (again, for visual clarity).

    I'm having trouble visualizing the trick you mentioned using hblank/hscroll to switch vertical and horizontal lines between the permutations. Can you think of an example in a game that uses that trick?
     
  4. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    I know that it's not used anymore but, how can I find free RAM space to install the Sonic 2 Clone Driver v2?
    (or maybe I am just a doof, either way, I am just a noob at assembly so any guidance?)
     
  5. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,378
    47
    28
    SonLVL
    Why?
     
  6. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    To put it simply, I was using the Xenowhirl Disassembly with S2 Clone Driver on it, only thing now was to implement it, but I couldn't find any free RAM space there.
     
  7. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,378
    47
    28
    SonLVL
    IMO you shouldn't be using either of those things, but if you look at the RAM editing page, the region from $F100-$F5FF is unused.
     
  8. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    I know about the first two things but thanks for the help
     
  9. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    So, I decided that I would dump the Xenowhirl Disassembly in favor of the Git disassembly to install the Sonic 2 Clone Driver v2 (latest Git repo), however, after I finished installing that, and built the disassembly, it showed a black screen, did I do something wrong? Was there a problem with the Clone Driver? I would really need some help on this.
     
  10. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,378
    47
    28
    SonLVL
  11. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    Oh wow, well I feel dumb.
    Also, figured out what was wrong, the code
    Code (Text):
    1. bsr.w    JmpTo_SoundDriverLoad
    was removed, so it couldn't load. Just fixed it.
     
  12. Kampfer

    Kampfer

    Member
    1,608
    0
    16
    So, long time poster, longer time lurker needing help editing S1:

    I decided to to edit the background of GHZ, but ran into issues with the background deformation on the lakebed of GHZ. I want the art to be something else, but with the way it deforms I can't do something other than water. I know near zilch of ASM but I saw there is a handy deformation code generator by Selbi with easy to use instructions on the SSRG forum post about the program.

    When I saw the Rev01 code for GHZ, I didn't see where I should insert the code vis a vis Selbi's intructions. I saw the spot in the Rev00 code, so I copy/pasted the rev00 GHZ deform code code into the rev01 file. I then inserted the Selbi program generated code where it belonged and included the line for screen locking (which I think is redundant in GHZ due the background being one screen high). This was the deform code.

    Code (Text):
    1.  
    2. Deform_GHZ:
    3.         move.w    (v_scrshiftx).w,d4
    4.         ext.l    d4
    5.         asl.l    #5,d4
    6.         move.l    d4,d1
    7.         asl.l    #1,d4
    8.         add.l    d1,d4
    9.         moveq    #0,d5
    10.         bsr.w    ScrollBlock1
    11.         bsr.w    ScrollBlock4
    12.         lea    (v_hscrolltablebuffer).w,a1
    13.         move.w    (v_screenposy).w,d0
    14.         andi.w    #$7FF,d0
    15.         lsr.w    #5,d0
    16.         neg.w    d0
    17.         addi.w    #$26,d0
    18.         move.w    d0,(v_bg2screenposy).w
    19.         move.w    d0,d4
    20.         bsr.w    ScrollBlock3
    21.         move.w    ($FFFFF70C).w,($FFFFF618).w
    22.         move.w    (v_bgscreenposy).w,(v_bgscrposy_dup).w
    23.         lea    ($FFFFCC00).w,a1    ; load beginning address of horizontal scroll buffer to a1
    24.         move.w    ($FFFFF700).w,d0    ; load FG screen's X position
    25.         neg.w    d0            ; negate (positive to negative)
    26.         swap    d0            ; send to the left side of d0
    27.         move.w    ($FFFFF708).w,d0    ; load BG screen's X position
    28.         neg.w    d0            ; negate (positive to negative)
    29.         asr.w    #8,d0            ; divide by 256 (Slow down the scroll position)
    30.         move.w    #114-1,d1        ; set number of scan lines to dump (minus 1 for dbf)
    31. GHZ_DeformLoop_1:
    32.         move.l    d0,(a1)+        ; dump both the FG and BG scanline position to buffer
    33.         dbf    d1,GHZ_DeformLoop_1    ; repeat d1 number of scanlines
    34.  
    35.         move.w    ($FFFFF700).w,d0    ; load FG screen's X position
    36.         neg.w    d0            ; negate (positive to negative)
    37.         swap    d0            ; send to the left side of d0
    38.         move.w    ($FFFFF708).w,d0    ; load BG screen's X position
    39.         neg.w    d0            ; negate (positive to negative)
    40.         asr.w    #4,d0            ; divide by 16 (Slow down the scroll position)
    41.         move.w    #63-1,d1        ; set number of scan lines to dump (minus 1 for dbf)
    42. GHZ_DeformLoop_2:
    43.         move.l    d0,(a1)+        ; dump both the FG and BG scanline position to buffer
    44.         dbf    d1,GHZ_DeformLoop_2    ; repeat d1 number of scanlines
    45.  
    46.         move.w    ($FFFFF700).w,d0    ; load FG screen's X position
    47.         neg.w    d0            ; negate (positive to negative)
    48.         swap    d0            ; send to the left side of d0
    49.         move.w    ($FFFFF708).w,d0    ; load BG screen's X position
    50.         neg.w    d0            ; negate (positive to negative)
    51.         asr.w    #2,d0            ; divide by 4 (Slow down the scroll position)
    52.         move.w    #49-1,d1        ; set number of scan lines to dump (minus 1 for dbf)
    53. GHZ_DeformLoop_3:
    54.         move.l    d0,(a1)+        ; dump both the FG and BG scanline position to buffer
    55.         dbf    d1,GHZ_DeformLoop_3    ; repeat d1 number of scanlines
    56.         rts
    57. ; End of function Deform_GHZ
    58.  
    This was the result:



    Hilarious as the title banner is floating away, not really what I wanted and tiles change randomly in the background instead of any scrolling. I started to fiddle with the code (AKA take a hammer to the deform routine to see what would happen), and when I deleted "bsr.w ScrollBlock1" and "bsr.w ScrollBlock4" I almost got what I wanted:



    Close, but now some tiles in the background wont load and the banner on the title screen still flies away.

    So in sum, I guess answering one of the following questions would resolve this issue.

    1. If I can insert the Selbi program generated code in the original Rev01 deform layers file, where does it go?
    2. If I need to paste the GHZ Rev00 code into the Rev01 deform layers file in order to use the new deform layers code, how do I get the tiles in the background to cooperate?
    3. In any event, how do I edit the GHZ deform code without mangling the title screen?
     
  13. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    Ok, so, I was in the middle of adding Knuckles into my hack and as I tried to use build.bat, these appeared on "s2.log"
    Since I am now running out of trial posts on this place as a result, I would like to know what I did wrong.
     
  14. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,378
    47
    28
    SonLVL
    They could be mistakes caused by another error, in which case fixing the other error(s) will cause them to disappear (AS is buggy like that), or, you inserted something between those instructions and the labels they reference, causing the distance to be too far. That can be fixed by moving the extra data somewhere else or by first loading the label's address into a1 with lea (label).l,a1 and then replacing pc with a1 in the existing instruction.
     
  15. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    Or I can just move the character stuff and fix up certain things until it works again...
    which it did...
    Anyhow, as my time being a Trialist ends, I will like to say thank you for your support MainMemory.
    Unless I am actually a full-on Member, which would be rad but who knows.
    UPDATE:
    I am done with the Knuckles guide for now, but uh, I got a problem...
    [​IMG]
    That Knuckles is basically a broken Tails.
    It didn't show Knuckles' art, only Tails'
    Did I forget something again?
     
    Last edited: Nov 29, 2019
  16. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,378
    47
    28
    SonLVL
    I'm not sure how you managed that. Did you forget to add in the actual files for Knuckles' art, mappings, and DPLCs?
     
  17. BlueSpeedsterYT

    BlueSpeedsterYT

    An absolute noob at Assembly Member
    18
    0
    1
    I already did those, it's just that it doesn't even show up.
     
  18. Pokepunch

    Pokepunch

    Member
    82
    0
    6
    UK
    A Sonic 2 Hack
    In that case I'd advise you to go over the guide again, you've probably missed something.
     
  19. I'm doing homebrew Mega Drive work (apologies if this should be in the fangaming forum, but it's 68k related so I figured I'd get better answers here).
    I use ASM68K's GROUP and SECTION directives to align certain parts of my code; for example, the following declares three sections, for the 68k interrupt vector table ($0-$FF), the Sega ROM header table ($100-$1FF), and my code's section ($200-$100000).

    Code (Text):
    1.  
    2.  
    3. ; SectRomIvt - ROM's interrupt vector table
    4. BaRomIvtStart:      EQU         BaRomStart
    5. BcRomIvtLen:        EQU         $100
    6. GroupRomIvt:        GROUP       ORG(BaRomIvtStart),SIZE(BcRomIvtLen)
    7.                     SECTION     SectRomIvt,GroupRomIvt
    8.  
    9. ; SectRomHeader - ROM's Sega header
    10. BaRomHeaderStart:   EQU         BaRomIvtStart + BcRomIvtLen
    11. BcRomHeaderLen:     EQU         $100
    12. GroupRomHeader:     GROUP       ORG(BaRomHeaderStart),SIZE(BcRomHeaderLen)
    13.                     SECTION     SectRomHeader,GroupRomHeader
    14.  
    15. ; SectRomCode - ROM code (after exception table & header)
    16. BaRomCodeStart:     EQU         BaRomHeaderStart + BcRomHeaderLen
    17. BcRomCodeLen:       EQU         $100000 - $200
    18. GroupRomCode:       GROUP       ORG(BaRomCodeStart),SIZE(BcRomCodeLen)
    19.                     SECTION     SectRomCode,GroupRomCode
    20.  
    21.  
    Then I can switch to each section throughout my code, e.g.:

    Code (Text):
    1.  
    2.     SECTION SectRomCode
    3.    
    4. ; Initialization routine
    5. RInit:
    6.         ; Start the player at the top left of the screen.
    7.         MOVE.W  #128,WaPlayerPosX
    8.         MOVE.W  #128,WaPlayerPosY
    9.  
    10.         JSR     RInitGraphics
    11.         RTS
    12.  
    However, when I do this, the listing file (.L68) shows offsets from the start of the section, rather than from the start of the ROM.
    For example, this shows the RInit routine beginning at $0, when it's really located at $200 in the ROM file:

    Code (Text):
    1. 00000000                                SECTION SectRomCode
    2. 00000000                              
    3. 00000000                            ; Initialization routine
    4. 00000000                            RInit:
    5. 00000000                                    ; Start the player at the top left of the screen.
    6. 00000000 33FC 0080 00FF 0000                MOVE.W  #128,WaPlayerPosX
    7. 00000008 33FC 0080 00FF 0002                MOVE.W  #128,WaPlayerPosY
    8. 00000010                          
    9.  
    10. 00000010 4EB9 0000 0000                     JSR     RInitGraphics
    11. 00000016 4E75                               RTS
    12. 00000018                            
    Is it possible to tell the assembler to write the listing file using the final offsets in the ROM, rather than the section?
     
  20. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    I am not like 100% sure how its gonna actually work, but in addition of org(x), try obj(x) too. I am worried it will break all absolute addresses though, but its worth a shot? If it doesn't work I'll investigate it tomorrow
     
    Last edited: Dec 3, 2019