Vgm2FamiTrackerTxtAy38910x1Sn76489x2.sdlbasic 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. #! /usr/bin/sdlbrt
  2. finp$="tune.vgm"
  3. '- .vgm to FamiTracker .txt converter - AY-3-8910(x1) + SN76489 (x2) version
  4. '- copyleft Paulo Silva, oct'20
  5. '-------------------------------
  6. '- bugs:
  7. '- - an acute sound might appear because an issue related to volume 0 that VortexTracker doesnt support, R-- note used instead (and the converter should store which note/frequency is for a probable volume changing, and set back the note/frequency value back)
  8. '- - doesn't read yet the author/title information
  9. '- - 'L' will be useful for the loop point location
  10. '- - probably will need a sample counter before converting
  11. '- - missing noise support
  12. '- - frequncy inaccuracy from the germanic notation formula probably fixed, needs more testing
  13. '-------------------------------
  14. ltxtm$="ROW .. : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ... : ... .. . ...":ltxcr$=ltxtm$
  15. freq0=0:freq1=0:freq2=0:vol0=0:vol1=0:vol2=0
  16. patsz=48:patc=0:patid=0:freqq=0
  17. hdram=0x40:vgmv=0:veof=0
  18. dim hdrv[256]
  19. if argc>2 then:finp$=argv(2):end if
  20. fout2$=finp$+"_famitracker.txt":fout3$=finp$+"_famitracker_debug.txt"
  21. frmc=0:frmr=300:trg=0
  22. frmi=735
  23. if argc>3 then:
  24. if argv(3)="1" or ucase$(argv(2))="-PAL" then
  25. frmi=882:end if:end if
  26. debug=0
  27. if argc>4 then:
  28. if argv(4)="1" or ucase$(argv(2))="-DEBUG" then
  29. debug=1:end if:end if
  30. '- fix: 0x0FE=440hz=A-4
  31. function nttfrq$(freqb)
  32. e$= "C-1C#1D-1D#1E-1F-1F#1G-1G#1A-1A#1B-1"
  33. e$=e$+"C-2C#2D-2D#2E-2F-2F#2G-2G#2A-2A#2B-2"
  34. e$=e$+"C-3C#3D-3D#3E-3F-3F#3G-3G#3A-3A#3B-3"
  35. e$=e$+"C-4C#4D-4D#4E-4F-4F#4G-4G#4A-4A#4B-4"
  36. e$=e$+"C-5C#5D-5D#5E-5F-5F#5G-5G#5A-5A#5B-5"
  37. e$=e$+"C-6C#6D-6D#6E-6F-6F#6G-6G#6A-6A#6B-6"
  38. e$=e$+"C-7C#7D-7D#7E-7F-7F#7G-7G#7A-7A#7B-7"
  39. e$=e$+"C-8C#8D-8D#8E-8F-8F#8G-8G#8A-8A#8B-8..."
  40. tmq=141-(int((log(freqb*.99)/log(2))*12))
  41. if tmq<1 then:tmq=1:end if
  42. if tmq>84 then:tmq=84:end if
  43. return mid$(e$,(tmq*3)-2,3)
  44. end function
  45. open finp$ for input as #1
  46. for i=0 to 255
  47. hdrv[i]=readbyte(1)
  48. next
  49. close #1
  50. hdram=0x040
  51. vgmv=hdrv[8]+hdrv[9]*256
  52. if vgmv>=0x0150 then:hdram=0x080:end if
  53. if vgmv>=0x0170 then:hdram=0x100:end if
  54. '- wrong information???
  55. ttsam=hdrv[0x18]+hdrv[0x19]*256+hdrv[0x1A]*65536+hdrv[0x1B]*16777216
  56. hsam$="PlayOrder=L0"
  57. for i=1 to (ttsam/(frmi*patsz))-1
  58. hsam$=hsam$+","+str$(i)
  59. next
  60. open finp$ for input as #1
  61. open fout2$ for output as #2
  62. open fout3$ for output as #3
  63. print #2,"# FamiTracker text format":print #2,""
  64. print #2,"# Module information"
  65. print #2,"TITLE \"\""
  66. print #2,"AUTHOR \"\""
  67. print #2,"COPYRIGHT \"\"":print #2,""
  68. print #2,"# Module comment"
  69. print #2,"COMMENT \"\"":print #2,""
  70. print #2,"# Global settings"
  71. print #2,"MACHINE 0"
  72. print #2,"FRAMERATE 0"
  73. print #2,"EXPANSION 16"
  74. print #2,"VIBRATO 1"
  75. print #2,"SPLIT 32":print #2,""
  76. print #2,"# Namco 163 global settings"
  77. print #2,"N163CHANNELS 6":print #2,""
  78. print #2,"# Macros":print #2,""
  79. print #2,"# DPCM samples":print #2,""
  80. print #2,"# Detune settings":print #2,""
  81. print #2,"# Grooves":print #2,""
  82. print #2,"# Tracks using default groove"
  83. print #2,"# Instruments"
  84. print #2,"INST2A03 0 -1 -1 -1 -1 -1 \"instrument01\""
  85. print #2,"INSTN163 1 -1 -1 -1 -1 -1 32 0 1 \"instrument02\""
  86. print #2,"N163WAVE 1 0 : 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0":print #2,""
  87. print #2,"# Tracks":print #2,""
  88. print #2,"TRACK "+str$(patsz)+" 1 128 \"test\""
  89. print #2,"COLUMNS : 1 1 1 1 1 1 1 1 1 1 1 1 1":print #2,""
  90. print #2,"Pattern 00"
  91. '- the amount of header bytes depends on vgm format version
  92. for eee=0 to hdram-1:q0=readbyte(1):next '- read offset byte first
  93. txou1$=" #("+str$(0)+")"
  94. while veof=0:
  95. q0=readbyte(1)
  96. '- vgm eof command
  97. if q0=0x66 then:
  98. veof=1
  99. print #3,"--vgm-eof--"
  100. print #2,""
  101. print #2,"# End of export"
  102. end if
  103. '- delay 1 byte (1..16 samples)
  104. if bitwiseand(q0,0x70)=0x70 then
  105. frmc=frmc+bitwiseand(q0,0xF)+1
  106. txou1$=" #("+str$(frmc)+")"
  107. 'print #3,txou1$
  108. end if
  109. '- delay 3 bytes (0..65535 samples)
  110. if q0=0x61 then
  111. q0=readbyte(1)
  112. frmc=frmc+q0
  113. q0=readbyte(1)
  114. frmc=frmc+(q0*256)
  115. txou1$=" #("+str$(frmc)+")"
  116. 'print #3,txou1$
  117. end if
  118. '- 1 ntsc frame delay, 735 samples
  119. if q0=0x62 then
  120. frmc=frmc+735
  121. txou1$=" #("+str$(frmc)+")"
  122. 'print #3,txou1$
  123. end if
  124. '- 1 pal frame delay, 882 samples
  125. if q0=0x63 then
  126. frmc=frmc+882
  127. txou1$=" #("+str$(frmc)+")"
  128. 'print #3,txou1$
  129. end if
  130. '- updates frameout pulses
  131. while frmr<frmc
  132. '- writes 1F in the first line of the first pattern
  133. 'if (patc<1 and patid=0) then
  134. 'ltxcr$=replace$(12,ltxcr$,"1F")
  135. 'ltxcr$=replace$(26,ltxcr$,"1F")
  136. 'ltxcr$=replace$(40,ltxcr$,"1F")
  137. 'end if
  138. '- creates a new pattern
  139. if patc>(patsz-1) then:
  140. print #2," "
  141. patid=patid+1:patc=0
  142. 'txou9$="Pattern "+str$(patid)+"]"
  143. txou9$="Pattern "+right$("00000"+ucase$(hex$(patid)),2)
  144. print #2,txou9$
  145. end if
  146. '- writes a pattern line in each frame
  147. if trg=0 then
  148. print #3,"--frameout-unchanged--"
  149. 'print #2,ltxtm$
  150. ltxcr$=ltxtm$
  151. ltxcr$=replace$(4,ltxcr$, right$("00000"+ucase$(hex$(patc)),2) ) '?????? <-----
  152. print #2,ltxcr$
  153. else
  154. print #3,"--frameout--"
  155. ltxcr$=replace$(4,ltxcr$, right$("00000"+ucase$(hex$(patc)),2) ) '?????? <-----
  156. print #2,ltxcr$
  157. ltxcr$=ltxtm$
  158. trg=0
  159. end if
  160. frmr=frmr+frmi
  161. patc=patc+1
  162. end while
  163. '- token 0xA0 gets registers and values to AY-3-8910 output
  164. if q0=0xA0 then
  165. q0=readbyte(1)
  166. '- channel 0, fine
  167. if q0=0x00 then
  168. q0=readbyte(1)
  169. freq0a= bitwiseor((bitwiseand(freq0,0xF00)),(bitwiseand(q0,0x0FF)))
  170. ltxtm1$=ltxtm$
  171. ltxtm2$=replace$(9,ltxtm1$,nttfrq$(freq0a))
  172. ltxcr$=replace$(9,ltxcr$,nttfrq$(freq0a))
  173. ltxcr$=replace$(13,ltxcr$,"00")
  174. print #3,ltxtm2$
  175. trg=1
  176. end if
  177. '- channel 0, coarse
  178. if q0=0x01 then
  179. q0=readbyte(1)
  180. freq0a= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq0,0x0FF)) )
  181. ltxtm1$=ltxtm$
  182. ltxtm2$=replace$(9,ltxtm1$,nttfrq$(freq0a))
  183. ltxcr$=replace$(9,ltxcr$,nttfrq$(freq0a))
  184. ltxcr$=replace$(13,ltxcr$,"00")
  185. print #3,ltxtm2$
  186. trg=1
  187. end if
  188. '- channel 1, fine
  189. if q0=0x02 then
  190. q0=readbyte(1)
  191. freq1a= bitwiseor ( (bitwiseand(freq1,0xF00)),(bitwiseand(q0,0x0FF)) )
  192. ltxtm1$=ltxtm$
  193. ltxtm2$=replace$(24,ltxtm1$,nttfrq$(freq1a))
  194. ltxcr$=replace$(24,ltxcr$,nttfrq$(freq1a))
  195. ltxcr$=replace$(28,ltxcr$,"00")
  196. print #3,ltxtm2$
  197. trg=1
  198. end if
  199. '- channel 1, coarse
  200. if q0=0x03 then
  201. q0=readbyte(1)
  202. freq1a= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq1,0x0FF)) )
  203. ltxtm1$=ltxtm$
  204. ltxtm2$=replace$(24,ltxtm1$,nttfrq$(freq1a))
  205. ltxcr$=replace$(24,ltxcr$,nttfrq$(freq1a))
  206. ltxcr$=replace$(28,ltxcr$,"00")
  207. print #3,ltxtm2$
  208. trg=1
  209. end if
  210. '- channel 2, fine
  211. if q0=0x04 then
  212. q0=readbyte(1)
  213. freq2a= bitwiseor ( (bitwiseand(freq2,0xF00)),(bitwiseand(q0,0x0FF)) )
  214. ltxtm1$=ltxtm$
  215. ltxtm2$=replace$(39,ltxtm1$,nttfrq$(freq2a))
  216. ltxcr$=replace$(39,ltxcr$,nttfrq$(freq2a))
  217. ltxcr$=replace$(43,ltxcr$,"00")
  218. print #3,ltxtm2$
  219. trg=1
  220. end if
  221. '- channel 2, coarse
  222. if q0=0x05 then
  223. q0=readbyte(1)
  224. freq2a= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq2,0x0FF)) )
  225. ltxtm1$=ltxtm$
  226. ltxtm2$=replace$(39,ltxtm1$,nttfrq$(freq2a))
  227. ltxcr$=replace$(39,ltxcr$,nttfrq$(freq2a))
  228. ltxcr$=replace$(43,ltxcr$,"00")
  229. print #3,ltxtm2$
  230. trg=1
  231. end if
  232. '- channel 1, volume
  233. if q0=0x08 then
  234. q0=readbyte(1)
  235. vol0a= bitwiseand(q0,0xF)
  236. ltxtm1$=ltxtm$
  237. ltxtm2$=replace$(16,ltxtm1$,ucase$(right$(hex$(0x10+vol0a),1)))
  238. ltxcr$=replace$(16,ltxcr$,ucase$(right$(hex$(0x10+vol0a),1)))
  239. print #3,ltxtm2$
  240. trg=1
  241. end if
  242. '- channel 2, volume
  243. if q0=0x09 then
  244. q0=readbyte(1)
  245. vol1a= bitwiseand(q0,0xF)
  246. ltxtm1$=ltxtm$
  247. ltxtm2$=replace$(31,ltxtm1$,ucase$(right$(hex$(0x10+vol1a),1)))
  248. ltxcr$=replace$(31,ltxcr$,ucase$(right$(hex$(0x10+vol1a),1)))
  249. print #3,ltxtm2$
  250. trg=1
  251. end if
  252. '- channel 3, volume
  253. if q0=0x0A then
  254. q0=readbyte(1)
  255. vol2a= bitwiseand(q0,0xF)
  256. ltxtm1$=ltxtm$
  257. ltxtm2$=replace$(46,ltxtm1$,ucase$(right$(hex$(0x10+vol2a),1)))
  258. ltxcr$=replace$(46,ltxcr$,ucase$(right$(hex$(0x10+vol2a),1)))
  259. print #3,ltxtm2$
  260. trg=1
  261. end if
  262. '?????
  263. if q0=6 then
  264. print #3,ltxtm$
  265. end if
  266. '?????
  267. 'if q0=7 then
  268. ' q0=readbyte(1)
  269. ' ltxtm1$=ltxtm$
  270. ' ltxtm2$=left$(ltxtm1$,31)+ right$(bin$(512+q0),8) +right$(ltxtm1$,2)+txou1$
  271. ' print #3,ltxtm2$
  272. ' trg=1
  273. ' end if
  274. end if
  275. '- token 0x50 gets registers and values to SN76489 output
  276. if q0=0x50 then
  277. q0=readbyte(1)
  278. if bitwiseand (q0,128)=0 then
  279. '- channel 0 - coarse
  280. if freqq=0 then
  281. freq0b= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq0,0x00F)) )
  282. ltxtm1$=ltxtm$
  283. ltxtm2$=replace$(9+75,ltxtm1$,nttfrq$(freq0b))
  284. ltxcr$=replace$(9+75,ltxcr$,nttfrq$(freq0b))
  285. ltxcr$=replace$(13+75,ltxcr$,"01")
  286. print #3,ltxtm2$+" #("+str$(frmc)+")"
  287. trg=1
  288. end if
  289. '- channel 1 - coarse
  290. if freqq=1 then
  291. freq1b= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq1,0x00F)) )
  292. ltxtm1$=ltxtm$
  293. ltxtm2$=replace$(24+75,ltxtm1$,nttfrq$(freq1b))
  294. ltxcr$=replace$(24+75,ltxcr$,nttfrq$(freq1b))
  295. ltxcr$=replace$(13+15+75,ltxcr$,"01")
  296. print #3,ltxtm2$+" #("+str$(frmc)+")"
  297. trg=1
  298. end if
  299. '- channel 2 - coarse
  300. if freqq=2 then
  301. freq2b= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq2,0x00F)) )
  302. ltxtm1$=ltxtm$
  303. ltxtm2$=replace$(39+75,ltxtm1$,nttfrq$(freq2b))
  304. ltxcr$=replace$(39+75,ltxcr$,nttfrq$(freq2b))
  305. ltxcr$=replace$(13+30+75,ltxcr$,"01")
  306. print #3,ltxtm2$+" #("+str$(frmc)+")"
  307. trg=1
  308. end if
  309. end if
  310. if bitwiseand (q0,128)=128 then
  311. '- channel 0 - fine
  312. if bitwiseand (q0,0xF0)=0x80 then '- tone ch0
  313. freqq=0
  314. freq0b= bitwiseor ( (bitwiseand(freq0,0xFF0)),(bitwiseand(q0,0x00F)) )
  315. ltxtm1$=ltxtm$
  316. ltxtm2$=replace$(9+75,ltxtm1$,nttfrq$(freq0b))
  317. ltxcr$=replace$(9+75,ltxcr$,nttfrq$(freq0b))
  318. ltxcr$=replace$(13+75,ltxcr$,"01")
  319. print #3,ltxtm2$+" #("+str$(frmc)+")"
  320. trg=1
  321. end if
  322. '- channel 1 - fine
  323. if bitwiseand (q0,0xF0)=0xA0 then '- tone ch1
  324. freqq=1
  325. freq1b= bitwiseor ( (bitwiseand(freq1,0xFF0)),(bitwiseand(q0,0x00F)) )
  326. ltxtm1$=ltxtm$
  327. ltxtm2$=replace$(24+75,ltxtm1$,nttfrq$(freq1b))
  328. ltxcr$=replace$(24+75,ltxcr$,nttfrq$(freq1b))
  329. ltxcr$=replace$(13+15+75,ltxcr$,"01")
  330. print #3,ltxtm2$+" #("+str$(frmc)+")"
  331. trg=1
  332. end if
  333. '- channel 2 - fine
  334. if bitwiseand (q0,0xF0)=0xC0 then '- tone ch2
  335. freqq=2
  336. freq2b= bitwiseor ( (bitwiseand(freq2,0xFF0)),(bitwiseand(q0,0x00F)) )
  337. ltxtm1$=ltxtm$
  338. ltxtm2$=replace$(39+75,ltxtm1$,nttfrq$(freq2b))
  339. ltxcr$=replace$(39+75,ltxcr$,nttfrq$(freq2b))
  340. ltxcr$=replace$(13+30+75,ltxcr$,"01")
  341. print #3,ltxtm2$+" #("+str$(frmc)+")"
  342. trg=1
  343. end if
  344. 'if bitwiseand (q0,0xF0)=0xE0 then '- freq noise
  345. ' end if
  346. '- channel 0 - volume
  347. if bitwiseand (q0,0xF0)=0x90 then '- volume ch0
  348. 'freqq=0
  349. vol0b=15-bitwiseand(q0,0xF)
  350. ltxtm1$=ltxtm$
  351. ltxtm2$=replace$(16+75,ltxtm1$,ucase$(right$(hex$(0x10+vol0b),1)))
  352. ltxcr$=replace$(16+75,ltxcr$,ucase$(right$(hex$(0x10+vol0b),1)))
  353. print #3,ltxtm2$+" #("+str$(frmc)+")"
  354. trg=1
  355. end if
  356. '- channel 1 - volume
  357. if bitwiseand (q0,0xF0)=0xB0 then '- volume ch1
  358. 'freqq=1
  359. vol1b=15-bitwiseand(q0,0xF)
  360. ltxtm1$=ltxtm$
  361. ltxtm2$=replace$(31+75,ltxtm1$,ucase$(right$(hex$(0x10+vol1b),1)))
  362. ltxcr$=replace$(31+75,ltxcr$,ucase$(right$(hex$(0x10+vol1b),1)))
  363. print #3,ltxtm2$+" #("+str$(frmc)+")"
  364. trg=1
  365. end if
  366. '- channel 2 - volume
  367. if bitwiseand (q0,0xF0)=0xD0 then '- volume ch2
  368. 'freqq=2
  369. vol2b=15-bitwiseand(q0,0xF)
  370. ltxtm1$=ltxtm$
  371. ltxtm2$=replace$(46+75,ltxtm1$,ucase$(right$(hex$(0x10+vol2b),1)))
  372. ltxcr$=replace$(46+75,ltxcr$,ucase$(right$(hex$(0x10+vol2b),1)))
  373. print #3,ltxtm2$+" #("+str$(frmc)+")"
  374. trg=1
  375. end if
  376. 'if bitwiseand (q0,0xF0)=0xF0 then '- volume ch3
  377. ' end if
  378. end if
  379. end if
  380. '- token 0x30 gets registers and values to SN76489 (second chip) output
  381. if q0=0x30 then
  382. q0=readbyte(1)
  383. if bitwiseand (q0,128)=0 then
  384. '- channel 0 - coarse
  385. if freqq=0 then
  386. freq0c= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq0,0x00F)) )
  387. ltxtm1$=ltxtm$
  388. ltxtm2$=replace$(9+75+45,ltxtm1$,nttfrq$(freq0c))
  389. ltxcr$=replace$(9+75+45,ltxcr$,nttfrq$(freq0c))
  390. ltxcr$=replace$(13+75+45,ltxcr$,"01")
  391. print #3,ltxtm2$+" #("+str$(frmc)+")"
  392. trg=1
  393. end if
  394. '- channel 1 - coarse
  395. if freqq=1 then
  396. freq1c= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq1,0x00F)) )
  397. ltxtm1$=ltxtm$
  398. ltxtm2$=replace$(24+75+45,ltxtm1$,nttfrq$(freq1c))
  399. ltxcr$=replace$(24+75+45,ltxcr$,nttfrq$(freq1c))
  400. ltxcr$=replace$(13+75+15+45,ltxcr$,"01")
  401. print #3,ltxtm2$+" #("+str$(frmc)+")"
  402. trg=1
  403. end if
  404. '- channel 2 - coarse
  405. if freqq=2 then
  406. freq2c= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq2,0x00F)) )
  407. ltxtm1$=ltxtm$
  408. ltxtm2$=replace$(39+75+45,ltxtm1$,nttfrq$(freq2c))
  409. ltxcr$=replace$(39+75+45,ltxcr$,nttfrq$(freq2c))
  410. ltxcr$=replace$(13+75+30+45,ltxcr$,"01")
  411. print #3,ltxtm2$+" #("+str$(frmc)+")"
  412. trg=1
  413. end if
  414. end if
  415. if bitwiseand (q0,128)=128 then
  416. '- channel 0 - fine
  417. if bitwiseand (q0,0xF0)=0x80 then '- tone ch0
  418. freqq=0
  419. freq0c= bitwiseor ( (bitwiseand(freq0,0xFF0)),(bitwiseand(q0,0x00F)) )
  420. ltxtm1$=ltxtm$
  421. ltxtm2$=replace$(9+75+45,ltxtm1$,nttfrq$(freq0c))
  422. ltxcr$=replace$(9+75+45,ltxcr$,nttfrq$(freq0c))
  423. ltxcr$=replace$(13+75+45,ltxcr$,"01")
  424. print #3,ltxtm2$+" #("+str$(frmc)+")"
  425. trg=1
  426. end if
  427. '- channel 1 - fine
  428. if bitwiseand (q0,0xF0)=0xA0 then '- tone ch1
  429. freqq=1
  430. freq1c= bitwiseor ( (bitwiseand(freq1,0xFF0)),(bitwiseand(q0,0x00F)) )
  431. ltxtm1$=ltxtm$
  432. ltxtm2$=replace$(24+75+45,ltxtm1$,nttfrq$(freq1c))
  433. ltxcr$=replace$(24+75+45,ltxcr$,nttfrq$(freq1c))
  434. ltxcr$=replace$(13+75+15+45,ltxcr$,"01")
  435. print #3,ltxtm2$+" #("+str$(frmc)+")"
  436. trg=1
  437. end if
  438. '- channel 2 - fine
  439. if bitwiseand (q0,0xF0)=0xC0 then '- tone ch2
  440. freqq=2
  441. freq2c= bitwiseor ( (bitwiseand(freq2,0xFF0)),(bitwiseand(q0,0x00F)) )
  442. ltxtm1$=ltxtm$
  443. ltxtm2$=replace$(39+75+45,ltxtm1$,nttfrq$(freq2c))
  444. ltxcr$=replace$(39+75+45,ltxcr$,nttfrq$(freq2c))
  445. ltxcr$=replace$(13+75+30+45,ltxcr$,"01")
  446. print #3,ltxtm2$+" #("+str$(frmc)+")"
  447. trg=1
  448. end if
  449. 'if bitwiseand (q0,0xF0)=0xE0 then '- freq noise
  450. ' end if
  451. '- channel 0 - volume
  452. if bitwiseand (q0,0xF0)=0x90 then '- volume ch0
  453. 'freqq=0
  454. vol0c=15-bitwiseand(q0,0xF)
  455. ltxtm1$=ltxtm$
  456. ltxtm2$=replace$(16+75+45,ltxtm1$,ucase$(right$(hex$(0x10+vol0c),1)))
  457. ltxcr$=replace$(16+75+45,ltxcr$,ucase$(right$(hex$(0x10+vol0c),1)))
  458. print #3,ltxtm2$+" #("+str$(frmc)+")"
  459. trg=1
  460. end if
  461. '- channel 1 - volume
  462. if bitwiseand (q0,0xF0)=0xB0 then '- volume ch1
  463. 'freqq=1
  464. vol1c=15-bitwiseand(q0,0xF)
  465. ltxtm1$=ltxtm$
  466. ltxtm2$=replace$(31+75+45,ltxtm1$,ucase$(right$(hex$(0x10+vol1c),1)))
  467. ltxcr$=replace$(31+75+45,ltxcr$,ucase$(right$(hex$(0x10+vol1c),1)))
  468. print #3,ltxtm2$+" #("+str$(frmc)+")"
  469. trg=1
  470. end if
  471. '- channel 2 - volume
  472. if bitwiseand (q0,0xF0)=0xD0 then '- volume ch2
  473. 'freqq=2
  474. vol2c=15-bitwiseand(q0,0xF)
  475. ltxtm1$=ltxtm$
  476. ltxtm2$=replace$(46+75+45,ltxtm1$,ucase$(right$(hex$(0x10+vol2c),1)))
  477. ltxcr$=replace$(46+75+45,ltxcr$,ucase$(right$(hex$(0x10+vol2c),1)))
  478. print #3,ltxtm2$+" #("+str$(frmc)+")"
  479. trg=1
  480. end if
  481. 'if bitwiseand (q0,0xF0)=0xF0 then '- volume ch3
  482. ' end if
  483. end if
  484. end if
  485. if eof(1)<>0 then
  486. veof=1
  487. print #2,""
  488. print #2,"# End of export"
  489. end if
  490. wend
  491. for eeq=0 to patid
  492. txou$="ORDER "+right$(hex$(0x100+eeq),2)+" :"
  493. for eer=0 to 12
  494. txou$=txou$+" "+right$(hex$(0x100+eeq),2)
  495. next
  496. print #2,txou$
  497. next
  498. print #2,""
  499. 'print #2,"ORDER 00 : 00 00 00 00 00 00 00 00 00 00 00 00 00"
  500. 'print #2,"ORDER 01 : 01 01 01 01 01 01 01 01 01 01 01 01 01"
  501. 'print #2,"ORDER 02 : 02 02 02 02 02 02 02 02 02 02 02 02 02"
  502. 'print #2,"ORDER 03 : 03 03 03 03 03 03 03 03 03 03 03 03 03"
  503. 'print #2,"ORDER 04 : 04 04 04 04 04 04 04 04 04 04 04 04 04"
  504. 'print #2,"ORDER 05 : 05 05 05 05 05 05 05 05 05 05 05 05 05"
  505. 'print #2,"ORDER 06 : 06 06 06 06 06 06 06 06 06 06 06 06 06"
  506. 'print #2,"ORDER 07 : 07 07 07 07 07 07 07 07 07 07 07 07 07"
  507. 'print #2,"ORDER 08 : 08 08 08 08 08 08 08 08 08 08 08 08 08"
  508. 'print #2,"ORDER 09 : 09 09 09 09 09 09 09 09 09 09 09 09 09"
  509. 'print #2,"ORDER 0A : 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A"
  510. 'print #2,"ORDER 0B : 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B"
  511. 'print #2,"ORDER 0C : 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C"
  512. 'print #2,"ORDER 0D : 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D"
  513. 'print #2,"ORDER 0E : 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E"
  514. 'print #2,"ORDER 0F : 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F"
  515. 'print #2,""
  516. close #1:close #2:close #3
  517. if debug=0 then:
  518. shell("rm "+fout3$)
  519. end if
  520. 'print #2,"[Module]"
  521. 'print #2,"VortexTrackerII=1"
  522. 'print #2,"Version=3.6"
  523. 'print #2,"Title="
  524. 'print #2,"Author="
  525. 'print #2,"NoteTable=2"
  526. 'print #2,"Speed=1"
  527. 'print #2,hsam$
  528. 'print #2," "
  529. 'print #2,"[Ornament1]":print #2,"L0":print #2," "
  530. 'print #2,"[Sample1]":print #2,"Tne +000_ +00_ F_ L":print #2," "