home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
ddjmag
/
ddj8711.arc
/
BREEDEN.LST
next >
Wrap
File List
|
1987-10-08
|
35KB
|
685 lines
Listing 1
Screen # 0
\ jbb 15:47 08/04/87
GETIMAGE
Copyright 1987, All Rights Reserved
by
J. Brooks Breeden
Columbus, Ohio
August 4, 1987
Loads an EGAPAINT file into video memory
from within UR/FORTH for subsequent animation, etc.
Screen # 1
\ Misc. jbb 13:01 08/04/87
DOSINT \ fetch level 2 DOS interface
HCB IMAGEHCB \ create the handle block
CREATE PALTAB 16 ALLOT \ to hold egapaint's palette
: ?MEMREQ ( x1 y1 x2 y2 - bytes) \ calc. memory req to @BLOCK
ROT - 1+ -ROT SWAP - 1+ 2/ 1+ * 4 + ;
HEX
: RESTORE-EGA ( - ) \ restore EGA's default mode:
2 3C4 PC! 0F 3C5 PC! \ default map mask
3 3CE PC! 0 3CF PC! \ default data rotate reg value
5 3CE PC! 0 3CF PC! \ default write mode 0
8 3CE PC! FF 3CF PC! ; \ default bit mask
DECIMAL
-->
Screen # 2
\ EGA map mask control jbb 15:37 08/04/87
HEX
: READMODE0 ( - ) 5 3CE PC! 8 3CF PC! 2 3CE PC! 0 3CF PC! ;
\ set map-masks to select active EGA color bit-planes
: BLUEPLANE ( - ) 2 3C4 PC! 1 3C5 PC! ; \ plane 0
: GREENPLANE ( - ) 2 3C4 PC! 2 3C5 PC! ; \ plane 1
: REDPLANE ( - ) 2 3C4 PC! 4 3C5 PC! ; \ plane 2
: INTENSEPLANE ( - ) 2 3C4 PC! 8 3C5 PC! ; \ plane 3
DECIMAL
-->
Screen # 3
\ File control jbb 12:59 08/04/87
: OPENIMAGEFILE ( ^filename - )
IMAGEHCB NAME>HCB \ force filename
IMAGEHCB O_RD FOPEN \ open file for reading
IF ABORT" Can't open file." THEN ;
: CLOSEIMAGEFILE ( - ) IMAGEHCB FCLOSE DROP ;
: MAKEIMAGEFILE ( ^filename - )
IMAGEHCB NAME>HCB \ force filename
IMAGEHCB 0 FMAKE \ make "normal" file
IF ABORT" Can't make file." THEN ;
-->
Screen # 4
\ Read EGAPAINT file from disk to video jbb 15:45 08/04/87
\ To load EGAPAINT disk image into EGA video segment...
\ set map mask, read bytes from disk, repeat for each plane
: READBYTES ( - ) \ read 28,000 bytes to video segment
IMAGEHCB ?VSEG 0 \ source=handle; dest.= videoseg:offset
28000 FREADL \ read 28,000 bytes
DROP ; \ drop flag.
: READPAINTFILE ( - ) \ read all four planes in sequence...
BLUEPLANE READBYTES REDPLANE READBYTES
GREENPLANE READBYTES INTENSEPLANE READBYTES ;
-->
Screen # 5
\ jbb 15:44 08/04/87
: LOADPAINTFILE ( ^filename - )
640X350 VMODE CLS \ hi-res 16-color
OPENIMAGEFILE \ Open the file, and
IMAGEHCB PALTAB 16 FREAD \ read palette data.
IF PALTAB !PALETTE \ If read was successful,
THEN \ set palette to new colors.
READMODE0 \ Set read mode 0 and
READPAINTFILE \ read the bit-plane data.
CLOSEIMAGEFILE \ Close the file, and
RESTORE-EGA ; \ restore the EGA defaults.
-->
Screen # 6
\ Load the EGAPAINT full-screen image jbb 15:17 08/04/87
CREATE BARON ,C" THEFOKKR.IMG" \ orig 112K EGAPAINT disk file
CREATE FOKKER ,C" DERFOKKR.IMG" \ new smaller @BLOCK disk file
CREATE DR.1 3072 ALLOT \ memory req as multiple of 8
: SAVEDR.1 1 1 106 53 DR.1 @BLOCK ; \ get block to memory
: GETIMAGE BARON LOADPAINTFILE SAVEDR.1 ; \ get orig image>mem
: SAVEFOKKER FOKKER MAKEIMAGEFILE \ build .img file on disk
IMAGEHCB PALTAB 16 FWRITE DROP \ include pallete info
IMAGEHCB DR.1 2904 FWRITE DROP \ write DR.1 mem to disk
CLOSEIMAGEFILE ; \ close it out...
-->
Screen # 7
\ CHECKOUT JUNK jbb 16:07 08/04/87
: CK1 HR DR.1 267 148 !BLOCK
277 156 361 192 FRAME \ Fokker image limits
LTBLUE FG
267 148 372 200 FRAME \ image area saved
262 143 272 153 FRAME \ hit zone around CORNER
314 165 324 175 FRAME ; \ hit zone on Fokker
: GUNSIGHT ( - ) ORANGE FG 269 170 369 170 LINE
319 133 319 274 LINE 319 170 50 circle ;
: CK CK1 GUNSIGHT ;
Listing 2
Listing 2. Pseudocode to move a full 112,000 byte image
from the disk to the screen: NOTE: ALL NUMBERS HEXIDECIMAL
Set the video mode to graphics mode xx however your language
does it.
Open the file using a DOS handle however your language does
it.
If palette data is the first data in the file,
Then read the palette data and set the new palette. (This
should be covered in your language's high level routines.)
Set read mode 0
Write 5 to port 3CE, then
write 8 to port 3CF, then
write 2 to port 3CE, then
write 0 to port 3CF.
Set map mask to plane 0 (blue plane)
Write 2 to port 3C4, then
write 1 to port 3C5.
Read 28,000 bytes from the file to A000:0000 however your
language does it.
Set map mask to plane 2 (red plane)
Write 2 to port 3C4, then
write 4 to port 3C5.
Read 28,000 bytes from the file to A000:0000 however your
language does it.
Set map mask to plane 1 (green plane)
Write 2 to port 3C4, then
write 4 to port 3C5.
Read 28,000 bytes from the file to A000:0000 however your
language does it.
Set map mask to plane 3 (intensity plane)
Write 2 to port 3C4, then
write 8 to port 3C5.
Read 28,000 bytes from the file to A000:0000 however your
language does it.
Close the file, however your language does it.
Restore EGA default values.
(set map mask default: all planes active)
Write 2 to port 3C4, then
write 0F to port 3C5.