flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
FlierMate1 19 Jun 2022, 18:18
Firstly, thanks to bitRAKE for his code snippet to split string (https://board.flatassembler.net/topic.php?t=21996)
This is a simple demo showing short MP4 "video" in Windows command prompt window. Limitation: Don't know how to resize to bigger window I am asking for code on how to allocate memory buffer, because I have another 4MB car racing "video" file which is impossible to play with my existing code. Please let me know what you think about this. (The "video" file is split using "$" character, generated by myself from sample MP4 using FFMPEG) Code: format PE console entry start include 'win32a.inc' section '.data' data readable writable _filename db "airplane.mp4.txt",0 _buffer rb 464728 _handle dd ? _console dd ? _len dd ? section '.code' code readable executable start: push 0 push FILE_ATTRIBUTE_NORMAL push OPEN_EXISTING push 0 push FILE_SHARE_READ push GENERIC_READ push _filename call [CreateFile] cmp eax, INVALID_HANDLE_VALUE mov dword [_handle], eax je .error push STD_OUTPUT_HANDLE call [GetStdHandle] mov dword [_console], eax push 0 push _len push 464728 push _buffer push dword [_handle] call [ReadFile] test eax, eax jz .error call Play .error: push 0 call [ExitProcess] Play: ; String split iterator (bitRAKE) ; ; RDI: string to scan ; RCX: length of string in characters, >0 ; AX: character to split on lea edi, [_buffer] mov ecx, dword [_len] .scan: mov al, '$' mov esi, edi repnz scasb push edi jnz .last sub edi, 1 ; don't count the split character in length .last: push ecx sub edi, esi ; length without terminator ;jz skip push 0 ; FUNCTION (address:RSI, length:RDI) push 0 push edi push esi push dword [_console] call [WriteConsole] push 200 call [Sleep] .skip: pop ecx ; characters to go pop edi ; start cmp ecx, 0 jz .done jmp .scan .done: ret section '.idata' import readable writable library kernel32, 'KERNEL32.DLL' import kernel32,\ GetStdHandle, 'GetStdHandle', \ WriteConsole, 'WriteConsoleA', \ GetTickCount, 'GetTickCount', \ Sleep, 'Sleep', \ CreateFile, 'CreateFileA', \ ReadFile, 'ReadFile', \ ExitProcess,'ExitProcess'
Last edited by FlierMate1 on 21 Jun 2022, 14:11; edited 2 times in total |
||||||||||||||||||||
![]() |
|
bitRAKE 20 Jun 2022, 08:16
With windows 10 MS is pushing towards better VT100 support - so, everything old is new again. I was just thinking the other day of coding a little program to display some of the old terminal animations. There are interesting effects like twinkling stars and stuff that looked cool at 300 baud. The stuff people were able to do in such a constrained environment in quite amazing.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
FlierMate1 20 Jun 2022, 15:48
@I, thanks for the code, it works as expected. The default console window size on my Windows is actually big enough, 120x30, to fit my animated ASCII art.
I wrote: Maybe MapViewOfFile for file? This sounds like a cool API function. I will study more if I need to cater for large file. bitRAKE wrote: I was just thinking the other day of coding a little program to display some of the old terminal animations...The stuff people were able to do in such a constrained environment in quite amazing. I think you also mean demoscene coders back in the old days. Like...bad apple ? ( https://en.wikipedia.org/wiki/Bad_Apple!!#Use_as_a_graphical_and_audio_test ) Thanks for your "string split " code again! |
|||
![]() |
|
FlierMate1 20 Jun 2022, 16:05
The animated ASCII art was converted from this real MP4 using a simple algorithm:
https://www.videvo.net/video/ek-boeing-777-landing/4036/
Last edited by FlierMate1 on 21 Jun 2022, 14:26; edited 2 times in total |
||||||||||
![]() |
|
FlierMate1 21 Jun 2022, 06:12
It is not only that, can also applies color to the ASCII art, hence, ANSI art. But I had tested it before, it is slower when playing the animated ANSI art.
Not just from MP4 video, ASCII art can also be converted from animated GIF frame by frame. I plan to create a complete ASCII/ANSI art Studio (convert & play), but not sure its usefulness, or if there is any similar tool on GitHub already.
|
|||||||||||||||||||
![]() |
|
bitRAKE 21 Jun 2022, 07:11
https://www.ansilove.org/ is the one I know of. Back in the BBS days I think most of them were created by hand, with very limited colors/characters.
Have you seen Picnic's Hobby Basic? He's included some ANSI art amongst his example programs. (I haven't tried them on the latest Win10/11, but they should work even better, imho.) _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
FlierMate1 21 Jun 2022, 14:02
Interestingly, "ansilove" does the opposite, it converts ANSI art to PNG image file.
Yes, I too notice those are created by hand. I am aware of Picnic's HB, but have never downloaded it before. It is an interpreter and closed-source. From his thread, yes, I too notice ANSI art created by hand. (I tried to download HB.zip but Windows reported 'Failed - Virus detected', I have disabled the Real-time Virus &Threat Protection before this, but suddenly have no clue where to turn off App & Browser Control ![]() Also, from your String Split Iterator, I forgot to set the ECX to length of string, and it still work, must be based on random value in ECX register. ![]() |
|||
![]() |
|
bitRAKE 21 Jun 2022, 16:34
FlierMate1 wrote: I tried to download HB.zip but Windows reported 'Failed - Virus detected', I have disabled the Real-time Virus &Threat Protection before this _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
Picnic 21 Jun 2022, 21:49
Hello FlierMate1, bitRAKE,
FlierMate1 wrote: I am aware of Picnic's HB, but have never downloaded it before. It is an interpreter and closed-source. From his thread, yes, I too notice ANSI art created by hand. Sorry to hear that. HB.zip is clean. Still, Windows refuses to run it (or even download it sometimes) unless the the Real-time Virus & Threat Protection is disabled. Nevertheless, if you manage to skip Windows security you'll see that HB runs quite smooth in Windows 10. bitRAKE wrote: If I had to contend with MS's definition of security [beyond disabling it] then I doubt I could use Windows. It's more like a bit religion where some oracle in the sky says, "these bits are bad" and millions of machines echo "these bits are bad". There always needs to be bad bits - how else you going to know how protected you are? Recently i download s suspicious file. I knew it and took my chances. I lost an external disk (it locked and asking me for money to unlock it). Windows 10 didn't complain about anything, my AV the same. |
|||
![]() |
|
FlierMate1 22 Jun 2022, 08:10
Picnic wrote:
I understand, my experimental compiler also went through the same issue, falsely detected by Windows (and several other AVs) as malware. I remember must turn off several other settings besides Virus & Threat Protection to successfully download certain .Zip files. Thank you for the kind message, Picnic. |
|||
![]() |
|
revolution 22 Jun 2022, 09:04
But how to convince the mainstream users when they fully believe all the AV marketing about how foolproof AVs are?
You upload your code to some place, and then the users demand it be removed because of the dangerous nasty viruses inside. ![]() ![]() ![]() Last edited by revolution on 22 Jun 2022, 11:40; edited 2 times in total |
|||
![]() |
|
Ali.Z 22 Jun 2022, 11:35
a campaign, "AV is PUP"
_________________ Asm For Wise Humans |
|||
![]() |
|
bitRAKE 24 Jun 2022, 17:51
Picnic wrote: Recently i download s suspicious file. I knew it and took my chances. I lost an external disk (it locked and asking me for money to unlock it). Windows 10 didn't complain about anything, my AV the same. The process I imagine is boot into BIOS, load image off network. This requires a backup process if work is to persist across images. It makes all local drives disposable. Maybe loose a day of work, but zero down time. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
FlierMate11 21 Jan 2023, 06:58
Hi, my first demo example in Post #1 is far from perfect, as it doesn't set to larger console screen window, and it doesn't set cursor position back to 0,0 on every frame redraw.
Now I fixed this. Thanks to @I for your good code. Below is API call in each of the console app player: Code: call [CreateFile] call [GetStdHandle] call [ReadFile] call [GetConsoleScreenBufferInfoEx] call [SetConsoleScreenBufferInfoEx] call [GetConsoleWindow] call [SetWindowPos] loop: call [SetCursorPos] call [WriteConsole] call [Sleep] call [ExitProcess] Please choose to download which object you want to watch (airplane landing, racing car, moon & earth), each of this Zip file contains .asm source file, .exe executable and .mp4.txt character video. However, once you launch the player, you cannot interrupt it until it finishes playing. The longest character video is car.mp4.txt with about 800 frames. Frames are delimited with "$" (dollar sign) character. Correction: Oops, SetCursorPos is used to set cursor position of mouse pointer, not screen cursor. I have commented the relevant code and recompiled them. ![]()
|
|||||||||||||||||||||||||||||||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.