News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_roudoudou

New generation of musical loader

Started by roudoudou, 15:24, 11 August 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

roudoudou


EDIT 2016/08/12
First release available for any purpose you want.


3 sources


FDC_library_v035.asm (including a sample test program for non interlaced sector data disk)
BB5A_replacement_v001.asm (not necessary if you do not want to display errors)
sampletest_unpacked_6903.asm (3.9Khz digitalised sample)


------------------------------------------Hello there!


I read the interview of Kevin T. (arnoldemu) about his work for Batman Demo, thoses lines in particular.


QuoteThe sectors are setup so that in ideal conditions and perfect drive rotation speed, the transfer of one sector size falls within a frame without error. In reality this doesn't happen often, especially with 3" drives, so it checks for errors and retries. [...] I think my loader is not that much different from the others


I thought that since The Demo, people uses the same technic, a fortiori the same philosophy:
- FDC is always slaved to another task.
- As a result you have many retries, and you loader is f*cking slow. So you do not want to answer about the transfert rate in your interview ;)
- It's mandatory to use small sector size, even with a 25Hz music.


Then i remember an old discussion with Shap about the FDC: When you are reading datas, another data cannot be available before approx 30us, regarding of the drive RPM.


The interresting information about that discussion is -> You can do something when FDC is waiting another data. It's a very short time, but you can do something! Then you have no more limits! You can use any sector size you want, any format, you can play a music, or even digitalized samples! And the finishing touch, you can finally read the floppy at FULL SPEED with no more f*cking retries! Tac! Tac! Tac! Tac! Tac! Tac! Tac! Tac! BOOM! Load at +30k/s. EDIT: ok, 15k/s...


For my loader, i found informations in the french magazines QuasarCPC, SOS programmeur and Disc+Ultra documentation (thanks Targhan for advice me to look at this one!). They have a few differences in bit interpretation of state registers. It allow me to really understand the meaning of all registers cause each author interpret registers his own way. Most people are testing the least possible things when dealing with FDC. As i want my loader to be robust and efficient, i also looked into Unofficial Amstrad WWW Resource code of Kevin T. which comfort me to do thoses additionnal controls, and even more. I also guessed some undocumented behaviours, espacially the #8 command (get interrupt state) which return only one byte instead of two, if a seek is still in progress...


I also encounter many problems with a real FDC vs emulated FDC but i did not understand why (i have versions that works with sugarbox,winape,arnold and not with a CPC for testing purpose?). Maybe ACE will also fail? I will send a version to Offset (Arnold, Lone, Executionner?).


As my FDC library isn't finished yet (and need MOAR testing), i do not publish the source code today...


But i will! See you next time!


crappy video teaser thanks to Iron for testing (sorry, it's a CPC+, you will have to believe me) http://uplea.com/dl/B5EC6F7A71BEA06


roudoudou / Flower Corp.






If people are curious or wanted to test with their own routines, here is the main data reading loop i use. Be aware there is more to do. PPI must stay in a stable state after data reading, sample replay must continue during seek, calibrating, interrupt-state, etc.



; assuming this before beginning
exx
ld de,#0900
ld bc,#F4C0
ld hl,sample_adress ; size and adress multiple of 256
exx
ret


FDCMainStateIsData EQU  32 ; 1 -> instr in progress 0 -> result to fetch


FDC_GenericReadDataSAMPLE
push bc
push de
ld bc,#FB7E
ld d,FDCMainStateIsData
call FDC_GenericReadDataLoopSample
pop de
pop bc
ret


;------------- unrolled FDC read + SAMPLE replay -------------


FDC_GenericReadDataLoopSample
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
exx
out (c),d ; #09 channel B volume register
set 1,b
out (c),c ; #C0
exx
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
exx
xor a
out (c),a  ; #00 (inactive)
res 1,b
res 6,c ; #C0 -> #80
exx
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
exx
ld e,(hl)
inc hl
exx
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
exx
out (c),e ; sample value
set 1,b
out (c),c ; #80
exx
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
exx
out (c),e ; #00 (inactive)
res 1,b
set 6,c
ld a,h
exx
ex af,af'
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
;
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
ex af,af'
FDC_PutPSG_HEND: cp #12 ; H-end
jr nz,FDC_PutPSG_GOK
exx
FDC_PutPSG_LoopReinit: ld h,#12
exx
FDC_PutPSG_GOK
; before we loop, wait a little
in a,(c)
jp p,$+11
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
;
in a,(c)
jp p,FDC_GenericReadDataLoopSample
and d
ret z
inc c
in a,(c)
dec c
ld (hl),a
inc hl
jp FDC_GenericReadDataLoopSample
My pronouns are RASM and ACE

CraigsBar

Any chance of uploading the mp4 here? Damn web sharing on android sucks!
IRC:  #Retro4All on Freenode

roudoudou

You cannot upload that type of file. The only allowed extensions are asm,doc,gif,jpg,mpg,pdf,png,txt,zip,mp3,rar,bin,bas,jar,ogg,cdt,sna.
My pronouns are RASM and ACE

TFM

#3
I made a loader with max. data transfer rate (about 20 KB/sec), with calling the music-subroutine 300 times per second. It workes very well, but I can not use f.e. players like from sound-tracker, because that would be too slow. So I need my own player.  :-\

Quote from: roudoudou on 15:24, 11 August 16... BOOM! Load at +30k/s.
Nah, you can't make 30 KB / second.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

roudoudou

you are right, 5 rotations per second, it can't be more than 25k/s  ;D  (an emulator will run this speed as head displacement is virtually free)
with a real head displacement and an old floppy drive, you are approx 15k/s. Maybe a little more with a modern 3.5 drive
My pronouns are RASM and ACE

arnoldemu

I have seen this method used before. I think with the Midline Process. Here I am talking about sending data to fdc and using the time between each byte to do it.
I have also tried to write a loader that does this but only for normal music (not sampled).

I don't know how much you have done, but the other things to consider are:

- writing sample data when you write each byte to fdc to set read data command
- writing sample data when you are reading result phase from fdc.
- writing sample data in the time between read data command written and first byte is read, this is the time it takes for the fdc to find the sector id on the track, verify it, and then start to read data.
- there is also time after reading data when fdc is verifying the crc and possibly some time for the gap (need to check that).

Arnold doesn't emulate the following yet:
1. delay from writing command to fdc finding the sector's data
2. head load delay
3. head unload delay
4. accurate timing for each byte.

So maybe it's one of these things that is making the difference between emulator and real machine.

Also, the timings will vary based on 3.5" (which will be close to 300rpm always because of the direct drive to the motor), 3" which will vary based on the band and how new it is, and hfe (which could be almost perfect timings - better than 3.5").

So test on 3" drive to be sure you got it right.

I hope you do it, it will be a very impressive bit of coding and an impressive result.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

roudoudou

Quote from: arnoldemu on 19:38, 11 August 16
I have seen this method used before. I think with the Midline Process. Here I am talking about sending data to fdc and using the time between each byte to do it.
I have also tried to write a loader that does this but only for normal music (not sampled).

I don't know how much you have done, but the other things to consider are:

- writing sample data when you write each byte to fdc to set read data command
- writing sample data when you are reading result phase from fdc.
- writing sample data in the time between read data command written and first byte is read, this is the time it takes for the fdc to find the sector id on the track, verify it, and then start to read data.
- there is also time after reading data when fdc is verifying the crc and possibly some time for the gap (need to check that).



All the reading part is done while playing sample. It's easier to do outside the main-reading-loop cause delay are more permissives and ears are not perfects  :D  but this part clearly need some adjustments (easy to do, i remove the floppy from the drive and let the library cry there is not disk again and again...)


For the bold-part, writing sample data in the time between read data command and first byte read is done by the unrolled loop i posted in the first message as if FDC is not ready to send data, the code move forward. Same thing for the inter-sector GAP, the code move forward and play sample (a little faster but...    ...ears are not perfects)


Now i work on a complete FDC library -> read/write/format + read&sample


But i think i will only release the read&sample code, cause it's the only interresting thing


I have to make some choices about the error management. I wrote a multimode BB5A with a small 256 bytes font but the end-user must be able to choose if he wants error management or not, as the loader is not supposed to do a single retry...


The evolution may be to play a music but it will be a little more complex to do -> a list of register/value to send, a delay before sending again, interlaced with data-reading!
My pronouns are RASM and ACE

TFM

Quote from: roudoudou on 19:36, 11 August 16
you are right, 5 rotations per second, it can't be more than 25k/s  ;D  (an emulator will run this speed as head displacement is virtually free)
with a real head displacement and an old floppy drive, you are approx 15k/s. Maybe a little more with a modern 3.5 drive


Don't forget the stepping! Big waste of time (especially on 3" drives where 12 ms are save, but 4 ms only for 3.5" and 5.25" drives). On real 3" drives I can get up to 20 KB/sec, calculated by reading 180 KB in 9 seconds (data format).


Of course you can use Trackload and get more quick, but this would really only work when using the idea you proposed before  :) :) :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TrgInJapan

Doing stuff in the FDC main loop is what I do in the Midline Process. Check the Orion Prime loader for the fastest loader possible.
As for the "new generation of musical loader", please wait for September and our new release :).

Trg.Aks

Gryzor


roudoudou

Quote from: TrgInJapan on 12:43, 12 August 16
Doing stuff in the FDC main loop is what I do in the Midline Process. Check the Orion Prime loader for the fastest loader possible.
As for the "new generation of musical loader", please wait for September and our new release :) .

Trg.Aks


Nice inner loop in the midline process!  8)



My pronouns are RASM and ACE

roudoudou

As some people ask me for sources because they can't wait, here they are


I updated the first post and added the sources, freeware diffusion


I'm supposed to get some CPC in a few months so i will make more testing (and improvements on reliability with more hardware checking)










Sorry shap, i waited 20 years your sample loader you told me. Here is mine, first ever released on CPC old generation  :P

My pronouns are RASM and ACE

TFM

Quote from: TrgInJapan on 12:43, 12 August 16
Doing stuff in the FDC main loop is what I do in the Midline Process. Check the Orion Prime loader for the fastest loader possible.


How much KB / second does the "fastest loader possible" transfer?
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

roudoudou

Quote from: TFM on 19:49, 12 August 16

How much KB / second does the "fastest loader possible" transfer?


This can't be the fastest since the "fastest" loader of Targhan use 10 sectors -> more gap to read than with 5 sectors of 1024 bytes...
My pronouns are RASM and ACE

TrgInJapan

10*512 or 5*1024 doesn't change anything in practice since you will probably read the whole track anyway. And you will actually lose speed when changing track with 5 sectors: you will need longer time to land on the next sector.

@TMF : I read all the sectors in a row and get on the right readable one when changing track, so I never lose time. We already discussed about it. And since I read 10 sectors and you 9... I win :).

Trg.Aks

shap

Quote from: roudoudou on 14:57, 12 August 16
Sorry shap, i waited 20 years your sample loader you told me. Here is mine, first ever released on CPC old generation  :P
Yo Roud,

I suppose that is a joke, 3,9Khz xD

My loader plays 16Khz one ;)

roudoudou

Quote from: TrgInJapan on 09:07, 13 August 16
10*512 or 5*1024 doesn't change anything in practice since you will probably read the whole track anyway. And you will actually lose speed when changing track with 5 sectors: you will need longer time to land on the next sector.

@TMF : I read all the sectors in a row and get on the right readable one when changing track, so I never lose time. We already discussed about it. And since I read 10 sectors and you 9... I win :) .

Trg.Aks

You have to wait the same time disregarding the sector size when reading sectors in a row ;)

Quote from: shap on 17:45, 14 August 16
Yo Roud,

I suppose that is a joke, 3,9Khz xD

My loader plays 16Khz one ;)

I know your version is supposed to replay a higher frequency replay, but i haven't heared it yet! Still not released  :P

Maybe you will, i hope so!
My pronouns are RASM and ACE

TrgInJapan

QuoteYou have to wait the same time disregarding the sector size when reading sectors in a row

Yes but that's not the point. Sector size has an impact on optimizing your track change. As an example, imagine what happens when reading a size 6 sector. By the time you read it, you will need another full rotation to read the one on the next track because you will miss the sector once you've changed the track. This will also happen, at a smaller scale, when using 5*1024 sectors. So it is actually a bit slower than using 10*512 sectors.

Anyway, make tests on a real CPC... :).

TFM

Quote from: TrgInJapan on 09:07, 13 August 16
@TMF : I read all the sectors in a row and get on the right readable one when changing track, so I never lose time. We already discussed about it. And since I read 10 sectors and you 9... I win :) .
Trg.Aks


Nope, because 10 sectors are not standard format. My file structure also works with 5 sectors of 1024 bytes (kind of the same because the disc rotates at the same speed, but a little better since there are a bit fewer gap bytes to read)


In additon my routines start to read at the first sector to come. Your routines to that only on consecutive sectors as long as you read them in one attempt.


But to end this discussion: Why don't you just read 180 KB of a 3" floppy disc and tell me how long it needs. If it is 9 seconds we're even. If you make it in 8 seconds you win.  ;) :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TrgInJapan

I will do that in two weeks when I am back :).

However, it is important to note that if you put only 9 sectors per track, you will read LESS data in the same amount of time than I do when having 10 sectors per track.

So in the end you are wasting more time to read as much value as I do! You ask me to read 180kb but, according to me, I will read 210kb in 9s. I'll keep you posted :).

TFM

Quote from: TrgInJapan on 03:35, 17 August 16
I will do that in two weeks when I am back :) .

However, it is important to note that if you put only 9 sectors per track, you will read LESS data in the same amount of time than I do when having 10 sectors per track.

So in the end you are wasting more time to read as much value as I do! You ask me to read 180kb but, according to me, I will read 210kb in 9s. I'll keep you posted :) .

Interestingly the time stays the same [nb]ok, not completely, but difference is less than 0.5 seconds.[/nb] for 180 KB (9 sectors, 512 bytes) or 200 KB (5 sectors, 1024 bytes). Verified last night. Seems that the critical thing is the moment when moving the head to the next track and how to proceed reading then. If needed I can also do a test for 41/42 tracks, used 40 tracks up to now.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Ast

@TFM : do you have your cpcs with you in Usa ?
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

TFM

Quote from: Ast on 20:00, 17 August 16
@TFM : do you have your cpcs with you in Usa ?


Got my original 6128 here, with 3' and HxC, also getting 3.5' to work hopefully soon. Also M-X4 with X-MEM, PlayCity, Albireo, X-MASS, Mini-Booster and Y-MEM. Using a Sony Monitor (it's a jerk!). So basically the spartan equipment.  ;) :)  If you need me to do tests, let me know.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TrgInJapan

@TFM: Yes, I expected such result. The only real way to win/lose speed is by tweaking how the sectors are arranged. Not so much as when reading a track as when moving from one track to another! THIS is where is difference can be made.

Powered by SMFPacks Menu Editor Mod