shithub: sms

Download patch

ref: 5e858a33cdc59ffea8b4a4d7025a34efad801126
parent: 3e48e5e879677f7b285803feb799ad4a31ceeffb
author: Jean-André Santoni <jean.andre.santoni@gmail.com>
date: Thu Aug 28 05:39:45 EDT 2025

have psg.c compiled

--- a/psg.c
+++ b/psg.c
@@ -13,12 +13,12 @@
 	1642, 1298, 1031, 819, 650, 516, 410, 326, 0
 };
 
-static double cyclespersample;
-static double cycles;
+static float cyclespersample;
+static float cyc;
 static u16int freqreg[4];
 static u16int countreg[4];
 static u8int attn[4];
-static bool flipflop[4];
+static int flipflop[4];
 static u16int noise;
 static u8int curr_reg;
 static u8int curr_type;
@@ -27,13 +27,13 @@
 psginit(const u16int rate, const int clockspd)
 {
 	cyclespersample = (double)clockspd / (double)PSGDIV/ (double)rate;
-	cycles = cyclespersample;
+	cyc = cyclespersample;
 }
 
 void
 psgwrite(const u8int data)
 {
-	bool first = data & 128;
+	int first = data & 128;
 	if(first){
 		curr_reg = (data >> 5) & 3;
 		curr_type = (data >> 4) & 1;
@@ -68,10 +68,10 @@
 	return (flipflop[chn] ? 1 : -1) * vol_table[attn[chn]];
 }
 
-int16_t
+u16int
 psgstep()
 {
-	while(cycles > 0){
+	while(cyc > 0){
 		for(u8int i = 0; i < 4; i++){
 			countreg[i]--;
 			if(!countreg[i]){
@@ -89,10 +89,10 @@
 			}
 		}
 
-		cycles--;
+		cyc--;
 	}
 
-	cycles += cyclespersample;
+	cyc += cyclespersample;
 
 	return vol(0) + vol(1) + vol(2) + vol(3);
 }
--