Skip to content
This repository
Browse code

Minor update to WOS search, run gofmt

  • Loading branch information...
commit 3c15915e88517b04f243f383837b262666da3721 1 parent 5f06655
Tul project tul-project authored
2  .gitignore
... ... @@ -1,3 +1 @@
1   -*~
2   -gospeccy
3 1 scripts/startup_local*
3  src/gospeccy/gospeccy.go
@@ -35,6 +35,7 @@ import (
35 35 "github.com/remogatto/gospeccy/src/formats"
36 36 "github.com/remogatto/gospeccy/src/interpreter"
37 37 "github.com/remogatto/gospeccy/src/spectrum"
  38 + "net/url"
38 39 "os"
39 40 pathutil "path"
40 41 "runtime"
@@ -270,7 +271,7 @@ func main() {
270 271 }
271 272 } else if *wos != "" {
272 273 var records []spectrum.WosRecord
273   - records, err := spectrum.WosQuery(app, *wos)
  274 + records, err := spectrum.WosQuery(app, "regexp="+url.QueryEscape(strings.Replace(*wos, " ", "*", -1)))
274 275 if err != nil {
275 276 app.PrintfMsg("%s", err)
276 277 exit(app)
9 src/interpreter/functions.go
@@ -7,6 +7,8 @@ import (
7 7 "github.com/remogatto/gospeccy/src/formats"
8 8 "github.com/remogatto/gospeccy/src/spectrum"
9 9 "io/ioutil"
  10 + "net/url"
  11 + "strings"
10 12 "time"
11 13 )
12 14
@@ -247,7 +249,7 @@ func wrapper_wait(t *eval.Thread, in []eval.Value, out []eval.Value) {
247 249 func wrapper_script(t *eval.Thread, in []eval.Value, out []eval.Value) {
248 250 scriptName := in[0].(eval.StringValue).Get(t)
249 251
250   - err := runScript(w, scriptName, /*optional*/ false)
  252 + err := runScript(w, scriptName, false /*optional*/)
251 253 if err != nil {
252 254 fmt.Fprintf(stdout, "%s\n", err)
253 255 return
@@ -258,7 +260,7 @@ func wrapper_script(t *eval.Thread, in []eval.Value, out []eval.Value) {
258 260 func wrapper_optionalScript(t *eval.Thread, in []eval.Value, out []eval.Value) {
259 261 scriptName := in[0].(eval.StringValue).Get(t)
260 262
261   - err := runScript(w, scriptName, /*optional*/ true)
  263 + err := runScript(w, scriptName, true /*optional*/)
262 264 if err != nil {
263 265 fmt.Fprintf(stdout, "%s\n", err)
264 266 return
@@ -346,9 +348,10 @@ func wrapper_wosFind(t *eval.Thread, in []eval.Value, out []eval.Value) {
346 348 }
347 349
348 350 pattern := in[0].(eval.StringValue).Get(t)
  351 + pattern = strings.Replace(pattern, " ", "*", -1)
349 352
350 353 var records []spectrum.WosRecord
351   - records, err := spectrum.WosQuery(app, pattern)
  354 + records, err := spectrum.WosQuery(app, "regexp="+url.QueryEscape(pattern))
352 355 if err != nil {
353 356 fmt.Fprintf(stdout, "%s", err)
354 357
4 src/interpreter/interpreter.go
@@ -209,7 +209,7 @@ func (i *Interpreter) compile(w *eval.World, fileSet *token.FileSet, sourceCode
209 209 // For each successfully found/verified variable, the variable's name is added to 'i.vars'.
210 210 func (i *Interpreter) tryToAddVars(w *eval.World, fileSet *token.FileSet, vars []string) {
211 211 for _, name := range vars {
212   - _, err := w.Compile(fileSet, /*sourceCode*/ name)
  212 + _, err := w.Compile(fileSet, name /*sourceCode*/)
213 213 if err == nil {
214 214 // The variable exists, add its name to 'i.vars'
215 215 i.vars[name] = true
@@ -281,7 +281,7 @@ func Init(_app *spectrum.Application, _cmdLineArg string, _speccy *spectrum.Spec
281 281
282 282 // Run the startup script
283 283 var err error
284   - err = runScript(w, STARTUP_SCRIPT, /*optional*/ IgnoreStartupScript)
  284 + err = runScript(w, STARTUP_SCRIPT, IgnoreStartupScript /*optional*/)
285 285 if err != nil {
286 286 app.PrintfMsg("%s", err)
287 287 app.RequestExit()
2  src/output/sdl/sdl.go
@@ -10,10 +10,10 @@ import (
10 10 "fmt"
11 11 "github.com/0xe2-0x9a-0x9b/Go-SDL/sdl"
12 12 "github.com/0xe2-0x9a-0x9b/Go-SDL/ttf"
  13 + "github.com/remogatto/clingon"
13 14 "github.com/remogatto/gospeccy/src/env"
14 15 "github.com/remogatto/gospeccy/src/interpreter"
15 16 "github.com/remogatto/gospeccy/src/spectrum"
16   - "github.com/remogatto/clingon"
17 17 "reflect"
18 18 "sync"
19 19 )
4 src/output/sdl/sdl_display.go
@@ -230,7 +230,7 @@ func (display *SDLScreen) render(screen *spectrum.DisplayData) {
230 230 screen.CompletionTime_orNil <- time.Now()
231 231 }
232 232
233   - SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, /*scale*/ 1, display.updatedRectsCh)
  233 + SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, 1 /*scale*/, display.updatedRectsCh)
234 234 unscaledDisplay.releaseMemory()
235 235
236 236 }
@@ -325,7 +325,7 @@ func (display *SDLScreen2x) render(screen *spectrum.DisplayData) {
325 325 screen.CompletionTime_orNil <- time.Now()
326 326 }
327 327
328   - SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, /*scale*/ 2, display.updatedRectsCh)
  328 + SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, 2 /*scale*/, display.updatedRectsCh)
329 329 unscaledDisplay.releaseMemory()
330 330 }
331 331
1  src/output/sdl/sdl_display_test.go
@@ -14,7 +14,6 @@ import (
14 14 //"unsafe"
15 15 )
16 16
17   -
18 17 // func (s *SDLSurface) At(x, y int) image.Color {
19 18 // var bpp = int(s.surface.Format.BytesPerPixel)
20 19
6 src/spectrum/helpers.go
@@ -137,7 +137,7 @@ func SystemRomPath(fileName string) (string, error) {
137 137 var (
138 138 currDir = "roms"
139 139 userDir = path.Join(DefaultUserDir, "roms")
140   - srcDir = path.Join(srcDir, "roms")
  140 + srcDir = path.Join(srcDir, "roms")
141 141 )
142 142
143 143 var paths []string
@@ -161,7 +161,7 @@ func ScriptPath(fileName string) (string, error) {
161 161 var (
162 162 currDir = "scripts"
163 163 userDir = path.Join(DefaultUserDir, "scripts")
164   - srcDir = path.Join(srcDir, "scripts")
  164 + srcDir = path.Join(srcDir, "scripts")
165 165 )
166 166
167 167 var paths []string
@@ -185,7 +185,7 @@ func FontPath(fileName string) (string, error) {
185 185 var (
186 186 currDir = "fonts"
187 187 userDir = path.Join(DefaultUserDir, "fonts")
188   - srcDir = path.Join(srcDir, "fonts")
  188 + srcDir = path.Join(srcDir, "fonts")
189 189 )
190 190
191 191 var paths []string
6 src/spectrum/wos.go
@@ -14,7 +14,7 @@ import (
14 14
15 15 var (
16 16 fileSuffixes = []string{".tap.zip", ".sna.zip", ".z80.zip"}
17   - queryBaseURL = "http://www.worldofspectrum.org/infoseek.cgi?regexp="
  17 + queryBaseURL = "http://www.worldofspectrum.org/infoseek.cgi?"
18 18 )
19 19
20 20 func knownType(filename string) bool {
@@ -40,7 +40,7 @@ func WosQuery(app *Application, query string) ([]WosRecord, error) {
40 40 client := new(http.Client)
41 41 query = queryBaseURL + query
42 42 if app.Verbose {
43   - app.PrintfMsg("Query string: %s", query)
  43 + app.PrintfMsg("WOS query: %s", query)
44 44 app.PrintfMsg("Fetching...")
45 45 }
46 46 response, err := client.Get(query)
@@ -54,7 +54,7 @@ func WosQuery(app *Application, query string) ([]WosRecord, error) {
54 54 return nil, err
55 55 }
56 56 if app.Verbose {
57   - app.PrintfMsg(response.Status)
  57 + app.PrintfMsg("Response status: %s", response.Status)
58 58 }
59 59
60 60 var matches []WosRecord
4 src/spectrum/z80.go
@@ -137,7 +137,7 @@ func NewZ80(memory MemoryAccessor, ports PortAccessor) *Z80 {
137 137 z80.iy = register16{&z80.iyh, &z80.iyl}
138 138 z80.de_ = register16{&z80.d_, &z80.e_}
139 139
140   - z80.perfCounter_hostCpuInstr, _ = perf.NewCounter_Instructions( /*user*/ true, /*kernel*/ false)
  140 + z80.perfCounter_hostCpuInstr, _ = perf.NewCounter_Instructions(true /*user*/, false /*kernel*/)
141 141
142 142 return z80
143 143 }
@@ -220,7 +220,7 @@ func (z80 *Z80) loadSnapshot(s formats.Snapshot) error {
220 220 z80.sp = cpu.SP
221 221
222 222 // Border color
223   - z80.ports.writePortInternal(0xfe, ula.Border&0x07, /*contend*/ false)
  223 + z80.ports.writePortInternal(0xfe, ula.Border&0x07, false /*contend*/)
224 224
225 225 // Populate memory
226 226 copy(z80.memory.Data()[0x4000:], mem[:])
6 src/spectrum/z80_test.go
@@ -279,7 +279,7 @@ func TestDoOpcodes(t *testing.T) {
279 279 // Instantiate a Z80 processor
280 280 z80 := NewZ80(&memory, &port)
281 281 ula := NewULA()
282   - z80.init(ula, /*tapeDrive_orNil*/ nil)
  282 + z80.init(ula, nil /*tapeDrive_orNil*/)
283 283 ula.init(z80, &memory, &port)
284 284
285 285 memory.z80 = z80
@@ -393,7 +393,7 @@ func TestDoOpcodes(t *testing.T) {
393 393 byte := memWrites[i]
394 394 if byte != "-1" {
395 395 value, _ := strconv.ParseUint(byte, 16, 0)
396   - z80.memory.Write(uint16(addr), uint8(value), /*protectROM*/ false)
  396 + z80.memory.Write(uint16(addr), uint8(value), false /*protectROM*/)
397 397 addr++
398 398 }
399 399 }
@@ -496,7 +496,7 @@ func BenchmarkZ80(b *testing.B) {
496 496
497 497 for i := 0; i < b.N; i++ {
498 498 speccy.CommandChannel <- Cmd_RenderFrame{CompletionTime_orNil: nil}
499   - //speccy.renderFrame(/*completionTime_orNil*/ nil)
  499 + //speccy.renderFrame(nil /*completionTime_orNil*/)
500 500 }
501 501
502 502 app.RequestExit()
4 src/test/test.go
@@ -3,11 +3,11 @@ package test
3 3 import (
4 4 "github.com/0xe2-0x9a-0x9b/Go-SDL/sdl"
5 5 "github.com/0xe2-0x9a-0x9b/Go-SDL/ttf"
  6 + "github.com/remogatto/clingon"
6 7 "github.com/remogatto/gospeccy/src/formats"
7 8 "github.com/remogatto/gospeccy/src/interpreter"
8 9 output "github.com/remogatto/gospeccy/src/output/sdl"
9 10 "github.com/remogatto/gospeccy/src/spectrum"
10   - "github.com/remogatto/clingon"
11 11 "github.com/remogatto/prettytest"
12 12 "io/ioutil"
13 13 )
@@ -246,7 +246,7 @@ Welcome to the GoSpeccy CLI Testing Mode
246 246 ----------------------------------------
247 247 `)
248 248 }
249   - audio, err := output.NewSDLAudio(app, output.PLAYBACK_FREQUENCY, /*hqAudio*/ true)
  249 + audio, err := output.NewSDLAudio(app, output.PLAYBACK_FREQUENCY, true /*hqAudio*/)
250 250 if err == nil {
251 251 speccy.CommandChannel <- spectrum.Cmd_AddAudioReceiver{audio}
252 252 } else {

0 comments on commit 3c15915

Please sign in to comment.
Something went wrong with that request. Please try again.