basic explanation

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

By pp

Rookie (27)

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

29-11-2005, 20:55

Does anyone know what the following basic code does to an msx2 (please in sandbox level language)?

poke -1,170
clear 20, &HE48F
poke 65535!,168
poke &HFFFF, &HAA
poke &HF3DC,5
poke &HF3DD,1
if peek(&HF677)=128 then poke &HE100,0
poke &HF676,1
poke &HF677,225
defusr=&HE000
print usr(0)

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By sjoerd

Hero (609)

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

29-11-2005, 21:22

reset? Tongue

By Manuel

Ascended (19273)

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

29-11-2005, 21:55

poke -1,170 is the same as poke &HFFFF, &HAA and is almost the same as poke 65535!,168. This is to set the secondary slot registers. See also the FAQ, misc section about the 'universal slot correct poke'.

clear 20, &HE48F: reserves 20 bytes for basic string space and says that the highest address for basic is E48F

if peek(&HF677)=128 then poke &HE100,0: checks if basic starts at &h8000, and if so, set address E100 to 0. This is necessary if you want to let a basic program start there, but you need this for that as well:
poke &HF676,1: poke &HF677,225: sets the start of basic to &HE101.

defusr=&HE000: print usr(0): starts a machine code routine on address &HE000

poke &HF3DC,5: poke &HF3DD,1: This seems to be the same as LOCATE 5,1

Other folks: please correct me if I'm wrong Smile

By pp

Rookie (27)

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

29-11-2005, 22:17

Hi Manuel, thanks for these answers.
What does the "!" mean behind the 65535 poke ?

By Manuel

Ascended (19273)

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

29-11-2005, 22:32

It's automatically added by basic, because it's such a huge number. It means: treat the number as an integer.

By the way, for the POKE statement, -1, &hFFFF and 65535 are all the same: it's the very last byte in the 64kB range of the Z80, where the Slot Select Register is.

By pp

Rookie (27)

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

30-11-2005, 08:26

Why does it have to be &HAA in that address ? Is &HAA for a specific slot number, for example 3-2 ?

By Manuel

Ascended (19273)

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

30-11-2005, 09:53

&HAA == 170, in binary: 10101010. In groups of 2: 10 10 10 10, in decimal per group: 2 2 2 2. This means that for each of the 4 pages, subslot 2 is selected.
If the mapper is in subslot 3, you will hence need 3 3 3 3 -> 11111111 -> POKE -1, 255. This is for Sony machines. For the turboR, the mapper is in subslot 0, so you will get POKE -1,0.

For this to work, you need to have slot 3 selected for the upper memory block of course: address -1 (FFFF) of the primary slot where the mapper is in should be selected via I/O port &HA8. But this is already the case in most systems, because the top 2 pages need to be RAM, so it has already selected the slot with the memory mapper there.

Again: please correct me if I'm wrong.

By AuroraMSX

Paragon (1902)

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

30-11-2005, 10:57

It's automatically added by basic, because it's such a huge number. It means: treat the number as an integer.
Actually, it means, "treat the number as a single precision floating point number". Integer ranges from -32768 upto 32767.

% -> integer
! -> single
# -> double
$ -> string

By pp

Rookie (27)

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

30-11-2005, 14:26

Manuel, your explanation is great ! I'm not sure that I fully understand the term subslot however. What I understand is that an MSX2 has 4 slots and that these 4 slots can be divded per page in another 4 slots, if a mapper exists. Are these the subslots that you mean ? Per page that you select in a slot there can be 4 subslots right ?

So with the poke -1,170 I also select all pages in subslot 3-2, if my mapper is in slot 3 ? Does this mean that I swap out the bios and the basic rom (pages 0 and 1) at that time ?

pp

By POISONIC

Paladin (1012)

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

30-11-2005, 19:19

hey Power Plant (dutch joke)

By pp

Rookie (27)

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

30-11-2005, 20:29

Manuel, which routine uses the &HFFFF address then ? It's nice to fill a RAM address (&HFFFF) with a certain value (170), and call it a slot select register, but you would normally do that because of a routine that is using or reading it.

How is slot selecting transformed in Z80 instructions ? Eventually, the address bus will be split up in 4 pages, but somehow the Z80 will have to give the instructions which slot to select for each page, right ?

How does this work ?

Regards,

pp

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