From 24af60d7a9833bba58e9625c689a203077d47fab Mon Sep 17 00:00:00 2001 From: Thorsten Kattanek Date: Fri, 20 Aug 2021 12:43:26 +0200 Subject: [PATCH] [#211] Floppy1581 in C64Class eingeuegt und initialisiert. --- src/c64_class.cpp | 42 +++++++++++++++------- src/c64_class.h | 6 ++-- src/floppy1581_class.cpp | 76 ++++++++++++++++++++++++++++++++++++++-- src/floppy1581_class.h | 29 +++++++++++++-- 4 files changed, 135 insertions(+), 18 deletions(-) diff --git a/src/c64_class.cpp b/src/c64_class.cpp index 15159d0..7f1c753 100755 --- a/src/c64_class.cpp +++ b/src/c64_class.cpp @@ -8,7 +8,7 @@ // Dieser Sourcecode ist Copyright geschützt! // // Geistiges Eigentum von Th.Kattanek // // // -// Letzte Änderung am 08.07.2021 // +// Letzte Änderung am 20.08.2021 // // www.emu64.de // // // ////////////////////////////////////////////////// @@ -353,8 +353,6 @@ C64Class::C64Class(int *ret_error, int soundbuffer_size, VideoCrtClass *video_cr /// Floppy mit C64 verbinden /// - sprintf(filename,"%s1541.rom",rom_path); - char motor_filename[FILENAME_MAX]; char motor_on_filename[FILENAME_MAX]; char motor_off_filename[FILENAME_MAX]; @@ -369,19 +367,34 @@ C64Class::C64Class(int *ret_error, int soundbuffer_size, VideoCrtClass *video_cr sprintf(stepper_inc_filename,"%sstepper_inc.raw",floppy_sound_path); sprintf(stepper_dec_filename,"%sstepper_dec.raw",floppy_sound_path); + sprintf(filename,"%s1541.rom",rom_path); + for(int i=0; iSetResetReady(&floppy_reset_ready[i],0xEBFF); + floppy1541[i]->SetResetReady(&floppy1541_reset_ready[i],0xEBFF); floppy1541[i]->SetC64IEC(&c64_iec_wire); floppy1541[i]->SetDeviceNumber(static_cast(8+i)); floppy1541[i]->LoadDosRom(filename); - //floppy1541[i]->LoadFloppySounds((char*)"floppy_sounds/motor.raw",(char*)"floppy_sounds/motor_on.raw",(char*)"floppy_sounds/motor_off.raw",(char*)"floppy_sounds/anschlag.raw",(char*)"floppy_sounds/stepper_inc.raw",(char*)"floppy_sounds/stepper_dec.raw"); floppy1541[i]->LoadFloppySounds(motor_filename,motor_on_filename,motor_off_filename,bumper_filename,stepper_inc_filename,stepper_dec_filename); floppy1541[i]->SetEnableFloppy(false); floppy1541[i]->SetEnableFloppySound(true); } + sprintf(filename,"%s1581.rom",rom_path); + + for(int i=0; iSetResetReady(&floppy1581_reset_ready[i],0xFFFF); + floppy1581[i]->SetC64IEC(&c64_iec_wire); + floppy1581[i]->SetDeviceNumber(static_cast(8+i)); + floppy1581[i]->LoadDosRom(filename); + floppy1581[i]->SetEnableFloppy(false); + } + /// Init Vars /// c64_frequency = C64Takt; c64_speed = 100; @@ -915,7 +928,7 @@ void C64Class::WarpModeLoop() } else { - if((c64_reset_ready == true) && (floppy_reset_ready[0] == true)) + if((c64_reset_ready == true) && (floppy1541_reset_ready[0] == true)) { SDL_ClearError(); if(SDL_CreateThread(SDLThreadLoad ,"C64ThreadLoad",this) == nullptr) @@ -1033,7 +1046,7 @@ void C64Class::FillAudioBuffer(uint8_t *stream, int laenge) } else { - if((c64_reset_ready == true) && (floppy_reset_ready[0] == true)) + if((c64_reset_ready == true) && (floppy1541_reset_ready[0] == true)) { SDL_ClearError(); if(SDL_CreateThread(SDLThreadLoad ,"C64ThreadLoad",this) == nullptr) @@ -2719,7 +2732,8 @@ int C64Class::LoadAutoRun(uint8_t floppy_nr, FILE *file, const char *filename, i HardReset(); wait_reset_ready = true; c64_reset_ready = false; - floppy_reset_ready[0] = false; + floppy1541_reset_ready[0] = false; + floppy1581_reset_ready[0] = false; return 0; break; @@ -2733,7 +2747,8 @@ int C64Class::LoadAutoRun(uint8_t floppy_nr, FILE *file, const char *filename, i HardReset(); wait_reset_ready = true; c64_reset_ready = false; - floppy_reset_ready[0] = false; + floppy1541_reset_ready[0] = false; + floppy1581_reset_ready[0] = false; return 0; break; @@ -2749,7 +2764,8 @@ int C64Class::LoadAutoRun(uint8_t floppy_nr, FILE *file, const char *filename, i HardReset(); wait_reset_ready = true; c64_reset_ready = false; - floppy_reset_ready[0] = false; + floppy1541_reset_ready[0] = false; + floppy1581_reset_ready[0] = false; return 0; break; @@ -2764,7 +2780,8 @@ int C64Class::LoadAutoRun(uint8_t floppy_nr, FILE *file, const char *filename, i HardReset(); wait_reset_ready = true; c64_reset_ready = false; - floppy_reset_ready[0] = false; + floppy1541_reset_ready[0] = false; + floppy1581_reset_ready[0] = false; return 0; break; @@ -2779,7 +2796,8 @@ int C64Class::LoadAutoRun(uint8_t floppy_nr, FILE *file, const char *filename, i HardReset(); wait_reset_ready = true; c64_reset_ready = false; - floppy_reset_ready[0] = false; + floppy1541_reset_ready[0] = false; + floppy1581_reset_ready[0] = false; return 0; break; diff --git a/src/c64_class.h b/src/c64_class.h index cd822f0..b5222fb 100755 --- a/src/c64_class.h +++ b/src/c64_class.h @@ -8,7 +8,7 @@ // Dieser Sourcecode ist Copyright geschützt! // // Geistiges Eigentum von Th.Kattanek // // // -// Letzte Änderung am 18.08.2021 // +// Letzte Änderung am 20.08.2021 // // www.emu64.de // // // ////////////////////////////////////////////////// @@ -349,6 +349,7 @@ class C64Class REUClass *reu; GEORAMClass *geo; Floppy1541 *floppy1541[MAX_FLOPPY_NUM]; + Floppy1581 *floppy1581[MAX_FLOPPY_NUM]; TAPE1530 *tape; bool enable_stereo_sid; @@ -506,7 +507,8 @@ class C64Class //////////////////////////////////////////////////////////// bool c64_reset_ready; - bool floppy_reset_ready[MAX_FLOPPY_NUM]; + bool floppy1541_reset_ready[MAX_FLOPPY_NUM]; + bool floppy1581_reset_ready[MAX_FLOPPY_NUM]; char c64_command_line[MAX_STRING_LENGTH]; uint16_t c64_command_line_lenght; diff --git a/src/floppy1581_class.cpp b/src/floppy1581_class.cpp index fab8340..434338d 100644 --- a/src/floppy1581_class.cpp +++ b/src/floppy1581_class.cpp @@ -8,14 +8,86 @@ // Dieser Sourcecode ist Copyright geschützt! // // Geistiges Eigentum von Th.Kattanek // // // -// Letzte Änderung am 18.08.2021 // +// Letzte Änderung am 20.08.2021 // // www.emu64.de // // // ////////////////////////////////////////////////// #include "floppy1581_class.h" -Floppy1581::Floppy1581() +Floppy1581::Floppy1581(bool *reset) { + RESET = reset; +} + +void Floppy1581::SetC64IEC(uint8_t *iec) +{ + +} + +void Floppy1581::SetResetReady(bool *ResetReady, uint16_t ResetReadyAdr) +{ + //cpu->ResetReady = ResetReady; + //cpu->ResetReadyAdr = ResetReadyAdr; +} + +void Floppy1581::SetDeviceNumber(uint8_t number) +{ + if((number < 8) || (number > 11)) return; + if(Jumper == (number-8)) return; + + Jumper = number - 8; + + //cpu->Reset(); +} + +bool Floppy1581::LoadDosRom(const char *filename) +{ + FILE *file; + file = fopen(filename, "rb"); + if (file == NULL) + { + return false; + } + + if(0x8000 != fread (ROM, 1, 0x8000, file)) + { + fclose(file); + return false; + } + + fclose(file); + return true; +} + +void Floppy1581::SetEnableFloppy(bool status) +{ + if((!FloppyEnabled) && (status)) + { + /* + MotorStatusOld = false; + DiskMotorOn = false; + + CycleCounter = 0; + + cpu->Reset(); + via1->Reset(); + via2->Reset(); + + StepperIncWait = true; + + AktHalbSpur = -1; //1 + GCR_PTR = GCRSpurStart = GCRImage + ((AktHalbSpur)) * GCR_TRACK_SIZE; + GCRSpurEnde = GCRSpurStart + TrackSize[AktHalbSpur]; + */ + } + else + { + // MotorLoopStatus = 0; + // StepperLoopStatus = 0; + } + FloppyEnabled = status; + if(!status) + FloppyIECLocal = 0xFF; } diff --git a/src/floppy1581_class.h b/src/floppy1581_class.h index 6d03692..da2426b 100644 --- a/src/floppy1581_class.h +++ b/src/floppy1581_class.h @@ -8,7 +8,7 @@ // Dieser Sourcecode ist Copyright geschützt! // // Geistiges Eigentum von Th.Kattanek // // // -// Letzte Änderung am 18.08.2021 // +// Letzte Änderung am 20.08.2021 // // www.emu64.de // // // ////////////////////////////////////////////////// @@ -16,11 +16,36 @@ #ifndef FLOPPY1581_H #define FLOPPY1581_H +#include +#include +#include +#include + +#include "./structs.h" class Floppy1581 { public: - Floppy1581(); + /// Funktionen /// + + Floppy1581(bool *reset); + void SetC64IEC(uint8_t *iec); + void SetResetReady(bool* ResetReady, uint16_t ResetReadyAdr); + void SetDeviceNumber(uint8_t number); + bool LoadDosRom(const char* filename); + void SetEnableFloppy(bool status); + + /// Variablen /// + + bool *RESET; + uint8_t FloppyIECLocal; + uint8_t Jumper; + +private: + bool FloppyEnabled; + + uint8_t RAM[0x0800]; // 2KB + uint8_t ROM[0x8000]; // 32KB }; #endif // FLOPPY1581_H