home bbs files messages ]

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"  wrote in message   
   news:1115090299.066417.226430@g14g2000cwa.googlegroups.com...   
   > Hello people. I am doing a program that uses multi-dimensional arrays   
   > to creat a tic-tac-toe program.   
   >   
   > Can anyone help me get started? Oh and should I use procedures or   
   > functions?   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca