Dicas de Programação
08 de Agosto de 2007 | Autor: Marcelo Martins ( Clube do TK90X )
Se você conhece alguma dica legal, colabore!
Compartilhe seu conhecimento.
MERGE em programas protegidos
10 FOR N=23296 TO 23314: READ A: POKE N,A: NEXT N: RAND USR 23296 20 DATA 62,1,33,16,91,50,116,92,34,93,92,205,14,6,207,8,34,34,13 |
Esta dica deixa invisível o começo da primeira linha ( 10 REM ), além de zerar a linha.
Atenção: deixar 8 espaços após o 10 REM _ _ _ _ _ _ _ _ DICAS DE ...
10 REM DICAS DE PROGRAMAÇÃO 20 FOR N=23760 TO 23767: POKE N,8: NEXT N: POKE 23756,0 |
Tanto faz digitar em minúsculo ou maiúsculo.
10 PRINT "Você quer mais dicas de programação? (S/N)" 20 IF CHR$ PEEK 23556="S" THE RUN: STOP |
Quantos bytes seu programa está ocupando na memória RAM?
PRINT PEEK 23627+256*PEEK 23628-PEEK 23635-256*PEEK 23636 |
Quantos bytes livres tem na memória RAM?
PRINT PEEK 23730+256*PEEK 23731-PEEK 23653-256*PEEK 23654
OU
PRINT 65536-USR 7962 |
SAVE direto, sem a mensagem "Ligue o gravador...."
SAVE "dicas": POKE PEEK 23631+256*PEEK 23632+2,181: SAVE "dicas2" |
Esta dica faz a mensagem girar em seu eixo.
10 FOR N=30 TO 0 STEP -1: POKE 23606,N 20 PRINT AT 10,8;"DICAS DE PROGRAMAÇÃO" 30 PAUSE 3: NEXT N |
Um CLS diferente
10 FOR N=30000 TO 30017: READ A: POKE N,A: NEXT N 20 DATA 33,255,87,14,32,167,203,38,43,13,32,250,62,63, 188,32,242,201:LIST 30 FOR N=0 TO 7: RAND USR 30000: NEXT N |
Efeitos com brilho
10 FOR N=30000 TO 30016: READ A: POKE N,A: NEXT N (liga) 20 FOR X=35000 TO 35016: READ B: POKE X,B: NEXT X (desliga) 30 DATA 33,0,88,6,3,197,6,0,203,246,35,16,251,193,16,245,201 40 DATA 33,0,88,6,3,197,6,0,203,182,35,16,251,193,16,245,201 50 LIST: FOR N=0 TO 50: RAND USR 30000: PAUSE 2: RAND USR 35000: NEXT N |
Efeitos com cor
10 FOR N=30000 TO 30024: READ A: POKE N,A: NEXT N 20 DATA 62,7,230,7,87,33,0,88,6,3,197,6,0,126,230,248,178,119, 35,16,248,193,16,242,201 30 PRINT AT 10,12;"DICAS DE PROGRAMAÇÃO": FOR N=0 TO 7: POKE 30001,N: RAND USR 30000: NEXT N: GOTO 30 |
Efeitos com cor de fundo
10 FOR N=30000 TO 30030: READ A: POKE N,A: NEXT N 20 DATA 62,7,203,39,203,39,203,39,230,56,87,33,0,88,6,3,197,6,0, 126,230,199,178,119,35,16,248,193,16,242,201 30 PRINT AT 10,12;"DICAS DE PROGRAMAÇÃO": FOR N=0 TO 7: POKE 30001,N: RAND USR 30000: NEXT N: GOTO 30 |
Scroll em diagonal
10 FOR N=30000 TO 30024: READ A: POKE N,A: NEXT N 20 DATA 6,192,17,255,87,213,225,43,197,1,31,0,26,237,184,35,54,0, 43,43,27,193,16,240,201 30 DIM T$(704): FOR F=1 TO 704: LET T$(F)=CHR$ (INT(RND*133)+32): NEXT F: PRINT T$ 40 FOR N=0 TO 23: RAND USR 30000: RAND USR 3190: NEXT N |
Super CLS com som
10 FOR N=30000 TO 30034: READ A: POKE N,A: NEXT N 20 DATA 58,72,92,245,6,8,17,0,24,33,0,64,126,211,254,203,30,35,27, 122,179,32,245,16,237,241,31,31,31,211,254,205,107,13,201 30 LIST: PAUSE 0: RAND USR 30000: GOTO 30 |
Espelho
10 CLEAR 64999: FOR N=65000 TO 65018: READ A: POKE N,A: NEXT N 20 DATA 33,0,64,78,6,8,203,17,31,16,251,119,35,124,254,88,32,241,201 30 CLS: LIST: RAND USR 65000 |
Destacando mensagens
10 FOR N=30000 TO 30044: READ A: POKE N,A: NEXT N: INK 7 20 DATA 14,32,33,0,88,6,24,17,32,0,229,54,18,25,16,251,197,33,208, 0,17,32,0,205,181,3,193,225 30 DATA 229,6,24,17,32,0,54,15,2,5,16,251,225,35,13,32,217,201 40 LIST: RAND USR 30000 |
Inverte a tela (sem mexer nos atributos)
10 CLEAR 49999: FOR N=50000 TO 50018: READ A: POKE N,A: NEXT N 20 DATA 243,33,255,23,1,0,64,10,47,2,3,43,62,255,188,32,246,251,201 30 LIST: RAND USR 50000 |
Som
10 CLEAR 29999: FOR N=30000 TO 30037: READ A: POKE N,A: NEXT N 20 DATA 38,2,1,25,1,22,0,122,211,254,20,124,186,32,248,11,62,0, 184,32,240,36,210,188,32,231,201 30 RAND USR 30000 |
Som em Basic
10 FOR N=0 TO 60 STEP 5: SOUND.01,N: SOUND.01,N-2: NEXT N |
Escrevendo diferente
10 INPUT A$: FOR N=1 TO LEN A$: LET B=CODE A$(N) 20 LET C=15360+B*8: LET D=20671+N: FOR P=0 TO 7 30 POKE D+(256*P), PEEK (C+P): NEXT P: NEXT N: PAUSE 0 |
Escrevendo ao contrário
10 INPUT A$: PRINT AT 10,0;A$;: LET V$=CHR$ 8 20 FOR N=1 TO LEN A$: PRINT V$+A$(N)+V$;: NEXT N |
Armazenador de tela
10 CLEAR 56999: FOR N=57000 TO 57023: READ A: POKE N,A: NEXT N 20 DATA 33,0,64,17,0,223,1,0,27,237,176,201,33,0,223,17,0,64,1,0, 27,237,176,201
RAND USR 57000 = Guarda a tela na memória RAND USR 57012 = Mostra a tela armazenado na memória |
CLS direfente II (de cima para baixo)
1 REM coloque aqui 65 caractéres 10 FOR N=23760 TO 23824: READ X: POKE N,X: NEXT N 20 DATA 62,0,33,0,64,205,229,92,33,0,72,205,229,92,33,0,80,205,229, 92,201 30 DATA 229,245,6,8,229,22,0,54,0,35,20,122,254,32,32,247,17,0,32, 175,27,186,32,252,225,17,0,1 40 DATA 25,16,229,241,225,17,32,0,25,60,254,8,32,214,175,201
RAND USR 23760 = Executa o novo CLS POKE 23799,x = onde x, quanto menor for, mais rápido se executará o CLS. Valor máximo para x é 255. |
Letreiro dinâmico
Atenção: na linha 10 deve conter 32 espaços entre as aspas.
10 LET B$=" --- 32 espaços --- " 20 LET A$=B$+"*** CLUBE DO TK90X ***": LET A$=A$+B$+B$ 30 FOR N=1 TO LEN A$-31: PRINT AT 21,0; A$ (N TO N+31 40 IF N>32 THEN PRINT AT 0,0;A$ (N-32 TO N-1) 50 PAUSE 10: NEXT N: GOTO 30 |
Saindo pela direita (Tira a tela pela direita)
10 FOR N=0 TO 25: READ A: POKE 30000+N,A: NEXT N 20 DATA 14,0,33,0,64,62,192,6,16,167,203,22,35,203,22,35,16,24,8,61, 32,242,13,32,234,201,0 30 LIST: RAND USR 30000 |
Cronômetro
10 POKE 23674,255: POKE 23673,255: POKE 23672, 255 20 LET T=(65536*PEEK 23674+PEEK 23672+256*PEEK 23673)/60 30 PRINT AT 11,12; INT (T/60);":"; INT (T-INT (T/60)*60);"_ _ _ _" 40 GOTO 20
"_ _ _ _" = 4 espaços |
Destacando o texto
10 BORDER 0: PAPER 0: INK 5: OVER 1: BRIGHT 1: CLS 20 LET A$=" CLUBE DO TK90X": LET A=LEN A$: LET B=(INT (10-(A/2)))*8 30 PRINT OVER 1; AT 1,B/B;A$ 40 FOR X=8 TO B+A*8: PLOT X,160: DRAW 0,7: NEXT X 50 GOTO 40
...LET B=(INT (10 ... este 10 é o valor para coluna ...PLOT X,160... este 160 é o valor para linha |
Túnel 3D
10 BORDER 0: OVER 1: FOR T=0 TO 255: PLOT T,0: DRAW 255-T*2,175: NEXT T 20 FOR T=175 TO 0 STEP -1: PLOT 0, T: DRAW 255,175-T*2: NEXT T |
Grave seu programa BASIC como se fosse Linguagem de Máquina
Acrescente no final do seu programa Basic as seguintes linhas:
9997 LET A=PEEK 23653+256*PEEK 23654 9998 SAVE "nome"CODE 23552, A+23500 9999 RUN
Grave com GOTO 9997 Carregue com LOAD ""CODE |
Preenche a tela
10 FOR N=30000 TO 30011: READ A: POKE N,A: NEXT N 20 DATA 33,0,0,17,0,64,1,0,24,237,176,201 |
Preenche a tela de atributos
10 FOR N=30000 TO 30020: READ A: POKE N,A: NEXT N 20 DATA 17,0,88,46,0,237,95,71,58,140,92,128,230,63,103,1,0, 3,237,176,201 |
16 ou 48 Kbytes?
Descubra se seu TK90X/95/ZX Spectrum tem 16 ou 48 Kb de memória:
PRINT PEEK 23732 + 256 * PEEK 23733
Se o resultado for 32767 = 16Kb Se o resultado for 65535 = 48Kb |