Page 1 of 1

Question about lesson S2 - Easy Sprites on the ZX Spectrum

Posted: Wed Jun 29, 2022 8:08 pm
by dlsa
Hello,

I am following the lesson and at the beginning on the routine labelled as 'GetScreenPos' I don't understand up to the 'ld e,a' statement. What is being done ?

Thanks,
Regards

Re: Question about lesson S2 - Easy Sprites on the ZX Spectrum

Posted: Wed Jun 29, 2022 9:19 pm
by akuyou
Can I ask if you've learned Z80 at this stage?
These tutorials assume you already understand Z80 before you try to get graphics on the screen.

You can see the documentation for this lesson here:
https://www.chibiakumas.com/z80/simples ... p#LessonS2

Unfortunately the screen co-ordinates on the ZX spectrum are not particular 'logically organized'... so various bits of the current line number need different multiplications performed on them and added to the final result - that's what's being done in that subroutine

Re: Question about lesson S2 - Easy Sprites on the ZX Spectrum

Posted: Thu Jun 30, 2022 6:29 pm
by dlsa
Hello,

I know a little assembler for the Z80. My question comes from looking at the GetScreenPos routine.
I just don't get why the value %00111000 you are anding to the c value in the a register.
Sure this is probably related to the way the screen is layed out , but t I don't understand why that value.

Thanks,
Regards

Re: Question about lesson S2 - Easy Sprites on the ZX Spectrum

Posted: Thu Jun 30, 2022 8:56 pm
by akuyou
As you said, that's simply how the screen memory of the spectrum is organized. To my knowledge there's no simpler way of calculating a VRAM position on the speccy.

Try writing a routine that slowly fills the spectrum screen one byte at a time, and you'll see how the areas of the screen are organized in memory.