News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Can anyone?

Started by ChildoftheHorn, December 09, 2006, 05:58:02 AM

Previous topic - Next topic

ChildoftheHorn

Hey, This is my code. I want to create a box instead of drawing those edges, rather the outer edge. How would I be able to draw the table I have below without having any spaces in the lines?
Then, I would like to have it only display the blue in the background of the table instead of the entire window. How would I be able to do that? I already turned this in, but I would like it to be cleaner -- for my sake...
Basically I want to change the whole Clear_scr and Disp_table PROC s.

Thank You for suggestions!




Title ASCII_TABLER            (ascii_tabler.asm)

;Description: This program generates a simple ASCII code table up to the value FFh. The table displayed has the background of blue and a white text.

;Due Date: 12/1/06 at 2PM CST ¦

INCLUDE Irvine16.inc

.data

Tab  db ?                              ;draws the table, like the example picture
   db " _______________________________________ "
   db "|                                                                    |"
   db "|              ASCII Table                                      |"
   db "|_______________________________________|"
   db "|                                                                    |"
   db "| HEX   0 1 2 3 4 5 6 7 8 9 A B C D E F               |"
   db "|_______________________________________|"
   db "|      |                                                             |"
   db "|  0  |                                                             |"
   db "|  1  |                                                             |"
   db "|  2  |                                                             |"
   db "|  3  |                                                             |"
   db "|  4  |                                                             |"
   db "|  5  |                                                             |"
   db "|  6  |                                                             |"
   db "|  7  |                                                             |"
   db "|  8  |                                                             |"
   db "|  9  |                                                             |"
   db "|  A  |                                                             |"
   db "|  B  |                                                             |"
   db "|  C  |                                                             |"
   db "|  D  |                                                             |"
   db "|  E  |                                                             |"
   db "|  F  |                                                             |"
   db "|___|___________________________________|"
aBGROUND DWORD 2000 DUP(20h)               
ASCII_B BYTE ?
ASCII WORD 00

.code
main PROC
   mov esi, OFFSET aBGROUND            ;starts the display
   mov ax, @data      ;DGROUP - the starting entered data
   mov ds, ax
   mov ax, 0B800h      ;32kb of video memory, draw till 0B8ff-end of structure
   mov es, ax      ;Video Memory Buffer
     mov ah, 0
     mov al, 3
     
     int 10h         ;interupts the Video BIOS - *note not 16h or 21h*
     mov eax, 10000
     
     call CLEAR_SCR      
     call DISP_TABLE
     call DISP_ASCII
     call Delay      ;allows the program to show up as one entity instead of progressively generated (cleaner)
     
     mov ah, 10h      ;waits for input
     int 16h         ;note that int 16 is used to finish the program, not to store the video
exit
main ENDP
;______________________________________________________________________________________________
CLEAR_SCR PROC   USES ax cx di                                 
;                                                         
;Fills the screen with spaces                                                                    
;______________________________________________________________________________________________
   cld               
   mov ax, 1020h         
   mov cx, (2000)            ;displays whole matrix
   mov di, 0               ;resets di   
   
   Push_AX:
      stosw            ;puts ax to [di] - video
   loop Push_AX
   
   mov ecx, 19
   ret                  ;Return from proceedure
CLEAR_SCR ENDP
;_____________________________________________________________________________________________
DISP_TABLE PROC USES bx cx dx ax                                 
;                                                         
;Displays the table by placing it in the Video Memory   Buffer                                                        
;_____________________________________________________________________________________________
   mov di, ((0*80) + 18)*2            ;begin near the center [video]
   mov ASCII, 1               
   mov cx, 25                  ;starting space (middle row)
   Rows:
      push cx
      mov cx, 41                  
      Columns:
         mov bx, OFFSET Tab
         add bx, ASCII         ;adds 1h to the new symbol
         mov al, [bx]
         mov ah, 23               ;displays symbol
         stosw                  ;moves ax to [di]
         inc ASCII
      loop Columns
      add di, 78               
      pop cx
   loop Rows
   ret                     ;Returns
DISP_TABLE ENDP
;____________________________________________________________________________________________
DISP_ASCII PROC USES cx                                             
;                                                         
;Displays the contents by dumping into the Video Memory Buffer                                                                      
;____________________________________________________________________________________________
   mov cx, 16   
   mov ASCII_B, 0
   mov di, 1332            
   Row:                  ;Two loops start at row and move to the right (through the columns), like reading a book.
      push cx            
      mov cx, 16
      Column:            
         mov al, ASCII_B
         mov ah, 31         ;sets background and foreground
         stosw            
         mov al, 20h         ;between the different entries fills with 20h, a space
         inc ASCII_B         ;updates to the new value
         stosw
      loop Column
      add di, 96            
      pop cx
   loop Row               
   ret                     ;Returns
DISP_ASCII ENDP

END main

ToutEnMasm


A protected forum where programmers learning assembler can ask questions in a sensible and safe atmosphere without being harassed or insulted. This is also targetted at experienced programmers from other languages learning assembler that don't want to be treated like kids. Note that 16 bit code or questions will be moved to the 16 bit forum.

PBrennick

ChildoftheHorn,

Try the attached table. It looks nice but there are no guarantees. For example, it would not display here as it is using codes that are not supported everywhere anymore. All I can say it to try it.

Paul




[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

ChildoftheHorn,

If by "spaces in the lines" you mean that the vertical lines are discontinuous, you can produce continuous vertical lines by replacing ASCII character 124 with extended ASCII character 179.

In DISP_TABLE you are displaying 41 columns, but your table data is 69 characters wide.

Do you actually want the table data to start with an undefined byte?

In DISP_TABLE and DISP_ASCII, if you use hex for the attribute it will be easier to interpret. For example, it is difficult to recognize 23 as white on blue, but easy to recognize 17h as white on blue.

CLEAR_SCR is using the attribute 10h, black on blue. Generally, the purpose of setting the attribute when you clear the screen is so you can later display characters without having to specify the attribute. If you intend that only the table have a blue background, then you should set the appropriate attributes in DISP_TABLE and DISP_ASCII, and leave the attribute for the screen at its default white on black (07h).
eschew obfuscation

galoot

Try this simple test. Drop to a command prompt. Hold the ALT key down and type 178 on the number pad release the ALT key.
What happens?  It should place a shaded box on the screen. ALT + 179 makes the vertical line you desire. If you can print the
IBM graphics character to the screen then try the same test in you editor. Lots of editors will not allow this. For example look at
the instructions for this message editor ALT + s is submit, ALT + p is preview. Trying this in a windows program will produce windows
escape sequences, such as ALT + TAB calls a different window to the forground ALT + F4 will close a windows etc. If your editor
doesn't pass the test you might want to try the one I've attached.

[attachment deleted by admin]