News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_TCMSLP

Help: Screen ram layout?

Started by TCMSLP, 22:06, 12 November 12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TCMSLP

Hi All,

I've just started taking my first steps in Z80 and thought playing with the video ram would be an excellent way to see the effects of my code.

Having read that the screen memory is not laid out too sanely, I checked The Amstrad CPC Firmware Guide (pages 30-31) for clues.  I think (?) it states that mode 2 is the simplest with each bit mapping to a single (I assumed consecutive) pixel.  Great!

So, I compile this using JavaCPC:-


org &6000

SCR_SET_MODE EQU &BC0E

ld a, 2                       ; mode 2
call SCR_SET_MODE

ld a, $111111            ; byte to write
ld hl, $c000       ; start of screen ram

.loop
ld (hl), a         ; set byte to $11111111
inc hl                      ; increment hl
jp loop


Yes, I realise it loops forever.  I was about to implement a counter to count down from 16384 however it seems everything I try to do results in running out of registers.   

Anyway, run the above and I get stripes.  The CPC Firmware guide doesn't seem to explain this.  Although, it does describe moving down/up a line or right/left a character by incrementing +/- &02 and +/- &50.  When printing one byte with these offsets, this seems to be correct.   However, my $11111111 always results in stripes.

Clearly I'm missing something obvious here.   Can anyone point me in the right direction?

ralferoo

It's just a not very good assembler. It should be warning you that $11111111 is overflowing the A register - it's being truncated to $11, or in binary 00010001. What you want is $FF.

TCMSLP

Argh yes, I shouldn't work on this when tired. I meant to use %11111111. *head desk*

Thanks :)

Devilmarkus

$ is used like &.

You need to use the % sign:

org &6000

SCR_SET_MODE EQU &BC0E

ld a, 2                       ; mode 2
call SCR_SET_MODE

ld a, %111111            ; byte to write
ld hl, $c000       ; start of screen ram

.loop
ld (hl), a         ; set byte to %11111111
inc hl                      ; increment hl
jp loop


Edit: Your answer was faster :P
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Quote from: ralferoo on 23:27, 12 November 12
It's just a not very good assembler. It should be warning you that $11111111 is overflowing the A register - it's being truncated to $11, or in binary 00010001. What you want is $FF.

True... the integrated Z80 assembler in JavaCPC is very basic... But should be ok for the most quick things ;)
As I don't know assembler, it was hard to create an assembler interpreter and compiler...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

ralferoo

Quote from: Devilmarkus on 23:44, 14 November 12
True... the integrated Z80 assembler in JavaCPC is very basic... But should be ok for the most quick things ;)
As I don't know assembler, it was hard to create an assembler interpreter and compiler...
Sorry, I didn't mean to criticise too much and "bad" was probably the wrong word. I just meant that a 32-bit value is never going to fit into an 8-bit register and that's the kind of thing most compilers and more often that not assemblers warn you about...

But don't get me wrong, any kind of embedded assembler in an emulator is massively useful! :)

Devilmarkus

No worries ;)
I know what you wanted to say ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Powered by SMFPacks Menu Editor Mod