mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 21:09:02 +00:00
machine/gba: rename display and make pointer receivers
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -38,27 +38,27 @@ func (p Pin) Set(value bool) {
|
|||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
var Display = FramebufDisplay{(*[160][240]volatile.Register16)(unsafe.Pointer(uintptr(gba.MEM_VRAM)))}
|
var Display = DisplayMode3{(*[160][240]volatile.Register16)(unsafe.Pointer(uintptr(gba.MEM_VRAM)))}
|
||||||
|
|
||||||
type FramebufDisplay struct {
|
type DisplayMode3 struct {
|
||||||
port *[160][240]volatile.Register16
|
port *[160][240]volatile.Register16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d FramebufDisplay) Configure() {
|
func (d *DisplayMode3) Configure() {
|
||||||
// Use video mode 3 (in BG2, a 16bpp bitmap in VRAM) and Enable BG2
|
// Use video mode 3 (in BG2, a 16bpp bitmap in VRAM) and Enable BG2
|
||||||
gba.DISP.DISPCNT.Set(gba.DISPCNT_BGMODE_3<<gba.DISPCNT_BGMODE_Pos |
|
gba.DISP.DISPCNT.Set(gba.DISPCNT_BGMODE_3<<gba.DISPCNT_BGMODE_Pos |
|
||||||
gba.DISPCNT_SCREENDISPLAY_BG2_ENABLE<<gba.DISPCNT_SCREENDISPLAY_BG2_Pos)
|
gba.DISPCNT_SCREENDISPLAY_BG2_ENABLE<<gba.DISPCNT_SCREENDISPLAY_BG2_Pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d FramebufDisplay) Size() (x, y int16) {
|
func (d *DisplayMode3) Size() (x, y int16) {
|
||||||
return 240, 160
|
return 240, 160
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d FramebufDisplay) SetPixel(x, y int16, c color.RGBA) {
|
func (d *DisplayMode3) SetPixel(x, y int16, c color.RGBA) {
|
||||||
d.port[y][x].Set((uint16(c.R) >> 3) | ((uint16(c.G) >> 3) << 5) | ((uint16(c.B) >> 3) << 10))
|
d.port[y][x].Set((uint16(c.R) >> 3) | ((uint16(c.G) >> 3) << 5) | ((uint16(c.B) >> 3) << 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d FramebufDisplay) Display() error {
|
func (d *DisplayMode3) Display() error {
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user