newbie questions
newbie questions
hi everybody! this is my first post here so allow me to quickly introduce myself. i'm a so-called chiptune musician with special interest in the most minimalistic sound devices. i know very little about zx81 or programming in general, but i'm trying to expand my knowledge
anyway here's what i want to do. i want to create a little music demo for zx81 which uses the zx81mi music routine (and possibly others as well).
i've already written a little procedural landscape generator that i've attached below.
so here are my questions:
1) how can i speed up/optimize the code?
2) how can i inject the code from zx81mi into my program? i've tried to copy+paste it in zxtoken but that deletes the subsequent BASIC code. (btw i'm on xp pro so i can only use zxtoken, not zxbasic.)
anyway here's what i want to do. i want to create a little music demo for zx81 which uses the zx81mi music routine (and possibly others as well).
i've already written a little procedural landscape generator that i've attached below.
so here are my questions:
1) how can i speed up/optimize the code?
2) how can i inject the code from zx81mi into my program? i've tried to copy+paste it in zxtoken but that deletes the subsequent BASIC code. (btw i'm on xp pro so i can only use zxtoken, not zxbasic.)
- Attachments
-
- utzta817_ZxBasic.TXT
- (1.71 KiB) Downloaded 222 times
-
- utzta818.P
- (2.67 KiB) Downloaded 234 times
Re: newbie questions
Hi,
Or... Vb81 XuR (it work too in TXT mode.)(btw i'm on xp pro so i can only use zxtoken, not zxbasic.)
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: newbie questions
Hello, and welcome to the forum.utz wrote:1) how can i speed up/optimize the code?
To get the most speed out of your program you'd need to write it in machine code. But that's a very big step to make from BASIC. You can make some changes to make your BASIC program faster though - try the following:
As loops take time to processes you could combine your loops at lines 110-140, 160-180 & 190-210 into a single loop - and save time by not overwriting the display (i.e. put chr$ 3 and then overwrite with chr$ 137). Or instead don't do 110-140 in a loop - just replace with a 31 character string of chr$ 3s & chr$ 131s and just combine 160-180 & 190-210.
Re: newbie questions
Hi,
I will try to code a scrolling code in Asm.
Regards the splash screen, you can capture the D_File screen in a single PRINT command...
This feature will be present in the next XuR realease.
Xav.
I will try to code a scrolling code in Asm.
Regards the splash screen, you can capture the D_File screen in a single PRINT command...
This feature will be present in the next XuR realease.
Xav.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: newbie questions
thanks. i've implemented the suggested changes. left in the overwriting of display - the chr$ 137s depend on the randomly generated landscape so i'd have to introduce another if-clause. now i'm thinking i should combine the ifs in line 170/200 into a single line but i'm not quite sure how to make use of AND. maybe someone could give an example?
also another question, is it faster to use chr$ codes or the actual graphic symbols?
and... i still need to get the code from zx81mi into the program!!!
@XavSnap asm scolling would be nice of course! on the other hand zx81jens' routine (280-310) seems to do the job, as long as the string doesn't get too long - but that can be probably solved by splitting it up in parts.
also another question, is it faster to use chr$ codes or the actual graphic symbols?
and... i still need to get the code from zx81mi into the program!!!
Code: Select all
1 FAST
2 LET A=16
3 DIM S(66)
4 CLS
5 PRINT AT 4,0;"ŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸ³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³ŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³ŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸ ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿ŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸ ŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸŸ"
10 FOR N=0 TO 63
20 LET B=INT (10*RND)-4
30 IF A+B>0 THEN LET A=A+B
40 IF A>20 THEN LET A=A-10
70 FOR C=8 TO A
80 PLOT N,C
90 NEXT C
100 LET S(N+1)=A
110 NEXT N
120 LET S(66)=S(64)
130 PRINT AT 18,0;"žžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžžž®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®"
160 FOR I=1 TO 32
170 IF S(I*2)>7 THEN PRINT AT 18,I-1;CHR$ 137
200 IF S((I*2)+2)>12 THEN PRINT AT 19,I-1;CHR$ 137
210 NEXT I
220 PRINT AT 0,0;CHR$ 5+CHR$ 5+CHR$ 132+CHR$ 1+CHR$ 3+CHR$ 5+CHR$ 132+CHR$ 1+CHR$ 6+CHR$ 4+CHR$ 7+CHR$ 4+CHR$ 7+CHR$ 1+CHR$ 7+CHR$ 5+CHR$ 132+CHR$ 0+CHR$ 0
230 PRINT CHR$ 5+CHR$ 5+CHR$ 133+CHR$ 0+CHR$ 6+CHR$ 0+CHR$ 133+CHR$ 0+CHR$ 7+CHR$ 5+CHR$ 7+CHR$ 0+CHR$ 7+CHR$ 0+CHR$ 6+CHR$ 4+CHR$ 133+CHR$ 0+CHR$ 0
240 PRINT CHR$ 3+CHR$ 1+CHR$ 2+CHR$ 0+CHR$ 3+CHR$ 1+CHR$ 2+CHR$ 0+CHR$ 1+CHR$ 1+CHR$ 1+CHR$ 0+CHR$ 3+CHR$ 1+CHR$ 3+CHR$ 1+CHR$ 2+CHR$ 0+CHR$ 0
250 PRINT "BY IRRLICHT PROJECT"
255 PRINT AT 21,0;"««««««««««««««««««««««««««««««««"
260 SLOW
270 PAUSE 20
280 LET A$="«««««««««««««««««««««««««««««««lets«see«if«this«routine«can«be«used«as«a«scroll«effect"
290 LET A$=A$(2 TO )+A$(1)
300 PRINT AT 21,1;A$(1 TO 30)
310 GOTO 290
- Attachments
-
- utzta81a.P
- (2.66 KiB) Downloaded 213 times
Re: newbie questions
Hi,
The Plot function in ASM is too slow...
In your case, you had to keep le Basic routine.
But, i have code the scrolling routine in ASM.
Have Fun.
The Plot function in ASM is too slow...
In your case, you had to keep le Basic routine.
But, i have code the scrolling routine in ASM.
Have Fun.
- Attachments
-
- Line_Scroll.zip
- ASM SCROLLED LINE ON ZX81
- (7.83 KiB) Downloaded 208 times
-
- LINE_SCROLL.P
- (2.03 KiB) Downloaded 213 times
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: newbie questions
160 FOR I=1 TO 32
170 IF S(I*2)>7 THEN PRINT AT 18,I-1;CHR$ 137
200 IF S((I*2)+2)>12 THEN PRINT AT 19,I-1;CHR$ 137
210 NEXT I
OR
160 FOR I=1 TO 32
170 PRINT AT 18,I-1;CHR$ 137 AND S(I*2)>7;AT 19,I-1;CHR$ 137 AND S((I*2)+2)>12
210 NEXT I
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: newbie questions
I was going to suggest:Code: Select all
160 FOR I=1 TO 32 170 IF S(I*2)>7 THEN PRINT AT 18,I-1;CHR$ 137 200 IF S((I*2)+2)>12 THEN PRINT AT 19,I-1;CHR$ 137 210 NEXT I
Code: Select all
160 FOR I=1 TO 32 STEP 2
170 PRINT AT 18,I-1;CHR$ 137 AND S(I)>7;AT 19,I-1;CHR$ 137 AND S(I+2)>12
210 NEXT I
Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
Re: newbie questions
I'd suggest removing those multiplys and constant subtractions from within your loop.
Code: Select all
159 LET Q=2
160 FOR I=0 TO 31
170 IF S(Q)>7 THEN PRINT AT 18,I;CHR$ 137
200 IF S(Q+2)>12 THEN PRINT AT 19,I;CHR$ 137
205 LET Q=Q+2
210 NEXT I
Re: newbie questions
thanks everybody for the support!
@RWAP now that looks elegant! i totally forgot about STEP command. will use this.
@XavSnap merci beaucoup! i tried your XuR kit but i still don't know how to insert the code from zx81 Music Interpreter
@RWAP now that looks elegant! i totally forgot about STEP command. will use this.
@XavSnap merci beaucoup! i tried your XuR kit but i still don't know how to insert the code from zx81 Music Interpreter