Skip to content

Commit

Permalink
Implement more syscalls (#79)
Browse files Browse the repository at this point in the history
This pull-request adds implementation of some trivial/simple/fake
BIOS syscalls.
  • Loading branch information
skx authored May 18, 2024
1 parent b470520 commit e35e2f6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
20 changes: 20 additions & 0 deletions cpm/cpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,26 @@ func New(logger *slog.Logger, prn string) *CPM {
Handler: BiosSysCallPrintChar,
Fake: true,
}
b[15] = CPMHandler{
Desc: "LISTST",
Handler: BiosSysCallPrinterStatus,
Fake: true,
}
b[17] = CPMHandler{
Desc: "CONOST",
Handler: BiosSysCallScreenOutputStatus,
Fake: true,
}
b[18] = CPMHandler{
Desc: "AUXIST",
Handler: BiosSysCallAuxInputStatus,
Fake: true,
}
b[19] = CPMHandler{
Desc: "AUXOST",
Handler: BiosSysCallAuxOutputStatus,
Fake: true,
}

// Create the emulator object and return it
tmp := &CPM{
Expand Down
40 changes: 40 additions & 0 deletions cpm/cpm_bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,46 @@ func BiosSysCallPrintChar(cpm *CPM) error {
return err
}

// BiosSysCallPrinterStatus returns status of current printer device.
//
// This is fake, and always returns "ready".
func BiosSysCallPrinterStatus(cpm *CPM) error {

// Ready
cpm.CPU.States.AF.Hi = 0xFF
return nil
}

// BiosSysCallScreenOutputStatus returns status of current screen output device.
//
// This is fake, and always returns "ready".
func BiosSysCallScreenOutputStatus(cpm *CPM) error {

// Ready
cpm.CPU.States.AF.Hi = 0xFF
return nil
}

// BiosSysCallAuxInputStatus returns status of current auxiliary input device.
//
// This is fake, and always returns "ready".
func BiosSysCallAuxInputStatus(cpm *CPM) error {

// Ready
cpm.CPU.States.AF.Hi = 0xFF
return nil
}

// BiosSysCallAuxOutputStatus returns status of current auxiliary output device.
//
// This is fake, and always returns "ready".
func BiosSysCallAuxOutputStatus(cpm *CPM) error {

// Ready
cpm.CPU.States.AF.Hi = 0xFF
return nil
}

// BiosHandler is involved when a BIOS syscall needs to be executed,
// which is handled via a small trampoline.
//
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {

// Now show them.
fmt.Printf("BDOS\n")
for id := range ids {
for _, id := range ids {
ent := c.BDOSSyscalls[uint8(id)]
fake := ""
if ent.Fake {
Expand All @@ -84,7 +84,7 @@ func main() {

// Now show them.
fmt.Printf("BIOS\n")
for id := range ids {
for _, id := range ids {
ent := c.BIOSSyscalls[uint8(id)]
fake := ""
if ent.Fake {
Expand Down

0 comments on commit e35e2f6

Please sign in to comment.