Home Artists Posts Import Register

Content

Español abajo

When Paul Leaman wrote emulators for CAPCOM games he came across a constant writing by the CPU to a misterious address. The CPU didn't seem to be waiting for any data after that writting. It also kept writting the same value. What could that be for? He assumed it was a watchdog. A watchdog is a circuit that counts down and if the count reaches zero, it will reset the whole system. Watchdogs are useful for embedded systems in case the system reaches a non working condition as it will automatically restart. The Popeye arcade game has a watchdog.

However, I still have not seen a single CAPCOM CPS0 game with one. What Paul was facing was something different. Documented in CAPCOM's schematics as OKOUT, that writing actually tells the sprite controller to transfer the sprite data table from the CPU RAM to the sprite controller internal buffer. This transfer is done through a DMA (Direct Memory Access) mechanism. The CPU is halted and during some 100 micro seconds the sprite controller directly drives the CPU RAM to extract the data from it. Once the transfer is done, the CPU resumes its operation as if nothing had happened.

Emulators don't replicate this transfer. This means that the CPU is running a bit faster (~1%) as it does not face these halt states. And also that you may get sprites on screen that aren't supposed to be there. Look at how GnG starts in MAME and how it starts on MiSTer/Arcade PCB. There are some strange sprites showing in MAME that shouldn't be there.

Although these differences may not look critical, this is for me one of the things to do accurately when transferring games to FPGA. As my golden rule is: a hardware feature on which software can act upon in a noticeably way must be replicated accurately. And this is such a feature.

Spanish

Cuando Paul Leaman escribió sus emuladores para juegos de CAPCOM descubrió que la CPU escribía constantemente el mismo valor en una dirección de memoria concreta. ¿Para qué podía valer esto? La CPU no parecía hacer nada relacionado con esa escritura. Sin embargo las escrituras estaban ahí. Paul creyó que esto era un watchdog (perro guardián). Los watchdog son contadores que resetean el circuito en el que están cuando su cuenta se agota. Se usan en sistemas embebidos porque si el sistema se cuelga y deje de restaurar la cuenta, esta se agotará y reiniciará el sistema. Popeye es un ejemplo de juego arcade con watchdog.


Sin embargo, no he visto aun un solo juego CAPCOM CPS0 con watchdog. Lo que Paul estaba viendo realmente era algo diferente. Documentada en los diagramas de CAPCOM como OKOUT, esa escritura indica al controlador de objetos que transfiera los datos de la tabla de objetos desde la RAM de la CPU hasta el búfer del controlador de objetos. Esta transferencia se hace por DMA (Acceso Directo a Memoria). La CPU queda bloqueada durante ese tiempo, que es algo de algo más de 100 micro segundos. En ese intervalo la controladora toma el control de la memoria y extrae los datos de los objetos. Cuando acaba la CPU continua con su trabajo como si no hubiera pasado nada.

Los emuladores no simulan esta transferencia. Esto hace que la CPU corra algo más rápido (~1%) porque no tiene periodos de espera. También hace que a veces se vean objetos que no deberían verse en pantalla. Por ejemplo, el arranque de GnG en MAME y en MiSTer/arcade es distinto. En MAME se ven algunos objetos raros que no deberían verse.

Aunque estas diferencias no parecen críticas, para mí esta es una de las cosas a hacer bien a la hora de transferir juegos a FPGA. Mi regla de oro es: las característica del hardware sobre las que el software puede actuar de una forma visible han de replicarse correctamente. Y esta es una de esas cosas.

Files

Comments

Manuel Astudillo

It's interesting how many shortcuts you can do when emulating in SW vs FPGA. I wonder if many of these cores where emulated in MAME without even having access to the schematics, just trying to reverse engineer the ASM code and the ROM data.

80's spaceman

You wrote this so well, a non tech person like me understood it! Thanks! :)

JOTEGO

Most emulators have been written by reading the machine code in the ROM files and using imagination. Somethings like sound synthesizers cannot be done this way, though.