[MSX] Back to screen 0

Post Reply
bradstallion
Member
Posts: 32
Joined: Wed Mar 13, 2024 12:52 pm

[MSX] Back to screen 0

Post by bradstallion »

Hi,
sorry in advance for this newbie question.
I would like to jump to screen 2, do stuff, and then go back to screen 0:

Code: Select all

#include <msx.h>
#include <stdlib.h>
#include <stdio.h>

void main() {
  clg();
  vdp_set_mode(mode_2);

  while (!getk()) {
  }

  vdp_set_mode(mode_0);
}
compiled with

Code: Select all

zcc +msx -subtype=msxdos2  test.c -o test.com
The problem is that when the code goes back to MSXDOS2, the colors are changed and characters have some column missing.
Can you help? How can I restore the mode 0 as it was before running the code?
Thanks
User avatar
dom
Well known member
Posts: 2269
Joined: Sun Jul 15, 2007 10:01 pm

Re: [MSX] Back to screen 0

Post by dom »

This is probably the easiest way to do it - just do an interslot call to reset back to SCREEN 0.

Code: Select all

#include <msx.h>
#include <stdlib.h>
#include <stdio.h>

void main() {
  clg();
  vdp_set_mode(mode_2);

  while (!getk()) {
  }

#asm
CALSLT:      EQU    $001C
EXPTBL:      EQU    $FCC1

             ld     iy,(EXPTBL-1)       ;BIOS slot in iyh
             ld     ix,$006C            ;initxt
             call   CALSLT              ;interslot call
#endasm
}
bradstallion
Member
Posts: 32
Joined: Wed Mar 13, 2024 12:52 pm

Re: [MSX] Back to screen 0

Post by bradstallion »

Great! Thanks dom!
Post Reply