MINIGRAFIK batch processing suite

Basic and Machine Language

Moderator: Moderators

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

MINIGRAFIK batch processing suite

Postby Mike » Sun May 29, 2011 6:06 am

Hi, y'all!

As I promised in the MINIPAINT thread long time ago, here's the current version of the MG batch processing suite (download):

Image

The examples generally require at least a +8K RAM expansion, some of them need more ('EARTH GLOBE 2' also needs RAM in BLK5).

Most of the utilities and example programs already had been published elsewhere, I've collected them onto a *.d64 disk image in the archive. These comprise, inter alia:

- import of 80x192 and 160x192 *.pgm files,
- export to Koala format (with a viewer running on C64 included),
- routines to draw boxes, ellipses, fill areas and print text,
- examples accessing the MG screen from machine language,
- the VIC DOS wedge, a file tokenizer, and a program restore utility for use after NEW or reset ('OLD'),
- and two picture slide shows!!

Greetings,

Michael

P.S.: For those new to MINIGRAFIK, here's a manual of MG.
Last edited by Mike on Thu Feb 20, 2014 4:27 pm, edited 3 times in total.

User avatar
Wilson
Vic 20 Enthusiast
Posts: 156
Joined: Mon Sep 28, 2009 7:19 am

Postby Wilson » Sun May 29, 2011 10:49 pm

Yay!
I had good fun playing with a bunch of the example programs today. The slide show was very enjoyable as well. The parrot had a greater impression on me this time around for some reason. :)
Thanks Mike and everybody involved for all the hard work that brought this suite to fruition.

Unfortunately, I cannot get what is, IMO, the most useful tool in this suite to work: PGM IMPORT. Unless it takes an extremely long time to run, both the hires and multicolor versions seem to just hang when I run VICE on warp. With 1581 TDE I get a "string too long" error in lines 31 and 33 for the hires and multicolor versions respectively. I've tried about as much as I can think of, so I'm finally going to have to admit defeat on this one. This has been my process:
>convert 160x192 .bmp to .pgm in IrfanView/ImageMagick (same results with both)
>write resulting .pgm to a .d81 file
>run PGM IMPORT and enter the filename with and without the PGM extension.
And... nothing. :(
The PGM file I'm using is 8bpp. Neither ImageMagick or IrfanView seem to allow me to produce anything lower.

I know orion70 and others have used it just fine so I must be overlooking something here. Anyone have an idea?

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Mon May 30, 2011 2:31 am

Wilson wrote:PGM IMPORT. Unless it takes an extremely long time to run, both the hires and multicolor versions seem to just hang when I run VICE on warp.

When you've done all user input, PGM IMPORT responds with the echoed header of the file, it should read:

Code: Select all

P5
80 192
255

HEADER OK. PRESS KEY.

PGM IMPORT MONO expects '160 192' instead. Conversion then starts after the key press. If one of those lines doesn't match, conversion is halted. If you get a '?STRING TOO LONG' error, that might indicate one of the programs involved in transferring the file has somehow messed up the line endings. In *.pgm files, these header lines are supposed to end with ASCII 10 (LF), and not ASCII 13 (CR, or even CR+LF).

You should also check in the directory of the *.d81, whether the file really has the name you intended. Normally, on the PC side, it should be given in lower-case, but written in upper-case (but unshifted!) on the VIC-20. If you write the file name in upper-case on the PC, this is usually translated to shifted characters on the VIC-20, most probably not what you wanted.

Michael

User avatar
orion70
Meteo VIC
Posts: 3328
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Postby orion70 » Mon May 30, 2011 5:11 am

Hello, I don't know if this could be of help, but in my experience I had this 'string too long error' when I input the wrong file name. Also, it can be a wrong image format, but first I'd check the name (be sure it includes the extension if there's one).

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Postby GreyGhost » Mon May 30, 2011 5:54 am

What PC program do you guys use to convert a picture(jpeg, gif, bmp ) to a pgm file?
Rob

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Mon May 30, 2011 8:24 am

I use IrfanView for that task.

First, from the picture select a window which has the same proportions as the MG screen has on a monitor. For a PAL VIC-20 this is roughly 1.4:1 (you see this number in the title bar of the IrfanView window), this figure is slightly different for NTSC. Then crop the picture to the window with 'Edit > Crop selection' (Ctrl-Y). In the menu 'Image > Resize/Resample' choose:

'Preserve aspect ratio' ticked off,
Width: 80 or 160,
Height: 192,
Resample > Bell filter,

and press OK. Finally, do 'Image > Convert to Greyscale' and save the resulting image as *.pgm.

PGM IMPORT MONO does no dithering and is best for converting line art. If your picture contains smooth luminance gradations, PGM IMPORT can convert them to dither patterns simulating 13 different 'grey' scales. The two end colours are always white and black, but the two intermediate colours can be chosen from all 16 colours available. The first intermediate colour should be the darker one, otherwise you'll get a strange contrast.

User avatar
tokra
Vic 20 Nerd
Posts: 836
Joined: Tue Apr 27, 2010 5:32 pm
Location: Germany

Postby tokra » Mon May 30, 2011 10:44 am

I use IrfanView as well, and you should make sure when saving to set "Compression level" to 0 and to "Binary encoding"

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Mon May 30, 2011 12:19 pm

The *.pgm file should indeed be saved in binary encoding. The ASCII encoding would be rejected by PGM IMPORT, because the header is different (P2 instead of P5).

The compression level shown in the dialog box only applies to PNG output though, and can savely be left at 6. Also, there's no compression used in *.pgm files.

@Wilson: Oh, and I found another obstacle while reading the listing of PGM IMPORT again I posted once: the OPEN command requires a SEQ file to open, so that is what your transfer program to *.d81 should save the file as (I had a good reason to use the SEQ file type for this: *.pgm files are not programs, and do not have a two-byte start address!)

If your transfer program doesn't support typing the file as SEQ, you might either temporarily alter ",S,R" to ",P,R" or leave out the transfer to the *.d81 image completely, instead mount drive #8 as VDrive in VICE, pointing to the directory on the host PC where that file resides. VDrive simply ignores the CBM DOS file type (PRG, SEQ, ...)

User avatar
Wilson
Vic 20 Enthusiast
Posts: 156
Joined: Mon Sep 28, 2009 7:19 am

Postby Wilson » Mon May 30, 2011 10:59 pm

orion70 wrote:Hello, I don't know if this could be of help, but in my experience I had this 'string too long error' when I input the wrong file name. Also, it can be a wrong image format, but first I'd check the name (be sure it includes the extension if there's one).
Thanks for the suggestion! I exhausted pretty much every combination of the file name and possible extensions trying to figure this out... Many times the error probably was caused by an invalid file name because of this. :lol:
Mike wrote:@Wilson: Oh, and I found another obstacle while reading the listing of PGM IMPORT again I posted once: the OPEN command requires a SEQ file to open, so that is what your transfer program to *.d81 should save the file as (I had a good reason to use the SEQ file type for this: *.pgm files are not programs, and do not have a two-byte start address!)

Thank you, that was the problem. :) How silly of me to not check the file type. I now have it working with VDrive and disk images. VDrive is undeniably handier though. Thanks for that tip as well.
I was very excited to see the image appear during the conversion process.
I can't express the usefulness of this utility in words, so I'll try to make something in the next week.

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Tue May 31, 2011 2:53 am

Nice to read you got it to work! :D

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Postby GreyGhost » Tue May 31, 2011 6:55 am

Hi, I'm getting the string too long error also, and I think I'm following the instructions above correctly. Using a hex editor (HxD) I have this for a header in the pgm file:

P5.# Created by IrfanView.160 192.255.
And then starts with a series of 00 or FF. I'm assuming off and on bits when read by the Vic.

Is this correct? It seems to have all the correct numbers in the header.

Also, I'm using the Vdrive in VICE and stripping the .pgm off the end of the file. Is this ok, or should I add the .seq extension to it? Or just leave the .pgm on it? File name is written in lowercase letters. What else can I be doing wrong?(heh any number of things I'd guess)
Rob

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Tue May 31, 2011 7:13 am

GreyGhost wrote:Hi, I'm getting the string too long error also [...] I have this for a header in the pgm file:

P5.# Created by IrfanView.160 192.255.

That looks correct. Lines in the header beginning with '#' are comments, and PGM IMPORT ignores them.

Also, I'm using the Vdrive in VICE and stripping the .pgm off the end of the file.

You can leave the file name as is, and enter the full filename with extension. As I wrote above, VDrive ignores the CBM DOS file type.

If you do a 'LOAD"$",8', you can check that VDrive indeed has mounted the directory as intended. You should also tick off both options 'read/write *.p00 files' - if they're selected that could be one reason VDrive cannot find your *.pgm file (VDrive then tries to search for a file with a name similar to 'NAMEPGM.S00', and will fail).

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Postby GreyGhost » Tue May 31, 2011 2:32 pm

:D :lol: :D It was the checked boxes. I unchecked read/write .p00 and it worked first time.

Thanks, this opens up a whole new avenue for me.
Rob

User avatar
Mike
Herr VC
Posts: 3079
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Wed Jun 01, 2011 3:08 pm

You see, VICE still is good for some surprises. :)

The programs all use the @-prefixed commands of MINIGRAFIK, but it is still possible, and often useful, to directly access the bitmap with PEEK and POKE. That is done for example in MG TEXT PRINT, where the character ROM is transferred byte-wise to the bitmap.

The bitmap is located in the range 4352 to 8191 (3840 bytes), and the colour RAM uses the range 37888 to 38127 (240 bytes). It is surely quite instructive to try out that access method for own programs.

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Postby GreyGhost » Wed Jun 01, 2011 5:15 pm

I went a little crazy last night and made this slide slow. All but one are black and white. Btw, I like fantasy art.

http://www.freedrive.com/file/1458209
Rob


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 0 guests