BASIC

General Chit Chat about Sinclair Computers and their Clones
rune
Posts: 153
Joined: Thu Sep 04, 2014 8:35 am

BASIC

Post by rune » Sun Sep 28, 2014 4:10 pm

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?

User avatar
zx81jens
Posts: 183
Joined: Sat May 10, 2008 8:26 am
Location: a Basement in Nienburg / Germany

Re: BASIC

Post by zx81jens » Sun Sep 28, 2014 4:34 pm

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)
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 ןןıʍ ı

rune
Posts: 153
Joined: Thu Sep 04, 2014 8:35 am

Re: BASIC

Post by rune » Sun Sep 28, 2014 5:26 pm

Thanks Jens

I like simple solutions.

User avatar
Buka
Posts: 33
Joined: Sun May 12, 2013 2:51 pm
Location: Russia

Re: BASIC

Post by Buka » Sun Sep 28, 2014 10:00 pm

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
"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 ...

User avatar
Buka
Posts: 33
Joined: Sun May 12, 2013 2:51 pm
Location: Russia

Re: BASIC

Post by Buka » Sun Sep 28, 2014 10:06 pm

Oops, even simpler: :oops:

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 25 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 ...

rune
Posts: 153
Joined: Thu Sep 04, 2014 8:35 am

Re: BASIC

Post by rune » Mon Sep 29, 2014 8:26 am

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.

User avatar
Buka
Posts: 33
Joined: Sun May 12, 2013 2:51 pm
Location: Russia

Re: BASIC

Post by Buka » Mon Sep 29, 2014 10:16 am

Version a little faster, but not much.

Even faster only machine code ... ;)
Attachments
inv2.P
(1.27 KiB) Downloaded 27 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 ...

User avatar
XavSnap
Posts: 498
Joined: Sat May 10, 2008 4:23 pm

Re: BASIC

Post by XavSnap » Tue Sep 30, 2014 12:45 am

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.

rune
Posts: 153
Joined: Thu Sep 04, 2014 8:35 am

Re: BASIC

Post by rune » Wed Oct 01, 2014 9:18 am

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 :)
Last edited by rune on Wed Oct 01, 2014 8:33 pm, edited 1 time in total.

dr beep
Posts: 1105
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: BASIC

Post by dr beep » Wed Oct 01, 2014 1:45 pm

When you know where your code is printed on the screen you can also change the inversebit of the score on the screen.

Post Reply