package main // c64 player dependencies //import "io" //import "os" //import "bytes" //import "mime/multipart" import "fmt" //import "net/http" import "net/url" import "strconv" import "log" import "github.com/hypebeast/go-osc/osc" // C64 object type C64 struct { u1541_host string } func (c64 *C64) reset(msg *osc.Message) { if _, err := put(c64.u1541_host+"/v1/machine:reset"); err != nil { log.Print(err) } } func (c64 *C64) reboot(msg *osc.Message) { if _, err := put(c64.u1541_host+"/v1/machine:reboot"); err != nil { log.Print(err) } } func (c64 *C64) runPRG(msg *osc.Message) { params := url.Values{} params.Add("file", getOSC[string](msg)) if _, err := put(c64.u1541_host+"/v1/runners:run_prg?" + params.Encode()); err != nil { log.Print(err) } } func (c64 *C64) insertDisk(msg *osc.Message) { params := url.Values{} params.Add("image", getOSC[string](msg)) if _, err := put(c64.u1541_host+"/v1/drives/a:mount?" + params.Encode()); err != nil { log.Print(err) } } func (c64 *C64) sidplay(msg *osc.Message) { params := url.Values{} params.Add("file", getOSC[string](msg)) if songnr := getOSC[int](msg); songnr != 0 { params.Add("songnr", strconv.Itoa(songnr)) } if _, err := put(c64.u1541_host+"/v1/runners:sidplay?" + params.Encode()); err != nil { log.Print(err) } } // Send key strokes via Keyboardcache func (c64 *C64) sendKeys(msg *osc.Message) { // Load buffer for _, char := range getOSC[string](msg) { params := url.Values{} params.Add("address", "277") params.Add("data", fmt.Sprintf("%02x", char)) log.Printf("sent %02x", char) if _, err := put(c64.u1541_host+"/v1/machine:writemem?" + params.Encode()); err != nil { log.Print(err) return } params = url.Values{} params.Add("address", "c6") params.Add("data", "01") if _, err := put(c64.u1541_host+"/v1/machine:writemem?" + params.Encode()); err != nil { log.Print(err) return } } }