.bas file combined with .bin file (Development MSX Fora)MSX Resource Center            
            
English Nederlands Espa�ol Portugu�s Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 63 gasten en 2 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - .bas file combined with .bin file

Schrijver

.bas file combined with .bin file

norakomi
msx professional
Berichten: 861
Geplaatst: 13 Februari 2005, 22:50   
Let´s give this example to clarify my question.

lets say i take all 16 colors of my game (screen 5) and darken them one tint.
then darken them again and again.
result: a fade out.

I have a programm to make bin files out of bas files.

NOW:
Can i make a bin file to fade out the colours in my game?
And can I call or usr this file while i´m in my .bas file in the middle of my game,

(like a: If hero=hit then gosub"fadeout.bin" .............
and later on in the fadeout.bin file..... return (to game.bas)



This whole question is because in basic (and especially 2gether with nBasic), there is a limited amount of memory, a limit in the size of my game.
So if I can split my file in more than one file, binary files, or machine coded files
this would be beneficial for my basic file..........

I guess :?
DarQ
msx professional
Berichten: 837
Geplaatst: 13 Februari 2005, 23:54   
you can use a bin file to fadeout/in.
but you have to know the adresses of the routines in the binfile.

fadeout could be at #c000
fadein could be at #c010

defusr(0)=&hc000:a=usr(0) to fadeout..

ah well, you can also use basic to fadeout. with NBASIC it's fast enough.
ill fire openmsx and see what i used... i think it was old code:
fori=0to7:forj=0to31:x=vpeek(&h7680+j)-17:x=x+(xand&h88)/8:vpoke&h7680+j,x:nextj:color=restore:nexti:cls

dont forget _turboon:<code>:_turbooff or it'll be very slow
DarQ
msx professional
Berichten: 837
Geplaatst: 14 Februari 2005, 00:01   
oh, using more binary routines spares a LOT of memory... using ASM for fading,cursorcontrol and that sort of things can save you a lot..
BiFi
msx guru
Berichten: 3142
Geplaatst: 14 Februari 2005, 09:39   
What I usually do is code the DEFUSRx=address stuff inside the binary. Doing a BLOAD"filename.ext",R will execute the small piece of code doing the DEFUSR's for you. That way you don't have to know the addresses and it'll always work... Maybe you should just know the start of the full code to protect it against any unwanted overwriting (by doing a CLEAR 200,address statement).
norakomi
msx professional
Berichten: 861
Geplaatst: 14 Februari 2005, 12:20   
hmmm,
interesting indeed.
Ok, lets say I make this fadeout with an assembler......
no, let's take a more simple example.
Let's say I make a programm with an assembler to print variable "a" on screen.
I start at &hc000
Is it an idea to bsave this programm likeso:
bsave"printa.bin",&hc000,&hc(end)

and then in basic I have this program:
10 bload"printa.bin"
20 a=10
30 defusr(0)=&hc000
40 a=usr(0)

is this the way to combine basic and assembly....
or to be more precies,
is this the way to combine a basic file and a binary file?

I know this example is somewhat stupid,
but this is a start to combining larger machine coded routines with basic....
like scrolling backgrounds, sprite collisions, fadein/out etc. etc. and so on....

or?
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 14 Februari 2005, 14:36   
Yes, this is the way although number after DEFUSR should not be in " ( ) " Example: DEFUSR9=&HC000

As BASIC variables are not very easy to handle in assembler, I recommend you to use USR to pass data between ML code and BASIC. Here is simple example, that just calculates *2 in assembler:
10 DEFINT A-Z
20 BLOAD"CALCX2.BIN" ' You can also use ",R" to run custom init routine
30 DEFUSR=&HC000 ' Same as DEFUSR0=&HC000
40 PRINT USR(10) ' Pass variable trough #F7F8

Here is the assembler part:

USR:	EQU #F7F8 ' Address used to pass variables to BASIC
USR0:	EQU #F39A ' Address, where DEFUSR in BASIC stores the start address.

	DB #FE 		' Bin file header start byte
	DW BEGIN	' Begin address (#C000)
	DW END		' End address
	DW START	' Init address used only if ",R" is after BLOAD

	ORG #C000	' Address, where this program will be loaded.
BEGIN:
	LD HL,(USR)	' Get number from USR(X)
	ADD HL,HL	' * 2
	LD (USR),HL	' Result to BASIC
	RET		' Return to BASIC

START:	' Here is custom init routine that is used 
	' to replace line 30 in BASIC, if ",R" is used.

	LD HL,#C000
	LD (USR0),HL
	RET
END:


When you run this program, number 20 should be printed to screen.
BiFi
msx guru
Berichten: 3142
Geplaatst: 14 Februari 2005, 18:42   
NYYRIKKI: better is doing this first:
LD A,($F663)    ; get VALTYP
CP 2
CALL NZ,$2F8A   ; convert to integer if it isn't yet
LD HL,($F7F8)
This way you'll be sure to get an integer all the time.
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 14 Februari 2005, 18:54   
Sure, I just wanted to keep the example simple. Maybe it could be a good idea to write an article to www.tni.nl about this as well...
Grauw
msx professional
Berichten: 1006
Geplaatst: 14 Februari 2005, 20:56   
www.tni.nl? map.tni.nl you mean!

In any case, it’s a good idea, indeed.


~Grauw
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 15 Februari 2005, 08:30   
Yup, sorry about that :-)
AuroraMSX

msx master
Berichten: 1260
Geplaatst: 15 Februari 2005, 12:36   
Quote:

I have a programm to make bin files out of bas files.



Hm. Note that such BASIC 2 BIN converters often just alter the way you load your program from disk/tape into memory. The program itself will still be in BASIC and may thus overwrite an existing BASIC program.


 
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.