MSXbas2ROM question

Par Pineapple

Resident (47)

Portrait de Pineapple

28-08-2021, 16:11

OK, so I got MSXbas2ROM working, and I really like it. I couldn't get it to work at first because I didn't realize that my basic program needed to be saved as ASCII.

Anyway, I have run into an issue that I haven't been able to solve yet:
It looks like variables are limited in size to 9999.
Is there a workaround for this, like a way to specify a variable as a larger integer?

I am using a variable for the score, and if I get to 10000 points, the score turns into "1E+04"
Anyone know a solution?

!login ou Inscrivez-vous pour poster

Par MsxKun

Paragon (1134)

Portrait de MsxKun

28-08-2021, 16:13

Pineapple wrote:

Anyone know a solution?

Yes, but you are not going to like it Sad

Par thegeps

Paragon (1260)

Portrait de thegeps

28-08-2021, 17:30

Well you can use a workaround. You are compiling your basic so it should be fine:
Instead of have a single variable for the score you have to use a variable for every digit of your score that could be changed during the game (this way is used on C64 asm because 6510 BCD is bugged).
So if your score is modified by hundreds you need variables from hundreds and up:
If your max score is 999900 (incrementing by hundreds) your variables will be:
S1,S2,S3 and S4 (S4 is hundreds, s3 thousands and so on)
So when score=score+100 (but the same for 500) you'll do:

S4=S4+1:IF S4>=10 THEN S4=S4-10:S3=S3+1:IFS3>=10THENS3=S3-10:S2=S2+1:IFS2>=10THENS2=S2-10:S1=S1+1:IFS1>9THENS1=9

PRINT S1;S2;S3;S4;"00"

Par syn

Prophet (2135)

Portrait de syn

28-08-2021, 19:09

GuyveR800 says you can use PRINT USING, which is able to do what you want.

Par Pineapple

Resident (47)

Portrait de Pineapple

28-08-2021, 22:00

Also, the documentation says to use RANDOMIZE instead of rnd(-time), but I can't seem to get "RANDOMIZE" to compile...

Par Amaury Carvalho

Resident (41)

Portrait de Amaury Carvalho

30-08-2021, 02:13

Hi, Pineapple!

First of all, thanks for testing MSXBAS2ROM!!

Printing numerical decimal values above 9999 will result in scientific notation just like occurs with Basic Kun. Unfortunately, it's one of many differences between interpreter and MSXBAS2ROM.

So, the code below will print different results comparing compiled from interpreted code:

10 A% = 10000 : B# = 10000 : C = 9999
20 PRINT A%, B#, C, STR$(B#)

You can use integer values instead, but with the draw back that your score will be limited to a max of 32767 points.

Also, the PRINT USING statement is not supported yet, but its in my backlog to implement in the future.

The MSXBAS2ROM functionalities backlog follow some prioritization rules (mostly respecting time, effort and incremental limitations), and in general prioritizes Patreon/Catarse supporters suggestions.

I hope I clarified your doubts and thanks again!

Par Pineapple

Resident (47)

Portrait de Pineapple

30-08-2021, 04:16

Thank you.
I had to do several workarounds to get my game to work with msxbas2rom, but it has been invaluable in helping me to finish my msxdev21 submission.

One limitation I found is that msxbas2rom often wants variables to be integers, so I had to use int() to solve a few problems with my game.

Also, I found that a for loop can't start with a variable, but CAN end with one.
for example FOR A TO B won't work, but FOR 0 TO B will work.