corrected heading levels

This commit is contained in:
sejo 2022-03-27 21:38:25 -06:00
parent a35cef5c43
commit 3249b44e06
2 changed files with 23 additions and 23 deletions

View File

@ -1,5 +1,5 @@
# tutorial uxn apéndice a: repetir un tile dentro de un rectángulo
lang=es en->{uxn_tutorial_appendix_a}
lang=es en->{uxn tutorial appendix a}
en la primera parte del {tutorial de uxn día 6} hablamos de cómo cubrir el fondo de la pantalla con un tile dado.
aquí generalizaremos un procedimiento similar en una subrutina dibuja-tiles que dibuje un rectángulo relleno con un tile dado. recibirá las coordenadas x,y de la esquina superior izquierda del rectángulo, su anchura y altura en píxeles y la dirección del tile:
@ -12,7 +12,7 @@ un recordatorio de que estamos utilizando la convención de añadir un signo de
vamos a detallar cómo llegar a dos versiones de esta subrutina, una que se basa en una fuerte manipulación de la pila, y otra que utiliza variables. esto con el fin de comparar ambos enfoques y darnos una visión más amplia de las posibilidades dentro de uxntal.
## configuración
# configuración
comencemos con el siguiente programa como plantilla. incluye los datos para un sprite de 1bpp compuesto por líneas diagonales.
@ -39,7 +39,7 @@ BRK
@tile-fondo 1122 4488 1122 4488
```
## repetir un tile en una fila
# repetir un tile en una fila
¿qué procedimiento podríamos seguir para repetir el dibujo de un tile empezando por x y terminando en un límite correspondiente a x+ancho?
@ -49,7 +49,7 @@ una forma sería algo así como:
* añadir 8 (el tamaño del tile) a x
* ¿es x menor que el límite? si lo es, repite el procedimiento, si no, termina
### versión concreta
## versión concreta
antes de abstraerlo, recomiendo que lo escribamos con números concretos.
@ -96,7 +96,7 @@ integrando todo ello, podríamos obtener:
nótese el uso de DUP2 para evitar releer el valor de x.
### abstrayendo
## abstrayendo
ahora, digamos que queremos que el código anterior funcione con cualquier x inicial y ancho inicial dados, presentes en la pila antes de empezar.
@ -156,7 +156,7 @@ nuestra subrutina se vería entonces de la siguiente manera:
RTN
```
### programa completo
## programa completo
lo siguiente muestra nuestro programa en contexto, llenando completamente la primera fila de nuestra pantalla con nuestro tile:
@ -204,7 +204,7 @@ RTN
@tile-fondo 1122 4488 1122 4488
```
## repetir una fila
# repetir una fila
similar a lo que acabamos de hacer: ¿cuál es el procedimiento que podríamos seguir para repetir verticalmente una fila empezando por `y` y terminando en un límite correspondiente a y+altura?
@ -214,7 +214,7 @@ siguiendo la misma estrategia, podríamos hacer:
* añadir 8 (el tamaño del tile) a y
* ¿es `y` menor que el límite? si lo es, repetir el procedimiento, en caso contrario terminar
### versión concreta
## versión concreta
utilicemos los mismos números que antes, suponiendo que nuestra `y` inicial es 0008, nuestra altura es 0100, y por tanto, nuestro límite siendo 0108.
@ -241,7 +241,7 @@ el siguiente código se basa en el bucle anterior de x, pero ahora dibuja una fi
LTH2 ,&bucle-y JCN ( saltar si x es menor que el límite )
```
### versión abstracta
## versión abstracta
ahora, antes de saltar directamente a la emulación de la solución para dibujar la fila, vamos a notar que en este caso no es tan fácil.
@ -261,7 +261,7 @@ si solo quisiéramos cubrir toda la pantalla con un sprite, ya tenemos todo el c
entonces podríamos pasar a la sección relativa de las paletas. sin embargo, lo que sigue puede ser interesante como una forma de ver un posible enfoque para escribir un código uxntal más complejo :)
### usando la manipulación de la pila
## usando la manipulación de la pila
en principio podríamos simplemente manipular los elementos dados en la pila, almacenándolos cuando sea apropiado, para adaptar nuestra subrutina a su firma.
@ -444,7 +444,7 @@ podemos entonces llamarlo de la siguiente manera para obtener un cuadrado de 256
=> ./img/screenshot_uxn-background-square.png captura de pantalla que muestra un gran cuadrado en la pantalla varvara compuesto por líneas diagonales
### usando variables
## usando variables
comparemos el enfoque anterior con el uso de variables relativas.
@ -565,7 +565,7 @@ nota que esta subrutina tal como está requiere 24 bytes de memoria de programa
en nuestro caso eso no es un gran problema, pero es una buena manera de evaluar nuestras prioridades: código súper legible pero probablemente ineficiente (como esta última subrutina), código súper optimizado pero probablemente ilegible (código de solo escritura, dicen), o algo en el medio.
## dibuja-fondo
# dibuja-fondo
ahora que tenemos estas bonitas subrutinas, podemos simplemente envolverlas en otra que cubrirá todo el fondo con nuestro tile elegido.

View File

@ -12,7 +12,7 @@ a reminder that we are using the convention of adding a caret (^) after the name
we will detail how to get to two versions of this subroutine, one that relies on heavy stack wrangling, and other one that uses variables. this in order to compare both approaches and give us a broader view of the possibilities within uxntal.
## setting up
# setting up
let's start with the following program as a template. it includes the data for a 1bpp sprite consisting of diagonal lines.
@ -39,7 +39,7 @@ BRK
@tile-background 1122 4488 1122 4488
```
## repeating a tile in a row
# repeating a tile in a row
what's a procedure we could follow to repeat the drawing of a tile starting from x, and ending at a limit corresponding to x+width?
@ -49,7 +49,7 @@ one way would be something like:
* add 8 (the size of the tile) to x
* is x less than the limit? if it is, repeat procedure, otherwise end
### concrete version
## concrete version
before abstracting it away, i recommed we write it with concrete numbers.
@ -96,7 +96,7 @@ integrating all of it, we would be able to get:
note the use of DUP2 in order to avoid re-reading the value of x.
### abstracting
## abstracting
now, let's say we want to have the previous code work with any given initial x and width, present in the stack before starting.
@ -156,7 +156,7 @@ our subroutine would then look as follows:
RTN
```
### complete program
## complete program
the following shows our program in context, completely filling the first row of our screen with our tile:
@ -204,7 +204,7 @@ RTN
@tile-background 1122 4488 1122 4488
```
## repeating a row
# repeating a row
similar to what we just did: what's a procedure we could follow to repeat vertically a row starting from y, and ending at a limit corresponding to y+height?
@ -214,7 +214,7 @@ following the same strategy, we could do:
* add 8 (the size of the tile) to y
* is y less than the limit? if it is, repeat procedure, otherwise end
### concrete version
## concrete version
let's use the same numbers as before, assuming that our initial y is 0008, our height is 0100, and therefore our limit would be 0108.
@ -241,7 +241,7 @@ the following code is based on the previous x loop, but it now draws a row in a
LTH2 ,&loop-y JCN ( jump if x is less than the limit )
```
### abstract version
## abstract version
now, before jumping right into emulating the solution for drawing the row, let's note that in this case it is not that easy.
@ -261,7 +261,7 @@ if we just wanted to cover all the screen with a sprite, we have all the require
we could then just jump to the section regarding the paddles. however, what follows can be interesting as a way of looking at possible approach to write more complex uxntal code :)
### using stack wrangling
## using stack wrangling
in principle we could just manipulate the items given in the stack, stashing them when appropriate, in order to adapt our subroutine to its signature.
@ -444,7 +444,7 @@ we can then call it like the following in order to get a 256x256 square filled w
=> ./img/screenshot_uxn-background-square.png screenshot showing a big square in the varvara screen composed of diagonal lines
### using variables
## using variables
let's compare the previous approach with the use of relative variables.
@ -565,7 +565,7 @@ note that this subroutine as-is, requires 24 bytes of program memory more than t
in our case that's not much of a problem, but it's a good way of evaluating our priorities: super readable but probably inefficient code (like this last subroutine), super optimized but probably unreadable code (write-only code, they say), or something in the middle.
## draw-background
# draw-background
now that we have these nice subroutines, we can just wrap them in another one that will cover the whole background with our chosen tile.