News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_mr_lou

Turn this into an RSX

Started by mr_lou, 18:55, 19 October 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mr_lou

Can someone help me turn the following into an RSX command?

10 FOR a=1 TO 17:POKE 39999+a,VAL("&"+MID$("DD7E00CDB4BBF5CD60BB320000F1C3B4BB",a*2-1,2)):NEXT

20 LOCATE x,y:CALL 40000,0:PRINT CHR$(PEEK(0)) '  this works as COPYCHR$ in any CPC


Instead of line 20 I could like to be able to instead go: |code,x,y or |ascii,x,y and get back the ASCII character code - not the actual CHR$ of the ASCII code.
In other words, I want an RSX command that'll return the ASCII code of the character on the screen at location x,y.

Thanks!

mr_lou

I should probably add that I still need everything to be done as in line 10. I.e. all from BASIC. No loading on any binary file, and no ASM source.  :)

AMSDOS

Quote from: mr_lou on 18:55, 19 October 18
Can someone help me turn the following into an RSX command?

10 FOR a=1 TO 17:POKE 39999+a,VAL("&"+MID$("DD7E00CDB4BBF5CD60BB320000F1C3B4BB",a*2-1,2)):NEXT

20 LOCATE x,y:CALL 40000,0:PRINT CHR$(PEEK(0)) '  this works as COPYCHR$ in any CPC


Instead of line 20 I could like to be able to instead go: |code,x,y or |ascii,x,y and get back the ASCII character code - not the actual CHR$ of the ASCII code.
In other words, I want an RSX command that'll return the ASCII code of the character on the screen at location x,y.

Thanks!


This is what I came up with, it uses a routine which is on the Wiki to print a 3 digit decimal number



10 p=1:FOR a=&A000 TO &A046:POKE a,VAL("&"+MID$("210FA0010AA0CDD1BCC913A0C319A0FCA60AA041534349C900DD6E00DD6602CD75BBCD60BBCD29A0C90664CD35A0060ACD35A006010E009038030C18FA80F579C630CD5ABBF1C9",p,2):p=p+2:NEXT a:CALL &A000



To use |ASCII,x,y and it will print the value at that position.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

mr_lou

Quote from: AMSDOS on 00:25, 20 October 18
This is what I came up with, it uses a routine which is on the Wiki to print a 3 digit decimal number
To use |ASCII,x,y and it will print the value at that position.

Thanks!

It does output a 3-digit number. But I am unable to put this number into a variable, like

a = |ascii,1,1
a$ = |ascii,1,1


Those just gives me a syntax error?

HAL6128

#4
Passing back a varable with a RSX should be able with @a (address)?


Should this function do the same as the Basic command ASC?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

mr_lou

#5
Quote from: HAL 6128 on 07:47, 20 October 18
Passing back a varable with a RSX should be able with @a (address)?


Should this function do the same as the Basic command ASC?
Yea, the idea was to be able to call |ascii,x,y to know which ascii code is currently visible on that location on the screen. And then be able to use that in game logic. I.e.
if |ascii,x,y = 239 then ...

EDIT: Hm, I realize RSX commands probably can't do that.....?

Urusergi

Quote from: HAL 6128 on 07:47, 20 October 18
Passing back a varable with a RSX should be able with @a (address)?

p=1:FOR a=&A000 TO &A02A:POKE a,VAL("&"+MID$("2109A0010DA0C3D1BC09A00DA012A0C318A041534349C900AFCDB4BBF5CD60BBDD6E00DD660177F1C3B4BB",p,2)):p=p+2:NEXT a:CALL &A000

Syntax:
a%=0:LOCATE x,y: |ASCII,@a%:PRINT a%

mr_lou

Quote from: Urusergi on 17:04, 20 October 18
p=1:FOR a=&A000 TO &A02A:POKE a,VAL("&"+MID$("2109A0010DA0C3D1BC09A00DA012A0C318A041534349C900AFCDB4BBF5CD60BBDD6E00DD660177F1C3B4BB",p,2)):p=p+2:NEXT a:CALL &A000

Syntax:
a%=0:LOCATE x,y: |ASCII,@a%:PRINT a%

I was just wondering about that exact syntax. Was just about to write a post asking about it. Except I'd prefer if the LOCATE command was also part of the RSX. (Wouldn't it speed things up a bit?)

So it becomes:
a%=0
|ascii,x,y,@a%
print a%


Or even better:
a%=0
|address,@a% ' Only need to be called once
|ascii,x,y
print a%



Urusergi

#8
Quote from: mr_lou on 17:09, 20 October 18
I was just wondering about that exact syntax. Was just about to write a post asking about it. Except I'd prefer if the LOCATE command was also part of the RSX. (Wouldn't it speed things up a bit?)

Ok, here you are 8)
p=1:FOR a=&A000 TO &A02D:POKE a,VAL("&"+MID$("2109A0010DA0C3D1BCFCA60DA012A0C318A041534349C900AFCDB4BBF5DD6E02DD6604CD75BBCD60BB12F1C3B4BB",p,2)):p=p+2:NEXT a:CALL &A000

Syntax:
10 a%=0:x%=1:y%=1
20 |ASCII,x%,y%,@a%
30 PRINT a%


EDIT: And the other one:
p=1:FOR a=&A000 TO &A040:POKE a,VAL("&"+MID$("2109A0010DA0C3D1BCFCA60DA015A0C322A0C327A0414444524553D341534349C900ED5341A0C9AFCDB4BBF5DD6E00DD6602CD75BBCD60BBED5B41A012F1C3B4BB",p,2)):p=p+2:NEXT a:CALL &A000

Syntax:
10 a%=0:|ADDRESS,@a%
20 x%=1:y%=1:|ASCII,x%,y%
30 PRINT a%

AMSDOS


Quote from: mr_lou on 07:36, 20 October 18
Thanks!


It does output a 3-digit number. But I am unable to put this number into a variable, like


a = |ascii,1,1
a$ = |ascii,1,1



Those just gives me a syntax error?


There was no mention of a variable, only that you wanted to output the ASCII value on a character at location x,y, that's how I read it in your initial post.


QuoteExcept I'd prefer if the LOCATE command was also part of the RSX. (Wouldn't it speed things up a bit?)


Not necessarily, I had this discussion here a couple of years ago, the outcome there was RSX routines were slower than the Tokenised BASIC. The situation changes when a program is compiled. There maybe some benefit from having a LOCATE incorporated with the TXT RD CHAR, though I think this is why some people choose to use CALL instead of a RSX.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

funkheld

#10

Hi good afternoon.


it is a waste of memory for the data.
first in a string and then again the data in another memory area.  >:(


bin from disk to memory.   ;D


greeting

AMSDOS

Quote from: funkheld on 20:03, 02 November 18
Hi good afternoon.


it is a waste of memory for the data.
first in a string and then again the data in another memory area.  >:(


bin from disk to memory.   ;D


greeting


That's just wasting Disk Space though  :D 


A BASIC Stub file is the most efficient, but it's a hassle writing a saver for it and is not so easy presenting a file to paste into an emulator and not good if that file is the subject of further editing.


Some foreign type-ins I've seen setup a REM statement at the start of a program and use that to store their M/C routine in that, again it would be double handling, though it would still be within the BASIC area. I think someone might have made a TXT RD CHAR (COPYCHR$) routine like that.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

mr_lou

There can be reasons for not wanting a bin on disk.

For example, I believe the CPCretroDev BASIC competition requires your BASIC game to only be in one file - and only use BASIC.
Not sure if any RSX commands invalidates the game though.

AMSDOS

Quote from: mr_lou on 21:41, 02 November 18
There can be reasons for not wanting a bin on disk.

For example, I believe the CPCretroDev BASIC competition requires your BASIC game to only be in one file - and only use BASIC.
Not sure if any RSX commands invalidates the game though.


To only use BASIC means no M/C routines can be used, I don't know how far that can be taken though. In this case it's a standard routine to read the screen and return a character using the firmware, in order to make the game compatible with all the machines.


I have highlighted alternative BASIC methods which do take more time to work on, though the results have been satisfying, despite using up a bit more memory.


One of the games I submitted earlier this year to the 10-Liners Compo had a Sprite Driver in it. I explained that to them when I submitted the game, though they must of weight the game accordingly and decided to submit it into one of the regular categories. But it did seem somewhat dicey to be testing to see what's acceptable and what's not or where that line is drawn.



* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod