Implement VIEW/WINDOW/PALETTE, PMAP, fix MBF float format, update to v0.13.0

Graphics viewport and coordinate mapping:
- VIEW [[SCREEN] (x1,y1)-(x2,y2) [,[fill][,border]]] with clipping
- WINDOW [[SCREEN] (x1,y1)-(x2,y2)] with Cartesian/screen modes
- PALETTE [attribute, color] with CGA 16-color remapping
- PMAP(coord, func) for logical/physical coordinate conversion
- All graphics statements (PSET, LINE, CIRCLE, PAINT, GET/PUT) respect
  viewport clipping and WINDOW coordinate mapping

MBF (Microsoft Binary Format) float support:
- CVS/CVD now interpret bytes as MBF format (compatible with real GW-BASIC)
- MKS$/MKD$ now produce MBF-encoded bytes
- Fixed shift errors in MBF↔IEEE conversion routines (single: 1→0, double: 4→3)
- Random-access file I/O now byte-compatible with original GWBASIC.EXE

66 tests (2 new), 61 compat matches (up from 58).
This commit is contained in:
Eremey Valetov
2026-03-10 22:20:58 -04:00
parent 4551c88a50
commit 0bacfcef6c
15 changed files with 478 additions and 47 deletions
+15
View File
@@ -0,0 +1,15 @@
0
1
-1
3.14
100.5
0
1
-1
3.14
0
32767
-32768
-1
0 0 0 129
DONE
+7
View File
@@ -0,0 +1,7 @@
PMAP(0,0)= 0
PMAP(0,1)= 199
PMAP(100,0)= 639
PMAP(100,1)= 0
PMAP(0,2)= 0
PMAP(199,3)= 0
VIEW/WINDOW/PALETTE OK
+22
View File
@@ -0,0 +1,22 @@
10 REM MBF format conversion test
20 REM Test MKS$/CVS roundtrip
30 PRINT CVS(MKS$(0))
40 PRINT CVS(MKS$(1))
50 PRINT CVS(MKS$(-1))
60 PRINT CVS(MKS$(3.14))
70 PRINT CVS(MKS$(100.5))
80 REM Test MKD$/CVD roundtrip
90 PRINT CVD(MKD$(0#))
100 PRINT CVD(MKD$(1#))
110 PRINT CVD(MKD$(-1#))
120 PRINT CVD(MKD$(3.14#))
130 REM Test MKI$/CVI roundtrip
140 PRINT CVI(MKI$(0))
150 PRINT CVI(MKI$(32767))
160 PRINT CVI(MKI$(-32768))
170 PRINT CVI(MKI$(-1))
180 REM Test MBF byte encoding
190 REM MKS$(1) in MBF should be: 00 00 00 81 (exponent=129, mantissa=0.5)
200 A$ = MKS$(1)
210 PRINT ASC(MID$(A$,1,1)); ASC(MID$(A$,2,1)); ASC(MID$(A$,3,1)); ASC(MID$(A$,4,1))
220 PRINT "DONE"
+21
View File
@@ -0,0 +1,21 @@
10 REM VIEW / WINDOW / PALETTE test
20 SCREEN 2
30 REM Test WINDOW coordinate mapping
40 WINDOW (0,0)-(100,100)
50 REM PMAP: logical to physical
60 PRINT "PMAP(0,0)="; PMAP(0,0)
70 PRINT "PMAP(0,1)="; PMAP(0,1)
80 PRINT "PMAP(100,0)="; PMAP(100,0)
90 PRINT "PMAP(100,1)="; PMAP(100,1)
100 REM PMAP: physical to logical
110 PRINT "PMAP(0,2)="; PMAP(0,2)
120 PRINT "PMAP(199,3)="; PMAP(199,3)
130 WINDOW
140 REM Test VIEW
150 VIEW (10,10)-(100,50)
160 REM After VIEW, drawing clips to viewport
170 VIEW
180 REM Test PALETTE (just reset, no visual check)
190 PALETTE
200 SCREEN 0
210 PRINT "VIEW/WINDOW/PALETTE OK"