Solar Wars (UNROM version)

Moderator: Moderators

tepples
Posts: 22819
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Solar Wars (UNROM version)

Post by tepples »

Chris Covell has given us permission to include Solar Wars in the Double Action 53 multicart. So I mapper hacked it from CNROM to UNROM, which fits in better with the current menu program. Because the publicly distributed source code of Solar Wars lacks Memblers' music, I had to start from the binary, not the source code.

The patching tool requires Python 2.x, ca65, and ld65. It makes these changes:
  • Inserts two blank 16K banks before the game, leaving the original program at banks 2 and 3
  • Moves machine init code to bank 0
  • Compresses CHR ROM data with PB53 codec and adds it along with decompressor to banks 0 and 1
  • Replaces all five CNROM bank switches with calls to the decompressor
  • Adds quit code for Action 53 mapper at $FFEB
  • Fix for initial tank placement per 43110
  • Fix for tank movement stack overflow per 43110
Attachments
SolarWarsUNROM.zip
...and I didn't even need to go to stackoverflow.com
(65.09 KiB) Downloaded 1328 times
JRoatch
Formerly 43110
Posts: 428
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Solar Wars (UNROM version)

Post by JRoatch »

So there was a bug in the original and this version that made the game freeze randomly on the start of a round. Long story short here's the game genie code that'll fix it: ZIVYYIZG
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Re: Solar Wars (UNROM version)

Post by 3gengames »

Why not just post what to change in the code? I can't easily find a Linux GG decoder, plus we have to go back and change the source code anyway.
JRoatch
Formerly 43110
Posts: 428
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Solar Wars (UNROM version)

Post by JRoatch »

You are right, that is a bit opaque.
For this binary it changes from
$f566: jmp $f542
to
$f566: jmp $f552

If the source was available it basically corrects the InitP1X loop point in the subroutine InitTanks.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Solar Wars (UNROM version)

Post by ccovell »

The source has been available for 15 years: http://www.chrismcovell.com/data/SolarWarsSource.zip
http://www.chrismcovell.com/solarwars.html

Thanks for finding & correcting the bug!

Also, GG en/decoder: http://www.chrismcovell.com/CheatConverter.html
tepples
Posts: 22819
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Solar Wars (UNROM version)

Post by tepples »

ccovell wrote:The source has been available for 15 years: http://www.chrismcovell.com/data/SolarWarsSource.zip
In Diary.TXT in the zipfile, ccovell wrote:Because the music is entirely his work, and the code isn't mine, I won't be including his music data.
In any case, I've updated the mapper hack with 43110's patch. Thank you.
User avatar
Dwedit
Posts: 5066
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Solar Wars (UNROM version)

Post by Dwedit »

Using compression yet keeping in the easter egg image that only shows up in CHR viewers...
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
JRoatch
Formerly 43110
Posts: 428
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Solar Wars (UNROM version)

Post by JRoatch »

Found another potentially fatal bug, but only fatal in the UNROM version.

When a tank attempts to move up a wall (something like 5 or more blocks tall), a byte gets pushed to stack but never gets pulled. Since now half of stack is used for uncompressing CHR pages and that the call stack can be moved into that space. There's a potential situation where the call stack gets completely clobbered.

Quickest fix is to redirect 2 jumps to a part of the code that pops the value.
$db8c: jmp $dba9
$dc4c: jmp $dc69

As for where this is in source, I've been working off a personal disassembly (I was curious about the music engine) that doesn't have all the labels yet.
tepples
Posts: 22819
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Solar Wars (UNROM version)

Post by tepples »

Thanks for the fix. Can others bang on it before I put out DA53 RC2?
JRoatch
Formerly 43110
Posts: 428
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Solar Wars (UNROM version)

Post by JRoatch »

Maybe wait a day or two before RC2? it's up to you.

Also now reading my disassembly. I think the palette is at $e193-$e373, and the fading palette table is at $fb19-$fb59, and a immediate loaded byte at $e0b7 (all cpu address space). You could replace the blacker then black values in those ranges.

Edit: Edit: Actually there is lots of hard coded palette values in many places. It might be easier to finish labeling my disassembly and fix the blacker then black values from that.
Last edited by JRoatch on Thu Nov 20, 2014 3:03 pm, edited 2 times in total.
tepples
Posts: 22819
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Solar Wars (UNROM version)

Post by tepples »

Judgment call: I might end up leaving fixing $0D black for the remix compo.

This might help you understand the music code, as might this.
User avatar
Memblers
Posts: 4081
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Solar Wars (UNROM version)

Post by Memblers »

You guys know the source code to the Nerdtracker 2 engine has been available since day one, right?
http://nesdev.com/nt2/
http://nesdev.com/nt2/download/nedplay.zip

And about the music not being included with Solar Wars source, the way I supplied it to Chris was just a binary file, so you'll have same thing by ripping it out of the ROM or NSF. Unfortunately I lost (by overwriting) one of the .NED files included in the soundtrack, and while I might have the .DAT file for it sitting around, I have long since overwritten the "songs.asm" file that included the .dat files, so reconstructing it in source form would be, at best, a pain in the ass.

Thanks for fixing that bug, that's pretty awesome to see it gone after all this time.
tepples
Posts: 22819
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Solar Wars (UNROM version)

Post by tepples »

Thanks for clarifying.

Perhaps a good remix compo project might involve extracting the music (using the format doc I made) and converting it to something a more modern music engine can play, then doing a monster refactor of the game source itself to eliminate the cargo cult programming that was common in the pre-PowerPak days. Yes, I know it'll be a big job.


Wishlist
  • Dump all music as instrument and pattern definitions
  • Get the title screen music playing in a modern NES music player (such as FamiTone, GGSound, or Pently), as a proof of concept
  • Get the rest of the music playing
  • Eliminate use of color $0D
  • Thorough code review, eliminating what have since been discovered as poor practices
  • Compress the nametables!
  • Add crosshair to visualize the velocity better
  • Add alternate polar control scheme to match more conventional Scorched Earth/Gorillas clones
  • Add a way to display the tongueman
User avatar
Memblers
Posts: 4081
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Solar Wars (UNROM version)

Post by Memblers »

On the subject of wishlists, I've always thought Solar Wars would be a good test case for multi-player over the internet. Then you could chat, or type taunting messages while the other player is taking their turn. :) Could be done with cheap hardware, just USB/RS232 over the controller port, I remember after a long search finding some nice free software that was worked as a COM-port to TCP bridge, but I can't remember what it was called (I do believe the author is Russian, but it was documented in English as well). I'm sorta gradually working my way back to that problem again, because I'm definitely wanting internet access for some NES apps I'm working on, and in my case as well, it doesn't need to be low latency or anything.

Thinking about the Solar Wars soundtrack, I remember that the temp.dat file I used, which would have been track 0 in the NSF, was actually a blank file (probably with just note-off commands, and the DPCM note table), which means that I certainly do have all the .dat files here, I can see them here dated Oct 6th, 1999 which must have been the day I sent off the binary. So I could post the set of those, if they're really wanted. And/or NEDs for all but the lost one.
lidnariq
Site Admin
Posts: 11606
Joined: Sun Apr 13, 2008 11:12 am

Re: Solar Wars (UNROM version)

Post by lidnariq »

Memblers wrote:as a COM-port to TCP bridge
Socat should give you enough rope... although I don't know if cygwin's COMx:-to-ttySx emulation is adequate.

Or SLIP if you want something a little more general.
Post Reply