Scan matrix

Hello,

i definitely need help :

i want to use the scan-matrix driver http://ucapps.de/mios/sm_example2_v1.zip

with C, (in order to drive the C64 keyboard http://www.midibox.org/forum/index.php?topic=6505.msg41509#msg41509) but i really dont know how to mix asm and C

I tried to put required files into ./mios_wrapper/

and include them into mios_wrapper.asm with no chance

i have those errors :

Assembling MIOS SDCC wrapper
mios_wrapper\sm_simple.inc:193:Error [103] syntax error
mios_wrapper\sm_simple.inc:194:Error [103] syntax error
mios_wrapper\sm_simple.inc:195:Error [103] syntax error
mios_wrapper\sm_simple.inc:196:Error [103] syntax error
mios_wrapper\sm_simple.inc:197:Error [103] syntax error
mios_wrapper\sm_simple.inc:198:Error [103] syntax error
mios_wrapper\sm_simple.inc:199:Error [103] syntax error
mios_wrapper\sm_simple.inc:200:Error [103] syntax error
mios_wrapper\sm_simple.inc:204:Error [103] syntax error
mios_wrapper\sm_simple.inc:313:Error [103] syntax error
mios_wrapper\midi_evnt.inc:101:Error [103] syntax error

mios_wrapper\macros.h:90:Error [151] Operand contains unresolvable labels or is too complex.
mios_wrapper\macros.h:92:Error [151] Operand contains unresolvable labels or is too complex.
mios_wrapper\midi_evnt.inc:271:Error [151] Operand contains unresolvable labels or is too complex.
mios_wrapper\midi_evnt.inc:274:Error [151] Operand contains unresolvable labels or is too complex.
ERROR!

PLease help me if you can  :-[

http://www.midibox.org/forum/index.php?topic=5270.msg36662#msg36662  :slight_smile:

Yes, thank you !

I understand “__asm” & “__endasm”,

but in fact, what i want (or ‘hope’) to do, is to mix the asm driver, with C code. Then it’s lot more complicated (to me)

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:

  1. 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

  2. forget the example and code your own application in plain C (I’d do that)

:wink:

Michael

Well, the SM_Stuff, is a driver, not an application.

For that reason, i think it should not be converted to C

Thank you anyway, i start learning ASM… :wink:

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.

Anyway,

good luck,

Michael

Ok, i understand. thanx !!!  :slight_smile:

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

Best Regards, Thorsten.

:cry: i’m lost

Hi Bill,

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;

:wink:

Regards,

Michael