MC-bitmap data for GRAPHIC3 command

Started by MIRKOSOFT, April 03, 2010, 04:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!


I have some pictures in Hi-Res format (bitmap: $2000-$3F3F / attributes $1C00-$1FE7) for GRAPHIC1 command.
I created also pictures in Multicolor format and there it needs one more color-plan.
For MC mode is bitmap & attributes the same as Hi-Res.
When I use GRAPHIC3 command I'm surprised that color-plan is not from color-RAM ($D800-$DBE7).
On C64 was standard to use color-plan RAM $D800-$DBE7 (Color-RAM), but which location is used for MC-mode on C128?


Thanks for every reply.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

wte

Q:
Quote from: MIRKOSOFT on April 03, 2010, 04:23 AMwhich location is used for MC-mode on C128?

A:
The C128 uses RAM $D800-$DBE7 (Color-RAM)!
This RAM area is available twice ;)

Regards WTE

Hydrophilic

Multi-color bitmap mode, on both C64 and C128, use two color planes.  The first is from "video matrix" and the second is from "color RAM".

The video matrix (in bitmap mode) holds two colors.  One color in the high nibble and one color in low nibble.  Note this comes from system RAM.  For C128 example, $1c00 with hi-res or multi-color BASIC bitmap.

In multi-color bitmap, there are 4 colors: background (from VIC register at $d021), color 1, color 2, and color 3.  Colors 1 and 2 come from system RAM / video matrix (like hi-res bitmap described above).  Color 3 comes for "color RAM" at I/O region $d800~$dbff.

In both C64 and C128, "color RAM" is a special chip that is only accessible to CPU when I/O is active (it is always accessible to VIC).  For C64 you need a value like $35 or $37 in address $01; for C128 you need a value like $3e or $00 in address $ff00... if you want to access Color RAM.

Anyway, Color RAM holds bitmap color 3 (or text color).  Normally you would just save $d800~$dbe7, but the C128 has TWO color banks!  Although it is not well-documented, it is an awesome feature of the C128.

Hmmm... how can I explain... maybe an ASCII graph?


VIC
  |
  |
\ /
  V
C0 / C1
  ^
/ \
  |
  |
CPU


In C64 mode, the CPU and VIC always access the same Color RAM (after all, the C64 only has one Color RAM).

In C128 mode you controll which Color RAM is used by the CPU and which one is used by VIC.  Commodore's BASIC does this so nicely that most people don't even realize there are TWO banks of Color RAM.

Anyway in C128 mode, Color RAM access is controled by CPU I/O port $01.  Bit 0 controls access by CPU, while bit 1 controls access by VIC.  On power-up, both bits are set to 1.  So you could call "Color RAM Bank 1" = "Text Color" and you could call "Color RAM Bank 0" = "MC Bitmap Color" (for lack of better name).

Umm, this is getting confusing to me... and I am writining it... let me see if I can simplify...

$01 / bit 0 = 0 (CPU access Color RAM 0 / mc-bitmap)
$01 / bit 0 = 1 (CPU access Color RAM 1 / text)
$01 / bit 1 = 0 (VIC access Color RAM 0 / mc-bitmap)
$01 / bit 1 = 1 (VIC access Color RAM 1 / text)

Normal value of "CPU Register $01" is $73; both CPU and VIC access Color RAM bank 1 / text.

In GRAPHIC 3/4 "CPU Register $01" is $75; the CPU will access Color RAM bank 1 (text) but VIC will access Color RAM bank 0 / mc_bitmap

Anyway, if you want to load/save a multi-color bitmap, you must be sure the CPU will access mc_bitmap Color RAM.  The default IRQ routine will set "register" $01 bit 0 to "1" so normally CPU will only access text Color RAM.  You need to disable IRQ and set "register" $01 bit 0 to "0" if you want to read/write/load/save the MC_Bitmap data at $d800~$dbe7.

I am sorry if this is confusing... Let me give a real-world example... If Hydrophilic wants to save the bitmap Color RAM then I do this:

POKE 216,255:REM DISABLE KERNAL VIC CHANGES
POKE 1,PEEK(1)AND254:REM USE COLOR BANK 0 (MC-BITMAP)
BSAVE "FILENAME", B15, P55296 TO P56296
POKE 216,0:REM ENABLE KERNAL IRQ / VIC TEXT MODE

Notice after BSAVE that I do not POKE 1, x because the KERNAL IRQ will set value automatically after (re)enable with POKE 216,0.  Maybe this is wrong?  But it works for me.

At the moment, I can't think of a better description.  So please ask questions and I will try to clarify this lousy description...
I'm kupo for kupo nuts!