Discussion Forum for all things Microbee
Colours on a Microbee - Printable Version

+- Discussion Forum for all things Microbee (https://microbeetechnology.com.au/forum)
+-- Forum: Microbee Forum (https://microbeetechnology.com.au/forum/forum-1.html)
+--- Forum: Microbee Software and Documentation (https://microbeetechnology.com.au/forum/forum-7.html)
+--- Thread: Colours on a Microbee (/thread-486.html)



Colours on a Microbee - Under4Mhz - 09-05-2022

How do I set the set the colour attribute table on a colour Microbee?

I'd like to support colours in my game where it's supported in the hardware.


RE: Colours on a Microbee - MbeeTech - 09-05-2022

(09-05-2022, 08:26 PM)Under4Mhz Wrote: How do I set the set the colour attribute table on a colour Microbee?

I'd like to support colours in my game where it's supported in the hardware.

Colour in the Microbee is set per character cell on the screen.  You can set the foreground and background colours separately.
The colour ram sits in the same memory space as the Programmable Character Generator (PCG) ram at 0F800h->0FFFFh and can 
be accessed by switching the Colour ram in and out (replacing the PCG ram in memory space).

To do this, I/O port 08h bit 6 controls the colour ram switching.

Set bit 6 to switch colour ram into memory at 0F800h -> 0FFFFh (2k)

Reset bit 6 to switch the PCG ram back into memory at 0F800h -> 0FFFFh.

Use the same offset from the start of the ram block as you would for writing a character to the screen ram
IE:  If you write a 'T' to 16 characters across on the first line of the screen, and then want to colour the 'T'
blue, you would write the value for blue at offset 16 from the start of colour ram (0F800h) = 0F810h

This is only a brief overview of course.  The best thing to do would be to download the Microbee Technical manual
from the repository and read up on the hardware.  Note that the original colour scheme and the Premium series
colour scheme are different, but are accessed in the same way.


RE: Colours on a Microbee - Under4Mhz - 11-05-2022

I've written a test program for colours. I set the colour value from 0 to 255.

In summary:

- mbee 256TC is using 4 bit colour
- mbee 128K is using 5 bit colour
- mbee Premium Plus isn't setting colours.

Why isn't the premium plus colours being set? Is it using some other method to access the colour table?
Should I use the 256TC or 128K colours?
How do I set the 256TC to 64 column mode?


RE: Colours on a Microbee - MbeeTech - 11-05-2022

(11-05-2022, 12:21 PM)Under4Mhz Wrote: I've written a test program for colours. I set the colour value from 0 to 255.

In summary:

- mbee 256TC is using 4 bit colour
- mbee 128K is using 5 bit colour
- mbee Premium Plus isn't setting colours.

Why isn't the premium plus colours being set? Is it using some other method to access the colour table?
Should I use the 256TC or 128K colours?
How do I set the 256TC to 64 column mode?

I've never used Mame, so I can't comment on the Premium Plus implementation properly, but it should be just the same as the 256TC output.
Same Screen / colour / PCG arrangement. The Premium Series and 256TC are the same in this regard and programmed exactly the same.
The Premium Plus is a regular Premium Baseboard (where all the screen stuff is) with a new coreboard ( to do mainly the SDcard Floppy emulation).
I don't know why someone (not referring to our member 'someone') would create a mame emulation specific to the Premium Plus unless they
are going to emulate the Coldfire second processor as well - without that, it's a regular Premium Series machine.

The screen  shot of the Premium Plus output seems to be the Boot menu screen colour positioning, with garbage / unwritten screen ram contents.


RE: Colours on a Microbee - someone - 11-05-2022

1. Ensure that you are using port 0x08 as the COLOUR PORT.
2. When using the Alpha Plus (Premium Series) and later models, ensure that the APLUS VIDOPTS PORT (port 0x1C) is set correctly.
It's best to learn with the APLUS VIDOPTS PORT disabled with a value of 0x00.
If it's turned on, then video attributes and video memory bank select are in effect so they too must be correctly populated/configured.

The microbee went through 2 colour design iterations:
The first used a 2 bits per colour regime on the output connector with the background colour intensity set via bits 1:3 of the COLOUR PORT.
Allocation of the colour RAM is split [7:5]=Backgnd,  [4:0]=Foregnd (i.e. only 32 colours fore gnd available & 8 colours for backgnd with global intensity control)
The COLOUR PORT address as both 0x08 & 0x18.

The second used by the Alpha Plus (Premium Series) and later used 4 bits per colour to confirm with the IBM CGA (i.e. 16 colours for both foregnd and backgnd).
Allocation of the colour is assigned by NYBBLE - Backgnd = MSN,  Foregnd = LSN.
The COLOUR PORT address is only 0x08.

Both use bit 6 of the COLOUR PORT to switch in the COLOUR RAM into the memory map.

This is how things can look when properly configured and working.
Beware of the horrible music!



RE: Colours on a Microbee - Under4Mhz - 12-05-2022

How do I set the 256TC into 64 column mode?


RE: Colours on a Microbee - someone - 13-05-2022

(12-05-2022, 06:03 PM)Under4Mhz Wrote: How do I set the 256TC into 64 column mode?
Identically to any other microbee - by reprogramming the CRTC.
The best place to grab the default CRTC register values is from the MWB ROMs.
The standard initialisation routine configures 16 registers.
Also note that the 13.5MHz dot clock microbees use some different values than the 12MHz ones.


RE: Colours on a Microbee - MbeeTech - 14-05-2022

(12-05-2022, 06:03 PM)Under4Mhz Wrote: How do I set the 256TC into 64 column mode?
Here's a code snippet to set 64 x 16 screen mode :

Code:
crtc    equ    0ch    ;6545 control port
crtd    equ    0dh    ;6545 data port


;set up the 64*16 screen format
init64:
    ld    hl,d6545
    ld    b,16
lp6545:    
        ld    a,b
    dec    a
    out    (crtc),a
    ld    a,(hl)
    out    (crtd),a
    dec    hl
    djnz    lp6545
    ret

;--------------------------------------------------------------------------
;6545 (Video Driver Chip) DATA (data to set the 6545 to 64*16 screen format
;--------------------------------------------------------------------------
    db    108-1    ;horizontal sync timing constant
    db    64            ;number of displayed characters per line
    db    81            ;horizontal sync position
    db    55            ;horizontal and vertical sync width
    db    19-1            ;vertical sync width
    db    09            ;vertical sync timing constant
    db    16            ;number of displayed rows per screen
    db    17            ;vertical sync position
    db    72            ;mode control constant
    db    16-1            ;number of scan lines per character
    db    20h+15    ;cursor mode and start line
    db    15            ;cursor end line
    dw    0            ;display start address relative to 0F000h
    db    0            ;cursor position
d6545:    
        db    0



RE: Colours on a Microbee - Under4Mhz - 15-05-2022

Thanks for the information. Since I'm using sdcc,I updated it to use C:

Code:
enum {
    crtStatusVSync = 5,                // Video is in vsync
    crtStatusLightPen,                 // Keyboard hit
    crtStatusUpdateReady,              // Wrote to reg 31
};

#define VDU_VSYNC_MASK ( 1 << crtStatusVSync )

static volatile __sfr __at 0x0C CrtRegPort;
static volatile __sfr __at 0x0D CrtDataPort;
static volatile __sfr __at 0x08 VduBankPort;

// from the R6545 crt display controller manual
enum {

    crtHorizontalTotalChars = 0,
    crtHorizontalDisplayedChars = 1,
    crtHorizontalSyncPosition = 2,

    crtHorizontalVerticalSyncWidths = 3,

    crtVerticalTotalRows = 4,
    crtVerticalTotalLineAdjust = 5,
    crtVerticalDisplayedRows = 6,
    crtVerticalSyncPosition = 7,
    crtModeControl = 8,
    crtRowScanLines = 9,

    crtCursorPositionHigh = 14,
    crtCursorPositionLow,
};

///< Setup crt to 64x16 tiles and hide the cursor
void vdu_crt_setup() {

    // Cursor off screen
    CrtRegPort = crtCursorPositionHigh;
    CrtDataPort = 0xff;
    CrtRegPort = crtCursorPositionLow;
    CrtDataPort = 0xff;

    CrtRegPort = crtHorizontalDisplayedChars; // Columns on screen
    CrtDataPort = 64;
    CrtRegPort = crtVerticalDisplayedRows;    // Rows on screen
    CrtDataPort = 16;
    CrtRegPort = crtRowScanLines;             // Rows per character - cuts of the bottom of tiles
    CrtDataPort = 15;                         // Rows - 1
}

///< Switch in vdu PCG or colour data at 0xF8000
void vdu_bank( bool colour ) __fastcall {

    VduBankPort = colour ? 0x47 : 0x07;
}

///< Wait for full vblank cycle, so 1/50th of a second has passed (for timing)
void vdu_wait() {

    #define VDU_STATUS_PORT 0x0C
    #define VDU_VSYNC_BIT 5

    __asm

crt_poll:
        in      a,(#VDU_STATUS_PORT)
        bit    #VDU_VSYNC_BIT,a
        jp      z, crt_poll

crt_poll_end:
        in      a,(#VDU_STATUS_PORT)
        bit    #VDU_VSYNC_BIT,a
        jp      nz, crt_poll_end

    __endasm;

}



RE: Colours on a Microbee - MbeeTech - 16-05-2022

(15-05-2022, 11:36 AM)Under4Mhz Wrote: Thanks for the information. Since I'm using sdcc,I updated it to use C:

Just looking at your code, I see you are only setting a few registers for displayed characters wide x high.
I would recommend setting all of the registers in the table previously provided so that you are not relying on
the previous screen mode having the correct sync width, display start address etc.

Also, you can actually turn off the cursor without putting into an off screen area. I'm not sure what putting it into an off screen
address would do to be honest. If you set bit 5 of the cursor start scan line register (R10) this turns off the cursor.