Black squares...
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Black squares...
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: Black squares...
I see your squares and I raise you a fraction of randomness
That's quite annoying you know as I really wanted to have for L20 "IF (RND*10) > 6 THEN LET A=32 ELSE LET A=143 , that would of saved messing about and saved a line. *sigh* Someone forgot to allow that in ZXBasic
I thought about having a 5 FOR X=2 TO 10 STEP 2 and then having L20 say > X for the randomness check, that way it would print less squares (as X=2 aka RND*10 > 2) for each loop around but increasing in number each time, it seemed a bit too much messing about. Same for colour.
I then thought about just writing directly so that I could easily do the bottom two lines with pratting with the #0 / #1 thing but again its going a bit too far maybe hehe.
EDIT... Pic of rubbish listing output:
Code: Select all
10 FOR N=0 TO 703
20 IF (RND*10) > 4 THEN LET A=32 : GOTO 40
30 LET A=143
40 PRINT CHR$ A;
50 NEXT N
60 PRINT AT 0,0;
70 GOTO 10
I thought about having a 5 FOR X=2 TO 10 STEP 2 and then having L20 say > X for the randomness check, that way it would print less squares (as X=2 aka RND*10 > 2) for each loop around but increasing in number each time, it seemed a bit too much messing about. Same for colour.
I then thought about just writing directly so that I could easily do the bottom two lines with pratting with the #0 / #1 thing but again its going a bit too far maybe hehe.
EDIT... Pic of rubbish listing output:
- Einar Saukas
- Bugaboo
- Posts: 3143
- Joined: Wed Nov 15, 2017 2:48 pm
Re: Black squares...
LET A=143-(111 AND RND>.6)
Re: Black squares...
Thanks! , that is quite complicated though relatively. This reminds me of a cheat for UU I wrote as its so short on memory I really really needed an ELSE but had to use two lines:
Code: Select all
326 IF w$="*" THEN POKE VAL "23659",VAL "2": INPUT "Where to (1-100) ? ";loc: IF loc<1 OR loc>100 THEN GO TO 326
327 IF w$="*" THEN LET z$="Moving...": GO SUB pr: LET POS=loc: GO SUB 1000: GO TO 100
Code: Select all
326 IF w$="*" THEN POKE VAL "23659",VAL "2": INPUT "Where to (1-100) ? ";loc: IF loc<1 OR loc>100 THEN GO TO 326 ELSE LET z$="Moving...": GO SUB pr: LET POS=loc: GO SUB 1000: GO TO 100
- PROSM
- Manic Miner
- Posts: 476
- Joined: Fri Nov 17, 2017 7:18 pm
- Location: Sunderland, England
- Contact:
Re: Black squares...
Why use RND, when you can use... a Galois linear-feedback shift register!
Sure, it's not BASIC, but then again, it's only 44 bytes:
Code: Select all
org 28000
c_mosaicfade:
ld a,39 ; Galois LFSR seed
c_mosaicfade_l1:
ld b,3 ; 9 squares per frame
c_mosaicfade_l2:
call c_mosaicfade_plot ; Plot square
djnz c_mosaicfade_l2
halt
jr c_mosaicfade_l1
c_mosaicfade_plot:
rrca ; Rotate
jr nc,c_mosaicfade_plot_l1
xor $38 ; XOR if last bit cycled was 1 (feedback part)
c_mosaicfade_plot_l1:
ld l,a
ld h,$58
ld c,0
ld (hl),c ; 1st attr. page
inc h
xor 54
ld l,a
ld (hl),c ; 2nd attr. page
inc h
xor 73
ld l,a
ld (hl),c ; 3rd attr. page
xor 127
c_mosaicfade_plot_l2:
cp 39 ; Are we back to the start of the period?
ret nz ; Return if not
or a
ret z
pop de ; We want to return directly to the caller
xor a
jr c_mosaicfade_plot_l1
end 28000
All software to-date
Working on something, as always.
Working on something, as always.
Re: Black squares...
I see what you did there! And I like it!
I did think about assembly but it seemed a lot of trouble , you know how it is you sometimes need a few dozen instructions to do what you could do in Basic in 10 seconds! I know it would be about 100 times faster though hehe.
Slightly off topic: I just noted your signature link, will have a read through that this evening as it is something I'm very interested in although currently (as seen elsewhere) my erm primary thing is Quill conversions from one platform to another. But that is something for another topic.
EDIT... Back on topic: I think if you added a splash of colour to the squares in your routine it would be even better
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: Black squares...
I hope you have your multipoint belts on, as this topic has gone round the square at 90 degrees...
Mark
Code: Select all
10 POKE (RND*768)+22528,(RND>.5)*56: GO TO 10
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: Black squares...
Colour one:
Alas, both of these demonstrates how computer random is not so much when used lots of times in a row...
Mark
Code: Select all
10 POKE (RND*768)+22528,RND*56: GO TO 10
Mark
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: Black squares...
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: Black squares...
Yes I know the diagonal effect.1024MAK wrote: ↑Fri Aug 02, 2019 4:06 pm Colour one:
Alas, both of these demonstrates how computer random is not so much when used lots of times in a row...Code: Select all
10 POKE (RND*768)+22528,RND*56: GO TO 10
Mark
Despite trying various things with this in the past such as setting RND to be a seed value (frames?) and setting it again as well as introducing another RND check if over X then set to 56 (to set squares back to white) etc etc, it never really looked that brilliant!
Yes I know!
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: Black squares...
A better colour version:
Mark
Code: Select all
1 FOR a=0 TO 14444: POKE PEEK a+PEEK (a+1) +PEEK (a+2) +22528,RND*56: NEXT a: GO TO 1
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
-
- Manic Miner
- Posts: 205
- Joined: Thu Feb 22, 2018 3:27 pm
- Location: virginias eastern shore
- Contact:
Re: Black squares...
That's cool Mark. I typed it in and ran it, noticed that diagonal tendency to the way the squares are placed. Interesting.
BTW is there a command to make the keyboard window in Fuse get bigger somehow? I have to use a magnifying glass to read it.
BTW is there a command to make the keyboard window in Fuse get bigger somehow? I have to use a magnifying glass to read it.
- PROSM
- Manic Miner
- Posts: 476
- Joined: Fri Nov 17, 2017 7:18 pm
- Location: Sunderland, England
- Contact:
Re: Black squares...
If you're talking about the "Keyboard Helper" window, then I'm afraid not - that's the biggest it gets. If you are having trouble with the keyword entry system, you might want to try typing in your BASIC programs from 128K mode; you can type your commands out letter by letter from there.
All software to-date
Working on something, as always.
Working on something, as always.
-
- Manic Miner
- Posts: 205
- Joined: Thu Feb 22, 2018 3:27 pm
- Location: virginias eastern shore
- Contact:
Re: Black squares...
Thanks Prosm! Does that also include key command words and punctuation?
- PROSM
- Manic Miner
- Posts: 476
- Joined: Fri Nov 17, 2017 7:18 pm
- Location: Sunderland, England
- Contact:
Re: Black squares...
In 128K mode, the only key positions you'll have to remember are for the punctuation marks. Everything else is typed out letter by letter, including key command words.
You may also want to consider trying out the "Keyboard Helper" function in ZX Spin. This allows you to write out whole BASIC statements using the PC keyboard mapping by first typing them into a separate input box, and then by clicking a button, allowing the emulator to convert these to Spectrum key presses.
In addition, the BASin development environment allows you to write BASIC programs in a standard Windows environment, and test them out in an integrated emulator at any time. It also comes with many useful features, such as a UDG editor, a debugger and a line renumbering facility.
To get slightly back on topic...
Not yet random colour, but somewhat prettier:
Code: Select all
org 28000
c_mosaicfade:
ld a,39 ; Galois LFSR seed
ld d,$38 ; LFSR mask (and mask for attributes)
c_mosaicfade_l1:
ld b,3 ; 9 squares per frame
c_mosaicfade_l2:
call c_mosaicfade_plot ; Plot square
djnz c_mosaicfade_l2
halt
jr c_mosaicfade_l1
c_mosaicfade_plot:
rrca ; Rotate
jr nc,c_mosaicfade_plot_l1
xor d ; XOR if last bit cycled was 1 (feedback part)
c_mosaicfade_plot_l1:
ld l,a
ld h,$58
call c_matchcolours
ld (hl),a ; 1st attr. page
ld a,l
inc h
xor %00110110 ; Randomise position
ld l,a
call c_matchcolours ; Set ink to be same colour as paper
ld (hl),a
ld a,l ; Get page position value
inc h
xor %11001001 ; Randomise position
ld l,a
call c_matchcolours
ld (hl),a
ld a,l
cpl ; Restore to original value (equiv. to XOR $FF)
c_mosaicfade_plot_l2:
cp 39 ; Are we back to the start of the period?
ret nz ; Return if not
or a
ret z
pop hl ; We want to return directly to the caller
xor a
jr c_mosaicfade_plot_l1
c_matchcolours:
and d ; Keep only the paper colour
ld c,a
rrca
rrca
rrca ; Rotate paper colour into ink colour slot
or c ; Combine paper and ink colours
ret
end 28000
All software to-date
Working on something, as always.
Working on something, as always.
Re: Black squares...
The Fuse keyboard graphic was replaced by a much better one back in December. Unfortunately development of Fuse has rather stalled and they've not released a new version since before then.
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.