Close

Load BMP file from SD-card

A project log for BASIC microcomputer, based on Arduino

A microcomputer with PS/2 keyboard, SD card storage and composite video output, running Terminal-BASIC

andrey-skvortsovAndrey Skvortsov 03/31/2019 at 20:521 Comment

Terminal-BASIC 2.0-rc introduced UNIX-style file operations. This video shows the process of loading 1-bpp BMP file from SD-card. Yes, it's damn slow. Image was loaded by the following BASIC program:

   1 DEF FN BN% (BYT%, BIT%) = (BYT% \ (2 ^ BIT%)) AND 1
  10 INPUT F$
  20 GOSUB  1000
 100 END
1000 REM LOAD
1010 BMP% = FOPEN ( F$ )
1020 IF BMP% = -  1 THEN PRINT "FOPEN" : GOTO  1995
1030 B% = FREAD ( BMP% ) : M% = FREAD ( BMP% )
1040 S$ = CHR$ ( B% ) + CHR$ ( M% )
1050 IF S$ <> "BM" THEN PRINT "HEADER" : GOTO  1990
1060 FOR I% =  1 TO  8 : B% = FREAD ( BMP% ) : NEXT I%
1070 DP% = FREAD ( BMP% )
1080 DP% = DP% + FREAD ( BMP% ) *  256
1085 DP%=DP%-12
1090 IF DP% < 0 GOTO 1110
1100 FOR I%=0 TO DP%-1 : B%=FREAD(BMP%) : NEXT I%    
1110 FOR Y%=191 TO 0 STEP -1
1120   FOR X%=0 TO 24
1130     B% = FREAD(BMP%)
1140     FOR XX%=0 TO 7
1150       POINTC X%*8+XX%, Y%, FN BN%(B%,7-XX%)
1600     NEXT XX%
1700   NEXT X%
1710   B%=FREAD(BMP%):B%=FREAD(BMP%):B%=FREAD(BMP%)
1800 NEXT Y%
1990 FCLOSE BMP%
1991 S$=GET$()
1992 IF S$="" GOTO 1991
1995 RETURN

Discussions

Andrey Skvortsov wrote 03/31/2019 at 20:55 point

P.S. The old-school computer on the image is 1982 ДВК-2 with 15ИЭ-00-013 terminal

  Are you sure? yes | no