- fps set to 15

- First effort for the track preloading
- Disk accelerator back to 25 MHz
This commit is contained in:
Tamas Rudnai 2020-02-17 22:22:14 -08:00
parent 9b3b79cca0
commit 76ad2cfc59
7 changed files with 92 additions and 37 deletions

View File

@ -265,7 +265,7 @@ class ViewController: NSViewController {
// return // return
frameCnt += 1 frameCnt += 1
if ( frameCnt == 15 ) { if ( frameCnt == fps / 2 ) {
// flashingSpace = blockChar // flashingSpace = blockChar
ViewController.charConvTbl = ViewController.charConvTblFlashOn ViewController.charConvTbl = ViewController.charConvTblFlashOn
} }

View File

@ -101,7 +101,7 @@ extern void hires_Update(void);
extern double mips; extern double mips;
extern double mhz; extern double mhz;
#define fps 30 #define fps 15
extern void tst6502(void); extern void tst6502(void);
extern void m6502_ColdReset(void); extern void m6502_ColdReset(void);

View File

@ -68,7 +68,7 @@ INLINE void RTS() {
// disk accelerator would only work for a certain amount of time // disk accelerator would only work for a certain amount of time
// currently it is 200ms simulated times // currently it is 200ms simulated times
if ( m6502.clktime - disk.clk_since_last_read > clk_diskAcceleratorTimeout ) { if ( m6502.clktime - disk.clk_last_access > clk_diskAcceleratorTimeout ) {
clk_6502_per_frm = clk_6502_per_frm_set; clk_6502_per_frm = clk_6502_per_frm_set;
} }
} }

View File

@ -17,7 +17,7 @@ disk_t disk = {
0, // clk_since_last_read 0, // clk_since_last_read
}; };
const unsigned long long clk_6502_per_frm_diskAccelerator = 100 * M / fps; // disk acceleration bumps up CPU clock to 100 MHz const unsigned long long clk_6502_per_frm_diskAccelerator = 25 * M / fps; // disk acceleration bumps up CPU clock to 25 MHz
const unsigned long long clk_diskAcceleratorTimeout = 200000ULL; const unsigned long long clk_diskAcceleratorTimeout = 200000ULL;
@ -60,7 +60,7 @@ void disk_phase() {
// printf(", p:%d d:%d l:%d: ph:%u trk:%u)", position, direction, lastPosition, phase.count, woz_tmap.phase[phase.count]); // printf(", p:%d d:%d l:%d: ph:%u trk:%u)", position, direction, lastPosition, phase.count, woz_tmap.phase[phase.count]);
disk.clk_since_last_read = m6502.clktime; disk.clk_last_access = m6502.clktime;
clk_6502_per_frm = clk_6502_per_frm_diskAccelerator; clk_6502_per_frm = clk_6502_per_frm_diskAccelerator;
} }
@ -74,8 +74,9 @@ void disk_phase() {
uint8_t disk_read() { uint8_t disk_read() {
dbgPrintf("io_DISK_READ (S%u)\n", 6); dbgPrintf("io_DISK_READ (S%u)\n", 6);
disk.clk_since_last_read = m6502.clktime; disk.clk_last_access = m6502.clktime;
clk_6502_per_frm = clk_6502_per_frm_diskAccelerator; clk_6502_per_frm = clk_6502_per_frm_diskAccelerator;
return woz_read(); return woz_read();
} }

View File

@ -18,17 +18,21 @@
#define minDiskPhaseNum 0 #define minDiskPhaseNum 0
#define maxDiskPhaseNum (minDiskPhaseStates * maxDiskTrackNum) #define maxDiskPhaseNum (minDiskPhaseStates * maxDiskTrackNum)
typedef struct phase_s { typedef struct phase_s {
uint8_t lastMagnet : 4; uint8_t lastMagnet : 4;
uint8_t magnet : 4; uint8_t magnet : 4;
int count; int count;
} phase_t; } phase_t;
typedef struct disk_s { typedef struct disk_s {
phase_t phase; phase_t phase;
uint64_t clk_since_last_read; uint64_t clk_last_access;
uint64_t clk_last_read;
} disk_t; } disk_t;
extern disk_t disk; extern disk_t disk;

View File

@ -26,6 +26,54 @@ woz_header_t woz_header;
woz_chunk_header_t woz_chunk_header; woz_chunk_header_t woz_chunk_header;
woz_tmap_t woz_tmap; woz_tmap_t woz_tmap;
woz_trks_t woz_trks; woz_trks_t woz_trks;
int track_loaded = -1;
#pragma pack(push, 1)
typedef union trackEntry_u {
struct {
uint8_t data;
uint8_t shift;
};
uint16_t shift16;
} trackEntry_t;
#pragma pack(pop)
trackEntry_t prepared_track[WOZ_TRACK_BYTE_COUNT];
typedef enum readState_e {
readNormal = 0,
readHold,
} readState_t;
readState_t readState = readNormal;
uint8_t readLatch;
void woz_loadTrack( int track ) {
trackEntry_t reg = {0};
reg.shift = woz_trks[track].data[0];
reg.data = woz_trks[track].data[1];
prepared_track[0] = reg;
for ( int offs = 1; offs < WOZ_TRACK_BYTE_COUNT; offs++ ) {
for ( int i = 0; i < 8; i++ ) {
if (reg.shift & 0x80) {
reg.shift = 0;
}
reg.shift16 <<= 1;
}
reg.data = woz_trks[track].data[ (offs + 1) % WOZ_TRACK_BYTE_COUNT ];
prepared_track[offs] = reg;
}
}
uint8_t woz_read() { uint8_t woz_read() {
@ -36,6 +84,11 @@ uint8_t woz_read() {
dbgPrintf("TRCK TOO HIGH!\n"); dbgPrintf("TRCK TOO HIGH!\n");
return rand(); return rand();
} }
if ( track != track_loaded ) {
woz_loadTrack(track);
track_loaded = track;
}
#ifdef WOZ_REAL_SPIN #ifdef WOZ_REAL_SPIN
@ -166,39 +219,35 @@ uint8_t woz_read() {
#elif defined( WOZ_REAL_SPIN2 ) #elif defined( WOZ_REAL_SPIN2 )
clkelpased = m6502.clktime - clklast; // clkelpased = m6502.clktime - disk.clk_last_read;
clklast = m6502.clktime & ~3; // disk.clk_last_read = m6502.clktime;
bitOffset = (clkelpased >> 2) & 7; bitOffset = (m6502.clktime >> 2) & 7;
trackOffset += (clkelpased >> 5) % WOZ_TRACK_BYTE_COUNT; trackOffset = (m6502.clktime >> 5) % WOZ_TRACK_BYTE_COUNT;
WOZread.data = woz_trks[track].data[trackOffset]; trackEntry_t reg = prepared_track[trackOffset];
do {
switch (readState) {
case readNormal:
readLatch = reg.shift;
break;
case readHold:
default:
readState = readNormal;
break;
}
// to avoid infinite loop and to search for bit 7 high if (reg.shift & 0x80) {
for ( int i = 0; i < WOZ_TRACK_BYTE_COUNT * 8; i++ ) { reg.shift = 0;
if ( ++bitOffset >= 8 ) { readState = readHold;
bitOffset = 0;
// if ( ++trackOffset >= WOZ_TRACK_BYTE_COUNT ) {
// trackOffset = 0;
// }
trackOffset++;
trackOffset %= WOZ_TRACK_BYTE_COUNT;
// printf("offs:%u\n", trackOffset);
WOZread.data = woz_trks[track].data[trackOffset];
} }
WOZread.shift16 <<= 1; reg.shift16 <<= 1;
if ( WOZread.valid ) { } while ( --bitOffset > 0 );
uint8_t byte = WOZread.shift;
// printf("%02X ", byte); printf("READ: clk:%llu to:%u bo:%llu B:%02X\n", m6502.clktime, trackOffset, (m6502.clktime >> 2) & 7, readLatch);
WOZread.shift = 0; return readLatch;
if (outdev) fprintf(outdev, "byte: %02X\n", byte);
return byte;
}
}
if (outdev) fprintf(outdev, "TIME OUT!\n");
return rand();
#else // WOZ_REAL_SPIN #else // WOZ_REAL_SPIN

View File

@ -76,6 +76,7 @@ typedef woz_track_t woz_trks_t[DISKII_MAXTRACKS];
#define __NO__WOZ_REAL_SPIN2 #define __NO__WOZ_REAL_SPIN2
#ifdef WOZ_REAL_SPIN #ifdef WOZ_REAL_SPIN
typedef union { typedef union {
@ -118,7 +119,7 @@ extern uint8_t WOZlatch;
//extern woz_trks_t woz_trks; //extern woz_trks_t woz_trks;
extern uint8_t woz_read(); extern uint8_t woz_read(void);
extern void woz_loadFile( const char * filename ); extern void woz_loadFile( const char * filename );