Implement MBF binary file compatibility, fix binary loader null-byte truncation, update to v0.14.0
Binary tokenized SAVE/LOAD now stores float constants in Microsoft Binary Format (MBF) on disk, matching original GWBASIC.EXE. A token-walking function (convert_floats) converts IEEE↔MBF at the save_binary()/load_binary() boundary. Also fixes a latent bug where load_binary() scanned for 0x00 to find the end of each token line — this fails when float bytes contain null (e.g. MBF for 100.5 is 00 00 49 87). The loader now uses the next-line pointer to compute token data length, matching the original's approach.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
10 REM MBF binary save/load round-trip test
|
||||
20 REM Creates a program with float constants, saves binary, loads back
|
||||
30 REM Uses a flag file to detect second run and break the loop
|
||||
40 OPEN "gwbasic_mbfrt_inner.bas" FOR OUTPUT AS #1
|
||||
50 PRINT #1, "10 PRINT 3.14"
|
||||
60 PRINT #1, "20 PRINT -100.5"
|
||||
70 PRINT #1, "30 PRINT 2.71828#"
|
||||
80 PRINT #1, "40 ON ERROR GOTO 100"
|
||||
90 PRINT #1, "50 OPEN "+CHR$(34)+"gwbasic_mbfrt_flag"+CHR$(34)+" FOR INPUT AS #1"
|
||||
100 PRINT #1, "60 CLOSE #1"
|
||||
110 PRINT #1, "70 KILL "+CHR$(34)+"gwbasic_mbfrt_flag"+CHR$(34)
|
||||
120 PRINT #1, "80 KILL "+CHR$(34)+"gwbasic_mbfrt_bin.bas"+CHR$(34)
|
||||
130 PRINT #1, "90 END"
|
||||
140 PRINT #1, "100 RESUME 110"
|
||||
150 PRINT #1, "110 OPEN "+CHR$(34)+"gwbasic_mbfrt_flag"+CHR$(34)+" FOR OUTPUT AS #1"
|
||||
160 PRINT #1, "120 CLOSE #1"
|
||||
170 PRINT #1, "130 SAVE "+CHR$(34)+"gwbasic_mbfrt_bin.bas"+CHR$(34)
|
||||
180 PRINT #1, "140 KILL "+CHR$(34)+"gwbasic_mbfrt_inner.bas"+CHR$(34)
|
||||
190 PRINT #1, "150 LOAD "+CHR$(34)+"gwbasic_mbfrt_bin.bas"+CHR$(34)+",R"
|
||||
200 CLOSE #1
|
||||
210 LOAD "gwbasic_mbfrt_inner.bas",R
|
||||
Reference in New Issue
Block a user