News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Morri

BASIC game idea - WIP

Started by Morri, 02:34, 19 May 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Morri

Hi all,
I know it's only just been announced today but I'm pretty sure I will enter a game into this years #CPCRetroDev 2016 contest and I already have a good idea of what I'm going to do.

I'm going to enter into the BASIC category with a game I have been thinking about for awhile, in fact I already have a few of the routines I want to use working, namely the sprite handling (control codes) and hardware scrolling (OUT command).
I've still got a lot of work to do to make this a presentable, working game but the end of October should be achievable.

Anyway, this is where I require help. I was thinking about the possibility of adding in-game music to the program using DATA statements.
Is such a thing possible and is there anyone here who knows how to do this? I have no musical talent at all and would also need help to create the actual music.

Any help would be appreciated, even if it's pointing me to a thread / website etc with how to achieve such a result.

Cheers.
Keeping it Kiwi since 1977

Bytebreaker

#1
Hi Morri,


if you go to the demos section you find my little triangles demo (thanks for your tag scroll routine btw.).


Little Triangles Demo


Insert the dsk and just load"vscroll.bas" and list it.


The scrolltext is irrelevant but you will find there also a simple routine that plays data music based on a software interrupt while the scroller is moving. In theory, you could use all 3 interrupt intervals that Amstrad Basic is able to handle at at time and make music with 3 voices this way. But I am afraid there will be problems with smooth gameplay, then. Even my simple method required to find out a proper timing interval in order not to make the scrolltext stop. I am afraid you will need an Assembler routine for background music, but I am not sure, since I don't know the CPC that well, yet.


Edit:


I speak about lines 1760 to 1820. Here, an array is defined in which the music data gets injected. In line 1820 the interrupt is defined, i.e., the sound playing speed. The last three notes are zeroes to enforce a pause before the music loops.

In line 2410 we find the subroutine that actually plays the music. If all datas have been processed, reset array counter.
It's primitive and simple but maybe it's an inspiration to you. I developed the code directly on CPC so I have no text file to copy and paste here, sorry.

Edit 2:


I used an array for the music so I could easier use the RESTORE command for resetting the scrolltext datas only without getting in conflict with the music datas.











AMSDOS

Hi Morri,


I don't recall typing in any BASIC games where the music played during the game, but I haven't seen anyone make use of an EVERY or AFTER statement to play a tune in a BASIC game, not sure if it can be applied like that, the tune would have to be present in an Array and looped though on each time interval, but it's all theory and Assembly is out when it comes to these games.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

andycadley

CPC Basic has full support for interrupt driven music via the ON SQ mechanism. Since it uses a queuing system, it shouldn't have problems with timing.

Morri

Thanks for the answers so far.

Quote from: AMSDOS on 10:46, 19 May 16
I don't recall typing in any BASIC games where the music played during the game
Neither have I, the closest example I can find was Regreso al CPC which won the basic category in CPCRetroDev2015 last year. This game uses EVERY and DATA statements to produce a tune during the intro sequence. TBH if this is all that is possible I would be happy with that. Was only wondering if any program had gone one step further and had an actual in-game tune.

Quote from: Bytebreaker on 10:23, 19 May 16
I used an array for the music so I could easier use the RESTORE command for resetting the scrolltext datas only without getting in conflict with the music datas.
Using arrays is a good idea, my only worry (without any tests) would be memory issues for longer tunes???

Quote from: andycadley on 13:30, 19 May 16
CPC Basic has full support for interrupt driven music via the ON SQ mechanism. Since it uses a queuing system, it shouldn't have problems with timing.
I have seen this command used in a few small demos, the 6128 manual I think but I don't undestand how it works. This was where I was hoping an expert might be able to help me develop a tune. ;D

Keeping it Kiwi since 1977

AMSDOS

Should be worth checking the ON SQ actually.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

tastefulmrship

I learned how to ON SQ from this type-in from ACU;
pak caverns &copy amstrad computer user (1986)

Both the loader and the main game use the same-style routine.

Morri

I have now made super quick progress with my game and it is now in a playable state.
It has actually been a really fun game to make and is quite challenging to play. I must say for a Basic game it is actually quite good and I think it has some real replay-ability.  ;)

I still have a few things to finish but it's coming along nicely. Here is a list of to dos and on some of them I really need help. I have put any requests in bold and if anyone can help, please feel free to let me know.

1) I'm unsure if this will be a CPCRetroDev2016 entry as I developed it on my 6128 and it works fine in all emulators in 6128 mode, however when I change to 464 mode the graphics get all messed up.
I have had a couple of goes at fixing it but I don't know enough about the differences between Basic 1.0 and 1.1 and can't seem to fix it.
Text is not a problem, only my control code drawn characters. They work OK up until around halfway across the screen and then wrap down one line. Very annoying.

2) Finish the level design, I have done 7 out of 9 levels. Easy to do, just hard to come up with original and increasingly difficulty levels.

3) Figure out the music issue mentioned earlier. I have come to the conclusion that it will only be menu music with sound effects in game. Most of the sound effects are already done.
If anyone is interested in developing a tune for me in Basic using data statements, please let me know. I know the song I want to use, I just don't know what I'm doing here.

4) Continue to playtest and fix bugs.
Keeping it Kiwi since 1977

AMSDOS


Quote from: Morri on 02:31, 25 May 16
I have had a couple of goes at fixing it but I don't know enough about the differences between Basic 1.0 and 1.1 and can't seem to fix it.
Text is not a problem, only my control code drawn characters. They work OK up until around halfway across the screen and then wrap down one line. Very annoying.


TAG does work a little bit differently on a 464, which is probably where your frustration is. The solution is to probably have TAG..TAGOFF around the character your drawing.
With the control codes, Devilmarkus once suggested using LOCATE because while they don't display themselves (unless your in TAG mode), they can fill up the screen and cause it to Roll.
The most unusual time I had to fix a BASIC 1.1 program, was HAL6128's Bouncing Ball which is in the Hisoft Pascal 4t thread. I had to change a screen address to the 464 equivalent, but was still not working. In that situation it was using CLS, but on a 464 because it was in TAG mode, PRINT CHR$(12) was being displayed, but the program worked fine when I used TAG..TAGOFF around the printed graphic.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Morri

Quote from: AMSDOS on 03:52, 25 May 16
TAG does work a little bit differently on a 464, which is probably where your frustration is. The solution is to probably have TAG..TAGOFF around the character your drawing.
With the control codes, Devilmarkus once suggested using LOCATE because while they don't display themselves (unless your in TAG mode), they can fill up the screen and cause it to Roll.
The most unusual time I had to fix a BASIC 1.1 program, was HAL6128's Bouncing Ball which is in the Hisoft Pascal 4t thread. I had to change a screen address to the 464 equivalent, but was still not working. In that situation it was using CLS, but on a 464 because it was in TAG mode, PRINT CHR$(12) was being displayed, but the program worked fine when I used TAG..TAGOFF around the printed graphic.
I am using LOCATE to display these graphics, no MOVE or DRAW commands. I'll still try using TAG to see if it helps.
Keeping it Kiwi since 1977

AMSDOS

Quote from: Morri on 04:40, 25 May 16
I am using LOCATE to display these graphics, no MOVE or DRAW commands. I'll still try using TAG to see if it helps.


Oooh I'm sorry, I thought you were using TAG!  :o


You only need TAG if you're drawing to the Graphic Cursor Position (which uses MOVE), not Text Cursor Position (which uses LOCATE).


Ironically I wrote this little bouncing ball program a couple of weeks ago, which has a multicoloured ball. It's using Transparent mode & LOCATE to move around the screen, which seems to work on the 464. So perhaps compare that with your game I guess, unfortunately the Graphical Ball I'm using is 8x8.




10 MODE 0
20 SYMBOL 255,0,24,36,66,66,36,24,0
30 SYMBOL 254,0,0,24,52,60,24,0,0
40 SYMBOL 253,0,0,0,8,0,0,0,0
50 INK 0,0:INK 1,1:INK 2,2:INK 3,11:INK 4,18
60 GOSUB 4010
70 exit=0 : x=10 : y=10 : dir=1 : dir2=1
80 WHILE INKEY(18)=-1
90  v=1 : GOSUB 1010
100  CALL &BD19 : CALL &BD19
110  IF x=20 THEN dir=-1
120 IF x=1 THEN dir=1
130 IF y=25 THEN dir2=-1
140 IF y=1 THEN dir2=1
150 v=0 : GOSUB 1010
160 x=x+dir
170 y=y+dir2
180 WEND
190 CALL &BC02 : INK 1,26 : PEN 1
200 PRINT CHR$(22);CHR$(0);
210 MODE 2
220 END
1000 ' Draw or Erase Ball?
1010 PRINT CHR$(22);CHR$(v);
1020 IF v=1 THEN GOSUB 2010 ELSE GOSUB 3010
1030 RETURN
2000 ' Draw Ball
2010 PEN 1
2020 LOCATE x,y : PRINT CHR$(255);
2030 PEN 2
2040 LOCATE x,y : PRINT CHR$(254);
2050 PEN 3
2060 LOCATE x,y : PRINT CHR$(253);
2070 RETURN
3000 ' Erase Ball
3010 PEN 4 : LOCATE x,y : PRINT CHR$(207);
3020 RETURN
4000 ' Draw Background
4010 FOR y=1 TO 25
4020 PEN 4
4030 LOCATE 1,y
4040 PRINT STRING$(20,CHR$(207));
4050 NEXT y
4060 RETURN


* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Morri

OK, I think I've worked out the problem. Basic 1.0 doesn't seem to be a fan of using the arrows to move the cursor around inside a PRINT command. After awhile it drops the cursor down by one line when it shouldn't. The below code should show the issue. I couldn't print arrows so you'll have to add those manually.
Does anyone know why this works in Basic 1.1 but not 1.0?


10 x=11
20 MODE 1:BORDER 0
30 a$="XX[insert down arrow/left arrow/left arrow]XX"
40 i$=LOWER$(INKEY$):IF i$="" THEN 40
50 IF i$="x" AND x<39 THEN GOSUB 90:x=x+2
60 IF i$="z" AND x>1 THEN GOSUB 90:x=x-2
70 LOCATE x,10:PRINT a$
80 GOTO 40
90 LOCATE x,10:PRINT"  [insert down arrow/left arrow/left arrow]  ":RETURN

Keeping it Kiwi since 1977

Morri

#12
Even using the control codes chr$(10) for move cursor down and chr$(8 ) for move cursor left produces the same bug.
I am confused. ???

10 x=11
20 MODE 1:BORDER 0
30 a$="XX"+CHR$(10)+CHR$(8 )+CHR$(8 )+"XX"
40 i$=LOWER$(INKEY$):IF i$="" THEN 40
50 IF i$="x" AND x<39 THEN GOSUB 90:x=x+2
60 IF i$="z" AND x>1 THEN GOSUB 90:x=x-2
70 LOCATE x,10:PRINT a$
80 GOTO 40
90 LOCATE x,10:PRINT"  "+CHR$(10)+CHR$(8 )+CHR$(8 )+"  ":RETURN

Keeping it Kiwi since 1977

AMSDOS

Quote from: Morri on 01:25, 26 May 16
Even using the control codes chr$(10) for move cursor down and chr$(8 ) for move cursor left produces the same bug.
I am confused. ???

10 x=11
20 MODE 1:BORDER 0
30 a$="XX"+CHR$(10)+CHR$(8 )+CHR$(8 )+"XX"
40 i$=LOWER$(INKEY$):IF i$="" THEN 40
50 IF i$="x" AND x<39 THEN GOSUB 90:x=x+2
60 IF i$="z" AND x>1 THEN GOSUB 90:x=x-2
70 LOCATE x,10:PRINT a$
80 GOTO 40
90 LOCATE x,10:PRINT"  "+CHR$(10)+CHR$(8 )+CHR$(8 )+"  ":RETURN


Yeah this has me stumped, unfortunately I can't test this at the moment. Perhaps instead of using the '+' for the chr use the semi-colon ';' instead?
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Morri

Quote from: AMSDOS on 02:36, 26 May 16
Yeah this has me stumped, unfortunately I can't test this at the moment. Perhaps instead of using the '+' for the chr use the semi-colon ';' instead?
Interesting. The semi-colon does help. Still not perfect but getting there. Will continue looking tonight.
Keeping it Kiwi since 1977

AMSDOS

#15
Quote from: Morri on 03:16, 26 May 16
Interesting. The semi-colon does help. Still not perfect but getting there. Will continue looking tonight.


I've had the chance to have a look at your Example, I seem to be getting XXs across the screen regardless of BASIC 1.0 or 1.1, in 1.0 though in Line 50 where it's got x<39, BASIC 1.0 was getting up to that condition but incrementing. Changing x<38 would mean x will get to 39 and stop in BASIC 1.0. I tested this in BASIC 1.1 which seem to do the same.


The Xs were still messing up the screen though, I was using BASIC 1.1 at that stage, so I made some changes and came up with this:




10 x=11
20 MODE 1:BORDER 0
30 a$="XX"+CHR$(10)+CHR$(8 )+CHR$(8 )+"XX"
40 i$=LOWER$(INKEY$):IF i$="" THEN 40
50 IF i$="x" AND x<39 THEN GOSUB 90:x=x+1
60 IF i$="z" AND x>1 THEN GOSUB 100:x=x-1
70 LOCATE x,10:PRINT a$
80 GOTO 40
90 LOCATE x,10:PRINT" ";CHR$(10)+CHR$(8 );" ";:RETURN
100 LOCATE x,10:PRINT CHR$(9);" ";CHR$(10)+CHR$(8 );" ";:RETURN



I've changed the increment of x to add or subtract 1 in Lines 50 & 60, Line 90 takes care of the Left Side of the XXs and Line 100 takes care of the Right Side of the XXs. But when I tried that in BASIC 1.0 started getting problems which describes what you said earlier.


So this is what I came up with which works in BASIC 1.0:




10 x=11
20 MODE 1:BORDER 0
40 i$=LOWER$(INKEY$):IF i$="" THEN 40
50 IF i$="x" AND x<39 THEN GOSUB 90:x=x+1
60 IF i$="z" AND x>1 THEN GOSUB 100:x=x-1
70 LOCATE x,10:PRINT "XX";CHR$(10);CHR$(8 );CHR$(8 );"XX";
80 GOTO 40
90 LOCATE x,10:PRINT" ";CHR$(10);CHR$(8 );" ";:RETURN
100 LOCATE x,10:PRINT CHR$(9);" ";CHR$(10);CHR$(8 );" ";:RETURN



So not much change, I've altered Line 70c and deleted Line 30 and changed Lines 90 & 100 from '+' to ';'. But I forgot to see if it was the PRINT a$ in Line  70 which was the problem, there's no Semi-Colon after it, so earlier I didn't realise you declared the FourXs as a variable, so in that situation using Semi-Colon is a Syntax Error, but in Line 70 a Semi-Colon in the BASIC 1.1 program may make all the difference in BASIC 1.0.


Ps. I noticed you had a space after 'CHR$(8 )' didn't realise it at first, until I saw all those horrible emoji's appear! Most annoying! :(
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Morri

Good job getting this to work. BASIC 1.0 really loves itself some semi-colon.  :P

Oh man, my code is going to need a major overhaul. Hopefully I can make it 464 compatible. Wish me luck!  :laugh:
Keeping it Kiwi since 1977

andycadley

My guess would be that you've stumbled upon a bug in BASIC 1.0, although I don't think I've ever seen a definitive list of the changes in 1.1. Usually it's just the new commands and occasional mention of "various bug fixes". I guess you'd need to do a comparison of the disassembled code to find all of them.

AMSDOS

Quote from: andycadley on 06:21, 26 May 16
My guess would be that you've stumbled upon a bug in BASIC 1.0, although I don't think I've ever seen a definitive list of the changes in 1.1. Usually it's just the new commands and occasional mention of "various bug fixes". I guess you'd need to do a comparison of the disassembled code to find all of them.


It puzzles me why Amstrad continued selling 464s with BASIC 1.0 in them up until 1989, I'm not sure if this has been explained. In 1984 sure, Locomotive had to come up with a BASIC for the 464 and with the success of the 464, Locomotive could refine it, make it faster, address any issues & add some extras, which was ready in time for the 664.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Morri

Looks like I need to figure this out within strings. My code is way to reliant on strings and arrays for me to be able to change it. :'(
Keeping it Kiwi since 1977

Morri

OK, printing character graphics as 2 separate lines fixes the problem / bug.
i.e. 1st row of sprite = chr$(a)+chr$(b)
2nd row = chr$(c)+chr$(d)
locate 1,1:print 1st row
locate 1,2:print 2nd row

I might base my code around this solution. Not ideal but I should be able to make it work with a 464 now (I hope).
Keeping it Kiwi since 1977

AMSDOS

This is what I came up with, which works on a 464, I just hope it doesn't complicate things for your game. I've simplified the process, so the Control Codes are singular (e.g. dn$=CHR(10) ), so when I print it now, those Control Codes have Semi-colons following and the Four "Xs" move across the screen.


This is reminiscent of an article published in The Amstrad User which is in Issue 18 on pages 26-28, which deals with Multicoloured Characters, but I think that guy was using a 664. They have used multiple Control codes to a string and are using Semi-colons when Printing those, but it appears the 464 may not like the Multiple Control Codes to a string, which may relate to how a 464 Passes Character String.




10 x=11
20 MODE 1:BORDER 0
30 blank$=" " : rht$=CHR$(9)
31 dude$="XX" : dn$=CHR$(10) : lft$=CHR$(8)
40 i$=LOWER$(INKEY$):IF i$="" THEN 40
50 IF (i$="x") AND (x<39) THEN GOSUB 90:x=x+1
60 IF (i$="z") AND (x>1) THEN GOSUB 100:x=x-1
70 LOCATE x,10:PRINT dude$;dn$;lft$;lft$;dude$
80 GOTO 40
90 LOCATE x,10:PRINT blank$;dn$;lft$;blank$;:RETURN
100 LOCATE x,10:PRINT rht$;blank$;dn$;lft$;blank$;:RETURN
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Quote from: Morri on 22:04, 27 May 16
OK, printing character graphics as 2 separate lines fixes the problem / bug.
i.e. 1st row of sprite = chr$(a)+chr$(b)
2nd row = chr$(c)+chr$(d)
locate 1,1:print 1st row
locate 1,2:print 2nd row

I might base my code around this solution. Not ideal but I should be able to make it work with a 464 now (I hope).


Yes, it is valid on a 464, though I was using my previous program to use the locate, rather than the control codes, which worked. Lines 90 & 100 remained the same and still worked with the LOCATE version.
I made another version out of a Character I made back in the 90s which is 2 Characters Wide, 3 Characters in Height, because I only had one character I made a second by reversing it, so it faces Left when moving Left & Right for Right. I went back to singular Characters for the variable name and using the approach as I had above works fine on the 464. There's probably not a lot you'd get out of it, so won't worry about posting it, unless you want to see it. I also modified the inkey$ to inkey so Line 40 can be deleted and Line 50 can read:


if inked(1)<>-1 and ...


for the right arrow and,


if inkey(8 )<>-1 and ...


for the left arrow. The GOTO can then point to Line 50, so will perform better.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Quote from: Morri on 21:08, 19 May 16
I have seen this command used in a few small demos, the 6128 manual I think but I don't undestand how it works. This was where I was hoping an expert might be able to help me develop a tune. ;D


I'm no maestro, but I found this BASIC game has a tune in it which is using the ON SQ GOSUB if you were looking for examples, the link to the PDF is on this page.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod