Use non-compressed DSK images with http links. Valid also with ROMs
This commit is contained in:
parent
f53b849a52
commit
67a92895b3
|
@ -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)
|
||||
|
||||
|
|
17
resources.go
17
resources.go
|
@ -3,6 +3,7 @@ package apple2
|
|||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
@ -11,12 +12,19 @@ import (
|
|||
|
||||
const (
|
||||
internalPrefix = "<internal>/"
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue