Ok, so far we’ve seen how we can fix a bricked EverDrive clone by desoldering the flash chip and by using an external programmer. However, we can take this one step further – EverDrives reprogram their own flash memory using nothing but the Game Boy as a programmer, so why can’t we? The obvious answer seems like “because we can’t run our own code when another cartridge is plugged in”, but fortunately for us, that’s not true! You see, the Game Boy doesn’t actually care where the code it runs lives and it has 8kB of internal WRAM (32kB on the Game Boy Color). So all we need to do is write some code to un-brick the cartridge, copy that code to the internal WRAM, jump to it and then we no longer have a need for the cartridge. We can remove the cartridge that originally contained the code and replace it with another one, say a bricked EverDrive clone, and then our code can interact with the newly inserted cartridge.
Let’s take a look how this works in practice:
CopyToRam:
ld hl, _RAM ; Load the location of WRAM into hl
ld d, high(RAM_CODE_SOURCE) ; Load the location of our code
ld e, low(RAM_CODE_SOURCE) ; to copy into de
.copyByte
copy [hli], [de] ; Copy a byte and increment hl
inc e ; Increment the lower byte of the source address
jr nz, .copyByte ; Unless we reach an address ending in 0x00, loop
jp _RAM ; Jump to the code we just copied to WRAM

