runable Graphics wanted...

You need an actual VIC.

Moderator: Moderators

groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

runable Graphics wanted...

Post by groepaz »

Hy,

i am playing around with the screenshot feature in VICE a bit, i need runable VIC20 graphics. Preferably something that loads quickly and doesnt require me to press any buttons/keys. Any pointers? :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: runable Graphics wanted...

Post by Mike »

groepaz wrote:i need runable VIC20 graphics. [...] Any pointers? :)
All MINIGRAFIK/MINIPAINT picture files contain a built-in display routine. Just load them with ",8" (*not* ",8,1"!) with a +8K RAM expansion and then run them.

The *.d64 of the MG batch suite features several picture files, which are normally displayed within a slide show, but you can also view them stand-alone with the method just stated.
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: runable Graphics wanted...

Post by groepaz »

thank you, that helped :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: runable Graphics wanted...

Post by groepaz »

Oh btw, while i am at it... the point of this request was that i am fixing "native" Screenshots - ie C64 "koala" and "hires" formats.

Now the question is - is there a similar common format for vic20 aswell? and can you point to a description of the format, and preferably a pc based tool to display it (for quick testing)?
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: runable Graphics wanted...

Post by Mike »

groepaz wrote:Oh btw, while i am at it... the point of this request was that i am fixing "native" Screenshots - ie C64 "koala" and "hires" formats.

Now the question is - is there a similar common format for vic20 aswell? and can you point to a description of the format, and preferably a pc based tool to display it (for quick testing)?
I am the inventor of the aforementioned MG file format, so my view might be somewhat biased, but I think yes, it is the equivalent of *.koa for the VIC-20. There is enough 3rd party use of it to justify the point.

The format has been thoroughly documented in the MINIPAINT manual, in Appendix D, save for the static/boilerplate binary blobs at the begin and end. You get a copy of those with each saved file. ;)

Thus far I didn't consider a PC based viewer, but I can hack together a MG2PPM converter, which also would check the conformity of the static parts. Shall we discuss the details in PM?

I should note that MG displays a 160x192 pixel bitmap, whereas the standard text mode has an equivalent resolution of 176x184 pixels, so you won't be able to screenshot a text screen as MG bitmap.
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: runable Graphics wanted...

Post by groepaz »

We already have code to deal with the size differences (either scaling or cropping or adding borders), so that's no problem.

It raises another question though - is there also a "hires" format? :) Or does this work similar to the C64 Textmode, ie mixed hires and mulicolor, toggled by some bit in the color ram?
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: runable Graphics wanted...

Post by Mike »

groepaz wrote:Or does this work similar to the C64 Textmode, ie mixed hires and mulicolor, toggled by some bit in the color ram?
Exactly this. The VIC-I always renders a multi-colour text mode.
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: runable Graphics wanted...

Post by groepaz »

OK, fine, should be very doable then :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: runable Graphics wanted...

Post by Mike »

groepaz wrote:[...] can you point to a description of the format, and preferably a pc based tool to display it (for quick testing)?
Mike wrote:Thus far I didn't consider a PC based viewer, but I can hack together a MG2PPM converter, which also would check the conformity of the static parts. [...]
Here we go: (download)

You can use the resize function of your favourite image processing tool to apply the correct pixel aspect ratio. ;)

Code: Select all

/*
 *  mg_render.c - written 2020-09-17 by Michael Kircher
 *
 *  - validate and render a MG picture file to *.ppm with predefined palette.
 */

#include <stdio.h>
#include <stdlib.h>
#include "image.h"

#define X_SIZE 160
#define Y_SIZE 192

#define FILE_SIZE 4097

typedef enum {false,true} boolean;

RGB vic_palette[16]=
{
  {  0,   0,   0},  /* Black        */
  {255, 255, 255},  /* White        */
  {148,  23,   1},  /* Red          */
  { 82, 198, 212},  /* Cyan         */
  {144,  28, 204},  /* Purple       */
  { 81, 190,   8},  /* Green        */
  { 49,  26, 213},  /* Blue         */
  {196, 215,  28},  /* Yellow       */
  {163,  81,   0},  /* Orange       */
  {208, 176,  22},  /* Light Orange */
  {233, 121, 105},  /* Light Red    */
  {132, 243, 255},  /* Light Cyan   */
  {221, 115, 255},  /* Light Purple */
  {142, 246,  79},  /* Light Green  */
  {133, 112, 255},  /* Light Blue   */
  {242, 255,  84}   /* Light Yellow */
};

unsigned char MG_FILE_HEADER[]=
{
  0xF1, 0x10, 0x0C, 0x12, 0xD8, 0x07, 0x9E, 0x20, 0x38, 0x35,
  0x38, 0x34, 0x00, 0x00, 0x00
};

unsigned char MG_FILE_FOOTER[]=
{
  0x18, 0xA9, 0x10, 0xA8, 0x99, 0xF0, 0x0F, 0x69, 0x0C, 0x90,
  0x02, 0xE9, 0xEF, 0xC8, 0xD0, 0xF4, 0xA0, 0x05, 0x18, 0xB9,
  0xE4, 0xED, 0x79, 0xFA, 0x21, 0x99, 0x00, 0x90, 0x88, 0x10,
  0xF3, 0xAD, 0x0E, 0x90, 0x29, 0x0F, 0x0D, 0x0E, 0x12, 0x8D,
  0x0E, 0x90, 0xAD, 0x0F, 0x12, 0x8D, 0x0F, 0x90, 0xA9, 0x10,
  0x85, 0xFB, 0xA9, 0x12, 0x85, 0xFC, 0xA9, 0x00, 0x85, 0xFD,
  0xA9, 0x11, 0x85, 0xFE, 0xA2, 0x0F, 0xA0, 0x00, 0xB1, 0xFB,
  0x91, 0xFD, 0xC8, 0xD0, 0xF9, 0xE6, 0xFC, 0xE6, 0xFE, 0xCA,
  0xD0, 0xF2, 0xA2, 0x00, 0xA0, 0x00, 0xBD, 0x10, 0x21, 0xE8,
  0x99, 0x00, 0x94, 0xC8, 0x4A, 0x4A, 0x4A, 0x4A, 0x99, 0x00,
  0x94, 0xC8, 0xC0, 0xF0, 0xD0, 0xEC, 0x20, 0xE4, 0xFF, 0xF0,
  0xFB, 0x4C, 0x32, 0xFD, 0x02, 0xFE, 0xFE, 0xEB, 0x00, 0x0C
};

IMAGE *mg_render(unsigned char *raw)
{
  IMAGE *dst;
  if(NULL != (dst=image_alloc(X_SIZE,Y_SIZE,RGB_IMG)))
  {
    RGB temp,palette[4];
    int x1,x2,y1,y2;
    unsigned char bitmap,colour;
    boolean is_multi,is_inverse=(0 == (raw[-1]&0x08));

    palette[3]=vic_palette[(raw[-2]>>4)&0x0F];
    for(y1=0; y1<Y_SIZE/16; y1++)
      for(x1=0; x1<X_SIZE/8; x1++)
      {
        colour=(raw+X_SIZE*Y_SIZE/8)[((X_SIZE/8)*y1+x1)/2];
        palette[0]=vic_palette[(raw[-1]>>4)&0x0F];
        if(0 == (x1&1))
        {
          palette[1]=vic_palette[colour&0x07];
          is_multi=(0 != (colour&0x08));
        }
        else
        {
          palette[1]=vic_palette[(colour>>4)&0x07];
          is_multi=(0 != ((colour>>4)&0x08));
        }
        palette[2]=vic_palette[raw[-1]&0x07];
        if(is_multi)
        {
          temp=palette[1]; palette[1]=palette[2]; palette[2]=temp;
        }
        else if(is_inverse)
        {
          temp=palette[0]; palette[0]=palette[1]; palette[1]=temp;
        }
        for(y2=0; y2<16; y2++)
        {
          bitmap=raw[Y_SIZE*x1+16*y1+y2];
          if(!is_multi)
            for(x2=0; x2<8; x2+=1)
              rgb_pixel(dst,8*x1+x2,16*y1+y2)=palette[(bitmap>>(7-x2))&0x01];
          else
            for(x2=0; x2<8; x2+=2)
            {
              int x=8*x1+x2,y=16*y1+y2;
              rgb_pixel(dst,x+1,y)=rgb_pixel(dst,x,y)=palette[(bitmap>>(6-x2))&0x03];
            }
        }
      }
  }
  return(dst);
}

int main(int argc, char *argv[])
{
  FILE *src;
  IMAGE *dst;
  unsigned char file[FILE_SIZE];
  int i, data;

  if(3 != argc)
  {
    fprintf(stderr,"%s: Syntax: %s <in_file> <out_file>\n",argv[0],argv[0]);
    exit(EXIT_FAILURE);
  }

  if(NULL == (src=fopen(argv[1],"rb")))
  {
    fprintf(stderr,"%s: Error: could not open file \'%s\' for read access.\n",argv[0],argv[1]);
    exit(EXIT_FAILURE);
  }

  for(i=0; i<FILE_SIZE; i++)
  {
    if(EOF == (data=getc(src)))
    {
      fprintf(stderr,"%s: Error: file \'%s\' truncated.\n",argv[0],argv[1]);
      exit(EXIT_FAILURE);
    }
    file[i]=data;
  }
  if(EOF != (data=getc(src)))
  {
    fprintf(stderr,"%s: Error: file \'%s\' over-length.\n",argv[0],argv[1]);
    exit(EXIT_FAILURE);
  }

  fclose(src);

  for(i=0; i<sizeof(MG_FILE_HEADER); i++)
  {
    if(file[i] != MG_FILE_HEADER[i])
    {
      fprintf(stderr,"%s: Error: file \'%s\', header mismatch.\n",argv[0],argv[1]);
      exit(EXIT_FAILURE);
    }
  }
  for(i=0; i<sizeof(MG_FILE_FOOTER); i++)
  {
    if(file[i+FILE_SIZE-sizeof(MG_FILE_FOOTER)] != MG_FILE_FOOTER[i])
    {
      fprintf(stderr,"%s: Error: file \'%s\', footer mismatch.\n",argv[0],argv[1]);
      exit(EXIT_FAILURE);
    }
  }
  if(0 != (file[15] & 0x0F))
  {
    fprintf(stderr,"%s: Error: file \'%s\' saved with non-0 audio volume.\n",argv[0],argv[1]);
    exit(EXIT_FAILURE);
  }

  dst=mg_render(file+17);
  image_save(dst,argv[2]);
  image_free(dst);

  exit(EXIT_SUCCESS);
}
Greetings,

Michael
User avatar
pixel
Vic 20 Scientist
Posts: 1357
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: runable Graphics wanted...

Post by pixel »

Mike wrote: Fri Sep 18, 2020 5:42 am Here we go: (download)
Hey, thant's great! If you don't mind I slap on an open-source license of your choice, refurbish it a bit, add a make script for Unices and put it on Github. :)
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: runable Graphics wanted...

Post by Mike »

pixel wrote:Hey, thant's great! If you don't mind I slap on an open-source license of your choice, refurbish it a bit, add a make script for Unices and put it on Github. :)
@pixel: PM sent.

For the interested parties: "image.c", "image.h" and "matrix.h" are licenced with CC0, and "mg_render.c" is licenced with CC-BY-SA.
User avatar
pixel
Vic 20 Scientist
Posts: 1357
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: runable Graphics wanted...

Post by pixel »

Mike wrote: Wed Sep 23, 2020 1:35 am For the interested parties: "image.c", "image.h" and "matrix.h" are licenced with CC0, and "mg_render.c" is licenced with CC-BY-SA.
It's been finished a couple of days ago – if someone could tell me how (what text) to include these licenses in the sources that'd be much of a help.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1357
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: runable Graphics wanted...

Post by pixel »

Here is the unixoid version: https://github.com/SvenMichaelKlose/mg_render with Windoze executable included.

Took some extra time because of a lot of regular work and then something that could've been COVID knocked me out for the better part of the week.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: runable Graphics wanted...

Post by groepaz »

Oookay, i finally found the time to actually add this :)

https://sourceforge.net/p/vice-emu/code/39977/

Not perfect yet, Hires blocks not handled at all right now. The algorithm that chooses the common/shared colors can probably be improved. The tables used for color substitution are kindof bad. Patches welcome :)

Find an ad hoc build for windows here: https://github.com/VICE-Team/svn-mirror ... tag/r39977

Cheers :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
ops
Vic 20 Dabbler
Posts: 88
Joined: Mon Feb 19, 2018 11:25 am
Location: Finland

Re: runable Graphics wanted...

Post by ops »

Thanks, interesting feature. I just tested on Linux.

Multicolor seems pretty OK but hires needs to be supported to get decent screenshots from games.

Screenshot from 2021-05-03 22-28-34.png
Screenshot from 2021-05-03 22-33-13.png
Post Reply