Skip to content
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

Turn raylib usage into interfaces #7

Closed
delaneyj opened this issue Dec 12, 2024 · 4 comments
Closed

Turn raylib usage into interfaces #7

delaneyj opened this issue Dec 12, 2024 · 4 comments

Comments

@delaneyj
Copy link

delaneyj commented Dec 12, 2024

Is like to use to make examples for my project, https://data-star.dev and NATS. Basically a live twitch play like thing but without websockets or any user js. Was going to fork but would you be interested in a PR if successful?

@maxpoletaev
Copy link
Owner

Sounds interesting! Could you please give more details on what exactly you are trying to achieve?

Getting rid of raylib should be pretty easy, and you don't actually need to abstract it. The emulation itself does not depend on raylib, so in theory, you can "go get" this package and only use its core components to access the frame buffer and input devices but implement your own rendering and input handling on top of that.

That's basically means re-implementing cmd/dendy/offline.go for a different rendering backend. A very simplified version of this might be:

package main

import (
    "github.com/maxpoletaev/dendy/ines"
    "github.com/maxpoletaev/dendy/input"
    "github.com/maxpoletaev/dendy/system"
)

rom, _ := ines.OpenROM(romFile)
cart, _ := ines.NewCartridge(rom)
joy1 := input.NewJoystick()
nes := system.New(cart, joy1, nil)

for {
    nes.Tick()
    if nes.FrameReady() {
       renderFrame(nes.Frame())
       buttons := readPlayerInput()
       joy1.SetButtons(buttons)
   }
}

@maxpoletaev
Copy link
Owner

maxpoletaev commented Dec 14, 2024

I've actually had this in mind for a very long time for the wasm renderer, but never got to work on it

@maxpoletaev
Copy link
Owner

Yep, runs fine in a browser https://maxpoletaev.github.io/dendy/

@delaneyj
Copy link
Author

delaneyj commented Jan 6, 2025

Awesome thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants