Login
PETSCII to BASIC lines
Title:PETSCII to BASIC lines
Category:Utility/Graphic
Release Date:
Language:English
Size:16K
Machine:PAL & NTSC
Code Type:Basic
Distribution:Freeware
Code by:RoePipi
Notes:
No votes yet.
PETSCII to BASIC lines Screenshot


Description
"PETSCII image to BASIC lines with formatting" by PipiSoft 2019

INTRODUCTION
============

Ever been annoyed drawing some nice PETSCII graphics on-screen realizing you couldn't save it in BASIC program lines in an easy - and somehow quicker than typing it in - way?
Maybe you want to insert it in your existing BASIC program...
You could save it in a .prg file... but then you'd have to load it in separately.
Or maybe you liked a particular screen in a program, and you want to illustrate it in your own one.
Or maybe you want to spare space for your PETSCII graphics and don't want to do it by hand.
If any of these is true, this program is for you.

FEATURES
========

- Generate BASIC lines beside/into an existing BASIC program in memory
- Add multiple images to your BASIC program
- Spare 30-40% of storage required (e.g. 1300 bytes of BASIC lines instead of 2000 bytes of prg)
- Supports colored, reverse and flashing characters
- Supports converting spaces to Cursor Right characters
- Supports processing only a rectangular area, albeit a bit complicated
- Ability to store picture rows in reverse order
- Output is somewhat compatible with C64

TL;DR QUICK USAGE
=================

1. Paste program code to emulator.
2. MONITOR, L"your picture $0800-$0fe7",8
3. ESC+T ESC+B a window at the bottom, X, GOTO60000
4. Home, Enter 11 times, repeat from step 2 but with a window at the top.
5. Repeat a 3rd time.
6. Congratulations, you've got your picture in 25 PRINT lines.

PROGRAM CODE
============

60000 W=0:S=10:C$="?":Q$="'":U=32:CU=0:IFI=0THENINPUT"BASE LINE NUMBER, INCREMENT";B,I
60010 N=0:DO:C=0:R=0:F=0:A$="":IFWTHENK=39:ELSECHAR,0,T,CHR$(27)+"K":K=POS(0)+1
60020 DO:P=3072+T*40+C:A=PEEK(P):IF(AAND128)<>RTHENR=128-R:A$=A$+CHR$(146-R)
60030 IFA<>UTHENE=PEEK(P-1024):IF(EAND128)<>FTHENF=128-F:A$=A$+CHR$(132-F/64)
60035 IFA<>UTHENE=EAND127:DOUNTILE=D:J=15:DOUNTILJ=0ORE=PEEK(275+J):J=J-1:LOOP
60040 IFA<>UTHENPOKE1177,62:D=PEEK(57651+J):POKE1177,63:A$=A$+CHR$(D):D=E:LOOP
60050 A=AAND127:A=A-(A<32)*64-(A>63)*32-(A>95)*32:IFA=34THENA=ASC(Q$)
60055 POKE65292,P/256:POKE65293,PAND255:IFCUTHENIFPEEK(P)=UTHENA=29
60060 A$=A$+CHR$(A):C=C+1:LOOPUNTILC>=K:A$(N)=A$
60070 T=T+1:N=N+1:LOOPUNTILN>S-1ORT>24:IFI=0THENI=1
60080 ?CHR$(27)"N";:FORJ=0TON-1:?B+(J+T-N)*I;C$CHR$(34)A$(J)CHR$(34):NEXT
60090 IFT<25THEN?"T="T":B="B":I="I":D="D;

USAGE
=====

WARNING: This program will clear your picture while processing, usually more times. You'll have to reload it each time.
NOTE: Make sure the picture has the matching color key table at $0113-$0122 (see "Extra tips" below). Foreign color codes will be converted to black/first color.
1. Make sure my program lines won't overwrite yours, renumber if necessary (to allow this, I avoided using GOTOs or any kind of line references).
2. Paste program lines into emulator window. See "Advanced options" now if you wish to use them.
3. Load your picture in screen memory ($0800-$0fe7) without changing the BASIC end-of-program pointers ($2d-$32), e.g. using L command in MONITOR mode (use rows near the top, to avoid scrolling).
4. If needed, restrict the active scrollable screen area to at least one row using ESC+T and ESC+B key commands. It's possible to resort to different areas of the screen in different sessions.
5. Use a free row to start the program with GOTO 60000 and press Enter. (Don't forget to X from MONITOR mode if you used that.)
6. Enter base line number (the first line number to store your graphics) and increment (between lines). You can use a negative increment to store your picture rows in reverse order.
7. The program recomposes 10 lines from your picture, then deletes the screen and displays your new program lines.
8. If you're satisfied with the results, press Enter on each new line, including the last one with the needed variables, then repeat steps from 3. A whole screen usually requires 3 turns.
9. Delete the program's lines if you wish (60000-60090), then save everything else.

Advanced options
================

For consistency, you should NOT change these between sessions processing an image.
- Whole rows (W, line 60000): If set to 1, DATA lines will contain all the 40 characters per line, not just up to the last non-space char.
- Command to use (C$, line 60000): You can use e.g. DATA lines instead of PRINT.
- Top row to start (T): specify T=(row) before GOTO 60000. T must be between 0 and 24, 24 being the bottom of the screen.
- Generated lines per session (S, line 60000): If you get too many or too few lines in one go, you can change this variable.
- Left column of picture (C, line 60010): Use it if your picture is further right from the left border.
- Right column of picture: To specify this, set Whole rows flag (W, line 60000) to 1 and replace K=39 in line 60010 to the desired number (0-39, 39 being the rightmost column).
- Neutral screen code (U, default: 32, line 60000): It prevents unnecessary color/flash switching when processing blank characters, by default, spaces.
If you need to keep colors of all characters, e.g. when processing game levels, set it to -1.
- Use Cursor Right characters instead of blank characters (CU, line 60000): Set to 1 if needed.
- If you're sure there's enough space in your current window to display all the needed data lines, you can erase ?CHR$(27)"N";: from line 60080.

ALTERNATIVE LINES
=================

If PEEKing from ROM causes problems:
60040 IFA<>UTHENA$=A$+CHR$(DEC(MID$("90051C9F9C1E1F9E8195969798999A9B",J*2+1,2))):D=E:LOOP
(Long line, please shorten some statements after pasting)

PROGRAM FLOW
============

60000 Set user variables.
60010 / New session. Start a new line, reset reverse and flash modes, empty data string, determine rightmost column,
60020 : / Process actual line. Read next char from screen, switch reverse mode if necessary,
60030 : : / If it isn't a space, check its color, switch flashing mode if necessary.
60035 : : : To match, find it in the color keys' table,
60040 : : \ Add matching CHR$ color char to data string.
60050 : : Convert screen code to CHR$,
60055 : : Show cursor at actual character. Substitute blank char with Cursor Right if needed.
60060 : \ Add actual char to data string, increase column count, end line, store data string into array.
60070 \ Increase line count, end session, make sure line count is not 0.
60080 Empty screen, print data lines,
60090 If there can be more rows, output variables to use in next session.

VARIABLES
=========

set A next char code (0-255)
set A$ actual PRINT data line
set A$(0-10) PRINT data lines (x2 lines expected on screen)
user B base line number
set C actual column (0-39)
user C$ command used at data lines
user CU use cursor right chars instead of spaces (0/1)
saved D last color code used (0-255)
set E next color code (0-255)
set F flashing mode (0/128)
user I line increment (<>0)
set J color code search (0-15)
set K actual column limit (0-39)
set N actual PRINT data line (0-10)
set P cursor position on screen (3072-4071)
user Q$ quotation marks replacement char
set R reverse mode (0/128)
user S rows generated lines per session (1-11)
user T top top row to work with (0-24)
user U neutral screen code (default: 32)
user W whole rows flag (0/1)

NOTES
=====

- Reverse and flashing modes are turned off each new line as normal.
- Empty lines are interpreted as one blank char.

LIMITATIONS
===========

- Quotation marks (") will be converted to apostrophes ('). You may need to try other methods to add them to the picture later.
- Can't check the resulting line lengths. Please cut them into more lines if needed.

EXTRA TIPS
==========

- Using YAPE, you can export any screen from programs selecting File / Save as PRG... from menu and saving a .prg file from address $0800 to $0fe8. Also, you can save the actual color key table from $0113 to $0123.

Copyright © Plus/4 World Team, 2001-2024