Added a mii_cycle_t type

Instead of using the sub-standard __int128

Signed-off-by: Michel Pollet <buserror@gmail.com>
This commit is contained in:
Michel Pollet 2023-10-28 16:57:04 +01:00
parent af6ff70155
commit cdca612df2
5 changed files with 31 additions and 15 deletions

View File

@ -10,6 +10,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "mii_types.h"
#include "mii_65c02.h" #include "mii_65c02.h"
#include "mii_dd.h" #include "mii_dd.h"
#include "mii_bank.h" #include "mii_bank.h"
@ -17,6 +18,7 @@
#include "mii_video.h" #include "mii_video.h"
#include "mii_speaker.h" #include "mii_speaker.h"
#include "mii_mouse.h" #include "mii_mouse.h"
#include "mii_analog.h"
enum { enum {
MII_BANK_MAIN = 0, // main 48K address space MII_BANK_MAIN = 0, // main 48K address space
@ -76,12 +78,13 @@ typedef struct mii_trace_t {
uint32_t step_inst; uint32_t step_inst;
} mii_trace_t; } mii_trace_t;
/* /*
* principal emulator state, for a faceless emulation * principal emulator state, for a faceless emulation
*/ */
typedef struct mii_t { typedef struct mii_t {
unsigned int state; unsigned int state;
__uint128_t cycles; mii_cycles_t cycles;
/* this is the video frame/VBL rate vs 60hz, default to 1.0 */ /* this is the video frame/VBL rate vs 60hz, default to 1.0 */
float speed; float speed;
float speed_current; // calculated speed float speed_current; // calculated speed
@ -121,6 +124,7 @@ typedef struct mii_t {
mii_speaker_t speaker; mii_speaker_t speaker;
mii_mouse_t mouse; mii_mouse_t mouse;
mii_dd_system_t dd; mii_dd_system_t dd;
mii_analog_t analog;
} mii_t; } mii_t;
enum { enum {

View File

@ -156,7 +156,7 @@ mii_speaker_click(
// if we've gone past the end of the frame, switch to the next one // if we've gone past the end of the frame, switch to the next one
if (sample_index >= s->fsize) { if (sample_index >= s->fsize) {
sample_index = 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; s->findex = (s->findex + 1) % MII_SPEAKER_FRAME_COUNT;
f = &s->frame[s->findex]; f = &s->frame[s->findex];
f->start = newstart; f->start = newstart;

View File

@ -17,8 +17,8 @@ struct snd_pcm_t;
typedef int16_t mii_audio_sample_t; typedef int16_t mii_audio_sample_t;
typedef struct mii_audio_frame_t { typedef struct mii_audio_frame_t {
__uint128_t start; mii_cycles_t start;
uint16_t fill; uint16_t fill;
mii_audio_sample_t * audio; mii_audio_sample_t * audio;
} mii_audio_frame_t; } mii_audio_frame_t;

14
src/mii_types.h Normal file
View File

@ -0,0 +1,14 @@
/*
* mii_types.h
*
* Copyright (C) 2023 Michel Pollet <buserror@gmail.com>
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef __uint128_t mii_cycles_t;

View File

@ -8,9 +8,7 @@
#pragma once #pragma once
#include <stdbool.h> #include "mii_types.h"
#include <stdint.h>
// TODO move VRAM stuff to somewhere else // TODO move VRAM stuff to somewhere else
/* /*
@ -32,14 +30,14 @@ enum {
struct mii_t; struct mii_t;
typedef struct mii_video_t { typedef struct mii_video_t {
void * state; // protothread state in mii_video.c void * state; // protothread state in mii_video.c
uint8_t line; // current line uint8_t line; // current line
bool vbl_irq; // VBL IRQ emabled (set by mouse card) bool vbl_irq; // VBL IRQ emabled (set by mouse card)
__uint128_t wait; // 'wait until' cycle marker mii_cycles_t wait; // 'wait until' cycle marker
uint32_t pixels[MII_VRAM_WIDTH * MII_VRAM_HEIGHT]; uint32_t pixels[MII_VRAM_WIDTH * MII_VRAM_HEIGHT];
uint32_t frame_count; // incremented every frame uint32_t frame_count; // incremented every frame
uint32_t frame_drawn; uint32_t frame_drawn;
uint8_t color_mode; // color, green, amber uint8_t color_mode; // color, green, amber
} mii_video_t; } mii_video_t;
bool bool