我正在尋找一種方法來獲取FPC下控制檯視頻行和列的數量。我正在尋找最便攜的方式,但至少有一個可以在Windows(最好也是在Linux下)下工作。FreePascal控制檯視頻行和列
從舊的Turbo Pascal日子裏,我寫下了函數,但它們不會在FPC下編譯,而且在彙編中它們不是很便攜。
//Return the number of video rows
function GetVideoY: Byte; assembler;
asm
mov ax,$40
mov es,ax
mov al,es:$84
inc al
end; { GetVideoY }
//Return the number of video columns
function GetVideoX: Byte; assembler;
asm
mov ax,$40
mov es,ax
mov al,es:$4A
end; { GetVideoX }
UPDATE: 基於正確答案的建議上述程序成爲:
//Return the number of video rows
function GetVideoY: Byte;
begin
GetVideoY := WindMaxY - WindMinY + 1;
end;
//Return the number of video columns
function GetVideoX: Byte;
begin
GetVideoX := WindMaxX - WindMinX + 1;
end;
我想他們都在Windows和Linux,他們似乎工作確定。謝謝。
你的asm函數做由於未指定彙編程序模式,因此無法編譯:** {$ ASMMODE intel} **。他們看起來像是在16位時代寫的。嘗試轉換寄存器:** ax ** - > ** eax **,** es ** - > ** esp **。 ** al **仍然可以,因爲它與結果大小(8位)相匹配。否則,你可以看看** crt **單元。 – 2014-11-06 12:58:07
@ user3661500轉換es-> esp錯誤,因爲es是段寄存器,段寄存器名稱沒有更改。 OP正嘗試讀取ROM-BIOS數據區中的絕對內存地址40:004A和40:0084的字節(http://webpages.charter.net/danrollins/techhelp/0093.HTM) – xmojmr 2014-11-06 16:44:06
原始代碼使用BIOS地址來獲取這些信息。但這是無關緊要的,因爲重要的是具有相同的功能,而不是如何實現。例如,可能有Windows和/或Linux API調用爲控制檯提供了列和行。 – tonypdmtr 2014-11-06 18:36:43