📄 cmd_screendump.asm
字号:
; 09/04/2000
; mode4_eps in progress
; mode3_latex in progress
; elements in hrules must be in a col <255 bytes
%include "util.mac"
%include "icedump.inc"
%include "wiat.inc"
global Parse_ScreenDump
global Parse_ScreenDump.EmodeFileName
global Parse_ScreenDump.EmodeExtPtr
global Parse_ScreenDump.modeMsg
extern sdata
extern ON_TOGGLE_EXPERT_MODE.Emode
extern EmodeSub.IncDumpNum
extern SetCB
extern Parser.error
extern TempBuffer
extern GetVideoMem
bits 32
;-------------------------------------------------------------------------------
; SCREENDUMP [<file>]
;-------------------------------------------------------------------------------
segment _LTEXT
Parse_ScreenDump:
mov dl,byte [ON_TOGGLE_EXPERT_MODE.Emode]
cmp dl,'E' ; see if in expert mode
je .modeE
call [pSkipWhiteSpace] ; skip to <file name>
jz near .modeToggle
mov ebp,[dClient_ESI] ; store pointer to file name
mov [ebp],esi
jmp short .continue
.modeE:
mov edi,.EmodeFileName
mov ebp,[dClient_ESI] ; store ptr to filename
mov [ebp],edi
add edi,[.EmodeExtPtr] ; get offset of the extension
call EmodeSub.IncDumpNum
.continue:
push byte SERVICE_DUMP
mov ebp,[dClient_EAX]
pop dword [ebp]
mov ebp,[dClient_EDI] ; store start address of our buffer
mov edi,[TempBuffer]
mov [ebp],edi
call GetVideoMem ; get start of video memory
mov esi,eax
mov eax,[bLINES_current]
movzx eax,byte [eax]
mov ecx,eax ; need this in ecx for the outer loop
mov ebx,[dWIDTH_current]
mov ebx,[ebx]
mul ebx
mov dl,[.mode]
cmp dl,'0'
je .mode0
cmp dl,'2'
je near mode2_html ; code is a little further /fOSSiL/
; to save some bytes on short jumps
cmp dl,'3'
je near mode3_latex
cmp dl,'4'
je near mode4_eps
lea eax,[eax+2*ecx] ; fixup for the extra cr/lf
mov ebp,[dClient_ECX] ; store length of our buffer
mov [ebp],eax
cmp eax,TempBuffer_size
ja near Parser.error
mov ax,0x0A0D ; cr/lf
.getNextPatchDatum:
push ecx ; yeah, sloppy, i know :) /Ghiri/
mov ecx,ebx
.innerloop:
movsb
inc esi
loop .innerloop ; parse and copy raw screen
stosw ; put in cr/lf
pop ecx
loop .getNextPatchDatum
jmp short .setCB
.mode0:
add eax,eax
cmp eax,TempBuffer_size
ja near Parser.error
mov ecx,eax
rep movsb
.setDumpLength:
mov ebp,[dClient_ECX] ; store length of block
mov [ebp],eax
.setCB:
call SetCB
jc near Parser.error
xor eax,eax
inc eax
mov ebp,[fPAGEIN_InProgress] ; set internal Winice flag to 1
mov [ebp],eax
mov ebp,[fExecuteMoreCommands] ; set internal Winice flag to 0
mov [ebp],ah
popad
retn
.modeToggle:
mov al,[.mode] ; 3-pos toggle /fOSSiL/
inc al
cmp al,'5' ; now 5-pos toggle
jb .modeToggle_n0
mov al,'0'
.modeToggle_n0:
mov [.mode],al
mov esi,.modeMsg
call [pPrintToCommandWindow]
jmp Parser.error
segment _LDATA
.modeMsg: db 'Screen dumper set to mode '
.mode: db '1',0
.EmodeViewFilename: db 'Current auto-dump filename: '
.EmodeFileName: db 'C:\DEFAULT.00/',0 ; watch out for .EmodeExtPtr
; this should pad up to OPT_EMODE_FILENAMELEN and leave extra space
; for dump-number
TIMES OPT_EMODE_FILENAMELEN-($-.EmodeFileName)+1+OPT_EMODE_NUMLEN db 0
.EmodeExtPtr: dd 11
;----------------------------------
; /fOSSiL/ RAW-->html
; Let the games begin...
;----------------------------------
segment _LTEXT
mode2_html:
cmp eax,TempBuffer_size/2 ; EAX contains #bytes
ja near Parser.error
mov eax,.begin ; write html header
call .write
; ebx = Width, ecx = Height
.loop1:
mov eax,.line1 ; write row header part 1
call .write
xor eax, eax
lodsw
push eax ; we will need it
shr eax,12
call .wclr ; write backcolor
mov eax,.line2
call .write ; write row header part 2
pop eax
push ecx
mov ecx,ebx
jmp .loop2_nl
.loop2:
lodsw
.loop2_nl:
ror eax, 8
cmp ah, al ; check current color
je .loop2_nc
call .setcolor ; set font color
mov ah, al ; save current color
.loop2_nc:
rol eax, 8
call .wchar ; xlat and write char out
loop .loop2
pop ecx
mov eax,.endline ; write endline
call .write
loop .loop1
mov eax,.end ; write end block
call .write
sub edi,[TempBuffer]
mov ebp,[dClient_ECX] ; store length of block
mov [ebp],edi
call SetCB
jc near Parser.error
xor eax,eax ; wow, saves 2 bytes
inc eax ; thanks G-Rom ;-)
mov ebp,[fPAGEIN_InProgress] ; set internal Winice flag to 1
mov [ebp],eax
mov ebp,[fExecuteMoreCommands] ; set internal Winice flag to 0
mov [ebp],ah
popad
retn
.write:
push esi
mov esi,eax
.w_loop:
lodsb
or al,al
jz .w_done
stosb
jmp short .w_loop
.w_done:
pop esi
retn
.setcolor:
push eax
mov eax,.setclr1 ; write <FONT...
call .write
mov eax, [esp]
call .wclr ; write color code
mov eax,.setclr2
call .write ; write end tag
pop eax
retn
.wclr:
mov edx,eax
mov eax,'AF00'
mov dh,3
shl dl,5 ; check and adjust intensity
jnc .wc_loop ; CF=0 when intensity low
add al, 5
.wc_loop:
shl dl,1 ; test next bit
jc .wc_nr1
ror eax,16 ; switch to '00', also clc
; clc ; left for clarity, if it helps =)
.wc_nr1:
stosw
jc .wc_nr2
ror eax,16 ; put it back now
.wc_nr2:
dec dh
jnz .wc_loop
retn
.wchar:
; some lame char xlat
; unfortunately, a nessecity for html
push esi
push eax
mov dl,al
mov esi,.xltab
.ch_next:
lodsb
cmp dl,al
jz .chout
or al,al
jz .ch_nomatch
.ch_skip:
lodsb
or al,al
jnz .ch_skip
jmp .ch_next
.ch_nomatch:
cmp dl,32 ; no matching xlat entry found
jb .chout ; check if 32-127 ascii code
cmp dl,127 ; and if not, print ' '
ja .chout
mov al,dl
stosb
jmp short .ch_end
.chout:
mov eax,esi ; we've moved on to 1->many char xlat
call .write ; so now we have to print strings
.ch_end:
pop eax
pop esi
retn
segment _LDATA
.begin: db '<HTML><BODY>',13,10
db '<TABLE bgcolor="black"><TR><TD><TABLE border="0">',13,10,0
.end: db '</TABLE></TD></TABLE>',13,10
db '</BODY></HTML>',0
.line1: db '<TR bgcolor="#',0
.line2: db '"><TD><PRE>',0
.endline: db '</TD>',13,10,0
.setclr1: db '<FONT color="#',0
.setclr2: db '">',0
.xltab: db 16,'>',0, 17,'<',0, 24,'^',0, 25,'v',0
db 30,'^',0, 31,'v',0, 196,'-',0, '<','<',0
db 0,' ',0
;----------------------------------
; /Ghiri/ RAW-->LaTeX
; Goddamn, I had to look at fOSSIL's HTML code after all :p
;----------------------------------
; ESI = ptr to raw dump
; EAX = # bytes in raw dump
; EBX = Width
; ECX = Height
segment _LTEXT
mode3_latex:
cmp eax,TempBuffer_size/2
ja near Parser.error
mov eax,.begin ; write LaTeX header
call .write
.loop1: ; line loop
mov dword [.colorchangeflag], 0
mov eax,.line1 ; write row header part 1
call .write
xor eax, eax
lodsw
push eax ; we will need it
shr eax,12
call .wclrbk ; write backcolor
mov eax,[esp]
ror eax,8
call .writefirsttextcolor ; special handling
pop eax
cmp byte [.green], 1 ; see if we are cleaning up after a hrule
je .specialgreen
ror eax,8 ; fix color for first byte in line
push ecx
mov ecx,ebx
jmp .loop2_nl
.specialgreen: ; special handling for cleanup after hrule lines
xor eax,eax
mov [.green],al
dec ecx ; reduce #lines
jmp .loop1
.writefirsttextcolor: ; set original text color
dec edi
call .wclr
retn
.loop2: ; chars in a line loop
lodsw
ror eax, 8
cmp ah, al ; check current color
je .loop2_nc
call .setcolor ; set text color
.loop2_nl:
mov ah, al ; save current color
.loop2_nc:
rol eax, 8
call .wchar ; xlat and write char out
loop .loop2 ; chars in a line loops
pop ecx
mov eax, [.colorchangeflag]
cmp eax, 1
mov eax, .colorendline
je .writeendtag
mov eax,.endline ; write endline
.writeendtag:
call .write
dec ecx ; loop for each line (too far for loop instruction)
jecxz .outloop1
jmp .loop1
.outloop1:
mov eax,.end ; write end block
call .write
sub edi,[TempBuffer]
mov ebp,[dClient_ECX] ; store length of block
mov [ebp],edi
call SetCB
jc near Parser.error
xor eax,eax ; wow, saves 2 bytes
inc eax ; thanks G-Rom ;-)
mov ebp,[fPAGEIN_InProgress] ; set internal Winice flag to 1
mov [ebp],eax
mov ebp,[fExecuteMoreCommands] ; set internal Winice flag to 0
mov [ebp],ah
popad
retn
.write:
push esi
mov esi,eax
.w_loop:
lodsb
or al,al
jz .w_done
stosb
jmp short .w_loop
.w_done:
pop esi
retn
.setcolor: ; closes previous latex textcolor command and begins new one
push eax
mov eax,[.colorchangeflag]
cmp eax,0
mov dword [.colorchangeflag], 1
mov eax,.setclrfirst
je .firstcolorchange
mov eax,.setclr1
.firstcolorchange:
call .write
mov eax, [esp]
call .wclr ; write color code
pop eax
retn
.wclrbk: ; different color routine (use different shade of grey)
and eax,7 ; ignore intensity bit
cmp eax,7
jne .c0
mov eax,.cLightGrey
call .write
retn
.wclr: ; sets color code
and eax,7 ; ignore intensity bit
cmp eax,7
jne .c0
mov eax,.cDarkGrey
call .write
retn
.c0:
cmp eax,0 ; code is ugly, but works. perhaps will
jne .c1 ; cleanup before release
mov eax,.cBlack
call .write
retn
.c1:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -