CPCWiki forum

General Category => Programming => Topic started by: Prodatron on 00:57, 03 December 24

Title: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 00:57, 03 December 24
One year passed, and here is the new challenge for 2024:

https://www.youtube.com/watch?v=3q5ZWJmMhgQ

https://logiker.com/Vintage-Computing-Christmas-Challenge-2024

This time it's a "present/gift".
Looking forward to it again, always crazy with how less bytes some people are able to do this on different platforms.

@Logon System, you have to go for it again! :D
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 01:44, 03 December 24
Also looking forward to it. This time it seems there is less symmetry that could be used to shorten the program. But we will see ...
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 15:10, 04 December 24
Quote from: lightforce6128 on 01:44, 03 December 24This time it seems there is less symmetry that could be used to shorten the program.
Another problem is, that this time there are 7 different chars in total (including space, excluding line feed).
In the past you always had only 2 chars (including space).

So I wonder, if the entries will be larger this time.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: GUNHED on 12:47, 05 December 24
Here is my first result, no optimisation at all.

It needs &48 Bytes = 72 Bytes

See picture...
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Overflow on 16:07, 05 December 24
Quote from: Prodatron on 00:57, 03 December 24@Logon System, you have to go for it again! :D
Go!

Quote from: Prodatron on 15:10, 04 December 24So I wonder, if the entries will be larger this time.
They will. No doubt they will. That said it also implies many ways to optimize. Nice challenge - different from last year.


Quote from: GUNHED on 12:47, 05 December 24It needs &48 Bytes = 72 Bytes
Almost the same at first shot (70 bytes). Now let's optimize. :)

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: GUNHED on 18:53, 05 December 24
First optimisation: Down at &40 = 64 Bytes.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 20:45, 05 December 24
With my very first approach I am at 58 bytes, and it seems to be hard to decrease this.
Another idea is needed to reach less bytes.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: BSC on 00:14, 07 December 24
Nice compo. Good to see your participation @Overflow :)

My first try is under 60 bytes. I hope to squeeze one or two more bytes. 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 12:29, 07 December 24
101 bytes in CPC Basic.  ::)
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 23:47, 07 December 24
99 bytes, no more ideas.  ::)
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 02:35, 10 December 24
Quote from: ZorrO on 23:47, 07 December 2499 bytes, no more ideas.  ::)

First I tried with BASIC, three different approaches. But none of them is even close to 99 bytes. So this seems to be a good achievement ... for now. :D
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 02:46, 10 December 24
I find it always surprising how close the assembly solutions are and also how similar the improvement steps are. I implemented two assembly solutions, and with the "Ready" prompt at a bad location I also achieve less than 60 bytes. But the prompt needs to move somehow ... (letting the prompt appear saves some bytes compared to halting the program, but moving the cursor to a good location eats up the improvement again).

While working with this a bit I have to correct myself: There are many symmetries, in the image itself as well as in the numbers.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 21:12, 11 December 24
Nice challenge!

I'm at 54 bytes now, but I wonder what Logiker means by 
"All characters can be replaced with another character if this does NOT influence the code."

Does he mean we're not allowed to replace the symbols with others that look similar but have an ascii-code that happen to be useful as constant, opcode or other?
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 21:51, 11 December 24
I think for example ZX80 & ZX81 don't have ! and \ but you still can use it as challenge machine.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: andycadley on 22:00, 11 December 24
Quote from: arnolde on 21:12, 11 December 24Nice challenge!

I'm at 54 bytes now, but I wonder what Logiker means by
"All characters can be replaced with another character if this does NOT influence the code."

Does he mean we're not allowed to replace the symbols with others that look similar but have an ascii-code that happen to be useful as constant, opcode or other?
I don't think that would be allowed, since then the symbols used literally affects the code. It's really an exception for machines whose character set doesn't contain suitable characters.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 23:05, 11 December 24
Quote from: arnolde on 21:12, 11 December 24Nice challenge!

I'm at 54 bytes now, but I wonder what Logiker means by
"All characters can be replaced with another character if this does NOT influence the code."

Does he mean we're not allowed to replace the symbols with others that look similar but have an ascii-code that happen to be useful as constant, opcode or other?
It means, that if using characters, which

- are NOT originally specified; see here...

QuoteThe characters used are:
  • - Minus
  • + Plus
  • ! Exclamation mark
  • \ Backslash
  • / Slash
  • O Big O
All characters can be replaced with another character if this does NOT influence the code. E.g. backslash on the C64 gets replaced by chr$(205). Or on the right-hand side I replaced the big O by a smaller one, as it looks nicer, but it didn't influence the code. At any time, I could replace the o with O or the C64 Backslash with its counterpart on the C64.

- AND will change/optimize your code

are NOT allowed.

Probably the best example is using "*" instead of "-" (you probably know, what this could mean :P ). This of course is not allowed.

PS: Hope Logiker isn't angry, that people are posting their current sizes, as this is against the rules, but I did this mistake as well in the past, sorry...
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 08:04, 12 December 24
Quote from: Prodatron on 23:05, 11 December 24Probably the best example is using "*" instead of "-"
I would say we had enough fun with 42 in the last few years  ;)

Quote from: Prodatron on 23:05, 11 December 24Hope Logiker isn't angry, that people are posting their current sizes,
I think it's only forbidden to post the final size or did I misunderstand?
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 08:42, 12 December 24
Haha indeed. Yes you are probably right :)
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 23:20, 12 December 24
Logiker would like more people to participate. I don't know, maybe then there would be a chance for more sponsors. And there are many people who will write some code and read that others are better because they wrote much shorter code, and will think that sending their work makes no sense because I won't win anything anyway.

Last year it was similar, he asked people not to brag on forums etc. but he didn't say that you are out of the competition if you give your result because then there would be fewer people, not more. Or maybe someone weaker would even win, because a better one will be out because he bragged about his result.

So he has a dilemma whether to throw such people out of the competition or not. Because there would be a storm of denunciations, but would it increase the number of participants?

But I see that his request was ignored this year too.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: eto on 23:52, 12 December 24
Imho the discussion here with the progress that is shared makes it more interesting - not less. I could not care less about that competition but reading here about it and seeing how people squeeze out a byte here or there - that makes it interesting again.

Maybe it would be better to find different prize catagories to motivate more people to come up with their ideas - not only the size itself. E.g. most elegent code, most surprising solution, best newcomer.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 00:31, 13 December 24
Categories can be multiplied, e.g. each platform or language. Although in many there would be only one participant. But without sponsors they will only get congratulations.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 20:51, 13 December 24
Quote from: arnolde on 21:12, 11 December 24I'm at 54 bytes now, but I wonder what Logiker means by 
Also, I have to admit that this was the strangest kind of bragging: It was actually a typo, I meant 64 bytes  :picard: 
Now, meanwhile I have condensed it, but I don't see 54 happening for now – maybe if I find another approach... 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 06:29, 14 December 24
Quote from: arnolde on 20:51, 13 December 24Now, meanwhile I have condensed it, but I don't see 54 happening for now – maybe if I find another approach...

I found another approach  ;D  and the problem with the prompt could also be solved. Now I cannot find anything to compress this further, but we will see. The challenge is not over.

Until now I tried 4 approaches in BASIC and 3 in assembly.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 15:34, 14 December 24
I wonder if anyone has tried chatGPT.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Overflow on 21:31, 14 December 24
Hi guys! I can confirm I will submit one entry. I've already spent a few days and many hours about that challenge. More fun than last year ! Since the shape is more complex, I believe there's place for more different algorithms, more optimizations and more tricks. Tonight I'm likely done with final size. 10 days to go !
:-X :-X :-X

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 08:14, 15 December 24
Yes, I agree! What I like about this year's callenge is that even if you find the best and most optimized algorithm for the main shape, it's not worth anything if you can't use its routines for drawing the bow in the first line – that's what I am struggling the most with at the monent...  8)

But I made an interesting discovery which might give our Z80 with its 16 bit arithmetics a little advantage... 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 01:39, 17 December 24
Quote from: ZorrO on 15:34, 14 December 24I wonder if anyone has tried chatGPT.

When I tried this last time, it was not quite good in Z80 assembly, but always stumbled towards 6510 assembly. It seems the training data did not contain enough information about Z80 programming. Maybe this has changed now, or maybe it is possible to provide it with the additional needed information (e.g. as part of the question or as attachment). Somewhere I saw specialized ChatGPTs with Z80 knowledge. I guess, for Locomotive BASIC it is not much different.

But size coding is very different from normal software development. Because the training data probably contained much normal source code and only a bit of size coding, this would also need additional information. To get a good answer, you would have to ask a really long and elaborated question, containing all the information that guides ChatGPT to a good answer.

But once you have this prompt, it maybe can be reused for the next challenge ... :)
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 01:49, 17 December 24
For a BASIC program, how do you measure the size? As far as I can see, there are several possibilities:


All these approaches will show small differences, but every byte counts.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 01:56, 17 December 24
Quote from: arnolde on 08:14, 15 December 24Yes, I agree! What I like about this year's callenge is that even if you find the best and most optimized algorithm for the main shape, it's not worth anything if you can't use its routines for drawing the bow in the first line – that's what I am struggling the most with at the monent...  8)

But I made an interesting discovery which might give our Z80 with its 16 bit arithmetics a little advantage... 

Currently I have given up on this and spent a lot of bytes to draw the bow separately (and to reserve the empty row for it). It would be nice if this could somehow be combined with the main drawing routine ...

I also were thinking about to use 16 bit arithmetics, but I urgently need the 8 bit registers at another location. And I need more registers ... :laugh:
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: BSC on 08:55, 17 December 24
I am really looking forward to the other solutions this time. Much more than last year. 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Mark_wllms on 09:03, 17 December 24
QuoteAll characters can be replaced with another character if this does NOT influence the code.

Has anyone tried searching for any of these character sequences in the Amstrad ROM?
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: prevtenet on 16:09, 17 December 24
Quote from: lightforce6128 on 01:39, 17 December 24
Quote from: ZorrO on 15:34, 14 December 24I wonder if anyone has tried chatGPT.

When I tried this last time, it was not quite good in Z80 assembly, but always stumbled towards 6510 assembly.
I've had the best luck with Claude 3.5 Sonnet, at least for having a good mixture of technical knowledge and generating (mostly) correct Z80 assembly. It's not yet good enough to just cut-and-paste and expect it to work, but it does come up with useful ideas I would have missed.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 17:58, 17 December 24
Quote from: Mark_wllms on 09:03, 17 December 24Has anyone tried searching for any of these character sequences in the Amstrad ROM?
Of course! But without luck...
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 22:56, 17 December 24
@lightforce6128 

After reset on 6128 type:
?fre(0)  give 42249
load"basic
again ?fre(0)  give something
?something-42249  get size Basic

After RUN probably some variables took some space, you can try add first line
1 END
run
1  - to delete this line, and try ?fre(0)  again, but to be sure better save it, reset and measure after load. 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Longshot on 13:32, 20 December 24
5 days left...

Happy holidays :D
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 14:59, 20 December 24
Quote from: Longshot on 13:32, 20 December 245 days left...
And probably 10 days left until the results...
I am very excited!! ;D
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 18:37, 23 December 24
OK, i just submitted a Loco Basic and an Assembler entry.
I feel a bit silly this year, like I have the imression that both my approaches were not really the most clever ones and also I didn't find a lot of optimizations , but we'll see...

I am anyway very very curious to see what you guys did!

Until then, Merry Christmas!!!
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Overflow on 20:00, 25 December 24
Entry submitted ! ;D

Much to discuss here in a few days. I'm eager to see others' approaches - on other computers too. To loop or not to loop - that is the question !  ;)  
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 21:20, 25 December 24
Quote from: Overflow on 20:00, 25 December 24To loop or not to loop - that is the question !  ;) 
Yes, and if so, how  ;D

I'm also very much looking forward.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 12:51, 28 December 24
The presentation of the entries is finished and will be shown today, at 7 pm CET.

https://www.youtube.com/watch?v=kJYbIC-14s4
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 19:47, 28 December 24
Crazy, Logon System will be one of the best again W.T.F. :o ;D
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 19:51, 28 December 24
Congratulation again to Longshot and Overflow, but also to Lightforce, you are all crazy cool!!
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 20:10, 28 December 24
Incredible achievement by all the winners! I can't wait to study all this sources in detail – and I hope you guys are here for us if we need some details explained  :o
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 20:16, 28 December 24
It's the first time that a CPC entry (Longshot) was #1 (together with a 6502 entry) for all ASM entries. Soooooo cool!
Funny, this time it seemed to be too complex for Spectrum guys haha (just kidding!).

Yes, I have to study the other CPC entries soon (currently the video is too bad to see the Logon System sources) :P
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Longshot on 20:58, 28 December 24
Congratulations to all participants, this year again, the codes are varied and appetizing.
I will look at some sources. ;D

The Lightforce6128 code is amazing :o , especially in the way it displays the object. Congratulations!!
The ribbon is "executed" and it found the display routine in high rom: more interesting than the routine in low rom that I use. (To remember for next time).

The code from Overflow is a Z80A cathedral.

Quotecurrently the video is too bad to see the Logon System sources
;;=======================================================================
;; Vintage Computing Christmas Challenge 2024 (VC3 2024)
;; Amstrad CPC 6128 / Longshot (Logon System)
;; December 2024
;; 41 bytes.
;; Christmas strings in the box
;; run from basic : memory &2d00:mode 0:load "vcc2024.bin":call #2d2b
;; or type : run "STUB" with the same content
;; For 464 or 664 model, update _firm_disprom equ.
;;=======================================================================
_firm_disprom_464  equ #6eb
_firm_disprom_664  equ #6ec
_firm_disprom_6128 equ #6fc

_firm_disprom    equ _firm_disprom_6128

size_code     equ end_code-start_code
org_code    equ #7f00-5

        org org_code
start_code
                    ; on run (de=#2d2b, hl=#004x, a=0 bc=#20ff)
                    ; #2d2b >> 1st charset "-+"
exec_code
        ld hl,#8000+200        ; End of christmas_buffer+1 >> #8000+(20 bytes x 10 lines)
fill_10lines                ; ========================
        ld bc,#14dc        ; b=19+1 loop / c=200-1+21 (for lddr)
        ld a,h            ; a=%10000000 (selector for 2nd char of charset) 8 bits+Carry
fill_oneline                ; ------------------------
        dec l            ; ptrbuf-- ZF=1 if l==0
        rla            ; rotate selector 9 bits
        ld (hl),d        ; "-" or " "
        jr nc,select_2ndchar    ; CF=0 first char
        ld (hl),e        ; "+" or "!"
select_2ndchar
        djnz fill_oneline    ; complete line
                    ; ------------------------
        ld de,#2021        ; New current charset " !"
        ld (hl),d        ; + 1 space
        jr nz,fill_10lines    ; new line until hl=ptrbuf=#8000 (l=0 ZF=1)
                    ; ========================
        ld d,h            ; d=msb ptrbuf
        dec hl            ;
        ld e,200-1        ; Duplicate (9+1) lines to (1+9+1) lines
        ex de,hl
        lddr
        ld l,christmas_string    ; h is ok. l on lsb string buffer
        rst #28            ; Display string & go back to Basic
        dw _firm_disprom     ;

christmas_string
        db #1f,10,#7f        ; locate x=10 y=scroll down
        db #cd,"O",#cc,13,10    ; gift bow "\","O","/"
christmas_buffer            ; Buffer to build   
end_code
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: ZorrO on 23:08, 28 December 24
This year I was too lazy to send, but I enjoyed watching someone's works, especially in the wild category. Like last year, I also didn't understand most of it. :D

Just like last year, I was most interested in BASIC CPC. The best result was Azicuetano at 19:23, only 86 bytes.

But it seems to me that Logiker made a mistake in counting sources and omitted spaces that are part of the program. After entering it in the emulator and of course removing unnecessary spaces after PRINT, and before TO and before THEN, it comes out to 98 bytes. Which gives it third place in CPC BASIC, not first.

I would fix two things there, I would remove the semicolon from the first PRINT, that's 1 byte of savings. And instead of "<" in the second PRINT I would add the Ctrl+H arrow symbol at the end of both versions of o$. We subtract 3 bytes and add 2, which gives a total savings of two bytes. But still 3rd place.

And I would have fourth in CPC, if I sent it.  ::)

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: dodogildo on 23:20, 28 December 24
Congrats to everybody who participated and to the Logon Systems in particular.

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 04:43, 29 December 24
Congratulation to @Overflow and @Longshot for reaching 42 and even 41 bytes. This will be interesting literature.


Quote from: lightforce6128 on 06:29, 14 December 24Until now I tried 4 approaches in BASIC and 3 in assembly.

When I wrote this, it came into my mind that this could be misunderstood as a (forbidden) hint to a size of 43 bytes. This was not really a problem, because at this time I was far from this, and others, too. So I let this ambiguous meaning uncommented. Maybe it would encourage others to reach this ridiculous low number ...

Then, slowly, I reached exactly this number by myself. With a strict understanding of the rules now this would be a problem. So I tried everything to somehow reach at least 42 bytes, but without success.

This is a true story! I'm innocent! Luckily the rules are not applied so strictly.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 04:49, 29 December 24
Quote from: ZorrO on 23:08, 28 December 24This year I was too lazy to send, ... And I would have fourth in CPC, if I sent it.  ::)

When we talked about this earlier, you already had a quite good result, 10 bytes smaller than my best approach. You should have sent in your work.

But I fully understand this. For me it was the same last year. I had already a good approach, but hesitated to sent it in on time.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Overflow on 08:15, 29 December 24
Wow! was a blast for CPC reaching thé higher places. :)

Double kudos for lightforce6128 : nice catch for the high rom call, and a fantastic way to draw thru poking locate coordinates

 I'll have a look at other entries later. Here's mine.

org #2100 -#22; call #0901=de
loop_Y  ld h,#21   
loop_knot   ld a,(hl)
            call #BB5A
            dec l
            jr nz,loop_knot
        dec (hl); (#2100) counts Y
        ret z
        ld l,h; hl=#2121="! "+1
        dec e
        jr nz,jr_Y
            ld e,d; =9
            ld hl,#2B2D; "+-"
jr_Y equ $ -1; #2B == dec hl           
        ld bc,#100 +19; b counts X
loop_X      ld a,l
            djnz jr_X
                ld b,d; =9
                ld a,h
jr_X        call #BB5A
            dec c
            jr nz,loop_X
        db #C3; jp #0Dxx=loop_Y
    db 19 +1; counts Y at org #2100
    db #0D,#CC,"o",#CD,0,9,#1F
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 09:25, 29 December 24
Wow, this is so amazing!

Kudos to Overflow for taking advantage of "!"-1=" ", for the clever way of putting the bow in a buffer and display it at every row and of course for all the opcode trickery... "Z80A Cathedral" is a very appropriate description.

Congrats to Longshot for using mode 0 in order to do newline by only displaying a space (while one might argue that including the mode instruction in the basic stub is a little bit of cheating); for finding the string display routine in ROM (I also had approaches that filled a text buffer but the output loop just made the code too big... and to elegantly realize the 1-8 pattern with a 9-bitplane.

Bravo to lightforce6128, very elegant, I have to study it in depth later.

I am quite humbled. The only thing I still am proud about is my discovery that #2120 ("!-") + #0A0D (newline) = #2B2D ("+-").
Here is my code if anyone is interested:

;============================================
; Vintage Computing Christmas Challenge 2024
;============================================
; Submission by Arnolde of Leosoft
;   "Je m'appelle boite" (I call myself box)
;============================================
; Z80 Machine Code for Amstrad CPC, 51 bytes
;============================================
; Main loop consists of fall-through calls to
;   realize the 1-8-1-8-1 structure. It calls
;   itself recusively to serve both for the
;   line setup and the character output.
; Carry flag indicates recursion depth:
;   set = line setup mode (outer loop)
;   reset = char output mode (inner loop)
; Zero flag indicates if the current item is
;   set = a single
;   reset = an octuplet
; As the characters always cone in pairs,
;   they are passed via DE
;============================================
; To launch from Basic:
;   MEMORY &5C1F
;   LOAD "VCCC24.BIN",&5C20
;   CALL &5C20
; or run the basic loader:
;   RUN "VCCC24.BAS"
;============================================

org #5C20

; input conditions:
  ; Carry is reset -> char mode enabled
  ; DE = #5C20 = "\ "

; draw bow
  call do_8e_1d   ; output 8 spaces + "\"
  ld de,"/O"      ; (#2F4F)
  call do_1e_1d   ; output "O/"
  scf             ; set line mode
; draw box
loop:             ; 1-8-1-8-1:
  call do_1d      ; 1-
  call do_8e_1d   ; -8-1-
do_8e_1d:         ; -8-1
  ld b,7          ; will be inc'ed to 8
do_1e_1d:
  ld a,e          ; load octuplet character
  inc b           ; =1 if called directly
  repet:
    call do_it
    dec b         ; not djnz because
    jr nz,repet   ; we need zero flag
do_1d:
  ld a,d          ; load single character
do_it:            ; either...
  jp nc,#BB5A     ; output character, or...
  ; set up next line ("outer loop")
  ccf             ; set char output mode
  ld c,b          ; backup outer counter
  ld de,#0A0D     ; = LF-CR (newline)
  ld hl,"! "      ; octuplet (#2120)
  jr nz,$+3       ; z set -> setup single:
    add hl,de     ; = #2B2D = "+-" = single *
  call do_1e_1d   ; go down one text line **
  ex de,hl        ; line chars -> de
  call loop       ; output current char line
  ld b,c          ; restore outer counter
  scf             ; back to line mode
ret

; *) Yes, "! " + #0A0D = "+-". Was that an
;    intentional easter egg, Logiker?
; **) We can keep b as is, because even if
;     b>1, the repeated character is CR
  
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Longshot on 14:13, 29 December 24
It's always impressive to see the multitude of logics to solve the same problem.

Quote(while one might argue that including the mode instruction in the basic stub is a little bit of cheating)

I thought about the mode change. I saw that some machines use different languages or OS whose "text mode" is not necessarily the one in force on the stock machine (for example on CP/M or on Symbos) and which do not change text mode. Clearing the screen was also allowed in launchers of previous productions (including on Cpc), and it was not specified that changing modes is prohibited before the run.

If the mode change must be integrated into the code, it takes 2 more bytes (in the bow string) or in a mode 1/mode 2 version that adds CR/LF instead of Space. In this case, the shortest program on Cpc is the Overflow Z80A cathedral :laugh: .

We can discuss other things too. I didn't play on the executability of the characters or on the gap between the ascii codes, because I found the rule a bit convoluted:

On Cpc, with a French rom, the character "\" appears as "ç", which is not very aesthetic. The rules allow "replacing" the character by its equivalent provided that it does not advantage the code.... On Cpc, there are really a lot of replacement choices. (&CD/&CC for \ / for example)

In other words, you can advantage your code with a rotten display, but not take advantage of an ascii code more graphically consistent with the expected pattern if the code takes advantage of it....

In short, the rules are still not very strict, especially since it is quite pointless to compare the different systems with each other. But hey, the ZX spectrum lost this year. :laugh:

Do any of you know whether APL exists on CPC?
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: arnolde on 16:21, 29 December 24
Quote from: Longshot on 14:13, 29 December 24On Cpc, with a French rom, the character "\" appears as "ç", which is not very aesthetic.

Ah, oui, I noticed that, but it is of course a good reason to replace with &CD/&CC – and as you didn't use these bytes for other purposes, c'est completement OK donc. (And as you were one of the big heroes of my CTM640-lit teenager room, I forgive you anything anyway.)

Quote from: Longshot on 14:13, 29 December 24In short, the rules are still not very strict, especially since it is quite pointless to compare the different systems with each other. But hey, the ZX spectrum lost this year. :laugh:
And that, obviously, is the most important thing  ;D ;D

You're right, this years pattern was great because there were so many ways to tackle it. I had another approach, also with a recursive loop, starting with A=236 and adding 28 every time. Thus, Carry is set every 9 times and Carry+Zero the 19th time. But I wasn't able to get it small enough...
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: GUNHED on 17:17, 29 December 24
That's the source code I used, it takes advantage of control codes... the result is 52 bytes long:


TFM's "Zeige Geschenk" Programm für FutureOS auf CPC6128 oder 6128plus :-)

Das Programm benötigt 52 Bytes im Speicher - Version 3 :-)



  ARNOR Z80 ASSEMBLER version 1.15                              Page 001

00003  7F74  (7F74)                ORG  &7F74        ;Source Code 'GESCHENK.MAX' -> Assembliert in 52 Bytes
00004                              NOLIST            ;2024.12.12
00005  7F74                        WRITE "-RUN-ME."  ;Zeilen 52 / Code-Bytes 52
00006                   
00007                   
00008                    ;OS-Variablen und OS-Funktionen
00009                   
00010  7F74  (FF22)        OSRON_A EQU  &FF22
00011  7F74  (FBFA)        TERM_2  EQU  &FBFA
00012                   
00013                   
00014                    ;ZEIge GEschenk
00015                   
00016  7F74  69            ZEI_GE  LD    L,C
00016  7F75  CD FA FB              CALL  TERM_2
00017                   
00018  7F78  3E 0A                LD    A,&0A
00019                   
00020  7F7A  21 9B 7F      ZGL    LD    HL,G_STR_2+&01
00021                   
00022  7F7D  77                    LD    (HL),A
00023  7F7E  2D                    DEC  L
00024  7F7F  CD FA FB              CALL  TERM_2
00025                   
00026  7F82  3E 13                LD    A,&13
00027  7F84  18 F4                JR    ZGL
00028                   
00029                   
00030                    ;Zeichenketten
00031                   
00032  7F86  02            G_STR_1 DB    &02          ;ROM Zeichensatz
00033                   
00034  7F87  0C                    DB    &0C          ;Cursor Heim
00035                   
00036  7F88  09                    DB    &09          ;Tabulator
00037                   
00038  7F89  5C 4F 2F 0E          DB    "\O/",&0E
00039                   
00040  7F8D  05 13 21              DB    &05,&13,"!"  ;Vertikal 19x "!" ausgeben
00041                   
00042  7F90  08 08                DB    &08,&08      ;Cursor-Position +8
00043  7F92  05 13 21              DB    &05,&13,"!"  ;Vertikal 19x "!" ausgeben
00044                   
00045  7F95  08 08                DB    &08,&08      ;Cursor-Position +8
00046  7F97  05 13 21              DB    &05,&13,"!"  ;Vertikal 19x "!" ausgeben
00047                   
00048  7F9A  1E 01 00      G_STR_2 DB    &1E,&01,&00
00049                   
00050  7F9D  2B 07 08 00          DB    "+",&07,&08,&00,"-"
      7FA1  2D
00051  7FA2  2B 07 08 00          DB    "+",&07,&08,&00,"-"
      7FA6  2D
00052  7FA7  2B                    DB    "+"
00053                   

Errors: 00000  Warnings: 00000 



Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: lightforce6128 on 02:14, 30 December 24
I'm trying to understand how the other entries work. Each one has its own special tricks.

@Longshot : During work on this challenge I always cursed the fact the I need a modulo 9 operation, but thought that only a modulo 8 operation can easily be created by bit operations. Until I saw the RLA in your source code ... 8-bit accumulator and 1-bit carry flag. Really nice!

To also get a small source code size, I compressed my source code heavily. I also have a longer version of my source code with many comments that might help in understanding:

NOLIST

;; Vintage Computing Christmas Challenge 2024 (VC3 2024)
;;
;;   Object   : Christmas Present
;;   Category : Main Challenge
;;   System   : Amstrad CPC 6128
;;   Language : Z80 Assembler (WinAPE/Maxam)
;;   Author   : lightforce6128
;;
;; Either run with WinAPE assembler (F3, then F9),
;;
;; or assemble with WinAPE assembler (F3, then Ctrl+F9)
;; optionally clear screen via CLS:LOCATE 1,22
;; and execute via CALL 11529,
;;
;; or assemble with WinAPE assembler (F3, then Ctrl+F9)
;; save via SAVE "present.bin",B,11529,43
;; load via MEMORY 11529:LOAD"present
;; optionally clear screen via CLS:LOCATE 1,22
;; and execute via CALL 11529
;;
;; The program itself does not clear the screen and it does not halt.
;; Both is allowed in the rules for this challenge, although both is
;; not quite user-friendly.


;; This special starting address moves parts of the program
;; to memory locations that allow to make special use of the
;; registers containing pointers to these memory locations.
;; It is checked in an assertion-like statement below.
ORG &2D00

;; Define some constants for OS access.
CHR_LOCATE EQU 31 ;; also requires column and row
LO_SIDE_CALL EQU &10
BASIC_PRINT_STRING EQU &C38B ;; call with RST LO_SIDE_CALL
TXT_CURSOR_POSITION EQU &B726
TXT_OUTPUT EQU &BB5A

;; This entrypoint for execution directly from WinAPE assembler
;; sets some registers as they would be set if program had been
;; called from command line. This setup code is not counted for
;; size and is not saved to disk by the third starting option
;; as described in the header. It is removed from the shortened
;; version of the source code.
RUN winapeAssemblerEntryPoint
winapeAssemblerEntryPoint:
LD BC,&20FF
LD DE,&2D09
LD HL,&0045

;; From here every byte is counted.
binaryStart:

;; This is also the official starting point of this program
;; as reached by the command CALL 11529.
callEntryPoint:

;; A:00 BC:20FF DE:2D09 HL:0045 IX:BFFE IY:0000 SP:BFF8

bow:
;; Define the control string to print the bow.
;; This is also a short nonsense code snippet
;; that does not interfere with the rest
;; of the program. But it sets up a needed
;; value in register H.
DEFB CHR_LOCATE, 9, 1, "\O/" ;; RRA : ADD HL,BC : LD BC,&4F5C : CPL
DEFB 0                       ;; NOP

;; Check if this is placed at the right position.
;; Its memory address is later used also for
;; another purpose.
bowExpected EQU "-"*256+9
IF bow-bowExpected
PRINT "Wrong program location: Should be $bowExpected, but is $bow."
STOP
ENDIF

;; A:FF BC:4F5C DE:2D09 HL:2144 IX:BFFE IY:0000 SP:BFF8

;; Print the bow. The system call will not alter register HL,
;; so it can be used below in a second role.
EX DE,HL : RST LO_SIDE_CALL : DEFW BASIC_PRINT_STRING

;; A:FF BC:4F5C DE:2144 HL:2D09 IX:BFFE IY:0000 SP:BFF8

;; Complete setting up of two small, two-element queues,
;; one with characters, one with step sizes.
;;     HD:2D21 ("-!")   LE:0901
LD E,1

;; First draw all the horizontal lines with dashes,
;; then the vertical lines with exclamation marks,
;; and finally the corners with plus signs.
characterLoop:
LD B,18
columnLoop:
LD C,18
rowLoop:
;; Position the cursor. Adjust the row to
;; keep space for the bow.
INC C : LD (TXT_CURSOR_POSITION),BC : DEC C
;; Print the character stored in the front
;; element of queue HD.
LD A,H : CALL TXT_OUTPUT
;; Use the front element of queue LE as row step size.
LD A,C : SUB A,L : LD C,A
JR NC,rowLoop
;; Use the second element of queue LE as column step size.
LD A,B : SUB A,E : LD B,A
JR NC,columnLoop
;; Shift both queues to update character and step sizes.
;; Fill up the queues with character "+" and step size 9.
;;     initial          : HD:2D21 ("-!")   LE:0901
;;     first iteration  : HD:212B ("!+")   LE:0109
;;     second iteration : HD:2B2B ("++")   LE:0909
;;     no change afterwards
EX DE,HL : LD DE,"+"*256+9
JR characterLoop

;; Here counting of bytes end.
binaryEnd:

;; Print out size and commands to save, load, and start program.
IF1
binaryLength EQU binaryEnd - binaryStart
PRINT
PRINT 'address range: &binaryStart - &binaryEnd (&binaryLength bytes)'
PRINT
PRINT 'save with: SAVE"present.bin",B,&binaryStart,&binaryLength'
PRINT 'load with: MEMORY &binaryStart:LOAD"present"'
PRINT 'optionally clear screen: CLS:LOCATE 1,22'
PRINT 'start with: CALL &callEntryPoint'
ENDIF
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Longshot on 15:05, 30 December 24
Displaying the buffer via the low rom with rst#28 has the advantage of gaining a "ret" to return to the basic prompt.

@lightforce6128
You can reach the 42-bytes score by replacing the #01 position of the bow position with #EB (same position, but here a useful "EX DE,HL") and removing the one following the #00 :

DEFB CHR_LOCATE, 9, #eb, "\O/" ;; RRA : ADD HL,BC : EX DE,HL : LD E,H : LD C,A : CPL
;; so it can be used below in a second role.
    RST LO_SIDE_CALL : DEFW BASIC_PRINT_STRING

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 16:58, 30 December 24
Shit, we didn't know about RST #10, that it can be used to call the Basic routine as well.
Otherwise we would have reached 44 bytes, and it would return to the prompt.

;** 44 BYTES **

txtout  equ #bb5a

adr_run equ 19*256+255      ;call address is #13ff and predefines DE;
                            ;A=0, CF=0, D=row counter, E,CF=9bit row pattern
adr_org equ #1f00-32        ;31 (see "len_sub") is the size until "txt_chars"
                            ;which has to be placed at #1f00
        org adr_org

        ld hl,txt_bow       ;plot bow (H=#1f)
gift1   rst #10             ;plot bow or just cr/lf
        dw #c38b
        ld bc,19*256+255    ;B=column counter, C,CF=9bit column pattern
        adc a               ;build row index (A=rowbit9), CF=0
gift2   rla                 ;add column index (A=2*rowbit9+1*columnbit9)
        ld l,a              ;HL=#1f0x
        ld a,(hl)           ;load char from indexed table
        call txtout         ;print it
        ld a,l              ;restore A
        rra                 ;restore column CF from A, A=row index
        rr c                ;move through column 9bit pattern
        djnz gift2          ;column loop
        rra                 ;restore row CF from A
        ld a,b              ;A is 0 again
        rl e                ;move through row 9bit pattern
        ld l,10             ;HL=#1f0a=txt_crlf
        dec d
        jr nz,gift1         ;row loop
        ret

len_sub equ $-adr_org
                            ;here the address is #xx00
txt_chars
        db "+","-","!"," "
txt_bow
        db #1f,9,25,"\o/"   ;placing and plotting the bow
txt_crlf
        db 13,10            ;CR/LF for both the bow and the rows
                            ;(always followed by zeros)
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: logiker on 16:09, 01 January 25
Quote from: ZorrO on 23:08, 28 December 24But it seems to me that Logiker made a mistake in counting sources and omitted spaces that are part of the program. After entering it in the emulator and of course removing unnecessary spaces after PRINT, and before TO and before THEN, it comes out to 98 bytes. Which gives it third place in CPC BASIC, not first.
Thanks for this hint. Measuring the size is in the responsibility of each participant. For many systems, I even don't know how to measure them, so it depends on communities like this one to regulate it a little bit. And of course the rules are not extra strict, as it should be mainly about the fun with coding.
The entry supplied by Azicuetano in this case is inadequate. It lacks a .dsk or .bin file and the counting is not understandable. I wrote to him. Either the entry has to be corrected or it needs to be disqualified. 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: logiker on 12:17, 05 January 25
Hello!

I found out that getting the file size on the Amstrad is very tricky, because the main binary format used for emulation is dsk and tools (especially the cat command in BASIC) mostly don't show the filesize. It's not really important for the challenge, because the filesize usually is higher than the size of the source code (typed characters). But still, I want to add one thing or the other.

Quote from: lightforce6128 on 01:49, 17 December 24
  • Edit the source code with an editor / on an OS where the size in bytes is printed out.
  • Store it on disc and look into the header.
  • Use FRE(0) before and after writing the program.
  • Use this: ?PEEK(&AE66)+256*PEEK(&AE67)-PEEK(&AE64)-256*PEEK(&AE65)
  • Something that is simpler to use and that I do not know.
Thanks for this list. Let me add what I found out:


And here once more in short as checklist to get the file size:


I hope this helps.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Longshot on 13:52, 05 January 25
Quote from: Prodatron on 16:58, 30 December 24Shit, we didn't know about RST #10, that it can be used to call the Basic routine as well.
Who said that Z80A coding is not art? ;)

It is brilliantly done, this waltz of the CF bit with E and C which is common to the lines and columns, and which allows to index the charset. :o

It is also very clever to have reused the display function for the gift bow and the common Cr+Lf.

Quote from: logiker on 16:09, 01 January 25For many systems, I even don't know how to measure them, so it depends on communities like this one to regulate it a little bit
And imagine the calculation if a participant presents a cat'art, or it would be enough just to do a CAT of the DSK to display the object. :-\
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 23:31, 05 January 25
Quote from: Longshot on 13:52, 05 January 25Who said that Z80A coding is not art? ;)
It is brilliantly done, this waltz of the CF bit with E and C which is common to the lines and columns, and which allows to index the charset. :o
It is also very clever to have reused the display function for the gift bow and the common Cr+Lf.
Thank you @Longshot for your very kind words!
Your winning approach and the others are so fascinating to me, Z80 Asm and this challenge are always just crazy, I love it.
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: logiker on 10:05, 06 January 25
The size of Azicuetano's entry is now corrected. He forgot to count 6 spaces at the end of the first line as well as a new line.

Some entries might have a slightly wrong size measurement as far as Locomotive BASIC is concerned. See my post above. Still, here are the CPC specific results.

Assembler

01 Christmas Present (Amstrad CPC 6128/Z80 Assembler) by Longshot / Logon System.......41
02 Christmas Present (Amstrad CPC/Z80 Assembler) by Overflow...........................42
03 Christmas Present (Amstrad CPC/Z80 Assembler) by lightforce6128.....................43
04 Christmas Present (Amstrad CPC 6128/Z80 Assembler) by SymbiosiS.....................46
05 Christmas Present (Amstrad CPC/Z80 Assembler) by Arnolde of Leosoft.................51
06 Christmas Present (Amstrad CPC 6128/MAXAM Z80 Assem..) by TFM of FutureSoft.........52
07 Christmas Present (Amstrad CPC 6128/Z80 Assembler) by Prodatron.....................54
08 Christmas Present (Amstrad CPC/Z80 Assembler) by Gallegux...........................62
09 Christmas Present (Amstrad CPC/Z80 Assembler) by Retropoke..........................63
10 Christmas Present (Amstrad CPC/Z80 Assembler) by issalig............................85
11 Christmas Present (Amstrad CPC/CP/M 8080 Assembler) by DrSnuggles..................110
11 Christmas Present (Amstrad CPC/Z80 Assembler) by DrSnuggles........................110


BASIC

01 Christmas Present (Amstrad CPC/Locomotive BASIC) by Logiker.........................90
02 Christmas Present (Amstrad CPC/Locomotive BASIC) by Azicuetano......................93
03 Christmas Present (Amstrad CPC/Locomotive BASIC) by Arnolde of Leosoft..............97
04 Christmas Present (Amstrad CPC/Locomotive BASIC) by lightforce6128.................114
05 Christmas Present (Amstrad CPC/Locomotive BASIC) by issalig........................115
06 Christmas Present (Amstrad CPC/Locomotive BASIC) by DrSnuggles.....................127
07 Christmas Present (Amstrad CPC/Locomotive BASIC) by Zima...........................128
08 Christmas Present (Amstrad CPC/Locomotive BASIC) by Retropoke......................131
09 Christmas Present (Amstrad CPC/Locomotive BASIC) by zombieprozess..................203
10 Christmas Present (Amstrad CPC/Locomotive BASIC) by Pararaum/T7D...................407

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: BSC on 20:40, 06 January 25
Quote from: Longshot on 13:52, 05 January 25It is brilliantly done, this waltz of the CF bit with E and C which is common to the lines and columns, and which allows to index the charset. :o

It is also very clever to have reused the display function for the gift bow and the common Cr+Lf.
The waltzing CF was one of the first ideas I had, way before Prodatron and I decided to merge our approaches.
But apparently going solo is much more fruitful and also supports an appropriate share (or rather no need for it) of credit, so that's what I am going to do next time. 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Overflow on 20:27, 10 January 25
38  :D

Back to business - I've been seriously busy since Xmas.

Thanks to lightforce6128's trick about rst#10, we are now down to 38 bytes : I used his rst call within my own code.

Note : source code for Winape, assemble and CALL &901 from Basic.

(about:invalid)

    org #2100; call #0901=de
loop_y  ld hl,#2121 - 2
        rst #10
        dw #c38b   
        ld l,h
        inc (hl); (#2121) counts -Y
        ret z
        dec e
        jr nz,jr_Y
            ld e,d; =9
            ld hl,#2B2D; "+-"
jr_Y equ $ -1; #2B == dec hl           
        ld bc,#100 +19; b counts X
loop_X      ld a,l
            djnz jr_X
                ld b,d; =9
                ld a,h
jr_X        call #BB5A
            dec c
            jr nz,loop_X
    db #C3; jp #091F=loop_Y
    db #1F,#09; locate 9,n n=<0
    db -20; counts -Y at org #2121
    db #CD,"o",#CC; knot
    db #0D; start of line
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Prodatron on 20:42, 10 January 25
:o :o Can't believe this... Crazy! :)
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Longshot on 15:57, 16 April 25
Overflow has just published an article about the coding tips used in its crazy 38-bytes version:

https://overflowlogonsystem.wixsite.com/amstradcpc/post/xmas-gift-vc-2024-coding-tips

[ Also translated in french here :
https://thecheshirec.at/2025/04/16/xmas-gift-vc%c2%b3-2024-coding-tips ]

Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: Overflow on 09:00, 17 April 25
Quote from: Longshot on 15:57, 16 April 25Overflow has just published (...)
Thanks for posting the news here. Thanks also for translation. If you have any question, this is the place to post.

And now I'm eager to reach Xmas time to see what Logiker finds this year. Who knows ? maybe it will include some animated chars !? 
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: logiker on 16:28, 18 April 25
The submissions for VCCC-2024 post-entries are officially open now 🐰🥚. They will stay active until All Saints' Day (November 1st) 😇.

You can hand in your submission here: https://logiker.com/compo/vccc2024post/upload.html
Title: Re: The Vintage Computing Christmas Challenge 2024
Post by: krusty_benediction on 21:41, 20 April 25
Hi !
I initially used the RST #10 : DW #C38B  stuff on the 4k we just released https://www.pouet.net/prod.php?which=103970.
It worked like a charm until using a machine with unidos, but if I have well understood the issue generalize to machines having additional roms.

The workaround is to use an additional indirection
rst #18 : dw rst_18_params
...
rst_18_params
    DW #C38B
    db 0


As I discovered that when I was supposed to create the pouet page, I have not investigated to find better workarounds. Hopefully we had these 3 spare bytes
Powered by SMFPacks Menu Editor Mod