MEGA65 / mega65-libc

Simple C library for the MEGA65
GNU Lesser General Public License v3.0
25 stars 17 forks source link

Reduce calls to `mega65_io_enable()` #43

Open mlund opened 1 year ago

mlund commented 1 year ago

To ensure that MEGA65 expanded features are availbel, mega65_io_enable() is called from many functions, for example memory.c::do_dma() and multiple places in fcio.c, see e.g. the call graph produces by Doxygen: image

lydon42 commented 1 year ago

To the last point, the following parts of core and utilities do enable mega65_io:

So I gather we are save on that side.

As you have added versions, this is a good change as it reduces repetition, which makes the program slower, so if someone forgot to enable MEGA65 IO at the start of the program, they can fix it after reading the release notes.

Additrional idea: If we add a real startup for MEGA65 C programs to the various compilers, then the startup should do that and the user does not need to remember, right?

mlund commented 1 year ago

Is this habit still the case? https://github.com/MEGA65/mega65-libc/blob/0f7bdab33b0cd59c62d3a6d547e73c05ffd20535/src/fcio.c#L557

lydon42 commented 1 year ago

good question, lets ask @dansanderson

dansanderson commented 1 year ago

The Compendium warns that DOS operations reset the KEY register. I don't see where this happens in code. (Get_DOS doesn't seem to have anything relevant.) I'm still pretty new to the DOS code.

There are only a few direct references to vic+47 (and none to d024) and they're in respectable places (ioinit, c64beg, reset). I gather that any write to d024 that isn't an enable knock will disable, so maybe there are indirect references. The only place I know that resets all VIC registers is the one in ioinit.

I have tried and failed to set a watchpoint on a VIC register, so I don't know if there's an easy way to interrogate this. Ideas welcome. Let me know how else i can help.