Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.pascal.borland    |    Borland Pascal was actually pretty neat    |    2,978 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 1,693 of 2,978    |
|    John Smith to All    |
|    Re: Tic-Tac-Toe    |
|    01 Jun 05 11:52:22    |
   
   From: assemblywizard@gmail.com   
      
   science guy:   
      
   Don't even bother keeping an array, just write and read characters from   
   the screen (long as your code is running in a dos box at a command line)   
   the following code reads a char from x,y on the screen (it is taken from   
   the pascal faq)... simply write your 'x's and 'o's and write the logic   
   to determine when a win is had (also keeping track of what "squares"   
   have already been written to... hope this is of a bit of help... code   
   follows to read a screen x,y mapped char:   
   program x;   
   uses crt, dos;   
   function screenchar (column, row : byte) : char;   
    var regs : registers;   
    videocolumns : byte;   
    videobase : word;   
    offset : word;   
    begin   
    { Get the video base address }   
    FillChar (regs, SizeOf(regs), 0);   
    regs.ah := $0F;   
    Intr ($10, regs);   
    if regs.al = 7 then   
    videobase := $B000   
    else   
    videobase := $B800;   
    { Get the screen width }   
    FillChar(regs, SizeOf(regs), 0);   
    regs.ah := $0F;   
    Intr ($10, regs);   
    videocolumns := regs.ah;   
    { Get the character }   
    offset := (((row-1)*videocolumns)+(column-1))*2;   
    screenchar := chr(mem[videobase:offset]);   
    end;   
      
    begin   
    writeln ('Character at 5, 2 is ascii ', Ord(screenchar(5,2)));   
    end.   
      
   Warmest regards,   
   John   
      
   "science guy"
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca