@@ -4,37 +4,33 @@ import (
44 "flag"
55 "fmt"
66 r "github.com/lachee/raylib-goplus/raylib"
7+ "github.com/pkg/profile"
78 "github.com/raulferras/nes-golang/src/debugger"
89 "github.com/raulferras/nes-golang/src/graphics"
910 "github.com/raulferras/nes-golang/src/nes"
1011 "github.com/raulferras/nes-golang/src/nes/gamePak"
1112 "github.com/raulferras/nes-golang/src/nes/types"
1213 "github.com/raulferras/nes-golang/src/utils"
1314 "image"
14- "log"
1515 "math/rand"
1616 _ "net/http/pprof"
17- "os"
18- "runtime/pprof"
1917 "time"
2018)
2119
2220var cpuAdvance bool
2321
2422func main () {
25- /*
26- var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
27- var romPath = flag.String("rom", "", "path to rom")
28- var debugPPU = flag.Bool("debugPPU", false, "Displays PPU debug information")
29- flag.Parse()*/
30- cpuprofile , romPath , debugPPU , maxCPUCycle := cmdLineArguments ()
23+ scale , cpuprofile , romPath , debugPPU , maxCPUCycle := cmdLineArguments ()
3124 if cpuprofile != "" {
32- f , err := os .Create (cpuprofile )
25+ /* f, err := os.Create(cpuprofile)
3326 if err != nil {
3427 log.Fatal(err)
3528 }
3629 pprof.StartCPUProfile(f)
30+ pprof.
3731 defer pprof.StopCPUProfile()
32+ */
33+ defer profile .Start (profile .CPUProfile , profile .ProfilePath ("." )).Stop ()
3834 }
3935
4036 rand .Seed (time .Now ().UnixNano ())
@@ -71,11 +67,11 @@ func main() {
7167 ),
7268 )
7369
74- loop (console )
70+ loop (console , scale )
7571 r .CloseWindow ()
7672}
7773
78- func loop (console * nes.Nes ) {
74+ func loop (console * nes.Nes , scale int ) {
7975 cpuAdvance = true
8076 console .Start ()
8177 _timestamp := r .GetTime ()
@@ -130,12 +126,13 @@ func drawEmulation(frame *image.RGBA) {
130126 }
131127}
132128
133- func cmdLineArguments () (string , string , bool , int64 ) {
129+ func cmdLineArguments () (int , string , string , bool , int64 ) {
134130 var cpuprofile = flag .String ("cpuprofile" , "" , "write cpu profile to file" )
135131 var romPath = flag .String ("rom" , "" , "path to rom" )
136132 var debugPPU = flag .Bool ("debugPPU" , false , "Displays PPU debug information" )
137133 var stopAtCpuCycle = flag .Int64 ("maxCpuCycle" , - 1 , "stops emulation at given cpu cycle" )
134+ var scale = flag .Int ("scale" , 1 , "scale resolution" )
138135 flag .Parse ()
139136
140- return * cpuprofile , * romPath , * debugPPU , * stopAtCpuCycle
137+ return * scale , * cpuprofile , * romPath , * debugPPU , * stopAtCpuCycle
141138}
0 commit comments