Cross-compiler of my dreams

Pagina 2/7
1 | | 3 | 4 | 5 | 6 | 7

Van LeandroCorreia

Paladin (955)

afbeelding van LeandroCorreia

09-11-2004, 16:40

To BiFI...

No, not like this... Let me try again...

1) Type a BASIC program listing.
2) Click in the "Generate ROM button".
3) The compiler would generate an OPTIMIZED MACHINE CODE ROM file to be played in an emulator or real MSX.

Reason:

That would help in the creation of many new programs for the MSX. I'd love to use such a program to create new games.

Van LeandroCorreia

Paladin (955)

afbeelding van LeandroCorreia

09-11-2004, 16:46

To Flyguille...
Two of these problems could be solved in relatively simple ways...

Single/double precision variables could (should) be fixed point variables. Much faster!
Dynamic storage size of each alphanumeric variable... Well perhaps not dynamic variables at all... Just declared variables with their respective size at the beginning of the program.

Van flyguille

Prophet (3028)

afbeelding van flyguille

09-11-2004, 17:11

To Flyguille...
Two of these problems could be solved in relatively simple ways...

Single/double precision variables could (should) be fixed point variables. Much faster!
Dynamic storage size of each alphanumeric variable... Well perhaps not dynamic variables at all... Just declared variables with their respective size at the beginning of the program.

the problem is that declaring variable as fixed lenght is not the MSX-BASIC way....

is not just a problem of to declare all at beggining.... the problem is of the msx-basic programmers that usually uses variable like A$ for a lot of differents purposes , because the dynamic storage system allow that..... but that way is a lot slowly because when you increace the size of a variable the system needs to locate another location for the variable or to move all the content on the memory including the pointers.

I not knows exactly what is the storage system that uses MSX-BASIC.... i thinks when a variable reduce or increase its size, the rest is moved a bit. mmmm.... that is slower!!!.... or maybe it allow to change the location of the variable making holes of empty space in the alphanumeric variable.... that is faster but hard to handle the holes then.

fixed point single/double precision is used by MSX-BASIC, and it is slow.... the z80 can't handle those directly, because that you need to run large an slowly routines to parse a math formula.

in assembler is too EASY, check it....

A = A + B
------------
add a,b

A = 1 + 2
------------
ld a, 1
ld b, 2
add a,b

(where all values are 8 bits unsigned size)

for 16 bits

HL = 1 + 2
-------------
ld hl, 1
ld de, 2
add hl,de

as you see assembler is more easy than msx-basic, because there is only a fews instructions a lot less than msx-BASIC, and if you understand the principles you can start beging a professional programmer!!!!!

again, assembler hasn't instruction like A = b * c, but one time more MNBIOS support that

is too simply....

check it out

HL = 2 * 3
--------------
ld b, 2
ld c, 3
CALL MULT8

is not so hard, just little codes..........

Van LeandroCorreia

Paladin (955)

afbeelding van LeandroCorreia

09-11-2004, 17:21

Yes, but..

1) It's quite easy to get lost in an Assembly program...
2) You must know a lot of MSX architeture to program in Assembly.
3) BASIC is much simpler... If a compiler could be fast enough to program a game with a decent scroll, that'd be enough for me and most people. I do not know Assembly, but I am sure that it's not so difficult, only more tedious. However most programmers are scared of it.

By the way, would fixed point math of let me say, two digits precision be too slow, such as...
A=A+1.12 ? That'd be enough for most games.

Van flyguille

Prophet (3028)

afbeelding van flyguille

09-11-2004, 17:54

1.12 is a value that needs to be coded in BCD

because in BINARY you can't to say HL= 1.12 or HL =.12

the best way to handle the decimal value is packed it in BCD (binary coded decimal), with that kind of values is a lot slowly to calculate the result of a math formula.

That is the problem of all BASIC turbos likes TURBO basic ... where you can to run 20 times faster your basic program. But they only handle integer values, because handling single/double pressision values in assembler is too slow..... and abut speed to do that is the same than the MSX-BASIC speed

Van LeandroCorreia

Paladin (955)

afbeelding van LeandroCorreia

09-11-2004, 18:17

So, how to games made in Assembly control such decimal values? For instance...

Golvellius: In the vertical scrolling stages, the hero moves in a constant speed. It´s coordinates X and Y are incremented/decremented by a value of 1, for instance. However, when the player moves in a diagonal way, his coordinates are not moved in a X+1, Y+1 basis. Instead of that, both coordinates are changed in fractional values.

Anaza Kaleidoscope Special: enemy shots move in less then 1 by 1 pixel speeds too, to create different angles.

How did they achieve it?

Van NYYRIKKI

Enlighted (5939)

afbeelding van NYYRIKKI

09-11-2004, 18:33

LeandroCorreia : Why you just don't take X-BASIC? It is 98% MSX-BASIC compatible and it is extremely fast (will solve your speed problems). If you still want to play with ROM files, you can use abowe mentioned tools, just insert both ROM's.


I not knows exactly what is the storage system that uses MSX-BASIC.... i thinks when a variable reduce or increase its size, the rest is moved a bit. mmmm.... that is slower!!!

Actually no, MSX-BASIC is quite intelligent with variables. When size increases and it can not fit to memory area, that was reserved for the variable, the variable will be moved to location, where is more space. Rest of the variables are not touched. This surely causes memory fragmentation, but it is not that slow to use. When memory is filled up, MSX-BASIC starts a clean up process, and if that happens, you can go to take a cup of coffee.

To test the functionality, try for example this:

10 DIM A$(1000)
20 COLOR ,1
30 R=RND(1)*1000
40 A$(R)=A$(R)+"A"
50 COLOR ,2
60 GOTO 20

Van flyguille

Prophet (3028)

afbeelding van flyguille

09-11-2004, 18:45

becuase it has tricks in the programming

by example...

HL = will have the integer value (the whole part)
A = will have the fractional part... (so A = 1 will means as .01) (so A = 10 will means as .10)....

so then , we calculate like

HL.A = HL.A + DE.B

where DE & B is in the same scale meaning....

so the procedure to do that is:

A = A+B
if A > 99 then A=A-100: HL=HL+1
HL = HL + DE

so, we handles the fractional part separately of the interget part. both values coded in integer.... because in assembler only you can to have integer binaries.

so, the same in assembler is

//FIXED//

add a,b ; a = a + b
cp 100 ; to compare A with 100
jr c, label ; is "A" less than 100? if is TRUE it will jump
inc HL ; hl = hl + 1
sub 100 ; a = a - 100
label: add hl,de ; hl = hl + de

if you compares both codes, the basic version and assembler version are identically, only changes the syntax.... in both case we only uses INTEGER values to desigante single presission values.

Van NYYRIKKI

Enlighted (5939)

afbeelding van NYYRIKKI

09-11-2004, 18:48

There is no need to move anything less than a pixel as pixel is a smallest amount you can move, so that you can see the difference. Solution is simple: Just don't move it! To demonstrate this on BASIC:

10 SCREEN 2
20 SPRITE$(0)=STRING$(8,255)
30 ' Main loop
40 TIME=0:FOR I=0 TO 1:I=TIME:NEXT I 'Wait for screen refresh
50 R=R+1:IF R<5 THEN 80 ELSE R=0
60 ' Next line is executed not executed every time
70 PUT SPRITE 0,(X,0),8,0:X=(X+1)AND255
80 ' Next line is executed each time
90 PUT SPRITE 1,(X2,10),10,0:X2=(X2+1)AND255
100 GOTO 30

Van LeandroCorreia

Paladin (955)

afbeelding van LeandroCorreia

09-11-2004, 18:51

To Flyguille...

So, it can be done. Just slightly slower. Smile

To Nyyrikki...

The idea of such a "Dreamcompiler" is simple... Doing that, anyone could create great games for the MSX, and dump the ROMs on the web, and burn cartridges compatible with any MSX. Try to imagine new Konami quality games running on any MSX without any kind of extension. Smile

I am also aware of your idea... My Skooter remake (for PC) uses only integer variables (except for just one variable used for speed sync). Skooter moves at each game cycle, and enemies move at each two game cycles, to be half of Skooter´s speed. Floating numbers should be used for easier manipulation.

By the way, I did not use floating variables in Skooter, because of some minor problems in BlitzBasic (1.6+.1= 1.600000000001). That made my collision detections really painful Tongue

Pagina 2/7
1 | | 3 | 4 | 5 | 6 | 7