mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
machine, runtime/interrupt: switch to use register definitions from device/gba
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
package machine
|
||||
|
||||
import (
|
||||
"device/gba"
|
||||
|
||||
"image/color"
|
||||
"runtime/interrupt"
|
||||
"runtime/volatile"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -16,40 +17,37 @@ const deviceName = "GBA"
|
||||
// Interrupt numbers as used on the GameBoy Advance. Register them with
|
||||
// runtime/interrupt.New.
|
||||
const (
|
||||
IRQ_VBLANK = interrupt.IRQ_VBLANK
|
||||
IRQ_HBLANK = interrupt.IRQ_HBLANK
|
||||
IRQ_VCOUNT = interrupt.IRQ_VCOUNT
|
||||
IRQ_TIMER0 = interrupt.IRQ_TIMER0
|
||||
IRQ_TIMER1 = interrupt.IRQ_TIMER1
|
||||
IRQ_TIMER2 = interrupt.IRQ_TIMER2
|
||||
IRQ_TIMER3 = interrupt.IRQ_TIMER3
|
||||
IRQ_COM = interrupt.IRQ_COM
|
||||
IRQ_DMA0 = interrupt.IRQ_DMA0
|
||||
IRQ_DMA1 = interrupt.IRQ_DMA1
|
||||
IRQ_DMA2 = interrupt.IRQ_DMA2
|
||||
IRQ_DMA3 = interrupt.IRQ_DMA3
|
||||
IRQ_KEYPAD = interrupt.IRQ_KEYPAD
|
||||
IRQ_GAMEPAK = interrupt.IRQ_GAMEPAK
|
||||
IRQ_VBLANK = gba.IRQ_VBLANK
|
||||
IRQ_HBLANK = gba.IRQ_HBLANK
|
||||
IRQ_VCOUNT = gba.IRQ_VCOUNT
|
||||
IRQ_TIMER0 = gba.IRQ_TIMER0
|
||||
IRQ_TIMER1 = gba.IRQ_TIMER1
|
||||
IRQ_TIMER2 = gba.IRQ_TIMER2
|
||||
IRQ_TIMER3 = gba.IRQ_TIMER3
|
||||
IRQ_COM = gba.IRQ_COM
|
||||
IRQ_DMA0 = gba.IRQ_DMA0
|
||||
IRQ_DMA1 = gba.IRQ_DMA1
|
||||
IRQ_DMA2 = gba.IRQ_DMA2
|
||||
IRQ_DMA3 = gba.IRQ_DMA3
|
||||
IRQ_KEYPAD = gba.IRQ_KEYPAD
|
||||
IRQ_GAMEPAK = gba.IRQ_GAMEPAK
|
||||
)
|
||||
|
||||
// Make it easier to directly write to I/O RAM.
|
||||
var ioram = (*[0x400]volatile.Register8)(unsafe.Pointer(uintptr(0x04000000)))
|
||||
|
||||
// Set has not been implemented.
|
||||
func (p Pin) Set(value bool) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
var Display = FramebufDisplay{(*[160][240]volatile.Register16)(unsafe.Pointer(uintptr(0x06000000)))}
|
||||
var Display = FramebufDisplay{(*[160][240]volatile.Register16)(unsafe.Pointer(uintptr(gba.MEM_VRAM)))}
|
||||
|
||||
type FramebufDisplay struct {
|
||||
port *[160][240]volatile.Register16
|
||||
}
|
||||
|
||||
func (d FramebufDisplay) Configure() {
|
||||
// Write into the I/O registers, setting video display parameters.
|
||||
ioram[0].Set(0x03) // Use video mode 3 (in BG2, a 16bpp bitmap in VRAM)
|
||||
ioram[1].Set(0x04) // Enable BG2 (BG0 = 1, BG1 = 2, BG2 = 4, ...)
|
||||
// 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.DISPCNT_SCREENDISPLAY_BG2_ENABLE<<gba.DISPCNT_SCREENDISPLAY_BG2_Pos)
|
||||
}
|
||||
|
||||
func (d FramebufDisplay) Size() (x, y int16) {
|
||||
|
||||
Reference in New Issue
Block a user