Page 1 of 3
BASIC
Posted: Sun Sep 28, 2014 4:10 pm
by rune
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?
Re: BASIC
Posted: Sun Sep 28, 2014 4:34 pm
by zx81jens
Also, is there a way to save a program so that it autoruns when loaded?
That one is easy...
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)
Re: BASIC
Posted: Sun Sep 28, 2014 5:26 pm
by rune
Thanks Jens
I like simple solutions.
Re: BASIC
Posted: Sun Sep 28, 2014 10:00 pm
by Buka
rune wrote:
10 PRINT "SCORE : "; S; " LIVES: "; L
Very simple, but slow to continuously update:
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
Re: BASIC
Posted: Sun Sep 28, 2014 10:06 pm
by Buka
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.
Re: BASIC
Posted: Mon Sep 29, 2014 8:26 am
by rune
Thanks Buka
I can see what you are doing, but as you say it will be slow. Probably to slow for anything where the score changes rapidly.
Re: BASIC
Posted: Mon Sep 29, 2014 10:16 am
by Buka
Version a little faster, but not much.
Even faster only machine code ...
Re: BASIC
Posted: Tue Sep 30, 2014 12:45 am
by XavSnap
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
Re: BASIC
Posted: Wed Oct 01, 2014 9:18 am
by rune
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
Re: BASIC
Posted: Wed Oct 01, 2014 1:45 pm
by dr beep
When you know where your code is printed on the screen you can also change the inversebit of the score on the screen.