nedoPC.org

Electronics hobbyists community established in 2002
Atom Feed | View unanswered posts | View active topics It is currently 28 Mar 2024 11:24



Reply to topic  [ 4 posts ] 
Формат сжатия текстовых мультиков ETA 
Author Message
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22411
Location: Silicon Valley
Reply with quote
Я тут мимоходом придумал формат хранения текстовых (ASCII плюс псевдографика и 32 опциональных юзерских символа) мультиков:
Code:
 Encoded Text Animation (ETA):
 =============================
 Header: '@',Cols,Rows,Number
 User: Number*8 - user characters (up to 32)
 Data: Sequence of bytes that ends with 0xF0:
 0xxxxxxx - ASCII character itself (including user space <0x20)
 100xxxxx - Repeat space 2...33 times (x+2)
 1010xxxx - Skip 1...16 characters (0 means 16)
 1011xxxx - GFX character itself (0xB0...0xBF)
 110xxxxx - GFX character itself (0xC0...0xDF)
 1110xxxx - Repeat next character 1...16 times (0 means 16) + 1 byte after that
 1111xxxx - Extended GFX character itself, but
 11110000 - End of the image/movie (0xF0)
 11110001 - End of the frame that should stay for N/30 sec and start from row M
            (0xF1 + 2 bytes N and M after that)

 Shaos, April 2015


В нём, например, вот это "кино" http://www.asciimation.co.nz из 2 мегов сжимается до 184К ;)

_________________
:dj: https://mastodon.social/@Shaos


19 Apr 2015 20:12
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22411
Location: Silicon Valley
Reply with quote
Вот плеер под DOS, собираемый во фришном Turbo-C 2.01:
Code:
/* ETA_PLAY.C - A.A.Shabarshin (April 2015) - for Turbo-C 2.01
==============================================================

Copyright (c) 2015 A.A.Shabarshin <me@shaos.net>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/

#include <stdio.h>
#include <conio.h>

/*

 Encoded Text Animation (ETA):
 =============================
 Header: '@',Cols,Rows,Number
 User: Number*8 - user characters (up to 32)
 Data: Sequence of bytes that ends with 0xF0:
 0xxxxxxx - ASCII character itself (including user space <0x20)
 100xxxxx - Repeat space 2...33 times (x+2)
 1010xxxx - Skip 1...16 characters (0 means 16)
 1011xxxx - GFX character itself (0xB0...0xBF)
 110xxxxx - GFX character itself (0xC0...0xDF)
 1110xxxx - Repeat next character 1...16 times (0 means 16) + 1 byte after that
 1111xxxx - Extended GFX character itself, but
 11110000 - End of the image/movie (0xF0)
 11110001 - End of the frame that should stay for N/30 sec and start from row M
            (0xF1 + 2 bytes N and M after that)

 Shaos, April 2015

*/

int main(int argc, char** argv)
{
 int i,c,n,m,w,h,x,y;
 FILE *f;
 if(argc<2)
 {
   printf("Usage: ETA_PLAY FILE.ETA\n");
   return -1;
 }
 f = fopen(argv[1],"rb");
 if(f==NULL)
 {
   printf("Can't open file '%s'!\n",argv[1]);
   return -2;
 }
 c = fgetc(f);
 if(c!='@')
 {
   printf("Invalid ETA file!\n");
   return -3;
 }
 w = fgetc(f);
 h = fgetc(f);
 c = fgetc(f);
 if(c!=0)
 {
   printf("This player doesn't support user defined characters!\n");
   return -3;
 }
 x = (80-w)/2;
 y = (25-h)/2;
 clrscr();
 window(x,y,x+w-1,y+h);
#if 0
 /* this is for later borlands */
 _setcursortype(_NOCURSOR);
#endif
 m = 0;
 while(c!=0xF0)
 {
   c = fgetc(f);
   switch(c>>4)
   {
     case 0:
     case 1:
     case 2:
     case 3:
     case 4:
     case 5:
     case 6:
     case 7:
       putch(c);
       break;
     case 8:
     case 9:
       n = (c & 0x1F) + 2;
       for(i=0;i<n;i++) putch(' ');
       break;
     case 10:
       n = c & 0x0F;
       if(n==0) n = 16;
       i = wherex() + n;
       if(i > w)
          gotoxy(i-w,wherey()+1);
       else
          gotoxy(i,wherey());
       break;
     case 11:
     case 12:
     case 13:
       putch(c);
       break;
     case 14:
       n = c & 0x0F;
       if(n==0) n = 16;
       c = fgetc(f);
       for(i=0;i<n;i++) putch(c);
       break;
     case 15:
       if(c==0xF0) break;
       if(c==0xF1)
       {
          m++;
          delay(33*fgetc(f));
          gotoxy(1,fgetc(f)+1);
          if(kbhit() && getch()==27) c=0xF0;
       }
       else putch(c);
       break;
   }
 }
 fclose(f);
 return 0;
}

_________________
:dj: https://mastodon.social/@Shaos


19 Apr 2015 20:13
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22411
Location: Silicon Valley
Reply with quote
Версию под Linux (ncurses5) и Windows (console) тоже накатать не проблема, если это кому-нибудь нужно, а пока я нацеливаю это на XORLib+PIC32...

_________________
:dj: https://mastodon.social/@Shaos


19 Apr 2015 20:35
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22411
Location: Silicon Valley
Reply with quote
Shaos wrote:
Я тут мимоходом придумал формат хранения текстовых (ASCII плюс псевдографика и 32 опциональных юзерских символа) мультиков:
Code:
 Encoded Text Animation (ETA):
 =============================
 Header: '@',Cols,Rows,Number
 User: Number*8 - user characters (up to 32)
 Data: Sequence of bytes that ends with 0xF0:
 0xxxxxxx - ASCII character itself (including user space <0x20)
 100xxxxx - Repeat space 2...33 times (x+2)
 1010xxxx - Skip 1...16 characters (0 means 16)
 1011xxxx - GFX character itself (0xB0...0xBF)
 110xxxxx - GFX character itself (0xC0...0xDF)
 1110xxxx - Repeat next character 1...16 times (0 means 16) + 1 byte after that
 1111xxxx - Extended GFX character itself, but
 11110000 - End of the image/movie (0xF0)
 11110001 - End of the frame that should stay for N/30 sec and start from row M
            (0xF1 + 2 bytes N and M after that)

 Shaos, April 2015


В нём, например, вот это "кино" http://www.asciimation.co.nz из 2 мегов сжимается до 184К ;)

Возможное расширение для представления цветного текста:
Code:
F2 - clear screen (fill with spaces)
F3 x - set attribute as
| bit 7 - Intensity of background (use carefully)
| bits 6...4 - Background color RGB
| bit 3 - Intensity of foreground
| bits 2...0 - Foreground color RGB (text)
F4 - inverse attributes
F5 - change text color to gray over black (and set high intensity)
F6 - change text color to white over black (and set low intensity)
F7 - change text color to bright white over black (and set high intensity)
F8 - change text color to black (gray if high intensity set) and print character 0xDB
F9 - change text color to blue and print character 0xDB
FA - change text color to green and print character 0xDB
FB - change text color to cyan and print character 0xDB
FC - change text color to red and print character 0xDB
FD - change text color to magenta and print character 0xDB
FE - change text color to brown (yellow if high intensity set) and print character 0xDB
FF - change text color to white and print character 0xDB

Вот я подсветил, что в данный момент используется - зелёным обычные печатные символы ASCII, жёлтым - досовская пседографика.
Красным подсвечено то, что могло бы использоваться в будущем для подмены первых 32 символов пользовательским знакогенератором (пока не поддержано).
Ну и все остальные символы - это команды по вышеизложенной спецификации:


Attachments:
VGAtextETA.gif
VGAtextETA.gif [ 8.34 KiB | Viewed 2416 times ]

_________________
:dj: https://mastodon.social/@Shaos
20 Feb 2021 21:05
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.