Cheap 68K to Z80 SMPS Pointer Fixer

Discussion in 'Utilities Archive' started by sonic, Feb 16, 2011.

Thread Status:
Not open for further replies.
  1. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    Short story. I tried to put the Star Light Zone theme in the Simon Wai prototype of Sonic 2 a couple years ago and failed miserably. I tried again on the 13th and succeeded beautifully. Yes, I know about Erik JS's tool, I just thought I would try my hand at doing it the old school way. I made this Python script for debugging basically, to make sure I did the pointers correctly, though it uses some very basic logic. Perhaps it will garner some appreciation from those who have difficulty using the former. Now, without further ado, here it is in all its horribly coded glory!


    And a



    that nobody cares about.



    Code:
    from struct import unpack, pack
    
    
    
    count=0
    
    flag=0
    
    pos=47
    
    
    
    seq=raw_input("68K to Z80: ")
    
    file=open(seq,"rb+")
    
    cs=file.read()
    
    
    
    off=int(raw_input("Base offset: 0x"),16)
    
    
    
    for x in range(10,30,4):
    
    	count+=1
    
    	file.seek(x)
    
    	ptr=unpack(">H",file.read(2))[0]
    
    	pp=pack&#40;&#34;<H&#34;,off+ptr&#41;
    
    	file.seek&#40;x&#41;
    
    	file.write&#40;pp&#41;
    
    
    
    for y in range&#40;30,48,6&#41;&#58;
    
    	count+=1
    
    	file.seek&#40;y&#41;
    
    	ptr=unpack&#40;&#34;>H&#34;,file.read&#40;2&#41;&#41;&#91;0&#93;
    
    	pp=pack&#40;&#34;<H&#34;,off+ptr&#41;
    
    	file.seek&#40;y&#41;
    
    	file.write&#40;pp&#41;
    
    
    
    for z in range&#40;0,12,6&#41;&#58;
    
    	count+=1
    
    	file.seek&#40;z&#41;
    
    	ptr=unpack&#40;&#34;>H&#34;,file.read&#40;2&#41;&#41;&#91;0&#93;
    
    	pp=pack&#40;&#34;<H&#34;,off+ptr&#41;
    
    	file.seek&#40;z&#41;
    
    	file.write&#40;pp&#41;
    
    
    
    while flag!=1&#58;
    
    	pos+=1
    
    	if cs&#91;pos&#58;pos+1&#93;==&#34;\xf6&#34; or cs&#91;pos&#58;pos+1&#93;==&#34;\xf8&#34;&#58;
    
    		count+=1
    
    		file.seek&#40;pos+1&#41;
    
    		ptr=unpack&#40;&#34;>h&#34;,file.read&#40;2&#41;&#41;&#91;0&#93;
    
    		pp=pack&#40;&#34;<H&#34;,off+pos+ptr+2&#41;
    
    		file.seek&#40;pos+1&#41;
    
    		file.write&#40;pp&#41;
    
    		pos+=2
    
    	else&#58;
    
    		if cs&#91;pos&#58;pos+1&#93;==&#34;\xf7&#34;&#58;
    
    			count+=1
    
    			file.seek&#40;pos+3&#41;
    
    			ptr=unpack&#40;&#34;>h&#34;,file.read&#40;2&#41;&#41;&#91;0&#93;
    
    			pp=pack&#40;&#34;<H&#34;,off+pos+ptr+4&#41;
    
    			file.seek&#40;pos+3&#41;
    
    			file.write&#40;pp&#41;
    
    			pos+=4
    
    		else&#58;
    
    			if pos==len&#40;cs&#41;&#58;
    
    				flag=1
    
    
    
    print &#34;Fixed&#34;,count,&#34;pointers.&#34;
    
    raw_input&#40;&#34;Hit enter to exit.&#34;&#41;
     
  2. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Oh, there's no noise (or the PSG configuration for the noise channel are badly configured) in the song and the lead voice is wrong. Usually, it is very easy to convert these voices. I don't know about you, but it's way too easy for me to import from Z80 into 68K and also the opposite, except for Chaotix, Ristar and Sonic 2 Final. So, not bad stuff... But not that impressive like I was thinking when I was just reading the topic's title. I was hoping to find some tool of some video of a tool here, but I didn't see. I'm feeling a bit disappointed.
     
  3. FireRat

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

    Joined:
    Oct 31, 2009
    Messages:
    535
    Next time, post things like this in the Q & A forum, I think
     
  4. sonic

    sonic Well-Known Member Member

    Joined:
    Mar 27, 2008
    Messages:
    62
    Location:
    Michigan
    Yeah, it's just a quick and dirty pointer fixer for the header and F6-F8 Coordination Flags to get things up and running. Nothing to be impressed by. :p
     
Thread Status:
Not open for further replies.