···11-/*****************************************************************************
22- * pce *
33- *****************************************************************************/
44-55-/*****************************************************************************
66- * File name: src/drivers/pbit/pbit-io.h *
77- * Created: 2012-01-31 by Hampa Hug <hampa@hampa.ch> *
88- * Copyright: (C) 2012 Hampa Hug <hampa@hampa.ch> *
99- *****************************************************************************/
1010-1111-/*****************************************************************************
1212- * This program is free software. You can redistribute it and / or modify it *
1313- * under the terms of the GNU General Public License version 2 as published *
1414- * by the Free Software Foundation. *
1515- * *
1616- * This program is distributed in the hope that it will be useful, but *
1717- * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919- * Public License for more details. *
2020- *****************************************************************************/
2121-2222-2323-#ifndef PCE_PBIT_IO_H
2424-#define PCE_PBIT_IO_H 1
2525-2626-2727-#include <drivers/pbit/pbit.h>
2828-2929-3030-#define PBIT_FORMAT_NONE 0
3131-#define PBIT_FORMAT_PBIT 1
3232-#define PBIT_FORMAT_TC 2
3333-3434-3535-unsigned pbit_get_uint16_be (const void *buf, unsigned idx);
3636-unsigned pbit_get_uint16_le (const void *buf, unsigned idx);
3737-3838-unsigned long pbit_get_uint32_be (const void *buf, unsigned idx);
3939-unsigned long pbit_get_uint32_le (const void *buf, unsigned idx);
4040-4141-void pbit_set_uint16_be (void *buf, unsigned idx, unsigned val);
4242-void pbit_set_uint16_le (void *buf, unsigned idx, unsigned val);
4343-4444-void pbit_set_uint32_be (void *buf, unsigned idx, unsigned long val);
4545-void pbit_set_uint32_le (void *buf, unsigned idx, unsigned long val);
4646-4747-4848-int pbit_read (FILE *fp, void *buf, unsigned long cnt);
4949-int pbit_read_ofs (FILE *fp, unsigned long ofs, void *buf, unsigned long cnt);
5050-int pbit_write (FILE *fp, const void *buf, unsigned long cnt);
5151-int pbit_skip (FILE *fp, unsigned long cnt);
5252-5353-5454-pbit_img_t *pbit_img_load_fp (FILE *fp, unsigned type);
5555-pbit_img_t *pbit_img_load (const char *fname, unsigned type);
5656-5757-int pbit_img_save_fp (FILE *fp, const pbit_img_t *img, unsigned type);
5858-int pbit_img_save (const char *fname, const pbit_img_t *img, unsigned type);
5959-6060-6161-#endif
+83-83
src/drivers/pbit/pbit.c
src/drivers/pri/pri.c
···33 *****************************************************************************/
4455/*****************************************************************************
66- * File name: src/drivers/pbit/pbit.c *
66+ * File name: src/drivers/pri/pri.c *
77 * Created: 2012-01-31 by Hampa Hug <hampa@hampa.ch> *
88 * Copyright: (C) 2012-2013 Hampa Hug <hampa@hampa.ch> *
99 *****************************************************************************/
···2424#include <stdio.h>
2525#include <string.h>
26262727-#include "pbit.h"
2727+#include "pri.h"
282829293030/*****************************************************************************
3131 * Clear all bits in the range i1 < i <= i2 in buf
3232 *****************************************************************************/
3333static
3434-void pbit_clear_bits (unsigned char *buf, unsigned long i1, unsigned long i2)
3434+void pri_clear_bits (unsigned char *buf, unsigned long i1, unsigned long i2)
3535{
3636 unsigned char m1, m2;
3737···6767 *
6868 * @return The new track or NULL on error
6969 *****************************************************************************/
7070-pbit_trk_t *pbit_trk_new (unsigned long size, unsigned long clock)
7070+pri_trk_t *pri_trk_new (unsigned long size, unsigned long clock)
7171{
7272- pbit_trk_t *trk;
7272+ pri_trk_t *trk;
73737474- trk = malloc (sizeof (pbit_trk_t));
7474+ trk = malloc (sizeof (pri_trk_t));
75757676 if (trk == NULL) {
7777 return (NULL);
···9999/*****************************************************************************
100100 * Delete a track
101101 *****************************************************************************/
102102-void pbit_trk_del (pbit_trk_t *trk)
102102+void pri_trk_del (pri_trk_t *trk)
103103{
104104 if (trk != NULL) {
105105 free (trk->data);
···110110/*****************************************************************************
111111 * Create an exact copy of a track
112112 *****************************************************************************/
113113-pbit_trk_t *pbit_trk_clone (const pbit_trk_t *trk)
113113+pri_trk_t *pri_trk_clone (const pri_trk_t *trk)
114114{
115115- pbit_trk_t *ret;
115115+ pri_trk_t *ret;
116116117117- ret = pbit_trk_new (trk->size, trk->clock);
117117+ ret = pri_trk_new (trk->size, trk->clock);
118118119119 if (ret == NULL) {
120120 return (NULL);
···135135 *
136136 * @param val An 8 bit value that is used to initialize the track
137137 *****************************************************************************/
138138-void pbit_trk_clear (pbit_trk_t *trk, unsigned val)
138138+void pri_trk_clear (pri_trk_t *trk, unsigned val)
139139{
140140 if (trk->size > 0) {
141141 memset (trk->data, val, (trk->size + 7) / 8);
142142- pbit_clear_bits (trk->data, trk->size, (trk->size - 1) | 7);
142142+ pri_clear_bits (trk->data, trk->size, (trk->size - 1) | 7);
143143 }
144144}
145145···148148 *
149149 * @param val A 16 bit value that is used to initialize the track
150150 *****************************************************************************/
151151-void pbit_trk_clear_16 (pbit_trk_t *trk, unsigned val)
151151+void pri_trk_clear_16 (pri_trk_t *trk, unsigned val)
152152{
153153 unsigned long i, n;
154154 unsigned char buf[2];
···166166 trk->data[i] = buf[i & 1];
167167 }
168168169169- pbit_clear_bits (trk->data, trk->size, (trk->size - 1) | 7);
169169+ pri_clear_bits (trk->data, trk->size, (trk->size - 1) | 7);
170170}
171171172172/*****************************************************************************
···174174 *
175175 * @param clock The bit rate in Herz
176176 *****************************************************************************/
177177-void pbit_trk_set_clock (pbit_trk_t *trk, unsigned long clock)
177177+void pri_trk_set_clock (pri_trk_t *trk, unsigned long clock)
178178{
179179 trk->clock = clock;
180180}
···184184 *
185185 * @return The bit rate in Herz
186186 *****************************************************************************/
187187-unsigned long pbit_trk_get_clock (const pbit_trk_t *trk)
187187+unsigned long pri_trk_get_clock (const pri_trk_t *trk)
188188{
189189 return (trk->clock);
190190}
···194194 *
195195 * @return The track size in bits
196196 *****************************************************************************/
197197-unsigned long pbit_trk_get_size (const pbit_trk_t *trk)
197197+unsigned long pri_trk_get_size (const pri_trk_t *trk)
198198{
199199 return (trk->size);
200200}
···207207 * If the new size is greater than the old size, the new bits are
208208 * initialized to 0.
209209 *****************************************************************************/
210210-int pbit_trk_set_size (pbit_trk_t *trk, unsigned long size)
210210+int pri_trk_set_size (pri_trk_t *trk, unsigned long size)
211211{
212212 unsigned long i1;
213213 unsigned char *tmp;
···234234235235 if (size > 0) {
236236 i1 = (size < trk->size) ? size : trk->size;
237237- pbit_clear_bits (tmp, i1, (size - 1) | 7);
237237+ pri_clear_bits (tmp, i1, (size - 1) | 7);
238238 }
239239240240 trk->size = size;
···248248 *
249249 * @param pos The new track position in bits
250250 *****************************************************************************/
251251-void pbit_trk_set_pos (pbit_trk_t *trk, unsigned long pos)
251251+void pri_trk_set_pos (pri_trk_t *trk, unsigned long pos)
252252{
253253 if (trk->size > 0) {
254254 trk->idx = pos % trk->size;
···264264 *
265265 * @return Non-zero if the current position wrapped around
266266 *****************************************************************************/
267267-int pbit_trk_get_bits (pbit_trk_t *trk, unsigned long *val, unsigned cnt)
267267+int pri_trk_get_bits (pri_trk_t *trk, unsigned long *val, unsigned cnt)
268268{
269269 unsigned long v;
270270 unsigned char m;
···307307 *
308308 * @return Non-zero if the current position wrapped around
309309 *****************************************************************************/
310310-int pbit_trk_set_bits (pbit_trk_t *trk, unsigned long val, unsigned cnt)
310310+int pri_trk_set_bits (pri_trk_t *trk, unsigned long val, unsigned cnt)
311311{
312312 unsigned char m;
313313 unsigned char *p;
···343343 return (trk->wrap);
344344}
345345346346-int pbit_trk_rotate (pbit_trk_t *trk, unsigned long idx)
346346+int pri_trk_rotate (pri_trk_t *trk, unsigned long idx)
347347{
348348 unsigned long i;
349349 unsigned char dm, sm;
···408408}
409409410410411411-pbit_cyl_t *pbit_cyl_new (void)
411411+pri_cyl_t *pri_cyl_new (void)
412412{
413413- pbit_cyl_t *cyl;
413413+ pri_cyl_t *cyl;
414414415415- cyl = malloc (sizeof (pbit_cyl_t));
415415+ cyl = malloc (sizeof (pri_cyl_t));
416416417417 if (cyl == NULL) {
418418 return (NULL);
···424424 return (cyl);
425425}
426426427427-void pbit_cyl_del (pbit_cyl_t *cyl)
427427+void pri_cyl_del (pri_cyl_t *cyl)
428428{
429429 unsigned long i;
430430431431 if (cyl != NULL) {
432432 for (i = 0; i < cyl->trk_cnt; i++) {
433433- pbit_trk_del (cyl->trk[i]);
433433+ pri_trk_del (cyl->trk[i]);
434434 }
435435436436 free (cyl->trk);
···438438 }
439439}
440440441441-unsigned long pbit_cyl_get_trk_cnt (const pbit_cyl_t *cyl)
441441+unsigned long pri_cyl_get_trk_cnt (const pri_cyl_t *cyl)
442442{
443443 return (cyl->trk_cnt);
444444}
445445446446-pbit_trk_t *pbit_cyl_get_track (pbit_cyl_t *cyl, unsigned long h, int alloc)
446446+pri_trk_t *pri_cyl_get_track (pri_cyl_t *cyl, unsigned long h, int alloc)
447447{
448448- pbit_trk_t *trk;
448448+ pri_trk_t *trk;
449449450450 if ((h < cyl->trk_cnt) && (cyl->trk[h] != NULL)) {
451451 return (cyl->trk[h]);
···455455 return (NULL);
456456 }
457457458458- trk = pbit_trk_new (0, 0);
458458+ trk = pri_trk_new (0, 0);
459459460460 if (trk == NULL) {
461461 return (NULL);
462462 }
463463464464- if (pbit_cyl_set_track (cyl, trk, h)) {
465465- pbit_trk_del (trk);
464464+ if (pri_cyl_set_track (cyl, trk, h)) {
465465+ pri_trk_del (trk);
466466 return (NULL);
467467 }
468468469469 return (trk);
470470}
471471472472-int pbit_cyl_set_track (pbit_cyl_t *cyl, pbit_trk_t *trk, unsigned long h)
472472+int pri_cyl_set_track (pri_cyl_t *cyl, pri_trk_t *trk, unsigned long h)
473473{
474474 unsigned long i;
475475- pbit_trk_t **tmp;
475475+ pri_trk_t **tmp;
476476477477 if (h < cyl->trk_cnt) {
478478- pbit_trk_del (cyl->trk[h]);
478478+ pri_trk_del (cyl->trk[h]);
479479480480 cyl->trk[h] = trk;
481481482482 return (0);
483483 }
484484485485- tmp = realloc (cyl->trk, (h + 1) * sizeof (pbit_trk_t *));
485485+ tmp = realloc (cyl->trk, (h + 1) * sizeof (pri_trk_t *));
486486487487 if (tmp == NULL) {
488488 return (1);
···500500 return (0);
501501}
502502503503-int pbit_cyl_add_track (pbit_cyl_t *cyl, pbit_trk_t *trk)
503503+int pri_cyl_add_track (pri_cyl_t *cyl, pri_trk_t *trk)
504504{
505505- return (pbit_cyl_set_track (cyl, trk, cyl->trk_cnt));
505505+ return (pri_cyl_set_track (cyl, trk, cyl->trk_cnt));
506506}
507507508508-int pbit_cyl_del_track (pbit_cyl_t *cyl, unsigned long h)
508508+int pri_cyl_del_track (pri_cyl_t *cyl, unsigned long h)
509509{
510510 if ((h >= cyl->trk_cnt) || (cyl->trk[h] == NULL)) {
511511 return (1);
512512 }
513513514514- pbit_trk_del (cyl->trk[h]);
514514+ pri_trk_del (cyl->trk[h]);
515515516516 cyl->trk[h] = NULL;
517517···523523}
524524525525526526-pbit_img_t *pbit_img_new (void)
526526+pri_img_t *pri_img_new (void)
527527{
528528- pbit_img_t *img;
528528+ pri_img_t *img;
529529530530- img = malloc (sizeof (pbit_img_t));
530530+ img = malloc (sizeof (pri_img_t));
531531532532 if (img == NULL) {
533533 return (NULL);
···542542 return (img);
543543}
544544545545-void pbit_img_del (pbit_img_t *img)
545545+void pri_img_del (pri_img_t *img)
546546{
547547 unsigned long i;
548548549549 if (img != NULL) {
550550 for (i = 0; i < img->cyl_cnt; i++) {
551551- pbit_cyl_del (img->cyl[i]);
551551+ pri_cyl_del (img->cyl[i]);
552552 }
553553554554 free (img->comment);
···557557 }
558558}
559559560560-unsigned long pbit_img_get_cyl_cnt (const pbit_img_t *img)
560560+unsigned long pri_img_get_cyl_cnt (const pri_img_t *img)
561561{
562562 return (img->cyl_cnt);
563563}
564564565565-unsigned long pbit_img_get_trk_cnt (const pbit_img_t *img, unsigned long c)
565565+unsigned long pri_img_get_trk_cnt (const pri_img_t *img, unsigned long c)
566566{
567567 if ((c >= img->cyl_cnt) || (img->cyl[c] == NULL)) {
568568 return (0);
···572572}
573573574574static
575575-void pbit_img_fix_cyl (pbit_img_t *img)
575575+void pri_img_fix_cyl (pri_img_t *img)
576576{
577577 while ((img->cyl_cnt > 0) && (img->cyl[img->cyl_cnt - 1] == NULL)) {
578578 img->cyl_cnt -= 1;
579579 }
580580}
581581582582-pbit_cyl_t *pbit_img_get_cylinder (pbit_img_t *img, unsigned long c, int alloc)
582582+pri_cyl_t *pri_img_get_cylinder (pri_img_t *img, unsigned long c, int alloc)
583583{
584584- pbit_cyl_t *cyl;
584584+ pri_cyl_t *cyl;
585585586586 if ((c < img->cyl_cnt) && (img->cyl[c] != NULL)) {
587587 return (img->cyl[c]);
···591591 return (NULL);
592592 }
593593594594- cyl = pbit_cyl_new();
594594+ cyl = pri_cyl_new();
595595596596 if (cyl == NULL) {
597597 return (NULL);
598598 }
599599600600- if (pbit_img_set_cylinder (img, cyl, img->cyl_cnt)) {
601601- pbit_cyl_del (cyl);
600600+ if (pri_img_set_cylinder (img, cyl, c)) {
601601+ pri_cyl_del (cyl);
602602 return (NULL);
603603 }
604604605605 return (cyl);
606606}
607607608608-pbit_cyl_t *pbit_img_rmv_cylinder (pbit_img_t *img, unsigned long c)
608608+pri_cyl_t *pri_img_rmv_cylinder (pri_img_t *img, unsigned long c)
609609{
610610- pbit_cyl_t *cyl;
610610+ pri_cyl_t *cyl;
611611612612 if ((c >= img->cyl_cnt) || (img->cyl[c] == NULL)) {
613613 return (NULL);
···617617618618 img->cyl[c] = NULL;
619619620620- pbit_img_fix_cyl (img);
620620+ pri_img_fix_cyl (img);
621621622622 return (cyl);
623623}
624624625625-int pbit_img_set_cylinder (pbit_img_t *img, pbit_cyl_t *cyl, unsigned long c)
625625+int pri_img_set_cylinder (pri_img_t *img, pri_cyl_t *cyl, unsigned long c)
626626{
627627 unsigned long i;
628628- pbit_cyl_t **tmp;
628628+ pri_cyl_t **tmp;
629629630630 if (c < img->cyl_cnt) {
631631- pbit_cyl_del (img->cyl[c]);
631631+ pri_cyl_del (img->cyl[c]);
632632 img->cyl[c] = cyl;
633633- pbit_img_fix_cyl (img);
633633+ pri_img_fix_cyl (img);
634634635635 return (0);
636636 }
637637638638- tmp = realloc (img->cyl, (c + 1) * sizeof (pbit_cyl_t *));
638638+ tmp = realloc (img->cyl, (c + 1) * sizeof (pri_cyl_t *));
639639640640 if (tmp == NULL) {
641641 return (1);
···650650 img->cyl = tmp;
651651 img->cyl_cnt = c + 1;
652652653653- pbit_img_fix_cyl (img);
653653+ pri_img_fix_cyl (img);
654654655655 return (0);
656656}
657657658658-int pbit_img_add_cylinder (pbit_img_t *img, pbit_cyl_t *cyl)
658658+int pri_img_add_cylinder (pri_img_t *img, pri_cyl_t *cyl)
659659{
660660- return (pbit_img_set_cylinder (img, cyl, img->cyl_cnt));
660660+ return (pri_img_set_cylinder (img, cyl, img->cyl_cnt));
661661}
662662663663-int pbit_img_del_cylinder (pbit_img_t *img, unsigned long c)
663663+int pri_img_del_cylinder (pri_img_t *img, unsigned long c)
664664{
665665 if ((c >= img->cyl_cnt) || (img->cyl[c] == NULL)) {
666666 return (1);
667667 }
668668669669- pbit_cyl_del (img->cyl[c]);
669669+ pri_cyl_del (img->cyl[c]);
670670671671 img->cyl[c] = NULL;
672672673673- pbit_img_fix_cyl (img);
673673+ pri_img_fix_cyl (img);
674674675675 return (0);
676676}
677677678678-pbit_trk_t *pbit_img_get_track (pbit_img_t *img, unsigned long c, unsigned long h, int alloc)
678678+pri_trk_t *pri_img_get_track (pri_img_t *img, unsigned long c, unsigned long h, int alloc)
679679{
680680- pbit_cyl_t *cyl;
681681- pbit_trk_t *trk;
680680+ pri_cyl_t *cyl;
681681+ pri_trk_t *trk;
682682683683- cyl = pbit_img_get_cylinder (img, c, alloc);
683683+ cyl = pri_img_get_cylinder (img, c, alloc);
684684685685 if (cyl == NULL) {
686686 return (NULL);
687687 }
688688689689- trk = pbit_cyl_get_track (cyl, h, alloc);
689689+ trk = pri_cyl_get_track (cyl, h, alloc);
690690691691 if (trk == NULL) {
692692 return (NULL);
···695695 return (trk);
696696}
697697698698-int pbit_img_set_track (pbit_img_t *img, pbit_trk_t *trk, unsigned long c, unsigned long h)
698698+int pri_img_set_track (pri_img_t *img, pri_trk_t *trk, unsigned long c, unsigned long h)
699699{
700700- pbit_cyl_t *cyl;
700700+ pri_cyl_t *cyl;
701701702702- cyl = pbit_img_get_cylinder (img, c, 1);
702702+ cyl = pri_img_get_cylinder (img, c, 1);
703703704704 if (cyl == NULL) {
705705 return (1);
706706 }
707707708708- if (pbit_cyl_set_track (cyl, trk, h)) {
708708+ if (pri_cyl_set_track (cyl, trk, h)) {
709709 return (1);
710710 }
711711712712 return (0);
713713}
714714715715-int pbit_img_del_track (pbit_img_t *img, unsigned long c, unsigned long h)
715715+int pri_img_del_track (pri_img_t *img, unsigned long c, unsigned long h)
716716{
717717 if ((c >= img->cyl_cnt) || (img->cyl[c] == NULL)) {
718718 return (1);
719719 }
720720721721- if (pbit_cyl_del_track (img->cyl[c], h)) {
721721+ if (pri_cyl_del_track (img->cyl[c], h)) {
722722 return (1);
723723 }
724724725725 return (0);
726726}
727727728728-int pbit_img_add_comment (pbit_img_t *img, const unsigned char *buf, unsigned cnt)
728728+int pri_img_add_comment (pri_img_t *img, const unsigned char *buf, unsigned cnt)
729729{
730730 unsigned char *tmp;
731731···743743 return (0);
744744}
745745746746-int pbit_img_set_comment (pbit_img_t *img, const unsigned char *buf, unsigned cnt)
746746+int pri_img_set_comment (pri_img_t *img, const unsigned char *buf, unsigned cnt)
747747{
748748 free (img->comment);
749749···754754 return (0);
755755 }
756756757757- if (pbit_img_add_comment (img, buf, cnt)) {
757757+ if (pri_img_add_comment (img, buf, cnt)) {
758758 return (1);
759759 }
760760
-95
src/drivers/pbit/pbit.h
···11-/*****************************************************************************
22- * pce *
33- *****************************************************************************/
44-55-/*****************************************************************************
66- * File name: src/drivers/pbit/pbit.h *
77- * Created: 2012-01-31 by Hampa Hug <hampa@hampa.ch> *
88- * Copyright: (C) 2012-2013 Hampa Hug <hampa@hampa.ch> *
99- *****************************************************************************/
1010-1111-/*****************************************************************************
1212- * This program is free software. You can redistribute it and / or modify it *
1313- * under the terms of the GNU General Public License version 2 as published *
1414- * by the Free Software Foundation. *
1515- * *
1616- * This program is distributed in the hope that it will be useful, but *
1717- * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919- * Public License for more details. *
2020- *****************************************************************************/
2121-2222-2323-#ifndef PCE_PBIT_H
2424-#define PCE_PBIT_H 1
2525-2626-2727-typedef struct {
2828- unsigned long clock;
2929-3030- unsigned long size;
3131- unsigned char *data;
3232-3333- unsigned long idx;
3434- char wrap;
3535-} pbit_trk_t;
3636-3737-3838-typedef struct {
3939- unsigned long trk_cnt;
4040- pbit_trk_t **trk;
4141-} pbit_cyl_t;
4242-4343-4444-typedef struct {
4545- unsigned long cyl_cnt;
4646- pbit_cyl_t **cyl;
4747-4848- unsigned long comment_size;
4949- unsigned char *comment;
5050-} pbit_img_t;
5151-5252-5353-pbit_trk_t *pbit_trk_new (unsigned long size, unsigned long clock);
5454-void pbit_trk_del (pbit_trk_t *trk);
5555-pbit_trk_t *pbit_trk_clone (const pbit_trk_t *trk);
5656-void pbit_trk_clear (pbit_trk_t *trk, unsigned val);
5757-void pbit_trk_clear_16 (pbit_trk_t *trk, unsigned val);
5858-void pbit_trk_set_clock (pbit_trk_t *trk, unsigned long clock);
5959-unsigned long pbit_trk_get_clock (const pbit_trk_t *trk);
6060-unsigned long pbit_trk_get_size (const pbit_trk_t *trk);
6161-int pbit_trk_set_size (pbit_trk_t *trk, unsigned long size);
6262-6363-void pbit_trk_set_pos (pbit_trk_t *trk, unsigned long pos);
6464-int pbit_trk_get_bits (pbit_trk_t *trk, unsigned long *val, unsigned cnt);
6565-int pbit_trk_set_bits (pbit_trk_t *trk, unsigned long val, unsigned cnt);
6666-int pbit_trk_rotate (pbit_trk_t *trk, unsigned long idx);
6767-6868-pbit_cyl_t *pbit_cyl_new (void);
6969-void pbit_cyl_del (pbit_cyl_t *cyl);
7070-unsigned long pbit_cyl_get_trk_cnt (const pbit_cyl_t *cyl);
7171-pbit_trk_t *pbit_cyl_get_track (pbit_cyl_t *cyl, unsigned long idx, int alloc);
7272-int pbit_cyl_set_track (pbit_cyl_t *cyl, pbit_trk_t *trk, unsigned long h);
7373-int pbit_cyl_add_track (pbit_cyl_t *cyl, pbit_trk_t *trk);
7474-int pbit_cyl_del_track (pbit_cyl_t *cyl, unsigned long h);
7575-7676-pbit_img_t *pbit_img_new (void);
7777-void pbit_img_del (pbit_img_t *img);
7878-unsigned long pbit_img_get_cyl_cnt (const pbit_img_t *img);
7979-unsigned long pbit_img_get_trk_cnt (const pbit_img_t *img, unsigned long c);
8080-8181-pbit_cyl_t *pbit_img_get_cylinder (pbit_img_t *img, unsigned long c, int alloc);
8282-pbit_cyl_t *pbit_img_rmv_cylinder (pbit_img_t *img, unsigned long idx);
8383-int pbit_img_set_cylinder (pbit_img_t *img, pbit_cyl_t *cyl, unsigned long c);
8484-int pbit_img_add_cylinder (pbit_img_t *img, pbit_cyl_t *cyl);
8585-int pbit_img_del_cylinder (pbit_img_t *img, unsigned long c);
8686-8787-pbit_trk_t *pbit_img_get_track (pbit_img_t *img, unsigned long c, unsigned long h, int alloc);
8888-int pbit_img_set_track (pbit_img_t *img, pbit_trk_t *trk, unsigned long c, unsigned long h);
8989-int pbit_img_del_track (pbit_img_t *img, unsigned long c, unsigned long h);
9090-9191-int pbit_img_add_comment (pbit_img_t *img, const unsigned char *buf, unsigned cnt);
9292-int pbit_img_set_comment (pbit_img_t *img, const unsigned char *buf, unsigned cnt);
9393-9494-9595-#endif
···11+/*****************************************************************************
22+ * pce *
33+ *****************************************************************************/
44+55+/*****************************************************************************
66+ * File name: src/drivers/pri/pri-io.h *
77+ * Created: 2012-01-31 by Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2012-2013 Hampa Hug <hampa@hampa.ch> *
99+ *****************************************************************************/
1010+1111+/*****************************************************************************
1212+ * This program is free software. You can redistribute it and / or modify it *
1313+ * under the terms of the GNU General Public License version 2 as published *
1414+ * by the Free Software Foundation. *
1515+ * *
1616+ * This program is distributed in the hope that it will be useful, but *
1717+ * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919+ * Public License for more details. *
2020+ *****************************************************************************/
2121+2222+2323+#ifndef PCE_PRI_IMG_H
2424+#define PCE_PRI_IMG_H 1
2525+2626+2727+#include <drivers/pri/pri.h>
2828+2929+3030+#define PRI_FORMAT_NONE 0
3131+#define PRI_FORMAT_PBIT 1
3232+#define PRI_FORMAT_TC 2
3333+3434+3535+unsigned pri_get_uint16_be (const void *buf, unsigned idx);
3636+unsigned pri_get_uint16_le (const void *buf, unsigned idx);
3737+3838+unsigned long pri_get_uint32_be (const void *buf, unsigned idx);
3939+unsigned long pri_get_uint32_le (const void *buf, unsigned idx);
4040+4141+void pri_set_uint16_be (void *buf, unsigned idx, unsigned val);
4242+void pri_set_uint16_le (void *buf, unsigned idx, unsigned val);
4343+4444+void pri_set_uint32_be (void *buf, unsigned idx, unsigned long val);
4545+void pri_set_uint32_le (void *buf, unsigned idx, unsigned long val);
4646+4747+4848+int pri_read (FILE *fp, void *buf, unsigned long cnt);
4949+int pri_read_ofs (FILE *fp, unsigned long ofs, void *buf, unsigned long cnt);
5050+int pri_write (FILE *fp, const void *buf, unsigned long cnt);
5151+int pri_skip (FILE *fp, unsigned long cnt);
5252+5353+5454+pri_img_t *pri_img_load_fp (FILE *fp, unsigned type);
5555+pri_img_t *pri_img_load (const char *fname, unsigned type);
5656+5757+int pri_img_save_fp (FILE *fp, const pri_img_t *img, unsigned type);
5858+int pri_img_save (const char *fname, const pri_img_t *img, unsigned type);
5959+6060+6161+#endif
+95
src/drivers/pri/pri.h
···11+/*****************************************************************************
22+ * pce *
33+ *****************************************************************************/
44+55+/*****************************************************************************
66+ * File name: src/drivers/pri/pri.h *
77+ * Created: 2012-01-31 by Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2012-2013 Hampa Hug <hampa@hampa.ch> *
99+ *****************************************************************************/
1010+1111+/*****************************************************************************
1212+ * This program is free software. You can redistribute it and / or modify it *
1313+ * under the terms of the GNU General Public License version 2 as published *
1414+ * by the Free Software Foundation. *
1515+ * *
1616+ * This program is distributed in the hope that it will be useful, but *
1717+ * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919+ * Public License for more details. *
2020+ *****************************************************************************/
2121+2222+2323+#ifndef PCE_PRI_H
2424+#define PCE_PRI_H 1
2525+2626+2727+typedef struct {
2828+ unsigned long clock;
2929+3030+ unsigned long size;
3131+ unsigned char *data;
3232+3333+ unsigned long idx;
3434+ char wrap;
3535+} pri_trk_t;
3636+3737+3838+typedef struct {
3939+ unsigned long trk_cnt;
4040+ pri_trk_t **trk;
4141+} pri_cyl_t;
4242+4343+4444+typedef struct {
4545+ unsigned long cyl_cnt;
4646+ pri_cyl_t **cyl;
4747+4848+ unsigned long comment_size;
4949+ unsigned char *comment;
5050+} pri_img_t;
5151+5252+5353+pri_trk_t *pri_trk_new (unsigned long size, unsigned long clock);
5454+void pri_trk_del (pri_trk_t *trk);
5555+pri_trk_t *pri_trk_clone (const pri_trk_t *trk);
5656+void pri_trk_clear (pri_trk_t *trk, unsigned val);
5757+void pri_trk_clear_16 (pri_trk_t *trk, unsigned val);
5858+void pri_trk_set_clock (pri_trk_t *trk, unsigned long clock);
5959+unsigned long pri_trk_get_clock (const pri_trk_t *trk);
6060+unsigned long pri_trk_get_size (const pri_trk_t *trk);
6161+int pri_trk_set_size (pri_trk_t *trk, unsigned long size);
6262+6363+void pri_trk_set_pos (pri_trk_t *trk, unsigned long pos);
6464+int pri_trk_get_bits (pri_trk_t *trk, unsigned long *val, unsigned cnt);
6565+int pri_trk_set_bits (pri_trk_t *trk, unsigned long val, unsigned cnt);
6666+int pri_trk_rotate (pri_trk_t *trk, unsigned long idx);
6767+6868+pri_cyl_t *pri_cyl_new (void);
6969+void pri_cyl_del (pri_cyl_t *cyl);
7070+unsigned long pri_cyl_get_trk_cnt (const pri_cyl_t *cyl);
7171+pri_trk_t *pri_cyl_get_track (pri_cyl_t *cyl, unsigned long idx, int alloc);
7272+int pri_cyl_set_track (pri_cyl_t *cyl, pri_trk_t *trk, unsigned long h);
7373+int pri_cyl_add_track (pri_cyl_t *cyl, pri_trk_t *trk);
7474+int pri_cyl_del_track (pri_cyl_t *cyl, unsigned long h);
7575+7676+pri_img_t *pri_img_new (void);
7777+void pri_img_del (pri_img_t *img);
7878+unsigned long pri_img_get_cyl_cnt (const pri_img_t *img);
7979+unsigned long pri_img_get_trk_cnt (const pri_img_t *img, unsigned long c);
8080+8181+pri_cyl_t *pri_img_get_cylinder (pri_img_t *img, unsigned long c, int alloc);
8282+pri_cyl_t *pri_img_rmv_cylinder (pri_img_t *img, unsigned long idx);
8383+int pri_img_set_cylinder (pri_img_t *img, pri_cyl_t *cyl, unsigned long c);
8484+int pri_img_add_cylinder (pri_img_t *img, pri_cyl_t *cyl);
8585+int pri_img_del_cylinder (pri_img_t *img, unsigned long c);
8686+8787+pri_trk_t *pri_img_get_track (pri_img_t *img, unsigned long c, unsigned long h, int alloc);
8888+int pri_img_set_track (pri_img_t *img, pri_trk_t *trk, unsigned long c, unsigned long h);
8989+int pri_img_del_track (pri_img_t *img, unsigned long c, unsigned long h);
9090+9191+int pri_img_add_comment (pri_img_t *img, const unsigned char *buf, unsigned cnt);
9292+int pri_img_set_comment (pri_img_t *img, const unsigned char *buf, unsigned cnt);
9393+9494+9595+#endif
···11-.TH PBIT 1 "2012-03-10" "HH" "pce"
11+.TH PRI 1 "2013-06-09" "HH" "pce"
22\
33.SH NAME
44-pbit \- convert and modify PBIT image files
44+pri \- convert and modify PCE raw image files
5566.SH SYNOPSIS
77-.BI pbit " [options] [input-file] [options] [output-file]"
77+.BI pri " [options] [input-file] [options] [output-file]"
8899.SH DESCRIPTION
1010-\fBpbit\fR(1) is used to modify and convert PBIT images
1010+\fBpri\fR(1) is used to modify and convert PCE raw image
1111files.
12121313.SH OPTIONS
···101101Set the image comment to \fItext\fR.
102102.TP
103103.BI "decode " "type filename"
104104-Decode the image and save it as a pfdc sector image to \fIfilename\fR.
104104+Decode the image and save it as a pri sector image to \fIfilename\fR.
105105Valid decode types are:
106106.RS
107107.TP
···122122Remove even numbered tracks.
123123.TP
124124.BI "encode " "type filename"
125125-Load a pfdc sector image from \fIfilename\fR and encode it.
125125+Load a pri sector image from \fIfilename\fR and encode it.
126126Valid encode types are:
127127.RS
128128.TP
···173173.BR pce-ibmpc "(1),"
174174.BR pce-macplus "(1),"
175175.BR pce-img "(1),"
176176-.BR pfdc "(1)"
176176+.BR psi "(1)"
177177178178.SH AUTHOR
179179Hampa Hug <hampa@hampa.ch>