Mode 7 flip between pages

Discuss all aspects of programming here. From 8-bit through to modern architectures.
Post Reply
User avatar
pixelblip
Posts: 1400
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Mode 7 flip between pages

Post by pixelblip » Thu Oct 17, 2019 5:52 am

Hi there
I've been using Kieran's excellent Image to mode 7 converter. I am achieving new things with it! Really good bit of software I think you will all agree :D
Does anyone have any suggestions - I have a number of mode 7 images in edit tf at the moment . 7 of them.

I want to animate them. So my question is what format do I save them in from Edit tf to display on a beeb and also is there some code to load a series of mode 7 pages then flip between them quickly?

I do have another request but I'll pop that somewhere else....
Thanks for your help if you can offer any.

User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Mode 7 flip between pages

Post by jgharston » Thu Oct 17, 2019 1:07 pm

As it's only 1K the simplest is a fast copy loop.

\ (src)=>start of source data
LDA #19:JSR OSBYTE :\ Wait for VSync
LDX #4:LDY #0
LDA #&7C:STA dst+1:STY dst+0
.loop
LDA (src),Y:STA (dst),Y
INY:BNE loop:DEX:BNE loop
RTS

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
pixelblip
Posts: 1400
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Mode 7 flip between pages

Post by pixelblip » Thu Oct 17, 2019 6:20 pm

Thank you jgharston....I'll see if I can work that out......I'm no assembly expert and a real novice.....lets see...

dp11
Posts: 956
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: Mode 7 flip between pages

Post by dp11 » Thu Oct 17, 2019 7:53 pm

jgharston wrote:
Thu Oct 17, 2019 1:07 pm
As it's only 1K the simplest is a fast copy loop.

\ (src)=>start of source data
LDA #19:JSR OSBYTE :\ Wait for VSync
LDX #4:LDY #0
LDA #&7C:STA dst+1:STY dst+0
.loop
LDA (src),Y:STA (dst),Y
INY:BNE loop:DEX:BNE loop
RTS
The copy loop needs a little more work I think. It copies the same page 4 times

User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Mode 7 flip between pages

Post by jgharston » Thu Oct 17, 2019 9:47 pm

dp11 wrote:
Thu Oct 17, 2019 7:53 pm
The copy loop needs a little more work I think. It copies the same page 4 times
I was posting from work!

\ (src)=>start of source data
LDA #19:JSR OSBYTE :\ Wait for VSync
LDX #4:LDY #0
LDA #&7C:STA dst+1:STY dst+0
.loop
LDA (src),Y:STA (dst),Y
INY:BNE loop
INC src+1:INC dst+1
DEX:BNE loop
RTS

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Andrew_Waite
Posts: 177
Joined: Tue Aug 30, 2016 2:58 pm
Contact:

Re: Mode 7 flip between pages

Post by Andrew_Waite » Sun Nov 10, 2019 4:06 am

pixelblip wrote:
Thu Oct 17, 2019 5:52 am
I want to animate them. So my question is what format do I save them in from Edit tf to display on a beeb and also is there some code to load a series of mode 7 pages then flip between them quickly?
I think that the two programs below do something similar to what you are looking to achieve. They create animated images of Miner Willy and Technician Ted walking across the screen of the BBC Micro. Both programs create 20 different Mode 7 screens in the Beeb's main memory, then change registers 12 and 13 of the 6845 CRT controller chip to change the 'Display Start Address' to cycle through the 20 screens to produce the animated images of Miner Willy and Technician Ted.

Miner Willy :
viewtopic.php?t=14919&start=120#p218814

Technician Ted :
viewtopic.php?t=14919&start=120#p218885
Last edited by Andrew_Waite on Sun Nov 10, 2019 1:15 pm, edited 1 time in total.

User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Mode 7 flip between pages

Post by jgharston » Sun Nov 10, 2019 12:57 pm

Andrew_Waite wrote:
Sun Nov 10, 2019 4:06 am
I think that the two programs below do something similar to what you are looking to achieve. They create animated images of Miner Willy and Technician Ted walking across the screen of the BBC micro. Both programs create 20 different Mode 7 screens in the Beeb's main memory, then change registers 12 and 13 of the 6845 CRT controller chip to change the 'Display Start Address' to cycle through the 20 screens to produce the animated images of Miner Willy and Technician Ted.
This is a simple program that displays something then lets you scroll through memory. It can clearly be optimised.

Code: Select all

   10 MODE7
   20 *ROMS
   30 *FX4,1
   40 ADDR%=&7C00
   50 REPEAT
   60 *FX19
   70 VDU23;12,((ADDR%DIV256)-&74)EOR&20;0;0;0
   80 VDU23;13,ADDR%;0;0;0
   90 A$=GET$
  100 IF A$=CHR$&8A:ADDR%=ADDR%+40
  110 IF A$=CHR$&8B:ADDR%=ADDR%-40
  120 ADDR%=ADDR% AND &FFFF
  130 UNTIL FALSE

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
Lardo Boffin
Posts: 1690
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Mode 7 flip between pages

Post by Lardo Boffin » Sun Nov 10, 2019 3:10 pm

Andrew_Waite wrote:
Sun Nov 10, 2019 4:06 am
Both programs create 20 different Mode 7 screens in the Beeb's main memory, then change registers 12 and 13 of the 6845 CRT controller chip to change the 'Display Start Address' to cycle through the 20 screens to produce the animated images of Miner Willy and Technician Ted.
I didn’t know you could do that with Mode 7.
Could you double buffer mode 7 doing that? As opposed to 20 buffer!
Atom, issue 5
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Mode 7 flip between pages

Post by jgharston » Sun Nov 10, 2019 8:16 pm

Lardo Boffin wrote:
Sun Nov 10, 2019 3:10 pm
Andrew_Waite wrote:
Sun Nov 10, 2019 4:06 am
Both programs create 20 different Mode 7 screens in the Beeb's main memory, then change registers 12 and 13 of the 6845 CRT controller chip to change the 'Display Start Address' to cycle through the 20 screens to produce the animated images of Miner Willy and Technician Ted.
I didn’t know you could do that with Mode 7.
Could you double buffer mode 7 doing that? As opposed to 20 buffer!
Yeah, I was sure that the MODE 7 screen was hardwired to the top 1K of RAM. I tested my posted code on BeebEm not on real hardware. My nagging suspicion is that with five address lines tied high on IC11, and only MA0-MA9 are passed through to the RAM, that forces the MODE 7 screen to be within the top 1024 bytes of screen RAM.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
pixelblip
Posts: 1400
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Mode 7 flip between pages

Post by pixelblip » Tue Nov 12, 2019 7:22 am

Thank you everyone that has been really useful and helpful. Interesting. I will study the code.

User avatar
kieranhj
Posts: 823
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Mode 7 flip between pages

Post by kieranhj » Tue Nov 12, 2019 9:09 pm

It’s been long established that with CRTC linear addressing mode, as used for MODE 7, the screen address is generally restricted to the top 1024 bytes of lower RAM, so &7C00 to &7FFF. However on Model B there is also a mapping to &3C00 which can be used for buffer swapping. Sadly this isn’t available on Master, although you could swap SHADOW RAM in.

(Perhaps paging in 20K to buffer a 1K screen is a bit overkill, particularly when you can copy 1000 bytes reasonably quickly with an unrolled loop during vblank.)
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
Lardo Boffin
Posts: 1690
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Mode 7 flip between pages

Post by Lardo Boffin » Tue Nov 12, 2019 11:25 pm

How would you go about using the &3C00 buffer process?
Atom, issue 5
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

User avatar
kieranhj
Posts: 823
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Mode 7 flip between pages

Post by kieranhj » Wed Nov 13, 2019 10:54 pm

I’m sure there are some practical posts on here or maybe the old RetroSoftware programming forum. Otherwise check out the technical details on BeebWiki: http://beebwiki.mdfs.net/Address_translation#TTX_VDU
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

Post Reply