home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
149.lha
/
ColorTerm
/
video.4th
< prev
Wrap
Text File
|
1988-04-25
|
11KB
|
342 lines
\ video.f
DECIMAL
320 CONSTANT LWidth
640 CONSTANT HWidth
200 CONSTANT LHeight
4 CONSTANT LDepth \ 4 bitplanes = 16 colors
CREATE ColorTable \ Byte values for C64 colors.
0 C, 0 C, 0 C, 15 C, 15 C, 15 C, 15 C, 0 C, 0 C,
0 C, 15 C, 15 C, 15 C, 0 C, 15 C, 0 C, 15 C, 0 C,
0 C, 0 C, 15 C, 15 C, 15 C, 0 C, 15 C, 7 C, 0 C,
7 C, 3 C, 0 C, 15 C, 10 C, 10 C, 2 C, 2 C, 2 C,
10 C, 10 C, 10 C, 10 C, 15 C, 10 C, 10 C, 10 C, 15 C,
13 C, 13 C, 13 C,
struct NewScreen ns
0 ns +nsLeftEdge W!
0 ns +nsTopEdge W!
LHeight ns +nsHeight W!
LDepth ns +nsDepth W!
0 ns +nsDetailPen C!
1 ns +nsBlockPen C!
0 ns +nsViewModes W!
CUSTOMSCREEN SCREENQUIET | ns +nsType W!
NULL ns +nsFont !
NULL ns +nsDefaultTitle !
NULL ns +nsGadgets !
NULL ns +nsCustomBitMap !
structend
struct NewWindow nw
0 nw +nwLeftEdge W!
0 nw +nwTopEdge W!
LWidth nw +nwWidth W!
LHeight nw +nwHeight W!
0 nw +nwDetailPen C!
1 nw +nwBlockPen C!
fCLOSEWINDOW MENUPICK | RAWKEY | nw +nwIDCMPFlags !
ACTIVATE BORDERLESS | WINDOWCLOSE | nw +nwFlags !
NULL nw +nwFirstGadget !
NULL nw +nwCheckMark !
NULL nw +nwTitle !
NULL nw +nwBitMap !
CUSTOMSCREEN nw +nwType W!
structend
40 CONSTANT DefaultColumns
24 CONSTANT LineHeight
32 CONSTANT ASCIISpace
CREATE DiskFontLibName 0," diskfont.library"
CREATE UpperFontName 0," C64upper.font" \ uppercase/graphics font
CREATE LowerFontName 0," C64lower.font" \ lowercase/uppercase font
-1 CONSTANT Up
1 CONSTANT Down
-1 CONSTANT Left
1 CONSTANT Right
0 CONSTANT Black
1 CONSTANT White
2 CONSTANT Red
3 CONSTANT Cyan
4 CONSTANT Purple
5 CONSTANT Green
6 CONSTANT Blue
7 CONSTANT Yellow
8 CONSTANT Orange
9 CONSTANT Brown
10 CONSTANT LightRed
11 CONSTANT Gray1
12 CONSTANT Gray2
13 CONSTANT LightGreen
14 CONSTANT LightBlue
15 CONSTANT Gray3
struct TextAttr UpperFontAttr
struct TextAttr LowerFontAttr
VARIABLE UpperFont \ Pointer to 64 font.
VARIABLE LowerFont
VARIABLE CurrentFont
GLOBAL CursorX \ location of cursor on screen
GLOBAL CursorY
VARIABLE CursorCharacter
VARIABLE ColumnWidth
GLOBAL BaseLine \ BaseLine of text.
GLOBAL RpBitMap
GLOBAL SpareBitMap
VARIABLE CurrentColor
VARIABLE TextBuffer
GLOBAL Inserting? \ Boolean flag--true if insert mode is on
GLOBAL Reversed?
: OpenDiskFont ( textattr --- font )
!A0 CALL.LIB@ 10 5 ;
: GetSpareBitMap ( --- ) \ Allocate and initialize spare BitMap.
BitMap MEMF_CHIP MEMF_CLEAR | AllocMem TO SpareBitMap
SpareBitMap LDepth HWidth LHeight InitBitMap
LDepth 0 DO
HWidth LHeight AllocRaster SpareBitMap +bmPlanes I 4* + !
LOOP ;
: FreeSpareBitMap ( --- ) \ Deallocate spare BitMap.
LDepth 0 DO
SpareBitMap +bmPlanes I 4* + @ HWidth LHeight FreeRaster
LOOP
SpareBitMap BitMap FreeMem ;
: VPORT ( --- vport ) \ Return address of current screen's Viewport.
CurrentScreen @ +scViewPort ;
: GetFonts ( --- ) \ Open custom fonts.
DiskFontLibName 0 10 OPEN.LIB DROP
UpperFontAttr TextAttr ERASE
UpperFontName UpperFontAttr +taName !
8 UpperFontAttr +taYSize W!
LowerFontAttr TextAttr ERASE
LowerFontName LowerFontAttr +taName !
8 LowerFontAttr +taYSize W!
UpperFontAttr OpenDiskFont UpperFont ! \ error checking!!!
LowerFontAttr OpenDiskFont LowerFont ! ;
: CloseFonts ( --- ) \ Close the custom fonts and diskfontlibrary.
UpperFont @ CloseFont \ error checking!!!
LowerFont @ CloseFont
10 CLOSE.LIB ;
: SetPens ( apen bpen --- ) \ Set pen colors.
RPORT SWAP SetBPen RPORT SWAP SetAPen ;
: MakeTextColor ( color --- ) \ Set text color.
DUP CurrentColor !
Black
Reversed? IF
SWAP
THEN
SetPens ;
: SetVidMode ( f --- ) \ Set normal or reversed mode.
TO Reversed?
CurrentColor @ MakeTextColor ;
: SetNormal ( --- ) \ Set normal drawing mode.
FALSE SetVidMode ;
: SetReversed ( --- ) \ Set inverse drawing mode.
TRUE SetVidMode ;
: ClearScr ( --- ) \ Clear screen to black.
0 TO CursorX 0 TO CursorY
SetNormal
FALSE TO Inserting?
RPORT Black SetRast ;
: SetNewFont ( font --- ) \ Switch to different font.
LOCALS| newfont |
ClearScr
RPORT newfont SetFont DROP
newfont +tfBaseLine W@ TO BaseLine
newfont CurrentFont ! ;
: SetColors ( --- ) \ Set screen to C64 colors.
1 LDepth SCALE 0 DO
VPORT I
ColorTable I 3 * + C@ \ red
ColorTable I 3 * 1+ + C@ \ green
ColorTable I 3 * 2+ + C@ \ blue
SetRGB4
LOOP ;
: SetScreenWidth ( n --- ) \ Set up screen width.
DUP 8* ns +nsWidth W!
DUP 8* nw +nwWidth W!
DUP 80 = IF
HIRES ns +nsViewModes W!
ELSE
0 ns +nsViewModes W!
THEN
1- ColumnWidth !
ns OpenScreen
CurrentScreen @ nw +nwScreen !
nw OpenWindow
SetColors
RPORT JAM2 SetDrMd
ClearScr ;
: SwitchRes ( n menu --- ) \ Switch screen resolution.
LOCALS| newmenu width |
CurrentWindow @ ClearMenuStrip
CurrentWindow @ CloseWindow
CurrentScreen @ CloseScreen
width SetScreenWidth
CurrentFont @ SetNewFont
CurrentWindow @ newmenu @ SetMenuStrip ;
: SetVideo ( --- ) \ Set up screen.
DefaultColumns SetScreenWidth
RPORT +rpBitMap @ TO RpBitMap
GetSpareBitMap
Yellow CurrentColor !
LowerFont @ SetNewFont
0 TextBuffer !
166 CursorCharacter C! ;
: LocateText ( --- ) \ Position graphics cursor to draw text.
RPORT CursorX 8* CursorY 8* BaseLine + Move ;
: ToggleCursor ( --- ) \ Draw cursor at current cursor position.
LocateText
RPORT COMPLEMENT SetDrMd
RPORT CursorCharacter 1 Text DROP
RPORT JAM2 SetDrMd ;
: ScrollScreen ( --- ) \ Scroll screen upwards one line.
SpareBitMap RPORT +rpBitMap !
SpareBitMap CurrentScreen @ +scViewPort +vpRasInfo @ +riBitMap !
RPORT Black SetRast \ erase spare BitMap
RpBitMap 0 8 SpareBitMap 0 0
CurrentWindow @ +wdWidth W@ LHeight 8- 192 255 NULL BltBitMap DROP
CurrentScreen @ MakeScreen \ show the spare
RethinkDisplay
SpareBitMap 0 0 RpBitMap 0 0
CurrentWindow @ +wdWidth W@ LHeight 192 255 NULL BltBitMap DROP
RpBitMap RPORT +rpBitMap ! \ switch back to the real one
RpBitMap CurrentScreen @ +scViewport +vpRasInfo @ +riBitmap !
CurrentScreen @ MakeScreen \ and display it
RethinkDisplay ;
: CheckCursorLimits ( --- ) \ Make sure cursor is still on the screen.
CursorX ColumnWidth @ > IF
0 TO CursorX 1 CursorY + TO CursorY
ELSE
CursorX 0< IF ColumnWidth @ TO CursorX -1 CursorY + TO CursorY THEN
THEN
CursorY 0< IF
0 TO CursorY
ELSE
CursorY LineHeight > IF LineHeight TO CursorY ScrollScreen THEN
THEN ;
: MoveHorizontal ( direction --- ) \ Move cursor horizontally.
CursorX + TO CursorX CheckCursorLimits ;
: MoveVertical ( direction --- ) \ Move cursor vertically.
CursorY + TO CursorY CheckCursorLimits ;
: PrintLF ( --- ) \ Print a linefeed.
CursorY 1+ TO CursorY CheckCursorLimits ;
: PrintCR ( --- ) \ Print a carriage return.
SetNormal
FALSE TO Inserting?
0 TO CursorX PrintLF ;
: HomeCursor ( --- ) \ Move cursor to home position.
0 TO CursorX 0 TO CursorY ;
: EmitScrChar ( char --- ) \ Draw a character.
TextBuffer C!
LocateText
RPORT TextBuffer 1 Text DROP
1 CursorX + TO CursorX CheckCursorLimits ;
: PrintBackSpace ( --- ) \ Print a backspace.
-1 CursorX + TO CursorX CheckCursorLimits
ASCIISpace EmitScrChar
-1 CursorX + TO CursorX CheckCursorLimits ;
: MoveChars ( direction --- ) \ Insert or delete a character.
8* NEGATE RPORT SWAP 0 CursorX 8* CursorY 8*
CurrentWindow @ +wdWidth W@
CursorY 1+ 8*
ScrollRaster ;
: InsertChar ( --- ) \ Insert space at cursor position.
Right MoveChars
Reversed?
SetNormal
ASCIISpace EmitScrChar
-1 CursorX + TO CursorX CheckCursorLimits
IF
SetReversed
THEN ;
: DeleteChar ( --- ) \ Delete character at cursor position.
-1 CursorX + TO CursorX CheckCursorLimits
Left MoveChars ;
: PrintScrChar ( char --- ) \ Output a character to the screen.
LOCALS| char |
char 161 < IF
char CASE
ASCIISpace 127 RANGE.OF char EmitScrChar ENDOF
5 OF White MakeTextColor ENDOF
7 OF CurrentScreen @ DisplayBeep ENDOF
8 OF PrintBackSpace ENDOF
{ 10 OF PrintLF ENDOF }
13 OF PrintCR ENDOF
14 OF LowerFont @ SetNewFont ENDOF
17 OF Down MoveVertical ENDOF
18 OF SetReversed ENDOF
19 OF HomeCursor ENDOF
20 OF DeleteChar ENDOF
28 OF Red MakeTextColor ENDOF
29 OF Right MoveHorizontal ENDOF
30 OF Green MakeTextColor ENDOF
31 OF Blue MakeTextColor ENDOF
129 OF Orange MakeTextColor ENDOF
142 OF UpperFont @ SetNewFont ENDOF
144 OF Black MakeTextColor ENDOF \ ???
145 OF Up MoveVertical ENDOF
146 OF SetNormal ENDOF
147 OF ClearScr ENDOF
148 OF InsertChar ENDOF
149 155 RANGE.OF char 140 - MakeTextColor ENDOF
156 OF Purple MakeTextColor ENDOF
157 OF Left MoveHorizontal ENDOF
158 OF Yellow MakeTextColor ENDOF
159 OF Cyan MakeTextColor ENDOF
160 OF ASCIISpace EmitScrChar ENDOF
ENDCASE
ELSE
char CASE
161 191 RANGE.OF char EmitScrChar ENDOF
192 223 RANGE.OF char 96 - EmitScrChar ENDOF
224 254 RANGE.OF char 64 - EmitScrChar ENDOF
255 OF char EmitScrChar ENDOF
ENDCASE
THEN ;