Skip to content

Commit

Permalink
Whoo qemu
Browse files Browse the repository at this point in the history
  • Loading branch information
leuat committed May 16, 2021
1 parent 642caff commit 8f46a6b
Show file tree
Hide file tree
Showing 17 changed files with 530 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ vic_memory_config = none
via_zeropages = ,
project_path = /Users/leuat/code/TRSE/ReleaseM1/trse.app/Contents/MacOS/../../tutorials/AMSTRADCPC/UnitTests/
open_files = ,[ext]units/global/unittests/classes.tru, unittests.asm, unittests.ras
current_file = unittests.ras
current_file = unittests.asm
2 changes: 1 addition & 1 deletion Publish/tutorials/X86/unittests/x86_unittests.trse
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ columns = 40
vic_memory_config = none
via_zeropages = ,
project_path = /Users/leuat/code/TRSE/ReleaseM1/trse.app/Contents/MacOS/../../tutorials/X86/unittests/
open_files = ,[ext]units/global/unittests/classes.tru, utests.ras
open_files = ,utests.asm, utests.ras, [ext]units/global/unittests/classes.tru
current_file = utests.ras
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -609,5 +609,6 @@
<file>resources/images/amiga_intro.png</file>
<file>resources/text/opcodes_z80.txt</file>
<file>resources/images/tutorials/olimp.jpg</file>
<file>resources/bin/bootsect.bin</file>
</qresource>
</RCC>
Binary file added resources/bin/bootsect.bin
Binary file not shown.
16 changes: 12 additions & 4 deletions source/Compiler/assembler/asmx86.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "asmx86.h"
#include "source/Compiler/optimiser/postoptimizerx86.h"

#include <QRegularExpression>


AsmX86::AsmX86()
Expand Down Expand Up @@ -50,7 +50,8 @@ void AsmX86::Connect() {
void AsmX86::Program(QString name, QString vicParam)
{
m_source+=m_startInsertAssembler;
Asm("[ORG "+Util::numToHex(Syntax::s.m_currentSystem->m_programStartAddress) + "]");
if (Syntax::s.m_currentSystem->m_programStartAddress!=0)
Asm("[ORG "+Util::numToHex(Syntax::s.m_currentSystem->m_programStartAddress) + "]");
m_hash = "";
/* Asm("jmp save_ds_register");
Write("ds_register_saved: dw 0",0);
Expand All @@ -67,8 +68,15 @@ void AsmX86::EndProgram()

void AsmX86::Write(QString str, int level)
{
QString s = str.replace("$","0x");
Assembler::Write(s,level);
QRegularExpression regexp("\\$\\b[0-9a-fA-F]+\\b");
if (str.contains(regexp))
str = str.replace("$","0x");
// QString s = str.replace(regexp,"0x");
// if (s.contains("$"))
// qDebug() << s;
//if (s!=str) qDebug() <<s;
//QString s = str.replace("$","0x");
Assembler::Write(str,level);
}

void AsmX86::DeclareArray(QString name, QString type, int count, QStringList data, QString pos)
Expand Down
1 change: 0 additions & 1 deletion source/Compiler/compilers/compilerx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void CompilerX86::InitAssemblerAnddispatcher(QSharedPointer<AbstractSystem> syst




}

void CompilerX86::Connect()
Expand Down
37 changes: 26 additions & 11 deletions source/Compiler/systems/systemx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,36 @@ void SystemX86::Assemble(QString &text, QString filename, QString currentDir, QS
//qDebug() << m_settingsIni->getString("assembler");
QProcess process;
QStringList params;
// -kick1hunks -o example$1 -nosym source$1.asm
// params << "-kick1hunks";
// params << "-Fhunkexe";
params << "-o" << filename + ".exe";
params << filename+".asm";
// qDebug() << params;
bool qemu = false;
if (m_projectIni->contains("qemu") && m_projectIni->getString("qemu").startsWith("qemu")) {
params << "-f"<< "bin";
params << filename+".asm";
params << "-o" << filename + ".bin";
qemu = true;
}
else
{
params << "-o" << filename + ".exe";
params << filename+".asm";
}
process.start(m_settingsIni->getString("nasm"), params);
process.waitForFinished();
output = process.readAllStandardOutput();
output+= process.readAllStandardError();
// qDebug() << output;
/* output = process.readAllStandardError();
process.start(m_settingsIni->getString("nasm"), QStringList() << filename + ".obj" << filename + ".exe");
process.waitForFinished();
*/


if (qemu) {
QByteArray boot = Util::loadBinaryFile(":resources/bin/bootsect.bin");
// qDebug() <<boot.count();
QByteArray data = Util::loadBinaryFile(filename+".bin");
boot.append(data);
Util::SaveByteArray(boot,filename+".bin");

}





int assembleTime = timer.elapsed()- time;
time = timer.elapsed();
Expand Down
5 changes: 5 additions & 0 deletions source/Compiler/systems/systemx86.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class SystemX86 : public AbstractSystem
m_processor = PX86;
m_system = X86;
m_startAddress = 0x100;
if (m_projectIni->contains("qemu") && m_projectIni->getString("qemu").startsWith("qemu")){
m_startAddress = 0x7c00;
m_startAddress = 0x1000;
}

m_programStartAddress = m_startAddress;
m_cpu = m_projectIni->getString("cpu_x86_system");
m_allowedGlobalTypeFlags << "compressed"<<"pure"<<"pure_variable" <<"pure_number" << "signed" <<"no_term";
Expand Down
2 changes: 2 additions & 0 deletions source/dialogprojectsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void DialogProjectSettings::FillFromIni()
ui->leUserDefinedtempVars->setText(fromStringList(m_ini->getStringList("zeropages_userdefined")));

ui->cmbSystem->setCurrentText(m_ini->getString("system"));
ui->cmbQuemu->setCurrentText(m_ini->getString("qemu"));
// on_cmbSystem_currentIndexChanged(ui->cmbSystem)
UpdateSystem();

Expand Down Expand Up @@ -203,6 +204,7 @@ void DialogProjectSettings::FillToIni()
m_ini->setString("petmodel", ui->cbmPetSystem->currentText());

m_ini->setString("amstradcpc_model", ui->cmbAmstradCPCModel->currentText());
m_ini->setString("qemu",ui->cmbQuemu->currentText());
m_ini->setString("amstradcpc_options", ui->leAmstradCPCOptions->text());

m_ini->setFloat("spectrum_model", ui->cbmSpectrumModel->currentIndex());
Expand Down
Loading

0 comments on commit 8f46a6b

Please sign in to comment.