home *** CD-ROM | disk | FTP | other *** search
- /*=======================================================*/
- /* TVFBUILD.C */
- /* */
- /* (c) Copyright 1988 Ralf Brown All Rights Reserved */
- /* May be freely copied for noncommercial use, so long */
- /* as this copyright notice remains intact, and any */
- /* changes are marked in the comment blocks preceding */
- /* functions. */
- /*=======================================================*/
-
- #include "tvapi.h"
- #include "tvstream.h"
-
- /*=============================================*/
- /* TVfld_build_header start creation of a */
- /* field table definition */
- /* Ralf Brown 7/5/88 */
- /*=============================================*/
-
- BYTE * pascal TVfld_build_header(int num_fields,int screen_type,int curr_attr,int selected_attr)
- {
- BYTE *stream ;
- int stream_len = sizeof(FT_HEADER) + 6 + num_fields*(sizeof(FT_ENTRY) + 5) ;
- int i, count ;
-
- if ((stream = (BYTE *)malloc( stream_len + 4)) == NULL)
- return NULL ;
- stream[0] = 0x1B ;
- stream[1] = 0 ;
- *(int *)(stream+2) = stream_len ;
- stream[4] = 0xE5 ; /* \ force field table entries to be 8 bytes */
- stream[5] = 0x10 ; /* / */
- stream[6] = 0xFF ;
- stream[7] = num_fields ;
- stream[8] = screen_type ;
- stream[9] = 0 ;
- stream[10] = 0 ;
- stream[11] = curr_attr ;
- stream[12] = selected_attr ;
- count = 1 ;
- for (i = sizeof(FT_HEADER) + num_fields*sizeof(FT_ENTRY) + 7 ; i < stream_len + 4 ; i += 5)
- {
- stream[i] = 0xF0 ;
- stream[i+1] = count ;
- stream[i+2] = 0xF2 ;
- stream[i+3] = count++ ;
- stream[i+4] = curr_attr ;
- }
- stream[stream_len+1] = 0xF4 ; /* move cursor to first field */
- stream[stream_len+2] = 1 ;
- stream[stream_len+3] = WS_FLDRESET ;
- return stream ;
- }
-
- /*=============================================*/
- /* TVfld_build_entry fill in an entry in a */
- /* previously started */
- /* field table definition */
- /* Ralf Brown 7/5/88 */
- /*=============================================*/
-
- void pascal TVfld_build_entry(BYTE *stream,int field,int upleftrow,int upleftcol,
- int lowrightrow,int lowrightcol,int type,int modifier,
- int color,int key2)
- {
- stream += 7 ; /* skip stream header and opcode */
- if (field >= 1 && field <= stream[1])
- {
- stream += sizeof(FT_HEADER) ; /* skip field table header */
- stream += (sizeof(FT_ENTRY) * (field-1)) ;
- stream[0] = upleftrow ;
- stream[1] = upleftcol ;
- stream[2] = lowrightrow ;
- stream[3] = lowrightcol ;
- stream[4] = type ;
- stream[5] = modifier ;
- stream[6] = color ;
- stream[7] = key2 ;
- }
- }
-
- /*=============================================*/
- /* TVfld_build_color set the field's attribute*/
- /* Ralf Brown 7/5/88 */
- /*=============================================*/
-
- void pascal TVfld_build_color(BYTE *stream,int field,int attr)
- {
- stream += 7 ; /* skip stream header and opcode */
- if (field >= 1 && field <= stream[1])
- {
- stream += stream[1] * sizeof(FT_ENTRY) + sizeof(FT_HEADER) ;
- stream[5*field-1] = attr ;
- }
- }
-
- /*=============================================*/
- /* TVfld_build_cursor set which field the */
- /* cursor will start in */
- /* Ralf Brown 7/10/88 */
- /*=============================================*/
-
- void pascal TVfld_build_cursor(BYTE *stream,int field)
- {
- if (field >= 1 && field <= stream[8])
- stream[(*(int *)(stream+2))+2] = field ;
- }
-
- /* End of TVFBUILD.C */
-