Skip to content

Commit

Permalink
Emubase updated: floppy re-worked
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Jan 8, 2025
1 parent dc3778c commit 040896f
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 88 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,29 @@ The BKBTL project consists of:
* [**bkbtl-doc**](https://github.com/nzeemin/bkbtl-doc) — documentation and screenshots.
* Project wiki: https://github.com/nzeemin/bkbtl-doc/wiki


## Как запустить под Linux

### Собрать из исходников

1. Установить пакеты: Qt 5.15.2 + QtScript
1. Установить пакеты: Qt 5 + QtScript<br>
`sudo apt install qtbase5-dev qt5-qmake qtscript5-dev`
2. Скачать исходники: либо через<br>
`git clone https://github.com/nzeemin/bkbtl-qt.git`<br>
либо скачать как .zip и распаковать
3. Выполнить команды:<br>
`cd emulator`<br>
`qmake "CONFIG+=release" QtBkBtl.pro`<br>
`make`<br>
4. Даём права на выполнение: `chmod +x QtBkBtl`
5. Запускаем `QtBkBtl`
4. Дать права на выполнение: `chmod +x QtBkBtl`
5. Запустить `QtBkBtl`
6. Если при запуске появилось сообщение вида `Failed to load Monitor ROM file.`, то
скачать .rom файлы от [BKBTL](https://github.com/nzeemin/bkbtl/tree/master/roms), положить в ту же папку где лежит файл `QtBkBtl`, запустить снова

### Используя готовый AppImage

1. Зайти в [Releases](https://github.com/nzeemin/bkbtl-qt/releases) найти последний AppImage-релиз и скачать `*.AppImage` файл
2. Дать права на выполнение: `chmod +x BKBTL_Qt-9cc9d83-x86_64.AppImage` (подставить тут правильное название AppImage файла)
3. Если при запуске появилось сообщение вида `Failed to load Monitor ROM file.`, то
3. Запустить AppImage файл
4. Если при запуске появилось сообщение вида `Failed to load Monitor ROM file.`, то
скачать .rom файлы от [BKBTL](https://github.com/nzeemin/bkbtl/tree/master/roms), положить в ту же папку где лежит AppImage файл, запустить снова
14 changes: 7 additions & 7 deletions emulator/emubase/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CMotherboard::CMotherboard() :
m_CPUbps = nullptr;

// Allocate memory for RAM and ROM
m_pRAM = static_cast<uint8_t*>(::malloc(128 * 1024)); //::memset(m_pRAM, 0, 128 * 1024);
m_pRAM = static_cast<uint8_t*>(::calloc(128 * 1024, 1));
m_pROM = static_cast<uint8_t*>(::calloc(64 * 1024, 1));

SetConfiguration(BK_CONF_BK0010_BASIC); // Default configuration
Expand All @@ -52,8 +52,8 @@ CMotherboard::~CMotherboard()
delete m_pSoundAY;

// Free memory
::free(m_pRAM);
::free(m_pROM);
::free(m_pRAM); m_pRAM = nullptr;
::free(m_pROM); m_pROM = nullptr;
}

void CMotherboard::SetConfiguration(uint16_t conf)
Expand Down Expand Up @@ -192,7 +192,7 @@ void CMotherboard::DetachFloppyImage(int slot)

uint16_t CMotherboard::GetRAMWord(uint16_t offset) const
{
return *((uint16_t*)(m_pRAM + offset));
return *reinterpret_cast<uint16_t*>(m_pRAM + offset);
}
uint16_t CMotherboard::GetRAMWord(uint8_t chunk, uint16_t offset) const
{
Expand All @@ -210,12 +210,12 @@ uint8_t CMotherboard::GetRAMByte(uint8_t chunk, uint16_t offset) const
}
void CMotherboard::SetRAMWord(uint16_t offset, uint16_t word)
{
*((uint16_t*)(m_pRAM + offset)) = word;
*reinterpret_cast<uint16_t*>(m_pRAM + offset) = word;
}
void CMotherboard::SetRAMWord(uint8_t chunk, uint16_t offset, uint16_t word)
{
uint32_t dwOffset = ((static_cast<uint32_t>(chunk) & 7) << 14) + offset;
*((uint16_t*)(m_pRAM + dwOffset)) = word;
*reinterpret_cast<uint16_t*>(m_pRAM + dwOffset) = word;
}
void CMotherboard::SetRAMByte(uint16_t offset, uint8_t byte)
{
Expand Down Expand Up @@ -364,7 +364,7 @@ bool CMotherboard::SystemFrame()
const int audioticks = 20286 / (SOUNDSAMPLERATE / 25);
m_SoundChanges = 0;
const int teletypeTicks = 20000 / (9600 / 25);
int floppyTicks = (m_Configuration & BK_COPT_BK0011) ? 38 : 44;
int floppyTicks = (m_Configuration & BK_COPT_BK0011) ? 38 : 32;
int teletypeTxCount = 0;

int frameTapeTicks = 0, tapeSamplesPerFrame = 0, tapeReadError = 0;
Expand Down
5 changes: 3 additions & 2 deletions emulator/emubase/Disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ uint16_t DisassembleInstruction(const uint16_t* pMemory, uint16_t addr, TCHAR* s
}

length = 1;
_sntprintf(strDst, strDstSize - 1, _T("%06o"), addr + ((short)(char)static_cast<uint8_t>(instr & 0xff) * 2) + 2);
_sntprintf(strDst, strDstSize - 1, _T("%06ho"), (uint16_t)(addr + ((short)(char)(uint8_t)(instr & 0xff) * 2) + 2));

// Branches & interrupts
switch (instr & ~static_cast<uint16_t>(0377))
Expand Down Expand Up @@ -713,7 +713,8 @@ void Disasm_InstructionHint(const uint16_t* memory, const CProcessor * pProc, co
// Prepare "Instruction Hint" for a regular instruction (not a branch/jump one)
// buffer, buffer2 - buffers for 1st and 2nd lines of the instruction hint, min size 42
// Returns: number of hint lines; 0 = no hints
int Disasm_GetInstructionHint(const uint16_t* memory, const CProcessor * pProc, const CMotherboard * pBoard,
int Disasm_GetInstructionHint(const uint16_t* memory, const CProcessor * pProc,
const CMotherboard * pBoard,
LPTSTR buffer, LPTSTR buffer2)
{
const size_t buffersize = 42;
Expand Down
13 changes: 7 additions & 6 deletions emulator/emubase/Emubase.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ int Disasm_GetInstructionHint(

#define FLOPPY_FSM_IDLE 0

#define FLOPPY_CMD_CORRECTION250 04
#define FLOPPY_CMD_CORRECTION500 010
#define FLOPPY_CMD_ENGINESTART 020
#define FLOPPY_CMD_SIDEUP 040
#define FLOPPY_CMD_DIR 0100
#define FLOPPY_CMD_STEP 0200
#define FLOPPY_CMD_SEARCHSYNC 0400
#define FLOPPY_CMD_SKIPSYNC 01000
#define FLOPPY_CMD_READDATA 0400
#define FLOPPY_CMD_WRITEMARKER 01000
#define FLOPPY_CMD_PRECORRECTION 02000

//dir == 0 to center (towards trk0)
//dir == 1 from center (towards trk80)

Expand Down Expand Up @@ -108,6 +108,7 @@ class CFloppyController
bool m_shiftflag; // Write mode shift register has data
bool m_shiftmarker; // Write marker in m_marker
bool m_writing; // TRUE = write mode, false = read mode
bool m_searchsynctrig; // Search for sync trigger
bool m_searchsync; // Read sub-mode: TRUE = search for sync, false = just read
bool m_crccalculus; // TRUE = CRC is calculated now
bool m_trackchanged; // TRUE = m_data was changed - need to save it into the file
Expand All @@ -124,8 +125,8 @@ class CFloppyController
bool IsAttached(int drive) const { return (m_drivedata[drive].fpFile != nullptr); }
bool IsReadOnly(int drive) const { return m_drivedata[drive].okReadOnly; } // return (m_status & FLOPPY_STATUS_WRITEPROTECT) != 0; }
bool IsEngineOn() { return (m_flags & FLOPPY_CMD_ENGINESTART) != 0; }
uint16_t GetData(void); // Reading port 177132 - data
uint16_t GetState(void); // Reading port 177130 - device status
uint16_t GetData(); // Reading port 177132 - data
uint16_t GetState(); // Reading port 177130 - device status
uint16_t GetDataView() const { return m_datareg; } // Get port 177132 value for debugger
uint16_t GetStateView() const { return m_status; } // Get port 177130 value for debugger
void SetCommand(uint16_t cmd); // Writing to port 177130 - commands
Expand Down
Loading

0 comments on commit 040896f

Please # to comment.