Slashdot Mirror


Game Boy Zelda Comes With Source, Sort Of

Jamie found a fun story about a 90s Zelda Game Boy ROM that shipped with the source code- not so much on purpose, but more because the linker padded out the last meg of ROM with random memory contents, which happened to include game source code.

32 of 200 comments (clear)

  1. Avoiding the malloc() by kcbanner · · Score: 4, Informative

    I guess the only way to really avoid the malloc() calls grabbing your source code would have been to compile, then reboot to link...so the extra data thats padded on the end of the ROM image would just be your emtpy RAM contents.

    --
    Obligatory blog plug: http://www.caseybanner.ca/
    1. Re:Avoiding the malloc() by simcop2387 · · Score: 5, Informative

      thats what calloc is for, it'll clear it for you, malloc just gets it.

    2. Re:Avoiding the malloc() by billcopc · · Score: 5, Informative

      When you're a ROM developer, you don't think in such terms. It's all about mapping this and interleaving that.

      Rather than writing the extra few lines to calculate the padding required, set up a 0-filled buffer and truncate the first (or last) buffer, rounding up the fwrite call to 2mb requires 0 extra lines.

      Besides, they don't expect many people to actually look at the ROM code. This emulation craze is fairly recent.

      --
      -Billco, Fnarg.com
    3. Re:Avoiding the malloc() by Carrot007 · · Score: 5, Insightful

      > This emulation craze is fairly recent.

      What? I really mean it what?

      I remeber running sonic (megadrive) on a low end pentium (133) back in the day, albeit with no sound.

      I also remeber using various earlier emulators on my amiga before that (speccy and such).

      Maybe you have a differnet definition of recent than me though.

      --
      +----------------- | What is the question!
    4. Re:Avoiding the malloc() by Anonymous Coward · · Score: 5, Insightful

      "Maybe you have a differnet definition of recent than me though."

      No, he just apparently has a different definition of "craze" to you. Being the only person in your state to emulate a megadrive on a low-end Pentium without sound doesn't mean that's when the emulation craze started. That was just you pushing the boundaries of what was available at the time. The average gamer wouldn't have understood you back then if you said the word "emulation" to them.

      Only in recent years have so many people been emulating earlier consoles and arcade games on their home PCs, with pretty faithful representation of the original experience.

    5. Re:Avoiding the malloc() by kevmatic · · Score: 4, Informative

      First release of Zsnes was in 1997. It was designed to run on 486es, and was written in heavily optimized ASM.
      NESticle was also released in 1997. These pretty much sparked a craze, and lead to the creation of the Emulation Community and its Golden Age was pretty much in full swing by the middle of 1998.

      It has pretty much died, but Zsnes is still under very active development and the new pSX Emulator has revitalized Playstation emulation since ePSXe hasn't been updated in years and leaves MUCH to be desired.

      http://www.romhacking.net/ for info on ROM hacking.
      http://psxemulator.gazaxian.com/ for pSX Emulator. Try it!

  2. Deja Vu by hlomas · · Score: 5, Funny

    News Post Comes With Article, Sort Of

  3. Air Fortress (NES) had exact same issue! by Dwedit · · Score: 4, Informative

    Air Fortress (Famicom version) also included a portion of the source code due to not clearing memory before linking.

    1. Re:Air Fortress (NES) had exact same issue! by Indefinite,+Ephemera · · Score: 4, Informative
  4. Not true by Megane · · Score: 5, Informative

    Now the site is Wordpressed (like Slashdotting, only the other way around) and you can't get to it, but one of the last posts before it died pointed out that this was from a trainered version. That's where someone adds cheat code to a ROM. As it turns out, the original doesn't have any of the code in question. Dissassembling for the purpose of adding cheats is a completely sensible explanation of the code that was found.

    The moral of the story? Start with a known clean dump (look for the "[!]" tag) before assuming that the introns were in the original game.

    --
    #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    1. Re:Not true by Kjella · · Score: 4, Funny

      Now the site is Wordpressed (like Slashdotting, only the other way around) and you can't get to it, Uhh, the wordpress site is down and slashdot is up - that's a classic slashdotting. A "wordpressing" would be if the wordpress blog linked to slashdot, and enough people came to slashdot to bring slashdot down (good luck on that).
      --
      Live today, because you never know what tomorrow brings
    2. Re:Not true by stoolpigeon · · Score: 5, Funny

      well he did say it was from digg- no need to be redundant.

      --
      It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    3. Re:Not true by Bert64 · · Score: 4, Interesting

      Yes, wordpress is rather inefficient...
      How do php accelerators such as eaccelerator affect it, and what level of hardware would you need to handle a significant load of wordpress hits?

      --
      http://spamdecoy.net - free throwaway anonymous email - avoid spam!
  5. This is a non-story by Dwedit · · Score: 4, Informative

    This is a non-story. This only applies to a specific Pirate ROM Dump of Zelda DX. The clean dump does not contain any embedded source code.

  6. It happens by Diomidis+Spinellis · · Score: 5, Funny
    This used to happen more often than one would expect. In the 1980s I found portions of Ashton Tate's Framework II source code in "blank" sectors of floppy disks containing printer drivers. Those were the days where:
    • each application came with its own display and printer drivers,
    • people were using floppy disks to move around source code, and, worse,
    • other people had enough free time to trawl "blank" sectors for interesting tidbits.
    1. Re:It happens by urcreepyneighbor · · Score: 4, Funny

      other people had enough free time to trawl "blank" sectors for interesting tidbits. Eh? I still do that.... Then again, I am urcreepyneighbor....
      --
      "The fight for freedom has only just begun." - Geert Wilders
    2. Re:It happens by PCM2 · · Score: 5, Funny

      A company I worked for once participated in the beta test program for Adobe Illustrator ... I think it was version 7. We were primarily a Mac shop, so we were using the Mac versions of the CD-ROMs they sent us. One build they sent us had a funny property... when you put the CD-ROM in the drive, the Trash can would turn full. Oh but wait -- before you old Mac people start going "ho ho ho," there wasn't actually anything important in the Trash can. But that's when I noticed that a couple of extra folders would appear on the desktop, too. ;-) In one of those was about 340MB of source code for Adobe Illustrator, Dimensions, Streamline and some other stuff.

      About four days after we received this particular build (and I had noticed its interesting attributes) I got a call from Adobe:

      Adobe: There are problems with the latest build of Illustrator. We need to recall those CD-ROMs immediately.

      Me: Gosh ... sounds bad. Problems?

      Adobe: Yes. We will be sending you a prepaid FedEx return envelope. It's extremely important that you return those discs to us right away.

      Me: I see. Oh, my. Look ... can you tell me what the problem is? It's not a virus, is it?

      Adobe: I can't really say. It's a technical issue. But if you've installed Build 378468434 on any of your equipment, you should un-install it right away.

      Me: Oh, dear. Oh, dear oh dear. I will do so, ma'am, immediately. It ... it wouldn't damage any of our systems, would it?

      Adobe: Um... you should be OK. But, just to be on the safe side you should be sure to uninstall it from any of your machines and make sure you send those CDs back to us right away.

      Me: Yes ma'am, will do.

      Adobe: Thanks, have a nice day.

      Me: (pushes eject button on CD-R burner, grabs a Sharpie)

      --
      Breakfast served all day!
    3. Re:It happens by Deadstick · · Score: 4, Interesting

      Ashton-Tate wasn't above having somebody ELSE's code in their products either. When they wrote the "laser burn" copy protection routine for dBase III, they needed to put a hook in the BIOS -- which wasn't so easy in those days of expensive memory, because the BIOS used to run directly from ROM instead of being shadowed out into RAM. So they wrote their own BIOS -- by which I mean, they copied some 700 bytes of the IBM Fixed Disk BIOS (which was published in the PC-XT user manual), added the hook, and then hid the dirty deed under an encryption routine that was absurdly simple (although very tedious on a floppy machine) to penetrate.

      It was obvious they knew they were writing a pirate product, because they went through the code and swapped arithmetic and logical shift instructions wherever they were certain to produce identical results, presumably in order to get the fraction of identical bytes down.

      rj

  7. Re:Whoops... by mouse_8b · · Score: 5, Funny

    Awesome. :) This must be why they always say not to code whilst drunk. Who says that? They should be shot.
  8. Not too uncommon by 0123456 · · Score: 5, Interesting

    One of the 'Elite' sequels was shipped with a swap file on the CD-ROM. Opening that swap file with a text editor showed it included much of the C code for the game, which presumably must have been swapped out while they were compiling at some point and then copied to the CD by mistake.

    From what I remember the installer copied the swap file to the hard disk, but the first patch either deleted it or zeroed it :).

    1. Re:Not too uncommon by vranash · · Score: 5, Interesting

      Having that game (Which was actually Bethesda's Sea Dogs 2 rebadged before release.) It had a *TON* of files with it, although I think they were lua-scripts or something, not actual c-code. Regardless they had a lot of options available in them for modifying core components of the game. You could change your characters starting stats, name, ship type, etc. Given the somewhat frustrating land-side swordplay, I ended up having more fun tweaking the game than playing it.

      Having reminded me, I may have to dig it out sometime soon and see what else it's got going.

  9. Partially Not Not true by hxnwix · · Score: 4, Insightful

    Now the site is Wordpressed When slashdot brings down a site running Apache, we call it slashdotting, not Apache-ing. When slashdot brings down a site running wordpress, we call it slashdotting, not wordpressing.

    the original doesn't have any of the code in question Are the other games mentioned also trainered?

    "X-Men - Wolverine's Rage" (MD5: b1729716baaea01d4baa795db31800b0), which contains Windows 9x registry keys and INF files, "Mortal Kombat 4 (MD5: 7311f937a542baadf113e9115158cde3), in which you can find some small source fragments, "Gift" (MD5: e6a51088c8fea7980649064bd3a9f9ff), which will tell you that the developers had some Game Boy emulators installed on their system, or the "BIT-MANAGERS" games "Spirou" (MD5:5aa012cf540a5267d6adea6659764441, Turbo C, MAP file, source) and "TinTin in Tibet" (Game Boy Color version, MD5: 8150a3978211939d367f48ffcd49f979), which, amongst other things, contains references to Nintendo's Game Boy Advance (!) SDK ("C:\Cygnus\thumbelf-000512\H-i686-cygwin32\lib\gcc-lib\thumb-elf\2.9-arm-000512, "/tantor/build/nintendo/arm-000512/i686-cygwin32/src/newlib/libc/stdio/stdio.c").
    1. Re:Partially Not Not true by ConceptJunkie · · Score: 4, Funny

      Now the site is Wordpressed

      When slashdot brings down a site running Apache, we call it slashdotting, not Apache-ing. When slashdot brings down a site running wordpress, we call it slashdotting, not wordpressing.

      Except Wordpress comes pre-Slashdotted for your convenience.

      --
      You are in a maze of twisty little passages, all alike.
  10. Re:Whoops... by JensenDied · · Score: 4, Funny

    Someone has never heard of the Ballmer Peak.
    Windows ME is why they say not to code the entire project smashed though.

    --

    09:F9:11:02 - 9D:74:E3:5B - D8:41:56:C5 - 63:56:88:C0

  11. There's more by Kayamon · · Score: 5, Interesting

    Golden Axe 2 (the arcade ROM) has a good chunk of it's source code contained in there too, including the source for it's security routine (oh the hilarity...)

    And the PAL version of ICO (PS2) had an objdump of the entire ELF on the disc, which is basically a disassembly with full symbol information.

    --
    Kayamon
  12. Re:Malloc clears? by 0123456 · · Score: 4, Informative

    "What do they mean by clear the memory? Because when I malloc() (and not calloc()) I seem to get whatever was there before.."

    But you don't get anything from another process. When malloc() runs out of memory and asks for a new chunk from the operating system, a modern system will usually zero the block that it returns, whereas some older operating systems (e.g. MS-DOS, I think?) would just give a pointer to a chunk of free memory which could still contain any data that the previous user had left in it; that could be any program which had previously run on the machine.

    When you free something and call malloc() again afterwards, you may well get a block with old data from your program. But in most cases you won't get a block with old data from a different program.

    The same applies to disk files; with some operating systems in the past you could open a file, write a byte a megabyte into the file and then read a megabyte of old data preceding it in free blocks which had been allocated to you and not cleared. That was obviously a big potential security hole, so most modern operating systems will zero all the data in the file instead (more precisely, they'll probably allocate a sparse file which will return zeros from areas which haven't been written to).

  13. Re:Giving up. by ceoyoyo · · Score: 4, Funny

    "Stuff that matters" is sarcastic.

    Actually, I've noticed that lately it says something about going outside. Also sarcastic.

  14. Does anyone else... by achenaar · · Score: 5, Funny

    find it amusing that this happened because of the Link-er.
    I can't be the only one...
    Can I?

    I'll get me coat.

  15. Re:Malloc clears? by mikael_j · · Score: 4, Insightful

    I think you're giving MS-DOS too much credit when it comes to memory management. Basically, it was single-tasking so you could just use whatever memory you wanted to.

    /Mikael

    --
    Greylisting is to SMTP as NAT is to IPv4
  16. FoxPro by Anonymous Coward · · Score: 5, Interesting

    Posted anonymously to hide my shame of working with visual FoxPro.

    FoxPro, I discovered after shipping our product for 2 years, didn't really compile anything when you made an .exe It just included a runtime and the source code in the .exe file. If you looked at it ina hex editor, there was the full source code, complete with comments. Apparently there was an option to scramble the source code. The guy responsible for building the installation didn't do that.

  17. opensource by Paul_Hindt · · Score: 5, Funny

    Dude, get this...I downloaded this game, I think it was called Quake 3...well, I started poking around on their website and found all the source code! Crazy huh?

  18. Reminds me of Weitek by Ungrounded+Lightning · · Score: 4, Interesting

    This reminds me of one of the several oopsies that led to the demise of Weitek. (This one wasn't the last straw. But it was a pretty big bale.)

    An administrator decided that, to save money, those darned resource-wasting engineers would be limited to one new floppy disk per week.

    So floppies got reused a lot. And of course eventually somebody got sloppy.

    The master for one of their graphics driver distributions was built on a recycled floppy disk. Of course the old files were deleted, rather than the disk being reformatted with a surface-analysis (and data wiping) pass. And of course this master was sector-cloned for production.

    Turns out the entire source code for the drivers had previously lived on that disk - and many of the algorithms that made the product cutting-edge were either in the driver or had enough info in the driver source about what the chip was up to that it made reverse-engineering a snap.

    So just apply any of several "undelete the lost files" tools to any copy of the distribution disks and you could recover pretty much the whole source code, comments and all.

    Shortly after this, the best of Weitek's cutting-edge algorithms became industry standards.

    That's one of the characteristics of Trade Secrets. Once it's no longer a secret (especially if the owner managed to leak it himself), it's public domain.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way