Hello everyone,
Is there an MSX2 BIOS routine that restores the MSX1 palette on SCREEN2 or 4 ?
Thanks.
ログイン/登録して投稿
Hello everyone,
Is there an MSX2 BIOS routine that restores the MSX1 palette on SCREEN2 or 4 ?
Thanks.
There is a routine in Sub-Rom BIOS. This routine can be called as below if your program doesn't run under DOS.
SUBROM equ 0015Ch ; Call routine in Sub-ROM INIPLT equ 00141h ; Initialize colors palette call EXPL ret EXPL: push ix ld ix,INIPLT jp SUBROM
or
EXTROM equ 0015Fh ; Call routine in Sub-ROM INIPLT equ 00141h ; Initialize colors palette ld ix,INIPLT call EXTROM ret
Thanks.
Oh, very interesting; I just discovered that INIPLT
doesn't just reset the palette; it first stores the previous VDP palette into VRAM. Then the RSTPLT
routine allows to restore the saved palette from VRAM.
It's handy, but strange to store the palette in VRAM and not in RAM's BIOS working area.
Do we know which address this data is stored at?
There is a risk of overwriting the game data!
This is the kind of discovery that reminds me why it was not a bad idea to make MSXgl BIOS independent. ^^
EDIT: Or is it a translation error!? « initialises the palette (the current palette is saved in VRAM) »
It is possible that the original talked about recording in the VDP and someone translated it as « VRAM »? Or a RAM/VRAM mistmatch?
I couldn't find the Japanese data pack of the MSX2 SubROM, but all English texts on the web use the same sentence.
Since the palette registers are write-only, a copy of the palette is stored in VRAM. Where exactly depends on the screen mode.
See https://www.msx.org/wiki/VDP_Color_Palette_Registers
Afaik INIPLT resets to the default palette, and it resets the mirror in VRAM as well. RSTPLT is equivalent to BASIC's COLOR=RESTORE which you would typically invoke after BLOAD "",S-ing an image that includes the palette data to apply it.
Thanks you for the explanation.
Since the other read-only VDP registers are stored in RAM, I expected the same for the palette.
Given your answer on RSTPLT, I guess the reason to store this info in VRAM was to have all the data contiguous in VRAM for using BASIC bload/bsave functions.
As for me, I wonder why they put two routines to call the sub-Rom routines.
Here's a supplement just in case anyone is interested.
Under MSX-DOS, you can do like in these examples.
By using the Sub-ROM routine:
; Routine to initialize colors palette under MSX-DOS EXBRSA equ 0FAF8h ; Sub-ROM slot number CALLF equ 00030h ; Inter slot call INIPLT equ 00141h ; MSX2 colors palette initialization org 0100h IniColPalDOS: ld ix,INIPLT ; Routine address call CalSUB ; Call routine in sub-ROM ret ; Back to MSX-DOS ; Routine to call a Sub-ROM routine under MSX-DOS ; ; Entry: Routine parameters ; IX = Address of the routine to call into Sub-ROM CalSUB: push af ld a,(EXBRSA) ld (CalSUBslt),a ; Set slot number push ix ex (sp),hl ld a,l ld (CalSUBadrs),a ; Set low byte of the routine address ld a,h ld (CalSUBadr+1),a ; Set high byte of the routine address ex (sp),hl pop ix pop af rst 030h ; Inter slot call CalSUBslt: db 0 ; Slot number CalSUBadrs: dw 0 ; Address ret
By direct access to VDP:
VDP_DW equ 00007h RG16SAV equ 0FFEFh ; Routine to initialize colors palette (MSX2~) ; ; Modify: AF, BC, HL ; Note: Data in VRAM are not initialized IniMSX2palette: ld a,(VDP_DW) ld c,a ; C= Writing port 1 of VDP xor a ; Set color 0 ... di out (c),a ld (RG16SAV),a ld a,80h+16 out (c),a ; ...into register 16 (+80h) ei inc c ; C= Writing port 2 of VDP ld b,31 ld hl,IniPaletteData otir ret ; Back to MSX-DOS IniPaletteData: db 00h,0 ; Color 0 db 00h,0 ; 1 db 11h,6 ; 2 db 33h,6 ; 3 db 17h,1 ; 4 db 27h,3 ; 5 db 51h,1 ; 6 db 27h,6 ; 7 db 71h,1 ; 8 db 73h,3 ; 9 db 61h,6 ; 10 db 64h,0 ; 11 db 11h,4 ; 12 db 65h,2 ; 13 db 55h,5 ; 14 db 77h,7 ; 15
If you replace the data by those below, you will get colors close to those of the MSX1s.
db 00h,0 ; Color 0 db 00h,0 ; 1 db 11h,5 ; 2 db 33h,6 ; 3 db 26h,2 ; 4 db 37h,3 ; 5 db 52h,2 ; 6 db 27h,6 ; 7 db 62h,2 ; 8 db 63h,3 ; 9 db 52h,5 ; 10 db 63h,6 ; 11 db 11h,4 ; 12 db 55h,2 ; 13 db 55h,5 ; 14 db 77h,7 ; 15
Note that the palette of the MSX1 as it shows on screen depends on the exact used VDP type and the video output method (RGB vs CVBS).
For reference, see for instance the discussion here: https://github.com/openMSX/openMSX/issues/1024
Oups, direct access method will not work under DOS without read VDP_DW with the RDSLT (0000Ch) routine. I forgot to replace ld a,(VDP_DW) by:
ld a,(0fcc1h) ld hl,VDP_DW call 000ch
Don't you have an account yet? Become an MSX-friend and register an account!