<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 07 Dec 2004 08:39:14 +0000
From   : jgh@... (Jonathan Graham Harston)
Subject: Re: mode switching

"JAMES WATSON" <james@...> wrote:
> I have a game running in mode 1 and have highscores table running in
> MODE 7. MODE 1 is slightly smaller missing the bottom 2 character rows
> to accommodate the screen memory for MODE 7.
 
I take it from this that you also don't want to clear the MODE 7 screen
either.
 
> How can I switch between MODE 1 and MODE 7 without clearing the screen
> memory in MODE 1?
 
You need to program the CRTC (Cathode Ray Tube Controller) and the VIDPROC
(video processor). You will only be able to use the VDU to write to screen
in one of the MODEs. It is easier to POKE messages to a MODE 7 screen, so
use real MODE 1 and a fake MODE 7.
 
The following program demonstates using &3000-&7BFF to hold MODE 1
contents and &7C00-&7FFF to hold MODE 7 contents without clearing either
of them.
 
REM > ModeSwitch
MODE1:PROCMode1            :REM Initialise into MODE 1
PRINT "MODE 1"             :REM Use VDU to write to MODE 1 screen
$&7C00="MODE 7":?&7C06=32  :REM Poke a message into MODE 7 screen
REPEATA$=GET$
IFA$="1":PROCMode1
IFA$="7":PROCMode7
UNTIL0
END
:
DEFPROCMode1               :REM Program CRTC and VIDPROC for MODE 1
VDU23;0,127;0;0;0          :REM 128 character units per line
VDU23;1,80;0;0;0           :REM 80 displayed character units
VDU23;2,98;0;0;0           :REM Display horizontal offset
VDU23;3,&28;0;0;0
VDU23;4,38;0;0;0
VDU23;5,0;0;0;0
VDU23;6,30;0;0;0           :REM Hide MODE 7 in bottom 2 lines
VDU23;7,34;0;0;0
VDU23;8,&01;0;0;0
VDU23;9,7;0;0;0
VDU23;10,&67;0;0;0
VDU23;11,8;0;0;0
VDU23;12,&30 DIV 8;0;0;0   :REM Display starts at &3000
VDU23;13,&00;0;0;0
VDU23;14,&30 DIV 8;0;0;0   :REM Display cursor at &3000
VDU23;15,&00;0;0;0
*FX154,216
ENDPROC                    :REM Set VIDPROC for MODE 1
:
DEFPROCMode7               :REM Program CRTC and VIDPROC for MODE 7
VDU23;0,63;0;0;0           :REM 64 characters units per line
VDU23;1,40;0;0;0           :REM 40 displayed character units
VDU23;2,53;0;0;0           :REM Display horizontal offset
VDU23;3,&24;0;0;0
VDU23;4,30;0;0;0
VDU23;5,2;0;0;0
VDU23;6,25;0;0;0           :REM 25 displayed character lines
VDU23;7,27;0;0;0
VDU23;8,&93;0;0;0
VDU23;9,18;0;0;0
VDU23;10,&32;0;0;0
VDU23;11,19;0;0;0
VDU23;12,(&7C-&74)EOR&20;0;0;0 :REM Display starts at &7C00
VDU23;13,&00;0;0;0
VDU23;14,(&7C-&74)EOR&20;0;0;0 :REM Display cursor at &7C00
VDU23;15,&00;0;0;0
*FX154,75
ENDPROC                    :REM Set VIDPROC for MODE 7
 
If you are writing in machine code and know your program owns the hardware
and is running in the I/O processor, it is more efficient to write the
data directly to the controllers:
 
.ModeSetup                          :\ On entry, X=table offset
LDY #0                              :\ Start at register 0
.MSLoop
LDA ModeTable,X:STY &FE00:STA &FE01 :\ Program CRTC
INX:INY:CPY #16:BNE MSLoop          :\ Write 16 registers
LDA ModeTable,X:STA &FE20           :\ Write VIDPROC value
RTS
:
.ModeTable
.ModeTable1
EQUB 127:EQUB 80:EQUB 98 :EQUB &28
EQUB 38 :EQUB 0 :EQUB 30 :EQUB 34
EQUB &01:EQUB 7 :EQUB &67:EQUB 8
EQUB &30 DIV 8  :EQUB &00
EQUB &30 DIV 8  :EQUB &00
EQUB 216
.ModeTable7
EQUB 63 :EQUB 40:EQUB 53 :EQUB &24
EQUB 30 :EQUB 2 :EQUB 25 :EQUB 27
EQUB &93:EQUB 18:EQUB &32:EQUB 19
EQUB (&7C-&74)EOR&20:EQUB &00
EQUB (&7C-&74)EOR&20:EQUB &00
EQUB 75
 
Then you select the display with:
 
LDX #ModeTable1-ModeTable:JSR ModeSelect :\ Display in MODE 1
 
LDX #ModeTable7-ModeTable:JSR ModeSelect :\ Display in MODE 7
 
 
-- 
J.G.Harston - jgh@...                - mdfs.net/User/JGH
Badly formed email is deleted unseen as spam
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>