if (lof_changed || interlace_seen <= 0 || (currprefs.gfx_iscanlines && interlace_seen > 0) || last_redraw_point >= 2 || long_field || doublescan < 0) {
last_redraw_point = 0;
- if (framecnt == 0)
- finish_drawing_frame ();
+ if (framecnt == 0) {
+ finish_drawing_frame();
+#ifdef AVIOUTPUT
+ if (!picasso_on) {
+ frame_drawn();
+ }
+#endif
+ }
#if 0
if (interlace_seen > 0) {
interlace_seen = -1;
- } else if (interlace_seen == -1) {
+ }
+ else if (interlace_seen == -1) {
interlace_seen = 0;
if (currprefs.gfx_scandoubler && currprefs.gfx_vresolution)
- notice_screen_contents_lost ();
+ notice_screen_contents_lost();
}
#endif
#ifdef SAVESTATE
if (!savestate_state) {
if (currprefs.quitstatefile[0]) {
- savestate_initsave (currprefs.quitstatefile, 1, 1, true);
- save_state (currprefs.quitstatefile, _T(""));
+ savestate_initsave(currprefs.quitstatefile, 1, 1, true);
+ save_state(currprefs.quitstatefile, _T(""));
}
}
#endif
quit_program = -quit_program;
- set_inhibit_frame (IHF_QUIT_PROGRAM);
+ set_inhibit_frame(IHF_QUIT_PROGRAM);
set_special(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
return;
}
- count_frame ();
+ count_frame();
- if (framecnt == 0)
- init_drawing_frame ();
- else if (currprefs.cpu_memory_cycle_exact)
- init_hardware_for_drawing_frame ();
+ if (framecnt == 0) {
+ init_drawing_frame();
+ } else if (currprefs.cpu_memory_cycle_exact) {
+ init_hardware_for_drawing_frame();
+ }
} else {
- if (isvsync_chipset ())
- flush_screen (gfxvidinfo.inbuffer, 0, 0); /* vsync mode */
+ if (isvsync_chipset()) {
+ flush_screen(gfxvidinfo.inbuffer, 0, 0); /* vsync mode */
+ }
}
gui_flicker_led (-1, 0, 0);
-#ifdef AVIOUTPUT
- if (!picasso_on)
- frame_drawn ();
-#endif
}
void hsync_record_line_state (int lineno, enum nln_how how, int changed)
extern void drawing_init (void);
extern bool notice_interlace_seen (bool);
extern void notice_resolution_seen (int, bool);
-extern void frame_drawn (void);
+extern bool frame_drawn (void);
extern void redraw_frame (void);
extern bool draw_frame (struct vidbuffer*);
extern int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy, int *prealh);
#include "fsdb.h"
#include "threaddep/thread.h"
#include "zfile.h"
+#include "savestate.h"
#define MAX_AVI_SIZE (0x80000000 - 0x1000000)
static int frame_skip;
static uae_u64 total_avi_size;
static int partcnt;
-static int first_frame = 1;
+static int first_frame;
int avioutput_audio, avioutput_video, avioutput_enabled, avioutput_requested;
static int videoallocated;
regquerydata(avikey, _T("VideoConfigurationState"), state, &ss);
}
pcv->hic = ICOpen (pcv->fccType, pcv->fccHandler, ICMODE_COMPRESS);
- if (pcv->hic) {
+ if (pcv->hic || (!pcv->hic && pcv->fccHandler == mmioFOURCC('D', 'I', 'B', ' '))) { // DIB = uncompressed
ok = 1;
- ICSetState (pcv->hic, state, ss);
+ if (pcv->hic)
+ ICSetState (pcv->hic, state, ss);
}
xfree (state);
}
ss = 0;
}
if (ss == 0)
- state = xmalloc (uae_u8, 1);
+ state = xcalloc (uae_u8, 1);
avikey = openavikey ();
if (avikey) {
regsetdata (avikey, _T("VideoConfigurationState"), state, ss);
static void AVIOutput_End2(bool fullrestart)
{
- first_frame = 1;
+ first_frame = 0;
avioutput_enabled = 0;
if (alive) {
if (fullstart) {
reset_sound();
init_hz_normal();
- first_frame = 1;
+ first_frame = 0;
+ if (savestate_state && !avioutput_originalsize)
+ first_frame = 1;
} else {
first_frame = 0;
}
}
}
-void AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize)
+static void start_if_requested(void)
{
- if (!avioutput_audio || !avioutput_enabled)
+ if (!avioutput_requested)
return;
+ AVIOutput_Begin(true);
+}
+
+static bool can_record(void)
+{
+ if (savestate_state == STATE_DORESTORE || savestate_state == STATE_RESTORE)
+ return false;
+ return true;
+}
+
+bool AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize)
+{
+ if (!can_record())
+ return false;
+
+ start_if_requested();
+
+ if (!avioutput_audio || !avioutput_enabled)
+ return false;
if (!sndbufsize)
- return;
+ return false;
if (avioutput_failed)
- return;
+ return false;
if (!avi_sndbuffer) {
avi_sndbufsize = sndbufsize * 2;
}
memcpy(avi_sndbuffer + avi_sndbuffered, sndbuffer, sndbufsize);
avi_sndbuffered += sndbufsize;
+ return true;
}
-void frame_drawn (void)
+bool frame_drawn (void)
{
+ if (!can_record())
+ return false;
+
+ start_if_requested();
+
if (screenshot_multi) {
screenshot(1, 1);
if (screenshot_multi > 0)
}
if (!avioutput_enabled)
- return;
+ return false;
if (avioutput_failed)
- return;
+ return false;
if (avioutput_audio == AVIAUDIO_WAV) {
finish_sound_buffer();
}
first_frame = 0;
avi_sndbuffered = 0;
- return;
+ return true;
}
if (avioutput_audio) {
finish_sound_buffer();
- if (!first_frame) {
+ if (first_frame == 0 || first_frame == -1) {
int bytesperframe;
bytesperframe = wfxSrc.Format.nChannels * 2;
StreamSizeAudioGot += avi_sndbuffered / bytesperframe;
}
if (first_frame) {
- first_frame = 0;
- return;
+ if (first_frame > 0)
+ first_frame--;
+ else
+ first_frame++;
+ return true;
}
if (!avioutput_video)
- return;
+ return false;
AVIOutput_WriteVideo ();
+ return true;
}
/* Resampler from:
extern TCHAR avioutput_filename_inuse[MAX_DPATH];
extern void AVIOutput_Toggle (int mode, bool immediate);
-extern void AVIOutput_WriteAudio (uae_u8 *sndbuffer, int sndbufsize);
-extern void AVIOutput_WriteVideo (void);
+extern bool AVIOutput_WriteAudio (uae_u8 *sndbuffer, int sndbufsize);
extern int AVIOutput_ChooseAudioCodec (HWND hwnd, TCHAR*, int);
extern int AVIOutput_GetAudioCodec (TCHAR*, int);
extern int AVIOutput_ChooseVideoCodec (HWND hwnd, TCHAR*, int);
// must be after driveclick_mix
paula_sndbufpt = paula_sndbuffer;
#ifdef AVIOUTPUT
- if (avioutput_enabled && avioutput_audio) {
- AVIOutput_WriteAudio((uae_u8*)paula_sndbuffer, bufsize);
- if (avioutput_nosoundsync)
- sound_setadjust(0);
+ if (avioutput_audio) {
+ if (AVIOutput_WriteAudio((uae_u8*)paula_sndbuffer, bufsize)) {
+ if (avioutput_nosoundsync)
+ sound_setadjust(0);
+ }
}
if (avioutput_enabled && (!avioutput_framelimiter || avioutput_nosoundoutput))
return;
if (resumepaused (7)) {
inputdevice_acquire (TRUE);
setmouseactive (1);
-#ifdef AVIOUTPUT
- AVIOutput_Begin (true);
-#endif
}
flipgui(false);
fpscounter_reset ();
break;
restart_requested = 0;
}
- if (ret > 0) {
-#ifdef AVIOUTPUT
- AVIOutput_Begin (true);
-#endif
- }
return ret;
}