-
Notifications
You must be signed in to change notification settings - Fork 10
AddSource Flag
Note: most likely this technique is not needed for simple games. So, it's not mandatory for jr-devs.
The AddSource
can be chosen in the Flag column of the Achievement Editor
When a condition has the Add Source
flag, the value on that memory address is added to the accumulator. When a condition is reached that does not modify the accumulator, the accumulator is added to value of the address on that condition before the comparison is made, and the accumulator will be reset to 0. It may sound a bit confusing, but the example below will clarify how this works:
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | AddSource | Mem | 8-bit | 0x8010 | |||||
2 | Mem | 8-bit | 0x8020 | > | Value | 0x04 | 0 (0) |
In this example the value in 0x8010
will be added to the value in 0x8020
and the comparison will check is if this sum is greater than four.
If the value in 0x8010
is 1
and the value in 0x8020
is 2
, the comparison will be 1 + 2 > 4
, or 3 > 4
.
Trying to summarize the explanation in an image:
You can use the Add Source
flag to sum more addresses, like in the example below:
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | AddSource | Mem | 8-bit | 0x8010 | |||||
2 | AddSource | Mem | 8-bit | 0x8011 | |||||
3 | Mem | 8-bit | 0x8020 | > | Value | 0x04 | 0 (0) |
This represents value(0x8010) + value(0x8011) + value(0x8020) > 4
.
The accumulator is reset after its used, so you can have multiple AddSource
chains in one trigger without having to worry about them interfering with each other.
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | AddSource | Mem | 8-bit | 0x8010 | |||||
2 | Mem | 8-bit | 0x8020 | > | Value | 0x04 | 0 (0) | ||
3 | AddSource | Mem | 8-bit | 0x8030 | |||||
4 | Mem | 8-bit | 0x8040 | < | Value | 0x80 | 0 (0) |
This represents value(0x8010) + value(0x8020) > 4 AND value(0x8030) + value(0x8040) < 0x80
.
The accumulator and all logic being performed is limited to 32-bits. If the total value exceeds 0xFFFFFFFF, there will be an overflow and only the 32 least significant bits will be used in the comparison.
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | AddSource | Mem | 32-bit | 0x8010 | |||||
2 | Mem | 32-bit | 0x8020 | > | Value | 0x30000000 | 0 (0) |
If 0x8010 is 0xC0000000 and 0x8020 is 0x54321ABC, then the total will be 0x114321ABC, which is more than 32-bits and will be truncated to 0x14321ABC, which is not more then 0x30000000, so the logic will evaluate false.
Additionally, you can use AddSource to modify a value. By clicking on the "Cmp" column, a dropdown will open with three operators: *
, /
, and &
. This allows you to modify the value before adding it to the accumulator.
*
: Multiply the left side by the right side.
-
AddSource 8-bit Mem 0x8010 * Value 0x14
would read the 8-bit value from $8010, multiply it by 20 (0x14 hex) and then add that to the accumulator.
/
: Divide the left side by the right side.
-
AddSource 8-bit Mem 0x8010 / Value 0x14
would read the 8-bit value from $8010, divide by 20 (rounding down) and then add that to the accumulator.
&
: Bitwise-mask the left side with the right side.
-
AddSource 8-bit Mem 0x8010 & Value 0x3f
would read the 8-bit value from $8010, discard bits 6 and 7 (0x3f is 00111111 in binary) and then add that to the accumulator.
You can use memory references on the right side as well. AddSource 8-bit Mem 0x8010 * 8-bit Mem 0x8011
would read the two 8-bit values, multiply them together, and add that to the accumulator.
The accumulator is typed based on the first thing added to it. If the first AddSource
/SubSource
of a chain is an integer, the accumulator will be an integer and any floats added to the accumulator will be floored before they're added to the accumulator. If the first AddSource
/SubSource
of a chain is a float, the accumulator will be a float and any integers added to the accumulator will be converted to floats before they're added to the accumulator.
Note that when the accumulator is added to the final condition, the type of the final condition is used. So if the final condition is float and the accumulator is an integer, the accumulator will be converted to a float before it's added to the final condition.
To force all floats in an AddSource
chain to be floored, you need an extra first and last condition:
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | AddSource | Value | 0 | ||||||
2 | AddSource | Mem | Float | 0x1000 | |||||
3 | AddSource | Mem | Float | 0x1004 | |||||
4 | AddSource | Mem | Float | 0x1008 | |||||
5 | Value | 0 | > | Value | 12 | 0 (0) |
Line 1 primes the accumulator as an integer, so lines 2-4 will be floored before they're added to the accumulator. Line 5 ensures the final value is an integer before doing the comparison. Without line 1, lines 2-4 would be accumulated as floats. Without line 5, the accumulator would be added to the last float without it being floored.
- User Guidelines
- Developer Guidelines
- Content Guidelines
- FAQ
- Setup Guide
- Emulator Support and Issues
- Ways to Contribute
- RABot, the RA Discord Robot
- Events
- Overlay Themes
- Useful Links
- Contributing with the docs
- About Us
- Tutorials
- Developer Docs
- How to Become an Achievement Developer
- Getting Started as an Achievement Developer
- Game Identification
- Achievement Design
- Achievement Scoring
- Difficulty Scale and Balance
- Progression and Win Condition Typing
- Badge and Icon Creation
- Achievement Development Overview
- Flags
- BitCount Size
- Alt Groups
- Hit Counts
- Delta Values
- Prior Values
- Value Definition
- Condition Syntax
- Minimum Required Versions for Logic Features
- Memory Inspector
- Real Examples
- Set Development Roadmap
- Achievement Templates
- Tips and Tricks
- Leaderboards
- Rich Presence
- RATools
- Console Specific Tips
- Emulator Hotkeys for Developers
- libretro core support
- Docs To Do List
- WIP User Code of Conduct
- WIP CoC FAQ
- WIP Content Guidelines
- WIP-Jr
- WIP---Dev-Tips---Code-Notes-En-Masse
- WIP-‐-Reauthorship-Policy
- Manifesto RetroAchievements
- Código de Conduta do Usuário
- FAQ - Perguntas Frequentes
- Como contribuir se você não é um desenvolvedor
- Tutorial para Jogos Multi-Discos
- Introdução
- Primeiros Passos como um Desenvolvedor de Conquistas
- Recursos de Lógica para Achievements
- Exemplos Reais
- Dicas e Truques
- Dicas Específicas de Console
- Modelos de Achievement
- Escala de Dificuldade e Equilíbrio
- Roteiro de Desenvolvimento de um Set de Conquistas
- Criação de Ícones e Emblemas
- Leaderboards
- Rich Presence
- Design de Conquistas
- Manifesto RetroAchievements
- Código de Conducta del Usuario
- FAQ - Preguntas Frecuentes
- Tablas Globales y Reglas para la Casería de Logros
- Mi juego no esta cargando los logros
- Como contribuir si no eres un desarrollador
- Por que no deberías utilizar la función de cargar estado
- Contribuyendo con los documentos
- Como funciona la Documentación de RA
- Descargas
- Intro
- Código de Conducta del Desarrollador
- Como convertirme en un Desarrollador de Logros
- Primeros pasos como un Desarrollador de Logros
- Un vistazo al Inspector de Memoria
- Características en la Logica de un Logro
- Ejemplos Reales
- Intro
- Utilizando Hit Counts como un Temporizador
- Utilizando Valores Delta y Hit Counts para Detectar un Incremento
- Un Ejemplo Simple en como evitar el Abuso de Estados de Guardado
- Evitar el Problema de que un Contador se Incremente Dos Veces en el Mismo Frame
- Creando un Temporizador con un ResetIf Hits basándote en la Velocidad de un Juego
- Plantillas para Logros
- Tips y Trucos
- Escala de Dificultad y Balance
- Diseño de Logros
- Mapa de Desarrollo de Set
- Revisiones en Set de Logros
- Creación de Iconos y Badges
- Tablas de Clasificación
- Rich Presence
- Trabajando con el ROM apropiado
- Identificación del Juego
- Guía para Sets Bonus
- Logros para ROM hacks
- Tips Específicos por Consola