VOGONS


Reply 160 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t

pics...uncorrected and unscaled.

640x200test.jpg
Filename
640x200test.jpg
File size
159.79 KiB
Views
1174 views
File license
Fair use/fair dealing exception
Monkey2.jpg
Filename
Monkey2.jpg
File size
117.39 KiB
Views
1174 views
File license
Fair use/fair dealing exception

Reply 161 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t
Benedikt wrote on 2020-07-19, 14:24:
I just had another idea, namely for a hardware-assisted solution. If we add an oscillator matching the pixel clock, an edge-trig […]
Show full quote

I just had another idea, namely for a hardware-assisted solution.
If we add an oscillator matching the pixel clock, an edge-triggered flip-flop and an xor-gate, we could invert the polarity of the sampling clock depending on whether the oscillator output is high or low during the rising edge of the hsync pulse.
This should ensure that we always sample the pixels and not the transition between pixels.
The software part would become trivial.
You'd obviously need a logic analyzer of the kind that has an external clock input or add it as a modification.

Yes, maybe its time to think about a hardware solution. Just to keep as bookmark: It seems to be possible to modify EGA clock using the feature connector without modifying the card itself:
https://books.google.de/books?id=vcqI6sY2e-kC … z%20ega&f=false
Have to read to see if its helpful.

What I will try next: The Analyzer is easy to open and you see a single crystal: 24.000 MHz for the max sample frequency. I will replace it with a socket to see how it behaves with other crystals. 16.257 MHz would be great. Dont know if this works or if it interferes with the USB-transfer. There is also an external "CLK" connector but it seems it cannot be used by Sigrok.

LA24.jpg
Filename
LA24.jpg
File size
693.84 KiB
Views
1159 views
File license
Fair use/fair dealing exception

Reply 162 of 212, by Benedikt

User metadata
Rank Oldbie
Rank
Oldbie
Predator99 wrote on 2020-07-25, 16:28:

What I will try next: The Analyzer is easy to open and you see a single crystal: 24.000 MHz for the max sample frequency. I will replace it with a socket to see how it behaves with other crystals. 16.257 MHz would be great. Dont know if this works or if it interferes with the USB-transfer. There is also an external "CLK" connector but it seems it cannot be used by Sigrok.

Be careful with that!
IIRC, USB derives its clock signal from an input clock that has to be a multiple of 12MHz.
If the 24MHz crystal provides both, the sample clock and the USB clock, there's a substantial risk that replacing the crystal will break the device.
Sigroks inability to use the custom clock signal from the CLK input looks like a firmware issue, if you ask me.

Reply 163 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t
Benedikt wrote on 2020-07-25, 17:36:
Be careful with that! IIRC, USB derives its clock signal from an input clock that has to be a multiple of 12MHz. If the 24MHz cr […]
Show full quote
Predator99 wrote on 2020-07-25, 16:28:

What I will try next: The Analyzer is easy to open and you see a single crystal: 24.000 MHz for the max sample frequency. I will replace it with a socket to see how it behaves with other crystals. 16.257 MHz would be great. Dont know if this works or if it interferes with the USB-transfer. There is also an external "CLK" connector but it seems it cannot be used by Sigrok.

Be careful with that!
IIRC, USB derives its clock signal from an input clock that has to be a multiple of 12MHz.
If the 24MHz crystal provides both, the sample clock and the USB clock, there's a substantial risk that replacing the crystal will break the device.
Sigroks inability to use the custom clock signal from the CLK input looks like a firmware issue, if you ask me.

Doesnt matter, for 6€ can afford a new one.

Tested some other crystal I had in spare: 24.576 MHz, 16.000 MHz. A USB device is detected with these, but no driver loaded...only 24.000 works. Was worth a try.

Reply 164 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t
root42 wrote on 2020-07-17, 19:56:

37s on a 2013 iMac with i5. So pretty old. I think your slowdown is due to the wrong texture format. If I create a texture in the wrong format it has to be converted before it is uploaded to the GPU. I will fix that soon.

So what does this mean? Can I speed it up by changing any setting in my Windows System?

I played with capturing at only 16 MHz and I am very happy with the results. Display at 320x200 is nearly perfect now. 640x350 is also looking very good.
If have again implemented the setting of individual rows...this code can be made quickly with excel. Its still too slow since you implemented the scaling of the window..

if (x== 175 ) {pset(surface, 0 , y, color1);}
if (x== 177 ) {pset(surface, 1 , y, color1);}
if (x== 179 ) {pset(surface, 2 , y, color1);}
if (x== 182 ) {pset(surface, 3 , y, color1);}
....
if (x== 881 ) {pset(surface, 316 , y, color1);}
if (x== 884 ) {pset(surface, 317 , y, color1);}
if (x== 886 ) {pset(surface, 318 , y, color1);}
if (x== 888 ) {pset(surface, 319 , y, color1);}

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-w64-mingw32\include\SDL2\SDL.h>
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-w64-mingw32\include

\SDL2\SDL_surface.h>


#include <io.h>
#include <fcntl.h>





#define IMG_WIDTH 320
#define IMG_HEIGHT 247

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
static const Uint32 rmask = 0xff000000;
static const Uint32 gmask = 0x00ff0000;
static const Uint32 bmask = 0x0000ff00;
static const Uint32 amask = 0x000000ff;
#else
static const Uint32 rmask = 0x00ff0000;
static const Uint32 gmask = 0x0000ff00;
static const Uint32 bmask = 0x000000ff;
static const Uint32 amask = 0xff000000;
#endif

static Uint32 egapal[64];

void
init_pal()
{
int i;
for( i = 0; i < 64; ++i ) {
Uint32 color =
( ((i & (1 << 0)) << 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & bmask)
+ (((i & (1 << 1)) >> 0) + ((i & (1 << 3)) >> 3)) * (0x55555555 & gmask)
+ (((i & (1 << 2)) >> 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & rmask)
+ amask
;
printf("%xd ", color);
egapal[i] = color;
}
}

inline
void
pset(
SDL_Surface *surface,
unsigned int x,
unsigned int y,
unsigned char color
)
{
if( x >= IMG_WIDTH || y >= IMG_HEIGHT ) {
Show last 450 lines
    return;
}

Uint32 *target_pixel = surface->pixels + y * surface->pitch +
x * sizeof( *target_pixel );
*target_pixel = egapal[color];
}

int main()
{
int x_scaled;
int new_frame = 0;
unsigned char value, color1;
int hsync = 0, vsync = 0;
int frame = 0;
unsigned int vsyncc = 0, ref_len = 0;
unsigned int x = 0, y = 0;
SDL_Window *window;

init_pal();

SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"SIGROK2EGA",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
IMG_WIDTH,
IMG_HEIGHT,
SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE
);

if (window == NULL) {
SDL_Log( "Could not create window: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Renderer *ren = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == NULL) {
SDL_DestroyWindow( window );
SDL_Log( "SDL_CreateRenderer Error: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Surface *surface =
SDL_CreateRGBSurface(
0,
IMG_WIDTH,
IMG_HEIGHT,
32,
rmask,
gmask,
bmask,
amask
);
if (surface == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, surface);
if( tex == NULL ) {
SDL_Log( "SDL_CreateTextueFromSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

while(!feof(stdin)) {
value = fgetc(stdin);
vsync = value & 128;
hsync = value & 64;
if( vsync == 0 ) {
vsyncc = 0;
new_frame = 0;
} else {
vsyncc++;
if( vsyncc > 20 ) {
vsyncc = 0;
y = 0;
// this means a new frame?
if( !new_frame ) {
new_frame = 1;
frame++;
printf("frame %u\n", frame);

SDL_UpdateTexture(tex, NULL, surface->pixels, surface->pitch);
// SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);

SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
}
}
}
color1 = value & 0x3F;
//fast perfekt int x_scaled = round(319.5/714.5*(x-126));
//int x_scaled = round(319.5/714.5*(x-126));
//if (x==174) {int x_scaled = 300;}
// int x_scaled=x ;
//int y_scaled = y - 13;

if (x>174) {
if (x<888) {
if (x== 175 ) {pset(surface, 0 , y, color1);}
if (x== 177 ) {pset(surface, 1 , y, color1);}
if (x== 179 ) {pset(surface, 2 , y, color1);}
if (x== 182 ) {pset(surface, 3 , y, color1);}
if (x== 184 ) {pset(surface, 4 , y, color1);}
if (x== 186 ) {pset(surface, 5 , y, color1);}
if (x== 188 ) {pset(surface, 6 , y, color1);}
if (x== 191 ) {pset(surface, 7 , y, color1);}
if (x== 193 ) {pset(surface, 8 , y, color1);}
if (x== 195 ) {pset(surface, 9 , y, color1);}
if (x== 197 ) {pset(surface, 10 , y, color1);}
if (x== 200 ) {pset(surface, 11 , y, color1);}
if (x== 202 ) {pset(surface, 12 , y, color1);}
if (x== 204 ) {pset(surface, 13 , y, color1);}
if (x== 206 ) {pset(surface, 14 , y, color1);}
if (x== 209 ) {pset(surface, 15 , y, color1);}
if (x== 211 ) {pset(surface, 16 , y, color1);}
if (x== 213 ) {pset(surface, 17 , y, color1);}
if (x== 215 ) {pset(surface, 18 , y, color1);}
if (x== 217 ) {pset(surface, 19 , y, color1);}
if (x== 220 ) {pset(surface, 20 , y, color1);}
if (x== 222 ) {pset(surface, 21 , y, color1);}
if (x== 224 ) {pset(surface, 22 , y, color1);}
if (x== 226 ) {pset(surface, 23 , y, color1);}
if (x== 229 ) {pset(surface, 24 , y, color1);}
if (x== 231 ) {pset(surface, 25 , y, color1);}
if (x== 233 ) {pset(surface, 26 , y, color1);}
if (x== 235 ) {pset(surface, 27 , y, color1);}
if (x== 238 ) {pset(surface, 28 , y, color1);}
if (x== 240 ) {pset(surface, 29 , y, color1);}
if (x== 242 ) {pset(surface, 30 , y, color1);}
if (x== 244 ) {pset(surface, 31 , y, color1);}
if (x== 247 ) {pset(surface, 32 , y, color1);}
if (x== 249 ) {pset(surface, 33 , y, color1);}
if (x== 251 ) {pset(surface, 34 , y, color1);}
if (x== 253 ) {pset(surface, 35 , y, color1);}
if (x== 255 ) {pset(surface, 36 , y, color1);}
if (x== 258 ) {pset(surface, 37 , y, color1);}
if (x== 260 ) {pset(surface, 38 , y, color1);}
if (x== 262 ) {pset(surface, 39 , y, color1);}
if (x== 264 ) {pset(surface, 40 , y, color1);}
if (x== 267 ) {pset(surface, 41 , y, color1);}
if (x== 269 ) {pset(surface, 42 , y, color1);}
if (x== 271 ) {pset(surface, 43 , y, color1);}
if (x== 273 ) {pset(surface, 44 , y, color1);}
if (x== 276 ) {pset(surface, 45 , y, color1);}
if (x== 278 ) {pset(surface, 46 , y, color1);}
if (x== 280 ) {pset(surface, 47 , y, color1);}
if (x== 282 ) {pset(surface, 48 , y, color1);}
if (x== 285 ) {pset(surface, 49 , y, color1);}
if (x== 287 ) {pset(surface, 50 , y, color1);}
if (x== 289 ) {pset(surface, 51 , y, color1);}
if (x== 291 ) {pset(surface, 52 , y, color1);}
if (x== 293 ) {pset(surface, 53 , y, color1);}
if (x== 296 ) {pset(surface, 54 , y, color1);}
if (x== 298 ) {pset(surface, 55 , y, color1);}
if (x== 300 ) {pset(surface, 56 , y, color1);}
if (x== 302 ) {pset(surface, 57 , y, color1);}
if (x== 305 ) {pset(surface, 58 , y, color1);}
if (x== 307 ) {pset(surface, 59 , y, color1);}
if (x== 309 ) {pset(surface, 60 , y, color1);}
if (x== 311 ) {pset(surface, 61 , y, color1);}
if (x== 314 ) {pset(surface, 62 , y, color1);}
if (x== 316 ) {pset(surface, 63 , y, color1);}
if (x== 318 ) {pset(surface, 64 , y, color1);}
if (x== 320 ) {pset(surface, 65 , y, color1);}
if (x== 323 ) {pset(surface, 66 , y, color1);}
if (x== 325 ) {pset(surface, 67 , y, color1);}
if (x== 327 ) {pset(surface, 68 , y, color1);}
if (x== 329 ) {pset(surface, 69 , y, color1);}
if (x== 331 ) {pset(surface, 70 , y, color1);}
if (x== 334 ) {pset(surface, 71 , y, color1);}
if (x== 336 ) {pset(surface, 72 , y, color1);}
if (x== 338 ) {pset(surface, 73 , y, color1);}
if (x== 340 ) {pset(surface, 74 , y, color1);}
if (x== 343 ) {pset(surface, 75 , y, color1);}
if (x== 345 ) {pset(surface, 76 , y, color1);}
if (x== 347 ) {pset(surface, 77 , y, color1);}
if (x== 349 ) {pset(surface, 78 , y, color1);}
if (x== 352 ) {pset(surface, 79 , y, color1);}
if (x== 354 ) {pset(surface, 80 , y, color1);}
if (x== 356 ) {pset(surface, 81 , y, color1);}
if (x== 358 ) {pset(surface, 82 , y, color1);}
if (x== 361 ) {pset(surface, 83 , y, color1);}
if (x== 363 ) {pset(surface, 84 , y, color1);}
if (x== 365 ) {pset(surface, 85 , y, color1);}
if (x== 367 ) {pset(surface, 86 , y, color1);}
if (x== 369 ) {pset(surface, 87 , y, color1);}
if (x== 372 ) {pset(surface, 88 , y, color1);}
if (x== 374 ) {pset(surface, 89 , y, color1);}
if (x== 376 ) {pset(surface, 90 , y, color1);}
if (x== 378 ) {pset(surface, 91 , y, color1);}
if (x== 381 ) {pset(surface, 92 , y, color1);}
if (x== 383 ) {pset(surface, 93 , y, color1);}
if (x== 385 ) {pset(surface, 94 , y, color1);}
if (x== 387 ) {pset(surface, 95 , y, color1);}
if (x== 390 ) {pset(surface, 96 , y, color1);}
if (x== 392 ) {pset(surface, 97 , y, color1);}
if (x== 394 ) {pset(surface, 98 , y, color1);}
if (x== 396 ) {pset(surface, 99 , y, color1);}
if (x== 399 ) {pset(surface, 100 , y, color1);}
if (x== 401 ) {pset(surface, 101 , y, color1);}
if (x== 403 ) {pset(surface, 102 , y, color1);}
if (x== 405 ) {pset(surface, 103 , y, color1);}
if (x== 407 ) {pset(surface, 104 , y, color1);}
if (x== 410 ) {pset(surface, 105 , y, color1);}
if (x== 412 ) {pset(surface, 106 , y, color1);}
if (x== 414 ) {pset(surface, 107 , y, color1);}
if (x== 416 ) {pset(surface, 108 , y, color1);}
if (x== 419 ) {pset(surface, 109 , y, color1);}
if (x== 421 ) {pset(surface, 110 , y, color1);}
if (x== 423 ) {pset(surface, 111 , y, color1);}
if (x== 425 ) {pset(surface, 112 , y, color1);}
if (x== 428 ) {pset(surface, 113 , y, color1);}
if (x== 430 ) {pset(surface, 114 , y, color1);}
if (x== 432 ) {pset(surface, 115 , y, color1);}
if (x== 434 ) {pset(surface, 116 , y, color1);}
if (x== 437 ) {pset(surface, 117 , y, color1);}
if (x== 439 ) {pset(surface, 118 , y, color1);}
if (x== 441 ) {pset(surface, 119 , y, color1);}
if (x== 443 ) {pset(surface, 120 , y, color1);}
if (x== 445 ) {pset(surface, 121 , y, color1);}
if (x== 448 ) {pset(surface, 122 , y, color1);}
if (x== 450 ) {pset(surface, 123 , y, color1);}
if (x== 452 ) {pset(surface, 124 , y, color1);}
if (x== 454 ) {pset(surface, 125 , y, color1);}
if (x== 457 ) {pset(surface, 126 , y, color1);}
if (x== 459 ) {pset(surface, 127 , y, color1);}
if (x== 461 ) {pset(surface, 128 , y, color1);}
if (x== 463 ) {pset(surface, 129 , y, color1);}
if (x== 466 ) {pset(surface, 130 , y, color1);}
if (x== 468 ) {pset(surface, 131 , y, color1);}
if (x== 470 ) {pset(surface, 132 , y, color1);}
if (x== 472 ) {pset(surface, 133 , y, color1);}
if (x== 475 ) {pset(surface, 134 , y, color1);}
if (x== 477 ) {pset(surface, 135 , y, color1);}
if (x== 479 ) {pset(surface, 136 , y, color1);}
if (x== 481 ) {pset(surface, 137 , y, color1);}
if (x== 483 ) {pset(surface, 138 , y, color1);}
if (x== 486 ) {pset(surface, 139 , y, color1);}
if (x== 488 ) {pset(surface, 140 , y, color1);}
if (x== 490 ) {pset(surface, 141 , y, color1);}
if (x== 492 ) {pset(surface, 142 , y, color1);}
if (x== 495 ) {pset(surface, 143 , y, color1);}
if (x== 497 ) {pset(surface, 144 , y, color1);}
if (x== 499 ) {pset(surface, 145 , y, color1);}
if (x== 501 ) {pset(surface, 146 , y, color1);}
if (x== 504 ) {pset(surface, 147 , y, color1);}
if (x== 506 ) {pset(surface, 148 , y, color1);}
if (x== 508 ) {pset(surface, 149 , y, color1);}
if (x== 510 ) {pset(surface, 150 , y, color1);}
if (x== 513 ) {pset(surface, 151 , y, color1);}
if (x== 515 ) {pset(surface, 152 , y, color1);}
if (x== 517 ) {pset(surface, 153 , y, color1);}
if (x== 519 ) {pset(surface, 154 , y, color1);}
if (x== 521 ) {pset(surface, 155 , y, color1);}
if (x== 524 ) {pset(surface, 156 , y, color1);}
if (x== 526 ) {pset(surface, 157 , y, color1);}
if (x== 528 ) {pset(surface, 158 , y, color1);}
if (x== 530 ) {pset(surface, 159 , y, color1);}
if (x== 533 ) {pset(surface, 160 , y, color1);}
if (x== 535 ) {pset(surface, 161 , y, color1);}
if (x== 537 ) {pset(surface, 162 , y, color1);}
if (x== 539 ) {pset(surface, 163 , y, color1);}
if (x== 542 ) {pset(surface, 164 , y, color1);}
if (x== 544 ) {pset(surface, 165 , y, color1);}
if (x== 546 ) {pset(surface, 166 , y, color1);}
if (x== 548 ) {pset(surface, 167 , y, color1);}
if (x== 551 ) {pset(surface, 168 , y, color1);}
if (x== 553 ) {pset(surface, 169 , y, color1);}
if (x== 555 ) {pset(surface, 170 , y, color1);}
if (x== 557 ) {pset(surface, 171 , y, color1);}
if (x== 559 ) {pset(surface, 172 , y, color1);}
if (x== 562 ) {pset(surface, 173 , y, color1);}
if (x== 564 ) {pset(surface, 174 , y, color1);}
if (x== 566 ) {pset(surface, 175 , y, color1);}
if (x== 568 ) {pset(surface, 176 , y, color1);}
if (x== 571 ) {pset(surface, 177 , y, color1);}
if (x== 573 ) {pset(surface, 178 , y, color1);}
if (x== 575 ) {pset(surface, 179 , y, color1);}
if (x== 577 ) {pset(surface, 180 , y, color1);}
if (x== 580 ) {pset(surface, 181 , y, color1);}
if (x== 582 ) {pset(surface, 182 , y, color1);}
if (x== 584 ) {pset(surface, 183 , y, color1);}
if (x== 586 ) {pset(surface, 184 , y, color1);}
if (x== 589 ) {pset(surface, 185 , y, color1);}
if (x== 591 ) {pset(surface, 186 , y, color1);}
if (x== 593 ) {pset(surface, 187 , y, color1);}
if (x== 595 ) {pset(surface, 188 , y, color1);}
if (x== 597 ) {pset(surface, 189 , y, color1);}
if (x== 600 ) {pset(surface, 190 , y, color1);}
if (x== 602 ) {pset(surface, 191 , y, color1);}
if (x== 604 ) {pset(surface, 192 , y, color1);}
if (x== 606 ) {pset(surface, 193 , y, color1);}
if (x== 609 ) {pset(surface, 194 , y, color1);}
if (x== 611 ) {pset(surface, 195 , y, color1);}
if (x== 613 ) {pset(surface, 196 , y, color1);}
if (x== 615 ) {pset(surface, 197 , y, color1);}
if (x== 618 ) {pset(surface, 198 , y, color1);}
if (x== 620 ) {pset(surface, 199 , y, color1);}
if (x== 622 ) {pset(surface, 200 , y, color1);}
if (x== 624 ) {pset(surface, 201 , y, color1);}
if (x== 627 ) {pset(surface, 202 , y, color1);}
if (x== 629 ) {pset(surface, 203 , y, color1);}
if (x== 631 ) {pset(surface, 204 , y, color1);}
if (x== 633 ) {pset(surface, 205 , y, color1);}
if (x== 635 ) {pset(surface, 206 , y, color1);}
if (x== 638 ) {pset(surface, 207 , y, color1);}
if (x== 640 ) {pset(surface, 208 , y, color1);}
if (x== 642 ) {pset(surface, 209 , y, color1);}
if (x== 644 ) {pset(surface, 210 , y, color1);}
if (x== 647 ) {pset(surface, 211 , y, color1);}
if (x== 649 ) {pset(surface, 212 , y, color1);}
if (x== 651 ) {pset(surface, 213 , y, color1);}
if (x== 653 ) {pset(surface, 214 , y, color1);}
if (x== 656 ) {pset(surface, 215 , y, color1);}
if (x== 658 ) {pset(surface, 216 , y, color1);}
if (x== 660 ) {pset(surface, 217 , y, color1);}
if (x== 663 ) {pset(surface, 218 , y, color1);}
if (x== 665 ) {pset(surface, 219 , y, color1);}
if (x== 667 ) {pset(surface, 220 , y, color1);}
if (x== 669 ) {pset(surface, 221 , y, color1);}
if (x== 671 ) {pset(surface, 222 , y, color1);}
if (x== 673 ) {pset(surface, 223 , y, color1);}
if (x== 676 ) {pset(surface, 224 , y, color1);}
if (x== 678 ) {pset(surface, 225 , y, color1);}
if (x== 680 ) {pset(surface, 226 , y, color1);}
if (x== 682 ) {pset(surface, 227 , y, color1);}
if (x== 685 ) {pset(surface, 228 , y, color1);}
if (x== 687 ) {pset(surface, 229 , y, color1);}
if (x== 689 ) {pset(surface, 230 , y, color1);}
if (x== 691 ) {pset(surface, 231 , y, color1);}
if (x== 694 ) {pset(surface, 232 , y, color1);}
if (x== 696 ) {pset(surface, 233 , y, color1);}
if (x== 698 ) {pset(surface, 234 , y, color1);}
if (x== 700 ) {pset(surface, 235 , y, color1);}
if (x== 703 ) {pset(surface, 236 , y, color1);}
if (x== 705 ) {pset(surface, 237 , y, color1);}
if (x== 707 ) {pset(surface, 238 , y, color1);}
if (x== 709 ) {pset(surface, 239 , y, color1);}
if (x== 711 ) {pset(surface, 240 , y, color1);}
if (x== 714 ) {pset(surface, 241 , y, color1);}
if (x== 716 ) {pset(surface, 242 , y, color1);}
if (x== 718 ) {pset(surface, 243 , y, color1);}
if (x== 720 ) {pset(surface, 244 , y, color1);}
if (x== 723 ) {pset(surface, 245 , y, color1);}
if (x== 725 ) {pset(surface, 246 , y, color1);}
if (x== 727 ) {pset(surface, 247 , y, color1);}
if (x== 729 ) {pset(surface, 248 , y, color1);}
if (x== 732 ) {pset(surface, 249 , y, color1);}
if (x== 734 ) {pset(surface, 250 , y, color1);}
if (x== 736 ) {pset(surface, 251 , y, color1);}
if (x== 738 ) {pset(surface, 252 , y, color1);}
if (x== 741 ) {pset(surface, 253 , y, color1);}
if (x== 743 ) {pset(surface, 254 , y, color1);}
if (x== 745 ) {pset(surface, 255 , y, color1);}
if (x== 747 ) {pset(surface, 256 , y, color1);}
if (x== 749 ) {pset(surface, 257 , y, color1);}
if (x== 752 ) {pset(surface, 258 , y, color1);}
if (x== 754 ) {pset(surface, 259 , y, color1);}
if (x== 756 ) {pset(surface, 260 , y, color1);}
if (x== 758 ) {pset(surface, 261 , y, color1);}
if (x== 761 ) {pset(surface, 262 , y, color1);}
if (x== 763 ) {pset(surface, 263 , y, color1);}
if (x== 765 ) {pset(surface, 264 , y, color1);}
if (x== 767 ) {pset(surface, 265 , y, color1);}
if (x== 770 ) {pset(surface, 266 , y, color1);}
if (x== 772 ) {pset(surface, 267 , y, color1);}
if (x== 774 ) {pset(surface, 268 , y, color1);}
if (x== 776 ) {pset(surface, 269 , y, color1);}
if (x== 778 ) {pset(surface, 270 , y, color1);}
if (x== 781 ) {pset(surface, 271 , y, color1);}
if (x== 783 ) {pset(surface, 272 , y, color1);}
if (x== 785 ) {pset(surface, 273 , y, color1);}
if (x== 787 ) {pset(surface, 274 , y, color1);}
if (x== 790 ) {pset(surface, 275 , y, color1);}
if (x== 792 ) {pset(surface, 276 , y, color1);}
if (x== 794 ) {pset(surface, 277 , y, color1);}
if (x== 796 ) {pset(surface, 278 , y, color1);}
if (x== 799 ) {pset(surface, 279 , y, color1);}
if (x== 801 ) {pset(surface, 280 , y, color1);}
if (x== 803 ) {pset(surface, 281 , y, color1);}
if (x== 805 ) {pset(surface, 282 , y, color1);}
if (x== 808 ) {pset(surface, 283 , y, color1);}
if (x== 810 ) {pset(surface, 284 , y, color1);}
if (x== 812 ) {pset(surface, 285 , y, color1);}
if (x== 814 ) {pset(surface, 286 , y, color1);}
if (x== 817 ) {pset(surface, 287 , y, color1);}
if (x== 819 ) {pset(surface, 288 , y, color1);}
if (x== 821 ) {pset(surface, 289 , y, color1);}
if (x== 823 ) {pset(surface, 290 , y, color1);}
if (x== 825 ) {pset(surface, 291 , y, color1);}
if (x== 828 ) {pset(surface, 292 , y, color1);}
if (x== 830 ) {pset(surface, 293 , y, color1);}
if (x== 832 ) {pset(surface, 294 , y, color1);}
if (x== 834 ) {pset(surface, 295 , y, color1);}
if (x== 837 ) {pset(surface, 296 , y, color1);}
if (x== 839 ) {pset(surface, 297 , y, color1);}
if (x== 841 ) {pset(surface, 298 , y, color1);}
if (x== 843 ) {pset(surface, 299 , y, color1);}
if (x== 846 ) {pset(surface, 300 , y, color1);}
if (x== 848 ) {pset(surface, 301 , y, color1);}
if (x== 850 ) {pset(surface, 302 , y, color1);}
if (x== 852 ) {pset(surface, 303 , y, color1);}
if (x== 854 ) {pset(surface, 304 , y, color1);}
if (x== 857 ) {pset(surface, 305 , y, color1);}
if (x== 859 ) {pset(surface, 306 , y, color1);}
if (x== 861 ) {pset(surface, 307 , y, color1);}
if (x== 863 ) {pset(surface, 308 , y, color1);}
if (x== 866 ) {pset(surface, 309 , y, color1);}
if (x== 868 ) {pset(surface, 310 , y, color1);}
if (x== 870 ) {pset(surface, 311 , y, color1);}
if (x== 872 ) {pset(surface, 312 , y, color1);}
if (x== 875 ) {pset(surface, 313 , y, color1);}
if (x== 877 ) {pset(surface, 314 , y, color1);}
if (x== 879 ) {pset(surface, 315 , y, color1);}
if (x== 881 ) {pset(surface, 316 , y, color1);}
if (x== 884 ) {pset(surface, 317 , y, color1);}
if (x== 886 ) {pset(surface, 318 , y, color1);}
if (x== 888 ) {pset(surface, 319 , y, color1);}
}}

x++;
if( hsync ) {
ref_len++;
if( ref_len > 30 && x > 700 ) {
// pset(surface, x_scaled, y, 5);
y++;
x = 0;
}
} else {
ref_len = 0;
}
}

SDL_DestroyWindow( window );
SDL_Quit();

return 0;
}

Attachments

Reply 165 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t

Made some further optimizations ... 320x200 now running in real-time. Almost no display errors, playing action games is no problem! Gods patch also included.

I am very happy with the project now 😀 😀 😀

Only thing missing is a autodetection of 320 and 640 modes. At the moment I have to switch between two programs...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-

w64-mingw32\include\SDL2\SDL.h>
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-

w64-mingw32\include\SDL2\SDL_surface.h>


#include <io.h>
#include <fcntl.h>





#define IMG_WIDTH 320
#define IMG_HEIGHT 200

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
static const Uint32 rmask = 0xff000000;
static const Uint32 gmask = 0x00ff0000;
static const Uint32 bmask = 0x0000ff00;
static const Uint32 amask = 0x000000ff;
#else
static const Uint32 rmask = 0x00ff0000;
static const Uint32 gmask = 0x0000ff00;
static const Uint32 bmask = 0x000000ff;
static const Uint32 amask = 0xff000000;
#endif

static Uint32 egapal[64];

void
init_pal()
{
int i;
for( i = 0; i < 64; ++i ) {
Uint32 color =
( ((i & (1 << 0)) << 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & bmask)
+ (((i & (1 << 1)) >> 0) + ((i & (1 << 3)) >> 3)) * (0x55555555 & gmask)
+ (((i & (1 << 2)) >> 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & rmask)
+ amask
;
printf("%xd ", color);
egapal[i] = color;
}
}

inline
void
pset(
SDL_Surface *surface,
unsigned int x,
unsigned int y,
unsigned char color
)
Show last 515 lines
{
if( x >= IMG_WIDTH || y >= IMG_HEIGHT ) {
return;
}

Uint32 *target_pixel = surface->pixels + y * surface->pitch +
x * sizeof( *target_pixel );
*target_pixel = egapal[color];
}

int main()
{
_setmode (_fileno( stdin ), _O_BINARY );

int x_scaled;
int new_frame = 0;
unsigned char value, color1;
int hsync = 0, vsync = 0;
int frame = 0;
unsigned int vsyncc = 0, ref_len = 0;
unsigned int x = 0, y = 0;
SDL_Window *window;

init_pal();

SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"SIGROK2EGA",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
IMG_WIDTH,
IMG_HEIGHT,
SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE
);

if (window == NULL) {
SDL_Log( "Could not create window: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Renderer *ren = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == NULL) {
SDL_DestroyWindow( window );
SDL_Log( "SDL_CreateRenderer Error: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Surface *surface =
SDL_CreateRGBSurface(
0,
IMG_WIDTH,
IMG_HEIGHT,
32,
rmask,
gmask,
bmask,
amask
);
if (surface == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, surface);
if( tex == NULL ) {
SDL_Log( "SDL_CreateTextueFromSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

while(!feof(stdin)) {
value = fgetc(stdin);
vsync = value & 128;
hsync = value & 64;
if( vsync == 0 ) {
vsyncc = 0;
new_frame = 0;
} else {
vsyncc++;
if( vsyncc > 20 ) {
vsyncc = 0;
y = 0;
// this means a new frame?
if( !new_frame ) {
new_frame = 1;
frame++;
printf("frame %u\n", frame);

SDL_UpdateTexture(tex, NULL, surface->pixels, surface->pitch);
// SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);

SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
}
}
}
color1 = value & 0x3F;
//fast perfekt int x_scaled = round(319.5/714.5*(x-126));
//int x_scaled = round(319.5/714.5*(x-126));
//if (x==174) {int x_scaled = 300;}
// int x_scaled=x ;
int y_scaled = y - 34;

//if (y>32){
//if (y<235){

if (x>174) {
if (x<600) {

if (x>174) {
if (x<400) {

if (x>174) {
if (x<220) {
if (x== 175 ) {pset(surface, 0 , y_scaled, color1);}
if (x== 177 ) {pset(surface, 1 , y_scaled, color1);}
if (x== 179 ) {pset(surface, 2 , y_scaled, color1);}
if (x== 182 ) {pset(surface, 3 , y_scaled, color1);}
if (x== 184 ) {pset(surface, 4 , y_scaled, color1);}
if (x== 186 ) {pset(surface, 5 , y_scaled, color1);}
if (x== 188 ) {pset(surface, 6 , y_scaled, color1);}
if (x== 191 ) {pset(surface, 7 , y_scaled, color1);}
if (x== 193 ) {pset(surface, 8 , y_scaled, color1);}
if (x== 195 ) {pset(surface, 9 , y_scaled, color1);}
if (x== 197 ) {pset(surface, 10 , y_scaled, color1);}
if (x== 200 ) {pset(surface, 11 , y_scaled, color1);}
if (x== 202 ) {pset(surface, 12 , y_scaled, color1);}
if (x== 204 ) {pset(surface, 13 , y_scaled, color1);}
if (x== 206 ) {pset(surface, 14 , y_scaled, color1);}
if (x== 209 ) {pset(surface, 15 , y_scaled, color1);}
if (x== 211 ) {pset(surface, 16 , y_scaled, color1);}
if (x== 213 ) {pset(surface, 17 , y_scaled, color1);}
if (x== 215 ) {pset(surface, 18 , y_scaled, color1);}
if (x== 217 ) {pset(surface, 19 , y_scaled, color1);}
}}
if (x>217) {
if (x<261) {
if (x== 220 ) {pset(surface, 20 , y_scaled, color1);}
if (x== 222 ) {pset(surface, 21 , y_scaled, color1);}
if (x== 224 ) {pset(surface, 22 , y_scaled, color1);}
if (x== 226 ) {pset(surface, 23 , y_scaled, color1);}
if (x== 229 ) {pset(surface, 24 , y_scaled, color1);}
if (x== 231 ) {pset(surface, 25 , y_scaled, color1);}
if (x== 233 ) {pset(surface, 26 , y_scaled, color1);}
if (x== 235 ) {pset(surface, 27 , y_scaled, color1);}
if (x== 238 ) {pset(surface, 28 , y_scaled, color1);}
if (x== 240 ) {pset(surface, 29 , y_scaled, color1);}
if (x== 242 ) {pset(surface, 30 , y_scaled, color1);}
if (x== 244 ) {pset(surface, 31 , y_scaled, color1);}
if (x== 247 ) {pset(surface, 32 , y_scaled, color1);}
if (x== 249 ) {pset(surface, 33 , y_scaled, color1);}
if (x== 251 ) {pset(surface, 34 , y_scaled, color1);}
if (x== 253 ) {pset(surface, 35 , y_scaled, color1);}
if (x== 255 ) {pset(surface, 36 , y_scaled, color1);}
if (x== 258 ) {pset(surface, 37 , y_scaled, color1);}
if (x== 260 ) {pset(surface, 38 , y_scaled, color1);}
}}
if (x>260) {
if (x<310) {
if (x== 262 ) {pset(surface, 39 , y_scaled, color1);}
if (x== 264 ) {pset(surface, 40 , y_scaled, color1);}
if (x== 267 ) {pset(surface, 41 , y_scaled, color1);}
if (x== 269 ) {pset(surface, 42 , y_scaled, color1);}
if (x== 271 ) {pset(surface, 43 , y_scaled, color1);}
if (x== 273 ) {pset(surface, 44 , y_scaled, color1);}
if (x== 276 ) {pset(surface, 45 , y_scaled, color1);}
if (x== 278 ) {pset(surface, 46 , y_scaled, color1);}
if (x== 280 ) {pset(surface, 47 , y_scaled, color1);}
if (x== 282 ) {pset(surface, 48 , y_scaled, color1);}
if (x== 285 ) {pset(surface, 49 , y_scaled, color1);}
if (x== 287 ) {pset(surface, 50 , y_scaled, color1);}
if (x== 289 ) {pset(surface, 51 , y_scaled, color1);}
if (x== 291 ) {pset(surface, 52 , y_scaled, color1);}
if (x== 293 ) {pset(surface, 53 , y_scaled, color1);}
if (x== 296 ) {pset(surface, 54 , y_scaled, color1);}
if (x== 298 ) {pset(surface, 55 , y_scaled, color1);}
if (x== 300 ) {pset(surface, 56 , y_scaled, color1);}
if (x== 302 ) {pset(surface, 57 , y_scaled, color1);}
if (x== 305 ) {pset(surface, 58 , y_scaled, color1);}
if (x== 307 ) {pset(surface, 59 , y_scaled, color1);}
if (x== 309 ) {pset(surface, 60 , y_scaled, color1);}
}}
if (x>310) {
if (x<360) {
if (x== 311 ) {pset(surface, 61 , y_scaled, color1);}
if (x== 314 ) {pset(surface, 62 , y_scaled, color1);}
if (x== 316 ) {pset(surface, 63 , y_scaled, color1);}
if (x== 318 ) {pset(surface, 64 , y_scaled, color1);}
if (x== 320 ) {pset(surface, 65 , y_scaled, color1);}
if (x== 323 ) {pset(surface, 66 , y_scaled, color1);}
if (x== 325 ) {pset(surface, 67 , y_scaled, color1);}
if (x== 327 ) {pset(surface, 68 , y_scaled, color1);}
if (x== 329 ) {pset(surface, 69 , y_scaled, color1);}
if (x== 331 ) {pset(surface, 70 , y_scaled, color1);}
if (x== 334 ) {pset(surface, 71 , y_scaled, color1);}
if (x== 336 ) {pset(surface, 72 , y_scaled, color1);}
if (x== 338 ) {pset(surface, 73 , y_scaled, color1);}
if (x== 340 ) {pset(surface, 74 , y_scaled, color1);}
if (x== 343 ) {pset(surface, 75 , y_scaled, color1);}
if (x== 345 ) {pset(surface, 76 , y_scaled, color1);}
if (x== 347 ) {pset(surface, 77 , y_scaled, color1);}
if (x== 349 ) {pset(surface, 78 , y_scaled, color1);}
if (x== 352 ) {pset(surface, 79 , y_scaled, color1);}
if (x== 354 ) {pset(surface, 80 , y_scaled, color1);}
if (x== 356 ) {pset(surface, 81 , y_scaled, color1);}
if (x== 358 ) {pset(surface, 82 , y_scaled, color1);}
}}
if (x>358) {
if (x<400) {
if (x== 361 ) {pset(surface, 83 , y_scaled, color1);}
if (x== 363 ) {pset(surface, 84 , y_scaled, color1);}
if (x== 365 ) {pset(surface, 85 , y_scaled, color1);}
if (x== 367 ) {pset(surface, 86 , y_scaled, color1);}
if (x== 369 ) {pset(surface, 87 , y_scaled, color1);}
if (x== 372 ) {pset(surface, 88 , y_scaled, color1);}
if (x== 374 ) {pset(surface, 89 , y_scaled, color1);}
if (x== 376 ) {pset(surface, 90 , y_scaled, color1);}
if (x== 378 ) {pset(surface, 91 , y_scaled, color1);}
if (x== 381 ) {pset(surface, 92 , y_scaled, color1);}
if (x== 383 ) {pset(surface, 93 , y_scaled, color1);}
if (x== 385 ) {pset(surface, 94 , y_scaled, color1);}
if (x== 387 ) {pset(surface, 95 , y_scaled, color1);}
if (x== 390 ) {pset(surface, 96 , y_scaled, color1);}
if (x== 392 ) {pset(surface, 97 , y_scaled, color1);}
if (x== 394 ) {pset(surface, 98 , y_scaled, color1);}
if (x== 396 ) {pset(surface, 99 , y_scaled, color1);}
if (x== 399 ) {pset(surface, 100 , y_scaled, color1);}
}}}}

if (x>399) {
if (x<600) {

if (x>399) {
if (x<450) {


if (x== 401 ) {pset(surface, 101 , y_scaled, color1);}
if (x== 403 ) {pset(surface, 102 , y_scaled, color1);}
if (x== 405 ) {pset(surface, 103 , y_scaled, color1);}
if (x== 407 ) {pset(surface, 104 , y_scaled, color1);}
if (x== 410 ) {pset(surface, 105 , y_scaled, color1);}
if (x== 412 ) {pset(surface, 106 , y_scaled, color1);}
if (x== 414 ) {pset(surface, 107 , y_scaled, color1);}
if (x== 416 ) {pset(surface, 108 , y_scaled, color1);}
if (x== 419 ) {pset(surface, 109 , y_scaled, color1);}
if (x== 421 ) {pset(surface, 110 , y_scaled, color1);}
if (x== 423 ) {pset(surface, 111 , y_scaled, color1);}
if (x== 425 ) {pset(surface, 112 , y_scaled, color1);}
if (x== 428 ) {pset(surface, 113 , y_scaled, color1);}
if (x== 430 ) {pset(surface, 114 , y_scaled, color1);}
if (x== 432 ) {pset(surface, 115 , y_scaled, color1);}
if (x== 434 ) {pset(surface, 116 , y_scaled, color1);}
if (x== 437 ) {pset(surface, 117 , y_scaled, color1);}
if (x== 439 ) {pset(surface, 118 , y_scaled, color1);}
if (x== 441 ) {pset(surface, 119 , y_scaled, color1);}
if (x== 443 ) {pset(surface, 120 , y_scaled, color1);}
if (x== 445 ) {pset(surface, 121 , y_scaled, color1);}
if (x== 448 ) {pset(surface, 122 , y_scaled, color1);}
}}
if (x>448) {
if (x<500) {
if (x== 450 ) {pset(surface, 123 , y_scaled, color1);}
if (x== 452 ) {pset(surface, 124 , y_scaled, color1);}
if (x== 454 ) {pset(surface, 125 , y_scaled, color1);}
if (x== 457 ) {pset(surface, 126 , y_scaled, color1);}
if (x== 459 ) {pset(surface, 127 , y_scaled, color1);}
if (x== 461 ) {pset(surface, 128 , y_scaled, color1);}
if (x== 463 ) {pset(surface, 129 , y_scaled, color1);}
if (x== 466 ) {pset(surface, 130 , y_scaled, color1);}
if (x== 468 ) {pset(surface, 131 , y_scaled, color1);}
if (x== 470 ) {pset(surface, 132 , y_scaled, color1);}
if (x== 472 ) {pset(surface, 133 , y_scaled, color1);}
if (x== 475 ) {pset(surface, 134 , y_scaled, color1);}
if (x== 477 ) {pset(surface, 135 , y_scaled, color1);}
if (x== 479 ) {pset(surface, 136 , y_scaled, color1);}
if (x== 481 ) {pset(surface, 137 , y_scaled, color1);}
if (x== 483 ) {pset(surface, 138 , y_scaled, color1);}
if (x== 486 ) {pset(surface, 139 , y_scaled, color1);}
if (x== 488 ) {pset(surface, 140 , y_scaled, color1);}
if (x== 490 ) {pset(surface, 141 , y_scaled, color1);}
if (x== 492 ) {pset(surface, 142 , y_scaled, color1);}
if (x== 495 ) {pset(surface, 143 , y_scaled, color1);}
if (x== 497 ) {pset(surface, 144 , y_scaled, color1);}
if (x== 499 ) {pset(surface, 145 , y_scaled, color1);}
}}
if (x>499) {
if (x<550) {
if (x== 501 ) {pset(surface, 146 , y_scaled, color1);}
if (x== 504 ) {pset(surface, 147 , y_scaled, color1);}
if (x== 506 ) {pset(surface, 148 , y_scaled, color1);}
if (x== 508 ) {pset(surface, 149 , y_scaled, color1);}
if (x== 510 ) {pset(surface, 150 , y_scaled, color1);}
if (x== 513 ) {pset(surface, 151 , y_scaled, color1);}
if (x== 515 ) {pset(surface, 152 , y_scaled, color1);}
if (x== 517 ) {pset(surface, 153 , y_scaled, color1);}
if (x== 519 ) {pset(surface, 154 , y_scaled, color1);}
if (x== 521 ) {pset(surface, 155 , y_scaled, color1);}
if (x== 524 ) {pset(surface, 156 , y_scaled, color1);}
if (x== 526 ) {pset(surface, 157 , y_scaled, color1);}
if (x== 528 ) {pset(surface, 158 , y_scaled, color1);}
if (x== 530 ) {pset(surface, 159 , y_scaled, color1);}
if (x== 533 ) {pset(surface, 160 , y_scaled, color1);}
if (x== 535 ) {pset(surface, 161 , y_scaled, color1);}
if (x== 537 ) {pset(surface, 162 , y_scaled, color1);}
if (x== 539 ) {pset(surface, 163 , y_scaled, color1);}
if (x== 542 ) {pset(surface, 164 , y_scaled, color1);}
if (x== 544 ) {pset(surface, 165 , y_scaled, color1);}
if (x== 546 ) {pset(surface, 166 , y_scaled, color1);}
if (x== 548 ) {pset(surface, 167 , y_scaled, color1);}
}}
if (x>548) {
if (x<600) {
if (x== 551 ) {pset(surface, 168 , y_scaled, color1);}
if (x== 553 ) {pset(surface, 169 , y_scaled, color1);}
if (x== 555 ) {pset(surface, 170 , y_scaled, color1);}
if (x== 557 ) {pset(surface, 171 , y_scaled, color1);}
if (x== 559 ) {pset(surface, 172 , y_scaled, color1);}
if (x== 562 ) {pset(surface, 173 , y_scaled, color1);}
if (x== 564 ) {pset(surface, 174 , y_scaled, color1);}
if (x== 566 ) {pset(surface, 175 , y_scaled, color1);}
if (x== 568 ) {pset(surface, 176 , y_scaled, color1);}
if (x== 571 ) {pset(surface, 177 , y_scaled, color1);}
if (x== 573 ) {pset(surface, 178 , y_scaled, color1);}
if (x== 575 ) {pset(surface, 179 , y_scaled, color1);}
if (x== 577 ) {pset(surface, 180 , y_scaled, color1);}
if (x== 580 ) {pset(surface, 181 , y_scaled, color1);}
if (x== 582 ) {pset(surface, 182 , y_scaled, color1);}
if (x== 584 ) {pset(surface, 183 , y_scaled, color1);}
if (x== 586 ) {pset(surface, 184 , y_scaled, color1);}
if (x== 589 ) {pset(surface, 185 , y_scaled, color1);}
if (x== 591 ) {pset(surface, 186 , y_scaled, color1);}
if (x== 593 ) {pset(surface, 187 , y_scaled, color1);}
if (x== 595 ) {pset(surface, 188 , y_scaled, color1);}
if (x== 597 ) {pset(surface, 189 , y_scaled, color1);}
}}}}}}
if (x>597) {
if (x<800) {

if (x>597) {
if (x<650) {
if (x== 600 ) {pset(surface, 190 , y_scaled, color1);}
if (x== 602 ) {pset(surface, 191 , y_scaled, color1);}
if (x== 604 ) {pset(surface, 192 , y_scaled, color1);}
if (x== 606 ) {pset(surface, 193 , y_scaled, color1);}
if (x== 609 ) {pset(surface, 194 , y_scaled, color1);}
if (x== 611 ) {pset(surface, 195 , y_scaled, color1);}
if (x== 613 ) {pset(surface, 196 , y_scaled, color1);}
if (x== 615 ) {pset(surface, 197 , y_scaled, color1);}
if (x== 618 ) {pset(surface, 198 , y_scaled, color1);}
if (x== 620 ) {pset(surface, 199 , y_scaled, color1);}
if (x== 622 ) {pset(surface, 200 , y_scaled, color1);}
if (x== 624 ) {pset(surface, 201 , y_scaled, color1);}
if (x== 627 ) {pset(surface, 202 , y_scaled, color1);}
if (x== 629 ) {pset(surface, 203 , y_scaled, color1);}
if (x== 631 ) {pset(surface, 204 , y_scaled, color1);}
if (x== 633 ) {pset(surface, 205 , y_scaled, color1);}
if (x== 635 ) {pset(surface, 206 , y_scaled, color1);}
if (x== 638 ) {pset(surface, 207 , y_scaled, color1);}
if (x== 640 ) {pset(surface, 208 , y_scaled, color1);}
if (x== 642 ) {pset(surface, 209 , y_scaled, color1);}
if (x== 644 ) {pset(surface, 210 , y_scaled, color1);}
if (x== 647 ) {pset(surface, 211 , y_scaled, color1);}
if (x== 649 ) {pset(surface, 212 , y_scaled, color1);}
}}
if (x>649) {
if (x<700) {

if (x== 651 ) {pset(surface, 213 , y_scaled, color1);}
if (x== 653 ) {pset(surface, 214 , y_scaled, color1);}
if (x== 656 ) {pset(surface, 215 , y_scaled, color1);}
if (x== 658 ) {pset(surface, 216 , y_scaled, color1);}
if (x== 660 ) {pset(surface, 217 , y_scaled, color1);}
if (x== 663 ) {pset(surface, 218 , y_scaled, color1);}
if (x== 665 ) {pset(surface, 219 , y_scaled, color1);}
if (x== 667 ) {pset(surface, 220 , y_scaled, color1);}
if (x== 669 ) {pset(surface, 221 , y_scaled, color1);}
if (x== 671 ) {pset(surface, 222 , y_scaled, color1);}
if (x== 673 ) {pset(surface, 223 , y_scaled, color1);}
if (x== 676 ) {pset(surface, 224 , y_scaled, color1);}
if (x== 678 ) {pset(surface, 225 , y_scaled, color1);}
if (x== 680 ) {pset(surface, 226 , y_scaled, color1);}
if (x== 682 ) {pset(surface, 227 , y_scaled, color1);}
if (x== 685 ) {pset(surface, 228 , y_scaled, color1);}
if (x== 687 ) {pset(surface, 229 , y_scaled, color1);}
if (x== 689 ) {pset(surface, 230 , y_scaled, color1);}
if (x== 691 ) {pset(surface, 231 , y_scaled, color1);}
if (x== 694 ) {pset(surface, 232 , y_scaled, color1);}
if (x== 696 ) {pset(surface, 233 , y_scaled, color1);}
if (x== 698 ) {pset(surface, 234 , y_scaled, color1);}
}}
if (x>698) {
if (x<750) {
if (x== 700 ) {pset(surface, 235 , y_scaled, color1);}
if (x== 703 ) {pset(surface, 236 , y_scaled, color1);}
if (x== 705 ) {pset(surface, 237 , y_scaled, color1);}
if (x== 707 ) {pset(surface, 238 , y_scaled, color1);}
if (x== 709 ) {pset(surface, 239 , y_scaled, color1);}
if (x== 711 ) {pset(surface, 240 , y_scaled, color1);}
if (x== 714 ) {pset(surface, 241 , y_scaled, color1);}
if (x== 716 ) {pset(surface, 242 , y_scaled, color1);}
if (x== 718 ) {pset(surface, 243 , y_scaled, color1);}
if (x== 720 ) {pset(surface, 244 , y_scaled, color1);}
if (x== 723 ) {pset(surface, 245 , y_scaled, color1);}
if (x== 725 ) {pset(surface, 246 , y_scaled, color1);}
if (x== 727 ) {pset(surface, 247 , y_scaled, color1);}
if (x== 729 ) {pset(surface, 248 , y_scaled, color1);}
if (x== 732 ) {pset(surface, 249 , y_scaled, color1);}
if (x== 734 ) {pset(surface, 250 , y_scaled, color1);}
if (x== 736 ) {pset(surface, 251 , y_scaled, color1);}
if (x== 738 ) {pset(surface, 252 , y_scaled, color1);}
if (x== 741 ) {pset(surface, 253 , y_scaled, color1);}
if (x== 743 ) {pset(surface, 254 , y_scaled, color1);}
if (x== 745 ) {pset(surface, 255 , y_scaled, color1);}
if (x== 747 ) {pset(surface, 256 , y_scaled, color1);}
if (x== 749 ) {pset(surface, 257 , y_scaled, color1);}
}}
if (x>749) {
if (x<800) {
if (x== 752 ) {pset(surface, 258 , y_scaled, color1);}
if (x== 754 ) {pset(surface, 259 , y_scaled, color1);}
if (x== 756 ) {pset(surface, 260 , y_scaled, color1);}
if (x== 758 ) {pset(surface, 261 , y_scaled, color1);}
if (x== 761 ) {pset(surface, 262 , y_scaled, color1);}
if (x== 763 ) {pset(surface, 263 , y_scaled, color1);}
if (x== 765 ) {pset(surface, 264 , y_scaled, color1);}
if (x== 767 ) {pset(surface, 265 , y_scaled, color1);}
if (x== 770 ) {pset(surface, 266 , y_scaled, color1);}
if (x== 772 ) {pset(surface, 267 , y_scaled, color1);}
if (x== 774 ) {pset(surface, 268 , y_scaled, color1);}
if (x== 776 ) {pset(surface, 269 , y_scaled, color1);}
if (x== 778 ) {pset(surface, 270 , y_scaled, color1);}
if (x== 781 ) {pset(surface, 271 , y_scaled, color1);}
if (x== 783 ) {pset(surface, 272 , y_scaled, color1);}
if (x== 785 ) {pset(surface, 273 , y_scaled, color1);}
if (x== 787 ) {pset(surface, 274 , y_scaled, color1);}
if (x== 790 ) {pset(surface, 275 , y_scaled, color1);}
if (x== 792 ) {pset(surface, 276 , y_scaled, color1);}
if (x== 794 ) {pset(surface, 277 , y_scaled, color1);}
if (x== 796 ) {pset(surface, 278 , y_scaled, color1);}
if (x== 799 ) {pset(surface, 279 , y_scaled, color1);}
}}}}
if (x>799) {
if (x<850) {
if (x== 801 ) {pset(surface, 280 , y_scaled, color1);}
if (x== 803 ) {pset(surface, 281 , y_scaled, color1);}
if (x== 805 ) {pset(surface, 282 , y_scaled, color1);}
if (x== 808 ) {pset(surface, 283 , y_scaled, color1);}
if (x== 810 ) {pset(surface, 284 , y_scaled, color1);}
if (x== 812 ) {pset(surface, 285 , y_scaled, color1);}
if (x== 814 ) {pset(surface, 286 , y_scaled, color1);}
if (x== 817 ) {pset(surface, 287 , y_scaled, color1);}
if (x== 819 ) {pset(surface, 288 , y_scaled, color1);}
if (x== 821 ) {pset(surface, 289 , y_scaled, color1);}
if (x== 823 ) {pset(surface, 290 , y_scaled, color1);}
if (x== 825 ) {pset(surface, 291 , y_scaled, color1);}
if (x== 828 ) {pset(surface, 292 , y_scaled, color1);}
if (x== 830 ) {pset(surface, 293 , y_scaled, color1);}
if (x== 832 ) {pset(surface, 294 , y_scaled, color1);}
if (x== 834 ) {pset(surface, 295 , y_scaled, color1);}
if (x== 837 ) {pset(surface, 296 , y_scaled, color1);}
if (x== 839 ) {pset(surface, 297 , y_scaled, color1);}
if (x== 841 ) {pset(surface, 298 , y_scaled, color1);}
if (x== 843 ) {pset(surface, 299 , y_scaled, color1);}
if (x== 846 ) {pset(surface, 300 , y_scaled, color1);}
if (x== 848 ) {pset(surface, 301 , y_scaled, color1);}
}}
if (x>849) {
if (x<889) {
if (x== 850 ) {pset(surface, 302 , y_scaled, color1);}
if (x== 852 ) {pset(surface, 303 , y_scaled, color1);}
if (x== 854 ) {pset(surface, 304 , y_scaled, color1);}
if (x== 857 ) {pset(surface, 305 , y_scaled, color1);}
if (x== 859 ) {pset(surface, 306 , y_scaled, color1);}
if (x== 861 ) {pset(surface, 307 , y_scaled, color1);}
if (x== 863 ) {pset(surface, 308 , y_scaled, color1);}
if (x== 866 ) {pset(surface, 309 , y_scaled, color1);}
if (x== 868 ) {pset(surface, 310 , y_scaled, color1);}
if (x== 870 ) {pset(surface, 311 , y_scaled, color1);}
if (x== 872 ) {pset(surface, 312 , y_scaled, color1);}
if (x== 875 ) {pset(surface, 313 , y_scaled, color1);}
if (x== 877 ) {pset(surface, 314 , y_scaled, color1);}
if (x== 879 ) {pset(surface, 315 , y_scaled, color1);}
if (x== 881 ) {pset(surface, 316 , y_scaled, color1);}
if (x== 884 ) {pset(surface, 317 , y_scaled, color1);}
if (x== 886 ) {pset(surface, 318 , y_scaled, color1);}
if (x== 888 ) {pset(surface, 319 , y_scaled, color1);}
}}

x++;
if( hsync ) {
ref_len++;
if( ref_len > 30 && x > 700 ) {
// pset(surface, x_scaled, y, 5);
y++;
x = 0;
}
} else {
ref_len = 0;
}
}

SDL_DestroyWindow( window );
SDL_Quit();

return 0;
}
Last edited by Predator99 on 2020-07-26, 15:47. Edited 2 times in total.

Reply 166 of 212, by root42

User metadata
Rank l33t
Rank
l33t

Will check out your changes later. That include path... the epitome of unportable! 😀 You know there are include directives for the compiler? 😀
I will also try to fix the texture problem. Different cards have different native texture formats (e.g. ARGB vs. RGBA) and you have to use the right one or else the texture data will have to be converted before being uploaded to the device. The textures allow us to scale the window arbitrarily.

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC

Reply 167 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t
root42 wrote on 2020-07-26, 13:00:

Will check out your changes later. That include path... the epitome of unportable! 😀 You know there are include directives for the compiler? 😀

Lol...I know its ugly but I am happy to have it running at all 😀 Would also like to upload a EXE but I am getting an error with the -static option.

Program is great...its running since my last post in Fullscreen-Mode...and running...and running... 😀

All readers should order their Analyzer...NOW 😉

Real-Time quality at 16MHz..:

ck16mhz.jpg
Filename
ck16mhz.jpg
File size
540.34 KiB
Views
1080 views
File license
Fair use/fair dealing exception

Reply 168 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t

So this is the Windows-EXE and another demo file. To start, extract all files in a folder and type at the command prompt:

type keen-16MHZ.bin | ega-c-320-16MHZ.exe

The demo is 60 seconds long. If your PC can process it faster than that you will also be able to run it in real-time directly from the logic analyzer.

Attachments

  • Filename
    Keen-16MHZ.part001.rar
    File size
    4.88 MiB
    Downloads
    72 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    ega-c-320-16MHZ.rar
    File size
    487.36 KiB
    Downloads
    56 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    Keen-16MHZ.part003.rar
    File size
    1.34 MiB
    Downloads
    53 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    Keen-16MHZ.part002.rar
    File size
    4.88 MiB
    Downloads
    51 downloads
    File license
    Fair use/fair dealing exception

Reply 169 of 212, by imi

User metadata
Rank l33t
Rank
l33t
Predator99 wrote on 2020-07-26, 13:59:

All readers should order their Analyzer...NOW 😉

already did a while ago... seems to be stuck in customs since 2 weeks ^^

looking good :3

Reply 170 of 212, by Deksor

User metadata
Rank l33t
Rank
l33t

Still no aspect ratio correction available ? It'd be nice to have that 😁

Also does it still need a beefy CPU or can a raspberry pi run it ?

Trying to identify old hardware ? Visit The retro web - Project's thread The Retro Web project - a stason.org/TH99 alternative

Reply 171 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t

You can chosse whatever aspect ratio you like. Yes, strong CPU required. My i7-4790 is very borderline, it often interrupts when trying to scale the window, but it works. Hope it will get better with the improvement root42 announced.

So this is the same for 640x350 at 16MHZ. Quite looking OK, but screenshots are ugly. View Demo with

type 640x350-16MHZ.bin | ega-c-640-16MHZ

With the 640 program you can the see the BIOS screen, use DOS and most text based programs. When starting a game you need to switch to the 320 Program. Autodetection shoudl be quite easy to implement, VSYNC ist inverted between the 2 modes. Will follow...
http://minuszerodegrees.net/mda_cga_ega/mda_cga_ega.htm

Filename
ega-c-640-16MHZ.rar
File size
485.55 KiB
Downloads
59 downloads
File license
Fair use/fair dealing exception
Filename
640x350-16MHZ.part001.rar
File size
4.88 MiB
Downloads
52 downloads
File license
Fair use/fair dealing exception
Filename
640x350-16MHZ.part002.rar
File size
2.87 MiB
Downloads
50 downloads
File license
Fair use/fair dealing exception
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-

w64-mingw32\include\SDL2\SDL.h>
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-

w64-mingw32\include\SDL2\SDL_surface.h>


#include <io.h>
#include <fcntl.h>





#define IMG_WIDTH 640
#define IMG_HEIGHT 350

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
static const Uint32 rmask = 0xff000000;
static const Uint32 gmask = 0x00ff0000;
static const Uint32 bmask = 0x0000ff00;
static const Uint32 amask = 0x000000ff;
#else
static const Uint32 rmask = 0x00ff0000;
static const Uint32 gmask = 0x0000ff00;
static const Uint32 bmask = 0x000000ff;
static const Uint32 amask = 0xff000000;
#endif

static Uint32 egapal[64];

void
init_pal()
{
int i;
for( i = 0; i < 64; ++i ) {
Uint32 color =
( ((i & (1 << 0)) << 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & bmask)
+ (((i & (1 << 1)) >> 0) + ((i & (1 << 3)) >> 3)) * (0x55555555 & gmask)
+ (((i & (1 << 2)) >> 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & rmask)
+ amask
;
printf("%xd ", color);
egapal[i] = color;
}
}

inline
void
pset(
SDL_Surface *surface,
unsigned int x,
unsigned int y,
unsigned char color
)
Show last 134 lines
{
if( x >= IMG_WIDTH || y >= IMG_HEIGHT ) {
return;
}

Uint32 *target_pixel = surface->pixels + y * surface->pitch +
x * sizeof( *target_pixel );
*target_pixel = egapal[color];
}

int main()
{
_setmode (_fileno( stdin ), _O_BINARY );

int x_scaled;
int new_frame = 0;
unsigned char value, color1;
int hsync = 0, vsync = 0;
int frame = 0;
unsigned int vsyncc = 0, ref_len = 0;
unsigned int x = 0, y = 0;
SDL_Window *window;

init_pal();

SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"SIGROK2EGA",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
IMG_WIDTH,
IMG_HEIGHT,
SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE
);

if (window == NULL) {
SDL_Log( "Could not create window: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Renderer *ren = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == NULL) {
SDL_DestroyWindow( window );
SDL_Log( "SDL_CreateRenderer Error: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Surface *surface =
SDL_CreateRGBSurface(
0,
IMG_WIDTH,
IMG_HEIGHT,
32,
rmask,
gmask,
bmask,
amask
);
if (surface == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, surface);
if( tex == NULL ) {
SDL_Log( "SDL_CreateTextueFromSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

while(!feof(stdin)) {
value = fgetc(stdin);
vsync = value & 128;
hsync = value & 64;
if( vsync != 0 ) {
vsyncc = 0;
new_frame = 0;
} else {
vsyncc++;
if( vsyncc > 20 ) {
vsyncc = 0;
y = 0;
// this means a new frame?
if( !new_frame ) {
new_fram
e = 1;
frame++;
printf("frame %u\n", frame);

SDL_UpdateTexture(tex, NULL, surface->pixels, surface->pitch);
// SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);

SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
}
}
}
color1 = value & 0x3F;

int x_scaled=x-75 ;
int y_scaled = y-3 ;

//if (y>32){
//if (y<235){

pset(surface, x_scaled, y_scaled, color1);

x++;
if( hsync ) {
ref_len++;
if( ref_len > 30 && x > 700 ) {
// pset(surface, x_scaled, y, 5);
y++;
x = 0;
}
} else {
ref_len = 0;
}
}

SDL_DestroyWindow( window );
SDL_Quit();

return 0;
}

Reply 172 of 212, by Deksor

User metadata
Rank l33t
Rank
l33t

Well what I meant was perfect 4:3 aspect ratio with the best scaling possible.

Hope root42's idea works too ^^

Trying to identify old hardware ? Visit The retro web - Project's thread The Retro Web project - a stason.org/TH99 alternative

Reply 173 of 212, by Benedikt

User metadata
Rank Oldbie
Rank
Oldbie
Deksor wrote on 2020-07-26, 20:41:

Still no aspect ratio correction available ? It'd be nice to have that 😁

Also does it still need a beefy CPU or can a raspberry pi run it ?

Using it on a Raspberry Pi would be quite silly, because a Raspberry Pi has plenty of GPIOs and several PLL clock generators.
It wouldn't surprise me if it can synthesize let's say 2x the pixel clock, clock a DMA channel with it and have it read bytes from its GPIO lines via DMA.
The software side would then merely have to decide whether to preserve odd or even samples for any given scan line before writing it to a frame buffer.
It could also feed the result into one of its hardware video encoders.

Reply 174 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t

ARE ALL DEVICES SOLD OUT IN THE MEAN TIME?? :-p

Made a major improvement and inserted some spaghetti-code 😉

I implemented the detection of screen modes so I need only one program.

Short description how it works:
The reason that I had to switch the programs between 640 and 320 pixel modes (or exactly: 350 or 200 lines) was
Mode 1 = LINES: 200, H.SYNC: positive at 15.7 kHz, V.SYNC: positive at 60 Hz
Mode 2 = LINES: 350, H.SYNC: positive at 21.85 kHz, V.SYNC: negative at 60 Hz

Therefore the VSYNC is inverted between the modes and the next frame is not detected correctly. I implemented a VSYNC-counter ("mode_det") which sums up all values for "vsync" within a frame. This value is printed and you can see a clear difference when switching modes.

So if it is between 380000-400000 I define its a 320 pixel mode, everything else is 640 for the moment. I think this concept can be enhanced also for all other resolution and it will also help to implement a autodetection of the sigrok sample-rate...

Code looks like shit but it runs and runs and runs... 😉

Only problem at the moment: I define a 640x350 screen. But when switching to 320x200 only part of the screen is used.

Somebody 😉 knows if I can adjust the current window size to match the output..?

autodet.jpg
Filename
autodet.jpg
File size
93.53 KiB
Views
966 views
File license
Fair use/fair dealing exception
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-w64-mingw32\include\SDL2\SDL.h>
#include <C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\SDL2-2.0.12\i686-w64-mingw32\include\SDL2\SDL_surface.h>


#include <io.h>
#include <fcntl.h>





#define IMG_WIDTH 640
#define IMG_HEIGHT 350

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
static const Uint32 rmask = 0xff000000;
static const Uint32 gmask = 0x00ff0000;
static const Uint32 bmask = 0x0000ff00;
static const Uint32 amask = 0x000000ff;
#else
static const Uint32 rmask = 0x00ff0000;
static const Uint32 gmask = 0x0000ff00;
static const Uint32 bmask = 0x000000ff;
static const Uint32 amask = 0xff000000;
#endif

static Uint32 egapal[64];

void
init_pal()
{
int i;
for( i = 0; i < 64; ++i ) {
Uint32 color =
( ((i & (1 << 0)) << 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & bmask)
+ (((i & (1 << 1)) >> 0) + ((i & (1 << 3)) >> 3)) * (0x55555555 & gmask)
+ (((i & (1 << 2)) >> 1) + ((i & (1 << 3)) >> 3)) * (0x55555555 & rmask)
+ amask
;
printf("%xd ", color);
egapal[i] = color;
}
}

inline
void
pset(
SDL_Surface *surface,
unsigned int x,
unsigned int y,
unsigned char color
)
{
if( x >= IMG_WIDTH || y >= IMG_HEIGHT ) {
return;
}
Show last 629 lines

Uint32 *target_pixel = surface->pixels + y * surface->pitch +
x * sizeof( *target_pixel );
*target_pixel = egapal[color];
}

int main()
{
_setmode (_fileno( stdin ), _O_BINARY );

int x_scaled;
int mode=320;
int mode_det=0;
int new_frame = 0;
unsigned char value, color1;
int hsync = 0, vsync = 0;
int frame = 0;
unsigned int vsyncc = 0, ref_len = 0;
unsigned int x = 0, y = 0;
SDL_Window *window;

init_pal();

SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"SIGROK2EGA",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
IMG_WIDTH,
IMG_HEIGHT,
SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE
);

if (window == NULL) {
SDL_Log( "Could not create window: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Renderer *ren = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == NULL) {
SDL_DestroyWindow( window );
SDL_Log( "SDL_CreateRenderer Error: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Surface *surface =
SDL_CreateRGBSurface(
0,
IMG_WIDTH,
IMG_HEIGHT,
32,
rmask,
gmask,
bmask,
amask
);
if (surface == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}

SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, surface);
if( tex == NULL ) {
SDL_Log( "SDL_CreateTextueFromSurface() failed: %s", SDL_GetError());
SDL_Quit();
return 1;
}



while(!feof(stdin)) {
value = fgetc(stdin);
vsync = value & 128;
hsync = value & 64;
mode_det=mode_det+vsync;


if(mode==640){
if( vsync != 0 ) {

vsyncc = 0;
new_frame = 0;
} else {
vsyncc++;
if( vsyncc > 20 ) {
vsyncc = 0;
y = 0;
// this means a new frame?
if( !new_frame ) {
new_frame = 1;
frame++;
if (mode_det <400000) {if (mode_det > 380000) {printf ("current mode 640 next mode 320");mode=320;}}else {printf("current mode 640 next mode 640");mode=640;}
printf(" mode_det %u\n", mode_det);
mode_det=0;
SDL_UpdateTexture(tex, NULL, surface->pixels, surface->pitch);
// SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);

SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
}
}
}
color1 = value & 0x3F;

int x_scaled=x-75 ;
int y_scaled = y-3 ;

//if (y>32){
//if (y<235){

pset(surface, x_scaled, y_scaled, color1);

x++;
if( hsync ) {
ref_len++;
if( ref_len > 30 && x > 700 ) {
// pset(surface, x_scaled, y, 5);
y++;
x = 0;
}
} else {
ref_len = 0;
}
}


if(mode==320){
if( vsync == 0 ) {

vsyncc = 0;
new_frame = 0;
} else {
vsyncc++;
if( vsyncc > 20 ) {
vsyncc = 0;
y = 0;
// this means a new frame?
if( !new_frame ) {
new_frame = 1;
// frame++;
if (mode_det <400000) {if (mode_det > 380000) {mode=320;}}else {printf("current mode 320 next mode 640");mode=640;}
printf(" mode_det %u\n", mode_det);
mode_det=0;
SDL_UpdateTexture(tex, NULL, surface->pixels, surface->pitch);
// SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);

SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
}
}
}
color1 = value & 0x3F;
//fast perfekt int x_scaled = round(319.5/714.5*(x-126));
//int x_scaled = round(319.5/714.5*(x-126));
//if (x==174) {int x_scaled = 300;}
// int x_scaled=x ;
int y_scaled = y - 34;

//if (y>32){
//if (y<235){
if (x<889) {

if (x<550) {
if (x>174) {

if (x<359) {


if (x<194) {
if (x>174) {
if (x== 175 ) {pset(surface, 0 , y_scaled, color1);}
if (x== 177 ) {pset(surface, 1 , y_scaled, color1);}
if (x== 179 ) {pset(surface, 2 , y_scaled, color1);}
if (x== 182 ) {pset(surface, 3 , y_scaled, color1);}
if (x== 184 ) {pset(surface, 4 , y_scaled, color1);}
if (x== 186 ) {pset(surface, 5 , y_scaled, color1);}
if (x== 188 ) {pset(surface, 6 , y_scaled, color1);}
if (x== 191 ) {pset(surface, 7 , y_scaled, color1);}
if (x== 193 ) {pset(surface, 8 , y_scaled, color1);}
}}
if (x<218) {
if (x>194) {
if (x== 195 ) {pset(surface, 9 , y_scaled, color1);}
if (x== 197 ) {pset(surface, 10 , y_scaled, color1);}
if (x== 200 ) {pset(surface, 11 , y_scaled, color1);}
if (x== 202 ) {pset(surface, 12 , y_scaled, color1);}
if (x== 204 ) {pset(surface, 13 , y_scaled, color1);}
if (x== 206 ) {pset(surface, 14 , y_scaled, color1);}
if (x== 209 ) {pset(surface, 15 , y_scaled, color1);}
if (x== 211 ) {pset(surface, 16 , y_scaled, color1);}
if (x== 213 ) {pset(surface, 17 , y_scaled, color1);}
if (x== 215 ) {pset(surface, 18 , y_scaled, color1);}
if (x== 217 ) {pset(surface, 19 , y_scaled, color1);}
}}
if (x>219) {
if (x<236) {
if (x== 220 ) {pset(surface, 20 , y_scaled, color1);}
if (x== 222 ) {pset(surface, 21 , y_scaled, color1);}
if (x== 224 ) {pset(surface, 22 , y_scaled, color1);}
if (x== 226 ) {pset(surface, 23 , y_scaled, color1);}
if (x== 229 ) {pset(surface, 24 , y_scaled, color1);}
if (x== 231 ) {pset(surface, 25 , y_scaled, color1);}
if (x== 233 ) {pset(surface, 26 , y_scaled, color1);}
if (x== 235 ) {pset(surface, 27 , y_scaled, color1);}
}}
if (x>237) {
if (x<261) {

if (x== 238 ) {pset(surface, 28 , y_scaled, color1);}
if (x== 240 ) {pset(surface, 29 , y_scaled, color1);}
if (x== 242 ) {pset(surface, 30 , y_scaled, color1);}
if (x== 244 ) {pset(surface, 31 , y_scaled, color1);}
if (x== 247 ) {pset(surface, 32 , y_scaled, color1);}
if (x== 249 ) {pset(surface, 33 , y_scaled, color1);}
if (x== 251 ) {pset(surface, 34 , y_scaled, color1);}
if (x== 253 ) {pset(surface, 35 , y_scaled, color1);}
if (x== 255 ) {pset(surface, 36 , y_scaled, color1);}
if (x== 258 ) {pset(surface, 37 , y_scaled, color1);}
if (x== 260 ) {pset(surface, 38 , y_scaled, color1);}
}}
if (x<283) {
if (x>261) {
if (x== 262 ) {pset(surface, 39 , y_scaled, color1);}
if (x== 264 ) {pset(surface, 40 , y_scaled, color1);}
if (x== 267 ) {pset(surface, 41 , y_scaled, color1);}
if (x== 269 ) {pset(surface, 42 , y_scaled, color1);}
if (x== 271 ) {pset(surface, 43 , y_scaled, color1);}
if (x== 273 ) {pset(surface, 44 , y_scaled, color1);}
if (x== 276 ) {pset(surface, 45 , y_scaled, color1);}
if (x== 278 ) {pset(surface, 46 , y_scaled, color1);}
if (x== 280 ) {pset(surface, 47 , y_scaled, color1);}
if (x== 282 ) {pset(surface, 48 , y_scaled, color1);}
}}
if (x<310) {
if (x>284) {
if (x== 285 ) {pset(surface, 49 , y_scaled, color1);}
if (x== 287 ) {pset(surface, 50 , y_scaled, color1);}
if (x== 289 ) {pset(surface, 51 , y_scaled, color1);}
if (x== 291 ) {pset(surface, 52 , y_scaled, color1);}
if (x== 293 ) {pset(surface, 53 , y_scaled, color1);}
if (x== 296 ) {pset(surface, 54 , y_scaled, color1);}
if (x== 298 ) {pset(surface, 55 , y_scaled, color1);}
if (x== 300 ) {pset(surface, 56 , y_scaled, color1);}
if (x== 302 ) {pset(surface, 57 , y_scaled, color1);}
if (x== 305 ) {pset(surface, 58 , y_scaled, color1);}
if (x== 307 ) {pset(surface, 59 , y_scaled, color1);}
if (x== 309 ) {pset(surface, 60 , y_scaled, color1);}
}}
if (x>310) {
if (x<332) {
if (x== 311 ) {pset(surface, 61 , y_scaled, color1);}
if (x== 314 ) {pset(surface, 62 , y_scaled, color1);}
if (x== 316 ) {pset(surface, 63 , y_scaled, color1);}
if (x== 318 ) {pset(surface, 64 , y_scaled, color1);}
if (x== 320 ) {pset(surface, 65 , y_scaled, color1);}
if (x== 323 ) {pset(surface, 66 , y_scaled, color1);}
if (x== 325 ) {pset(surface, 67 , y_scaled, color1);}
if (x== 327 ) {pset(surface, 68 , y_scaled, color1);}
if (x== 329 ) {pset(surface, 69 , y_scaled, color1);}
if (x== 331 ) {pset(surface, 70 , y_scaled, color1);}
}}
if (x>333) {
if (x<359) {

if (x== 334 ) {pset(surface, 71 , y_scaled, color1);}
if (x== 336 ) {pset(surface, 72 , y_scaled, color1);}
if (x== 338 ) {pset(surface, 73 , y_scaled, color1);}
if (x== 340 ) {pset(surface, 74 , y_scaled, color1);}
if (x== 343 ) {pset(surface, 75 , y_scaled, color1);}
if (x== 345 ) {pset(surface, 76 , y_scaled, color1);}
if (x== 347 ) {pset(surface, 77 , y_scaled, color1);}
if (x== 349 ) {pset(surface, 78 , y_scaled, color1);}
if (x== 352 ) {pset(surface, 79 , y_scaled, color1);}
if (x== 354 ) {pset(surface, 80 , y_scaled, color1);}
if (x== 356 ) {pset(surface, 81 , y_scaled, color1);}
if (x== 358 ) {pset(surface, 82 , y_scaled, color1);}
}}} else {
if (x>360) {
if (x<400) {
if (x== 361 ) {pset(surface, 83 , y_scaled, color1);}
if (x== 363 ) {pset(surface, 84 , y_scaled, color1);}
if (x== 365 ) {pset(surface, 85 , y_scaled, color1);}
if (x== 367 ) {pset(surface, 86 , y_scaled, color1);}
if (x== 369 ) {pset(surface, 87 , y_scaled, color1);}
if (x== 372 ) {pset(surface, 88 , y_scaled, color1);}
if (x== 374 ) {pset(surface, 89 , y_scaled, color1);}
if (x== 376 ) {pset(surface, 90 , y_scaled, color1);}
if (x== 378 ) {pset(surface, 91 , y_scaled, color1);}
if (x== 381 ) {pset(surface, 92 , y_scaled, color1);}
if (x== 383 ) {pset(surface, 93 , y_scaled, color1);}
if (x== 385 ) {pset(surface, 94 , y_scaled, color1);}
if (x== 387 ) {pset(surface, 95 , y_scaled, color1);}
if (x== 390 ) {pset(surface, 96 , y_scaled, color1);}
if (x== 392 ) {pset(surface, 97 , y_scaled, color1);}
if (x== 394 ) {pset(surface, 98 , y_scaled, color1);}
if (x== 396 ) {pset(surface, 99 , y_scaled, color1);}
if (x== 399 ) {pset(surface, 100 , y_scaled, color1);}
}}


if (x>400) {
if (x<422) {
if (x== 401 ) {pset(surface, 101 , y_scaled, color1);}
if (x== 403 ) {pset(surface, 102 , y_scaled, color1);}
if (x== 405 ) {pset(surface, 103 , y_scaled, color1);}
if (x== 407 ) {pset(surface, 104 , y_scaled, color1);}
if (x== 410 ) {pset(surface, 105 , y_scaled, color1);}
if (x== 412 ) {pset(surface, 106 , y_scaled, color1);}
if (x== 414 ) {pset(surface, 107 , y_scaled, color1);}
if (x== 416 ) {pset(surface, 108 , y_scaled, color1);}
if (x== 419 ) {pset(surface, 109 , y_scaled, color1);}
if (x== 421 ) {pset(surface, 110 , y_scaled, color1);}
}}


if (x>422) {
if (x<449) {

if (x== 423 ) {pset(surface, 111 , y_scaled, color1);}
if (x== 425 ) {pset(surface, 112 , y_scaled, color1);}
if (x== 428 ) {pset(surface, 113 , y_scaled, color1);}
if (x== 430 ) {pset(surface, 114 , y_scaled, color1);}
if (x== 432 ) {pset(surface, 115 , y_scaled, color1);}
if (x== 434 ) {pset(surface, 116 , y_scaled, color1);}
if (x== 437 ) {pset(surface, 117 , y_scaled, color1);}
if (x== 439 ) {pset(surface, 118 , y_scaled, color1);}
if (x== 441 ) {pset(surface, 119 , y_scaled, color1);}
if (x== 443 ) {pset(surface, 120 , y_scaled, color1);}
if (x== 445 ) {pset(surface, 121 , y_scaled, color1);}
if (x== 448 ) {pset(surface, 122 , y_scaled, color1);}
}}
if (x<549){
if (x>449) {
if (x<471) {
if (x== 450 ) {pset(surface, 123 , y_scaled, color1);}
if (x== 452 ) {pset(surface, 124 , y_scaled, color1);}
if (x== 454 ) {pset(surface, 125 , y_scaled, color1);}
if (x== 457 ) {pset(surface, 126 , y_scaled, color1);}
if (x== 459 ) {pset(surface, 127 , y_scaled, color1);}
if (x== 461 ) {pset(surface, 128 , y_scaled, color1);}
if (x== 463 ) {pset(surface, 129 , y_scaled, color1);}
if (x== 466 ) {pset(surface, 130 , y_scaled, color1);}
if (x== 468 ) {pset(surface, 131 , y_scaled, color1);}
if (x== 470 ) {pset(surface, 132 , y_scaled, color1);}
}}
if (x>471) {
if (x<500) {
if (x== 472 ) {pset(surface, 133 , y_scaled, color1);}
if (x== 475 ) {pset(surface, 134 , y_scaled, color1);}
if (x== 477 ) {pset(surface, 135 , y_scaled, color1);}
if (x== 479 ) {pset(surface, 136 , y_scaled, color1);}
if (x== 481 ) {pset(surface, 137 , y_scaled, color1);}
if (x== 483 ) {pset(surface, 138 , y_scaled, color1);}
if (x== 486 ) {pset(surface, 139 , y_scaled, color1);}
if (x== 488 ) {pset(surface, 140 , y_scaled, color1);}
if (x== 490 ) {pset(surface, 141 , y_scaled, color1);}
if (x== 492 ) {pset(surface, 142 , y_scaled, color1);}
if (x== 495 ) {pset(surface, 143 , y_scaled, color1);}
if (x== 497 ) {pset(surface, 144 , y_scaled, color1);}
if (x== 499 ) {pset(surface, 145 , y_scaled, color1);}
}}
if (x>500) {
if (x<522) {
if (x== 501 ) {pset(surface, 146 , y_scaled, color1);}
if (x== 504 ) {pset(surface, 147 , y_scaled, color1);}
if (x== 506 ) {pset(surface, 148 , y_scaled, color1);}
if (x== 508 ) {pset(surface, 149 , y_scaled, color1);}
if (x== 510 ) {pset(surface, 150 , y_scaled, color1);}
if (x== 513 ) {pset(surface, 151 , y_scaled, color1);}
if (x== 515 ) {pset(surface, 152 , y_scaled, color1);}
if (x== 517 ) {pset(surface, 153 , y_scaled, color1);}
if (x== 519 ) {pset(surface, 154 , y_scaled, color1);}
if (x== 521 ) {pset(surface, 155 , y_scaled, color1);}
}}
if (x>523) {
if (x<550) {
if (x== 524 ) {pset(surface, 156 , y_scaled, color1);}
if (x== 526 ) {pset(surface, 157 , y_scaled, color1);}
if (x== 528 ) {pset(surface, 158 , y_scaled, color1);}
if (x== 530 ) {pset(surface, 159 , y_scaled, color1);}
if (x== 533 ) {pset(surface, 160 , y_scaled, color1);}
if (x== 535 ) {pset(surface, 161 , y_scaled, color1);}
if (x== 537 ) {pset(surface, 162 , y_scaled, color1);}
if (x== 539 ) {pset(surface, 163 , y_scaled, color1);}
if (x== 542 ) {pset(surface, 164 , y_scaled, color1);}
if (x== 544 ) {pset(surface, 165 , y_scaled, color1);}
if (x== 546 ) {pset(surface, 166 , y_scaled, color1);}
if (x== 548 ) {pset(surface, 167 , y_scaled, color1);}
}}} }}} else {
if (x<750){
if (x<674){
if (x>550) {
if (x<572) {
if (x== 551 ) {pset(surface, 168 , y_scaled, color1);}
if (x== 553 ) {pset(surface, 169 , y_scaled, color1);}
if (x== 555 ) {pset(surface, 170 , y_scaled, color1);}
if (x== 557 ) {pset(surface, 171 , y_scaled, color1);}
if (x== 559 ) {pset(surface, 172 , y_scaled, color1);}
if (x== 562 ) {pset(surface, 173 , y_scaled, color1);}
if (x== 564 ) {pset(surface, 174 , y_scaled, color1);}
if (x== 566 ) {pset(surface, 175 , y_scaled, color1);}
if (x== 568 ) {pset(surface, 176 , y_scaled, color1);}
if (x== 571 ) {pset(surface, 177 , y_scaled, color1);}
}}
if (x>572) {
if (x<598) {

if (x== 573 ) {pset(surface, 178 , y_scaled, color1);}
if (x== 575 ) {pset(surface, 179 , y_scaled, color1);}
if (x== 577 ) {pset(surface, 180 , y_scaled, color1);}
if (x== 580 ) {pset(surface, 181 , y_scaled, color1);}
if (x== 582 ) {pset(surface, 182 , y_scaled, color1);}
if (x== 584 ) {pset(surface, 183 , y_scaled, color1);}
if (x== 586 ) {pset(surface, 184 , y_scaled, color1);}
if (x== 589 ) {pset(surface, 185 , y_scaled, color1);}
if (x== 591 ) {pset(surface, 186 , y_scaled, color1);}
if (x== 593 ) {pset(surface, 187 , y_scaled, color1);}
if (x== 595 ) {pset(surface, 188 , y_scaled, color1);}
if (x== 597 ) {pset(surface, 189 , y_scaled, color1);}
}}
if (x>599) {
if (x<623) {
if (x== 600 ) {pset(surface, 190 , y_scaled, color1);}
if (x== 602 ) {pset(surface, 191 , y_scaled, color1);}
if (x== 604 ) {pset(surface, 192 , y_scaled, color1);}
if (x== 606 ) {pset(surface, 193 , y_scaled, color1);}
if (x== 609 ) {pset(surface, 194 , y_scaled, color1);}
if (x== 611 ) {pset(surface, 195 , y_scaled, color1);}
if (x== 613 ) {pset(surface, 196 , y_scaled, color1);}
if (x== 615 ) {pset(surface, 197 , y_scaled, color1);}
if (x== 618 ) {pset(surface, 198 , y_scaled, color1);}
if (x== 620 ) {pset(surface, 199 , y_scaled, color1);}
if (x== 622 ) {pset(surface, 200 , y_scaled, color1);}
}}
if (x>623) {
if (x<650) {
if (x== 624 ) {pset(surface, 201 , y_scaled, color1);}
if (x== 627 ) {pset(surface, 202 , y_scaled, color1);}
if (x== 629 ) {pset(surface, 203 , y_scaled, color1);}
if (x== 631 ) {pset(surface, 204 , y_scaled, color1);}
if (x== 633 ) {pset(surface, 205 , y_scaled, color1);}
if (x== 635 ) {pset(surface, 206 , y_scaled, color1);}
if (x== 638 ) {pset(surface, 207 , y_scaled, color1);}
if (x== 640 ) {pset(surface, 208 , y_scaled, color1);}
if (x== 642 ) {pset(surface, 209 , y_scaled, color1);}
if (x== 644 ) {pset(surface, 210 , y_scaled, color1);}
if (x== 647 ) {pset(surface, 211 , y_scaled, color1);}
if (x== 649 ) {pset(surface, 212 , y_scaled, color1);}
}}
if (x>650) {
if (x<674) {

if (x== 651 ) {pset(surface, 213 , y_scaled, color1);}
if (x== 653 ) {pset(surface, 214 , y_scaled, color1);}
if (x== 656 ) {pset(surface, 215 , y_scaled, color1);}
if (x== 658 ) {pset(surface, 216 , y_scaled, color1);}
if (x== 660 ) {pset(surface, 217 , y_scaled, color1);}
if (x== 663 ) {pset(surface, 218 , y_scaled, color1);}
if (x== 665 ) {pset(surface, 219 , y_scaled, color1);}
if (x== 667 ) {pset(surface, 220 , y_scaled, color1);}
if (x== 669 ) {pset(surface, 221 , y_scaled, color1);}
if (x== 671 ) {pset(surface, 222 , y_scaled, color1);}
if (x== 673 ) {pset(surface, 223 , y_scaled, color1);}
}} }

if (x>675) {
if (x<699) {

if (x== 676 ) {pset(surface, 224 , y_scaled, color1);}
if (x== 678 ) {pset(surface, 225 , y_scaled, color1);}
if (x== 680 ) {pset(surface, 226 , y_scaled, color1);}
if (x== 682 ) {pset(surface, 227 , y_scaled, color1);}
if (x== 685 ) {pset(surface, 228 , y_scaled, color1);}
if (x== 687 ) {pset(surface, 229 , y_scaled, color1);}
if (x== 689 ) {pset(surface, 230 , y_scaled, color1);}
if (x== 691 ) {pset(surface, 231 , y_scaled, color1);}
if (x== 694 ) {pset(surface, 232 , y_scaled, color1);}
if (x== 696 ) {pset(surface, 233 , y_scaled, color1);}
if (x== 698 ) {pset(surface, 234 , y_scaled, color1);}
}}
if (x>699) {
if (x<724) {
if (x== 700 ) {pset(surface, 235 , y_scaled, color1);}
if (x== 703 ) {pset(surface, 236 , y_scaled, color1);}
if (x== 705 ) {pset(surface, 237 , y_scaled, color1);}
if (x== 707 ) {pset(surface, 238 , y_scaled, color1);}
if (x== 709 ) {pset(surface, 239 , y_scaled, color1);}
if (x== 711 ) {pset(surface, 240 , y_scaled, color1);}
if (x== 714 ) {pset(surface, 241 , y_scaled, color1);}
if (x== 716 ) {pset(surface, 242 , y_scaled, color1);}
if (x== 718 ) {pset(surface, 243 , y_scaled, color1);}
if (x== 720 ) {pset(surface, 244 , y_scaled, color1);}
if (x== 723 ) {pset(surface, 245 , y_scaled, color1);}
}}
if (x>724) {
if (x<750) {
if (x== 725 ) {pset(surface, 246 , y_scaled, color1);}
if (x== 727 ) {pset(surface, 247 , y_scaled, color1);}
if (x== 729 ) {pset(surface, 248 , y_scaled, color1);}
if (x== 732 ) {pset(surface, 249 , y_scaled, color1);}
if (x== 734 ) {pset(surface, 250 , y_scaled, color1);}
if (x== 736 ) {pset(surface, 251 , y_scaled, color1);}
if (x== 738 ) {pset(surface, 252 , y_scaled, color1);}
if (x== 741 ) {pset(surface, 253 , y_scaled, color1);}
if (x== 743 ) {pset(surface, 254 , y_scaled, color1);}
if (x== 745 ) {pset(surface, 255 , y_scaled, color1);}
if (x== 747 ) {pset(surface, 256 , y_scaled, color1);}
if (x== 749 ) {pset(surface, 257 , y_scaled, color1);}
}}} else {
if (x>751) {
if (x<775) {
if (x== 752 ) {pset(surface, 258 , y_scaled, color1);}
if (x== 754 ) {pset(surface, 259 , y_scaled, color1);}
if (x== 756 ) {pset(surface, 260 , y_scaled, color1);}
if (x== 758 ) {pset(surface, 261 , y_scaled, color1);}
if (x== 761 ) {pset(surface, 262 , y_scaled, color1);}
if (x== 763 ) {pset(surface, 263 , y_scaled, color1);}
if (x== 765 ) {pset(surface, 264 , y_scaled, color1);}
if (x== 767 ) {pset(surface, 265 , y_scaled, color1);}
if (x== 770 ) {pset(surface, 266 , y_scaled, color1);}
if (x== 772 ) {pset(surface, 267 , y_scaled, color1);}
if (x== 774 ) {pset(surface, 268 , y_scaled, color1);}
}}
if (x>775) {
if (x>775) {
if (x<800) {

if (x== 776 ) {pset(surface, 269 , y_scaled, color1);}
if (x== 778 ) {pset(surface, 270 , y_scaled, color1);}
if (x== 781 ) {pset(surface, 271 , y_scaled, color1);}
if (x== 783 ) {pset(surface, 272 , y_scaled, color1);}
if (x== 785 ) {pset(surface, 273 , y_scaled, color1);}
if (x== 787 ) {pset(surface, 274 , y_scaled, color1);}
if (x== 790 ) {pset(surface, 275 , y_scaled, color1);}
if (x== 792 ) {pset(surface, 276 , y_scaled, color1);}
if (x== 794 ) {pset(surface, 277 , y_scaled, color1);}
if (x== 796 ) {pset(surface, 278 , y_scaled, color1);}
if (x== 799 ) {pset(surface, 279 , y_scaled, color1);}
}}
if (x>800) {
if (x<822) {
if (x== 801 ) {pset(surface, 280 , y_scaled, color1);}
if (x== 803 ) {pset(surface, 281 , y_scaled, color1);}
if (x== 805 ) {pset(surface, 282 , y_scaled, color1);}
if (x== 808 ) {pset(surface, 283 , y_scaled, color1);}
if (x== 810 ) {pset(surface, 284 , y_scaled, color1);}
if (x== 812 ) {pset(surface, 285 , y_scaled, color1);}
if (x== 814 ) {pset(surface, 286 , y_scaled, color1);}
if (x== 817 ) {pset(surface, 287 , y_scaled, color1);}
if (x== 819 ) {pset(surface, 288 , y_scaled, color1);}
if (x== 821 ) {pset(surface, 289 , y_scaled, color1);}
}}
if (x>822) {
if (x<849) {
if (x== 823 ) {pset(surface, 290 , y_scaled, color1);}
if (x== 825 ) {pset(surface, 291 , y_scaled, color1);}
if (x== 828 ) {pset(surface, 292 , y_scaled, color1);}
if (x== 830 ) {pset(surface, 293 , y_scaled, color1);}
if (x== 832 ) {pset(surface, 294 , y_scaled, color1);}
if (x== 834 ) {pset(surface, 295 , y_scaled, color1);}
if (x== 837 ) {pset(surface, 296 , y_scaled, color1);}
if (x== 839 ) {pset(surface, 297 , y_scaled, color1);}
if (x== 841 ) {pset(surface, 298 , y_scaled, color1);}
if (x== 843 ) {pset(surface, 299 , y_scaled, color1);}
if (x== 846 ) {pset(surface, 300 , y_scaled, color1);}
if (x== 848 ) {pset(surface, 301 , y_scaled, color1);}
}}
if (x>849) {
if (x<864) {
if (x== 850 ) {pset(surface, 302 , y_scaled, color1);}
if (x== 852 ) {pset(surface, 303 , y_scaled, color1);}
if (x== 854 ) {pset(surface, 304 , y_scaled, color1);}
if (x== 857 ) {pset(surface, 305 , y_scaled, color1);}
if (x== 859 ) {pset(surface, 306 , y_scaled, color1);}
if (x== 861 ) {pset(surface, 307 , y_scaled, color1);}
if (x== 863 ) {pset(surface, 308 , y_scaled, color1);}

}}
if (x>865) {
if (x<889) {

if (x== 866 ) {pset(surface, 309 , y_scaled, color1);}
if (x== 868 ) {pset(surface, 310 , y_scaled, color1);}
if (x== 870 ) {pset(surface, 311 , y_scaled, color1);}
if (x== 872 ) {pset(surface, 312 , y_scaled, color1);}
if (x== 875 ) {pset(surface, 313 , y_scaled, color1);}
if (x== 877 ) {pset(surface, 314 , y_scaled, color1);}
if (x== 879 ) {pset(surface, 315 , y_scaled, color1);}
if (x== 881 ) {pset(surface, 316 , y_scaled, color1);}
if (x== 884 ) {pset(surface, 317 , y_scaled, color1);}
if (x== 886 ) {pset(surface, 318 , y_scaled, color1);}
if (x== 888 ) {pset(surface, 319 , y_scaled, color1);}
}}}}}}

x++;
if( hsync ) {
ref_len++;
if( ref_len > 30 && x > 700 ) {
// pset(surface, x_scaled, y, 5);
y++;
x = 0;
}
} else {
ref_len = 0;
}
}}



SDL_DestroyWindow( window );
SDL_Quit();

return 0;
}

Reply 175 of 212, by root42

User metadata
Rank l33t
Rank
l33t

Would be good if you could fork my git repo and submit your code into your own repo. That will make an eventual merge and cleanup operation easier than copying from this thread. 😀 Nice work though!

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC

Reply 176 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t

Thanks..all based on your nice work..!

Unfortunately I have no idea how git works.... 😉

Do you know how I can resize the window from 640x350 to 320x200 without closing it? I tried
SDL_SetWindowSize(window,320,200);
...but this also scales the content down.

Also played with
SDL_RenderSetLogicalSize(ren, 320,200);
SDL_RenderSetScale(ren, 1,1);
...without success.

Reply 177 of 212, by root42

User metadata
Rank l33t
Rank
l33t
Predator99 wrote on 2020-08-04, 10:02:
Thanks..all based on your nice work..! […]
Show full quote

Thanks..all based on your nice work..!

Unfortunately I have no idea how git works.... 😉

Do you know how I can resize the window from 640x350 to 320x200 without closing it? I tried
SDL_SetWindowSize(window,320,200);
...but this also scales the content down.

Also played with
SDL_RenderSetLogicalSize(ren, 320,200);
SDL_RenderSetScale(ren, 1,1);
...without success.

We probably want to create a second texture for that and set that as the render surface. When I am back from vacation I will have a look.

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC

Reply 178 of 212, by Predator99

User metadata
Rank l33t
Rank
l33t
Predator99 wrote on 2020-08-03, 20:54:
Short description how it works: The reason that I had to switch the programs between 640 and 320 pixel modes (or exactly: 350 or […]
Show full quote

Short description how it works:
The reason that I had to switch the programs between 640 and 320 pixel modes (or exactly: 350 or 200 lines) was
Mode 1 = LINES: 200, H.SYNC: positive at 15.7 kHz, V.SYNC: positive at 60 Hz
Mode 2 = LINES: 350, H.SYNC: positive at 21.85 kHz, V.SYNC: negative at 60 Hz

Therefore the VSYNC is inverted between the modes and the next frame is not detected correctly. I implemented a VSYNC-counter ("mode_det") which sums up all values for "vsync" within a frame. This value is printed and you can see a clear difference when switching modes.

So if it is between 380000-400000 I define its a 320 pixel mode, everything else is 640 for the moment. I think this concept can be enhanced also for all other resolution and it will also help to implement a autodetection of the sigrok sample-rate...

So this doesnt seem to work as epxected. It seems not to be possible to distinguish between 320x200 and 640x200 resolution based on HSYNC or VSYNC data. Its the same for both resolutions. There are only more pixels per line in 640 mode.
Need another method for this...

Reply 179 of 212, by root42

User metadata
Rank l33t
Rank
l33t
Predator99 wrote on 2020-08-05, 10:01:

So this doesnt seem to work as epxected. It seems not to be possible to distinguish between 320x200 and 640x200 resolution based on HSYNC or VSYNC data. Its the same for both resolutions. There are only more pixels per line in 640 mode.
Need another method for this...

True, the distinction works only for 200 vs. 350 lines modes. 640 and 320 are the same modes just with a different pixel clock. However that’s a signal not available on the EGA connector. You could create a heuristic that tries to figure out the mode, but it will never be perfect.

YouTube and Bonus
80486DX@33 MHz, 16 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & GUSar Lite, PC MIDI Card+X2+SC55+MT32, OSSC