It is currently Sat Feb 24, 2018 8:37 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Jan 24, 2018 4:47 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3211
Location: Nacogdoches, Texas
Basically the title. I had somebody make me a program to separate a file into two files byte by byte for the purpose of working with the Irem M92. I'm curious about looking into Gunforce II with IDA Pro, which is why I need to interleave files, because I was looking into the game's cut 4 player mode. What's interesting is that there's actually blank space in ram the size of that used by player 1 and 2. In addition, writing to what would be the x and y values of each character copies the value into memory near it as to store last frame's x and y position, just like what is done with player 1 and 2. It appears they got pretty far into implementing a 3rd and 4th player before dropping them.

I'd like to be trying to see if I can get sprites to work on the system, but I still haven't found a good deal on eBay so I won't be able to test it in on real hardware. :| Major Title 2 going for over $300 is simply insane.

Unrelated, but I have gotten a lot of my old SNES code to work with an object table being offset by direct page, so there's that. I also got a github for something unrelated, but it might encourage me to work a little harder on the SNES so I can post something presentable. :lol:


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 5:20 pm 
Offline
User avatar

Joined: Mon Oct 01, 2012 3:47 pm
Posts: 154
Location: freemland (NTSC-U)
Seems like romwak can do what you're asking for. The "Byte Merge Two Files (/m)" option in particular.


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 7:35 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3211
Location: Nacogdoches, Texas
Thanks; it worked. :) I figured there might already be a program like this.


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 8:51 pm 
Offline
User avatar

Joined: Tue Apr 04, 2017 1:22 pm
Posts: 27
Location: Ohio, USA
I know a lot of people here like to use Python as a general-purpose tool for things like this.

Here's just a few lines that will accomplish the task:

Code:
with open('first_file_name.bin', 'rb') as infile1, open('second_file_name.bin', 'rb') as infile2, open('output_file_name.bin', 'wb') as outfile:
   
   interleave = zip(infile1.read(), infile2.read())
   
   for byte1, byte2 in interleave:
      
      outfile.write(byte1)
      outfile.write(byte2)

_________________
http://zutanogames.com/ <-- my dev blog


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 9:58 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3211
Location: Nacogdoches, Texas
@Zutano The only programming languages I know are 65816 and 80186 assembly. I'm not very interested in high level programming and haven't run into enough situations were learning a high level programming language would help me. I don't plan on making this my profession.

I don't know if any of you are familiar with IDA Pro, but for whatever reason, it's refusing to run what MAME debugger is clearly showing as code; the reset vector points straight to here.

Attachment:
MAME debugger.jpg
MAME debugger.jpg [ 49.49 KiB | Viewed 664 times ]

You can see I'm at the same spot in the hex viewer; that whole section is highlighted because it thinks that information should be grouped for some reason.

Attachment:
IDA Pro hex view.jpg
IDA Pro hex view.jpg [ 162.74 KiB | Viewed 664 times ]

Here's the code file if anyone wants to figure out how to get it to work:

Attachment:
Gunforce II code.bin [512 KiB]
Downloaded 5 times

Edit: I fixed it; All I had to do was uncheck "load as code segment" upon opening the file to make it stop grouping everything, which let it start at 0xE734 and disassemble correctly. There's only a handful of routines it found; I'm guessing it couldn't find any of the object routines because they aren't exactly trivial to find, in that you don't access them in an "if/else" way.


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 11:45 pm 
Offline

Joined: Fri Jul 04, 2014 9:31 pm
Posts: 836
Espozo wrote:
I'm not very interested in high level programming and haven't run into enough situations were learning a high level programming language would help me.

I have. Graphics and data preparation for SNES programs. It's extremely useful to be able to use (say) Matlab to convert graphics, compile HDMA tables, optimize tricks like HDMA palette expansion and lossy packed-pixel Mode 7 that take a substantial amount of compute time on a Pentium 4... Even for audio, every now and then I encounter something my collection of audio processing tools doesn't do, and it's Matlab to the rescue. If you don't want to pay for Matlab, NumPy (an offshoot of Python) may offer similar capabilities. Octave is basically free Matlab, but it's not quite the same and I've had trouble with colour depth support...

The task you started the thread over would be utterly trivial in Matlab or a similar language, and they tend to be far more user-friendly and OS-independent than C and its relatives.

...

On the other hand, I've been familiar with high-level programming for nearly two decades now, and with Matlab specifically for most of that time, so it's easy to just whip up a routine. If what you want to do can be done well enough with existing tools, the entry barrier might be too high to be worth it. (I haven't gotten far enough in SNES programming to have a good idea of what can be accomplished without custom tools. The M92 situation is probably worse, but without a baseline, that doesn't mean much.)


Top
 Profile  
 
PostPosted: Thu Jan 25, 2018 2:38 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1330
https://github.com/Mikejmoffitt/romtools

bsplit does exactly this (splits / combines odd/even files)

Build it:
Code:
gcc bsplit.c -o bsplit -O3


Combining / interleaving two files:
Code:
bsplit c in.even in.odd out.full


Splitting one into two files:
Code:
bsplit c in.full out.even out.odd


If you are working with patching a game and trying it in MAME, I recommend you make a makefile and do the work using a simple build system to make iterative testing easier. Here is an example.


Top
 Profile  
 
PostPosted: Thu Jan 25, 2018 5:16 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3211
Location: Nacogdoches, Texas
mikejmoffitt wrote:
bsplit does exactly this (splits / combines odd/even files)

Romawk is working fine for me though; I've already made a number of batch files for using it.

mikejmoffitt wrote:
If you are working with patching a game and trying it in MAME, I recommend you make a makefile and do the work using a simple build system to make iterative testing easier. Here is an example.

What does this do?

I opened up the file in IDA Pro, but it didn't really find shit, so I've tried to set watchpoints for the controller inputs in MAME debugger, but I can't figure out how to set them for the read port address space, which is where the controller registers are located.


Top
 Profile  
 
PostPosted: Fri Jan 26, 2018 12:42 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1330
Espozo wrote:
mikejmoffitt wrote:
bsplit does exactly this (splits / combines odd/even files)

Romawk is working fine for me though; I've already made a number of batch files for using it.

mikejmoffitt wrote:
If you are working with patching a game and trying it in MAME, I recommend you make a makefile and do the work using a simple build system to make iterative testing easier. Here is an example.

What does this do?

I opened up the file in IDA Pro, but it didn't really find shit, so I've tried to set watchpoints for the controller inputs in MAME debugger, but I can't figure out how to set them for the read port address space, which is where the controller registers are located.


If IDA can't find anything, first make sure you've given it the right entry point. If it can't make any sense of that code, then you should make sure you haven't incorrectly interleaved your files.

You want
Code:
wpiset
for the IO port address space.

If you are making any changes, you are going to get tired of using a hex editor and hand assembling, or manually writing over sections to patch. You should use an assembler, binclude the original program file, and use org to set your location to patch over. That is exactly what the project I linked you to does. The readme is detailed in describing the intent, and the patch file is commented.


Top
 Profile  
 
PostPosted: Mon Jan 29, 2018 1:34 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3211
Location: Nacogdoches, Texas
Sorry for the late reply; school work got in the way.

mikejmoffitt wrote:
If IDA can't find anything, first make sure you've given it the right entry point. If it can't make any sense of that code, then you should make sure you haven't incorrectly interleaved your files.

They're interleaved correctly, and I did find the correct entry point by using the MAME disassembler. It's just that for some reason, with some games I've opened up, IDA is innable to find more than four routines for whatever reason. There are some routines that I have no idea how it could find them; for example, ones where the CPU jumps to a memory address defined by somewhere in ram, like what I'm doing in my object routine for my SNES game engine.

mikejmoffitt wrote:
for the IO port address space.

Thanks! :) However, I did now realize that I could have just set a watchpoint for values in ram that I know are being used by the different players... :roll:


Top
 Profile  
 
PostPosted: Sun Feb 04, 2018 3:30 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3211
Location: Nacogdoches, Texas
Do you know if there is a way to have MAME use more controllers for a game than it normally does? I don't know why I'm asking this just now... (The registers are 0x06 and 0x07 of the IO address space)

Something that's bizarre, is that for whatever reason, the game reads the value for each controller register, and then copies it to five non-continuous areas in ram, which makes debugging a lot more annoying. The two guns that you carry count as separate objects, and the relationship between them and the body is also really bizarre, which is also unfortunate. :|

I did find how to freeze the time though, so I don't have to worry about it running out. :lol:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: DRW, NovaSquirrel and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group