day0 day1 day2 day3 day4 day5 day6 day7 day8 day9 day10 day11 day12 day13 day14 day15 day16 day17 day18 day19 day20 day21 day22 day23 day24 day25 day26 day27 day28 day29 day30 day31

here to recap my December Adventure 2024. More info about this and other people doing it here

DAY 0

December is starting tomorrow, so let's speak about what are my goals for this december adventure 2024. I have a UXN software that I would like to complete. It's some spin off Noodle, just a screen and you can draw some 1 bit image in it, the twist being that in the same time it's generating a SVG file of your drawing.

For now it's still missing a lot of feature so I think I will work on implementing them so it will finally be an usable software. The list of feature I will work on this december:

Honestly not sure how much time I will need to add all of that. We will see, I guess that's why it's an adventure !

DAY 1

Here we go for this first day of december! Today in the menu is drawing rectangle.

As a rectangle is basically just two straight line and two vertical line, that's really not that hard. For now, I will not bother with filled rectangle, I don't have any use for them I can think of in top of my head. So my strategy was simple, just draw the two horizontal line, then draw the two vertical line. So overall I just did two loop, one for each axis. Honestly I didn't have any real difficulty putting this out, I just lost 10 min because I did the classic mistake of writing GTH in place of GTH2.

So to finish this first day review I will share the little bit of code I wrote. Please note it's litteraly the first draw, there is a lot of duplication, typically I just STA value many time when I could have just load them one time and DUP them as much as needed, but it was early in the morning and was not feeling tracking the stack so I did it the lazy way.
Please note the code assume you STA x0 in @x and y0 in @y and jump into this with x1 and y1 in the stack

----------------------------------------------------------- @draw-rectangle ( x1* y1* | adress ) DUP2 ;y LDA2 NEQ2 ?{ ;y LDA2 INC2 ;y STA2 } OVR2 ;x LDA2 GTH2 ?{ ;x LDA2 ROT2 ;x STA2 SWP2 } DUP2 ;y LDA2 GTH2 ?{ ;y LDA2 SWP2 ;y STA2 } ;x LDA2 STH2 ;y LDA2 .Screen/y DEO2 &horizontal-line ( x1* y1* | adress x0* ) ;x LDA2 .Screen/x DEO2 #41 .Screen/pixel DEO ;x LDA2 .Screen/x DEO2 DUP2 .Screen/y DEO2 #41 .Screen/pixel DEO ;y LDA2 .Screen/y DEO2 OVR2 ;x LDA2 NEQ2 ?{ ;draw-rectangle/vertical-line JMP2 } ;x LDA2 INC2 ;x STA2 ;draw-rectangle/horizontal-line JMP2 &vertical-line ;y LDA2 .Screen/y DEO2 #41 .Screen/pixel DEO ;y LDA2 .Screen/y DEO2 STH2kr .Screen/x DEO2 #41 .Screen/pixel DEO ;x LDA2 .Screen/x DEO2 ;y LDA2 INC2 ;y STA2 DUP2 ;y LDA2 NEQ2 ?{ POP2 POP2 POP2r JMP2r } ;draw-rectangle/vertical-line JMP2 BRK @x $2 @y $2 -----------------------------------------------------------

DAY 2

Hello ! Today I didn't have much time as most of it have been used by my employer to make people richer. So I went for the low effort stuff and just put what I did in day 1 in the main rom. So I litteraly just copy and paste the previous UXN code into another file. But the particularity of this rom ( one day I will find a name for it I swear ) is that the rectangle I'm now able to draw in the screen should also be included in a svg file who is generated on the fly when you are using the rom. The way it works is quite simple, I just build a string and then put this string in a file. In this case the string look like this:

@rect-svg "<rect 20 "x= 27 20 20 20 20 20 27 20 "y= 27 20 20 20 20 20 27 20 "width= 27 20 20 20 20 20 27 20 "height= 27 20 20 20 20 20 27 20

After that I just need to fill the string with the x,y width, height and these are info I can easily obtain. If you are curious about how I fill this string, I use a modified version of the pdec routine available in this page, I left as an exercise for the reader to find what the modification is... Sorry always dreamed about saying that, the truth is I'm just not motivated to explain it right now.

To end today post, no code this time but a simple svg file with rectangle in it, produced by an uxn rom :)

DAY 3

Hello ! Here we go for day 3 of this adventure. Today I wanted to challenge myself. To be exact, I have one goal for this month where I'm fully clueless about how it should be done. The goal in question is "Being able to draw ellipse". I litteraly never implemented any algorithm who let you do that, for the simple reason that I never need to draw ellipse. So I first check for these algorithm, I find plenty of variant of the mid point algorithm, all writen in C. Most of them use negative number, something UXN didn't provide properly. But well, I still tried to take the C code and convert it... It was a total failure, the result is litteraly just a pixel in the screen and then the stack is broken. I have no idea why. For 45 min I carefully follow the stack, checking line by line and yet, it's just not working. Beetbug is showing me that the program work fine the first time, and then when it's looping, the stack got destroyed... It make no sense ? I can't keep checking everything today, I have other things to do. I come with no clue about how draw ellipse in UXN and after a day of working, I still have no clue. I don't know if I'm just bad at converting C code into tal, or if I'm just bad a following a stack, or if the algorithm just don't work or if all of that is just hard because of the way uxn have been thought.

The fact that algorithm are just a list of stuff to do and not being able to just rewrite these step is really an easy way to make you feel dumb. Let's hope sleeping give me inspiration to climb this wall