.module OsCli ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.Execute === ; ; Executes an OS-level command. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to LF-terminated command string. ; ; OUTPUTS: ; REGISTERS ; * F - Carry set on error. ; * HL - Pointer to error descriptor on error. ; ; DESTROYED: ; REGISTERS ; * All registers are preserved by this function; they might not be by the ; commands that are executed in turn, however. ; ;@doc:end ;------------------------------------------------------------------------------- Execute push af - ld a,(hl) cp ' ' jr z,ExecuteSkipPrefix cp '*' jr nz,FoundCommand ExecuteSkipPrefix inc hl jr - FoundCommand ld (CurrentCommandLine),hl ld a,(hl) cp '|' jr nz,+ pop af ret + push hl push de push bc ; Check for empty commands. ld a,(hl) or a jr z,NoCommand ld de,Commands.Table ; Iterate over all possible commands. CheckNextCommand ld a,(de) or a jr z,CommandNotFound inc de push hl call CommandStartsWith ld (CommandLineArgs),hl pop hl dec de jr z,CommandFound ; Command doesn't match. ; Advance to point at next command... ld a,(de) push hl ld l,a ld h,0 add hl,de ex de,hl pop hl jr CheckNextCommand CommandFound ld a,(de) ld l,a ld h,0 add hl,de dec hl ld d,(hl) dec hl ld e,(hl) ld (CommandJumpVector+1),de ld a,$C3 ; JP nnnn ld (CommandJumpVector+0),a pop bc pop de pop hl pop af jp CommandJumpVector CommandNotFound pop bc pop de pop hl pop af scf ld hl,Errors.BadCommand ret NoCommand pop bc pop de pop hl pop af or a ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.CheckEndOfStatement === ; ; Checks that HL points to the end of a statement (whitespace is permitted). ; If not, bails out to CommandError. ; ;@doc:end ;------------------------------------------------------------------------------- CheckEndOfStatement ld a,(hl) inc hl or a ret z cp '\r' ret z cp ' ' jr z,CheckEndOfStatement cp '\r' jr z,CheckEndOfStatement pop hl jp CommandError CommandError ld hl,Errors.BadCommand scf ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.CommandStartsWith === ; ; Checks if a CR-terminated string pointed to by HL starts with the NUL- ; terminated string pointed to by DE. ; The string pointed to by HL may be in mixed case; the string pointed to by ; DE must be in uppercase. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to CR-terminated command-line string. ; * DE - Pointer to a NUL-terminated command to check against. ; ; OUTPUTS: ; REGISTERS ; * HL - Pointer to end of matched string. ; * F - Z is set if HL starts with DE. ; ; DESTROYED: ; REGISTERS ; * AF. ; ;@doc:end ;------------------------------------------------------------------------------- CommandStartsWith push de ex de,hl - ld a,(hl) or a jr z,CommandStartsWith.Exit ld a,(de) cp (hl) jr z,+ .fcall "Char.ToUpper" cp (hl) jr nz,CommandStartsWith.Exit + inc hl inc de jr - CommandStartsWith.Exit ex de,hl pop de ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.GetOnOff === ; ; Checks for an "ON" or "OFF" argument to a command. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to CR-terminated string that may end in ON or OFF. ; ; OUTPUTS: ; REGISTERS ; * F - C set on error; NZ if due to end of string, Z on invalid data. ; - C reset on error; NZ if ON, Z if OFF. ; ; DESTROYED: ; REGISTERS ; * AF, HL ; ;@doc:end ;------------------------------------------------------------------------------- GetOnOff ld a,(hl) inc hl cp '\r' jr nz,+ or a scf ret + cp ' ' jr z,GetOnOff cp 'O' jr z,+ xor a scf ret + ld a,(hl) cp 'N' jr z,GetOnOff.On cp 'F' jr z,GetOnOff.Off scf ret GetOnOff.On inc hl ld a,(hl) cp ' ' jr z,GetOnOff.On cp '\r' jr nz,GetOnOff.Error or a ret GetOnOff.Off inc hl ld a,(hl) cp 'F' jr nz,GetOnOff.Error - inc hl ld a,(hl) cp ' ' jr z,- cp '\r' jr nz,GetOnOff.Error xor a ret GetOnOff.Error xor a scf ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.SkipWhitespace === ; ; Skips leading whitespace. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to string containing potential whitespace. ; ; OUTPUTS: ; REGISTERS ; * HL - Pointer to start of non-whitespace characaters. ; ; DESTROYED: ; REGISTERS ; * AF ; ;@doc:end ;------------------------------------------------------------------------------- SkipWhitespace ld a,(hl) cp '\r' ret z cp ' ' ret nz inc hl jr SkipWhitespace ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.SkipComma === ; ; Skips whitespace and a comma. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to string containing potential comma. ; ; OUTPUTS: ; REGISTERS ; * HL - Pointer after comma. ; * F - Z set if a comma was found, NZ otherwise. ; ; DESTROYED: ; REGISTERS ; * AF ; ;@doc:end ;------------------------------------------------------------------------------- SkipComma call SkipWhitespace ld a,(hl) cp ',' ret nz inc hl ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.GetFilename === ; ; Gets a filename. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to CR-terminated string that contains a filename. ; ; OUTPUTS: ; REGISTERS ; * F - C set on error ; * HL - Points past filename on success; points to error descriptor on error. ; MEMORY ; * OP1 - Formatted TI-OS name of the variable. ; * OP2~OP3 - NUL-terminated string name of the file. ; ; DESTROYED: ; REGISTERS ; * AF, HL ; MEMORY ; * OP2, OP3 ; ;@doc:end ;------------------------------------------------------------------------------- GetFilename call SkipWhitespace ld a,(hl) cp '\r' jr nz,+ xor a dec a scf ld hl,Errors.BadCommand ret + push bc push de push hl ld hl,OP2+0 ld de,OP2+1 ld (hl),0 ld bc,12 ldir pop hl ld bc,15*256 ld de,OP2 GetAsciiFilenameLoop ld a,(hl) or a jr z,GotEndOfFilename cp '\r' jr z,GotEndOfFilename inc hl cp ' ' jr z,GotEndOfFilename cp '"' jr nz,NotQuotedFilename bit 0,c jr z,+ dec c jr GotEndOfFilename + ld a,(OP2) or a jr z,+ ; Error! ld hl,Errors.BadCommand xor a scf pop de pop bc ret + inc c jr HandledAsciiFilenameChar NotQuotedFilename ld (de),a inc de HandledAsciiFilenameChar djnz GetAsciiFilenameLoop ; Bad command. ld hl,Errors.BadCommand pop de pop bc xor a scf ret GotEndOfFilename bit 0,c jr z,+ ld hl,Errors.BadCommand pop de pop bc xor a scf ret + push hl ld hl,OP2 .fcall "File.NameToOP1" jr nc,+ xor a scf pop de pop de pop bc ret + pop hl pop de pop bc ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.GetHexWord === ; ; Gets a hex word. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to CR-terminated string that contains a hex word. ; ; OUTPUTS: ; REGISTERS ; * F - C set on error ; * HL - Points past hex word on success; points to error descriptor on error. ; * DE - Hex word. ; * BC - Points past hex word on success and on error. ; ; DESTROYED: ; REGISTERS ; * AF, HL, BC. ; ;@doc:end ;------------------------------------------------------------------------------- GetHexWord ld de,0 call SkipWhitespace ld a,(hl) cp '\r' jr nz,+ xor a dec a scf ld hl,Errors.BadCommand ld b,h ld c,l ret + - ld a,(hl) cp '\r' jr z,GotHexWord cp ' ' jr z,GotHexWord .fcall "Char.ParseHexNybble" jr nc,+ ld b,h ld c,l ld hl,Errors.BadHex or a scf ret + inc hl sla e \ rl d sla e \ rl d sla e \ rl d sla e \ rl d or e ld e,a jr - GotHexWord xor a ld b,h ld c,l ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.GetDecimalByte === ; ; Gets a decimal byte. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to CR-terminated string that contains a decimal byte. ; ; OUTPUTS: ; REGISTERS ; * F - C set on error ; * HL - Points past decimal on success; points to error descriptor on error. ; * A - Decimal byte. ; * BC - Points past decimal word on success and on error. ; DESTROYED: ; REGISTERS ; * AF, HL, DE, BC. ; ;@doc:end ;------------------------------------------------------------------------------- GetDecimalByte ld e,0 call SkipWhitespace ld a,(hl) cp '\r' jr nz,+ xor a dec a scf ld hl,Errors.BadCommand ld b,h ld c,l ret + - ld a,(hl) cp '\r' jr z,GotDecimalByte cp ' ' jr z,GotDecimalByte cp ',' jr z,GotDecimalByte .fcall "Char.ParseDecimal" jr nc,+ ld b,h ld c,l ld hl,Errors.BadCommand or a scf ret + inc hl ld d,a sla e ld a,e add a,a add a,a add a,e add a,d ld e,a jr - GotDecimalByte xor a ld a,e ld b,h ld c,l ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === OsCli.GetDecimalWord === ; ; Gets a decimal word. ; ; INPUTS: ; REGISTERS ; * HL - Pointer to CR-terminated string that contains a decimal word. ; ; OUTPUTS: ; REGISTERS ; * F - C set on error ; * HL - Points past decimal on success; points to error descriptor on error. ; * DE - Decimal byte. ; * BC - Points past decimal word on success and on error. ; DESTROYED: ; REGISTERS ; * AF, HL, DE, BC. ; ;@doc:end ;------------------------------------------------------------------------------- GetDecimalWord ld de,0 call SkipWhitespace ld a,(hl) cp '\r' jr nz,+ xor a dec a scf ld hl,Errors.BadCommand ld b,h ld c,l ret + - ld a,(hl) cp '\r' jr z,GotDecimalWord cp ' ' jr z,GotDecimalWord cp ',' jr z,GotDecimalWord .fcall "Char.ParseDecimal" jr nc,+ ld b,h ld c,l ld hl,Errors.BadCommand or a scf ret + inc hl ex de,hl add hl,hl ld c,l \ ld b,h add hl,hl add hl,hl add hl,bc ld b,0 \ ld c,a add hl,bc ex de,hl jr - GotDecimalWord xor a ld b,h ld c,l ret .module Commands ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Bye === ; ; Quits BBC BASIC. ; ;@doc:end ;------------------------------------------------------------------------------- Bye jp ExitBasic ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Refresh === ; ; Changes the way that BBC BASIC refreshes the screen. ; ;@doc:end ;------------------------------------------------------------------------------- Refresh ld hl,(CommandLineArgs) call GetOnOff jr c,RefreshError jr nz,RefreshOn RefreshOff xor a ld (Vdu.WriteToLcdEnabled),a ret RefreshOn ld a,-1 ld (Vdu.WriteToLcdEnabled),a RefreshNoArgs .fcall "Lcd.Copy" or a ret RefreshError jr nz,RefreshNoArgs jp CommandError ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.FX === ; ; *FX A,X,Y => A%=A:L%=X:H%=Y:CALL OSBYTE ; ;@doc:end ;------------------------------------------------------------------------------- FX FXArgs = OP1 ld ix,FXArgs xor a ld (ix+0),a ld (ix+1),a ld (ix+2),a ld hl,(CommandLineArgs) ld b,3 FxArgCharLoop ld a,(hl) inc hl or a jr z,HitEndOfFX cp $0D jr z,HitEndOfFX cp ',' jr z,NextFxArg cp ' ' jr z,FxArgCharLoop cp '\t' jr z,FxArgCharLoop .fcall "Char.IsNumeric" jp nz,CommandError sub '0' push af push hl ld a,(ix+0) ; *10 = *2+*8 add a,a ld l,a add a,a add a,a add a,l ld (ix+0),a pop hl pop af add a,(ix+0) ld (ix+0),a jr FxArgCharLoop NextFxArg inc ix djnz FxArgCharLoop ; End? call CheckEndOfStatement HitEndOfFX ld a,(FXArgs+0) ld hl,(FXArgs+1) .fcall "OSBYTE.Execute" or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Escape === ; ; *ESC ON|OFF ; ;@doc:end ;------------------------------------------------------------------------------- Escape ld hl,(CommandLineArgs) call GetOnOff jp c,CommandError jr z,EscOff EscOn ld a,(Host.EscapeBreakEffect) and ~1 ld (Host.EscapeBreakEffect),a or a ret EscOff ld a,(Host.EscapeBreakEffect) or 1 ld (Host.EscapeBreakEffect),a or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Help === ; ; Displays OS version. ; ;@doc:end ;------------------------------------------------------------------------------- Help ld a,'O' .fcall "Vdu.WriteByte" ld a,'S' .fcall "Vdu.WriteByte" ld a,' ' .fcall "Vdu.WriteByte" ld a,(OS.Version.Major) .fcall "Vdu.Text.PutHexNybble" ld a,'.' .fcall "Vdu.WriteByte" ld a,(OS.Version.Minor) .fcall "Utility.EncodeBCD" .fcall "Vdu.Text.PutHexByte" .fcall "Vdu.Text.NewLine" or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Exec === ; ; Read console input from a file. ; ;@doc:end ;------------------------------------------------------------------------------- Exec ld hl,(CommandLineArgs) call GetFilename jr nc,FilenameExec ret z ; Error in file. ; *EXEC on its own. ld a,(Keypad.ExecHandle) or a ret z dec a push ix .fcall "File.Close" pop ix ret FilenameExec ld a,(Keypad.ExecHandle) or a jr z,+ dec a push ix .fcall "File.Close" pop ix ret c + push ix .fcall "File.OpenRead" pop ix ret c ld a,e inc a ld (Keypad.ExecHandle),a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Delete === ; ; Delete a file. ; ;@doc:end ;------------------------------------------------------------------------------- Delete ld hl,(CommandLineArgs) call GetFilename ret c .bcall _File.Delete ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Type === ; ; "Types" a file. ; ;@doc:end ;------------------------------------------------------------------------------- Type ld hl,(CommandLineArgs) call GetFilename ret c push ix .fcall "File.OpenRead" pop ix ret c - push de push ix .fcall "File.ReadByte" pop ix jr nc,TypeReadOK pop de ret TypeReadOK jr nz,TypeEOF cp '\r' jr nz,+ .fcall "Vdu.Text.NewLine" jr TypedChar + cp 32 jr c,TypedChar bit 7,a jr z,+ ld a,'?' + .fcall "Vdu.WriteByte" TypedChar pop de dec d ld a,d and 7 jr nz,- .fcall "Keypad.GetCharNoHelper" jr nz,- jr nc,- jr TypeEscape TypeEOF pop de TypeEscape push ix .fcall "File.Close" pop ix ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Copy === ; ; Makes a copy of a file. ; ;@doc:end ;------------------------------------------------------------------------------- Copy CopyReadHandle = OP5+0 CopyWriteHandle = OP5+1 CopySize = OP5+2 xor a ld (CopyReadHandle),a ld (CopyWriteHandle),a ld hl,(CommandLineArgs) call GetFilename ret c push hl .bcall _OP1ToOP4 pop hl call GetFilename ret c push ix .bcall _OP1ToOP6 .bcall _OP4ToOP1 ld hl,OP1 .fcall "File.OpenRead" jp c,ExitCopy ld a,e ld (CopyReadHandle),a .fcall "File.GetSize" jp c,ExitCopy ld (CopySize),hl push hl .bcall _OP6ToOP1 pop hl .fcall "File.Create" jp c,ExitCopy ld a,h or l jr nz,+ or a jr ExitCopy + push hl .bcall _OP6ToOP1 pop hl .fcall "File.OpenUpdate" jr c,ExitCopy ld a,e ld (CopyWriteHandle),a ld a,(CopyReadHandle) ld e,a .fcall "File.ResolveHandle" jr c,ExitCopy ld a,(ix+Info.VarPage) or a jr z,CopySourceInRam CopySourceInRom ld b,a ld l,(ix+Info.VarOffset+0) ld h,(ix+Info.VarOffset+1) .fcall "File.ReadRom" .fcall "File.ReadRom" push hl push bc ld a,(CopyWriteHandle) ld e,a .fcall "File.ResolveHandle" pop bc pop hl jr c,ExitCopy ld e,(ix+Info.VarOffset+0) ld d,(ix+Info.VarOffset+1) inc de inc de push de pop ix ld de,(CopySize) - .fcall "File.ReadRom" ld (ix),a inc ix dec de ld a,d or e jr nz,- or a jr ExitCopy CopySourceInRam ld l,(ix+Info.VarOffset+0) ld h,(ix+Info.VarOffset+1) inc hl inc hl push hl ld a,(CopyWriteHandle) ld e,a .fcall "File.ResolveHandle" pop hl jr c,ExitCopy ld e,(ix+Info.VarOffset+0) ld d,(ix+Info.VarOffset+1) inc de inc de ld bc,(CopySize) ldir or a ExitCopy push af push hl ld a,(CopyReadHandle) or a jr z,+ ld e,a .fcall "File.Close" + ld a,(CopyWriteHandle) or a jr z,+ ld e,a .fcall "File.Close" + pop hl pop af pop ix ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Save === ; ; Saves a region of memory to a file. ; ;@doc:end ;------------------------------------------------------------------------------- Save FileMemoryStart = OP5+0 FileMemoryEnd = OP5+2 ld de,0 ld (FileMemoryEnd),de ld hl,(CommandLineArgs) call GetFilename ret c call GetHexWord jr nc,+ ld a,(bc) cp '+' scf ret nz ld h,b ld l,c + ld (FileMemoryStart),de call SkipWhitespace ld a,(hl) cp '\r' jp z,CommandError cp '+' jr nz,+ inc hl ld (FileMemoryEnd),de + call GetHexWord ret c ld hl,(FileMemoryEnd) add hl,de ; hl = end of file. ld de,(FileMemoryStart) or a sbc hl,de ld b,h ld c,l push ix .fcall "File.BlockSave" pop ix ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Load === ; ; Loads a region of memory from a file. ; ;@doc:end ;------------------------------------------------------------------------------- Load ld hl,(CommandLineArgs) call GetFilename ret c call GetHexWord ret c push ix ld bc,-1 .fcall "File.BlockLoad" pop ix ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Catalogue === ; ; Lists files. ; ;@doc:end ;------------------------------------------------------------------------------- Catalogue ld hl,(CommandLineArgs) call SkipWhitespace ld (CommandLineArgs),hl push ix push iy ld iy,(TIOS.IY) ld a,pictObj call CatalogueType ld a,progObj call CatalogueType ld a,appVarObj call CatalogueType pop iy pop ix or a ret CatalogueType push af .bcall _ZeroOP1 pop af ld (OP1),a CatalogueLoop .fcall "Keypad.GetCharNoHelper" jr nz,NotEscapedCatalogue jr nc,NotEscapedCatalogue pop iy pop iy pop ix xor a ld (Interrupt.OnKey),a ld hl,Errors.Escape scf ret NotEscapedCatalogue .bcall _FindAlphaUp ret c ld hl,OP2 .fcall "File.OP1ToName" ld hl,OP2 ld de,(CommandLineArgs) ld a,(de) cp '\r' jr z,+ .fcall "String.Match" jr nz,CatalogueLoop ld hl,OP2 + .fcall "Vdu.Text.WriteString" .fcall "Vdu.Text.NewLine" jr CatalogueLoop ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.YAxis === ; ; Sets the orientation of the Y axis. ; ;@doc:end ;------------------------------------------------------------------------------- YAxis ld hl,YAxisArgs rst rMov9ToOP1 ld hl,(CommandLineArgs) call SkipWhitespace push hl ld de,OP1 .fcall "String.Compare" pop hl jr z,YAxis.Up ld de,OP1+3 .fcall "String.Compare" jp nz,CommandError YAxis.Down ld a,$C9 ; RET jr + YAxis.Up ld a,$C3 ; JP nn + ld (Graphics.FlipY16),a ld (Graphics.FlipY8),a or a ret YAxisArgs .db "UP\r" .db "DOWN\r" ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.GScale === ; ; Sets graphics scale factor. ; ;@doc:end ;------------------------------------------------------------------------------- GScale ld hl,(CommandLineArgs) call GetDecimalByte jp c,CommandError ld (OP6+0),a ld (OP6+1),a .fcall "Graphics.IsValidScaleFactor" jr z,+ ld hl,Errors.BadCommand scf ret + call SkipComma jr nz,+ call GetDecimalByte jp c,CommandError ld (OP6+1),a .fcall "Graphics.IsValidScaleFactor" jr z,+ ld hl,Errors.BadCommand scf ret + ld a,(OP6+0) .fcall "Graphics.SetScaleFactor.X" ld a,(OP6+1) .fcall "Graphics.SetScaleFactor.Y" or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Himem === ; ; Moves HIMEM safely. ; ;@doc:end ;------------------------------------------------------------------------------- Himem ld hl,(CommandLineArgs) call SkipWhitespace ld a,(hl) cp '\r' jr nz,Himem.MoveHimem Himem.ResetHimem ld hl,(Memory.TotalAllocated) ld de,$9D95-kb(2) add hl,de ld de,(Basic.BBCBASIC_FREE) inc de or a sbc hl,de add hl,de jr nc,+ ld hl,Errors.NoRoom ret + ld (Basic.BBCBASIC_HIMEM),hl ret Himem.MoveHimem call GetHexWord ret c ex de,hl .fcall "Memory.MoveHimem" ret nc ld hl,Errors.NoRoom ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.ResetChar === ; ; Resets user-defined characters. ; ;@doc:end ;------------------------------------------------------------------------------- ResetChar xor a ld (OP6+0),a dec a ld (OP6+1),a ld hl,(CommandLineArgs) call SkipWhitespace ld a,(hl) cp '\r' jr z,ResetChar.Go call GetDecimalByte ret c ld (OP6+0),a ld (OP6+1),a call SkipComma jr nz,ResetChar.Go call GetDecimalByte ret c ld (OP6+1),a ResetChar.Go ; Check start<=end ld a,(OP6+0) ld l,a ld a,(OP6+1) cp l ld hl,Errors.BadCommand ret c - ld a,(OP6+0) call ResetSingleChar ld hl,OP6+0 ld a,(OP6+1) cp (hl) jr z,+ inc (hl) jr - + xor a ret ResetSingleChar ld l,a ld h,0 add hl,hl add hl,hl add hl,hl cp 32 jr c,ResetChar.Zero or a jp m,ResetChar.Zero push hl ld de,(Vdu.Text.UserDefinableFont) add hl,de ex de,hl pop hl ld bc,Resources.LargeFont-256 add hl,bc ld bc,8 ldir ret ResetChar.Zero ld de,(Vdu.Text.UserDefinableFont) add hl,de ld d,h \ ld e,l inc de ld bc,7 ld (hl),0 ldir ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Speed === ; ; Sets the CPU speed. ; ;@doc:end ;------------------------------------------------------------------------------- Speed ld hl,(CommandLineArgs) call GetDecimalByte jr c,Speed.BadNumber ld c,0 cp 6 jr z,Speed.Set inc c cp 15 jp nz,CommandError in a,(2) or a jp p,CommandError Speed.Set ld a,c ld (Speed.Fast),a .fcall "Speed.SlowDown" .fcall "Speed.SpeedUp" ret Speed.BadNumber ld hl,(CommandLineArgs) call SkipWhitespace ld a,(hl) ld c,0 cp 'S' jr z,Speed.Set inc c cp 'F' jr z,Speed.Set jp CommandError ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.BuildInfo === ; ; Displays build information. ; ;@doc:end ;------------------------------------------------------------------------------- BuildInfo ld hl,BuildInfo.String ld de,OP1 ld bc,BuildInfo.String.Length ldir ld hl,OP1 .fcall "Vdu.Text.WriteString" or a ret BuildInfo.String .db GetBuildInfoString(),"\n\r",0 BuildInfo.String.Length = $-BuildInfo.String ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Sleep === ; ; Puts the calculator into sleep mode. ; ;@doc:end ;------------------------------------------------------------------------------- Sleep ld hl,(CommandLineArgs) call GetDecimalWord jr c,Sleep.BadNumber ex de,hl or a ld de,5 sbc hl,de jp c,Sleep.BadNumber add hl,de ex de,hl Sleep.SetIdleTime di ld (Sleep.IdleTime),de .fcall "Sleep.ResetIdleTimer" ei xor a ret Sleep.BadNumber ld hl,(CommandLineArgs) call GetOnOff jr c,Sleep.BadOnOff ld de,0 jr z,Sleep.SetIdleTime ld de,120 jr Sleep.SetIdleTime Sleep.BadOnOff jp z,CommandError .fcall "Sleep.Sleep" xor a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.LoadText === ; ; Loads a BASIC program from a text file. ; ;@doc:end ;------------------------------------------------------------------------------- LoadText xor a jr LoadRunText ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.RunText === ; ; Loads/runs a BASIC program from a text file. ; ;@doc:end ;------------------------------------------------------------------------------- RunText ld a,-1 LoadRunText ld (OsCli.LoadRunText.IsRunning),a ld hl,(CommandLineArgs) call GetFilename ret c .fcall "File.OpenRead" ret c ld a,e inc a ld (Keypad.LoadTextHandle),a .fcall "Basic.BBCBASIC_NEW" xor a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Keyboard === ; ; Keyboard-related fun. ; ;@doc:end ;------------------------------------------------------------------------------- Keyboard ld a,(Keyboard.Enabled) or a ret z ld hl,(Keyboard.LayoutFileDescription) .fcall "Vdu.Text.WriteStringNewLine" or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Dirty === ; ; Marks file handles as dirty. ; ;@doc:end ;------------------------------------------------------------------------------- Dirty .fcall "File.DirtyHandles" or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.GBuf === ; ; Sets the graph buffer address. ; ;@doc:end ;------------------------------------------------------------------------------- GBuf ld hl,(CommandLineArgs) call SkipWhitespace ld de,plotSScreen ld a,(hl) cp '\r' jr z,+ call GetHexWord ret c + ld (Lcd.Buffer),de ld a,(Vdu.WriteToLcdEnabled) or a ret z .fcall "Lcd.Copy" or a ret ;------------------------------------------------------------------------------- ;@doc:OS ; ; === Commands.Font === ; ; Sets the font size for VDU 5. ; ;@doc:end ;------------------------------------------------------------------------------- Font ld hl,(CommandLineArgs) call SkipWhitespace ld a,(hl) cp '\r' jr z,Font.SetDefault cp 'S' ; SMALL jr z,Font.SetSmall cp 'L' ; Large jr z,Font.SetLarge ld hl,Errors.BadCommand scf ret Font.SetLarge ld hl,8+256*8 jr Font.SetValue Font.SetSmall ld hl,4+256*6 jr Font.SetValue Font.SetDefault ld hl,(Vdu.Text.CharSize) Font.SetValue ld (Vdu.Text.Graphical.CharSize),hl or a ret .function osclicommand(name, target) .db strlength(name) + 4 .db name, 0 .dw target .endfunction Table osclicommand("REFRESH", Refresh) osclicommand("GBUF", GBuf) osclicommand("FONT", Font) osclicommand("FX", FX) osclicommand("YAXIS", YAxis) osclicommand("GSCALE", GScale) osclicommand("SAVE", Save) osclicommand("S.", Save) osclicommand("LOADTEXT", LoadText) osclicommand("LOAD", Load) osclicommand("DELETE", Delete) osclicommand("DEL", Delete) osclicommand("ERASE", Delete) osclicommand("ERA", Delete) osclicommand("COPY", Copy) osclicommand("ESC", Escape) osclicommand("SPEED", Speed) osclicommand("EXEC", Exec) osclicommand("CAT", Catalogue) osclicommand("DIR", Catalogue) osclicommand(".", Catalogue) osclicommand("HELP", Help) osclicommand("TYPE", Type) osclicommand("BYE", Bye) osclicommand("QUIT", Bye) osclicommand("EXIT", Bye) osclicommand("HIMEM", Himem) osclicommand("RESETCHR", ResetChar) osclicommand("BUILDINFO", BuildInfo) osclicommand("SLEEP", Sleep) osclicommand("RUNTEXT", RunText) osclicommand("KEYB", Keyboard) osclicommand("DIRTY", Dirty) .db 0 .endmodule .endmodule