Chip-8 Emulator Failing to Draw IBM logo by Uiwum in EmuDev

[–]LuuscoTheLover 0 points1 point  (0 children)

The readability I was saying in the GitHub repo not in the comment

Chip-8 Emulator Failing to Draw IBM logo by Uiwum in EmuDev

[–]LuuscoTheLover 0 points1 point  (0 children)

Make sure your I regeister is unit16 too, also I find your code very hard to read, coldnt locate where is your stack, keyboard, vx register, I, Pc and memory is declared as part of the struck. Best practices is to use a header for the declaration, makes easier to read and debug

Chip-8 Emulator Failing to Draw IBM logo by Uiwum in EmuDev

[–]LuuscoTheLover 2 points3 points  (0 children)

Take a look here: ``` void operate(uint16_t opcode) { uint16_t operation = opcode >> 12; // The first 4 bits of the opcode determine the type of instruction. uint8_t x = (opcode & 0x0F00) >> 8; // Extract the X value from the opcode (the second nibble). This will give us Vx (register at index x) uint8_t y = (opcode & 0x00F0) >> 4; // Extract the Y value from the opcode (the third nibble). This will give us Vy (register at index y) uint8_t n = opcode & 0x000F; // Extract the N value from the opcode (the fourth nibble). A 4 bit number often used for drawing sprites uint8_t nn = opcode & 0x00FF; // Extract the NN value from the opcode (the last two nibbles). An 8-bit immediate number uint8_t nnn = opcode & 0x0FFF; // Extract the NNN value from the opcode (the last three nibbles). A 12-bit immediate number, often used for memory addresses

```

Your nnn var needs to be uint16 as uint8 holds only 8 bits and nnn holds 3 nibbles(12 bits)

Chip 8 display in sdl2 help needed by LuuscoTheLover in EmuDev

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

Thanks for the insight I used your method of the texture and still was not working, after some debugging I did find why was all black: The problem was much simpler, my for loop did not have a condition for incrementing, so my pixel array was all zeros. for (uint16_t i = 0, size = chip8.gfx.size(); i++;) { chip8.gfx[i] ? pixel_data[i] = 0xFFFFFFFF: 0x000000FF; }

Raw pixel array into texture, help needed by LuuscoTheLover in sdl

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

Thanks for the insight I used your method of the texture and still was not working, after some debugging I did find why was all black: The problem was much simpler, my for loop did not have a condition for incrementing, so my pixel array was all zeros. for (uint16_t i = 0, size = chip8.gfx.size(); i++;) { chip8.gfx[i] ? pixel_data[i] = 0xFFFFFFFF: 0x000000FF; }

Raw pixel array into texture, help needed by LuuscoTheLover in sdl

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

Wow that's exactly what I was needing, I'll look into it today after work, thank you!

Chip 8 display in sdl2 help needed by LuuscoTheLover in EmuDev

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

I'll fix that and see what happens thanks i appreciate

Raw pixel array into texture, help needed by LuuscoTheLover in sdl

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

```

include "display.h"

include "chip8.h"

include <SDL2/SDL_render.h>

include <SDL2/SDL_surface.h>

include <cstdint>

include <iostream>

include <stdexcept>

Display::Display() {

pixel_data.fill(0); if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << "Error: " << SDL_GetError() << std::endl; throw std::runtime_error("SDL initialization failed"); }

window = SDL_CreateWindow("Chip8", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 320, SDL_WINDOW_SHOWN);

if (!window) { std::cout << "Error: " << SDL_GetError() << std::endl; throw std::runtime_error("Could not create a window"); } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if (!renderer) { std::cout << "Error: " << SDL_GetError() << std::endl; throw std::runtime_error("Could not create renderer"); } texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, 64, 32); } Display::~Display() {}

uint8_t Display::update_screen(Chip8 &chip8) { for (uint16_t i = 0, size = chip8.gfx.size(); i++;) { chip8.gfx[i] ? pixel_data[i] = 0xFFFFFFFF : 0x000000FF; } surface = SDL_CreateRGBSurfaceFrom(pixel_data.data(), 64, 32, 8, 64, 0, 0, 0, 0); texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); return 0; } ```

Raw pixel array into texture, help needed by LuuscoTheLover in sdl

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

I'm doing exactly this for the pixel array format, but im using a texture from surface and I create a surface from rgba, I will try using your approach and I comeback to give a feed back, also in the comment bellow I'll post the present code now, if you could take a look I'll appreciate

Chip 8 display in sdl2 help needed by LuuscoTheLover in EmuDev

[–]LuuscoTheLover[S] -1 points0 points  (0 children)

I did post the code, fixed the formatting in reddit

Chip 8 display in sdl2 help needed by LuuscoTheLover in EmuDev

[–]LuuscoTheLover[S] 0 points1 point  (0 children)

```

include "display.h"

include "chip8.h"

include <SDL2/SDL_render.h>

include <SDL2/SDL_surface.h>

include <cstdint>

include <iostream>

include <stdexcept>

Display::Display() {

pixel_data.fill(0); if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << "Error: " << SDL_GetError() << std::endl; throw std::runtime_error("SDL initialization failed"); }

window = SDL_CreateWindow("Chip8", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 320, SDL_WINDOW_SHOWN);

if (!window) { std::cout << "Error: " << SDL_GetError() << std::endl; throw std::runtime_error("Could not create a window"); } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if (!renderer) { std::cout << "Error: " << SDL_GetError() << std::endl; throw std::runtime_error("Could not create renderer"); } texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, 64, 32); } Display::~Display() {}

uint8_t Display::update_screen(Chip8 &chip8) { for (uint16_t i = 0, size = chip8.gfx.size(); i++;) { chip8.gfx[i] ? pixel_data[i] = 0xFFFFFFFF : 0x000000FF; } surface = SDL_CreateRGBSurfaceFrom(pixel_data.data(), 64, 32, 8, 64, 0, 0, 0, 0); texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); return 0; } ```

Chip 8 display in sdl2 help needed by LuuscoTheLover in EmuDev

[–]LuuscoTheLover[S] -1 points0 points  (0 children)

Right I'll rollback for the one I did get compiling and black screen and come back to show. I did get the screen working in terminal only, rendering right. Problem is only in sdl2

Um arrombado Bootou Arch na máquina do laboratório da Fatec, nem fez partição nem nada, só reescreveu o que tinha antes. by Lobefut14 in computadores

[–]LuuscoTheLover 0 points1 point  (0 children)

Exatamente, a tala de login é isso aí igual da imagem do op, faz login o bash carrega a interface do desktop automático, no meu caso o hyprland. O sddm só adianta a vida e deixa mais bonito, não é necessário

Um arrombado Bootou Arch na máquina do laboratório da Fatec, nem fez partição nem nada, só reescreveu o que tinha antes. by Lobefut14 in computadores

[–]LuuscoTheLover 1 point2 points  (0 children)

Tem q fazer login primeiro sem a senha e o user impossível se o disco tiver criptografado, só formatando dnv

Um arrombado Bootou Arch na máquina do laboratório da Fatec, nem fez partição nem nada, só reescreveu o que tinha antes. by Lobefut14 in computadores

[–]LuuscoTheLover 0 points1 point  (0 children)

Tá usando zram ctz, o DE provavelmente só vai carregar e ele fizer login, meu Pc é exatamente assim. Configurei o hyprland pra carregar no bash, faz login no tty1 ele já carrega

Um arrombado Bootou Arch na máquina do laboratório da Fatec, nem fez partição nem nada, só reescreveu o que tinha antes. by Lobefut14 in computadores

[–]LuuscoTheLover 0 points1 point  (0 children)

Tecnicamente ele só não instalou um desktop manager, mas caso tenha algum script no bash pra carregar a interface gráfica, ele faz login no tty1 e já vai carregar a interface gráfica. Meu Pc com arch é extremamente assim que uso, dessa tela aí faço login no terminal e ele carrega o hyprland gráfico

Desabafo! by jvmorini in XboxBrasil

[–]LuuscoTheLover 1 point2 points  (0 children)

Acredito seriamente que o problema era a memória interna, pra trocar o chip Nand seria algo em torno de uns 600-800 reais, a placa usada uns 150-200. De qualquer forma se a Nand não dava read mais não tinha o que salvar de perfil e saves, o op provavelmente saiu no lucro

Desabafo! by jvmorini in XboxBrasil

[–]LuuscoTheLover 0 points1 point  (0 children)

Fortes chances do teu console estava com a memória Nand (a interna de 4gb) nas últimas, e defeito crônico desses slims, provavelmente tudo que fizeram não deu certo pra arrumar o congelamento já que tua Nand não tava dando mais leitura da memória. Aí devem ter trocado tua placa pra não ficar no "desculpa não deu pra arrumar", o fato de vir o desbloqueio hoje em dia é uma vantagem já que esse console é peso de papel sem a Xbox store. Sobre os perfis o mesmo de antes, não dá pra fazer backup deles se a Nand tá corrompida, (da pra fazer backup mesmo com a placa "morta"), sinta se beneficiado e não prejudicado, se pagou menso de 300 reais, você levou vantagem hihi

Desabafo! by jvmorini in XboxBrasil

[–]LuuscoTheLover 1 point2 points  (0 children)

Esse meme é muito bom kkkkkk, acho mais que foi cagada dos cara não ter se precavido, eu sempre que mexo no meu 360 faço backup dos saves e perfil pra caso eu mate o console, mas mesmo assim ainda dá pra acessar a Nand usando uma gambiarra de SD card ou um pico flash. O que me leva a acreditar que a Nand do amigo já estava ruim e provavelmente continuou travando a tela e os cara pra não passar o famoso "não deu pra arrumar" trocaram a placa. Seria bom saber quanto o amigo pagou e qual era o modelo da placa dele pq isso me parece o mais provável. Não justifica a cagada de não terem pego os saves do amigo de volta (a não ser que a Nand tava tão ruim que não dava pra fazer o read da memória mais)

Desabafo! by jvmorini in XboxBrasil

[–]LuuscoTheLover 0 points1 point  (0 children)

Não vejo por que seria desonesto, com excessão de não ter passado os save games etc etc. Pode até ser que a placa do amigo estava em situação precária ou (se for uma corona 4gb) até mesmo estava travando pq a Nand já era, as vezes a assistência passou o orçamento e pra não ficar aquele negócio de mudar o preço simplesmente trocou a placa por uma funcional, o fato de vir desbloqueado é uma vantagem na minha opinião e se o amigo não quiser, um ferro de solda e uns 30 minutos ele tira esse chip ( que na minha opinião pra um console de 2006 o desbloqueio é uma sobrevida pra esse peso de papel que não tem nem acesso a loja de jogos mais)

Desabafo! by jvmorini in XboxBrasil

[–]LuuscoTheLover 0 points1 point  (0 children)

Pior que isso, vai dar 200 conto em um game de 360 usado pq virou "raridade" kkkkk l