├── BIN2SRC
├── BIN2BSV.PAS
└── BIN2SRC.PAS
├── LICENSE
├── README.md
├── RM
├── BGIEDIT.PAS
├── BGIGADGE.PAS
├── BGIIMAGE.PAS
├── BGIMISC.PAS
├── BGIMOUSE.PAS
├── BGIPAL.PAS
├── BGIREQ.PAS
├── BGITEXT.PAS
├── BIGEDIT.PAS
├── BITS.PAS
├── CORE.PAS
├── DEF2RAW.PAS
├── DRIVERS.PAS
├── FORMAT.PAS
├── KEYS.PAS
├── MESSAGES.PAS
├── PANEL.PAS
├── RM.INC
├── RM.PAS
├── RML16.OBJ
├── RML16.XGF
├── RML256.OBJ
├── RML256.XGF
├── RMLOGO.BMP
├── RMSTRG.PAS
├── RMTITLE.PAS
├── RRES.PAS
├── RWBMP.PAS
├── RWCEL.PAS
├── RWCUSTOM.PAS
├── RWICO.PAS
├── RWPCX.PAS
├── RWXGF.PAS
├── SCREEN.PAS
├── SVGA16.BGI
├── SVGA16.OBJ
├── SVGA256.BGI
├── SVGA256.OBJ
├── TOOLS.PAS
├── VARS.PAS
├── WCON.PAS
├── WDEF.PAS
├── WMASK.PAS
├── WPRF.PAS
├── XGF2SRC.PAS
└── XGRAPH.PAS
├── RMCLIP
├── BGIEDIT.PAS
├── BGIGADGE.PAS
├── BGIIMAGE.PAS
├── BGIMISC.PAS
├── BGIMOUSE.PAS
├── BGIPAL.PAS
├── BGITEXT.PAS
├── BITS.PAS
├── KEYS.PAS
├── PANEL.PAS
├── PARSE.PAS
├── RKEY.PAS
├── RLIST.PAS
├── RMCLIP.PAS
├── RWBMP.PAS
├── RWPAL.PAS
├── RWPCX.PAS
├── RWRAW.PAS
├── SCREEN.PAS
├── SVGA16.BGI
├── SVGA16.OBJ
├── SVGA256.BGI
├── SVGA256.OBJ
├── VARS.PAS
├── WPRF.PAS
├── WXGF.PAS
└── XGRAPH.PAS
└── RP
├── PCX2RAW.PAS
├── PCX2XGF.PAS
├── RAW2DEF.PAS
├── RAW2PRF.PAS
├── RAW2XGF.PAS
├── RKEY.PAS
├── RP.PAS
├── VARS.PAS
└── WXGF.PAS
/BIN2SRC/BIN2BSV.PAS:
--------------------------------------------------------------------------------
1 | (* Data Meaning
2 | 'BYTE Magic number (always 0xFD, 253)
3 | 'INT Segment. Set to 0x9999 by modern versions.
4 | 'INT Offset is always 0
5 | 'INT Length, the number of bytes
6 |
7 | Article: Q34407
8 | Product(s): See article
9 | Version(s): 3.00 4.00 4.00b 4.50
10 | Operating System(s): MS-DOS
11 | Keyword(s): ENDUSER | B_BasicCom B_GWBasicI | mspl13_basic
12 | Last Modified: 9-JAN-1991
13 |
14 | A file saved with the BSAVE statement has a 7-byte header with the
15 | following hexadecimal format:
16 |
17 | ww xx xx yy yy zz zz
18 |
19 | ww: A signature byte equal to 253, which tells DOS and other
20 | programs that this is a BASIC BSAVE/BLOAD format file.
21 | xx xx: The segment address from the last BSAVE.
22 | yy yy: The offset address from the last BSAVE.
23 | zz zz: The number of bytes BSAVEd.
24 |
25 | This information applies to Microsoft QuickBASIC versions 3.00, 4.00,
26 | 4.00b, and 4.50 for MS-DOS; to Microsoft BASIC Compiler versions 6.00
27 | and 6.00b for MS-DOS; and to Microsoft BASIC Professional Development
28 | System (PDS) versions 7.00 and 7.10 for MS-DOS.
29 |
30 | This information is provided as is. The BSAVE format is not guaranteed
31 | to be the same in a future release.
32 |
33 | Microsoft GW-BASIC Interpreter (versions 3.20, 3.22, and 3.23) uses
34 | the same 7-byte header string, and also repeats the 7-byte string,
35 | appending it after the final data byte. BASICA (provided in IBM or
36 | Compaq ROM on some computer models) does not repeat the 7-byte string
37 | at the end. GW-BASIC and BASICA both terminate the file with ASCII 26,
38 | also known as a CTRL+Z character (hex 1A). QuickBASIC and Microsoft
39 | BASIC Compiler don't append CTRL+Z or repeat the 7-byte string at the
40 | end.
41 |
42 | To determine whether a file was BSAVEd by GW-BASIC, BASICA, or
43 | QuickBASIC, compare the length of the memory saved against the file
44 | length. The difference is 15 bytes in GW-BASIC, 7 bytes in QuickBASIC,
45 | and 8 bytes in BASICA.
46 |
47 | Despite the slight format differences, files BSAVEd under any of the
48 | three above BASIC dialects correctly BLOAD into each other BASIC.
49 | *)
50 |
51 | Program BIN2BSV;
52 |
53 | const
54 | ProgramName = 'Bin2Bsv 1.0';
55 | CopyRight = '(c) Copyright 2022 By RetroNick. All Rights Reserved';
56 | GitHub1 = 'Get source and latest version from github:';
57 | GitHub2 = 'https://github.com/RetroNick2020';
58 |
59 | MaxBSaveSize = 32767;
60 | type
61 | BsvRec = Record
62 | Magic : Byte;
63 | Seg : Word;
64 | Off : Word;
65 | Length : Word;
66 | end;
67 |
68 | Var
69 | InFileMemPtr : Pointer;
70 | InFileSize : Word;
71 |
72 |
73 | (* we could allocate less memory - but this just a small app - 32Kb is no big deal *)
74 | Procedure GetTheMemory;
75 | begin
76 | GetMem(InFileMemPtr,MaxBsaveSize);
77 | if InFileMemPtr = NIL then
78 | begin
79 | Writeln('Failed to Allocate Enough Memeory, we need ',MaxBSaveSize,' bytes!');
80 | end;
81 | end;
82 |
83 | Procedure FreeTheMemory;
84 | begin
85 | if InFileMemPtr<>NIL then
86 | begin
87 | Freemem(InFileMemPtr,MaxBsaveSize);
88 | end;
89 | end;
90 |
91 |
92 | Procedure FailAndCleanUp;
93 | begin
94 | FreeTheMemory;
95 | writeln('Looks like something went wrong - not sure what to say.');
96 | halt;
97 | end;
98 |
99 | Procedure CheckSize(filename : string);
100 | var
101 | F : File;
102 | begin
103 | Assign(F,filename);
104 | {$I-}
105 | Reset(F,1);
106 | if FileSize(F) > 32767 then
107 | begin
108 | writeln('Source file too big. Must be ',MaxBSaveSize,' bytes or less!');
109 | Close(F);
110 | FreeTheMemory;
111 | Halt;
112 | end;
113 | Close(f);
114 | {$I+}
115 | if IOResult <> 0 then
116 | begin
117 | FailAndCleanUp;
118 | end;
119 | end;
120 |
121 | Procedure ReadFile(filename : string);
122 | var
123 | F : File;
124 | RSize : Word;
125 | begin
126 | Assign(F,filename);
127 | {$I-}
128 | Reset(F,1);
129 | BlockRead(F,InFileMemPtr^,MaxBSaveSize,RSize);
130 | close(F);
131 | {$I+}
132 | if IOResult <> 0 then
133 | begin
134 | FailAndCleanUp;
135 | end;
136 | InFileSize:=RSize;
137 | end;
138 |
139 | Procedure WriteFile(filename : string);
140 | var
141 | F : File;
142 | WSize : Word;
143 | Bsv :BsvRec;
144 | begin
145 | Bsv.Magic:=$FD; (* 253 *)
146 | Bsv.Seg:=$9999;
147 | Bsv.Off:=$0;
148 | Bsv.Length:=InFileSize;
149 | Assign(F,filename);
150 | {$I-}
151 | Rewrite(F,1);
152 | BlockWrite(F,Bsv,sizeof(Bsv));
153 | BlockWrite(F,InFileMemPtr^,InFileSize,WSize);
154 | BlockWrite(F,Bsv,sizeof(Bsv));
155 | close(F);
156 | {$I+}
157 | if IOResult <> 0 then
158 | begin
159 | FailAndCleanUp;
160 | end;
161 | end;
162 |
163 | Procedure PrintHelp;
164 | begin
165 | writeln(ProgramName);
166 | writeln(Copyright);
167 | writeln;
168 | writeln(GitHub1);
169 | writeln(GitHub2);
170 | writeln;
171 |
172 | writeln('Usage: Bin2Bsv