News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_p9iaai

I've recreated an old CPC type-in game

Started by p9iaai, 10:02, 08 December 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eto

Quote from: scruss on 00:03, 13 December 24ooh, nice. Your code seemed to be split into three lines, so Arnold's Auto-Type tool didn't like it. This worked:
Indeed. It was on purpose as the code-block does not have any line breaks and then is hard to read. If you don't want to type it manually, you can also use the DSK that was attached.

Quote from: scruss on 00:03, 13 December 24There should be a stop between games
Totally agreed! Unfortunately there is simply not enough space in the lin editor. At least not with my approach. I would need another 25 characters or so to add a pause between games.

If you want to add a pause between games, just remove the "else run" in line 1 and add this:

2 while inkey(18)<0:wend:run
This code waits for RETURN to be pressed.

eto

Not sure if it counts but this here will make a one-liner including pause:

1 l1=PEEK(&170):l2=PEEK(&170+l1):l3=PEEK(&170+l1+l2):POKE &170+l1,l2+l3:POKE &170+l1+l2-1,1:FOR i=&170+l1+l2 TO &170+l1+l2+l3-4:POKE i,PEEK(i+4):NEXT:DELETE 1:END
2 MODE 1:L=L+1:MOVE 0,0:DRAW 636,0,1:DRAWR 0,160:DRAWR 0,78,3:DRAWR 0,160,1:DRAW 0,398:PLOT 0,200,2:PRINT L:FOR i=0 TO 2+l*3:LOCATE 3+RND*36,2+RND*22:PRINT"*":NEXT:z=0:WHILE z=0:y=SQR(1):z=TESTR(2,4*INKEY(47)+2):PLOTR 0,0:WEND:SOUND 1,400
3 IF z=3 THEN 2 ELSE WHILE INKEY(18)<0:WEND:RUN

It's longer than the line editor can handle but the final line will still be less than 256 bytes.

Jean-Marie

You can get rid of the MODE 1 instruction using the Control code number 4, which is produced when pressing CTRL and D. It's a thunderbolt character, and cannot be copy/pasted from PC to CPC.

p9iaai


eto

Quote from: Jean-Marie on 02:20, 13 December 24You can get rid of the MODE 1 instruction using the Control code number 4, which is produced when pressing CTRL and D. It's a thunderbolt character, and cannot be copy/pasted from PC to CPC.
Oh I did not know that I can concatenate a String with a variable without a semicolon. :-) 

Control codes are super convenient to save space and well worth mentioning them as an option. I did not use them here as I wanted to do it in the spirit of a real type-in and control characters have often been a challenge for a type-in. 

scruss

Quote from: Jean-Marie on 02:20, 13 December 24You can get rid of the MODE 1 instruction using the Control code number 4, which is produced when pressing CTRL and D. It's a thunderbolt character, and cannot be copy/pasted from PC to CPC.
OOh, that was clever.

I remembered the frame flyback call, so this bops along at a decent speed and is editable:
1MODE 1:L=L+1:?L:MOVE 0,0:DRAW 636,0,1:DRAWR 0,160:DRAWR 0,78,3:DRAWR 0,160,1:DRAW 0,398:PLOT 0,200,2:FOR i=0 TO 2+L*3:LOCATE 3+RND*36,2+RND*22:?"*":NEXT:z=0:WHILE z=0:CALL &BD19:z=TESTR(2,4*INKEY(47)+2):PLOTR 0,0:WEND:IF z=3 THEN 1 ELSE RUN

To be really true to the Beeb version, the screen aspect ratio should be 5:4, but that's only for purists


Jean-Marie

Remember we can write CALL&BD19, all stuck, to save 1 character.
Similarly, IF z=3THEN 1ELSE RUN is valid!

scruss

So final short form of Jean-Marie's code, with all extra spaces removed, might be:
1MODE 1:L=L+1:?L:MOVE 0,0:DRAW 636,0,1:DRAWR 0,160:DRAWR 0,78,3:DRAWR 0,160,1:DRAW 0,398:PLOT 0,200,2:FOR i=0 TO 2+L*3:LOCATE 3+RND*36,2+RND*22:?"*":NEXT:z=0:WHILE z=0:CALL&BD19:z=TESTR(2,4*INKEY(47)+2):PLOTR 0,0:WEND:IF z=3THEN 1ELSE RUN
If you use the Arnold emulator under Linux (and possible even then, a very specific version), you can get it to start, auto-type the code and run with:
arnold --autotype='1MODE 1:L=L+1:?L:MOVE 0,0:DRAW 636,0,1:DRAWR 0,160:DRAWR 0,78,3:DRAWR 0,160,1:DRAW 0,398:PLOT 0,200,2:FOR i=0 TO 2+L*3:LOCATE 3+RND*36,2+RND*22:?"*":NEXT:z=0:WHILE z=0:CALL&BD19:z=TESTR(2,4*INKEY(47)+2):PLOTR 0,0:WEND:IF z=3THEN 1ELSE RUN\nRUN\n'

I'm sure that will make the other user of Arnold under Linux quite happy ...

Powered by SMFPacks Menu Editor Mod