mirror of https://github.com/trudnai/Steve2.git
Compare commits
3 Commits
6083fab773
...
82100c6bc3
Author | SHA1 | Date |
---|---|---|
tudnai | 82100c6bc3 | |
tudnai | b1e7f620d1 | |
tudnai | 30917d2b56 |
|
@ -219,6 +219,8 @@ class HiRes: NSView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let usePixelTrail = true
|
||||||
|
|
||||||
// let pixelTrail = 2 // maybe too fast?
|
// let pixelTrail = 2 // maybe too fast?
|
||||||
// let pixelTrail = 1.5
|
// let pixelTrail = 1.5
|
||||||
|
@ -275,12 +277,15 @@ class HiRes: NSView {
|
||||||
if shadowScreen[ screenIdx ] != block {
|
if shadowScreen[ screenIdx ] != block {
|
||||||
blockChanged[ blockVertIdx + blockHorIdx ] = 0xFF
|
blockChanged[ blockVertIdx + blockHorIdx ] = 0xFF
|
||||||
}
|
}
|
||||||
else if ( ViewController.shared?.CRTMonitor ?? false ) {
|
else if usePixelTrail && ( ViewController.shared?.CRTMonitor ?? false ) {
|
||||||
// slow CRT fade out effect
|
// slow CRT fade out effect
|
||||||
if (y % HiRes.blockHeight == 0) && (blockChanged[ blockVertIdx + blockHorIdx ] > 0) {
|
if (y % HiRes.blockHeight == 0) && (blockChanged[ blockVertIdx + blockHorIdx ] > 0) {
|
||||||
blockChanged[ blockVertIdx + blockHorIdx ] = UInt8( Double(blockChanged[ blockVertIdx + blockHorIdx ]) / pixelTrail )
|
blockChanged[ blockVertIdx + blockHorIdx ] = UInt8( Double(blockChanged[ blockVertIdx + blockHorIdx ]) / pixelTrail )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
blockChanged[ blockVertIdx + blockHorIdx ] = 0
|
||||||
|
}
|
||||||
|
|
||||||
shadowScreen[ screenIdx ] = block
|
shadowScreen[ screenIdx ] = block
|
||||||
|
|
||||||
|
@ -296,21 +301,22 @@ class HiRes: NSView {
|
||||||
}
|
}
|
||||||
prevColor = monoColor
|
prevColor = monoColor
|
||||||
}
|
}
|
||||||
// else if ( ViewController.current?.CRTMonitor ?? false ) {
|
else if usePixelTrail && ( ViewController.shared?.CRTMonitor ?? false ) {
|
||||||
// var srgb = pixelsSRGB[pixelAddr]
|
var srgb = pixelsSRGB[pixelAddr + highBit]
|
||||||
//
|
|
||||||
// let s = srgb >> 24 & 0xFF
|
let s = srgb >> 24 & 0xFF
|
||||||
// let r = srgb >> 16 & 0xFF
|
let r = srgb >> 16 & 0xFF
|
||||||
// let g = srgb >> 8 & 0xFF
|
let g = srgb >> 8 & 0xFF
|
||||||
// let b = srgb >> 0 & 0xFF
|
let b = srgb >> 0 & 0xFF
|
||||||
//
|
|
||||||
// srgb = UInt32(Double(s) / pixelTrail) << 24
|
srgb = UInt32(Double(s) / pixelTrail) << 24
|
||||||
// | UInt32(Double(r) / pixelTrail) << 16
|
| UInt32(Double(r) / pixelTrail) << 16
|
||||||
// | UInt32(Double(g) / pixelTrail) << 8
|
| UInt32(Double(g) / pixelTrail) << 8
|
||||||
// | UInt32(Double(b) / pixelTrail)
|
| UInt32(Double(b) / pixelTrail)
|
||||||
//
|
|
||||||
// pixelsSRGB[pixelAddr] = srgb;
|
pixelsSRGB[pixelAddr + highBit] = srgb;
|
||||||
// }
|
pixelsSRGB[pixelAddr + highBit + 1] = srgb;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
pixelsSRGB[pixelAddr + highBit] = color_black
|
pixelsSRGB[pixelAddr + highBit] = color_black
|
||||||
pixelsSRGB[pixelAddr + highBit + 1] = color_black
|
pixelsSRGB[pixelAddr + highBit + 1] = color_black
|
||||||
|
@ -346,7 +352,7 @@ class HiRes: NSView {
|
||||||
|
|
||||||
case 2: // green
|
case 2: // green
|
||||||
// reducing color bleeding
|
// reducing color bleeding
|
||||||
if (colorAddr > 0) && (pixelsSRGB[colorAddr - 2] != color_black) {
|
if (colorAddr > 1) && (pixelsSRGB[colorAddr - 2] != color_black) {
|
||||||
pixelsSRGB[colorAddr] = color_green
|
pixelsSRGB[colorAddr] = color_green
|
||||||
pixelsSRGB[colorAddr + 1] = color_green
|
pixelsSRGB[colorAddr + 1] = color_green
|
||||||
}
|
}
|
||||||
|
|
|
@ -1849,6 +1849,7 @@ class ViewController: NSViewController {
|
||||||
|
|
||||||
fps = DEFAULT_FPS
|
fps = DEFAULT_FPS
|
||||||
video_fps_divider = ECO_VIDEO_DIV
|
video_fps_divider = ECO_VIDEO_DIV
|
||||||
|
spkr_fps_divider = DEF_SPKR_DIV
|
||||||
break
|
break
|
||||||
|
|
||||||
case "Game":
|
case "Game":
|
||||||
|
@ -1857,6 +1858,7 @@ class ViewController: NSViewController {
|
||||||
|
|
||||||
fps = GAME_FPS
|
fps = GAME_FPS
|
||||||
video_fps_divider = GAME_VIDEO_DIV
|
video_fps_divider = GAME_VIDEO_DIV
|
||||||
|
spkr_fps_divider = GAME_SPKR_DIV
|
||||||
break
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1865,6 +1867,7 @@ class ViewController: NSViewController {
|
||||||
|
|
||||||
fps = DEFAULT_FPS
|
fps = DEFAULT_FPS
|
||||||
video_fps_divider = DEF_VIDEO_DIV
|
video_fps_divider = DEF_VIDEO_DIV
|
||||||
|
spkr_fps_divider = DEF_SPKR_DIV
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,13 @@
|
||||||
#include "woz.h"
|
#include "woz.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef DISASSEMBLER
|
//#ifdef DISASSEMBLER
|
||||||
#define INSTR INLINE static
|
//#define INSTR INLINE static
|
||||||
#else
|
//#else
|
||||||
#define INSTR INLINE static
|
//#define INSTR INLINE static
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
#define INSTR static
|
||||||
|
|
||||||
#define CRYSTAL_MHZ 14.31818 // NTSC version (original)
|
#define CRYSTAL_MHZ 14.31818 // NTSC version (original)
|
||||||
#define DEFAULT_MHZ_6502 (CRYSTAL_MHZ / 14) // 1.023 MHz
|
#define DEFAULT_MHZ_6502 (CRYSTAL_MHZ / 14) // 1.023 MHz
|
||||||
|
@ -230,13 +232,14 @@ extern double mhz;
|
||||||
|
|
||||||
#define DEFAULT_FPS 60U
|
#define DEFAULT_FPS 60U
|
||||||
#define DEF_VIDEO_DIV 2U
|
#define DEF_VIDEO_DIV 2U
|
||||||
#define DEF_SPKR_DIV 2U
|
#define DEF_SPKR_DIV 1U
|
||||||
#define DEF_DRV_LED_DIV 4U
|
#define DEF_DRV_LED_DIV 4U
|
||||||
|
|
||||||
#define ECO_VIDEO_DIV 4U
|
#define ECO_VIDEO_DIV 4U
|
||||||
|
|
||||||
#define GAME_FPS 60U // 180U // 480U
|
#define GAME_FPS 600U // 180U // 480U
|
||||||
#define GAME_VIDEO_DIV 1U // (GAME_FPS / DEFAULT_FPS)
|
#define GAME_VIDEO_DIV 10U // (GAME_FPS / DEFAULT_FPS)
|
||||||
|
#define GAME_SPKR_DIV 10U
|
||||||
|
|
||||||
extern unsigned int video_fps_divider;
|
extern unsigned int video_fps_divider;
|
||||||
extern unsigned int fps;
|
extern unsigned int fps;
|
||||||
|
|
|
@ -125,7 +125,7 @@ float spkr_vol = 0.5;
|
||||||
|
|
||||||
|
|
||||||
unsigned spkr_fps = DEFAULT_FPS;
|
unsigned spkr_fps = DEFAULT_FPS;
|
||||||
//unsigned spkr_fps_divider = 1;
|
unsigned spkr_fps_divider = DEF_SPKR_DIV;
|
||||||
unsigned spkr_frame_cntr = 0;
|
unsigned spkr_frame_cntr = 0;
|
||||||
unsigned spkr_clk = 0;
|
unsigned spkr_clk = 0;
|
||||||
|
|
||||||
|
@ -498,14 +498,17 @@ char spkr_state = 0;
|
||||||
|
|
||||||
|
|
||||||
#define _NO_SPKR_EARLY_ZERO_LEVEL 500
|
#define _NO_SPKR_EARLY_ZERO_LEVEL 500
|
||||||
|
const float SPKR_FADE_TRAILING_SLOPE = 0.2;
|
||||||
|
|
||||||
INLINE void spkr_finish_square(const int new_idx) {
|
INLINE void spkr_finish_square(const int new_idx) {
|
||||||
|
|
||||||
|
float level = spkr_level;
|
||||||
|
const float slope = spkr_level >= 0 ? SPKR_FADE_TRAILING_SLOPE : -SPKR_FADE_TRAILING_SLOPE;
|
||||||
|
|
||||||
// avoid buffer under/over runs
|
// avoid buffer under/over runs
|
||||||
if ( (new_idx < 0) || (new_idx >= SPKR_BUF_SLOT_SIZE(BUFFER_COUNT)) ) {
|
if ( (new_idx < 0) || (new_idx >= SPKR_BUF_SLOT_SIZE(BUFFER_COUNT)) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// only fill small enough gaps and larger ones will go back to 0
|
// only fill small enough gaps and larger ones will go back to 0
|
||||||
#ifdef SPKR_EARLY_ZERO_LEVEL
|
#ifdef SPKR_EARLY_ZERO_LEVEL
|
||||||
|
@ -513,6 +516,10 @@ INLINE void spkr_finish_square(const int new_idx) {
|
||||||
#endif
|
#endif
|
||||||
// finish the aquare wave
|
// finish the aquare wave
|
||||||
while ( spkr_sample_last_idx < new_idx ) {
|
while ( spkr_sample_last_idx < new_idx ) {
|
||||||
|
if ( fabs(level) > SPKR_FADE_TRAILING_SLOPE ) {
|
||||||
|
level -= slope;
|
||||||
|
spkr_level = level;
|
||||||
|
}
|
||||||
spkr_samples[ spkr_sample_last_idx++ ] = spkr_level;
|
spkr_samples[ spkr_sample_last_idx++ ] = spkr_level;
|
||||||
spkr_samples[ spkr_sample_last_idx++ ] = spkr_level; // stereo
|
spkr_samples[ spkr_sample_last_idx++ ] = spkr_level; // stereo
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1163,7 @@ void spkr_buffer_with_prebuf(void) {
|
||||||
|
|
||||||
|
|
||||||
void spkr_update() {
|
void spkr_update() {
|
||||||
// if ( ++spkr_frame_cntr >= spkr_fps_divider ) {
|
if ( ++spkr_frame_cntr >= spkr_fps_divider ) {
|
||||||
spkr_frame_cntr = 0;
|
spkr_frame_cntr = 0;
|
||||||
|
|
||||||
// Fix: Unqueue was not working properly some cases, so we need to monitor
|
// Fix: Unqueue was not working properly some cases, so we need to monitor
|
||||||
|
@ -1248,10 +1255,10 @@ void spkr_update() {
|
||||||
|
|
||||||
spkr_clk = 0;
|
spkr_clk = 0;
|
||||||
|
|
||||||
// }
|
}
|
||||||
// else {
|
else {
|
||||||
// spkr_clk += m6502.clkfrm;
|
spkr_clk += m6502.clkfrm;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// free up unused buffers
|
// free up unused buffers
|
||||||
spkr_unqueue( spkr_src[SPKR_SRC_GAME_SFX] );
|
spkr_unqueue( spkr_src[SPKR_SRC_GAME_SFX] );
|
||||||
|
|
|
@ -85,7 +85,7 @@ extern const double spkr_sample_rate;
|
||||||
extern const unsigned spkr_buf_alloc_size;
|
extern const unsigned spkr_buf_alloc_size;
|
||||||
extern const unsigned spkr_buf_size;
|
extern const unsigned spkr_buf_size;
|
||||||
extern unsigned spkr_fps;
|
extern unsigned spkr_fps;
|
||||||
//extern unsigned spkr_fps_divider;
|
extern unsigned spkr_fps_divider;
|
||||||
extern spkr_sample_t * spkr_samples;
|
extern spkr_sample_t * spkr_samples;
|
||||||
extern int spkr_sample_idx;
|
extern int spkr_sample_idx;
|
||||||
extern int spkr_level;
|
extern int spkr_level;
|
||||||
|
|
|
@ -32,7 +32,7 @@ uint8_t* HiResBufferPointer = Apple2_64K_MEM + Page1Addr;
|
||||||
uint16_t HiResLineAddrTbl[PixelHeight];
|
uint16_t HiResLineAddrTbl[PixelHeight];
|
||||||
|
|
||||||
|
|
||||||
double pixelTrail = 15;
|
double pixelTrail = 2.0;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Reference in New Issue