diff --git a/README.md b/README.md index caa361b..d07a17a 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ casa@servidor:~$ ./apple2sdl ![DOS 3.3 started](doc/dos33.png) ### Play games -Download an DSK file ([Asimov](https://mirrors.apple2.org.za/ftp.apple.asimov.net/images/) is an excellent source) and use the `-disk` parameter. +Download an DSK file locally or use the a link ([Asimov](https://www.apple.asimov.net/images/) is an excellent source) with the `-disk` parameter: ``` -casa@servidor:~$ ./apple2sdl -disk ~/Downloads/karateka.dsk +casa@servidor:~$ ./apple2sdl -disk "https://www.apple.asimov.net/images/games/action/karateka/karateka (includes intro).dsk" ``` ![Karateka](doc/karateka.png) diff --git a/resources.go b/resources.go index 93e5afb..5d70838 100644 --- a/resources.go +++ b/resources.go @@ -3,6 +3,7 @@ package apple2 import ( "io" "io/ioutil" + "net/http" "os" "strings" @@ -11,12 +12,19 @@ import ( const ( internalPrefix = "/" + httpPrefix = "http://" + httpsPrefix = "https://" ) func isInternalResource(filename string) bool { return strings.HasPrefix(filename, internalPrefix) } +func isHTTPResource(filename string) bool { + return strings.HasPrefix(filename, httpPrefix) || + strings.HasPrefix(filename, httpsPrefix) +} + func loadResource(filename string) []uint8 { var file io.Reader if isInternalResource(filename) { @@ -28,6 +36,15 @@ func loadResource(filename string) []uint8 { } defer resourceFile.Close() file = resourceFile + + } else if isHTTPResource(filename) { + response, err := http.Get(filename) + if err != nil { + panic(err) + } + defer response.Body.Close() + file = response.Body + } else { diskFile, err := os.Open(filename) if err != nil {