Post Aw4Elr4R6Qmn14TpeC by foone@digipres.club
 (DIR) More posts by foone@digipres.club
 (DIR) Post #Aw4E32JwQcxIsPMTUe by foone@digipres.club
       2025-07-12T19:40:24Z
       
       0 likes, 0 repeats
       
       NES mapper programming sounds like shitposts or elaborate pranks. For example, MMC1. Super common chip, used on Metroid, Legend of Zelda, Bionic Commando. To program it, you simply write five bytes to the upper half of the memory space. The LSB of each byte is added to a shift register and then for the 5th byte the 13th and 14th bit of the address are used to determine which register to program.
       
 (DIR) Post #Aw4E8cz1XrPA21FAZ6 by foone@digipres.club
       2025-07-12T19:41:29Z
       
       0 likes, 0 repeats
       
       this is the kind of thing you'd expect to happen as part of some kind of tricky DRM system but no, the NES's DRM is implemented completely differently (and outside of the view of the CPU).this is just how you bank switch on the MMC1
       
 (DIR) Post #Aw4EWUW8flgoj1701A by dryak@mstdn.science
       2025-07-12T19:45:40Z
       
       0 likes, 0 repeats
       
       @foone but think of all the transistors they saved on the MMC1 this way!🙃
       
 (DIR) Post #Aw4Ecc0NkK4ngZB0HA by foone@digipres.club
       2025-07-12T19:46:46Z
       
       1 likes, 0 repeats
       
       also there has to be at least one cycle between writes, or it ignores them. This is intentional behavior because of a weirdness of the 6502 where any instruction that modifies memory does two writes, once with the original value and once with the modified value.emulating this behavior correctly is required for at least two published games, because of course it is
       
 (DIR) Post #Aw4EfWllfWvwJejO7s by stilescrisis@mastodon.gamedev.place
       2025-07-12T19:47:01Z
       
       0 likes, 0 repeats
       
       @foone fascinating to see someone so versed in old tech and reverse engineering, but displeased by latches.
       
 (DIR) Post #Aw4Elr4R6Qmn14TpeC by foone@digipres.club
       2025-07-12T19:48:35Z
       
       0 likes, 0 repeats
       
       @stilescrisis it's not just a latch (the NES is full of latches: that's how the controllers work), it's a latch that's mapped to half of memory and has to be done one byte at a time and the address only matters at the end and it's got a timing requirement. it's just everything you can do weird at once
       
 (DIR) Post #Aw4EqM8JYSfIVtRMvY by stilescrisis@mastodon.gamedev.place
       2025-07-12T19:49:19Z
       
       0 likes, 0 repeats
       
       @foone I love the 6502, none of this surprises me anymore
       
 (DIR) Post #Aw4Ex9JXc6nQmcvmNM by foone@digipres.club
       2025-07-12T19:50:34Z
       
       0 likes, 0 repeats
       
       also some PCBs didn't bother connecting pin 14 to the MMC1. So this behavior is different, and only pin 13 matters.This means you can have two games with the same ROM and the same mapper chip, but they work differently because the PCB is different.
       
 (DIR) Post #Aw4F3ne0a1yHbPfwTg by foone@digipres.club
       2025-07-12T19:51:30Z
       
       0 likes, 0 repeats
       
       @stilescrisis I'm from the x86, where we at least pretended there was a good plan behind all the weirdness (there wasn't)
       
 (DIR) Post #Aw4FSXePBHlTErev4K by foone@digipres.club
       2025-07-12T19:56:15Z
       
       1 likes, 0 repeats
       
       one of the registers you program with this interface is used to select the PRG-RAM bank, which is the 4th bit on the CHR0/CHR1 registers... except for one game, A Ressha de Ikou, where it's the 5th.
       
 (DIR) Post #Aw4GOPN67XqaMD9lEO by foone@digipres.club
       2025-07-12T20:06:43Z
       
       0 likes, 0 repeats
       
       it doesn't affect the MMC1, but the way some mappers are implemented on the NES also leads to a fun situation where your code needs to make sure the writes to ROM are only ever "writing" over the same value
       
 (DIR) Post #Aw4GVEQbCszGRZ31uq by foone@digipres.club
       2025-07-12T20:07:53Z
       
       0 likes, 0 repeats
       
       this is caused by a bus conflict with the mapper and the CPU confusing the mapper. you try to write a 5 to $8000 to program the mapper, but the mapper has mapped 0 to $8000 and the 0 wins.
       
 (DIR) Post #Aw4GaVDoCC3NyaZvsW by foone@digipres.club
       2025-07-12T20:08:53Z
       
       0 likes, 0 repeats
       
       so even though the mapper is listening to writes in the entire top half of the address space, you gotta make sure the ROM has the correct values to write over, or it won't work.
       
 (DIR) Post #Aw4GpYjHR8bHCNTjxw by rotopenguin@mastodon.social
       2025-07-12T20:11:37Z
       
       0 likes, 0 repeats
       
       @foone this is what architect engineers refer to as "eventual consistency"
       
 (DIR) Post #Aw4HYn8khj3yvMxfxg by foone@digipres.club
       2025-07-12T20:19:48Z
       
       0 likes, 0 repeats
       
       every corner of the NES is like this.you look up any section of that machine and it's like "this came in 5 flavors, none of which are compatible, none of which is properly described in any commonly used ROM format. emulating or programming it correctly is difficult. three games depend on this working exactly this way, and another two games depend on it not working this way"
       
 (DIR) Post #Aw4I09PjzwNzpBxBuC by piggo@piggo.space
       2025-07-12T20:21:53.026983Z
       
       0 likes, 0 repeats
       
       @foone why is the first write required to write the old value? Was this a sort of synchronization primitive, ... or just some weird implementation detail  leaking out?
       
 (DIR) Post #Aw4I0AlOytJ60f60J6 by foone@digipres.club
       2025-07-12T20:24:41Z
       
       0 likes, 0 repeats
       
       @piggo it's because when you try to write the value, the ROM itself also tries to "write" its own value, as the output enable on the ROM chip isn't disabled
       
 (DIR) Post #Aw4IAF9lVFZ6WvIGum by foone@digipres.club
       2025-07-12T20:26:31Z
       
       0 likes, 0 repeats
       
       @gloriouscow seven years is maybe a bit optimistic, but yeah.
       
 (DIR) Post #Aw4IPZCRGWB32JqoyW by gsuberland@chaos.social
       2025-07-12T20:29:17Z
       
       0 likes, 0 repeats
       
       @foone oh that's an aspect I'd never even considered for emulation. like... you've got a binary image of the game ROM, but those cartridge PCBs aren't guaranteed to just be homogenous transparent carrier boards, and defining any kind of cross-emulator metadata standard to describe nonstandard behaviours is very hard.
       
 (DIR) Post #Aw4J4VlcvqMMGPplBY by gsuberland@chaos.social
       2025-07-12T20:30:07Z
       
       0 likes, 0 repeats
       
       @foone I guess that's why so many emulator projects end up having a big database of per-game hacks.
       
 (DIR) Post #Aw4J4Ws2pT5TgbqOpM by foone@digipres.club
       2025-07-12T20:36:42Z
       
       0 likes, 0 repeats
       
       @gsuberland yep
       
 (DIR) Post #Aw4JsKs9iE0mxBe5iq by Ronflaix@mastodon.gamedev.place
       2025-07-12T20:45:38Z
       
       0 likes, 0 repeats
       
       @foone gaming consoles converging towards computers and tablets makes programming them easier (citation needed) but we're losing all the weirder (and bester) aspects of the art.
       
 (DIR) Post #Aw4PM4ZLOMpAqcqUoi by shac@ioc.exchange
       2025-07-12T21:47:03Z
       
       0 likes, 0 repeats
       
       @foone This is me cancelling plans to ever write an NES emulator
       
 (DIR) Post #Aw4nh7nqxdjtrKCgSG by curtmack@floss.social
       2025-07-13T02:19:45Z
       
       0 likes, 0 repeats
       
       @foone another fun thing about the MMC1: it's on the programmer to write 5 bytes correctly. The behavior of the MMC1 if it's left in an inconsistent state is indeterminate and almost certainly varies between revisions.Luckily this would never be an issue, unless a major game happened to have an invalid password that triggers illegal MMC1 writes, and it happens to be something immediately striking and primed to spread the early Internet - say, ENGAGE RIDLEY MOTHER FUCKER
       
 (DIR) Post #AwLbrYtnS7syxucQ6q by Haijo7@snac.haijo.eu
       2025-07-21T04:37:00Z
       
       0 likes, 0 repeats
       
       @foone@digipres.club is the CIC chip digital though? if not, it can't be called DRM
       
 (DIR) Post #AwLbrZh4UvIjQjflui by foone@digipres.club
       2025-07-21T04:57:16Z
       
       0 likes, 0 repeats
       
       @Haijo7 it is, yeah. it's a 4-bit Sharp microcontroller