Skip to content

Commit

Permalink
Warm boot on Ctrl-C at the start of a line #17
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Jun 22, 2024
1 parent fa15986 commit 7487c25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/bdos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ impl Bdos {
bdos_console::write_string(env, arg16);
},
10 => { // C_READSTR
bdos_console::read_string(env, arg16);
let result = bdos_console::read_string(env, arg16);
if result == ExecutionResult::Continue{
return result;
}
},
11 => { // C_STAT - Console status
res8 = Some(bdos_console::status(env));
Expand Down
12 changes: 10 additions & 2 deletions src/bdos_console.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use iz80::Machine;
use crate::ExecutionResult;

use super::bdos_environment::*;

pub fn read(env: &mut BdosEnvironment) -> u8 {
Expand Down Expand Up @@ -38,7 +40,7 @@ pub fn write_string(env: &mut BdosEnvironment, address: u16) {
}
}

pub fn read_string(env: &mut BdosEnvironment, address: u16) -> u8 {
pub fn read_string(env: &mut BdosEnvironment, address: u16) -> ExecutionResult {
// The Read Buffer function reads a line of edited console input into a
// buffer addressed by registers DE. Console input is terminated when either
// input buffer overflows or a carriage return or line-feed is typed. The
Expand All @@ -62,6 +64,12 @@ pub fn read_string(env: &mut BdosEnvironment, address: u16) -> u8 {
if ch == 10 || ch == 13 { // CR of LF
break;
}

// break on control-c at the start of the line
if ch == 3 && size == 0 {
return ExecutionResult::WarmBoot
}

if ch == 127 { // DEL
if size > 0 {
size -= 1;
Expand All @@ -79,7 +87,7 @@ pub fn read_string(env: &mut BdosEnvironment, address: u16) -> u8 {
}

env.machine.poke(address + 1, size);
size
ExecutionResult::Continue
}

pub fn status(env: &mut BdosEnvironment) -> u8 {
Expand Down

0 comments on commit 7487c25

Please sign in to comment.