Load half a mode 7 screen

bbc micro/electron/atom/risc os coding queries and routines
User avatar
pixelblip
Posts: 2225
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Load half a mode 7 screen

Post by pixelblip » Sat Aug 08, 2020 9:06 pm

Hi there
More questions!
Can someone tell me the best way of loading the top half of a mode 7 screen from 1 full mode 7 screen (a .bin file) then the bottom half from another mode 7 screen in BBC basic for windows (.bin) please? I am trying to combine two pictures from 2 files top half and bottom half. I need to do it a number of times in a loop.
Thanks a lot

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

Re: Load half a mode 7 screen

Post by pixelblip » Sat Aug 08, 2020 9:07 pm

Sorry more annoying mode 7 questions! I've done something cool but need to know how do do this...and also how to stop flickering if I CLS the screen after it's loaded the first screen.
Thanks again

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

Re: Load half a mode 7 screen

Post by pixelblip » Sat Aug 08, 2020 10:25 pm

PS Can't wait to show you what I've done when I know how to do this. It is way cool!

dp11
Posts: 1199
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: Load half a mode 7 screen

Post by dp11 » Sat Aug 08, 2020 10:41 pm

The simplest way is to split the files into two.

Code: Select all

*load fullscreen 6C00
*save top 6C00 + 200
*save bot 6E00 + 200

#to load a file to the top of screen 
*load file 7C00
#to load a file to the bottom of screen 
*load file 7E00

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 3:35 am

Lovely thanks for helping me out dp11. Let's see now! :)

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 6:02 am

Code: Select all

   10MODE 7

   20VDU 23,1,0;0;0;0;

   30A%=RND(3)

   40*LOAD TOP 7C00

   50REPEAT

   60*LOAD P1 7E00

   70*LOAD N2BIN  7E00

   80*LOAD N3BIN  7E00

   90 *LOAD N4 7E00

  100*LOAD P5 7E00

  110*LOAD P6 7E00

  120*LOAD P7 7E00

  130*FX19

  140UNTIL FALSE


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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 6:09 am

Fly by (took a lot of work to get here !)
Attachments
flyby.gif
flyby.gif (21.06 KiB) Viewed 935 times

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 6:12 am

What I'd like to do with this is grab the ship sprite and move it around somehow. Not sure the best way of going about that.....

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 6:13 am

I was thinking of Iridium on the gameboy advance. Anyone remember that? That was a cool game. I thought I'd do a teletext version in the style of. It's 8 frames

User avatar
tricky
Posts: 4687
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Load half a mode 7 screen

Post by tricky » Sun Aug 09, 2020 9:33 am

You might be better just keeping the bottom halves in memory and copying them in assembler.
Something like:

Code: Select all

; copy 12 lines from &XX00 to the bottom 12 lines of the screen
.copy_lower ; use X%=source page e.g. &70 for &7000 and &7100 : JSR copy_lower
stx pg_lo+2
inx
stx pg_hi+2
ldx #40*6 ; quarter screen address with -1 as X is 1 based to allow bne
.loop
.pg_lo ; used for self modifying code - count use lda (zp),y but it would be slower and need ZP ;)
lda &7c00+13*40-1,x ; high byte will be overwritten by X%
sta &7c00+13*40-1,x ; 3rd quarter
.pg_hi ; used for self modifying code - count use lda (zp),y but it would be slower and need ZP ;)
lda &7c00+19*40-1,x ; high byte will be overwritten by X%+1
sta &7c00+19*40-1,x ; 4th quarter
dex
bne loop
RTS
the data would be saved with *SAVE "FRAME" &7E00 +&200 (the first 8 and last 24 bytes won't be used)
and load each frame with *LOAD "FRAME" &7000 or where ever that are being stored.
Should be less than a 1/10th of a frame (>500fps).
Disclaimer, written on my phone without testing 8)

PS It could probably be tweaked to not cross a page boundary all the time for the second page, but it is probably plenty fast enough ;)

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 10:02 am

Nice one Tricky!
I plan on doing some more of these and making .ssd's of them if I can.
Thanks v much!

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 10:19 am

PS written on your phone!?!! What that code?!!!

User avatar
tricky
Posts: 4687
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Load half a mode 7 screen

Post by tricky » Sun Aug 09, 2020 10:40 am

Yep ;)
Formatting is a pain and auto-correct even worse :lol:

PS Just too lazy to go upstairs! :lol:

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 10:42 am

That is so amazing! Talk about an experienced coder!

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 10:44 am

I'd love to unlock the mysterious power of assembler but in reality I know I wouldn't have the time to do that and paint and make art. I am so curious about it though.

User avatar
tricky
Posts: 4687
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Load half a mode 7 screen

Post by tricky » Sun Aug 09, 2020 10:54 am

I don't want to peak your interest too much, but it is basically a for loop going from 240 down to 1 and copying two bytes per iteration.
For x=239to0 step-1
X?&7e08=x?&7008
X?&7ef8=x?&70f8
Next
Now I have written it like this, I can see that there is a bug, which can be fixed by removing the INX above.

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 10:57 am

Ok that is made simpler thank you it's not so scarey.
I have great respect for all you programmers!
Basic can do so much but to have the skills and power to develop software ( which is time consuming I know ) it's amazing.

User avatar
Richard Russell
Posts: 1668
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Load half a mode 7 screen

Post by Richard Russell » Sun Aug 09, 2020 3:36 pm

pixelblip wrote:
Sat Aug 08, 2020 9:06 pm
Can someone tell me the best way of loading the top half of a mode 7 screen from 1 full mode 7 screen (a .bin file) then the bottom half from another mode 7 screen in BBC basic for windows (.bin) please?
You did ask for a BBC BASIC for Windows (or presumably BBC BASIC for SDL 2.0) solution but the ones you have received all seem to assume the MODE 7 screen is memory-mapped at &7C00 (not even &FFFF7C00 as it would need to be on a Second Processor)! If you're still interested in a BB4W/BBCSDL version I can easily create one for you, but for testing purposes it would be handy to have the .bin file(s) that you want to load.

User avatar
tricky
Posts: 4687
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Load half a mode 7 screen

Post by tricky » Sun Aug 09, 2020 8:59 pm

Sorry, I did not note that there first time I saw the post, but had forgotten when I came back and read posts about *load and thanks things.
Last edited by tricky on Mon Aug 10, 2020 8:27 am, edited 1 time in total.

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

Re: Load half a mode 7 screen

Post by pixelblip » Sun Aug 09, 2020 11:22 pm

Ok thanks Richard BBC Basic would be much better. I'll upload the .bin files. Thanks Tricky the assembler is still very useful for actual BBC stuff.

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

Re: Load half a mode 7 screen

Post by pixelblip » Mon Aug 10, 2020 9:16 am

Hi Richard

Here are the bin files of the pictures. I intend to do lots more of these animations in time as they are quite cool!

'Top Ship1' and 'Top Ship 2' are frames of the ship moving up and down. Really I would have liked to have animated the ship rather than save frames of it moving up and down ( which was quite time consuming to do funnily) but I wasn't sure how to grab the ship as a sprite from the teletext picture I painted - if you have any advice or can try it then that would be most appreciated.

Without going too off topic I would like to be able to load a series of frames and on top of that move a sprite over the top of the frames. But I know that isn't what I asked for in this thread...it's what I am sort of trying to do down the line though.

I might try e.g a man walking later on with a background that scrolls....If I have the background animation frames in place and animated then I can think about how to do the other things in programming. At the moment it's quite effective just seeing the ship flying over a cool landscape :)

Thanks for your help.
Attachments
Richard.zip
(2.5 KiB) Downloaded 9 times

User avatar
Richard Russell
Posts: 1668
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Load half a mode 7 screen

Post by Richard Russell » Mon Aug 10, 2020 10:12 am

pixelblip wrote:
Mon Aug 10, 2020 9:16 am
Here are the bin files of the pictures.
Thanks. I see each file is 512 bytes long (not even a multiple of 40), which isn't what I was expecting. How do they map to the screen?

User avatar
Richard Russell
Posts: 1668
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Load half a mode 7 screen

Post by Richard Russell » Mon Aug 10, 2020 10:50 am

Richard Russell wrote:
Mon Aug 10, 2020 10:12 am
I see each file is 512 bytes long (not even a multiple of 40)
I've been able to exactly reproduce the animation you posted earlier in the thread, but only by offsetting the data in the 'Frame' files by 8 bytes horizontally compared with the 'Top Ship' files. That doesn't sound quite right, and somehow I feel it may be connected with the file size not being a multiple of 40 bytes (I might have expected the 'Top Ship' files, which seem to contain 13 rows, to be 520 bytes and the 'Frame' files, which contain 12 rows, to be 480 bytes). I'm missing something somewhere....

bbcsdl_animation.gif
Last edited by Richard Russell on Mon Aug 10, 2020 10:56 am, edited 1 time in total.

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

Re: Load half a mode 7 screen

Post by pixelblip » Mon Aug 10, 2020 10:55 am

Ahh sorry I know what it is now. I forgot I loaded then saved out the pictures 'top' and 'bottom'. So they are not the full ones. Doh. Apologies. I will find them now!

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

Re: Load half a mode 7 screen

Post by pixelblip » Mon Aug 10, 2020 11:13 am

Ok I think these are the full frames ( I think ). Sorry I am all over the place as you know. Artists for you.
Attachments
Richard 2.zip
(2.53 KiB) Downloaded 10 times

User avatar
Richard Russell
Posts: 1668
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Load half a mode 7 screen

Post by Richard Russell » Mon Aug 10, 2020 11:18 am

pixelblip wrote:
Mon Aug 10, 2020 10:55 am
Doh. Apologies. I will find them now!
I understand now: you assumed the bottom part of your screen starts at &7E00 but it doesn't, it starts at &7E08 (do the math, as they say), hence the mysterious 8-byte offset.

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

Re: Load half a mode 7 screen

Post by pixelblip » Mon Aug 10, 2020 11:22 am

Ahh sorry I don't know if that was my mistake from the advice Tricky gave ( with the memory ).

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

Re: Load half a mode 7 screen

Post by pixelblip » Mon Aug 10, 2020 11:28 am

What would be good is a way of grabbing a sprite from a picture and being able to move it ( or it randomly move ) over a background.
So the ship is grabbed from my picture and somehow put into memory or a Dim statement that can then be moved around screen.

One plan I had was to make a man walk with the background scrolling (hence why I asked you about scrolling).
I find if I try to calculate the shapes from the paintings it is very difficult ....I need a way of being able to grab the ship and then move it around.
I am getting a bit far ahead of myself I know!
It's so much fun using BBC basic to do stuff like this and I think you'll agree the end results are very impressive.

User avatar
Richard Russell
Posts: 1668
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Load half a mode 7 screen

Post by Richard Russell » Mon Aug 10, 2020 11:29 am

pixelblip wrote:
Mon Aug 10, 2020 11:13 am
Ok I think these are the full frames ( I think ).
Thinking in terms of efficiency (i.e. file and memory usage) do you want to store your MODE 7 animations always as full frames, or only the region that is changing? I know 1 kbyte isn't very much, and the file system is almost certainly rounding it up anyway, but it's something that ought to be decided before too much code is written.

As my current code stands it's slightly simpler if the files contain only the appropriate rows (so 520 bytes for the Ship files and 480 bytes for the Frame files, as I said) but that could be changed. I just don't want to keep changing it!

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

Re: Load half a mode 7 screen

Post by pixelblip » Mon Aug 10, 2020 11:38 am

I am not sure really whatever you think is best. I am not so worried about room as simplicity thanks.
If they are full frames it's a bit easier to understand isn't it.

It makes me think is it possible to put all the frames as data statements into the program itself so it is self contained ( unless you did that already which I suspect you might have ).

Most of these animations are 8 frames only so I think I will stick to that as it's easy ( for now ). The 8 frames is a nod and wink to colour cycling in Mode 2 :)

Post Reply

Return to “programming”