@@ -75,6 +75,9 @@ C64Class::C64Class(int *ret_error, int soundbuffer_size, VideoCrtClass *video_cr
7575
7676 this ->start_minimized = start_minimized;
7777
78+ LimitCyclesEvent = nullptr ;
79+ DebugCartEvent = nullptr ;
80+
7881 changed_graphic_modi = false ;
7982 changed_window_pos = false ;
8083 changed_window_size = false ;
@@ -95,6 +98,9 @@ C64Class::C64Class(int *ret_error, int soundbuffer_size, VideoCrtClass *video_cr
9598
9699 warp_mode = false ;
97100
101+ enable_debug_cart = false ;
102+ is_wtite_to_debug_cart = false ;
103+
98104 LogText = log_function;
99105
100106 enable_mouse_1351 = false ;
@@ -606,11 +612,26 @@ C64Class::~C64Class()
606612 if (crt != nullptr ) delete crt;
607613 if (reu != nullptr ) delete reu;
608614 if (geo != nullptr ) delete geo;
615+ if (tape != nullptr ) delete tape;
609616
610617 if (video_capture != nullptr ) delete video_capture;
611618
612619 if (audio_16bit_buffer != nullptr )
613620 delete [] audio_16bit_buffer;
621+
622+ SDL_FreeSurface (img_joy_arrow0);
623+ SDL_FreeSurface (img_joy_arrow1);
624+ SDL_FreeSurface (img_joy_button0);
625+ SDL_FreeSurface (img_joy_button1);
626+ SDL_FreeSurface (sdl_window_icon);
627+
628+ if (screenshot_dir != nullptr ) delete[] screenshot_dir;
629+
630+ if (mutex1 != nullptr )
631+ {
632+ SDL_DestroyMutex (mutex1);
633+ mutex1 = nullptr ;
634+ }
614635}
615636
616637void C64Class::StartEmulation ()
@@ -659,6 +680,8 @@ void C64Class::EndEmulation()
659680 time_out--;
660681 }
661682
683+ SDL_DetachThread (sdl_thread);
684+
662685 SDL_PauseAudioDevice (audio_dev, 1 );
663686 if (audio_dev > 0 ) SDL_CloseAudioDevice (audio_dev);
664687
@@ -673,7 +696,7 @@ void C64Class::SetLimitCycles(int nCycles)
673696
674697void C64Class::SetEnableDebugCart (bool enable)
675698{
676- cpu-> SetEnableDebugCart ( enable) ;
699+ enable_debug_cart = enable;
677700}
678701
679702void AudioMix (void *not_used, Uint8 *stream, int laenge)
@@ -693,11 +716,14 @@ void AudioMix(void *not_used, Uint8 *stream, int laenge)
693716int SDLThreadWarp (void *userdat)
694717{
695718 C64Class *c64 = static_cast <C64Class*>(userdat);
719+ c64->warp_thread_is_end = false ;
696720
697721 while (!c64->warp_thread_end )
698722 {
699- c64->WarpModeLoop ();
723+ c64->WarpModeLoop ();
700724 }
725+
726+ c64->warp_thread_is_end = true ;
701727 return 0 ;
702728}
703729
@@ -924,17 +950,17 @@ void C64Class::WarpModeLoop()
924950 }
925951 }
926952
927- if (cpu->WRITE_DEBUG_CART )
953+ // DebugCartEvent soll nur maximal einmal aufgerufen werden
954+ if (is_wtite_to_debug_cart && (DebugCartEvent != nullptr ))
928955 {
929- // Event auslösen
930- cpu-> WRITE_DEBUG_CART = false ;
931- if ( DebugCartEvent ! = nullptr ) DebugCartEvent (cpu-> GetDebugCartValue ());
956+ is_wtite_to_debug_cart = false ;
957+ DebugCartEvent (debug_cart_value) ;
958+ DebugCartEvent = nullptr ; // Nur einmal aufrufen
932959 }
933960
934961 NextSystemCycle ();
935962
936963 // //////////////////////// Testweise //////////////////////////
937-
938964 static int zyklen_counter = 0 ;
939965 if (++zyklen_counter == 19656 )
940966 {
@@ -1039,11 +1065,13 @@ void C64Class::FillAudioBuffer(uint8_t *stream, int laenge)
10391065 }
10401066 }
10411067
1042- if (cpu->WRITE_DEBUG_CART )
1068+
1069+ // DebugCartEvent soll nur maximal einmal aufgerufen werden
1070+ if (is_wtite_to_debug_cart && (DebugCartEvent != nullptr ))
10431071 {
1044- // Event auslösen
1045- cpu-> WRITE_DEBUG_CART = false ;
1046- if ( DebugCartEvent ! = nullptr ) DebugCartEvent (cpu-> GetDebugCartValue ());
1072+ is_wtite_to_debug_cart = false ;
1073+ DebugCartEvent (debug_cart_value) ;
1074+ DebugCartEvent = nullptr ; // Nur einmal aufrufen
10471075 }
10481076
10491077 NextSystemCycle ();
@@ -2710,12 +2738,21 @@ void C64Class::EnableWarpMode(bool enabled)
27102738 SDL_PauseAudioDevice (audio_dev, 1 ); // Audiostream pausieren
27112739 warp_thread_end = false ;
27122740 warp_thread = SDL_CreateThread (SDLThreadWarp," WarpThread" ,this );
2741+ LogText (" WarpMode aktiviert\n " );
27132742 }
27142743 else
27152744 {
27162745 // WarpMode deaktivieren
27172746 warp_thread_end = true ;
2747+ SDL_DetachThread (warp_thread);
2748+
2749+ while (!warp_thread_is_end)
2750+ {
2751+ SDL_Delay (1 );
2752+ }
2753+
27182754 SDL_PauseAudioDevice (audio_dev, 0 ); // Audiostream wieder starten
2755+ LogText (" WarpMode deaktiviert\n " );
27192756 }
27202757}
27212758
@@ -4003,7 +4040,7 @@ void C64Class::NextSystemCycle()
40034040{
40044041 CheckKeys ();
40054042
4006- if (hold_next_system_cycle)
4043+ if (hold_next_system_cycle)
40074044 return ;
40084045
40094046 cycle_counter++;
@@ -4276,6 +4313,12 @@ bool C64Class::CheckBreakpoints()
42764313
42774314void C64Class::WriteSidIO (uint16_t address, uint8_t value)
42784315{
4316+ if ((enable_debug_cart == true ) && (address == DEBUG_CART_ADRESS))
4317+ {
4318+ debug_cart_value = value;
4319+ is_wtite_to_debug_cart = true ;
4320+ }
4321+
42794322 if (enable_stereo_sid)
42804323 {
42814324 if ((address & 0xFFE0 ) == 0xD400 ) sid1->WriteIO (address,value);
0 commit comments