You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
// Draw a red square on the GameBoy Advance screen after waiting for a period of time
import (
"image/color"
"machine"
"time"
)
var display = machine.Display
func main() {
display.Configure()
//Try to sleep with function
time.Sleep(10 * time.Second)
//Try to sleep with while
now := time.Now().Unix()
for (time.Now().Unix() - now) < 1000000 {
_ = 0
}
//Draw a red square
for x := int16(30); x < 50; x++ {
for y := int16(80); y < 100; y++ {
display.SetPixel(x, y, color.RGBA{255, 0, 0, 255})
}
}
display.Display()
}
Expected result: There is some sort of delay before drawing the red square
Actual result: The red square is drawn immediately
Tested behavior in m-gba, visualboy advance, iodine, gbajs, and even on a legitimate Gameboy Advance SP using a flash cart.
It seems like I must be missing something obvious because this should be extremely straightforward to perform. Is time just not working for this target?
The text was updated successfully, but these errors were encountered:
In the example I hook machine.IRQ_VBLANK which fires the interrupt handler roughly 59.71540070833901659232620059483728860926694 times a second. Working backward from that, you can make your own timer.
I may submit a PR to hook the actual IRQ_TIMER0 in a way that "time" will work, but for now this is a valid workaround and I'm closing this. Thanks to all who worked on the interrupts API.
tinygo build -target gameboy-advance -o .\timetest.gba timetest.go
Expected result: There is some sort of delay before drawing the red square
Actual result: The red square is drawn immediately
Tested behavior in m-gba, visualboy advance, iodine, gbajs, and even on a legitimate Gameboy Advance SP using a flash cart.
It seems like I must be missing something obvious because this should be extremely straightforward to perform. Is time just not working for this target?
The text was updated successfully, but these errors were encountered: