MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / drive_write_data

Function drive_write_data

src/disk.cpp:2931–2997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2929}
2930
2931static void drive_write_data (drive * drv)
2932{
2933 int ret = -1;
2934 int tr = drv->cyl * 2 + side;
2935
2936 if (drive_writeprotected (drv) || drv->trackdata[tr].type == TRACK_NONE) {
2937 /* read original track back because we didn't really write anything */
2938 drv->buffered_side = 2;
2939 return;
2940 }
2941 if (drv->writediskfile) {
2942 drive_write_ext2 (drv->bigmfmbuf, drv->writediskfile, &drv->writetrackdata[tr],
2943 floppy_writemode > 0 ? dsklength2 * 8 : drv->tracklen);
2944 }
2945 switch (drv->filetype) {
2946 case ADF_NORMAL:
2947 case ADF_NORMAL_HEADER:
2948 if (drv->ddhd > 1 && currprefs.floppyslots[drv - &floppy[0]].dfxtype != DRV_35_HD) {
2949 // HD image in DD drive: ignore writing.
2950 drv->buffered_side = 2;
2951 } else {
2952 if (drive_write_adf_amigados (drv)) {
2953 if (currprefs.floppy_auto_ext2) {
2954 convert_adf_to_ext2 (drv, currprefs.floppy_auto_ext2);
2955 } else {
2956 static int warned;
2957 if (!warned)
2958 notify_user (NUMSG_NEEDEXT2);
2959 warned = 1;
2960 }
2961 }
2962 }
2963 return;
2964 case ADF_EXT1:
2965 break;
2966 case ADF_EXT2:
2967 if (!floppy_writemode)
2968 ret = drive_write_adf_amigados (drv);
2969 if (ret) {
2970 write_log (_T("not an amigados track %d (error %d), writing as raw track\n"), drv->cyl * 2 + side, ret);
2971 drive_write_ext2 (drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side],
2972 floppy_writemode > 0 ? dsklength2 * 8 : drv->tracklen);
2973 }
2974 return;
2975 case ADF_IPF:
2976 break;
2977 case ADF_SCP:
2978 break;
2979 case ADF_PCDOS:
2980 ret = drive_write_pcdos (drv, drv->diskfile, 0);
2981 if (ret < 0)
2982 write_log (_T("not a PC formatted track %d (error %d)\n"), drv->cyl * 2 + side, ret);
2983 break;
2984#ifdef FLOPPYBRIDGE
2985 case ADF_FLOPPYBRIDGE:
2986 if (drv->bridge) {
2987 // Request to commit the buffer we have collected to disk - this should hardly ever be triggered
2988 drv->tracklen = drv->bridge->commitWriteBuffer(side, drv->cyl);

Callers 3

convert_adf_to_ext2Function · 0.85
disk_doupdate_writeFunction · 0.85
disk.cppFile · 0.85

Calls 8

drive_writeprotectedFunction · 0.85
drive_write_ext2Function · 0.85
convert_adf_to_ext2Function · 0.85
drive_write_pcdosFunction · 0.85
drive_write_adf_amigadosFunction · 0.70
write_logFunction · 0.70
notify_userFunction · 0.50
commitWriteBufferMethod · 0.45

Tested by

no test coverage detected