- 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:
2024-12-04 13:56:24 +01:00
parent e0bb34052f
commit b1d04f21f7
6 changed files with 44 additions and 5 deletions

View File

@@ -172,11 +172,22 @@ int main(int argc, char *argv[])
zxscreen::redraw(); zxscreen::redraw();
} else { } else {
//if (z80::getPC()==0x05C8) zx_tape::go_berserk(); //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()) 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 // En cada bucle fem 10 pasos de la CPU, sino s'ofega
for (int i=0;i<10;++i) { for (int i=0;i<10;++i) {
uint8_t dt = z80::step(); uint8_t dt = z80::step();

View File

@@ -122,7 +122,7 @@ namespace zxscreen
reinit(); reinit();
} }
void refresh(const uint8_t dt) void refresh(const uint32_t dt)
{ {
const uint8_t* memory = z80::getMem(); const uint8_t* memory = z80::getMem();
const uint8_t border_color = zx_ula::get_border_color(); 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) void redraw(const bool present)
{ {
if (zx_tape::getplaying() && zx_tape::getberserk()) return; if (zx_tape::getplaying() && zx_tape::getberserk()) return;

View File

@@ -5,7 +5,8 @@ namespace zxscreen
{ {
void init(); void init();
void reinit(); void reinit();
void refresh(const uint8_t dt); void refresh(const uint32_t dt);
void fullrefresh();
void redraw(const bool present=true); void redraw(const bool present=true);
void present(); void present();

View File

@@ -1,5 +1,6 @@
#include "zx_tape.h" #include "zx_tape.h"
#include "zx_ula.h" #include "zx_ula.h"
#include "zx_screen.h"
#include <vector> #include <vector>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -114,6 +115,7 @@ namespace zx_tape
current_pulse = 0; current_pulse = 0;
pulse_level = 1; pulse_level = 1;
current_section = PULSE_SYNC1; current_section = PULSE_SYNC1;
printf("going to pulse_sync1...\n");
} }
} }
} }
@@ -125,6 +127,7 @@ namespace zx_tape
pulse_pos -= PULSE_LEN_SYNC1; pulse_pos -= PULSE_LEN_SYNC1;
pulse_level = 0; pulse_level = 0;
current_section = PULSE_SYNC2; current_section = PULSE_SYNC2;
printf("going to pulse_sync2...\n");
} }
} }
@@ -135,6 +138,7 @@ namespace zx_tape
pulse_pos -= PULSE_LEN_SYNC2; pulse_pos -= PULSE_LEN_SYNC2;
pulse_level = 1; pulse_level = 1;
current_section = PULSE_DATA; current_section = PULSE_DATA;
printf("going to pulse_data...\n");
} }
} }
static int level[2] = {0, 0}; static int level[2] = {0, 0};
@@ -161,6 +165,7 @@ namespace zx_tape
{ {
block_pos = 0; block_pos = 0;
current_section = PULSE_SYNC3; current_section = PULSE_SYNC3;
printf("going to pulse_sync3...\n");
} }
} }
} }
@@ -195,6 +200,7 @@ namespace zx_tape
pulse_pos -= PULSE_LEN_SYNC3; pulse_pos -= PULSE_LEN_SYNC3;
pulse_level = 0; pulse_level = 0;
current_section = PULSE_WAIT; current_section = PULSE_WAIT;
printf("going to pulse_wait...\n");
} }
} }
@@ -208,11 +214,18 @@ namespace zx_tape
current_section = PULSE_PILOT; current_section = PULSE_PILOT;
pulse_level = 1; pulse_level = 1;
current_block++; current_block++;
if (current_block>=blocks.size()) if (current_block>=blocks.size())
{ {
printf("end\n");
stop(); stop();
rewind(); 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; } void setberserk(const bool value) { berserk_mode = value; }
const bool getberserk() { return berserk_mode; } const bool getberserk() { return berserk_mode; }
const bool getplaying() { return playing; } 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);
}
} }

View File

@@ -11,4 +11,5 @@ namespace zx_tape
void setberserk(const bool value); void setberserk(const bool value);
const bool getberserk(); const bool getberserk();
const bool getplaying(); const bool getplaying();
void report();
} }

View File

@@ -283,7 +283,7 @@ namespace zx_ula
t_sound-=317; t_sound-=317;
samples_generated++; samples_generated++;
if (samples_t >=3500000) { if (samples_t >=3500000) {
printf("%i\n", samples_generated); //printf("%i\n", samples_generated);
samples_generated=0; samples_generated=0;
samples_t = 0; samples_t = 0;
} }