Changing color mode using Display Color Register $18063 does not work as expected

Anything QL Software or Programming Related.
Post Reply
User avatar
grafvonb
Bent Pin Expansion Port
Posts: 80
Joined: Sat Jan 05, 2019 7:54 am
Location: Frankfurt/Germany

Changing color mode using Display Color Register $18063 does not work as expected

Post by grafvonb »

When I run this code I expect the QL to change from 4 to 8 color mode. However it does not work.
If I run "mode 4" before and run the binary the screen background turns to magenta and fonts are corrupt (with blue lines or similar).

Code: Select all

move.b  #%00001000,$18063       ;turn on 8 color mode
The other way (from 8 to 4 color mode by switching 3rd bit to zero, delivers similar result).
What is wrong with this snippet? I even tried to switch off interrupts but without effect.

(I use vasm as compiler on Windows and run the binary on real QL with Minerva (QemuLator behaves same))


Loving QL & ZX Spectrum & Amiga...
User avatar
tofro
Font of All Knowledge
Posts: 2699
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Changing color mode using Display Color Register $18063 does not work as expected

Post by tofro »

grafvonb wrote:When I run this code I expect the QL to change from 4 to 8 color mode. However it does not work.
If I run "mode 4" before and run the binary the screen background turns to magenta and fonts are corrupt (with blue lines or similar).

Code: Select all

move.b  #%00001000,$18063       ;turn on 8 color mode
The other way (from 8 to 4 color mode by switching 3rd bit to zero, delivers similar result).
What is wrong with this snippet? I even tried to switch off interrupts but without effect.

(I use vasm as compiler on Windows and run the binary on real QL with Minerva (QemuLator behaves same))
What you're doing is setting the hardware to 8-colour-mode (seen by the blue and magenta colours which are not available in four-colour-mode) but not telling the operating system. That's why it's thinking you're still using 4 colours and messes up the screen and fonts.

The proper way to do that is to use the MT.DMODE (see the QL Technical guide) trap which switches both the software and the hardware between modes.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
NormanDunbar
Forum Moderator
Posts: 2271
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Changing color mode using Display Color Register $18063 does not work as expected

Post by NormanDunbar »



Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
grafvonb
Bent Pin Expansion Port
Posts: 80
Joined: Sat Jan 05, 2019 7:54 am
Location: Frankfurt/Germany

Re: Changing color mode using Display Color Register $18063 does not work as expected

Post by grafvonb »

Thank you for the info about this trap. I changed the code to set 8 colors mode to the following and it works as expected!

Code: Select all

   moveq    #$10,d0              ;MT.DMODE Set or read the display mode
   moveq    #$8,d1               ;d1.b key, 1:read mode -> d1.b display mode, 0:mode is 4 colour, 8:mode is 8 colour
                                 ;d2.b key, 1:read mode -> d2.b display type, 0:monitor, 1:625-line TV, 2:525-line TV
                                 ;d3,a0,a1,a2,a3-preserved, a4-???
   trap     #1


Loving QL & ZX Spectrum & Amiga...
Post Reply