DEV Community

Discussion on: Mini Micro and the 6502: Adding retro to the neo-retro

Collapse
 
sebnozzi profile image
Sebastian Nozzi • Edited

I have some questions about memory-mapping. I know nothing about all this, so bear with me ... You write a byte to addresses $4001 or $4002 result in writing a number or a character on the screen ... Does this happen immediately? When? How often? Why doesn't the CPU keep writing the same character / number stored in those addresses ...? Or is my understanding wrong? Does the system "know" when a new value has been stored on an address and "react" (?) only once? Thanks in advance!

Collapse
 
bibleclinger profile image
BibleClinger

My understanding (which is severely lacking compared to actual hardware experts) is that real hardware essentially acts as a state machine. Writing to addresses mapped to the hardware can trigger this state machine, when it's in the correct state, to begin an operation and to move along in states, so that it will complete an operation once when the correct number of write operations are performed. You can think of these addresses as hardware registers that are monitored for changes.

In terms of my implementation for this project, I have the hardware designed as plugin objects that have onRead and onWrite methods. When the plugins are registered, the addresses they want monitored for reading and the addresses they want monitored for writing, are transferred to the main program/class. Memory access triggers the correct methods for the correct hardware.