Skip to content

Commit

Permalink
Merge pull request #20 from skx/19-reset
Browse files Browse the repository at this point in the history
Allow reseting drives by implementing DRV_ALLRESET
  • Loading branch information
skx authored Apr 15, 2024
2 parents 8f33088 + 9a09cc1 commit a64def2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpm/cpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func New(filename string, logger *slog.Logger) *CPM {
Desc: "C_READSTRING",
Handler: SysCallReadString,
}
sys[13] = CPMHandler{
Desc: "DRV_ALLRESET",
Handler: SysCallDriveAllReset,
}
sys[14] = CPMHandler{
Desc: "DRV_SET",
Handler: SysCallDriveSet,
Expand Down
14 changes: 14 additions & 0 deletions cpm/cpm_syscalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ func SysCallReadString(cpm *CPM) error {
return nil
}

// SysCallDriveAllReset resets the drives
func SysCallDriveAllReset(cpm *CPM) error {
if cpm.fileIsOpen {
cpm.fileIsOpen = false
cpm.file.Close()
}

cpm.currentDrive = 1
cpm.userNumber = 0

cpm.CPU.States.AF.Hi = 0x00
return nil
}

// SysCallDriveSet updates the current drive number
func SysCallDriveSet(cpm *CPM) error {
// The drive number passed to this routine is 0 for A:, 1 for B: up to 15 for P:.
Expand Down

0 comments on commit a64def2

Please sign in to comment.