How is basic stored in the memory?

Page 2/3
1 | | 3

By Vampier

Prophet (2405)

Vampier's picture

14-10-2007, 20:39

Come on.. think outside the box... what's the whole purpose of me doing this? LOL!

By Metalion

Paragon (1616)

Metalion's picture

14-10-2007, 20:51

Come on.. think outside the box... what's the whole purpose of me doing this? LOL!
I must say I've got absolutely no idea QuestionQuestionQuestion

By Vampier

Prophet (2405)

Vampier's picture

14-10-2007, 20:52

read/write directly to emulator ?

By multi

Expert (74)

multi's picture

15-10-2007, 04:08

so you can make a very nice full featured msx-basic editor on the PC that fires up the emulator and starts executing when you press the run button?

By Vampier

Prophet (2405)

Vampier's picture

15-10-2007, 06:56

That's the goal... the idea isn't new though Smile

By MOA

Champion (293)

MOA's picture

15-10-2007, 21:30

nitpick mode:

Why are you converting the peeked value to a hexadecimal string and compare those, instead of just doing:

1 DEFINT A
120 A=PEEK(&H8000+I)
130 'PRINT HEX$(A)+"|"+CHR$(VAL("&h"+A$)),S
140 IF A=&HEF THEN PRINT"=";:NEXT
(etc.)

Isn't that much faster? Question

By Vampier

Prophet (2405)

Vampier's picture

17-10-2007, 06:05

Ok I'm not doing this in basic but in TCL:

I'm really busy with work during the week but have time in the weekends to work on it. It'll work with openMSX only since it supports TCL. If someone wants to code the same for blueMSX just take a look at the TCL code.

(ps it's not working for a long shot but it's a start)

#*****************************************
#* Basic Reader
#*****************************************

# Helper Functions
proc base {base} {
	set base [expr {[peek [expr $base+1]]*256+[peek $base]}]
	return $base
}

proc getEnd {} {
	for {set i [base 0xf676]} {$i < 0xffff} {incr i} {
		if {[base $i]=="0"} {return $i}
	}
}

proc getInit {addr} {
	return [concat [format %x [base $addr]] " :: " [base [expr $addr+2]]]
}

# Main Function
proc getBasic {} {
	set startBasic [base 0xf676]
	set endBasic [getEnd]

	set listing ""

	puts $startBasic
	puts $endBasic

	set newLine 1

	if {$startBasic == $endBasic} {return "No Listing in Memory"}

	for {set addr [expr $startBasic]} {$addr < $endBasic} {incr addr} {
		
		if {$newLine==1} {
			set com [getInit $addr]
			append listing $com
			incr addr 4
			set newLine 0
			
		}

		set addrVal [peek $addr]
	
		set com ""


		if {$addrVal==0x97} {set com "DEF"}
		if {$addrVal==0x8F} {set com "REM"}



		if {$addrVal==0xf1} {set com "+"}
		if {$addrVal==0xf2} {set com "-"}
		if {$addrVal==0xf3} {set com "*"}
		if {$addrVal==0xf4} {set com "/"}
		if {$addrVal==0xf5} {set com "^"}
		if {$addrVal==0xfc} {set com "\\"}

		if {$addrVal==0x20} {set com " "}
		if {$addrVal==0x22} {set com "\""}
		if {$addrVal==0x91} {set com "print"}

		if {$addrVal==0x11} {set com "1"}
		if {$addrVal==0x12} {set com "2"}
		if {$addrVal==0x13} {set com "3"}
		if {$addrVal==0x14} {set com "4"}
		if {$addrVal==0x15} {set com "5"}
		if {$addrVal==0x16} {set com "6"}
		if {$addrVal==0x17} {set com "7"}
		if {$addrVal==0x18} {set com "8"}
		if {$addrVal==0x19} {set com "9"}
		if {$addrVal==0x1a} {set com "0"}
		if {$addrVal==0xef} {set com "="}
		if {$addrVal==0x3a} {set com ":"}

		#BASIC COMMANDS
	if {$addrVal==0xFF || $addrVal==0x3A} {
		#incr addr 1
		#set addrVal [peek $addr]

                                [I cut tokenized BASIC stuff out]

} else {
		if {$addrVal>=0x20 && $addrVal<=0x5A} {set com [format %c $addrVal]}
		if {$addrVal>=0x61 && $addrVal<=0x7A} {set com [format %c $addrVal]}
}

append listing $com

		puts [concat [format %x $addr] " - " [format %x $addrVal] " - " $com]
		if {$addrVal=="0"} {set newLine 1; append listing "\n"}
	}

puts $listing
}

By Vampier

Prophet (2405)

Vampier's picture

18-10-2007, 06:18

http://openmsx.pastebin.com/f7a4253a3

and done (for now... with 3 todos) Thanks to JoyRex :)

members.home.nl/parkel/openmsx/openmsx0446.png

By NYYRIKKI

Enlighted (6011)

NYYRIKKI's picture

18-10-2007, 07:49

That problem is weird... SCREEN 3 works, but SCREEN 0 doesn't !?

[edit]

Ah...

I don't know anything about TCL, but...

if {$addrVal==0x1a} {set com "0"}

Shouldn't this be...

if {$addrVal==0x10} {set com "0"}

?

By Vampier

Prophet (2405)

Vampier's picture

18-10-2007, 08:09

that was my bad...

- if {[byte $addr]>0x11 && [byte $addr]<0x1a} {set tok [expr [byte $addr]-0x11]; set forward 1}
+ if {[byte $addr]>=0x11 && [byte $addr]<=0x1a} {set tok [expr [byte $addr]-0x11]; set forward 1}

The code is now based on JoyRex's script.

Page 2/3
1 | | 3