GTE (tile engine)

GTE (Generic Tile Engine) is a 2D tile engine developed for the Apple personal computer and written in 65816 assembly language.

History

The underlying technology was developed for a recreational port of SUPER Mario Bros for the Apple platform. At this point the engine only supported single-layer backgrounds, a single non-standard tile size and limited sprite support. After The Release of the unfinished SMB GS, the core graphics engine was modularized and released as a GS/OS Tool Set.

Features

GTE provides graphical capabilities that lie roughly between the third and fourth generation of video game consoles. The technical capabilities of the engine are contrasted with the NES and SNES consoles, which share the same CPU family as the Apple

Name

GTE

Nintendo Entertainment System/Famicom

Super Nintendo Entertainment System/Super Famicom

CPU

2.8MHz 65c816

1.79MHz 6502

3.58MHz 65c816

Screen Resolution

320x200

256x240

256x224, 512x224, 256x239, 512x239; Interlaced: 512x448, 512x478

Simultaneous Colors

256 out of 4096 (16 per line)

25 out of 53

256 out of 32768 indexed, 11 bpp direct

Sprites

32, 32 max per line, any size up to 64 KiB per sprite

64, 8 max per line, 8x8 or 16x8 pixels

128, 32 max per line; up to 64x64 pixels

Tile Sizes

4x4, 8x8, 16x16

8x8

8x8, 8x16, 16x8, 16x16

Background Layers

2 planes plus 1 static background

1 plane

4 planes; each up to 1024 x 1024

Memory

8 MiB main RAM
32 KiB video RAM

48 KiB main RAM (+ bank switching)
2 KiB video RAM

128 KiB main RAM
64 KiB video RAM
64 KiB audio RAM

Effects

  • Per-pixel clipping masks for each plane
  • Overlay
  • Per-scanline offsets
  • Per-scanline palette binding
  • Per-scanline sprite enable/disable
  • Color emphasis
  • Pixelization (mosaic) per background
  • Color addition and subtraction
  • Clipping windows (per background, affecting color, math, or both)
  • Scrolling per 8x8 tile
  • Mode 7 matrix operations

Framerate (min/avg/max)

10/15/18
*Based on a full-screen 320x200 plane

  • Smaller planes are faster
  • May be boosted by 3rd-party accelerators

30/60/60

30/60/60

Implementation

The memory bandwidth of the Apple is 1 MiB/s, which is too slow to update the 32 KiB graphics memory at a full 60 frames per second. In fact, the theoretical maximum frame rate for full-screen animation is 31.25 frames per second. Thus, GTE focuses on achieving a reasonable frame rate given the limitations of the hardware.

The tile engine achieves its speed by leveraging hardware-specific feature of the Apple platform as described in IIgs TN #70: Fast Graphics Hints to map the CPU stack to the RAM address of the graphics buffer and using specialized stack instructions to quickly copy graphics data to the screen. This technique is faster than a RAM-to-RAM copy because the hardware stack is automatically decremented after the data is pushed to memory.

Plane Buffers

Since the Apple does not support multiple graphics planes in hardware, this feature must be implemented in software.

Tiles

Tiles are stored internally as aligned bitmap images. A total of 64 KiB are available for tile storage and the total number of tiles are fixed at 256 regardless of the tile size (4x4, 8x8 or 16x16). Each tile consumes 256 bytes of RAM. 64 bytes area llocated for the tile data, a horizontally mirrored version of the tile and the corresponding masks. the image data are stored in sequential 16 KiB chunks of memory as given i the following memory map:

  • $0X00: Tile Data
  • $4X00: Horizontally Flipped Tile Data
  • $8X00: Tile Data Mask
  • $CX00: Horizontally Flipped Tile Data Mask

Sprites