# Using expanded CPC Plus palette from BASIC

**URL:** <https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133>\
**Category:** Programming\
**Created:** [August 26, 2026, 2:44pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133 "2026-08-26T14:44:47Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![shad0wfax](https://forum.cpcwiki.eu/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shad0wfax](https://forum.cpcwiki.eu/u/shad0wfax)\
**Post date:** [August 26, 2026, 2:44pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/1 "2026-08-26T14:44:48Z")

</div>

Hi all!

As I’m a new user of this forum and this is my first post, let me introduce myself: My name is David and I’m from Barcelona, Spain. Although I’ve never owned an Amstrad computer (my first computer was a Commodore 64), I experienced the 8 and 16-bit computer boom of the 80s and early 90s and some of my friends had a CPC464 (and one of them a CPC6128).

Recently I’ve become interested in retro-programming in BASIC for vintage 8 bit and 16 bit systems, both for learning and for fun. Some months ago I wrote a simple game called “Mega Chase”, and I’ve been writing versions for different computers such as the Commodore 64, the MSX2+, the Amiga (AGA), the Atari ST/E, the Commodore VIC-20, the Commodore Plus/4, or the Mega65 (not a “vintage” system strictly speaking, though). Now I’m developing a version for the Amstrad CPC “plus” series, to take advantage of the expanded colour palette and the hardware sprites.

I’m facing a problem, though, when trying to use the 4096 colour palette for the main screen (the specific sprite palette works perfectly). When, for instance, I want to change the border colour (address &6420 and &6421 of the ASIC), the original colour is restored immediately, in the next frame. The results are the same even if I use de “DI” instruction to disable interrupts. It does the same both on WinApe (Windows) and in Amspirit (MacOS).

Is there a way to use the expanded palette from BASIC without the “immediate restoration” effect?

Best,

David (shad0wfax)

---

<div class="post-metadata">

**Author:** ![mattl](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/mattl/32/174_2.png) [@mattl](https://forum.cpcwiki.eu/u/mattl)\
**Post date:** [August 26, 2026, 3:21pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/2 "2026-08-26T15:21:31Z")

</div>

I’d be interested to see if you can get that working. Could make for some very interesting projects.

---

<div class="post-metadata">

**Author:** ![Gryzor](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/gryzor/32/7_2.png) [@Gryzor](https://forum.cpcwiki.eu/u/Gryzor)\
**Post date:** [August 26, 2026, 3:30pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/3 "2026-08-26T15:30:25Z")

</div>

Oh, our first new user! Welcome, hope you find some answers here 🙂

---

<div class="post-metadata">

**Author:** ![SagaDS](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/sagads/32/160_2.png) [@SagaDS](https://forum.cpcwiki.eu/u/SagaDS)\
**Post date:** [August 26, 2026, 4:05pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/4 "2026-08-26T16:05:48Z")

</div>

We have this kind of issue in ASM when using hardware access (using Hardware registers and colors), the firmware just reset it on each new frame… To correct this, we disable firmware and take full control of the CPC.  
So I am not sure that you can keep a CPC+ color inside a BASIC program because firmware is necessary for BASIC.

If you use FRAME (Basic 1.1) did you try to change it just after (to set it at beginning of each frame)?

---

<div class="post-metadata">

**Author:** ![AndyCadley](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/andycadley/32/177_2.png) [@AndyCadley](https://forum.cpcwiki.eu/u/AndyCadley)\
**Post date:** [August 26, 2026, 5:04pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/5 "2026-08-26T17:04:38Z")

</div>

The problem is the CPC firmware sets up and interrupt routine that changes colours every frame (this is how flashing colours work). You basically have two options:

1. The easy way: Use B-Asic extensions which handle all this for you, as well as giving you a bunch of other useful RSX commands

2. The marginally more difficult way: In AA114, in the Tech tips page, there is a short BASIC listing which handles removing the interrupt handlers for you. Don’t be tempted to follow the advice a few issues earlier, in the article about using the Plus features because it just does it in a nasty ha KY way that slows down keyboard responsiveness and probably messes up all the timers etc.

---

<div class="post-metadata">

**Author:** ![mattl](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/mattl/32/174_2.png) [@mattl](https://forum.cpcwiki.eu/u/mattl)\
**Post date:** [August 26, 2026, 5:25pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/6 "2026-08-26T17:25:04Z")

</div>

![Screenshot 2026-08-26 at 13.24.41](https://forum.cpcwiki.eu/uploads/default/original/1X/c8e1a1b178d38d4ca3cd161f129d404026fb8e9b.jpeg)

Here’s the part @AndyCadley mentioned clipped out.

---

<div class="post-metadata">

**Author:** ![Gryzor](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/gryzor/32/7_2.png) [@Gryzor](https://forum.cpcwiki.eu/u/Gryzor)\
**Post date:** [August 26, 2026, 7:15pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/7 "2026-08-26T19:15:58Z")

</div>

That was a nice letter Rob sent in.

---

<div class="post-metadata">

**Author:** ![AndyCadley](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/andycadley/32/177_2.png) [@AndyCadley](https://forum.cpcwiki.eu/u/AndyCadley)\
**Post date:** [August 26, 2026, 7:40pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/8 "2026-08-26T19:40:10Z")

</div>

Yeah. Although he is incorrect about the need to re-lock the ASIC after changing colours etc, that is completely unnecessary.

---

<div class="post-metadata">

**Author:** ![shad0wfax](https://forum.cpcwiki.eu/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shad0wfax](https://forum.cpcwiki.eu/u/shad0wfax)\
**Post date:** [August 27, 2026, 10:31am UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/9 "2026-08-27T10:31:51Z")

</div>

Thank you very much for all your replies. It’s clear that this is a very active and helpful community 🙂

It’s a pity that Amstrad didn’t provide an updated version of the Basic when releasing the “Plus” series, to take advantage of the ASIC enhancements, as it would have made things a lot easier. I didn’t know about the existence of B-Asic, but anyway I cannot use it as the memory space is already used by some data and the interrupt music routine. Moreover, I want to stick to Basic 1.1 as much as possible as I want to compile the code with ABASC. This means that this time I won’t use the extended palette for the graphics, but only for the sprites, but it’s quite good anyway because I can do effects such as colour cycling and fades.

Thanks again for your help!

---

<div class="post-metadata">

**Author:** ![lightforce6128](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/lightforce6128/32/32_2.png) [@lightforce6128](https://forum.cpcwiki.eu/u/lightforce6128)\
**Post date:** [August 27, 2026, 6:50pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/10 "2026-08-27T18:50:39Z")

</div>

There is a difference between the BASIC command “DI” and the assembler command “DI”. While the former only disables routines registered via “AFTER” or “EVERY”, the latter wil disable all interrupt-driven routines, especially also keyboard polling and music playback. But as long as the firmware routines are running, they will reprogram the colors 50 times per second to allow for flashing colors (in BASIC e.g. with BORDER 1,0). This means: If you change something in the hardware, it will be overwritten in the next frame.

---

<div class="post-metadata">

**Author:** ![lightforce6128](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/lightforce6128/32/32_2.png) [@lightforce6128](https://forum.cpcwiki.eu/u/lightforce6128)\
**Post date:** [August 27, 2026, 6:54pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/11 "2026-08-27T18:54:54Z")

</div>

Another thing: If you blend in the simulated memory page with the ASIC controls, at the same time the regular memory page is blended out. You must make sure that BASIC does not use this big block of memory (with the MEMORY instruction), or bad things will happen (e.g. BASIC will try to interprete and execute the ASIC controls as BASIC program). To reprogram the ASIC securely, I guess a small assembler routine could be helpful.

---

<div class="post-metadata">

**Author:** ![lightforce6128](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/lightforce6128/32/32_2.png) [@lightforce6128](https://forum.cpcwiki.eu/u/lightforce6128)\
**Post date:** [August 27, 2026, 7:47pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/12 "2026-08-27T19:47:32Z")

</div>

I found that the firmware already contains a routine to disable automatic color changes. But it is not part of the jump table, so a small assembler routine is required to call it. It will disable firmware color handling and set all pens to dark blue. Afterwards you need to directly change colors with the GateArray or the ASIC. You need to use the odd hardware color codes instead of the nice ternary numbers used by BASIC and the firmware. Here is a small program doing this. To check that it works, set e.g. BORDER 1,0 before. When the program ends, the flashing stops.

```basic
MODE 2 : BORDER 0,1

10 MEMORY &9FFF ' Protect memory for small assembler routine.
20 POKE &A000,&CF ' RST &10 ;; LO JUMP
30 POKE &A001,&55 ' DEFB &55 ;; low address byte
40 POKE &A002,&0D+&80 ' DEFB &8D ;; high address byte + enable BASIC ROM
50 CALL &A000 ' Call the prepared assembler routine.
60 OUT &7F00,1 ' GateArray: SELECT PEN 1
70 OUT &7F00,&4A ' GateArray: SET INK brightYellow

```

You need to alter line 30 depending on the system. The values are as follows:

- 464 - &4F
- 664 - &51
- 6128 and Plus - &55

It might be possible to achieve the same with another approach, e.g. just disabling the event routine instead of removing it.

* * *

Splitting replies is only allowed up to three consecutive replies. So I have to merge the above with my fourth reply below.

I was interested in how the small program from AA114 works. After disassembling and understanding it, I’m not really convinced: It will work, but it sets up another interrupt routine to fight against the firmware routine (by constantly resetting a counter). I think, disabling the firmware routine is the better way.

```x86asm
NOLIST
ORG #8000

KL_NEW_FRAME_FLY EQU #BCD7
KL_DELETE_FRAME_FLY EQU #BCDD
PRIORITY EQU #81
ROM_CONFIGURATION EQU #FF
BLINK_COUNTER EQU #B7F8

enable_color_change_suppression: ;; ;;
    LD HL,event_block ;; 21 17 80 ;; Set pointer to event data.
    LD BC,PRIORITY*256 + ROM_CONFIGURATION ;; 01 FF 81 ;;
    LD DE,RESET_BLINK_COUNTER ;; 11 12 80 ;; Set pointer to event routine.
    JP KL_NEW_FRAME_FLY ;; C3 D7 BC ;; Install new event routine.

disable_color_change_suppression: ;; ;;
    LD HL,event_block ;; 21 17 80 ;; Set pointer to event data.
    JP KL_DELETE_FRAME_FLY ;; C3 DD BC ;; Uninstall event routine.

reset_blink_counter: ;; ;;
    XOR A ;; AF ;;
    LD (BLINK_COUNTER),A ;; 32 F8 B7 ;; Reset the blink counter.
    RET ;; C9 ;;

event_block: ;; ;; Store event data here.
    ;; DEFW next_event_block ;; ;;
    ;; DEFB counter ;; ;;
    ;; DEFB priority ;; ;;
    ;; DEFW event_routine ;; ;;
    ;; DEFB rom_configuration ;; ;;

```

---

<div class="post-metadata">

**Author:** ![shad0wfax](https://forum.cpcwiki.eu/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shad0wfax](https://forum.cpcwiki.eu/u/shad0wfax)\
**Post date:** [August 28, 2026, 9:08pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/13 "2026-08-28T21:08:17Z")

</div>

Ok, this explains why the “colour restoration” remains despite using the Basic “DI” command. Thanks for the clarification.

---

<div class="post-metadata">

**Author:** ![shad0wfax](https://forum.cpcwiki.eu/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shad0wfax](https://forum.cpcwiki.eu/u/shad0wfax)\
**Post date:** [August 28, 2026, 9:12pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/14 "2026-08-28T21:12:33Z")

</div>

When I need to access the ASIC registers (basically, for sprite positioning and/or sprite palette), I use the following structure: DI:OUT &7F00,&B8:[accessing ASIC registers]:OUT &7F00,&A0:EI. According to your previous message, does that mean that “DI” and “EI” are not necessary?

---

<div class="post-metadata">

**Author:** ![AndyCadley](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/andycadley/32/177_2.png) [@AndyCadley](https://forum.cpcwiki.eu/u/AndyCadley)\
**Post date:** [August 28, 2026, 9:44pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/15 "2026-08-28T21:44:14Z")

</div>

BASIC DI/EI won’t do anything there,they only prevent AFTER and EVERY routines from being executed.

---

<div class="post-metadata">

**Author:** ![shad0wfax](https://forum.cpcwiki.eu/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shad0wfax](https://forum.cpcwiki.eu/u/shad0wfax)\
**Post date:** [August 28, 2026, 10:18pm UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/16 "2026-08-28T22:18:57Z")

</div>

Yes! It works! Thank you very much!

Cheers,

David

---

<div class="post-metadata">

**Author:** ![Gryzor](https://forum.cpcwiki.eu/user_avatar/forum.cpcwiki.eu/gryzor/32/7_2.png) [@Gryzor](https://forum.cpcwiki.eu/u/Gryzor)\
**Post date:** [August 29, 2026, 6:43am UTC](https://forum.cpcwiki.eu/t/using-expanded-cpc-plus-palette-from-basic/133/17 "2026-08-29T06:43:27Z")

</div>

Oh great, syntax highlighting works beautifully, though a bit incomplete!
