We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Dynamic Z

From SnesLab
Jump to: navigation, search

Dynamic Z is a patch for Super Mario World that allows performing a variety of actions during V-Blank. It was made by anonimzwx. Dynamic Z is meant to be a replacement for DSX as both allow coding dynamic sprites.

Dynamic Z does not require a buffer for coding dynamic sprites, which significantly reduces the slowdown caused by these type of sprites. Additionally, it can create sprites with a 30FPS animation synchronized with each other; this allows having twice as many dynamic sprites on-screen compared to DSX.

Features

  • Graphic changes
  • Color palette changes
  • Color palette and graphic changes on the player
  • Tile changes
  • Support for Dynamic, Semi-Dynamic and Giga-Dynamic sprites
  • A special DMA mode, which grants 50% more transfer capacity by removing the game's original DMA code
  • Player DMA optimizations that gives more time during NMI and slightly curbs slowdown
  • Compatibility with DSX sprites


How it works?

Dynamic Sprite Support

Dynamic Z have tables to define transfers to VRAM between #7400 and #7FFF (In the case of Overworld Sprites #6800 and #6FFF) . Every Table have 1 slot for each space of 16x8:

  • DMA Resource: This Table is used to know in what RAM Address starts the source that will be transfer to the VRAM.
  • DMA BNK: This Table is used to know in what Bank starts dma must find the DMA Resource.
  • DMA Length: This Table is used to know how much data must send to VRAM.

Each slot of the tables is mapped to a value on the VRAM, the first slot start at #7400 and the last starts at #7FE0, Between 2 consecutive slots, there are 20 address of diference on the VRAM (40 bytes of difference).

To know what slots read of the tables, Dynamic Z use a table called DMA Next, each slot on this table indicates a link between a slot and another slot, for example, if slot #$00 have the value #$20, then after load slot #$00 on the VRAM, the patch will loads slot #$20, if a Slot have the value #$FF, if the patch read that slot, will finish the transfer to VRAM.

To know what is the first slot, there is a RAM Address called First Slot, if this address is #$FF, then Dynamic Z won't load anything on the VRAM.

With the table DMA Next, Dynamic Z create a data structure called Linked List. To add DMA Transfers at the end of the list, there is a RAM Address called Last Slot that have the last slot that will be loaded on the VRAM.

To connect this system with sprites there are some tables that can be used:

  • Slots Used By Sprite: Dynamic Z Consideres each slot as a square of 16x16, each dynamic sprite use a number of slots, for example a dynamic sprite of 16x16 uses 1 slot, here a table with the number of slots of each sprite:
Size Slots
16x16 1
32x16 2
32x32 4
48x48 8
64x64 16
80x80 24
96x96 All
112x112 All

In the case of 96x96 and 112x112 Dynamic Sprites, they uses their own system and they reserve all slots. You can't use a 96x96 or 112x112 Dynamic Sprite with others Dynamic Sprites.

  • FPS: This table is used to know the frecuency of a sprite to change it's graphics on the VRAM. Dynamic Z allows 2 frecuencies, 30 FPS (can change their graphics every 2 snes frames) and 60 FPS (can change their graphics each frame). On practice use 30 FPS allows to use the double of Dynamic Sprites, because you can sincronice their Dynamic Routines and have 16 slots (24 with 50% more mode) for sprites that loads their graphics on even frames and 16 (or 24) for sprites that loads their graphics on odd frames. Almost all sprites can be made with 30FPS, try to avoid 60FPS dynamic sprites.
  • Sprite Type: It is used to know the type of the dynamic sprite, #$00 = Free Slot, #$01 = Normal, #$02 = Extended, #$03 = Cluster and #$04 = Overworld Sprite.
  • Sprite ID: It is used to know what is the Index of the sprite on its sprite table.
  • Sprite Number: It is used to know what is the Number of the sprite.
  • Transfer Frame: It is one table for each kind of sprite. It is used for 30FPS to know if it uses slots of even frames or odd frames. if bit 7 is 0 = Even Frames, if bit 7 is 1 = Odd Frames. Also is used to know if the sprite must reserve a slot starting from the bottom of the Dynamic Space (for example on the second half of SP4) or from the top of the Dynamic Space (second half of SP3), if Bit 6 is 0 = Bottom, if bit 6 is 1 = Top.
  • VRAM Disp: It is one table for each kind of sprite. It is used to know what is the slot assigned to the sprite.
  • Signals: They represent if a space on the VRAM is used by a sprite, each Signal represents 4 slots, each group of 2 slots on each signal is a counter that decrease in 1 each frame, if the value is #$00 then the slot is free to use.
  • Max Slots: Is the max number of slots that can be used in each frame. By default is #$10 (16 slots), if you use 50% more mode it can be #$18 (24 slots). This value can be modified by the user if he wants to use less space on SP4 or SP3, for example if the user use Max Slot = #$08, then only will use a space of 128x32 on the VRAM.

RAM Addresses

Name Address SA-1 Address Define Length Description
Dynamic Timer 7F0B44 418000 !DynamicTimer 1 byte A timer that decrease in 1, every frame when Dynamic Z is working, it is used for 30FPS Dynamic sprites to know if the frame is even or odd.
Signal for the Bottom Left Quarter of Second Half of SP4 7F0B45 418001 !SignalSP4SecondHalfBottomLeftQuarter 1 byte Signal used to know if slots that are allocated on the Bottom Left quarter of the second half of SP 4 are used free or not.
Signal for the Bottom Right Quarter of Second Half of SP4 7F0B46 418002 !SignalSP4SecondHalfBottomRightQuarter 1 byte Signal used to know if slots that are allocated on the Bottom Right quarter of the second half of SP 4 are used free or not.
Signal for the Top Left Quarter of Second Half of SP4 7F0B47 418003 !SignalSP4SecondHalfTopLeftQuarter 1 byte Signal used to know if slots that are allocated on the Top Left quarter of the second half of SP 4 are used free or not.
Signal for the Top Right Quarter of Second Half of SP4 7F0B48 418004 !SignalSP4SecondHalfTopRightQuarter 1 byte Signal used to know if slots that are allocated on the Top Right quarter of the second half of SP 4 are used free or not.
Signal for the Bottom Left Quarter of First Half of SP4 7F0B49 418005 !SignalSP4FirstHalfBottomLeftQuarter 1 byte Signal used to know if slots that are allocated on the Bottom Left quarter of the second half of SP 4 are used free or not.
Signal for the Bottom Right Quarter of First Half of SP4 7F0B4A 418006 !SignalSP4FirstHalfBottomRightQuarter 1 byte Signal used to know if slots that are allocated on the Bottom Right quarter of the second half of SP 4 are used free or not.
Signal for the Top Left Quarter of First Half of SP4 7F0B4B 418007 !SignalSP4FirstHalfTopLeftQuarter 1 byte Signal used to know if slots that are allocated on the Top Left quarter of the first half of SP 4 are used free or not.
Signal for the Top Right Quarter of First Half of SP4 7F0B4C 418008 !SignalSP4FirstHalfTopRightQuarter 1 byte Signal used to know if slots that are allocated on the Top Right quarter of the first half of SP 4 are used free or not.
Signal for the Bottom Left Quarter of Second Half of SP3 7F0B4D 418009 !SignalSP3SecondHalfBottomLeftQuarter 1 byte Signal used to know if slots that are allocated on the Bottom Left quarter of the second half of SP 3 are used free or not.
Signal for the Bottom Right Quarter of Second Half of SP3 7F0B4E 41800A !SignalSP3SecondHalfBottomRightQuarter 1 byte Signal used to know if slots that are allocated on the Bottom Right quarter of the second half of SP 3 are used free or not.
Signal for the Top Left Quarter of Second Half of SP3 7F0B4F 41800B !SignalSP3SecondHalfTopLeftQuarter 1 byte Signal used to know if slots that are allocated on the Top Left quarter of the second half of SP 3 are used free or not.
Signal for the Top Right Quarter of Second Half of SP3 7F0B50 41800C !SignalSP3SecondHalfTopRightQuarter 1 byte Signal used to know if slots that are allocated on the Top Right quarter of the second half of SP 3 are used free or not.
Slots Used in Even Frames 7F0B51 41800D !SlotsUsedEven 1 byte Number of slots used on even frames.
Slots Used in Odd Frames 7F0B52 41800E !SlotsUsedOdd 1 byte Number of slots used on odd frames.
Max Slots 7F0B53 41800F !MaxSlots 1 byte Maximum number of slots that can be used per frame.
Number of Blocks 7F0B54 418010 !NumberOfBlocks 1 byte Number of blocks that can be used for Dynamic Routines, each block represent a space in VRAM of 128x32, by default is 2 (equivalent to have a complete SP for dynamic sprites).
VRAM Displacement Normal Sprites 7F0B55 418011 !VRAMDispNormalSprite 12 bytes (22 bytes on SA1 roms) A number used to know what is the slot assigned to a Normal Dynamic Sprite.
VRAM Displacement Extended Sprites 7F0B61 418027 !VRAMDispExtendedSprite 10 bytes A number used to know what is the slot assigned to a Extended Dynamic Sprite.
VRAM Displacement Cluster Sprites 7F0B6B 418031 !VRAMDispClusterSprite 20 bytes A number used to know what is the slot assigned to a Cluster Dynamic Sprite.
VRAM Displacement Overworld Sprites 7F0B7F 418045 !VRAMDispOWSprite 16 bytes A number used to know what is the slot assigned to a OVerworld Dynamic Sprite.
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example
Example Example Example Example Example Example