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

Anything QL Software or Programming Related.
User avatar
grafvonb
ROM Dongle
Posts: 35
Joined: Sat Jan 05, 2019 7:54 am
Location: Frankfurt/Germany

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

Postby grafvonb » Tue Feb 04, 2020 7:10 pm

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
QL Wafer Drive
Posts: 1820
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

Postby tofro » Tue Feb 04, 2020 7:42 pm

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
Aurora
Posts: 905
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

Postby NormanDunbar » Tue Feb 04, 2020 9:37 pm



Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
User avatar
grafvonb
ROM Dongle
Posts: 35
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

Postby grafvonb » Wed Feb 05, 2020 6:06 pm

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...

Who is online

Users browsing this forum: No registered users and 6 guests