z80 timing accuracy and M1 cycle (Emulation MSX Forum)MSX Resource Center               
              
English Nederlands Espa�ol Portugu�s Russian         
 News
   Frontpage
  News archive
  News topics

 Resources
   MSX Forum
  Articles
  Reviews
  Fair reports
  Photo shoots
  Fairs and meetings
  Polls
  Links
  Search

 Software
   Downloads
  Webshop

 MRC
   Who we are
  Join our team
  Donate
  Policies
  Contact us
  Link to Us
  Statistics

 Search
 
  

  

 Login
 

Username

Password




Don't you have an account yet? Become an MSX-friend and register an account now!.


 Statistics
 

There are 50 guests and 3 MSX friends online

You are an anonymous user.
 

MSX Forum


MSX Forum

Emulation - z80 timing accuracy and M1 cycle

Goto page ( Previous Page 1 | 2 )
Author

z80 timing accuracy and M1 cycle

msd
msx professional
Posts: 621
Posted: December 24 2005, 17:41   
I think they should take 5.. and not 8
ARTRAG
msx master
Posts: 1752
Posted: December 24 2005, 18:44   
@m9710797
thanks !! I corrected the error in my code, the sound is sligtly better
but the improvement isn't very big.
The problems could be simply in the freqency errors that are in my player itself.

If you have a true HW MSX and you want to try how the player works,
send me an email and I'll send you back the apo.com, the asm file and the data
computed with the new timings. In this way you can hear the differences of
an execution of apo.com on the emulator and on the true HW and tell me if the
errors are due to my alghiritm or to the opemmsx timings.
My email is in my profile.



ARTRAG
msx master
Posts: 1752
Posted: December 28 2005, 17:40   
Hi people, I am again facing the debug of a cycle accurate PCM player,
have a look at this code (compile with sjasm plus)
;------------------
     MACRO  PsgW reg,value
            ld a,reg    ; select AY channel A volume register ; 7+1
            out (#A0),a                                       ; 11+1
            ld  a,value                                       ; 7+1
            out (#A1),a ; and write back to the AY            ; 11+1
            ENDM                                 ; total 36+4 = 40T
;------------------


        MACRO Wait28 
            .4 nop          ; 5*4 = 20
            cp 0            ; 8    
            ENDM            ; total 28
            
        MACRO Wait68 
            .2 ex (sp),hl   ; 20*2 =40
            Wait28
            ENDM            ; total 68


;------------------

        MACRO next  reg
            ld  a,(hl)  ; 8
            .4 rrca     ; 4*5
            and 15      ; 8
            ld  reg,a   ; 5
            ld  a,(hl)  ; 8
            and 15      ; 8
            exx         ; 5
            ld  reg,a   ; 5
            exx         ; 5
            inc hl      ; 7
            ENDM            ; tot = 79

;------------------

        OUTPUT wavplay.com
       
        ORG 100h

START:
        di
        PsgW 0,255
        PsgW 1,255
        PsgW 2,255
        PsgW 3,255
        PsgW 4,255
        PsgW 5,255
        PsgW 6,255
        PsgW 7,10111111B


;-------------------------------------
; IN   HL - Sample Start address
;      HL'- Sample length
;-------------------------------------

        ld  hl, SAMPLE
        ld  bc,#0101
        ld  de,bc
        exx
        ld  hl, FINISH-SAMPLE+1
        ld  c,#A1           
        

.LOOP:      
        exx             ; 5
        dec b           ; 5
        jp nz,waitA     ; 11 
        next  b         ; 79
1       dec d           ; 5
        jp nz,waitB     ; 11 
        next  d         ; 79
2       dec e           ; 5
        jp nz,waitC     ; 11 
        next  e         ; 79
3       exx             ; 5
        
        ld  a,8         ; 8
        out (#a0),a     ; 12
        inc a           ; 5
        out (c),b       ; 14
        out (#a0),a     ; 12
        inc a           ; 5
        out (c),d       ; 14
        out (#a0),a     ; 12
        out (c),e       ; 14
            
        Wait28 
        
        dec hl          ; 7
        ld  a,h         ; 5
        or  l           ; 5
        jp  nz,.LOOP    ; 11
                        ; tot  = 447T
        ret

waitA   Wait68          ; 68
        jp   1B         ; 11
                        ; tot = 79

waitB   Wait68          ; 68
        jp   2B         ; 11
                        ; tot = 79
                        
waitC   Wait68          ; 68
        jp   3B         ; 11
                        ; tot = 79


;       b7b6b5b4|b3b2b1b0
;       NumTick |LevVolum


SAMPLE:
        include "C:\MATLAB6p5\work\out.txt"

FINISH:

ARTRAG
msx master
Posts: 1752
Posted: December 28 2005, 17:44   
1) are my cycle computation correct?

The data are supposed to be stored in LRE where the high nibble is the counter
and the low nibble is the PSG channel volume.

2) is anyone able to get a faster/better coding that can fit with the 8Khz play requirements?

note that AFAI understand 8KHz => 447 Tcycles
ARTRAG
msx master
Posts: 1752
Posted: December 28 2005, 19:16   
Sorry read LRE as RLE
 
Goto page ( Previous Page 1 | 2 )
 







(c) 1994 - 2008 MSX Resource Center Foundation. MSX is a trademark of MSX Licensing Corporation.