Skip to content

title: "DrawTextBox" description: TRSE built-in method (from IDE help)


DrawTextBox

Systems: C64, MEGA65, PLUS4, C128, NES, VIC20, PET
Parameters: a,a,b,b,b,b


DrawTextBox( [addresstable], [chararray], [column], [row], [width], [height] );

  • [addresstable] - Address table for your screen size
  • [chararray] - Screen character value array in order of TL,T,TR,R,BR,B,BL,L (8 bytes)
  • [column] - Left column, starting from 0
  • [row] - Top row, starting from 0
  • [width] - Box width
  • [height] - Box height

Description

Draws a box to screen memory, utilizing AddressTable to accomodate different screen sizes.

An array is used to define characters to draw the box (screen values), in order: top left, top, top right, right, bottom right, bottom, bottom left, left.

As the method uses AddressTable, it can also be used to write to color memory, in that case the [chararray] should contain color values. There is also DrawColorTextBox() -method available if one wants to draw single color text boxes to screen.

AddressTable can be created easily with CreateAddressTable().

Example for C64

program TextBoxExample; var // Defines for screen addresses and size @define screen_mem $0400 @define color_mem $D800 @define screen_width 40 @define screen_height 25 s_addr: array[@screen_height] of integer; // Array to hold address table to screen memory c_addr: array[@screen_height] of integer; // Array to hold address table to color memory petsciibox: array[8] of byte = ($55, $43, $49, $5d, $4b, $43, $4a, $5d); boxcolors: array[8] of byte = (1, 2, 3, 4, 5, 6, 7, 8); begin // Change screen color to black SCREEN_BG_COL := BLACK; SCREEN_FG_COL := BLACK; // Fill screen memory with space clearscreen($20, ^@screen_mem); // Fill color RAM with black clearscreen(BLACK, ^@color_mem); // Create address tables to screen memory and color RAM createaddresstable(s_addr, @screen_mem, @screen_width, @screen_height); createaddresstable(c_addr, @color_mem, @screen_width, @screen_height); // Draw text box drawtextbox(s_addr, petsciibox, 10, 5, 20, 15); // Draw box colors to color RAM drawtextbox(c_addr, boxcolors, 10, 5, 20, 15); // Loop Forever loop(); end.

Example screenshot

Remarks

It is your responsibility to make sure box is not drawn outside screen memory. Minimum width and height is 3. Smaller values will explode galaxies and burn forests :(