well, I can’t ASM and I don’t know the example besides having taken a quick look.
It seems that the SM_Stuff is that what you want to have, it shouldn’t be very complicated but maybe a bit time-consuming to wrap it into a C-file with __asm and __endasm.
on the other hand there are two more options:
convert the whole asm project to C (I think most of the smaller projects will be converted to C sooner or later, so if you make a start, it surely will be apreciated) ;D
forget the example and code your own application in plain C (I’d do that)
I call “application” what is based on the MIOS skeleton (Init(), Timer(), blabla).
Therefore you can achive nearly all you want with a plain C custom application :
You can disable the SRIO driver, setup a timer and scan and set pins of the pic. Besides the specialized de-/multiplexing that’s apparently what the SM_example does (please correct me anyone if I am wrong).
But am I right, that you want to use it for reading the state of your C64 Keyboard?
If this is the case, you could just use a DIN module, check the pin states and demultiplex it by code. That sounds a lot easier.
Sidenote: with the new mkmk.pl script (part of the most recent C wrapper release), it’s possible to integrate assembly modules (.asm files) into a C project.
The assembly code must be relocatable (means: it requires a data and code section, absolute addresses should not be specified).
An example can be found in the midi router package, see MAKEFILE.SPEC how to add .asm files, and see int_midi.asm/int_midi.h, how a relocatable module looks like
as mentioned, I’m not the guy to do ASM, so please don’t see my solution as the quickest, best or fastest; but if you can code C it may be the easiest - if that what you get from the keyboard are really just encoded ON/OFF states (I don’t know about PS/2 or whatever signals may come out of a keyboard), I would proceed like this:
add a DIN to your Core
connect the 8 wires from the Keyboard to 8 DIN pins
setup a global variable c64matrix[8]; to save space you could create a bitfield.
now you just have to use the DIN_NotifyToggle() Function,
just place your appropriate handler there. It will notify you whenever a state is switching. Use the global c64matrix to prevent having to check all the other seven pins on notify toggle:
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam {
// update the matrix
c64matrix[pin] = value;
// check what to do
switch(c64matrix) {
case 0x00: // e.g. key '0' pressed
do_that();
break;
case 0x01: // e.g. key 'a' pressed
do_this();
break;
default:
do_nothing();
break;
}
}
I think, this might be easy, if the keyboard is really just en-/decoding states;