#535 DMS2 software hangs up after a few seconds

Next_release
open
nobody
None
3
2015-02-27
2014-05-26
No

Running DMS2 software for Yamaha SFG-05 causes a hangup of the MSX after a few seconds of running. See https://www.youtube.com/watch?v=KObWdwt3zUE

Analysis done so far:
the software seems to hang in some loop in which it checks $f9a2
that's in the play buffer area
looks like that area contains a routine
perhaps it's just waiting for some interrupt or so?

 8F4B  ei                  FB
 8F4C  nop                 00
 8F4D  di                  F3
 8F4E  ld     hl,#f9a2     21 A2 F9
 8F51  ld     c,(hl)       4E
 8F52  inc    hl           23
 8F53  ld     a,(hl)       7E
 8F54  sub    c            91
 8F55  cp     #c9          FE C9
 8F57  jr     nc,#8f4b     30 F2

so, something should become C9
aha, the diff between 0xF9A2 and 0xF9A3's content it seems
but F9A3 contains 0xC9 already
and F9A2 contains 0
so the diff is 0xC9
If A >= N, then C flag is reset.
so I guess it waits for it to become smaller than 0xC9
Question is: who writes there
ei; nop; di is interesting
a small time gap for interrupts to happen?
ISR seems to be at 0x2CFC
and indeed, it seems to get written around there
oh, it deopends on #3FF6 and #3FF5, which are the MIDI DATA and STATUS registers, which are not properly implemented
The YM2148 is only very partly implemented
that's the MIDI serial chip
I tried to port it from blueMSX in the days, but I got stuck on stuff I didn't know how to port
the program does a readData and a readStatus on that 2148
I guess I need a datasheet Tongue
not found Sad
then i guess the bluemsx implementation has to serve as the datasheet
wouterv: unfortunately the program does the same in blueMSX, according to mars2000you
so it won't help to complete the implementation exactly like in blueMSX I guess

The author of this software responded like this:

=====================================================================================

This is a simple loop that reads F9A2 and F9A3
and loops until the value read from F9A2 becomes larger than the fixed value (C9) which is in F9A3.

F9A2 must be a up-counter

Normally the system runs with interrupts disabled to ensure accurate playback, but while the system is waiting for the up-counter F9A2 to reach and cross the threshold value in F9A3, it enables interrupts so that any pending MSX system interrupts can be serviced. The NOP is there to ensure that any pending interrupts trigger a handler, as the Z80 datasheet suggested that if you put EI and DI back-to-back that there were circumstances where the interrupt handler may not trigger.

So basically it is waiting for a timed period to elapse, and while it is waiting, it uses this opportunity to allow any pending MSX interrupts to be serviced, as the rest of the time, the system runs with interrupts disabled.

The question is, why is the byte at F9A2 not being incremented.
I don't know if F9A2 is memory or a hardware port.
If it is a hardware port, then it is a TIMER
If it is memory, then it is updated from a TIMER handler.

Without more information, that is as much as I can deduce from the disassembly you have presented.

=====================================================================================

This is the ISR (it's the routine that is jumped to at 0x38), actually, the first 200 lines, I didn't check where it is actually ending:

2CFC  push   hl           E5
2CFD  push   af           F5
2CFE  push   de           D5
2CFF  ld     hl,(#f979)   2A 79 F9
2D02  ld     e,#30        1E 30
2D04  rst    00h          C7
2D05  ex     de,hl        EB
2D06  pop    de           D1
2D07  ld     a,l          7D
2D08  or     h            B4
2D09  jr     z,#2d0e      28 03
2D0B  pop    af           F1
2D0C  ex     (sp),hl      E3
2D0D  ret                 C9
2D0E  pop    af           F1
2D0F  pop    hl           E1
2D10  push   hl           E5
2D11  push   af           F5
2D12  push   bc           C5
2D13  push   de           D5
2D14  push   ix           DD E5
2D16  push   iy           FD E5
2D18  ld     a,(#3ff1)    3A F1 3F
2D1B  rrca                0F
2D1C  jr     c,#2d48      38 2A
2D1E  ld     a,(#3ff1)    3A F1 3F
2D21  bit    1,a          CB 4F
2D23  jr     nz,#2d2e     20 09
2D25  ld     hl,(#f979)   2A 79 F9
2D28  ld     e,#38        1E 38
2D2A  rst    00h          C7
2D2B  ex     de,hl        EB
2D2C  jr     #2d63        18 35
2D2E  call   #0325        CD 25 03
2D31  ld     a,#1e        3E 1E
2D33  ld     hl,(#f979)   2A 79 F9
2D36  rst    28h          EF
2D37  ld     a,(hl)       7E
2D38  or     #23          F6 23
2D3A  ld     c,#14        0E 14
2D3C  call   #02d3        CD D3 02
2D3F  ld     hl,(#f979)   2A 79 F9
2D42  ld     e,#34        1E 34
2D44  rst    00h          C7
2D45  ex     de,hl        EB
2D46  jr     #2d63        18 1B
2D48  call   #0311        CD 11 03
2D4B  ld     a,#1e        3E 1E
2D4D  ld     hl,(#f979)   2A 79 F9
2D50  rst    28h          EF
2D51  ld     a,(hl)       7E
2D52  or     #13          F6 13
2D54  ld     c,#14        0E 14
2D56  call   #02d3        CD D3 02
2D59  call   #0573        CD 73 05
2D5C  ld     hl,(#f979)   2A 79 F9
2D5F  ld     e,#32        1E 32
2D61  rst    00h          C7
2D62  ex     de,hl        EB
2D63  ld     a,l          7D
2D64  or     h            B4
2D65  jr     z,#2d70      28 09
2D67  pop    iy           FD E1
2D69  pop    ix           DD E1
2D6B  pop    de           D1
2D6C  pop    bc           C1
2D6D  pop    af           F1
2D6E  ex     (sp),hl      E3
2D6F  ret                 C9
2D70  pop    iy           FD E1
2D72  pop    ix           DD E1
2D74  pop    de           D1
2D75  pop    bc           C1
2D76  pop    af           F1
2D77  pop    hl           E1
2D78  ei                  FB
2D79  ret                 C9
2D7A  push   af           F5
2D7B  ld     a,(#f9a5)    3A A5 F9
2D7E  and    #08          E6 08
2D80  jp     z,#2d8b      CA 8B 2D
2D83  ld     a,(#3ff6)    3A F6 3F
2D86  and    #02          E6 02
2D88  jp     nz,#2df3     C2 F3 2D
2D8B  push   hl           E5
2D8C  push   de           D5
2D8D  ld     hl,(#f9a0)   2A A0 F9
2D90  ld     a,(#f9a2)    3A A2 F9
2D93  ld     e,a          5F
2D94  ld     d,#00        16 00
2D96  add    hl,de        19
2D97  ld     a,(hl)       7E
2D98  ld     (#3ff5),a    32 F5 3F
2D9B  inc    e            1C
2D9C  ld     a,e          7B
2D9D  ld     (#f9a2),a    32 A2 F9
2DA0  ld     a,(#f9a3)    3A A3 F9
2DA3  cp     e            BB
2DA4  jp     nz,#2db1     C2 B1 2D
2DA7  ld     hl,#f9a5     21 A5 F9
2DAA  ld     a,(hl)       7E
2DAB  and    #fd          E6 FD
2DAD  ld     (hl),a       77
2DAE  ld     (#3ff6),a    32 F6 3F
2DB1  ld     hl,#f9a4     21 A4 F9
2DB4  res    1,(hl)       CB 8E
2DB6  pop    de           D1
2DB7  pop    hl           E1
2DB8  pop    af           F1
2DB9  ei                  FB
2DBA  ret                 C9
2DBB  jr     #2dbf        18 02
2DBD  ei                  FB
2DBE  nop                 00
2DBF  di                  F3
2DC0  ld     hl,(#f9a0)   2A A0 F9
2DC3  ld     a,l          7D
2DC4  or     h            B4
2DC5  jr     z,#2de8      28 21
2DC7  ld     a,(#f9a2)    3A A2 F9
2DCA  ld     d,a          57
2DCB  ld     a,(#f9a3)    3A A3 F9
2DCE  ld     e,a          5F
2DCF  sub    d            92
2DD0  jp     m,#2dbd      FA BD 2D
2DD3  ld     d,#00        16 00
2DD5  add    hl,de        19
2DD6  ld     (hl),c       71
2DD7  inc    e            1C
2DD8  ld     a,e          7B
2DD9  ld     (#f9a3),a    32 A3 F9
2DDC  ld     hl,#f9a5     21 A5 F9
2DDF  ld     a,(hl)       7E
2DE0  or     #02          F6 02
2DE2  ld     (hl),a       77
2DE3  ld     (#3ff6),a    32 F6 3F
2DE6  ei                  FB
2DE7  ret                 C9
2DE8  ld     a,(#3ff6)    3A F6 3F
2DEB  rrca                0F
2DEC  jr     nc,#2de8     30 FA
2DEE  ld     a,c          79
2DEF  ld     (#3ff5),a    32 F5 3F
2DF2  rst    18h          DF
2DF3  push   hl           E5
2DF4  push   de           D5
2DF5  push   bc           C5
2DF6  ld     a,(#3ff5)    3A F5 3F
2DF9  ld     c,a          4F
2DFA  ld     a,(#3ff6)    3A F6 3F
2DFD  and    #30          E6 30
2DFF  jp     nz,#2e5d     C2 5D 2E
2E02  ld     hl,(#f979)   2A 79 F9
2E05  ld     de,#0036     11 36 00
2E08  add    hl,de        19
2E09  ld     a,(hl)       7E
2E0A  ld     e,a          5F
2E0B  inc    hl           23
2E0C  or     (hl)         B6
2E0D  jp     z,#2e16      CA 16 2E
2E10  ld     h,(hl)       66
2E11  ld     l,e          6B
2E12  or     a            B7
2E13  call   #012f        CD 2F 01
2E16  jp     c,#2e3a      DA 3A 2E
2E19  ld     hl,(#f99c)   2A 9C F9
2E1C  ld     a,(#f99f)    3A 9F F9
2E1F  ld     e,a          5F
2E20  ld     d,#00        16 00
2E22  add    hl,de        19
2E23  ld     (hl),c       71
2E24  inc    e            1C
2E25  ld     a,e          7B
2E26  ld     (#f99f),a    32 9F F9
2E29  ld     hl,#f9a4     21 A4 F9
2E2C  bit    1,(hl)       CB 4E
2E2E  jp     nz,#2e5b     C2 5B 2E
2E31  ld     a,(#f99e)    3A 9E F9
2E34  cp     e            BB
2E35  jp     nz,#2e3a     C2 3A 2E
2E38  set    1,(hl)       CB CE
2E3A  ld     a,c          79
2E3B  and    #f8          E6 F8
2E3D  xor    #f8          EE F8
2E3F  jp     nz,#2e55     C2 55 2E
2E42  ld     hl,(#f97d)   2A 7D F9
2E45  ld     de,#0068     11 68 00
2E48  add    hl,de        19
2E49  ld     a,c          79
2E4A  and    #07          E6 07
2E4C  ld     e,a          5F
2E4D  ld     d,#00        16 00
2E4F  add    hl,de        19
2E50  ld     a,(hl)       7E
2E51  rlca                07
2E52  call   c,#2e75      DC 75 2E
2E55  pop    bc           C1
2E56  pop    de           D1
2E57  pop    hl           E1
2E58  pop    af           F1

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks