BLOAD a BASIC program?

Pagina 1/4
| 2 | 3 | 4

Door pgimeno

Champion (318)

afbeelding van pgimeno

20-02-2022, 14:34

Just like it's possible to have BASIC programs in ROM, would it be possible to have BASIC programs be loaded and run via BLOAD...,R?

The idea is to be able to have BASIC programs in tape that can be run directly (without typing RUN afterwards) without having to be saved in ASCII. It's OK if there's a requirement of at least 32K RAM, and maybe an assembler stub.

Aangemeld of registreer om reacties te plaatsen

Van MsxKun

Paragon (1111)

afbeelding van MsxKun

20-02-2022, 18:44

Yep, it is posible. On an old MSX-Club or MSX-Extra Magazine they explained the way to do it.
It seems a bit like magic to me back then Big smile And I think yes, it involved some asm. Let's see if I can find it...

Van MsxKun

Paragon (1111)

afbeelding van MsxKun

20-02-2022, 19:14

MSX-Club 63, page 66.

Van pgimeno

Champion (318)

afbeelding van pgimeno

20-02-2022, 20:28

Thanks. Hmm, not exactly what I had in mind. That code is entering "R" "U" "N" + Enter into the keyboard buffer. I'd need a stub in ASCII that does that series of POKEs and then CLOADs the next block. I was hoping for something that you can run directly, so BLOAD,R seems like the only option.

Van MsxKun

Paragon (1111)

afbeelding van MsxKun

20-02-2022, 22:03

Well, i'm too meh today, I can't think much. Use a little binary that includes the ROM, but changing the ROM to BIN to make it bloadable in RAM with Bload, jump to the asm code that changes the header again to delete the BIN bytes and then jump to the Basic instruction RUN on the MSX-Basic ROM? Sorry if it doesn't make sense, surely there is a better solution, but it't been a bad day, my head refuses to do nothing.

Van Manuel

Ascended (18853)

afbeelding van Manuel

21-02-2022, 00:01

I guess one could create a bloadable basic program by saving the program itself and adding at the end a routine to run it (and perhaps poke some system variables where needed) and let the run-address point to that routine.

Van NYYRIKKI

Enlighted (5939)

afbeelding van NYYRIKKI

21-02-2022, 00:41

Everything can be done... It is a good idea to to pack the BASIC program even further as I've noticed that tokenized BASIC usually packs really well. I have experimented a bit with Pletter, but I could imagine ZX0 is even better choice. Here is a stupid example just to get you going.

Fair warning though: Users don't like it here, if you take shortcuts on standards, so I suggest you use these tricks for personal use only.

        OUTPUT "PROG.BIN"

        DB #FE
        DW BEGIN,END,BEGIN
        ORG #C000

BEGIN:
        LD HL,BASBEGIN+1
        LD DE,(#F676)
        LD BC,END-BASBEGIN-1
        LDIR
        LD (#F6C2),DE
        CALL #4253  ; (Nonstandard entry point used by Disk ROM)
 	LD HL,RUN
 	JP #4173 ; (Nonstandard entry point used by Disk ROM)

RUN:    DB ":RUN",0

BASBEGIN:
        INCBIN "PROG.BAS"
END:

Van gdx

Enlighted (5576)

afbeelding van gdx

21-02-2022, 01:50

I think it's better to use the standard entry NEWSTT (04601h) that is described in the Datapack.

Van gdx

Enlighted (5576)

afbeelding van gdx

21-02-2022, 09:55

I quickly tested NEWSTT with a little game from a old French magazine that i translated. It works fine.

Download:
https://1fichier.com/?7aai7nzhvzbhklrqasna

Here is the used method:

; Routine to load and execute a BASIC program from a binary file

NEWSTT	equ	04601h	; Run a Basic instruction

VARTAB	equ	0F6C2h
ARYTAB	equ	0F6C4h
STREND	equ	0F6C6h
TEMP	equ	0F6A7h
TEMP2	equ	0F6BCh

	org	08000h-7	; (8000h - binary file header length)

#insert	"ZENITH.DAT"	; To make this file, load the BASIC program and save it with BSAVE (You need to know the exact size)

; About BSAVE:
; Start address is 8000h
; End address is 8000h + BASIC program lengh (three 00h at end included) + the following routine length
; Execution address is 8000h + BASIC program length (three 00h at end included)

	ld	hl,$
	ld	(VARTAB),hl
	ld	(ARYTAB),hl
	ld	(STREND),hl

	ld	hl,0F56Ah
	ld	(TEMP),hl
	ld	hl,0F42Bh
	ld	(TEMP2),hl

	ld	hl,RUN		; Address of the BASIC instruction
	call	NEWSTT		; Executes the BASIC instruction
	ret
RUN:
	db	3Ah,8Ah,0	; 8Ah = token for RUN instruction (put 3Ah before and 0 after it)

I saved the assembled program with the name ZENITH.BIN. Then i make the CAS file by replacing the header.
NEWSTT routine allows us to run any BASIC instruction in a program in machine language.
VARTAB, ARYTAB, STREND, TEMP and TEMP2 variables must be initialized for the execution of the BASIC program. Maybe more info is needed about TEMP and TEMP2.

Van gdx

Enlighted (5576)

afbeelding van gdx

22-02-2022, 01:12

Van eimaster

Champion (272)

afbeelding van eimaster

22-02-2022, 06:19

There are lots of games which are BASIC and are executed by BLOAD"CAS:", R. I found about some of them back in the days when they stop running because of some error apparently because of some loading errors. Some of them can be Listed while some cannot. I wondered how can I make my own BASIC Programs BSAVEd and runs automatically by BLOAD. Another thing I wanted was how to make my BASIC Programs protected and non-viewable by LIST command. I still do know how to do both.
These days it's easy to discover if a BLODed running game is BASIC in OPEN MSX emulator by using "Listing" command in the console window. Still wondering how they did it.

Pagina 1/4
| 2 | 3 | 4