'******************************************************************************
'* 
'* GENERIC CONSOLE COMMANDS (Used by emulator console for all configs)
'*
'******************************************************************************

'------------------------ Service Tools ---------------------------------------

//Text format function
public function fstr(s as string, slen as byte) as string
 dim l as integer : l=Length(s)
 select case true
 case l<slen : result=s+Space(slen-l)
 case (l>slen) and (slen<=3) : result="..."
 case l>slen : result=Mid(s,1,slen-3)+"..."
 case else : result=s 
 end select
end

'-------------------------- Help Command --------------------------------------

//Help on console commands
public procedure Help
 ? "CONSOLE commands:"
 ? " All instructions, available in scripts (""print"" etc)"
 ? " Help (or H) - show list of all console commands"
 ? " Step (or S) - execute single CPU instruction"
 ? " Step(n) (or S(n)) - execute n CPU instructions"
 ? " StepOver (or SO) - execute some instruction until next"
 ? " StepOverOver (or SOO) - execute any instruction until next"
 ? " Dasm - disassemble current CPU instruction"
 ? " *use PgUp/PgDn keys to scroll console text"
end
public procedure H alias Help

'---------------------- Disassembling Command ---------------------------------

//Dissasembling of current CPU instruction
public procedure Dasm
 ? "can not disassemble"
end

'--------------------------- Debug Commands -----------------------------------

//Execute CPU instruction and dissasemble it
public procedure Step(Count as dword=1,NeedDasm as boolean=true) 
 if Count>0 then dbg.Step(Count) : if NeedDasm then Dasm : end
public procedure S alias Step

//Execute some complex CPU instruction and dissasemble it
public procedure StepOver 
 dbg.StepOver : Dasm : end
public procedure SO alias StepOver

//Execute any CPU instruction and dissasemble it
public procedure StepOverOver
 dbg.StepOverOver : Dasm : end
public procedure SOO alias StepOverOver
