BLOAD a BASIC program?

Страница 2/4
1 | | 3 | 4

By eimaster

Champion (282)

Аватар пользователя eimaster

22-02-2022, 07:58

Some games or programs which are BASIC and are executed by BLOAD"CAS:",R
(some games have a BASIC loader but they themselves are machine code).

1. Arquimedes XXI (1986)(Dinamic Software)
2. 737 Flight Simulator (1984)(Microsoft)(GB)(Side A)
3. Cubit (1986)(Mr. Micro)
4. VACUUMANIA (1984)(PSS)(GB)

By gdx

Enlighted (6221)

Аватар пользователя gdx

22-02-2022, 08:52

I also saw some games which are BASIC and are executed by BLOAD"CAS:", R but I don't remember which ones, and I don't know if they used the same method.

POKE&HFBB1,1 prevents CTRL+STOP.
POKE&HFF89,199 prevents to see the listing.

By mcolom

Champion (316)

Аватар пользователя mcolom

22-02-2022, 09:19

The Spanish "COLT36" game by Topo Soft is also made in BASIC, along with some machine code. The last BLOAD in the BASIC loader puts the program in 0x83E8. If moved (4608 bytes) from there to 0x8000, the BASIC program can be LISTed.

By gdx

Enlighted (6221)

Аватар пользователя gdx

22-02-2022, 13:33

I looked a little COLT36. Another method is used. It initializes VARTAB as me but runs the program jumping to the address 073ACh (Main-ROM). I don't know if it is reliable and there are probably other parameters to adjust before jump to 073ACh.

By MsxKun

Paragon (1124)

Аватар пользователя MsxKun

22-02-2022, 15:19

mcolom wrote:

The Spanish "COLT36" game by Topo Soft is also made in BASIC, along with some machine code. The last BLOAD in the BASIC loader puts the program in 0x83E8. If moved (4608 bytes) from there to 0x8000, the BASIC program can be LISTed.

Same with Cobra's Arc. At some point you could get an error and program exited to Basic.

By pgimeno

Champion (328)

Аватар пользователя pgimeno

22-02-2022, 18:27

Thanks for all the answers, they allowed me to figure out a method that doesn't involve executing a RUN command.

The easiest way I found is to set up VARTAB and TXTTAB and jump to 7E14h, which initializes a lot of things and calls a few hooks before jumping to 4601h, but since that one isn't documented, following NYYRIKKI's advice I finally decided to go with a variation of gdx's method:

NEWSTT		equ	0x4601
TXTTAB		equ	0xF676
VARTAB		equ	0xF6C2
ARYTAB		equ	0xF6C4
STREND		equ	0xF6C6
DATPTR		equ	0xF6C8

		org	0x8000
		incbin	"basic.tok"	; this has the initial FF replaced with 00

start:		ld	hl,start
		ld	(VARTAB),hl
		ld	(ARYTAB),hl
		ld	(STREND),hl
		ld	hl,0x8001
		ld	(TXTTAB),hl
		dec	hl
		ld	(DATPTR),hl
		jp	NEWSTT

I generate the basic.tok file with my tokenizer, https://codeberg.org/pgimeno/vdptest/src/branch/master/asc2c... and to simplify the creation of a CAS file with the right start address and the BASIC program with the first byte replaced, I have created a Python program, bas2bincas.py which can be used directly in a makefile.

import sys

def main():
  f = open(sys.argv[1], 'rb')
  try:
    bas = f.read()
  finally:
    f.close()
  tapename = sys.argv[3]
  L = len(bas) + 0x8000
  stub = bytearray((0x21,L&0xFF,L>>8,0x22,0xC2,0xF6,0x22,0xC4,0xF6,0x22,0xC6,
    0xF6,0x21,0x01,0x80,0x22,0x76,0xF6,0x2B,0x22,0xC8,0xF6,0xC3,0x01,0x46))
  last = L + len(stub) - 1
  blkmark = b'\x1F\xA6\xDE\xBA\xCC\x13\x7D\x74'
  f = open(sys.argv[2], 'wb')
  try:
    f.write(blkmark)
    f.write(b'\xD0' * 10)
    f.write(('%-6s' % tapename).encode('utf8')[:6])

    f.write(blkmark)
    f.write(bytearray((0, 0x80, last & 0xFF, last >> 8, L & 0xFF, L >> 8)))
    f.write(b'\00')
    f.write(bas[1:])
    f.write(stub)
    # Pad CAS
    f.write(b'\00' * (-(last-1) % 8))
  finally:
    f.close()

main()

This works fine with >=32K RAM and loading the program at start with BLOAD"CAS:",R which is the intention.

By eimaster

Champion (282)

Аватар пользователя eimaster

23-02-2022, 00:22

I want to ask a question relative to this post.

How can I simply know the exact address which I can use as the end address of my BASIC program so that I can use it in the BSAVE"BASprg",&H8000,&HmyBASprgEndAddress]?

By eimaster

Champion (282)

Аватар пользователя eimaster

23-02-2022, 00:36

MsxKun wrote:

MSX-Club 63, page 66.

Can you provide me with a link to download this issue?
Is it the one in this link:
https://vdocument.in/msx-club-63-56f980593fc99.html

By pgimeno

Champion (328)

Аватар пользователя pgimeno

23-02-2022, 03:17

eimaster wrote:

I want to ask a question relative to this post.

How can I simply know the exact address which I can use as the end address of my BASIC program so that I can use it in the BSAVE"BASprg",&H8000,&HmyBASprgEndAddress]?

Use (VARTAB)-1:

BSAVE"BASprg",&H8000,PEEK(&HF6C2)+256*(PEEK(&HF6C3)-256)-1

By gdx

Enlighted (6221)

Аватар пользователя gdx

23-02-2022, 09:30

I tested except the Python program. Indeed NEWSTT can be used to execute a complet BASIC program without use RUN. It seems work fine. Good job Pgimeno !

Since you seem to know BASIC well, I take this opportunity to ask you for help. I can't solve the following problem. The return to Basic is done but the disk instructions become unusable.

https://www.msx.org/forum/msx-talk/development/back-to-the-b...

Страница 2/4
1 | | 3 | 4