ON ERROR PROCError(REPORT$ + " at line " + STR$ERL)
ScrW% = 640
ScrH% = 512
PROCFixWndSz
VDU 23,22,ScrW%;ScrH%;8,16,16,0
bits% = FNCreateDIBSection
DIM code% 127
FOR I% = 0 TO 2 STEP 2
P% = code%
[OPT I%
mov eax, [^bits%] ; base address of DIBSection
mov ecx, ScrW%*ScrH% ; no. of pixels to write
mov edx, &12345678 ; colour
.lp
mov [eax], edx ; write pixel to DIBSection
add eax, 4 ; inc. addr by 4 bytes
sub edx, &01020305
dec ecx ; dec loop counter
jg lp ; loop if > 0
ret
]
NEXT I%
CALL code%
SYS "InvalidateRect", @hwnd%, 0, 0
*REFRESH
END
DEFFNCreateDIBSection
LOCAL A%,B%,H%,O%
DIM B% 19:!B%=44:B%!4=@vdu%!208:B%!8=@vdu%!212:B%!12=&200001
SYS"CreateDIBSection",@memhdc%,B%,0,^A%,0,0TOH%
IF H%=0 PROCError("Create DIBSection failed")
SYS"SelectObject",@memhdc%,H%TOO%
SYS"DeleteObject",O%
CLS
=A%
DEF PROCFixWndSz
LOCAL W%
SYS"GetWindowLong",@hwnd%,-16 TO W%
SYS"SetWindowLong",@hwnd%,-16,W% ANDNOT&40000 ANDNOT&10000
ENDPROC
DEF PROCError(s$)
OSCLI "REFRESH ON"
CLS : ON : VDU 7
PRINT '" " + s$;
REPEAT UNTIL INKEY(1)=0
ENDPROC
ON ERROR PROCError(REPORT$ + " at line " + STR$ERL)
ScrW% = 512
ScrH% = 512
PROCFixWndSz
VDU 23,22,ScrW%;ScrH%;8,16,16,0
REM Create 32bpp (ARGB &AARRGGBB) DIBSection:
bits% = FNCreateDIBSection
DIM code% 127
FOR I% = 0 TO 2 STEP 2
P% = code%
[OPT I%
mov eax, [^bits%] ; base address of DIBSection colour bits (pixels)
mov ecx, ScrW%*ScrH% ; no. of pixels to write (4 bytes per pixel)
mov edx, &00654321 ; initial (&AARRGGBB) colour
.lp
mov [eax + 4*ecx -4], edx ; write pixel to DIBSection
sub edx, &00010101 ; update/modify colour
loopnz lp ; ECX is automatically decremented & checked
ret
]
NEXT I%
CALL code%
SYS "InvalidateRect", @hwnd%, 0, 0
*REFRESH
END
DEFFNCreateDIBSection
LOCAL A%,B%,H%,O%
DIM B% 19:!B%=44:B%!4=@vdu%!208:B%!8=@vdu%!212:B%!12=&200001
SYS"CreateDIBSection",@memhdc%,B%,0,^A%,0,0TOH%
IF H%=0 PROCError("Create DIBSection failed")
SYS"SelectObject",@memhdc%,H%TOO%
SYS"DeleteObject",O%
CLS
=A%
DEF PROCFixWndSz
LOCAL W%
SYS"GetWindowLong",@hwnd%,-16 TO W%
SYS"SetWindowLong",@hwnd%,-16,W% ANDNOT&40000 ANDNOT&10000
ENDPROC
DEF PROCError(s$)
OSCLI "REFRESH ON"
CLS : ON : VDU 7
PRINT '" " + s$;
REPEAT UNTIL INKEY(1)=0
ENDPROC