Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Resource fork
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Data types == The smallest elements making up a resource fork are called data types. There are several data types. After a resource fork is accessed, its contents can be found by reading it in as appropriate for the data types defined in advance. Placing definitions inside the program stating how data is to be treated makes it possible to store resources called TMPL resources as well. Using this method increases the visibility of the data when viewed with a program such as ResEdit, making later editing simpler. As the Macintosh platform originated with Motorola-based processors (68k and PPC), the data is serialized to disk in [[endianness|big-endian]] format. The following is a list of the major data types, in alphabetical order. {| class="wikitable" |- ! style="text-align:left" | Data type || actual name || style="text-align:left" |Description |- | BBIT || binary bit||Represents a single Boolean bit (true or false). Normally the number of BBITs must be a multiple of 8. |- | BOOL || Boolean||Represents a Boolean value. It consists of 2 bytes; 256 is true, and 0 is false. |- | CHAR || character||Represents a one-byte character. |- | CSTR || C string||Represents a string of the form used in the [[C (programming language)|C programming language]]: a [[null-terminated string]] of bytes. |- | DLNG || decimal long word integer||A decimal long word (4 byte integer). Represents values between approximately β 2.1 billion and 2.1 billion. |- | HEXD || hex dump||Indicates that the data from this position to the end is hexadecimal. This is used to represent code resources or compressed data. |- | HLNG || long word hexadecimal||This data is treated as a 4 byte hexadecimal value. It is used, among other things, to represent integers greater than 2.1 billion, such as unsigned long values in C. |- | PSTR || Pascal string||Represents a Pascal string, with the first byte giving the length of the string. |- | TNAM || type name||A string representing a value such as a [[creator code]], which is always 4 bytes long. |- | RECT || rectangle||Represents the coordinates of the corners of a rectangle (top, left, bottom, right). Always 8 bytes long. |} == Types ==import pygame import sys pygame.init() # Screen setup WIDTH, HEIGHT = 800, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Simple Shooter") # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) # Player setup player_pos = [WIDTH // 2, HEIGHT // 2] player_size = 50 player_speed = 5 # Bullet setup bullet_speed = 10 bullets = [] clock = pygame.time.Clock() while True: screen.fill(WHITE) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: # Shoot a bullet from player position bullet = pygame.Rect(player_pos[0] + player_size//2 - 5, player_pos[1], 10, 20) bullets.append(bullet) keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: player_pos[0] -= player_speed if keys[pygame.K_RIGHT]: player_pos[0] += player_speed if keys[pygame.K_UP]: player_pos[1] -= player_speed if keys[pygame.K_DOWN]: player_pos[1] += player_speed # Draw player player_rect = pygame.Rect(player_pos[0], player_pos[1], player_size, player_size) pygame.draw.rect(screen, BLACK, player_rect) # Update and draw bullets for bullet in bullets[:]: bullet.y -= bullet_speed if bullet.y < 0: bullets.remove(bullet) else: pygame.draw.rect(screen, RED, bullet) pygame.display.flip() clock.tick(60) The type codes below, like the above datatypes, are used as type identifiers for more than resource forks themselves: they are used to identify files themselves, to describe data in the clipboard, and much more. Types must be 4 bytes long, so types like snd and STR actually have a space (0x20) at the end. {| class="wikitable" |- ! style="text-align:left" | Name of resource type || actual name !! style="text-align:left" |Description |- | alis || alias||Stores an alias to another file, in a resource fork of a file whose "alias" attribute bit is set |- | ALRT || alert||Defines the shape of an application alert box |- | APPL || application||Stores application information |- | BNDL || bundle||Defines data such as a file type icon used in an application |- | cicn || color icon||Defines a color icon used in data |- | clut || color look-up table||Defines a color palette used in data |- | CNTL || control||Defines the details of a component positioned in a window |- | CODE || code resource||Stores the machine code for the program |- | CURS || cursor||Defines the shape of a monochrome cursor (8 Γ 8 bit square) |- | DITL || dialog item list||Defines a component of a window |- | DLOG || dialog||Defines the shape of a dialog box for an application |- | FREF || file reference||Defines a file type handled by an application |- | hfdr || icon balloon help||Defines the contents and shape of the balloon help displayed when the cursor hovers over the file in the Finder |- | icl8 || 8-bit icon list||Defines an icon displayed in the Finder |- | icns || 32-bit icon list||Defines an icon displayed in the Finder |- | ICON || icon||Defines a monochrome item used in data |- | kind || file description||Defines a description of a file type |- | MBAR || menu bar||Defines a menu and menu bar for an application |- | MDEF || menu definition||Defines a menu for an application. Can also be used to define menus with complex shapes such as color palettes. |- | MENU || menu||Defines the menu items in an application |- | MooV || movie||Stores a QuickTime movie |- | open || open||Defines a file type which the application can open |- | PICT || picture||Stores a PICT image contained in the file |- | PREF || preference||Stores the environment settings for an application |- | snd || sound||Stores a sound used in the file |- | STR || string||Stores a string or hexadecimal data used in the file |- | STR# || string list||Stores multiple strings used in the file |- | styl || style||Defines style information, such as the font, color and size of text |- | TEXT || text||Stores text |- | TMPL || template||Defines the format for the resource data |- | vers || version||Defines the [[Software versioning|version]] or region of use of the file |- | WDEF || window definition||Defines a window for the application. Windows of an unspecified shape can also be defined. |- | WIND || window||Defines the shape of an application window |}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Resource fork
(section)
Add topic