-
Notifications
You must be signed in to change notification settings - Fork 10
SubSource Flag
Note: most likely this technique is not needed for simple games. So, it's not mandatory for jr-devs.
The SubSource
can be chosen in the Flag column of the Achievement Editor
Works similarly to Add Source
, but the Sub Source
flag subtracts the calculated value from the accumulator.
Because it subtracts from the accumulator, SubSource A, B
is actually B - A
.
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | SubSource | Mem | 8-bit | 0x8010 | |||||
2 | Mem | 8-bit | 0x8020 | > | Value | 0x04 | 0 (0) |
In this example the value in 0x8010
will be subtracted from 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 1 > 4
.
SubSource
can also be used to track specific increases in addresses. The conditions below states that the current value in address 0x80dc
minus the value in the previous frame in the same address must be equal 2
. Effectively, this means that the condition is true whenever the value in address 0x80dc
increases by exactly two.
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | SubSource | Delta | 8-bit | 0x80dc | |||||
2 | Mem | 8-bit | 0x80dc | = | Value | 0x02 | 0 (0) |
The accumulator and all logic performed is limited to an unsigned 32-bit number. If the total drops below 0, it underflows, resulting in a very large positive number. Here's the representation for the first few negative numbers:
-
-1
is0xFFFFFFFF
-
-2
is0xFFFFFFFE
-
-3
is0xFFFFFFFD
-
-4
is0xFFFFFFFC
-
-5
is0xFFFFFFFB
-
-6
is0xFFFFFFFA
-
-7
is0xFFFFFFF9
- and so on...
So, if you wanted to see if a value was 1 less than another value, you could write:
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | SubSource | Mem | 8-bit | 0x8020 | |||||
2 | Mem | 8-bit | 0x8010 | = | Value | 0xffffffff | 0 (0) |
This would be true if the value at $8010 (1) was 1 less than the value at $8020 (2): 1 - 2
= -1
= 0xFFFFFFFF
.
However, you should swap the conditions to make it easier to read (B - A = -1
) is the same as (A - B = 1
):
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | SubSource | Mem | 8-bit | 0x8010 | |||||
2 | Mem | 8-bit | 0x8020 | = | Value | 1 | 0 (0) |
This evaluates -1 + 2 = 1
, which is true.
It is also possible to use straight negative numbers in the left section of your Sub/Add Source operations. To do so, remember to change the Type from Mem
to Value
, and use the values as explained above, such as 0xFFFFFFE5
for -27
, and 0xFFFFFFE3
for -29
, for example:
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | SubSource | Mem | 32-bit | 0x8020 | |||||
2 | Value | 0xffffffe5 | = | Value | 0xffffffe3 | 0 (0) |
If $8020 contains 2, this would be true. -2 + (-27) = -29
, which is -2 - 27 = -29
, which is true.
If you use a negative number in a SubSource
flag, it will result in a double negative, turning the number back to positive.
ID | Flag | Type | Size | Memory | Cmp | Type | Size | Mem/Val | Hits |
---|---|---|---|---|---|---|---|---|---|
1 | SubSource | Value | 0xfffffffe | ||||||
2 | Value | 0xffffffe5 | = | Value | 0xffffffe3 | 0 (0) |
This means -(-2) + (-27) = -29
, which is 2 - 27 = -29
, which is -25 = -29
, which is false.
- 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