(tickInterval <-chan time.Time, printStateConfig PrintStateConfig)
| 91 | } |
| 92 | |
| 93 | func (c *SimpleComputer) Run(tickInterval <-chan time.Time, printStateConfig PrintStateConfig) { |
| 94 | log.Println("Starting computer....") |
| 95 | c.putValueInRAM(0xFEFE, 0x0040) //JMP back to code region start if IAR reaches the end |
| 96 | c.putValueInRAM(0xFEFF, CODE_REGION_START) |
| 97 | |
| 98 | // start at offet of user code |
| 99 | c.cpu.SetIAR(CODE_REGION_START) |
| 100 | go c.screenControl.Run() |
| 101 | |
| 102 | steps := 0 |
| 103 | for { |
| 104 | <-tickInterval |
| 105 | c.cpu.Step() |
| 106 | |
| 107 | if printStateConfig.PrintState { |
| 108 | if steps%printStateConfig.PrintStateEvery == 0 { |
| 109 | fmt.Println("COMPUTER\n-----------------------------------------------------------") |
| 110 | fmt.Printf("Cycle count = %d, step count = %d, printing state every %d steps\n\n", steps/6, steps, printStateConfig.PrintStateEvery) |
| 111 | fmt.Println("CPU\n----------------------------------------") |
| 112 | fmt.Println(c.cpu.String()) |
| 113 | fmt.Println() |
| 114 | } |
| 115 | } |
| 116 | steps++ |
| 117 | } |
| 118 | } |
nothing calls this directly
no test coverage detected