https://github.com/sysl-dev/loving-2bpp
A Library for Love2D to read 2BPP (Console/Handheld) Graphics
https://github.com/sysl-dev/loving-2bpp
gameboy image love2d lua nes
Last synced: 6 months ago
JSON representation
A Library for Love2D to read 2BPP (Console/Handheld) Graphics
- Host: GitHub
- URL: https://github.com/sysl-dev/loving-2bpp
- Owner: sysl-dev
- License: mit
- Created: 2023-08-27T22:10:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-27T22:11:51.000Z (over 2 years ago)
- Last Synced: 2025-03-22T13:23:18.398Z (about 1 year ago)
- Topics: gameboy, image, love2d, lua, nes
- Language: Lua
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## Loving 2BPP
This is a small library for Love2D to render 2BPP data into the ImageData format for whatever you want to do with it.
Included with this library is:
- An example of 2bpp graphics
- A **Very Cursed Method** to read the data.
### Using Loving 2BPP
```lua
-- Require the library
local loving_2bpp = require("loving2bpp")
-- Read in the file
loving_2bpp.read("2bpp.txt")
-- Choose a tile or a page to render
-- Page example
local page = love.graphics.newImage(loving_2bpp.render_page(1))
-- Tile Example
local tile = love.graphics.newImage(loving_2bpp.convert_tile(1))
-- Then, once done you can draw it like a normal image/split it with quads/etc
function love.draw()
love.graphics.print("This is so cursed.")
love.graphics.draw(tile, 20, 20, 0, 4, 4)
end
```
### Config
Change the values directly:
```lua
loving_2bpp.config = {
page_size = 256 * 8, -- 256 per line
block_size = 16, -- (Tile Layer A, Tile Layer B)
max_size = 1000000, -- 1MB Max Size Import Default
mode = "console", -- Console or Handheld, each has different types of 2BPP rendering.
}
```
### Read more about the 2BPP format for Console and Handheld
- https://www.huderlem.com/demos/gameboy2bpp.html
- https://sneslab.net/wiki/Graphics_Format#How_It_Works (This explains it close enough, just up to the 2bpp part)