From cdca612df2e9d396b1dc2ae82d03f794d52c934d Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Sat, 28 Oct 2023 16:57:04 +0100 Subject: [PATCH] Added a mii_cycle_t type Instead of using the sub-standard __int128 Signed-off-by: Michel Pollet --- src/mii.h | 6 +++++- src/mii_speaker.c | 2 +- src/mii_speaker.h | 4 ++-- src/mii_types.h | 14 ++++++++++++++ src/mii_video.h | 20 +++++++++----------- 5 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 src/mii_types.h diff --git a/src/mii.h b/src/mii.h index 07153d8..ba7ff41 100644 --- a/src/mii.h +++ b/src/mii.h @@ -10,6 +10,7 @@ #include #include +#include "mii_types.h" #include "mii_65c02.h" #include "mii_dd.h" #include "mii_bank.h" @@ -17,6 +18,7 @@ #include "mii_video.h" #include "mii_speaker.h" #include "mii_mouse.h" +#include "mii_analog.h" enum { MII_BANK_MAIN = 0, // main 48K address space @@ -76,12 +78,13 @@ typedef struct mii_trace_t { uint32_t step_inst; } mii_trace_t; + /* * principal emulator state, for a faceless emulation */ typedef struct mii_t { unsigned int state; - __uint128_t cycles; + mii_cycles_t cycles; /* this is the video frame/VBL rate vs 60hz, default to 1.0 */ float speed; float speed_current; // calculated speed @@ -121,6 +124,7 @@ typedef struct mii_t { mii_speaker_t speaker; mii_mouse_t mouse; mii_dd_system_t dd; + mii_analog_t analog; } mii_t; enum { diff --git a/src/mii_speaker.c b/src/mii_speaker.c index aa376bf..c7ffa7b 100644 --- a/src/mii_speaker.c +++ b/src/mii_speaker.c @@ -156,7 +156,7 @@ mii_speaker_click( // if we've gone past the end of the frame, switch to the next one if (sample_index >= s->fsize) { sample_index = sample_index % s->fsize; - __uint128_t newstart = s->mii->cycles - (sample_index * s->clk_per_sample); + mii_cycles_t newstart = s->mii->cycles - (sample_index * s->clk_per_sample); s->findex = (s->findex + 1) % MII_SPEAKER_FRAME_COUNT; f = &s->frame[s->findex]; f->start = newstart; diff --git a/src/mii_speaker.h b/src/mii_speaker.h index a9995cc..37a2a76 100644 --- a/src/mii_speaker.h +++ b/src/mii_speaker.h @@ -17,8 +17,8 @@ struct snd_pcm_t; typedef int16_t mii_audio_sample_t; typedef struct mii_audio_frame_t { - __uint128_t start; - uint16_t fill; + mii_cycles_t start; + uint16_t fill; mii_audio_sample_t * audio; } mii_audio_frame_t; diff --git a/src/mii_types.h b/src/mii_types.h new file mode 100644 index 0000000..c6a45b1 --- /dev/null +++ b/src/mii_types.h @@ -0,0 +1,14 @@ +/* + * mii_types.h + * + * Copyright (C) 2023 Michel Pollet + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include + +typedef __uint128_t mii_cycles_t; diff --git a/src/mii_video.h b/src/mii_video.h index dd5fc56..1be80df 100644 --- a/src/mii_video.h +++ b/src/mii_video.h @@ -8,9 +8,7 @@ #pragma once -#include -#include - +#include "mii_types.h" // TODO move VRAM stuff to somewhere else /* @@ -32,14 +30,14 @@ enum { struct mii_t; typedef struct mii_video_t { - void * state; // protothread state in mii_video.c - uint8_t line; // current line - bool vbl_irq; // VBL IRQ emabled (set by mouse card) - __uint128_t wait; // 'wait until' cycle marker - uint32_t pixels[MII_VRAM_WIDTH * MII_VRAM_HEIGHT]; - uint32_t frame_count; // incremented every frame - uint32_t frame_drawn; - uint8_t color_mode; // color, green, amber + void * state; // protothread state in mii_video.c + uint8_t line; // current line + bool vbl_irq; // VBL IRQ emabled (set by mouse card) + mii_cycles_t wait; // 'wait until' cycle marker + uint32_t pixels[MII_VRAM_WIDTH * MII_VRAM_HEIGHT]; + uint32_t frame_count; // incremented every frame + uint32_t frame_drawn; + uint8_t color_mode; // color, green, amber } mii_video_t; bool