Re: SCREEN
- Posted by Jacques Deschenes <desja at GLOBETROTTER.QC.CA> Aug 20, 1997
- 675 views
At 18:40 20-08-97 +0100, you wrote: >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS <EUPHORIA at >MIAMIU.ACS.MUOHIO.EDU> >Poster: Jean Hendrickx <jean.hendrickx at EURONET.BE> >Organization: Infoboard Belgium >Subject: SCREEN >------------------------------------------------------------------------------- > >Hi all, >Sorry for the precedent post it was a bit upseted. >I have a try at emulating the Qbasic _function_ SCREEN() >This function determines what character, if any, is at any given >screen location and also determines the character's color >attributes. > SCREEN(row, column [,optionflag]) >where row is the screen row from 1-25, column position 1-80, and >optionflag is a numeric expression specifying which information >to return. When you omit optionflag, the function returns the >ASCII value corresponding to the character at the specified screen >position. If no character found, returns 32 (blank space). If >optionflag is present and evaluate a non zero value, SCREEN returns >the attribute (color) of the referenced character (integer >from 0-255). To decipher this information : >foreground color= attribute MOD 16 >background color= (attribute AND &H70) \16 >-- >I used the bios service 10,8 to do that. but it don't work. >Here is the try : because a to long text it's attached file. > The call of bios seems to clear the screen and nothing is found. >am I missed something ? Any help should be hearty appreciated. >Regards, >-- Jean.Hendrickx. j.hendrickx at infoboard.be >-- SCREEN.EX simulation fonction SCREEN from Qbasic JCH 17/8/97 >include machine.e >include graphics.e >include get.e >constant SCREEN=1 >integer row, col, dum >atom key >sequence coord >object atrib >coord={} atrib={} key=-1 >-- >function Screen(integer row, integer col) >sequence inReg, outReg >inReg= repeat(0,10) >-- cursor at desired location (bios service 10,2) >inReg[REG_AX]=#0002 -- service 2 >inReg[REG_DX]=row*#100 + col >inReg[REG_BX]=#0000 -- video page -------------| >outReg=dos_interrupt(#10,inReg)-- outReg={0,0,0,0,773,0,48,12870,0,0,0} > -- | > -- R=773:256=3 C=remaind=5 > >-- get ASCII character code in AL and attribute byte in AH >-- bios service 10,8 >inReg[REG_AX]=#0008 -- service 8 >inReg[REG_BX]=#0000 -- video page >outReg=dos_interrupt(#10,inReg) > return outReg --[REG_AX] >end function >-- >row=1 col=1 >-- coord= Screen(row,col) -- Control of service 10/2 >--nrow= floor(coord[5]/256) >--ncol= remainder(coord[5],256) >--? nrow >--? ncol -- OK >position(row, col) text_color(7) bk_color(1) >puts(SCREEN,"AAAAAAAAAAA") >while key=-1 do key=get_key() end while >atrib=Screen(row,col) -- return : {0,0,0,0,257,0,32,12870,0,0} >dum=graphics_mode(-1) -- | >? atrib -- " " >-- END CODE ---- > Hi Jean, the problem is that you're placing function code in AL instead of AH It should be: r[REG_AX] = #0200 -- function 2 AH = 2 r[REG_AX] = #0800 -- function 8 AH = 8 try this code ------ cut here ----------- include machine.e include image.e function screen(integer row, integer col, integer OptionFlag) sequence r, pos pos = get_position() position(row,col) r = repeat(0,10) r[REG_AX] = 8*#100 -- AH = 8 get character and attribute at cursor pos. r = dos_interrupt(#10,r) position(pos[1],pos[2]) if OptionFlag then return remainder(r[REG_AX],256) -- return AL = character else return floor(r[REG_AX]/256) -- return AH = attribute end if end function constant CHARACTER = 1, ATTRIBUTE = 0 text_color(BLUE) bk_color(YELLOW) puts(1,"Hello world\n") ? screen(1,1,CHARACTER) ? screen(1,1,ATTRIBUTE) --- code end ------------- Jacques Deschenes Baie-Comeau, Quebec Canada desja at globetrotter.qc.ca