BasEdit.NET

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

BasEdit.NET

Post by Schlowski »

Hi,

finally after some years I managed to convert / upgrade my old BasEdit to the .NET platform. Switching from DirectX graphics to GDI+ should help all those people who had difficulties to use BasEdit until now.
It's written with VB Express 2008 and uses .NET 3.5

Image

Featurelist:

Code: Select all

Purpose: 
Edit Commodore Basic files on the PC with syntax highlighting and support of the full PETSCII character set

Features:
- full featured editor 
  - unlimited lines
  - syntax highlighting
  - cut&paste
  - search&replace 
  - insert and overwrite mode
  - switch font size small / big
  - switch font upper/graphics - lower/upper
  - supports special characters for cursor movement and colors in strings
  - character window with all 256 PETSCII characters, double-click to insert characters at actual position
  - right-click on a line number to jump to that line
- load and save tokenized BASIC (PRG) files
- load and save PETSCII (untokenized) files
- load and save ASCII files
  - with support of different translations for {up}, {down}, {clr} etc.
    - BasText
    - PetCat
    - Tok64 
- support for
  - host filesystem (= directories on PC) 
  - diskimages (read & write)
    - D64
    - D71
    - D81 (no partitions)   
    - attach existing or create empty diskimages
    - diskmanager tool integrated 
      - copy files from / to diskimage
      - delete files
      - rename files
      - change order of files in directory
- copy and paste ASCII blocks via clipboard using the above translations
- supports different Basic dialects 
  - Basic V2
  - Basic V3.5
  - Basic V4
  - Basic V4/C64
  - Basic V7
  - Basic V10
  - @Basic
  - Exbasic Level II
  - Wimbasic
  - Speech Basic
  - Turtle Basic
  - Waterloo Structured Basic
  - Super Expander
- supports different fonts (VIC-20, C64) 
- change load adress of PRG file
- Save&Run file in editor with emulator via F5 
  - file will be automatically converted from label to line# mode if necessary
  - prg file will bes saved (host filesystem or diskimage, wherever it was loaded from)
  - depending on the start address of the PRG file special emulators will be automatically selected
     --> VIC +3K, PET/CBM series
     --> C64
     --> VIC unexp, VIC +SuperExpander, Plus/4, C16
     --> VIC +8K and more       
     --> C128                   
     --> CBM II series
  - and a setting for a standard emulator if none of the above will be selected
- two different edit modes:
  a) line# mode: the classic editing mode with line#
     - Renumber feature for the whole program or blocks of line#s
     - Auto mode with intelligent numbering when inserting lines between existing lines
     - Compact source to squeeze as much commands in one line as possible
     - Cross refernce to show all jumps and all usages of variables
     - Syntax Check
     - Proofreader support for Compute '83 and '86 versions
     - import binary data with conversion to data lines and an optional POKE-loop
  b) label mode: enhanced editing mode without line# like in modern Basics
     - one command per line
     - indentation of loops 
     - special comments with ' (single apostroph) will be ignored when converting to line#
  - programs can be converted from/to both modes at any time, substituiton of line#/labels will be done automatically
- project mode
  - keeps both edit modes in sync, providing a line# PRG file and a label mode PETSCII file for editing
  - when using label mode, variables can be of any length and will be shortened automatically when transforming into line# mode 
    - shortening of variables keeps track of used variables to avoid double usage (CHECK and CHECK1 will be transformed to CH and CE, for example)
- drag and drop files onto BasEdit icon or onto edit area in running BasEdit will load that file  
- free definable keyboard layout
- Basic tokens, ASCII tokenizer, different emulators, colors, fonts etc. can be changed via BasEdit.Ini or special files
F1 pops up a little help dialog with short command summary:

Code: Select all

movement:
        cursor keys - move around
        home - start of line
        end - end of line
        pgup - one page up
        pgdown - one page down
        ctrl-pgup - got first line
        ctrl-pgdown - goto last line
        ctrl-home - goto first char
        ctrl-end - goto last char
        mouse click - move cursor to mouse position

block commands:
        (blocks can be either some chars in >one< line or multiple >complete< lines)
        shift cursor keys - mark text
        shift-del - cut block, copy to blockbuffer
        ctrl-del - copy block to blockbuffer
        shift-ins - insert blockbuffer
        
other commands:
        num lock - switch between 16x16 (standard) and 8x8 (small) font
        ins - switch between insert and overwrite mode
        ctrl-shift - switch between fonts (upper+graphics / upper+lower)
 
right mouse click opens context menu for loading and saving files
Keyboard mapping can be controlled by Keymap.txt for all those of you not using german QWERTZ keyboards :-)

Getting the special commodore symbols on PC keyboards can be tough, special mappings are made for
ctrl and letter keys = graphic symbols
alt and numbers = color codes and reverse on/off
alt and cursor keys = {up}, {down}, {left}, {right}
alt and home = {home}
alt and shift and home = {shift home}

Or just open the charset window (F2) and double click on the desired symbol.

Edit BasEdit.Ini for further options like tab indent, which tokenfile to use, colors etc.

http://www.stojalowski.de/files/BasEdit.net.zip - always latest release

No installation needed, just unzip to some folder and have fun.
Last edited by Schlowski on Fri Jun 04, 2010 4:14 am, edited 3 times in total.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Great! I will try it in a couple of days. Thanks!

I'm using VB Express 2008 for PRG Starter! :D
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

I've tried it a little now. Seems quite slow, isn't it?

How about a scroll bar?

I see you have some kind of measurement at the bottom? It says 7-9ms on this computer when I do nothing. How did you measure more accurate than +-15ms? I'm using My.Computer.Clock.TickCount but it doesn't seem to be more accurate than 15ms.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

GDI+ isn't the fastest when it comes to filling the screen with images. Each character is a 16x16 (or 8x8) Bitmap which has to be drawn via DrawImage. My first attempt was to use one big source bitmap consisting of all characters and copying characters with DrawImage out of this bitmap onto screen. This was amazingly slow because DrawImage with source regions covers scaling and transformations for source and destination rectangles which is unneeded overhead her. Now I prepare each character as a single bitmap and copy them 1:1 on screen, this is way faster. But as you noticed, not too fast at all.
I tried to optimize my rendering, so most of the time only the actual line on screen will be updated like cursor flashing or character insertation or deletion. But some operations like moving up and down pages, block commands etc. need an update of the whole screen.
Unlike the old BasEdit which uses an infinite DirectDraw loop (and eats up the whole CPU time) this version does its rendering in a timer. Every 100ms it checks for necessary screen updates. So at most you get 10 fps, I thought this would be enough since we do not have an FPS her ;-) I think the feeling of slowness results in this time frame, because if you press a key it can last up to 0.1 secs until you get a feedback. Here is place for some optimization. Maybe I just decrease the timer intervall to increase responsiveness.
Another irritating behaviour is the fact that the cursor movement and the screen updates are not synchronized, because key presses are event driven and screen updates are timer driven. So sometimes it seems the cursor jumps some columns or rows. More room for improvements.

For the measurement:

Code: Select all

Dim sw as New Stopwatch
sw.Start()
...
sw.Stop()
Msgbox (sw.ElapsedMilliseconds.ToString() + " ms")
TickCount has no good resolution, there is some interesting reading about Timers, Stopwatches, TickCount etc. in the MSDN library, resolution of Stopwatches are dependent of the availability of high resolution timers in your OS. You can check this with sw.IsHighResolution. If yes, you get a resolution of 100ns.

The 7-9 ms are they time needed to update the actual line. If you do a pgup or pgdown and thereby have a quick peek at the status line you can see how long an update of the whole screen lasts, for me its's up to 335 ms on a fullscreen window in 1280x1024... As I said, GDI+ isn't the fastest.

About scroll bars: Maybe later, for the moment I want to concentrate on the editing and missing features. To be honest I dislike them not because of their usage but because of the programming overhead they introduce :-)

UPDATE:
Two new config values in BasEdit.Ini:

Code: Select all

' ms between screen updates - typical values are between 10 and 50
TimerResolution=25

' timer ticks per cursor blink
BlinkCounter=6
With these values and the again updatedt version it feels much better!

UPDATE 2:
Made some changes to screen update while typing, now typing and screen updates are more in sync.

Use link in first post to grab new version.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Schlowski wrote:

Code: Select all

Dim sw as New Stopwatch
sw.Start()
...
sw.Stop()
Msgbox (sw.ElapsedMilliseconds.ToString() + " ms")
Cool. Thanks! I have to try that when I start coding on my next PRG Starter version.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Schlowski wrote:But some operations like moving up and down pages, block commands etc. need an update of the whole screen.
Maybe you could do things like; for example copy the whole window contents (except for the top line) as a bitmap, and then paste it at (0,0) and then just insert the next line at the bottom when moving the whole text one line up (walking down in the text).

I found a bug btw... Place the cursor somewhere in the text. Press return a couple of times. Then press backspace a couple of times.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Problem is I would have to be more detailled with the information which parts of the screen have to be redrawn. Especially block commands with insert and delete can range from one line to the whole screen, I don't think it's worth the effort to speed it up any more as long as there are more interesting things to do :-)

(I'm thinking about something like a screen matrix as on the original VIC to keep track of changes, so cursor blinking would be a change of one character instead of the whole line, inserting or deleting a char would only affect the part of the line from cursor on etc. For me it's more important to have a clear feedback while typing than speed while scrolling. Maybe because I mostly go up and down by page, not by row...)

For the bug - this seems to have to do with line concatenation, I will have a look.

Thanks for your input, it's always interesting to have some feedback, because everybody looks different at things.

UPDATE: After some more reading about GDI+ and DrawImage I stumbled across DrawBitmapUnscaled - this speeds up drawing by 50 to 70%, depending on screen size and number of characters on screen :-) Version updated as usual...

UPDATE 2: And after some other optimization like eliminating unneeded spaces etc. another speed-up of 66 to 75% for full page updates.
Timings for my test system:

Code: Select all

Before optimization:
Window size  58x39 chars : 274ms
Window size 106x62,5 chars : 340ms

After optimization:
Window size  58x39 chars : 21ms
Window size 106x62,5 chars : 45ms
Now scrolling down line by line even in fullscreen window should be fast enough...
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

New version up, implemented Search and Renumber.

Boray, did you had the opportunity to take a look at the new version? I'm eagerly waiting for your judgement about speed...
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

I tried it now. Hey, it's really fast now! It's flying! Great job!

How does the Renumber work? What is From, To etc?

It says "Abbrechen" in German here and there.

I think it would be a good idea to try to implement mouse wheel scrolling.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

I think the suggestion someone had for "VIC 20 Prg Gen" would be great, to have a "RUN program" function where you can have a setting for your preferred emulator to run the program when you want to try your code.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Thanks, that's good to hear.

Mouse wheel - yes that is definately one thing I want to have, don't know how often I drive that wheel and nothing happens :-)

"Abbrechen" - Damn, I didn't thought of the fact that the buttons in dialogs (beside the system dialogs like file requester) don't get translated automagically by the system. Ok, i will change them.

Renumber: From and To are bounds of the the original line numbers inbetween which the renumbering takes place, Start is the first new line no and Step is the difference to the next new line no.
Sample:

Code: Select all

Before:
1 REM Line #1
2 REM Line #2
3 REM Line #3
4 REM Line #4
5 REM Line #5
6 REM Line #6
7 REM Line #7
8 REM Line #8
9 REM Line #9
10 REM Line #10

Renumber From=3, To=5, Start=100, Step=10

After:
1 REM Line #1
2 REM Line #2
6 REM Line #6
7 REM Line #7
8 REM Line #8
9 REM Line #9
10 REM Line #10
100 REM Line #3
110 REM Line #4
120 REM Line #5
RUN command will be implemented, I thought of this, too. At least for VICE, i don't know much about other emulators, but maybe one can trick with some commandline arguments etc.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

That is good news!

Aha, so you can use Renumber to move sections of code :)

If you only input to the Start and Step fields and leave From and To empty, you get the error message "Can't convert the string to integer".
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Users, tststs ;-)

No, just kidding, I have to do some validity checks and default values if you omit some fields. Will follow soon, promised.
User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Post by Schema »

I like the concept. Some ideas - should be possible if you have "awareness" of the code (for renumber, etc)

-Syntax Highlighting

-On a GOTO or GOSUB, could you right-click on the destination line number and say "go to"? Or make them hyperlinks (with CTRL)?
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Syntax Highlighting is on my list, together with some sort of userdefinable color sets.

The GOTO-thingy is a nice idea, should be possible without too much effort... Mmh... Right-click could be difficult as my "main menu" is a context-menu. This is due to the fact that I use the ALT key for some special key commands and this collides with standard menu.
Post Reply