Understanding video memory and pages

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
kan
Posts: 15
Joined: Mon Sep 21, 2015 6:44 pm
Location: Seville, Spain

Understanding video memory and pages

Post by kan »

Hi,
I think I haven't understood very well how video memory and pages works in a Dragon 32/64.
So far, I understand how to set the highest resolution #4, 256x192 two colors, using machine code:

Code: Select all

       STA   $FFC0   ; [SAM VDG Reg V0]
       STA   $FFC3   ; [SAM VDG Reg V1]
       STA   $FFC5   ; [SAM VDG Reg V2]
And the memory that it needs is 6144 bytes. Which I'm not sure is the next statements, and I hope you can tell me which one are true:
- We have 2 pages in that resolution
- The page #0 starts at $0600 and the page #1 starts at $1E00
- I can use the addresses $FFC6 <-> $FFD3 to choose the page we want to show
- I can write values from $0600 to $1DFF to update page #0
- I can write values from $1E00 to $3600 to update page #1

I'm trying to do an animation using 2 pages, but so far I haven't got it, so there is something I'm wrong.

Thanks for your help!
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: Understanding video memory and pages

Post by tormod »

When using machine code you are not limited to two pages. The SAM has a 7-bit register which (multiplied by 512) defines the start address of the displayed graphics. The graphics mode defines the length of the video memory region.

There are a number of books that explain this well, for instance "Inside the Dragon" or "Anatomy of a Dragon". Also the SAM and 6847 data sheets are worth looking at. For a summary of SAM register locations see http://dragon32.info/info/memmap.txt

I haven't looked at it, but the book "Dragon Machine Language For The Absolute Beginner" is in the archive and has a chapter on graphics.
User avatar
Bosco
Posts: 330
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: Understanding video memory and pages

Post by Bosco »

Hi kan.

There's an article on p15 of Dragon User Nov 1985 that should be of help. :)

http://archive.worldofdragon.org/downlo ... r_1185.pdf
kan
Posts: 15
Joined: Mon Sep 21, 2015 6:44 pm
Location: Seville, Spain

Re: Understanding video memory and pages

Post by kan »

Hi Tormod and Bosco,
I'm reading your references... I think I'm starting to understand the video memory of Dragon 32.
I'll keep you updated on any progress

Thanks!
kan
Posts: 15
Joined: Mon Sep 21, 2015 6:44 pm
Location: Seville, Spain

Re: Understanding video memory and pages

Post by kan »

I finally understood how the video memory works. It's easier when you got it :D
I was confused because when you use the PMODE basic command, you can specify the startpage:

Code: Select all

    PMODE mode,startpage
But, in machine code you don't have any "startpage" but you specify the position of the memory you want to use by the graphics card. This is done thanks to the SAM Display Offset bits F0-F6 which multiplies by 512 ($200) the address used by the graphics card.
For example, you want to use the memory from $0200 to $19FF:

Code: Select all

		STA		$FFC7   ; [SAM Display Offset bit F0] = 1 
So, if the value of SAM Display Offset is $01, then $200*$01 = $200. If the resolution is MODE 4 (256 by 192), the memory needed is 6144 bytes. So, the graphics card will use from $200 to $19FF.
But, if you want to use the memory from $1A00 to $31FF:

Code: Select all

		STA		$FFC7   ; [SAM Display Offset bit F0] = 1 
		STA		$FFCB   ; [SAM Display Offset bit F2] = 1 
		STA		$FFCD   ; [SAM Display Offset bit F3] = 1
The value of SAM Display Offset is $0D, then $200*$0D = $1A00 and the graphics card will use from $1A00 to $31FF.

Thanks for your help!
Post Reply