Page 1 of 1

Simulating a keypress in Euphoric debugger

Posted: Thu Jul 04, 2013 11:59 pm
by Symoon
Ok, here's the story.
I want to upgrade my old disk transfer tool (Cloaddsk), that reads a disk on real Oric, saves it to PC using the tape save (a simple CSAVE of the read data), then building a disk image (DSK file) from it.
This works perfectly fine with Sedoric disks, I'd like to make it work with any kind of disk.

To do so, I need a routine reading a whole track, including the gaps. Nibble 2.4 does this, so I tried to disassemble it and find the routine, but after several evenings (since 2004), I'm getting nowhere. I'm lost in so much machine code.

So I thought I could locate this routine by using Euphoric's debugger (the routine crashed Oricutron 0.9). But to do so and follow the step by step execution, I have to simulate the keys that trigger the command (CTRL P, that is). Simply typing on keyboard is impossible: time to switch to the debugger, I'd miss the routine start.

So I use the debugger again, and write $9D in $0208, and $A2 in 0209, which are the values I found when I press CTRL P on the keyboard.
But nothing happens.

So my questions are:
- does anyone know how to simulate the CTRL P key combination by "poking" in RAM?
- alternatively, does anyone know where the "load track" routine starts in Nibble 2.4?
- alternatively again, does anyone have a routine (ideally in machine code, not C or ASM) that reads a whole track, with parameters Track / Side / Drive
:?:

All this to try and transfer a special protected disk ;) (18 sectors per track and protection byte in the gaps, not Jasmin, not Sedoric, which readdsk doesn't read).
Upgrading Cloaddsk this way would be the ultimate transfer tool, reading on a real Oric any disk format.

Thanks!

Re: Simulating a keypress in Euphoric debugger

Posted: Fri Jul 05, 2013 8:32 pm
by Symoon
Found it.
To simulate CTRL P (in Nibble, at least), here are the values you have to set:
$0208 $9D (don't understand, but I saw this - guess it's something like a keyboard matrix value)
$0209 $A2 (for CTRL key if I'm not mistaken)
...
$02DF $D0 (which is $50, hex value for ASCII code of "P", with bit 7 set).

Back to the emulator, it behaves as if I pressed CTRL P.

I hope now I will be able to follow step by step what happens next, thus find the entry point to the loading track routine. Pfew!

EDIT: oh well, it worked, and now it's not working anymore. I'm fet up, giving up.

Re: Simulating a keypress in Euphoric debugger

Posted: Sat Jun 21, 2014 7:22 pm
by Symoon
One year later ;)
To simulate CRTL + Key, just put $40 + ASCII code of the key into memory $02DF.

For instance, L is $4C; so put $8C into $02DF and the screen will be blanked as with CTRL L.

Re: Simulating a keypress in Euphoric debugger

Posted: Sun Jun 22, 2014 11:38 am
by Dbug
Cool, that can be useful indeed, thanks for sharing :)

Re: Simulating a keypress in Euphoric debugger

Posted: Sat Jul 05, 2014 10:05 am
by Symoon
What's strange is that if I do it in machine code (LDA $8C STA$02DF RTS), it has no effect when I call the routine.
But if I execute the routine step by step with the Euphoric debugger, it works, the screen clears.
:?:

Re: Simulating a keypress in Euphoric debugger

Posted: Sat Jul 05, 2014 10:35 am
by Dbug
Symoon wrote:What's strange is that if I do it in machine code (LDA $8C STA$02DF RTS), it has no effect when I call the routine.
But if I execute the routine step by step with the Euphoric debugger, it works, the screen clears.
:?:
You meant LDA #$8C

When you write LDA $8C it means "load A with whatever is present at the memory address $008C"

Re: Simulating a keypress in Euphoric debugger

Posted: Sat Jul 05, 2014 11:10 am
by Symoon
Dbug wrote:
Symoon wrote:What's strange is that if I do it in machine code (LDA $8C STA$02DF RTS), it has no effect when I call the routine.
But if I execute the routine step by step with the Euphoric debugger, it works, the screen clears.
:?:
You meant LDA #$8C

When you write LDA $8C it means "load A with whatever is present at the memory address $008C"
Yes you're right - sorry I never use assembler actually, I write directly the op codes on paper and on a file. So I'm not quite good with the syntax - but I used $A9 opcode indeed ;)