Difference between revisions of "Paging in video memory"

From BeebWiki
Jump to: navigation, search
(update)
m (See Also)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Programming]]
 
[[Category:Programming]]
 
[[Category:6502]]
 
[[Category:6502]]
The BBC Master, the Aries-B20, the Aries B-32 and the Watford 32 RAM card
+
The BBC Master, the Aries-B20 and B-32, the Integra-B and the Watford 32 RAM
have shadow screen memory. The following code (taken from
+
card have shadow screen memory. The following code (taken from
 
HADFS<ref>[http://mdfs.net/hadfs mdfs.net/hadfs]</ref> and
 
HADFS<ref>[http://mdfs.net/hadfs mdfs.net/hadfs]</ref> and
 
HostFS<ref>[http://mdfs.net/hostfs mdfs.net/hostfs]</ref>) will page in or
 
HostFS<ref>[http://mdfs.net/hostfs mdfs.net/hostfs]</ref>) will page in or
out the video memory transparently using the appropriate OSBYTE call to do so.
+
out the video memory transparently using the appropriate OSBYTE call to do
 +
so.
  
 
   \ Screen selection routines
 
   \ Screen selection routines
 
   \ =========================
 
   \ =========================
   \ On entry, Y=0 - select main memory
+
   \ On entry, A=0 - select main memory
   \          Y=1 - select video memory
+
   \          A=1 - select video memory
 +
  \ On exit,  all registers corrupted
 
   \
 
   \
 
   .vramSelect
 
   .vramSelect
   TYA:PHA:AND #1:PHA:TAX   :\ A=0 main RAM, A=1 video RAM
+
   PHA:TAX                   :\ A=0 main RAM, A=1 video RAM
   LDA #108:JSR OSBYTE     :\ Attempt to select Master video RAM
+
   LDA #108:JSR OSBYTE       :\ Attempt to select Master/Integra-B video RAM
   PLA:INX:BNE vramOk       :\ X<>255, successful
+
   PLA:INX:BNE vramOk       :\ X<>255, successful
   EOR #1:TAX               :\ A=1 main RAM, A=0 video RAM
+
   EOR #1:TAX               :\ A=1 main RAM, A=0 video RAM
   LDA #111:JSR OSBYTE     :\ Attempt to select Aries/Watford RAM
+
   LDA #111:JMP OSBYTE       :\ Attempt to select Aries/Watford video RAM
 
   .vramOk
 
   .vramOk
   PLA:TAY:RTS
+
   RTS
  
 
Using this code, filing system or other code can selectively access main or
 
Using this code, filing system or other code can selectively access main or
Line 27: Line 29:
 
   \ Decide what local memory to transfer data to/from
 
   \ Decide what local memory to transfer data to/from
 
   \ -------------------------------------------------
 
   \ -------------------------------------------------
   \ On entry, DADR+0...DADR+3=data transfer address
+
   \ On entry, DADDR+0...DADDR+3=data transfer address
   \                         A=&Fx - read (load) data
+
   \                           A=&Fx - read (load) data
   \                         A=&Ex - write (save) data
+
   \                           A=&Ex - write (save) data
 
   \
 
   \
   LDX &27A:BPL WaitTransIO    :\ No Tube
+
   LDX &27A:BPL TransIO      :\ No Tube
   LDX DADR+3                   :\ Check transfer address
+
   LDX DADDR+3               :\ Check transfer address &XX------
   INX:BNE WaitTransTube        :\ Tube present, ADDR<&FFxxxxxx
+
   INX:BNE TransTube        :\ Tube present, ADDR<&FFxxxxxx
   .WaitTransIO
+
   .TransIO
   AND #&F0:TAY                :\ Y=transfer flag with b7=1 for IO transfer
+
   AND #&F0:PHA              :\ Push transfer flag, b7=1 for IO transfer
   LDX DADR+2:INX:BEQ WaitIOGo  :\ &FFFFxxxx - current IO memory
+
   LDX DADDR+2               :\ Get address &--XX----
  LDA &D0                      :\ Get VDU status, bit 4=shadow screen
+
  INX:BEQ TransIOGo        :\ &FFFFxxxx - current IO memory
   INX:BEQ WaitIOScreen        :\ &FFFExxxx - use current display memory according to b4
+
   INX:BEQ TransIODisplay    :\ &FFFExxxx - use current display memory
   INX:BNE WaitIOGo             :\ Not &FFFDxxxx - use current IO memory
+
   INX:BEQ TransIOShadow    :\ &FFFDxxxx - shadow memory
   LDA #16                      :\ &FFFDxxxx - shadow screen memory, force b4=1
+
  BNE TransIOGo             :\ Not &FFFDxxxx - use current IO memory
   .WaitIOScreen
+
  :
   AND #16:BEQ WaitIOGo        :\ Non-shadow screen displayed, jump with Y=&E0/&F0
+
  .TransIODisplay
   INY:JSR vramSelect          :\ Set b0 for screen, page in video RAM
+
   LDA #&84:JSR OSBYTE
   .WaitIOGo
+
  TYA:BPL TransIOGo        :\ Not shadow screen displayed
   TYA:PHA                      :\ Save IO and screen selection flags
+
   .TransIOShadow
 +
   LDA #1:JSR vramSelect    :\ Page in shadow memory
 +
   PLA:ORA #1:PHA            :\ Set b0 for screen, page in video RAM
 +
   :
 +
   .TransIOGo
 
   \ At this point, the byte on the stack holds
 
   \ At this point, the byte on the stack holds
 
   \  &E0 - load is to current memory
 
   \  &E0 - load is to current memory
Line 51: Line 57:
 
   \  &F0 - save is from current memory
 
   \  &F0 - save is from current memory
 
   \  &F1 - save is from screen memory
 
   \  &F1 - save is from screen memory
   \ ie b7=1 - IO memory, b0=main/video memory
+
   \ ie b7=1 - IO memory, b4=save/load, b0=main/video memory
 
   \
 
   \
 
   \
 
   \
Line 57: Line 63:
 
   \
 
   \
 
   \
 
   \
   .WaitExitDone
+
   .TransExitDone
   PLA:BPL WaitExitRelease      :\ Pop transfer flag, b0=0 - Tube release
+
   PLA:BPL TransExitRelease  :\ Pop transfer flag, b7=0 - Tube release
   ROR A:BCS WaitExitScreen    :\ b0=1, Screen release
+
   ROR A:BCS TransExitScreen :\ b0=1, Screen release
 
   RTS
 
   RTS
   .WaitExitRelease
+
   .TransExitRelease
   JMP TubeRelChk              :\ Release Tube, return
+
   JMP TubeRelease          :\ Release Tube, return
   .WaitExitScreen
+
   .TransExitScreen
   LDY #0:JMP vramSelect       :\ Page in main memory, return
+
   LDA #0:JMP vramSelect     :\ Page in main memory, return
 
   \
 
   \
   .WaitTransTube
+
   .TransTube
   CLC:ADC #&10:ROL A           :\ Cy=1/0 for load/save
+
   CLC:ADC #&10:ROL A       :\ Cy=1/0 for load/save
   LDA #0:ADC #0:PHA           :\ A=1/0 for load/save
+
   LDA #0:ADC #0:PHA         :\ A=1/0 for load/save
   JSR TubeAction               :\ Claim Tube and start transfer
+
   JSR TubeAction           :\ Claim Tube and start transfer
 
   \ At this point, the byte on the stack holds
 
   \ At this point, the byte on the stack holds
 
   \  &1 - load is to Tube
 
   \  &1 - load is to Tube
Line 79: Line 85:
 
   \
 
   \
 
   \
 
   \
   JMP WaitExitDone            :\ Jump to release Tube
+
   JMP TransExitDone        :\ Jump to release Tube
 +
 
 +
== Electron ==
 +
This is untested at present, but this appears to be the equivalent code for the Electron
 +
\ Electron screen selection routine
 +
\ =================================
 +
\ On entry, A=0 - select main memory
 +
\          A=1 - select video memory
 +
\ On exit,  A corrupted, X,Y preserved
 +
\
 +
  .vramSelect
 +
ROR A                      :\ Move selection in bit 0 to Carry
 +
LDA &027F:BPL vramOk      :\ No shadow RAM present
 +
ROR A:STA &FC7F            :\ Move Carry A to bit 7, set paging flag
 +
.vramOk
 +
RTS
 +
 
 +
==See also==
 +
* [[OSBYTE &6C]] - Select Master/Integra-B shadow memory
 +
* [[OSBYTE &6F]] - Select Aries/Watford shadow memory
 +
* [[OSBYTE &84]] - Read top of user memory
 +
* [[Paging in video memory]]
 +
* [[Extended addressing]]
 +
* http://mdfs.net/Docs/Comp/BBC/Osbyte00
 +
 
 +
----
  
 
== References ==
 
== References ==
Line 85: Line 116:
  
 
[[User:Jgharston|Jgharston]] 22:25, 25 December 2011 (UTC)
 
[[User:Jgharston|Jgharston]] 22:25, 25 December 2011 (UTC)
 +
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 20:38, 3 April 2015 (UTC)

Latest revision as of 19:26, 22 January 2021

The BBC Master, the Aries-B20 and B-32, the Integra-B and the Watford 32 RAM card have shadow screen memory. The following code (taken from HADFS[1] and HostFS[2]) will page in or out the video memory transparently using the appropriate OSBYTE call to do so.

 \ Screen selection routines
 \ =========================
 \ On entry, A=0 - select main memory
 \           A=1 - select video memory
 \ On exit,  all registers corrupted
 \
 .vramSelect
 PHA:TAX                   :\ A=0 main RAM, A=1 video RAM
 LDA #108:JSR OSBYTE       :\ Attempt to select Master/Integra-B video RAM
 PLA:INX:BNE vramOk        :\ X<>255, successful
 EOR #1:TAX                :\ A=1 main RAM, A=0 video RAM
 LDA #111:JMP OSBYTE       :\ Attempt to select Aries/Watford video RAM
 .vramOk
 RTS

Using this code, filing system or other code can selectively access main or video memory according to the standard &FFFFxxxx, &FFFExxxx and &FFFDxxxx address ranges.

 \ Decide what local memory to transfer data to/from
 \ -------------------------------------------------
 \ On entry, DADDR+0...DADDR+3=data transfer address
 \                           A=&Fx - read (load) data
 \                           A=&Ex - write (save) data
 \
 LDX &27A:BPL TransIO      :\ No Tube
 LDX DADDR+3               :\ Check transfer address &XX------
 INX:BNE TransTube         :\ Tube present, ADDR<&FFxxxxxx
 .TransIO
 AND #&F0:PHA              :\ Push transfer flag, b7=1 for IO transfer
 LDX DADDR+2               :\ Get address &--XX----
 INX:BEQ TransIOGo         :\ &FFFFxxxx - current IO memory
 INX:BEQ TransIODisplay    :\ &FFFExxxx - use current display memory
 INX:BEQ TransIOShadow     :\ &FFFDxxxx - shadow memory
 BNE TransIOGo             :\ Not &FFFDxxxx - use current IO memory
 :
 .TransIODisplay
 LDA #&84:JSR OSBYTE
 TYA:BPL TransIOGo         :\ Not shadow screen displayed
 .TransIOShadow
 LDA #1:JSR vramSelect     :\ Page in shadow memory
 PLA:ORA #1:PHA            :\ Set b0 for screen, page in video RAM
 :
 .TransIOGo
 \ At this point, the byte on the stack holds
 \   &E0 - load is to current memory
 \   &E1 - load is to screen memory
 \   &F0 - save is from current memory
 \   &F1 - save is from screen memory
 \ ie b7=1 - IO memory, b4=save/load, b0=main/video memory
 \
 \
 \ Do IO memory transfer here
 \
 \
 .TransExitDone
 PLA:BPL TransExitRelease  :\ Pop transfer flag, b7=0 - Tube release
 ROR A:BCS TransExitScreen :\ b0=1, Screen release
 RTS
 .TransExitRelease
 JMP TubeRelease           :\ Release Tube, return
 .TransExitScreen
 LDA #0:JMP vramSelect     :\ Page in main memory, return
 \
 .TransTube
 CLC:ADC #&10:ROL A        :\ Cy=1/0 for load/save
 LDA #0:ADC #0:PHA         :\ A=1/0 for load/save
 JSR TubeAction            :\ Claim Tube and start transfer
 \ At this point, the byte on the stack holds
 \   &1 - load is to Tube
 \   &0 - save is from Tube
 \ ie b7=0 - Tube memory
 \
 \
 \ Do Tube transfer here
 \
 \
 JMP TransExitDone         :\ Jump to release Tube

Electron

This is untested at present, but this appears to be the equivalent code for the Electron

\ Electron screen selection routine
\ =================================
\ On entry, A=0 - select main memory
\           A=1 - select video memory
\ On exit,  A corrupted, X,Y preserved
\
 .vramSelect
ROR A                      :\ Move selection in bit 0 to Carry
LDA &027F:BPL vramOk       :\ No shadow RAM present
ROR A:STA &FC7F            :\ Move Carry A to bit 7, set paging flag
.vramOk
RTS

See also


References

Jgharston 22:25, 25 December 2011 (UTC) Jgharston (talk) 20:38, 3 April 2015 (UTC)