Jump to content
Sign in to follow this  
  • entries
    7
  • comment
    1
  • views
    4,532

Data Structures

walker7

424 views

Creating data structures is an important part of programming. By pressing a certain key combo (such as CTRL+D), you could enter a screen that will let you make data structures for your program. Take a look at this screen.
gallery_42566_2054_4.png
This is where you enter data structures.

 

The cursor starts in the prefix field. You might want to type a prefix for all the elements in the structure. Whenever you enter a new element of the structure, the name field will start with this prefix already in it. If you don't want to enter a prefix, just press Enter to go straight to the data fields.

  • For each element, type its name in the black box, the size in the red box, and the quantity in the blue box.
  • For the size, you can type "B," "W," or "L." You can also use "1," "2," or "4." These correspond to 1-byte, 2-byte, or 4-byte elements, respectively.
  • The structure is a 3-character field. If you want only one of this data field, type "1." If you want more, just type however many you want.
  • If you type a quantity greater than 999, it will show an ASCII character in the hundreds digit. For example, entering 1024 will make it show ":24", but it still represents an array of 1,024 elements. As you input bigger numbers, the hundreds digit cycles through all the ASCII characters, then repeating with different colors.


Here's an example. Say you want to make a structure for a music header. Assuming you're programming for the Sega Genesis, you know that there are 6 FM channels and 4 PSG channels.

 

First, you might want to put the song's tempo. It is a 2-byte value. With the "mus_" already in the prefix box, you just need to type "Tempo" in the black box to complete the element name.
gallery_42566_2054_348.png

Press Enter, and the cursor moves to the red box on the same line.
gallery_42566_2054_27.png

Now, type "W" or "2" in the red box so the data field will be 2 bytes. A "2" will appear in the box, and the cursor moves to the blue box.
gallery_42566_2054_81.png

Finally, type "1" in the blue box to indicate you only want one field for tempo.
gallery_42566_2054_73.png

The entire line looks like this:
gallery_42566_2054_67.png

After that, press Enter to add a second line. Repeat this procedure for as many fields as you need in your data structure.

The remaining fields for the music header are:

  • After tempo is a pointer to each FM channel's data. There should be 6 of these, one for each FM channel. Each is two bytes.
  • A pointer for each PSG channel's data. There are 4 of them, each are two bytes.
  • Volumes for each FM channel. Since the YM2612 has 7-bit volume levels, these could be represented in one byte.
  • A packed 16-bit field for the PSG volumes. This could be thought of as four 4-bit fields packed into a single value.
  • Indices for each FM channel's instrument. These could be one byte each.



After entering all those data fields, the screen would look like this:
gallery_42566_2054_1079.png

  • After the data structure is entered, just press CTRL+Enter to exit the screen. The data structure appears at the point where your cursor was when you entered this screen.
  • If you entered this screen by mistake, you could press ESC and go back to programming. Any data entered here will then be discarded.




This post just mentions how you would declare data structures for a program. In a later post, I will mention how to actually enter the data.



0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...