Page 3 of 3

Re: Best Password System

Posted: Mon Feb 27, 2012 8:00 pm
by Memblers
slobu wrote: So, I'd like to come up with a password system that stores 8-bit values. It should involve the least writing/inputting by the end user.
Why not use something more modern, like FlashROM, and ditch the annoying password entry altogether? Seriously, if your game is under 128kB, then the chip is like $1.07, and under 512kB would be $1.70. That's about the same cost, if not cheaper, than using EPROM. So it basically adds no cost at all.

Only downside is without extra SRAM, you need some room in RAM to hold the code that actually erases/writing of the FlashROM. It's not very much code though, shouldn't be a problem. And you would leave 4kB or 8kB free in your ROM (8kB would be recommended because you could keep a backup save to revert to if the other is corrupt upon loading).

I've been advising various people to do this for years, I've yet to see anyone do it though. So what if it's not emulated, obviously if someone wants to save in an emulator they're just going to use a save state.

I could supply the code and boards to do this, if it helps. Though the board I have now that supports this has "the works" (good mapper, WRAM, etc), I could easily make a simpler board that allows saving.

Re: Best Password System

Posted: Tue Feb 28, 2012 1:19 am
by slobu
Memblers wrote:
slobu wrote: So, I'd like to come up with a password system that stores 8-bit values. It should involve the least writing/inputting by the end user.
Why not use something more modern, like FlashROM, and ditch the annoying password entry altogether? Seriously, if your game is under 128kB, then the chip is like $1.07, and under 512kB would be $1.70. That's about the same cost, if not cheaper, than using EPROM. So it basically adds no cost at all.

Only downside is without extra SRAM, you need some room in RAM to hold the code that actually erases/writing of the FlashROM. It's not very much code though, shouldn't be a problem. And you would leave 4kB or 8kB free in your ROM (8kB would be recommended because you could keep a backup save to revert to if the other is corrupt upon loading).

I've been advising various people to do this for years, I've yet to see anyone do it though. So what if it's not emulated, obviously if someone wants to save in an emulator they're just going to use a save state.

I could supply the code and boards to do this, if it helps. Though the board I have now that supports this has "the works" (good mapper, WRAM, etc), I could easily make a simpler board that allows saving.
I appreciate both the opinion and the offer Memblers! I hope the 8T-ROM becomes something like the Melody board from AtariAge. Normal humans without soldering skills can purchase such a board through a storefront. It levels the playing field quite a bit.

Cart making is still a black art nowadays. You either do it yourself (which requires much more knowledge than programming). Or rely on sometimes unreliable strangers on the 'net - who may not have the time or inclination to burn your ROM when the need arises.

Passwords have a place in classic gaming - good or bad. As I said in a previous post, this is a fallback option for a generic game framework. Not every target may support SRAM.

If you have to do a password Memblers I'd be very interested in what it'd look like. Again, you've got 10,000 times my experience and I'd love to hear your thoughts!

Re: Best Password System

Posted: Tue Feb 28, 2012 1:22 am
by Shiru
Memblers wrote:So what if it's not emulated,
It increases difficulty of debug. You can't test this functionality with neither emulators nor PowerPak, you would need to flash you special cartridge every time to test it. Beta testers also would need to have it to test a game with full functionality, to not miss a situation like 'saved on the last level, and the game erased itself'.

Re: Best Password System

Posted: Tue Feb 28, 2012 1:27 am
by bunnyboy
Shiru wrote:
Memblers wrote:So what if it's not emulated,
It increases difficulty of debug. You can't test this functionality with neither emulators nor PowerPak, you would need to flash you special cartridge every time to test it. Beta testers also would need to have it to test a game with full functionality, to not miss a situation like 'saved on the last level, and the game erased itself'.
I have a UNROM board with flash on it. For people targeting it they just use WRAM for testing instead. The read/write routines are pretty contained so it is easy to swap between sram and flash.

Posted: Tue Feb 28, 2012 5:05 am
by Bregalad
Yes, I know it would be way better to reprogram flash ROMs to do saves, but this cant be (currently) emulated which is a BIG problem (at least to me).

Something even cooler would be a device that plugs in controller port #2 or the expansion port and have some EEPROM with a block system like Playstation Memory Cards. Then again this is useless if it's unemulated and if no games makes use of it.

Posted: Tue Feb 28, 2012 6:03 am
by tokumaru
Bregalad wrote:Yes, I know it would be way better to reprogram flash ROMs to do saves, but this cant be (currently) emulated which is a BIG problem (at least to me).
Maybe it's time we added a "PRG-ROM is Flash" to the iNES header? =)

Re: Best Password System

Posted: Tue Feb 28, 2012 8:16 am
by tepples
Memblers wrote:Only downside is without extra SRAM, you need some room in RAM to hold the code that actually erases/writing of the FlashROM.
That and without extra SRAM, you don't get the map destructibility or other space for working data that comes from having extra SRAM. There's a reason that a lot of Koei games had one SRAM chip for saving and one for working.
I could supply the code and boards to do this, if it helps.
Once you make such boards available along with a solution that doesn't require a developer to learn to solder, I'm in.
Bregalad wrote:Something even cooler would be a device that plugs in controller port #2 or the expansion port and have some EEPROM with a block system like Playstation Memory Cards.
Or like the N64 Controller Pak, which turned a lot of games supporting save into games not supporting save in the hands of tightwad parents who would cheap out on memory cards.
tokumaru wrote:Maybe it's time we added a "PRG-ROM is Flash" to the iNES header?
I guess that's part of what the NES 2.0 submapper is for. Flash would need mapper support to direct writes to the mapper or to the flash chip.

Posted: Thu Mar 01, 2012 6:53 am
by Karatorian
On Topic

While I've never implemented a password system, I do have a few suggestions as to how to build one.

The first one is to implement some sort of bit packing. There are a lot of cases where you don't need a full eight bits to store data. Even if you have that data in bytes for easy access during gameplay, every little bit matters when trying to keep passwords a reasonable length.

As you mention that this is for a generic framework, try to be flexible with the format of the packed data. A preset combination, like this...
slobu wrote:6 8-bit (0-255) variables
6 4-bit (0-15) variables
5 3-bit (0-7) variables
9 1-bit (true/false) variables
...is sure to be exactly the wrong option for some game or programmer at some point. An ideal solution would be for it to handle arbitrary bit-strings without preconceived notions as to what the bits mean. Of course, some bit packng utility routines would be helpful, so that one doesn't have to write their own every time. But the more generic, the better.

As for password length and symbol set size, again, I think the more generic the better. Some games need to store lots of data (RPGs), others, not so much (arcade games). Therefore, password length is highly dictated by the game's requirements. Basically, an N length bit-string is stored in an M length password. The (linear) relationship between M and N is dictated by the size of the symbol set (plus overhead, if any).

For the size of the symbol set, there are really two broad methods. The simple choice is to choose some 2**n value (such as 16, 32, or 64). This has the advantage of being easy to translate between the password and the binary data. Using 16 symbols may be convenient for the developer as it allows for plain hex. (Whether used in the final product, or only in dev builds.)

The other method (as mentioned by Bregalad), is an arbitrary base-N encoding. This allows the developer to choose any size of symbol set they desire. This can be used to tune the size of the set (such as 26 for plain alphabetic, ~36 for alphanumeric, 46/48 for kana, etc) or password length (using 16 symbols in a 4 by 4 grid, for example). The downside to this is that the encoding and decoding are more complex. However, as saving and loading aren't timing critical, this isn't much of an issue.

As for the actual symbols themselves, I think that should be left up to the developer. The target language dictates which symbols will be comprehensible or comfortable for the player. The password system should allow for localization, the same as any other part of the game.

Finally, there is the matter of checking and or encrypting. The first thing to consider is that either will add to the complexity of the password system and make the password longer. Neither of which is desirable. That said, some sort of checking is basically required for a good user experience. A typo should lead to an error message, not some random (and possibly broken) combination of values.

Encryption is largely useless in my opinion. It's not as though you're going to make a system that's unbreakable, so it's mostly a waste of dev and CPU time. The bit spreading effect of a good hash may be aesthetically desirable (though that is a matter of opinion, and it may sometimes be undesirable, for instance when using straight hex in a debug build). Either way, I wouldn't get too carried away. Use something simple or nothing at all.

It probably sounds like I've waffled a lot and answered basically "It depends." This is sorta' true. When one asks "What is the best?", that's usually the answer. However, don't take this to mean that you can can't or shouldn't implement a concrete solution. I think the best system would have a lot of flexibility and allow the developer to set (compile time) options to tune the system for their specific needs.

For instance, I might have to save 27 bits of a data. I want to use 16 symbols (0-F) for dev builds (so it's hackable), but 26 (A-Z) for production builds (to reduce password length). Being able to set this all up with a few defines would be great. Of course, there has to be some limits, but offering a reasonable range should be doable.

All of this assumes you want to build a generic framework. If you're doing a one-off for a specific project, it might be easier to just build what you need. Then again, it might still be worthwhile to build something flexible. (After all, you never know exactly what you need in the beginning.)

Slightly Off Topic

The idea to just use the Dpad directly to enter a password has some merit. As discussed above, it's liable to lead to long password lengths unless the number of bits stored is quite small, but the core idea is sound. As I see it, the key advantage isn't (Zack's motivating itch) the elimination of the need to move one's view between the screen and the saved password (paper/phone/etc), but economy of data entry.

When the user enters a password in a traditional password system, they actually provide the system with more bits of information than the system utilizes. Each character of the password requires them to hit some number of Dpad directions plus some an action button. As stated in the original proposal, each Dpad press actually provides two bits of data, most of this data is ultimately unused and mapped to a smaller number of bits. This alternative utilizes all of these bits.

Using all eight buttons of the controller would allow for 3 bits to be gathered per input. Of course, this means that no buttons can be utilized to edit the entry if an error is made. If the password is short, such a simple scheme could work. (As a bonus, you could also check for the Konami code.) If you reserve one button for backspace, you can get ~2.8 bits per input. If an additional button is reserved for entry confirmation, this is reduced to ~2.6 bits. Encoding and decoding these fractional bits is the same as the base-N password decoding. Whether the resulting password lengths would be unwieldy depends on how many bits one needs to store.

Alternatively, one could adopt a chording scheme for even more efficient input. A simple system using just A, B, and the Dpad, would provide ~3.3 bits per entry and still reserve start and select for meta functions. This has two advantages. The first is that the ten total combinations map to the 10 decimal digits, allowing one to reuse existing number base conversion code. The second is that these sorts of button combinations are already second nature to most gamers. (I think this would be an especially nice fit for a fighting game.) More complex chording schemes could be even more efficient, but the added complexity may outweigh the benifits.

Way Off Topic

In regards to alternatives such as various non-volatile memories, I have some ideas, but I'll not derail the thread further.

Posted: Thu Mar 01, 2012 10:33 am
by slobu
..they actually provide the system with more bits of information than the system utilizes
I never noticed that! Perhaps the characters A-Z could be cycled through in four directions (up/down/left/right) adding 2 extra bits of information. This gives us 104 values. We could interpret each entered value as 2 entries with 0-9. The game developer could divvy up the individual 0-9 entries as they see fit for each game variable. Values past 99 will be regarded as invalid. A mask will be applied based off of a character in the password. If someone tries to make their own password they're bound to produce at least one invalid entry.

Posted: Thu Mar 01, 2012 10:39 am
by Bisqwit
Human beings appreciate redundance and choice.
That you can navigate half a screen right and two rows up by going first right and then up, or by going first up and then right, or maybe go left and wrap through the screen edge and then up, or vice versa, or maybe you'll rather wrap vertically, or maybe do both as well. That the system won't care which way you do it.

On the other hand, if you're designing an input system to be used only by TAS folks... you've got a small audience. First of all, the TAS folks aren't going to be using passwords to begin with. :-)

EDIT: And this I know, because I went the same tangent in Rockman Basics, maybe even farther. http://bisqwit.iki.fi/kala/rmbasicsgeneric.zip