- Codi mega ampastrat, treballant en el jittering del só, en que s'update un poc la pantalla en berserk mode, i està petant el zx_tape i no se com ho fà, pero me gonne a casa...
This commit is contained in:
15
main.cpp
15
main.cpp
@@ -172,11 +172,22 @@ int main(int argc, char *argv[])
|
||||
zxscreen::redraw();
|
||||
} else {
|
||||
//if (z80::getPC()==0x05C8) zx_tape::go_berserk();
|
||||
bool berserk=false;
|
||||
if (zx_tape::getplaying() && zx_tape::getberserk()) { berserk=true; time = SDL_GetTicks(); }
|
||||
while (zx_tape::getplaying() && zx_tape::getberserk())
|
||||
{
|
||||
zx_tape::update(z80::step());
|
||||
// zx_tape::update(z80::step());
|
||||
uint8_t dt = z80::step();
|
||||
t_states += dt;
|
||||
zx_tape::update(dt);
|
||||
if (SDL_GetTicks()-time>=1000) {
|
||||
time = SDL_GetTicks();
|
||||
zx_tape::report();
|
||||
}
|
||||
//zx_ula::sound_update(dt);
|
||||
//zxscreen::refresh(dt);
|
||||
}
|
||||
|
||||
if (berserk) { printf("%i\n", SDL_GetTicks()-time); t_states=0; }
|
||||
// En cada bucle fem 10 pasos de la CPU, sino s'ofega
|
||||
for (int i=0;i<10;++i) {
|
||||
uint8_t dt = z80::step();
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace zxscreen
|
||||
reinit();
|
||||
}
|
||||
|
||||
void refresh(const uint8_t dt)
|
||||
void refresh(const uint32_t dt)
|
||||
{
|
||||
const uint8_t* memory = z80::getMem();
|
||||
const uint8_t border_color = zx_ula::get_border_color();
|
||||
@@ -173,6 +173,12 @@ namespace zxscreen
|
||||
}
|
||||
}
|
||||
|
||||
void fullrefresh()
|
||||
{
|
||||
t_screen = 0;
|
||||
refresh(69888);
|
||||
}
|
||||
|
||||
void redraw(const bool present)
|
||||
{
|
||||
if (zx_tape::getplaying() && zx_tape::getberserk()) return;
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace zxscreen
|
||||
{
|
||||
void init();
|
||||
void reinit();
|
||||
void refresh(const uint8_t dt);
|
||||
void refresh(const uint32_t dt);
|
||||
void fullrefresh();
|
||||
void redraw(const bool present=true);
|
||||
void present();
|
||||
|
||||
|
||||
20
zx_tape.cpp
20
zx_tape.cpp
@@ -1,5 +1,6 @@
|
||||
#include "zx_tape.h"
|
||||
#include "zx_ula.h"
|
||||
#include "zx_screen.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -114,6 +115,7 @@ namespace zx_tape
|
||||
current_pulse = 0;
|
||||
pulse_level = 1;
|
||||
current_section = PULSE_SYNC1;
|
||||
printf("going to pulse_sync1...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,6 +127,7 @@ namespace zx_tape
|
||||
pulse_pos -= PULSE_LEN_SYNC1;
|
||||
pulse_level = 0;
|
||||
current_section = PULSE_SYNC2;
|
||||
printf("going to pulse_sync2...\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +138,7 @@ namespace zx_tape
|
||||
pulse_pos -= PULSE_LEN_SYNC2;
|
||||
pulse_level = 1;
|
||||
current_section = PULSE_DATA;
|
||||
printf("going to pulse_data...\n");
|
||||
}
|
||||
}
|
||||
static int level[2] = {0, 0};
|
||||
@@ -161,6 +165,7 @@ namespace zx_tape
|
||||
{
|
||||
block_pos = 0;
|
||||
current_section = PULSE_SYNC3;
|
||||
printf("going to pulse_sync3...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,6 +200,7 @@ namespace zx_tape
|
||||
pulse_pos -= PULSE_LEN_SYNC3;
|
||||
pulse_level = 0;
|
||||
current_section = PULSE_WAIT;
|
||||
printf("going to pulse_wait...\n");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,11 +214,18 @@ namespace zx_tape
|
||||
current_section = PULSE_PILOT;
|
||||
pulse_level = 1;
|
||||
current_block++;
|
||||
|
||||
if (current_block>=blocks.size())
|
||||
{
|
||||
printf("end\n");
|
||||
stop();
|
||||
rewind();
|
||||
}
|
||||
else
|
||||
{
|
||||
zxscreen::fullrefresh();
|
||||
printf("going to pulse_pilot on block %i...\n", current_block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,4 +235,11 @@ namespace zx_tape
|
||||
void setberserk(const bool value) { berserk_mode = value; }
|
||||
const bool getberserk() { return berserk_mode; }
|
||||
const bool getplaying() { return playing; }
|
||||
|
||||
void report()
|
||||
{
|
||||
if (current_block >= blocks.size()) return;
|
||||
const int percent = (float(block_pos)/float(blocks[current_block].length))*100;
|
||||
printf("tape loading: %i%\n", percent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,5 @@ namespace zx_tape
|
||||
void setberserk(const bool value);
|
||||
const bool getberserk();
|
||||
const bool getplaying();
|
||||
void report();
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace zx_ula
|
||||
t_sound-=317;
|
||||
samples_generated++;
|
||||
if (samples_t >=3500000) {
|
||||
printf("%i\n", samples_generated);
|
||||
//printf("%i\n", samples_generated);
|
||||
samples_generated=0;
|
||||
samples_t = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user