Machine code challenge

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia

Re: Machine code challenge

Post by Hikaru » Wed Nov 22, 2017 7:06 pm

Err, you might be looking too much into it. There's basically two loops, the outer one makes the edges, the inner one fills the horizontal lines if the Z flag is set. Before entering the overall loop, we set the Z flag using CP A so the first line is filled horizontally. Next time this happens is at the last line, where Z is set by DEC E when E reaches 0. In between these two it's just putting the edges, and the inner loop does nothing apart from INC HL x 30.

Ast A. Moore wrote:
Wed Nov 22, 2017 6:17 pm
R-Tape wrote:
Wed Nov 22, 2017 4:15 pm
I can see Hikaru's makes a blue box, but I still need to work out how it's doing it...
I commented his code. Hope I didn’t make it sound more complicated than it actually is
Scratch that, now I have no idea what's going on in there myself. Well done! :lol:

krt17 wrote:
Wed Nov 22, 2017 6:57 pm
from Russia with love
Not bad. I knew something was off about that JP P: RET construction. :)
0 x
Inactive account

Posts: 7
Joined: Wed Nov 22, 2017 6:54 pm

Re: Machine code challenge

Post by krt17 » Wed Nov 22, 2017 7:07 pm

and ofc jp p ret equ ret m jr
0 x

User avatar
Manic Miner
Posts: 509
Joined: Mon Nov 13, 2017 11:45 am
Location: Kent, UK

Re: Machine code challenge

Post by MatGubbins » Wed Nov 22, 2017 11:13 pm

I had some trouble getting the asm from krt17 to work properly with EmuZWin, it was due to the 0x before the hex, so they were stripped out and replaced with dec for those of us without a working hex head. The colour variable was moved to the start to allow for different borders to be set by the user. It is a magnificent bit of code, that works the screen backwards (bung some HALTs in there to see it in action) and in less bytes too.

Code: Select all

Frame     LD      C,10 ; colour
        ld      hl,23295

        xor     a
        ld      a,23
        ld      b,30
        ld      (hl), c
        dec     hl
        jr      nz,skip
        ld      (hl), c
skip    dec     hl
        djnz    L1

        ld      (hl), c
        dec     hl
        dec     a
        ret     m
        jr      L2
Asking for snippets of code from forum members shows us that we all write things in a different way, upper/lower case, hex/dec mixtures
The result is that we learn from each other, new ways of improving the code and hopefully squeezing an extra graphic or something into the end game.
Dave, you have 6 extra bytes so far... use them wisely!
0 x
Bomb Munchies Ver1930 17th Nov 2017 (look for the blue download box ) If you get a time-out message and live in the UK then try after 9pm-3am.
Send me a PM and I can email it to you too. Kent, UK

Post Reply