Next basic snippets

The Speccy's spritely young offspring. Discuss everything from FPGA to ZX
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Next basic snippets

Post by Jbizzel »

Well, I fired up my next and I'm having fun.

Here is the code I was looking for before. It will put a background in layer 2 and let you load a z80 which plays over the top.

You can change the file format to BMP and use the images that are stored in demos/bmp256/bmp

You run this then browse for a image, then a z80 file.

Anything back becomes transparent so you can see the background.

Image

I guess you could modify this code using

.tapein to load a tap file. I'll try later.

I assume the Next can display any 256*192 256 colour bmp. I'll test that too. :)

I didn't write this code, it was Dave Clarke.
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

I don't see to be able to pass a variable to a . Command.

Code: Select all

.bmpload jaws.bmp
works
But this doesn't :(

Code: Select all

let a$ ="jaws.bmp"
.bmpload a$
PS any 256colour BMP that are 256*192 seem to work. I made one in ms paint to test

Here's one I made earlier...

Image

Ok, solved.

Code: Select all

.$ bmpload a$
Etc

Edit, going back to my original idea... I guess the sl2 file format is different to a bmp. So my BMP idea doesn't work very well. More investigation required
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

A little bmp viewer in next basic :)

Image
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: Next basic snippets

Post by Luzie »

Nice ones!

But you should please give this snippets a short description in the Subject Line so we can find them easier.

Or better, put them in a list on a website and offer them for direct download.

If you like, I can offer you some webspace for it.
dfzx
Manic Miner
Posts: 707
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Next basic snippets

Post by dfzx »

I can see why people grumble about Next BASIC not being good for beginners. I don't have a Next (yet) and, despite 40 years of programming experience, I really can't see what that's doing.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

dfzx wrote: Wed Mar 23, 2022 7:18 pm I can see why people grumble about Next BASIC not being good for beginners. I don't have a Next (yet) and, despite 40 years of programming experience, I really can't see what that's doing.
The second code snippet...

10 open the file browser and let's the user select a bmp file type, storing the result in a$
40 uses a command to display the bmp on the screen. The .$ command allows the following .command to take a variable as it's input. The rest is normal basic :)

My observations 2 hours into learning this next basic...

If you have used a +3e or even esxdos it will help you a lot :)

I do think the manual is pretty poor!!! :(
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Luzie wrote: Wed Mar 23, 2022 7:00 pm Nice ones!

But you should please give this snippets a short description in the Subject Line so we can find them easier.

Or better, put them in a list on a website and offer them for direct download.

If you like, I can offer you some webspace for it.
Ok, how do we do it please? :)
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Apparently this displays next images, similar to .bmpload

Code: Select all

.showsimg



Useful link for dealing with bmp and next image file formats

https://github.com/stefanbylund/zxnext_ ... nYo3FpPGd4

https://wiki.specnext.dev/File_Formats? ... ZAv94NbAYc

https://zx.remysharp.com/tools/?fbclid= ... tYfe18VZjg
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: Next basic snippets

Post by Luzie »

Jbizzel wrote: Wed Mar 23, 2022 7:30 pm
Luzie wrote: Wed Mar 23, 2022 7:00 pm Nice ones!

But you should please give this snippets a short description in the Subject Line so we can find them easier.

Or better, put them in a list on a website and offer them for direct download.

If you like, I can offer you some webspace for it.
Ok, how do we do it please? :)
I´ll send you an PM tomorrow, after I set up the webspace and a SFTP-Login for you.
User avatar
PeterJ
Site Admin
Posts: 6966
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Next basic snippets

Post by PeterJ »

Thanks @Luzie,

Just another option @Jbizzel,

I could offer a page off the forum, similar to the website links page. You would have to send the text and files to me for inclusion though.

Peter
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Just to add, sl2 is spectrum Next specific format that can be loaded natively with
load "image.sl2" layer
There are dot commands which will do the same thing with bitmaps, but you don't really know what state they'll leave the palette or layer state in or even the border, and it's a more complicated process loading and executing another executable, to do something that can be done in BASIC with sl2, so it's worth converting. It's just slightly slicker.
Obviously that's only important if you're using it in a program.
@PeterJ and @Luzie Next issue is getting the next.bas into text files or readable on the PC!
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: Next basic snippets

Post by Luzie »

Jbizzel wrote: Wed Mar 23, 2022 8:33 pm @PeterJ and @Luzie Next issue is getting the next.bas into text files or readable on the PC!
Can be done online, and there´s even a commandline API for converting: https://zx.remysharp.com/bas/
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Ok, got this working pretty well.

This code loads lets you select an .SL2 image and a tap game, and then it adds a layer 2 BG. Black is transparent.

Here is my Snake game, with a background I made for it in gimp and then using Remi's tool to convert the next format.

Next owners, give it a go and see what game work well :)

Image

Image


New commands:

RUN AT = what speed do you want the program to run at? 0 is normal spectrum speed.
LOAD file LAYER = loads an image to the current layer you're pointing to
LAYER 2,1 points to layer 2
LAYER OVER selects the order of the layers I think?? Not sure about this one
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Useful snippets...

Image

Image
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

https://jbizzel.itch.io/snake-zx

Here is a worked example.... I've made a version of zx snake for the next using layer 2 graphics.

So quickly losing it's spectrumness.

However, this is very easy to do in next basic. Similar effect to using the zx0 tools in zx basic - also very simple to do.

So to keep it spectrum like becomes about the art, artist and tools. Also key is the standard the tools conform to.

I could for example create a layer two images file with zx paintbrush and convert it to SL2 using Remi Sharps excellent online converter.

This would make a more spectrum like game, but with some next qualities.

This is as an experiment about style as much as anything.

Anyway, why not try the game this way and see how it feels :)
Image
dfzx
Manic Miner
Posts: 707
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Next basic snippets

Post by dfzx »

Jbizzel wrote: Thu Mar 24, 2022 11:20 am I've made a version of zx snake for the next using layer 2 graphics.

So quickly losing it's spectrumness.
Adding a backdrop is guaranteed to make a game loose Spectrumness, isn't it? The Speccy couldn't do that, so as soon as a Next developer adds it, it no longer looks like a Spectrum game.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Code: Select all

.spredit filename
Opens a sprit editor similar to the one found in ADG.

You can create and save sprite sheets and use them in your games.

Here's one I made earlier...

Image
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

This just doesn't seem right :D :D :D :D


Image

Image
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

https://m.youtube.com/watch?v=OZN5bo6rnIw

Not a snippet as such, but this guy has some fairly short bids covering the sprite routines in spectrum basic.

Even if you're going to use zx basic next build I'd say a sensible place to start is the next basic spirit routines and the in built sprite and tile editor.

I'm going to assume at this point that the zx basic next built gives access to these libraries in a way that's faithful to next basic.
User avatar
Nige
Dizzy
Posts: 53
Joined: Tue Feb 15, 2022 7:01 pm
Location: UK
Contact:

Re: Next basic snippets

Post by Nige »

Jbizzel wrote: Thu Mar 24, 2022 9:17 am Useful snippets...

Image

Image
A bit bigger than a snippet, sorry ;)
My BetaBasic4 version of Darry Sloane's Spectrum Next Connect 4 program. WIP :)

Code: Select all

5 LIST FORMAT 2:KEYWORDS 4: BORDER 7: PAPER 7: INK 0: BRIGHT 0: CLS
10 REM CONNECT 4 :Original by Darryl Sloane :Feb 2020
15 REM :BetaBasic v4/ESXDos version:by Nigel's Workbench:Feb 2022
20 REM Import sprite data
30 REM LOAD*"connect4.SPR" N.BANK 16,0,1280
40 N.SPRITE_BANK 16
50 N.SPRITE_CLEAR:N.SPRITE_PRINT 1
200 REM Set up board
210 LET i=1
220 REM  FOR y=88 TO 168 STEP 16
221 FOR y=152 TO 72 STEP -16
230 REM FOR x=104 TO 200 STEP 16
231 FOR x=200 TO 104 STEP -16
240 N.SPRITE i,x,y,7,1
241 REM N.SPRITE i,x,y,1,1
250 LET i=i+1
260 NEXT x: NEXT y
300 REM Set up player sprite
310 REM N.SPRITE 0,152,72,0,1
311 N.SPRITE 0,152,168,6
500 REM Initialise variables
510 REM LET p=4:LET x=152:LET c=0
511 LET p=4,x=152,c=6
520 DIM b(7): FOR i=1 TO 7: LET b(i)=6: NEXT i
600 REM Invite player movement
610 IF INKEY$ ="1" THEN GO SUB 700
620 IF INKEY$ ="2" THEN GO SUB 800
630 IF INKEY$ =" " OR INKEY$ ="5" THEN GO SUB 900
640 IF INKEY$ ="r" THEN GO TO 50
650 GO TO 610
700 REM Move left
710 IF p=1 THEN RETURN
720 FOR i=1 TO 16
730 REM LET x=x-1:N.SPRITE 0,x,72,c,1
731 LET x=x-1:N.SPRITE 0,x,168,c,1
740 NEXT i
750 LET p=p-1
760 RETURN
800 REM Move right
810 IF p=7 THEN RETURN
820 FOR i=1 TO 16
830 REM LET x=x+1:N.SPRITE 0,x,72,c,1
831 LET x=x+1:N.SPRITE 0,x,168,c,1
840 NEXT i
850 LET p=p+1
860 RETURN
900 REM Drop counter
910 IF b(p)=0 THEN RETURN
920 REM LET y=72
921 LET y=168
930 FOR i=1 TO b(p)*16
940 REM LET y=y+1
941 LET y=y-1
943 IF y=71 THEN RETURN
950 N.SPRITE 0,x,y,c,1
960 NEXT i
970 LET b(p)=b(p)-1
980 REM N.SPRITE p+7*b(p),x,y,3+c,1
990 REM IF c=0 THEN LET c=1:ELSE LET c=0
991 IF c=6 THEN LET c=2: LOCAL LET c=6
1000 REM N.SPRITE 0,x,72,c,1
1001 N.SPRITE 0,x,168,c,1
1010 RETURN
5000 DEF PROC N.SPRITE_BANK bn
5010 DEFAULT bn=16
5020 REM
5030 END PROC
6000 DEF PROC N.SPRITE_PRINT sp
6010 DEFAULT sp=-1
6030 END PROC
7000 DEF PROC N.SPRITE_CLEAR
7010 CLS
7020 END PROC
8000 DEF PROC N.SPRITE sn,sx,sy,si,sp
8010 DEFAULT sn=0,sx=248,sy=175,si=8,sp=1
8020 IF sn > 0 THEN PLOT PAPER sp; INK si; INVERSE 0;sx,sy;"O "
8030 IF sn < 1 THEN PLOT INK si; INVERSE 0;sx,sy;"0"
8999 END PROC
9000 DEF PROC sve
9010 SAVE *"connect4.BB4"
9020 END PROC
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: Next basic snippets

Post by Luzie »

Jbizzel wrote: Wed Mar 23, 2022 10:52 pm This code loads lets you select an .SL2 image and a tap game, and then it adds a layer 2 BG. Black is transparent.
@Jbizzel How can we change the transparency colour from NextBASIC? Maybe with the "Global Transparency Register" $14 ? https://wiki.specnext.dev/Global_Transparency_Register
Short Description Sets the "transparent" colour for Layer 2, ULA and LoRes pixel data.
is this the way to maybe change transparency colour to bright yellow for displaying a Layer 2 picture under Tranz Am´s brihgt yellow (ATTR=112 dez/01110000 bin http://www.overtakenbyevents.com/lets-t ... en-layout/) Playfield?
Image
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

@Luzie the problem the tranz Am is that the level background changes, sometimes black, sometimes yellow.
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: Next basic snippets

Post by Luzie »

Jbizzel wrote: Sun Apr 03, 2022 7:25 pm @Luzie the problem the tranz Am is that the level background changes, sometimes black, sometimes yellow.
Oh yes. There´s a "night terrain level" with black background. So this won´t work with a just one single transparency colour.
funkheld
Dizzy
Posts: 57
Joined: Tue May 18, 2021 9:01 pm

Re: Next basic snippets

Post by funkheld »

Hello Jebizzel.

A tip for your images for Layer2. They are not good as SL2.
Make the as BMP 256x192 and 256 colors with Gimp.
In Gimp you can take over the palette from the Next.
When the BMP is finished, the BMP is mirrored and the first 1078 bytes are taken out, then you have a BMP with 49152 bytes which you can then load into Layer2 as a BMP.
Then you have clean pictures.
User avatar
Jbizzel
Dynamite Dan
Posts: 1538
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Next basic snippets

Post by Jbizzel »

Thanks @funkheld

I understood that next basic has robust commands for dealing with SL2 files, and for this reason I have been advised to use the SL2 file type rather than BMPs.

I did use gimp to create the background image in my Snake game. This was a 256*192 256 colour bmp, which I then converted to SL2 using remi sharps tool
Post Reply