Skip to content

Commit

Permalink
Pick lint
Browse files Browse the repository at this point in the history
  • Loading branch information
smoynes committed Nov 9, 2023
1 parent 7346e50 commit dca72fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/vm/disp.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ func (driver *DisplayDriver) Init(vm *LC3, addrs []Word) {

// Read gets the status of the display device. Reading any other address returns an error.
func (driver *DisplayDriver) Read(addr Word) (Word, error) {
switch addr { //golint:exhaustive
case driver.statusAddr:
if addr == driver.statusAddr {
return Word(driver.handle.device.DSR()), nil
case driver.dataAddr:
} else if addr == driver.dataAddr {
return Word(driver.handle.device.Read()), nil
default:
} else {
return Word(0xdea1), fmt.Errorf("read: %w: %s:%s", ErrNoDevice, addr, driver)
}
}
Expand All @@ -180,14 +179,13 @@ func (driver *DisplayDriver) InterruptRequested() bool {

// Write sets the data register of the display device. Writing any other address returns an error.
func (driver *DisplayDriver) Write(addr Word, value Register) error {
switch addr {
case driver.dataAddr:
if addr == driver.dataAddr {
driver.handle.device.Write(value)
return nil
case driver.statusAddr:
} else if addr == driver.statusAddr {
driver.handle.device.SetDSR(value)
return nil
default:
} else {
return fmt.Errorf("write: %w: %s:%s", ErrNoDevice, addr, driver)
}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/vm/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (mmio MMIO) PSR() ProcessorStatus {
// DDR returns the value of the display data register, if it has been mapped.
func (mmio MMIO) DDR() rune {
ddr := rune('⍝')

if dev := mmio.devs[DDRAddr]; dev != nil {
val := dev.(*DisplayDriver)
ddr = rune(val.handle.device.ddr)
Expand All @@ -152,6 +153,7 @@ func (mmio MMIO) DDR() rune {
// DDR returns the value of the display status register, if it has been mapped.
func (mmio MMIO) DSR() Word {
dsr := Word('⍝')

if dev := mmio.devs[DSRAddr]; dev != nil {
val := dev.(*DisplayDriver)
dsr = Word(val.handle.device.dsr)
Expand All @@ -163,6 +165,7 @@ func (mmio MMIO) DSR() Word {
// KBDR returns the value of the keyboard data register, if it has been mapped.
func (mmio MMIO) KBDR() Word {
kbdr := Word('⍝')

if dev := mmio.devs[KBDRAddr]; dev != nil {
val := dev.(*Keyboard)
kbdr = Word(val.KBDR)
Expand All @@ -174,6 +177,7 @@ func (mmio MMIO) KBDR() Word {
// KBSR returns the value of the keyboard status register, if it has been mapped.
func (mmio MMIO) KBSR() Word {
kbsr := Word('⍝')

if dev := mmio.devs[KBSRAddr]; dev != nil {
val := dev.(*Keyboard)
kbsr = Word(val.KBSR)
Expand Down

0 comments on commit dca72fe

Please sign in to comment.