Skip to content

Commit

Permalink
[#211]
Browse files Browse the repository at this point in the history
Floppy1581 in C64Class eingeuegt und initialisiert.
  • Loading branch information
ThKattanek committed Aug 20, 2021
1 parent c42a76d commit 24af60d
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 18 deletions.
42 changes: 30 additions & 12 deletions src/c64_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
// //
//////////////////////////////////////////////////
Expand Down Expand Up @@ -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];
Expand All @@ -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; i<MAX_FLOPPY_NUM; i++)
{
// 1541
floppy1541[i] = new Floppy1541(&reset_wire,audio_frequency,audio_spec_have.samples,&floppy_found_breakpoint);
floppy1541[i]->SetResetReady(&floppy_reset_ready[i],0xEBFF);
floppy1541[i]->SetResetReady(&floppy1541_reset_ready[i],0xEBFF);
floppy1541[i]->SetC64IEC(&c64_iec_wire);
floppy1541[i]->SetDeviceNumber(static_cast<uint8_t>(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; i<MAX_FLOPPY_NUM; i++)
{
// 1581
floppy1581[i] = new Floppy1581(&reset_wire);
floppy1581[i]->SetResetReady(&floppy1581_reset_ready[i],0xFFFF);
floppy1581[i]->SetC64IEC(&c64_iec_wire);
floppy1581[i]->SetDeviceNumber(static_cast<uint8_t>(8+i));
floppy1581[i]->LoadDosRom(filename);
floppy1581[i]->SetEnableFloppy(false);
}

/// Init Vars ///
c64_frequency = C64Takt;
c64_speed = 100;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions src/c64_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
// //
//////////////////////////////////////////////////
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
76 changes: 74 additions & 2 deletions src/floppy1581_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
29 changes: 27 additions & 2 deletions src/floppy1581_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,44 @@
// 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 //
// //
//////////////////////////////////////////////////

#ifndef FLOPPY1581_H
#define FLOPPY1581_H

#include <math.h>
#include <cstring>
#include <fstream>
#include <functional>

#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

0 comments on commit 24af60d

Please sign in to comment.