Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - LDIR timing on MEKA

Reply to topic
Author Message
  • Joined: 23 Nov 2016
  • Posts: 16
  • Location: Argentina
Reply with quote
LDIR timing on MEKA
Post Posted: Tue Dec 13, 2016 7:42 pm
Hi,

I'm trying to understand a behaviour on the instruction LDIR on MEKA.

I'm debugging for example, Ghost House, and on PC = 0x88, it hits LDIR.

Now, after finishing it, sometimes the lines counter finishes on 230 lines, and sometimes on 228. The inputs are always the same, since it's just resetting ram. Shouldn't it always take the same amount of time ?

According to online documentation, it takes 21 cycles if BC != 0, otherwise 16

Thanks,
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14682
  • Location: London
Reply with quote
Post Posted: Tue Dec 13, 2016 11:09 pm
Is bc the same every time? Are the start points the same each time? Is the interrupt firing on line 192 (or whatever it is, I'm not sure) or is it delayed due to disabled interrupts?

Meka does have some faulty timing on some of the extended opcodes, but I found that via the CLOCK cycle counter, not the line counter.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Nov 2016
  • Posts: 16
  • Location: Argentina
Reply with quote
Post Posted: Wed Dec 14, 2016 1:57 am
All registers are the same every time, the instruction is hit almost at the start of the program, interrupts are always disabled.

So, MEKA has some kind of random duration for LDIR ?

Can anyone confirm this ?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14682
  • Location: London
Reply with quote
Post Posted: Wed Dec 14, 2016 5:54 am
What's the code path to offset $88? I'd assumed it was in the VBlank, are you saying it's at startup? I think Meka is deterministic, if sometimes inaccurate.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Nov 2016
  • Posts: 16
  • Location: Argentina
Reply with quote
Post Posted: Wed Dec 14, 2016 1:11 pm
Cycles are always correct until just before LDIR.

After LDIR is random
  View user's profile Send private message Visit poster's website
  • Joined: 08 Dec 2005
  • Posts: 488
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Thu Dec 15, 2016 7:11 am
I only see line 230. Are you clicking "Reset Emulation" before each run?
  View user's profile Send private message Visit poster's website
  • Joined: 23 Nov 2016
  • Posts: 16
  • Location: Argentina
Reply with quote
Post Posted: Thu Dec 15, 2016 1:11 pm
I hit reload ROM, which seems to reset every counter.

Check the IPeriod value, it's always different, even if the lines are 230
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14682
  • Location: London
Reply with quote
Post Posted: Thu Dec 15, 2016 8:27 pm
It seems to be consistent for me. I load the ROM (the export version), then "c 88" gets me to line 0 iperiod 85, and then "s" gets me to line 25 iperiod 85. I do a ctrl+backspace hard reset to try again. CLOCK says 184977 cycles every time. (The ldir in question is blanking all of RAM at startup, which is why it's only 85 cycles into the execution, and interrupts are not up yet.)

Edit: I am using a version of latest Github Meka with altered cycle timings, which I think are more correct (Meka's seem to include wait states for some rarely used opcodes, which is wrong) so you may find your clock count is higher, but this has no effect on the consistency.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8644
  • Location: Paris, France
Reply with quote
Post Posted: Fri Dec 16, 2016 8:46 am
Which version of MEKA are you using?
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!