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

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

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

Post 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 168 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
Attachments
maze3.gcl
(283 Bytes) Downloaded 144 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

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

Post 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 142 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]
]
Attachments
maze4.gcl
(296 Bytes) Downloaded 163 times
Phibrizzo
Posts: 67
Joined: 09 Nov 2022, 22:46

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

Post by Phibrizzo »

Yes, I trying Your idea. Works exelent! Now final file have 73 bytes.
Thanks a lot.
But 68 bytes is like masterpiece :-)
petersieg
Posts: 110
Joined: 28 Jun 2023, 09:06

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

Post by petersieg »

Nice to see so many participants / entries on this small contest.

;-)
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

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

Post 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.
petersieg
Posts: 110
Joined: 28 Jun 2023, 09:06

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

Post by petersieg »

"Maybe it is time to think about a different effect."

Sure, why not ;-)

Let the demo party begin ;-)
qwertyface
Posts: 68
Joined: 16 Jul 2019, 09:19
Location: UK

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

Post 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!
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

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

Post 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
qwertyface
Posts: 68
Joined: 16 Jul 2019, 09:19
Location: UK

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

Post by qwertyface »

Just when you think you've learned everything you can from Marcel's code :-)
Phibrizzo
Posts: 67
Joined: 09 Nov 2022, 22:46

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

Post 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.
Post Reply