FAQ  •  Register  •  Login

128k memory paging, how can we do that? :S

<<

nitrofurano

Posts: 349

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Wed May 29, 2013 12:55 pm

128k memory paging, how can we do that? :S

hi everyone!
based on the information i found at http://www.worldofspectrum.org/faq/refe ... erence.htm

i tried this one:
  Code:
cls
page1=0
a=(((peek($5B5C))band $F8)bor (page1 band 7))
poke $5B5C,a:out $7FFD,a
poke $C123,80
page1=1
a=(((peek($5B5C))band $F8)bor (page1 band 7))
poke $5B5C,a:out $7FFD,a
poke $C123,81
page1=0
a=(((peek($5B5C))band $F8)bor (page1 band 7))
poke $5B5C,a:out $7FFD,a
print peek($C123)
page1=1
a=(((peek($5B5C))band $F8)bor (page1 band 7))
poke $5B5C,a:out $7FFD,a
print peek($C123)
pause 0


and i can't figure out what is going wrong there...- any clue? :S
<<

nitrofurano

Posts: 349

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Wed May 29, 2013 3:06 pm

Re: 128k memory paging, how can we do that? :S

now it seems weird why

  Code:
cls
poke 23388,16:out 32765,16:poke 50000,16
poke 23388,17:out 32765,17:poke 50000,17
poke 23388,19:out 32765,19:poke 50000,19
poke 23388,20:out 32765,20:poke 50000,20
poke 23388,22:out 32765,22:poke 50000,22
poke 23388,23:out 32765,23:poke 50000,23
poke 23388,16:out 32765,16:print peek (50000)
poke 23388,17:out 32765,17:print peek (50000)
poke 23388,19:out 32765,19:print peek (50000)
poke 23388,20:out 32765,20:print peek (50000)
poke 23388,22:out 32765,22:print peek (50000)
poke 23388,23:out 32765,23:print peek (50000)
pause 0


works, and

  Code:
sub setmemorypage(ta as ubyte)
  dim tb as ubyte
  tb=(ta band 7)bor 8
  poke 23388,tb:out 32765,tb
  end sub
cls
setmemorypage(0):poke 50000,80
setmemorypage(1):poke 50000,81
setmemorypage(3):poke 50000,83
setmemorypage(4):poke 50000,84
setmemorypage(6):poke 50000,86
setmemorypage(7):poke 50000,87
setmemorypage(0):print peek(50000)
setmemorypage(1):print peek(50000)
setmemorypage(3):print peek(50000)
setmemorypage(4):print peek(50000)
setmemorypage(6):print peek(50000)
setmemorypage(7):print peek(50000)
pause 0


isn't... :S
<<

nitrofurano

Posts: 349

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Wed May 29, 2013 3:46 pm

Re: 128k memory paging, how can we do that? :S

fixed (i think...)
  Code:
sub setmemorypage(ta as uinteger)
  tb=(ta band 7)bor 16
  poke 23388,tb:out 32765,tb
  end sub
cls
setmemorypage(0):poke 50000,80
setmemorypage(1):poke 50000,81
setmemorypage(3):poke 50000,83
setmemorypage(4):poke 50000,84
setmemorypage(6):poke 50000,86
setmemorypage(7):poke 50000,87
setmemorypage(0):print peek(50000)
setmemorypage(1):print peek(50000)
setmemorypage(3):print peek(50000)
setmemorypage(4):print peek(50000)
setmemorypage(6):print peek(50000)
setmemorypage(7):print peek(50000)
pause 0
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed May 29, 2013 7:17 pm

Re: 128k memory paging, how can we do that? :S

nitrofurano wrote:fixed (i think...)
  Code:
sub setmemorypage(ta as uinteger)
  tb=(ta band 7)bor 16
  poke 23388,tb:out 32765,tb
  end sub
cls
setmemorypage(0):poke 50000,80
setmemorypage(1):poke 50000,81
setmemorypage(3):poke 50000,83
setmemorypage(4):poke 50000,84
setmemorypage(6):poke 50000,86
setmemorypage(7):poke 50000,87
setmemorypage(0):print peek(50000)
setmemorypage(1):print peek(50000)
setmemorypage(3):print peek(50000)
setmemorypage(4):print peek(50000)
setmemorypage(6):print peek(50000)
setmemorypage(7):print peek(50000)
pause 0

For what I read in the speccy.org forum, you need to disable interruptions (DI) before bankswitching. If an interrupt enters during bankswitching, the computer might hang, or have unpredictable results. :?: :?:
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Thu May 30, 2013 11:37 pm

Re: 128k memory paging, how can we do that? :S

Why not use inline ASM? Not tested:
  Code:
sub setmemorypage(ta as ubyte)
   ASM
      di
      ld a,(ix+5)
      and 7
      or 8
      ld bc,32765
      out (c),a
      ld (23388),a
      ei
   END ASM
end sub
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri May 31, 2013 6:15 am

Re: 128k memory paging, how can we do that? :S

LCD wrote:Why not use inline ASM? Not tested:
  Code:
sub setmemorypage(ta as ubyte)
   ASM
      di
      ld a,(ix+5)
      and 7
      or 8
      ld bc,32765
      out (c),a
      ld (23388),a
      ei
   END ASM
end sub


This is a perfect case for FASTCALL :P
  Code:
sub FASTCALL setmemorypage(ta as ubyte)
   ASM
      di
      ; ld a,(ix+5) ; Not needed already in A
      and 7
      or 8
      ld bc,32765
      out (c),a
      ld (23388),a
      ei
   END ASM
end sub
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri May 31, 2013 9:00 am

Re: 128k memory paging, how can we do that? :S

boriel wrote:
LCD wrote:Why not use inline ASM? Not tested:
  Code:
sub setmemorypage(ta as ubyte)
   ASM
      di
      ld a,(ix+5)
      and 7
      or 8
      ld bc,32765
      out (c),a
      ld (23388),a
      ei
   END ASM
end sub


This is a perfect case for FASTCALL :P
  Code:
sub FASTCALL setmemorypage(ta as ubyte)
   ASM
      di
      ; ld a,(ix+5) ; Not needed already in A
      and 7
      or 8
      ld bc,32765
      out (c),a
      ld (23388),a
      ei
   END ASM
end sub

Ooops, you are right, I overseen it. Thanks! Generally I prefer 128K USR0 mode because interrupts are not harmful in this mode.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri May 31, 2013 10:40 am

Re: 128k memory paging, how can we do that? :S

LCD wrote:Ooops, you are right, I overseen it. Thanks! Generally I prefer 128K USR0 mode because interrupts are not harmful in this mode.

128K USR0 :?: What is this mode?
(I'm still learning this :P maybe I can do something for it in the compiler).
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri May 31, 2013 2:05 pm

Re: 128k memory paging, how can we do that? :S

boriel wrote:
LCD wrote:Ooops, you are right, I overseen it. Thanks! Generally I prefer 128K USR0 mode because interrupts are not harmful in this mode.

128K USR0 :?: What is this mode?
(I'm still learning this :P maybe I can do something for it in the compiler).

USR0 mode is if you enter in 128 BASIC the command USR0. This resets the machine into 48K ROM but with enabled 128K features like AY or bank switching+second screen.
You cannot use +3 DOS or RAMDISC commands, but you also don't need to POKE 23388 to switch banks, OUT 32765 is enough. DivIDE also works in this mode on Spectrum 128K machines.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri May 31, 2013 6:20 pm

Re: 128k memory paging, how can we do that? :S

LCD wrote:
boriel wrote:
LCD wrote:Ooops, you are right, I overseen it. Thanks! Generally I prefer 128K USR0 mode because interrupts are not harmful in this mode.

128K USR0 :?: What is this mode?
(I'm still learning this :P maybe I can do something for it in the compiler).

USR0 mode is if you enter in 128 BASIC the command USR0. This resets the machine into 48K ROM but with enabled 128K features like AY or bank switching+second screen.
You cannot use +3 DOS or RAMDISC commands, but you also don't need to POKE 23388 to switch banks, OUT 32765 is enough. DivIDE also works in this mode on Spectrum 128K machines.

Interesting!!!!
Could it be possible to start this mode without resetting the RAM? I mean: Executing a program in 128K mode in ZXBASIC and the program manages in some way to enter that mode an continue execution? Seems a good start.
Another question: I guess +2 ROM won't be available. Will it be?
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Sun Jun 02, 2013 9:11 am

Re: 128k memory paging, how can we do that? :S

boriel wrote:Interesting!!!!
Could it be possible to start this mode without resetting the RAM? I mean: Executing a program in 128K mode in ZXBASIC and the program manages in some way to enter that mode an continue execution? Seems a good start.

Maybe switching to the 48K ROM and jumping in the 48K Editor routine will do the job... I think, the topic was discussed on WOS before.
boriel wrote:Another q#uestion: I guess +2 ROM won't be available. Will it be?

It won't be available unless you page it in.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO