Assembly language question
Assembly language question
Hi all,
Just a question for you guys, I'm working on a game where I need the program to choose a text message/text description that should be contained in an array, my problem is how would I implement that in assembly language?
I've tried several different ways that I could come up with, but could never get the proper output message/description or the entire array would be displayed, so basically I had no control over displaying a couple messages/descriptions or just a single one.
I hope that made sense?!
Sure would appreciate a step in the right direction. TIA.
Just a question for you guys, I'm working on a game where I need the program to choose a text message/text description that should be contained in an array, my problem is how would I implement that in assembly language?
I've tried several different ways that I could come up with, but could never get the proper output message/description or the entire array would be displayed, so basically I had no control over displaying a couple messages/descriptions or just a single one.
I hope that made sense?!
Sure would appreciate a step in the right direction. TIA.
Re: Assembly language question
(On drawing space is shown with ')
I would see 3 different approaches. The first is the easiest, where each message has the same length.
The second and third approach uses an array of pointers for the text messages. The second approach points to a length of the message, followed by the message. The third approach points to a message, that is 0xFF terminated.
Re: Assembly language question
I'll give these a shot and see what happens. Thanks!
Re: Assembly language question
Here's my suggestion for the second approach:
Last edited by mrtinb on Tue Apr 26, 2022 11:25 pm, edited 1 time in total.
Re: Assembly language question
Another way to print a message...
from: viewtopic.php?t=3485
Cut a text with a high bit 7 in the text... (save 3bytes of memory per line offset&lenght)
from: viewtopic.php?t=3485
Cut a text with a high bit 7 in the text... (save 3bytes of memory per line offset&lenght)
Code: Select all
;; 10 PRINT USR 16514"tIL FAUDRAIT PEUT ETRE DU FEU..–AH,AH...VOUS ETES PRISONNIEr"
EXTERR .equ $005B ; Basic Break function ! Ignore line instructions.
CURSEUR .equ $8F5 ; Point to PRINT AT DEST.(BC=X,Y)
CHAINE .equ $B6B ; PRINT A CHAINE (BC=LEN;DE=TEXT LOC)
.Org $417B
LD HL,($4016)
LD BC,($407B)
NEXTCHAR:
INC HL
LD A,(HL)
CP $76
JP Z,EXTERR
BIT 7,A
JR Z,NEXTCHAR
DEC BC
LD A,B
OR C
JR NZ,NEXTCHAR
DISPLAY:
INC HL
LD A,(HL)
BIT 7,A
JR NZ,DISPLAY2
CP $0C
JR Z,NEXTLINE
CP $01
JR NZ,DISPLAY3
LD A,11
DISPLAY3:
RST 10H
JR DISPLAY
DISPLAY2:
RES 7,A
RST 10H
JP $005B
NEXTLINE:
LD DE,($400E)
NEXTCHR:
LD A,(DE)
CP $76
JR Z,DISPLAY
;EX DE,HL
;LD (HL),0
;EX DE,HL
LD A,0
RST 10h
INC DE
JR NEXTCHR
;TITRE REM TO SCREEN
LD DE,16514 ; FROM REM LINE
LD BC,$0606
LD ($407B),BC
NXTLINE:
PUSH DE
CALL CURSEUR
POP DE
LD H,D
LD L,E
LD BC,23
PUSH DE
CALL CHAINE
POP DE
EX DE,HL
LD BC,32
ADD HL,BC
EX DE,HL
LD BC,($407B)
INC B
LD ($407B),BC
LD A,B
CP 14
JR Z,EXIT
JR NXTLINE
EXIT:
LD BC,$0607
LD ($407B),BC
RET
.end
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Assembly language question
I would go for an endmarker, method 3.
If you use bit 6 as marker then you could use the byte itself too.
get byte, reset bit 6, do print, read again, increase pointer, if not set set continue print.
If you use bit 6 as marker then you could use the byte itself too.
get byte, reset bit 6, do print, read again, increase pointer, if not set set continue print.
Re: Assembly language question
I chose solution 2, as there is a built-in ROM routine to print message with pointer and length.
Re: Assembly language question
I was thinking...is there a way to create an array of pointers that could be chosen using a variable which would then display the appropriate message/description no matter how long it is?
Example:
variable = 1 - show message or decription #1, variable =2 - show message or description #2, etc...
Or am I overthinking this and the examples all of you posted could be used the same way, but I'm just not getting my head around it?
Thanks to all who replied so far, I appreciate the help!
Example:
variable = 1 - show message or decription #1, variable =2 - show message or description #2, etc...
Or am I overthinking this and the examples all of you posted could be used the same way, but I'm just not getting my head around it?
Thanks to all who replied so far, I appreciate the help!
Re: Assembly language question
The code I provided, can be used for messages up to 8 lines (256/32). The routine could be modified so the length before each message from 8-bit to 16-bit. Then the length of the text message is 64k.
However an easier approach is to use 2 messages to display 16 lines, or 3 messages to display 24 lines. 24 lines is the full screen.
However an easier approach is to use 2 messages to display 16 lines, or 3 messages to display 24 lines. 24 lines is the full screen.
Re: Assembly language question
Hi fitz301,
You had to use an ASM routine to reproduce a DATA/READ command...
I have seen this kind of routine in a "You Computer" magazine.
But my code also count the "message" index.
You had to type "POKE 16507,x" to display the right message (1-xxx)
To answer to Dr Beep, i had to set the 7th bits to enter the text in a PRINT Basic line command.
Any bytes with the 6th bit on can't be typed in Basic, and can't be displayed.
But, it's right... the 6th bit set to 1 can be integrated in a pure ASM code.
To answer to Martin,... it a good code too !
------------------------------------------------
Only normal characters will be displayed on the following code.
Up right scare character (/ ') = "
£=New-Line
Note:
- The first REM had to be change to display the new program header, but the line had to be POKEd to avoid to delete the ASM codes after it !
- Alway put an inverted character at the first character location.
- An inverted character clase the (cluster) message line(s) in the PRINT string.
- You will be able to type many lines to store DATAs like :
For example:
100 PRINT USR 16763;"«\
SCREW DRIVEr\
DOOr\
MESSAGE 1«"
- Was designed to replace GOSUB/RETURN Basic routines:
10 GOSUB 1000+((A-1)*2)
1000 PRINT "MESSAGE1"
1001 RETURN
1002 PRINT "MESSAGE2"
1003 RETURN
1004 PRINT
1005 RETURN
... How use 6 bytes per option/line. (12 bytes saved)
You had to use an ASM routine to reproduce a DATA/READ command...
I have seen this kind of routine in a "You Computer" magazine.
But my code also count the "message" index.
You had to type "POKE 16507,x" to display the right message (1-xxx)
To answer to Dr Beep, i had to set the 7th bits to enter the text in a PRINT Basic line command.
Any bytes with the 6th bit on can't be typed in Basic, and can't be displayed.
But, it's right... the 6th bit set to 1 can be integrated in a pure ASM code.
To answer to Martin,... it a good code too !
------------------------------------------------
Only normal characters will be displayed on the following code.
Up right scare character (/ ') = "
£=New-Line
Note:
- The first REM had to be change to display the new program header, but the line had to be POKEd to avoid to delete the ASM codes after it !
- Alway put an inverted character at the first character location.
- An inverted character clase the (cluster) message line(s) in the PRINT string.
- You will be able to type many lines to store DATAs like :
For example:
100 PRINT USR 16763;"«\
SCREW DRIVEr\
DOOr\
MESSAGE 1«"
- Was designed to replace GOSUB/RETURN Basic routines:
10 GOSUB 1000+((A-1)*2)
1000 PRINT "MESSAGE1"
1001 RETURN
1002 PRINT "MESSAGE2"
1003 RETURN
1004 PRINT
1005 RETURN
... How use 6 bytes per option/line. (12 bytes saved)
Code: Select all
1 REM [HEX:\
85,89,89,89,89,89,89,89,\
89,89,89,89,89,89,89,89,\
89,89,89,89,89,89,05,00,\
82,00,00,00,00,00,00,00,\
88,05,88,88,88,88,00,31,\
26,00,32,26,2E,38,34,33,\
00,88,88,88,88,85,88,00,\
80,82,00,00,00,00,00,00,\
88,05,88,88,00,29,3A,00,\
35,37,34,2B,2A,38,38,2A,\
3A,37,00,88,88,85,88,00,\
80,80,82,00,00,00,00,00,\
88,05,88,88,88,88,88,00,\
2B,34,31,2E,27,3A,38,00,\
88,88,88,88,88,85,88,00,\
80,80,80,05,00,00,00,00,\
85,8A,8A,8A,8A,8A,8A,8A,\
8A,8A,8A,8A,8A,8A,8A,8A,\
8A,8A,8A,8A,8A,8A,05,00,\
80,80,07,00,00,00,00,00,\
00,00,35,37,34,2C,37,26,\
32,32,2A,00,2A,28,37,2E,\
39,00,35,26,37,00,00,00,\
80,07,00,00,00,00,00,00,\
00,00,00,00,00,26,31,26,\
2E,33,00,27,37,2A,2C,2A,\
34,33,00,00,00,00,00,00,\
07,00,00,00,00,00,00,00,\
00,00,35,34,3A,37,00,32,\
2E,28,37,34,16,38,3E,38,\
39,2A,32,2A,38,1B,00,76,\
76,2A,16,40,ED,4B,7B,40,\
23,7E,FE,76,CA,5B,00,CB,\
7F,28,F5,0B,78,B1,20,F0,\
23,7E,CB,7F,20,0D,FE,0C,\
28,0F,FE,01,20,02,3E,0B,\
D7,18,ED,CB,BF,D7,C3,5B,\
00,ED,5B,0E,40,1A,FE,76,\
28,DE,3E,00,D7,13,18,F5,\
11,82,40,01,04,06,ED,43,\
7B,40,D5,CD,F5,08,D1,62,\
6B,01,17,00,D5,CD,6B,0B,\
D1,EB,01,20,00,09,EB,ED,\
4B,7B,40,04,ED,43,7B,40,\
78,FE,0E,28,02,18,DB,01,\
07,06,ED,43,7B,40,C9 ]
10 FOR A=1 TO 4
20 POKE 16507,A
30 PRINT USR 16763;"«\
VOUS ETES DEVANT UNE MAISON£\
LA PORTE EST OUVERTE–\
VOUS ETES DANS UN COULOIR,IL Y A\
UNE PORTE A L¶EST ET UNE PORTE£\
A L¶OUEST–\
VOUS ETES DANS UN SALON,IL Y A£\
UNE PORTE A L¶OUEST–\
IL Y A UNE DROLE D¶ODEUR–"
36 PRINT
37 PRINT "--------------------------------"
38 PAUSE 1000
40 NEXT A
Xavier ...on the Facebook groupe : "Zx81 France"(fr)