Skip to content

Commit

Permalink
some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Jul 29, 2024
1 parent 723eb11 commit 0598a8a
Show file tree
Hide file tree
Showing 40 changed files with 123 additions and 137 deletions.
4 changes: 2 additions & 2 deletions apple2Run.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func (a *Apple2) Start(paused bool) {
if !a.paused {
for i := 0; i < cpuSpinLoops; i++ {
// Conditional tracing
//pc, _ := a.cpu.GetPCAndSP()
//a.cpu.SetTrace(pc >= 0xc700 && pc < 0xc800)
// pc, _ := a.cpu.GetPCAndSP()
// a.cpu.SetTrace(pc >= 0xc700 && pc < 0xc800)

// Execution
a.cpu.ExecuteInstruction()
Expand Down
18 changes: 8 additions & 10 deletions boardAppleII.go → boardApple2.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const (
ioFlagAnnunciator2 uint8 = 0x5c
ioFlagAnnunciator3 uint8 = 0x5e

//ioDataCassette uint8 = 0x60
//ioFlagButton0 uint8 = 0x61
//ioFlagButton1 uint8 = 0x62
//ioFlagButton2 uint8 = 0x63
//ioDataPaddle0 uint8 = 0x64
//ioDataPaddle1 uint8 = 0x65
//ioDataPaddle2 uint8 = 0x66
//ioDataPaddle3 uint8 = 0x67
// ioDataCassette uint8 = 0x60
// ioFlagButton0 uint8 = 0x61
// ioFlagButton1 uint8 = 0x62
// ioFlagButton2 uint8 = 0x63
// ioDataPaddle0 uint8 = 0x64
// ioDataPaddle1 uint8 = 0x65
// ioDataPaddle2 uint8 = 0x66
// ioDataPaddle3 uint8 = 0x67

// Not real softSwitches. Using the numbers to store the flags somewhere.
ioFlagRGBCardActive uint8 = 0x7d
Expand Down Expand Up @@ -136,15 +136,13 @@ func buildKeySoftSwitch(io *ioC0Page) softSwitchR {
}
}
value := io.softSwitchesData[ioDataKeyboard]
//fmt.Printf("Key $%02x, %v\n", value, strobed)
return value
}
}

func buildStrobeKeyboardSoftSwitch(io *ioC0Page) softSwitchR {
return func() uint8 {
result := io.softSwitchesData[ioDataKeyboard]
//fmt.Printf("Strobe $%02x\n", result)
io.softSwitchesData[ioDataKeyboard] &^= 1 << 7
return result
}
Expand Down
10 changes: 5 additions & 5 deletions boardApple2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func addApple2ESoftSwitches(io *ioC0Page) {
return ssOff
}, "VERTBLANK")

//io.softSwitchesData[ioFlagAltChar] = ssOn // Not sure about this.
// io.softSwitchesData[ioFlagAltChar] = ssOn // Not sure about this.

}

func addSoftSwitchesMmu(io *ioC0Page, addressClear uint8, addressSet uint8, AddressGet uint8, flag *bool, name string) {
func addSoftSwitchesMmu(io *ioC0Page, addressClear uint8, addressSet uint8, addressGet uint8, flag *bool, name string) {
io.addSoftSwitchW(addressClear, func(uint8) {
*flag = false
}, name+"OFF")
Expand All @@ -70,12 +70,12 @@ func addSoftSwitchesMmu(io *ioC0Page, addressClear uint8, addressSet uint8, Addr
*flag = true
}, name+"ON")

io.addSoftSwitchR(AddressGet, func() uint8 {
io.addSoftSwitchR(addressGet, func() uint8 {
return ssFromBool(*flag)
}, name)
}

func addSoftSwitchesIou(io *ioC0Page, addressClear uint8, addressSet uint8, AddressGet uint8, ioFlag uint8, name string) {
func addSoftSwitchesIou(io *ioC0Page, addressClear uint8, addressSet uint8, addressGet uint8, ioFlag uint8, name string) {
io.addSoftSwitchW(addressClear, func(uint8) {
io.softSwitchesData[ioFlag] = ssOff
}, name+"OFF")
Expand All @@ -84,7 +84,7 @@ func addSoftSwitchesIou(io *ioC0Page, addressClear uint8, addressSet uint8, Addr
io.softSwitchesData[ioFlag] = ssOn
}, name+"ON")

io.addSoftSwitchR(AddressGet, func() uint8 {
io.addSoftSwitchR(addressGet, func() uint8 {
return io.softSwitchesData[ioFlag]
}, name)
}
9 changes: 0 additions & 9 deletions boardBase64a.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ package izapple2
Copam BASE64A adaptation.
*/

const (
// There are 6 ROM chips. Each can have 4Kb or 8Kb. They can fill
// 2 or 4 banks with 2kb windows.
base64aRomBankSize = 12 * 1024
base64aRomBankCount = 4
base64aRomWindowSize = 2 * 1024
base64aRomChipCount = 6
)

func loadBase64aRom(a *Apple2) error {
return loadMultiPageRom(a, []string{
"<internal>/BASE64A_D0.BIN",
Expand Down
1 change: 1 addition & 0 deletions boardBasis108.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (v *videoBasis108) GetCurrentVideoMode() uint32 {

isTextMode := v.a.io.isSoftSwitchActive(ioFlagText)
isHiResMode := v.a.io.isSoftSwitchActive(ioFlagHiRes)

if isTextMode {
mode |= screen.VideoText80
} else if isHiResMode {
Expand Down
2 changes: 1 addition & 1 deletion cardBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func getCardFactory() map[string]*cardBuilder {
cardFactory["parallel"] = newCardParallelPrinterBuilder()
cardFactory["prodosromdrive"] = newCardProDOSRomDriveBuilder()
cardFactory["prodosromcard3"] = newCardProDOSRomCard3Builder()
//cardFactory["prodosnvramdrive"] = newCardProDOSNVRAMDriveBuilder()
// cardFactory["prodosnvramdrive"] = newCardProDOSNVRAMDriveBuilder()
cardFactory["saturn"] = newCardSaturnBuilder()
cardFactory["smartport"] = newCardSmartPortStorageBuilder()
cardFactory["swyftcard"] = newCardSwyftBuilder()
Expand Down
7 changes: 3 additions & 4 deletions cardDan2Controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ func (c *CardDan2Controller) writeSoftSwitch(address uint8, data uint8) {
c.portC |= uint8(1) << bit
}
c.romCsxx.setPage((c.portC & 0x07) | ((c.portB << 4) & 0xf0))
} else {
if data != 0xfa {
c.tracef("Not supported status %v, it must be 0xfa\n", data)
}
} else if data != 0xfa {
c.tracef("Not supported status %v, it must be 0xfa\n", data)

/* Sets the 8255 with status 0xfa, 1111_1010:
1: set mode
11: port A mode 2
Expand Down
6 changes: 3 additions & 3 deletions cardDisk2DriveStepper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var cogPositions = []int{

func moveDriveStepper(phases uint8, prevStep int) int {

//fmt.Printf("magnets: 0x%x\n", phases)
// fmt.Printf("magnets: 0x%x\n", phases)

cogPosition := cogPositions[phases]
if cogPosition == undefinedPosition {
Expand All @@ -57,7 +57,7 @@ func moveDriveStepper(phases uint8, prevStep int) int {
prevPosition := prevStep % stepsPerGroup // Direction, step in the current group of magnets.
delta := cogPosition - prevPosition
if delta < 0 {
delta = delta + stepsPerGroup
delta += stepsPerGroup
}

var nextStep int
Expand All @@ -78,6 +78,6 @@ func moveDriveStepper(phases uint8, prevStep int) int {
}
}

//fmt.Printf("[DiskII] 1/4 track: %03d %vO\n", nextStep, strings.Repeat(" ", nextStep))
// fmt.Printf("[DiskII] 1/4 track: %03d %vO\n", nextStep, strings.Repeat(" ", nextStep))
return nextStep
}
7 changes: 3 additions & 4 deletions cardDisk2Sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type CardDisk2Sequencer struct {

// Shared methods between both versions on the Disk II card
type cardDisk2Shared interface {
//insertDiskette(drive int, ...)
setTrackTracer(tt trackTracer)
}

Expand Down Expand Up @@ -91,7 +90,7 @@ func newCardDisk2SequencerBuilder() *cardBuilder {
if c.sectors13 {
P5RomFile = "<internal>/Apple Disk II 13 Sector Interface Card ROM P5 - 341-0009.bin"
// Buggy sequencer not need for 13 sectors disks to work
//P6RomFile = "<internal>/Apple Disk II 13 Sector Interface Card ROM P6 - 341-0010.bin"
// P6RomFile = "<internal>/Apple Disk II 13 Sector Interface Card ROM P6 - 341-0010.bin"
}

err := c.loadRomFromResource(P5RomFile, cardRomSimple)
Expand Down Expand Up @@ -308,7 +307,7 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool {
c.register = (c.register << 1) | ((inst >> 2) & 1)
case 2:
// Shift right bringing wProt
c.register = c.register >> 1
c.register >>= 1
if wProt {
c.register |= 0x80
}
Expand All @@ -327,7 +326,7 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool {
}
}

//fmt.Printf("[D2SEQ] Step. seq:%x inst:%x next:%x reg:%02x\n",
// fmt.Printf("[D2SEQ] Step. seq:%x inst:%x next:%x reg:%02x\n",
// c.sequence, inst, next, c.register)

c.sequence = next
Expand Down
6 changes: 3 additions & 3 deletions cardInOut.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func (c *CardInOut) assign(a *Apple2, slot int) {
if value&0x7f == 10 {
value = 13 + 0x80
}
//fmt.Printf("[cardInOut] Read access to softswith 0x%x for slot %v, value %x.\n", 0, slot, value)
// fmt.Printf("[cardInOut] Read access to softswith 0x%x for slot %v, value %x.\n", 0, slot, value)
return value
}, "INOUTR")
c.addCardSoftSwitchW(1, func(value uint8) {
//fmt.Printf("[cardInOut] Write access to softswith 0x%x for slot %v, value 0x%x: %v, %v.\n", 1, slot, value, value&0x7f, string(value&0x7f))
// fmt.Printf("[cardInOut] Write access to softswith 0x%x for slot %v, value 0x%x: %v, %v.\n", 1, slot, value, value&0x7f, string(value&0x7f))
if value&0x7f == 13 {
fmt.Printf("\n")
} else {
Expand All @@ -62,7 +62,7 @@ func (c *CardInOut) assign(a *Apple2, slot int) {
}, "INOUTW")

data := buildBaseInOutRom(slot)
c.romCsxx = newMemoryRangeROM(0xC200, data[:], "InOUt card")
c.romCsxx = newMemoryRangeROM(0xC200, data, "InOUt card")
c.cardBase.assign(a, slot)
}

Expand Down
2 changes: 1 addition & 1 deletion cardLanguage.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (c *CardLanguage) ssAction(ss uint8, write bool) {
c.readState = false
c.writeState = lcWriteDisabled
case 3:
//RAM read, RAM write
// RAM read, RAM write
c.readState = true
if !write {
c.writeState++
Expand Down
3 changes: 1 addition & 2 deletions cardMouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (c *CardMouse) assign(a *Apple2, slot int) {
}, "TIMEDATEMOUSE")

data := buildBaseInOutRom(slot)
c.romCsxx = newMemoryRangeROM(0xC200, data[:], "Mouse card")
c.romCsxx = newMemoryRangeROM(0xC200, data, "Mouse card")

// Identification as a mouse card
// From Technical Note Misc #8, "Pascal 1.1 Firmware Protocol ID Bytes":
Expand All @@ -253,7 +253,6 @@ func (c *CardMouse) assign(a *Apple2, slot int) {
data[0x0b] = 0x01
data[0x0c] = 0x20
// From "AppleMouse // User's Manual", Appendix B:
//data[0x0c] = 0x20
data[0xfb] = 0xd6

// Set 8 entrypoints to sofstwitches 2 to 1f
Expand Down
2 changes: 1 addition & 1 deletion cardParallelPrinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *CardParallelPrinter) assign(a *Apple2, slot int) {
func (c *CardParallelPrinter) printByte(value uint8) {
if c.ascii {
// As text the MSB has to be removed, but if done, graphics modes won't work
value = value & 0x7f // Remove the MSB bit
value &= 0x7f // Remove the MSB bit
}
c.file.Write([]byte{value})
}
2 changes: 1 addition & 1 deletion cardProDOSRomCard3.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *CardProDOSRomCard3) translateAddress(address uint16) int {
offset := address - 0xC800
pageAddress := int(c.bank&0x7FF) * 0x0800

//fmt.Printf("CardProDOSRomCard3.translateAddress: address=%04X, bank=%04X, offset=%04X, pageAddress=%08X\n", address, c.bank, offset, pageAddress)
// fmt.Printf("CardProDOSRomCard3.translateAddress: address=%04X, bank=%04X, offset=%04X, pageAddress=%08X\n", address, c.bank, offset, pageAddress)

return pageAddress + int(offset)
}
Expand Down
2 changes: 1 addition & 1 deletion cardProDOSRomDrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newCardProDOSRomDriveBuilder() *cardBuilder {
name: "ProDOS ROM Drive",
description: "A bootable 1 MB solid state disk by Terence Boldt",
defaultParams: &[]paramSpec{
//{"image", "ROM image with the ProDOS volume", "https://github.com/tjboldt/ProDOS-ROM-Drive/raw/v4.0/Firmware/GamesWithFirmware.po"},
// {"image", "ROM image with the ProDOS volume", "https://github.com/tjboldt/ProDOS-ROM-Drive/raw/v4.0/Firmware/GamesWithFirmware.po"},
{"image", "ROM image with the ProDOS volume", "https://github.com/Alex-Kw/ProDOS-ROM-Drive-Images/raw/main/ProDOS_2.4.3_TJ.po"},
},
buildFunc: func(params map[string]string) (Card, error) {
Expand Down
4 changes: 2 additions & 2 deletions cardSaturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *CardSaturn) ssAction(ss uint8) {
c.readState = false
c.writeState = lcWriteDisabled
case 3:
//RAM read, RAM write
// RAM read, RAM write
c.altBank = false
c.readState = true
c.writeState++
Expand Down Expand Up @@ -98,7 +98,7 @@ func (c *CardSaturn) ssAction(ss uint8) {
c.readState = false
c.writeState = lcWriteDisabled
case 11:
//RAM read, RAM write
// RAM read, RAM write
c.altBank = true
c.readState = true
c.writeState++
Expand Down
4 changes: 2 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func (a *Apple2) executeCommand(command command) {
switch command.getId() {
case CommandToggleSpeed:
if a.cycleDurationNs == 0 {
//fmt.Println("Slow")
// fmt.Println("Slow")
a.cycleDurationNs = 1000.0 / CPUClockMhz
} else {
//fmt.Println("Fast")
// fmt.Println("Fast")
a.cycleDurationNs = 0
}
case CommandShowSpeed:
Expand Down
2 changes: 1 addition & 1 deletion component/mc6845.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (m *MC6845) Write(rs bool, value uint8) {
} else if m.sel <= 15 {
// R0 to R15 are writable
m.reg[m.sel] = value
//fmt.Printf("Set %v to %v\n", m.sel, value)
// fmt.Printf("Set %v to %v\n", m.sel, value)
}
}

Expand Down
27 changes: 14 additions & 13 deletions component/microPD1990ac.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import (
)

/*
microPD1990ac Serial I/O Calendar Clock IC
See:
https://www.semiee.com/file/backup/NEC-D1990.pdf
microPD1990ac Serial I/O Calendar Clock IC
See:
Used by the ThunderClock+ real time clock card.
https://www.semiee.com/file/backup/NEC-D1990.pdf
The 40 bit register has 5 bytes (10 nibbles):
byte 4:
month, binary from 1 to 12
day of week, BCD 0 to 6
byte 3: day of month, BCD 1 to 31
byte 2: hour, BCD 0 to 23
byte 1: minute, BCD 0 to 59
byte 0: seconds, BCD 0 to 59
Used by the ThunderClock+ real time clock card.
The 40 bit register has 5 bytes (10 nibbles):
byte 4:
month, binary from 1 to 12
day of week, BCD 0 to 6
byte 3: day of month, BCD 1 to 31
byte 2: hour, BCD 0 to 23
byte 1: minute, BCD 0 to 59
byte 0: seconds, BCD 0 to 59
*/
type MicroPD1990ac struct {
clock bool // CLK state
Expand Down Expand Up @@ -55,7 +56,7 @@ func (m *MicroPD1990ac) In(clock bool, strobe bool, command uint8, dataIn bool)
m.loadTime()
default:
// Ignore unknown commands (like set time)
//panic(fmt.Sprintf("PD1990ac command %v not implemented.", m.command))
// panic(fmt.Sprintf("PD1990ac command %v not implemented.", m.command))
}
}

Expand Down
2 changes: 1 addition & 1 deletion e2e_woz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func testWoz(t *testing.T, sequencer bool, file string, expectedTracks []int, cy
t.Errorf("Quarter tracks, expected %#v, got %#v", expectedTracks, tt.quarterTracks)
}

//t.Errorf("Cycles: %d vs %d", at.a.cpu.GetCycles(), cycleLimit)
// t.Errorf("Cycles: %d vs %d", at.a.cpu.GetCycles(), cycleLimit)
}

const (
Expand Down
6 changes: 3 additions & 3 deletions frontend/a2fyne/fyneKeyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (k *keyboard) putKey(keyEvent *fyne.KeyEvent) {
*/

// Keys with control are not generating events in putKey()
//ctrl := k.controlLeft || k.controlRight
// ctrl := k.controlLeft || k.controlRight

result := uint8(0)
switch keyEvent.Name {
Expand Down Expand Up @@ -127,14 +127,14 @@ func (k *keyboard) putKey(keyEvent *fyne.KeyEvent) {
case fyne.KeyF11:
k.s.a.SendCommand(izapple2.CommandToggleCPUTrace)
case fyne.KeyF12:
//case fyne.KeyPrintScreen:
// case fyne.KeyPrintScreen:
err := screen.SaveSnapshot(k.s.a.GetVideoSource(), k.s.screenMode, "snapshot.png")
if err != nil {
fmt.Printf("Error saving snapshoot: %v.\n.", err)
} else {
fmt.Println("Saving snapshot")
}
//case fyne.KeyPause:
// case fyne.KeyPause:
// k.s.a.SendCommand(izapple2.CommandPauseUnpause)
}

Expand Down
Loading

0 comments on commit 0598a8a

Please sign in to comment.