This commit is contained in:
tudnai
2022-06-26 18:30:42 -07:00
parent 24a45012da
commit 8cc6b2c6dc
9 changed files with 68 additions and 87 deletions
+4 -5
View File
@@ -1462,7 +1462,7 @@
<popUpButton key="view" id="MAv-S5-diZ">
<rect key="frame" x="0.0" y="14" width="43" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" image="Chip" imagePosition="only" alignment="right" lineBreakMode="truncatingTail" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" pullsDown="YES" arrowPosition="noArrow" id="WVW-Wo-mc9">
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" image="popUpButtonCell:WVW-Wo-mc9:image" imagePosition="only" alignment="right" lineBreakMode="truncatingTail" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" pullsDown="YES" arrowPosition="noArrow" id="WVW-Wo-mc9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="Gc4-Or-LMB">
@@ -1853,7 +1853,7 @@
<subviews>
<popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="49f-8R-QCc">
<rect key="frame" x="0.0" y="83" width="120" height="103"/>
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" image="popUpButtonCell:CNs-lh-urM:image" imagePosition="only" alignment="left" lineBreakMode="truncatingTail" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" pullsDown="YES" arrowPosition="noArrow" altersStateOfSelectedItem="NO" id="CNs-lh-urM">
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" image="popUpButtonCell:WVW-Wo-mc9:image" imagePosition="only" alignment="left" lineBreakMode="truncatingTail" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" pullsDown="YES" arrowPosition="noArrow" altersStateOfSelectedItem="NO" id="CNs-lh-urM">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="N33-K0-nba">
@@ -1887,7 +1887,7 @@
</popUpButton>
<popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="QDr-Cp-9QQ">
<rect key="frame" x="0.0" y="0.0" width="120" height="103"/>
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" image="popUpButtonCell:CNs-lh-urM:image" imagePosition="only" alignment="left" lineBreakMode="truncatingTail" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" pullsDown="YES" arrowPosition="noArrow" altersStateOfSelectedItem="NO" selectedItem="28N-X8-n7Q" id="8FA-1D-k8p">
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" image="popUpButtonCell:WVW-Wo-mc9:image" imagePosition="only" alignment="left" lineBreakMode="truncatingTail" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" pullsDown="YES" arrowPosition="noArrow" altersStateOfSelectedItem="NO" selectedItem="28N-X8-n7Q" id="8FA-1D-k8p">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="8He-mk-LVI">
@@ -2184,7 +2184,6 @@
<outlet property="ledingInitEdgeLabel" destination="Eaz-eQ-aTu" id="jsG-f0-dad"/>
<outlet property="lores" destination="Gqh-qw-fjy" id="vOE-5m-Jfi"/>
<outlet property="scanLines" destination="dGn-a4-c1t" id="3Xy-Ku-95P"/>
<outlet property="sidePanel" destination="Fdf-pv-iEw" id="Cd2-Cs-GBE"/>
<outlet property="soundGapLabel" destination="yIR-MN-Hdl" id="aRe-Mw-oH1"/>
<outlet property="soundGapSlider" destination="64O-qO-cQV" id="2dt-yL-0Pq"/>
<outlet property="speedometer" destination="FBZ-dh-6Fs" id="L0v-RY-xwB"/>
@@ -138917,7 +138916,7 @@ BQB9EQcAfREJAH0RCwB9ERQAfREZAH0RHwB9EScAfREpAH0RKwB9ES0AfREvAH0imwB9IqAAfSKtAH0i
sAB9Ir0AfSLCAH0iygB9Is0AfSLSAH0i2gAAAAAAAAQBAAAAAAAAAFAAAAAAAAAAAAAAAAAAfSLdA
</mutableData>
</image>
<image name="popUpButtonCell:CNs-lh-urM:image" width="1" height="1">
<image name="popUpButtonCell:WVW-Wo-mc9:image" width="1" height="1">
<mutableData key="keyedArchiveRepresentation">
YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05T
S2V5ZWRBcmNoaXZlctEICVRyb290gAGvEBcLDBkaIRQmKisyNTo9PkNGR0pUXF1hZFUkbnVsbNYNDg8Q
+1 -1
View File
@@ -40,7 +40,7 @@ class MonitorView: NSView {
static let textDisplay_frameSize = NSSize(width: 1120 + overscan_h, height: 768 + overscan_v)
override func viewDidMoveToWindow() {
print("Added to NEW window")
// print("Added to NEW window")
}
func adjustTextDisplaySize() {
-1
View File
@@ -22,7 +22,6 @@
//
import Cocoa
import AVFoundation
class ToolBarController: NSWindowController, NSWindowDelegate {
+17 -17
View File
@@ -23,7 +23,7 @@
import Cocoa
import AVFoundation
//import AVFoundation
//import Metal
//
@@ -53,22 +53,22 @@ let colorOrange = NSColor.init( red:1, green:0.38671875, blue:0.0078125, alpha:
var monoColor = colorGreen;
var spk_up: AVAudioPlayer?
var spk_dn: AVAudioPlayer?
@_cdecl("ViewController_spk_up_play")
func spk_up_play() {
spk_up?.stop()
spk_dn?.stop()
spk_up?.play()
}
@_cdecl("ViewController_spk_dn_play")
func spk_dn_play() {
spk_up?.stop()
spk_dn?.stop()
spk_dn?.play()
}
//var spk_up: AVAudioPlayer?
//var spk_dn: AVAudioPlayer?
//
//@_cdecl("ViewController_spk_up_play")
//func spk_up_play() {
// spk_up?.stop()
// spk_dn?.stop()
// spk_up?.play()
//}
//
//@_cdecl("ViewController_spk_dn_play")
//func spk_dn_play() {
// spk_up?.stop()
// spk_dn?.stop()
// spk_dn?.play()
//}
#if METAL_YES
+3 -2
View File
@@ -405,7 +405,7 @@ void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, co
fseek(f, 0L, SEEK_SET);
if ( size && (size > flen) ) {
printf("ROM image is too small (size:0x%04X flen:0x04X)\n", size, flen);
printf("ROM image is too small (size:0x%04X flen:0x%04X)\n", size, flen);
return;
}
@@ -540,6 +540,7 @@ void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
#endif
#ifdef DEBUG_COUNTER_TEST
uint8_t counter[] = {
// 1 * COUNTER2
// 2
@@ -637,7 +638,7 @@ void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
0x60, // 2E END RTS
};
#endif
// set the default speed
clk_6502_per_frm_set = clk_6502_per_frm = FRAME(default_MHz_6502);
+34 -54
View File
@@ -255,7 +255,7 @@ static void spkr_debug(FILE * file) {
// initialize OpenAL
void spkr_init() {
const char *defname = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
printf( "Default device: %s\n", defname );
dbgPrintf2( "Default device: %s\n", defname );
// opens debug dump files for audio data -- if enabled
spkr_debug_init();
@@ -268,25 +268,25 @@ void spkr_init() {
alcMakeContextCurrent(ctx);
// Fill buffer with zeros
memset( spkr_sample_buf, 0, SPKR_SLOT_SIZE(BUFFER_COUNT + SPKR_SILENT_SLOT) ); // spkr_buf_alloc_size + spkr_extra_buf * sizeof(spkr_sample_t));
memset( spkr_sample_buf, 0, SPKR_SLOT_SIZE(BUFFER_COUNT + SPKR_SILENT_SLOT) );
// memset(spkr_samples + spkr_sample_idx * sizeof(spkr_sample_t), 0, (sample_buf_array_len - spkr_sample_idx) * sizeof(spkr_sample_t));
freeBuffers--;
// freeBuffers--;
// DEBUG ONLY!!!
spkr_debug(spkr_debug_raw_file);
spkr_debug(spkr_debug_ema_file);
alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, SPKR_SLOT_SIZE(1), spkr_sample_rate); // spkr_sample_idx * sizeof(spkr_sample_t), spkr_sample_rate);
al_check_error();
alSourceQueueBuffers(spkr_src[SPKR_SRC_GAME_SFX], 1, &spkr_buffers[freeBuffers]);
al_check_error();
// alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, SPKR_SLOT_SIZE(1), spkr_sample_rate); // spkr_sample_idx * sizeof(spkr_sample_t), spkr_sample_rate);
// al_check_error();
// alSourceQueueBuffers(spkr_src[SPKR_SRC_GAME_SFX], 1, &spkr_buffers[freeBuffers]);
// al_check_error();
// Create buffer to store samples
alGenBuffers(BUFFER_COUNT, spkr_buffers);
al_check_error();
alGenBuffers(1, &spkr_disk_motor_buf);
al_check_error();
alGenBuffers(1, &spkr_disk_arm_buf);
al_check_error();
@@ -575,13 +575,14 @@ void spkr_toggle() {
int playDelay = SPKR_PLAY_DELAY;
#ifdef SPKR_FILTER_RESET
INLINE static void spkr_filter_reset() {
spkr_level = SPKR_LEVEL_ZERO;
spkr_level_ema = SPKR_LEVEL_ZERO;
spkr_level_dema = SPKR_LEVEL_ZERO;
spkr_level_tema = SPKR_LEVEL_ZERO;
}
#endif
// Exponential Moving Average
INLINE int ema( int val, int prev, float ema_len ) {
@@ -627,6 +628,7 @@ INLINE static void spkr_filter_ema(int buf_len) {
}
#ifdef SPKR_FILTER_SMA
INLINE static void spkr_filter_sma(int buf_len) {
static const unsigned sma_len = 35;
static spkr_sample_t sma_buf [ sma_len ] = {0};
@@ -647,6 +649,7 @@ INLINE static void spkr_filter_sma(int buf_len) {
spkr_samples[i++] = spkr_level;
}
}
#endif
INLINE static void spkr_filter(int buf_len) {
@@ -654,7 +657,10 @@ INLINE static void spkr_filter(int buf_len) {
spkr_debug(spkr_debug_raw_file);
spkr_filter_ema(buf_len);
// spkr_filter_sma(buf_len);
#ifdef SPKR_FILTER_SMA
spkr_filter_sma(buf_len);
#endif
}
@@ -672,7 +678,7 @@ INLINE void spkr_debug_spike() {
void spkr_play() {
ALenum state;
alGetSourcei( spkr_src[SPKR_SRC_GAME_SFX], AL_SOURCE_STATE, &state );
// al_check_error();
// al_check_error();
switch (state) {
case AL_PLAYING:
@@ -680,13 +686,9 @@ void spkr_play() {
break;
case AL_INITIAL:
// printf("spkr_play: AL_INITIAL\n");
case AL_STOPPED:
// printf("spkr_play: AL_STOPPED\n");
case AL_PAUSED:
// printf("spkr_play: AL_PAUSED\n");
default:
// printf("spkr_play: default\n");
// no we can play this empty buffer first and then later on the real one
alSourcePlay(spkr_src[SPKR_SRC_GAME_SFX]);
break;
@@ -770,29 +772,24 @@ void spkr_play_with_pause() {
}
void spkr_buffer_with_pause(int buf_len) {
void spkr_buffer_with_prebuf(int buf_len) {
ALenum state;
alGetSourcei( spkr_src[SPKR_SRC_GAME_SFX], AL_SOURCE_STATE, &state );
// al_check_error();
// al_check_error();
switch (state) {
case AL_PAUSED:
// printf("spkr_buffer_with_pause: AL_PAUSED\n");
case AL_PLAYING:
// printf("spkr_buffer_with_pause: AL_PLAYING\n");
// it is already playing so we can just simply feed the next sound block
alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, buf_len, spkr_sample_rate);
al_check_error();
alSourceQueueBuffers(spkr_src[SPKR_SRC_GAME_SFX], 1, &spkr_buffers[freeBuffers]);
al_check_error();
break;
case AL_INITIAL:
// printf("spkr_buffer_with_pause: AL_INITIAL\n");
case AL_STOPPED:
// printf("spkr_buffer_with_pause: AL_STOPPED\n");
default:
// printf("spkr_buffer_with_pause: AL_default\n");
// start with a silent sound block so later on we will not roun out of buffer that easy
alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_sample_buf, buf_len * (1 + SPKR_SILENT_SLOT), spkr_sample_rate);
al_check_error();
@@ -801,7 +798,6 @@ void spkr_buffer_with_pause(int buf_len) {
break;
}
memset(spkr_samples, 0, buf_len);
}
@@ -817,7 +813,7 @@ void spkr_update() {
ALint queued = 0;
alGetSourcei ( spkr_src[SPKR_SRC_GAME_SFX], AL_BUFFERS_QUEUED, &queued );
al_check_error();
// printf("q:%d clkfrm:%d frm:%llu max:%llu\n", queued, clkfrm, clk_6502_per_frm, clk_6502_per_frm_max);
// printf("q:%d clkfrm:%d frm:%llu max:%llu\n", queued, clkfrm, clk_6502_per_frm, clk_6502_per_frm_max);
if ( queued < SPKR_MAX_QUEUED ) {
if ( spkr_play_time > 0) {
@@ -848,28 +844,18 @@ void spkr_update() {
spkr_debug(spkr_debug_ema_file);
#endif
spkr_buffer_with_pause(SPKR_SLOT_SIZE(1));
spkr_buffer_with_prebuf(SPKR_SLOT_SIZE(1));
}
memset(spkr_samples, 0, SPKR_SLOT_SIZE(BUFFER_COUNT) ); // sample_buf_array_len * sizeof(spkr_sample_t)); // spkr_buf_size * sizeof(spkr_sample_t) * SPKR_CHANNELS);
memset(spkr_samples, 0, SPKR_SLOT_SIZE(BUFFER_COUNT) );
spkr_sample_idx = 0;
spkr_sample_last_idx = 0;
// spkr_filter_reset();
}
else {
// push a click into the speaker buffer
// (we will play the entire buffer at the end of the frame)
// spkr_sample_idx = ( (spkr_clk + m6502.clkfrm) / ( MHZ(default_MHz_6502) / spkr_sample_rate)) * SPKR_CHANNELS;
// spkr_debug_spike();
// //spkr_samples[sample_idx] = spkr_level;
// memset(spkr_samples + spkr_sample_idx, spkr_level, spkr_buf_alloc_size * DEFAULT_FPS - spkr_sample_idx);
// spkr_play_with_prebuf();
// push a click into the speaker buffer
// spkr_debug_spike();
if (--freeBuffers < 0) {
printf("freeBuffer < 0 (%i)\n", freeBuffers);
@@ -880,27 +866,18 @@ void spkr_update() {
else {
// finish the aquare wave
spkr_finish_square(spkr_buf_size);
const int buf_len = round((double)spkr_buf_size + spkr_extra_buf) * sizeof(spkr_sample_t);
// digital filtering the audio stream -- most notably smoothing
spkr_filter(SPKR_SLOT_SIZE(1));
spkr_buffer_with_pause(SPKR_SLOT_SIZE(1));
// play slot
spkr_buffer_with_prebuf(SPKR_SLOT_SIZE(1));
}
}
spkr_play();
// spkr_play_with_pause();
// int dst = 0;
// int src = spkr_buf_size + spkr_extra_buf;
// int size = max(0, (int)spkr_sample_idx - src);
// if (size) {
// shift sample buffer
memcpy(spkr_samples, spkr_samples + SPKR_SLOT_SIZE(1), SPKR_SLOT_SIZE(1) );
// }
memset(spkr_samples + SPKR_SLOT_SIZE(1), 0, SPKR_SLOT_SIZE(1) );
spkr_sample_idx -= SPKR_SLOT_SIZE(1);
@@ -928,6 +905,9 @@ void spkr_update() {
// printf("spkr_play_time: %u, queued: %i\n", spkr_play_time, queued);
// }
}
else {
printf("spkr_update: Warning: Queued is too high: %i\n", queued);
}
spkr_clk = 0;
+3 -1
View File
@@ -283,10 +283,12 @@ static uint32_t crc32(const uint8_t *buf, size_t size) {
@param value An indicator of the bit to write. If this is zero then a 0 is written; otherwise a 1 is written.
@return The position immediately after the bit.
*/
#ifdef DISK2WOZ_WRITEBIT
static size_t write_bit(uint8_t *buffer, size_t position, int value) {
buffer[position >> 3] |= (value ? 0x80 : 0x00) >> (position & 7);
return position + 1;
}
#endif
/*!
Appends a byte to a buffer at a supplied position, returning the
@@ -409,7 +411,7 @@ static void serialise_track(uint8_t *dest, const uint8_t *src, uint8_t track_num
}
// Step through the sectors in physical order.
for(size_t sector = 0; sector < 16; ++sector) {
for(int sector = 0; sector < 16; ++sector) {
/*
Write the sector header.
*/
+1 -1
View File
@@ -541,7 +541,7 @@ int woz_parseBuffer() {
printf("WOZ Invalid CRC (%u vs %u)\n", woz_header->crc, crc);
}
else {
printf("WOZ valid CRC (%u vs %u)\n", woz_header->crc, crc);
dbgPrintf2("WOZ valid CRC (%u vs %u)\n", woz_header->crc, crc);
}
+5 -5
View File
@@ -13,14 +13,14 @@ static const uint16_t PageSize = 0x2000;
static const uint16_t Page1Addr = 0x2000;
static const uint16_t Page2Addr = 0x4000;
static const uint16_t PixelWidth = 280;
static const uint16_t PixelMixedHeight = 160;
//static const uint16_t PixelWidth = 280;
//static const uint16_t PixelMixedHeight = 160;
static const uint16_t PixelHeight = 192;
static const uint16_t MixedHeight = 160;
static const uint8_t MixedTextHeight = 4;
//static const uint8_t MixedTextHeight = 4;
static const uint8_t blockRows = 24;
static const uint8_t blockCols = 40;
static const uint8_t blockWidth = PixelWidth / blockCols;
//static const uint8_t blockWidth = PixelWidth / blockCols;
static const uint8_t blockHeight = PixelHeight / blockRows;
const uint8_t* HiResRawPointer = Apple2_64K_RAM + Page1Addr;
@@ -58,7 +58,7 @@ const uint32_t color_yellow = 0xFFBBBB11;
// default is green
const uint32_t color_mono = 0xFF2BD84A;
static const int ScreenBitmapSize = (PixelWidth * PixelHeight * 4);
//static const int ScreenBitmapSize = (PixelWidth * PixelHeight * 4);
const uint8_t color_R = 2;
const uint8_t color_G = 1;