Question about lesson S2 - Easy Sprites on the ZX Spectrum

Posts relating to ZX Spectrum (and clones)... also Spectrum NEXT
Post Reply
dlsa
Posts: 2
Joined: Tue Jun 28, 2022 8:27 pm

Question about lesson S2 - Easy Sprites on the ZX Spectrum

Post by dlsa » Wed Jun 29, 2022 8:08 pm

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

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

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

Post by akuyou » Wed Jun 29, 2022 9:19 pm

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
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

dlsa
Posts: 2
Joined: Tue Jun 28, 2022 8:27 pm

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

Post by dlsa » Thu Jun 30, 2022 6:29 pm

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

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

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

Post by akuyou » Thu Jun 30, 2022 8:56 pm

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.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Post Reply

Return to “ZX Spectrum Assembly Programming”