neilsf / XC-BASIC

A compiling BASIC dialect for the Commodore-64
https://xc-basic.net/
MIT License
74 stars 15 forks source link

Draft: Raster interrupts #90

Closed neilsf closed 4 years ago

neilsf commented 4 years ago

This is going to be a mayor improvement and contrarily to my previous beliefs it may be implemented as part of the core language instead of an optional extension.

This is an implementation DRAFT and is posted here so that you can add your own ideas/remarks.

XC=BASIC will handle raster interrupts via interrupt service routines (ISR) that are simple procedures:

PROC my_irq_handler
  <statements>
ENDPROC

ISR Procedures can't have parameters or even if they do define parameters, no parameters will be passed to them - which is legal in XC=BASIC.

The XC=BASIC runtime is able to register at most eight raster interrupts (RI), for example:

RI # ISR Raster line
0 my_irq_handler 50
1 another_proc 120
2 \<none> \<none>

... and so on, until RI # 7.

The commands for setting/clearing an entry in the RI table could be similar to:

RI_SET <ri_no>, <proc_name>, <raster_line>
RI_CLEAR <ri_no>

Other commands that should be implemented:

RI_SYSHANDLER <ON | OFF>

Enables or disables the KERNAL interrupt handler, i.e keyboard input and flashing cursor.

RI_UPDATE

Updates the RI table based on the RI_SET and RI_CLEAR commands, disables CIA timer interrupts and starts raster interrupt service.

RI_OFF

Disables raster interrupt service and re-enables CIA timer interrupts.

These are preliminary ideas yet, anything may change until the actual implementation.

oliverhermanni commented 4 years ago

This would make XC=BASIC so much better! Your draft looks good to me. Not sure, if you remember, but we talked about this some weeks ago and there you had similar ideas.

neilsf commented 4 years ago

@oliverhermanni the idea comes from an old C64 version of Pascal - can't remember which - although that one supported only one interrupt handler routine at a time.

oliverhermanni commented 4 years ago

That Pascal version is probably so old that the developers thought nobody needs more interrupt handlers than one. :D

neilsf commented 4 years ago

Implemented in xcb-ext-rasterinterrupts.