BASIC
BASIC
Im not sure what the best way to ask this question is but Is it possible to print a variable value as inverse text? For example if the score for a game was held in Variable S and I wanted to print something like this:
10 PRINT "SCORE : "; S; " LIVES: "; L
Where everything including the Variables would be white text on black. I can get the text printing OK, but not the variables.
Also, is there a way to save a program so that it autoruns when loaded?
10 PRINT "SCORE : "; S; " LIVES: "; L
Where everything including the Variables would be white text on black. I can get the text printing OK, but not the variables.
Also, is there a way to save a program so that it autoruns when loaded?
Re: BASIC
That one is easy...Also, is there a way to save a program so that it autoruns when loaded?
Just put two new Lines to the end of the Program like this:
998 save "nameoftheprogram"
999 run
Then type in GOTO 998
The next time you load in the Program it will start for himself.
Greetings
Jens (German ZX-Team)
eyerything will be okay in the end.
if it´s not okay, it´s not the end.
and: uıɐbɐ ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ɹǝʌǝ ɹǝʌǝu ןןıʍ ı
if it´s not okay, it´s not the end.
and: uıɐbɐ ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ɹǝʌǝ ɹǝʌǝu ןןıʍ ı
Re: BASIC
Very simple, but slow to continuously update:rune wrote: 10 PRINT "SCORE : "; S; " LIVES: "; L
1 REM EXAMLE
10 LET S=100
20 LET L=5
30 LET S$=STR$ S
40 GOSUB 9000
50 PRINT "SCORE: ";S$;
60 LET S$=STR$ L
70 GOSUB 9000
80 PRINT " LIVES: ";S$
100 STOP
9000 REM INV TEXT VAR
9001 FOR I=1 TO LEN S$
9010 LET S$(I)=CHR$ (CODE S$(I)+128)
9020 NEXT I
9030 RETURN
"The Earth is just too small and fragile a basket for the human race to keep all its eggs in." ― Robert Anson Heinlein
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
Re: BASIC
Oops, even simpler:
10 LET S=100
20 LET L=5
50 LET S$="SCORE: "+STR$ S+" LIVES: "+STR$ L
70 GOSUB 9000
80 PRINT AT 0,0;S$
90 LET S=S+10
100 LET L=L+1
110 GOTO 50
9000 REM INV TEXT VAR
9001 FOR I=1 TO LEN S$
9010 LET S$(I)=CHR$ (CODE S$(I)+128)
9020 NEXT I
9030 RETURN
P.S. But still slow.
10 LET S=100
20 LET L=5
50 LET S$="SCORE: "+STR$ S+" LIVES: "+STR$ L
70 GOSUB 9000
80 PRINT AT 0,0;S$
90 LET S=S+10
100 LET L=L+1
110 GOTO 50
9000 REM INV TEXT VAR
9001 FOR I=1 TO LEN S$
9010 LET S$(I)=CHR$ (CODE S$(I)+128)
9020 NEXT I
9030 RETURN
P.S. But still slow.
- Attachments
-
- inv.p
- (1.21 KiB) Downloaded 269 times
"The Earth is just too small and fragile a basket for the human race to keep all its eggs in." ― Robert Anson Heinlein
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
Re: BASIC
Version a little faster, but not much.
Even faster only machine code ...
Even faster only machine code ...
- Attachments
-
- inv2.P
- (1.27 KiB) Downloaded 259 times
"The Earth is just too small and fragile a basket for the human race to keep all its eggs in." ― Robert Anson Heinlein
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
Re: BASIC
hi,
Code: Select all
1 REM [HEX:\
2A,0C,40,11,00,00,19,01,00,03,3E,\
76,23,BE,28,FC,3E,80,AE,77,0B,78,\
B1,20,F1,C9 ]
10 LET S=100
20 LET L=5
25 LET A=16514
30 PRINT"SCORE: ";
31 RAND USR A
32 PRINT S;
33 RAND USR A
34 PRINT " LIVES: ";
35 RAND USR A
36 PRINT L;
37 RAND USR A
;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------
; Zx81 Program name: VB81 XuR [test2.txt] :
; REM line name: D=16514/16600 : H=4082/40D8
#define ORG .org ; TASM cross-assembler definitions
#define equ .equ
;------- Rom and Ram Symbols -------
RAM_D_FILE equ $400C
ORG $4082 ; [@16514/@h4082]
LD HL,(RAM_D_FILE) ; GET D-FILE
LD DE,$0000
ADD HL,DE
LD BC,$0300
Lb408C:
LD A,$76
Lb408E:
INC HL
CP (HL)
JR Z, Lb408E ; [$408E:16526]
LD A,$80
XOR (HL)
LD (HL),A
DEC BC
LD A,B
OR C
JR NZ, Lb408C ; [$408C:16524]
RET ; ==========================
.end
Code: Select all
; VB81 XuR [test2.txt]
; 1 REM: 26 Bytes@4082-409B
16514:42,12,64,17,0,0,25,1,0,3
16524:62,118,35,190,40,252,62
16531:128,174,119,11,120,177,32
16538:241,201
Last edited by XavSnap on Wed Oct 01, 2014 6:42 pm, edited 1 time in total.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: BASIC
XavSnap,
Looks great, I'm going to look at the code later today.
Can I ask how you got the Basic in a format that could be copied and pasted above?
It would be very useful if its possible to use an external editor and import/export with an emulator.
OK - edited to say I've got the routine into the emulator and it works brilliantly. I even understand what it does and will modify it to invert the last line instead of the the full screen.
That's two things I've achieved today
Looks great, I'm going to look at the code later today.
Can I ask how you got the Basic in a format that could be copied and pasted above?
It would be very useful if its possible to use an external editor and import/export with an emulator.
OK - edited to say I've got the routine into the emulator and it works brilliantly. I even understand what it does and will modify it to invert the last line instead of the the full screen.
That's two things I've achieved today
Last edited by rune on Wed Oct 01, 2014 8:33 pm, edited 1 time in total.