### Author Topic: How convert CPC memory address to screen coordinates  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

#### Arnaud

• Supporter
• 6128 Plus
• Posts: 689
• Country:
• Liked: 613
• Likes Given: 1246
##### How convert CPC memory address to screen coordinates
« on: 20:53, 02 October 16 »
Hello,
i need a little help to convert CPC memory address to PC window screen coordinates.

Ex : 0xC0EB the byte is at (1,16) (i think)

But i wasn't able to create a formula from the table "Video memory starting location for all pixel lines" of CPCTelera documentation.

Thanks

#### ZbyniuR

• 464 Plus
• Posts: 324
• Country:
• 6128 A1230 PSX Win7
• Liked: 348
• Likes Given: 160
##### Re: How convert CPC memory address to screen coordinates
« Reply #1 on: 02:33, 03 October 16 »
After MODE command first byte of first pixel line is start at &c000.
Next pixel line is start 2048 bytes away from start of first line. The same next 6 lines, 2048 bytes away from previous line. But line 9 is start at 80 bytes from first one line. Next one 2048 bytes from line 9 etc. Line 17 start at 160 bytes from line 1.

start line 1 = start address of video memory + 0*80 + 0*2048
start line 2 = start address of video memory + 0*80 + 1*2048
... 3 = ... + 0*80 + 2*2048
... 4 = ... + 0*80 + 3*2048
... 5 = ... + 0*80 + 4*2048
... 6 = ... + 0*80 + 5*2048
... 7 = ... + 0*80 + 6*2048
... 8 = ... + 0*80 + 7*2048

... 9 = ... + 1*80 + 0*2048
... 10 = ... + 1*80 + 1*2048
... 11 = ... + 1*80 + 2*2048
... 12 = ... + 1*80 + 3*2048
... 13 = ... + 1*80 + 4*2048
... 14 = ... + 1*80 + 5*2048
... 15 = ... + 1*80 + 6*2048
... 16 = ... + 1*80 + 7*2048

... 17 = ... + 2*80 + 0*2048
... 18 = ... + 2*80 + 1*2048
... (...)
... 24 = ... + 2*80 + 7*2048

... 25 = ... + 3*80 + 0*2048

(...) (...)
line 200 (last one) = ... + 24*80 + 7*2048

I hope it's will help.
If after MODE screen was scroll, all this is more complicated.
« Last Edit: 02:35, 03 October 16 by ZbyniuR »
In STARS, TREK is better than WARS.

#### Arnaud

• Supporter
• 6128 Plus
• Posts: 689
• Country:
• Liked: 613
• Likes Given: 1246
##### Re: How convert CPC memory address to screen coordinates
« Reply #2 on: 22:16, 03 October 16 »
Finally i understood how works this table.

Thanks for help, my function works now.