don't click here

Random Hack/Mini Project Thread

Discussion in 'Engineering & Reverse Engineering' started by Malevolence, Jul 4, 2009.

  1. OrionNavattan

    OrionNavattan

    Member
    117
    104
    43
    Oregon
    Still polishing the documentation and drafting a release thread, but for the moment, enjoy a little preview of a potentially game-changing development tool. (Almost befitting that this comes just days after Devon's Sonic 1 Mode 1 experiments.)

    IMG_8726.jpg
     
  2. Bobblen

    Bobblen

    Member
    289
    155
    43
    A while back I made this little hack on smspower

    View topic - Sonic The Hedgehog SMS Remix (beta version) - Forums - SMS Power!

    It's main purpose was to basically advertise the fact that Maxim's massively enhanced version of WV's Sonic 1 SMS editor 'STH1EDWV' was an amazing tool and people should try it. As it happened, Slogra's astonishing Sonic Genesis for Master System did a much better job at that, and I quickly forgot about it. I also never released the mini hack here, so without further ado I present:

    Sonic 1 SMS Remix

    It's based on the idea that we've all played the game to death, so I tried to make something which encouraged a bit of exploring
    -all extra lives moved to new locations (including small layout changes to accommodate them)
    -all chaos emeralds moved to new locations (including small layout changes to accommodate them)
    -all maps allow backtracking, if you reach the end of a level, it should always be possible to get back to the start if you look around a bit.
    -and new for this version, that includes disabling the scrolling in Bridge 1 and screen locking/instant death in Jungle 2.

    It isn't polished, the difficulty is all over the place, it's very lightly tested and it's not winning any awards :-) but it is a functional* hack for Sonic 1 SMS, and I think that's pretty cool.

    Screenshots are a bit tricky as they'd reveal something hidden and nothing has changed except the hidden stuff. I'll think about it.

    *subject to testing...
     

    Attached Files:

  3. OrionNavattan

    OrionNavattan

    Member
    117
    104
    43
    Oregon
    My attempt to improve SMPS-PCM's sample streaming routine using movep unfortunately did not work due to hardware limitations (movep simply copies the data too fast for hardware to handle), but it did produce a usable 68k routine for copying data to an 8-bit peripheral using movep (confirmed as this code worked in GPGX due to that emulator not emulating the waveram behavior correctly):

    Code (ASM):
    1. ; -------------------------------------------------------------------------
    2. ; Subroutine to copy data to an 8-bit peripheral using movep
    3. ; Can handle data of any size, and starting at any address
    4.  
    5. ; input:
    6. ;   a0   = source
    7. ;   a1   = destination
    8. ;   d0.w = size of data
    9.  
    10. ;   uses d1.l, d4.l, d5.w
    11. ; -------------------------------------------------------------------------
    12.  
    13. CopyTo8Bit:
    14.        move.l   a0,d1            
    15.        btst   #0,d1               ; is start address of data odd?
    16.        beq.s   .even               ; branch if not
    17.    
    18.        move.b   (a0)+,(a1)+           ; copy first byte manually if starting at odd address
    19.        addq.w   #1,a1               ; skip over non-write address
    20.        subq.w   #1,d0               ; minus 1 for 1 byte copied
    21.    
    22.    .even:
    23.        move.w   d0,d5               ; if data is not divisible by 8, there will be a remainder of up to 7 bytes
    24.        lsr.w   #3,d0               ; d0 = loops to copy data with 8 bytes per iteration (excluding any remainder)
    25.        beq.s   .less_than_8       ; branch if there are less than 8 bytes total
    26.        subq.w   #1,d0               ; minus 1 for loop counter
    27.  
    28.    .copy:
    29.        move.l   (a0)+,d4           ; get 4 bytes of data
    30.        movep.l   d4,0(a1)           ; write to destination
    31.        move.l   (a0)+,d4           ; get another 4 bytes
    32.        movep.l   d4,4*2(a1)           ; write to destination
    33.        lea 8*2(a1),a1               ; advance destination address
    34.        dbf   d0,.copy               ; repeat for all longwords of data
    35.  
    36.    .less_than_8:
    37.        andi.w   #7,d5               ; d5 = remainder if data size was not divisible by 8
    38.        beq.s   .no_remainder       ; branch if there is no remainder
    39.        cmpi.b   #4,d5
    40.        bcs.s   .less_than_4       ; branch if remainder is less than 4 bytes
    41.        
    42.        move.l   (a0)+,d4           ; get 4 bytes of data
    43.        movep.l   d4,0(a1)           ; copy to destination
    44.        addq.w   #8,a1               ; advance destination address
    45.        subq.w   #4,d5               ; minus 4 bytes from remainder
    46.        beq.s   .no_remainder       ; branch if remainder was exactly 4
    47.    
    48.    .less_than_4:
    49.        subq.w   #1,d5               ; minus 1 for loop counter
    50.  
    51.    .copy_remainder:
    52.        move.b   (a0)+,(a1)+           ; copy one byte of data
    53.        addq.w   #1,a1               ; skip over non-write addresses
    54.        dbf   d5,.copy_remainder       ; loop until remainder is gone
    55.    
    56.    .no_remainder:
    57.        rts
     
    Last edited: Sep 18, 2023