November 21, 2024, 08:15:11 AM

Author Topic: External playbook editor  (Read 74402 times)

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #30 on: June 10, 2016, 01:55:56 PM »
No problem at all. I've been keeping busy trying to get this hack done without having glitches. Currently I have gotten it so that I can have the 5 offensive pages when using default plays, but now there is an issue when using the custom playbook. I don't think it should be too hard to fix though. I also want to find out how to increase the number of pages for the defensive side. I'll post a patch for the ROM when it's finished.
« Last Edit: June 10, 2016, 01:57:34 PM by blitzmaster5000 »

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #31 on: June 13, 2016, 10:58:49 PM »
Almost have the extended playbook hack done! It works perfectly with the default plays, just need to work out a few kinks with the custom playbook.

Basically the issue is when the custom playbook is loaded in, it loads all the data from the MPK file, which includes the "custom playbook". However, with the hack I'm doing, this custom playbook is unnecessary as we will already have all those plays in the game. I'm still trying to find out how to fix it so it will load all the same plays as it would normally.

jaker3

  • Administrator
  • Sr. Member
  • *****
  • Posts: 334
    • View Profile
Re: External playbook editor
« Reply #32 on: June 16, 2016, 09:45:09 AM »
only got about an hour or so worth of work in this week on the projects.

But finally got it out on github:
https://github.com/thompjake/NFL-Blitz-Play-Maker

I was thinking the other day... would it be possible to store custom plays in the rom and change the function to pull them from the rom versus the memory pack?

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #33 on: June 16, 2016, 02:43:42 PM »
only got about an hour or so worth of work in this week on the projects.

But finally got it out on github:
https://github.com/thompjake/NFL-Blitz-Play-Maker

I was thinking the other day... would it be possible to store custom plays in the rom and change the function to pull them from the rom versus the memory pack?


This definitely crossed my mind as well! I found where the MPK data is loaded into the game (or at least where the first playbook is stored). I think we should be able to do this actually. We would just to write the exact data of the custom plays to the area in the ROM.

What I'm thinking we could possibly do is have the program you're working on dump the data directly into the ROM. I think we maybe able to modify the function that loads the custom plays to trigger even when there is no memory pak (to avoid having to load up the custom playbook everytime).

I can post some of the assembly here to help explain how the data is read/written. I'm still working on the playbook when a custom playbook is loaded. Should be done soon.

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #34 on: June 20, 2016, 04:55:06 PM »
I played a bit with some friends using the extended playbook. It was awesome! One of them mentioned that it seemed like the timer was shorter, but it was really just having the extra plays makes it seem like it's shorter as there's more to go through, so I increased the play select timer from 9 to 20 seconds.

I was thinking more about what you said for the custom playbook, dumping it right onto the ROM. I now know where it is all loaded into memory and how to increase the size of the custom playbook. Because the game just has all these plays in line, we maybe able to just add more and more sequentially and then tell the game that there are 2 or 3 (or however many) custom pages there are. If it works, we could have essentially an infinite amount of custom plays.

jaker3

  • Administrator
  • Sr. Member
  • *****
  • Posts: 334
    • View Profile
Re: External playbook editor
« Reply #35 on: June 20, 2016, 07:57:16 PM »
Thats awesome! Was going to suggest changing the play select clock, by the time you flip to page 5 half the time was gone haha. Make Any headway on inserting custom plays in the ROM? I hope to get loading plays from the save files done this week.

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #36 on: June 21, 2016, 12:20:10 PM »
Not quite yet. I've been first trying to increase the number of pages on defense before anything. Those plays are loaded slightly differently than the offensive ones because in the default case there is only 1 page, so I haven't found a register that acts as a page "counter". I may have to just add in some code to act as this, to allow for more defensive pages.

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #37 on: June 24, 2016, 04:36:47 PM »
Got the defensive playbook size increased. It only goes from 1 to 2 pages, but it's better than just the 1. It's still buggy with custom plays though.

I also noticed a bug with the offensive extended playbook when using custom plays - if you press B (flip play button) on page 2, it will switch to the custom play page with them flipped. It still works, it's just not supposed to happen.

I'm thinking about how exactly we can load the custom play data into the RAM where it needs to go (starts at address 802ADF20). An issue I foresee is that there are many addresses for the custom plays, so I don't know if there's anywhere in the ROM that has enough empty space to stick this data. The alternative is to try and make the game write the memory pak file into the RAM immediately instead of waiting. If multiple people made the own plays on different memory paks, we would still need to combine them into 1 mpk file which could then be loaded into the RAM. I guess it's not the end of the world if we can't get the mpk data directly in the ROM, but it would be nice as we wouldn't have to load the custom playbook each time.

I really want to see if the play data is the same for 2001 now... I may try and import a few of those plays to see. If so, we maybe able to get in enough default plays to make a 6th offensive page and 3rd defensive one.

Here is the code for the extended playbook/timer in case you're curious how it was done.

Code: [Select]
=======================
changes to Version 2.2
=======================
Fixed defensive play issues
0xD2980 8032E930 XORI V0, S3, 0x0002 //moves actual custom custom play data to last page

=======================
changes to Version 2.1
=======================
//fixing default play flipping issue w/ play 5
8032E7E0 SW T1, 0x002C (SP) //stores into 800C2C84; flip play - boolean 0 or 1; each is for normal or flipped
0xD7298 8032E748 XORI V0,S3, 0x0005 //Fixes flip page issues for custom plays, must be == to number of pages; originally 0x0002
0xD27AC 8032E75C SLTI V0,S3, 0x0006 //Fixes flip page w/ default plays; must be > # of pages; originally 0x0004



==========================================
changes to ROM blitzXL_V20.z64
==========================================
//extending playbook - default and custom
0xD2590 8032E540 ADDIU V0,R0,0x0005 //sets 5 pages for default playbook
0xD25D0 8032E580 SLTI V0,S3,0x0006 //sets 6 pages for custom playbook
0x34130 8024D410 ADDIU V0,A1,0x1399 //original 1369; moves defensive play data back to make room for new plays
0x34150 8024D430 SLTI V0,A3, 0x0023 //original 0009; allows all play table data to be written
//fixing playbook to read/write correct plays
0xd1924 J 0x80070C28 //ORIGINALLY addu a0,v0,v1 ; 71828 IN ROM; jump to new area to make playbook pages correct
0xd1928 addu a0,v0,v1 //ORIGINALLY LW V0, $0000 (A0)
0x71828 LW V0, 0x0000 (A0) //line needed from original function
0x7182C ADDU S4,S5,R0 //sets correct page number; may not work w/ custom plays
0x81730 ADDU A1,S5,R0 //sets correct page number; may not work w/ custom plays
0x71830 j 0x8032D8DC //jump back; D192C IN ROM; this is address from NEMU; calculated one didn't work
//move custom pages around - puts custom plays last - still need to fix page #
0x37B44 80250E24 ADDIU T0, A2, 0x1350 //original 0x1370; writes the entire first playbook; truncate may damage last play; make sure to only truncate play data
0xd2558 8032E508 XORI V0,S3, 0x0005 //original 0x2; sets playbook on the last page (versus 3rd)
0xd2a20 8032E9D0 ADDIU T1, R0, 0x0005 //original 0x2; sets playbook on last page; not changing this freezes game
//fix how to load in data for multiple playbooks for p2,p3,p4
80250E00 BEQL V0,R0, $XXXX // originally SUBU V0,V0,A0; jump to 80250E10 if first playbook
80250E04 NOP // originally SLL V0,V0, 0x4; delete for branch
80250E08 SUBU V0,V0,V0 // originally SUBU V0,V0,A0; set V0 = 0
80250E0C ORI V0,V0, 0x13C0 // originally SLL V0,V0, 0x3; set size of playbook to be larger
//fixing page 4 custom - above fixes the graphics and text, but this will fix actually loading correct play data
0xd1750 8032D700 J $00070C3C //originally lui v1, 0x8037; is 7183C in ROM
0xd1754 8032D704 lui v1, 0x8037 //originally addu v1,v1,v0
0x7183C addu v1,v1,v0 //entry point at jump
0x71840 addu a1,s3,r0 //copy s3 value (correct page #) to a1
0x71844 J $8032D708 //jump back to RAM address; is d1754 in ROM
//DEFENSE - add more pages (currently 2, default 1)
0xD26B8 BEQ R0, V1, 0x000D26B8 //branch if custom play or not; same as original code
0xD2698 SLTI V0,S3, 0x0003 //puts custom play page last; originally 0x0002
0xD26A4 ADDIU T1, R0, 0X0002 //increases to 3 pages for custom playbook; originally 1
0xD26B8 J $80070C70 //jumps to same page change code as offensive, just with page total = 2; 0x71870 IN ROM
0x71870 **page change code** //same code as that for offensive play select (found at 0x8032e5a4)
0x71890 SLTI V0,S3, 0X0002 //set playbook size to 2 pages (for defense); ORIGINALLY 1
0x7189C ADDIU T1, R0, 0X0002 //set playbook size to 2 (no custom plays)
0x7199C **end of page change code**
0xD2980 XORI V0, S3, 0x0002 //moves actual custom custom play data to last page

//Increasing playbook timer //
//Time stored in 800BCB68
//800BCB98 similar to timer
0xd7710 LW S0, 0x0000(A0)
0xd7714 J 0X80070C4C //originally LWC1, F2, 0x0004(A0); 7184C IN ROM
0xd7718 LWC1, F2, 0x0004(A0) //originally CVT.S.W F2, F2
0x7184C CVT.S.W F2, F2
0x71850 SUB S0,S0,S0 //SET S0 = 0
0x71854 ORI S0,R0, 0X0014 //INCREASE TIMER TO 20 SECONDS
0x71858 J 0x800D6B1C //JUMP BACK TO D771C IN ROM

Edit: got pretty much all the bugs figured out! Fixed the flipping play issue and got custom plays working perfectly for defense. I changed how the extra plays were added on the defensive side too and changed the code to represent it.

I think the only thing left is making the custom playbook work for players 2,3,4.
« Last Edit: June 26, 2016, 09:04:55 AM by blitzmaster5000 »

jaker3

  • Administrator
  • Sr. Member
  • *****
  • Posts: 334
    • View Profile
Re: External playbook editor
« Reply #38 on: June 27, 2016, 07:39:14 PM »
Hey BlitzMaster,

Whats the Rom location for the playbook information?

Also started on the memory pack saving/editing functionality. might take a bit longer, but nothing difficult.

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #39 on: June 27, 2016, 08:38:30 PM »
Jake,

Do you mean the default playbook or custom one? If you mean the actual play data for the default plays, it's all over the place being referenced by the table info Zoinkity mentioned (I think this table starts around 80291398). It's not easy to follow - it seems each play has ~7 addresses it jumps to for what I assume to be the routes/actions for each player. This is the data that I had previously mentioned is really hard to understand. I haven't played around with it much since then as I've been focusing on getting the extended playbook going.

However, based on where the play table data sends you, I think the beginning of the actual default play data is around 0x72D00 (RAM = 8028BFE8) and ends around 0x73AB0  (RAM = 8028CD98).

If you mean where the game stores all of the custom playbook data, it isn't actually on the ROM (obviously) as the data is pulled from the memory pak and then stored in memory starting at address 802ADF20. This is also where the list of plays for the default playbook is at as well (starting at address 802AF26E, which is right after the very last defensive custom play). All the game does is fill in the blank spots w/ the player made data when you load custom plays.

The game automatically loads a list of plays (the function that writes these is at 8024D3EC if you're interested in how it writes the data) when the game starts. In the normal version (no extended playbook), it will load up
802AF26C 00010203
802AF270 04050607
802AF274 08090A0B
etc up to 27 plays (9 plays per page x 3 pages), and do the same sort of thing for defensive plays.

I have modified it to go up to 35 plays though, so there is a bit more data in that part. This mean's I'm needing to offset all of the playbooks after the 1st one, as each has slightly more data now for the extra plays than before.

I will post an in depth explanation of how the game loads/stores everything tomorrow for clarification. It will be helpful as it will show what I'm changing as well to allow the extended playbook + custom plays.

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #40 on: June 28, 2016, 08:30:28 PM »
Alright I got everything working perfectly I think! I tested out 4 custom playbooks simultaneously and I didn't have any issues. It had both the extended default playbook as well as the extra offensive and defensive custom play pages. So now that that's done, I could probably help a bit more on the external playbook editor. Let me know how it's going and if there's anything in particular I can help with.

I will also start digging around Blitz 2001 to see if I can find that play data and possibly import it into this version.

edit: Found the play data and tables linking them in 2001. The data looks almost identical, so I'm thinking we maybe able to import them without too many changes. There are few things we would need to figure out/do first though:

1. The current play data in 2000 has the tables linking the raw data. I'm not sure how the playbook looks up the table, so I need to figure this out. Each play has a hex value associated with it that the playbook references that is then pulling in the data using the tables at 80291398.

2. Once we figure out how it pulls the data in, we maybe able to stick the new table and data from 2001 in there somewhere and simply update the pointers.

I'm sure it will be more complicated than that, but would be pretty awesome if this works. We would have probably ~7 default offensive and ~3-4 default defensive plays. Then once the external playbook editor is done, we will have more plays than we will probably ever need!
« Last Edit: June 30, 2016, 01:02:52 PM by blitzmaster5000 »

jaker3

  • Administrator
  • Sr. Member
  • *****
  • Posts: 334
    • View Profile
Re: External playbook editor
« Reply #41 on: June 30, 2016, 07:39:19 PM »
Sounds legit Blitzmaster! Do you happen to know if there is any index on the MPK files that state how many plays are in a book? Or if there is a delimiter that dictates the end of a playbook?

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #42 on: June 30, 2016, 08:25:26 PM »
Jake,

There is no index on the MPK saying how many plays there are as far as I know. Each playbook has a set amount of space that will be filled in with each play. When you generate a new play, it replaces all the 0's with the play data. So it just fills in the blanks essentially.

As far as the end of the playbook is concerned - Yes, there is common data at the end which corresponds to the default playlist you can load up - it looks like 00010203 04050607 08090A0B.... However this data will be obselete with the expanded playbook as we will have all plays loaded at all times.


The way the game works is it sets aside RAM for the whole MPK file, from about 802ADF20 ~ 802B2CD6.  These are all blank except for the parts related to the default plays.

The spacing between playbooks is exactly like it is in the MPK. So when you load a playbook, it will load up all the values into the empty space here. So if you're playing as P1, it will fill the data starting at 802ADF20. If you play as P2, it will load the data into 802AF298. P4, will be 802B1988.

Here's an image of the RAM of the default playlist for P1, before and after I loaded the P2 custom playbook, which shows up right after the end of the first playbook's playlist (you can move these around actually which I will talk about more below).

before:


after:



You can see that just after the first custom playbook play list (from 802AF62C to 802AF28C), some new data was loaded. It's literally the exact same data being loaded from the MPK file.

What I found is that you can specify where to put each playbook. This means we could potentially expand each playbook in the MPK, that will then be imported into the game. Assuming can then reference the extra plays, we should be able to import more than 1 page of offense and defense.

jaker3

  • Administrator
  • Sr. Member
  • *****
  • Posts: 334
    • View Profile
Re: External playbook editor
« Reply #43 on: July 01, 2016, 09:30:12 AM »
Looks like that 3rd byte is blocking for linemen.

Here are all the addresses for the first playbook first play with the scheme "side I". All the coordinates for the players are listed.

Code: [Select]
Playbook 1 addresses - scheme is side I; values for players are for this scheme

0x31D8 //playbook name, 6 characters
0x31DE //pin number, 4 characters
0x31E2 //play 1 name line 1, 8 characters
0x31EA //0x00
0x31EB //play 1 name line 2, 8 characters
0x31F3 //0x00
0x31F4 //0x04
0x31F5 //0x03
play data
x y ? action
0x31f6 11 08 00 80 // left lineman
0x31FA 00 00 00 00 //
0x31FE 00 00 00 00 //
0x3202 00 00 00 00 //
0x3206 00 00 00 00 //
0x320A 00 00 00 00 //
0x320E 00 00 00 00 //
0x3212 00 00 00 00 //
0x3216 14 08 00 80 //center lineman
0x321A 00 00 00 00 //
0x321E      00 00 00 00 //
0x3222 00 00 00 00 //
0x3226      00 00 00 00 //
0x322A 00 00 00 00 //
0x322E 00 00 00 00 //
0x3232 00 00 00 00 //
0x3236 17 08 00 80 //right lineman
0x323A 00 00 00 00 //
0x323E      00 00 00 00 //
0x3242 00 00 00 00 //
0x3246      00 00 00 00 //
0x324A 00 00 00 00 //
0x324E 00 00 00 00 //
0x3252 00 00 00 00 //
0x3256 14 05 00 80 //QB
0x325A 00 00 00 00 //
0x325E 00 00 00 00 //
0x3262 00 00 00 00 //
0x3266      00 00 00 00 //
0x326A 00 00 00 00 //
0x326E      00 00 00 00 //
0x3272 00 00 00 00 //
0x3276 19 04 00 80 //WR1
0x327A 00 00 00 00 //
0x327E 00 00 00 00 //
0x3282 00 00 00 00 //
0x3286      00 00 00 00 //
0x328A 00 00 00 00 //
0x328E      00 00 00 00 //
0x3292 00 00 00 00 //
0x3296 1C 08 00 80 //WR2
0x329A 00 00 00 00 //
0x329E 00 00 00 00 //
0x32A2  00 00 00 00 //
0x32A6      00 00 00 00 //
0x32AA  00 00 00 00 //
0x32AE      00 00 00 00 //
0x32B2    00 00 00 00 //
0x32B6 1C 06 00 80 //WR3
0x32BA 00 00 00 00 //
0x32BE 00 00 00 00 //
0x32C2  00 00 00 00 //
0x32C6      00 00 00 00 //
0x32CA  00 00 00 00 //
0x32CE      00 00 00 00 //
0x32D2    00 00 00 00 //
0x32D6 00 00 00 00 //?? all plays have similar code at end
0x32DA 00 00 00 08 //??
0x32DE    01 14 00 02 //??
0x32E2 00 01 02 02 //??
0x32E6 02 04 06 06 //??
0x32EA 06 00 01 00 //??
0x32EE 02 03 03 03 //??
0x32F2 00 00 //??

blitzmaster5000

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: External playbook editor
« Reply #44 on: July 05, 2016, 08:47:33 PM »
Been looking more into importing some of the 2001 plays into the hacked 2000 version. Based on everything I see, it seems like it should be possible, just need to copy+paste in that data and then update the tables.

If we could get these in there, I was hoping to also add the images for the plays. How exactly would we be able to import the image back into the ROM? I think there's a pointer for each playbook play image, so I'm wondering if we could stick the new images somewhere and just point to them. I'm just not sure how to add new image files into the ROM.