Interrupts:

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
qwertyface
Posts: 18
Joined: 16 Jul 2019, 09:19

Re: Interrupts:

Post by qwertyface » 29 May 2020, 10:25

[Partly replying just to keep conversations going on this forum]

I'd been wondering if a good use for the vBlank interrupt would be to implement a keyboard buffer for programs like BASIC. Perhaps using a small ring buffer, of say 32 characters, or less. I think it would be easy for slow programs to miss keystrokes (in fact I think I saw a comment to this effect somewhere).

at67
Posts: 190
Joined: 14 May 2018, 08:29

Re: Interrupts:

Post by at67 » 29 May 2020, 10:49

qwertyface wrote:
29 May 2020, 10:25
[Partly replying just to keep conversations going on this forum]

I'd been wondering if a good use for the vBlank interrupt would be to implement a keyboard buffer for programs like BASIC. Perhaps using a small ring buffer, of say 32 characters, or less. I think it would be easy for slow programs to miss keystrokes (in fact I think I saw a comment to this effect somewhere).
I don't see any reason why it couldn't be done. The Tiny BASIC source code that Marcel has created is well documented, (I have studied it a lot whilst building my own BASIC runtime), so adding a daisy chained timer/clock/keyboard handler to it would be a good way of learning not only some of Marcel's GCL/vCPU low level tricks and coding techniques, but how the VBlank interrupt system works within it as well.

The internal interrupt handlers I have created are all isolated modules that have no dependencies on shared data, so I have no issue with race conditions or access conflicts. I think the keyboard handler would be slightly different here, the simplest thing to try would be probably be to just disable interrupts from your main code before accessing your keyboard data structure, and then re-enabling them afterwards.

You could get more complex with non blocking double buffered techniques as you iterated different solutions to the problem...sounds like fun!

Post Reply