mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-12 06:29:58 +00:00
Use 32bit counters to avoid overflow
- Previously there were cases where we could overflow cpu65_cycles_to_execute when adding the cycles_speaker_feedback
This commit is contained in:
parent
978011cffa
commit
851d22568b
@ -57,7 +57,7 @@ extern void *cpu65_vmem_w[65536];
|
||||
extern unsigned char cpu65_flags_encode[256];
|
||||
extern unsigned char cpu65_flags_decode[256];
|
||||
|
||||
extern int16_t cpu65_cycle_count;
|
||||
extern int32_t cpu65_cycle_count;
|
||||
|
||||
#if CPU_TRACING
|
||||
void cpu65_trace_begin(const char *trace_file);
|
||||
|
@ -52,7 +52,9 @@ static void testcpu_setup(void *arg) {
|
||||
|
||||
//reinitialize();
|
||||
cpu65_uninterrupt(0xff);
|
||||
extern int16_t cpu65_cycles_to_execute;
|
||||
extern int32_t cpu65_cycles_to_execute;
|
||||
extern int32_t cpu65_cycle_count;
|
||||
cpu65_cycle_count = 0;
|
||||
cpu65_cycles_to_execute = 1;
|
||||
|
||||
cpu65_pc = TEST_LOC;
|
||||
|
@ -54,9 +54,9 @@
|
||||
double cycles_persec_target = CLK_6502;
|
||||
unsigned long long cycles_count_total = 0;
|
||||
int cycles_speaker_feedback = 0;
|
||||
int16_t cpu65_cycles_to_execute = 0; // cycles-to-execute by cpu65_run()
|
||||
int16_t cpu65_cycle_count = 0; // cycles currently excuted by cpu65_run()
|
||||
static int16_t cycles_checkpoint_count = 0;
|
||||
int32_t cpu65_cycles_to_execute = 0; // cycles-to-execute by cpu65_run()
|
||||
int32_t cpu65_cycle_count = 0; // cycles currently excuted by cpu65_run()
|
||||
static int32_t cycles_checkpoint_count = 0;
|
||||
static unsigned int g_dwCyclesThisFrame = 0;
|
||||
|
||||
// scaling and speed adjustments
|
||||
@ -370,7 +370,7 @@ unsigned int CpuGetCyclesThisVideoFrame(void) {
|
||||
|
||||
// Called when an IO-reg is accessed & accurate global cycle count info is needed
|
||||
void timing_checkpoint_cycles(void) {
|
||||
const int16_t d = cpu65_cycle_count - cycles_checkpoint_count;
|
||||
const int32_t d = cpu65_cycle_count - cycles_checkpoint_count;
|
||||
assert(d >= 0);
|
||||
cycles_count_total += d;
|
||||
cycles_checkpoint_count = cpu65_cycle_count;
|
||||
|
@ -2155,10 +2155,10 @@ continue:
|
||||
addb DebugCycleCount, %al
|
||||
movb %al, DebugCycleCount
|
||||
TRACE_EPILOGUE
|
||||
addw %ax, SN(cpu65_cycle_count)
|
||||
addl %eax, SN(cpu65_cycle_count)
|
||||
subl %eax, SN(gc_cycles_timer_0)
|
||||
subl %eax, SN(gc_cycles_timer_1)
|
||||
subw %ax, SN(cpu65_cycles_to_execute)
|
||||
subl %eax, SN(cpu65_cycles_to_execute)
|
||||
jle exit_cpu65_run
|
||||
continue1: xorLQ _XAX, _XAX
|
||||
orb SN(cpu65__signal), %al
|
||||
|
Loading…
x
Reference in New Issue
Block a user