Page 2 of 3

Re: Time for a contest? Simplest maze-like printing..

Posted: 13 Nov 2023, 00:07
by lb3361
Phibrizzo wrote: 12 Nov 2023, 20:20 It is shorter but less effective.
You're right! I tried to be too smart when sampling addresses in a single 16 bits quantity.
This new version is almost like your code except for using SYS_Random to shuffle the entropy on each try.
That cost me five bytes to setup. Somehow I save two bytes in the final loop: 79+5-2=82 bytes.
maze3.gt1
(82 Bytes) Downloaded 590 times

Code: Select all

gcl0x
[do
  \SYS_Random_34 _sysFn=
  [do 34!! $f8& \sysArgs4. 160- if>=0loop $7, $78& \sysArgs5. if=0loop]
  1 x= $6; [if<0 $ff x= _sysArgs4 7+ _sysArgs4=]
  \SYS_VDrawBits_134 _sysFn= $3f00 _sysArgs0=
  1 [do \sysArgs2. 1<< b= 134!! _sysArgs4 x+ \sysArgs4. <b, if<>0loop]
loop]
I believe you can save the same two bytes in the final loop my moving the LSLW();ST(line) just before SYS(134). Then you can save four additional bytes by branching to the ST(sysArgs4) in the direction branch, something I cannot do easily in GCL.

Code: Select all

        ...
        LDI  #7
_LAB #4
        ADDW sysArgs4
        ST      sysArg4
; ------ Draw loop ------
_LAB #3
        LD      line
        BEQ     #1
        ST      sysArg2
        LSLW
        ST      line
        SYS     #134                
        LD      sign
        BRA #4

Re: Time for a contest? Simplest maze-like printing..

Posted: 13 Nov 2023, 10:44
by lb3361
Nightly idea using inline assembly in GCL and trashing all memory above $800.
One can still save 5 bytes by giving up on SYS_Random...
maze4.gt1
(68 Bytes) Downloaded 580 times

Code: Select all

gcl0x
[
  \SYS_Random_34 _sysFn=
  [do 34!! $f8& \sysArgs4. $7, $78& \sysArgs5. if=0loop]
  \SYS_VDrawBits_134 _sysFn= $3f01 _sysArgs0= b=
  x 2& 1- x= >x,
  [do _sysArgs4+ \sysArgs4.
      <b, \sysArgs2. #\BCC #\EQ #$fe {inline assembly like PhiBrizzo's code}
      1<< <b. 134!! x loop]
]

Re: Time for a contest? Simplest maze-like printing..

Posted: 13 Nov 2023, 16:03
by Phibrizzo
Yes, I trying Your idea. Works exelent! Now final file have 73 bytes.
Thanks a lot.
But 68 bytes is like masterpiece :-)

Re: Time for a contest? Simplest maze-like printing..

Posted: 13 Nov 2023, 16:56
by petersieg
Nice to see so many participants / entries on this small contest.

;-)

Re: Time for a contest? Simplest maze-like printing..

Posted: 14 Nov 2023, 00:02
by lb3361
Phibrizzo wrote: 13 Nov 2023, 16:03 Yes, I trying Your idea. Works exelent! Now final file have 73 bytes. Thanks a lot.
But 68 bytes is like masterpiece :-)
Every line contains some of your ideas, so the credit must be shared.

Also I think that you can use the same tricks and squeeze your code to 63 bytes (73 - 5 for SYS_Random).
Maybe it is time to think about a different effect.

- L.

Re: Time for a contest? Simplest maze-like printing..

Posted: 14 Nov 2023, 11:11
by petersieg
"Maybe it is time to think about a different effect."

Sure, why not ;-)

Let the demo party begin ;-)

Re: Time for a contest? Simplest maze-like printing..

Posted: 19 Nov 2023, 13:13
by qwertyface
Wow, I'd never realised it was possible to do inline assembly in GCL by using the addresses as byte values. It makes perfect sense, of course. I wish I'd known that sooner!

Re: Time for a contest? Simplest maze-like printing..

Posted: 20 Nov 2023, 00:31
by lb3361
I saw it in MSBASIC.gcl, where Marcel uses it to work around GCL's inability to evaluate constant expressions at compile time.
https://github.com/kervinck/gigatron-ro ... C.gcl#L836

Re: Time for a contest? Simplest maze-like printing..

Posted: 20 Nov 2023, 11:57
by qwertyface
Just when you think you've learned everything you can from Marcel's code :-)

Re: Time for a contest? Simplest chessboard printing..

Posted: 11 Mar 2024, 13:07
by Phibrizzo
I proposes a new competition. Very old, from ZX Spectum forum.

Goal: draw black and white 1x1 pixel chessboard on full screen.

Rules:
- must run on ROMv5+
- 32KB+ machines
- no SYS functions
- all tricks allowed

The winner is: shortest gt1 file.