Quit a program cleanly

Page 2/4
1 | | 3 | 4

Par DamnedAngel

Master (233)

Portrait de DamnedAngel

03-01-2021, 22:39

What display problem?

Par aoineko

Master (167)

Portrait de aoineko

04-01-2021, 16:12

DamnedAngel wrote:

What display problem?

The Screen Mode still unchanged and even if set back the Screen mode 0 manually, the screen is full of invalid characters (corresponding to the content of the VRAM when I quit I suppose). I tried to clean the VRAM before exiting but if I do so, I got a blank screen.
I supposed I have to set back the VRAM in the stat it was before I launch my game, but I didn't found yet Bios/DOS initialization routines to do that.
Perhaps, it's simply not standard to return to Basic/DOS after changing the whole VRAM. That was my second question: Am I supposed to allow user to return to Basic/DOS after playing my game without having to reboot its MSX?

Par Dolphin101546015

Champion (335)

Portrait de Dolphin101546015

04-01-2021, 16:45

You might restore VRAM data self, you will set screen mode (0 for example), restore VDP tables registers (NT, CT PT), and copy 2kb EEPROM font from address &h1BBF to PT.

Par Grauw

Ascended (10157)

Portrait de Grauw

04-01-2021, 17:03

Just call the TOTEXT BIOS routine. It resets everything to the last used text mode.

Par aoineko

Master (167)

Portrait de aoineko

04-01-2021, 18:36

Grauw wrote:

Just call the TOTEXT BIOS routine. It resets everything to the last used text mode.

Thank you!

(and thank you also for your site which taught me so much!)

Par aoineko

Master (167)

Portrait de aoineko

04-01-2021, 21:31

TOTEXT don't work for me because I don't use Bios to setup VDP in my game library, so I suppose there is no valid "previous screen mode".
That said, under BASIC environnent, a call to INITXT do the job! (I was sure I had already tried it, though)

I still have to find a solution for the MSX-DOS environment.
I tried to do an interslot call to INITXT before calling the DOS routine 05h but I get stuck on a blank screen.

Par Daemos

Paragon (1954)

Portrait de Daemos

04-01-2021, 22:22

If your set video modes by hand don't forget to write your changes to the VDP mirrors as well. If you like to change something on the VDP read the VDP register mirror first. Do your changes and write it back before applying it to the VDP. Like that the BIOS always knows whats going to after you want to call something video related.

ecample code below

           bit7          bit6          bit5          bit4          bit3          bit2          bit1          bit0
;register 1 0             BLK (display) IE0 (Vblank)   M1            M2            0             SZ            MAG
  ld a,(VDP_0+1)
  or %0000'0010
  and %1111'1110
  ;ld    a,%0010'0010
  ld    (VDP_0+1),a
  di
  out   ($99),a         ;/SpriteInitialize:
  ld    a,1+128
  ei
  out   ($99),a

VDP_0: equ $F3DF

Par aoineko

Master (167)

Portrait de aoineko

04-01-2021, 23:05

I don't touch the Bios work area in RAM at all. In the Basic environment, the INITXT function works well and allows me to return to Basic without any problem.
For the DOS version, the only difference is that I have to go through an inter-slot call to INITXT since Page 0 is on the RAM Slot and not on Main-ROM.
But that doesn't explain why the MSX freezes during this function (it seems stuck in a loop around 6600h ; into MSXDOS2.SYS?).
If I don't call INITXT before exiting, I am back on DOS (even if visually, I only see buggy pixels on the screen) and e.g. if I type MODE 40, the display returns to normal.
I would have to find the code in Main-ROM or in the DOS system that handles MODE 40 and do the same thing in my program.

Par aoineko

Master (167)

Portrait de aoineko

04-01-2021, 23:20

Just to confirm, the DOS display is correct after running my program if I launch it from a batch file with a MODE 40 after my program.
I searched in the MSX-DOS doc if there was an equivalent of MODE 40 in the list of functions that can be called via call 5h, but I couldn't find anything.

Par Grauw

Ascended (10157)

Portrait de Grauw

04-01-2021, 23:39

TOTEXT will work if you write the value 5 to SCRMOD (0FCAFH) in system memory when you enable screen 5. Or, alternatively, initially switch to screen 5 using CHGMOD in your program.

Benefit of TOTEXT is that it respects the original screen mode, which is screen 1 on Japanese MSX computers, not screen 0.

Interslot call to BIOS should not crash in DOS (and is the proper way). What is the code you used?

    ld iy,(EXPTBL - 1)
    ld ix,TOTEXT
    call CALSLT
Page 2/4
1 | | 3 | 4