Subversion Repositories NedoOS

Rev

Rev 2376 | Blame | Compare with Previous | Last modification | View Log | Download

  1. opnawritemusiconlyfm1
  2. ;e = register
  3. ;d = value
  4.         ld a,e
  5.         cp 0x12
  6.         ret z
  7.         cp 0x21
  8.         ret z
  9.         call opnawritefm1
  10.         ld a,e
  11.         sub 0x10
  12.         ret nz
  13.         dec a
  14.         jr nz,$-1
  15.         ret
  16.  
  17. opnawritemusiconlyfm2
  18. ;e = register
  19. ;d = value
  20.         ld a,e
  21.         cp 0x0c
  22.         ret z
  23.         cp 0x0d
  24.         ret z
  25.         cp 0x06
  26.         jp nc,opnawritefm2
  27.         add a,a
  28.         add a,e
  29.         ld (opnafm2commandtable+1),a
  30. opnafm2commandtable
  31.         jr $
  32.         jp opnawritectrl1 ; control 1       (00)
  33.         jp opnawritectrl2 ; control 2       (01)
  34.         jp opnawritefm2   ; start addr low  (02)
  35.         jp opnawritefm2   ; start addr high (03)
  36.         jp opnawritefm2   ; stop addr low   (04)
  37.         jp opnawritefm2   ; stop addr high  (05)
  38.  
  39. opnawritectrl1
  40.         ld a,d
  41.         and %10110001
  42.         ld d,a
  43.         jp opnawritefm2
  44.  
  45. opnawritectrl2
  46.         ld a,d
  47.         and 0x03
  48.         call z,opnasetnoconversionhandlers
  49.         call nz,opnasetconversionhandlers
  50.         ld a,d
  51.         and %11000100
  52.         ld d,a
  53.         jp opnawritefm2
  54.  
  55. opnaconvertstartlo
  56.         ld a,d
  57.         ld (opnastartaddr),a
  58. opnawriteconvertedstartaddr
  59. opnastartaddr=$+1
  60.         ld hl,0
  61.         add hl,hl
  62.         add hl,hl
  63.         add hl,hl
  64.         ld d,l
  65.         ld e,0x02
  66.         call opnawritefm2
  67.         ld d,h
  68.         inc e
  69.         jp opnawritefm2
  70.  
  71. opnaconvertstarthi
  72.         ld a,d
  73.         ld (opnastartaddr+1),a
  74.         jr opnawriteconvertedstartaddr
  75.  
  76. opnaconvertstoplo
  77.         ld a,d
  78.         ld (opnastopaddr),a
  79. opnawriteconvertedstopaddr
  80. opnastopaddr=$+1
  81.         ld hl,0
  82.         add hl,hl
  83.         add hl,hl
  84.         add hl,hl
  85.         ld d,l
  86.         ld e,0x04
  87.         call opnawritefm2
  88.         ld d,h
  89.         inc e
  90.         jp opnawritefm2
  91.  
  92. opnaconvertstophi
  93.         ld a,d
  94.         ld (opnastopaddr+1),a
  95.         jr opnawriteconvertedstopaddr
  96.  
  97. vgmopnainit
  98.         call opnainit
  99.         jr opnasetnoconversionhandlers
  100.  
  101.         macro opna_set_adpcm_register_handler reg,handler
  102.         ld hl,handler
  103.         ld (opnafm2commandtable+3+reg*3),hl
  104.         endm
  105.  
  106. opnasetnoconversionhandlers
  107.         opna_set_adpcm_register_handler 2,opnawritefm2
  108.         opna_set_adpcm_register_handler 3,opnawritefm2
  109.         opna_set_adpcm_register_handler 4,opnawritefm2
  110.         opna_set_adpcm_register_handler 5,opnawritefm2
  111.         ret
  112.  
  113. opnasetconversionhandlers
  114.         opna_set_adpcm_register_handler 2,opnaconvertstartlo
  115.         opna_set_adpcm_register_handler 3,opnaconvertstarthi
  116.         opna_set_adpcm_register_handler 4,opnaconvertstoplo
  117.         opna_set_adpcm_register_handler 5,opnaconvertstophi
  118.         ret
  119.  
  120. opnaloaddatablock
  121. ;dhl = data+header size
  122.         push de
  123.         push hl
  124.         call turnturbooff
  125.         pop hl
  126.         pop de
  127. ;continue uploading at 3.5Mhz
  128.         exx
  129.         call memorystreamread4 ;adbc = total ram size
  130.         call memorystreamread4 ;adbc = start address
  131.         exx
  132.         ld bc,8
  133.         call sub24x16
  134.         jp z,turnturboon
  135.         call setup24bitscounterloop
  136.         ex de,hl
  137.         ld e,b
  138.         exx
  139. ;address in 4-bytes blocks for 1-bit RAM mode
  140.         srl d : rr bc
  141.         srl d : rr bc
  142.         push bc
  143.         ld de,0x0100
  144.         call opnawritefm2
  145.         ld de,0x6000
  146.         call opnawritefm2
  147.         ld de,0x0001
  148.         call opnawritefm2
  149.         ld de,0x1310
  150.         call opnawritefm2
  151.         ld de,0x8010
  152.         call opnawritefm2
  153.         pop hl
  154.         ld d,l : ld e,0x02
  155.         call opnawritefm2
  156.         ld d,h : ld e,0x03
  157.         call opnawritefm2
  158.         ld de,0xff04
  159.         call opnawritefm2
  160.         ld de,0xff05
  161.         call opnawritefm2
  162.         ld de,0xff0c
  163.         call opnawritefm2
  164.         ld de,0xff0d
  165.         call opnawritefm2
  166. ;start uploading the data
  167.         ld bc,OPNA2_DAT
  168.         ld hl,(memorystreamcurrentaddr)
  169.         exx
  170.         ld bc,OPNA2_REG
  171.         in f,(c)
  172.         jp m,$-2
  173.         ld a,0x08
  174.         out (c),a
  175. .uploadloop
  176.         in f,(c)
  177.         jp m,$-2
  178.         exx
  179.         memory_stream_read_byte a
  180.         out (c),a
  181.         exx
  182.         dec e
  183.         jr nz,.uploadloop
  184.         dec hl
  185.         ld a,h
  186.         or l
  187.         jr nz,.uploadloop
  188.         exx
  189.         ld (memorystreamcurrentaddr),hl
  190.         ld de,0x8010
  191.         call opnawritefm2
  192.         ld de,0x0100
  193.         call opnawritefm2
  194.         jp turnturboon
  195.