Infinest / Megadrive-Vector-Table-Reader

GNU General Public License v3.0
3 stars 0 forks source link

[Feature Request] Arguments for getting certain values #3

Closed ArcadeTV closed 1 year ago

ArcadeTV commented 1 year ago

I'd love some arguments getting parsed and outputted undecorated, for example:

mdvtr.exe -0x004 -l or mdvtr.exe -startProgram -l

where argument #1 is what I want to read and argument #2 is how I want to get it (e.g. a long word -l) could output 00000200.

Other arguments that come to my mind are:

Thanks in advance ! :-)

Infinest commented 1 year ago

Hey! Cool to see you're still doing MD stuff. πŸ‘ I currently don't have my dev environment set up on my current system but this should be a good excuse to finally do that.

I'm not entirely sure what you mean with the first argument. Do you want the application to just read a single pointer from the given offset? That's the only case in which "l" would really make sense i think. For reading the entire table something like "min(Byte)Width" would make more sense imo. That could also replace the "unp" argument.

The "prefix" argument should be fairly easy to implement and would definitely be a cool idea though.

I'll take a look at https://github.com/Infinest/Megadrive-Vector-Table-Reader/issues/2 when i get to work on this feature request, too. Thanks for bringing my attention to it!

ArcadeTV commented 1 year ago

Yes :-) I had some time to kill while waiting for my firstborn to arrive, so I prepped my MD stuff again and put some work into more automations. Then I used your fabulous tool as usual for auto-documentation, when I realized that it could be used to get MD vectors as single values (just as you described it, my explanation was hurried, but you got it right) for automatic file creation from the commandline.

That's great, thanks for looking into it! Looking forward to share an updated toolchain in the not too distant future.

Infinest commented 1 year ago

Congrats on becoming a father! It's nice talking to you again after so long. πŸ™Œ And no worries! I understood it just fine. ^^

Personally i'm still holding out hope for something like Mesen coming to come along for the Mega Drive. The lack of good debugging tools is one of the reasons why i've stopped doing MD+ stuff. Still curious to see your toolchain once it's done though!

Anyways, I'll update you when i got something. Should be able to work on it at the weekend.

ArcadeTV commented 1 year ago

Thanks! :-) Dito. Please don't stress it.

I just saw you made an MD+ intro - funny I made one for msumd and it gets inserted automagically in the updated toolchain by declaring the offsets for the original H and V Interrupts. I'm confident that this will be an automated process sometimes in the future 😍

Infinest commented 1 year ago

I think the only one that uses it is Super Street Fighter 2. It's just a static image that fades in and out but it's pretty neat, in that you simple have to change the pointer at 0x004 to the beginning of the intro code and then do a jmp at the end of the intro to the original vector.

ArcadeTV commented 1 year ago

Yes, that's how I made mine - also I used bypass-routines for v- and h-interrupts in the same manner. I have added you to my msu-md-columns repo to see the updated toolchain and intro-insertion. The next part for the toolchain is to add some kind of setup.bat that parses the source rom with your MDVTR once it's updated.

Infinest commented 1 year ago

I feel a bit stupid but #2 is a bug that i had already fixed ages ago but i never built another release. πŸ™ˆ Anyways, i made a bunch of adjustments to the code and hopefully it should more or less cover your needs now.

Here's the output when starting the application without arguments:

Usage: mdvtr.exe file [options]
  options:
    -p, --prefix:      Specify the prefix for the output vector/s [default: "0x"]
    -b, --bit-padding: Determines the padding for the output vector/s.
                       Bit padding must be supplied in decimal, must be a multiple of 4 and the following must apply 0 <= padding <= 32. [default: 32]
    -o, --offset:      If specified, only outputs the vector at the given offset.
                       Offset must be supplied in hexadecimal, must be a multiple of 0x4 and the following must apply 0x0 <= offset <= 0xfc. Allowed syntax: 0xXX or XX

Here's a sample input: mdvtr.exe "Streets of Rage 2 (USA).md" -p "$" -b 16 -o 0x10

This would give us the vector at offset 0x10 in this format $XXXX. In this case the output would be $0200

I've created a pre-release. Could you please give it a try and give me some feedback? https://github.com/Infinest/Megadrive-Vector-Table-Reader/releases/tag/1.1

PS: I just skimmed through your new repository. Definitely looks like a lot of work was put into it. You work always impresses me!

ArcadeTV commented 1 year ago

Thank you so much, I managed to spare some time for testing the complete no-intro set with this batch:

@echo off
for /f "delims=|" %%f in ('dir /b .\roms') do mdvtr.exe ".\roms\%%f">.\vectors\%%f.txt

I also tried different parameter variants and it looks real good! It's perfect.

The default prefix being "0x" works totally fine, I guess I would have made it default to blank, but this is just to save one parameter in my setup upon calling the tool, so if you feel like "0x" as default it's absolutely OK.

I will try to find the time and play around a little more with it. Thanks again, this is very much appreciated!!

Infinest commented 1 year ago

Great to hear it's to your liking and you're welcome! To be honest i'd like to leave the default at "0x" since that also affects the output for an input without --offset and i think it's more human-readable like that. I've gone ahead an change the current build from pre-release to latest release. I'll close the other issue and leave this one open for a few more days so you can tell me if you have any further issues with the changes. πŸ‘

ArcadeTV commented 1 year ago

Indeed the tool works on 99,9% of all up-to-date no-intro roms, but I have identified these as failing. The obvious reason is that their header is not consistant, for example there're things like " SEGA GENESIS " (mind the first space) instead of "SEGA GENESIS " causing it it fail.

I'd suggest to either

Action Replay (Europe) (Program) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Aq Renkan Awa (Taiwan) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Ball Jacks (Japan, Europe) (En).md 
The file specified is not a valid Mega Drive ROM.
-----------
Bao Xiao San Guo (Taiwan) (Unl) (Alt).md 
The file specified is not a valid Mega Drive ROM.
-----------
Bao Xiao San Guo (Taiwan) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Budokan - The Martial Spirit (USA) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
CDX Pro (World) (v1.70) (Program) (Unl) (Alt) [b].md 
The file specified is not a valid Mega Drive ROM.
-----------
CDX Pro (World) (v1.8I) (Program) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
European Club Soccer (Europe) (Beta) (1991-10-25).md 
The file specified is not a valid Mega Drive ROM.
-----------
Frog Dude (Europe) (Proto).md 
The file specified is not a valid Mega Drive ROM.
-----------
Golden Axe II (World) (Beta).md 
The file specified is not a valid Mega Drive ROM.
-----------
Ishido - The Way of Stones (USA) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Juusou Kihei Leynos (Japan).md 
The file specified is not a valid Mega Drive ROM.
-----------
Klax (Japan) (Namco).md 
The file specified is not a valid Mega Drive ROM.
-----------
Ma Qiao E Mo Ta - Devilish Mahjong Tower (Taiwan) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Magic Bubble (Taiwan) (En) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Mallet Legend's Whac-a-Critter ~ Mallet Legend (USA, Taiwan) (En) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Micro Machines (USA).md 
The file specified is not a valid Mega Drive ROM.
-----------
Nyuushi Chokuzen Check - Nanmon Kimon Kiki Kaikai (Japan) (Sega Channel).md 
The file specified is not a valid Mega Drive ROM.
-----------
Onslaught (USA, Europe) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Panorama Cotton (Japan) (Beta) (1993-11-27).md 
The file specified is not a valid Mega Drive ROM.
-----------
Phantasy Star Fukkokuban (Japan).md 
The file specified is not a valid Mega Drive ROM.
-----------
Phelios (Europe).md 
The file specified is not a valid Mega Drive ROM.
-----------
Phelios (Japan).md 
The file specified is not a valid Mega Drive ROM.
-----------
Phelios (USA).md 
The file specified is not a valid Mega Drive ROM.
-----------
Planet Message Quiz (Japan) (Sega Channel).md 
The file specified is not a valid Mega Drive ROM.
-----------
Populous (USA) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Pro Action Replay 2 (Europe) (v2.1) (Program) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Sega Art Tool (Japan) (En) (Program).md 
The file specified is not a valid Mega Drive ROM.
-----------
Sega Channel (Japan) (v2.11) (Earlier) (Program).md 
The file specified is not a valid Mega Drive ROM.
-----------
Sega Channel (Japan) (v2.11) (Program).md 
The file specified is not a valid Mega Drive ROM.
-----------
Shadow Dancer - The Secret of Shinobi (World) (Beta) (1990-10-02).md 
The file specified is not a valid Mega Drive ROM.
-----------
Shi Jie Zhi Bang Zheng Ba Zhan - World Pro Baseball 94 (Taiwan) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Sonic & Knuckles (World) (Lock-on).bin 
The file specified is not a valid Mega Drive ROM.
-----------
Street Smart (Japan, USA) (En) (Beta) (1990-06-29).md 
The file specified is not a valid Mega Drive ROM.
-----------
Target Earth (USA) (Beta) (1990-02-16).md 
The file specified is not a valid Mega Drive ROM.
-----------
Target Earth (USA).md 
The file specified is not a valid Mega Drive ROM.
-----------
Tom Clown (Taiwan) (En) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Triple Play - Gold Edition (USA).md 
The file specified is not a valid Mega Drive ROM.
-----------
Triple Play 96 (USA).md 
The file specified is not a valid Mega Drive ROM.
-----------
World Heroes (Asia) (En) (Beta) (1994-04-20) (Alt) [b].md 
The file specified is not a valid Mega Drive ROM.
-----------
World Series Baseball (USA) (Beta) (1993-12-22).md 
The file specified is not a valid Mega Drive ROM.
-----------
World Series Baseball (USA) (Beta) (1994-03-04).md 
The file specified is not a valid Mega Drive ROM.
-----------
Xin Qi Gai Wang Zi (Taiwan) (Beta) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Xin Qi Gai Wang Zi (Taiwan) (Unl) (Alt).md 
The file specified is not a valid Mega Drive ROM.
-----------
Xin Qi Gai Wang Zi (Taiwan) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Zany Golf (USA) (Unl).md 
The file specified is not a valid Mega Drive ROM.
-----------
Zombie High (USA) (Proto) (1992-08-11).md 
The file specified is not a valid Mega Drive ROM.
-----------
Infinest commented 1 year ago

Thanks for testing so thoroughly. I've gone ahead and made a couple more changes. First of all, i've fixed some minor bugs i previously hadn't seen. On top of that, the error messages within parseRom() are now explained in more detail. If absolutely necessary, you can now also disable the check for "SEGA" at 0x100 with -i or --ignore-identifier. I've created another pre-release: https://github.com/Infinest/Megadrive-Vector-Table-Reader/releases/tag/1.2

ArcadeTV commented 1 year ago

I like that :-)

The file specified is not a valid Mega Drive ROM. Valid Mega Drive ROMs should have contain the word "SEGA" at offset 0x100. To ignore this check use the parameter -i, --ignore-identifier.

The output is now complete after I added the -i option, though the numbering is messed up again but only with some roms, not all. Have a look at this zip of outputted textfiles. Extract it and sort by size descending, so the irregular ones are displayed on top: https://drive.google.com/file/d/1sjrokpdlauKdw4hQ8KxBynDiSQPueZ77/view?usp=share_link

Here's an example from Crack Down (Europe).md:

0x000 Initial Stack Address                     : 0x00ffff00
0xe04 Start of program Code                     : 0x00000200
0xe08 Bus error                                 : 0x00002cf6
0xe0c Address error                             : 0x00002cfc
0xe10 Illegal instruction                       : 0x00002d02
0xe14 Division by zero                          : 0x00002d08
0xe18 CHK exception                             : 0x00002d0e
0xe1c TRAPV exception                           : 0x00002d14
0xe20 Privilage violation                       : 0x00002d80
0x1e01 TRACE exception                           : 0x00303c01
0x1e05 Line-A emulator                           : 0x004eb900
0x1e09 Line-F emulator                           : 0x02292a61
0x1e0d Reserved (NOT USED)                       : 0x00006630
0x1e11 Co-processor protocol violation           : 0x3c02004e
0x1e15 Format error                              : 0xb9000229
0x1e19 Uninitialized Interrupt                   : 0x2a610000
0x1e1d Reserved (NOT USED)                       : 0x584cdf00
0x1e21 Reserved (NOT USED)                       : 0x014e7530
0x1e25 Reserved (NOT USED)                       : 0x3c02004e
0x1e29 Reserved (NOT USED)                       : 0xb9000229
0x1e2d Reserved (NOT USED)                       : 0x2a614430
0x1e31 Reserved (NOT USED)                       : 0x3ce0004e
0x1e35 Reserved (NOT USED)                       : 0xb9000229
0x1e39 Reserved (NOT USED)                       : 0x2a61384e
0x1e3d Spurious Interrupt                        : 0x75083900
0x1e41 IRQ Level 1                               : 0x0200ffe2
0x1e45 IRQ Level 2 (EXT Interrupt)               : 0x19660000
0x1e49 IRQ Level 3                               : 0x0c064000
0x1e4d IRQ Level 4 (VDP Horizontal Interrupt)    : 0x0b4eb900
0x1e51 IRQ Level 5                               : 0x0010564e
0x1e55 IRQ Level 6 (VDP Vertical Interrupt)      : 0x754a7900
0x1e59 IRQ Level 7                               : 0xffe01575
0xffffffffffffffff TRAP #00 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #01 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #02 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #03 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #04 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #05 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #06 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #07 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #08 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #09 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #10 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #11 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #12 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #13 Exception                        : 0xffe01575
0xffffffffffffffff TRAP #14 Exception                        : 0x7515e0ff
0xffffffffffffffff TRAP #15 Exception                        : 0xffe01575
0xffffffffffffffff (FP) Branch or Set on Unordered Condition : 0x7515e0ff
0xffffffffffffffff (FP) Inexact Result                       : 0xffe01575
0xffffffffffffffff (FP) Divide by Zero                       : 0x7515e0ff
0xffffffffffffffff (FP) Underflow                            : 0xffe01575
0xffffffffffffffff (FP) Operand Error                        : 0x7515e0ff
0xffffffffffffffff (FP) Overflow                             : 0xffe01575
0xffffffffffffffff (FP) Signaling NAN                        : 0x7515e0ff
0xffffffffffffffff (FP) Unimplemented Data Type              : 0xffe01575
0xffffffffffffffff MMU Configuration Error                   : 0x7515e0ff
0xffffffffffffffff MMU Illegal Operation Error               : 0xffe01575
0xffffffffffffffff MMU Access Violation Error                : 0x7515e0ff
0xffffffffffffffff Reserved (NOT USED)                       : 0xffe01575
0xffffffffffffffff Reserved (NOT USED)                       : 0x7515e0ff
0xffffffffffffffff Reserved (NOT USED)                       : 0xffe01575
0xffffffffffffffff Reserved (NOT USED)                       : 0x7515e0ff
0xffffffffffffffff Reserved (NOT USED)                       : 0xffe01575

This is the content of my bat file. I've put the no-intro set in .\roms and save the textfiles to a subfolder "vectors" for each romfile:

@echo off
for /f "delims=|" %%f in ('dir /b .\roms') do mdvtr.exe ".\roms\%%f" -i>.\vectors\%%f.txt
Infinest commented 1 year ago

I've pushed a small change and updated the binary attached to the pre-release. Could you please give it another try?

ArcadeTV commented 1 year ago

That did the trick! :-) Every ROM in the current no-intro set was parsed flawlessly, every outputted textfile has the same size, no errors or bugs whatsoever, great job and a heartfelt THANK YOU!

Now for my last tests, I will do add some more options and report back . after that I consider this marvellous tool waterproof!

Infinest commented 1 year ago

No problem my friend and thank you too! ☺️ Great to hear it's working without problem now. Just give me the final go-ahead once you're done and i'll put the pre-release as the latest release.

ArcadeTV commented 1 year ago

Done! I've added all possible combination of options to the batch and everything went smoothly! Random example output:

Gain Ground (Japan) (En).md
Start of program Code: $202
VDP Horizontal Interrupt: $30e0
VDP Horizontal Interrupt: $2e22

The last remaining bit is to implement this into my build.bat and release it as a template boilerplate for new hacks.

Well done! Thank you so much! :-)

ArcadeTV commented 1 year ago

Oh, and for any future versions, pls consider a -v / --version option ;-)

    _/_/_/                _/_/  _/                                  _/      
     _/    _/_/_/      _/          _/_/_/      _/_/      _/_/_/  _/_/_/_/   
    _/    _/    _/  _/_/_/_/  _/  _/    _/  _/_/_/_/  _/_/        _/        
   _/    _/    _/    _/      _/  _/    _/  _/            _/_/    _/         
_/_/_/  _/    _/    _/      _/  _/    _/    _/_/_/  _/_/_/        _/_/      

MEGA DRIVE VECTOR TABLE READER v1.2 2023-03-20
https://github.com/Infinest/Megadrive-Vector-Table-Reader
Infinest commented 1 year ago

You are very welcome and wow! Thank you so much for the logo, it looks really cool. In fact, i like it so much, that i went right ahead and added the -v, --version arguments. ^^

Anyways, i'll close this issue tomorrow unless you've got any additional suggestions. Again, thank you for helping me improve this application. I pretty much just whipped it up really quick back then as a way to try my hand at C++ again. However with these additions i think it's actually become a quite helpful tool to actually use.πŸ‘

/Edit: I just pushed another tiny bug fix so please redownload the release if you already downloaded it. (20/03/2023 23:53)

ArcadeTV commented 1 year ago

The -v option looks soo tight in terminal 😍

ArcadeTV commented 1 year ago

I've tested the latet bugfix release again with all options, no issues found :-)