TextMode Editor (petDraw in BASLOAD)

Talk about your programs in progress. Discuss how to implement features, etc.
Forum rules
This section is for testing Commander X16 programs and programs related to the CX16 for other platforms (compilers, data conversion tools, etc.)

Feel free to post works in progress, test builds, prototypes, and tech demos.

Finished works go in the Downloads category. Don't forget to add a hashtag (#) and the version number your program was meant to run on. (ie: #R41).
Post Reply
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

TextMode Editor (petDraw in BASLOAD)

Post by Xiphod »

UPDATE: WIP complete, see actual maintained releases now at the following...
viewtopic.php?p=35499#p35499

Another 'while on the airplane' project, a little "what can do in 2 hours" challenge.

petDraw is good - its pixel-mode is hard to beat. But I still wanted a "text-mode screen-editor" program in BASLOAD - one, to show BASLOAD can do it. and two, just a few different features that I wanted beyond what petDraw had.

Basic premise is done, the program was written to (eventually) scale to whatever screen mode you end up using. A status bar at the top is a rolodex of available symbols (use [ ] or { } to cycle across those). Spacebar to doodle the current active symbol.

But the other feature is what I'm calling a "character set" mode and "display code" mode. With the eventual goal of being able export to BASIC code that contains the native character-set PRINT compatible code (that would then be mostly portable to PET and C64), or speedier TILE commands (maybe for smaller/partial text-blobs; less than full screen), or of course in a raw format compatible with BVLOAD.
EDITOR.JPG
EDITOR.JPG (34.18 KiB) Viewed 1229 times

WIP, some things left to do:
- save/load
- color handling (alter foreground/background)
- probably toggle the status bar from top to bottom
- change color of the active symbol, for contrast against the active-marker
- CTRL+N hotkeys to store "favorites" of symbols into groups (and save these hot key assignments)
- maybe an alphanumeric mode, so you can just start writing plain-text to make it part of the scene


EDIT: This initial "concept" version is fairly obsolete, but keeping around as a base (barebones) example for doing a full-screen editor and handling cursor movement from within BASLOAD.
Attachments
SYMBOL.PRG
(148 Bytes) Downloaded 44 times
EDITOR.BASL.TXT
(6.06 KiB) Downloaded 43 times
Last edited by Xiphod on Thu Jan 16, 2025 1:34 pm, edited 2 times in total.
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

Re: TextMode Editor (petDraw in BASLOAD)

Post by Xiphod »

Getting closer to actually being useful. No Save/Load yet, focused on adding Foreground/Background color support first.

CTRL-UP increase Foreground color
CTRL-DOWN decrease Foreground color
CTRL-RIGHT increase Background color
CTRL-LEFT decrease Background color

[ ] Decrease/Increase current active symbol (by 1)
{ } Decrease/Increase current active symbol (by 10)

ARROW KEYS to move the cursor around
DELETE Fast delete the current text cell (revert it back to empty space)
SPACEBAR Stamp the current symbol using the current selected color

"P" to apply the current selected color (Paint Color)
"C" to select the color of the current text cell as the selected color (Get Color)

ESC to exit


- bugfix in the character set-mode (TDATA always returns screen/display codes, have to adapt them back to PETSCII codes)
- but now there is another known bug if you switch back to display mode, the current text cell might become corrupted (can fix; for now, best to choose which mode you want at the start)

- when you move to a cell, top right corner has the decimal value of the current symbol index (this decimal value is shown using the current selected color)
- when starting the program, it will remain the current SCREEN resolution (so you can now run this using SCREEN 7, SCREEN 5, SCREEN 11, etc).
- default background to black (not sure how to do an option to cycle the background color, and how that should impact existing populated text cells; maybe it just erases the whole canvas each time)
- I think next time I'll change P->C (capture color) and C->A (activate color), so won't have to move hand so much
- gamepad support might be do-able here, may do that after SAVE/LOAD
- thinking of using F1-F12 to draw symbols (F1 the most left one, F2 the next one, etc). I think that's how TheDRAW used to do it.


editor2.jpg
editor2.jpg (30.54 KiB) Viewed 1103 times
editor1.jpg
editor1.jpg (29.22 KiB) Viewed 1103 times
Attachments
EDITOR.BASL.TXT
(12.01 KiB) Downloaded 41 times
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

Re: TextMode Editor (petDraw in BASLOAD)

Post by Xiphod »

REVISION 3 is now actually useful: an initial SAVE/LOAD is now working

- status row moved to the bottom (and now also shows current indexed symbol)
- fixed screen code back to characterset code conversion bug (PRINT CHR$ has to use the REVERSE codes to support a few group of screen-codes); the attached PETSCREEN.PRG is a test program to demonstrate this
- F5 save/F6 load hard-coded to save the text-mode VRAM directly to a TEST.BIN file (a few tricks to try to make the SAVE fast; but enabling the warp mode in the emulator also helps)
- idea: change symbol-selector into "useful groups" (maybe; the current selector is "font-agnostic" to avoid being biased towards just using PETSCII fonts)
- idea: SHIFT+ARROW to quick copy the current active symbol
- idea: a "bulk move" to shift portions of the scene around


Load by doing:

Code: Select all

BASLOAD"EDITOR.BASL.TXT"
RUN
Supported keys:
- "A" to APPLY the current active color (used to be "P")
- "C" to CAPTURE the color at the cursor position (and make it the current active color)
- "M" toggle between "character set" mode and "screen code" mode
- arrow keys: move cursor around the text-screen
- CTRL-ARROW keys: adjust the FG (foreground) and BG (background) of current active color [gets auto-applied to current text cell]
- "[" or "]": adjust the current active symbol left/right (move by 1)
- SHIFT "[" or "]" (i.e. { or }): fast-adjust the current active symbol left/right (move by 10)
- PGUP/PGDN: move cursor to top/bottom of text screen
- HOME/END: move cursor to left/right side of text screen
- DEL: reset text cell at cursor position (to black space)
- F5: save to TEXT.BIN (overwrites existing, saves only the currently active screen resolution portion; outside of this, $FF is used)
- F6: load from TEXT.BIN


Additional save options are TBD, but as a premise:

The idea of "character-mode" is you'll be able to save/export into a sequence of BASIC code and PRINT commands that will replicate the text-mode scene (using CHR$ as appropriate for inverse and colors). This generated code might be more compatible with other CBM systems, or useful if you just want to work with snippets/portions of the scene in "regular BASIC."

Whereas "screen code mode" will operate more with the TILE command, which is faster (sort of) but a little more obscure to work with from BASIC (probably end up as a sequence of DATA). TILE doesn't automatically increment to next column or row, so it's good for "surgical" screen edits talking directly to VRAM. While "character-mode" may be better for "bulk" output or long sequences of characters. So it just depends.

For now, the SAVE/LOAD just stores the text-mode VRAM as-is, just as a quick way to save the full-screen creative work and make it easier to test and build up the other features.



editor3.jpg
editor3.jpg (152.93 KiB) Viewed 1014 times
Attachments
EDITOR.BASL.TXT
(13.64 KiB) Downloaded 38 times
TEXT.BIN
(14.75 KiB) Downloaded 39 times
PETSCREEN.PRG
(836 Bytes) Downloaded 38 times
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

Re: TextMode Editor (petDraw in BASLOAD)

Post by Xiphod »

Big update. Fairly full featured now. Will focus more on EXPORT options next (to raw code, and scene-portions).

- SAVE/LOAD can now specify filename

- Symbols at bottom are now a user-defined index into the font table (so you can define your own groups of "favorite fonts")
- This table can be adjusted and saved in program, or it's a simple text-file format that can be edited (supports up to 900 indexes)

- Next update will export-to-characterset (PETSCII) PRINT CHR$, but all the editing is now just using direct display-codes (supporting both modes within BASIC was just getting slow, and not really necessary since we can handle it during the export). In app-editing of the symbol indexes is done using SHIFT-UP/DOWN to adjust the symbol index of the currently active slot.

- The font-index-order can be SAVE using F2, LOAD it using F3 (program doesn't load it automatically on startup; I may change this, but main reason is because the load is a little slow -- I thought about changing to a faster binary-blob format, but I like that it's easy to edit the symbol-index table from notepad or other external editors)

- Can press 1 through 9 (plus 0) to quickly stamp from the active symbol + the selected offset. e.g. pressing "5" will stamp the current active symbol plus 5 offsets away. Since we can group symbols now, the idea is you just move the active symbol to a group you're working with, then press 1-0 to apply them. Can still do spacebar to just apply the active symbol at the cursor position (so pressing 1 is effectively the same as pressing spacebar).

- T command added to "target" the current symbol (looks it up in the symbol table)

- can still use "C" to capture a color and "A" to apply it

- ALT-ARROW keys to "speed stamp" the current symbol (so don't have to move-then-spacebar, can just hold down ALT and move around). Good for filling up a space with color or drawing long sequences of a symbol.


Press F6 to load the default sample image and F3 to load the initial reference font-index symbol table.

Try It Now!

TODOs:
- thinking F9/F10 for a quick save (to a fixed filename). So if you want to test some changes, but then can revert if they don't pan out. Or maybe quick-save would auto-append 0/1/2/3/etc. to the last saved filename. But the copy from VRAM to RAM then disk is still a bit slow here in BASIC.

- thinking of sacrificing HEIGHT-1 row for two lines of menu/status (for example, to output current cursor location numbers or maybe to add a kind of "ruler", which may be necessary for some "move" features)

- a "bulk move" to shift portions of the scene. Little tricky, on how to specify the portion, and also to move in a non-destructive way to other content in the scene.
SCREEN_EDITOR.jpg
SCREEN_EDITOR.jpg (123.34 KiB) Viewed 850 times
Attachments
EDITOR_V1.ZIP
(110.99 KiB) Downloaded 41 times
EDITOR.BASL.TXT
(23.97 KiB) Downloaded 35 times
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

Re: TextMode Editor (petDraw in BASLOAD)

Post by Xiphod »

Full set of keys (also listed in the .TXT of the .ZIP)

Code: Select all

================================================================================
KEYS:

ARROW-KEYS        MOVE FLASHING CURSOR
HOME/END          MOVE CURSOR TO LEFT/RIGHT SIDE OF SCREEN ON CURRENT ROW
PGUP/PGDN         MOVE CURSOR TO TOP/BOTTOM SIDE OF SCREEN ON CURRENT COL

ALT-ARROW KEYS    Auto-apply the active symbol while move cursor around
                  (for quickly apply areas that use the same symbol)

CTRL-LEFT/RIGHT   ADJUST SELECTED BACKGROUND COLOR
CTRL-UP/DOWN      ADJUST SELECTED FOREGROUND COLOR

SHIFT-UP          INCREMENT FONT INDEX OF ACTIVE SYMBOL
SHIFT-DOWN        DECREMENT FONT INDEX OF ACTIVE SYMBOL

SPACEBAR          STAMP ACTIVE SYMBOL AT CURSOR POSITION
DELETE            CLEAR TEXT-CELL AT CURRENT CURSOR POSITION

[ or ]            DECREMENT/INCREMENT ACTIVE SYMBOL SLOT (by 1)
{ or }            FAST DECREMENT/INCREMENT ACTIVE SYMBOL SLOT (by 10)

T                 TARGET (find current cursor symbol in the symbol selection)
C                 CAPTURE COLOR (set color at cursor as the active color)
A                 APPLY COLOR (apply the active color to the current cursor symbol)

1..9 and 0        STAMP ACTIVE SYMBOL PLUS SPECIFIED OFFSET
                  1 == offset 0 (current active symbol, same as spacebar)
                  2 == offset 1
                  ...
                  9 == offset 8
                  0 == offset 9

F2                SAVE entire symbol table state (FONT.BIN)
                  FONT.BIN can be manually edited thereafter (simple format)

F3                LOAD entire symbol table state (FONT.BIN)

F5                SAVE SCENE (specify filename, ESCAPE to abort)
F6                LOAD SCENE (specify filename, ESCAPE to abort)

ESCAPE            EXIT PROGRAM (will lose scene if not saved!)
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

Re: TextMode Editor (petDraw in BASLOAD)

Post by Xiphod »

Added mouse support and one EXPORT feature (to export "just populated non-blank content" as a DATA sequence); the "raw" VRAM save is still there also for a full scene.

Solid and enough features, I think it's ready for Downloads. See:

viewtopic.php?p=35499
Post Reply