SS>Does someone have sourcecode to read (and display!) ANSI or AVATAR scre
SS>Not like:
SS>OPEN "CON:" FOR OUTPUT AS #1
SS>But 100% pure code.. So ANSI.SYS isn't needed...
The bload.ansi subroutine need the source of the three messages to
run. And don't need ANSI.SYS file loaded in memory. This source is
a part of my Screen Editor program E-SCREEN v3.01a.
'--------------------------------------------------------------
'------------- PBVANSI.INC ------------------------------------
'--------------------------------------------------------------
'
'ษอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
'บ SUB :bload.ansi 02-09-1992 บ
'ฬอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออน
'บ ACTION: บ
'บ บ
'บ บ
'บ TO PASS: บ
'บ file$ ===> บ
'บ บ
'บ RETURN: บ
'บ บ
'ศอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
sub bload.ansi( file$ )
shared cfgc%, cbgc%
ansi$ = dsk.file.get$( file$ ) ' get the file from the disk
cfgc% = 7
cbgc% = 0
fgc% = 7
bgc% = 0
y% = 1
x% = 1
columns% = scr.cols%
esc$ = chr$(27)
crlf$ = chr$(13,10)
find0$ = esc$+"[s" + crlf$+esc$+"[u"
replace find0$ with "" in ansi$
replace "๚[" with esc$+"[" in ansi$
replace "`[" with esc$+"[" in ansi$
lenansi% = len(ansi$)
do
ansi.esc$ = bload.ansi.get.esc$(ansi$)
lenansi% = lenansi% - len(ansi.esc$)
p% = instr(ansi.esc$, any "ABCDfHhJKlmnRsu")
num$ = mid$(ansi.esc$, 3, p% - 3)
ins$ = mid$(ansi.esc$, p%, 1)
txt$ = right$(ansi.esc$, len(ansi.esc$) - p%)
n% = val(num$)
if n% = 0 then n% = 1
select case ins$
case "A" ' UP n lines. if n=0 then n=1
y% = y% - n%
case "B" ' DOWN n lines. if n=0 then n=1
y% = y% + n%
case "C" ' RIGHT n lines. if n=0 then n=1
x% = x% + n%
case "D" ' LEFT n lines. if n=0 then n=1
x% = x% - n%
case "f", "H", "R" ' LOCATE n;f. if n or f = 0 then 1
if num$ "" then
m% = instr(num$, ";")
if m% > 0 then
y% = val(left$(num$, m%-1))
x% = val(mid$(num$,m%+1,len(num$)-m%))
else
y% = val(num$)
x% = 1
end if
else
y% = 1
x% = 1
end if
if c$ = "R" then
oldy% = y%
oldx% = x%
end if
case "h", "l" ' type of screen
scr% = val(num$)
select case scr%
case 0 ' 40*25 black and white
width 40
columns% = 40
case 1 ' 40*25 color
width 40
columns% = 40
case 2 : width 80 ' 80*25 black and withe
case 3 : width 80 ' 80*25 color
case 4 : screen 1 ' 320*200 color
case 5 : screen 1 ' 320*200 black and white
case 6 : screen 2 ' 640*200 black and white
case 7 : scroll%=-1 ' scroll up when end of screen
case else ' other case
end select
case "J" ' clear screen. CLS
if fgc% 0 or bgc% 0 then
cfgc% = fgc%
cbgc% = bgc%
else
cfgc% = 7
cbgc% = 0
end if
color cfgc%, cbgc%
cls
case "K" ' clear to end of line
color cfgc%, cbgc%
print space$(scr.cols% - x%);
color fgc%, bgc%
locate y%, x%
case "m" ' set colors
call scr.ansi2color.fn( num$, fgc%, bgc% )
case "n", "s" ' hold the cursor position in memo
oldy% = y%
oldx% = x%
case "u" ' restart the cursor position holded.
y% = oldy%
x% = oldx%
case else
error 102
end select
if mfgc% fgc% or mbgc% bgc% then
color fgc%, bgc%
mfgc% = fgc%
mbgc% = bgc%
end if
if x% < 1 then x% = 1
if y% < 1 then y% = 1
if y% > scr.rows% then call scr.text.8x8
if x% > scr.cols% then width 80
crlf% = instr(txt$, crlf$)
if crlf% > 0 then
replace crlf$ with "" in txt$
locate y%, x%
print left$(txt$,crlf%);
txt$ = right$(txt$, len(txt$)+1-crlf%)
incr y%
x% = 1
end if
if txt$ "" then
locate y%, x%
print txt$;
y% = csrlin
x% = pos(0)
end if
loop while lenansi%
end sub
'
'ษอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
'บ FUNCTION :bload.ansi.get.esc$ 02-09-1992 บ
'ฬอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออน
'บ ACTION: บ
'บ บ
'บ บ
'บ TO PASS: บ
'บ ansi$ ===> บ
'บ บ
'บ RETURN: บ
'บ bload.ansi.getesc===> บ
'บ บ
'ศอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
function bload.ansi.get.esc$(ansi$)
static p%
if p% = 0 then p% = 1
e% = instr( p%+1, ansi$, chr$(27) )
if e% > 0 then
bload.ansi.get.esc$ = mid$(ansi$, p%, e%-p% )
p% = e%
else
bload.ansi.get.esc$ = mid$(ansi$, p%, len(ansi$)+1-p%)
p% = 0
end if
end function
'
'ษอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
'บ SUB :scr.attr2ansi.fn 10-19-1992 บ
'ฬอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออน
'บ ACTION: Return all ANSI colors values of a passed color attribute บ
'บ value. บ
'บ TO PASS: บ
'บ attr% ===> Calour attribute value. บ
'บ บ
'บ RETURN: บ
'บ afgc% ===> ANSI Fore Ground Colour number บ
'บ abgc% ===> ANSI Back Ground Colour number บ
'บ inten% ===> Intensity. TRUE (-1) or FALSE (0) บ
'บ blink% ===> Blink. TRUE (-1) or FALSE (0) บ
'บ บ
'ศอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
sub scr.attr2ansi.fn( attr%, afgc%, abgc%, inten%, blink% )
afgc% = attr% mod 8 ' extract fore ground color
afgc% = scr.ansi2color%( afgc% )' true basic color
abgc% = attr% \ 16 ' extract back ground color
abgc% = abgc% mod 8
abgc% = scr.ansi2color%( abgc% )' true basic color
inten% = 0 ' intensity FALSE
blink% = 0 ' blink FALSE
if (attr% and 8) 0 then inten% = -1 ' intensity TRUE
if (attr% and 128) 0 then blink% = -1 ' blink TRUE
end sub
'
'ษอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
'บ SUB :scr.ansi2color.fn 10-19-1992 บ
'ฬอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออน
'บ ACTION: Extract from an ANSI color value into a character string บ
'บ the Fore Ground and Back Ground color values บ
'บ บ
'บ TO PASS: บ
'บ num$ ===> ANSI color value. บ
'บ บ
'บ RETURN: บ
'บ fgc% ===> Fore ground color PowerBasic value บ
'บ bgc% ===> Back ground color PowerBasic value บ
'บ บ
'ศอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
sub scr.ansi2color.fn( num$, fgc%, bgc% )
local p%, m%, c$, c%
static blink%, inten% ' Static var. to blink and Intensity
shared cfgc% ' PUBLIC VARIABLES!!! usables for the
shared cbgc% ' main program to clear screen.
' Fore Ground and Back Ground colors.
p% = 0
do
m% = instr(p% + 1, num$, ";") - 1 ' find ; into ANSI string
if m% < 1 then m% = len(num$) - p%
c$ = mid$(num$, p% + 1, m%) ' extract secuent color
c% = val(c$) ' color char. to color integer
select case c%
case 0, 8 ' clear screen colors
fgc% = 7
bgc% = 0
inten% = 0
blink% = 0
case 1 : inten% = -1 ' intensity TRUE
case 2 : inten% = 0 ' intensity FALSE
case 5 : blink% = -1 ' blink TRUE
case 30 to 37 ' fore ground
c% = c% - 30
fgc% = scr.ansi2color%( c% ) ' true basic color
case 40 to 47 ' back ground
c% = c% - 40
bgc% = scr.ansi2color%( c% ) ' true basic color
end select
p% = instr(p% + 1, num$, ";")
loop while p%
if inten% then ' Intensity
select case fgc%
case <8 , 16 to 23
fgc% = fgc% + 8
end select
end if
if blink% and fgc% < 16 then ' Blink
fgc% = fgc% + 16
end if
end sub
'
'ษอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออป
'บ FUNCTION :scr.ansi2color% 10-19-1992 บ
'ฬอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออน
'บ ACTION: Translate ANSI color value to a PowerBasic color value บ
'บ บ
'บ TO PASS: บ
'บ acolor% ===> ANSI color value. บ
'บ บ
'บ RETURN: บ
'บ scr.ansi2color%===> PowerBasic color value บ
'บ บ
'ศอออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออผ
function scr.ansi2color%( acolor% )
local PBcolor%
select case acolor% ' change ANSI color to PB color
case 1: PBcolor% = 4
case 3: PBcolor% = 6
case 4: PBcolor% = 1
case 6: PBcolor% = 3
case else: PBcolor% = acolor%
end select
scr.ansi2color% = PBcolor%
end function
* Wave Rider 1.20 [NR] *
... UNREGISTERED EVALUATION COPY
--- Wave Rider v1.20
(757:101/24)
---------------
* Origin: Clot BBS 34-3-2324070 (A 14K4) / 34-3-2654579 (A 28K8)
|