Skip to content

Half Shape (320 x 240) instead of (640x480) in Saturn Game #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
paulo101977 opened this issue Mar 26, 2025 · 5 comments
Open

Half Shape (320 x 240) instead of (640x480) in Saturn Game #137

paulo101977 opened this issue Mar 26, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@paulo101977
Copy link

paulo101977 commented Mar 26, 2025

I was trying to train using the Virtual Fighter 2 environment on Saturn, and I came across a problem: the observations are appearing cut off. The image frame is cut off. I believe the resolution of the original game would be around 640x480, but the shape is showing in the observation as 320x240.

I used the code below to do the preliminary work of doing the training:

import retro
from stable_baselines3.common.atari_wrappers import ClipRewardEnv, WarpFrame
from gymnasium.wrappers import RecordVideo
import cv2
import numpy as np
import matplotlib.pyplot as plt

def preprocess_observation(obs):
    resized = cv2.resize(obs, (640, 480))
    
    padded = cv2.copyMakeBorder(resized, 20, 20, 10, 10, cv2.BORDER_CONSTANT, value=[0, 0, 0])

    return padded

env = retro.make(
    game="VirtuaFighter2-Saturn",
    render_mode="human",
    inttype=retro.data.Integrations.ALL,
)


# env = display.GameDisplayEnv(env)
env = WarpFrame(env)

obs = env.reset()

while True:
    env.render()
    action = env.action_space.sample()
    env.render()
    observation, reward, terminated, truncated, info = env.step(action)
    processed = preprocess_observation(observation)
    
    
    cv2.imshow("Processed Frame", processed)
    cv2.waitKey(1)
    
    
    if terminated or truncated:
        break
env.close()
cv2.destroyAllWindows()

Images of the problem:

Image

Image

Image

@MatPoliquin MatPoliquin self-assigned this Mar 28, 2025
@MatPoliquin MatPoliquin added the bug Something isn't working label Mar 28, 2025
@MatPoliquin
Copy link
Collaborator

Thanks for the report, I will try to repro on my setup. In the meantime have you tried Virtual Fighter on the Sega 32x?

@paulo101977
Copy link
Author

Thanks for the report, I will try to repro on my setup. In the meantime have you tried Virtual Fighter on the Sega 32x?

Thanks!!!!
Yes, I tested Virtual Fighter 32x. With the default state, there was a strange behavior, at first it rendered well until the beginning of the fight. When the fight started, the fighters disappeared. Fortunately, I know how to use the integration tool and generated a new state. Regarding the resolution, it is rendering normally.

@paulo101977
Copy link
Author

@MatPoliquin I was integrating the retroarch_system
PS1 emulator, but the same problem happened. I think I'll investigate it on my part. As for my integration, I think I'll open a PR after I add some games...
Image

@paulo101977
Copy link
Author

@MatPoliquin I solved the problem here, but I only tested it on the PS1 emulator that I'm integrating. This change is in emulator.cpp

void Emulator::cbVideoRefresh(const void* data, unsigned width, unsigned height, size_t pitch) {
	assert(s_loadedEmulator);

	if (data) {
		s_loadedEmulator->m_imgData = data;
	}
	if (pitch) {
		s_loadedEmulator->m_imgPitch = pitch;
	}


	s_loadedEmulator -> m_avInfo.geometry.base_width = width;
	s_loadedEmulator -> m_avInfo.geometry.base_height = height;

}

@paulo101977
Copy link
Author

VirtuaFighter2-Saturn
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants