A easy way to Implement Cheat Support into the EverDrive 64

Discussion in 'Everdrive 64' started by Four_X, Dec 14, 2012.

  1. Zoinkity

    Zoinkity Site Supporter 2015

    Joined:
    Feb 18, 2012
    Messages:
    504
    Likes Received:
    111
    Technically the ScummVM shouldn't have been using BadVAddr and ExpectPC as variables. Didn't even realize they were writable. I'll give you the TRAP ops though ;*)
    The front end runs like crap in emulators (when you patch things up) on account for heavily looping float conversions and division.

    I'm not sure if a lot of you know this, but there were two code interpretters built into the GS. There's the 'active code list' feature attached to the trainer, used for codes created from searches and uploaded via PC at runtime. This accepted a list of actual GS codes written in binary and used an interpretter to execute them.

    The 'normal' codelist is entirely different. The GS generates ASM based on a formula for each type of code you entered. Annoyingly, the 50- type codes create a series of 8x style commands instead of looping. You could only use a 'GS button' type code in this list, and it tested a register to see if the GS button is pressed. Anyway, the point being that although the ASM is fairly long (and they made no attempt to reduce the size in any way) it does execute very fast.

    The biggest issue is that the trainer (especially the codegen trainer) wasn't exactly thread-safe. It only stored current registers as words, not doublewords, so register corruption was a problem with some titles and could be fatal!
     
  2. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    My current cheat engine deals with the "normal" codelist since I don't have any trainer/hacking support in it. It's one thing that I'll try to improve for the upcoming version.

    I won't make the mistake of saving 32 bits instead of 64 on the code. Sounds like folks weren't used to 64-bit processors. :D
     
  3. Zoinkity

    Zoinkity Site Supporter 2015

    Joined:
    Feb 18, 2012
    Messages:
    504
    Likes Received:
    111
    To be honest, I half suspect from the insane way they had to read their own ROM on the GS it might have been a 16bit device o.0
    They read ROM in multiple steps, loading the lower halfwords from one memory range and the upper halfwords from a different range, then shifting and ORing them together. Then again, they also execute code directly from ROM at one point, so maybe there's more at work here.

    There are so many things wrong with that blasted device ;*)

    The only ones the 'active code list' handled, back in the day:
    80/81 8/16 bit writes
    D0/D1 apply following code if 8/16 bit value matches at address
    D2/D3 apply following code if 8/16 bit values doesn't match at address

    50-type is nice and all, but basic support should probably shoot for those six.
     
  4. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    My current code supports most of the codes... except for some oddballs. I'll have to dig out my notes on that again, but one thing I noticed is that some cheats used the word patch (81) on odd addresses. My current cheat engine doesn't support that, so that was one update I NEED to make for this.
     
  5. Zoinkity

    Zoinkity Site Supporter 2015

    Joined:
    Feb 18, 2012
    Messages:
    504
    Likes Received:
    111
    It isn't supported by the actual GS hardware either. 81 must be 16bit aligned. Actual ASM uses the SH op. Your implementation is right.

    Emulators are stupid however and let you do all sorts of idiotic things, so codes like this persist. The effect on hardware is undefined.
     
  6. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    Oh, so odd values are from people hacking on emulators? I didn't think of that. It would be possible to make it work - just generate two byte stores instead of a word store. But should I?
     
  7. Zoinkity

    Zoinkity Site Supporter 2015

    Joined:
    Feb 18, 2012
    Messages:
    504
    Likes Received:
    111
    Your call really.
    I know at least two major code sites that correct those before posting them. That said, working Sharks are becoming rarer and fewer people are willing to put up with their quirks, so it isn't like backward-compatability is a huge issue. Not sure how many emulators accept odd HWs though, and if the answer is "most don't" then it would be adding a layer of confusion.

    It really is your call though. It would be a decent way to handle a common user error certainly.
    Oh, if you want the default codelist from a stock v3.3 BIOS just say the word ;*)
     
    Last edited: Feb 9, 2013
  8. Conker2012

    Conker2012 Intrepid Member

    Joined:
    Oct 19, 2012
    Messages:
    692
    Likes Received:
    81
    What Gameshark/Equaliser/Xplorer 64 code sites are there, please? I only know of http://www.kai666.com/ as that's a PAL site, but since now (thanks to the Everdrive) I can run games from any region, I'll be able to use codes for any region (with Chilly Willy's code engine, I mean, as the ED64 is incompatible with real cheat devices).
     
  9. Four_X

    Four_X Member

    Joined:
    Sep 14, 2011
    Messages:
    14
    Likes Received:
    0
  10. Conker2012

    Conker2012 Intrepid Member

    Joined:
    Oct 19, 2012
    Messages:
    692
    Likes Received:
    81
    Thanks for that, I've not seen that site before.
     
  11. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    See, this is what I'm talking about... go to the N64 codes, go to Banjo Kazooie 1.1 misc codes, and you'll find

    See? Word command on an odd address. I've seen things like that all over many code boards.

    And Zoinkity, I wouldn't mind seeing that list. :)
     
  12. Zoinkity

    Zoinkity Site Supporter 2015

    Joined:
    Feb 18, 2012
    Messages:
    504
    Likes Received:
    111
    The two I'm most familiar with are in competition with each other, spinoffs of the defunct gscentral.com (the style of which bsfree 'borrowed'):
    http://gscentral.org/
    http://viper.shadowflareindustries.com/antigsc/index.php
    There's also the most recent incarnation of gshi:
    http://gamehacking.org/

    Here's the official Datel default codelists encoded in the encrypted ar3.bin file. They should be the two final BIOSes issued. If not, get me a sample and I'll dump that one too ;*)
    View attachment 5775 GS 3.3; header: "(C) MUSHROOM &NU09.54 Mar 27"
    View attachment 5776 PAR3.3; header: "(C) MUSHROOM &NU16.08 Apr 18"

    There's no harm in supporting odd 16bit codes, but they don't work on actual hardware.
     
    Last edited: Feb 11, 2013
  13. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    I can make them work... instead of doing a word store, just do two byte stores. It makes the code bigger, which could affect the conditional codes (need a larger branch to skip an odd code block). See, that's all those codes are doing - generating a list of stores that are performed by the replacement exception handler before it jumps to the original exception handler. The conditional codes generate a load and a conditional test with a branch large enough to skip the instructions generated by the next code.

    Thanks for the lists... they seem pretty straightforward... nothing odd in them at first glance.
     
  14. MYCRAFTisbest

    MYCRAFTisbest Peppy Member

    Joined:
    Jan 4, 2013
    Messages:
    328
    Likes Received:
    2
    Do you really need to cheat? You spent at-least $100 so you could cheat? I am just happy that I get to play every N64 game and every NES game on one cart (thanks KRIKzz)
     
  15. Conker2012

    Conker2012 Intrepid Member

    Joined:
    Oct 19, 2012
    Messages:
    692
    Likes Received:
    81
    If someone wants to cheat then it's up to them. I don't see why anyone listens to rap music, likes ballet, watches soap opera, or likes to play games with infinite lives, etc, but if people do, then fine.

    Personally the 'cheats' I like in games don't tend to be the conventional cheats at all, but ones that alter the gameplay. I.e. being able to play through the whole game with just your favourite weapon, when in the normal (non-cheat activated) game you only get that weapon every so often. Plus there are cheat codes that alter the weapons themselves, or objects in the game world, or whatever. And sometimes there are items in a game that you'd never see normally (i.e the game does not access them), but using a cheat device you can put them in the game world; The NTSC version of The World is Not Enough, for example, has two unfinished levels you can access via a cheat device, and Perfect Dark has several objects that don't normally appear, plus unused music you can access with a cheat device. Using a cheat device's code creation function (which not all devices have, some only let you put enter codes directly, I am really hoping Chilly Willy's Gameshark routines eventually let you search for codes yourself) not only allows you to find hidden stuff, but also the act of discovering things like this can be very enjoyable.

    And you could also do things like play Perfect Dark's single player levels in multi-player, and vice versa, and play Goldeneye's multiplayer in single player levels, though some codes are now redundant for N64 backup drive users, as the authors of these codes have made them available too as ROM patches, so you can play a patched version on the ED64 and play singleplayer PD in multi-player, etc.

    Personally, I'm not a big fan of invincibility/infinite bombs/etc codes, but some people like them, which is fair enough.
     
  16. Zoinkity

    Zoinkity Site Supporter 2015

    Joined:
    Feb 18, 2012
    Messages:
    504
    Likes Received:
    111
    The GS is effectively a ram editor. Among other things, it been used to circumvent things like region-locking, activate debug features, shuffle resources, and activate 'removed' features. There's plenty of non-cheating codes, unless you're one of those people who insists that permitting more than one player to use the same driver in Mario Kart 64 is cheating.

    For some purposes it's more convenient than ROM hacking. For starters, it's faster, doesn't require codecs or CRC recalculation, doesn't require as much background with the system, and there's no conversion factor involved in address translation. Much more accessible.

    The full hardware device can be used as a debugger and to test code. The port was the best thing they added in; not only could you replace resources at runtime but even boot your own code. One of the best examples happens to be HCS's NES emulator. Heck, you could dump ROMs with the thing, and they cost less than an ordinary game! It would honestly be worth producing a modern, unsucky version of them for today's PCs and ports.
     
  17. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    I like to cheat when I want to blow off steam, but don't have the time to play a "full" game. Curb-stomping my way through WaveRace or Doom is a great way to blow off steam quickly. :D
     
  18. Conker2012

    Conker2012 Intrepid Member

    Joined:
    Oct 19, 2012
    Messages:
    692
    Likes Received:
    81
    Chilly Willy, have you made any progress? It would be great if you could post occasional updates, though if that's not your style then fair enough.
     
  19. Chilly Willy

    Chilly Willy Robust Member

    Joined:
    Mar 15, 2011
    Messages:
    242
    Likes Received:
    0
    Still working on the SD card support in libdragon. I've got other things to work on on other platforms, so no idea when I'll finish that. It's a bit lower on the todo list than the next update to the Myth menus.
     
  20. Conker2012

    Conker2012 Intrepid Member

    Joined:
    Oct 19, 2012
    Messages:
    692
    Likes Received:
    81
    OK mate, thanks for letting us know, and please keep us informed of any relevant updates.
     

Share This Page