fdivitto / FabGL

ESP32 Display Controller (VGA, PAL/NTSC Color Composite, SSD1306, ST7789, ILI9341), PS/2 Mouse and Keyboard Controller, Graphics Library, Sound Engine, Game Engine and ANSI/VT Terminal
http://www.fabglib.org
Other
1.46k stars 218 forks source link

Send Disk on Altair8800 just sending 0x00 #91

Open gdampf opened 3 years ago

gdampf commented 3 years ago

Just start a fresh Altair8800, press Pause S A and you will get a stream of zeros in the length of the disk. One of the pre-conditions is not initialized for the selected disk (m_enabled or m_headLoaded). By saving and initializing m_enabled = true and m_headLoaded = 0 and restore it at the end, Mits88Disk::sendDiskImageToStream will work correctly. I guess, it is the same for Mits88Disk::receiveDiskImageFromStream.

gdampf commented 3 years ago

I think, this could be optimized, but seams to work: `void Mits88Disk::sendDiskImageToStream(int drive, Stream * stream) { const int prevDrive = m_drive; const bool prev_enabled = m_enabled; const int prevTrack = m_track[drive]; const int prevLoaded = m_headLoaded[drive];

m_headLoaded[drive] = 0; m_enabled = true; setDrive(drive);

int len = 0; int notz = 0; for (int t = 0; t < m_tracksCount; ++t) { m_track[m_drive] = t; for (int s = 0; s < m_trackSize; ++s) { m_sector[m_drive] = s; m_pos[m_drive] = 0; for (int b = 0; b < SECTOR_SIZE; ++b) { int v = readByteFromDisk(); stream->write(v); len++; } } }

setDrive(prevDrive); m_enabled = prev_enabled; m_headLoaded[drive] = prevLoaded; m_track[drive] = prevTrack;

}`