Jump to content
  • 0

Switching cursor blinking OFF


pzembrod
 Share

Question

Hi all, and @Michael Steil I hope you don't mind if I loop you into this directly, as it involves a bit of KERNAL API design thoughts.

While preparing to wrap up work on the R39-compatible v3.9.3 of VolksForth (and subsequently cc64), I thought I'd try to fix one ugliness that I accepted when initially porting it to the X16: Switching cursor blinking off cleanly.

Here's what VolksForth does on all CBM machines when fetching a character from the console: It switches on the cursor and goes into a loop until a key press is detected, then get that key and switch the cursor off again. (Why like this, why not just a JSR BASIN? Because, in that loop, there's also a PAUSE which hands off control to VolksForth's cooperative multitasker.)

Now for the most part this works nicely on the X16. I'm using the KERNAL var BLNSW at $037b (I know, KERNAL vars are potentially subject to change), and the cursor comes online nicely and stops blinking again, as expected.

The problem is: If it gets switched off while in inverse mode, that inverse character on the screen stays. So far this hasn't caused real problems, but it's ugly. On the C64 this is solved simply by taking the original character under cursor from GDBLN (C64: $ce, X16: $037d) and storing it at the screen address pointed at by PNT (C64: $d1/d2, current screen line address) and PNTR (C64: $d2, current col in screen line). Obviously, with VERA this is a bit more involved on the X16.

Now, today I've dug again pretty deep into the relevant KERNAL code in editor.s and screen.s, and it seems the only way I could achieve the same would be by replicating some of the code in cursor_blink: and pretty much all of screen_set_char:. But doing that seems pretty wrong to me.

Now my first question is, of course: Did I miss anything?

And the follow-up: Would it make sense to make some more screen-related VERA functionality available via KERNAL API?
Semi-related: I would e.g. also love it if I had  direct screen output and keyboard input calls available, bypassing the CBM channel I/O.

Any input appreciated

Cheers
/Philip

P.S. Here's the code:
Key reading loop: https://github.com/pzembrod/VolksForth/blob/master/6502/C64/src/vf-sys-cbm.fth#L8
C64 curon/off: https://github.com/pzembrod/VolksForth/blob/master/6502/C64/src/vf-sys-c64.fth#L50
X16 curon/off (as yet): https://github.com/pzembrod/VolksForth/blob/master/6502/C64/src/vf-sys-x16.fth#L70
(note that 6502 VolksForth's inner interpreter that calls these words leaves X=0 and Y=1)
 

Edited by pzembrod
  • Like 1
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi Stefan,

that's an interesting idea. Although somehow I feel the cursor should be the responsibility of the Kernal- Also, so far VolksForth doesn't need to do anything in the IRQ routine (except in the C16+ case switch on the ROM), and it would keep some things simpler if I could keep it that way. I'll keep this option in mind, though.

Cheers
/Philip

Link to comment
Share on other sites

  • 0

Safely turning blink on and off (ie: NOT leaving an inverse character on the screen) really should be part of the KERNAL. 

There are also some other issues with cursor handling, notably that the cursor does not blink ON when the cursor is moved. In the Commodore 64, the cursor always blinks ON after moving, which allows the user to see where the cursor is when quickly moving around the screen.

  • The cursor should always clear after a keypress and before the cursor position or screen is updated. 
  • The cursor should always turn back on immediately after the cursor position and screen are updated, restarting the blink cycle from the beginning (ON, wait...)
  • We need a safe On/Off switch that turns the cursor on and starts the blink cycle, or turns it off and resets the inverse bit (if appropriate).

 

Edited by TomXP411
  • Like 1
Link to comment
Share on other sites

  • 0

I guess we all agree with @TomXP411 on how the cursor should work. Still in R39, when you hold down a key, the cursor is mostly hidden. Maybe not a big problem, but it doesn't look good.

Some other things I've observed if you were to build the perfect cursor:

  • In ISO mode there are no inverted characters. When the cursor is turned on standing over a character you cannot see what's behind it in R38/R39 when in ISO mode. Not a big problem as you can see the character during the period when the cursor is off, but still not perfect.
  • If in 16 color text mode, you could make a cursor that swaps the background and foreground colors instead of changing the character. That looks the same as inverted characters in PETSCII mode, and it would work in both PETSCII and ISO mode. In the X16 Edit R39 version I'm using this technique, and it works very well.
  • However, in 256 color text mode, you cannot change the background color of individual characters. The color swap method would not work
  • The only method I can think of that would work in ISO mode + 256 color text mode is to use a sprite
    • The sprite would be just a filled box in the foreground color of the same size as a character (the same as an inverted blank space that is)
    • The Z-depth of the cursor sprite would be behind layer 0 and 1 but in front of the background
    • When the cursor is turned on, the sprite is made visible at the right position and the character color is changed to the background color of the screen
    • It should look like an inverted character, but I haven't actually tested it
    • The drawback is that you are using one sprite
  • To cover all modes you would need at least two alternative cursor functions
    • One using the color swap method when in 16 color mode
    • One using the sprite method when in 256 color mode
Link to comment
Share on other sites

  • 0
7 hours ago, Stefan said:
  • The only method I can think of that would work in ISO mode + 256 color text mode is to use a sprite

An idea I had a few months ago: Use both tile layers as text. Both layers in 256 color mode. The background tile layer would use all reverse space characters with a 256 color mode. The foreground tile layer would have whatever characters you wanted to show with their own separate color from 256 color mode.

In this way you have an "apparent" 256 color background and foreground mode (which uses twice as much video memory). Then it could "blink" the cursor by just swapping the color attributes between the background and foreground tile layers.

It is effectively like the double petscii demos but limiting oneself to a single character of any color in the background.

Link to comment
Share on other sites

  • 0
34 minutes ago, Scott Robison said:

The only method I can think of that would work in ISO mode + 256 color text mode is to use a sprite

I've actually done that on the Maximite. It works well. since sprite 0 is already being used for the mouse cursor, we could use sprite 1 for the text cursor.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use