A89: Re: Difficulty inserting assembly into C code
[Prev][Next][Index][Thread]
A89: Re: Difficulty inserting assembly into C code
is there a way someone can help me out? l know l'm sending a lot of messages
to the list and l don't want to ask too much. l also know that it's not cool
to give someone a huge chunk of code and ask them to fix it...but l need a
little help. l've found that there isn't any getkey() function in any
libraries, which would just return 0 if no key is pressed (and not "idle").
what l'm trying to do is take the idle_loop() code out of userlib.asm and
strip all the pausing and apd stuff, so that it just checks for a key press
and returns a value (regardless of if a key was pressed or not). In the
first asm(" ") construct is the whole code, as it was. ln the second is my
code, after l've taken out what l think needs to be taken out (more or less).
l guess maybe if someone can tell me if the bottom code will work? Sorry
for the length of this mail, thanks though!
get_key()
{
asm("
movem.l a0-a6/d1-d7,-(a7)
\idle_start
move.l APD_INIT,APD_TIMER ; reset APD timer
clr.w APD_FLAG ; reset APD flag
\wait_idle
tst.w APD_FLAG ; time for APD?
beq \no_apd ; no -- do not shut down
\do_apd
trap #4
bra \idle_start
\no_apd
tst.w (doorsos::kb_vars+$1C) ; has a key been pressed?
beq \wait_idle
move.l APD_INIT,APD_TIMER ; reset APD timer (1)
move.w (doorsos::MaxHandles+$1E),d0
clr.w (doorsos::kb_vars+$1C) ; clear key buffer
\try_key_off
cmp.w #KEY_DIAMOND+$10B,d0 ;press of diamond+On
beq \do_apd ;->off
\not_key_off
movem.l (a7)+,a0-a6/d1-d7
rts
");
};
HERE'S MY NEW CODE?
get_key()
{
asm("
movem.l %a0-%a6/%d1-%d7,-(%a7)
tst.w (doorsos::kb_vars+$1C) ; has a key been pressed?
move.w (doorsos::MaxHandles+$1E),d0
clr.w (doorsos::kb_vars+$1C) ; clear key buffer
movem.l (%a7)+,%a0-%a6/%d1-%d7
");
};
Follow-Ups: